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,113 @@
// 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.
#ifndef _BRepProp_Surface_HeaderFile
#define _BRepProp_Surface_HeaderFile
#include <BRepAdaptor_Surface.hxx>
#include <GeomProp.hxx>
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
class TopoDS_Face;
//! @brief Local differential property evaluator for BRep faces.
//!
//! Thin wrapper over GeomProp:: free functions.
//! Delegates derivative computation to BRepAdaptor_Surface and passes
//! results to GeomProp::ComputeSurfaceNormal, ComputeSurfaceCurvatures, etc.
//!
//! Can be initialized from a TopoDS_Face or a BRepAdaptor_Surface.
//! When initialized from an existing BRepAdaptor_Surface, the adaptor is
//! referenced without copying (non-owning); when initialized from a
//! TopoDS_Face, an internal adaptor is created and owned.
//!
//! Usage:
//! @code
//! BRepProp_Surface aProp;
//! aProp.Initialize(myFace);
//! GeomProp::SurfaceNormalResult aNorm = aProp.Normal(0.5, 0.5, Precision::Confusion());
//! if (aNorm.IsDefined)
//! {
//! gp_Dir aDir = aNorm.Direction;
//! }
//! @endcode
class BRepProp_Surface
{
public:
DEFINE_STANDARD_ALLOC
//! Default constructor - uninitialized state.
BRepProp_Surface() = default;
//! Non-copyable and non-movable.
BRepProp_Surface(const BRepProp_Surface&) = delete;
BRepProp_Surface& operator=(const BRepProp_Surface&) = delete;
BRepProp_Surface(BRepProp_Surface&&) = delete;
BRepProp_Surface& operator=(BRepProp_Surface&&) = delete;
//! Initialize from a TopoDS_Face.
//! Creates an internal BRepAdaptor_Surface (owning).
//! @param[in] theFace the face to evaluate
Standard_EXPORT void Initialize(const TopoDS_Face& theFace);
//! Initialize from an existing BRepAdaptor_Surface.
//! The adaptor is referenced without copying (non-owning);
//! the caller must ensure the adaptor outlives this object.
//! @param[in] theSurface the adaptor to reference
Standard_EXPORT void Initialize(const BRepAdaptor_Surface& theSurface);
//! Initialize from a handle to BRepAdaptor_Surface.
//! Shares ownership of the adaptor (no copy).
//! @param[in] theSurface handle to the adaptor
Standard_EXPORT void Initialize(const occ::handle<BRepAdaptor_Surface>& theSurface);
//! Returns true if properly initialized.
bool IsInitialized() const { return myPtr != nullptr; }
//! Returns the underlying adaptor.
const BRepAdaptor_Surface& Adaptor() const { return *myPtr; }
//! Compute surface normal at given (U, V) parameter.
//! @param[in] theU U parameter
//! @param[in] theV V parameter
//! @param[in] theTol linear tolerance
//! @return normal result with validity flag
Standard_EXPORT GeomProp::SurfaceNormalResult Normal(double theU,
double theV,
double theTol) const;
//! Compute principal curvatures at given (U, V) parameter.
//! @param[in] theU U parameter
//! @param[in] theV V parameter
//! @param[in] theTol linear tolerance
//! @return curvature result with min/max values, directions, and validity flag
Standard_EXPORT GeomProp::SurfaceCurvatureResult Curvatures(double theU,
double theV,
double theTol) const;
//! Compute mean and Gaussian curvatures at given (U, V) parameter.
//! @param[in] theU U parameter
//! @param[in] theV V parameter
//! @param[in] theTol linear tolerance
//! @return mean/Gaussian curvature result with validity flag
Standard_EXPORT GeomProp::MeanGaussianResult MeanGaussian(double theU,
double theV,
double theTol) const;
private:
occ::handle<BRepAdaptor_Surface> myOwned; //!< Owns the adaptor when created from TopoDS_Face.
const BRepAdaptor_Surface* myPtr = nullptr; //!< Non-owning pointer to the active adaptor.
};
#endif // _BRepProp_Surface_HeaderFile