Salome HOME
Test case for Split feature
[modules/shaper.git] / src / SketchAPI / SketchAPI_Sketch.h
1 // Name   : SketchAPI_Sketch.h
2 // Purpose: 
3 //
4 // History:
5 // 07/06/16 - Sergey POKHODENKO - Creation of the file
6
7 #ifndef SRC_SKETCHAPI_SKETCHAPI_SKETCH_H_
8 #define SRC_SKETCHAPI_SKETCHAPI_SKETCH_H_
9
10 //--------------------------------------------------------------------------------------
11 #include "SketchAPI.h"
12
13 #include <list>
14
15 #include <SketchPlugin_Sketch.h>
16 #include <SketchPlugin_SketchEntity.h>
17
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_Reference;
27 class ModelHighAPI_Selection;
28 class SketchAPI_Arc;
29 class SketchAPI_Circle;
30 class SketchAPI_IntersectionPoint;
31 class SketchAPI_Line;
32 class SketchAPI_Mirror;
33 class SketchAPI_Point;
34 class SketchAPI_Projection;
35 class SketchAPI_Rectangle;
36 class SketchAPI_Rotation;
37 class SketchAPI_Translation;
38 //--------------------------------------------------------------------------------------
39 /**\class SketchAPI_Sketch
40  * \ingroup CPPHighAPI
41  * \brief Interface for Sketch feature
42  */
43 class SketchAPI_Sketch : public ModelHighAPI_Interface
44 {
45 public:
46   /// Constructor without values
47   SKETCHAPI_EXPORT
48   explicit SketchAPI_Sketch(const std::shared_ptr<ModelAPI_Feature> & theFeature);
49   /// Constructor with values
50   SKETCHAPI_EXPORT
51   SketchAPI_Sketch(const std::shared_ptr<ModelAPI_Feature> & theFeature,
52                    const std::shared_ptr<GeomAPI_Ax3> & thePlane);
53   /// Constructor with values
54   SKETCHAPI_EXPORT
55   SketchAPI_Sketch(const std::shared_ptr<ModelAPI_Feature> & theFeature,
56                    const ModelHighAPI_Selection & theExternal);
57   /// Constructor with values
58   SKETCHAPI_EXPORT
59   SketchAPI_Sketch(const std::shared_ptr<ModelAPI_Feature> & theFeature,
60                    std::shared_ptr<ModelAPI_Object> thePlaneObject);
61   /// Destructor
62   SKETCHAPI_EXPORT
63   virtual ~SketchAPI_Sketch();
64
65   INTERFACE_7(SketchPlugin_Sketch::ID(),
66               origin, SketchPlugin_Sketch::ORIGIN_ID(), GeomDataAPI_Point, /** Origin point */,
67               dirX, SketchPlugin_Sketch::DIRX_ID(), GeomDataAPI_Dir, /** Direction of X */,
68               normal, SketchPlugin_Sketch::NORM_ID(), GeomDataAPI_Dir, /** Normal */,
69               features, SketchPlugin_Sketch::FEATURES_ID(), ModelAPI_AttributeRefList, /** Features */,
70               external, SketchPlugin_SketchEntity::EXTERNAL_ID(), ModelAPI_AttributeSelection, /** External */,
71               solverError, SketchPlugin_Sketch::SOLVER_ERROR(), ModelAPI_AttributeString, /** Solver error */,
72               solverDOF, SketchPlugin_Sketch::SOLVER_DOF(), ModelAPI_AttributeString, /** Solver DOF */
73   )
74
75   /// Set plane
76   SKETCHAPI_EXPORT
77   void setPlane(const std::shared_ptr<GeomAPI_Ax3> & thePlane);
78
79   /// Set external
80   SKETCHAPI_EXPORT
81   void setExternal(const ModelHighAPI_Selection & theExternal);
82
83   /// Set external
84   SKETCHAPI_EXPORT
85   void setExternal(std::shared_ptr<ModelAPI_Object> thePlaneObject);
86
87   /// Add point
88   SKETCHAPI_EXPORT
89   std::shared_ptr<SketchAPI_Point> addPoint(
90       double theX, double theY);
91   /// Add point
92   SKETCHAPI_EXPORT
93   std::shared_ptr<SketchAPI_Point> addPoint(
94       const std::shared_ptr<GeomAPI_Pnt2d> & thePoint);
95   /// Add point
96   SKETCHAPI_EXPORT
97   std::shared_ptr<SketchAPI_Point> addPoint(const ModelHighAPI_Selection & theExternal);
98   /// Add point
99   SKETCHAPI_EXPORT
100   std::shared_ptr<SketchAPI_Point> addPoint(const std::string & theExternalName);
101
102   /// Add intersection point
103   SKETCHAPI_EXPORT
104   std::shared_ptr<SketchAPI_IntersectionPoint> addIntersectionPoint(const ModelHighAPI_Selection & theExternal);
105   /// Add point
106   SKETCHAPI_EXPORT
107   std::shared_ptr<SketchAPI_IntersectionPoint> addIntersectionPoint(const std::string & theExternalName);
108
109   /// Add line
110   SKETCHAPI_EXPORT
111   std::shared_ptr<SketchAPI_Line> addLine(
112       double theX1, double theY1, double theX2, double theY2);
113   /// Add line
114   SKETCHAPI_EXPORT
115   std::shared_ptr<SketchAPI_Line> addLine(
116       const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
117       const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint);
118   /// Add line
119   SKETCHAPI_EXPORT
120   std::shared_ptr<SketchAPI_Line> addLine(const ModelHighAPI_Selection & theExternal);
121   /// Add line
122   SKETCHAPI_EXPORT
123   std::shared_ptr<SketchAPI_Line> addLine(const std::string & theExternalName);
124
125   /// Add rectangle
126   SKETCHAPI_EXPORT
127   std::shared_ptr<SketchAPI_Rectangle> addRectangle(
128       double theX1, double theY1, double theX2, double theY2);
129   /// Add rectangle
130   SKETCHAPI_EXPORT
131   std::shared_ptr<SketchAPI_Rectangle> addRectangle(
132       const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
133       const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint);
134
135   /// Add circle
136   SKETCHAPI_EXPORT
137   std::shared_ptr<SketchAPI_Circle> addCircle(
138       double theCenterX, double theCenterY,
139       double theRadius);
140   /// Add circle
141   SKETCHAPI_EXPORT
142   std::shared_ptr<SketchAPI_Circle> addCircle(
143       const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
144       double theRadius);
145   /// Add circle
146   SKETCHAPI_EXPORT
147   std::shared_ptr<SketchAPI_Circle> addCircle(
148       double theX1, double theY1,
149       double theX2, double theY2,
150       double theX3, double theY3);
151   /// Add circle
152   SKETCHAPI_EXPORT
153   std::shared_ptr<SketchAPI_Circle> addCircle(
154       const std::shared_ptr<GeomAPI_Pnt2d>& thePoint1,
155       const std::shared_ptr<GeomAPI_Pnt2d>& thePoint2,
156       const std::shared_ptr<GeomAPI_Pnt2d>& thePoint3);
157   /// Add circle
158   SKETCHAPI_EXPORT
159   std::shared_ptr<SketchAPI_Circle> addCircle(const ModelHighAPI_Selection & theExternal);
160   /// Add circle
161   SKETCHAPI_EXPORT
162   std::shared_ptr<SketchAPI_Circle> addCircle(const std::string & theExternalName);
163
164   /// Add arc
165   SKETCHAPI_EXPORT
166   std::shared_ptr<SketchAPI_Arc> addArc(
167       double theCenterX, double theCenterY,
168       double theStartX, double theStartY,
169       double theEndX, double theEndY,
170       bool theInversed);
171
172   /// Add arc
173   SKETCHAPI_EXPORT
174   std::shared_ptr<SketchAPI_Arc> addArc(
175       const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
176       const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
177       const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
178       bool theInversed);
179
180   /// Add arc
181   SKETCHAPI_EXPORT
182   std::shared_ptr<SketchAPI_Arc> addArc(
183       double theStartX, double theStartY,
184       double theEndX, double theEndY,
185       double thePassedX, double thePassedY);
186
187   /// Add arc
188   SKETCHAPI_EXPORT
189   std::shared_ptr<SketchAPI_Arc> addArc(
190       const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
191       const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
192       const std::shared_ptr<GeomAPI_Pnt2d>& thePassed);
193
194   /// Add arc
195   SKETCHAPI_EXPORT
196   std::shared_ptr<SketchAPI_Arc> addArc(
197       const ModelHighAPI_RefAttr& theTangentPoint,
198       double theEndX, double theEndY,
199       bool theInversed);
200
201   /// Add arc
202   SKETCHAPI_EXPORT
203   std::shared_ptr<SketchAPI_Arc> addArc(
204       const ModelHighAPI_RefAttr& theTangentPoint,
205       const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
206       bool theInversed);
207
208   /// Add arc
209   SKETCHAPI_EXPORT
210   std::shared_ptr<SketchAPI_Arc> addArc(const ModelHighAPI_Selection & theExternal);
211
212   /// Add arc
213   SKETCHAPI_EXPORT
214   std::shared_ptr<SketchAPI_Arc> addArc(const std::string & theExternalName);
215
216   /// Add projection
217   SKETCHAPI_EXPORT
218   std::shared_ptr<SketchAPI_Projection> addProjection(
219       const ModelHighAPI_Selection & theExternalFeature);
220
221   /// Add projection
222   SKETCHAPI_EXPORT
223   std::shared_ptr<SketchAPI_Projection> addProjection(const std::string & theExternalName);
224
225   /// Add mirror
226   SKETCHAPI_EXPORT
227   std::shared_ptr<SketchAPI_Mirror> addMirror(
228       const ModelHighAPI_RefAttr & theMirrorLine,
229       const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects);
230
231   /// Add translation
232   SKETCHAPI_EXPORT
233   std::shared_ptr<SketchAPI_Translation> addTranslation(
234       const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects,
235       const ModelHighAPI_RefAttr & thePoint1,
236       const ModelHighAPI_RefAttr & thePoint2,
237       const ModelHighAPI_Integer & theNumberOfObjects,
238       bool theFullValue = false);
239
240   /// Add rotation
241   SKETCHAPI_EXPORT
242   std::shared_ptr<SketchAPI_Rotation> addRotation(
243       const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects,
244       const ModelHighAPI_RefAttr & theCenter,
245       const ModelHighAPI_Double & theAngle,
246       const ModelHighAPI_Integer & theNumberOfObjects,
247       bool theFullValue = false);
248
249   /// Add split
250   SKETCHAPI_EXPORT
251   std::shared_ptr<ModelHighAPI_Interface> addSplit(
252       const ModelHighAPI_Reference& theFeature,
253       const ModelHighAPI_RefAttr& thePoint1,
254       const ModelHighAPI_RefAttr& thePoint2);
255
256   /// Set angle
257   SKETCHAPI_EXPORT
258   std::shared_ptr<ModelHighAPI_Interface> setAngle(
259       const ModelHighAPI_RefAttr & theLine1,
260       const ModelHighAPI_RefAttr & theLine2,
261       const ModelHighAPI_Double & theValue);
262
263   /// Set complementary angle
264   SKETCHAPI_EXPORT
265   std::shared_ptr<ModelHighAPI_Interface> setAngleComplementary(
266       const ModelHighAPI_RefAttr & theLine1,
267       const ModelHighAPI_RefAttr & theLine2,
268       const ModelHighAPI_Double & theValue);
269
270   /// Set backward angle (= 360 - angle)
271   SKETCHAPI_EXPORT
272   std::shared_ptr<ModelHighAPI_Interface> setAngleBackward(
273       const ModelHighAPI_RefAttr & theLine1,
274       const ModelHighAPI_RefAttr & theLine2,
275       const ModelHighAPI_Double & theValue);
276
277   /// Set coincident
278   SKETCHAPI_EXPORT
279   std::shared_ptr<ModelHighAPI_Interface> setCoincident(
280       const ModelHighAPI_RefAttr & thePoint1,
281       const ModelHighAPI_RefAttr & thePoint2);
282
283   /// Set collinear
284   SKETCHAPI_EXPORT
285   std::shared_ptr<ModelHighAPI_Interface> setCollinear(
286       const ModelHighAPI_RefAttr & theLine1,
287       const ModelHighAPI_RefAttr & theLine2);
288
289   /// Set distance
290   SKETCHAPI_EXPORT
291   std::shared_ptr<ModelHighAPI_Interface> setDistance(
292       const ModelHighAPI_RefAttr & thePoint,
293       const ModelHighAPI_RefAttr & thePointOrLine,
294       const ModelHighAPI_Double & theValue);
295
296   /// Set equal
297   SKETCHAPI_EXPORT
298   std::shared_ptr<ModelHighAPI_Interface> setEqual(
299       const ModelHighAPI_RefAttr & theObject1,
300       const ModelHighAPI_RefAttr & theObject2);
301
302   /// Set fillet
303   SKETCHAPI_EXPORT
304   std::shared_ptr<ModelHighAPI_Interface> setFillet(
305       const std::list<ModelHighAPI_RefAttr> & thePoints,
306       const ModelHighAPI_Double & theRadius);
307
308   /// Set fixed
309   SKETCHAPI_EXPORT
310   std::shared_ptr<ModelHighAPI_Interface> setFixed(
311       const ModelHighAPI_RefAttr & theObject);
312
313   /// Set horizontal
314   SKETCHAPI_EXPORT
315   std::shared_ptr<ModelHighAPI_Interface> setHorizontal(
316       const ModelHighAPI_RefAttr & theLine);
317
318   /// Set length
319   SKETCHAPI_EXPORT
320   std::shared_ptr<ModelHighAPI_Interface> setLength(
321       const ModelHighAPI_RefAttr & theLine,
322       const ModelHighAPI_Double & theValue);
323
324   /// Set middle
325   SKETCHAPI_EXPORT
326   std::shared_ptr<ModelHighAPI_Interface> setMiddlePoint(
327       const ModelHighAPI_RefAttr & thePoint,
328       const ModelHighAPI_RefAttr & theLine);
329
330   /// Set parallel
331   SKETCHAPI_EXPORT
332   std::shared_ptr<ModelHighAPI_Interface> setParallel(
333       const ModelHighAPI_RefAttr & theLine1,
334       const ModelHighAPI_RefAttr & theLine2);
335
336   /// Set perpendicular
337   SKETCHAPI_EXPORT
338   std::shared_ptr<ModelHighAPI_Interface> setPerpendicular(
339       const ModelHighAPI_RefAttr & theLine1,
340       const ModelHighAPI_RefAttr & theLine2);
341
342   /// Set radius
343   SKETCHAPI_EXPORT
344   std::shared_ptr<ModelHighAPI_Interface> setRadius(
345       const ModelHighAPI_RefAttr & theCircleOrArc,
346       const ModelHighAPI_Double & theValue);
347
348   /// Set tangent
349   SKETCHAPI_EXPORT
350   std::shared_ptr<ModelHighAPI_Interface> setTangent(
351       const ModelHighAPI_RefAttr & theLine,
352       const ModelHighAPI_RefAttr & theCircle);
353
354   /// Set vertical
355   SKETCHAPI_EXPORT
356   std::shared_ptr<ModelHighAPI_Interface> setVertical(
357       const ModelHighAPI_RefAttr & theLine);
358
359   /// Set constraint value
360   SKETCHAPI_EXPORT
361   void setValue(
362       const std::shared_ptr<ModelHighAPI_Interface> & theConstraint,
363       const ModelHighAPI_Double & theValue);
364
365   // TODO(spo): rename to selectFaces() or faces() (or add faces() -> list to SWIG)
366   /// Select face
367   SKETCHAPI_EXPORT
368   std::list<ModelHighAPI_Selection> selectFace() const;
369
370   /// Dump wrapped feature
371   SKETCHAPI_EXPORT
372   virtual void dump(ModelHighAPI_Dumper& theDumper) const;
373
374 protected:
375   std::shared_ptr<ModelAPI_CompositeFeature> compositeFeature() const;
376
377 };
378
379 //! Pointer on Sketch object
380 typedef std::shared_ptr<SketchAPI_Sketch> SketchPtr;
381
382 /**\ingroup CPPHighAPI
383  * \brief Create Sketch feature
384  */
385 SKETCHAPI_EXPORT
386 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
387                     const std::shared_ptr<GeomAPI_Ax3> & thePlane);
388
389 /**\ingroup CPPHighAPI
390  * \brief Create Sketch feature
391  */
392 SKETCHAPI_EXPORT
393 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
394                     const ModelHighAPI_Selection & theExternal);
395
396 /**\ingroup CPPHighAPI
397  * \brief Create Sketch feature
398  */
399 SKETCHAPI_EXPORT
400 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
401                     const std::string & theExternalName);
402
403 /**\ingroup CPPHighAPI
404  * \brief Create Sketch feature
405  */
406 SKETCHAPI_EXPORT
407 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
408                     std::shared_ptr<ModelAPI_Object> thePlaneObject);
409
410 //--------------------------------------------------------------------------------------
411 //--------------------------------------------------------------------------------------
412 #endif /* SRC_SKETCHAPI_SKETCHAPI_SKETCH_H_ */