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);
239 /// Add transversal/tangent arc
241 std::shared_ptr<SketchAPI_MacroArc> addArc(
242 const ModelHighAPI_RefAttr& theConnectedPoint,
243 double theEndX, double theEndY,
245 bool theTransversal = false);
247 /// Add transversal/tangent arc
249 std::shared_ptr<SketchAPI_MacroArc> addArc(
250 const ModelHighAPI_RefAttr& theConnectedPoint,
251 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
253 bool theTransversal = false);
257 std::shared_ptr<SketchAPI_Arc> addArc(const ModelHighAPI_Selection & theExternal);
261 std::shared_ptr<SketchAPI_Arc> addArc(const std::string & theExternalName);
265 std::shared_ptr<SketchAPI_Projection> addProjection(
266 const ModelHighAPI_Selection & theExternalFeature,
267 bool theKeepResult = false);
271 std::shared_ptr<SketchAPI_Projection> addProjection(const std::string & theExternalName,
272 bool theKeepResult = false);
276 std::shared_ptr<SketchAPI_Mirror> addMirror(
277 const ModelHighAPI_RefAttr & theMirrorLine,
278 const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects);
282 std::shared_ptr<SketchAPI_Translation> addTranslation(
283 const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects,
284 const ModelHighAPI_RefAttr & thePoint1,
285 const ModelHighAPI_RefAttr & thePoint2,
286 const ModelHighAPI_Integer & theNumberOfObjects,
287 bool theFullValue = false);
291 std::shared_ptr<SketchAPI_Rotation> addRotation(
292 const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects,
293 const ModelHighAPI_RefAttr & theCenter,
294 const ModelHighAPI_Double & theAngle,
295 const ModelHighAPI_Integer & theNumberOfObjects,
296 bool theFullValue = false,
297 bool theReversed = false);
301 std::shared_ptr<ModelHighAPI_Interface> addSplit(
302 const ModelHighAPI_Reference& theFeature,
303 const std::shared_ptr<GeomAPI_Pnt2d>& thePositionPoint);
307 std::shared_ptr<ModelHighAPI_Interface> addTrim(
308 const ModelHighAPI_Reference& theFeature,
309 const std::shared_ptr<GeomAPI_Pnt2d>& thePositionPoint);
313 std::shared_ptr<ModelHighAPI_Interface> setAngle(
314 const ModelHighAPI_RefAttr & theLine1,
315 const ModelHighAPI_RefAttr & theLine2,
316 const ModelHighAPI_Double & theValue);
318 /// Set complementary angle
320 std::shared_ptr<ModelHighAPI_Interface> setAngleComplementary(
321 const ModelHighAPI_RefAttr & theLine1,
322 const ModelHighAPI_RefAttr & theLine2,
323 const ModelHighAPI_Double & theValue);
325 /// Set backward angle (= 360 - angle)
327 std::shared_ptr<ModelHighAPI_Interface> setAngleBackward(
328 const ModelHighAPI_RefAttr & theLine1,
329 const ModelHighAPI_RefAttr & theLine2,
330 const ModelHighAPI_Double & theValue);
334 std::shared_ptr<ModelHighAPI_Interface> setCoincident(
335 const ModelHighAPI_RefAttr & thePoint1,
336 const ModelHighAPI_RefAttr & thePoint2);
340 std::shared_ptr<ModelHighAPI_Interface> setCollinear(
341 const ModelHighAPI_RefAttr & theLine1,
342 const ModelHighAPI_RefAttr & theLine2);
346 std::shared_ptr<ModelHighAPI_Interface> setDistance(
347 const ModelHighAPI_RefAttr & thePoint,
348 const ModelHighAPI_RefAttr & thePointOrLine,
349 const ModelHighAPI_Double & theValue,
350 bool isSigned = false);
352 /// Set signed distance
354 std::shared_ptr<ModelHighAPI_Interface> setSignedDistance(
355 const ModelHighAPI_RefAttr & thePoint,
356 const ModelHighAPI_RefAttr & thePointOrLine,
357 const ModelHighAPI_Double & theValue);
359 /// Set unsigned distance
361 std::shared_ptr<ModelHighAPI_Interface> setUnsignedDistance(
362 const ModelHighAPI_RefAttr & thePoint,
363 const ModelHighAPI_RefAttr & thePointOrLine,
364 const ModelHighAPI_Double & theValue);
366 /// Set horizontal distance
368 std::shared_ptr<ModelHighAPI_Interface> setHorizontalDistance(
369 const ModelHighAPI_RefAttr & thePoint1,
370 const ModelHighAPI_RefAttr & thePoint2,
371 const ModelHighAPI_Double & theValue);
373 /// Set vertical distance
375 std::shared_ptr<ModelHighAPI_Interface> setVerticalDistance(
376 const ModelHighAPI_RefAttr & thePoint1,
377 const ModelHighAPI_RefAttr & thePoint2,
378 const ModelHighAPI_Double & theValue);
382 std::shared_ptr<ModelHighAPI_Interface> setEqual(
383 const ModelHighAPI_RefAttr & theObject1,
384 const ModelHighAPI_RefAttr & theObject2);
388 std::shared_ptr<ModelHighAPI_Interface> setFillet(
389 const ModelHighAPI_RefAttr & thePoint);
391 /// Set fillet with additional radius constraint
393 std::shared_ptr<ModelHighAPI_Interface> setFilletWithRadius(
394 const ModelHighAPI_RefAttr & thePoint,
395 const ModelHighAPI_Double & theRadius);
399 std::shared_ptr<ModelHighAPI_Interface> setFixed(
400 const ModelHighAPI_RefAttr & theObject);
404 std::shared_ptr<ModelHighAPI_Interface> setHorizontal(
405 const ModelHighAPI_RefAttr & theLine);
409 std::shared_ptr<ModelHighAPI_Interface> setLength(
410 const ModelHighAPI_RefAttr & theLine,
411 const ModelHighAPI_Double & theValue);
415 std::shared_ptr<ModelHighAPI_Interface> setMiddlePoint(
416 const ModelHighAPI_RefAttr & thePoint,
417 const ModelHighAPI_RefAttr & theLine);
421 std::shared_ptr<ModelHighAPI_Interface> setParallel(
422 const ModelHighAPI_RefAttr & theLine1,
423 const ModelHighAPI_RefAttr & theLine2);
425 /// Set perpendicular
427 std::shared_ptr<ModelHighAPI_Interface> setPerpendicular(
428 const ModelHighAPI_RefAttr & theLine1,
429 const ModelHighAPI_RefAttr & theLine2);
433 std::shared_ptr<ModelHighAPI_Interface> setRadius(
434 const ModelHighAPI_RefAttr & theCircleOrArc,
435 const ModelHighAPI_Double & theValue);
439 std::shared_ptr<ModelHighAPI_Interface> setTangent(
440 const ModelHighAPI_RefAttr & theLine,
441 const ModelHighAPI_RefAttr & theCircle);
445 std::shared_ptr<ModelHighAPI_Interface> setVertical(
446 const ModelHighAPI_RefAttr & theLine);
448 /// Set constraint value
451 const std::shared_ptr<ModelHighAPI_Interface> & theConstraint,
452 const ModelHighAPI_Double & theValue);
454 /// Move point or sketch feature
456 void move(const ModelHighAPI_RefAttr& theMovedEntity,
457 const std::shared_ptr<GeomAPI_Pnt2d>& theTargetPoint);
459 /// Move point or sketch feature
461 void move(const ModelHighAPI_RefAttr& theMovedEntity,
462 double theTargetX, double theTargetY);
465 std::shared_ptr<GeomAPI_Pnt2d> to2D(const std::shared_ptr<GeomAPI_Pnt>& thePoint);
467 // TODO(spo): rename to selectFaces() or faces() (or add faces() -> list to SWIG)
470 std::list<ModelHighAPI_Selection> selectFace() const;
472 /// Dump wrapped feature
474 virtual void dump(ModelHighAPI_Dumper& theDumper) const;
477 std::shared_ptr<ModelAPI_CompositeFeature> compositeFeature() const;
481 //! Pointer on Sketch object
482 typedef std::shared_ptr<SketchAPI_Sketch> SketchPtr;
484 /**\ingroup CPPHighAPI
485 * \brief Create Sketch feature
488 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
489 const std::shared_ptr<GeomAPI_Ax3> & thePlane);
491 /**\ingroup CPPHighAPI
492 * \brief Create Sketch feature
495 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
496 const ModelHighAPI_Selection & theExternal);
498 /**\ingroup CPPHighAPI
499 * \brief Create Sketch feature
502 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
503 const std::string & theExternalName);
505 /**\ingroup CPPHighAPI
506 * \brief Create Sketch feature
509 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
510 std::shared_ptr<ModelAPI_Object> thePlaneObject);
512 //--------------------------------------------------------------------------------------
513 //--------------------------------------------------------------------------------------
514 #endif /* SRC_SKETCHAPI_SKETCHAPI_SKETCH_H_ */