#include <GeomAPI_Pnt2d.h>
#include <ModelHighAPI_Double.h>
+#include <ModelHighAPI_Dumper.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,
: SketchAPI_SketchEntity(theFeature)
{
if(initialize()) {
- setByCenterStartEnd(theCenterX, theCenterY, theStartX, theStartY, theEndX, theEndY, theInversed);
+ 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,
}
}
-//==================================================================================================
+//================================================================================================
SketchAPI_Arc::SketchAPI_Arc(const std::shared_ptr<ModelAPI_Feature>& theFeature,
double theStartX, double theStartY,
double theEndX, double theEndY,
}
}
-//==================================================================================================
+//===============================================================================================
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,
}
}
-//==================================================================================================
+//================================================================================================
SketchAPI_Arc::SketchAPI_Arc(const std::shared_ptr<ModelAPI_Feature>& theFeature,
const ModelHighAPI_RefAttr& theTangentPoint,
double theEndX, double theEndY,
}
}
-//==================================================================================================
+//================================================================================================
SketchAPI_Arc::SketchAPI_Arc(const std::shared_ptr<ModelAPI_Feature>& theFeature,
const ModelHighAPI_RefAttr& theTangentPoint,
const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
}
}
-//==================================================================================================
+//================================================================================================
SketchAPI_Arc::SketchAPI_Arc(const std::shared_ptr<ModelAPI_Feature>& theFeature,
const ModelHighAPI_Selection& theExternal)
: SketchAPI_SketchEntity(theFeature)
}
}
-//==================================================================================================
+//================================================================================================
SketchAPI_Arc::SketchAPI_Arc(const std::shared_ptr<ModelAPI_Feature>& theFeature,
const std::string& theExternalName)
: SketchAPI_SketchEntity(theFeature)
}
}
-//==================================================================================================
+//================================================================================================
SketchAPI_Arc::~SketchAPI_Arc()
{
}
-//==================================================================================================
+//================================================================================================
void SketchAPI_Arc::setByCenterStartEnd(double theCenterX, double theCenterY,
double theStartX, double theStartY,
double theEndX, double theEndY,
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,
execute();
}
-//==================================================================================================
+//================================================================================================
void SketchAPI_Arc::setByStartEndPassed(double theStartX, double theStartY,
double theEndX, double theEndY,
double thePassedX, double 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)
execute();
}
-//==================================================================================================
+//================================================================================================
void SketchAPI_Arc::setByTangent(const ModelHighAPI_RefAttr& theTangentPoint,
double theEndX, double theEndY,
bool theInversed)
execute();
}
-//==================================================================================================
+//================================================================================================
void SketchAPI_Arc::setByTangent(const ModelHighAPI_RefAttr& theTangentPoint,
const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
bool theInversed)
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();
}
+
+//================================================================================================
+void SketchAPI_Arc::dump(ModelHighAPI_Dumper& theDumper) const
+{
+ if (isCopy())
+ return; // no need to dump copied feature
+
+ FeaturePtr aBase = feature();
+ const std::string& aSketchName = theDumper.parentName(aBase);
+
+ AttributeSelectionPtr anExternal = aBase->selection(SketchPlugin_SketchEntity::EXTERNAL_ID());
+ if (anExternal->context()) {
+ // 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);
+}