mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-04 13:13:25 +03:00
0027362: Meshing performance
1) BRepMesh_FastDiscretFace.cxx: - exclude planes from procedure of inserting internal points. - localize declaration of the container aNewVertices in each method where it is needed. - correct the logic of the method insertInternalVerticesOther, so that to separate the processes of removing extra points and addition of new points in different cycles, thus making the code more clear and in addition stable. - insert useful output of intermediate mesh to a file in control() method for debug purposes (with definition DEBUG_MESH). 2) Add global functions MeshTest_DrawTriangles and MeshTest_DrawLinks to draw mesh data in debug session. 3) BRepMesh_FastDiscret: - in the method Add calculations of deflections have been simplified for non-relative mode. - replace the attribute MinDist with Deflection in EdgeAttributes structure. Correct its computation so that later to store this value as deflection of the polygon. 4) Make protection against exception in the method BRepMesh_Delaun::addTriangle() when an added triangle creates a third connection of a mesh edge. 5) BRepMesh_EdgeTessellator.cxx, BRepMesh_EdgeTessellationExtractor.cxx: use Geom2dAdaptor_Curve in order to use b-spline cache while computing value on a curve. 6) In BndLib_Box2dCurve::PerformBSpline, avoid creating new b-spline in case of requested parameter range differ from natural bounds insignificantly. 7) In GeomAdaptor classes, postpone building of cache till the time of its actual usage. So, creation of an adapter to compute intervals of continuity does not lead to creation of internal cache. 8) In the methods BRepAdaptor_Curve::Bezier and BSpline do not call Transformed() if transformation is identity. 9) In the classes Geom_BSplineCurve, Geom_BSplineSurface, Geom_BezierCurve, Geom_BezierSurface, Geom2d_BSplineCurve, Geom2d_BezierCurve change the method Pole() to return the point by const reference. 10) In CPnts_AbscissaPoint.cxx, compute derivative by D1 instead of DN to make use of b-spline cache. 11) Change test cases to actual state: - Number of triangles/nodes can grow due to more accurate work with deflection of edges. Now the edge is tessellated using its own tolerance instead of maximal tolerance of all shapes in the face. - Accept new numbers of mesh errors (free links, free nodes) for really bad shapes. - Correct the test "bugs/mesh/bug25612" to produce stable result. - Disable redundant checks in test cases bug25378* (lower limit for computation time). - Speed up iso-lines computation for offset of bspline surfaces. For that use adaptor instead of original surface in evaluator of approximation. - Add output of polylines for debug of insertInternalVerticesOther(). Reference data in test case bugs\moddata_2\bug453_3 have been changed to be close to expected theoretical values. This makes the test give stable result on different platforms.
This commit is contained in:
@@ -136,10 +136,10 @@ void GeomAdaptor_Curve::load(const Handle(Geom_Curve)& C,
|
||||
{
|
||||
myFirst = UFirst;
|
||||
myLast = ULast;
|
||||
myCurveCache.Nullify();
|
||||
|
||||
if ( myCurve != C) {
|
||||
myCurve = C;
|
||||
myCurveCache.Nullify();
|
||||
myNestedEvaluator.Nullify();
|
||||
myBSplineCurve.Nullify();
|
||||
|
||||
@@ -164,20 +164,10 @@ void GeomAdaptor_Curve::load(const Handle(Geom_Curve)& C,
|
||||
}
|
||||
else if ( TheType == STANDARD_TYPE(Geom_BezierCurve)) {
|
||||
myTypeCurve = GeomAbs_BezierCurve;
|
||||
// Create cache for Bezier
|
||||
Handle(Geom_BezierCurve) aBezier = Handle(Geom_BezierCurve)::DownCast(myCurve);
|
||||
Standard_Integer aDeg = aBezier->Degree();
|
||||
TColStd_Array1OfReal aFlatKnots(BSplCLib::FlatBezierKnots(aDeg), 1, 2 * (aDeg + 1));
|
||||
myCurveCache = new BSplCLib_Cache(aDeg, aBezier->IsPeriodic(), aFlatKnots,
|
||||
aBezier->Poles(), aBezier->Weights());
|
||||
}
|
||||
else if ( TheType == STANDARD_TYPE(Geom_BSplineCurve)) {
|
||||
myTypeCurve = GeomAbs_BSplineCurve;
|
||||
// Create cache for B-spline
|
||||
Handle(Geom_BSplineCurve) aBspl = Handle(Geom_BSplineCurve)::DownCast(myCurve);
|
||||
myBSplineCurve = aBspl;
|
||||
myCurveCache = new BSplCLib_Cache(aBspl->Degree(), aBspl->IsPeriodic(),
|
||||
aBspl->KnotSequence(), aBspl->Poles(), aBspl->Weights());
|
||||
myBSplineCurve = Handle(Geom_BSplineCurve)::DownCast(myCurve);
|
||||
}
|
||||
else if ( TheType == STANDARD_TYPE(Geom_OffsetCurve)) {
|
||||
myTypeCurve = GeomAbs_OffsetCurve;
|
||||
@@ -192,8 +182,6 @@ void GeomAdaptor_Curve::load(const Handle(Geom_Curve)& C,
|
||||
myTypeCurve = GeomAbs_OtherCurve;
|
||||
}
|
||||
}
|
||||
else // rebuild cache of Bezier and B-spline curve even if the loaded curve is same
|
||||
RebuildCache(myFirst);
|
||||
}
|
||||
|
||||
// --
|
||||
@@ -544,14 +532,22 @@ void GeomAdaptor_Curve::RebuildCache(const Standard_Real theParameter) const
|
||||
{
|
||||
if (myTypeCurve == GeomAbs_BezierCurve)
|
||||
{
|
||||
// Create cache for Bezier
|
||||
Handle(Geom_BezierCurve) aBezier = Handle(Geom_BezierCurve)::DownCast(myCurve);
|
||||
Standard_Integer aDeg = aBezier->Degree();
|
||||
TColStd_Array1OfReal aFlatKnots(BSplCLib::FlatBezierKnots(aDeg), 1, 2 * (aDeg + 1));
|
||||
myCurveCache->BuildCache(theParameter, aDeg, aBezier->IsPeriodic(), aFlatKnots,
|
||||
if (myCurveCache.IsNull())
|
||||
myCurveCache = new BSplCLib_Cache(aDeg, aBezier->IsPeriodic(), aFlatKnots,
|
||||
aBezier->Poles(), aBezier->Weights());
|
||||
myCurveCache->BuildCache(theParameter, aDeg, aBezier->IsPeriodic(), aFlatKnots,
|
||||
aBezier->Poles(), aBezier->Weights());
|
||||
}
|
||||
else if (myTypeCurve == GeomAbs_BSplineCurve)
|
||||
{
|
||||
// Create cache for B-spline
|
||||
if (myCurveCache.IsNull())
|
||||
myCurveCache = new BSplCLib_Cache(myBSplineCurve->Degree(), myBSplineCurve->IsPeriodic(),
|
||||
myBSplineCurve->KnotSequence(), myBSplineCurve->Poles(), myBSplineCurve->Weights());
|
||||
myCurveCache->BuildCache(theParameter, myBSplineCurve->Degree(),
|
||||
myBSplineCurve->IsPeriodic(), myBSplineCurve->KnotSequence(),
|
||||
myBSplineCurve->Poles(), myBSplineCurve->Weights());
|
||||
@@ -618,14 +614,13 @@ void GeomAdaptor_Curve::D0(const Standard_Real U, gp_Pnt& P) const
|
||||
{
|
||||
myBSplineCurve->LocalD0(U, aStart, aFinish, P);
|
||||
}
|
||||
else if (!myCurveCache.IsNull()) // use cached data
|
||||
else
|
||||
{
|
||||
if (!myCurveCache->IsCacheValid(U))
|
||||
// use cached data
|
||||
if (myCurveCache.IsNull() || !myCurveCache->IsCacheValid(U))
|
||||
RebuildCache(U);
|
||||
myCurveCache->D0(U, P);
|
||||
}
|
||||
else
|
||||
myCurve->D0(U, P);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -655,14 +650,13 @@ void GeomAdaptor_Curve::D1(const Standard_Real U, gp_Pnt& P, gp_Vec& V) const
|
||||
{
|
||||
myBSplineCurve->LocalD1(U, aStart, aFinish, P, V);
|
||||
}
|
||||
else if (!myCurveCache.IsNull()) // use cached data
|
||||
else
|
||||
{
|
||||
if (!myCurveCache->IsCacheValid(U))
|
||||
// use cached data
|
||||
if (myCurveCache.IsNull() || !myCurveCache->IsCacheValid(U))
|
||||
RebuildCache(U);
|
||||
myCurveCache->D1(U, P, V);
|
||||
}
|
||||
else
|
||||
myCurve->D1(U, P, V);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -693,14 +687,13 @@ void GeomAdaptor_Curve::D2(const Standard_Real U,
|
||||
{
|
||||
myBSplineCurve->LocalD2(U, aStart, aFinish, P, V1, V2);
|
||||
}
|
||||
else if (!myCurveCache.IsNull()) // use cached data
|
||||
else
|
||||
{
|
||||
if (!myCurveCache->IsCacheValid(U))
|
||||
// use cached data
|
||||
if (myCurveCache.IsNull() || !myCurveCache->IsCacheValid(U))
|
||||
RebuildCache(U);
|
||||
myCurveCache->D2(U, P, V1, V2);
|
||||
}
|
||||
else
|
||||
myCurve->D2(U, P, V1, V2);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -732,14 +725,13 @@ void GeomAdaptor_Curve::D3(const Standard_Real U,
|
||||
{
|
||||
myBSplineCurve->LocalD3(U, aStart, aFinish, P, V1, V2, V3);
|
||||
}
|
||||
else if (!myCurveCache.IsNull()) // use cached data
|
||||
else
|
||||
{
|
||||
if (!myCurveCache->IsCacheValid(U))
|
||||
// use cached data
|
||||
if (myCurveCache.IsNull() || !myCurveCache->IsCacheValid(U))
|
||||
RebuildCache(U);
|
||||
myCurveCache->D3(U, P, V1, V2, V3);
|
||||
}
|
||||
else
|
||||
myCurve->D3(U, P, V1, V2, V3);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@@ -237,7 +237,7 @@ private:
|
||||
Standard_Real myLast;
|
||||
|
||||
Handle(Geom_BSplineCurve) myBSplineCurve; ///< B-spline representation to prevent castings
|
||||
Handle(BSplCLib_Cache) myCurveCache; ///< Cached data for B-spline or Bezier curve
|
||||
mutable Handle(BSplCLib_Cache) myCurveCache; ///< Cached data for B-spline or Bezier curve
|
||||
Handle(GeomEvaluator_Curve) myNestedEvaluator; ///< Calculates value of offset curve
|
||||
|
||||
|
||||
|
@@ -132,10 +132,10 @@ void GeomAdaptor_Surface::load(const Handle(Geom_Surface)& S,
|
||||
myULast = ULast;
|
||||
myVFirst = VFirst;
|
||||
myVLast = VLast;
|
||||
mySurfaceCache.Nullify();
|
||||
|
||||
if ( mySurface != S) {
|
||||
mySurface = S;
|
||||
mySurfaceCache.Nullify();
|
||||
myNestedEvaluator.Nullify();
|
||||
myBSplineSurface.Nullify();
|
||||
|
||||
@@ -181,26 +181,10 @@ void GeomAdaptor_Surface::load(const Handle(Geom_Surface)& S,
|
||||
else if (TheType == STANDARD_TYPE(Geom_BezierSurface))
|
||||
{
|
||||
mySurfaceType = GeomAbs_BezierSurface;
|
||||
// Create cache for Bezier
|
||||
Handle(Geom_BezierSurface) aBezier = Handle(Geom_BezierSurface)::DownCast(mySurface);
|
||||
Standard_Integer aDegU = aBezier->UDegree();
|
||||
Standard_Integer aDegV = aBezier->VDegree();
|
||||
TColStd_Array1OfReal aFlatKnotsU(BSplCLib::FlatBezierKnots(aDegU), 1, 2 * (aDegU + 1));
|
||||
TColStd_Array1OfReal aFlatKnotsV(BSplCLib::FlatBezierKnots(aDegV), 1, 2 * (aDegV + 1));
|
||||
mySurfaceCache = new BSplSLib_Cache(
|
||||
aDegU, aBezier->IsUPeriodic(), aFlatKnotsU,
|
||||
aDegV, aBezier->IsVPeriodic(), aFlatKnotsV,
|
||||
aBezier->Poles(), aBezier->Weights());
|
||||
}
|
||||
else if (TheType == STANDARD_TYPE(Geom_BSplineSurface)) {
|
||||
mySurfaceType = GeomAbs_BSplineSurface;
|
||||
Handle(Geom_BSplineSurface) myBspl = Handle(Geom_BSplineSurface)::DownCast(mySurface);
|
||||
myBSplineSurface = myBspl;
|
||||
// Create cache for B-spline
|
||||
mySurfaceCache = new BSplSLib_Cache(
|
||||
myBspl->UDegree(), myBspl->IsUPeriodic(), myBspl->UKnotSequence(),
|
||||
myBspl->VDegree(), myBspl->IsVPeriodic(), myBspl->VKnotSequence(),
|
||||
myBspl->Poles(), myBspl->Weights());
|
||||
myBSplineSurface = Handle(Geom_BSplineSurface)::DownCast(mySurface);
|
||||
}
|
||||
else if ( TheType == STANDARD_TYPE(Geom_OffsetSurface))
|
||||
{
|
||||
@@ -216,8 +200,6 @@ void GeomAdaptor_Surface::load(const Handle(Geom_Surface)& S,
|
||||
else
|
||||
mySurfaceType = GeomAbs_OtherSurface;
|
||||
}
|
||||
else // rebuild cache of Bezier and B-spline surface even if the loaded surface is same
|
||||
RebuildCache(myUFirst, myVFirst);
|
||||
}
|
||||
|
||||
// --
|
||||
@@ -679,11 +661,17 @@ void GeomAdaptor_Surface::RebuildCache(const Standard_Real theU,
|
||||
{
|
||||
if (mySurfaceType == GeomAbs_BezierSurface)
|
||||
{
|
||||
// Create cache for Bezier
|
||||
Handle(Geom_BezierSurface) aBezier = Handle(Geom_BezierSurface)::DownCast(mySurface);
|
||||
Standard_Integer aDegU = aBezier->UDegree();
|
||||
Standard_Integer aDegV = aBezier->VDegree();
|
||||
TColStd_Array1OfReal aFlatKnotsU(BSplCLib::FlatBezierKnots(aDegU), 1, 2 * (aDegU + 1));
|
||||
TColStd_Array1OfReal aFlatKnotsV(BSplCLib::FlatBezierKnots(aDegV), 1, 2 * (aDegV + 1));
|
||||
if (mySurfaceCache.IsNull())
|
||||
mySurfaceCache = new BSplSLib_Cache(
|
||||
aDegU, aBezier->IsUPeriodic(), aFlatKnotsU,
|
||||
aDegV, aBezier->IsVPeriodic(), aFlatKnotsV,
|
||||
aBezier->Poles(), aBezier->Weights());
|
||||
mySurfaceCache->BuildCache(theU, theV,
|
||||
aDegU, aBezier->IsUPeriodic(), aFlatKnotsU,
|
||||
aDegV, aBezier->IsVPeriodic(), aFlatKnotsV,
|
||||
@@ -691,10 +679,16 @@ void GeomAdaptor_Surface::RebuildCache(const Standard_Real theU,
|
||||
}
|
||||
else if (mySurfaceType == GeomAbs_BSplineSurface)
|
||||
{
|
||||
mySurfaceCache->BuildCache(theU, theV,
|
||||
// Create cache for B-spline
|
||||
if (mySurfaceCache.IsNull())
|
||||
mySurfaceCache = new BSplSLib_Cache(
|
||||
myBSplineSurface->UDegree(), myBSplineSurface->IsUPeriodic(), myBSplineSurface->UKnotSequence(),
|
||||
myBSplineSurface->VDegree(), myBSplineSurface->IsVPeriodic(), myBSplineSurface->VKnotSequence(),
|
||||
myBSplineSurface->Poles(), myBSplineSurface->Weights());
|
||||
mySurfaceCache->BuildCache(theU, theV,
|
||||
myBSplineSurface->UDegree(), myBSplineSurface->IsUPeriodic(), myBSplineSurface->UKnotSequence(),
|
||||
myBSplineSurface->VDegree(), myBSplineSurface->IsVPeriodic(), myBSplineSurface->VKnotSequence(),
|
||||
myBSplineSurface->Poles(), myBSplineSurface->Weights());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -723,14 +717,9 @@ void GeomAdaptor_Surface::D0(const Standard_Real U,
|
||||
{
|
||||
case GeomAbs_BezierSurface:
|
||||
case GeomAbs_BSplineSurface:
|
||||
if (!mySurfaceCache.IsNull())
|
||||
{
|
||||
if (!mySurfaceCache->IsCacheValid(U, V))
|
||||
RebuildCache(U, V);
|
||||
mySurfaceCache->D0(U, V, P);
|
||||
}
|
||||
else
|
||||
mySurface->D0(U, V, P);
|
||||
if (mySurfaceCache.IsNull() || !mySurfaceCache->IsCacheValid(U, V))
|
||||
RebuildCache(U, V);
|
||||
mySurfaceCache->D0(U, V, P);
|
||||
break;
|
||||
|
||||
case GeomAbs_OffsetSurface:
|
||||
@@ -772,14 +761,12 @@ void GeomAdaptor_Surface::D1(const Standard_Real U,
|
||||
(USide != 0 || VSide != 0) &&
|
||||
IfUVBound(u, v, Ideb, Ifin, IVdeb, IVfin, USide, VSide))
|
||||
myBSplineSurface->LocalD1(u, v, Ideb, Ifin, IVdeb, IVfin, P, D1U, D1V);
|
||||
else if (!mySurfaceCache.IsNull())
|
||||
else
|
||||
{
|
||||
if (!mySurfaceCache->IsCacheValid(U, V))
|
||||
if (mySurfaceCache.IsNull() || !mySurfaceCache->IsCacheValid(U, V))
|
||||
RebuildCache(U, V);
|
||||
mySurfaceCache->D1(U, V, P, D1U, D1V);
|
||||
}
|
||||
else
|
||||
mySurface->D1(u, v, P, D1U, D1V);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -824,14 +811,12 @@ void GeomAdaptor_Surface::D2(const Standard_Real U,
|
||||
(USide != 0 || VSide != 0) &&
|
||||
IfUVBound(u, v, Ideb, Ifin, IVdeb, IVfin, USide, VSide))
|
||||
myBSplineSurface->LocalD2(u, v, Ideb, Ifin, IVdeb, IVfin, P, D1U, D1V, D2U, D2V, D2UV);
|
||||
else if (!mySurfaceCache.IsNull())
|
||||
else
|
||||
{
|
||||
if (!mySurfaceCache->IsCacheValid(U, V))
|
||||
if (mySurfaceCache.IsNull() || !mySurfaceCache->IsCacheValid(U, V))
|
||||
RebuildCache(U, V);
|
||||
mySurfaceCache->D2(U, V, P, D1U, D1V, D2U, D2V, D2UV);
|
||||
}
|
||||
else
|
||||
mySurface->D2(u, v, P, D1U, D1V, D2U, D2V, D2UV);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@@ -272,7 +272,7 @@ private:
|
||||
Standard_Real myTolV;
|
||||
|
||||
Handle(Geom_BSplineSurface) myBSplineSurface; ///< B-spline representation to prevent downcasts
|
||||
Handle(BSplSLib_Cache) mySurfaceCache; ///< Cached data for B-spline or Bezier surface
|
||||
mutable Handle(BSplSLib_Cache) mySurfaceCache; ///< Cached data for B-spline or Bezier surface
|
||||
|
||||
protected:
|
||||
GeomAbs_SurfaceType mySurfaceType;
|
||||
|
Reference in New Issue
Block a user