SHAPER  9.12.0
SketchPlugin_Offset.h
1 // Copyright (C) 2020-2023 CEA, EDF
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 email : webmaster.salome@opencascade.com
18 //
19 
20 #ifndef SketchPlugin_Offset_H_
21 #define SketchPlugin_Offset_H_
22 
23 #include <SketchPlugin.h>
24 #include <SketchPlugin_ConstraintBase.h>
25 
26 #include <GeomDataAPI_Point2D.h>
27 
28 #include <GeomAPI_Edge.h>
29 
31 class GeomAlgoAPI_Offset;
33 
39 {
40 public:
42  inline static const std::string& ID()
43  {
44  static const std::string ID("SketchOffset");
45  return ID;
46  }
47 
49  SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
50  {
51  static std::string MY_KIND = SketchPlugin_Offset::ID();
52  return MY_KIND;
53  }
54 
56  inline static const std::string& JOINT_ID()
57  {
58  static const std::string ID("offset_joint");
59  return ID;
60  }
61 
63  inline static const std::string& JOINT_KEEP_DISTANCE()
64  {
65  static const std::string ID("KeepDistance");
66  return ID;
67  }
68 
70  inline static const std::string& JOINT_ARCS()
71  {
72  static const std::string ID("Arcs");
73  return ID;
74  }
75 
77  inline static const std::string& JOINT_LINES()
78  {
79  static const std::string ID("Lines");
80  return ID;
81  }
82 
84  inline static const std::string& EDGES_ID()
85  {
86  static const std::string ID("segments");
87  return ID;
88  }
89 
91  inline static const std::string& VALUE_ID()
92  {
93  static const std::string ID("offset_value");
94  return ID;
95  }
96 
98  inline static const std::string& REVERSED_ID()
99  {
100  static const std::string ID("reversed");
101  return ID;
102  }
103 
105  inline static const std::string& APPROX_ID()
106  {
107  static const std::string ID("approx");
108  return ID;
109  }
110 
112  inline static const std::string& ADD_WIRE_ACTION_ID()
113  {
114  static const std::string ID("add_wire");
115  return ID;
116  }
117 
119  SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
120 
122  SKETCHPLUGIN_EXPORT virtual void execute();
123 
124  SKETCHPLUGIN_EXPORT virtual bool isPreviewNeeded() const { return true; }
125 
131  SKETCHPLUGIN_EXPORT virtual bool customAction(const std::string& theActionId);
132 
134  SKETCHPLUGIN_EXPORT virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
135 
138 
139 protected:
141  virtual void initAttributes();
142 
143 private:
145  bool findWires();
146 
150  void addToSketch (const std::list< std::shared_ptr<GeomAlgoAPI_MakeShape> >& theOffsetAlgos);
151 
153  void mkBSpline (FeaturePtr& theResult, const GeomEdgePtr& theEdge,
154  std::list<ObjectPtr>& thePoolOfFeatures);
155 
160  void updateExistentOrCreateNew (const GeomShapePtr& theShape, FeaturePtr& theFeature,
161  std::list<ObjectPtr>& thePoolOfFeatures);
162 
173  bool findWireOneWay (const FeaturePtr& theFirstEdge,
174  const FeaturePtr& theEdge,
175  const std::shared_ptr<GeomDataAPI_Point2D>& theEndPoint,
176  std::set<FeaturePtr>& theEdgesSet,
177  std::set<FeaturePtr>& theProcessedEdgesSet,
178  std::list<FeaturePtr>& theChain,
179  const bool isPrepend = false);
180 
181  void makeFillet (const double theValue,
182  const std::shared_ptr<GeomAlgoAPI_WireBuilder>&,
183  const std::shared_ptr<GeomAlgoAPI_Offset>&,
184  std::list< std::shared_ptr<GeomAlgoAPI_MakeShape> >& theOffsetAlgos);
185 };
186 
187 #endif
Interface to the root class of all topological shapes constructions.
Definition: GeomAlgoAPI_MakeShape.h:35
Perform 3D offset for the shape.
Definition: GeomAlgoAPI_Offset.h:42
Allows to create wire-shapes by different parameters.
Definition: GeomAlgoAPI_WireBuilder.h:32
Feature for creation of a new constraint between other features.
Definition: SketchPlugin_ConstraintBase.h:56
Builds offset curves in the sketch.
Definition: SketchPlugin_Offset.h:39
virtual SKETCHPLUGIN_EXPORT bool customAction(const std::string &theActionId)
Find edges connected by coincident boundary constraint and composing a wire with the already selected...
Definition: SketchPlugin_Offset.cpp:767
static const std::string & APPROX_ID()
attribute to approx by segments and arcs
Definition: SketchPlugin_Offset.h:105
static const std::string & EDGES_ID()
list of offset edges
Definition: SketchPlugin_Offset.h:84
static const std::string & JOINT_ARCS()
Arcs joint (make fillets on all straight lines intersections)
Definition: SketchPlugin_Offset.h:70
static const std::string & VALUE_ID()
attribute to store the offset value
Definition: SketchPlugin_Offset.h:91
virtual void initAttributes()
Initializes attributes of derived class.
Definition: SketchPlugin_Offset.cpp:76
SketchPlugin_Offset()
Use plugin manager for features creation.
Definition: SketchPlugin_Offset.cpp:72
virtual SKETCHPLUGIN_EXPORT AISObjectPtr getAISObject(AISObjectPtr thePrevious)
Returns the AIS preview.
Definition: SketchPlugin_Offset.cpp:839
static const std::string & JOINT_ID()
Type of joint.
Definition: SketchPlugin_Offset.h:56
static const std::string & JOINT_LINES()
Lines joint (do not add new arcs, prolongate and intersect adjacent lines)
Definition: SketchPlugin_Offset.h:77
static const std::string & REVERSED_ID()
attribute to store the reversed offset direction
Definition: SketchPlugin_Offset.h:98
static const std::string & ADD_WIRE_ACTION_ID()
name for add wire action
Definition: SketchPlugin_Offset.h:112
virtual SKETCHPLUGIN_EXPORT const std::string & getKind()
Returns the kind of a feature.
Definition: SketchPlugin_Offset.h:49
static const std::string & ID()
Offset macro feature kind.
Definition: SketchPlugin_Offset.h:42
virtual SKETCHPLUGIN_EXPORT bool isPreviewNeeded() const
Returns true if preview update during the edition needed.
Definition: SketchPlugin_Offset.h:124
virtual SKETCHPLUGIN_EXPORT void execute()
Creates a new part document if needed.
Definition: SketchPlugin_Offset.cpp:140
virtual SKETCHPLUGIN_EXPORT void attributeChanged(const std::string &theID)
Called on change of any argument-attribute of this object.
Definition: SketchPlugin_Offset.cpp:742
static const std::string & JOINT_KEEP_DISTANCE()
Keep distance joint (add arcs where needed)
Definition: SketchPlugin_Offset.h:63