SHAPER  9.12.0
ModelAPI_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 ModelAPI_Tools_HeaderFile
21 #define ModelAPI_Tools_HeaderFile
22 
23 #include "ModelAPI.h"
24 #include <ModelAPI_AttributeSelectionList.h>
25 
27 class ModelAPI_Document;
28 class ModelAPI_Feature;
29 class ModelAPI_Result;
32 
34 class GeomAPI_Shape;
36 
37 #include <memory>
38 #include <vector>
39 #include <map>
40 #include <set>
41 #include <list>
42 
43 namespace ModelAPI_Tools {
45 MODELAPI_EXPORT std::shared_ptr<GeomAPI_Shape> shape(
46  const std::shared_ptr<ModelAPI_Result>& theResult);
47 
52 MODELAPI_EXPORT std::string getFeatureError(const std::shared_ptr<ModelAPI_Feature>& theFeature);
53 
55  std::shared_ptr<ModelAPI_ResultBody> resultBody;
56  std::shared_ptr<GeomAPI_Shape> baseShape;
57  std::shared_ptr<GeomAlgoAPI_MakeShape> makeShape;
58 };
59 
60 MODELAPI_EXPORT void loadModifiedShapes(std::shared_ptr<ModelAPI_ResultBody> theResultBody,
61  const std::list<std::shared_ptr<GeomAPI_Shape>>& theBaseShapes,
62  const std::list<std::shared_ptr<GeomAPI_Shape>>& theTools,
63  const std::shared_ptr<GeomAlgoAPI_MakeShape>& theMakeShape,
64  const std::shared_ptr<GeomAPI_Shape> theResultShape,
65  const std::string& theNamePrefix = "");
66 
67 MODELAPI_EXPORT void loadModifiedShapes(std::shared_ptr<ModelAPI_ResultBody> theResultBody,
68  const std::shared_ptr<GeomAPI_Shape>& theBaseShape,
69  const std::shared_ptr<GeomAlgoAPI_MakeShape>& theMakeShape,
70  const std::string theName);
72 MODELAPI_EXPORT void loadDeletedShapes(std::shared_ptr<ModelAPI_ResultBody> theResultBody,
73  const std::shared_ptr<GeomAPI_Shape> theBaseShape,
74  const std::list<std::shared_ptr<GeomAPI_Shape>>& theTools,
75  const std::shared_ptr<GeomAlgoAPI_MakeShape>& theMakeShape,
76  const std::shared_ptr<GeomAPI_Shape> theResultShapesCompound);
77 
79 MODELAPI_EXPORT void loadDeletedShapes(std::vector<ResultBaseAlgo>& theResultBaseAlgoList,
80  const std::list<std::shared_ptr<GeomAPI_Shape>>& theTools,
81  const std::shared_ptr<GeomAPI_Shape> theResultShapesCompound);
82 
88 MODELAPI_EXPORT bool findVariable(const std::shared_ptr<ModelAPI_Document>& theDocument,
89  std::shared_ptr<ModelAPI_Feature> theSearcher,
90  const std::wstring& theName, double& outValue,
91  std::shared_ptr<ModelAPI_ResultParameter>& theParam);
92 
99 MODELAPI_EXPORT bool findVariable(std::shared_ptr<ModelAPI_Feature> theSearcher,
100  const std::wstring& theName,
101  double& outValue, std::shared_ptr<ModelAPI_ResultParameter>& theParam,
102  const std::shared_ptr<ModelAPI_Document>& theDocument = std::shared_ptr<ModelAPI_Document>());
103 
111 MODELAPI_EXPORT std::shared_ptr<ModelAPI_Result> findPartResult(
112  const std::shared_ptr<ModelAPI_Document>& theMain,
113  const std::shared_ptr<ModelAPI_Document>& theSub);
114 
122 MODELAPI_EXPORT std::shared_ptr<ModelAPI_Feature> findPartFeature(
123  const std::shared_ptr<ModelAPI_Document>& theMain,
124  const std::shared_ptr<ModelAPI_Document>& theSub);
125 
131 MODELAPI_EXPORT std::shared_ptr<ModelAPI_CompositeFeature> compositeOwner(
132  const std::shared_ptr<ModelAPI_Feature>& theFeature);
133 
140 MODELAPI_EXPORT std::shared_ptr<ModelAPI_ResultBody>
141  bodyOwner(const std::shared_ptr<ModelAPI_Result>& theSub, const bool theRoot = false);
146 MODELAPI_EXPORT int bodyIndex(const std::shared_ptr<ModelAPI_Result>& theSub);
147 
154 MODELAPI_EXPORT bool hasSubResults(const std::shared_ptr<ModelAPI_Result>& theResult);
155 
159 MODELAPI_EXPORT void allSubs(const std::shared_ptr<ModelAPI_ResultBody>& theResult,
160  std::list<std::shared_ptr<ModelAPI_Result> >& theResults,
161  const bool theLowerOnly = false);
162 
166 MODELAPI_EXPORT void allResults(const std::shared_ptr<ModelAPI_Feature>& theFeature,
167  std::list<std::shared_ptr<ModelAPI_Result> >& theResults);
168 
174 MODELAPI_EXPORT bool allDocumentsActivated(std::wstring& theNotActivatedNames);
175 
181 MODELAPI_EXPORT bool removeFeaturesAndReferences(
182  const std::set<std::shared_ptr<ModelAPI_Feature> >& theFeatures,
183  const bool theFlushRedisplay = false,
184  const bool theUseComposite = false,
185  const bool theUseRecursion = true);
186 
192 MODELAPI_EXPORT bool removeFeatures(
193  const std::set<std::shared_ptr<ModelAPI_Feature> >& theFeatures,
194  const bool theFlushRedisplay);
195 
204 MODELAPI_EXPORT void findAllReferences(
205  const std::set<std::shared_ptr<ModelAPI_Feature> >& theFeatures,
206  std::map<std::shared_ptr<ModelAPI_Feature>,
207  std::set<std::shared_ptr<ModelAPI_Feature> > >& theReferences,
208  const bool theUseComposite = true,
209  const bool theUseRecursion = true);
210 
216 MODELAPI_EXPORT void findRefsToFeatures(
217  const std::set<std::shared_ptr<ModelAPI_Feature> >& aFeatures,
218  const std::map<std::shared_ptr<ModelAPI_Feature>,
219  std::set<std::shared_ptr<ModelAPI_Feature> > >& aReferences,
220  std::set<std::shared_ptr<ModelAPI_Feature> >& aFeaturesRefsTo);
221 
226 MODELAPI_EXPORT void getConcealedResults(const std::shared_ptr<ModelAPI_Feature>& theFeature,
227  std::list<std::shared_ptr<ModelAPI_Result> >& theResults);
228 
234 MODELAPI_EXPORT std::pair<std::wstring, bool> getDefaultName(
235  const std::shared_ptr<ModelAPI_Result>& theResult,
236  const bool theInherited = true,
237  const bool theRecursive = false);
238 
241 MODELAPI_EXPORT std::set<std::shared_ptr<ModelAPI_Feature> >
242  getParents(const std::shared_ptr<ModelAPI_Feature>& theFeature);
243 
249 MODELAPI_EXPORT void fillShapeHierarchy(
250  const std::shared_ptr<GeomAPI_Shape>& theShape,
251  const std::shared_ptr<ModelAPI_Result>& theContext,
252  GeomAPI_ShapeHierarchy& theHierarchy);
253 
256 MODELAPI_EXPORT void removeResults(const std::list<std::shared_ptr<ModelAPI_Result> >& theResults);
257 
262 MODELAPI_EXPORT double getDeflection(const std::shared_ptr<ModelAPI_Result>& theResult);
263 
268 MODELAPI_EXPORT void setDeflection(std::shared_ptr<ModelAPI_Result> theResult,
269  const double theDeflection);
270 
275 MODELAPI_EXPORT void getColor(const std::shared_ptr<ModelAPI_Result>& theResult,
276  std::vector<int>& theColor);
277 
282 MODELAPI_EXPORT void setColor(std::shared_ptr<ModelAPI_Result> theResult,
283  const std::vector<int>& theColor);
284 
289 MODELAPI_EXPORT void getIsoLines(const std::shared_ptr<ModelAPI_Result>& theResult,
290  bool& isVisible, std::vector<int>& theNbLines);
291 
296 MODELAPI_EXPORT void setIsoLines(std::shared_ptr<ModelAPI_Result> theResult,
297  const std::vector<int>& theIso);
298 
303 MODELAPI_EXPORT void showIsoLines(std::shared_ptr<ModelAPI_Result> theResult, bool theShow);
304 
305 MODELAPI_EXPORT bool isShownIsoLines(std::shared_ptr<ModelAPI_Result> theResult);
306 
311 MODELAPI_EXPORT void showEdgesDirection(std::shared_ptr<ModelAPI_Result> theResult, bool theShow);
312 
313 MODELAPI_EXPORT bool isShowEdgesDirection(std::shared_ptr<ModelAPI_Result> theResult);
314 
319 MODELAPI_EXPORT void bringToFront(std::shared_ptr<ModelAPI_Result> theResult, bool theFlag);
320 
321 MODELAPI_EXPORT bool isBringToFront(std::shared_ptr<ModelAPI_Result> theResult);
322 
327 MODELAPI_EXPORT double getTransparency(const std::shared_ptr<ModelAPI_Result>& theResult);
328 
333 MODELAPI_EXPORT void setTransparency(std::shared_ptr<ModelAPI_Result> theResult,
334  double theTransparency);
335 
336 
341 MODELAPI_EXPORT void copyVisualizationAttrs(std::shared_ptr<ModelAPI_Result> theSource,
342  std::shared_ptr<ModelAPI_Result> theDest);
343 
348 MODELAPI_EXPORT void copyImageAttribute(std::shared_ptr<ModelAPI_Result> theSource,
349  std::shared_ptr<ModelAPI_Result> theDest);
350 
356 MODELAPI_EXPORT std::list<std::shared_ptr<ModelAPI_Feature> > referencedFeatures(
357  std::shared_ptr<ModelAPI_Result> theTarget, const std::string& theFeatureKind,
358  const bool theSortResults);
359 
363 MODELAPI_EXPORT bool isInResults(AttributeSelectionListPtr theSelection,
364  const std::list<ResultPtr>& theResults,
365  std::set<ResultPtr>& theCashedResults);
366 
373 MODELAPI_EXPORT void findRandomColor(std::vector<int>& theValues, bool theReset = false);
374 
382 MODELAPI_EXPORT std::wstring validateMovement(
383  const FeaturePtr& theAfter, const std::list<FeaturePtr> theMoved);
384 
385 }
386 
387 #endif
Storage for the hierarchy of shapes and their parents (compounds or compsolids)
Definition: GeomAPI_ShapeHierarchy.h:34
Interface to the topological shape object.
Definition: GeomAPI_Shape.h:43
Interface to the root class of all topological shapes constructions.
Definition: GeomAlgoAPI_MakeShape.h:35
Feature that consists of other features: like sketcher with edges inside.
Definition: ModelAPI_CompositeFeature.h:33
Document for internal data structure of any object storage.
Definition: ModelAPI_Document.h:52
Feature function that represents the particular functionality of this operation.
Definition: ModelAPI_Feature.h:39
The body (shape) result of a feature.
Definition: ModelAPI_ResultBody.h:43
The construction element result of a feature.
Definition: ModelAPI_ResultParameter.h:34
The result of a feature.
Definition: ModelAPI_Result.h:35
Definition: ModelAPI_Tools.h:54