Added dump for Construction features Axis and Plane.
#include "ConstructionAPI_Axis.h"
+#include <ModelHighAPI_Dumper.h>
#include <ModelHighAPI_Tools.h>
//==================================================================================================
execute();
}
+//==================================================================================================
+void ConstructionAPI_Axis::dump(ModelHighAPI_Dumper& theDumper) const
+{
+ FeaturePtr aBase = feature();
+ const std::string& aDocName = theDumper.name(aBase->document());
+
+ theDumper << aBase << " = model.addAxis(" << aDocName;
+
+ std::string aCreationMethod = aBase->string(ConstructionPlugin_Axis::METHOD())->value();
+
+ if(aCreationMethod == ConstructionPlugin_Axis::CREATION_METHOD_BY_DIMENSIONS()) {
+ AttributeDoublePtr anAttrDX = aBase->real(ConstructionPlugin_Axis::DX());
+ AttributeDoublePtr anAttrDY = aBase->real(ConstructionPlugin_Axis::DY());
+ AttributeDoublePtr anAttrDZ = aBase->real(ConstructionPlugin_Axis::DZ());
+
+ theDumper << ", " << anAttrDX << ", " << anAttrDY << ", " << anAttrDZ;
+ } else if(aCreationMethod == ConstructionPlugin_Axis::CREATION_METHOD_BY_TWO_POINTS()) {
+ AttributeSelectionPtr anAttrFirstPnt = aBase->selection(ConstructionPlugin_Axis::POINT_FIRST());
+ AttributeSelectionPtr anAttrSecondPnt = aBase->selection(ConstructionPlugin_Axis::POINT_SECOND());
+
+ theDumper << ", " << anAttrFirstPnt << ", " << anAttrSecondPnt;
+ } else if(aCreationMethod == ConstructionPlugin_Axis::CREATION_METHOD_BY_LINE()) {
+ AttributeSelectionPtr anAttrLine = aBase->selection(ConstructionPlugin_Axis::LINE());
+
+ theDumper << ", " << anAttrLine;
+ } else if(aCreationMethod == ConstructionPlugin_Axis::CREATION_METHOD_BY_CYLINDRICAL_FACE()) {
+ AttributeSelectionPtr anAttrFace = aBase->selection(ConstructionPlugin_Axis::CYLINDRICAL_FACE());
+
+ theDumper << ", " << anAttrFace;
+ } else if(aCreationMethod == ConstructionPlugin_Axis::CREATION_METHOD_BY_PLANE_AND_POINT()) {
+ AttributeSelectionPtr anAttrPlane = aBase->selection(ConstructionPlugin_Axis::PLANE());
+ AttributeSelectionPtr anAttrPoint = aBase->selection(ConstructionPlugin_Axis::POINT());
+
+ theDumper << ", " << anAttrPlane << ", " << anAttrPoint;
+ } else if(aCreationMethod == ConstructionPlugin_Axis::CREATION_METHOD_BY_TWO_PLANES()) {
+ AttributeSelectionPtr anAttrPlane1 = aBase->selection(ConstructionPlugin_Axis::PLANE1());
+ AttributeDoublePtr anAttrOffset1 = aBase->real(ConstructionPlugin_Axis::OFFSET1());
+ AttributeBooleanPtr anAttrReverseOffset1 = aBase->boolean(ConstructionPlugin_Axis::REVERSE_OFFSET1());
+ AttributeSelectionPtr anAttrPlane2 = aBase->selection(ConstructionPlugin_Axis::PLANE2());
+ AttributeDoublePtr anAttrOffset2 = aBase->real(ConstructionPlugin_Axis::OFFSET2());
+ AttributeBooleanPtr anAttrReverseOffset2 = aBase->boolean(ConstructionPlugin_Axis::REVERSE_OFFSET2());
+
+ theDumper << ", " << anAttrPlane1 << ", " << anAttrOffset1 << ", " << anAttrReverseOffset1
+ << ", " << anAttrPlane2 << ", " << anAttrOffset2 << ", " << anAttrReverseOffset2;
+ } else if(aCreationMethod == ConstructionPlugin_Axis::CREATION_METHOD_BY_POINT_AND_DIRECTION()) {
+ AttributeSelectionPtr anAttrFirstPnt = aBase->selection(ConstructionPlugin_Axis::POINT_FIRST());
+ AttributeDoublePtr anAttrX = aBase->real(ConstructionPlugin_Axis::X_DIRECTION());
+ AttributeDoublePtr anAttrY = aBase->real(ConstructionPlugin_Axis::Y_DIRECTION());
+ AttributeDoublePtr anAttrZ = aBase->real(ConstructionPlugin_Axis::Z_DIRECTION());
+
+ theDumper << ", " << anAttrFirstPnt << ", " << anAttrX << ", " << anAttrY << ", " << anAttrZ;
+ }
+
+ theDumper << ")" << std::endl;
+}
+
//==================================================================================================
AxisPtr addAxis(const std::shared_ptr<ModelAPI_Document>& thePart,
- const ModelHighAPI_Selection& thePoint1,
- const ModelHighAPI_Selection& thePoint2)
+ const ModelHighAPI_Selection& theObject1,
+ const ModelHighAPI_Selection& theObject2)
{
// TODO(spo): check that thePart is not empty
std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Axis::ID());
- return AxisPtr(new ConstructionAPI_Axis(aFeature, thePoint1, thePoint2));
+ return AxisPtr(new ConstructionAPI_Axis(aFeature, theObject1, theObject2));
}
//==================================================================================================
const ModelHighAPI_Selection& thePlane2,
const ModelHighAPI_Double& theOffset2,
const bool theReverseOffset2);
+
+ /// Dump wrapped feature
+ CONSTRUCTIONAPI_EXPORT
+ virtual void dump(ModelHighAPI_Dumper& theDumper) const;
};
/// Pointer on Axis object
#include "ConstructionAPI_Plane.h"
+#include <ModelHighAPI_Dumper.h>
#include <ModelHighAPI_Tools.h>
//==================================================================================================
execute();
}
+//==================================================================================================
+void ConstructionAPI_Plane::dump(ModelHighAPI_Dumper& theDumper) const
+{
+ FeaturePtr aBase = feature();
+ const std::string& aDocName = theDumper.name(aBase->document());
+
+ theDumper << aBase << " = model.addPlane(" << aDocName;
+
+ std::string aCreationMethod = aBase->string(ConstructionPlugin_Plane::CREATION_METHOD())->value();
+
+ if(aCreationMethod == ConstructionPlugin_Plane::CREATION_METHOD_BY_GENERAL_EQUATION()) {
+ AttributeDoublePtr anAttrA = aBase->real(ConstructionPlugin_Plane::A());
+ AttributeDoublePtr anAttrB = aBase->real(ConstructionPlugin_Plane::B());
+ AttributeDoublePtr anAttrC = aBase->real(ConstructionPlugin_Plane::C());
+ AttributeDoublePtr anAttrD = aBase->real(ConstructionPlugin_Plane::D());
+
+ theDumper << ", " << anAttrA << ", " << anAttrB << ", " << anAttrC << ", " << anAttrD;
+ } else if(aCreationMethod == ConstructionPlugin_Plane::CREATION_METHOD_BY_THREE_POINTS()) {
+ AttributeSelectionPtr anAttrPnt1 = aBase->selection(ConstructionPlugin_Plane::POINT1());
+ AttributeSelectionPtr anAttrPnt2 = aBase->selection(ConstructionPlugin_Plane::POINT2());
+ AttributeSelectionPtr anAttrPnt3 = aBase->selection(ConstructionPlugin_Plane::POINT3());
+
+ theDumper << ", " << anAttrPnt1 << ", " << anAttrPnt2 << ", " << anAttrPnt3;
+ } else if(aCreationMethod == ConstructionPlugin_Plane::CREATION_METHOD_BY_LINE_AND_POINT()) {
+ AttributeSelectionPtr anAttrLine = aBase->selection(ConstructionPlugin_Plane::LINE());
+ AttributeSelectionPtr anAttrPoint = aBase->selection(ConstructionPlugin_Plane::POINT());
+ AttributeBooleanPtr anAttrPerpendicular = aBase->boolean(ConstructionPlugin_Plane::PERPENDICULAR());
+
+ theDumper << ", " << anAttrLine << ", " << anAttrPoint << ", " << anAttrPerpendicular;
+ } else if(aCreationMethod == ConstructionPlugin_Plane::CREATION_METHOD_BY_OTHER_PLANE()) {
+ AttributeSelectionPtr anAttrPlane = aBase->selection(ConstructionPlugin_Plane::PLANE());
+
+ std::string aCreationMethodOption =
+ aBase->string(ConstructionPlugin_Plane::CREATION_METHOD_BY_OTHER_PLANE_OPTION())->value();
+ if(aCreationMethodOption == ConstructionPlugin_Plane::CREATION_METHOD_BY_DISTANCE_FROM_OTHER()) {
+ AttributeDoublePtr anAttrDistance = aBase->real(ConstructionPlugin_Plane::DISTANCE());
+ AttributeBooleanPtr anAttrReverse = aBase->boolean(ConstructionPlugin_Plane::REVERSE());
+
+ theDumper << ", " << anAttrPlane << ", " << anAttrDistance << ", " << anAttrReverse;
+ } else if(aCreationMethodOption == ConstructionPlugin_Plane::CREATION_METHOD_BY_COINCIDENT_TO_POINT()) {
+ AttributeSelectionPtr anAttrPoint = aBase->selection(ConstructionPlugin_Plane::COINCIDENT_POINT());
+
+ theDumper << ", " << anAttrPlane << ", " << anAttrPoint;
+ } else if(aCreationMethodOption == ConstructionPlugin_Plane::CREATION_METHOD_BY_ROTATION()) {
+ AttributeSelectionPtr anAttrAxis = aBase->selection(ConstructionPlugin_Plane::AXIS());
+ AttributeDoublePtr anAttrAngle = aBase->real(ConstructionPlugin_Plane::ANGLE());
+
+ theDumper << ", " << anAttrPlane << ", " << anAttrAxis << ", " << anAttrAngle;
+ }
+ } else if(aCreationMethod == ConstructionPlugin_Plane::CREATION_METHOD_BY_TWO_PARALLEL_PLANES()) {
+ AttributeSelectionPtr anAttrPlane1 = aBase->selection(ConstructionPlugin_Plane::PLANE1());
+ AttributeSelectionPtr anAttrPlane2 = aBase->selection(ConstructionPlugin_Plane::PLANE2());
+
+ theDumper << ", " << anAttrPlane1 << ", " << anAttrPlane2;
+ }
+
+ theDumper << ")" << std::endl;
+}
+
//==================================================================================================
PlanePtr addPlane(const std::shared_ptr<ModelAPI_Document>& thePart,
const ModelHighAPI_Selection& theFace,
const ModelHighAPI_Selection& theAxis,
const ModelHighAPI_Double& theAngle);
+ /// Dump wrapped feature
+ CONSTRUCTIONAPI_EXPORT
+ virtual void dump(ModelHighAPI_Dumper& theDumper) const;
};
/// Pointer on Plane object
switch(aShapeType) {
case COMPOUND: {
- aShapeTypeStr = "Compound";
+ aShapeTypeStr = "COMPOUND";
break;
}
case COMPSOLID: {
- aShapeTypeStr = "CompSolid";
+ aShapeTypeStr = "COMPSOLID";
break;
}
case SOLID: {
- aShapeTypeStr = "Solid";
+ aShapeTypeStr = "SOLID";
break;
}
case SHELL: {
- aShapeTypeStr = "Shell";
+ aShapeTypeStr = "SHELL";
break;
}
case FACE: {
- aShapeTypeStr = "Face";
+ aShapeTypeStr = "FACE";
break;
}
case WIRE: {
- aShapeTypeStr = "Wire";
+ aShapeTypeStr = "WIRE";
break;
}
case EDGE: {
- aShapeTypeStr = "Edge";
+ aShapeTypeStr = "EDGE";
break;
}
case VERTEX: {
- aShapeTypeStr = "Vertex";
+ aShapeTypeStr = "VERTEX";
break;
}
case SHAPE: {
- aShapeTypeStr = "Shape";
+ aShapeTypeStr = "SHAPE";
break;
}
}
ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(
const std::shared_ptr<ModelAPI_AttributeSelection>& theAttrSelect)
{
- myDumpBuffer << "\"" << theAttrSelect->namingName() << "\"";
+ GeomShapePtr aShape = theAttrSelect->value();
+ if(!aShape.get()) {
+ aShape = theAttrSelect->context()->shape();
+ }
+
+ if(!aShape.get()) {
+ return *this;
+ }
+
+ std::string aShapeTypeStr = aShape->shapeTypeStr();
+
+ myDumpBuffer << "model.selection(\"" << aShapeTypeStr << "\", \"" << theAttrSelect->namingName() << "\")";
return *this;
}
}
//==================================================================================================
-GeomAPI_Shape::ShapeType shapeTypeByStr(const std::string& theShapeTypeStr)
+GeomAPI_Shape::ShapeType shapeTypeByStr(std::string theShapeTypeStr)
{
GeomAPI_Shape::ShapeType aShapeType = GeomAPI_Shape::SHAPE;
- std::string aShapeTypeStr = theShapeTypeStr;
- std::transform(aShapeTypeStr.begin(), aShapeTypeStr.end(), aShapeTypeStr.begin(), ::tolower);
+ std::transform(theShapeTypeStr.begin(), theShapeTypeStr.end(), theShapeTypeStr.begin(), ::tolower);
if(theShapeTypeStr == "compound") {
aShapeType = GeomAPI_Shape::COMPOUND;
const std::shared_ptr<ModelAPI_AttributeString> & theAttribute);
MODELHIGHAPI_EXPORT
-GeomAPI_Shape::ShapeType shapeTypeByStr(const std::string& theShapeTypeStr);
+GeomAPI_Shape::ShapeType shapeTypeByStr(std::string theShapeTypeStr);
MODELHIGHAPI_EXPORT
GeomAPI_Shape::ShapeType getShapeType(const ModelHighAPI_Selection& theSelection);
from ModelHighAPI import begin, end
from ModelHighAPI import apply as do
from ModelHighAPI import undo, redo
-from ModelHighAPI import reset
\ No newline at end of file
+from ModelHighAPI import reset
+from ModelHighAPI import ModelHighAPI_Selection as selection