1 // Name : ConstructionAPI_Point.cpp
5 // 29/03/16 - Sergey POKHODENKO - Creation of the file
7 #include "ConstructionAPI_Point.h"
9 #include <GeomAPI_Shape.h>
11 #include <ModelHighAPI_Selection.h>
12 #include <ModelHighAPI_Tools.h>
14 //==================================================================================================
15 ConstructionAPI_Point::ConstructionAPI_Point(const std::shared_ptr<ModelAPI_Feature>& theFeature)
16 : ModelHighAPI_Interface(theFeature)
21 //==================================================================================================
22 ConstructionAPI_Point::ConstructionAPI_Point(const std::shared_ptr<ModelAPI_Feature>& theFeature,
23 const ModelHighAPI_Double& theX,
24 const ModelHighAPI_Double& theY,
25 const ModelHighAPI_Double& theZ)
26 : ModelHighAPI_Interface(theFeature)
29 setByXYZ(theX, theY, theZ);
33 /*//==================================================================================================
34 ConstructionAPI_Point::ConstructionAPI_Point(const std::shared_ptr<ModelAPI_Feature>& theFeature,
35 const ModelHighAPI_Selection& theEdge,
36 const ModelHighAPI_Double& theDistanceValue,
37 const bool theDistancePercent,
38 const bool theReverse)
39 : ModelHighAPI_Interface(theFeature)
42 setByDistanceOnEdge(theEdge, theDistanceValue, theDistancePercent, theReverse);
46 //==================================================================================================
47 ConstructionAPI_Point::ConstructionAPI_Point(const std::shared_ptr<ModelAPI_Feature>& theFeature,
48 const ModelHighAPI_Selection& theObject1,
49 const ModelHighAPI_Selection& theObject2)
50 : ModelHighAPI_Interface(theFeature)
53 GeomAPI_Shape::ShapeType aType1 = getShapeType(theObject1);
54 GeomAPI_Shape::ShapeType aType2 = getShapeType(theObject2);
56 if(aType1 == GeomAPI_Shape::VERTEX && aType2 == GeomAPI_Shape::FACE) {
57 // If first object is vertex and second object is face then set by projection.
58 setByProjection(theObject1, theObject2);
59 } else if(aType1 == GeomAPI_Shape::EDGE && aType2 == GeomAPI_Shape::EDGE) {
60 // If both objects are edges then set by lines intersection.
61 setByLinesIntersection(theObject1, theObject2);
62 } else if(aType1 == GeomAPI_Shape::EDGE && aType2 == GeomAPI_Shape::FACE) {
63 // If first object is edge and second object is face then set by line and plane intersection.
64 setByLineAndPlaneIntersection(theObject1, theObject2);
69 //==================================================================================================
70 ConstructionAPI_Point::~ConstructionAPI_Point()
75 //==================================================================================================
76 void ConstructionAPI_Point::setByXYZ(const ModelHighAPI_Double& theX,
77 const ModelHighAPI_Double& theY,
78 const ModelHighAPI_Double& theZ)
80 //fillAttribute(ConstructionPlugin_Point::CREATION_METHOD_BY_XYZ(), mycreationMethod);
81 fillAttribute(theX, myx);
82 fillAttribute(theY, myy);
83 fillAttribute(theZ, myz);
88 /*//==================================================================================================
89 void ConstructionAPI_Point::setByDistanceOnEdge(const ModelHighAPI_Selection& theEdge,
90 const ModelHighAPI_Double& theDistanceValue,
91 const bool theDistancePercent,
92 const bool theReverse)
94 fillAttribute(ConstructionPlugin_Point::CREATION_METHOD_BY_DISTANCE_ON_EDGE(), mycreationMethod);
95 fillAttribute(theEdge, myedge);
96 fillAttribute(theDistanceValue, mydistanceValue);
97 fillAttribute(theDistancePercent, mydistancePercent);
98 fillAttribute(theReverse, myreverse);
103 //==================================================================================================
104 void ConstructionAPI_Point::setByProjection(const ModelHighAPI_Selection& theVertex,
105 const ModelHighAPI_Selection& theFace)
107 fillAttribute(ConstructionPlugin_Point::CREATION_METHOD_BY_PROJECTION(), mycreationMethod);
108 fillAttribute(theVertex, mypoint);
109 fillAttribute(theFace, myplane);
114 //==================================================================================================
115 void ConstructionAPI_Point::setByLinesIntersection(const ModelHighAPI_Selection& theEdge1,
116 const ModelHighAPI_Selection& theEdge2)
118 fillAttribute(ConstructionPlugin_Point::CREATION_METHOD_BY_LINES_INTERSECTION(), mycreationMethod);
119 fillAttribute(theEdge1, myfirstLine);
120 fillAttribute(theEdge2, mysecondLine);
125 //==================================================================================================
126 void ConstructionAPI_Point::setByLineAndPlaneIntersection(const ModelHighAPI_Selection& theEdge,
127 const ModelHighAPI_Selection& theFace)
129 fillAttribute(ConstructionPlugin_Point::CREATION_METHOD_BY_LINE_AND_PLANE_INTERSECTION(), mycreationMethod);
130 fillAttribute(theEdge, myintersectionLine);
131 fillAttribute(theFace, myintersectionPlane);
136 //==================================================================================================
137 PointPtr addPoint(const std::shared_ptr<ModelAPI_Document>& thePart,
138 const ModelHighAPI_Double& theX,
139 const ModelHighAPI_Double& theY,
140 const ModelHighAPI_Double& theZ)
142 // TODO(spo): check that thePart is not empty
143 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Point::ID());
144 return PointPtr(new ConstructionAPI_Point(aFeature, theX, theY, theZ));
147 /*//==================================================================================================
148 PointPtr addPoint(const std::shared_ptr<ModelAPI_Document> & thePart,
149 const ModelHighAPI_Selection& theEdge,
150 const ModelHighAPI_Double& theDistanceValue,
151 const bool theDistancePercent,
152 const bool theReverse)
154 // TODO(spo): check that thePart is not empty
155 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Point::ID());
156 return PointPtr(new ConstructionAPI_Point(aFeature, theEdge, theDistanceValue, theDistancePercent, theReverse));
159 //==================================================================================================
160 PointPtr addPoint(const std::shared_ptr<ModelAPI_Document> & thePart,
161 const ModelHighAPI_Selection& theObject1,
162 const ModelHighAPI_Selection& theObject2)
164 // TODO(spo): check that thePart is not empty
165 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Point::ID());
166 return PointPtr(new ConstructionAPI_Point(aFeature, theObject1, theObject2));