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 std::shared_ptr<GeomAPI_Pnt2d>& thePositionPoint);
279 std::shared_ptr<ModelHighAPI_Interface> addTrim(
280 const ModelHighAPI_Reference& theFeature,
281 const std::shared_ptr<GeomAPI_Pnt2d>& thePositionPoint);
285 std::shared_ptr<ModelHighAPI_Interface> setAngle(
286 const ModelHighAPI_RefAttr & theLine1,
287 const ModelHighAPI_RefAttr & theLine2,
288 const ModelHighAPI_Double & theValue);
290 /// Set complementary angle
292 std::shared_ptr<ModelHighAPI_Interface> setAngleComplementary(
293 const ModelHighAPI_RefAttr & theLine1,
294 const ModelHighAPI_RefAttr & theLine2,
295 const ModelHighAPI_Double & theValue);
297 /// Set backward angle (= 360 - angle)
299 std::shared_ptr<ModelHighAPI_Interface> setAngleBackward(
300 const ModelHighAPI_RefAttr & theLine1,
301 const ModelHighAPI_RefAttr & theLine2,
302 const ModelHighAPI_Double & theValue);
306 std::shared_ptr<ModelHighAPI_Interface> setCoincident(
307 const ModelHighAPI_RefAttr & thePoint1,
308 const ModelHighAPI_RefAttr & thePoint2);
312 std::shared_ptr<ModelHighAPI_Interface> setCollinear(
313 const ModelHighAPI_RefAttr & theLine1,
314 const ModelHighAPI_RefAttr & theLine2);
318 std::shared_ptr<ModelHighAPI_Interface> setDistance(
319 const ModelHighAPI_RefAttr & thePoint,
320 const ModelHighAPI_RefAttr & thePointOrLine,
321 const ModelHighAPI_Double & theValue);
325 std::shared_ptr<ModelHighAPI_Interface> setEqual(
326 const ModelHighAPI_RefAttr & theObject1,
327 const ModelHighAPI_RefAttr & theObject2);
331 std::shared_ptr<ModelHighAPI_Interface> setFillet(
332 const ModelHighAPI_RefAttr & thePoint);
334 /// Set fillet with additional radius constraint
336 std::shared_ptr<ModelHighAPI_Interface> setFilletWithRadius(
337 const ModelHighAPI_RefAttr & thePoint,
338 const ModelHighAPI_Double & theRadius);
342 std::shared_ptr<ModelHighAPI_Interface> setFixed(
343 const ModelHighAPI_RefAttr & theObject);
347 std::shared_ptr<ModelHighAPI_Interface> setHorizontal(
348 const ModelHighAPI_RefAttr & theLine);
352 std::shared_ptr<ModelHighAPI_Interface> setLength(
353 const ModelHighAPI_RefAttr & theLine,
354 const ModelHighAPI_Double & theValue);
358 std::shared_ptr<ModelHighAPI_Interface> setMiddlePoint(
359 const ModelHighAPI_RefAttr & thePoint,
360 const ModelHighAPI_RefAttr & theLine);
364 std::shared_ptr<ModelHighAPI_Interface> setParallel(
365 const ModelHighAPI_RefAttr & theLine1,
366 const ModelHighAPI_RefAttr & theLine2);
368 /// Set perpendicular
370 std::shared_ptr<ModelHighAPI_Interface> setPerpendicular(
371 const ModelHighAPI_RefAttr & theLine1,
372 const ModelHighAPI_RefAttr & theLine2);
376 std::shared_ptr<ModelHighAPI_Interface> setRadius(
377 const ModelHighAPI_RefAttr & theCircleOrArc,
378 const ModelHighAPI_Double & theValue);
382 std::shared_ptr<ModelHighAPI_Interface> setTangent(
383 const ModelHighAPI_RefAttr & theLine,
384 const ModelHighAPI_RefAttr & theCircle);
388 std::shared_ptr<ModelHighAPI_Interface> setVertical(
389 const ModelHighAPI_RefAttr & theLine);
391 /// Set constraint value
394 const std::shared_ptr<ModelHighAPI_Interface> & theConstraint,
395 const ModelHighAPI_Double & theValue);
398 std::shared_ptr<GeomAPI_Pnt2d> to2D(const std::shared_ptr<GeomAPI_Pnt>& thePoint);
400 // TODO(spo): rename to selectFaces() or faces() (or add faces() -> list to SWIG)
403 std::list<ModelHighAPI_Selection> selectFace() const;
405 /// Dump wrapped feature
407 virtual void dump(ModelHighAPI_Dumper& theDumper) const;
410 std::shared_ptr<ModelAPI_CompositeFeature> compositeFeature() const;
414 //! Pointer on Sketch object
415 typedef std::shared_ptr<SketchAPI_Sketch> SketchPtr;
417 /**\ingroup CPPHighAPI
418 * \brief Create Sketch feature
421 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
422 const std::shared_ptr<GeomAPI_Ax3> & thePlane);
424 /**\ingroup CPPHighAPI
425 * \brief Create Sketch feature
428 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
429 const ModelHighAPI_Selection & theExternal);
431 /**\ingroup CPPHighAPI
432 * \brief Create Sketch feature
435 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
436 const std::string & theExternalName);
438 /**\ingroup CPPHighAPI
439 * \brief Create Sketch feature
442 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
443 std::shared_ptr<ModelAPI_Object> thePlaneObject);
445 //--------------------------------------------------------------------------------------
446 //--------------------------------------------------------------------------------------
447 #endif /* SRC_SKETCHAPI_SKETCHAPI_SKETCH_H_ */