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_Circle;
31 class SketchAPI_IntersectionPoint;
33 class SketchAPI_Mirror;
34 class SketchAPI_Point;
35 class SketchAPI_Projection;
36 class SketchAPI_Rectangle;
37 class SketchAPI_Rotation;
38 class SketchAPI_Translation;
39 //--------------------------------------------------------------------------------------
40 /**\class SketchAPI_Sketch
42 * \brief Interface for Sketch feature
44 class SketchAPI_Sketch : public ModelHighAPI_Interface
47 /// Constructor without values
49 explicit SketchAPI_Sketch(const std::shared_ptr<ModelAPI_Feature> & theFeature);
50 /// Constructor with values
52 SketchAPI_Sketch(const std::shared_ptr<ModelAPI_Feature> & theFeature,
53 const std::shared_ptr<GeomAPI_Ax3> & thePlane);
54 /// Constructor with values
56 SketchAPI_Sketch(const std::shared_ptr<ModelAPI_Feature> & theFeature,
57 const ModelHighAPI_Selection & theExternal);
58 /// Constructor with values
60 SketchAPI_Sketch(const std::shared_ptr<ModelAPI_Feature> & theFeature,
61 std::shared_ptr<ModelAPI_Object> thePlaneObject);
64 virtual ~SketchAPI_Sketch();
66 INTERFACE_7(SketchPlugin_Sketch::ID(),
67 origin, SketchPlugin_Sketch::ORIGIN_ID(),
68 GeomDataAPI_Point, /** Origin point */,
69 dirX, SketchPlugin_Sketch::DIRX_ID(),
70 GeomDataAPI_Dir, /** Direction of X */,
71 normal, SketchPlugin_Sketch::NORM_ID(),
72 GeomDataAPI_Dir, /** Normal */,
73 features, SketchPlugin_Sketch::FEATURES_ID(),
74 ModelAPI_AttributeRefList, /** Features */,
75 external, SketchPlugin_SketchEntity::EXTERNAL_ID(),
76 ModelAPI_AttributeSelection, /** External */,
77 solverError, SketchPlugin_Sketch::SOLVER_ERROR(),
78 ModelAPI_AttributeString, /** Solver error */,
79 solverDOF, SketchPlugin_Sketch::SOLVER_DOF(),
80 ModelAPI_AttributeString, /** Solver DOF */
85 void setPlane(const std::shared_ptr<GeomAPI_Ax3> & thePlane);
89 void setExternal(const ModelHighAPI_Selection & theExternal);
93 void setExternal(std::shared_ptr<ModelAPI_Object> thePlaneObject);
97 std::shared_ptr<SketchAPI_Point> addPoint(
98 double theX, double theY);
101 std::shared_ptr<SketchAPI_Point> addPoint(
102 const std::shared_ptr<GeomAPI_Pnt2d> & thePoint);
105 std::shared_ptr<SketchAPI_Point> addPoint(const ModelHighAPI_Selection & theExternal);
108 std::shared_ptr<SketchAPI_Point> addPoint(const std::string & theExternalName);
110 /// Add intersection point
112 std::shared_ptr<SketchAPI_IntersectionPoint>
113 addIntersectionPoint(const ModelHighAPI_Selection & theExternal);
116 std::shared_ptr<SketchAPI_IntersectionPoint>
117 addIntersectionPoint(const std::string & theExternalName);
121 std::shared_ptr<SketchAPI_Line> addLine(
122 double theX1, double theY1, double theX2, double theY2);
125 std::shared_ptr<SketchAPI_Line> addLine(
126 const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
127 const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint);
130 std::shared_ptr<SketchAPI_Line> addLine(const ModelHighAPI_Selection & theExternal);
133 std::shared_ptr<SketchAPI_Line> addLine(const std::string & theExternalName);
137 std::shared_ptr<SketchAPI_Rectangle> addRectangle(
138 double theX1, double theY1, double theX2, double theY2);
141 std::shared_ptr<SketchAPI_Rectangle> addRectangle(
142 const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
143 const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint);
147 std::shared_ptr<SketchAPI_Circle> addCircle(
148 double theCenterX, double theCenterY,
152 std::shared_ptr<SketchAPI_Circle> addCircle(
153 const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
157 std::shared_ptr<SketchAPI_Circle> addCircle(
158 double theX1, double theY1,
159 double theX2, double theY2,
160 double theX3, double theY3);
163 std::shared_ptr<SketchAPI_Circle> addCircle(
164 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint1,
165 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint2,
166 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint3);
169 std::shared_ptr<SketchAPI_Circle> addCircle(const ModelHighAPI_Selection & theExternal);
172 std::shared_ptr<SketchAPI_Circle> addCircle(const std::string & theExternalName);
176 std::shared_ptr<SketchAPI_Arc> addArc(
177 double theCenterX, double theCenterY,
178 double theStartX, double theStartY,
179 double theEndX, double theEndY,
184 std::shared_ptr<SketchAPI_Arc> addArc(
185 const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
186 const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
187 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
192 std::shared_ptr<SketchAPI_Arc> addArc(
193 double theStartX, double theStartY,
194 double theEndX, double theEndY,
195 double thePassedX, double thePassedY);
199 std::shared_ptr<SketchAPI_Arc> addArc(
200 const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
201 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
202 const std::shared_ptr<GeomAPI_Pnt2d>& thePassed);
206 std::shared_ptr<SketchAPI_Arc> addArc(
207 const ModelHighAPI_RefAttr& theTangentPoint,
208 double theEndX, double theEndY,
213 std::shared_ptr<SketchAPI_Arc> addArc(
214 const ModelHighAPI_RefAttr& theTangentPoint,
215 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
220 std::shared_ptr<SketchAPI_Arc> addArc(const ModelHighAPI_Selection & theExternal);
224 std::shared_ptr<SketchAPI_Arc> addArc(const std::string & theExternalName);
228 std::shared_ptr<SketchAPI_Projection> addProjection(
229 const ModelHighAPI_Selection & theExternalFeature);
233 std::shared_ptr<SketchAPI_Projection> addProjection(const std::string & theExternalName);
237 std::shared_ptr<SketchAPI_Mirror> addMirror(
238 const ModelHighAPI_RefAttr & theMirrorLine,
239 const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects);
243 std::shared_ptr<SketchAPI_Translation> addTranslation(
244 const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects,
245 const ModelHighAPI_RefAttr & thePoint1,
246 const ModelHighAPI_RefAttr & thePoint2,
247 const ModelHighAPI_Integer & theNumberOfObjects,
248 bool theFullValue = false);
252 std::shared_ptr<SketchAPI_Rotation> addRotation(
253 const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects,
254 const ModelHighAPI_RefAttr & theCenter,
255 const ModelHighAPI_Double & theAngle,
256 const ModelHighAPI_Integer & theNumberOfObjects,
257 bool theFullValue = false);
261 std::shared_ptr<ModelHighAPI_Interface> addSplit(
262 const ModelHighAPI_Reference& theFeature,
263 const ModelHighAPI_RefAttr& thePoint1,
264 const ModelHighAPI_RefAttr& thePoint2);
268 std::shared_ptr<ModelHighAPI_Interface> setAngle(
269 const ModelHighAPI_RefAttr & theLine1,
270 const ModelHighAPI_RefAttr & theLine2,
271 const ModelHighAPI_Double & theValue);
273 /// Set complementary angle
275 std::shared_ptr<ModelHighAPI_Interface> setAngleComplementary(
276 const ModelHighAPI_RefAttr & theLine1,
277 const ModelHighAPI_RefAttr & theLine2,
278 const ModelHighAPI_Double & theValue);
280 /// Set backward angle (= 360 - angle)
282 std::shared_ptr<ModelHighAPI_Interface> setAngleBackward(
283 const ModelHighAPI_RefAttr & theLine1,
284 const ModelHighAPI_RefAttr & theLine2,
285 const ModelHighAPI_Double & theValue);
289 std::shared_ptr<ModelHighAPI_Interface> setCoincident(
290 const ModelHighAPI_RefAttr & thePoint1,
291 const ModelHighAPI_RefAttr & thePoint2);
295 std::shared_ptr<ModelHighAPI_Interface> setCollinear(
296 const ModelHighAPI_RefAttr & theLine1,
297 const ModelHighAPI_RefAttr & theLine2);
301 std::shared_ptr<ModelHighAPI_Interface> setDistance(
302 const ModelHighAPI_RefAttr & thePoint,
303 const ModelHighAPI_RefAttr & thePointOrLine,
304 const ModelHighAPI_Double & theValue);
308 std::shared_ptr<ModelHighAPI_Interface> setEqual(
309 const ModelHighAPI_RefAttr & theObject1,
310 const ModelHighAPI_RefAttr & theObject2);
314 std::shared_ptr<ModelHighAPI_Interface> setFillet(
315 const std::list<ModelHighAPI_RefAttr> & thePoints,
316 const ModelHighAPI_Double & theRadius);
320 std::shared_ptr<ModelHighAPI_Interface> setFixed(
321 const ModelHighAPI_RefAttr & theObject);
325 std::shared_ptr<ModelHighAPI_Interface> setHorizontal(
326 const ModelHighAPI_RefAttr & theLine);
330 std::shared_ptr<ModelHighAPI_Interface> setLength(
331 const ModelHighAPI_RefAttr & theLine,
332 const ModelHighAPI_Double & theValue);
336 std::shared_ptr<ModelHighAPI_Interface> setMiddlePoint(
337 const ModelHighAPI_RefAttr & thePoint,
338 const ModelHighAPI_RefAttr & theLine);
342 std::shared_ptr<ModelHighAPI_Interface> setParallel(
343 const ModelHighAPI_RefAttr & theLine1,
344 const ModelHighAPI_RefAttr & theLine2);
346 /// Set perpendicular
348 std::shared_ptr<ModelHighAPI_Interface> setPerpendicular(
349 const ModelHighAPI_RefAttr & theLine1,
350 const ModelHighAPI_RefAttr & theLine2);
354 std::shared_ptr<ModelHighAPI_Interface> setRadius(
355 const ModelHighAPI_RefAttr & theCircleOrArc,
356 const ModelHighAPI_Double & theValue);
360 std::shared_ptr<ModelHighAPI_Interface> setTangent(
361 const ModelHighAPI_RefAttr & theLine,
362 const ModelHighAPI_RefAttr & theCircle);
366 std::shared_ptr<ModelHighAPI_Interface> setVertical(
367 const ModelHighAPI_RefAttr & theLine);
369 /// Set constraint value
372 const std::shared_ptr<ModelHighAPI_Interface> & theConstraint,
373 const ModelHighAPI_Double & theValue);
375 // TODO(spo): rename to selectFaces() or faces() (or add faces() -> list to SWIG)
378 std::list<ModelHighAPI_Selection> selectFace() const;
380 /// Dump wrapped feature
382 virtual void dump(ModelHighAPI_Dumper& theDumper) const;
385 std::shared_ptr<ModelAPI_CompositeFeature> compositeFeature() const;
389 //! Pointer on Sketch object
390 typedef std::shared_ptr<SketchAPI_Sketch> SketchPtr;
392 /**\ingroup CPPHighAPI
393 * \brief Create Sketch feature
396 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
397 const std::shared_ptr<GeomAPI_Ax3> & thePlane);
399 /**\ingroup CPPHighAPI
400 * \brief Create Sketch feature
403 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
404 const ModelHighAPI_Selection & theExternal);
406 /**\ingroup CPPHighAPI
407 * \brief Create Sketch feature
410 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
411 const std::string & theExternalName);
413 /**\ingroup CPPHighAPI
414 * \brief Create Sketch feature
417 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
418 std::shared_ptr<ModelAPI_Object> thePlaneObject);
420 //--------------------------------------------------------------------------------------
421 //--------------------------------------------------------------------------------------
422 #endif /* SRC_SKETCHAPI_SKETCHAPI_SKETCH_H_ */