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_Selection;
28 class SketchAPI_Circle;
29 class SketchAPI_IntersectionPoint;
31 class SketchAPI_Mirror;
32 class SketchAPI_Point;
33 class SketchAPI_Projection;
34 class SketchAPI_Rectangle;
35 class SketchAPI_Rotation;
36 class SketchAPI_Translation;
37 //--------------------------------------------------------------------------------------
38 /**\class SketchAPI_Sketch
40 * \brief Interface for Sketch feature
42 class SketchAPI_Sketch : public ModelHighAPI_Interface
45 /// Constructor without values
47 explicit SketchAPI_Sketch(const std::shared_ptr<ModelAPI_Feature> & theFeature);
48 /// Constructor with values
50 SketchAPI_Sketch(const std::shared_ptr<ModelAPI_Feature> & theFeature,
51 const std::shared_ptr<GeomAPI_Ax3> & thePlane);
52 /// Constructor with values
54 SketchAPI_Sketch(const std::shared_ptr<ModelAPI_Feature> & theFeature,
55 const ModelHighAPI_Selection & theExternal);
58 virtual ~SketchAPI_Sketch();
60 INTERFACE_7(SketchPlugin_Sketch::ID(),
61 origin, SketchPlugin_Sketch::ORIGIN_ID(), GeomDataAPI_Point, /** Origin point */,
62 dirX, SketchPlugin_Sketch::DIRX_ID(), GeomDataAPI_Dir, /** Direction of X */,
63 normal, SketchPlugin_Sketch::NORM_ID(), GeomDataAPI_Dir, /** Normal */,
64 features, SketchPlugin_Sketch::FEATURES_ID(), ModelAPI_AttributeRefList, /** Features */,
65 external, SketchPlugin_SketchEntity::EXTERNAL_ID(), ModelAPI_AttributeSelection, /** External */,
66 solverError, SketchPlugin_Sketch::SOLVER_ERROR(), ModelAPI_AttributeString, /** Solver error */,
67 solverDOF, SketchPlugin_Sketch::SOLVER_DOF(), ModelAPI_AttributeString, /** Solver DOF */
72 void setPlane(const std::shared_ptr<GeomAPI_Ax3> & thePlane);
76 void setExternal(const ModelHighAPI_Selection & theExternal);
80 std::shared_ptr<SketchAPI_Point> addPoint(
81 double theX, double theY);
84 std::shared_ptr<SketchAPI_Point> addPoint(
85 const std::shared_ptr<GeomAPI_Pnt2d> & thePoint);
88 std::shared_ptr<SketchAPI_Point> addPoint(const ModelHighAPI_Selection & theExternal);
91 std::shared_ptr<SketchAPI_Point> addPoint(const std::string & theExternalName);
93 /// Add intersection point
95 std::shared_ptr<SketchAPI_IntersectionPoint> addIntersectionPoint(const ModelHighAPI_Selection & theExternal);
98 std::shared_ptr<SketchAPI_IntersectionPoint> addIntersectionPoint(const std::string & theExternalName);
102 std::shared_ptr<SketchAPI_Line> addLine(
103 double theX1, double theY1, double theX2, double theY2);
106 std::shared_ptr<SketchAPI_Line> addLine(
107 const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
108 const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint);
111 std::shared_ptr<SketchAPI_Line> addLine(const ModelHighAPI_Selection & theExternal);
114 std::shared_ptr<SketchAPI_Line> addLine(const std::string & theExternalName);
118 std::shared_ptr<SketchAPI_Rectangle> addRectangle(
119 double theX1, double theY1, double theX2, double theY2);
122 std::shared_ptr<SketchAPI_Rectangle> addRectangle(
123 const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
124 const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint);
128 std::shared_ptr<SketchAPI_Circle> addCircle(
129 double theCenterX, double theCenterY,
133 std::shared_ptr<SketchAPI_Circle> addCircle(
134 const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
138 std::shared_ptr<SketchAPI_Circle> addCircle(
139 double theX1, double theY1,
140 double theX2, double theY2,
141 double theX3, double theY3);
144 std::shared_ptr<SketchAPI_Circle> addCircle(
145 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint1,
146 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint2,
147 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint3);
150 std::shared_ptr<SketchAPI_Circle> addCircle(const ModelHighAPI_Selection & theExternal);
153 std::shared_ptr<SketchAPI_Circle> addCircle(const std::string & theExternalName);
157 std::shared_ptr<SketchAPI_Arc> addArc(
158 double theCenterX, double theCenterY,
159 double theStartX, double theStartY,
160 double theEndX, double theEndY,
165 std::shared_ptr<SketchAPI_Arc> addArc(
166 const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
167 const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
168 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
173 std::shared_ptr<SketchAPI_Arc> addArc(
174 double theStartX, double theStartY,
175 double theEndX, double theEndY,
176 double thePassedX, double thePassedY);
180 std::shared_ptr<SketchAPI_Arc> addArc(
181 const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
182 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
183 const std::shared_ptr<GeomAPI_Pnt2d>& thePassed);
187 std::shared_ptr<SketchAPI_Arc> addArc(
188 const ModelHighAPI_RefAttr& theTangentPoint,
189 double theEndX, double theEndY,
194 std::shared_ptr<SketchAPI_Arc> addArc(
195 const ModelHighAPI_RefAttr& theTangentPoint,
196 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
201 std::shared_ptr<SketchAPI_Arc> addArc(const ModelHighAPI_Selection & theExternal);
205 std::shared_ptr<SketchAPI_Arc> addArc(const std::string & theExternalName);
209 std::shared_ptr<SketchAPI_Projection> addProjection(
210 const ModelHighAPI_Selection & theExternalFeature);
214 std::shared_ptr<SketchAPI_Projection> addProjection(const std::string & theExternalName);
218 std::shared_ptr<SketchAPI_Mirror> addMirror(
219 const ModelHighAPI_RefAttr & theMirrorLine,
220 const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects);
224 std::shared_ptr<SketchAPI_Translation> addTranslation(
225 const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects,
226 const ModelHighAPI_RefAttr & thePoint1,
227 const ModelHighAPI_RefAttr & thePoint2,
228 const ModelHighAPI_Integer & theNumberOfObjects,
229 bool theFullValue = false);
233 std::shared_ptr<SketchAPI_Rotation> addRotation(
234 const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects,
235 const ModelHighAPI_RefAttr & theCenter,
236 const ModelHighAPI_Double & theAngle,
237 const ModelHighAPI_Integer & theNumberOfObjects,
238 bool theFullValue = false);
242 std::shared_ptr<ModelAPI_Feature> setAngle(
243 const ModelHighAPI_RefAttr & theLine1,
244 const ModelHighAPI_RefAttr & theLine2,
245 const ModelHighAPI_Double & theValue);
247 /// Set complementary angle
249 std::shared_ptr<ModelAPI_Feature> setAngleComplementary(
250 const ModelHighAPI_RefAttr & theLine1,
251 const ModelHighAPI_RefAttr & theLine2,
252 const ModelHighAPI_Double & theValue);
254 /// Set backward angle (= 360 - angle)
256 std::shared_ptr<ModelAPI_Feature> setAngleBackward(
257 const ModelHighAPI_RefAttr & theLine1,
258 const ModelHighAPI_RefAttr & theLine2,
259 const ModelHighAPI_Double & theValue);
263 std::shared_ptr<ModelAPI_Feature> setCoincident(
264 const ModelHighAPI_RefAttr & thePoint1,
265 const ModelHighAPI_RefAttr & thePoint2);
269 std::shared_ptr<ModelAPI_Feature> setCollinear(
270 const ModelHighAPI_RefAttr & theLine1,
271 const ModelHighAPI_RefAttr & theLine2);
275 std::shared_ptr<ModelAPI_Feature> setDistance(
276 const ModelHighAPI_RefAttr & thePoint,
277 const ModelHighAPI_RefAttr & thePointOrLine,
278 const ModelHighAPI_Double & theValue);
282 std::shared_ptr<ModelAPI_Feature> setEqual(
283 const ModelHighAPI_RefAttr & theObject1,
284 const ModelHighAPI_RefAttr & theObject2);
288 std::shared_ptr<ModelAPI_Feature> setFillet(
289 const std::list<ModelHighAPI_RefAttr> & thePoints,
290 const ModelHighAPI_Double & theRadius);
294 std::shared_ptr<ModelAPI_Feature> setFixed(
295 const ModelHighAPI_RefAttr & theObject);
299 std::shared_ptr<ModelAPI_Feature> setHorizontal(
300 const ModelHighAPI_RefAttr & theLine);
304 std::shared_ptr<ModelAPI_Feature> setLength(
305 const ModelHighAPI_RefAttr & theLine,
306 const ModelHighAPI_Double & theValue);
310 std::shared_ptr<ModelAPI_Feature> setMiddlePoint(
311 const ModelHighAPI_RefAttr & thePoint,
312 const ModelHighAPI_RefAttr & theLine);
316 std::shared_ptr<ModelAPI_Feature> setParallel(
317 const ModelHighAPI_RefAttr & theLine1,
318 const ModelHighAPI_RefAttr & theLine2);
320 /// Set perpendicular
322 std::shared_ptr<ModelAPI_Feature> setPerpendicular(
323 const ModelHighAPI_RefAttr & theLine1,
324 const ModelHighAPI_RefAttr & theLine2);
328 std::shared_ptr<ModelAPI_Feature> setRadius(
329 const ModelHighAPI_RefAttr & theCircleOrArc,
330 const ModelHighAPI_Double & theValue);
334 std::shared_ptr<ModelAPI_Feature> setTangent(
335 const ModelHighAPI_RefAttr & theLine,
336 const ModelHighAPI_RefAttr & theCircle);
340 std::shared_ptr<ModelAPI_Feature> setVertical(
341 const ModelHighAPI_RefAttr & theLine);
343 /// Set constraint value
346 const std::shared_ptr<ModelAPI_Feature> & theConstraint,
347 const ModelHighAPI_Double & theValue);
349 // TODO(spo): rename to selectFaces() or faces() (or add faces() -> list to SWIG)
352 std::list<ModelHighAPI_Selection> selectFace() const;
354 /// Dump wrapped feature
356 virtual void dump(ModelHighAPI_Dumper& theDumper) const;
359 std::shared_ptr<ModelAPI_CompositeFeature> compositeFeature() const;
363 //! Pointer on Sketch object
364 typedef std::shared_ptr<SketchAPI_Sketch> SketchPtr;
366 /**\ingroup CPPHighAPI
367 * \brief Create Sketch feature
370 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
371 const std::shared_ptr<GeomAPI_Ax3> & thePlane);
373 /**\ingroup CPPHighAPI
374 * \brief Create Sketch feature
377 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
378 const ModelHighAPI_Selection & theExternal);
380 /**\ingroup CPPHighAPI
381 * \brief Create Sketch feature
384 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
385 const std::string & theExternalName);
387 //--------------------------------------------------------------------------------------
388 //--------------------------------------------------------------------------------------
389 #endif /* SRC_SKETCHAPI_SKETCHAPI_SKETCH_H_ */