From 024f2600317b987778aa8443d386e25380fe0b65 Mon Sep 17 00:00:00 2001 From: Paul RASCLE Date: Sat, 28 Nov 2020 18:51:18 +0100 Subject: [PATCH] some cleaning --- src/HYDROData/HYDROData_TopoCurve.cxx | 119 +++++++------------------- 1 file changed, 32 insertions(+), 87 deletions(-) diff --git a/src/HYDROData/HYDROData_TopoCurve.cxx b/src/HYDROData/HYDROData_TopoCurve.cxx index dc6ba8fb..439379cb 100644 --- a/src/HYDROData/HYDROData_TopoCurve.cxx +++ b/src/HYDROData/HYDROData_TopoCurve.cxx @@ -47,8 +47,9 @@ #include "HYDRO_trace.hxx" #include -//! The type is intended to traverse the container -//! either from the begin to the end or vice versa. +/*! The type is intended to traverse the container + * either from the begin to the end or vice versa. + */ template class Iterator { @@ -95,7 +96,9 @@ public: IteratorType& operator *() {return myIterator;} }; -// Inserts the value after the position. +/*! Inserts the value after the position. + * + */ template static void InsertAfter( const typename std::list::iterator& thePosition, const ItemType& theValue, @@ -112,7 +115,9 @@ template static void InsertAfter( } } -// Converts the curve to a smooth cubic B-spline using the deflection. +/*! Converts the curve to a smooth cubic B-spline using the deflection. + * + */ static Handle(Geom_BSplineCurve) BSpline( const BRepAdaptor_Curve& theCurve, const double theDeflection) { @@ -122,7 +127,9 @@ static Handle(Geom_BSplineCurve) BSpline( return aConverter.HasResult() ? aConverter.Curve() : aBSpline; } -// Replaces the vertex of the edge considering the edge orientation. +/*! Replaces the vertex of the edge considering the edge orientation. + * + */ static TopoDS_Edge ReplaceVertex( const TopoDS_Edge& theEdge, const bool theIsEndVertex) { @@ -137,7 +144,9 @@ static TopoDS_Edge ReplaceVertex( return aNewEdge; } -// Projects the point to the curve. +/*! Projects the point to the curve. + * + */ double ProjectPointToCurve( const gp_XYZ& thePoint, const Adaptor3d_Curve& theCurve, @@ -206,7 +215,9 @@ static double ProjectPointToEdge( return ProjectPointToCurve(thePoint, BRepAdaptor_Curve(theEdge), theParameter); } -// Adds the parameter to the curve parameter list. +/*! Adds the parameter to the curve parameter list. + * + */ static int AddParameter( const Adaptor3d_Curve& theCurve, const double theParameter, @@ -269,50 +280,9 @@ static int AddParameter( return 1; } -// Intersects the first curve by the second one and -// adds the intersection parameters to the ordered list. -static int IntersectCurve( - const Adaptor3d_Curve& theCurve1, - const Adaptor3d_Curve& theCurve2, - std::list& theParameters) -{ - // Process the ends. - int aIntCount = 0; - const gp_XYZ aEndPs[] = { - theCurve2.Value(theCurve2.FirstParameter()).XYZ(), - theCurve2.Value(theCurve2.LastParameter()).XYZ()}; - for (int aPI = 0; aPI < 2; ++aPI) - { - double aParameter; - if (ProjectPointToCurve(aEndPs[aPI], theCurve1, aParameter) <= - Precision::SquareConfusion()) - { - DEBTRACE("aParameter " << aParameter); - aIntCount += AddParameter(theCurve1, aParameter, theParameters); - } - } - - // Process the internal extremums. - Extrema_ExtCC aAlgo(theCurve1, theCurve2); //, 1.e-6, 1.e-6); - if (aAlgo.IsDone()) - { - const int aECount = aAlgo.NbExt(); - for (int aEN = 1; aEN <= aECount; ++aEN) - { - Extrema_POnCurv aP1, aP2; - aAlgo.Points(aEN, aP1, aP2); - DEBTRACE("SquareDistance " << aP1.Value().SquareDistance(aP2.Value())); - if (aP1.Value().SquareDistance(aP2.Value()) <= - Precision::SquareConfusion()) - { - DEBTRACE("aP1.Parameter() " << aP1.Parameter()); - aIntCount += AddParameter(theCurve1, aP1.Parameter(), theParameters); - } - } - } - return aIntCount; -} - +/*! Intersects the first curve by the second one and + * adds the intersection parameters to the ordered list. + */ static int IntersectShape( const TopoDS_Edge& theEdge1, const TopoDS_Edge& theEdge2, @@ -321,39 +291,12 @@ static int IntersectShape( if (theEdge1.IsSame(theEdge2)) Standard_ConstructionError::Raise("The lines to make intersection must be different"); -// std::ostringstream oshp1, oshp2; -// BRepTools::Write(theEdge1, oshp1); -// BRepTools::Write(theEdge2, oshp2); -// BRep_Builder aBuilder; -// std::istringstream ishp1(oshp1.str()); -// std::istringstream ishp2(oshp2.str()); -// TopoDS_Shape aShape1, aShape2; -// DEBTRACE("oshp1.str() " << oshp1.str()); -// DEBTRACE("oshp2.str() " << oshp2.str()); -// try -// { -// BRepTools::Read(aShape1, ishp1, aBuilder); -// } catch (Standard_Failure) -// { -// DEBTRACE("Error Brep conversion"); -// return 0; -// } -// try -// { -// BRepTools::Read(aShape2, ishp2, aBuilder); -// } catch (Standard_Failure) -// { -// DEBTRACE("Error Brep conversion"); -// return 0; -// } - int nbSols = 0; BRepAdaptor_Curve aCurve1 = BRepAdaptor_Curve(theEdge1); - //BRepAdaptor_Curve aCurve2 = BRepAdaptor_Curve(theEdge2); // --- Calculate Lines Intersections Points: two times, changing the order (sometimes intersections not detected) - BRepExtrema_DistShapeShape dst(theEdge1, theEdge2); // first + BRepExtrema_DistShapeShape dst(theEdge1, theEdge2); // first order if (dst.IsDone()) { DEBTRACE("nb solutions found: " << dst.NbSolution()); @@ -378,7 +321,7 @@ static int IntersectShape( } } - BRepExtrema_DistShapeShape dst2(theEdge2, theEdge1); // second + BRepExtrema_DistShapeShape dst2(theEdge2, theEdge1); // second order if (dst2.IsDone()) { DEBTRACE("nb solutions found: " << dst.NbSolution()); @@ -405,20 +348,20 @@ static int IntersectShape( return nbSols; } -// Intersects the first edge by the second one and -// adds the intersection parameters to the ordered list. +/*! Intersects the first edge by the second one and + * adds the intersection parameters to the ordered list. + */ static int IntersectEdge( const TopoDS_Edge& theEdge1, const TopoDS_Edge& theEdge2, std::list& theParameters) { return IntersectShape(theEdge1, theEdge2, theParameters); -// BRepAdaptor_Curve aCurve1 = BRepAdaptor_Curve(theEdge1); -// BRepAdaptor_Curve aCurve2 = BRepAdaptor_Curve(theEdge2); -// return IntersectCurve(aCurve1, aCurve2, theParameters); } -// Returns the curve tangent in the position: 0 - start, 1 - end. +/*! Returns the curve tangent in the position: 0 - start, 1 - end. + * + */ static gp_XYZ Tangent(const Adaptor3d_Curve& theCurve, const int thePosition) { const Standard_Real aParam = (thePosition == 0) ? @@ -431,7 +374,9 @@ static gp_XYZ Tangent(const Adaptor3d_Curve& theCurve, const int thePosition) return ((1 / aNorm) * aV).XYZ(); } -// Returns the edge tangent in the position: 0 - start, 1 - end. +/*! Returns the edge tangent in the position: 0 - start, 1 - end. + * + */ static gp_XYZ Tangent(const TopoDS_Edge& theEdge, const int thePosition) { BRepAdaptor_Curve aCurve(theEdge); -- 2.30.2