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_MacroEllipticArc> addEllipticArc(
315 const std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr>& theCenter,
316 const std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr>& theMajorAxisPoint,
317 const std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr>& theStartPoint,
318 const std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr>& theEndPoint,
319 bool theInversed = false);
322 std::shared_ptr<SketchAPI_EllipticArc> addEllipticArc(const ModelHighAPI_Selection & theExternal);
325 std::shared_ptr<SketchAPI_EllipticArc> addEllipticArc(const std::string & theExternalName);
329 std::shared_ptr<SketchAPI_Projection> addProjection(
330 const ModelHighAPI_Selection & theExternalFeature,
331 bool theKeepResult = false);
335 std::shared_ptr<SketchAPI_Projection> addProjection(const std::string & theExternalName,
336 bool theKeepResult = false);
340 std::shared_ptr<SketchAPI_Mirror> addMirror(
341 const ModelHighAPI_RefAttr & theMirrorLine,
342 const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects);
346 std::shared_ptr<SketchAPI_Translation> addTranslation(
347 const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects,
348 const ModelHighAPI_RefAttr & thePoint1,
349 const ModelHighAPI_RefAttr & thePoint2,
350 const ModelHighAPI_Integer & theNumberOfObjects,
351 bool theFullValue = false);
355 std::shared_ptr<SketchAPI_Rotation> addRotation(
356 const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects,
357 const ModelHighAPI_RefAttr & theCenter,
358 const ModelHighAPI_Double & theAngle,
359 const ModelHighAPI_Integer & theNumberOfObjects,
360 bool theFullValue = false,
361 bool theReversed = false);
365 std::shared_ptr<ModelHighAPI_Interface> addSplit(
366 const ModelHighAPI_Reference& theFeature,
367 const std::shared_ptr<GeomAPI_Pnt2d>& thePositionPoint);
371 std::shared_ptr<ModelHighAPI_Interface> addTrim(
372 const ModelHighAPI_Reference& theFeature,
373 const std::shared_ptr<GeomAPI_Pnt2d>& thePositionPoint);
377 std::shared_ptr<ModelHighAPI_Interface> setAngle(
378 const ModelHighAPI_RefAttr & theLine1,
379 const ModelHighAPI_RefAttr & theLine2,
380 const ModelHighAPI_Double & theValue);
382 /// Set complementary angle
384 std::shared_ptr<ModelHighAPI_Interface> setAngleComplementary(
385 const ModelHighAPI_RefAttr & theLine1,
386 const ModelHighAPI_RefAttr & theLine2,
387 const ModelHighAPI_Double & theValue);
389 /// Set backward angle (= 360 - angle)
391 std::shared_ptr<ModelHighAPI_Interface> setAngleBackward(
392 const ModelHighAPI_RefAttr & theLine1,
393 const ModelHighAPI_RefAttr & theLine2,
394 const ModelHighAPI_Double & theValue);
398 std::shared_ptr<ModelHighAPI_Interface> setCoincident(
399 const ModelHighAPI_RefAttr & thePoint1,
400 const ModelHighAPI_RefAttr & thePoint2);
404 std::shared_ptr<ModelHighAPI_Interface> setCollinear(
405 const ModelHighAPI_RefAttr & theLine1,
406 const ModelHighAPI_RefAttr & theLine2);
410 std::shared_ptr<ModelHighAPI_Interface> setDistance(
411 const ModelHighAPI_RefAttr & thePoint,
412 const ModelHighAPI_RefAttr & thePointOrLine,
413 const ModelHighAPI_Double & theValue,
414 bool isSigned = false);
416 /// Set signed distance
418 std::shared_ptr<ModelHighAPI_Interface> setSignedDistance(
419 const ModelHighAPI_RefAttr & thePoint,
420 const ModelHighAPI_RefAttr & thePointOrLine,
421 const ModelHighAPI_Double & theValue);
423 /// Set unsigned distance
425 std::shared_ptr<ModelHighAPI_Interface> setUnsignedDistance(
426 const ModelHighAPI_RefAttr & thePoint,
427 const ModelHighAPI_RefAttr & thePointOrLine,
428 const ModelHighAPI_Double & theValue);
430 /// Set horizontal distance
432 std::shared_ptr<ModelHighAPI_Interface> setHorizontalDistance(
433 const ModelHighAPI_RefAttr & thePoint1,
434 const ModelHighAPI_RefAttr & thePoint2,
435 const ModelHighAPI_Double & theValue);
437 /// Set vertical distance
439 std::shared_ptr<ModelHighAPI_Interface> setVerticalDistance(
440 const ModelHighAPI_RefAttr & thePoint1,
441 const ModelHighAPI_RefAttr & thePoint2,
442 const ModelHighAPI_Double & theValue);
446 std::shared_ptr<ModelHighAPI_Interface> setEqual(
447 const ModelHighAPI_RefAttr & theObject1,
448 const ModelHighAPI_RefAttr & theObject2);
452 std::shared_ptr<ModelHighAPI_Interface> setFillet(
453 const ModelHighAPI_RefAttr & thePoint);
455 /// Set fillet with additional radius constraint
457 std::shared_ptr<ModelHighAPI_Interface> setFilletWithRadius(
458 const ModelHighAPI_RefAttr & thePoint,
459 const ModelHighAPI_Double & theRadius);
463 std::shared_ptr<ModelHighAPI_Interface> setFixed(
464 const ModelHighAPI_RefAttr & theObject);
468 std::shared_ptr<ModelHighAPI_Interface> setHorizontal(
469 const ModelHighAPI_RefAttr & theLine);
473 std::shared_ptr<ModelHighAPI_Interface> setLength(
474 const ModelHighAPI_RefAttr & theLine,
475 const ModelHighAPI_Double & theValue);
479 std::shared_ptr<ModelHighAPI_Interface> setMiddlePoint(
480 const ModelHighAPI_RefAttr & thePoint,
481 const ModelHighAPI_RefAttr & theLine);
485 std::shared_ptr<ModelHighAPI_Interface> setParallel(
486 const ModelHighAPI_RefAttr & theLine1,
487 const ModelHighAPI_RefAttr & theLine2);
489 /// Set perpendicular
491 std::shared_ptr<ModelHighAPI_Interface> setPerpendicular(
492 const ModelHighAPI_RefAttr & theLine1,
493 const ModelHighAPI_RefAttr & theLine2);
497 std::shared_ptr<ModelHighAPI_Interface> setRadius(
498 const ModelHighAPI_RefAttr & theCircleOrArc,
499 const ModelHighAPI_Double & theValue);
503 std::shared_ptr<ModelHighAPI_Interface> setTangent(
504 const ModelHighAPI_RefAttr & theLine,
505 const ModelHighAPI_RefAttr & theCircle);
509 std::shared_ptr<ModelHighAPI_Interface> setVertical(
510 const ModelHighAPI_RefAttr & theLine);
512 /// Set constraint value
515 const std::shared_ptr<ModelHighAPI_Interface> & theConstraint,
516 const ModelHighAPI_Double & theValue);
518 /// Move point or sketch feature
520 void move(const ModelHighAPI_RefAttr& theMovedEntity,
521 const std::shared_ptr<GeomAPI_Pnt2d>& theTargetPoint);
523 /// Move point or sketch feature
525 void move(const ModelHighAPI_RefAttr& theMovedEntity,
526 double theTargetX, double theTargetY);
529 std::shared_ptr<GeomAPI_Pnt2d> to2D(const std::shared_ptr<GeomAPI_Pnt>& thePoint);
531 // TODO(spo): rename to selectFaces() or faces() (or add faces() -> list to SWIG)
534 std::list<ModelHighAPI_Selection> selectFace() const;
536 /// Dump wrapped feature
538 virtual void dump(ModelHighAPI_Dumper& theDumper) const;
541 std::shared_ptr<ModelAPI_CompositeFeature> compositeFeature() const;
545 //! Pointer on Sketch object
546 typedef std::shared_ptr<SketchAPI_Sketch> SketchPtr;
548 /**\ingroup CPPHighAPI
549 * \brief Create Sketch feature
552 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
553 const std::shared_ptr<GeomAPI_Ax3> & thePlane);
555 /**\ingroup CPPHighAPI
556 * \brief Create Sketch feature
559 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
560 const ModelHighAPI_Selection & theExternal);
562 /**\ingroup CPPHighAPI
563 * \brief Create Sketch feature
566 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
567 const std::string & theExternalName);
569 /**\ingroup CPPHighAPI
570 * \brief Create Sketch feature
573 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
574 std::shared_ptr<ModelAPI_Object> thePlaneObject);
576 //--------------------------------------------------------------------------------------
577 //--------------------------------------------------------------------------------------
578 #endif /* SRC_SKETCHAPI_SKETCHAPI_SKETCH_H_ */