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_IntersectionPoint;
49 class SketchAPI_Mirror;
50 class SketchAPI_Point;
51 class SketchAPI_Projection;
52 class SketchAPI_Rectangle;
53 class SketchAPI_Rotation;
54 class SketchAPI_Translation;
55 //--------------------------------------------------------------------------------------
56 /**\class SketchAPI_Sketch
58 * \brief Interface for Sketch feature
60 class SketchAPI_Sketch : public ModelHighAPI_Interface
63 /// Constructor without values
65 explicit SketchAPI_Sketch(const std::shared_ptr<ModelAPI_Feature> & theFeature);
66 /// Constructor with values
68 SketchAPI_Sketch(const std::shared_ptr<ModelAPI_Feature> & theFeature,
69 const std::shared_ptr<GeomAPI_Ax3> & thePlane);
70 /// Constructor with values
72 SketchAPI_Sketch(const std::shared_ptr<ModelAPI_Feature> & theFeature,
73 const ModelHighAPI_Selection & theExternal);
74 /// Constructor with values
76 SketchAPI_Sketch(const std::shared_ptr<ModelAPI_Feature> & theFeature,
77 std::shared_ptr<ModelAPI_Object> thePlaneObject);
80 virtual ~SketchAPI_Sketch();
82 INTERFACE_7(SketchPlugin_Sketch::ID(),
83 origin, SketchPlugin_Sketch::ORIGIN_ID(),
84 GeomDataAPI_Point, /** Origin point */,
85 dirX, SketchPlugin_Sketch::DIRX_ID(),
86 GeomDataAPI_Dir, /** Direction of X */,
87 normal, SketchPlugin_Sketch::NORM_ID(),
88 GeomDataAPI_Dir, /** Normal */,
89 features, SketchPlugin_Sketch::FEATURES_ID(),
90 ModelAPI_AttributeRefList, /** Features */,
91 external, SketchPlugin_SketchEntity::EXTERNAL_ID(),
92 ModelAPI_AttributeSelection, /** External */,
93 solverError, SketchPlugin_Sketch::SOLVER_ERROR(),
94 ModelAPI_AttributeString, /** Solver error */,
95 solverDOF, SketchPlugin_Sketch::SOLVER_DOF(),
96 ModelAPI_AttributeString, /** Solver DOF */
101 void setPlane(const std::shared_ptr<GeomAPI_Ax3> & thePlane);
103 /// Change sketch plane
105 void setPlane(const ModelHighAPI_Selection & thePlane,
106 bool theRemoveExternalDependency = false);
110 void setExternal(const ModelHighAPI_Selection & theExternal);
114 void setExternal(std::shared_ptr<ModelAPI_Object> thePlaneObject);
116 /// Change order of sketch results (faces)
118 void changeFacesOrder(const std::list<std::list<ModelHighAPI_Selection> >& theFaces);
120 /// List points not connected by constraints with other sketch entitites
122 std::list< std::shared_ptr<SketchAPI_Point> > getFreePoints();
126 std::shared_ptr<SketchAPI_Point> addPoint(
127 double theX, double theY);
130 std::shared_ptr<SketchAPI_Point> addPoint(
131 const std::shared_ptr<GeomAPI_Pnt2d> & thePoint);
134 std::shared_ptr<SketchAPI_Point> addPoint(const ModelHighAPI_Selection & theExternal);
137 std::shared_ptr<SketchAPI_Point> addPoint(const std::string & theExternalName);
139 /// Add intersection point
141 std::shared_ptr<SketchAPI_IntersectionPoint>
142 addIntersectionPoint(const ModelHighAPI_Selection & theExternal,
143 bool theKeepResult = false);
146 std::shared_ptr<SketchAPI_IntersectionPoint>
147 addIntersectionPoint(const std::string & theExternalName,
148 bool theKeepResult = false);
152 std::shared_ptr<SketchAPI_Line> addLine(
153 double theX1, double theY1, double theX2, double theY2);
156 std::shared_ptr<SketchAPI_Line> addLine(
157 const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
158 const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint);
161 std::shared_ptr<SketchAPI_Line> addLine(const ModelHighAPI_Selection & theExternal);
164 std::shared_ptr<SketchAPI_Line> addLine(const std::string & theExternalName);
168 std::shared_ptr<SketchAPI_Rectangle> addRectangle(
169 double theX1, double theY1, double theX2, double theY2);
172 std::shared_ptr<SketchAPI_Rectangle> addRectangle(
173 const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
174 const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint);
178 std::shared_ptr<SketchAPI_Circle> addCircle(
179 double theCenterX, double theCenterY,
183 std::shared_ptr<SketchAPI_Circle> addCircle(
184 const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
188 std::shared_ptr<SketchAPI_MacroCircle> addCircle(
189 double theCenterX, double theCenterY,
190 double thePassedX, double thePassedY);
193 std::shared_ptr<SketchAPI_MacroCircle> addCircle(
194 const std::shared_ptr<GeomAPI_Pnt2d>& theCenterPoint,
195 const std::shared_ptr<GeomAPI_Pnt2d>& thePassedPoint);
198 std::shared_ptr<SketchAPI_MacroCircle> addCircle(
199 double theX1, double theY1,
200 double theX2, double theY2,
201 double theX3, double theY3);
204 std::shared_ptr<SketchAPI_MacroCircle> addCircle(
205 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint1,
206 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint2,
207 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint3);
210 std::shared_ptr<SketchAPI_Circle> addCircle(const ModelHighAPI_Selection & theExternal);
213 std::shared_ptr<SketchAPI_Circle> addCircle(const std::string & theExternalName);
217 std::shared_ptr<SketchAPI_Arc> addArc(
218 double theCenterX, double theCenterY,
219 double theStartX, double theStartY,
220 double theEndX, double theEndY,
225 std::shared_ptr<SketchAPI_Arc> addArc(
226 const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
227 const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
228 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
233 std::shared_ptr<SketchAPI_MacroArc> addArc(
234 double theStartX, double theStartY,
235 double theEndX, double theEndY,
236 double thePassedX, double thePassedY);
240 std::shared_ptr<SketchAPI_MacroArc> addArc(
241 const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
242 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
243 const std::shared_ptr<GeomAPI_Pnt2d>& thePassed);
245 /// Add transversal/tangent arc
247 std::shared_ptr<SketchAPI_MacroArc> addArc(
248 const ModelHighAPI_RefAttr& theConnectedPoint,
249 double theEndX, double theEndY,
251 bool theTransversal = false);
253 /// Add transversal/tangent arc
255 std::shared_ptr<SketchAPI_MacroArc> addArc(
256 const ModelHighAPI_RefAttr& theConnectedPoint,
257 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
259 bool theTransversal = false);
263 std::shared_ptr<SketchAPI_Arc> addArc(const ModelHighAPI_Selection & theExternal);
267 std::shared_ptr<SketchAPI_Arc> addArc(const std::string & theExternalName);
271 std::shared_ptr<SketchAPI_Ellipse> addEllipse(
272 double theCenterX, double theCenterY,
273 double theFocusX, double theFocusY,
274 double theMinorRadius);
277 std::shared_ptr<SketchAPI_Ellipse> addEllipse(
278 const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
279 const std::shared_ptr<GeomAPI_Pnt2d>& theFocus,
283 std::shared_ptr<SketchAPI_MacroEllipse> addEllipse(
284 double thePoint1X, double thePoint1Y,
285 double thePoint2X, double thePoint2Y,
286 double thePassedX, double thePassedY,
287 bool isPoint1Center = true);
290 std::shared_ptr<SketchAPI_MacroEllipse> addEllipse(
291 const std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr>& thePoint1,
292 const std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr>& thePoint2,
293 const std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr>& thePassedPoint,
294 bool isPoint1Center = true);
297 std::shared_ptr<SketchAPI_Ellipse> addEllipse(const ModelHighAPI_Selection & theExternal);
300 std::shared_ptr<SketchAPI_Ellipse> addEllipse(const std::string & theExternalName);
304 std::shared_ptr<SketchAPI_Projection> addProjection(
305 const ModelHighAPI_Selection & theExternalFeature,
306 bool theKeepResult = false);
310 std::shared_ptr<SketchAPI_Projection> addProjection(const std::string & theExternalName,
311 bool theKeepResult = false);
315 std::shared_ptr<SketchAPI_Mirror> addMirror(
316 const ModelHighAPI_RefAttr & theMirrorLine,
317 const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects);
321 std::shared_ptr<SketchAPI_Translation> addTranslation(
322 const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects,
323 const ModelHighAPI_RefAttr & thePoint1,
324 const ModelHighAPI_RefAttr & thePoint2,
325 const ModelHighAPI_Integer & theNumberOfObjects,
326 bool theFullValue = false);
330 std::shared_ptr<SketchAPI_Rotation> addRotation(
331 const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects,
332 const ModelHighAPI_RefAttr & theCenter,
333 const ModelHighAPI_Double & theAngle,
334 const ModelHighAPI_Integer & theNumberOfObjects,
335 bool theFullValue = false,
336 bool theReversed = false);
340 std::shared_ptr<ModelHighAPI_Interface> addSplit(
341 const ModelHighAPI_Reference& theFeature,
342 const std::shared_ptr<GeomAPI_Pnt2d>& thePositionPoint);
346 std::shared_ptr<ModelHighAPI_Interface> addTrim(
347 const ModelHighAPI_Reference& theFeature,
348 const std::shared_ptr<GeomAPI_Pnt2d>& thePositionPoint);
352 std::shared_ptr<ModelHighAPI_Interface> setAngle(
353 const ModelHighAPI_RefAttr & theLine1,
354 const ModelHighAPI_RefAttr & theLine2,
355 const ModelHighAPI_Double & theValue);
357 /// Set complementary angle
359 std::shared_ptr<ModelHighAPI_Interface> setAngleComplementary(
360 const ModelHighAPI_RefAttr & theLine1,
361 const ModelHighAPI_RefAttr & theLine2,
362 const ModelHighAPI_Double & theValue);
364 /// Set backward angle (= 360 - angle)
366 std::shared_ptr<ModelHighAPI_Interface> setAngleBackward(
367 const ModelHighAPI_RefAttr & theLine1,
368 const ModelHighAPI_RefAttr & theLine2,
369 const ModelHighAPI_Double & theValue);
373 std::shared_ptr<ModelHighAPI_Interface> setCoincident(
374 const ModelHighAPI_RefAttr & thePoint1,
375 const ModelHighAPI_RefAttr & thePoint2);
379 std::shared_ptr<ModelHighAPI_Interface> setCollinear(
380 const ModelHighAPI_RefAttr & theLine1,
381 const ModelHighAPI_RefAttr & theLine2);
385 std::shared_ptr<ModelHighAPI_Interface> setDistance(
386 const ModelHighAPI_RefAttr & thePoint,
387 const ModelHighAPI_RefAttr & thePointOrLine,
388 const ModelHighAPI_Double & theValue,
389 bool isSigned = false);
391 /// Set signed distance
393 std::shared_ptr<ModelHighAPI_Interface> setSignedDistance(
394 const ModelHighAPI_RefAttr & thePoint,
395 const ModelHighAPI_RefAttr & thePointOrLine,
396 const ModelHighAPI_Double & theValue);
398 /// Set unsigned distance
400 std::shared_ptr<ModelHighAPI_Interface> setUnsignedDistance(
401 const ModelHighAPI_RefAttr & thePoint,
402 const ModelHighAPI_RefAttr & thePointOrLine,
403 const ModelHighAPI_Double & theValue);
405 /// Set horizontal distance
407 std::shared_ptr<ModelHighAPI_Interface> setHorizontalDistance(
408 const ModelHighAPI_RefAttr & thePoint1,
409 const ModelHighAPI_RefAttr & thePoint2,
410 const ModelHighAPI_Double & theValue);
412 /// Set vertical distance
414 std::shared_ptr<ModelHighAPI_Interface> setVerticalDistance(
415 const ModelHighAPI_RefAttr & thePoint1,
416 const ModelHighAPI_RefAttr & thePoint2,
417 const ModelHighAPI_Double & theValue);
421 std::shared_ptr<ModelHighAPI_Interface> setEqual(
422 const ModelHighAPI_RefAttr & theObject1,
423 const ModelHighAPI_RefAttr & theObject2);
427 std::shared_ptr<ModelHighAPI_Interface> setFillet(
428 const ModelHighAPI_RefAttr & thePoint);
430 /// Set fillet with additional radius constraint
432 std::shared_ptr<ModelHighAPI_Interface> setFilletWithRadius(
433 const ModelHighAPI_RefAttr & thePoint,
434 const ModelHighAPI_Double & theRadius);
438 std::shared_ptr<ModelHighAPI_Interface> setFixed(
439 const ModelHighAPI_RefAttr & theObject);
443 std::shared_ptr<ModelHighAPI_Interface> setHorizontal(
444 const ModelHighAPI_RefAttr & theLine);
448 std::shared_ptr<ModelHighAPI_Interface> setLength(
449 const ModelHighAPI_RefAttr & theLine,
450 const ModelHighAPI_Double & theValue);
454 std::shared_ptr<ModelHighAPI_Interface> setMiddlePoint(
455 const ModelHighAPI_RefAttr & thePoint,
456 const ModelHighAPI_RefAttr & theLine);
460 std::shared_ptr<ModelHighAPI_Interface> setParallel(
461 const ModelHighAPI_RefAttr & theLine1,
462 const ModelHighAPI_RefAttr & theLine2);
464 /// Set perpendicular
466 std::shared_ptr<ModelHighAPI_Interface> setPerpendicular(
467 const ModelHighAPI_RefAttr & theLine1,
468 const ModelHighAPI_RefAttr & theLine2);
472 std::shared_ptr<ModelHighAPI_Interface> setRadius(
473 const ModelHighAPI_RefAttr & theCircleOrArc,
474 const ModelHighAPI_Double & theValue);
478 std::shared_ptr<ModelHighAPI_Interface> setTangent(
479 const ModelHighAPI_RefAttr & theLine,
480 const ModelHighAPI_RefAttr & theCircle);
484 std::shared_ptr<ModelHighAPI_Interface> setVertical(
485 const ModelHighAPI_RefAttr & theLine);
487 /// Set constraint value
490 const std::shared_ptr<ModelHighAPI_Interface> & theConstraint,
491 const ModelHighAPI_Double & theValue);
493 /// Move point or sketch feature
495 void move(const ModelHighAPI_RefAttr& theMovedEntity,
496 const std::shared_ptr<GeomAPI_Pnt2d>& theTargetPoint);
498 /// Move point or sketch feature
500 void move(const ModelHighAPI_RefAttr& theMovedEntity,
501 double theTargetX, double theTargetY);
504 std::shared_ptr<GeomAPI_Pnt2d> to2D(const std::shared_ptr<GeomAPI_Pnt>& thePoint);
506 // TODO(spo): rename to selectFaces() or faces() (or add faces() -> list to SWIG)
509 std::list<ModelHighAPI_Selection> selectFace() const;
511 /// Dump wrapped feature
513 virtual void dump(ModelHighAPI_Dumper& theDumper) const;
516 std::shared_ptr<ModelAPI_CompositeFeature> compositeFeature() const;
520 //! Pointer on Sketch object
521 typedef std::shared_ptr<SketchAPI_Sketch> SketchPtr;
523 /**\ingroup CPPHighAPI
524 * \brief Create Sketch feature
527 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
528 const std::shared_ptr<GeomAPI_Ax3> & thePlane);
530 /**\ingroup CPPHighAPI
531 * \brief Create Sketch feature
534 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
535 const ModelHighAPI_Selection & theExternal);
537 /**\ingroup CPPHighAPI
538 * \brief Create Sketch feature
541 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
542 const std::string & theExternalName);
544 /**\ingroup CPPHighAPI
545 * \brief Create Sketch feature
548 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
549 std::shared_ptr<ModelAPI_Object> thePlaneObject);
551 //--------------------------------------------------------------------------------------
552 //--------------------------------------------------------------------------------------
553 #endif /* SRC_SKETCHAPI_SKETCHAPI_SKETCH_H_ */