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);
245 std::shared_ptr<SketchAPI_MacroArc> addArc(
246 const ModelHighAPI_RefAttr& theTangentPoint,
247 double theEndX, double theEndY,
252 std::shared_ptr<SketchAPI_MacroArc> addArc(
253 const ModelHighAPI_RefAttr& theTangentPoint,
254 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
259 std::shared_ptr<SketchAPI_Arc> addArc(const ModelHighAPI_Selection & theExternal);
263 std::shared_ptr<SketchAPI_Arc> addArc(const std::string & theExternalName);
267 std::shared_ptr<SketchAPI_Projection> addProjection(
268 const ModelHighAPI_Selection & theExternalFeature,
269 bool theKeepResult = false);
273 std::shared_ptr<SketchAPI_Projection> addProjection(const std::string & theExternalName,
274 bool theKeepResult = false);
278 std::shared_ptr<SketchAPI_Mirror> addMirror(
279 const ModelHighAPI_RefAttr & theMirrorLine,
280 const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects);
284 std::shared_ptr<SketchAPI_Translation> addTranslation(
285 const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects,
286 const ModelHighAPI_RefAttr & thePoint1,
287 const ModelHighAPI_RefAttr & thePoint2,
288 const ModelHighAPI_Integer & theNumberOfObjects,
289 bool theFullValue = false);
293 std::shared_ptr<SketchAPI_Rotation> addRotation(
294 const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects,
295 const ModelHighAPI_RefAttr & theCenter,
296 const ModelHighAPI_Double & theAngle,
297 const ModelHighAPI_Integer & theNumberOfObjects,
298 bool theFullValue = false,
299 bool theReversed = false);
303 std::shared_ptr<ModelHighAPI_Interface> addSplit(
304 const ModelHighAPI_Reference& theFeature,
305 const std::shared_ptr<GeomAPI_Pnt2d>& thePositionPoint);
309 std::shared_ptr<ModelHighAPI_Interface> addTrim(
310 const ModelHighAPI_Reference& theFeature,
311 const std::shared_ptr<GeomAPI_Pnt2d>& thePositionPoint);
315 std::shared_ptr<ModelHighAPI_Interface> setAngle(
316 const ModelHighAPI_RefAttr & theLine1,
317 const ModelHighAPI_RefAttr & theLine2,
318 const ModelHighAPI_Double & theValue);
320 /// Set complementary angle
322 std::shared_ptr<ModelHighAPI_Interface> setAngleComplementary(
323 const ModelHighAPI_RefAttr & theLine1,
324 const ModelHighAPI_RefAttr & theLine2,
325 const ModelHighAPI_Double & theValue);
327 /// Set backward angle (= 360 - angle)
329 std::shared_ptr<ModelHighAPI_Interface> setAngleBackward(
330 const ModelHighAPI_RefAttr & theLine1,
331 const ModelHighAPI_RefAttr & theLine2,
332 const ModelHighAPI_Double & theValue);
336 std::shared_ptr<ModelHighAPI_Interface> setCoincident(
337 const ModelHighAPI_RefAttr & thePoint1,
338 const ModelHighAPI_RefAttr & thePoint2);
342 std::shared_ptr<ModelHighAPI_Interface> setCollinear(
343 const ModelHighAPI_RefAttr & theLine1,
344 const ModelHighAPI_RefAttr & theLine2);
348 std::shared_ptr<ModelHighAPI_Interface> setDistance(
349 const ModelHighAPI_RefAttr & thePoint,
350 const ModelHighAPI_RefAttr & thePointOrLine,
351 const ModelHighAPI_Double & theValue,
352 bool isSigned = false);
354 /// Set signed distance
356 std::shared_ptr<ModelHighAPI_Interface> setSignedDistance(
357 const ModelHighAPI_RefAttr & thePoint,
358 const ModelHighAPI_RefAttr & thePointOrLine,
359 const ModelHighAPI_Double & theValue);
361 /// Set unsigned distance
363 std::shared_ptr<ModelHighAPI_Interface> setUnsignedDistance(
364 const ModelHighAPI_RefAttr & thePoint,
365 const ModelHighAPI_RefAttr & thePointOrLine,
366 const ModelHighAPI_Double & theValue);
368 /// Set horizontal distance
370 std::shared_ptr<ModelHighAPI_Interface> setHorizontalDistance(
371 const ModelHighAPI_RefAttr & thePoint1,
372 const ModelHighAPI_RefAttr & thePoint2,
373 const ModelHighAPI_Double & theValue);
375 /// Set vertical distance
377 std::shared_ptr<ModelHighAPI_Interface> setVerticalDistance(
378 const ModelHighAPI_RefAttr & thePoint1,
379 const ModelHighAPI_RefAttr & thePoint2,
380 const ModelHighAPI_Double & theValue);
384 std::shared_ptr<ModelHighAPI_Interface> setEqual(
385 const ModelHighAPI_RefAttr & theObject1,
386 const ModelHighAPI_RefAttr & theObject2);
390 std::shared_ptr<ModelHighAPI_Interface> setFillet(
391 const ModelHighAPI_RefAttr & thePoint);
393 /// Set fillet with additional radius constraint
395 std::shared_ptr<ModelHighAPI_Interface> setFilletWithRadius(
396 const ModelHighAPI_RefAttr & thePoint,
397 const ModelHighAPI_Double & theRadius);
401 std::shared_ptr<ModelHighAPI_Interface> setFixed(
402 const ModelHighAPI_RefAttr & theObject);
406 std::shared_ptr<ModelHighAPI_Interface> setHorizontal(
407 const ModelHighAPI_RefAttr & theLine);
411 std::shared_ptr<ModelHighAPI_Interface> setLength(
412 const ModelHighAPI_RefAttr & theLine,
413 const ModelHighAPI_Double & theValue);
417 std::shared_ptr<ModelHighAPI_Interface> setMiddlePoint(
418 const ModelHighAPI_RefAttr & thePoint,
419 const ModelHighAPI_RefAttr & theLine);
423 std::shared_ptr<ModelHighAPI_Interface> setParallel(
424 const ModelHighAPI_RefAttr & theLine1,
425 const ModelHighAPI_RefAttr & theLine2);
427 /// Set perpendicular
429 std::shared_ptr<ModelHighAPI_Interface> setPerpendicular(
430 const ModelHighAPI_RefAttr & theLine1,
431 const ModelHighAPI_RefAttr & theLine2);
435 std::shared_ptr<ModelHighAPI_Interface> setRadius(
436 const ModelHighAPI_RefAttr & theCircleOrArc,
437 const ModelHighAPI_Double & theValue);
441 std::shared_ptr<ModelHighAPI_Interface> setTangent(
442 const ModelHighAPI_RefAttr & theLine,
443 const ModelHighAPI_RefAttr & theCircle);
447 std::shared_ptr<ModelHighAPI_Interface> setVertical(
448 const ModelHighAPI_RefAttr & theLine);
450 /// Set constraint value
453 const std::shared_ptr<ModelHighAPI_Interface> & theConstraint,
454 const ModelHighAPI_Double & theValue);
456 /// Move point or sketch feature
458 void move(const ModelHighAPI_RefAttr& theMovedEntity,
459 const std::shared_ptr<GeomAPI_Pnt2d>& theTargetPoint);
461 /// Move point or sketch feature
463 void move(const ModelHighAPI_RefAttr& theMovedEntity,
464 double theTargetX, double theTargetY);
467 std::shared_ptr<GeomAPI_Pnt2d> to2D(const std::shared_ptr<GeomAPI_Pnt>& thePoint);
469 // TODO(spo): rename to selectFaces() or faces() (or add faces() -> list to SWIG)
472 std::list<ModelHighAPI_Selection> selectFace() const;
474 /// Dump wrapped feature
476 virtual void dump(ModelHighAPI_Dumper& theDumper) const;
479 std::shared_ptr<ModelAPI_CompositeFeature> compositeFeature() const;
483 //! Pointer on Sketch object
484 typedef std::shared_ptr<SketchAPI_Sketch> SketchPtr;
486 /**\ingroup CPPHighAPI
487 * \brief Create Sketch feature
490 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
491 const std::shared_ptr<GeomAPI_Ax3> & thePlane);
493 /**\ingroup CPPHighAPI
494 * \brief Create Sketch feature
497 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
498 const ModelHighAPI_Selection & theExternal);
500 /**\ingroup CPPHighAPI
501 * \brief Create Sketch feature
504 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
505 const std::string & theExternalName);
507 /**\ingroup CPPHighAPI
508 * \brief Create Sketch feature
511 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
512 std::shared_ptr<ModelAPI_Object> thePlaneObject);
514 //--------------------------------------------------------------------------------------
515 //--------------------------------------------------------------------------------------
516 #endif /* SRC_SKETCHAPI_SKETCHAPI_SKETCH_H_ */