Modeling Data - Unify LProp packages into template classes in TKGeomBase (#1156)

Consolidate duplicated local property computation classes
(GeomLProp_CLProps, Geom2dLProp_CLProps2d, LProp3d_CLProps,
BRepLProp_CLProps, HLRBRep_CLProps and their SLProps counterparts)
into unified C++ template classes GeomLProp_CLPropsBase and
GeomLProp_SLProps with policy-based access (DirectAccess/ToolAccess).

Move LProp, GeomLProp, and GProp packages from TKG2d/TKG3d to
TKGeomBase. Remove Geom2dLProp and LProp3d packages entirely.
Merge Geom2dLProp_CurAndInf2d into GeomLProp_CurAndInf2d.
Preserve backward-compatible type aliases (using declarations)
for all previously existing class names.

Shared algorithm logic extracted into LProp_CurveUtils and
LProp_SurfaceUtils namespaces. 2D curve analysis helpers
(FuncCurExt2d, FuncCurNul2d, NumericCurInf2d) converted to
header-only .pxx implementations under GeomLProp.

Update all dependent code (LocalAnalysis, BRepFill, ChFi3d,
Geom2dHatch, GeomPlate, ProjLib, HLRBRep, DrawTrSurf, etc.)
to use new template instantiations. Migrate GTests from
TKG2d to TKGeomBase with updated class names.
This commit is contained in:
Pasukhin Dmitry
2026-03-10 16:49:55 +00:00
committed by GitHub
parent fe9a0de8d0
commit 6f6660d0d6
94 changed files with 1177 additions and 4161 deletions

View File

@@ -1,173 +0,0 @@
// Created on: 1994-02-24
// Created by: Laurent BOURESCHE
// Copyright (c) 1994-1999 Matra Datavision
// Copyright (c) 1999-2014 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 <BRepLProp_CLProps.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <LProp_NotDefined.hxx>
#include <Standard_OutOfRange.hxx>
#include <LProp_CurveUtils.pxx>
using Access = LProp_CurveUtils::DirectAccess;
//=================================================================================================
BRepLProp_CLProps::BRepLProp_CLProps(const BRepAdaptor_Curve& C,
const double U,
const int N,
const double Resolution)
: myCurve(C),
myDerOrder(N),
myCN(4),
myLinTol(Resolution),
myTangentStatus(LProp_Undecided)
{
Standard_OutOfRange_Raise_if(N < 0 || N > 3, "BRepLProp_CLProps::BRepLProp_CLProps()");
SetParameter(U);
}
//=================================================================================================
BRepLProp_CLProps::BRepLProp_CLProps(const BRepAdaptor_Curve& C,
const int N,
const double Resolution)
: myCurve(C),
myU(RealLast()),
myDerOrder(N),
myCN(4),
myLinTol(Resolution),
myTangentStatus(LProp_Undecided)
{
Standard_OutOfRange_Raise_if(N < 0 || N > 3, "BRepLProp_CLProps::BRepLProp_CLProps()");
}
//=================================================================================================
BRepLProp_CLProps::BRepLProp_CLProps(const int N, const double Resolution)
: myU(RealLast()),
myDerOrder(N),
myCN(0),
myLinTol(Resolution),
myTangentStatus(LProp_Undecided)
{
Standard_OutOfRange_Raise_if(N < 0 || N > 3, "BRepLProp_CLProps() - invalid input");
}
//=================================================================================================
void BRepLProp_CLProps::SetParameter(const double U)
{
LProp_CurveUtils::SetParameter<Access>(myCurve,
U,
myU,
myDerOrder,
myPnt,
myDerivArr,
myTangentStatus);
}
//=================================================================================================
void BRepLProp_CLProps::SetCurve(const BRepAdaptor_Curve& C)
{
myCurve = C;
myCN = 4;
}
//=================================================================================================
const gp_Pnt& BRepLProp_CLProps::Value() const
{
return myPnt;
}
//=================================================================================================
const gp_Vec& BRepLProp_CLProps::D1()
{
return LProp_CurveUtils::EnsureDeriv<Access>(myCurve, myU, myDerOrder, 1, myPnt, myDerivArr);
}
//=================================================================================================
const gp_Vec& BRepLProp_CLProps::D2()
{
return LProp_CurveUtils::EnsureDeriv<Access>(myCurve, myU, myDerOrder, 2, myPnt, myDerivArr);
}
//=================================================================================================
const gp_Vec& BRepLProp_CLProps::D3()
{
return LProp_CurveUtils::EnsureDeriv<Access>(myCurve, myU, myDerOrder, 3, myPnt, myDerivArr);
}
//=================================================================================================
bool BRepLProp_CLProps::IsTangentDefined()
{
return LProp_CurveUtils::IsTangentDefined<gp_Vec>(*this,
myCN,
myLinTol,
mySignificantFirstDerivativeOrder,
myTangentStatus);
}
//=================================================================================================
void BRepLProp_CLProps::Tangent(gp_Dir& D)
{
LProp_CurveUtils::Tangent<Access>(*this,
myCurve,
myU,
myDerivArr,
myPnt,
mySignificantFirstDerivativeOrder,
D);
}
//=================================================================================================
double BRepLProp_CLProps::Curvature()
{
return LProp_CurveUtils::Curvature(*this,
myDerivArr[0],
myDerivArr[1],
myLinTol,
mySignificantFirstDerivativeOrder,
myCurvature);
}
//=================================================================================================
void BRepLProp_CLProps::Normal(gp_Dir& N)
{
LProp_CurveUtils::Normal(*this, myDerivArr[0], myDerivArr[1], myLinTol, N);
}
//=================================================================================================
void BRepLProp_CLProps::CentreOfCurvature(gp_Pnt& P)
{
LProp_CurveUtils::CentreOfCurvature(*this,
myPnt,
myDerivArr[0],
myDerivArr[1],
myLinTol,
myCurvature,
P);
}

View File

@@ -17,109 +17,10 @@
#ifndef _BRepLProp_CLProps_HeaderFile
#define _BRepLProp_CLProps_HeaderFile
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <gp_Pnt.hxx>
#include <gp_Vec.hxx>
#include <gp_Dir.hxx>
#include <LProp_Status.hxx>
class LProp_BadContinuity;
class Standard_DomainError;
class Standard_OutOfRange;
class LProp_NotDefined;
class BRepAdaptor_Curve;
class gp_Vec;
class gp_Pnt;
class gp_Dir;
#include <GeomLProp_CLProps.hxx>
class BRepLProp_CLProps
{
public:
DEFINE_STANDARD_ALLOC
//! Initializes the local properties of the curve <C>
//! The current point and the derivatives are
//! computed at the same time, which allows an
//! optimization of the computation time.
//! <N> indicates the maximum number of derivations to
//! be done (0, 1, 2 or 3). For example, to compute
//! only the tangent, N should be equal to 1.
//! <Resolution> is the linear tolerance (it is used to test
//! if a vector is null).
Standard_EXPORT BRepLProp_CLProps(const BRepAdaptor_Curve& C,
const int N,
const double Resolution);
//! Same as previous constructor but here the parameter is
//! set to the value <U>.
//! All the computations done will be related to <C> and <U>.
Standard_EXPORT BRepLProp_CLProps(const BRepAdaptor_Curve& C,
const double U,
const int N,
const double Resolution);
//! Same as previous constructor but here the parameter is
//! set to the value <U> and the curve is set
//! with SetCurve.
//! the curve can have a empty constructor
//! All the computations done will be related to <C> and <U>
//! when the functions "set" will be done.
Standard_EXPORT BRepLProp_CLProps(const int N, const double Resolution);
//! Initializes the local properties of the curve
//! for the parameter value <U>.
Standard_EXPORT void SetParameter(const double U);
//! Initializes the local properties of the curve
//! for the new curve.
Standard_EXPORT void SetCurve(const BRepAdaptor_Curve& C);
//! Returns the Point.
Standard_EXPORT const gp_Pnt& Value() const;
//! Returns the first derivative.
//! The derivative is computed if it has not been yet.
Standard_EXPORT const gp_Vec& D1();
//! Returns the second derivative.
//! The derivative is computed if it has not been yet.
Standard_EXPORT const gp_Vec& D2();
//! Returns the third derivative.
//! The derivative is computed if it has not been yet.
Standard_EXPORT const gp_Vec& D3();
//! Returns True if the tangent is defined.
//! For example, the tangent is not defined if the
//! three first derivatives are all null.
Standard_EXPORT bool IsTangentDefined();
//! output the tangent direction <D>
Standard_EXPORT void Tangent(gp_Dir& D);
//! Returns the curvature.
Standard_EXPORT double Curvature();
//! Returns the normal direction <N>.
Standard_EXPORT void Normal(gp_Dir& N);
//! Returns the centre of curvature <P>.
Standard_EXPORT void CentreOfCurvature(gp_Pnt& P);
private:
BRepAdaptor_Curve myCurve;
double myU;
int myDerOrder;
int myCN;
double myLinTol;
gp_Pnt myPnt;
gp_Vec myDerivArr[3];
gp_Dir myTangent;
double myCurvature = 0.0;
LProp_Status myTangentStatus;
int mySignificantFirstDerivativeOrder = 0;
};
//! Alias for curve local properties using BRepAdaptor_Curve.
using BRepLProp_CLProps = GeomLProp_CLPropsBase<gp_Pnt, gp_Vec, gp_Dir, BRepAdaptor_Curve>;
#endif // _BRepLProp_CLProps_HeaderFile

View File

@@ -1,281 +0,0 @@
// Created on: 1994-02-24
// Created by: Laurent BOURESCHE
// Copyright (c) 1994-1999 Matra Datavision
// Copyright (c) 1999-2014 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 <BRepLProp_SLProps.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <LProp_NotDefined.hxx>
#include <Standard_OutOfRange.hxx>
#include <LProp_SurfaceUtils.pxx>
using Access = LProp_SurfaceUtils::DirectAccess;
//=================================================================================================
BRepLProp_SLProps::BRepLProp_SLProps(const BRepAdaptor_Surface& S,
const double U,
const double V,
const int N,
const double Resolution)
: mySurf(S),
myDerOrder(N),
myCN(4),
myLinTol(Resolution)
{
Standard_OutOfRange_Raise_if(N < 0 || N > 2, "BRepLProp_SLProps::BRepLProp_SLProps()");
SetParameters(U, V);
}
//=================================================================================================
BRepLProp_SLProps::BRepLProp_SLProps(const BRepAdaptor_Surface& S,
const int N,
const double Resolution)
: mySurf(S),
myU(RealLast()),
myV(RealLast()),
myDerOrder(N),
myCN(4),
myLinTol(Resolution),
myUTangentStatus(LProp_Undecided),
myVTangentStatus(LProp_Undecided),
myNormalStatus(LProp_Undecided),
myCurvatureStatus(LProp_Undecided)
{
Standard_OutOfRange_Raise_if(N < 0 || N > 2, "BRepLProp_SLProps::BRepLProp_SLProps()");
}
//=================================================================================================
BRepLProp_SLProps::BRepLProp_SLProps(const int N, const double Resolution)
: myU(RealLast()),
myV(RealLast()),
myDerOrder(N),
myCN(0),
myLinTol(Resolution),
myUTangentStatus(LProp_Undecided),
myVTangentStatus(LProp_Undecided),
myNormalStatus(LProp_Undecided),
myCurvatureStatus(LProp_Undecided)
{
Standard_OutOfRange_Raise_if(N < 0 || N > 2, "BRepLProp_SLProps::BRepLProp_SLProps() bad level");
}
//=================================================================================================
void BRepLProp_SLProps::SetSurface(const BRepAdaptor_Surface& S)
{
mySurf = S;
myCN = 4;
}
//=================================================================================================
void BRepLProp_SLProps::SetParameters(const double U, const double V)
{
LProp_SurfaceUtils::SetParameters<Access>(mySurf,
U,
V,
myU,
myV,
myDerOrder,
myPnt,
myD1u,
myD1v,
myD2u,
myD2v,
myDuv,
myUTangentStatus,
myVTangentStatus,
myNormalStatus,
myCurvatureStatus);
}
//=================================================================================================
const gp_Pnt& BRepLProp_SLProps::Value() const
{
return myPnt;
}
//=================================================================================================
const gp_Vec& BRepLProp_SLProps::D1U()
{
return LProp_SurfaceUtils::EnsureSurfDeriv<
Access>(mySurf, myU, myV, myDerOrder, 1, myPnt, myD1u, myD1v, myD2u, myD2v, myDuv, myD1u);
}
//=================================================================================================
const gp_Vec& BRepLProp_SLProps::D1V()
{
return LProp_SurfaceUtils::EnsureSurfDeriv<
Access>(mySurf, myU, myV, myDerOrder, 1, myPnt, myD1u, myD1v, myD2u, myD2v, myDuv, myD1v);
}
//=================================================================================================
const gp_Vec& BRepLProp_SLProps::D2U()
{
return LProp_SurfaceUtils::EnsureSurfDeriv<
Access>(mySurf, myU, myV, myDerOrder, 2, myPnt, myD1u, myD1v, myD2u, myD2v, myDuv, myD2u);
}
//=================================================================================================
const gp_Vec& BRepLProp_SLProps::D2V()
{
return LProp_SurfaceUtils::EnsureSurfDeriv<
Access>(mySurf, myU, myV, myDerOrder, 2, myPnt, myD1u, myD1v, myD2u, myD2v, myDuv, myD2v);
}
//=================================================================================================
const gp_Vec& BRepLProp_SLProps::DUV()
{
return LProp_SurfaceUtils::EnsureSurfDeriv<
Access>(mySurf, myU, myV, myDerOrder, 2, myPnt, myD1u, myD1v, myD2u, myD2v, myDuv, myDuv);
}
//=================================================================================================
bool BRepLProp_SLProps::IsTangentUDefined()
{
return LProp_SurfaceUtils::IsTangentUDefined(*this,
myCN,
myLinTol,
mySignificantFirstDerivativeOrderU,
myUTangentStatus);
}
//=================================================================================================
void BRepLProp_SLProps::TangentU(gp_Dir& D)
{
LProp_SurfaceUtils::TangentU<Access>(*this,
mySurf,
myU,
myV,
myD1u,
myD2u,
mySignificantFirstDerivativeOrderU,
D);
}
//=================================================================================================
bool BRepLProp_SLProps::IsTangentVDefined()
{
return LProp_SurfaceUtils::IsTangentVDefined(*this,
myCN,
myLinTol,
mySignificantFirstDerivativeOrderV,
myVTangentStatus);
}
//=================================================================================================
void BRepLProp_SLProps::TangentV(gp_Dir& D)
{
LProp_SurfaceUtils::TangentV<Access>(*this,
mySurf,
myU,
myV,
myD1v,
myD2v,
mySignificantFirstDerivativeOrderV,
D);
}
//=================================================================================================
bool BRepLProp_SLProps::IsNormalDefined()
{
return LProp_SurfaceUtils::IsNormalDefined(myD1u, myD1v, myLinTol, myNormal, myNormalStatus);
}
//=================================================================================================
const gp_Dir& BRepLProp_SLProps::Normal()
{
return LProp_SurfaceUtils::Normal(*this, myNormal);
}
//=================================================================================================
bool BRepLProp_SLProps::IsCurvatureDefined()
{
return LProp_SurfaceUtils::IsCurvatureDefined(*this,
myCN,
myDerOrder,
myD1u,
myD1v,
myD2u,
myD2v,
myDuv,
myNormal,
myMinCurv,
myMaxCurv,
myDirMinCurv,
myDirMaxCurv,
myMeanCurv,
myGausCurv,
myCurvatureStatus);
}
//=================================================================================================
bool BRepLProp_SLProps::IsUmbilic()
{
return LProp_SurfaceUtils::IsUmbilic(*this, myMaxCurv, myMinCurv);
}
//=================================================================================================
double BRepLProp_SLProps::MaxCurvature()
{
return LProp_SurfaceUtils::RequireCurvature(*this, myMaxCurv);
}
//=================================================================================================
double BRepLProp_SLProps::MinCurvature()
{
return LProp_SurfaceUtils::RequireCurvature(*this, myMinCurv);
}
//=================================================================================================
void BRepLProp_SLProps::CurvatureDirections(gp_Dir& Max, gp_Dir& Min)
{
LProp_SurfaceUtils::CurvatureDirections(*this, myDirMaxCurv, myDirMinCurv, Max, Min);
}
//=================================================================================================
double BRepLProp_SLProps::MeanCurvature()
{
return LProp_SurfaceUtils::RequireCurvature(*this, myMeanCurv);
}
//=================================================================================================
double BRepLProp_SLProps::GaussianCurvature()
{
return LProp_SurfaceUtils::RequireCurvature(*this, myGausCurv);
}

View File

@@ -17,159 +17,10 @@
#ifndef _BRepLProp_SLProps_HeaderFile
#define _BRepLProp_SLProps_HeaderFile
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <Standard_Integer.hxx>
#include <gp_Pnt.hxx>
#include <gp_Vec.hxx>
#include <gp_Dir.hxx>
#include <LProp_Status.hxx>
class LProp_BadContinuity;
class Standard_DomainError;
class Standard_OutOfRange;
class LProp_NotDefined;
class BRepAdaptor_Surface;
class BRepLProp_SurfaceTool;
class gp_Pnt;
class gp_Vec;
class gp_Dir;
#include <GeomLProp_SLProps.hxx>
class BRepLProp_SLProps
{
public:
DEFINE_STANDARD_ALLOC
//! Initializes the local properties of the surface <S>
//! for the parameter values (<U>, <V>).
//! The current point and the derivatives are
//! computed at the same time, which allows an
//! optimization of the computation time.
//! <N> indicates the maximum number of derivations to
//! be done (0, 1, or 2). For example, to compute
//! only the tangent, N should be equal to 1.
//! <Resolution> is the linear tolerance (it is used to test
//! if a vector is null).
Standard_EXPORT BRepLProp_SLProps(const BRepAdaptor_Surface& S,
const double U,
const double V,
const int N,
const double Resolution);
//! idem as previous constructor but without setting the value
//! of parameters <U> and <V>.
Standard_EXPORT BRepLProp_SLProps(const BRepAdaptor_Surface& S,
const int N,
const double Resolution);
//! idem as previous constructor but without setting the value
//! of parameters <U> and <V> and the surface.
//! the surface can have an empty constructor.
Standard_EXPORT BRepLProp_SLProps(const int N, const double Resolution);
//! Initializes the local properties of the surface S
//! for the new surface.
Standard_EXPORT void SetSurface(const BRepAdaptor_Surface& S);
//! Initializes the local properties of the surface S
//! for the new parameter values (<U>, <V>).
Standard_EXPORT void SetParameters(const double U, const double V);
//! Returns the point.
Standard_EXPORT const gp_Pnt& Value() const;
//! Returns the first U derivative.
//! The derivative is computed if it has not been yet.
Standard_EXPORT const gp_Vec& D1U();
//! Returns the first V derivative.
//! The derivative is computed if it has not been yet.
Standard_EXPORT const gp_Vec& D1V();
//! Returns the second U derivatives
//! The derivative is computed if it has not been yet.
Standard_EXPORT const gp_Vec& D2U();
//! Returns the second V derivative.
//! The derivative is computed if it has not been yet.
Standard_EXPORT const gp_Vec& D2V();
//! Returns the second UV cross-derivative.
//! The derivative is computed if it has not been yet.
Standard_EXPORT const gp_Vec& DUV();
//! returns True if the U tangent is defined.
//! For example, the tangent is not defined if the
//! two first U derivatives are null.
Standard_EXPORT bool IsTangentUDefined();
//! Returns the tangent direction <D> on the iso-V.
Standard_EXPORT void TangentU(gp_Dir& D);
//! returns if the V tangent is defined.
//! For example, the tangent is not defined if the
//! two first V derivatives are null.
Standard_EXPORT bool IsTangentVDefined();
//! Returns the tangent direction <D> on the iso-V.
Standard_EXPORT void TangentV(gp_Dir& D);
//! Tells if the normal is defined.
Standard_EXPORT bool IsNormalDefined();
//! Returns the normal direction.
Standard_EXPORT const gp_Dir& Normal();
//! returns True if the curvature is defined.
Standard_EXPORT bool IsCurvatureDefined();
//! returns True if the point is umbilic (i.e. if the
//! curvature is constant).
Standard_EXPORT bool IsUmbilic();
//! Returns the maximum curvature
Standard_EXPORT double MaxCurvature();
//! Returns the minimum curvature
Standard_EXPORT double MinCurvature();
//! Returns the direction of the maximum and minimum curvature
//! <MaxD> and <MinD>
Standard_EXPORT void CurvatureDirections(gp_Dir& MaxD, gp_Dir& MinD);
//! Returns the mean curvature.
Standard_EXPORT double MeanCurvature();
//! Returns the Gaussian curvature
Standard_EXPORT double GaussianCurvature();
private:
BRepAdaptor_Surface mySurf;
double myU;
double myV;
int myDerOrder;
int myCN;
double myLinTol;
gp_Pnt myPnt;
gp_Vec myD1u;
gp_Vec myD1v;
gp_Vec myD2u;
gp_Vec myD2v;
gp_Vec myDuv;
gp_Dir myNormal;
double myMinCurv = 0.0;
double myMaxCurv = 0.0;
gp_Dir myDirMinCurv;
gp_Dir myDirMaxCurv;
double myMeanCurv = 0.0;
double myGausCurv = 0.0;
int mySignificantFirstDerivativeOrderU = 0;
int mySignificantFirstDerivativeOrderV = 0;
LProp_Status myUTangentStatus;
LProp_Status myVTangentStatus;
LProp_Status myNormalStatus;
LProp_Status myCurvatureStatus;
};
//! Alias for surface local properties using BRepAdaptor_Surface.
using BRepLProp_SLProps = GeomLProp_SLPropsBase<BRepAdaptor_Surface>;
#endif // _BRepLProp_SLProps_HeaderFile

View File

@@ -5,9 +5,7 @@ set(OCCT_BRepLProp_FILES
BRepLProp.cxx
BRepLProp.hxx
BRepLProp_CLProps.hxx
BRepLProp_CLProps.cxx
BRepLProp_SLProps.hxx
BRepLProp_SLProps.cxx
BRepLProp_SurfaceTool.cxx
BRepLProp_SurfaceTool.hxx
)