Modeling Data - Add BRepProp package for modern BRep differential properties (#1116)

Add new BRepProp package to TKBRep as a thin wrapper over GeomProp:: free
functions for computing local differential properties of BRep edges and faces
without exceptions. Replaces the legacy BRepLProp macro-based (.gxx) pattern.

New package BRepProp (TKBRep) provides:
- BRepProp_Curve: Local curve property evaluator for BRep edges.
  Delegates derivative computation to BRepAdaptor_Curve and passes results
  to GeomProp::ComputeTangent, ComputeCurvature, ComputeNormal,
  ComputeCentreOfCurvature. Three Initialize overloads: from TopoDS_Edge
  (owning), from BRepAdaptor_Curve reference (non-owning), and from
  occ::handle<BRepAdaptor_Curve> (shared ownership). Includes static
  Continuity() methods for regularity analysis at curve junctions
  (replaces BRepLProp::Continuity).
- BRepProp_Surface: Local surface property evaluator for BRep faces.
  Delegates derivative computation to BRepAdaptor_Surface and passes results
  to GeomProp::ComputeSurfaceNormal, ComputeSurfaceCurvatures,
  ComputeMeanGaussian. Same three Initialize overloads as BRepProp_Curve.

Key design decisions:
- No variant dispatch needed: BRepAdaptor_Curve/Surface handle geometry-type
  dispatch internally via virtual methods, so BRepProp is a thin wrapper
  calling adaptor D1/D2/D3 then GeomProp:: free functions.
- Ownership pattern: occ::handle for owning case + raw const pointer for
  non-owning case, consistent with GeomProp_Curve/Surface.
- Returns result structs with IsDefined flags instead of throwing exceptions.

18 GTests: 11 unit tests (line, circle, box, cylinder, sphere) and
7 cross-validation tests against BRepLProp_CLProps/BRepLProp_SLProps.
This commit is contained in:
Pasukhin Dmitry
2026-02-24 22:19:34 +00:00
committed by GitHub
parent 55db67c60d
commit 33ef11ca53
9 changed files with 1260 additions and 0 deletions

View File

@@ -0,0 +1,94 @@
// Copyright (c) 2025 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <BRepProp_Surface.hxx>
#include <TopoDS_Face.hxx>
//==================================================================================================
void BRepProp_Surface::Initialize(const TopoDS_Face& theFace)
{
if (theFace.IsNull())
{
myOwned.Nullify();
myPtr = nullptr;
return;
}
myOwned = new BRepAdaptor_Surface(theFace);
myPtr = myOwned.get();
}
//==================================================================================================
void BRepProp_Surface::Initialize(const BRepAdaptor_Surface& theSurface)
{
myOwned.Nullify();
myPtr = &theSurface;
}
//==================================================================================================
void BRepProp_Surface::Initialize(const occ::handle<BRepAdaptor_Surface>& theSurface)
{
myOwned = theSurface;
myPtr = myOwned.get();
}
//==================================================================================================
GeomProp::SurfaceNormalResult BRepProp_Surface::Normal(const double theU,
const double theV,
const double theTol) const
{
if (!IsInitialized())
{
return {{}, false};
}
gp_Pnt aPnt;
gp_Vec aD1U, aD1V;
myPtr->D1(theU, theV, aPnt, aD1U, aD1V);
return GeomProp::ComputeSurfaceNormal(aD1U, aD1V, theTol);
}
//==================================================================================================
GeomProp::SurfaceCurvatureResult BRepProp_Surface::Curvatures(const double theU,
const double theV,
const double theTol) const
{
if (!IsInitialized())
{
return {};
}
gp_Pnt aPnt;
gp_Vec aD1U, aD1V, aD2U, aD2V, aD2UV;
myPtr->D2(theU, theV, aPnt, aD1U, aD1V, aD2U, aD2V, aD2UV);
return GeomProp::ComputeSurfaceCurvatures(aD1U, aD1V, aD2U, aD2V, aD2UV, theTol);
}
//==================================================================================================
GeomProp::MeanGaussianResult BRepProp_Surface::MeanGaussian(const double theU,
const double theV,
const double theTol) const
{
if (!IsInitialized())
{
return {};
}
gp_Pnt aPnt;
gp_Vec aD1U, aD1V, aD2U, aD2V, aD2UV;
myPtr->D2(theU, theV, aPnt, aD1U, aD1V, aD2U, aD2V, aD2UV);
return GeomProp::ComputeMeanGaussian(aD1U, aD1V, aD2U, aD2V, aD2UV, theTol);
}