X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGeomAlgoAPI%2FGeomAlgoAPI_PointBuilder.cpp;h=cad4bc3cc01b927fb79fe2d86d32be679d8c75a5;hb=8438647a5fb5186e3b5893fd69092792edef9ca8;hp=1c7e51bb733736e6a38729c46e5475da71890640;hpb=14b2f19dcba31d259343982c208daea43b407dc5;p=modules%2Fshaper.git diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_PointBuilder.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_PointBuilder.cpp index 1c7e51bb7..cad4bc3cc 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_PointBuilder.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_PointBuilder.cpp @@ -26,7 +26,8 @@ #include //================================================================================================== -std::shared_ptr GeomAlgoAPI_PointBuilder::vertex(const std::shared_ptr thePoint) +std::shared_ptr + GeomAlgoAPI_PointBuilder::vertex(const std::shared_ptr thePoint) { const gp_Pnt& aPnt = thePoint->impl(); BRepBuilderAPI_MakeVertex aMaker(aPnt); @@ -50,7 +51,8 @@ std::shared_ptr GeomAlgoAPI_PointBuilder::vertex(const double th } //================================================================================================== -std::shared_ptr GeomAlgoAPI_PointBuilder::point(const std::shared_ptr theVertex) +std::shared_ptr + GeomAlgoAPI_PointBuilder::point(const std::shared_ptr theVertex) { TopoDS_Shape aShape = theVertex->impl(); if ((!aShape.IsNull()) && (aShape.ShapeType() == TopAbs_VERTEX)) { @@ -63,10 +65,11 @@ std::shared_ptr GeomAlgoAPI_PointBuilder::point(const std::shared_p } //================================================================================================== -std::shared_ptr GeomAlgoAPI_PointBuilder::vertexOnEdge(const std::shared_ptr theEdge, - const double theValue, - const bool theIsPercent, - const bool theIsReverse) +std::shared_ptr GeomAlgoAPI_PointBuilder::vertexOnEdge( + const std::shared_ptr theEdge, + const double theValue, + const bool theIsPercent, + const bool theIsReverse) { std::shared_ptr aVertex; @@ -116,23 +119,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; } @@ -161,3 +157,28 @@ std::shared_ptr GeomAlgoAPI_PointBuilder::vertexByIntersection( return aVertex; } + +//================================================================================================== +std::shared_ptr GeomAlgoAPI_PointBuilder::vertexByIntersection( + const std::shared_ptr theEdge, + const std::shared_ptr theFace) +{ + std::shared_ptr aVertex; + + if(!theEdge.get() || !theFace.get() || !theEdge->isLine() || !theFace->isPlanar()) { + return aVertex; + } + + 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(aPnt->x(), aPnt->y(), aPnt->z())); + + return aVertex; +}