1 // Name : SketchAPI_Sketch.h
5 // 07/06/16 - Sergey POKHODENKO - Creation of the file
7 #ifndef SRC_SKETCHAPI_SKETCHAPI_SKETCH_H_
8 #define SRC_SKETCHAPI_SKETCHAPI_SKETCH_H_
10 //--------------------------------------------------------------------------------------
11 #include "SketchAPI.h"
15 #include <SketchPlugin_Sketch.h>
16 #include <SketchPlugin_SketchEntity.h>
18 #include <ModelHighAPI_Interface.h>
19 #include <ModelHighAPI_Macro.h>
20 //--------------------------------------------------------------------------------------
21 class ModelAPI_CompositeFeature;
22 class ModelAPI_Object;
23 class ModelHighAPI_Double;
24 class ModelHighAPI_Integer;
25 class ModelHighAPI_RefAttr;
26 class ModelHighAPI_Reference;
27 class ModelHighAPI_Selection;
29 class SketchAPI_Circle;
30 class SketchAPI_IntersectionPoint;
32 class SketchAPI_Mirror;
33 class SketchAPI_Point;
34 class SketchAPI_Projection;
35 class SketchAPI_Rectangle;
36 class SketchAPI_Rotation;
37 class SketchAPI_Translation;
38 //--------------------------------------------------------------------------------------
39 /**\class SketchAPI_Sketch
41 * \brief Interface for Sketch feature
43 class SketchAPI_Sketch : public ModelHighAPI_Interface
46 /// Constructor without values
48 explicit SketchAPI_Sketch(const std::shared_ptr<ModelAPI_Feature> & theFeature);
49 /// Constructor with values
51 SketchAPI_Sketch(const std::shared_ptr<ModelAPI_Feature> & theFeature,
52 const std::shared_ptr<GeomAPI_Ax3> & thePlane);
53 /// Constructor with values
55 SketchAPI_Sketch(const std::shared_ptr<ModelAPI_Feature> & theFeature,
56 const ModelHighAPI_Selection & theExternal);
57 /// Constructor with values
59 SketchAPI_Sketch(const std::shared_ptr<ModelAPI_Feature> & theFeature,
60 std::shared_ptr<ModelAPI_Object> thePlaneObject);
63 virtual ~SketchAPI_Sketch();
65 INTERFACE_7(SketchPlugin_Sketch::ID(),
66 origin, SketchPlugin_Sketch::ORIGIN_ID(), GeomDataAPI_Point, /** Origin point */,
67 dirX, SketchPlugin_Sketch::DIRX_ID(), GeomDataAPI_Dir, /** Direction of X */,
68 normal, SketchPlugin_Sketch::NORM_ID(), GeomDataAPI_Dir, /** Normal */,
69 features, SketchPlugin_Sketch::FEATURES_ID(), ModelAPI_AttributeRefList, /** Features */,
70 external, SketchPlugin_SketchEntity::EXTERNAL_ID(), ModelAPI_AttributeSelection, /** External */,
71 solverError, SketchPlugin_Sketch::SOLVER_ERROR(), ModelAPI_AttributeString, /** Solver error */,
72 solverDOF, SketchPlugin_Sketch::SOLVER_DOF(), ModelAPI_AttributeString, /** Solver DOF */
77 void setPlane(const std::shared_ptr<GeomAPI_Ax3> & thePlane);
81 void setExternal(const ModelHighAPI_Selection & theExternal);
85 void setExternal(std::shared_ptr<ModelAPI_Object> thePlaneObject);
89 std::shared_ptr<SketchAPI_Point> addPoint(
90 double theX, double theY);
93 std::shared_ptr<SketchAPI_Point> addPoint(
94 const std::shared_ptr<GeomAPI_Pnt2d> & thePoint);
97 std::shared_ptr<SketchAPI_Point> addPoint(const ModelHighAPI_Selection & theExternal);
100 std::shared_ptr<SketchAPI_Point> addPoint(const std::string & theExternalName);
102 /// Add intersection point
104 std::shared_ptr<SketchAPI_IntersectionPoint> addIntersectionPoint(const ModelHighAPI_Selection & theExternal);
107 std::shared_ptr<SketchAPI_IntersectionPoint> addIntersectionPoint(const std::string & theExternalName);
111 std::shared_ptr<SketchAPI_Line> addLine(
112 double theX1, double theY1, double theX2, double theY2);
115 std::shared_ptr<SketchAPI_Line> addLine(
116 const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
117 const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint);
120 std::shared_ptr<SketchAPI_Line> addLine(const ModelHighAPI_Selection & theExternal);
123 std::shared_ptr<SketchAPI_Line> addLine(const std::string & theExternalName);
127 std::shared_ptr<SketchAPI_Rectangle> addRectangle(
128 double theX1, double theY1, double theX2, double theY2);
131 std::shared_ptr<SketchAPI_Rectangle> addRectangle(
132 const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
133 const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint);
137 std::shared_ptr<SketchAPI_Circle> addCircle(
138 double theCenterX, double theCenterY,
142 std::shared_ptr<SketchAPI_Circle> addCircle(
143 const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
147 std::shared_ptr<SketchAPI_Circle> addCircle(
148 double theX1, double theY1,
149 double theX2, double theY2,
150 double theX3, double theY3);
153 std::shared_ptr<SketchAPI_Circle> addCircle(
154 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint1,
155 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint2,
156 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint3);
159 std::shared_ptr<SketchAPI_Circle> addCircle(const ModelHighAPI_Selection & theExternal);
162 std::shared_ptr<SketchAPI_Circle> addCircle(const std::string & theExternalName);
166 std::shared_ptr<SketchAPI_Arc> addArc(
167 double theCenterX, double theCenterY,
168 double theStartX, double theStartY,
169 double theEndX, double theEndY,
174 std::shared_ptr<SketchAPI_Arc> addArc(
175 const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
176 const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
177 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
182 std::shared_ptr<SketchAPI_Arc> addArc(
183 double theStartX, double theStartY,
184 double theEndX, double theEndY,
185 double thePassedX, double thePassedY);
189 std::shared_ptr<SketchAPI_Arc> addArc(
190 const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
191 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
192 const std::shared_ptr<GeomAPI_Pnt2d>& thePassed);
196 std::shared_ptr<SketchAPI_Arc> addArc(
197 const ModelHighAPI_RefAttr& theTangentPoint,
198 double theEndX, double theEndY,
203 std::shared_ptr<SketchAPI_Arc> addArc(
204 const ModelHighAPI_RefAttr& theTangentPoint,
205 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
210 std::shared_ptr<SketchAPI_Arc> addArc(const ModelHighAPI_Selection & theExternal);
214 std::shared_ptr<SketchAPI_Arc> addArc(const std::string & theExternalName);
218 std::shared_ptr<SketchAPI_Projection> addProjection(
219 const ModelHighAPI_Selection & theExternalFeature);
223 std::shared_ptr<SketchAPI_Projection> addProjection(const std::string & theExternalName);
227 std::shared_ptr<SketchAPI_Mirror> addMirror(
228 const ModelHighAPI_RefAttr & theMirrorLine,
229 const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects);
233 std::shared_ptr<SketchAPI_Translation> addTranslation(
234 const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects,
235 const ModelHighAPI_RefAttr & thePoint1,
236 const ModelHighAPI_RefAttr & thePoint2,
237 const ModelHighAPI_Integer & theNumberOfObjects,
238 bool theFullValue = false);
242 std::shared_ptr<SketchAPI_Rotation> addRotation(
243 const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects,
244 const ModelHighAPI_RefAttr & theCenter,
245 const ModelHighAPI_Double & theAngle,
246 const ModelHighAPI_Integer & theNumberOfObjects,
247 bool theFullValue = false);
251 std::shared_ptr<ModelHighAPI_Interface> addSplit(
252 const ModelHighAPI_Reference& theFeature,
253 const ModelHighAPI_RefAttr& thePoint1,
254 const ModelHighAPI_RefAttr& thePoint2);
258 std::shared_ptr<ModelHighAPI_Interface> setAngle(
259 const ModelHighAPI_RefAttr & theLine1,
260 const ModelHighAPI_RefAttr & theLine2,
261 const ModelHighAPI_Double & theValue);
263 /// Set complementary angle
265 std::shared_ptr<ModelHighAPI_Interface> setAngleComplementary(
266 const ModelHighAPI_RefAttr & theLine1,
267 const ModelHighAPI_RefAttr & theLine2,
268 const ModelHighAPI_Double & theValue);
270 /// Set backward angle (= 360 - angle)
272 std::shared_ptr<ModelHighAPI_Interface> setAngleBackward(
273 const ModelHighAPI_RefAttr & theLine1,
274 const ModelHighAPI_RefAttr & theLine2,
275 const ModelHighAPI_Double & theValue);
279 std::shared_ptr<ModelHighAPI_Interface> setCoincident(
280 const ModelHighAPI_RefAttr & thePoint1,
281 const ModelHighAPI_RefAttr & thePoint2);
285 std::shared_ptr<ModelHighAPI_Interface> setCollinear(
286 const ModelHighAPI_RefAttr & theLine1,
287 const ModelHighAPI_RefAttr & theLine2);
291 std::shared_ptr<ModelHighAPI_Interface> setDistance(
292 const ModelHighAPI_RefAttr & thePoint,
293 const ModelHighAPI_RefAttr & thePointOrLine,
294 const ModelHighAPI_Double & theValue);
298 std::shared_ptr<ModelHighAPI_Interface> setEqual(
299 const ModelHighAPI_RefAttr & theObject1,
300 const ModelHighAPI_RefAttr & theObject2);
304 std::shared_ptr<ModelHighAPI_Interface> setFillet(
305 const std::list<ModelHighAPI_RefAttr> & thePoints,
306 const ModelHighAPI_Double & theRadius);
310 std::shared_ptr<ModelHighAPI_Interface> setFixed(
311 const ModelHighAPI_RefAttr & theObject);
315 std::shared_ptr<ModelHighAPI_Interface> setHorizontal(
316 const ModelHighAPI_RefAttr & theLine);
320 std::shared_ptr<ModelHighAPI_Interface> setLength(
321 const ModelHighAPI_RefAttr & theLine,
322 const ModelHighAPI_Double & theValue);
326 std::shared_ptr<ModelHighAPI_Interface> setMiddlePoint(
327 const ModelHighAPI_RefAttr & thePoint,
328 const ModelHighAPI_RefAttr & theLine);
332 std::shared_ptr<ModelHighAPI_Interface> setParallel(
333 const ModelHighAPI_RefAttr & theLine1,
334 const ModelHighAPI_RefAttr & theLine2);
336 /// Set perpendicular
338 std::shared_ptr<ModelHighAPI_Interface> setPerpendicular(
339 const ModelHighAPI_RefAttr & theLine1,
340 const ModelHighAPI_RefAttr & theLine2);
344 std::shared_ptr<ModelHighAPI_Interface> setRadius(
345 const ModelHighAPI_RefAttr & theCircleOrArc,
346 const ModelHighAPI_Double & theValue);
350 std::shared_ptr<ModelHighAPI_Interface> setTangent(
351 const ModelHighAPI_RefAttr & theLine,
352 const ModelHighAPI_RefAttr & theCircle);
356 std::shared_ptr<ModelHighAPI_Interface> setVertical(
357 const ModelHighAPI_RefAttr & theLine);
359 /// Set constraint value
362 const std::shared_ptr<ModelHighAPI_Interface> & theConstraint,
363 const ModelHighAPI_Double & theValue);
365 // TODO(spo): rename to selectFaces() or faces() (or add faces() -> list to SWIG)
368 std::list<ModelHighAPI_Selection> selectFace() const;
370 /// Dump wrapped feature
372 virtual void dump(ModelHighAPI_Dumper& theDumper) const;
375 std::shared_ptr<ModelAPI_CompositeFeature> compositeFeature() const;
379 //! Pointer on Sketch object
380 typedef std::shared_ptr<SketchAPI_Sketch> SketchPtr;
382 /**\ingroup CPPHighAPI
383 * \brief Create Sketch feature
386 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
387 const std::shared_ptr<GeomAPI_Ax3> & thePlane);
389 /**\ingroup CPPHighAPI
390 * \brief Create Sketch feature
393 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
394 const ModelHighAPI_Selection & theExternal);
396 /**\ingroup CPPHighAPI
397 * \brief Create Sketch feature
400 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
401 const std::string & theExternalName);
403 /**\ingroup CPPHighAPI
404 * \brief Create Sketch feature
407 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
408 std::shared_ptr<ModelAPI_Object> thePlaneObject);
410 //--------------------------------------------------------------------------------------
411 //--------------------------------------------------------------------------------------
412 #endif /* SRC_SKETCHAPI_SKETCHAPI_SKETCH_H_ */