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,
129 bool theKeepResult = false);
132 std::shared_ptr<SketchAPI_IntersectionPoint>
133 addIntersectionPoint(const std::string & theExternalName,
134 bool theKeepResult = false);
138 std::shared_ptr<SketchAPI_Line> addLine(
139 double theX1, double theY1, double theX2, double theY2);
142 std::shared_ptr<SketchAPI_Line> addLine(
143 const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
144 const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint);
147 std::shared_ptr<SketchAPI_Line> addLine(const ModelHighAPI_Selection & theExternal);
150 std::shared_ptr<SketchAPI_Line> addLine(const std::string & theExternalName);
154 std::shared_ptr<SketchAPI_Rectangle> addRectangle(
155 double theX1, double theY1, double theX2, double theY2);
158 std::shared_ptr<SketchAPI_Rectangle> addRectangle(
159 const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
160 const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint);
164 std::shared_ptr<SketchAPI_Circle> addCircle(
165 double theCenterX, double theCenterY,
169 std::shared_ptr<SketchAPI_Circle> addCircle(
170 const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
174 std::shared_ptr<SketchAPI_MacroCircle> addCircle(
175 double theCenterX, double theCenterY,
176 double thePassedX, double thePassedY);
179 std::shared_ptr<SketchAPI_MacroCircle> addCircle(
180 const std::shared_ptr<GeomAPI_Pnt2d>& theCenterPoint,
181 const std::shared_ptr<GeomAPI_Pnt2d>& thePassedPoint);
184 std::shared_ptr<SketchAPI_MacroCircle> addCircle(
185 double theX1, double theY1,
186 double theX2, double theY2,
187 double theX3, double theY3);
190 std::shared_ptr<SketchAPI_MacroCircle> addCircle(
191 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint1,
192 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint2,
193 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint3);
196 std::shared_ptr<SketchAPI_Circle> addCircle(const ModelHighAPI_Selection & theExternal);
199 std::shared_ptr<SketchAPI_Circle> addCircle(const std::string & theExternalName);
203 std::shared_ptr<SketchAPI_Arc> addArc(
204 double theCenterX, double theCenterY,
205 double theStartX, double theStartY,
206 double theEndX, double theEndY,
211 std::shared_ptr<SketchAPI_Arc> addArc(
212 const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
213 const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
214 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
219 std::shared_ptr<SketchAPI_MacroArc> addArc(
220 double theStartX, double theStartY,
221 double theEndX, double theEndY,
222 double thePassedX, double thePassedY);
226 std::shared_ptr<SketchAPI_MacroArc> addArc(
227 const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
228 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
229 const std::shared_ptr<GeomAPI_Pnt2d>& thePassed);
233 std::shared_ptr<SketchAPI_MacroArc> addArc(
234 const ModelHighAPI_RefAttr& theTangentPoint,
235 double theEndX, double theEndY,
240 std::shared_ptr<SketchAPI_MacroArc> addArc(
241 const ModelHighAPI_RefAttr& theTangentPoint,
242 const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
247 std::shared_ptr<SketchAPI_Arc> addArc(const ModelHighAPI_Selection & theExternal);
251 std::shared_ptr<SketchAPI_Arc> addArc(const std::string & theExternalName);
255 std::shared_ptr<SketchAPI_Projection> addProjection(
256 const ModelHighAPI_Selection & theExternalFeature,
257 bool theKeepResult = false);
261 std::shared_ptr<SketchAPI_Projection> addProjection(const std::string & theExternalName,
262 bool theKeepResult = false);
266 std::shared_ptr<SketchAPI_Mirror> addMirror(
267 const ModelHighAPI_RefAttr & theMirrorLine,
268 const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects);
272 std::shared_ptr<SketchAPI_Translation> addTranslation(
273 const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects,
274 const ModelHighAPI_RefAttr & thePoint1,
275 const ModelHighAPI_RefAttr & thePoint2,
276 const ModelHighAPI_Integer & theNumberOfObjects,
277 bool theFullValue = false);
281 std::shared_ptr<SketchAPI_Rotation> addRotation(
282 const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects,
283 const ModelHighAPI_RefAttr & theCenter,
284 const ModelHighAPI_Double & theAngle,
285 const ModelHighAPI_Integer & theNumberOfObjects,
286 bool theFullValue = false,
287 bool theReversed = false);
291 std::shared_ptr<ModelHighAPI_Interface> addSplit(
292 const ModelHighAPI_Reference& theFeature,
293 const std::shared_ptr<GeomAPI_Pnt2d>& thePositionPoint);
297 std::shared_ptr<ModelHighAPI_Interface> addTrim(
298 const ModelHighAPI_Reference& theFeature,
299 const std::shared_ptr<GeomAPI_Pnt2d>& thePositionPoint);
303 std::shared_ptr<ModelHighAPI_Interface> setAngle(
304 const ModelHighAPI_RefAttr & theLine1,
305 const ModelHighAPI_RefAttr & theLine2,
306 const ModelHighAPI_Double & theValue);
308 /// Set complementary angle
310 std::shared_ptr<ModelHighAPI_Interface> setAngleComplementary(
311 const ModelHighAPI_RefAttr & theLine1,
312 const ModelHighAPI_RefAttr & theLine2,
313 const ModelHighAPI_Double & theValue);
315 /// Set backward angle (= 360 - angle)
317 std::shared_ptr<ModelHighAPI_Interface> setAngleBackward(
318 const ModelHighAPI_RefAttr & theLine1,
319 const ModelHighAPI_RefAttr & theLine2,
320 const ModelHighAPI_Double & theValue);
324 std::shared_ptr<ModelHighAPI_Interface> setCoincident(
325 const ModelHighAPI_RefAttr & thePoint1,
326 const ModelHighAPI_RefAttr & thePoint2);
330 std::shared_ptr<ModelHighAPI_Interface> setCollinear(
331 const ModelHighAPI_RefAttr & theLine1,
332 const ModelHighAPI_RefAttr & theLine2);
336 std::shared_ptr<ModelHighAPI_Interface> setDistance(
337 const ModelHighAPI_RefAttr & thePoint,
338 const ModelHighAPI_RefAttr & thePointOrLine,
339 const ModelHighAPI_Double & theValue,
340 bool isSigned = false);
342 /// Set signed distance
344 std::shared_ptr<ModelHighAPI_Interface> setSignedDistance(
345 const ModelHighAPI_RefAttr & thePoint,
346 const ModelHighAPI_RefAttr & thePointOrLine,
347 const ModelHighAPI_Double & theValue);
349 /// Set unsigned distance
351 std::shared_ptr<ModelHighAPI_Interface> setUnsignedDistance(
352 const ModelHighAPI_RefAttr & thePoint,
353 const ModelHighAPI_RefAttr & thePointOrLine,
354 const ModelHighAPI_Double & theValue);
356 /// Set horizontal distance
358 std::shared_ptr<ModelHighAPI_Interface> setHorizontalDistance(
359 const ModelHighAPI_RefAttr & thePoint1,
360 const ModelHighAPI_RefAttr & thePoint2,
361 const ModelHighAPI_Double & theValue);
363 /// Set vertical distance
365 std::shared_ptr<ModelHighAPI_Interface> setVerticalDistance(
366 const ModelHighAPI_RefAttr & thePoint1,
367 const ModelHighAPI_RefAttr & thePoint2,
368 const ModelHighAPI_Double & theValue);
372 std::shared_ptr<ModelHighAPI_Interface> setEqual(
373 const ModelHighAPI_RefAttr & theObject1,
374 const ModelHighAPI_RefAttr & theObject2);
378 std::shared_ptr<ModelHighAPI_Interface> setFillet(
379 const ModelHighAPI_RefAttr & thePoint);
381 /// Set fillet with additional radius constraint
383 std::shared_ptr<ModelHighAPI_Interface> setFilletWithRadius(
384 const ModelHighAPI_RefAttr & thePoint,
385 const ModelHighAPI_Double & theRadius);
389 std::shared_ptr<ModelHighAPI_Interface> setFixed(
390 const ModelHighAPI_RefAttr & theObject);
394 std::shared_ptr<ModelHighAPI_Interface> setHorizontal(
395 const ModelHighAPI_RefAttr & theLine);
399 std::shared_ptr<ModelHighAPI_Interface> setLength(
400 const ModelHighAPI_RefAttr & theLine,
401 const ModelHighAPI_Double & theValue);
405 std::shared_ptr<ModelHighAPI_Interface> setMiddlePoint(
406 const ModelHighAPI_RefAttr & thePoint,
407 const ModelHighAPI_RefAttr & theLine);
411 std::shared_ptr<ModelHighAPI_Interface> setParallel(
412 const ModelHighAPI_RefAttr & theLine1,
413 const ModelHighAPI_RefAttr & theLine2);
415 /// Set perpendicular
417 std::shared_ptr<ModelHighAPI_Interface> setPerpendicular(
418 const ModelHighAPI_RefAttr & theLine1,
419 const ModelHighAPI_RefAttr & theLine2);
423 std::shared_ptr<ModelHighAPI_Interface> setRadius(
424 const ModelHighAPI_RefAttr & theCircleOrArc,
425 const ModelHighAPI_Double & theValue);
429 std::shared_ptr<ModelHighAPI_Interface> setTangent(
430 const ModelHighAPI_RefAttr & theLine,
431 const ModelHighAPI_RefAttr & theCircle);
435 std::shared_ptr<ModelHighAPI_Interface> setVertical(
436 const ModelHighAPI_RefAttr & theLine);
438 /// Set constraint value
441 const std::shared_ptr<ModelHighAPI_Interface> & theConstraint,
442 const ModelHighAPI_Double & theValue);
444 /// Move point or sketch feature
446 void move(const ModelHighAPI_RefAttr& theMovedEntity,
447 const std::shared_ptr<GeomAPI_Pnt2d>& theTargetPoint);
449 /// Move point or sketch feature
451 void move(const ModelHighAPI_RefAttr& theMovedEntity,
452 double theTargetX, double theTargetY);
455 std::shared_ptr<GeomAPI_Pnt2d> to2D(const std::shared_ptr<GeomAPI_Pnt>& thePoint);
457 // TODO(spo): rename to selectFaces() or faces() (or add faces() -> list to SWIG)
460 std::list<ModelHighAPI_Selection> selectFace() const;
462 /// Dump wrapped feature
464 virtual void dump(ModelHighAPI_Dumper& theDumper) const;
467 std::shared_ptr<ModelAPI_CompositeFeature> compositeFeature() const;
471 //! Pointer on Sketch object
472 typedef std::shared_ptr<SketchAPI_Sketch> SketchPtr;
474 /**\ingroup CPPHighAPI
475 * \brief Create Sketch feature
478 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
479 const std::shared_ptr<GeomAPI_Ax3> & thePlane);
481 /**\ingroup CPPHighAPI
482 * \brief Create Sketch feature
485 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
486 const ModelHighAPI_Selection & theExternal);
488 /**\ingroup CPPHighAPI
489 * \brief Create Sketch feature
492 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
493 const std::string & theExternalName);
495 /**\ingroup CPPHighAPI
496 * \brief Create Sketch feature
499 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
500 std::shared_ptr<ModelAPI_Object> thePlaneObject);
502 //--------------------------------------------------------------------------------------
503 //--------------------------------------------------------------------------------------
504 #endif /* SRC_SKETCHAPI_SKETCHAPI_SKETCH_H_ */