1 // Copyright (C) 2014-2017 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
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 #ifndef SRC_SKETCHAPI_SKETCHAPI_SKETCH_H_
22 #define SRC_SKETCHAPI_SKETCHAPI_SKETCH_H_
24 //--------------------------------------------------------------------------------------
25 #include "SketchAPI.h"
29 #include <SketchPlugin_Sketch.h>
30 #include <SketchPlugin_SketchEntity.h>
32 #include <ModelHighAPI_Interface.h>
33 #include <ModelHighAPI_Macro.h>
34 //--------------------------------------------------------------------------------------
35 class ModelAPI_CompositeFeature;
36 class ModelAPI_Object;
37 class ModelHighAPI_Double;
38 class ModelHighAPI_Integer;
39 class ModelHighAPI_RefAttr;
40 class ModelHighAPI_Reference;
41 class ModelHighAPI_Selection;
43 class SketchAPI_MacroArc;
44 class SketchAPI_Circle;
45 class SketchAPI_MacroCircle;
46 class SketchAPI_IntersectionPoint;
48 class SketchAPI_Mirror;
49 class SketchAPI_Point;
50 class SketchAPI_Projection;
51 class SketchAPI_Rectangle;
52 class SketchAPI_Rotation;
53 class SketchAPI_Translation;
54 //--------------------------------------------------------------------------------------
55 /**\class SketchAPI_Sketch
57 * \brief Interface for Sketch feature
59 class SketchAPI_Sketch : public ModelHighAPI_Interface
62 /// Constructor without values
64 explicit SketchAPI_Sketch(const std::shared_ptr<ModelAPI_Feature> & theFeature);
65 /// Constructor with values
67 SketchAPI_Sketch(const std::shared_ptr<ModelAPI_Feature> & theFeature,
68 const std::shared_ptr<GeomAPI_Ax3> & thePlane);
69 /// Constructor with values
71 SketchAPI_Sketch(const std::shared_ptr<ModelAPI_Feature> & theFeature,
72 const ModelHighAPI_Selection & theExternal);
73 /// Constructor with values
75 SketchAPI_Sketch(const std::shared_ptr<ModelAPI_Feature> & theFeature,
76 std::shared_ptr<ModelAPI_Object> thePlaneObject);
79 virtual ~SketchAPI_Sketch();
81 INTERFACE_7(SketchPlugin_Sketch::ID(),
82 origin, SketchPlugin_Sketch::ORIGIN_ID(),
83 GeomDataAPI_Point, /** Origin point */,
84 dirX, SketchPlugin_Sketch::DIRX_ID(),
85 GeomDataAPI_Dir, /** Direction of X */,
86 normal, SketchPlugin_Sketch::NORM_ID(),
87 GeomDataAPI_Dir, /** Normal */,
88 features, SketchPlugin_Sketch::FEATURES_ID(),
89 ModelAPI_AttributeRefList, /** Features */,
90 external, SketchPlugin_SketchEntity::EXTERNAL_ID(),
91 ModelAPI_AttributeSelection, /** External */,
92 solverError, SketchPlugin_Sketch::SOLVER_ERROR(),
93 ModelAPI_AttributeString, /** Solver error */,
94 solverDOF, SketchPlugin_Sketch::SOLVER_DOF(),
95 ModelAPI_AttributeString, /** Solver DOF */
100 void setPlane(const std::shared_ptr<GeomAPI_Ax3> & thePlane);
104 void setExternal(const ModelHighAPI_Selection & theExternal);
108 void setExternal(std::shared_ptr<ModelAPI_Object> thePlaneObject);
112 std::shared_ptr<SketchAPI_Point> addPoint(
113 double theX, double theY);
116 std::shared_ptr<SketchAPI_Point> addPoint(
117 const std::shared_ptr<GeomAPI_Pnt2d> & thePoint);
120 std::shared_ptr<SketchAPI_Point> addPoint(const ModelHighAPI_Selection & theExternal);
123 std::shared_ptr<SketchAPI_Point> addPoint(const std::string & theExternalName);
125 /// Add intersection point
127 std::shared_ptr<SketchAPI_IntersectionPoint>
128 addIntersectionPoint(const ModelHighAPI_Selection & theExternal);
131 std::shared_ptr<SketchAPI_IntersectionPoint>
132 addIntersectionPoint(const std::string & theExternalName);
136 std::shared_ptr<SketchAPI_Line> addLine(
137 double theX1, double theY1, double theX2, double theY2);
140 std::shared_ptr<SketchAPI_Line> addLine(
141 const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
142 const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint);
145 std::shared_ptr<SketchAPI_Line> addLine(const ModelHighAPI_Selection & theExternal);
148 std::shared_ptr<SketchAPI_Line> addLine(const std::string & theExternalName);
152 std::shared_ptr<SketchAPI_Rectangle> addRectangle(
153 double theX1, double theY1, double theX2, double theY2);
156 std::shared_ptr<SketchAPI_Rectangle> addRectangle(
157 const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
158 const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint);
162 std::shared_ptr<SketchAPI_Circle> addCircle(
163 double theCenterX, double theCenterY,
167 std::shared_ptr<SketchAPI_Circle> addCircle(
168 const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
172 std::shared_ptr<SketchAPI_MacroCircle> addCircle(
173 double theCenterX, double theCenterY,
174 double thePassedX, double thePassedY);
177 std::shared_ptr<SketchAPI_MacroCircle> addCircle(
178 const std::shared_ptr<GeomAPI_Pnt2d>& theCenterPoint,
179 const std::shared_ptr<GeomAPI_Pnt2d>& thePassedPoint);
182 std::shared_ptr<SketchAPI_MacroCircle> addCircle(
183 double theX1, double theY1,
184 double theX2, double theY2,
185 double theX3, double theY3);
188 std::shared_ptr<SketchAPI_MacroCircle> addCircle(
189 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint1,
190 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint2,
191 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint3);
194 std::shared_ptr<SketchAPI_Circle> addCircle(const ModelHighAPI_Selection & theExternal);
197 std::shared_ptr<SketchAPI_Circle> addCircle(const std::string & theExternalName);
201 std::shared_ptr<SketchAPI_Arc> addArc(
202 double theCenterX, double theCenterY,
203 double theStartX, double theStartY,
204 double theEndX, double theEndY,
209 std::shared_ptr<SketchAPI_Arc> addArc(
210 const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
211 const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
212 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
217 std::shared_ptr<SketchAPI_MacroArc> addArc(
218 double theStartX, double theStartY,
219 double theEndX, double theEndY,
220 double thePassedX, double thePassedY);
224 std::shared_ptr<SketchAPI_MacroArc> addArc(
225 const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
226 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
227 const std::shared_ptr<GeomAPI_Pnt2d>& thePassed);
231 std::shared_ptr<SketchAPI_MacroArc> addArc(
232 const ModelHighAPI_RefAttr& theTangentPoint,
233 double theEndX, double theEndY,
238 std::shared_ptr<SketchAPI_MacroArc> addArc(
239 const ModelHighAPI_RefAttr& theTangentPoint,
240 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
245 std::shared_ptr<SketchAPI_Arc> addArc(const ModelHighAPI_Selection & theExternal);
249 std::shared_ptr<SketchAPI_Arc> addArc(const std::string & theExternalName);
253 std::shared_ptr<SketchAPI_Projection> addProjection(
254 const ModelHighAPI_Selection & theExternalFeature,
255 bool theKeepResult = false);
259 std::shared_ptr<SketchAPI_Projection> addProjection(const std::string & theExternalName,
260 bool theKeepResult = false);
264 std::shared_ptr<SketchAPI_Mirror> addMirror(
265 const ModelHighAPI_RefAttr & theMirrorLine,
266 const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects);
270 std::shared_ptr<SketchAPI_Translation> addTranslation(
271 const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects,
272 const ModelHighAPI_RefAttr & thePoint1,
273 const ModelHighAPI_RefAttr & thePoint2,
274 const ModelHighAPI_Integer & theNumberOfObjects,
275 bool theFullValue = false);
279 std::shared_ptr<SketchAPI_Rotation> addRotation(
280 const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects,
281 const ModelHighAPI_RefAttr & theCenter,
282 const ModelHighAPI_Double & theAngle,
283 const ModelHighAPI_Integer & theNumberOfObjects,
284 bool theFullValue = false,
285 bool theReversed = false);
289 std::shared_ptr<ModelHighAPI_Interface> addSplit(
290 const ModelHighAPI_Reference& theFeature,
291 const std::shared_ptr<GeomAPI_Pnt2d>& thePositionPoint);
295 std::shared_ptr<ModelHighAPI_Interface> addTrim(
296 const ModelHighAPI_Reference& theFeature,
297 const std::shared_ptr<GeomAPI_Pnt2d>& thePositionPoint);
301 std::shared_ptr<ModelHighAPI_Interface> setAngle(
302 const ModelHighAPI_RefAttr & theLine1,
303 const ModelHighAPI_RefAttr & theLine2,
304 const ModelHighAPI_Double & theValue);
306 /// Set complementary angle
308 std::shared_ptr<ModelHighAPI_Interface> setAngleComplementary(
309 const ModelHighAPI_RefAttr & theLine1,
310 const ModelHighAPI_RefAttr & theLine2,
311 const ModelHighAPI_Double & theValue);
313 /// Set backward angle (= 360 - angle)
315 std::shared_ptr<ModelHighAPI_Interface> setAngleBackward(
316 const ModelHighAPI_RefAttr & theLine1,
317 const ModelHighAPI_RefAttr & theLine2,
318 const ModelHighAPI_Double & theValue);
322 std::shared_ptr<ModelHighAPI_Interface> setCoincident(
323 const ModelHighAPI_RefAttr & thePoint1,
324 const ModelHighAPI_RefAttr & thePoint2);
328 std::shared_ptr<ModelHighAPI_Interface> setCollinear(
329 const ModelHighAPI_RefAttr & theLine1,
330 const ModelHighAPI_RefAttr & theLine2);
334 std::shared_ptr<ModelHighAPI_Interface> setDistance(
335 const ModelHighAPI_RefAttr & thePoint,
336 const ModelHighAPI_RefAttr & thePointOrLine,
337 const ModelHighAPI_Double & theValue,
338 bool isSigned = false);
340 /// Set signed distance
342 std::shared_ptr<ModelHighAPI_Interface> setSignedDistance(
343 const ModelHighAPI_RefAttr & thePoint,
344 const ModelHighAPI_RefAttr & thePointOrLine,
345 const ModelHighAPI_Double & theValue);
347 /// Set unsigned distance
349 std::shared_ptr<ModelHighAPI_Interface> setUnsignedDistance(
350 const ModelHighAPI_RefAttr & thePoint,
351 const ModelHighAPI_RefAttr & thePointOrLine,
352 const ModelHighAPI_Double & theValue);
354 /// Set horizontal distance
356 std::shared_ptr<ModelHighAPI_Interface> setHorizontalDistance(
357 const ModelHighAPI_RefAttr & thePoint1,
358 const ModelHighAPI_RefAttr & thePoint2,
359 const ModelHighAPI_Double & theValue);
361 /// Set vertical distance
363 std::shared_ptr<ModelHighAPI_Interface> setVerticalDistance(
364 const ModelHighAPI_RefAttr & thePoint1,
365 const ModelHighAPI_RefAttr & thePoint2,
366 const ModelHighAPI_Double & theValue);
370 std::shared_ptr<ModelHighAPI_Interface> setEqual(
371 const ModelHighAPI_RefAttr & theObject1,
372 const ModelHighAPI_RefAttr & theObject2);
376 std::shared_ptr<ModelHighAPI_Interface> setFillet(
377 const ModelHighAPI_RefAttr & thePoint);
379 /// Set fillet with additional radius constraint
381 std::shared_ptr<ModelHighAPI_Interface> setFilletWithRadius(
382 const ModelHighAPI_RefAttr & thePoint,
383 const ModelHighAPI_Double & theRadius);
387 std::shared_ptr<ModelHighAPI_Interface> setFixed(
388 const ModelHighAPI_RefAttr & theObject);
392 std::shared_ptr<ModelHighAPI_Interface> setHorizontal(
393 const ModelHighAPI_RefAttr & theLine);
397 std::shared_ptr<ModelHighAPI_Interface> setLength(
398 const ModelHighAPI_RefAttr & theLine,
399 const ModelHighAPI_Double & theValue);
403 std::shared_ptr<ModelHighAPI_Interface> setMiddlePoint(
404 const ModelHighAPI_RefAttr & thePoint,
405 const ModelHighAPI_RefAttr & theLine);
409 std::shared_ptr<ModelHighAPI_Interface> setParallel(
410 const ModelHighAPI_RefAttr & theLine1,
411 const ModelHighAPI_RefAttr & theLine2);
413 /// Set perpendicular
415 std::shared_ptr<ModelHighAPI_Interface> setPerpendicular(
416 const ModelHighAPI_RefAttr & theLine1,
417 const ModelHighAPI_RefAttr & theLine2);
421 std::shared_ptr<ModelHighAPI_Interface> setRadius(
422 const ModelHighAPI_RefAttr & theCircleOrArc,
423 const ModelHighAPI_Double & theValue);
427 std::shared_ptr<ModelHighAPI_Interface> setTangent(
428 const ModelHighAPI_RefAttr & theLine,
429 const ModelHighAPI_RefAttr & theCircle);
433 std::shared_ptr<ModelHighAPI_Interface> setVertical(
434 const ModelHighAPI_RefAttr & theLine);
436 /// Set constraint value
439 const std::shared_ptr<ModelHighAPI_Interface> & theConstraint,
440 const ModelHighAPI_Double & theValue);
442 /// Move point or sketch feature
444 void move(const ModelHighAPI_RefAttr& theMovedEntity,
445 const std::shared_ptr<GeomAPI_Pnt2d>& theTargetPoint);
447 /// Move point or sketch feature
449 void move(const ModelHighAPI_RefAttr& theMovedEntity,
450 double theTargetX, double theTargetY);
453 std::shared_ptr<GeomAPI_Pnt2d> to2D(const std::shared_ptr<GeomAPI_Pnt>& thePoint);
455 // TODO(spo): rename to selectFaces() or faces() (or add faces() -> list to SWIG)
458 std::list<ModelHighAPI_Selection> selectFace() const;
460 /// Dump wrapped feature
462 virtual void dump(ModelHighAPI_Dumper& theDumper) const;
465 std::shared_ptr<ModelAPI_CompositeFeature> compositeFeature() const;
469 //! Pointer on Sketch object
470 typedef std::shared_ptr<SketchAPI_Sketch> SketchPtr;
472 /**\ingroup CPPHighAPI
473 * \brief Create Sketch feature
476 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
477 const std::shared_ptr<GeomAPI_Ax3> & thePlane);
479 /**\ingroup CPPHighAPI
480 * \brief Create Sketch feature
483 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
484 const ModelHighAPI_Selection & theExternal);
486 /**\ingroup CPPHighAPI
487 * \brief Create Sketch feature
490 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
491 const std::string & theExternalName);
493 /**\ingroup CPPHighAPI
494 * \brief Create Sketch feature
497 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
498 std::shared_ptr<ModelAPI_Object> thePlaneObject);
500 //--------------------------------------------------------------------------------------
501 //--------------------------------------------------------------------------------------
502 #endif /* SRC_SKETCHAPI_SKETCHAPI_SKETCH_H_ */