SHAPER  9.15.0
ModelAPI_Tools.h
1 // Copyright (C) 2014-2025 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);
142 
143 /*
144 * Returns the result - main parent of this result.
145 * \param theSubBody the sub-element of composit result
146 * \returns Root resultBody
147 */
148 MODELAPI_EXPORT std::shared_ptr<ModelAPI_ResultBody> mainBody(const std::shared_ptr<ModelAPI_ResultBody> theSubBody);
149 
154 MODELAPI_EXPORT int bodyIndex(const std::shared_ptr<ModelAPI_Result>& theSub);
155 
162 MODELAPI_EXPORT bool hasSubResults(const std::shared_ptr<ModelAPI_Result>& theResult);
163 
167 MODELAPI_EXPORT void allSubs(const std::shared_ptr<ModelAPI_ResultBody>& theResult,
168  std::list<std::shared_ptr<ModelAPI_Result> >& theResults,
169  const bool theLowerOnly = false);
170 
174 MODELAPI_EXPORT void allResults(const std::shared_ptr<ModelAPI_Feature>& theFeature,
175  std::list<std::shared_ptr<ModelAPI_Result> >& theResults);
176 
182 MODELAPI_EXPORT bool allDocumentsActivated(std::wstring& theNotActivatedNames);
183 
189 MODELAPI_EXPORT bool removeFeaturesAndReferences(
190  const std::set<std::shared_ptr<ModelAPI_Feature> >& theFeatures,
191  const bool theFlushRedisplay = false,
192  const bool theUseComposite = false,
193  const bool theUseRecursion = true);
194 
200 MODELAPI_EXPORT bool removeFeatures(
201  const std::set<std::shared_ptr<ModelAPI_Feature> >& theFeatures,
202  const bool theFlushRedisplay);
203 
212 MODELAPI_EXPORT void findAllReferences(
213  const std::set<std::shared_ptr<ModelAPI_Feature> >& theFeatures,
214  std::map<std::shared_ptr<ModelAPI_Feature>,
215  std::set<std::shared_ptr<ModelAPI_Feature> > >& theReferences,
216  const bool theUseComposite = true,
217  const bool theUseRecursion = true);
218 
224 MODELAPI_EXPORT void findRefsToFeatures(
225  const std::set<std::shared_ptr<ModelAPI_Feature> >& aFeatures,
226  const std::map<std::shared_ptr<ModelAPI_Feature>,
227  std::set<std::shared_ptr<ModelAPI_Feature> > >& aReferences,
228  std::set<std::shared_ptr<ModelAPI_Feature> >& aFeaturesRefsTo);
229 
234 MODELAPI_EXPORT void getConcealedResults(const std::shared_ptr<ModelAPI_Feature>& theFeature,
235  std::list<std::shared_ptr<ModelAPI_Result> >& theResults);
236 
242 MODELAPI_EXPORT std::pair<std::wstring, bool> getDefaultName(
243  const std::shared_ptr<ModelAPI_Result>& theResult,
244  const bool theInherited = true,
245  const bool theRecursive = false);
246 
249 MODELAPI_EXPORT std::set<std::shared_ptr<ModelAPI_Feature> >
250  getParents(const std::shared_ptr<ModelAPI_Feature>& theFeature);
251 
257 MODELAPI_EXPORT void fillShapeHierarchy(
258  const std::shared_ptr<GeomAPI_Shape>& theShape,
259  const std::shared_ptr<ModelAPI_Result>& theContext,
260  GeomAPI_ShapeHierarchy& theHierarchy);
261 
264 MODELAPI_EXPORT void removeResults(const std::list<std::shared_ptr<ModelAPI_Result> >& theResults);
265 
270 MODELAPI_EXPORT double getDeflection(const std::shared_ptr<ModelAPI_Result>& theResult);
271 
276 MODELAPI_EXPORT void setDeflection(std::shared_ptr<ModelAPI_Result> theResult,
277  const double theDeflection);
278 
283 MODELAPI_EXPORT void getColor(const std::shared_ptr<ModelAPI_Result>& theResult,
284  std::vector<int>& theColor);
285 
291 MODELAPI_EXPORT void getColor(const std::shared_ptr<ModelAPI_Result> theResult,
292  const std::shared_ptr<GeomAPI_Shape> theShape,
293  std::vector<int>& theColor);
294 
301 MODELAPI_EXPORT void getColoredSubShapes(const std::shared_ptr<ModelAPI_Result> theResult,
302  std::map<std::shared_ptr<GeomAPI_Shape>, std::vector<int>>& theColoredShapes,
303  bool theGetSubResults = false);
304 
309 MODELAPI_EXPORT void removeSubShapeColors(const std::shared_ptr<ModelAPI_Result> theResult);
310 
315 MODELAPI_EXPORT void setColor(std::shared_ptr<ModelAPI_Result> theResult,
316  const std::vector<int>& theColor);
317 
323 MODELAPI_EXPORT void setColor(std::shared_ptr<ModelAPI_Result> theResult,
324  std::shared_ptr<GeomAPI_Shape> theShape,
325  const std::vector<int>& theColor);
326 
331 MODELAPI_EXPORT void getIsoLines(const std::shared_ptr<ModelAPI_Result>& theResult,
332  bool& isVisible, std::vector<int>& theNbLines);
333 
338 MODELAPI_EXPORT void setIsoLines(std::shared_ptr<ModelAPI_Result> theResult,
339  const std::vector<int>& theIso);
340 
345 MODELAPI_EXPORT void showIsoLines(std::shared_ptr<ModelAPI_Result> theResult, bool theShow);
346 
347 MODELAPI_EXPORT bool isShownIsoLines(std::shared_ptr<ModelAPI_Result> theResult);
348 
353 MODELAPI_EXPORT void showEdgesDirection(std::shared_ptr<ModelAPI_Result> theResult, bool theShow);
354 
355 MODELAPI_EXPORT bool isShowEdgesDirection(std::shared_ptr<ModelAPI_Result> theResult);
356 
361 MODELAPI_EXPORT void bringToFront(std::shared_ptr<ModelAPI_Result> theResult, bool theFlag);
362 
363 MODELAPI_EXPORT bool isBringToFront(std::shared_ptr<ModelAPI_Result> theResult);
364 
369 MODELAPI_EXPORT double getTransparency(const std::shared_ptr<ModelAPI_Result>& theResult);
370 
375 MODELAPI_EXPORT void setTransparency(std::shared_ptr<ModelAPI_Result> theResult,
376  double theTransparency);
377 
378 
383 MODELAPI_EXPORT void copyVisualizationAttrs(std::shared_ptr<ModelAPI_Result> theSource,
384  std::shared_ptr<ModelAPI_Result> theDest);
385 
390 MODELAPI_EXPORT void copyImageAttribute(std::shared_ptr<ModelAPI_Result> theSource,
391  std::shared_ptr<ModelAPI_Result> theDest);
392 
398 MODELAPI_EXPORT std::list<std::shared_ptr<ModelAPI_Feature> > referencedFeatures(
399  std::shared_ptr<ModelAPI_Result> theTarget, const std::string& theFeatureKind,
400  const bool theSortResults);
401 
405 MODELAPI_EXPORT bool isInResults(AttributeSelectionListPtr theSelection,
406  const std::list<ResultPtr>& theResults,
407  std::set<ResultPtr>& theCashedResults);
408 
415 MODELAPI_EXPORT void findRandomColor(std::vector<int>& theValues, bool theReset = false);
416 
424 MODELAPI_EXPORT std::wstring validateMovement(
425  const FeaturePtr& theAfter, const std::list<FeaturePtr> theMoved);
426 
427 }
428 
429 #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:53
Feature function that represents the particular functionality of this operation.
Definition: ModelAPI_Feature.h:41
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:37
Definition: ModelAPI_Tools.h:54