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