Fixed arc validator.
return aRes;
}
+std::shared_ptr<GeomAPI_Edge> GeomAlgoAPI_EdgeBuilder::line(
+ const std::shared_ptr<GeomAPI_Lin> theLin)
+{
+ if(!theLin.get()) {
+ return std::shared_ptr<GeomAPI_Edge>();
+ }
+
+ const gp_Lin& aLin = theLin->impl<gp_Lin>();
+ BRepBuilderAPI_MakeEdge anEdgeBuilder(aLin);
+ 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)
{
return aRes;
}
+std::shared_ptr<GeomAPI_Edge> GeomAlgoAPI_EdgeBuilder::lineCircle(
+ std::shared_ptr<GeomAPI_Circ> theCircle)
+{
+ if(!theCircle.get()) {
+ return std::shared_ptr<GeomAPI_Edge>();
+ }
+
+ const gp_Circ& aCirc = theCircle->impl<gp_Circ>();
+ BRepBuilderAPI_MakeEdge anEdgeBuilder(aCirc);
+ 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::lineCircleArc(
std::shared_ptr<GeomAPI_Pnt> theCenter, std::shared_ptr<GeomAPI_Pnt> theStartPoint,
std::shared_ptr<GeomAPI_Pnt> theEndPoint, std::shared_ptr<GeomAPI_Dir> theNormal)
#include <GeomAPI_Edge.h>
#include <GeomAPI_Pnt.h>
#include <GeomAPI_Dir.h>
+#include <GeomAPI_Lin.h>
+#include <GeomAPI_Circ.h>
#include <memory>
/**\class GeomAlgoAPI_EdgeBuilder
double theDY,
double theDZ);
+ /// Creates linear edge by GeomAPI_Lin.
+ /// \param theLin line.
+ static std::shared_ptr<GeomAPI_Edge> line(const std::shared_ptr<GeomAPI_Lin> theLin);
+
/// Creates edge - axis of the given cylindrical face. The result axis edge is infinite
static std::shared_ptr<GeomAPI_Edge> cylinderAxis(
std::shared_ptr<GeomAPI_Shape> theCylindricalFace);
std::shared_ptr<GeomAPI_Dir> theNormal,
double theRadius);
+ /// Creates linear edge in a form of a circle by GeomAPI_Circle
+ static std::shared_ptr<GeomAPI_Edge> lineCircle(std::shared_ptr<GeomAPI_Circ> theCircle);
+
/// Creates linear edge in a form of a circle arc by a three points
static std::shared_ptr<GeomAPI_Edge> lineCircleArc(std::shared_ptr<GeomAPI_Pnt> theCenter,
std::shared_ptr<GeomAPI_Pnt> theStartPoint,
#include <ModelGeomAlgo_Point2D.h>
#include <ModelGeomAlgo_Shape.h>
+#include <GeomAlgoAPI_EdgeBuilder.h>
#include <GeomAlgoAPI_ShapeTools.h>
#include <GeomAPI_Circ.h>
return true;
}
+static GeomShapePtr toInfiniteEdge(const GeomShapePtr theShape)
+{
+ if(!theShape.get()) {
+ return theShape;
+ }
+
+ if(!theShape->isEdge()) {
+ return theShape;
+ }
+
+ std::shared_ptr<GeomAPI_Edge> anEdge(new GeomAPI_Edge(theShape));
+
+ if(!anEdge.get()) {
+ return theShape;
+ }
+
+ if(anEdge->isLine()) {
+ std::shared_ptr<GeomAPI_Lin> aLine = anEdge->line();
+ GeomShapePtr aShape = GeomAlgoAPI_EdgeBuilder::line(aLine);
+ return aShape;
+ }
+
+ if(anEdge->isCircle() || anEdge->isArc()) {
+ std::shared_ptr<GeomAPI_Circ> aCircle = anEdge->circle();
+ GeomShapePtr aShape = GeomAlgoAPI_EdgeBuilder::lineCircle(aCircle);
+ return aShape;
+ }
+}
+
bool SketchPlugin_ArcEndPointIntersectionValidator::isValid(
const AttributePtr& theAttribute,
const std::list<std::string>& theArguments,
return true;
}
- GeomShapePtr anArcShape = anArcFeature->getArcShape(false);
+ GeomShapePtr anArcShape = toInfiniteEdge(anArcFeature->getArcShape(false));
if(!anArcShape.get() || anArcShape->isNull()) {
return true;
ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
if(aResult.get()) {
- GeomShapePtr aShape = aResult->shape();
+ GeomShapePtr aShape = toInfiniteEdge(aResult->shape());
if(aShape.get() && !aShape->isNull()) {
GeomShapePtr anIntersection = anArcShape->intersect(aShape);
if(anIntersection.get() && !anIntersection->isNull()) {
anIt != aResults.cend();
++anIt)
{
- GeomShapePtr aShape = (*anIt)->shape();
+ GeomShapePtr aShape = toInfiniteEdge((*anIt)->shape());
if(aShape.get() && !aShape->isNull()) {
GeomShapePtr anIntersection = anArcShape->intersect(aShape);
if(anIntersection.get() && !anIntersection->isNull()) {