1 // Copyright (C) 2014-2023 CEA, EDF
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 SketchPlugin_Fillet_H_
21 #define SketchPlugin_Fillet_H_
23 #include "SketchPlugin.h"
25 #include "SketchPlugin_SketchEntity.h"
27 #include <GeomAPI_IPresentable.h>
28 #include <GeomDataAPI_Point2D.h>
32 /// \class SketchPlugin_Fillet
34 /// \brief Feature for creation of a new arc filleting two objects which have
36 class SketchPlugin_Fillet: public SketchPlugin_SketchEntity, public GeomAPI_IPresentable
40 inline static const std::string& ID()
42 static const std::string MY_FEATURE_ID("SketchFillet");
46 /// Attribute name of fillet point.
47 inline static const std::string& FILLET_POINT_ID()
49 static const std::string ID("fillet_point");
53 /// \return the kind of a feature.
54 SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
56 static std::string MY_KIND = SketchPlugin_Fillet::ID();
60 /// \brief Creates a new part document if needed.
61 SKETCHPLUGIN_EXPORT virtual void execute();
63 /// \brief Request for initialization of data model of the feature: adding all attributes.
64 SKETCHPLUGIN_EXPORT virtual void initAttributes();
66 /// Returns the AIS preview
67 SKETCHPLUGIN_EXPORT virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
69 /// Reimplemented from ModelAPI_Feature::isMacro().
71 SKETCHPLUGIN_EXPORT virtual bool isMacro() const {return true;}
73 SKETCHPLUGIN_EXPORT virtual bool isPreviewNeeded() const {return false;}
75 /// Reimplemented from SketchPlugin_Feature::move().
77 SKETCHPLUGIN_EXPORT virtual void move(const double, const double) {}
79 /// \brief Use plugin manager for features creation
80 SketchPlugin_Fillet();
83 bool calculateFilletParameters();
85 /// Create new feature presenting a fillet arc and initialize its parameters
86 FeaturePtr createFilletArc();
88 /// Create point representing fillet apex and additional coincidences with fillet features
89 FeaturePtr createFilletApex(const std::shared_ptr<GeomAPI_Pnt2d>& theCoordinates);
91 /// Remove references to a feature participating in fillet,
92 /// but transfer "distance" constraints to features after fillet
93 /// \param[in, out] theFeaturesToRemove features referred to fillet edges
94 /// (all distances will be processed and removed from this list)
95 /// \param[in] theFilletPoints fillet points from participating features
96 void removeReferencesButKeepDistances(std::set<FeaturePtr>& theFeaturesToRemove,
97 const AttributePoint2DPtr theFilletPoints[2]);
99 bool findFeaturesContainingFilletPoint(std::shared_ptr<GeomDataAPI_Point2D> theFilletPoint);
102 FeaturePtr myBaseFeatures[2];
103 std::string myFeatAttributes[4]; // attributes of features
105 bool myIsNotInversed[2]; // indicates which point the features share
106 bool myFilletCreated;
107 std::shared_ptr<GeomAPI_XY> myCenterXY;
108 std::shared_ptr<GeomAPI_XY> myTangentXY1;
109 std::shared_ptr<GeomAPI_XY> myTangentXY2;