1 // Copyright (C) 2014-2019 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
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);
101 /// Change sketch plane
103 void setPlane(const ModelHighAPI_Selection & thePlane,
104 bool theRemoveExternalDependency = false);
108 void setExternal(const ModelHighAPI_Selection & theExternal);
112 void setExternal(std::shared_ptr<ModelAPI_Object> thePlaneObject);
116 std::shared_ptr<SketchAPI_Point> addPoint(
117 double theX, double theY);
120 std::shared_ptr<SketchAPI_Point> addPoint(
121 const std::shared_ptr<GeomAPI_Pnt2d> & thePoint);
124 std::shared_ptr<SketchAPI_Point> addPoint(const ModelHighAPI_Selection & theExternal);
127 std::shared_ptr<SketchAPI_Point> addPoint(const std::string & theExternalName);
129 /// Add intersection point
131 std::shared_ptr<SketchAPI_IntersectionPoint>
132 addIntersectionPoint(const ModelHighAPI_Selection & theExternal,
133 bool theKeepResult = false);
136 std::shared_ptr<SketchAPI_IntersectionPoint>
137 addIntersectionPoint(const std::string & theExternalName,
138 bool theKeepResult = false);
142 std::shared_ptr<SketchAPI_Line> addLine(
143 double theX1, double theY1, double theX2, double theY2);
146 std::shared_ptr<SketchAPI_Line> addLine(
147 const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
148 const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint);
151 std::shared_ptr<SketchAPI_Line> addLine(const ModelHighAPI_Selection & theExternal);
154 std::shared_ptr<SketchAPI_Line> addLine(const std::string & theExternalName);
158 std::shared_ptr<SketchAPI_Rectangle> addRectangle(
159 double theX1, double theY1, double theX2, double theY2);
162 std::shared_ptr<SketchAPI_Rectangle> addRectangle(
163 const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
164 const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint);
168 std::shared_ptr<SketchAPI_Circle> addCircle(
169 double theCenterX, double theCenterY,
173 std::shared_ptr<SketchAPI_Circle> addCircle(
174 const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
178 std::shared_ptr<SketchAPI_MacroCircle> addCircle(
179 double theCenterX, double theCenterY,
180 double thePassedX, double thePassedY);
183 std::shared_ptr<SketchAPI_MacroCircle> addCircle(
184 const std::shared_ptr<GeomAPI_Pnt2d>& theCenterPoint,
185 const std::shared_ptr<GeomAPI_Pnt2d>& thePassedPoint);
188 std::shared_ptr<SketchAPI_MacroCircle> addCircle(
189 double theX1, double theY1,
190 double theX2, double theY2,
191 double theX3, double theY3);
194 std::shared_ptr<SketchAPI_MacroCircle> addCircle(
195 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint1,
196 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint2,
197 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint3);
200 std::shared_ptr<SketchAPI_Circle> addCircle(const ModelHighAPI_Selection & theExternal);
203 std::shared_ptr<SketchAPI_Circle> addCircle(const std::string & theExternalName);
207 std::shared_ptr<SketchAPI_Arc> addArc(
208 double theCenterX, double theCenterY,
209 double theStartX, double theStartY,
210 double theEndX, double theEndY,
215 std::shared_ptr<SketchAPI_Arc> addArc(
216 const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
217 const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
218 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
223 std::shared_ptr<SketchAPI_MacroArc> addArc(
224 double theStartX, double theStartY,
225 double theEndX, double theEndY,
226 double thePassedX, double thePassedY);
230 std::shared_ptr<SketchAPI_MacroArc> addArc(
231 const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
232 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
233 const std::shared_ptr<GeomAPI_Pnt2d>& thePassed);
237 std::shared_ptr<SketchAPI_MacroArc> addArc(
238 const ModelHighAPI_RefAttr& theTangentPoint,
239 double theEndX, double theEndY,
244 std::shared_ptr<SketchAPI_MacroArc> addArc(
245 const ModelHighAPI_RefAttr& theTangentPoint,
246 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
251 std::shared_ptr<SketchAPI_Arc> addArc(const ModelHighAPI_Selection & theExternal);
255 std::shared_ptr<SketchAPI_Arc> addArc(const std::string & theExternalName);
259 std::shared_ptr<SketchAPI_Projection> addProjection(
260 const ModelHighAPI_Selection & theExternalFeature,
261 bool theKeepResult = false);
265 std::shared_ptr<SketchAPI_Projection> addProjection(const std::string & theExternalName,
266 bool theKeepResult = false);
270 std::shared_ptr<SketchAPI_Mirror> addMirror(
271 const ModelHighAPI_RefAttr & theMirrorLine,
272 const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects);
276 std::shared_ptr<SketchAPI_Translation> addTranslation(
277 const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects,
278 const ModelHighAPI_RefAttr & thePoint1,
279 const ModelHighAPI_RefAttr & thePoint2,
280 const ModelHighAPI_Integer & theNumberOfObjects,
281 bool theFullValue = false);
285 std::shared_ptr<SketchAPI_Rotation> addRotation(
286 const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects,
287 const ModelHighAPI_RefAttr & theCenter,
288 const ModelHighAPI_Double & theAngle,
289 const ModelHighAPI_Integer & theNumberOfObjects,
290 bool theFullValue = false,
291 bool theReversed = false);
295 std::shared_ptr<ModelHighAPI_Interface> addSplit(
296 const ModelHighAPI_Reference& theFeature,
297 const std::shared_ptr<GeomAPI_Pnt2d>& thePositionPoint);
301 std::shared_ptr<ModelHighAPI_Interface> addTrim(
302 const ModelHighAPI_Reference& theFeature,
303 const std::shared_ptr<GeomAPI_Pnt2d>& thePositionPoint);
307 std::shared_ptr<ModelHighAPI_Interface> setAngle(
308 const ModelHighAPI_RefAttr & theLine1,
309 const ModelHighAPI_RefAttr & theLine2,
310 const ModelHighAPI_Double & theValue);
312 /// Set complementary angle
314 std::shared_ptr<ModelHighAPI_Interface> setAngleComplementary(
315 const ModelHighAPI_RefAttr & theLine1,
316 const ModelHighAPI_RefAttr & theLine2,
317 const ModelHighAPI_Double & theValue);
319 /// Set backward angle (= 360 - angle)
321 std::shared_ptr<ModelHighAPI_Interface> setAngleBackward(
322 const ModelHighAPI_RefAttr & theLine1,
323 const ModelHighAPI_RefAttr & theLine2,
324 const ModelHighAPI_Double & theValue);
328 std::shared_ptr<ModelHighAPI_Interface> setCoincident(
329 const ModelHighAPI_RefAttr & thePoint1,
330 const ModelHighAPI_RefAttr & thePoint2);
334 std::shared_ptr<ModelHighAPI_Interface> setCollinear(
335 const ModelHighAPI_RefAttr & theLine1,
336 const ModelHighAPI_RefAttr & theLine2);
340 std::shared_ptr<ModelHighAPI_Interface> setDistance(
341 const ModelHighAPI_RefAttr & thePoint,
342 const ModelHighAPI_RefAttr & thePointOrLine,
343 const ModelHighAPI_Double & theValue,
344 bool isSigned = false);
346 /// Set signed distance
348 std::shared_ptr<ModelHighAPI_Interface> setSignedDistance(
349 const ModelHighAPI_RefAttr & thePoint,
350 const ModelHighAPI_RefAttr & thePointOrLine,
351 const ModelHighAPI_Double & theValue);
353 /// Set unsigned distance
355 std::shared_ptr<ModelHighAPI_Interface> setUnsignedDistance(
356 const ModelHighAPI_RefAttr & thePoint,
357 const ModelHighAPI_RefAttr & thePointOrLine,
358 const ModelHighAPI_Double & theValue);
360 /// Set horizontal distance
362 std::shared_ptr<ModelHighAPI_Interface> setHorizontalDistance(
363 const ModelHighAPI_RefAttr & thePoint1,
364 const ModelHighAPI_RefAttr & thePoint2,
365 const ModelHighAPI_Double & theValue);
367 /// Set vertical distance
369 std::shared_ptr<ModelHighAPI_Interface> setVerticalDistance(
370 const ModelHighAPI_RefAttr & thePoint1,
371 const ModelHighAPI_RefAttr & thePoint2,
372 const ModelHighAPI_Double & theValue);
376 std::shared_ptr<ModelHighAPI_Interface> setEqual(
377 const ModelHighAPI_RefAttr & theObject1,
378 const ModelHighAPI_RefAttr & theObject2);
382 std::shared_ptr<ModelHighAPI_Interface> setFillet(
383 const ModelHighAPI_RefAttr & thePoint);
385 /// Set fillet with additional radius constraint
387 std::shared_ptr<ModelHighAPI_Interface> setFilletWithRadius(
388 const ModelHighAPI_RefAttr & thePoint,
389 const ModelHighAPI_Double & theRadius);
393 std::shared_ptr<ModelHighAPI_Interface> setFixed(
394 const ModelHighAPI_RefAttr & theObject);
398 std::shared_ptr<ModelHighAPI_Interface> setHorizontal(
399 const ModelHighAPI_RefAttr & theLine);
403 std::shared_ptr<ModelHighAPI_Interface> setLength(
404 const ModelHighAPI_RefAttr & theLine,
405 const ModelHighAPI_Double & theValue);
409 std::shared_ptr<ModelHighAPI_Interface> setMiddlePoint(
410 const ModelHighAPI_RefAttr & thePoint,
411 const ModelHighAPI_RefAttr & theLine);
415 std::shared_ptr<ModelHighAPI_Interface> setParallel(
416 const ModelHighAPI_RefAttr & theLine1,
417 const ModelHighAPI_RefAttr & theLine2);
419 /// Set perpendicular
421 std::shared_ptr<ModelHighAPI_Interface> setPerpendicular(
422 const ModelHighAPI_RefAttr & theLine1,
423 const ModelHighAPI_RefAttr & theLine2);
427 std::shared_ptr<ModelHighAPI_Interface> setRadius(
428 const ModelHighAPI_RefAttr & theCircleOrArc,
429 const ModelHighAPI_Double & theValue);
433 std::shared_ptr<ModelHighAPI_Interface> setTangent(
434 const ModelHighAPI_RefAttr & theLine,
435 const ModelHighAPI_RefAttr & theCircle);
439 std::shared_ptr<ModelHighAPI_Interface> setVertical(
440 const ModelHighAPI_RefAttr & theLine);
442 /// Set constraint value
445 const std::shared_ptr<ModelHighAPI_Interface> & theConstraint,
446 const ModelHighAPI_Double & theValue);
448 /// Move point or sketch feature
450 void move(const ModelHighAPI_RefAttr& theMovedEntity,
451 const std::shared_ptr<GeomAPI_Pnt2d>& theTargetPoint);
453 /// Move point or sketch feature
455 void move(const ModelHighAPI_RefAttr& theMovedEntity,
456 double theTargetX, double theTargetY);
459 std::shared_ptr<GeomAPI_Pnt2d> to2D(const std::shared_ptr<GeomAPI_Pnt>& thePoint);
461 // TODO(spo): rename to selectFaces() or faces() (or add faces() -> list to SWIG)
464 std::list<ModelHighAPI_Selection> selectFace() const;
466 /// Dump wrapped feature
468 virtual void dump(ModelHighAPI_Dumper& theDumper) const;
471 std::shared_ptr<ModelAPI_CompositeFeature> compositeFeature() const;
475 //! Pointer on Sketch object
476 typedef std::shared_ptr<SketchAPI_Sketch> SketchPtr;
478 /**\ingroup CPPHighAPI
479 * \brief Create Sketch feature
482 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
483 const std::shared_ptr<GeomAPI_Ax3> & thePlane);
485 /**\ingroup CPPHighAPI
486 * \brief Create Sketch feature
489 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
490 const ModelHighAPI_Selection & theExternal);
492 /**\ingroup CPPHighAPI
493 * \brief Create Sketch feature
496 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
497 const std::string & theExternalName);
499 /**\ingroup CPPHighAPI
500 * \brief Create Sketch feature
503 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
504 std::shared_ptr<ModelAPI_Object> thePlaneObject);
506 //--------------------------------------------------------------------------------------
507 //--------------------------------------------------------------------------------------
508 #endif /* SRC_SKETCHAPI_SKETCHAPI_SKETCH_H_ */