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