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