#include <ModelAPI_AttributeSelection.h>
#include <ModelAPI_ResultConstruction.h>
#include <ModelAPI_AttributeString.h>
+#include <ModelAPI_AttributeDouble.h>
#include <GeomAPI_Edge.h>
+#include <GeomAPI_Vertex.h>
#include <GeomAlgoAPI_EdgeBuilder.h>
#include <GeomAlgoAPI_PointBuilder.h>
ModelAPI_AttributeSelection::typeId());
data()->addAttribute(ConstructionPlugin_Axis::CYLINDRICAL_FACE(),
ModelAPI_AttributeSelection::typeId());
+ data()->addAttribute(ConstructionPlugin_Axis::X_DIRECTION(),
+ ModelAPI_AttributeDouble::typeId());
+ data()->addAttribute(ConstructionPlugin_Axis::Y_DIRECTION(),
+ ModelAPI_AttributeDouble::typeId());
+ data()->addAttribute(ConstructionPlugin_Axis::Z_DIRECTION(),
+ ModelAPI_AttributeDouble::typeId());
}
void ConstructionPlugin_Axis::createAxisByTwoPoints()
}
}
+
+void ConstructionPlugin_Axis::createAxisByPointAndDirection()
+{
+ AttributeSelectionPtr aRef1 = data()->selection(ConstructionPlugin_Axis::POINT_FIRST());
+ AttributeDoublePtr aXAttr = data()->real(ConstructionPlugin_Axis::X_DIRECTION());
+ AttributeDoublePtr aYAttr = data()->real(ConstructionPlugin_Axis::Y_DIRECTION());
+ AttributeDoublePtr aZAttr = data()->real(ConstructionPlugin_Axis::Z_DIRECTION());
+ if ((aRef1.get() != NULL) && (aXAttr.get() != NULL) &&
+ (aYAttr.get() != NULL) && (aZAttr.get() != NULL)) {
+ GeomShapePtr aShape1 = aRef1->value();
+ if (!aShape1.get())
+ aShape1 = aRef1->context()->shape();
+
+ std::shared_ptr<GeomAPI_Vertex> aVertex(new GeomAPI_Vertex(aXAttr->value(),
+ aYAttr->value(),
+ aZAttr->value()));
+ if (aShape1->isVertex() && (!aShape1->isEqual(aVertex))) {
+ std::shared_ptr<GeomAPI_Pnt> aStart = GeomAlgoAPI_PointBuilder::point(aShape1);
+ std::shared_ptr<GeomAPI_Pnt> anEnd = GeomAlgoAPI_PointBuilder::point(aVertex);
+ if (aStart->distance(anEnd) > ConstructionPlugin_Axis::MINIMAL_LENGTH()) {
+ std::shared_ptr<GeomAPI_Edge> anEdge = GeomAlgoAPI_EdgeBuilder::line(aStart, anEnd);
+
+ ResultConstructionPtr aConstr = document()->createConstruction(data());
+ aConstr->setInfinite(true);
+ aConstr->setShape(anEdge);
+ setResult(aConstr);
+ }
+ }
+ }
+}
+
+
void ConstructionPlugin_Axis::createAxisByCylindricalFace()
{
std::shared_ptr<GeomAPI_Shape> aSelection = data()->selection(CYLINDRICAL_FACE())->value();
}
}
+
+
void ConstructionPlugin_Axis::execute()
{
AttributeStringPtr aMethodTypeAttr = string(ConstructionPlugin_Axis::METHOD());
createAxisByTwoPoints();
} else if (aMethodType == "AxisByCylindricalFaceCase") {
createAxisByCylindricalFace();
+ } else if (aMethodType == "AxisByPointAndDirection") {
+ createAxisByPointAndDirection();
}
}