SHAPER  9.12.0
SketchPlugin_Split.h
1 // Copyright (C) 2014-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_Split_H_
21 #define SketchPlugin_Split_H_
22 
23 #include "SketchPlugin.h"
24 #include "SketchPlugin_Tools.h"
25 
26 #include <GeomAPI_IPresentable.h>
27 #include <ModelAPI_IReentrant.h>
28 
29 #include <SketchPlugin_Sketch.h>
30 
32 class ModelAPI_Feature;
33 class ModelAPI_Result;
34 
35 typedef std::pair<std::string, std::shared_ptr<GeomDataAPI_Point2D> > IdToPointPair;
36 
64  public ModelAPI_IReentrant
65 {
66  public:
68  inline static const std::string& ID()
69  {
70  static const std::string MY_SPLIT_ID("SketchSplit");
71  return MY_SPLIT_ID;
72  }
74  SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
75  {
76  static std::string MY_KIND = SketchPlugin_Split::ID();
77  return MY_KIND;
78  }
80  inline static const std::string& SELECTED_OBJECT()
81  {
82  static const std::string MY_SELECTED_OBJECT("SelectedObject");
83  return MY_SELECTED_OBJECT;
84  }
85 
87  inline static const std::string& SELECTED_POINT()
88  {
89  static const std::string MY_SELECTED_POINT("SelectedPoint");
90  return MY_SELECTED_POINT;
91  }
92 
94  inline static const std::string& PREVIEW_OBJECT()
95  {
96  static const std::string MY_PREVIEW_OBJECT("PreviewObject");
97  return MY_PREVIEW_OBJECT;
98  }
99 
101  inline static const std::string& PREVIEW_POINT()
102  {
103  static const std::string MY_PREVIEW_POINT("PreviewPoint");
104  return MY_PREVIEW_POINT;
105  }
106 
108  SKETCHPLUGIN_EXPORT virtual void execute();
109 
111  SKETCHPLUGIN_EXPORT virtual void initAttributes();
112 
115  SKETCHPLUGIN_EXPORT virtual bool isMacro() const { return true; }
116 
119  SKETCHPLUGIN_EXPORT virtual bool isPreviewNeeded() const { return false; }
120 
123 
125  SKETCHPLUGIN_EXPORT virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
126 
128  virtual std::string processEvent(const std::shared_ptr<Events_Message>& theMessage);
129 
130 private:
138  void getConstraints(std::set<std::shared_ptr<ModelAPI_Feature>>& theFeaturesToDelete,
139  std::set<std::shared_ptr<ModelAPI_Feature>>& theFeaturesToUpdate,
140  std::map<std::shared_ptr<ModelAPI_Feature>, IdToPointPair>& theCoincidenceToFeature);
141 
150  void updateCoincidenceConstraintsToFeature(
151  const std::map<std::shared_ptr<ModelAPI_Feature>, IdToPointPair>& theCoincidenceToFeature,
152  const std::set<std::shared_ptr<GeomDataAPI_Point2D> >& theFurtherCoincidences,
153  const std::set<ResultPtr>& theFeatureResults,
154  const FeaturePtr& theSplitFeature,
155  std::set<FeaturePtr>& theFeaturesToDelete);
156 
160  void updateRefFeatureConstraints(const std::shared_ptr<ModelAPI_Result>& theFeatureBaseResult,
161  const std::list<AttributePtr>& theRefsToFeature);
162 
172  FeaturePtr splitLine(std::shared_ptr<ModelAPI_Feature>& theSplitFeature,
173  std::shared_ptr<ModelAPI_Feature>& theBeforeFeature,
174  std::shared_ptr<ModelAPI_Feature>& theAfterFeature,
175  std::set<std::shared_ptr<GeomDataAPI_Point2D> >& thePoints,
176  std::set<std::shared_ptr<ModelAPI_Feature>>& theCreatedFeatures,
177  std::set<std::pair<AttributePtr, AttributePtr>>& theModifiedAttributes);
178 
186  FeaturePtr splitArc(std::shared_ptr<ModelAPI_Feature>& theSplitFeature,
187  std::shared_ptr<ModelAPI_Feature>& theBeforeFeature,
188  std::shared_ptr<ModelAPI_Feature>& theAfterFeature,
189  std::set<std::shared_ptr<GeomDataAPI_Point2D> >& thePoints,
190  std::set<std::shared_ptr<ModelAPI_Feature>>& theCreatedFeatures,
191  std::set<std::pair<AttributePtr, AttributePtr>>& theModifiedAttributes);
192 
200  FeaturePtr splitEllipticArc(std::shared_ptr<ModelAPI_Feature>& theSplitFeature,
201  std::shared_ptr<ModelAPI_Feature>& theBeforeFeature,
202  std::shared_ptr<ModelAPI_Feature>& theAfterFeature,
203  std::set<std::shared_ptr<GeomDataAPI_Point2D> >& thePoints,
204  std::set<std::shared_ptr<ModelAPI_Feature>>& theCreatedFeatures,
205  std::set<std::pair<AttributePtr, AttributePtr>>& theModifiedAttributes);
206 
214  FeaturePtr splitClosed(std::shared_ptr<ModelAPI_Feature>& theSplitFeature,
215  std::shared_ptr<ModelAPI_Feature>& theBeforeFeature,
216  std::shared_ptr<ModelAPI_Feature>& theAfterFeature,
217  std::set<std::shared_ptr<GeomDataAPI_Point2D> >& thePoints,
218  std::set<std::shared_ptr<ModelAPI_Feature>>& theCreatedFeatures,
219  std::set<std::pair<AttributePtr, AttributePtr>>& theModifiedAttributes);
220 
228  void arrangePointsOnLine(const std::shared_ptr<GeomDataAPI_Point2D>& theStartPointAttr,
229  const std::shared_ptr<GeomDataAPI_Point2D>& theEndPointAttr,
230  std::shared_ptr<GeomDataAPI_Point2D>& theFirstPointAttr,
231  std::shared_ptr<GeomDataAPI_Point2D>& theSecondPointAttr) const;
232 
241  void arrangePointsOnArc(const FeaturePtr& theArc,
242  const std::shared_ptr<GeomDataAPI_Point2D>& theStartPointAttr,
243  const std::shared_ptr<GeomDataAPI_Point2D>& theEndPointAttr,
244  std::shared_ptr<GeomDataAPI_Point2D>& theFirstPointAttr,
245  std::shared_ptr<GeomDataAPI_Point2D>& theSecondPointAttr) const;
246 
250  void fillAttribute(const AttributePtr& theModifiedAttribute,
251  const AttributePtr& theSourceAttribute);
252 
256  std::set<std::shared_ptr<ModelAPI_Attribute> > getEdgeAttributes(
257  const std::shared_ptr<ModelAPI_Feature>& theFeature);
258 
262  std::shared_ptr<GeomDataAPI_Point2D> getPointAttribute(const bool isFirstAttribute);
263 
264 #ifdef _DEBUG
268  std::string getFeatureInfo(const std::shared_ptr<ModelAPI_Feature>& theFeature,
269  const bool isUseAttributesInfo = true);
270 #endif
271 private:
272 
273  std::map<std::shared_ptr<ModelAPI_Object>, std::set<GeomShapePtr> > myCashedShapes;
274  std::map<std::shared_ptr<ModelAPI_Object>,
275  GeomAlgoAPI_ShapeTools::PointToRefsMap> myCashedReferences;
276 };
277 
278 #endif
A class which defines an interface of object which is able to create its own presentation.
Definition: GeomAPI_IPresentable.h:29
Attribute that contains 2D point coordinates.
Definition: GeomDataAPI_Point2D.h:37
Feature function that represents the particular functionality of this operation.
Definition: ModelAPI_Feature.h:39
Interface of a class which can process specific messages.
Definition: ModelAPI_IReentrant.h:35
The result of a feature.
Definition: ModelAPI_Result.h:35
Feature for creation of the new feature in PartSet.
Definition: SketchPlugin_Feature.h:40
Feature for creation of a new constraint splitting object.
Definition: SketchPlugin_Split.h:65
virtual bool isPreviewNeeded() const
Reimplemented from ModelAPI_Feature::isPreviewNeeded().
Definition: SketchPlugin_Split.h:119
virtual std::string processEvent(const std::shared_ptr< Events_Message > &theMessage)
Apply information of the message to current object. It fills selected point and object.
Definition: SketchPlugin_Split.cpp:423
static const std::string & SELECTED_OBJECT()
The value parameter for the constraint.
Definition: SketchPlugin_Split.h:80
virtual void initAttributes()
Request for initialization of data model of the feature: adding all attributes.
Definition: SketchPlugin_Split.cpp:80
static const std::string & PREVIEW_OBJECT()
The value parameter for the preview object.
Definition: SketchPlugin_Split.h:94
SketchPlugin_Split()
Use plugin manager for features creation.
Definition: SketchPlugin_Split.cpp:76
virtual const std::string & getKind()
Returns the kind of a feature.
Definition: SketchPlugin_Split.h:74
virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious)
Returns the AIS preview.
Definition: SketchPlugin_Split.cpp:489
static const std::string & ID()
Split constraint kind.
Definition: SketchPlugin_Split.h:68
static const std::string & PREVIEW_POINT()
Start 2D point of the split segment.
Definition: SketchPlugin_Split.h:101
virtual void execute()
Creates a new part document if needed.
Definition: SketchPlugin_Split.cpp:96
static const std::string & SELECTED_POINT()
Start 2D point of the split segment.
Definition: SketchPlugin_Split.h:87
virtual bool isMacro() const
Reimplemented from ModelAPI_Feature::isMacro().
Definition: SketchPlugin_Split.h:115