- TopoDS_Shape aShape = thePrs.shape();
- if (aShape.ShapeType() != TopAbs_EDGE)
- return ResultPtr();
-
- // Check that we already have such external edge
- std::shared_ptr<GeomAPI_Edge> aInEdge = std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge());
- aInEdge->setImpl(new TopoDS_Shape(aShape));
- ResultPtr aResult = findExternalEdge(theSketch, aInEdge);
- if (aResult)
- return aResult;
-
- // If not found then we have to create new
- Standard_Real aStart, aEnd;
- Handle(V3d_View) aNullView;
- FeaturePtr aMyFeature;
-
- Handle(Geom_Curve) aCurve = BRep_Tool::Curve(TopoDS::Edge(aShape), aStart, aEnd);
- GeomAdaptor_Curve aAdaptor(aCurve);
- if (aAdaptor.GetType() == GeomAbs_Line) {
- // Create line
- aMyFeature = theSketch->addFeature(SketchPlugin_Line::ID());
-
- //DataPtr aData = myFeature->data();
- //std::shared_ptr<GeomDataAPI_Point2D> anEndAttr =
- // std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Line::END_ID()));
-
- //double aX, aY;
- //gp_Pnt Pnt1 = aAdaptor.Value(aStart);
- //convertTo2D(Pnt1, theSketch, aNullView, aX, aY);
- //setFeaturePoint(myFeature, aX, aY, SketchPlugin_Line::START_ID());
-
- //gp_Pnt Pnt2 = aAdaptor.Value(aEnd);
- //convertTo2D(Pnt2, theSketch, aNullView, aX, aY);
- //setFeaturePoint(myFeature, aX, aY, SketchPlugin_Line::END_ID());
- } else if (aAdaptor.GetType() == GeomAbs_Circle) {
- if (aAdaptor.IsClosed()) {
- // Create circle
- aMyFeature = theSketch->addFeature(SketchPlugin_Circle::ID());
- //gp_Circ aCirc = aAdaptor.Circle();
- //gp_Pnt aCenter = aCirc.Location();
-
- //double aX, aY;
- //convertTo2D(aCenter, theSketch, aNullView, aX, aY);
- //setFeaturePoint(myFeature, aX, aY, SketchPlugin_Circle::CENTER_ID());
- //setFeatureValue(myFeature, aCirc.Radius(), SketchPlugin_Circle::RADIUS_ID());
- } else {
- // Create arc
- aMyFeature = theSketch->addFeature(SketchPlugin_Arc::ID());
+ if (theShape.ShapeType() == TopAbs_EDGE) {
+ // Check that we already have such external edge
+ std::shared_ptr<GeomAPI_Edge> aInEdge = std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge());
+ aInEdge->setImpl(new TopoDS_Shape(theShape));
+ ResultPtr aResult = findExternalEdge(theSketch, aInEdge);
+ if (aResult)
+ return aResult;
+
+ // If not found then we have to create new
+ Standard_Real aStart, aEnd;
+ Handle(V3d_View) aNullView;
+ FeaturePtr aMyFeature;
+
+ Handle(Geom_Curve) aCurve = BRep_Tool::Curve(TopoDS::Edge(theShape), aStart, aEnd);
+ GeomAdaptor_Curve aAdaptor(aCurve);
+ if (aAdaptor.GetType() == GeomAbs_Line) {
+ // Create line
+ aMyFeature = theSketch->addFeature(SketchPlugin_Line::ID());
+ } else if (aAdaptor.GetType() == GeomAbs_Circle) {
+ if (aAdaptor.IsClosed()) {
+ // Create circle
+ aMyFeature = theSketch->addFeature(SketchPlugin_Circle::ID());
+ } else {
+ // Create arc
+ aMyFeature = theSketch->addFeature(SketchPlugin_Arc::ID());
+ }