1 // Copyright (C) 2014-2017 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
20 #ifndef SRC_SKETCHAPI_SKETCHAPI_SKETCH_H_
21 #define SRC_SKETCHAPI_SKETCHAPI_SKETCH_H_
23 //--------------------------------------------------------------------------------------
24 #include "SketchAPI.h"
28 #include <SketchPlugin_Sketch.h>
29 #include <SketchPlugin_SketchEntity.h>
31 #include <ModelHighAPI_Interface.h>
32 #include <ModelHighAPI_Macro.h>
33 //--------------------------------------------------------------------------------------
34 class ModelAPI_CompositeFeature;
35 class ModelAPI_Object;
36 class ModelHighAPI_Double;
37 class ModelHighAPI_Integer;
38 class ModelHighAPI_RefAttr;
39 class ModelHighAPI_Reference;
40 class ModelHighAPI_Selection;
42 class SketchAPI_MacroArc;
43 class SketchAPI_Circle;
44 class SketchAPI_MacroCircle;
45 class SketchAPI_IntersectionPoint;
47 class SketchAPI_Mirror;
48 class SketchAPI_Point;
49 class SketchAPI_Projection;
50 class SketchAPI_Rectangle;
51 class SketchAPI_Rotation;
52 class SketchAPI_Translation;
53 //--------------------------------------------------------------------------------------
54 /**\class SketchAPI_Sketch
56 * \brief Interface for Sketch feature
58 class SketchAPI_Sketch : public ModelHighAPI_Interface
61 /// Constructor without values
63 explicit SketchAPI_Sketch(const std::shared_ptr<ModelAPI_Feature> & theFeature);
64 /// Constructor with values
66 SketchAPI_Sketch(const std::shared_ptr<ModelAPI_Feature> & theFeature,
67 const std::shared_ptr<GeomAPI_Ax3> & thePlane);
68 /// Constructor with values
70 SketchAPI_Sketch(const std::shared_ptr<ModelAPI_Feature> & theFeature,
71 const ModelHighAPI_Selection & theExternal);
72 /// Constructor with values
74 SketchAPI_Sketch(const std::shared_ptr<ModelAPI_Feature> & theFeature,
75 std::shared_ptr<ModelAPI_Object> thePlaneObject);
78 virtual ~SketchAPI_Sketch();
80 INTERFACE_7(SketchPlugin_Sketch::ID(),
81 origin, SketchPlugin_Sketch::ORIGIN_ID(),
82 GeomDataAPI_Point, /** Origin point */,
83 dirX, SketchPlugin_Sketch::DIRX_ID(),
84 GeomDataAPI_Dir, /** Direction of X */,
85 normal, SketchPlugin_Sketch::NORM_ID(),
86 GeomDataAPI_Dir, /** Normal */,
87 features, SketchPlugin_Sketch::FEATURES_ID(),
88 ModelAPI_AttributeRefList, /** Features */,
89 external, SketchPlugin_SketchEntity::EXTERNAL_ID(),
90 ModelAPI_AttributeSelection, /** External */,
91 solverError, SketchPlugin_Sketch::SOLVER_ERROR(),
92 ModelAPI_AttributeString, /** Solver error */,
93 solverDOF, SketchPlugin_Sketch::SOLVER_DOF(),
94 ModelAPI_AttributeString, /** Solver DOF */
99 void setPlane(const std::shared_ptr<GeomAPI_Ax3> & thePlane);
103 void setExternal(const ModelHighAPI_Selection & theExternal);
107 void setExternal(std::shared_ptr<ModelAPI_Object> thePlaneObject);
111 std::shared_ptr<SketchAPI_Point> addPoint(
112 double theX, double theY);
115 std::shared_ptr<SketchAPI_Point> addPoint(
116 const std::shared_ptr<GeomAPI_Pnt2d> & thePoint);
119 std::shared_ptr<SketchAPI_Point> addPoint(const ModelHighAPI_Selection & theExternal);
122 std::shared_ptr<SketchAPI_Point> addPoint(const std::string & theExternalName);
124 /// Add intersection point
126 std::shared_ptr<SketchAPI_IntersectionPoint>
127 addIntersectionPoint(const ModelHighAPI_Selection & theExternal);
130 std::shared_ptr<SketchAPI_IntersectionPoint>
131 addIntersectionPoint(const std::string & theExternalName);
135 std::shared_ptr<SketchAPI_Line> addLine(
136 double theX1, double theY1, double theX2, double theY2);
139 std::shared_ptr<SketchAPI_Line> addLine(
140 const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
141 const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint);
144 std::shared_ptr<SketchAPI_Line> addLine(const ModelHighAPI_Selection & theExternal);
147 std::shared_ptr<SketchAPI_Line> addLine(const std::string & theExternalName);
151 std::shared_ptr<SketchAPI_Rectangle> addRectangle(
152 double theX1, double theY1, double theX2, double theY2);
155 std::shared_ptr<SketchAPI_Rectangle> addRectangle(
156 const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
157 const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint);
161 std::shared_ptr<SketchAPI_Circle> addCircle(
162 double theCenterX, double theCenterY,
166 std::shared_ptr<SketchAPI_Circle> addCircle(
167 const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
171 std::shared_ptr<SketchAPI_MacroCircle> addCircle(
172 double theCenterX, double theCenterY,
173 double thePassedX, double thePassedY);
176 std::shared_ptr<SketchAPI_MacroCircle> addCircle(
177 const std::shared_ptr<GeomAPI_Pnt2d>& theCenterPoint,
178 const std::shared_ptr<GeomAPI_Pnt2d>& thePassedPoint);
181 std::shared_ptr<SketchAPI_MacroCircle> addCircle(
182 double theX1, double theY1,
183 double theX2, double theY2,
184 double theX3, double theY3);
187 std::shared_ptr<SketchAPI_MacroCircle> addCircle(
188 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint1,
189 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint2,
190 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint3);
193 std::shared_ptr<SketchAPI_Circle> addCircle(const ModelHighAPI_Selection & theExternal);
196 std::shared_ptr<SketchAPI_Circle> addCircle(const std::string & theExternalName);
200 std::shared_ptr<SketchAPI_Arc> addArc(
201 double theCenterX, double theCenterY,
202 double theStartX, double theStartY,
203 double theEndX, double theEndY,
208 std::shared_ptr<SketchAPI_Arc> addArc(
209 const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
210 const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
211 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
216 std::shared_ptr<SketchAPI_MacroArc> addArc(
217 double theStartX, double theStartY,
218 double theEndX, double theEndY,
219 double thePassedX, double thePassedY);
223 std::shared_ptr<SketchAPI_MacroArc> addArc(
224 const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
225 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
226 const std::shared_ptr<GeomAPI_Pnt2d>& thePassed);
230 std::shared_ptr<SketchAPI_MacroArc> addArc(
231 const ModelHighAPI_RefAttr& theTangentPoint,
232 double theEndX, double theEndY,
237 std::shared_ptr<SketchAPI_MacroArc> addArc(
238 const ModelHighAPI_RefAttr& theTangentPoint,
239 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
244 std::shared_ptr<SketchAPI_Arc> addArc(const ModelHighAPI_Selection & theExternal);
248 std::shared_ptr<SketchAPI_Arc> addArc(const std::string & theExternalName);
252 std::shared_ptr<SketchAPI_Projection> addProjection(
253 const ModelHighAPI_Selection & theExternalFeature);
257 std::shared_ptr<SketchAPI_Projection> addProjection(const std::string & theExternalName);
261 std::shared_ptr<SketchAPI_Mirror> addMirror(
262 const ModelHighAPI_RefAttr & theMirrorLine,
263 const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects);
267 std::shared_ptr<SketchAPI_Translation> addTranslation(
268 const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects,
269 const ModelHighAPI_RefAttr & thePoint1,
270 const ModelHighAPI_RefAttr & thePoint2,
271 const ModelHighAPI_Integer & theNumberOfObjects,
272 bool theFullValue = false);
276 std::shared_ptr<SketchAPI_Rotation> addRotation(
277 const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects,
278 const ModelHighAPI_RefAttr & theCenter,
279 const ModelHighAPI_Double & theAngle,
280 const ModelHighAPI_Integer & theNumberOfObjects,
281 bool theFullValue = false);
285 std::shared_ptr<ModelHighAPI_Interface> addSplit(
286 const ModelHighAPI_Reference& theFeature,
287 const std::shared_ptr<GeomAPI_Pnt2d>& thePositionPoint);
291 std::shared_ptr<ModelHighAPI_Interface> addTrim(
292 const ModelHighAPI_Reference& theFeature,
293 const std::shared_ptr<GeomAPI_Pnt2d>& thePositionPoint);
297 std::shared_ptr<ModelHighAPI_Interface> setAngle(
298 const ModelHighAPI_RefAttr & theLine1,
299 const ModelHighAPI_RefAttr & theLine2,
300 const ModelHighAPI_Double & theValue);
302 /// Set complementary angle
304 std::shared_ptr<ModelHighAPI_Interface> setAngleComplementary(
305 const ModelHighAPI_RefAttr & theLine1,
306 const ModelHighAPI_RefAttr & theLine2,
307 const ModelHighAPI_Double & theValue);
309 /// Set backward angle (= 360 - angle)
311 std::shared_ptr<ModelHighAPI_Interface> setAngleBackward(
312 const ModelHighAPI_RefAttr & theLine1,
313 const ModelHighAPI_RefAttr & theLine2,
314 const ModelHighAPI_Double & theValue);
318 std::shared_ptr<ModelHighAPI_Interface> setCoincident(
319 const ModelHighAPI_RefAttr & thePoint1,
320 const ModelHighAPI_RefAttr & thePoint2);
324 std::shared_ptr<ModelHighAPI_Interface> setCollinear(
325 const ModelHighAPI_RefAttr & theLine1,
326 const ModelHighAPI_RefAttr & theLine2);
330 std::shared_ptr<ModelHighAPI_Interface> setDistance(
331 const ModelHighAPI_RefAttr & thePoint,
332 const ModelHighAPI_RefAttr & thePointOrLine,
333 const ModelHighAPI_Double & theValue);
337 std::shared_ptr<ModelHighAPI_Interface> setEqual(
338 const ModelHighAPI_RefAttr & theObject1,
339 const ModelHighAPI_RefAttr & theObject2);
343 std::shared_ptr<ModelHighAPI_Interface> setFillet(
344 const ModelHighAPI_RefAttr & thePoint);
346 /// Set fillet with additional radius constraint
348 std::shared_ptr<ModelHighAPI_Interface> setFilletWithRadius(
349 const ModelHighAPI_RefAttr & thePoint,
350 const ModelHighAPI_Double & theRadius);
354 std::shared_ptr<ModelHighAPI_Interface> setFixed(
355 const ModelHighAPI_RefAttr & theObject);
359 std::shared_ptr<ModelHighAPI_Interface> setHorizontal(
360 const ModelHighAPI_RefAttr & theLine);
364 std::shared_ptr<ModelHighAPI_Interface> setLength(
365 const ModelHighAPI_RefAttr & theLine,
366 const ModelHighAPI_Double & theValue);
370 std::shared_ptr<ModelHighAPI_Interface> setMiddlePoint(
371 const ModelHighAPI_RefAttr & thePoint,
372 const ModelHighAPI_RefAttr & theLine);
376 std::shared_ptr<ModelHighAPI_Interface> setParallel(
377 const ModelHighAPI_RefAttr & theLine1,
378 const ModelHighAPI_RefAttr & theLine2);
380 /// Set perpendicular
382 std::shared_ptr<ModelHighAPI_Interface> setPerpendicular(
383 const ModelHighAPI_RefAttr & theLine1,
384 const ModelHighAPI_RefAttr & theLine2);
388 std::shared_ptr<ModelHighAPI_Interface> setRadius(
389 const ModelHighAPI_RefAttr & theCircleOrArc,
390 const ModelHighAPI_Double & theValue);
394 std::shared_ptr<ModelHighAPI_Interface> setTangent(
395 const ModelHighAPI_RefAttr & theLine,
396 const ModelHighAPI_RefAttr & theCircle);
400 std::shared_ptr<ModelHighAPI_Interface> setVertical(
401 const ModelHighAPI_RefAttr & theLine);
403 /// Set constraint value
406 const std::shared_ptr<ModelHighAPI_Interface> & theConstraint,
407 const ModelHighAPI_Double & theValue);
410 std::shared_ptr<GeomAPI_Pnt2d> to2D(const std::shared_ptr<GeomAPI_Pnt>& thePoint);
412 // TODO(spo): rename to selectFaces() or faces() (or add faces() -> list to SWIG)
415 std::list<ModelHighAPI_Selection> selectFace() const;
417 /// Dump wrapped feature
419 virtual void dump(ModelHighAPI_Dumper& theDumper) const;
422 std::shared_ptr<ModelAPI_CompositeFeature> compositeFeature() const;
426 //! Pointer on Sketch object
427 typedef std::shared_ptr<SketchAPI_Sketch> SketchPtr;
429 /**\ingroup CPPHighAPI
430 * \brief Create Sketch feature
433 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
434 const std::shared_ptr<GeomAPI_Ax3> & thePlane);
436 /**\ingroup CPPHighAPI
437 * \brief Create Sketch feature
440 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
441 const ModelHighAPI_Selection & theExternal);
443 /**\ingroup CPPHighAPI
444 * \brief Create Sketch feature
447 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
448 const std::string & theExternalName);
450 /**\ingroup CPPHighAPI
451 * \brief Create Sketch feature
454 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
455 std::shared_ptr<ModelAPI_Object> thePlaneObject);
457 //--------------------------------------------------------------------------------------
458 //--------------------------------------------------------------------------------------
459 #endif /* SRC_SKETCHAPI_SKETCHAPI_SKETCH_H_ */