X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketchAPI%2FSketchAPI_Sketch.h;h=7f2fa98ea31fef627833078d25504f9835eee8c9;hb=f64e1300ed35bb1e9a2486cdb5713355e832dd39;hp=1e17d9daa22c079f03caea22e816a9553ca9ce0b;hpb=5944daf4fc389aee952abc5ace5a618512684f87;p=modules%2Fshaper.git diff --git a/src/SketchAPI/SketchAPI_Sketch.h b/src/SketchAPI/SketchAPI_Sketch.h index 1e17d9daa..7f2fa98ea 100644 --- a/src/SketchAPI/SketchAPI_Sketch.h +++ b/src/SketchAPI/SketchAPI_Sketch.h @@ -1,8 +1,21 @@ -// Name : SketchAPI_Sketch.h -// Purpose: +// Copyright (C) 2014-2023 CEA, EDF +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// History: -// 07/06/16 - Sergey POKHODENKO - Creation of the file #ifndef SRC_SKETCHAPI_SKETCHAPI_SKETCH_H_ #define SRC_SKETCHAPI_SKETCHAPI_SKETCH_H_ @@ -14,26 +27,40 @@ #include #include +#include +#include #include #include +#include //-------------------------------------------------------------------------------------- class ModelAPI_CompositeFeature; class ModelAPI_Object; -class ModelHighAPI_Double; class ModelHighAPI_Integer; class ModelHighAPI_RefAttr; -class ModelHighAPI_Selection; +class ModelHighAPI_Reference; class SketchAPI_Arc; +class SketchAPI_MacroArc; class SketchAPI_Circle; +class SketchAPI_MacroCircle; +class SketchAPI_Ellipse; +class SketchAPI_MacroEllipse; +class SketchAPI_EllipticArc; +class SketchAPI_MacroEllipticArc; +class SketchAPI_BSpline; class SketchAPI_IntersectionPoint; class SketchAPI_Line; class SketchAPI_Mirror; +class SketchAPI_Offset; class SketchAPI_Point; class SketchAPI_Projection; class SketchAPI_Rectangle; class SketchAPI_Rotation; class SketchAPI_Translation; +class SketchAPI_MacroMiddlePoint; + +//-------------------------------------------------------------------------------------- +typedef std::pair, ModelHighAPI_RefAttr> PointOrReference; //-------------------------------------------------------------------------------------- /**\class SketchAPI_Sketch * \ingroup CPPHighAPI @@ -53,28 +80,56 @@ public: SKETCHAPI_EXPORT SketchAPI_Sketch(const std::shared_ptr & theFeature, const ModelHighAPI_Selection & theExternal); + /// Constructor with values + SKETCHAPI_EXPORT + SketchAPI_Sketch(const std::shared_ptr & theFeature, + std::shared_ptr thePlaneObject); /// Destructor SKETCHAPI_EXPORT virtual ~SketchAPI_Sketch(); INTERFACE_7(SketchPlugin_Sketch::ID(), - origin, SketchPlugin_Sketch::ORIGIN_ID(), GeomDataAPI_Point, /** Origin point */, - dirX, SketchPlugin_Sketch::DIRX_ID(), GeomDataAPI_Dir, /** Direction of X */, - normal, SketchPlugin_Sketch::NORM_ID(), GeomDataAPI_Dir, /** Normal */, - features, SketchPlugin_Sketch::FEATURES_ID(), ModelAPI_AttributeRefList, /** Features */, - external, SketchPlugin_SketchEntity::EXTERNAL_ID(), ModelAPI_AttributeSelection, /** External */, - solverError, SketchPlugin_Sketch::SOLVER_ERROR(), ModelAPI_AttributeString, /** Solver error */, - solverDOF, SketchPlugin_Sketch::SOLVER_DOF(), ModelAPI_AttributeString, /** Solver DOF */ + origin, SketchPlugin_Sketch::ORIGIN_ID(), + GeomDataAPI_Point, /** Origin point */, + dirX, SketchPlugin_Sketch::DIRX_ID(), + GeomDataAPI_Dir, /** Direction of X */, + normal, SketchPlugin_Sketch::NORM_ID(), + GeomDataAPI_Dir, /** Normal */, + features, SketchPlugin_Sketch::FEATURES_ID(), + ModelAPI_AttributeRefList, /** Features */, + external, SketchPlugin_SketchEntity::EXTERNAL_ID(), + ModelAPI_AttributeSelection, /** External */, + solverError, SketchPlugin_Sketch::SOLVER_ERROR(), + ModelAPI_AttributeString, /** Solver error */, + solverDOF, SketchPlugin_Sketch::SOLVER_DOF(), + ModelAPI_AttributeString, /** Solver DOF */ ) /// Set plane SKETCHAPI_EXPORT void setPlane(const std::shared_ptr & thePlane); + /// Change sketch plane + SKETCHAPI_EXPORT + void setPlane(const ModelHighAPI_Selection & thePlane, + bool theRemoveExternalDependency = false); + /// Set external SKETCHAPI_EXPORT void setExternal(const ModelHighAPI_Selection & theExternal); + /// Set external + SKETCHAPI_EXPORT + void setExternal(std::shared_ptr thePlaneObject); + + /// Change order of sketch results (faces) + SKETCHAPI_EXPORT + void changeFacesOrder(const std::list >& theFaces); + + /// List points not connected by constraints with other sketch entitites + SKETCHAPI_EXPORT + std::list< std::shared_ptr > getFreePoints(); + /// Add point SKETCHAPI_EXPORT std::shared_ptr addPoint( @@ -88,14 +143,18 @@ public: std::shared_ptr addPoint(const ModelHighAPI_Selection & theExternal); /// Add point SKETCHAPI_EXPORT - std::shared_ptr addPoint(const std::string & theExternalName); + std::shared_ptr addPoint(const std::wstring & theExternalName); /// Add intersection point SKETCHAPI_EXPORT - std::shared_ptr addIntersectionPoint(const ModelHighAPI_Selection & theExternal); + std::shared_ptr + addIntersectionPoint(const ModelHighAPI_Selection & theExternal, + bool theKeepResult = false); /// Add point SKETCHAPI_EXPORT - std::shared_ptr addIntersectionPoint(const std::string & theExternalName); + std::shared_ptr + addIntersectionPoint(const std::wstring & theExternalName, + bool theKeepResult = false); /// Add line SKETCHAPI_EXPORT @@ -111,7 +170,7 @@ public: std::shared_ptr addLine(const ModelHighAPI_Selection & theExternal); /// Add line SKETCHAPI_EXPORT - std::shared_ptr addLine(const std::string & theExternalName); + std::shared_ptr addLine(const std::wstring & theExternalName); /// Add rectangle SKETCHAPI_EXPORT @@ -122,35 +181,101 @@ public: std::shared_ptr addRectangle( const std::shared_ptr & theStartPoint, const std::shared_ptr & theEndPoint); + /// Add rectangle + SKETCHAPI_EXPORT + std::shared_ptr addRectangleCentered( + const std::pair, ModelHighAPI_RefAttr> & theCenter, + const std::pair, ModelHighAPI_RefAttr> & theCorner); - /// Add circle + /// Add circle. + /// [DEPRECATED]: use addCircleWithPoint() instead. SKETCHAPI_EXPORT std::shared_ptr addCircle( double theCenterX, double theCenterY, double theRadius); - /// Add circle + /// Add circle. + /// [DEPRECATED]: use addCircleWithPoint() instead. SKETCHAPI_EXPORT std::shared_ptr addCircle( const std::shared_ptr& theCenter, double theRadius); - /// Add circle + /// Add circle. + /// [DEPRECATED]: use addCircleWithPoint() instead. SKETCHAPI_EXPORT - std::shared_ptr addCircle( + std::shared_ptr addCircle( + double theCenterX, double theCenterY, + double thePassedX, double thePassedY); + /// Add circle. + /// [DEPRECATED]: use addCircleWithPoint() instead. + SKETCHAPI_EXPORT + std::shared_ptr addCircle( + const std::shared_ptr& theCenterPoint, + const std::shared_ptr& thePassedPoint); + /// Add circle. + /// [DEPRECATED]: use addCircleWithPoint() instead. + SKETCHAPI_EXPORT + std::shared_ptr addCircle( double theX1, double theY1, double theX2, double theY2, double theX3, double theY3); - /// Add circle + /// Add circle. + /// [DEPRECATED]: use addCircleWithPoint() instead. SKETCHAPI_EXPORT - std::shared_ptr addCircle( + std::shared_ptr addCircle( const std::shared_ptr& thePoint1, const std::shared_ptr& thePoint2, const std::shared_ptr& thePoint3); - /// Add circle + /// Add circle. + /// [DEPRECATED]: use addCircleWithPoint() instead. SKETCHAPI_EXPORT std::shared_ptr addCircle(const ModelHighAPI_Selection & theExternal); - /// Add circle + /// Add circle. + /// [DEPRECATED]: use addCircleWithPoint() instead. + SKETCHAPI_EXPORT + std::shared_ptr addCircle(const std::wstring & theExternalName); + + /// Add circle with point + SKETCHAPI_EXPORT + std::shared_ptr addCircleWithPoint( + double theCenterX, double theCenterY, + double theRadius, double theAngle); + /// Add circle with point + SKETCHAPI_EXPORT + std::shared_ptr addCircleWithPoint( + const std::shared_ptr& theCenter, + double theRadius, double theAngle); + /// Add circle with point + SKETCHAPI_EXPORT + std::shared_ptr addCircleWithPoint( + double theCenterX, double theCenterY, + double thePassedX, double thePassedY, + double theAngle); + /// Add circle with point SKETCHAPI_EXPORT - std::shared_ptr addCircle(const std::string & theExternalName); + std::shared_ptr addCircleWithPoint( + const std::shared_ptr& theCenterPoint, + const std::shared_ptr& thePassedPoint, + double theAngle); + /// Add circle with point + SKETCHAPI_EXPORT + std::shared_ptr addCircleWithPoint( + double theX1, double theY1, + double theX2, double theY2, + double theX3, double theY3, + double theAngle); + /// Add circle with point + SKETCHAPI_EXPORT + std::shared_ptr addCircleWithPoint( + const std::shared_ptr& thePoint1, + const std::shared_ptr& thePoint2, + const std::shared_ptr& thePoint3, + double theAngle); + /// Add circle with point + SKETCHAPI_EXPORT + std::shared_ptr addCircleWithPoint(const ModelHighAPI_Selection& theExternal); + /// Add circle with point + SKETCHAPI_EXPORT + std::shared_ptr addCircleWithPoint(const std::wstring& theExternalName); /// Add arc SKETCHAPI_EXPORT @@ -170,31 +295,33 @@ public: /// Add arc SKETCHAPI_EXPORT - std::shared_ptr addArc( + std::shared_ptr addArc( double theStartX, double theStartY, double theEndX, double theEndY, double thePassedX, double thePassedY); /// Add arc SKETCHAPI_EXPORT - std::shared_ptr addArc( + std::shared_ptr addArc( const std::shared_ptr& theStart, const std::shared_ptr& theEnd, const std::shared_ptr& thePassed); - /// Add arc + /// Add transversal/tangent arc SKETCHAPI_EXPORT - std::shared_ptr addArc( - const ModelHighAPI_RefAttr& theTangentPoint, + std::shared_ptr addArc( + const ModelHighAPI_RefAttr& theConnectedPoint, double theEndX, double theEndY, - bool theInversed); + bool theInversed, + bool theTransversal = false); - /// Add arc + /// Add transversal/tangent arc SKETCHAPI_EXPORT - std::shared_ptr addArc( - const ModelHighAPI_RefAttr& theTangentPoint, + std::shared_ptr addArc( + const ModelHighAPI_RefAttr& theConnectedPoint, const std::shared_ptr& theEnd, - bool theInversed); + bool theInversed, + bool theTransversal = false); /// Add arc SKETCHAPI_EXPORT @@ -202,16 +329,96 @@ public: /// Add arc SKETCHAPI_EXPORT - std::shared_ptr addArc(const std::string & theExternalName); + std::shared_ptr addArc(const std::wstring & theExternalName); - /// Add projection + /// Add ellipse SKETCHAPI_EXPORT - std::shared_ptr addProjection( - const ModelHighAPI_Selection & theExternalFeature); + std::shared_ptr addEllipse( + double theCenterX, double theCenterY, + double theFocusX, double theFocusY, + double theMinorRadius); + /// Add ellipse + SKETCHAPI_EXPORT + std::shared_ptr addEllipse( + const std::shared_ptr& theCenter, + const std::shared_ptr& theFocus, + double theRadius); + /// Add ellipse + SKETCHAPI_EXPORT + std::shared_ptr addEllipse( + double thePoint1X, double thePoint1Y, + double thePoint2X, double thePoint2Y, + double thePassedX, double thePassedY, + bool isPoint1Center = true); + /// Add ellipse + SKETCHAPI_EXPORT + std::shared_ptr addEllipse( + const PointOrReference& thePoint1, + const PointOrReference& thePoint2, + const PointOrReference& thePassedPoint, + bool isPoint1Center = true); + /// Add ellipse + SKETCHAPI_EXPORT + std::shared_ptr addEllipse(const ModelHighAPI_Selection & theExternal); + /// Add ellipse + SKETCHAPI_EXPORT + std::shared_ptr addEllipse(const std::wstring & theExternalName); + + /// Add elliptic arc + SKETCHAPI_EXPORT + std::shared_ptr addEllipticArc( + double theCenterX, double theCenterY, + double theFocusX, double theFocusY, + double theStartX, double theStartY, + double theEndX, double theEndY, + bool theInversed = false); + /// Add elliptic arc + SKETCHAPI_EXPORT + std::shared_ptr addEllipticArc( + const PointOrReference& theCenter, + const PointOrReference& theMajorAxisPoint, + const PointOrReference& theStartPoint, + const PointOrReference& theEndPoint, + bool theInversed = false); + /// Add elliptic arc + SKETCHAPI_EXPORT + std::shared_ptr addEllipticArc(const ModelHighAPI_Selection & theExternal); + /// Add elliptic arc + SKETCHAPI_EXPORT + std::shared_ptr addEllipticArc(const std::wstring & theExternalName); + + /// Add B-spline + SKETCHAPI_EXPORT + std::shared_ptr addSpline( + const ModelHighAPI_Selection & external = ModelHighAPI_Selection(), + const int degree = -1, + const std::list& poles = std::list(), + const std::list& weights = std::list(), + const std::list& knots = std::list(), + const std::list& multiplicities = std::list(), + const bool periodic = false); + + /// Add interpolation feature + SKETCHAPI_EXPORT + std::shared_ptr addInterpolation( + const std::list& points, + const bool periodic = false, + const bool closed = false); + + /// Add approximation feature + SKETCHAPI_EXPORT + std::shared_ptr addApproximation( + const std::list& points, + const ModelHighAPI_Double& precision = ModelHighAPI_Double(1.e-3), + const bool periodic = false, + const bool closed = false); /// Add projection SKETCHAPI_EXPORT - std::shared_ptr addProjection(const std::string & theExternalName); + std::shared_ptr addProjection( + const ModelHighAPI_Selection & theExternalFeature, + bool keepResult = false, + bool keepRefToOriginal = true); /// Add mirror SKETCHAPI_EXPORT @@ -219,6 +426,15 @@ public: const ModelHighAPI_RefAttr & theMirrorLine, const std::list > & theObjects); + /// Add offset + SKETCHAPI_EXPORT + std::shared_ptr addOffset( + const std::list > & theObjects, + const ModelHighAPI_Double & theValue, + const bool theReversed = false, + const std::string & theJointType = SketchPlugin_Offset::JOINT_KEEP_DISTANCE(), + const bool theApprox = false); + /// Add translation SKETCHAPI_EXPORT std::shared_ptr addTranslation( @@ -235,103 +451,183 @@ public: const ModelHighAPI_RefAttr & theCenter, const ModelHighAPI_Double & theAngle, const ModelHighAPI_Integer & theNumberOfObjects, - bool theFullValue = false); + bool theFullValue = false, + bool theReversed = false); + + /// Add split + SKETCHAPI_EXPORT + std::shared_ptr addSplit( + const ModelHighAPI_Reference& theFeature, + const std::shared_ptr& thePositionPoint); + + /// Add trim + SKETCHAPI_EXPORT + std::shared_ptr addTrim( + const ModelHighAPI_Reference& theFeature, + const std::shared_ptr& thePositionPoint); /// Set angle SKETCHAPI_EXPORT - std::shared_ptr setAngle( + std::shared_ptr setAngle( + const ModelHighAPI_RefAttr & theLine1, + const ModelHighAPI_RefAttr & theLine2, + const ModelHighAPI_Double & theValue, + const std::string& type = std::string()); + + /// Set complementary angle + SKETCHAPI_EXPORT + std::shared_ptr setAngleComplementary( + const ModelHighAPI_RefAttr & theLine1, + const ModelHighAPI_RefAttr & theLine2, + const ModelHighAPI_Double & theValue); + + /// Set backward angle (= 360 - angle) + SKETCHAPI_EXPORT + std::shared_ptr setAngleBackward( const ModelHighAPI_RefAttr & theLine1, const ModelHighAPI_RefAttr & theLine2, const ModelHighAPI_Double & theValue); /// Set coincident SKETCHAPI_EXPORT - std::shared_ptr setCoincident( + std::shared_ptr setCoincident( const ModelHighAPI_RefAttr & thePoint1, const ModelHighAPI_RefAttr & thePoint2); /// Set collinear SKETCHAPI_EXPORT - std::shared_ptr setCollinear( + std::shared_ptr setCollinear( const ModelHighAPI_RefAttr & theLine1, const ModelHighAPI_RefAttr & theLine2); /// Set distance SKETCHAPI_EXPORT - std::shared_ptr setDistance( + std::shared_ptr setDistance( + const ModelHighAPI_RefAttr & thePoint, + const ModelHighAPI_RefAttr & thePointOrLine, + const ModelHighAPI_Double & theValue, + bool isSigned = false); + + /// Set signed distance + SKETCHAPI_EXPORT + std::shared_ptr setSignedDistance( + const ModelHighAPI_RefAttr & thePoint, + const ModelHighAPI_RefAttr & thePointOrLine, + const ModelHighAPI_Double & theValue); + + /// Set unsigned distance + SKETCHAPI_EXPORT + std::shared_ptr setUnsignedDistance( const ModelHighAPI_RefAttr & thePoint, const ModelHighAPI_RefAttr & thePointOrLine, const ModelHighAPI_Double & theValue); + /// Set horizontal distance + SKETCHAPI_EXPORT + std::shared_ptr setHorizontalDistance( + const ModelHighAPI_RefAttr & thePoint1, + const ModelHighAPI_RefAttr & thePoint2, + const ModelHighAPI_Double & theValue); + + /// Set vertical distance + SKETCHAPI_EXPORT + std::shared_ptr setVerticalDistance( + const ModelHighAPI_RefAttr & thePoint1, + const ModelHighAPI_RefAttr & thePoint2, + const ModelHighAPI_Double & theValue); + /// Set equal SKETCHAPI_EXPORT - std::shared_ptr setEqual( + std::shared_ptr setEqual( const ModelHighAPI_RefAttr & theObject1, const ModelHighAPI_RefAttr & theObject2); /// Set fillet SKETCHAPI_EXPORT - std::shared_ptr setFillet( - const std::list & thePoints, + std::shared_ptr setFillet( + const ModelHighAPI_RefAttr & thePoint); + + /// Set fillet with additional radius constraint + SKETCHAPI_EXPORT + std::shared_ptr setFilletWithRadius( + const ModelHighAPI_RefAttr & thePoint, const ModelHighAPI_Double & theRadius); /// Set fixed SKETCHAPI_EXPORT - std::shared_ptr setFixed( + std::shared_ptr setFixed( const ModelHighAPI_RefAttr & theObject); /// Set horizontal SKETCHAPI_EXPORT - std::shared_ptr setHorizontal( + std::shared_ptr setHorizontal( const ModelHighAPI_RefAttr & theLine); /// Set length SKETCHAPI_EXPORT - std::shared_ptr setLength( + std::shared_ptr setLength( const ModelHighAPI_RefAttr & theLine, const ModelHighAPI_Double & theValue); /// Set middle SKETCHAPI_EXPORT - std::shared_ptr setMiddlePoint( + std::shared_ptr setMiddlePoint( const ModelHighAPI_RefAttr & thePoint, const ModelHighAPI_RefAttr & theLine); + /// Set middle + SKETCHAPI_EXPORT + std::shared_ptr setMiddlePoint( + const ModelHighAPI_RefAttr& theLine); + /// Set parallel SKETCHAPI_EXPORT - std::shared_ptr setParallel( + std::shared_ptr setParallel( const ModelHighAPI_RefAttr & theLine1, const ModelHighAPI_RefAttr & theLine2); /// Set perpendicular SKETCHAPI_EXPORT - std::shared_ptr setPerpendicular( + std::shared_ptr setPerpendicular( const ModelHighAPI_RefAttr & theLine1, const ModelHighAPI_RefAttr & theLine2); /// Set radius SKETCHAPI_EXPORT - std::shared_ptr setRadius( + std::shared_ptr setRadius( const ModelHighAPI_RefAttr & theCircleOrArc, const ModelHighAPI_Double & theValue); /// Set tangent SKETCHAPI_EXPORT - std::shared_ptr setTangent( + std::shared_ptr setTangent( const ModelHighAPI_RefAttr & theLine, const ModelHighAPI_RefAttr & theCircle); /// Set vertical SKETCHAPI_EXPORT - std::shared_ptr setVertical( + std::shared_ptr setVertical( const ModelHighAPI_RefAttr & theLine); /// Set constraint value SKETCHAPI_EXPORT void setValue( - const std::shared_ptr & theConstraint, + const std::shared_ptr & theConstraint, const ModelHighAPI_Double & theValue); + /// Move point or sketch feature + SKETCHAPI_EXPORT + void move(const ModelHighAPI_RefAttr& theMovedEntity, + const std::shared_ptr& theTargetPoint); + + /// Move point or sketch feature + SKETCHAPI_EXPORT + void move(const ModelHighAPI_RefAttr& theMovedEntity, + double theTargetX, double theTargetY); + + SKETCHAPI_EXPORT + std::shared_ptr to2D(const std::shared_ptr& thePoint); + // TODO(spo): rename to selectFaces() or faces() (or add faces() -> list to SWIG) /// Select face SKETCHAPI_EXPORT @@ -349,6 +645,8 @@ protected: //! Pointer on Sketch object typedef std::shared_ptr SketchPtr; +//-------------------------------------------------------------------------------------- + /**\ingroup CPPHighAPI * \brief Create Sketch feature */ @@ -368,8 +666,23 @@ SketchPtr addSketch(const std::shared_ptr & thePart, */ SKETCHAPI_EXPORT SketchPtr addSketch(const std::shared_ptr & thePart, - const std::string & theExternalName); + const std::wstring & theExternalName); + +/**\ingroup CPPHighAPI + * \brief Create Sketch feature + */ +SKETCHAPI_EXPORT +SketchPtr addSketch(const std::shared_ptr & thePart, + std::shared_ptr thePlaneObject); //-------------------------------------------------------------------------------------- + +/** \ingroup CPPHighAPI + * \brief Copy sketch with all its sub-features + */ +SKETCHAPI_EXPORT +SketchPtr copySketch(const std::shared_ptr & thePart, + const SketchPtr & theSketch); + //-------------------------------------------------------------------------------------- #endif /* SRC_SKETCHAPI_SKETCHAPI_SKETCH_H_ */