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);
114 /// Change order of sketch results (faces)
116 void changeFacesOrder(const std::list<std::list<ModelHighAPI_Selection> >& theFaces);
118 /// List points not connected by constraints with other sketch entitites
120 std::list< std::shared_ptr<SketchAPI_Point> > getFreePoints();
124 std::shared_ptr<SketchAPI_Point> addPoint(
125 double theX, double theY);
128 std::shared_ptr<SketchAPI_Point> addPoint(
129 const std::shared_ptr<GeomAPI_Pnt2d> & thePoint);
132 std::shared_ptr<SketchAPI_Point> addPoint(const ModelHighAPI_Selection & theExternal);
135 std::shared_ptr<SketchAPI_Point> addPoint(const std::string & theExternalName);
137 /// Add intersection point
139 std::shared_ptr<SketchAPI_IntersectionPoint>
140 addIntersectionPoint(const ModelHighAPI_Selection & theExternal,
141 bool theKeepResult = false);
144 std::shared_ptr<SketchAPI_IntersectionPoint>
145 addIntersectionPoint(const std::string & theExternalName,
146 bool theKeepResult = false);
150 std::shared_ptr<SketchAPI_Line> addLine(
151 double theX1, double theY1, double theX2, double theY2);
154 std::shared_ptr<SketchAPI_Line> addLine(
155 const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
156 const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint);
159 std::shared_ptr<SketchAPI_Line> addLine(const ModelHighAPI_Selection & theExternal);
162 std::shared_ptr<SketchAPI_Line> addLine(const std::string & theExternalName);
166 std::shared_ptr<SketchAPI_Rectangle> addRectangle(
167 double theX1, double theY1, double theX2, double theY2);
170 std::shared_ptr<SketchAPI_Rectangle> addRectangle(
171 const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
172 const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint);
176 std::shared_ptr<SketchAPI_Circle> addCircle(
177 double theCenterX, double theCenterY,
181 std::shared_ptr<SketchAPI_Circle> addCircle(
182 const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
186 std::shared_ptr<SketchAPI_MacroCircle> addCircle(
187 double theCenterX, double theCenterY,
188 double thePassedX, double thePassedY);
191 std::shared_ptr<SketchAPI_MacroCircle> addCircle(
192 const std::shared_ptr<GeomAPI_Pnt2d>& theCenterPoint,
193 const std::shared_ptr<GeomAPI_Pnt2d>& thePassedPoint);
196 std::shared_ptr<SketchAPI_MacroCircle> addCircle(
197 double theX1, double theY1,
198 double theX2, double theY2,
199 double theX3, double theY3);
202 std::shared_ptr<SketchAPI_MacroCircle> addCircle(
203 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint1,
204 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint2,
205 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint3);
208 std::shared_ptr<SketchAPI_Circle> addCircle(const ModelHighAPI_Selection & theExternal);
211 std::shared_ptr<SketchAPI_Circle> addCircle(const std::string & theExternalName);
215 std::shared_ptr<SketchAPI_Arc> addArc(
216 double theCenterX, double theCenterY,
217 double theStartX, double theStartY,
218 double theEndX, double theEndY,
223 std::shared_ptr<SketchAPI_Arc> addArc(
224 const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
225 const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
226 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
231 std::shared_ptr<SketchAPI_MacroArc> addArc(
232 double theStartX, double theStartY,
233 double theEndX, double theEndY,
234 double thePassedX, double thePassedY);
238 std::shared_ptr<SketchAPI_MacroArc> addArc(
239 const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
240 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
241 const std::shared_ptr<GeomAPI_Pnt2d>& thePassed);
243 /// Add transversal/tangent arc
245 std::shared_ptr<SketchAPI_MacroArc> addArc(
246 const ModelHighAPI_RefAttr& theConnectedPoint,
247 double theEndX, double theEndY,
249 bool theTransversal = false);
251 /// Add transversal/tangent arc
253 std::shared_ptr<SketchAPI_MacroArc> addArc(
254 const ModelHighAPI_RefAttr& theConnectedPoint,
255 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
257 bool theTransversal = false);
261 std::shared_ptr<SketchAPI_Arc> addArc(const ModelHighAPI_Selection & theExternal);
265 std::shared_ptr<SketchAPI_Arc> addArc(const std::string & theExternalName);
269 std::shared_ptr<SketchAPI_Projection> addProjection(
270 const ModelHighAPI_Selection & theExternalFeature,
271 bool theKeepResult = false);
275 std::shared_ptr<SketchAPI_Projection> addProjection(const std::string & theExternalName,
276 bool theKeepResult = false);
280 std::shared_ptr<SketchAPI_Mirror> addMirror(
281 const ModelHighAPI_RefAttr & theMirrorLine,
282 const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects);
286 std::shared_ptr<SketchAPI_Translation> addTranslation(
287 const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects,
288 const ModelHighAPI_RefAttr & thePoint1,
289 const ModelHighAPI_RefAttr & thePoint2,
290 const ModelHighAPI_Integer & theNumberOfObjects,
291 bool theFullValue = false);
295 std::shared_ptr<SketchAPI_Rotation> addRotation(
296 const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects,
297 const ModelHighAPI_RefAttr & theCenter,
298 const ModelHighAPI_Double & theAngle,
299 const ModelHighAPI_Integer & theNumberOfObjects,
300 bool theFullValue = false,
301 bool theReversed = false);
305 std::shared_ptr<ModelHighAPI_Interface> addSplit(
306 const ModelHighAPI_Reference& theFeature,
307 const std::shared_ptr<GeomAPI_Pnt2d>& thePositionPoint);
311 std::shared_ptr<ModelHighAPI_Interface> addTrim(
312 const ModelHighAPI_Reference& theFeature,
313 const std::shared_ptr<GeomAPI_Pnt2d>& thePositionPoint);
317 std::shared_ptr<ModelHighAPI_Interface> setAngle(
318 const ModelHighAPI_RefAttr & theLine1,
319 const ModelHighAPI_RefAttr & theLine2,
320 const ModelHighAPI_Double & theValue);
322 /// Set complementary angle
324 std::shared_ptr<ModelHighAPI_Interface> setAngleComplementary(
325 const ModelHighAPI_RefAttr & theLine1,
326 const ModelHighAPI_RefAttr & theLine2,
327 const ModelHighAPI_Double & theValue);
329 /// Set backward angle (= 360 - angle)
331 std::shared_ptr<ModelHighAPI_Interface> setAngleBackward(
332 const ModelHighAPI_RefAttr & theLine1,
333 const ModelHighAPI_RefAttr & theLine2,
334 const ModelHighAPI_Double & theValue);
338 std::shared_ptr<ModelHighAPI_Interface> setCoincident(
339 const ModelHighAPI_RefAttr & thePoint1,
340 const ModelHighAPI_RefAttr & thePoint2);
344 std::shared_ptr<ModelHighAPI_Interface> setCollinear(
345 const ModelHighAPI_RefAttr & theLine1,
346 const ModelHighAPI_RefAttr & theLine2);
350 std::shared_ptr<ModelHighAPI_Interface> setDistance(
351 const ModelHighAPI_RefAttr & thePoint,
352 const ModelHighAPI_RefAttr & thePointOrLine,
353 const ModelHighAPI_Double & theValue,
354 bool isSigned = false);
356 /// Set signed distance
358 std::shared_ptr<ModelHighAPI_Interface> setSignedDistance(
359 const ModelHighAPI_RefAttr & thePoint,
360 const ModelHighAPI_RefAttr & thePointOrLine,
361 const ModelHighAPI_Double & theValue);
363 /// Set unsigned distance
365 std::shared_ptr<ModelHighAPI_Interface> setUnsignedDistance(
366 const ModelHighAPI_RefAttr & thePoint,
367 const ModelHighAPI_RefAttr & thePointOrLine,
368 const ModelHighAPI_Double & theValue);
370 /// Set horizontal distance
372 std::shared_ptr<ModelHighAPI_Interface> setHorizontalDistance(
373 const ModelHighAPI_RefAttr & thePoint1,
374 const ModelHighAPI_RefAttr & thePoint2,
375 const ModelHighAPI_Double & theValue);
377 /// Set vertical distance
379 std::shared_ptr<ModelHighAPI_Interface> setVerticalDistance(
380 const ModelHighAPI_RefAttr & thePoint1,
381 const ModelHighAPI_RefAttr & thePoint2,
382 const ModelHighAPI_Double & theValue);
386 std::shared_ptr<ModelHighAPI_Interface> setEqual(
387 const ModelHighAPI_RefAttr & theObject1,
388 const ModelHighAPI_RefAttr & theObject2);
392 std::shared_ptr<ModelHighAPI_Interface> setFillet(
393 const ModelHighAPI_RefAttr & thePoint);
395 /// Set fillet with additional radius constraint
397 std::shared_ptr<ModelHighAPI_Interface> setFilletWithRadius(
398 const ModelHighAPI_RefAttr & thePoint,
399 const ModelHighAPI_Double & theRadius);
403 std::shared_ptr<ModelHighAPI_Interface> setFixed(
404 const ModelHighAPI_RefAttr & theObject);
408 std::shared_ptr<ModelHighAPI_Interface> setHorizontal(
409 const ModelHighAPI_RefAttr & theLine);
413 std::shared_ptr<ModelHighAPI_Interface> setLength(
414 const ModelHighAPI_RefAttr & theLine,
415 const ModelHighAPI_Double & theValue);
419 std::shared_ptr<ModelHighAPI_Interface> setMiddlePoint(
420 const ModelHighAPI_RefAttr & thePoint,
421 const ModelHighAPI_RefAttr & theLine);
425 std::shared_ptr<ModelHighAPI_Interface> setParallel(
426 const ModelHighAPI_RefAttr & theLine1,
427 const ModelHighAPI_RefAttr & theLine2);
429 /// Set perpendicular
431 std::shared_ptr<ModelHighAPI_Interface> setPerpendicular(
432 const ModelHighAPI_RefAttr & theLine1,
433 const ModelHighAPI_RefAttr & theLine2);
437 std::shared_ptr<ModelHighAPI_Interface> setRadius(
438 const ModelHighAPI_RefAttr & theCircleOrArc,
439 const ModelHighAPI_Double & theValue);
443 std::shared_ptr<ModelHighAPI_Interface> setTangent(
444 const ModelHighAPI_RefAttr & theLine,
445 const ModelHighAPI_RefAttr & theCircle);
449 std::shared_ptr<ModelHighAPI_Interface> setVertical(
450 const ModelHighAPI_RefAttr & theLine);
452 /// Set constraint value
455 const std::shared_ptr<ModelHighAPI_Interface> & theConstraint,
456 const ModelHighAPI_Double & theValue);
458 /// Move point or sketch feature
460 void move(const ModelHighAPI_RefAttr& theMovedEntity,
461 const std::shared_ptr<GeomAPI_Pnt2d>& theTargetPoint);
463 /// Move point or sketch feature
465 void move(const ModelHighAPI_RefAttr& theMovedEntity,
466 double theTargetX, double theTargetY);
469 std::shared_ptr<GeomAPI_Pnt2d> to2D(const std::shared_ptr<GeomAPI_Pnt>& thePoint);
471 // TODO(spo): rename to selectFaces() or faces() (or add faces() -> list to SWIG)
474 std::list<ModelHighAPI_Selection> selectFace() const;
476 /// Dump wrapped feature
478 virtual void dump(ModelHighAPI_Dumper& theDumper) const;
481 std::shared_ptr<ModelAPI_CompositeFeature> compositeFeature() const;
485 //! Pointer on Sketch object
486 typedef std::shared_ptr<SketchAPI_Sketch> SketchPtr;
488 /**\ingroup CPPHighAPI
489 * \brief Create Sketch feature
492 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
493 const std::shared_ptr<GeomAPI_Ax3> & thePlane);
495 /**\ingroup CPPHighAPI
496 * \brief Create Sketch feature
499 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
500 const ModelHighAPI_Selection & theExternal);
502 /**\ingroup CPPHighAPI
503 * \brief Create Sketch feature
506 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
507 const std::string & theExternalName);
509 /**\ingroup CPPHighAPI
510 * \brief Create Sketch feature
513 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
514 std::shared_ptr<ModelAPI_Object> thePlaneObject);
516 //--------------------------------------------------------------------------------------
517 //--------------------------------------------------------------------------------------
518 #endif /* SRC_SKETCHAPI_SKETCHAPI_SKETCH_H_ */