Salome HOME
Added CPP High API for SketchPlugin_Arc
authordbv <dbv@opencascade.com>
Wed, 15 Jun 2016 08:14:18 +0000 (11:14 +0300)
committerspo <sergey.pokhodenko@opencascade.com>
Fri, 17 Jun 2016 11:41:09 +0000 (14:41 +0300)
src/PythonAPI/Test/TestSketcherAddArc.py
src/SketchAPI/CMakeLists.txt
src/SketchAPI/SketchAPI.i
src/SketchAPI/SketchAPI_Arc.cpp [new file with mode: 0644]
src/SketchAPI/SketchAPI_Arc.h [new file with mode: 0644]
src/SketchAPI/SketchAPI_Sketch.cpp
src/SketchAPI/SketchAPI_Sketch.h
src/SketchAPI/SketchAPI_swig.h
src/SketchPlugin/SketchPlugin_Arc.cpp
src/SketchPlugin/SketchPlugin_Arc.h

index 5899815e8da4585cbe8642955dab3901551d7f80..922078d2c2e494adc52df76a083a14f4dddc039c 100644 (file)
@@ -8,7 +8,7 @@ from TestSketcher import SketcherTestCase
 
 class SketcherAddArc(SketcherTestCase):
     def test_arc_by_coords(self):
-        arc = self.sketch.addArc(0, 1, 0, 0, 1, 1)
+        arc = self.sketch.addArc(0, 1, 0, 0, 1, 1, 0)
         model.do()
         self.assertEqual(arc.startPoint().x(), 0)
         self.assertEqual(arc.startPoint().y(), 0)
@@ -17,23 +17,21 @@ class SketcherAddArc(SketcherTestCase):
         center = geom.Pnt2d(0, 1)
         start = geom.Pnt2d(0, 0)
         end = geom.Pnt2d(1, 1)
-        arc = self.sketch.addArc(center, start, end)
+        arc = self.sketch.addArc(center, start, end, 0)
         model.do()
         self.assertEqual(arc.startPoint().x(), 0)
         self.assertEqual(arc.startPoint().y(), 0)
 
-    def test_number_of_args(self):
-        with self.assertRaises(WrongNumberOfArguments):
-            self.sketch.addArc(0, 1, 1, 1)
-        with self.assertRaises(WrongNumberOfArguments):
-            self.sketch.addArc(0, 1)
+    def test_number_of_args(self):
+        with self.assertRaises(WrongNumberOfArguments):
+            self.sketch.addArc(0, 1, 1, 1)
+        with self.assertRaises(WrongNumberOfArguments):
+            self.sketch.addArc(0, 1)
 
     def test_modify_arc(self):
         # Note: arc will modify startPoint and endPoint to be in circle
-        arc = self.sketch.addArc(0, 1, 0, 0, 1, 1)
-        arc.setCenter(0, 0)
-        arc.setStartPoint(1, 1)
-        arc.setEndPoint(-1, -1)
+        arc = self.sketch.addArc(0, 1, 0, 0, 1, 1, 0)
+        arc.setByCenterStartEnd(0, 0, 1, 1, -1, -1, 0)
         model.do()
         self.assertEqual(arc.center().x(), 0)
         self.assertEqual(arc.center().y(), 0)
