mirror of
https://github.com/Open-Cascade-SAS/OCCT.git
synced 2026-06-16 05:04:11 +08:00
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:
233
src/ModelingData/TKBRep/BRepProp/BRepProp_Curve.cxx
Normal file
233
src/ModelingData/TKBRep/BRepProp/BRepProp_Curve.cxx
Normal file
@@ -0,0 +1,233 @@
|
||||
// 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_Curve.hxx>
|
||||
|
||||
#include <gp_Dir.hxx>
|
||||
#include <gp_Vec.hxx>
|
||||
#include <Precision.hxx>
|
||||
#include <Standard_Failure.hxx>
|
||||
#include <TopAbs_Orientation.hxx>
|
||||
#include <TopoDS_Edge.hxx>
|
||||
|
||||
//==================================================================================================
|
||||
|
||||
void BRepProp_Curve::Initialize(const TopoDS_Edge& theEdge)
|
||||
{
|
||||
if (theEdge.IsNull())
|
||||
{
|
||||
myOwned.Nullify();
|
||||
myPtr = nullptr;
|
||||
return;
|
||||
}
|
||||
myOwned = new BRepAdaptor_Curve(theEdge);
|
||||
myPtr = myOwned.get();
|
||||
}
|
||||
|
||||
//==================================================================================================
|
||||
|
||||
void BRepProp_Curve::Initialize(const BRepAdaptor_Curve& theCurve)
|
||||
{
|
||||
myOwned.Nullify();
|
||||
myPtr = &theCurve;
|
||||
}
|
||||
|
||||
//==================================================================================================
|
||||
|
||||
void BRepProp_Curve::Initialize(const occ::handle<BRepAdaptor_Curve>& theCurve)
|
||||
{
|
||||
myOwned = theCurve;
|
||||
myPtr = myOwned.get();
|
||||
}
|
||||
|
||||
//==================================================================================================
|
||||
|
||||
GeomProp::TangentResult BRepProp_Curve::Tangent(const double theParam, const double theTol) const
|
||||
{
|
||||
if (!IsInitialized())
|
||||
{
|
||||
return {{}, false};
|
||||
}
|
||||
gp_Pnt aPnt;
|
||||
gp_Vec aD1, aD2, aD3;
|
||||
myPtr->D3(theParam, aPnt, aD1, aD2, aD3);
|
||||
return GeomProp::ComputeTangent(aD1, aD2, aD3, theTol);
|
||||
}
|
||||
|
||||
//==================================================================================================
|
||||
|
||||
GeomProp::CurvatureResult BRepProp_Curve::Curvature(const double theParam,
|
||||
const double theTol) const
|
||||
{
|
||||
if (!IsInitialized())
|
||||
{
|
||||
return {};
|
||||
}
|
||||
gp_Pnt aPnt;
|
||||
gp_Vec aD1, aD2;
|
||||
myPtr->D2(theParam, aPnt, aD1, aD2);
|
||||
return GeomProp::ComputeCurvature(aD1, aD2, theTol);
|
||||
}
|
||||
|
||||
//==================================================================================================
|
||||
|
||||
GeomProp::NormalResult BRepProp_Curve::Normal(const double theParam, const double theTol) const
|
||||
{
|
||||
if (!IsInitialized())
|
||||
{
|
||||
return {{}, false};
|
||||
}
|
||||
gp_Pnt aPnt;
|
||||
gp_Vec aD1, aD2;
|
||||
myPtr->D2(theParam, aPnt, aD1, aD2);
|
||||
return GeomProp::ComputeNormal(aD1, aD2, theTol);
|
||||
}
|
||||
|
||||
//==================================================================================================
|
||||
|
||||
GeomProp::CentreResult BRepProp_Curve::CentreOfCurvature(const double theParam,
|
||||
const double theTol) const
|
||||
{
|
||||
if (!IsInitialized())
|
||||
{
|
||||
return {{}, false};
|
||||
}
|
||||
gp_Pnt aPnt;
|
||||
gp_Vec aD1, aD2;
|
||||
myPtr->D2(theParam, aPnt, aD1, aD2);
|
||||
return GeomProp::ComputeCentreOfCurvature(aPnt, aD1, aD2, theTol);
|
||||
}
|
||||
|
||||
//==================================================================================================
|
||||
|
||||
GeomAbs_Shape BRepProp_Curve::Continuity(const BRepAdaptor_Curve& theCurve1,
|
||||
const BRepAdaptor_Curve& theCurve2,
|
||||
const double theU1,
|
||||
const double theU2,
|
||||
const double theTolLinear,
|
||||
const double theTolAngular)
|
||||
{
|
||||
GeomAbs_Shape aCont = GeomAbs_C0;
|
||||
bool isChecked = false;
|
||||
|
||||
// Determine maximum derivative order for each curve.
|
||||
const GeomAbs_Shape aCont1 = theCurve1.Continuity();
|
||||
const GeomAbs_Shape aCont2 = theCurve2.Continuity();
|
||||
int aN1 = 0;
|
||||
int aN2 = 0;
|
||||
if (aCont1 >= 5)
|
||||
aN1 = 3;
|
||||
else if (aCont1 == 4)
|
||||
aN1 = 2;
|
||||
else if (aCont1 == 2)
|
||||
aN1 = 1;
|
||||
if (aCont2 >= 5)
|
||||
aN2 = 3;
|
||||
else if (aCont2 == 4)
|
||||
aN2 = 2;
|
||||
else if (aCont2 == 2)
|
||||
aN2 = 1;
|
||||
|
||||
// Evaluate properties at junction points.
|
||||
BRepProp_Curve aProp1, aProp2;
|
||||
aProp1.Initialize(theCurve1);
|
||||
aProp2.Initialize(theCurve2);
|
||||
|
||||
// Check point coincidence.
|
||||
gp_Pnt aPnt1, aPnt2;
|
||||
gp_Vec aD1_1, aD1_2;
|
||||
theCurve1.D1(theU1, aPnt1, aD1_1);
|
||||
theCurve2.D1(theU2, aPnt2, aD1_2);
|
||||
if (!aPnt1.IsEqual(aPnt2, theTolLinear))
|
||||
{
|
||||
throw Standard_Failure("Curves not connected");
|
||||
}
|
||||
|
||||
const int aMinOrder = std::min(aN1, aN2);
|
||||
if (aMinOrder >= 1)
|
||||
{
|
||||
// Account for edge orientation.
|
||||
gp_Vec aVec1 = aD1_1;
|
||||
gp_Vec aVec2 = aD1_2;
|
||||
if (theCurve1.Edge().Orientation() == TopAbs_REVERSED)
|
||||
aVec1.Reverse();
|
||||
if (theCurve2.Edge().Orientation() == TopAbs_REVERSED)
|
||||
aVec2.Reverse();
|
||||
|
||||
if (aVec1.IsEqual(aVec2, theTolLinear, theTolAngular))
|
||||
{
|
||||
aCont = GeomAbs_C1;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Check G1 continuity via tangent directions.
|
||||
const GeomProp::TangentResult aTan1 = aProp1.Tangent(theU1, theTolLinear);
|
||||
const GeomProp::TangentResult aTan2 = aProp2.Tangent(theU2, theTolLinear);
|
||||
if (aTan1.IsDefined && aTan2.IsDefined)
|
||||
{
|
||||
gp_Dir aDir1 = aTan1.Direction;
|
||||
gp_Dir aDir2 = aTan2.Direction;
|
||||
if (theCurve1.Edge().Orientation() == TopAbs_REVERSED)
|
||||
aDir1.Reverse();
|
||||
if (theCurve2.Edge().Orientation() == TopAbs_REVERSED)
|
||||
aDir2.Reverse();
|
||||
if (aDir1.IsEqual(aDir2, theTolAngular))
|
||||
{
|
||||
aCont = GeomAbs_G1;
|
||||
}
|
||||
isChecked = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
isChecked = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (aMinOrder >= 2 && !isChecked)
|
||||
{
|
||||
// Compare second derivatives.
|
||||
gp_Pnt aDummy;
|
||||
gp_Vec aDummy1, aDummy2;
|
||||
gp_Vec aD2_1, aD2_2;
|
||||
theCurve1.D2(theU1, aDummy, aDummy1, aD2_1);
|
||||
theCurve2.D2(theU2, aDummy, aDummy2, aD2_2);
|
||||
if (aD2_1.IsEqual(aD2_2, theTolLinear, theTolAngular))
|
||||
{
|
||||
aCont = GeomAbs_C2;
|
||||
}
|
||||
}
|
||||
|
||||
// Same periodic edge implies CN.
|
||||
const TopoDS_Edge& anEdge1 = theCurve1.Edge();
|
||||
const TopoDS_Edge& anEdge2 = theCurve2.Edge();
|
||||
if (anEdge1.IsSame(anEdge2) && theCurve1.IsPeriodic() && aCont >= GeomAbs_G1)
|
||||
aCont = GeomAbs_CN;
|
||||
|
||||
return aCont;
|
||||
}
|
||||
|
||||
//==================================================================================================
|
||||
|
||||
GeomAbs_Shape BRepProp_Curve::Continuity(const BRepAdaptor_Curve& theCurve1,
|
||||
const BRepAdaptor_Curve& theCurve2,
|
||||
const double theU1,
|
||||
const double theU2)
|
||||
{
|
||||
return Continuity(theCurve1,
|
||||
theCurve2,
|
||||
theU1,
|
||||
theU2,
|
||||
Precision::Confusion(),
|
||||
Precision::Angular());
|
||||
}
|
||||
133
src/ModelingData/TKBRep/BRepProp/BRepProp_Curve.hxx
Normal file
133
src/ModelingData/TKBRep/BRepProp/BRepProp_Curve.hxx
Normal file
@@ -0,0 +1,133 @@
|
||||
// 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_Curve_HeaderFile
|
||||
#define _BRepProp_Curve_HeaderFile
|
||||
|
||||
#include <BRepAdaptor_Curve.hxx>
|
||||
#include <GeomAbs_Shape.hxx>
|
||||
#include <GeomProp.hxx>
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
|
||||
class TopoDS_Edge;
|
||||
|
||||
//! @brief Local differential property evaluator for BRep edges.
|
||||
//!
|
||||
//! Thin wrapper over GeomProp:: free functions.
|
||||
//! Delegates derivative computation to BRepAdaptor_Curve and passes
|
||||
//! results to GeomProp::ComputeTangent, ComputeCurvature, etc.
|
||||
//!
|
||||
//! Can be initialized from a TopoDS_Edge or a BRepAdaptor_Curve.
|
||||
//! When initialized from an existing BRepAdaptor_Curve, the adaptor is
|
||||
//! referenced without copying (non-owning); when initialized from a
|
||||
//! TopoDS_Edge, an internal adaptor is created and owned.
|
||||
//!
|
||||
//! Usage:
|
||||
//! @code
|
||||
//! BRepProp_Curve aProp;
|
||||
//! aProp.Initialize(myEdge);
|
||||
//! GeomProp::CurvatureResult aCurv = aProp.Curvature(0.5, Precision::Confusion());
|
||||
//! if (aCurv.IsDefined)
|
||||
//! {
|
||||
//! double aValue = aCurv.Value;
|
||||
//! }
|
||||
//! @endcode
|
||||
class BRepProp_Curve
|
||||
{
|
||||
public:
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
//! Default constructor - uninitialized state.
|
||||
BRepProp_Curve() = default;
|
||||
|
||||
//! Non-copyable and non-movable.
|
||||
BRepProp_Curve(const BRepProp_Curve&) = delete;
|
||||
BRepProp_Curve& operator=(const BRepProp_Curve&) = delete;
|
||||
BRepProp_Curve(BRepProp_Curve&&) = delete;
|
||||
BRepProp_Curve& operator=(BRepProp_Curve&&) = delete;
|
||||
|
||||
//! Initialize from a TopoDS_Edge.
|
||||
//! Creates an internal BRepAdaptor_Curve (owning).
|
||||
//! @param[in] theEdge the edge to evaluate
|
||||
Standard_EXPORT void Initialize(const TopoDS_Edge& theEdge);
|
||||
|
||||
//! Initialize from an existing BRepAdaptor_Curve.
|
||||
//! The adaptor is referenced without copying (non-owning);
|
||||
//! the caller must ensure the adaptor outlives this object.
|
||||
//! @param[in] theCurve the adaptor to reference
|
||||
Standard_EXPORT void Initialize(const BRepAdaptor_Curve& theCurve);
|
||||
|
||||
//! Initialize from a handle to BRepAdaptor_Curve.
|
||||
//! Shares ownership of the adaptor (no copy).
|
||||
//! @param[in] theCurve handle to the adaptor
|
||||
Standard_EXPORT void Initialize(const occ::handle<BRepAdaptor_Curve>& theCurve);
|
||||
|
||||
//! Returns true if properly initialized.
|
||||
bool IsInitialized() const { return myPtr != nullptr; }
|
||||
|
||||
//! Returns the underlying adaptor.
|
||||
const BRepAdaptor_Curve& Adaptor() const { return *myPtr; }
|
||||
|
||||
//! Compute tangent at given parameter.
|
||||
//! @param[in] theParam curve parameter
|
||||
//! @param[in] theTol linear tolerance
|
||||
//! @return tangent result with validity flag
|
||||
Standard_EXPORT GeomProp::TangentResult Tangent(double theParam, double theTol) const;
|
||||
|
||||
//! Compute curvature at given parameter.
|
||||
//! @param[in] theParam curve parameter
|
||||
//! @param[in] theTol linear tolerance
|
||||
//! @return curvature result with validity and infinity flags
|
||||
Standard_EXPORT GeomProp::CurvatureResult Curvature(double theParam, double theTol) const;
|
||||
|
||||
//! Compute normal at given parameter.
|
||||
//! @param[in] theParam curve parameter
|
||||
//! @param[in] theTol linear tolerance
|
||||
//! @return normal result with validity flag
|
||||
Standard_EXPORT GeomProp::NormalResult Normal(double theParam, double theTol) const;
|
||||
|
||||
//! Compute centre of curvature at given parameter.
|
||||
//! @param[in] theParam curve parameter
|
||||
//! @param[in] theTol linear tolerance
|
||||
//! @return centre result with validity flag
|
||||
Standard_EXPORT GeomProp::CentreResult CentreOfCurvature(double theParam, double theTol) const;
|
||||
|
||||
//! Computes the regularity at the junction between two curves.
|
||||
//! The point theU1 on theCurve1 and the point theU2 on theCurve2 must be coincident.
|
||||
//! @param[in] theCurve1 first curve adaptor
|
||||
//! @param[in] theCurve2 second curve adaptor
|
||||
//! @param[in] theU1 parameter on theCurve1
|
||||
//! @param[in] theU2 parameter on theCurve2
|
||||
//! @param[in] theTolLinear linear tolerance
|
||||
//! @param[in] theTolAngular angular tolerance
|
||||
//! @return the continuity order (C0, G1, C1, C2, CN)
|
||||
Standard_EXPORT static GeomAbs_Shape Continuity(const BRepAdaptor_Curve& theCurve1,
|
||||
const BRepAdaptor_Curve& theCurve2,
|
||||
double theU1,
|
||||
double theU2,
|
||||
double theTolLinear,
|
||||
double theTolAngular);
|
||||
|
||||
//! Same as above but using the standard tolerances from package Precision.
|
||||
Standard_EXPORT static GeomAbs_Shape Continuity(const BRepAdaptor_Curve& theCurve1,
|
||||
const BRepAdaptor_Curve& theCurve2,
|
||||
double theU1,
|
||||
double theU2);
|
||||
|
||||
private:
|
||||
occ::handle<BRepAdaptor_Curve> myOwned; //!< Owns the adaptor when created from TopoDS_Edge.
|
||||
const BRepAdaptor_Curve* myPtr = nullptr; //!< Non-owning pointer to the active adaptor.
|
||||
};
|
||||
|
||||
#endif // _BRepProp_Curve_HeaderFile
|
||||
94
src/ModelingData/TKBRep/BRepProp/BRepProp_Surface.cxx
Normal file
94
src/ModelingData/TKBRep/BRepProp/BRepProp_Surface.cxx
Normal 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);
|
||||
}
|
||||
113
src/ModelingData/TKBRep/BRepProp/BRepProp_Surface.hxx
Normal file
113
src/ModelingData/TKBRep/BRepProp/BRepProp_Surface.hxx
Normal 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
|
||||
9
src/ModelingData/TKBRep/BRepProp/FILES.cmake
Normal file
9
src/ModelingData/TKBRep/BRepProp/FILES.cmake
Normal file
@@ -0,0 +1,9 @@
|
||||
# Source files for BRepProp package
|
||||
set(OCCT_BRepProp_FILES_LOCATION "${CMAKE_CURRENT_LIST_DIR}")
|
||||
|
||||
set(OCCT_BRepProp_FILES
|
||||
BRepProp_Curve.cxx
|
||||
BRepProp_Curve.hxx
|
||||
BRepProp_Surface.cxx
|
||||
BRepProp_Surface.hxx
|
||||
)
|
||||
Reference in New Issue
Block a user