SHAPER  9.12.0
SketchPlugin_Tools.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_TOOLS_H_
21 #define SKETCHPLUGIN_TOOLS_H_
22 
23 #include <GeomAPI_Pnt2d.h>
24 
25 #include <ModelAPI_Feature.h>
26 #include <ModelAPI_Attribute.h>
27 #include <ModelAPI_AttributeRefAttr.h>
28 #include <GeomAPI_Shape.h>
29 #include <GeomAPI_AISObject.h>
30 #include <GeomDataAPI_Point2D.h>
31 #include <GeomDataAPI_Point2DArray.h>
32 #include <GeomAlgoAPI_ShapeTools.h>
33 
34 #include <list>
35 #include <map>
36 
37 class GeomAPI_AISObject;
38 
42 
43 namespace SketchPlugin_Tools {
44 
46 void clearExpressions(FeaturePtr theFeature);
47 
50 std::shared_ptr<GeomAPI_Pnt2d> getCoincidencePoint(const FeaturePtr theStartCoin);
51 
53 std::set<FeaturePtr> findCoincidentConstraints(const ObjectPtr& theObject);
54 
60 void findCoincidences(const FeaturePtr theStartCoin,
61  const std::string& theAttr,
62  std::set<FeaturePtr>& theList,
63  const bool theIsAttrOnly = false);
64 
66 std::set<FeaturePtr> findFeaturesCoincidentToPoint(const AttributePoint2DPtr& thePoint);
67 
69 std::set<AttributePoint2DPtr> findPointsCoincidentToPoint(const AttributePoint2DPtr& thePoint);
70 
71 void resetAttribute(SketchPlugin_Feature* theFeature, const std::string& theId);
72 
78 FeaturePtr createConstraintAttrAttr(SketchPlugin_Sketch* theSketch,
79  const std::string& theConstraintId,
80  const AttributePtr& theFirstAttribute,
81  const AttributePtr& theSecondAttribute);
82 
88 FeaturePtr createConstraintAttrObject(SketchPlugin_Sketch* theSketch,
89  const std::string& theConstraintId,
90  const AttributePtr& theFirstAttribute,
91  const ObjectPtr& theSecondObject);
92 
98 FeaturePtr createConstraintObjectObject(SketchPlugin_Sketch* theSketch,
99  const std::string& theConstraintId,
100  const ObjectPtr& theFirstObject,
101  const ObjectPtr& theSecondObject);
102 
109 void createCoincidenceOrTangency(SketchPlugin_Feature* theFeature,
110  const std::string& theId,
111  const AttributePtr theAttr,
112  const ObjectPtr theObject,
113  const bool theIsCanBeTangent);
114 
119 void createAuxiliaryPointOnEllipse(const FeaturePtr& theEllipseFeature,
120  const std::string& theAttrName);
121 
126 void createAuxiliaryAxisOfEllipse(const FeaturePtr& theEllipseFeature,
127  const std::string& theStartAttr,
128  const std::string& theEndAttr);
129 
135 void convertRefAttrToPointOrTangentCurve(const AttributeRefAttrPtr& theRefAttr,
136  const AttributePtr& theDefaultAttr,
137  std::shared_ptr<GeomAPI_Shape>& theTangentCurve,
138  std::shared_ptr<GeomAPI_Pnt2d>& thePassingPoint);
139 
141 GeomPnt2dPtr flyoutPointCoordinates(const std::shared_ptr<SketchPlugin_Constraint>& theConstraint);
142 
146 void customizeFeaturePrs(const AISObjectPtr& thePrs, bool isAxiliary);
147 
148 void setDimensionColor(const AISObjectPtr& theDimPrs);
149 
151 void replaceInName(ObjectPtr theObject, const std::wstring& theSource, const std::wstring& theDest);
152 
153 }; // namespace SketchPlugin_Tools
154 
155 namespace SketchPlugin_SegmentationTools
156 {
162  void getFeaturePoints(const FeaturePtr& theFeature,
163  std::shared_ptr<GeomDataAPI_Point2D>& theStartPointAttr,
164  std::shared_ptr<GeomDataAPI_Point2D>& theEndPointAttr);
165 
174  void getRefAttributes(const FeaturePtr& theFeature,
175  std::map<AttributePtr, std::list<AttributePtr> >& theRefs,
176  std::list<AttributePtr>& theRefsToFeature);
177 
182  GeomShapePtr getSubShape(
183  SketchPlugin_Feature* theFeature,
184  const std::string& theObjectAttributeId,
185  const std::string& thePointAttributeId,
186  std::map<ObjectPtr, std::set<GeomShapePtr> >& theCashedShapes,
187  std::map<ObjectPtr, GeomAlgoAPI_ShapeTools::PointToRefsMap>& theObjectToPoints);
188 
193  void fillObjectShapes(
194  SketchPlugin_Feature* theOpFeature,
195  const ObjectPtr& theObject,
196  std::map<ObjectPtr, std::set<GeomShapePtr> >& theCashedShapes,
197  std::map<ObjectPtr, GeomAlgoAPI_ShapeTools::PointToRefsMap>& theObjectToPoints);
198 
202  std::shared_ptr<GeomAPI_AISObject> getAISObject(std::shared_ptr<GeomAPI_AISObject> thePrevious,
203  SketchPlugin_Feature* theOpFeature,
204  const std::string& thePreviewObjectAttrName,
205  const std::string& thePreviewPointAttrName,
206  const std::string& theSelectedObjectAttrName,
207  const std::string& theSelectedPointAttrName);
208 
213  void updateRefAttConstraints(
214  const std::map<AttributePtr, std::list<AttributePtr> >& theBaseRefAttributes,
215  const std::set<std::pair<AttributePtr, AttributePtr> >& theModifiedAttributes);
216 
219  void updateFeaturesAfterOperation(const std::set<FeaturePtr>& theFeaturesToUpdate);
220 
221 
226  FeaturePtr createLineFeature(const FeaturePtr& theBaseFeature,
227  const std::shared_ptr<GeomAPI_Pnt2d>& theFirstPoint,
228  const std::shared_ptr<GeomAPI_Pnt2d>& theSecondPoint);
229 
235  FeaturePtr createArcFeature(
236  const FeaturePtr& theBaseFeature,
237  const std::shared_ptr<GeomAPI_Pnt2d>& theFirstPoint,
238  const std::shared_ptr<GeomAPI_Pnt2d>& theSecondPoint);
239 
240 }; // namespace SketchPlugin_SegmentationTools
241 
242 #endif // SKETCHPLUGIN_TOOLS_H_
Interface for AIS_InteractiveObject.
Definition: GeomAPI_AISObject.h:39
Abstract interface to the SketchPlugin_ConstraintBase For more info see: SketchPlugin_ConstraintBase....
Definition: SketchPlugin_Constraint.h:35
Feature for creation of the new feature in PartSet.
Definition: SketchPlugin_Feature.h:40
Feature for creation of the new part in PartSet.
Definition: SketchPlugin_Sketch.h:47