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_MacroCircle;
32 class SketchAPI_IntersectionPoint;
34 class SketchAPI_Mirror;
35 class SketchAPI_Point;
36 class SketchAPI_Projection;
37 class SketchAPI_Rectangle;
38 class SketchAPI_Rotation;
39 class SketchAPI_Translation;
40 //--------------------------------------------------------------------------------------
41 /**\class SketchAPI_Sketch
43 * \brief Interface for Sketch feature
45 class SketchAPI_Sketch : public ModelHighAPI_Interface
48 /// Constructor without values
50 explicit SketchAPI_Sketch(const std::shared_ptr<ModelAPI_Feature> & theFeature);
51 /// Constructor with values
53 SketchAPI_Sketch(const std::shared_ptr<ModelAPI_Feature> & theFeature,
54 const std::shared_ptr<GeomAPI_Ax3> & thePlane);
55 /// Constructor with values
57 SketchAPI_Sketch(const std::shared_ptr<ModelAPI_Feature> & theFeature,
58 const ModelHighAPI_Selection & theExternal);
59 /// Constructor with values
61 SketchAPI_Sketch(const std::shared_ptr<ModelAPI_Feature> & theFeature,
62 std::shared_ptr<ModelAPI_Object> thePlaneObject);
65 virtual ~SketchAPI_Sketch();
67 INTERFACE_7(SketchPlugin_Sketch::ID(),
68 origin, SketchPlugin_Sketch::ORIGIN_ID(),
69 GeomDataAPI_Point, /** Origin point */,
70 dirX, SketchPlugin_Sketch::DIRX_ID(),
71 GeomDataAPI_Dir, /** Direction of X */,
72 normal, SketchPlugin_Sketch::NORM_ID(),
73 GeomDataAPI_Dir, /** Normal */,
74 features, SketchPlugin_Sketch::FEATURES_ID(),
75 ModelAPI_AttributeRefList, /** Features */,
76 external, SketchPlugin_SketchEntity::EXTERNAL_ID(),
77 ModelAPI_AttributeSelection, /** External */,
78 solverError, SketchPlugin_Sketch::SOLVER_ERROR(),
79 ModelAPI_AttributeString, /** Solver error */,
80 solverDOF, SketchPlugin_Sketch::SOLVER_DOF(),
81 ModelAPI_AttributeString, /** Solver DOF */
86 void setPlane(const std::shared_ptr<GeomAPI_Ax3> & thePlane);
90 void setExternal(const ModelHighAPI_Selection & theExternal);
94 void setExternal(std::shared_ptr<ModelAPI_Object> thePlaneObject);
98 std::shared_ptr<SketchAPI_Point> addPoint(
99 double theX, double theY);
102 std::shared_ptr<SketchAPI_Point> addPoint(
103 const std::shared_ptr<GeomAPI_Pnt2d> & thePoint);
106 std::shared_ptr<SketchAPI_Point> addPoint(const ModelHighAPI_Selection & theExternal);
109 std::shared_ptr<SketchAPI_Point> addPoint(const std::string & theExternalName);
111 /// Add intersection point
113 std::shared_ptr<SketchAPI_IntersectionPoint>
114 addIntersectionPoint(const ModelHighAPI_Selection & theExternal);
117 std::shared_ptr<SketchAPI_IntersectionPoint>
118 addIntersectionPoint(const std::string & theExternalName);
122 std::shared_ptr<SketchAPI_Line> addLine(
123 double theX1, double theY1, double theX2, double theY2);
126 std::shared_ptr<SketchAPI_Line> addLine(
127 const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
128 const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint);
131 std::shared_ptr<SketchAPI_Line> addLine(const ModelHighAPI_Selection & theExternal);
134 std::shared_ptr<SketchAPI_Line> addLine(const std::string & theExternalName);
138 std::shared_ptr<SketchAPI_Rectangle> addRectangle(
139 double theX1, double theY1, double theX2, double theY2);
142 std::shared_ptr<SketchAPI_Rectangle> addRectangle(
143 const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
144 const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint);
148 std::shared_ptr<SketchAPI_Circle> addCircle(
149 double theCenterX, double theCenterY,
153 std::shared_ptr<SketchAPI_Circle> addCircle(
154 const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
158 std::shared_ptr<SketchAPI_MacroCircle> addCircle(
159 double theCenterX, double theCenterY,
160 double thePassedX, double thePassedY);
163 std::shared_ptr<SketchAPI_MacroCircle> addCircle(
164 const std::shared_ptr<GeomAPI_Pnt2d>& theCenterPoint,
165 const std::shared_ptr<GeomAPI_Pnt2d>& thePassedPoint);
168 std::shared_ptr<SketchAPI_MacroCircle> addCircle(
169 double theX1, double theY1,
170 double theX2, double theY2,
171 double theX3, double theY3);
174 std::shared_ptr<SketchAPI_MacroCircle> addCircle(
175 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint1,
176 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint2,
177 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint3);
180 std::shared_ptr<SketchAPI_Circle> addCircle(const ModelHighAPI_Selection & theExternal);
183 std::shared_ptr<SketchAPI_Circle> addCircle(const std::string & theExternalName);
187 std::shared_ptr<SketchAPI_Arc> addArc(
188 double theCenterX, double theCenterY,
189 double theStartX, double theStartY,
190 double theEndX, double theEndY,
195 std::shared_ptr<SketchAPI_Arc> addArc(
196 const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
197 const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
198 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
203 std::shared_ptr<SketchAPI_Arc> addArc(
204 double theStartX, double theStartY,
205 double theEndX, double theEndY,
206 double thePassedX, double thePassedY);
210 std::shared_ptr<SketchAPI_Arc> addArc(
211 const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
212 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
213 const std::shared_ptr<GeomAPI_Pnt2d>& thePassed);
217 std::shared_ptr<SketchAPI_Arc> addArc(
218 const ModelHighAPI_RefAttr& theTangentPoint,
219 double theEndX, double theEndY,
224 std::shared_ptr<SketchAPI_Arc> addArc(
225 const ModelHighAPI_RefAttr& theTangentPoint,
226 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
231 std::shared_ptr<SketchAPI_Arc> addArc(const ModelHighAPI_Selection & theExternal);
235 std::shared_ptr<SketchAPI_Arc> addArc(const std::string & theExternalName);
239 std::shared_ptr<SketchAPI_Projection> addProjection(
240 const ModelHighAPI_Selection & theExternalFeature);
244 std::shared_ptr<SketchAPI_Projection> addProjection(const std::string & theExternalName);
248 std::shared_ptr<SketchAPI_Mirror> addMirror(
249 const ModelHighAPI_RefAttr & theMirrorLine,
250 const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects);
254 std::shared_ptr<SketchAPI_Translation> addTranslation(
255 const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects,
256 const ModelHighAPI_RefAttr & thePoint1,
257 const ModelHighAPI_RefAttr & thePoint2,
258 const ModelHighAPI_Integer & theNumberOfObjects,
259 bool theFullValue = false);
263 std::shared_ptr<SketchAPI_Rotation> addRotation(
264 const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects,
265 const ModelHighAPI_RefAttr & theCenter,
266 const ModelHighAPI_Double & theAngle,
267 const ModelHighAPI_Integer & theNumberOfObjects,
268 bool theFullValue = false);
272 std::shared_ptr<ModelHighAPI_Interface> addSplit(
273 const ModelHighAPI_Reference& theFeature,
274 const ModelHighAPI_RefAttr& thePoint1,
275 const ModelHighAPI_RefAttr& thePoint2);
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);
397 // TODO(spo): rename to selectFaces() or faces() (or add faces() -> list to SWIG)
400 std::list<ModelHighAPI_Selection> selectFace() const;
402 /// Dump wrapped feature
404 virtual void dump(ModelHighAPI_Dumper& theDumper) const;
407 std::shared_ptr<ModelAPI_CompositeFeature> compositeFeature() const;
411 //! Pointer on Sketch object
412 typedef std::shared_ptr<SketchAPI_Sketch> SketchPtr;
414 /**\ingroup CPPHighAPI
415 * \brief Create Sketch feature
418 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
419 const std::shared_ptr<GeomAPI_Ax3> & thePlane);
421 /**\ingroup CPPHighAPI
422 * \brief Create Sketch feature
425 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
426 const ModelHighAPI_Selection & theExternal);
428 /**\ingroup CPPHighAPI
429 * \brief Create Sketch feature
432 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
433 const std::string & theExternalName);
435 /**\ingroup CPPHighAPI
436 * \brief Create Sketch feature
439 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
440 std::shared_ptr<ModelAPI_Object> thePlaneObject);
442 //--------------------------------------------------------------------------------------
443 //--------------------------------------------------------------------------------------
444 #endif /* SRC_SKETCHAPI_SKETCHAPI_SKETCH_H_ */