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 /// List points not connected by constraints with other sketch entitites
116 std::list< std::shared_ptr<SketchAPI_Point> > getFreePoints();
120 std::shared_ptr<SketchAPI_Point> addPoint(
121 double theX, double theY);
124 std::shared_ptr<SketchAPI_Point> addPoint(
125 const std::shared_ptr<GeomAPI_Pnt2d> & thePoint);
128 std::shared_ptr<SketchAPI_Point> addPoint(const ModelHighAPI_Selection & theExternal);
131 std::shared_ptr<SketchAPI_Point> addPoint(const std::string & theExternalName);
133 /// Add intersection point
135 std::shared_ptr<SketchAPI_IntersectionPoint>
136 addIntersectionPoint(const ModelHighAPI_Selection & theExternal,
137 bool theKeepResult = false);
140 std::shared_ptr<SketchAPI_IntersectionPoint>
141 addIntersectionPoint(const std::string & theExternalName,
142 bool theKeepResult = false);
146 std::shared_ptr<SketchAPI_Line> addLine(
147 double theX1, double theY1, double theX2, double theY2);
150 std::shared_ptr<SketchAPI_Line> addLine(
151 const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
152 const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint);
155 std::shared_ptr<SketchAPI_Line> addLine(const ModelHighAPI_Selection & theExternal);
158 std::shared_ptr<SketchAPI_Line> addLine(const std::string & theExternalName);
162 std::shared_ptr<SketchAPI_Rectangle> addRectangle(
163 double theX1, double theY1, double theX2, double theY2);
166 std::shared_ptr<SketchAPI_Rectangle> addRectangle(
167 const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
168 const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint);
172 std::shared_ptr<SketchAPI_Circle> addCircle(
173 double theCenterX, double theCenterY,
177 std::shared_ptr<SketchAPI_Circle> addCircle(
178 const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
182 std::shared_ptr<SketchAPI_MacroCircle> addCircle(
183 double theCenterX, double theCenterY,
184 double thePassedX, double thePassedY);
187 std::shared_ptr<SketchAPI_MacroCircle> addCircle(
188 const std::shared_ptr<GeomAPI_Pnt2d>& theCenterPoint,
189 const std::shared_ptr<GeomAPI_Pnt2d>& thePassedPoint);
192 std::shared_ptr<SketchAPI_MacroCircle> addCircle(
193 double theX1, double theY1,
194 double theX2, double theY2,
195 double theX3, double theY3);
198 std::shared_ptr<SketchAPI_MacroCircle> addCircle(
199 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint1,
200 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint2,
201 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint3);
204 std::shared_ptr<SketchAPI_Circle> addCircle(const ModelHighAPI_Selection & theExternal);
207 std::shared_ptr<SketchAPI_Circle> addCircle(const std::string & theExternalName);
211 std::shared_ptr<SketchAPI_Arc> addArc(
212 double theCenterX, double theCenterY,
213 double theStartX, double theStartY,
214 double theEndX, double theEndY,
219 std::shared_ptr<SketchAPI_Arc> addArc(
220 const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
221 const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
222 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
227 std::shared_ptr<SketchAPI_MacroArc> addArc(
228 double theStartX, double theStartY,
229 double theEndX, double theEndY,
230 double thePassedX, double thePassedY);
234 std::shared_ptr<SketchAPI_MacroArc> addArc(
235 const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
236 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
237 const std::shared_ptr<GeomAPI_Pnt2d>& thePassed);
241 std::shared_ptr<SketchAPI_MacroArc> addArc(
242 const ModelHighAPI_RefAttr& theTangentPoint,
243 double theEndX, double theEndY,
248 std::shared_ptr<SketchAPI_MacroArc> addArc(
249 const ModelHighAPI_RefAttr& theTangentPoint,
250 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
255 std::shared_ptr<SketchAPI_Arc> addArc(const ModelHighAPI_Selection & theExternal);
259 std::shared_ptr<SketchAPI_Arc> addArc(const std::string & theExternalName);
263 std::shared_ptr<SketchAPI_Projection> addProjection(
264 const ModelHighAPI_Selection & theExternalFeature,
265 bool theKeepResult = false);
269 std::shared_ptr<SketchAPI_Projection> addProjection(const std::string & theExternalName,
270 bool theKeepResult = false);
274 std::shared_ptr<SketchAPI_Mirror> addMirror(
275 const ModelHighAPI_RefAttr & theMirrorLine,
276 const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects);
280 std::shared_ptr<SketchAPI_Translation> addTranslation(
281 const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects,
282 const ModelHighAPI_RefAttr & thePoint1,
283 const ModelHighAPI_RefAttr & thePoint2,
284 const ModelHighAPI_Integer & theNumberOfObjects,
285 bool theFullValue = false);
289 std::shared_ptr<SketchAPI_Rotation> addRotation(
290 const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects,
291 const ModelHighAPI_RefAttr & theCenter,
292 const ModelHighAPI_Double & theAngle,
293 const ModelHighAPI_Integer & theNumberOfObjects,
294 bool theFullValue = false,
295 bool theReversed = false);
299 std::shared_ptr<ModelHighAPI_Interface> addSplit(
300 const ModelHighAPI_Reference& theFeature,
301 const std::shared_ptr<GeomAPI_Pnt2d>& thePositionPoint);
305 std::shared_ptr<ModelHighAPI_Interface> addTrim(
306 const ModelHighAPI_Reference& theFeature,
307 const std::shared_ptr<GeomAPI_Pnt2d>& thePositionPoint);
311 std::shared_ptr<ModelHighAPI_Interface> setAngle(
312 const ModelHighAPI_RefAttr & theLine1,
313 const ModelHighAPI_RefAttr & theLine2,
314 const ModelHighAPI_Double & theValue);
316 /// Set complementary angle
318 std::shared_ptr<ModelHighAPI_Interface> setAngleComplementary(
319 const ModelHighAPI_RefAttr & theLine1,
320 const ModelHighAPI_RefAttr & theLine2,
321 const ModelHighAPI_Double & theValue);
323 /// Set backward angle (= 360 - angle)
325 std::shared_ptr<ModelHighAPI_Interface> setAngleBackward(
326 const ModelHighAPI_RefAttr & theLine1,
327 const ModelHighAPI_RefAttr & theLine2,
328 const ModelHighAPI_Double & theValue);
332 std::shared_ptr<ModelHighAPI_Interface> setCoincident(
333 const ModelHighAPI_RefAttr & thePoint1,
334 const ModelHighAPI_RefAttr & thePoint2);
338 std::shared_ptr<ModelHighAPI_Interface> setCollinear(
339 const ModelHighAPI_RefAttr & theLine1,
340 const ModelHighAPI_RefAttr & theLine2);
344 std::shared_ptr<ModelHighAPI_Interface> setDistance(
345 const ModelHighAPI_RefAttr & thePoint,
346 const ModelHighAPI_RefAttr & thePointOrLine,
347 const ModelHighAPI_Double & theValue,
348 bool isSigned = false);
350 /// Set signed distance
352 std::shared_ptr<ModelHighAPI_Interface> setSignedDistance(
353 const ModelHighAPI_RefAttr & thePoint,
354 const ModelHighAPI_RefAttr & thePointOrLine,
355 const ModelHighAPI_Double & theValue);
357 /// Set unsigned distance
359 std::shared_ptr<ModelHighAPI_Interface> setUnsignedDistance(
360 const ModelHighAPI_RefAttr & thePoint,
361 const ModelHighAPI_RefAttr & thePointOrLine,
362 const ModelHighAPI_Double & theValue);
364 /// Set horizontal distance
366 std::shared_ptr<ModelHighAPI_Interface> setHorizontalDistance(
367 const ModelHighAPI_RefAttr & thePoint1,
368 const ModelHighAPI_RefAttr & thePoint2,
369 const ModelHighAPI_Double & theValue);
371 /// Set vertical distance
373 std::shared_ptr<ModelHighAPI_Interface> setVerticalDistance(
374 const ModelHighAPI_RefAttr & thePoint1,
375 const ModelHighAPI_RefAttr & thePoint2,
376 const ModelHighAPI_Double & theValue);
380 std::shared_ptr<ModelHighAPI_Interface> setEqual(
381 const ModelHighAPI_RefAttr & theObject1,
382 const ModelHighAPI_RefAttr & theObject2);
386 std::shared_ptr<ModelHighAPI_Interface> setFillet(
387 const ModelHighAPI_RefAttr & thePoint);
389 /// Set fillet with additional radius constraint
391 std::shared_ptr<ModelHighAPI_Interface> setFilletWithRadius(
392 const ModelHighAPI_RefAttr & thePoint,
393 const ModelHighAPI_Double & theRadius);
397 std::shared_ptr<ModelHighAPI_Interface> setFixed(
398 const ModelHighAPI_RefAttr & theObject);
402 std::shared_ptr<ModelHighAPI_Interface> setHorizontal(
403 const ModelHighAPI_RefAttr & theLine);
407 std::shared_ptr<ModelHighAPI_Interface> setLength(
408 const ModelHighAPI_RefAttr & theLine,
409 const ModelHighAPI_Double & theValue);
413 std::shared_ptr<ModelHighAPI_Interface> setMiddlePoint(
414 const ModelHighAPI_RefAttr & thePoint,
415 const ModelHighAPI_RefAttr & theLine);
419 std::shared_ptr<ModelHighAPI_Interface> setParallel(
420 const ModelHighAPI_RefAttr & theLine1,
421 const ModelHighAPI_RefAttr & theLine2);
423 /// Set perpendicular
425 std::shared_ptr<ModelHighAPI_Interface> setPerpendicular(
426 const ModelHighAPI_RefAttr & theLine1,
427 const ModelHighAPI_RefAttr & theLine2);
431 std::shared_ptr<ModelHighAPI_Interface> setRadius(
432 const ModelHighAPI_RefAttr & theCircleOrArc,
433 const ModelHighAPI_Double & theValue);
437 std::shared_ptr<ModelHighAPI_Interface> setTangent(
438 const ModelHighAPI_RefAttr & theLine,
439 const ModelHighAPI_RefAttr & theCircle);
443 std::shared_ptr<ModelHighAPI_Interface> setVertical(
444 const ModelHighAPI_RefAttr & theLine);
446 /// Set constraint value
449 const std::shared_ptr<ModelHighAPI_Interface> & theConstraint,
450 const ModelHighAPI_Double & theValue);
452 /// Move point or sketch feature
454 void move(const ModelHighAPI_RefAttr& theMovedEntity,
455 const std::shared_ptr<GeomAPI_Pnt2d>& theTargetPoint);
457 /// Move point or sketch feature
459 void move(const ModelHighAPI_RefAttr& theMovedEntity,
460 double theTargetX, double theTargetY);
463 std::shared_ptr<GeomAPI_Pnt2d> to2D(const std::shared_ptr<GeomAPI_Pnt>& thePoint);
465 // TODO(spo): rename to selectFaces() or faces() (or add faces() -> list to SWIG)
468 std::list<ModelHighAPI_Selection> selectFace() const;
470 /// Dump wrapped feature
472 virtual void dump(ModelHighAPI_Dumper& theDumper) const;
475 std::shared_ptr<ModelAPI_CompositeFeature> compositeFeature() const;
479 //! Pointer on Sketch object
480 typedef std::shared_ptr<SketchAPI_Sketch> SketchPtr;
482 /**\ingroup CPPHighAPI
483 * \brief Create Sketch feature
486 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
487 const std::shared_ptr<GeomAPI_Ax3> & thePlane);
489 /**\ingroup CPPHighAPI
490 * \brief Create Sketch feature
493 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
494 const ModelHighAPI_Selection & theExternal);
496 /**\ingroup CPPHighAPI
497 * \brief Create Sketch feature
500 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
501 const std::string & theExternalName);
503 /**\ingroup CPPHighAPI
504 * \brief Create Sketch feature
507 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
508 std::shared_ptr<ModelAPI_Object> thePlaneObject);
510 //--------------------------------------------------------------------------------------
511 //--------------------------------------------------------------------------------------
512 #endif /* SRC_SKETCHAPI_SKETCHAPI_SKETCH_H_ */