1 // Name : SketchAPI_Sketch.h
5 // 07/06/16 - Sergey POKHODENKO - Creation of the file
7 #ifndef SRC_SKETCHAPI_SKETCHAPI_SKETCH_H_
8 #define SRC_SKETCHAPI_SKETCHAPI_SKETCH_H_
10 //--------------------------------------------------------------------------------------
11 #include "SketchAPI.h"
15 #include <SketchPlugin_Sketch.h>
16 #include <SketchPlugin_SketchEntity.h>
18 #include <ModelHighAPI_Interface.h>
19 #include <ModelHighAPI_Macro.h>
20 //--------------------------------------------------------------------------------------
21 class ModelAPI_CompositeFeature;
22 class ModelAPI_Object;
23 class ModelHighAPI_Double;
24 class ModelHighAPI_Integer;
25 class ModelHighAPI_RefAttr;
26 class ModelHighAPI_Selection;
28 class SketchAPI_Circle;
29 class SketchAPI_IntersectionPoint;
31 class SketchAPI_Mirror;
32 class SketchAPI_Point;
33 class SketchAPI_Projection;
34 class SketchAPI_Rectangle;
35 class SketchAPI_Rotation;
36 class SketchAPI_Translation;
37 //--------------------------------------------------------------------------------------
38 /**\class SketchAPI_Sketch
40 * \brief Interface for Sketch feature
42 class SketchAPI_Sketch : public ModelHighAPI_Interface
45 /// Constructor without values
47 explicit SketchAPI_Sketch(const std::shared_ptr<ModelAPI_Feature> & theFeature);
48 /// Constructor with values
50 SketchAPI_Sketch(const std::shared_ptr<ModelAPI_Feature> & theFeature,
51 const std::shared_ptr<GeomAPI_Ax3> & thePlane);
52 /// Constructor with values
54 SketchAPI_Sketch(const std::shared_ptr<ModelAPI_Feature> & theFeature,
55 const ModelHighAPI_Selection & theExternal);
58 virtual ~SketchAPI_Sketch();
60 INTERFACE_7(SketchPlugin_Sketch::ID(),
61 origin, SketchPlugin_Sketch::ORIGIN_ID(), GeomDataAPI_Point, /** Origin point */,
62 dirX, SketchPlugin_Sketch::DIRX_ID(), GeomDataAPI_Dir, /** Direction of X */,
63 normal, SketchPlugin_Sketch::NORM_ID(), GeomDataAPI_Dir, /** Normal */,
64 features, SketchPlugin_Sketch::FEATURES_ID(), ModelAPI_AttributeRefList, /** Features */,
65 external, SketchPlugin_SketchEntity::EXTERNAL_ID(), ModelAPI_AttributeSelection, /** External */,
66 solverError, SketchPlugin_Sketch::SOLVER_ERROR(), ModelAPI_AttributeString, /** Solver error */,
67 solverDOF, SketchPlugin_Sketch::SOLVER_DOF(), ModelAPI_AttributeString, /** Solver DOF */
72 void setPlane(const std::shared_ptr<GeomAPI_Ax3> & thePlane);
76 void setExternal(const ModelHighAPI_Selection & theExternal);
78 // TODO(spo): addIntersection
82 std::shared_ptr<SketchAPI_Point> addPoint(
83 double theX, double theY);
86 std::shared_ptr<SketchAPI_Point> addPoint(
87 const std::shared_ptr<GeomAPI_Pnt2d> & thePoint);
90 std::shared_ptr<SketchAPI_Point> addPoint(const ModelHighAPI_Selection & theExternal);
93 std::shared_ptr<SketchAPI_Point> addPoint(const std::string & theExternalName);
95 /// Add intersection point
97 std::shared_ptr<SketchAPI_IntersectionPoint> addIntersectionPoint(const ModelHighAPI_Selection & theExternal);
100 std::shared_ptr<SketchAPI_IntersectionPoint> addIntersectionPoint(const std::string & theExternalName);
104 std::shared_ptr<SketchAPI_Line> addLine(
105 double theX1, double theY1, double theX2, double theY2);
108 std::shared_ptr<SketchAPI_Line> addLine(
109 const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
110 const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint);
113 std::shared_ptr<SketchAPI_Line> addLine(const ModelHighAPI_Selection & theExternal);
116 std::shared_ptr<SketchAPI_Line> addLine(const std::string & theExternalName);
120 std::shared_ptr<SketchAPI_Rectangle> addRectangle(
121 double theX1, double theY1, double theX2, double theY2);
124 std::shared_ptr<SketchAPI_Rectangle> addRectangle(
125 const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
126 const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint);
130 std::shared_ptr<SketchAPI_Circle> addCircle(
131 double theCenterX, double theCenterY,
135 std::shared_ptr<SketchAPI_Circle> addCircle(
136 const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
140 std::shared_ptr<SketchAPI_Circle> addCircle(
141 double theX1, double theY1,
142 double theX2, double theY2,
143 double theX3, double theY3);
146 std::shared_ptr<SketchAPI_Circle> addCircle(
147 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint1,
148 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint2,
149 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint3);
152 std::shared_ptr<SketchAPI_Circle> addCircle(const ModelHighAPI_Selection & theExternal);
155 std::shared_ptr<SketchAPI_Circle> addCircle(const std::string & theExternalName);
159 std::shared_ptr<SketchAPI_Arc> addArc(
160 double theCenterX, double theCenterY,
161 double theStartX, double theStartY,
162 double theEndX, double theEndY,
167 std::shared_ptr<SketchAPI_Arc> addArc(
168 const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
169 const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
170 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
175 std::shared_ptr<SketchAPI_Arc> addArc(
176 double theStartX, double theStartY,
177 double theEndX, double theEndY,
178 double thePassedX, double thePassedY);
182 std::shared_ptr<SketchAPI_Arc> addArc(
183 const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
184 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
185 const std::shared_ptr<GeomAPI_Pnt2d>& thePassed);
189 std::shared_ptr<SketchAPI_Arc> addArc(
190 const ModelHighAPI_RefAttr& theTangentPoint,
191 double theEndX, double theEndY,
196 std::shared_ptr<SketchAPI_Arc> addArc(
197 const ModelHighAPI_RefAttr& theTangentPoint,
198 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
203 std::shared_ptr<SketchAPI_Arc> addArc(const ModelHighAPI_Selection & theExternal);
207 std::shared_ptr<SketchAPI_Arc> addArc(const std::string & theExternalName);
211 std::shared_ptr<SketchAPI_Projection> addProjection(
212 const ModelHighAPI_Selection & theExternalFeature);
216 std::shared_ptr<SketchAPI_Mirror> addMirror(
217 const ModelHighAPI_RefAttr & theMirrorLine,
218 const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects);
222 std::shared_ptr<SketchAPI_Translation> addTranslation(
223 const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects,
224 const ModelHighAPI_RefAttr & thePoint1,
225 const ModelHighAPI_RefAttr & thePoint2,
226 const ModelHighAPI_Integer & theNumberOfObjects,
227 bool theFullValue = false);
231 std::shared_ptr<SketchAPI_Rotation> addRotation(
232 const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects,
233 const ModelHighAPI_RefAttr & theCenter,
234 const ModelHighAPI_Double & theAngle,
235 const ModelHighAPI_Integer & theNumberOfObjects,
236 bool theFullValue = false);
240 std::shared_ptr<ModelAPI_Feature> setAngle(
241 const ModelHighAPI_RefAttr & theLine1,
242 const ModelHighAPI_RefAttr & theLine2,
243 const ModelHighAPI_Double & theValue);
247 std::shared_ptr<ModelAPI_Feature> setCoincident(
248 const ModelHighAPI_RefAttr & thePoint1,
249 const ModelHighAPI_RefAttr & thePoint2);
253 std::shared_ptr<ModelAPI_Feature> setCollinear(
254 const ModelHighAPI_RefAttr & theLine1,
255 const ModelHighAPI_RefAttr & theLine2);
259 std::shared_ptr<ModelAPI_Feature> setDistance(
260 const ModelHighAPI_RefAttr & thePoint,
261 const ModelHighAPI_RefAttr & thePointOrLine,
262 const ModelHighAPI_Double & theValue);
266 std::shared_ptr<ModelAPI_Feature> setEqual(
267 const ModelHighAPI_RefAttr & theObject1,
268 const ModelHighAPI_RefAttr & theObject2);
272 std::shared_ptr<ModelAPI_Feature> setFillet(
273 const std::list<ModelHighAPI_RefAttr> & thePoints,
274 const ModelHighAPI_Double & theRadius);
278 std::shared_ptr<ModelAPI_Feature> setHorizontal(
279 const ModelHighAPI_RefAttr & theLine);
283 std::shared_ptr<ModelAPI_Feature> setLength(
284 const ModelHighAPI_RefAttr & theLine,
285 const ModelHighAPI_Double & theValue);
289 std::shared_ptr<ModelAPI_Feature> setMiddlePoint(
290 const ModelHighAPI_RefAttr & thePoint,
291 const ModelHighAPI_RefAttr & theLine);
295 std::shared_ptr<ModelAPI_Feature> setParallel(
296 const ModelHighAPI_RefAttr & theLine1,
297 const ModelHighAPI_RefAttr & theLine2);
299 /// Set perpendicular
301 std::shared_ptr<ModelAPI_Feature> setPerpendicular(
302 const ModelHighAPI_RefAttr & theLine1,
303 const ModelHighAPI_RefAttr & theLine2);
307 std::shared_ptr<ModelAPI_Feature> setRadius(
308 const ModelHighAPI_RefAttr & theCircleOrArc,
309 const ModelHighAPI_Double & theValue);
313 std::shared_ptr<ModelAPI_Feature> setRigid(
314 const ModelHighAPI_RefAttr & theObject);
318 std::shared_ptr<ModelAPI_Feature> setTangent(
319 const ModelHighAPI_RefAttr & theLine,
320 const ModelHighAPI_RefAttr & theCircle);
324 std::shared_ptr<ModelAPI_Feature> setVertical(
325 const ModelHighAPI_RefAttr & theLine);
327 // TODO(spo): addRectagle, projection
329 /// Set constraint value
332 const std::shared_ptr<ModelAPI_Feature> & theConstraint,
333 const ModelHighAPI_Double & theValue);
335 // TODO(spo): setText. Is it necessary as setValue accepts text expressions?
337 // TODO(spo): rename to selectFaces() or faces() (or add faces() -> list to SWIG)
340 std::list<ModelHighAPI_Selection> selectFace() const;
343 std::shared_ptr<ModelAPI_CompositeFeature> compositeFeature() const;
347 //! Pointer on Sketch object
348 typedef std::shared_ptr<SketchAPI_Sketch> SketchPtr;
350 /**\ingroup CPPHighAPI
351 * \brief Create Sketch feature
354 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
355 const std::shared_ptr<GeomAPI_Ax3> & thePlane);
357 /**\ingroup CPPHighAPI
358 * \brief Create Sketch feature
361 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
362 const ModelHighAPI_Selection & theExternal);
364 /**\ingroup CPPHighAPI
365 * \brief Create Sketch feature
368 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
369 const std::string & theExternalName);
371 //--------------------------------------------------------------------------------------
372 //--------------------------------------------------------------------------------------
373 #endif /* SRC_SKETCHAPI_SKETCHAPI_SKETCH_H_ */