+
+//==================================================================================================
+std::shared_ptr<GeomAPI_Vertex> GeomAlgoAPI_PointBuilder::vertexOnEdge(const std::shared_ptr<GeomAPI_Edge> theEdge,
+ const double theValue,
+ const bool theIsPercent,
+ const bool theIsReverse)
+{
+ std::shared_ptr<GeomAPI_Vertex> aVertex;
+
+ if(!theEdge.get()) {
+ return aVertex;
+ }
+
+ double aValue = theValue;
+ if(theIsPercent) {
+ aValue = theEdge->length() / 100.0 * aValue;
+ }
+
+ const TopoDS_Edge& anEdge = TopoDS::Edge(theEdge->impl<TopoDS_Shape>());
+ Standard_Real aUFirst, aULast;
+ Handle(Geom_Curve) anEdgeCurve = BRep_Tool::Curve(anEdge, aUFirst, aULast);
+
+ if(!anEdgeCurve.IsNull() ) {
+ Handle(Geom_Curve) aReOrientedCurve = anEdgeCurve;
+
+ if(theIsReverse) {
+ aReOrientedCurve = anEdgeCurve->Reversed();
+ aUFirst = anEdgeCurve->ReversedParameter(aULast);
+ }
+
+ // Get the point by length
+ GeomAdaptor_Curve anAdapCurve = GeomAdaptor_Curve(aReOrientedCurve);
+ GCPnts_AbscissaPoint anAbsPnt(anAdapCurve, aValue, aUFirst);
+ Standard_Real aParam = anAbsPnt.Parameter();
+ gp_Pnt aPnt = anAdapCurve.Value(aParam);
+ BRepBuilderAPI_MakeVertex aMkVertex(aPnt);
+ const TopoDS_Vertex& aShape = aMkVertex.Vertex();
+ aVertex.reset(new GeomAPI_Vertex());
+ aVertex->setImpl(new TopoDS_Vertex(aShape));
+ }
+
+ return aVertex;
+}
+
+//==================================================================================================
+std::shared_ptr<GeomAPI_Vertex> GeomAlgoAPI_PointBuilder::vertexByProjection(
+ const std::shared_ptr<GeomAPI_Vertex> theVertex,
+ const std::shared_ptr<GeomAPI_Face> thePlane)
+{
+ std::shared_ptr<GeomAPI_Vertex> aVertex;
+
+ if(!theVertex.get() || !thePlane.get() || !thePlane->isPlanar()) {
+ return aVertex;
+ }
+
+ std::shared_ptr<GeomAPI_Pnt> aProjPnt = theVertex->point();
+ std::shared_ptr<GeomAPI_Pln> aProjPln = thePlane->getPlane();
+
+ std::shared_ptr<GeomAPI_Pnt> aPnt = aProjPln->project(aProjPnt);
+
+ if(!aPnt.get()) {
+ return aVertex;
+ }
+
+ aVertex.reset(new GeomAPI_Vertex(aPnt->x(), aPnt->y(), aPnt->z()));
+
+ return aVertex;
+}
+
+//==================================================================================================
+std::shared_ptr<GeomAPI_Vertex> GeomAlgoAPI_PointBuilder::vertexByIntersection(
+ const std::shared_ptr<GeomAPI_Edge> theEdge1,
+ const std::shared_ptr<GeomAPI_Edge> theEdge2)
+{
+ std::shared_ptr<GeomAPI_Vertex> aVertex;
+
+ if(!theEdge1.get() || !theEdge2.get() || !theEdge1->isLine() || !theEdge2->isLine()) {
+ return aVertex;
+ }
+
+ std::shared_ptr<GeomAPI_Lin> aLin1 = theEdge1->line();
+ std::shared_ptr<GeomAPI_Lin> aLin2 = theEdge2->line();
+
+ std::shared_ptr<GeomAPI_Pnt> aPnt = aLin1->intersect(aLin2);
+
+ if(!aPnt.get()) {
+ return aVertex;
+ }
+
+ aVertex.reset(new GeomAPI_Vertex(aPnt->x(), aPnt->y(), aPnt->z()));
+
+ return aVertex;
+}
+
+//==================================================================================================
+std::shared_ptr<GeomAPI_Vertex> GeomAlgoAPI_PointBuilder::vertexByIntersection(
+ const std::shared_ptr<GeomAPI_Edge> theEdge,
+ const std::shared_ptr<GeomAPI_Face> theFace)
+{
+ std::shared_ptr<GeomAPI_Vertex> aVertex;
+
+ if(!theEdge.get() || !theFace.get() || !theEdge->isLine() || !theFace->isPlanar()) {
+ return aVertex;
+ }
+
+ std::shared_ptr<GeomAPI_Lin> aLin = theEdge->line();
+ std::shared_ptr<GeomAPI_Pln> aPln = theFace->getPlane();
+
+ std::shared_ptr<GeomAPI_Pnt> aPnt = aPln->intersect(aLin);
+
+ if(!aPnt.get()) {
+ return aVertex;
+ }
+
+ aVertex.reset(new GeomAPI_Vertex(aPnt->x(), aPnt->y(), aPnt->z()));
+
+ return aVertex;
+}