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_Ellipse;
46 class SketchAPI_MacroEllipse;
47 class SketchAPI_EllipticArc;
48 class SketchAPI_MacroEllipticArc;
49 class SketchAPI_IntersectionPoint;
51 class SketchAPI_Mirror;
52 class SketchAPI_Point;
53 class SketchAPI_Projection;
54 class SketchAPI_Rectangle;
55 class SketchAPI_Rotation;
56 class SketchAPI_Translation;
57 //--------------------------------------------------------------------------------------
58 /**\class SketchAPI_Sketch
60 * \brief Interface for Sketch feature
62 class SketchAPI_Sketch : public ModelHighAPI_Interface
65 /// Constructor without values
67 explicit SketchAPI_Sketch(const std::shared_ptr<ModelAPI_Feature> & theFeature);
68 /// Constructor with values
70 SketchAPI_Sketch(const std::shared_ptr<ModelAPI_Feature> & theFeature,
71 const std::shared_ptr<GeomAPI_Ax3> & thePlane);
72 /// Constructor with values
74 SketchAPI_Sketch(const std::shared_ptr<ModelAPI_Feature> & theFeature,
75 const ModelHighAPI_Selection & theExternal);
76 /// Constructor with values
78 SketchAPI_Sketch(const std::shared_ptr<ModelAPI_Feature> & theFeature,
79 std::shared_ptr<ModelAPI_Object> thePlaneObject);
82 virtual ~SketchAPI_Sketch();
84 INTERFACE_7(SketchPlugin_Sketch::ID(),
85 origin, SketchPlugin_Sketch::ORIGIN_ID(),
86 GeomDataAPI_Point, /** Origin point */,
87 dirX, SketchPlugin_Sketch::DIRX_ID(),
88 GeomDataAPI_Dir, /** Direction of X */,
89 normal, SketchPlugin_Sketch::NORM_ID(),
90 GeomDataAPI_Dir, /** Normal */,
91 features, SketchPlugin_Sketch::FEATURES_ID(),
92 ModelAPI_AttributeRefList, /** Features */,
93 external, SketchPlugin_SketchEntity::EXTERNAL_ID(),
94 ModelAPI_AttributeSelection, /** External */,
95 solverError, SketchPlugin_Sketch::SOLVER_ERROR(),
96 ModelAPI_AttributeString, /** Solver error */,
97 solverDOF, SketchPlugin_Sketch::SOLVER_DOF(),
98 ModelAPI_AttributeString, /** Solver DOF */
103 void setPlane(const std::shared_ptr<GeomAPI_Ax3> & thePlane);
105 /// Change sketch plane
107 void setPlane(const ModelHighAPI_Selection & thePlane,
108 bool theRemoveExternalDependency = false);
112 void setExternal(const ModelHighAPI_Selection & theExternal);
116 void setExternal(std::shared_ptr<ModelAPI_Object> thePlaneObject);
118 /// Change order of sketch results (faces)
120 void changeFacesOrder(const std::list<std::list<ModelHighAPI_Selection> >& theFaces);
122 /// List points not connected by constraints with other sketch entitites
124 std::list< std::shared_ptr<SketchAPI_Point> > getFreePoints();
128 std::shared_ptr<SketchAPI_Point> addPoint(
129 double theX, double theY);
132 std::shared_ptr<SketchAPI_Point> addPoint(
133 const std::shared_ptr<GeomAPI_Pnt2d> & thePoint);
136 std::shared_ptr<SketchAPI_Point> addPoint(const ModelHighAPI_Selection & theExternal);
139 std::shared_ptr<SketchAPI_Point> addPoint(const std::string & theExternalName);
141 /// Add intersection point
143 std::shared_ptr<SketchAPI_IntersectionPoint>
144 addIntersectionPoint(const ModelHighAPI_Selection & theExternal,
145 bool theKeepResult = false);
148 std::shared_ptr<SketchAPI_IntersectionPoint>
149 addIntersectionPoint(const std::string & theExternalName,
150 bool theKeepResult = false);
154 std::shared_ptr<SketchAPI_Line> addLine(
155 double theX1, double theY1, double theX2, double theY2);
158 std::shared_ptr<SketchAPI_Line> addLine(
159 const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
160 const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint);
163 std::shared_ptr<SketchAPI_Line> addLine(const ModelHighAPI_Selection & theExternal);
166 std::shared_ptr<SketchAPI_Line> addLine(const std::string & theExternalName);
170 std::shared_ptr<SketchAPI_Rectangle> addRectangle(
171 double theX1, double theY1, double theX2, double theY2);
174 std::shared_ptr<SketchAPI_Rectangle> addRectangle(
175 const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
176 const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint);
180 std::shared_ptr<SketchAPI_Circle> addCircle(
181 double theCenterX, double theCenterY,
185 std::shared_ptr<SketchAPI_Circle> addCircle(
186 const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
190 std::shared_ptr<SketchAPI_MacroCircle> addCircle(
191 double theCenterX, double theCenterY,
192 double thePassedX, double thePassedY);
195 std::shared_ptr<SketchAPI_MacroCircle> addCircle(
196 const std::shared_ptr<GeomAPI_Pnt2d>& theCenterPoint,
197 const std::shared_ptr<GeomAPI_Pnt2d>& thePassedPoint);
200 std::shared_ptr<SketchAPI_MacroCircle> addCircle(
201 double theX1, double theY1,
202 double theX2, double theY2,
203 double theX3, double theY3);
206 std::shared_ptr<SketchAPI_MacroCircle> addCircle(
207 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint1,
208 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint2,
209 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint3);
212 std::shared_ptr<SketchAPI_Circle> addCircle(const ModelHighAPI_Selection & theExternal);
215 std::shared_ptr<SketchAPI_Circle> addCircle(const std::string & theExternalName);
219 std::shared_ptr<SketchAPI_Arc> addArc(
220 double theCenterX, double theCenterY,
221 double theStartX, double theStartY,
222 double theEndX, double theEndY,
227 std::shared_ptr<SketchAPI_Arc> addArc(
228 const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
229 const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
230 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
235 std::shared_ptr<SketchAPI_MacroArc> addArc(
236 double theStartX, double theStartY,
237 double theEndX, double theEndY,
238 double thePassedX, double thePassedY);
242 std::shared_ptr<SketchAPI_MacroArc> addArc(
243 const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
244 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
245 const std::shared_ptr<GeomAPI_Pnt2d>& thePassed);
247 /// Add transversal/tangent arc
249 std::shared_ptr<SketchAPI_MacroArc> addArc(
250 const ModelHighAPI_RefAttr& theConnectedPoint,
251 double theEndX, double theEndY,
253 bool theTransversal = false);
255 /// Add transversal/tangent arc
257 std::shared_ptr<SketchAPI_MacroArc> addArc(
258 const ModelHighAPI_RefAttr& theConnectedPoint,
259 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
261 bool theTransversal = false);
265 std::shared_ptr<SketchAPI_Arc> addArc(const ModelHighAPI_Selection & theExternal);
269 std::shared_ptr<SketchAPI_Arc> addArc(const std::string & theExternalName);
273 std::shared_ptr<SketchAPI_Ellipse> addEllipse(
274 double theCenterX, double theCenterY,
275 double theFocusX, double theFocusY,
276 double theMinorRadius);
279 std::shared_ptr<SketchAPI_Ellipse> addEllipse(
280 const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
281 const std::shared_ptr<GeomAPI_Pnt2d>& theFocus,
285 std::shared_ptr<SketchAPI_MacroEllipse> addEllipse(
286 double thePoint1X, double thePoint1Y,
287 double thePoint2X, double thePoint2Y,
288 double thePassedX, double thePassedY,
289 bool isPoint1Center = true);
292 std::shared_ptr<SketchAPI_MacroEllipse> addEllipse(
293 const std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr>& thePoint1,
294 const std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr>& thePoint2,
295 const std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr>& thePassedPoint,
296 bool isPoint1Center = true);
299 std::shared_ptr<SketchAPI_Ellipse> addEllipse(const ModelHighAPI_Selection & theExternal);
302 std::shared_ptr<SketchAPI_Ellipse> addEllipse(const std::string & theExternalName);
306 std::shared_ptr<SketchAPI_EllipticArc> addEllipticArc(
307 double theCenterX, double theCenterY,
308 double theFocusX, double theFocusY,
309 double theStartX, double theStartY,
310 double theEndX, double theEndY,
311 bool theInversed = false);
314 std::shared_ptr<SketchAPI_EllipticArc> addEllipticArc(
315 const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
316 const std::shared_ptr<GeomAPI_Pnt2d>& theFocus,
317 const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
318 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
319 bool theInversed = false);
322 std::shared_ptr<SketchAPI_MacroEllipticArc> addEllipticArc(
323 const std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr>& theCenter,
324 const std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr>& theMajorAxisPoint,
325 const std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr>& theStartPoint,
326 const std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr>& theEndPoint,
327 bool theInversed = false);
330 std::shared_ptr<SketchAPI_EllipticArc> addEllipticArc(const ModelHighAPI_Selection & theExternal);
333 std::shared_ptr<SketchAPI_EllipticArc> addEllipticArc(const std::string & theExternalName);
337 std::shared_ptr<SketchAPI_Projection> addProjection(
338 const ModelHighAPI_Selection & theExternalFeature,
339 bool theKeepResult = false);
343 std::shared_ptr<SketchAPI_Projection> addProjection(const std::string & theExternalName,
344 bool theKeepResult = false);
348 std::shared_ptr<SketchAPI_Mirror> addMirror(
349 const ModelHighAPI_RefAttr & theMirrorLine,
350 const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects);
354 std::shared_ptr<SketchAPI_Translation> addTranslation(
355 const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects,
356 const ModelHighAPI_RefAttr & thePoint1,
357 const ModelHighAPI_RefAttr & thePoint2,
358 const ModelHighAPI_Integer & theNumberOfObjects,
359 bool theFullValue = false);
363 std::shared_ptr<SketchAPI_Rotation> addRotation(
364 const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects,
365 const ModelHighAPI_RefAttr & theCenter,
366 const ModelHighAPI_Double & theAngle,
367 const ModelHighAPI_Integer & theNumberOfObjects,
368 bool theFullValue = false,
369 bool theReversed = false);
373 std::shared_ptr<ModelHighAPI_Interface> addSplit(
374 const ModelHighAPI_Reference& theFeature,
375 const std::shared_ptr<GeomAPI_Pnt2d>& thePositionPoint);
379 std::shared_ptr<ModelHighAPI_Interface> addTrim(
380 const ModelHighAPI_Reference& theFeature,
381 const std::shared_ptr<GeomAPI_Pnt2d>& thePositionPoint);
385 std::shared_ptr<ModelHighAPI_Interface> setAngle(
386 const ModelHighAPI_RefAttr & theLine1,
387 const ModelHighAPI_RefAttr & theLine2,
388 const ModelHighAPI_Double & theValue);
390 /// Set complementary angle
392 std::shared_ptr<ModelHighAPI_Interface> setAngleComplementary(
393 const ModelHighAPI_RefAttr & theLine1,
394 const ModelHighAPI_RefAttr & theLine2,
395 const ModelHighAPI_Double & theValue);
397 /// Set backward angle (= 360 - angle)
399 std::shared_ptr<ModelHighAPI_Interface> setAngleBackward(
400 const ModelHighAPI_RefAttr & theLine1,
401 const ModelHighAPI_RefAttr & theLine2,
402 const ModelHighAPI_Double & theValue);
406 std::shared_ptr<ModelHighAPI_Interface> setCoincident(
407 const ModelHighAPI_RefAttr & thePoint1,
408 const ModelHighAPI_RefAttr & thePoint2);
412 std::shared_ptr<ModelHighAPI_Interface> setCollinear(
413 const ModelHighAPI_RefAttr & theLine1,
414 const ModelHighAPI_RefAttr & theLine2);
418 std::shared_ptr<ModelHighAPI_Interface> setDistance(
419 const ModelHighAPI_RefAttr & thePoint,
420 const ModelHighAPI_RefAttr & thePointOrLine,
421 const ModelHighAPI_Double & theValue,
422 bool isSigned = false);
424 /// Set signed distance
426 std::shared_ptr<ModelHighAPI_Interface> setSignedDistance(
427 const ModelHighAPI_RefAttr & thePoint,
428 const ModelHighAPI_RefAttr & thePointOrLine,
429 const ModelHighAPI_Double & theValue);
431 /// Set unsigned distance
433 std::shared_ptr<ModelHighAPI_Interface> setUnsignedDistance(
434 const ModelHighAPI_RefAttr & thePoint,
435 const ModelHighAPI_RefAttr & thePointOrLine,
436 const ModelHighAPI_Double & theValue);
438 /// Set horizontal distance
440 std::shared_ptr<ModelHighAPI_Interface> setHorizontalDistance(
441 const ModelHighAPI_RefAttr & thePoint1,
442 const ModelHighAPI_RefAttr & thePoint2,
443 const ModelHighAPI_Double & theValue);
445 /// Set vertical distance
447 std::shared_ptr<ModelHighAPI_Interface> setVerticalDistance(
448 const ModelHighAPI_RefAttr & thePoint1,
449 const ModelHighAPI_RefAttr & thePoint2,
450 const ModelHighAPI_Double & theValue);
454 std::shared_ptr<ModelHighAPI_Interface> setEqual(
455 const ModelHighAPI_RefAttr & theObject1,
456 const ModelHighAPI_RefAttr & theObject2);
460 std::shared_ptr<ModelHighAPI_Interface> setFillet(
461 const ModelHighAPI_RefAttr & thePoint);
463 /// Set fillet with additional radius constraint
465 std::shared_ptr<ModelHighAPI_Interface> setFilletWithRadius(
466 const ModelHighAPI_RefAttr & thePoint,
467 const ModelHighAPI_Double & theRadius);
471 std::shared_ptr<ModelHighAPI_Interface> setFixed(
472 const ModelHighAPI_RefAttr & theObject);
476 std::shared_ptr<ModelHighAPI_Interface> setHorizontal(
477 const ModelHighAPI_RefAttr & theLine);
481 std::shared_ptr<ModelHighAPI_Interface> setLength(
482 const ModelHighAPI_RefAttr & theLine,
483 const ModelHighAPI_Double & theValue);
487 std::shared_ptr<ModelHighAPI_Interface> setMiddlePoint(
488 const ModelHighAPI_RefAttr & thePoint,
489 const ModelHighAPI_RefAttr & theLine);
493 std::shared_ptr<ModelHighAPI_Interface> setParallel(
494 const ModelHighAPI_RefAttr & theLine1,
495 const ModelHighAPI_RefAttr & theLine2);
497 /// Set perpendicular
499 std::shared_ptr<ModelHighAPI_Interface> setPerpendicular(
500 const ModelHighAPI_RefAttr & theLine1,
501 const ModelHighAPI_RefAttr & theLine2);
505 std::shared_ptr<ModelHighAPI_Interface> setRadius(
506 const ModelHighAPI_RefAttr & theCircleOrArc,
507 const ModelHighAPI_Double & theValue);
511 std::shared_ptr<ModelHighAPI_Interface> setTangent(
512 const ModelHighAPI_RefAttr & theLine,
513 const ModelHighAPI_RefAttr & theCircle);
517 std::shared_ptr<ModelHighAPI_Interface> setVertical(
518 const ModelHighAPI_RefAttr & theLine);
520 /// Set constraint value
523 const std::shared_ptr<ModelHighAPI_Interface> & theConstraint,
524 const ModelHighAPI_Double & theValue);
526 /// Move point or sketch feature
528 void move(const ModelHighAPI_RefAttr& theMovedEntity,
529 const std::shared_ptr<GeomAPI_Pnt2d>& theTargetPoint);
531 /// Move point or sketch feature
533 void move(const ModelHighAPI_RefAttr& theMovedEntity,
534 double theTargetX, double theTargetY);
537 std::shared_ptr<GeomAPI_Pnt2d> to2D(const std::shared_ptr<GeomAPI_Pnt>& thePoint);
539 // TODO(spo): rename to selectFaces() or faces() (or add faces() -> list to SWIG)
542 std::list<ModelHighAPI_Selection> selectFace() const;
544 /// Dump wrapped feature
546 virtual void dump(ModelHighAPI_Dumper& theDumper) const;
549 std::shared_ptr<ModelAPI_CompositeFeature> compositeFeature() const;
553 //! Pointer on Sketch object
554 typedef std::shared_ptr<SketchAPI_Sketch> SketchPtr;
556 /**\ingroup CPPHighAPI
557 * \brief Create Sketch feature
560 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
561 const std::shared_ptr<GeomAPI_Ax3> & thePlane);
563 /**\ingroup CPPHighAPI
564 * \brief Create Sketch feature
567 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
568 const ModelHighAPI_Selection & theExternal);
570 /**\ingroup CPPHighAPI
571 * \brief Create Sketch feature
574 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
575 const std::string & theExternalName);
577 /**\ingroup CPPHighAPI
578 * \brief Create Sketch feature
581 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
582 std::shared_ptr<ModelAPI_Object> thePlaneObject);
584 //--------------------------------------------------------------------------------------
585 //--------------------------------------------------------------------------------------
586 #endif /* SRC_SKETCHAPI_SKETCHAPI_SKETCH_H_ */