aRes->setImpl(new TopoDS_Shape(anEdge));
return aRes;
}
+std::shared_ptr<GeomAPI_Edge> GeomAlgoAPI_EdgeBuilder::line(
+ double theDX, double theDY, double theDZ)
+{
+
+ const gp_Pnt& aStart = gp_Pnt(0, 0, 0);
+ const gp_Pnt& anEnd = gp_Pnt(theDX, theDY, theDZ);
+
+ if (aStart.IsEqual(anEnd, Precision::Confusion()))
+ return std::shared_ptr<GeomAPI_Edge>();
+ if (Abs(aStart.SquareDistance(anEnd)) > 1.e+100)
+ return std::shared_ptr<GeomAPI_Edge>();
+ BRepBuilderAPI_MakeEdge anEdgeBuilder(aStart, anEnd);
+ std::shared_ptr<GeomAPI_Edge> aRes(new GeomAPI_Edge);
+ TopoDS_Edge anEdge = anEdgeBuilder.Edge();
+ aRes->setImpl(new TopoDS_Shape(anEdge));
+ return aRes;
+}
std::shared_ptr<GeomAPI_Edge> GeomAlgoAPI_EdgeBuilder::cylinderAxis(
std::shared_ptr<GeomAPI_Shape> theCylindricalFace)
std::shared_ptr<GeomAPI_Pnt> theCenter, std::shared_ptr<GeomAPI_Pnt> theStartPoint,
std::shared_ptr<GeomAPI_Pnt> theEndPoint, std::shared_ptr<GeomAPI_Dir> theNormal)
{
+ std::shared_ptr<GeomAPI_Edge> aRes;
+
const gp_Pnt& aCenter = theCenter->impl<gp_Pnt>();
const gp_Dir& aDir = theNormal->impl<gp_Dir>();
+ /// OCCT creates an edge on a circle with empty radius, but visualization
+ /// is not able to process it
+ if (theCenter->isEqual(theStartPoint))
+ return aRes;
+
double aRadius = theCenter->distance(theStartPoint);
gp_Circ aCircle(gp_Ax2(aCenter, aDir), aRadius);
const gp_Pnt& anEnd = theEndPoint->impl<gp_Pnt>();
BRepBuilderAPI_MakeEdge anEdgeBuilder;
- if (aStart.IsEqual(anEnd, Precision::Confusion())
- || gp_Pnt(0, 0, 0).IsEqual(anEnd, Precision::Confusion()))
- anEdgeBuilder = BRepBuilderAPI_MakeEdge(aCircle);
- else
- anEdgeBuilder = BRepBuilderAPI_MakeEdge(aCircle, aStart, anEnd);
+ anEdgeBuilder = BRepBuilderAPI_MakeEdge(aCircle, aStart, anEnd);
- std::shared_ptr<GeomAPI_Edge> aRes(new GeomAPI_Edge);
anEdgeBuilder.Build();
- if (anEdgeBuilder.IsDone())
+ if (anEdgeBuilder.IsDone()) {
+ aRes = std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge);
aRes->setImpl(new TopoDS_Shape(anEdgeBuilder.Edge()));
- else
- aRes = std::shared_ptr<GeomAPI_Edge>();
+ }
return aRes;
}