Salome HOME
Add copyright header according to request of CEA from 06.06.2017
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_Fillet.h
1 // Copyright (C) 2014-2017  CEA/DEN, EDF R&D
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 //
20
21 #ifndef SketchPlugin_Fillet_H_
22 #define SketchPlugin_Fillet_H_
23
24 #include "SketchPlugin.h"
25
26 #include "SketchPlugin_SketchEntity.h"
27
28 #include <GeomAPI_IPresentable.h>
29 #include <GeomDataAPI_Point2D.h>
30
31 class GeomAPI_XY;
32
33 /// \class SketchPlugin_Fillet
34 /// \ingroup Plugins
35 /// \brief Feature for creation of a new arc filleting two objects which have
36 /// coincident point.
37 class SketchPlugin_Fillet: public SketchPlugin_SketchEntity, public GeomAPI_IPresentable
38 {
39  public:
40   /// Feature kind.
41   inline static const std::string& ID()
42   {
43     static const std::string MY_FEATURE_ID("SketchFillet");
44     return MY_FEATURE_ID;
45   }
46
47   /// Attribute name of fillet point.
48   inline static const std::string& FILLET_POINT_ID()
49   {
50     static const std::string ID("fillet_point");
51     return ID;
52   }
53
54   /// \return the kind of a feature.
55   SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
56   {
57     static std::string MY_KIND = SketchPlugin_Fillet::ID();
58     return MY_KIND;
59   }
60
61   /// \brief Creates a new part document if needed.
62   SKETCHPLUGIN_EXPORT virtual void execute();
63
64   /// \brief Request for initialization of data model of the feature: adding all attributes.
65   SKETCHPLUGIN_EXPORT virtual void initAttributes();
66
67   /// Returns the AIS preview
68   SKETCHPLUGIN_EXPORT virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
69
70   /// Reimplemented from ModelAPI_Feature::isMacro().
71   /// \returns true
72   SKETCHPLUGIN_EXPORT virtual bool isMacro() const {return true;}
73
74   SKETCHPLUGIN_EXPORT virtual bool isPreviewNeeded() const {return false;}
75
76   /// Reimplemented from SketchPlugin_Feature::move().
77   /// Do nothing.
78   SKETCHPLUGIN_EXPORT virtual void move(const double, const double) {}
79
80   /// \brief Use plugin manager for features creation
81   SketchPlugin_Fillet();
82
83 private:
84   bool calculateFilletParameters();
85
86   bool findFeaturesContainingFilletPoint(std::shared_ptr<GeomDataAPI_Point2D> theFilletPoint);
87
88 private:
89     FeaturePtr myBaseFeatures[2];
90     std::string myFeatAttributes[4]; // attributes of features
91     bool myIsReversed;
92     bool myIsNotInversed[2]; // indicates which point the features share
93     bool myFilletCreated;
94     std::shared_ptr<GeomAPI_XY> myCenterXY;
95     std::shared_ptr<GeomAPI_XY> myTangentXY1;
96     std::shared_ptr<GeomAPI_XY> myTangentXY2;
97 };
98
99 #endif