X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGeomAlgoAPI%2FGeomAlgoAPI_PointBuilder.cpp;h=e7414346d08c7f64a1aa29025c088ba04a39a8e0;hb=f0cec241aae9ca16d86e166f45cb5c4987d2c792;hp=b5db2869b32a40415f0e8b317c584bd4f51f40af;hpb=2b026d28c38ac5072ad411cdf0c79ce22b27be30;p=modules%2Fshaper.git diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_PointBuilder.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_PointBuilder.cpp index b5db2869b..e7414346d 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_PointBuilder.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_PointBuilder.cpp @@ -116,23 +116,16 @@ std::shared_ptr GeomAlgoAPI_PointBuilder::vertexByProjection( return aVertex; } - std::shared_ptr aGeomPnt = theVertex->point(); - gp_Pnt aPnt = aGeomPnt->impl(); + std::shared_ptr aProjPnt = theVertex->point(); + std::shared_ptr aProjPln = thePlane->getPlane(); - std::shared_ptr aGeomPln = thePlane->getPlane(); - gp_Pln aPln = aGeomPln->impl(); + std::shared_ptr aPnt = aProjPln->project(aProjPnt); - gp_Dir aPntAxis = aPnt.XYZ() - aPln.Location().XYZ(); - gp_Dir aPlnNorm = aPln.Axis().Direction(); - - if(aPntAxis * aPlnNorm > 0) { - aPlnNorm.Reverse(); + if(!aPnt.get()) { + return aVertex; } - double aDistance = aPln.Distance(aPnt); - aPnt.Translate(gp_Vec(aPlnNorm) * aDistance); - - aVertex.reset(new GeomAPI_Vertex(aPnt.X(), aPnt.Y(), aPnt.Z())); + aVertex.reset(new GeomAPI_Vertex(aPnt->x(), aPnt->y(), aPnt->z())); return aVertex; } @@ -148,32 +141,41 @@ std::shared_ptr GeomAlgoAPI_PointBuilder::vertexByIntersection( return aVertex; } - gp_Lin aLin1 = theEdge1->line()->impl(); - gp_Lin aLin2 = theEdge2->line()->impl(); + std::shared_ptr aLin1 = theEdge1->line(); + std::shared_ptr aLin2 = theEdge2->line(); + + std::shared_ptr aPnt = aLin1->intersect(aLin2); - if(aLin1.Distance(aLin2) > Precision::Confusion()) { + if(!aPnt.get()) { return aVertex; } - Handle(Geom_Line) aLine1 = new Geom_Line(aLin1); - Handle(Geom_Line) aLine2 = new Geom_Line(aLin2); + aVertex.reset(new GeomAPI_Vertex(aPnt->x(), aPnt->y(), aPnt->z())); - GeomAPI_ExtremaCurveCurve anExtrema(aLine1, aLine2); + return aVertex; +} - Standard_Integer aNbExtrema = anExtrema.NbExtrema(); +//================================================================================================== +std::shared_ptr GeomAlgoAPI_PointBuilder::vertexByIntersection( + const std::shared_ptr theEdge, + const std::shared_ptr theFace) +{ + std::shared_ptr aVertex; - if(aNbExtrema == 0) { + if(!theEdge.get() || !theFace.get() || !theEdge->isLine() || !theFace->isPlanar()) { 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); - } + std::shared_ptr aLin = theEdge->line(); + std::shared_ptr aPln = theFace->getPlane(); + + std::shared_ptr aPnt = aPln->intersect(aLin); + + if(!aPnt.get()) { + return aVertex; } - aVertex.reset(new GeomAPI_Vertex(aPnt1.X(), aPnt1.Y(), aPnt1.Z())); + aVertex.reset(new GeomAPI_Vertex(aPnt->x(), aPnt->y(), aPnt->z())); return aVertex; }