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