index 0659417de8a88d0c3e011f6fe977d2b9e1a336a4..206eee1c1b0f221924eb663fb9ad7b36f6f84122 100644 (file)
@@ -4,6 +4,7 @@ INCLUDE(Common)
 
 SET(PROJECT_HEADERS
   SketchAPI.h
+  SketchAPI_Arc.h
   SketchAPI_Circle.h
   SketchAPI_Line.h
   SketchAPI_Sketch.h
@@ -11,6 +12,7 @@ SET(PROJECT_HEADERS
 )
 
 SET(PROJECT_SOURCES
+  SketchAPI_Arc.cpp
   SketchAPI_Circle.cpp
   SketchAPI_Line.cpp
   SketchAPI_Sketch.cpp
index b515c2c746d47a5268a547f154bab4b0ec758097..7aad3d4de37c8d81d5df052cf338570f69200919 100644 (file)
@@ -20,6 +20,7 @@
 %include "std_shared_ptr.i"
 
 // shared pointers
+%shared_ptr(SketchAPI_Arc)
 %shared_ptr(SketchAPI_Circle)
 %shared_ptr(SketchAPI_Line)
 %shared_ptr(SketchAPI_Sketch)
@@ -55,6 +56,7 @@
 
 // all supported interfaces (the order is very important: base class first)
 %include "SketchAPI_SketchEntity.h"
+%include "SketchAPI_Arc.h"
 %include "SketchAPI_Circle.h"
 %include "SketchAPI_Line.h"
 %include "SketchAPI_Sketch.h"
diff --git a/src/SketchAPI/SketchAPI_Arc.cpp b/src/SketchAPI/SketchAPI_Arc.cpp
new file mode 100644 (file)
index 0000000..438c28d
--- /dev/null
@@ -0,0 +1,234 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File:        SketchAPI_Arc.cpp
+// Created:     09 June 2016
+// Author:      Dmitry Bobylev
+
+#include "SketchAPI_Arc.h"
+
+#include <GeomAPI_Pnt2d.h>
+
+#include <ModelHighAPI_Double.h>
+#include <ModelHighAPI_Selection.h>
+#include <ModelHighAPI_Tools.h>
+
+//==================================================================================================
+SketchAPI_Arc::SketchAPI_Arc(const std::shared_ptr<ModelAPI_Feature> & theFeature)
+: SketchAPI_SketchEntity(theFeature)
+{
+  initialize();
+}
+
+//==================================================================================================
+SketchAPI_Arc::SketchAPI_Arc(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                             double theCenterX, double theCenterY,
+                             double theStartX, double theStartY,
+                             double theEndX, double theEndY,
+                             bool theInversed)
+: SketchAPI_SketchEntity(theFeature)
+{
+  if(initialize()) {
+    setByCenterStartEnd(theCenterX, theCenterY, theStartX, theStartY, theEndX, theEndY, theInversed);
+  }
+}
+
+//==================================================================================================
+SketchAPI_Arc::SketchAPI_Arc(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                             const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
+                             const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
+                             const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
+                             bool theInversed)
+: SketchAPI_SketchEntity(theFeature)
+{
+  if(initialize()) {
+    setByCenterStartEnd(theCenter, theStart, theEnd, theInversed);
+  }
+}
+
+//==================================================================================================
+SketchAPI_Arc::SketchAPI_Arc(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                             double theStartX, double theStartY,
+                             double theEndX, double theEndY,
+                             double thePassedX, double thePassedY)
+: SketchAPI_SketchEntity(theFeature)
+{
+  if (initialize()) {
+    setByStartEndPassed(theStartX, theStartY, theEndX, theEndY, thePassedX, thePassedY);
+  }
+}
+
+//==================================================================================================
+SketchAPI_Arc::SketchAPI_Arc(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                             const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
+                             const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
+                             const std::shared_ptr<GeomAPI_Pnt2d>& thePassed)
+: SketchAPI_SketchEntity(theFeature)
+{
+  if (initialize()) {
+    setByStartEndPassed(theStart, theEnd, thePassed);
+  }
+}
+
+//==================================================================================================
+SketchAPI_Arc::SketchAPI_Arc(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                             const ModelHighAPI_RefAttr& theTangentPoint,
+                             double theEndX, double theEndY,
+                             bool theInversed)
+: SketchAPI_SketchEntity(theFeature)
+{
+  if (initialize()) {
+    setByTangent(theTangentPoint, theEndX, theEndY, theInversed);
+  }
+}
+
+//==================================================================================================
+SketchAPI_Arc::SketchAPI_Arc(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                             const ModelHighAPI_RefAttr& theTangentPoint,
+                             const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
+                             bool theInversed)
+: SketchAPI_SketchEntity(theFeature)
+{
+  if (initialize()) {
+    setByTangent(theTangentPoint, theEnd, theInversed);
+  }
+}
+
+//==================================================================================================
+SketchAPI_Arc::SketchAPI_Arc(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                             const ModelHighAPI_Selection& theExternal)
+: SketchAPI_SketchEntity(theFeature)
+{
+  if (initialize()) {
+    setByExternal(theExternal);
+  }
+}
+
+//==================================================================================================
+SketchAPI_Arc::SketchAPI_Arc(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                             const std::string& theExternalName)
+: SketchAPI_SketchEntity(theFeature)
+{
+  if (initialize()) {
+    setByExternalName(theExternalName);
+  }
+}
+
+//==================================================================================================
+SketchAPI_Arc::~SketchAPI_Arc()
+{
+
+}
+
+//==================================================================================================
+void SketchAPI_Arc::setByCenterStartEnd(double theCenterX, double theCenterY,
+                                        double theStartX, double theStartY,
+                                        double theEndX, double theEndY,
+                                        bool theInversed)
+{
+  fillAttribute(SketchPlugin_Arc::ARC_TYPE_CENTER_START_END(), myarcType);
+  fillAttribute(center(), theCenterX, theCenterY);
+  fillAttribute(startPoint(), theStartX, theStartY);
+  fillAttribute(endPoint(), theEndX, theEndY);
+  fillAttribute(theInversed, myinversed);
+
+  execute();
+}
+
+//==================================================================================================
+void SketchAPI_Arc::setByCenterStartEnd(const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
+                                        const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
+                                        const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
+                                        bool theInversed)
+{
+  fillAttribute(SketchPlugin_Arc::ARC_TYPE_CENTER_START_END(), myarcType);
+  fillAttribute(theCenter, mycenter);
+  fillAttribute(theStart, mystartPoint);
+  fillAttribute(theEnd, myendPoint);
+  fillAttribute(theInversed, myinversed);
+
+  execute();
+}
+
+//==================================================================================================
+void SketchAPI_Arc::setByStartEndPassed(double theStartX, double theStartY,
+                                        double theEndX, double theEndY,
+                                        double thePassedX, double thePassedY)
+{
+  fillAttribute(SketchPlugin_Arc::ARC_TYPE_THREE_POINTS(), myarcType);
+  fillAttribute(startPoint(), theStartX, theStartY);
+  fillAttribute(endPoint(), theEndX, theEndY);
+  fillAttribute(passedPoint(), thePassedX, thePassedY);
+
+  execute();
+}
+
+//==================================================================================================
+void SketchAPI_Arc::setByStartEndPassed(const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
+                                        const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
+                                        const std::shared_ptr<GeomAPI_Pnt2d>& thePassed)
+{
+  fillAttribute(SketchPlugin_Arc::ARC_TYPE_THREE_POINTS(), myarcType);
+  fillAttribute(theStart, mystartPoint);
+  fillAttribute(theEnd, myendPoint);
+  fillAttribute(thePassed, mypassedPoint);
+
+  execute();
+}
+
+//==================================================================================================
+void SketchAPI_Arc::setByTangent(const ModelHighAPI_RefAttr& theTangentPoint,
+                                 double theEndX, double theEndY,
+                                 bool theInversed)
+{
+  fillAttribute(SketchPlugin_Arc::ARC_TYPE_TANGENT(), myarcType);
+  fillAttribute(theTangentPoint, mytangentPoint);
+  fillAttribute(endPoint(), theEndX, theEndY);
+  fillAttribute(theInversed, myinversed);
+
+  execute();
+}
+
+//==================================================================================================
+void SketchAPI_Arc::setByTangent(const ModelHighAPI_RefAttr& theTangentPoint,
+                                 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
+                                 bool theInversed)
+{
+  fillAttribute(SketchPlugin_Arc::ARC_TYPE_TANGENT(), myarcType);
+  fillAttribute(theTangentPoint, mytangentPoint);
+  fillAttribute(theEnd, myendPoint);
+  fillAttribute(theInversed, myinversed);
+
+  execute();
+}
+
+//==================================================================================================
+void SketchAPI_Arc::setByExternal(const ModelHighAPI_Selection & theExternal)
+{
+  fillAttribute(theExternal, external());
+
+  execute();
+}
+
+//==================================================================================================
+void SketchAPI_Arc::setByExternalName(const std::string & theExternalName)
+{
+  fillAttribute(ModelHighAPI_Selection("EDGE", theExternalName), external());
+
+  execute();
+}
+
+//==================================================================================================
+void SketchAPI_Arc::setRadius(double theRadius)
+{
+  fillAttribute(ModelHighAPI_Double(theRadius), myradius);
+
+  execute();
+}
+
+//==================================================================================================
+void SketchAPI_Arc::setAngle(double theAngle)
+{
+  fillAttribute(ModelHighAPI_Double(theAngle), myangle);
+
+  execute();
+}
diff --git a/src/SketchAPI/SketchAPI_Arc.h b/src/SketchAPI/SketchAPI_Arc.h
new file mode 100644 (file)
index 0000000..4cff200
--- /dev/null
@@ -0,0 +1,158 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File:        SketchAPI_Arc.h
+// Created:     09 June 2016
+// Author:      Dmitry Bobylev
+
+#ifndef SketchAPI_Arc_H_
+#define SketchAPI_Arc_H_
+
+#include "SketchAPI.h"
+#include "SketchAPI_SketchEntity.h"
+
+#include <GeomDataAPI_Point2D.h>
+
+#include <SketchPlugin_Arc.h>
+
+class ModelHighAPI_RefAttr;
+class ModelHighAPI_Selection;
+
+/// \class FeaturesAPI_Boolean
+/// \ingroup CPPHighAPI
+/// \brief Interface for Arc feature.
+class SketchAPI_Arc: public SketchAPI_SketchEntity
+{
+public:
+  /// Constructor without values.
+  SKETCHAPI_EXPORT
+  explicit SketchAPI_Arc(const std::shared_ptr<ModelAPI_Feature>& theFeature);
+
+  /// Constructor with values.
+  SKETCHAPI_EXPORT
+  SketchAPI_Arc(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                double theCenterX, double theCenterY,
+                double theStartX, double theStartY,
+                double theEndX, double theEndY,
+                bool theInversed);
+
+  /// Constructor with values.
+  SKETCHAPI_EXPORT
+  SketchAPI_Arc(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
+                const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
+                const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
+                bool theInversed);
+
+  /// Constructor with values.
+  SKETCHAPI_EXPORT
+  SketchAPI_Arc(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                double theStartX, double theStartY,
+                double theEndX, double theEndY,
+                double thePassedX, double thePassedY);
+
+  /// Constructor with values.
+  SKETCHAPI_EXPORT
+  SketchAPI_Arc(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
+                const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
+                const std::shared_ptr<GeomAPI_Pnt2d>& thePassed);
+
+  /// Constructor with values.
+  SKETCHAPI_EXPORT
+  SketchAPI_Arc(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                const ModelHighAPI_RefAttr& theTangentPoint,
+                double theEndX, double theEndY,
+                bool theInversed);
+
+  /// Constructor with values.
+  SKETCHAPI_EXPORT
+  SketchAPI_Arc(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                const ModelHighAPI_RefAttr& theTangentPoint,
+                const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
+                bool theInversed);
+
+  /// Constructor with values.
+  SKETCHAPI_EXPORT
+  SketchAPI_Arc(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                const ModelHighAPI_Selection& theExternal);
+
+  /// Constructor with values.
+  SKETCHAPI_EXPORT
+  SketchAPI_Arc(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                const std::string& theExternalName);
+
+  /// Destructor.
+  SKETCHAPI_EXPORT
+  virtual ~SketchAPI_Arc();
+
+  INTERFACE_10(SketchPlugin_Arc::ID(),
+               arcType, SketchPlugin_Arc::ARC_TYPE(), ModelAPI_AttributeString, /** Arc type */,
+               center, SketchPlugin_Arc::CENTER_ID(), GeomDataAPI_Point2D, /** Center point */,
+               startPoint, SketchPlugin_Arc::START_ID(), GeomDataAPI_Point2D, /** Start point */,
+               endPoint, SketchPlugin_Arc::END_ID(), GeomDataAPI_Point2D, /** End point */,
+               inversed, SketchPlugin_Arc::INVERSED_ID(), ModelAPI_AttributeBoolean, /** Inversed flag */,
+               passedPoint, SketchPlugin_Arc::PASSED_POINT_ID(), GeomDataAPI_Point2D, /** Passed point */,
+               tangentPoint, SketchPlugin_Arc::TANGENT_POINT_ID(), ModelAPI_AttributeRefAttr, /** Tangent point */,
+               radius, SketchPlugin_Arc::RADIUS_ID(), ModelAPI_AttributeDouble, /** Radius */,
+               angle, SketchPlugin_Arc::ANGLE_ID(), ModelAPI_AttributeDouble, /** Angle */,
+               external, SketchPlugin_Arc::EXTERNAL_ID(), ModelAPI_AttributeSelection, /** External */)
+
+  /// Set by center and start, end point.
+  SKETCHAPI_EXPORT
+  void setByCenterStartEnd(double theCenterX, double theCenterY,
+                           double theStartX, double theStartY,
+                           double theEndX, double theEndY,
+                           bool theInversed);
+
+  /// Set by center and start, end point.
+  SKETCHAPI_EXPORT
+  void setByCenterStartEnd(const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
+                           const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
+                           const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
+                           bool theInversed);
+
+  /// Set by start, end and passed points.
+  SKETCHAPI_EXPORT
+  void setByStartEndPassed(double theStartX, double theStartY,
+                           double theEndX, double theEndY,
+                           double thePassedX, double thePassedY);
+
+  /// Set by start, end and passed points.
+  SKETCHAPI_EXPORT
+  void setByStartEndPassed(const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
+                           const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
+                           const std::shared_ptr<GeomAPI_Pnt2d>& thePassed);
+
+  /// Set by tangent and end point.
+  SKETCHAPI_EXPORT
+  void setByTangent(const ModelHighAPI_RefAttr& theTangentPoint,
+                    double theEndX, double theEndY,
+                    bool theInversed);
+
+  /// Set by tangent and end point.
+  SKETCHAPI_EXPORT
+  void setByTangent(const ModelHighAPI_RefAttr& theTangentPoint,
+                    const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
+                    bool theInversed);
+
+  /// Set by external.
+  SKETCHAPI_EXPORT
+  void setByExternal(const ModelHighAPI_Selection& theExternal);
+
+  /// Set by external name.
+  SKETCHAPI_EXPORT
+  void setByExternalName(const std::string& theExternalName);
+
+  /// Set radius.
+  SKETCHAPI_EXPORT
+  void setRadius(double theRadius);
+
+  /// Set angle.
+  SKETCHAPI_EXPORT
+  void setAngle(double theAngle);
+};
+
+/// Pointer on Arc object.
+typedef std::shared_ptr<SketchAPI_Arc> ArcPtr;
+
+#endif // SketchAPI_Arc_H_
index e13b203c2e059488cd6a2db5e04f85e37019ff23..8d24c1534e739f54b875adf7050afd6981f2fdec 100644 (file)
@@ -31,6 +31,7 @@
 #include <ModelHighAPI_Selection.h>
 #include <ModelHighAPI_Tools.h>
 //--------------------------------------------------------------------------------------
+#include "SketchAPI_Arc.h"
 #include "SketchAPI_Circle.h"
 #include "SketchAPI_Line.h"
 //--------------------------------------------------------------------------------------
@@ -216,6 +217,77 @@ std::shared_ptr<SketchAPI_Circle> SketchAPI_Sketch::addCircle(const std::string
   return CirclePtr(new SketchAPI_Circle(aFeature, theExternalName));
 }
 
+//--------------------------------------------------------------------------------------
+std::shared_ptr<SketchAPI_Arc> SketchAPI_Sketch::addArc(double theCenterX, double theCenterY,
+                                                        double theStartX, double theStartY,
+                                                        double theEndX, double theEndY,
+                                                        bool theInversed)
+{
+  std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Arc::ID());
+  return ArcPtr(new SketchAPI_Arc(aFeature,
+                                  theCenterX, theCenterY,
+                                  theStartX, theStartY,
+                                  theEndX, theEndY,
+                                  theInversed));
+}
+
+std::shared_ptr<SketchAPI_Arc> SketchAPI_Sketch::addArc(const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
+                                                        const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
+                                                        const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
+                                                        bool theInversed)
+{
+  std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Arc::ID());
+  return ArcPtr(new SketchAPI_Arc(aFeature, theCenter, theStart, theEnd, theInversed));
+}
+
+std::shared_ptr<SketchAPI_Arc> SketchAPI_Sketch::addArc(double theStartX, double theStartY,
+                                                        double theEndX, double theEndY,
+                                                        double thePassedX, double thePassedY)
+{
+  std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Arc::ID());
+  return ArcPtr(new SketchAPI_Arc(aFeature,
+                                  theStartX, theStartY,
+                                  theEndX, theEndY,
+                                  thePassedX, thePassedY));
+}
+
+std::shared_ptr<SketchAPI_Arc> SketchAPI_Sketch::addArc(const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
+                                                        const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
+                                                        const std::shared_ptr<GeomAPI_Pnt2d>& thePassed)
+{
+  std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Arc::ID());
+  return ArcPtr(new SketchAPI_Arc(aFeature, theStart, theEnd, thePassed));
+}
+
+std::shared_ptr<SketchAPI_Arc> SketchAPI_Sketch::addArc(const ModelHighAPI_RefAttr& theTangentPoint,
+                                                        double theEndX, double theEndY,
+                                                        bool theInversed)
+{
+  std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Arc::ID());
+  return ArcPtr(new SketchAPI_Arc(aFeature, theTangentPoint, theEndX, theEndY, theInversed));
+}
+
+std::shared_ptr<SketchAPI_Arc> SketchAPI_Sketch::addArc(const ModelHighAPI_RefAttr& theTangentPoint,
+                                                        const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
+                                                        bool theInversed)
+{
+  std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Arc::ID());
+  return ArcPtr(new SketchAPI_Arc(aFeature, theTangentPoint, theEnd, theInversed));
+}
+
+std::shared_ptr<SketchAPI_Arc> SketchAPI_Sketch::addArc(const ModelHighAPI_Selection & theExternal)
+{
+  std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Arc::ID());
+  return ArcPtr(new SketchAPI_Arc(aFeature, theExternal));
+}
+
+std::shared_ptr<SketchAPI_Arc> SketchAPI_Sketch::addArc(const std::string & theExternalName)
+{
+  // TODO(spo): Add constraint SketchConstraintRigid like in PythonAPI. Is it necessary?
+  std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Arc::ID());
+  return ArcPtr(new SketchAPI_Arc(aFeature, theExternalName));
+}
+
 //--------------------------------------------------------------------------------------
 std::shared_ptr<ModelAPI_Feature> SketchAPI_Sketch::setCoincident(
     const ModelHighAPI_RefAttr & thePoint1,
index 53e234cf021f3905f55234046018d516e540373d..a1433e99e1d5cd969f883b88ed0482c72e5422b3 100644 (file)
@@ -22,6 +22,7 @@ class ModelAPI_CompositeFeature;
 class ModelHighAPI_Double;
 class ModelHighAPI_RefAttr;
 class ModelHighAPI_Selection;
+class SketchAPI_Arc;
 class SketchAPI_Circle;
 class SketchAPI_Line;
 //--------------------------------------------------------------------------------------
@@ -112,7 +113,57 @@ public:
   SKETCHAPI_EXPORT
   std::shared_ptr<SketchAPI_Circle> addCircle(const std::string & theExternalName);
 
-  // TODO(spo): addArc
+  /// Add arc
+  SKETCHAPI_EXPORT
+  std::shared_ptr<SketchAPI_Arc> addArc(
+      double theCenterX, double theCenterY,
+      double theStartX, double theStartY,
+      double theEndX, double theEndY,
+      bool theInversed);
+
+  /// Add arc
+  SKETCHAPI_EXPORT
+  std::shared_ptr<SketchAPI_Arc> addArc(
+      const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
+      const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
+      const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
+      bool theInversed);
+
+  /// Add arc
+  SKETCHAPI_EXPORT
+  std::shared_ptr<SketchAPI_Arc> addArc(
+      double theStartX, double theStartY,
+      double theEndX, double theEndY,
+      double thePassedX, double thePassedY);
+
+  /// Add arc
+  SKETCHAPI_EXPORT
+  std::shared_ptr<SketchAPI_Arc> addArc(
+      const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
+      const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
+      const std::shared_ptr<GeomAPI_Pnt2d>& thePassed);
+
+  /// Add arc
+  SKETCHAPI_EXPORT
+  std::shared_ptr<SketchAPI_Arc> addArc(
+      const ModelHighAPI_RefAttr& theTangentPoint,
+      double theEndX, double theEndY,
+      bool theInversed);
+
+  /// Add arc
+  SKETCHAPI_EXPORT
+  std::shared_ptr<SketchAPI_Arc> addArc(
+      const ModelHighAPI_RefAttr& theTangentPoint,
+      const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
+      bool theInversed);
+
+  /// Add arc
+  SKETCHAPI_EXPORT
+  std::shared_ptr<SketchAPI_Arc> addArc(const ModelHighAPI_Selection & theExternal);
+
+  /// Add arc
+  SKETCHAPI_EXPORT
+  std::shared_ptr<SketchAPI_Arc> addArc(const std::string & theExternalName);
 
   /// Set coincident
   SKETCHAPI_EXPORT
index c8829b3c55fc5c9e2cb315f20feea7ca9ea2096b..6ce00f715b5f073bcbdc4d612065e951ac92b429 100644 (file)
@@ -10,6 +10,7 @@
   #include <ModelHighAPI_swig.h>
 
   #include "SketchAPI.h"
+  #include "SketchAPI_Arc.h"
   #include "SketchAPI_Circle.h"
   #include "SketchAPI_Line.h"
   #include "SketchAPI_Sketch.h"
index b98a915bf9b7f7bc9c3f519eee17f8106bf6efb5..a787a5d658c88770b9006a88bafcd0812b406f32 100644 (file)
@@ -43,39 +43,12 @@ const double paramTolerance = 1.e-4;
 const double PI =3.141592653589793238463;
 
 namespace {
-  static const std::string& ARC_TYPE_CENTER_START_END()
-  {
-    static const std::string TYPE("CenterStartEnd");
-    return TYPE;
-  }
-  static const std::string& ARC_TYPE_THREE_POINTS()
-  {
-    static const std::string TYPE("ThreePoints");
-    return TYPE;
-  }
-
-  static const std::string& PASSED_POINT_ID()
-  {
-    static const std::string PASSED_PNT("ArcPassedPoint");
-    return PASSED_PNT;
-  }
-  static const std::string& RADIUS_ID()
-  {
-    static const std::string RADIUS("ArcRadius");
-    return RADIUS;
-  }
-  static const std::string& ANGLE_ID()
-  {
-    static const std::string ANGLE("ArcAngle");
-    return ANGLE;
-  }
-
   static const std::string& POINT_ID(int theIndex)
   {
     switch (theIndex) {
     case 1: return SketchPlugin_Arc::START_ID();
     case 2: return SketchPlugin_Arc::END_ID();
-    case 3: return PASSED_POINT_ID();
+    case 3: return SketchPlugin_Arc::PASSED_POINT_ID();
     }
 
     static const std::string DUMMY;
index 0fd638d933bdf881fa5ac5ca9fd45c07802a070f..812123b04e142af2de742fcb98d8353da923e622 100644 (file)
@@ -50,6 +50,17 @@ class SketchPlugin_Arc : public SketchPlugin_SketchEntity, public GeomAPI_IPrese
     return TYPE;
   }
 
+  static const std::string& ARC_TYPE_CENTER_START_END()
+  {
+    static const std::string TYPE("CenterStartEnd");
+    return TYPE;
+  }
+  static const std::string& ARC_TYPE_THREE_POINTS()
+  {
+    static const std::string TYPE("ThreePoints");
+    return TYPE;
+  }
+
   static const std::string& TANGENT_POINT_ID()
   {
     static const std::string TANGENT_PNT("ArcTangentPoint");
@@ -82,6 +93,27 @@ class SketchPlugin_Arc : public SketchPlugin_SketchEntity, public GeomAPI_IPrese
     return MY_INVERSED_ID;
   }
 
+  /// Passed point of the arc.
+  static const std::string& PASSED_POINT_ID()
+  {
+    static const std::string PASSED_PNT("ArcPassedPoint");
+    return PASSED_PNT;
+  }
+
+  /// Arc radius.
+  static const std::string& RADIUS_ID()
+  {
+    static const std::string RADIUS("ArcRadius");
+    return RADIUS;
+  }
+
+  /// Arc angle.
+  static const std::string& ANGLE_ID()
+  {
+    static const std::string ANGLE("ArcAngle");
+    return ANGLE;
+  }
+
   /// Returns the kind of a feature
   SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
   {