1 // Name : ConstructionAPI_Point.cpp
5 // 29/03/16 - Sergey POKHODENKO - Creation of the file
7 #include "ConstructionAPI_Point.h"
9 #include <ModelHighAPI_Tools.h>
11 //==================================================================================================
12 ConstructionAPI_Point::ConstructionAPI_Point(const std::shared_ptr<ModelAPI_Feature>& theFeature)
13 : ModelHighAPI_Interface(theFeature)
18 //==================================================================================================
19 ConstructionAPI_Point::ConstructionAPI_Point(const std::shared_ptr<ModelAPI_Feature>& theFeature,
20 const ModelHighAPI_Double& theX,
21 const ModelHighAPI_Double& theY,
22 const ModelHighAPI_Double& theZ)
23 : ModelHighAPI_Interface(theFeature)
26 setByXYZ(theX, theY, theZ);
30 //==================================================================================================
31 ConstructionAPI_Point::ConstructionAPI_Point(const std::shared_ptr<ModelAPI_Feature>& theFeature,
32 const ModelHighAPI_Selection& theEdge,
33 const ModelHighAPI_Double& theDistanceValue,
34 const bool theDistancePercent,
35 const bool theReverse)
36 : ModelHighAPI_Interface(theFeature)
39 setByDistanceOnEdge(theEdge, theDistanceValue, theDistancePercent, theReverse);
43 //==================================================================================================
44 ConstructionAPI_Point::ConstructionAPI_Point(const std::shared_ptr<ModelAPI_Feature>& theFeature,
45 const ModelHighAPI_Selection& theObject1,
46 const ModelHighAPI_Selection& theObject2)
47 : ModelHighAPI_Interface(theFeature)
50 /// If first object is vertex and second object is face then set by projection.
52 setByProjection(theObject1, theObject2);
56 //==================================================================================================
57 ConstructionAPI_Point::~ConstructionAPI_Point()
62 //==================================================================================================
63 void ConstructionAPI_Point::setByXYZ(const ModelHighAPI_Double& theX,
64 const ModelHighAPI_Double& theY,
65 const ModelHighAPI_Double& theZ)
67 fillAttribute(ConstructionPlugin_Point::CREATION_METHOD_BY_XYZ(), mycreationMethod);
68 fillAttribute(theX, myx);
69 fillAttribute(theY, myy);
70 fillAttribute(theZ, myz);
75 //==================================================================================================
76 void ConstructionAPI_Point::setByDistanceOnEdge(const ModelHighAPI_Selection& theEdge,
77 const ModelHighAPI_Double& theDistanceValue,
78 const bool theDistancePercent,
79 const bool theReverse)
81 fillAttribute(ConstructionPlugin_Point::CREATION_METHOD_BY_DISTANCE_ON_EDGE(), mycreationMethod);
82 fillAttribute(theEdge, myedge);
83 fillAttribute(theDistanceValue, mydistanceValue);
84 fillAttribute(theDistancePercent, mydistancePercent);
85 fillAttribute(theReverse, myreverse);
90 //==================================================================================================
91 void ConstructionAPI_Point::setByProjection(const ModelHighAPI_Selection& theVertex,
92 const ModelHighAPI_Selection& thePlane)
94 fillAttribute(ConstructionPlugin_Point::CREATION_METHOD_BY_PROJECTION(), mycreationMethod);
95 fillAttribute(theVertex, mypoint);
96 fillAttribute(thePlane, myplane);
101 //==================================================================================================
102 PointPtr addPoint(const std::shared_ptr<ModelAPI_Document>& thePart,
103 const ModelHighAPI_Double& theX,
104 const ModelHighAPI_Double& theY,
105 const ModelHighAPI_Double& theZ)
107 // TODO(spo): check that thePart is not empty
108 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Point::ID());
109 return PointPtr(new ConstructionAPI_Point(aFeature, theX, theY, theZ));
112 //==================================================================================================
113 PointPtr addPoint(const std::shared_ptr<ModelAPI_Document> & thePart,
114 const ModelHighAPI_Selection& theEdge,
115 const ModelHighAPI_Double& theDistanceValue,
116 const bool theDistancePercent,
117 const bool theReverse)
119 // TODO(spo): check that thePart is not empty
120 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Point::ID());
121 return PointPtr(new ConstructionAPI_Point(aFeature, theEdge, theDistanceValue, theDistancePercent, theReverse));
124 //==================================================================================================
125 PointPtr addPoint(const std::shared_ptr<ModelAPI_Document> & thePart,
126 const ModelHighAPI_Selection& theObject1,
127 const ModelHighAPI_Selection& theObject2)
129 // TODO(spo): check that thePart is not empty
130 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Point::ID());
131 return PointPtr(new ConstructionAPI_Point(aFeature, theObject1, theObject2));