1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2 // Name : SketchAPI_Sketch.h
6 // 07/06/16 - Sergey POKHODENKO - Creation of the file
8 #ifndef SRC_SKETCHAPI_SKETCHAPI_SKETCH_H_
9 #define SRC_SKETCHAPI_SKETCHAPI_SKETCH_H_
11 //--------------------------------------------------------------------------------------
12 #include "SketchAPI.h"
16 #include <SketchPlugin_Sketch.h>
17 #include <SketchPlugin_SketchEntity.h>
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;
30 class SketchAPI_MacroArc;
31 class SketchAPI_Circle;
32 class SketchAPI_MacroCircle;
33 class SketchAPI_IntersectionPoint;
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
44 * \brief Interface for Sketch feature
46 class SketchAPI_Sketch : public ModelHighAPI_Interface
49 /// Constructor without values
51 explicit SketchAPI_Sketch(const std::shared_ptr<ModelAPI_Feature> & theFeature);
52 /// Constructor with values
54 SketchAPI_Sketch(const std::shared_ptr<ModelAPI_Feature> & theFeature,
55 const std::shared_ptr<GeomAPI_Ax3> & thePlane);
56 /// Constructor with values
58 SketchAPI_Sketch(const std::shared_ptr<ModelAPI_Feature> & theFeature,
59 const ModelHighAPI_Selection & theExternal);
60 /// Constructor with values
62 SketchAPI_Sketch(const std::shared_ptr<ModelAPI_Feature> & theFeature,
63 std::shared_ptr<ModelAPI_Object> thePlaneObject);
66 virtual ~SketchAPI_Sketch();
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 */
87 void setPlane(const std::shared_ptr<GeomAPI_Ax3> & thePlane);
91 void setExternal(const ModelHighAPI_Selection & theExternal);
95 void setExternal(std::shared_ptr<ModelAPI_Object> thePlaneObject);
99 std::shared_ptr<SketchAPI_Point> addPoint(
100 double theX, double theY);
103 std::shared_ptr<SketchAPI_Point> addPoint(
104 const std::shared_ptr<GeomAPI_Pnt2d> & thePoint);
107 std::shared_ptr<SketchAPI_Point> addPoint(const ModelHighAPI_Selection & theExternal);
110 std::shared_ptr<SketchAPI_Point> addPoint(const std::string & theExternalName);
112 /// Add intersection point
114 std::shared_ptr<SketchAPI_IntersectionPoint>
115 addIntersectionPoint(const ModelHighAPI_Selection & theExternal);
118 std::shared_ptr<SketchAPI_IntersectionPoint>
119 addIntersectionPoint(const std::string & theExternalName);
123 std::shared_ptr<SketchAPI_Line> addLine(
124 double theX1, double theY1, double theX2, double theY2);
127 std::shared_ptr<SketchAPI_Line> addLine(
128 const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
129 const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint);
132 std::shared_ptr<SketchAPI_Line> addLine(const ModelHighAPI_Selection & theExternal);
135 std::shared_ptr<SketchAPI_Line> addLine(const std::string & theExternalName);
139 std::shared_ptr<SketchAPI_Rectangle> addRectangle(
140 double theX1, double theY1, double theX2, double theY2);
143 std::shared_ptr<SketchAPI_Rectangle> addRectangle(
144 const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
145 const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint);
149 std::shared_ptr<SketchAPI_Circle> addCircle(
150 double theCenterX, double theCenterY,
154 std::shared_ptr<SketchAPI_Circle> addCircle(
155 const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
159 std::shared_ptr<SketchAPI_MacroCircle> addCircle(
160 double theCenterX, double theCenterY,
161 double thePassedX, double thePassedY);
164 std::shared_ptr<SketchAPI_MacroCircle> addCircle(
165 const std::shared_ptr<GeomAPI_Pnt2d>& theCenterPoint,
166 const std::shared_ptr<GeomAPI_Pnt2d>& thePassedPoint);
169 std::shared_ptr<SketchAPI_MacroCircle> addCircle(
170 double theX1, double theY1,
171 double theX2, double theY2,
172 double theX3, double theY3);
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);
181 std::shared_ptr<SketchAPI_Circle> addCircle(const ModelHighAPI_Selection & theExternal);
184 std::shared_ptr<SketchAPI_Circle> addCircle(const std::string & theExternalName);
188 std::shared_ptr<SketchAPI_Arc> addArc(
189 double theCenterX, double theCenterY,
190 double theStartX, double theStartY,
191 double theEndX, double theEndY,
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,
204 std::shared_ptr<SketchAPI_MacroArc> addArc(
205 double theStartX, double theStartY,
206 double theEndX, double theEndY,
207 double thePassedX, double thePassedY);
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);
218 std::shared_ptr<SketchAPI_MacroArc> addArc(
219 const ModelHighAPI_RefAttr& theTangentPoint,
220 double theEndX, double theEndY,
225 std::shared_ptr<SketchAPI_MacroArc> addArc(
226 const ModelHighAPI_RefAttr& theTangentPoint,
227 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
232 std::shared_ptr<SketchAPI_Arc> addArc(const ModelHighAPI_Selection & theExternal);
236 std::shared_ptr<SketchAPI_Arc> addArc(const std::string & theExternalName);
240 std::shared_ptr<SketchAPI_Projection> addProjection(
241 const ModelHighAPI_Selection & theExternalFeature);
245 std::shared_ptr<SketchAPI_Projection> addProjection(const std::string & theExternalName);
249 std::shared_ptr<SketchAPI_Mirror> addMirror(
250 const ModelHighAPI_RefAttr & theMirrorLine,
251 const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects);
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);
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);
273 std::shared_ptr<ModelHighAPI_Interface> addSplit(
274 const ModelHighAPI_Reference& theFeature,
275 const ModelHighAPI_RefAttr& thePoint1,
276 const ModelHighAPI_RefAttr& thePoint2);
280 std::shared_ptr<ModelHighAPI_Interface> addTrim(
281 const ModelHighAPI_Reference& theFeature,
282 const std::shared_ptr<GeomAPI_Pnt2d>& thePositionPoint);
286 std::shared_ptr<ModelHighAPI_Interface> setAngle(
287 const ModelHighAPI_RefAttr & theLine1,
288 const ModelHighAPI_RefAttr & theLine2,
289 const ModelHighAPI_Double & theValue);
291 /// Set complementary angle
293 std::shared_ptr<ModelHighAPI_Interface> setAngleComplementary(
294 const ModelHighAPI_RefAttr & theLine1,
295 const ModelHighAPI_RefAttr & theLine2,
296 const ModelHighAPI_Double & theValue);
298 /// Set backward angle (= 360 - angle)
300 std::shared_ptr<ModelHighAPI_Interface> setAngleBackward(
301 const ModelHighAPI_RefAttr & theLine1,
302 const ModelHighAPI_RefAttr & theLine2,
303 const ModelHighAPI_Double & theValue);
307 std::shared_ptr<ModelHighAPI_Interface> setCoincident(
308 const ModelHighAPI_RefAttr & thePoint1,
309 const ModelHighAPI_RefAttr & thePoint2);
313 std::shared_ptr<ModelHighAPI_Interface> setCollinear(
314 const ModelHighAPI_RefAttr & theLine1,
315 const ModelHighAPI_RefAttr & theLine2);
319 std::shared_ptr<ModelHighAPI_Interface> setDistance(
320 const ModelHighAPI_RefAttr & thePoint,
321 const ModelHighAPI_RefAttr & thePointOrLine,
322 const ModelHighAPI_Double & theValue);
326 std::shared_ptr<ModelHighAPI_Interface> setEqual(
327 const ModelHighAPI_RefAttr & theObject1,
328 const ModelHighAPI_RefAttr & theObject2);
332 std::shared_ptr<ModelHighAPI_Interface> setFillet(
333 const ModelHighAPI_RefAttr & thePoint);
335 /// Set fillet with additional radius constraint
337 std::shared_ptr<ModelHighAPI_Interface> setFilletWithRadius(
338 const ModelHighAPI_RefAttr & thePoint,
339 const ModelHighAPI_Double & theRadius);
343 std::shared_ptr<ModelHighAPI_Interface> setFixed(
344 const ModelHighAPI_RefAttr & theObject);
348 std::shared_ptr<ModelHighAPI_Interface> setHorizontal(
349 const ModelHighAPI_RefAttr & theLine);
353 std::shared_ptr<ModelHighAPI_Interface> setLength(
354 const ModelHighAPI_RefAttr & theLine,
355 const ModelHighAPI_Double & theValue);
359 std::shared_ptr<ModelHighAPI_Interface> setMiddlePoint(
360 const ModelHighAPI_RefAttr & thePoint,
361 const ModelHighAPI_RefAttr & theLine);
365 std::shared_ptr<ModelHighAPI_Interface> setParallel(
366 const ModelHighAPI_RefAttr & theLine1,
367 const ModelHighAPI_RefAttr & theLine2);
369 /// Set perpendicular
371 std::shared_ptr<ModelHighAPI_Interface> setPerpendicular(
372 const ModelHighAPI_RefAttr & theLine1,
373 const ModelHighAPI_RefAttr & theLine2);
377 std::shared_ptr<ModelHighAPI_Interface> setRadius(
378 const ModelHighAPI_RefAttr & theCircleOrArc,
379 const ModelHighAPI_Double & theValue);
383 std::shared_ptr<ModelHighAPI_Interface> setTangent(
384 const ModelHighAPI_RefAttr & theLine,
385 const ModelHighAPI_RefAttr & theCircle);
389 std::shared_ptr<ModelHighAPI_Interface> setVertical(
390 const ModelHighAPI_RefAttr & theLine);
392 /// Set constraint value
395 const std::shared_ptr<ModelHighAPI_Interface> & theConstraint,
396 const ModelHighAPI_Double & theValue);
399 std::shared_ptr<GeomAPI_Pnt2d> to2D(const std::shared_ptr<GeomAPI_Pnt>& thePoint);
401 // TODO(spo): rename to selectFaces() or faces() (or add faces() -> list to SWIG)
404 std::list<ModelHighAPI_Selection> selectFace() const;
406 /// Dump wrapped feature
408 virtual void dump(ModelHighAPI_Dumper& theDumper) const;
411 std::shared_ptr<ModelAPI_CompositeFeature> compositeFeature() const;
415 //! Pointer on Sketch object
416 typedef std::shared_ptr<SketchAPI_Sketch> SketchPtr;
418 /**\ingroup CPPHighAPI
419 * \brief Create Sketch feature
422 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
423 const std::shared_ptr<GeomAPI_Ax3> & thePlane);
425 /**\ingroup CPPHighAPI
426 * \brief Create Sketch feature
429 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
430 const ModelHighAPI_Selection & theExternal);
432 /**\ingroup CPPHighAPI
433 * \brief Create Sketch feature
436 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
437 const std::string & theExternalName);
439 /**\ingroup CPPHighAPI
440 * \brief Create Sketch feature
443 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
444 std::shared_ptr<ModelAPI_Object> thePlaneObject);
446 //--------------------------------------------------------------------------------------
447 //--------------------------------------------------------------------------------------
448 #endif /* SRC_SKETCHAPI_SKETCHAPI_SKETCH_H_ */