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);
103 void setExternal(const ModelHighAPI_Selection & theExternal);
107 void setExternal(std::shared_ptr<ModelAPI_Object> thePlaneObject);
111 std::shared_ptr<SketchAPI_Point> addPoint(
112 double theX, double theY);
115 std::shared_ptr<SketchAPI_Point> addPoint(
116 const std::shared_ptr<GeomAPI_Pnt2d> & thePoint);
119 std::shared_ptr<SketchAPI_Point> addPoint(const ModelHighAPI_Selection & theExternal);
122 std::shared_ptr<SketchAPI_Point> addPoint(const std::string & theExternalName);
124 /// Add intersection point
126 std::shared_ptr<SketchAPI_IntersectionPoint>
127 addIntersectionPoint(const ModelHighAPI_Selection & theExternal,
128 bool theKeepResult = false);
131 std::shared_ptr<SketchAPI_IntersectionPoint>
132 addIntersectionPoint(const std::string & theExternalName,
133 bool theKeepResult = false);
137 std::shared_ptr<SketchAPI_Line> addLine(
138 double theX1, double theY1, double theX2, double theY2);
141 std::shared_ptr<SketchAPI_Line> addLine(
142 const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
143 const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint);
146 std::shared_ptr<SketchAPI_Line> addLine(const ModelHighAPI_Selection & theExternal);
149 std::shared_ptr<SketchAPI_Line> addLine(const std::string & theExternalName);
153 std::shared_ptr<SketchAPI_Rectangle> addRectangle(
154 double theX1, double theY1, double theX2, double theY2);
157 std::shared_ptr<SketchAPI_Rectangle> addRectangle(
158 const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
159 const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint);
163 std::shared_ptr<SketchAPI_Circle> addCircle(
164 double theCenterX, double theCenterY,
168 std::shared_ptr<SketchAPI_Circle> addCircle(
169 const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
173 std::shared_ptr<SketchAPI_MacroCircle> addCircle(
174 double theCenterX, double theCenterY,
175 double thePassedX, double thePassedY);
178 std::shared_ptr<SketchAPI_MacroCircle> addCircle(
179 const std::shared_ptr<GeomAPI_Pnt2d>& theCenterPoint,
180 const std::shared_ptr<GeomAPI_Pnt2d>& thePassedPoint);
183 std::shared_ptr<SketchAPI_MacroCircle> addCircle(
184 double theX1, double theY1,
185 double theX2, double theY2,
186 double theX3, double theY3);
189 std::shared_ptr<SketchAPI_MacroCircle> addCircle(
190 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint1,
191 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint2,
192 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint3);
195 std::shared_ptr<SketchAPI_Circle> addCircle(const ModelHighAPI_Selection & theExternal);
198 std::shared_ptr<SketchAPI_Circle> addCircle(const std::string & theExternalName);
202 std::shared_ptr<SketchAPI_Arc> addArc(
203 double theCenterX, double theCenterY,
204 double theStartX, double theStartY,
205 double theEndX, double theEndY,
210 std::shared_ptr<SketchAPI_Arc> addArc(
211 const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
212 const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
213 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
218 std::shared_ptr<SketchAPI_MacroArc> addArc(
219 double theStartX, double theStartY,
220 double theEndX, double theEndY,
221 double thePassedX, double thePassedY);
225 std::shared_ptr<SketchAPI_MacroArc> addArc(
226 const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
227 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
228 const std::shared_ptr<GeomAPI_Pnt2d>& thePassed);
232 std::shared_ptr<SketchAPI_MacroArc> addArc(
233 const ModelHighAPI_RefAttr& theTangentPoint,
234 double theEndX, double theEndY,
239 std::shared_ptr<SketchAPI_MacroArc> addArc(
240 const ModelHighAPI_RefAttr& theTangentPoint,
241 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
246 std::shared_ptr<SketchAPI_Arc> addArc(const ModelHighAPI_Selection & theExternal);
250 std::shared_ptr<SketchAPI_Arc> addArc(const std::string & theExternalName);
254 std::shared_ptr<SketchAPI_Projection> addProjection(
255 const ModelHighAPI_Selection & theExternalFeature,
256 bool theKeepResult = false);
260 std::shared_ptr<SketchAPI_Projection> addProjection(const std::string & theExternalName,
261 bool theKeepResult = false);
265 std::shared_ptr<SketchAPI_Mirror> addMirror(
266 const ModelHighAPI_RefAttr & theMirrorLine,
267 const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects);
271 std::shared_ptr<SketchAPI_Translation> addTranslation(
272 const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects,
273 const ModelHighAPI_RefAttr & thePoint1,
274 const ModelHighAPI_RefAttr & thePoint2,
275 const ModelHighAPI_Integer & theNumberOfObjects,
276 bool theFullValue = false);
280 std::shared_ptr<SketchAPI_Rotation> addRotation(
281 const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects,
282 const ModelHighAPI_RefAttr & theCenter,
283 const ModelHighAPI_Double & theAngle,
284 const ModelHighAPI_Integer & theNumberOfObjects,
285 bool theFullValue = false,
286 bool theReversed = false);
290 std::shared_ptr<ModelHighAPI_Interface> addSplit(
291 const ModelHighAPI_Reference& theFeature,
292 const std::shared_ptr<GeomAPI_Pnt2d>& thePositionPoint);
296 std::shared_ptr<ModelHighAPI_Interface> addTrim(
297 const ModelHighAPI_Reference& theFeature,
298 const std::shared_ptr<GeomAPI_Pnt2d>& thePositionPoint);
302 std::shared_ptr<ModelHighAPI_Interface> setAngle(
303 const ModelHighAPI_RefAttr & theLine1,
304 const ModelHighAPI_RefAttr & theLine2,
305 const ModelHighAPI_Double & theValue);
307 /// Set complementary angle
309 std::shared_ptr<ModelHighAPI_Interface> setAngleComplementary(
310 const ModelHighAPI_RefAttr & theLine1,
311 const ModelHighAPI_RefAttr & theLine2,
312 const ModelHighAPI_Double & theValue);
314 /// Set backward angle (= 360 - angle)
316 std::shared_ptr<ModelHighAPI_Interface> setAngleBackward(
317 const ModelHighAPI_RefAttr & theLine1,
318 const ModelHighAPI_RefAttr & theLine2,
319 const ModelHighAPI_Double & theValue);
323 std::shared_ptr<ModelHighAPI_Interface> setCoincident(
324 const ModelHighAPI_RefAttr & thePoint1,
325 const ModelHighAPI_RefAttr & thePoint2);
329 std::shared_ptr<ModelHighAPI_Interface> setCollinear(
330 const ModelHighAPI_RefAttr & theLine1,
331 const ModelHighAPI_RefAttr & theLine2);
335 std::shared_ptr<ModelHighAPI_Interface> setDistance(
336 const ModelHighAPI_RefAttr & thePoint,
337 const ModelHighAPI_RefAttr & thePointOrLine,
338 const ModelHighAPI_Double & theValue,
339 bool isSigned = false);
341 /// Set signed distance
343 std::shared_ptr<ModelHighAPI_Interface> setSignedDistance(
344 const ModelHighAPI_RefAttr & thePoint,
345 const ModelHighAPI_RefAttr & thePointOrLine,
346 const ModelHighAPI_Double & theValue);
348 /// Set unsigned distance
350 std::shared_ptr<ModelHighAPI_Interface> setUnsignedDistance(
351 const ModelHighAPI_RefAttr & thePoint,
352 const ModelHighAPI_RefAttr & thePointOrLine,
353 const ModelHighAPI_Double & theValue);
355 /// Set horizontal distance
357 std::shared_ptr<ModelHighAPI_Interface> setHorizontalDistance(
358 const ModelHighAPI_RefAttr & thePoint1,
359 const ModelHighAPI_RefAttr & thePoint2,
360 const ModelHighAPI_Double & theValue);
362 /// Set vertical distance
364 std::shared_ptr<ModelHighAPI_Interface> setVerticalDistance(
365 const ModelHighAPI_RefAttr & thePoint1,
366 const ModelHighAPI_RefAttr & thePoint2,
367 const ModelHighAPI_Double & theValue);
371 std::shared_ptr<ModelHighAPI_Interface> setEqual(
372 const ModelHighAPI_RefAttr & theObject1,
373 const ModelHighAPI_RefAttr & theObject2);
377 std::shared_ptr<ModelHighAPI_Interface> setFillet(
378 const ModelHighAPI_RefAttr & thePoint);
380 /// Set fillet with additional radius constraint
382 std::shared_ptr<ModelHighAPI_Interface> setFilletWithRadius(
383 const ModelHighAPI_RefAttr & thePoint,
384 const ModelHighAPI_Double & theRadius);
388 std::shared_ptr<ModelHighAPI_Interface> setFixed(
389 const ModelHighAPI_RefAttr & theObject);
393 std::shared_ptr<ModelHighAPI_Interface> setHorizontal(
394 const ModelHighAPI_RefAttr & theLine);
398 std::shared_ptr<ModelHighAPI_Interface> setLength(
399 const ModelHighAPI_RefAttr & theLine,
400 const ModelHighAPI_Double & theValue);
404 std::shared_ptr<ModelHighAPI_Interface> setMiddlePoint(
405 const ModelHighAPI_RefAttr & thePoint,
406 const ModelHighAPI_RefAttr & theLine);
410 std::shared_ptr<ModelHighAPI_Interface> setParallel(
411 const ModelHighAPI_RefAttr & theLine1,
412 const ModelHighAPI_RefAttr & theLine2);
414 /// Set perpendicular
416 std::shared_ptr<ModelHighAPI_Interface> setPerpendicular(
417 const ModelHighAPI_RefAttr & theLine1,
418 const ModelHighAPI_RefAttr & theLine2);
422 std::shared_ptr<ModelHighAPI_Interface> setRadius(
423 const ModelHighAPI_RefAttr & theCircleOrArc,
424 const ModelHighAPI_Double & theValue);
428 std::shared_ptr<ModelHighAPI_Interface> setTangent(
429 const ModelHighAPI_RefAttr & theLine,
430 const ModelHighAPI_RefAttr & theCircle);
434 std::shared_ptr<ModelHighAPI_Interface> setVertical(
435 const ModelHighAPI_RefAttr & theLine);
437 /// Set constraint value
440 const std::shared_ptr<ModelHighAPI_Interface> & theConstraint,
441 const ModelHighAPI_Double & theValue);
443 /// Move point or sketch feature
445 void move(const ModelHighAPI_RefAttr& theMovedEntity,
446 const std::shared_ptr<GeomAPI_Pnt2d>& theTargetPoint);
448 /// Move point or sketch feature
450 void move(const ModelHighAPI_RefAttr& theMovedEntity,
451 double theTargetX, double theTargetY);
454 std::shared_ptr<GeomAPI_Pnt2d> to2D(const std::shared_ptr<GeomAPI_Pnt>& thePoint);
456 // TODO(spo): rename to selectFaces() or faces() (or add faces() -> list to SWIG)
459 std::list<ModelHighAPI_Selection> selectFace() const;
461 /// Dump wrapped feature
463 virtual void dump(ModelHighAPI_Dumper& theDumper) const;
466 std::shared_ptr<ModelAPI_CompositeFeature> compositeFeature() const;
470 //! Pointer on Sketch object
471 typedef std::shared_ptr<SketchAPI_Sketch> SketchPtr;
473 /**\ingroup CPPHighAPI
474 * \brief Create Sketch feature
477 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
478 const std::shared_ptr<GeomAPI_Ax3> & thePlane);
480 /**\ingroup CPPHighAPI
481 * \brief Create Sketch feature
484 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
485 const ModelHighAPI_Selection & theExternal);
487 /**\ingroup CPPHighAPI
488 * \brief Create Sketch feature
491 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
492 const std::string & theExternalName);
494 /**\ingroup CPPHighAPI
495 * \brief Create Sketch feature
498 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
499 std::shared_ptr<ModelAPI_Object> thePlaneObject);
501 //--------------------------------------------------------------------------------------
502 //--------------------------------------------------------------------------------------
503 #endif /* SRC_SKETCHAPI_SKETCHAPI_SKETCH_H_ */