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