#include "ConstructionAPI_Point.h"
+#include <GeomAPI_Pnt.h>
#include <GeomAPI_Shape.h>
+#include <GeomAPI_Vertex.h>
+#include <ModelHighAPI_Double.h>
#include <ModelHighAPI_Dumper.h>
#include <ModelHighAPI_Selection.h>
#include <ModelHighAPI_Tools.h>
}
}
+//==================================================================================================
+ConstructionAPI_Point::ConstructionAPI_Point(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const ModelHighAPI_Selection& theObject,
+ const bool theIsCircularEdge)
+: ModelHighAPI_Interface(theFeature)
+{
+ if (initialize())
+ {
+ if (theIsCircularEdge) {
+ setByCenterOfCircle(theObject);
+ } else if (theObject.shapeType() == "VERTEX") {
+ // This is tricky way to get vertex shape.
+ fillAttribute(theObject, mypointToProject);
+ GeomShapePtr aShape = mypointToProject->value();
+ if (!aShape.get()) {
+ ResultPtr aContext = mypointToProject->context();
+ if (!aContext.get()) {
+ fillAttribute(ModelHighAPI_Selection(), mypointToProject);
+ return;
+ }
+ aShape = aContext->shape();
+ }
+
+ if (!aShape.get()) {
+ fillAttribute(ModelHighAPI_Selection(), mypointToProject);
+ return;
+ }
+
+ GeomVertexPtr aVertex = aShape->vertex();
+ if (!aVertex.get()) {
+ fillAttribute(ModelHighAPI_Selection(), mypointToProject);
+ return;
+ }
+
+ GeomPointPtr aPnt = aVertex->point();
+ if (!aPnt.get()) {
+ fillAttribute(ModelHighAPI_Selection(), mypointToProject);
+ return;
+ }
+
+ fillAttribute(ModelHighAPI_Selection(), mypointToProject);
+ setByXYZ(aPnt->x(), aPnt->y(), aPnt->z());
+ } else {
+ setByCenterOfGravity(theObject);
+ }
+ }
+}
+
//==================================================================================================
ConstructionAPI_Point::~ConstructionAPI_Point()
{
const ModelHighAPI_Double& theZ)
{
//fillAttribute(ConstructionPlugin_Point::CREATION_METHOD_BY_XYZ(), mycreationMethod);
- fillAttribute(theX, myx);
- fillAttribute(theY, myy);
- fillAttribute(theZ, myz);
+
+ // TODO: Fill point attribute
+ //fillAttribute(theX, myx);
+ //fillAttribute(theY, myy);
+ //fillAttribute(theZ, myz);
+
fillAttribute(ConstructionPlugin_Point::CREATION_METHOD_BY_XYZ(), mycreationMethod);
+ fillAttribute(theX, theY, theZ, mypoint);
execute(false);
}
mycreationMethod);
fillAttribute(ConstructionPlugin_Point::PROJECTION_TYPE_ON_EDGE(),
myprojectionType);
- fillAttribute(theVertex, mypoinToProject);
+ fillAttribute(theVertex, mypointToProject);
fillAttribute(theEdge, myedgeForPointProjection);
execute();
mycreationMethod);
fillAttribute(ConstructionPlugin_Point::PROJECTION_TYPE_ON_FACE(),
myprojectionType);
- fillAttribute(theVertex, mypoinToProject);
+ fillAttribute(theVertex, mypointToProject);
fillAttribute(theFace, myfaceForPointProjection);
execute();
execute();
}
+//==================================================================================================
+void ConstructionAPI_Point::setByCenterOfGravity(const ModelHighAPI_Selection& theObject)
+{
+ fillAttribute(ConstructionPlugin_Point::CREATION_METHOD_BY_GEOMETRICAL_PROPERTY(),
+ mycreationMethod);
+ fillAttribute(ConstructionPlugin_Point::GEOMETRICAL_PROPERTY_TYPE_BY_CENTER_OF_GRAVITY(),
+ mygeometricalPropertyType);
+ fillAttribute(theObject, myobjectForCenterOfGravity);
+}
+
+//==================================================================================================
+void ConstructionAPI_Point::setByCenterOfCircle(const ModelHighAPI_Selection& theObject)
+{
+ fillAttribute(ConstructionPlugin_Point::CREATION_METHOD_BY_GEOMETRICAL_PROPERTY(),
+ mycreationMethod);
+ fillAttribute(ConstructionPlugin_Point::GEOMETRICAL_PROPERTY_TYPE_BY_CENTER_OF_CIRCLE(),
+ mygeometricalPropertyType);
+ fillAttribute(theObject, myobjectForCenterOfCircle);
+}
+
//==================================================================================================
void ConstructionAPI_Point::dump(ModelHighAPI_Dumper& theDumper) const
{
if (aMeth == "" || // default is XYZ
aMeth == ConstructionPlugin_Point::CREATION_METHOD_BY_XYZ()) {
- theDumper << x() << ", " << y() << ", " << z();
+ theDumper << point();
} else if (aMeth == ConstructionPlugin_Point::CREATION_METHOD_BY_INTERSECTION()) {
const std::string anIntersectionType = intersectionType()->value();
if (anIntersectionType == ConstructionPlugin_Point::INTERSECTION_TYPE_BY_LINES())
}
theDumper << ", " << reverse()->value();
} else if (aMeth == ConstructionPlugin_Point::CREATION_METHOD_BY_PROJECTION()) {
- theDumper << mypoinToProject << ", ";
+ theDumper << pointToProject() << ", ";
if (projectionType()->value() == ConstructionPlugin_Point::PROJECTION_TYPE_ON_EDGE()) {
- theDumper << myedgeForPointProjection;
+ theDumper << edgeForPointProjection();
} else {
- theDumper << myfaceForPointProjection;
+ theDumper << faceForPointProjection();
+ }
+ } else if (aMeth == ConstructionPlugin_Point::CREATION_METHOD_BY_GEOMETRICAL_PROPERTY()) {
+ if (geometricalPropertyType()->value() ==
+ ConstructionPlugin_Point::GEOMETRICAL_PROPERTY_TYPE_BY_CENTER_OF_GRAVITY())
+ {
+ theDumper << objectForCenterOfGravity();
+ }
+ else
+ {
+ theDumper << objectForCenterOfCircle() << ", " << true;
}
}
std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Point::ID());
return PointPtr(new ConstructionAPI_Point(aFeature, theObject1, theObject2, theObject3));
}
+
+//==================================================================================================
+PointPtr addPoint(const std::shared_ptr<ModelAPI_Document> & thePart,
+ const ModelHighAPI_Selection& theObject,
+ const bool theIsCircularEdge)
+{
+ std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Point::ID());
+ return PointPtr(new ConstructionAPI_Point(aFeature, theObject, theIsCircularEdge));
+}