Skip to content

Commit 553466c

Browse files
authored
Modeling - Simplify GeomGridEval classes (#1031)
- Removed point evaluation methods from surface evaluators (Torus, Sphere, Cylinder, Cone, Plane, BSpline, Bezier, SurfaceOfRevolution, SurfaceOfExtrusion, OffsetSurface, OtherSurface) - Simplified BSplineSurface and BSplineCurve evaluation implementations with cleaner helper templates - Updated utility functions to use surface adaptors directly instead of grid evaluators - Removed corresponding test cases for point-based evaluation methods - Cleaned up unused includes (`gp_Pnt2d.hxx`) and helper structures (`UVPoint`, `UVPointWithSpan`
1 parent 1f251bb commit 553466c

34 files changed

Lines changed: 680 additions & 5174 deletions

src/ModelingAlgorithms/TKGeomAlgo/IntCurveSurface/IntCurveSurface_PolyhedronUtils.pxx

Lines changed: 16 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,16 @@
1414
#ifndef IntCurveSurface_PolyhedronUtils_pxx_HeaderFile
1515
#define IntCurveSurface_PolyhedronUtils_pxx_HeaderFile
1616

17+
#include <Adaptor3d_Surface.hxx>
1718
#include <Bnd_Box.hxx>
18-
#include <NCollection_Array1.hxx>
19-
#include <NCollection_HArray1.hxx>
2019
#include <GeomGridEval_Surface.hxx>
2120
#include <gp.hxx>
2221
#include <gp_Pnt.hxx>
2322
#include <gp_Vec.hxx>
2423
#include <gp_XYZ.hxx>
24+
#include <NCollection_Array1.hxx>
2525
#include <NCollection_Array2.hxx>
26+
#include <NCollection_HArray1.hxx>
2627
#include <Standard_Real.hxx>
2728

2829
//! Utility functions for polyhedron discretization of surfaces.
@@ -622,45 +623,21 @@ inline double ComputeDeflectionWithCenter(const gp_Pnt& theP1,
622623
return std::abs(P1P.Dot(NormalVector));
623624
}
624625

625-
//! Compute the maximum deflection over all triangles using batch evaluation.
626-
//! Uses GeomGridEval_Surface::EvaluatePoints() to batch-evaluate all triangle centroids.
626+
//! Compute the maximum deflection over all triangles.
627+
//! Evaluates triangle centroids individually using the surface adaptor.
627628
//! @tparam PolyhedronType Type of polyhedron class
628-
//! @param[in] theEval Pre-initialized grid evaluator
629+
//! @param[in] theSurface Surface adaptor for point evaluation
629630
//! @param[in] thePolyhedron The polyhedron object (provides Triangle/Point access)
630631
//! @param[in] theNbTriangles Number of triangles
631632
//! @return Maximum deflection value
632633
template <typename PolyhedronType>
633-
double ComputeMaxDeflection(GeomGridEval_Surface& theEval,
634-
const PolyhedronType& thePolyhedron,
635-
const int theNbTriangles)
634+
double ComputeMaxDeflection(const Adaptor3d_Surface& theSurface,
635+
const PolyhedronType& thePolyhedron,
636+
const int theNbTriangles)
636637
{
637638
if (theNbTriangles <= 0)
638639
return 0.0;
639640

640-
// Collect all triangle centroid UV pairs
641-
NCollection_Array1<gp_Pnt2d> aCentroidUVs(1, theNbTriangles);
642-
643-
for (int i = 1; i <= theNbTriangles; ++i)
644-
{
645-
int i1, i2, i3;
646-
thePolyhedron.Triangle(i, i1, i2, i3);
647-
648-
double u1, v1, u2, v2, u3, v3;
649-
thePolyhedron.Point(i1, u1, v1);
650-
thePolyhedron.Point(i2, u2, v2);
651-
thePolyhedron.Point(i3, u3, v3);
652-
653-
const double uCenter = (u1 + u2 + u3) / 3.0;
654-
const double vCenter = (v1 + v2 + v3) / 3.0;
655-
aCentroidUVs.SetValue(i, gp_Pnt2d(uCenter, vCenter));
656-
}
657-
658-
// Batch evaluate all centroids
659-
NCollection_Array1<gp_Pnt> aCenterPoints = theEval.EvaluatePoints(aCentroidUVs);
660-
if (aCenterPoints.IsEmpty())
661-
return 0.0;
662-
663-
// Compute max deflection using pre-evaluated center points
664641
double tol = 0.0;
665642
for (int i = 1; i <= theNbTriangles; ++i)
666643
{
@@ -672,7 +649,13 @@ double ComputeMaxDeflection(GeomGridEval_Surface& theEval,
672649
const gp_Pnt P2 = thePolyhedron.Point(i2, u2, v2);
673650
const gp_Pnt P3 = thePolyhedron.Point(i3, u3, v3);
674651

675-
const double tol1 = ComputeDeflectionWithCenter(P1, P2, P3, aCenterPoints.Value(i));
652+
const double uCenter = (u1 + u2 + u3) / 3.0;
653+
const double vCenter = (v1 + v2 + v3) / 3.0;
654+
655+
gp_Pnt aCenter;
656+
theSurface.D0(uCenter, vCenter, aCenter);
657+
658+
const double tol1 = ComputeDeflectionWithCenter(P1, P2, P3, aCenter);
676659
if (tol1 > tol)
677660
tol = tol1;
678661
}

src/ModelingAlgorithms/TKGeomAlgo/IntCurveSurface/IntCurveSurface_ThePolyhedronOfHInter.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ void IntCurveSurface_ThePolyhedronOfHInter::Init(const occ::handle<Adaptor3d_Sur
103103
static_cast<bool*>(C_MyIsOnBounds),
104104
TheBnd);
105105

106-
double tol = PolyUtils::ComputeMaxDeflection(anEval, *this, NbTriangles());
106+
double tol = PolyUtils::ComputeMaxDeflection(*Surface, *this, NbTriangles());
107107
DeflectionOverEstimation(tol * 1.2);
108108
FillBounding();
109109

@@ -132,7 +132,7 @@ void IntCurveSurface_ThePolyhedronOfHInter::Init(const occ::handle<Adaptor3d_Sur
132132
static_cast<bool*>(C_MyIsOnBounds),
133133
TheBnd);
134134

135-
double tol = PolyUtils::ComputeMaxDeflection(anEval, *this, NbTriangles());
135+
double tol = PolyUtils::ComputeMaxDeflection(*Surface, *this, NbTriangles());
136136
DeflectionOverEstimation(tol * 1.2);
137137
FillBounding();
138138

src/ModelingAlgorithms/TKGeomAlgo/IntPatch/IntPatch_Polyhedron.cxx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@ IntPatch_Polyhedron::IntPatch_Polyhedron(const occ::handle<Adaptor3d_Surface>& S
129129
}
130130
}
131131

132-
// Compute max deflection using batch evaluation
133-
double tol = PolyUtils::ComputeMaxDeflection(anEval, *this, NbTriangles());
132+
// Compute max deflection using surface adaptor
133+
double tol = PolyUtils::ComputeMaxDeflection(*Surface, *this, NbTriangles());
134134
tol *= DEFLECTION_COEFF;
135135

136136
DeflectionOverEstimation(tol);
@@ -200,8 +200,8 @@ IntPatch_Polyhedron::IntPatch_Polyhedron(const occ::handle<Adaptor3d_Surface>& S
200200
}
201201
}
202202

203-
// Compute max deflection using batch evaluation
204-
double tol = PolyUtils::ComputeMaxDeflection(anEval, *this, NbTriangles());
203+
// Compute max deflection using surface adaptor
204+
double tol = PolyUtils::ComputeMaxDeflection(*Surface, *this, NbTriangles());
205205
tol *= DEFLECTION_COEFF;
206206

207207
DeflectionOverEstimation(tol);

src/ModelingAlgorithms/TKHLR/HLRBRep/HLRBRep_ThePolyhedronOfInterCSurf.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ void HLRBRep_ThePolyhedronOfInterCSurf::Init(HLRBRep_Surface* Surface,
102102
static_cast<bool*>(C_MyIsOnBounds),
103103
TheBnd);
104104

105-
double tol = PolyUtils::ComputeMaxDeflection(anEval, *this, NbTriangles());
105+
double tol = PolyUtils::ComputeMaxDeflection(Surface->Surface(), *this, NbTriangles());
106106
DeflectionOverEstimation(tol * 1.2);
107107
FillBounding();
108108

@@ -131,7 +131,7 @@ void HLRBRep_ThePolyhedronOfInterCSurf::Init(HLRBRep_Surface* S
131131
static_cast<bool*>(C_MyIsOnBounds),
132132
TheBnd);
133133

134-
double tol = PolyUtils::ComputeMaxDeflection(anEval, *this, NbTriangles());
134+
double tol = PolyUtils::ComputeMaxDeflection(Surface->Surface(), *this, NbTriangles());
135135
DeflectionOverEstimation(tol * 1.2);
136136
FillBounding();
137137

0 commit comments

Comments
 (0)