From 2b026d28c38ac5072ad411cdf0c79ce22b27be30 Mon Sep 17 00:00:00 2001 From: dbv Date: Wed, 6 Jul 2016 12:13:53 +0300 Subject: [PATCH] Compilation fix. --- src/GeomAlgoAPI/GeomAlgoAPI_PointBuilder.cpp | 57 ++++++++++++++++++-- src/GeomAlgoAPI/GeomAlgoAPI_PointBuilder.h | 7 +++ 2 files changed, 60 insertions(+), 4 deletions(-) diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_PointBuilder.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_PointBuilder.cpp index a76850441..b5db2869b 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_PointBuilder.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_PointBuilder.cpp @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -16,7 +17,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -65,8 +68,10 @@ std::shared_ptr GeomAlgoAPI_PointBuilder::vertexOnEdge(const std const bool theIsPercent, const bool theIsReverse) { + std::shared_ptr aVertex; + if(!theEdge.get()) { - return NULL; + return aVertex; } double aValue = theValue; @@ -78,7 +83,6 @@ std::shared_ptr GeomAlgoAPI_PointBuilder::vertexOnEdge(const std Standard_Real aUFirst, aULast; Handle(Geom_Curve) anEdgeCurve = BRep_Tool::Curve(anEdge, aUFirst, aULast); - std::shared_ptr aVertex; if(!anEdgeCurve.IsNull() ) { Handle(Geom_Curve) aReOrientedCurve = anEdgeCurve; @@ -106,8 +110,10 @@ std::shared_ptr GeomAlgoAPI_PointBuilder::vertexByProjection( const std::shared_ptr theVertex, const std::shared_ptr thePlane) { + std::shared_ptr aVertex; + if(!theVertex.get() || !thePlane.get() || !thePlane->isPlanar()) { - return NULL; + return aVertex; } std::shared_ptr aGeomPnt = theVertex->point(); @@ -126,5 +132,48 @@ std::shared_ptr GeomAlgoAPI_PointBuilder::vertexByProjection( double aDistance = aPln.Distance(aPnt); aPnt.Translate(gp_Vec(aPlnNorm) * aDistance); - return std::shared_ptr(new GeomAPI_Vertex(aPnt.X(), aPnt.Y(), aPnt.Z())); + aVertex.reset(new GeomAPI_Vertex(aPnt.X(), aPnt.Y(), aPnt.Z())); + + return aVertex; +} + +//================================================================================================== +std::shared_ptr GeomAlgoAPI_PointBuilder::vertexByIntersection( + const std::shared_ptr theEdge1, + const std::shared_ptr theEdge2) +{ + std::shared_ptr aVertex; + + if(!theEdge1.get() || !theEdge2.get() || !theEdge1->isLine() || !theEdge2->isLine()) { + return aVertex; + } + + gp_Lin aLin1 = theEdge1->line()->impl(); + gp_Lin aLin2 = theEdge2->line()->impl(); + + if(aLin1.Distance(aLin2) > Precision::Confusion()) { + return aVertex; + } + + Handle(Geom_Line) aLine1 = new Geom_Line(aLin1); + Handle(Geom_Line) aLine2 = new Geom_Line(aLin2); + + GeomAPI_ExtremaCurveCurve anExtrema(aLine1, aLine2); + + Standard_Integer aNbExtrema = anExtrema.NbExtrema(); + + if(aNbExtrema == 0) { + return aVertex; + } + + gp_Pnt aPnt1, aPnt2; + for(Standard_Integer anIndex = 1; anIndex <= aNbExtrema; ++anIndex) { + if(anExtrema.Distance(anIndex) <= Precision::Confusion()) { + anExtrema.Points(anIndex, aPnt1, aPnt2); + } + } + + aVertex.reset(new GeomAPI_Vertex(aPnt1.X(), aPnt1.Y(), aPnt1.Z())); + + return aVertex; } diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_PointBuilder.h b/src/GeomAlgoAPI/GeomAlgoAPI_PointBuilder.h index 906a2814f..c9298401c 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_PointBuilder.h +++ b/src/GeomAlgoAPI/GeomAlgoAPI_PointBuilder.h @@ -48,6 +48,13 @@ public: static std::shared_ptr vertexByProjection(const std::shared_ptr theVertex, const std::shared_ptr thePlane); + /// \brief Creates vertex by intersection two coplanar lines. + /// \param[in] theEdge1 first linear edge. + /// \param[in] theEdge2 second linear edge. + /// \return created vertex. + static std::shared_ptr vertexByIntersection(const std::shared_ptr theEdge1, + const std::shared_ptr theEdge2); + /// Return point by shape vertex static std::shared_ptr point(const std::shared_ptr theVertex); }; -- 2.39.2