]> SALOME platform Git repositories - modules/shaper.git/blobdiff - src/SketchAPI/SketchAPI_Arc.cpp
Salome HOME
Dump Python in the High Level Parameterized Geometry API (issue #1648)
[modules/shaper.git] / src / SketchAPI / SketchAPI_Arc.cpp
index 438c28d9ff094c2e7208ce93e499adfd444228ce..696bd9ab51571257375a0d9d4ef1ac1dbf47ec46 100644 (file)
@@ -9,6 +9,7 @@
 #include <GeomAPI_Pnt2d.h>
 
 #include <ModelHighAPI_Double.h>
+#include <ModelHighAPI_Dumper.h>
 #include <ModelHighAPI_Selection.h>
 #include <ModelHighAPI_Tools.h>
 
@@ -232,3 +233,34 @@ void SketchAPI_Arc::setAngle(double theAngle)
 
   execute();
 }
+
+//==================================================================================================
+void SketchAPI_Arc::dump(ModelHighAPI_Dumper& theDumper) const
+{
+  FeaturePtr aBase = feature();
+  const std::string& aSketchName = theDumper.parentName(aBase);
+
+  AttributeSelectionPtr anExternal = aBase->selection(SketchPlugin_SketchEntity::EXTERNAL_ID());
+  if (anExternal->value()) {
+    // arc is external
+    theDumper << aBase << " = " << aSketchName << ".addArc(" << anExternal << ")" << std::endl;
+  } else {
+    AttributeStringPtr aType = arcType();
+    if (aType->value() == SketchPlugin_Arc::ARC_TYPE_CENTER_START_END()) {
+      // arc given by center and start, end points
+      theDumper << aBase << " = " << aSketchName << ".addArc(" << center() << ", "
+                << startPoint() << ", " << endPoint() << ", " << inversed() << ")" << std::endl;
+    } else if (aType->value() == SketchPlugin_Arc::ARC_TYPE_THREE_POINTS()) {
+      // arc given by three points
+      theDumper << aBase << " = " << aSketchName << ".addArc(" << startPoint() << ", "
+                << endPoint() << ", " << passedPoint() << ")" << std::endl;
+    } else {
+      // tangent arc
+      AttributeRefAttrPtr aTangentPoint = tangentPoint();
+      theDumper << aBase << " = " << aSketchName << ".addArc("
+                << aTangentPoint << ", " << endPoint() << ", " << inversed() << ")" << std::endl;
+    }
+  }
+  // dump "auxiliary" flag if necessary
+  SketchAPI_SketchEntity::dump(theDumper);
+}