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);
56 /// Constructor with values
58 SketchAPI_Sketch(const std::shared_ptr<ModelAPI_Feature> & theFeature,
59 std::shared_ptr<ModelAPI_Object> thePlaneObject);
62 virtual ~SketchAPI_Sketch();
64 INTERFACE_7(SketchPlugin_Sketch::ID(),
65 origin, SketchPlugin_Sketch::ORIGIN_ID(), GeomDataAPI_Point, /** Origin point */,
66 dirX, SketchPlugin_Sketch::DIRX_ID(), GeomDataAPI_Dir, /** Direction of X */,
67 normal, SketchPlugin_Sketch::NORM_ID(), GeomDataAPI_Dir, /** Normal */,
68 features, SketchPlugin_Sketch::FEATURES_ID(), ModelAPI_AttributeRefList, /** Features */,
69 external, SketchPlugin_SketchEntity::EXTERNAL_ID(), ModelAPI_AttributeSelection, /** External */,
70 solverError, SketchPlugin_Sketch::SOLVER_ERROR(), ModelAPI_AttributeString, /** Solver error */,
71 solverDOF, SketchPlugin_Sketch::SOLVER_DOF(), ModelAPI_AttributeString, /** Solver DOF */
76 void setPlane(const std::shared_ptr<GeomAPI_Ax3> & thePlane);
80 void setExternal(const ModelHighAPI_Selection & theExternal);
84 void setExternal(std::shared_ptr<ModelAPI_Object> thePlaneObject);
88 std::shared_ptr<SketchAPI_Point> addPoint(
89 double theX, double theY);
92 std::shared_ptr<SketchAPI_Point> addPoint(
93 const std::shared_ptr<GeomAPI_Pnt2d> & thePoint);
96 std::shared_ptr<SketchAPI_Point> addPoint(const ModelHighAPI_Selection & theExternal);
99 std::shared_ptr<SketchAPI_Point> addPoint(const std::string & theExternalName);
101 /// Add intersection point
103 std::shared_ptr<SketchAPI_IntersectionPoint> addIntersectionPoint(const ModelHighAPI_Selection & theExternal);
106 std::shared_ptr<SketchAPI_IntersectionPoint> addIntersectionPoint(const std::string & theExternalName);
110 std::shared_ptr<SketchAPI_Line> addLine(
111 double theX1, double theY1, double theX2, double theY2);
114 std::shared_ptr<SketchAPI_Line> addLine(
115 const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
116 const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint);
119 std::shared_ptr<SketchAPI_Line> addLine(const ModelHighAPI_Selection & theExternal);
122 std::shared_ptr<SketchAPI_Line> addLine(const std::string & theExternalName);
126 std::shared_ptr<SketchAPI_Rectangle> addRectangle(
127 double theX1, double theY1, double theX2, double theY2);
130 std::shared_ptr<SketchAPI_Rectangle> addRectangle(
131 const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
132 const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint);
136 std::shared_ptr<SketchAPI_Circle> addCircle(
137 double theCenterX, double theCenterY,
141 std::shared_ptr<SketchAPI_Circle> addCircle(
142 const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
146 std::shared_ptr<SketchAPI_Circle> addCircle(
147 double theX1, double theY1,
148 double theX2, double theY2,
149 double theX3, double theY3);
152 std::shared_ptr<SketchAPI_Circle> addCircle(
153 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint1,
154 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint2,
155 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint3);
158 std::shared_ptr<SketchAPI_Circle> addCircle(const ModelHighAPI_Selection & theExternal);
161 std::shared_ptr<SketchAPI_Circle> addCircle(const std::string & theExternalName);
165 std::shared_ptr<SketchAPI_Arc> addArc(
166 double theCenterX, double theCenterY,
167 double theStartX, double theStartY,
168 double theEndX, double theEndY,
173 std::shared_ptr<SketchAPI_Arc> addArc(
174 const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
175 const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
176 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
181 std::shared_ptr<SketchAPI_Arc> addArc(
182 double theStartX, double theStartY,
183 double theEndX, double theEndY,
184 double thePassedX, double thePassedY);
188 std::shared_ptr<SketchAPI_Arc> addArc(
189 const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
190 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
191 const std::shared_ptr<GeomAPI_Pnt2d>& thePassed);
195 std::shared_ptr<SketchAPI_Arc> addArc(
196 const ModelHighAPI_RefAttr& theTangentPoint,
197 double theEndX, double theEndY,
202 std::shared_ptr<SketchAPI_Arc> addArc(
203 const ModelHighAPI_RefAttr& theTangentPoint,
204 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
209 std::shared_ptr<SketchAPI_Arc> addArc(const ModelHighAPI_Selection & theExternal);
213 std::shared_ptr<SketchAPI_Arc> addArc(const std::string & theExternalName);
217 std::shared_ptr<SketchAPI_Projection> addProjection(
218 const ModelHighAPI_Selection & theExternalFeature);
222 std::shared_ptr<SketchAPI_Projection> addProjection(const std::string & theExternalName);
226 std::shared_ptr<SketchAPI_Mirror> addMirror(
227 const ModelHighAPI_RefAttr & theMirrorLine,
228 const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects);
232 std::shared_ptr<SketchAPI_Translation> addTranslation(
233 const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects,
234 const ModelHighAPI_RefAttr & thePoint1,
235 const ModelHighAPI_RefAttr & thePoint2,
236 const ModelHighAPI_Integer & theNumberOfObjects,
237 bool theFullValue = false);
241 std::shared_ptr<SketchAPI_Rotation> addRotation(
242 const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects,
243 const ModelHighAPI_RefAttr & theCenter,
244 const ModelHighAPI_Double & theAngle,
245 const ModelHighAPI_Integer & theNumberOfObjects,
246 bool theFullValue = false);
250 std::shared_ptr<ModelAPI_Feature> setAngle(
251 const ModelHighAPI_RefAttr & theLine1,
252 const ModelHighAPI_RefAttr & theLine2,
253 const ModelHighAPI_Double & theValue);
255 /// Set complementary angle
257 std::shared_ptr<ModelAPI_Feature> setAngleComplementary(
258 const ModelHighAPI_RefAttr & theLine1,
259 const ModelHighAPI_RefAttr & theLine2,
260 const ModelHighAPI_Double & theValue);
262 /// Set backward angle (= 360 - angle)
264 std::shared_ptr<ModelAPI_Feature> setAngleBackward(
265 const ModelHighAPI_RefAttr & theLine1,
266 const ModelHighAPI_RefAttr & theLine2,
267 const ModelHighAPI_Double & theValue);
271 std::shared_ptr<ModelAPI_Feature> setCoincident(
272 const ModelHighAPI_RefAttr & thePoint1,
273 const ModelHighAPI_RefAttr & thePoint2);
277 std::shared_ptr<ModelAPI_Feature> setCollinear(
278 const ModelHighAPI_RefAttr & theLine1,
279 const ModelHighAPI_RefAttr & theLine2);
283 std::shared_ptr<ModelAPI_Feature> setDistance(
284 const ModelHighAPI_RefAttr & thePoint,
285 const ModelHighAPI_RefAttr & thePointOrLine,
286 const ModelHighAPI_Double & theValue);
290 std::shared_ptr<ModelAPI_Feature> setEqual(
291 const ModelHighAPI_RefAttr & theObject1,
292 const ModelHighAPI_RefAttr & theObject2);
296 std::shared_ptr<ModelAPI_Feature> setFillet(
297 const std::list<ModelHighAPI_RefAttr> & thePoints,
298 const ModelHighAPI_Double & theRadius);
302 std::shared_ptr<ModelAPI_Feature> setFixed(
303 const ModelHighAPI_RefAttr & theObject);
307 std::shared_ptr<ModelAPI_Feature> setHorizontal(
308 const ModelHighAPI_RefAttr & theLine);
312 std::shared_ptr<ModelAPI_Feature> setLength(
313 const ModelHighAPI_RefAttr & theLine,
314 const ModelHighAPI_Double & theValue);
318 std::shared_ptr<ModelAPI_Feature> setMiddlePoint(
319 const ModelHighAPI_RefAttr & thePoint,
320 const ModelHighAPI_RefAttr & theLine);
324 std::shared_ptr<ModelAPI_Feature> setParallel(
325 const ModelHighAPI_RefAttr & theLine1,
326 const ModelHighAPI_RefAttr & theLine2);
328 /// Set perpendicular
330 std::shared_ptr<ModelAPI_Feature> setPerpendicular(
331 const ModelHighAPI_RefAttr & theLine1,
332 const ModelHighAPI_RefAttr & theLine2);
336 std::shared_ptr<ModelAPI_Feature> setRadius(
337 const ModelHighAPI_RefAttr & theCircleOrArc,
338 const ModelHighAPI_Double & theValue);
342 std::shared_ptr<ModelAPI_Feature> setTangent(
343 const ModelHighAPI_RefAttr & theLine,
344 const ModelHighAPI_RefAttr & theCircle);
348 std::shared_ptr<ModelAPI_Feature> setVertical(
349 const ModelHighAPI_RefAttr & theLine);
351 /// Set constraint value
354 const std::shared_ptr<ModelAPI_Feature> & theConstraint,
355 const ModelHighAPI_Double & theValue);
357 // TODO(spo): rename to selectFaces() or faces() (or add faces() -> list to SWIG)
360 std::list<ModelHighAPI_Selection> selectFace() const;
362 /// Dump wrapped feature
364 virtual void dump(ModelHighAPI_Dumper& theDumper) const;
367 std::shared_ptr<ModelAPI_CompositeFeature> compositeFeature() const;
371 //! Pointer on Sketch object
372 typedef std::shared_ptr<SketchAPI_Sketch> SketchPtr;
374 /**\ingroup CPPHighAPI
375 * \brief Create Sketch feature
378 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
379 const std::shared_ptr<GeomAPI_Ax3> & thePlane);
381 /**\ingroup CPPHighAPI
382 * \brief Create Sketch feature
385 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
386 const ModelHighAPI_Selection & theExternal);
388 /**\ingroup CPPHighAPI
389 * \brief Create Sketch feature
392 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
393 const std::string & theExternalName);
395 /**\ingroup CPPHighAPI
396 * \brief Create Sketch feature
399 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
400 std::shared_ptr<ModelAPI_Object> thePlaneObject);
402 //--------------------------------------------------------------------------------------
403 //--------------------------------------------------------------------------------------
404 #endif /* SRC_SKETCHAPI_SKETCHAPI_SKETCH_H_ */