]> SALOME platform Git repositories - modules/shaper.git/blob - src/ModelAPI/ModelAPI_Tools.h
Salome HOME
02090e51604dbd6e5f5081db8c66154125ede186
[modules/shaper.git] / src / ModelAPI / ModelAPI_Tools.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        ModelAPI_Tools.h
4 // Created:     06 Aug 2014
5 // Author:      Vitaly Smetannikov
6
7 #ifndef ModelAPI_Tools_HeaderFile
8 #define ModelAPI_Tools_HeaderFile
9
10 #include "ModelAPI.h"
11
12 #include <ModelAPI_CompositeFeature.h>
13 #include <ModelAPI_Document.h>
14 #include <ModelAPI_Feature.h>
15 #include <ModelAPI_Result.h>
16 #include <ModelAPI_ResultParameter.h>
17 #include <ModelAPI_ResultCompSolid.h>
18
19 #include <GeomAPI_Shape.h>
20
21 #include <vector>
22
23 namespace ModelAPI_Tools {
24 /// Returns shape from the given Result object
25 MODELAPI_EXPORT std::shared_ptr<GeomAPI_Shape> shape(const ResultPtr& theResult);
26
27 /*! Returns the feature error generated according to feature error and exec state
28  * \param theFeature a feature
29  * \return error value or empty string
30  */
31 MODELAPI_EXPORT std::string getFeatureError(const FeaturePtr& theFeature);
32
33 /*!
34  * Searches for variable with name \param theName in \param theDocument. 
35  * If found, set it value in the \param outValue and returns true.
36  * theSearcher must be located later in the history than the found variable.
37  */
38 MODELAPI_EXPORT bool findVariable(const DocumentPtr& theDocument, FeaturePtr theSearcher,
39   const std::string& theName, double& outValue, ResultParameterPtr& theParam);
40
41 /*!
42  * Searches for variable with name \param theName in the active document (Part), when
43  * in the root document (PartSet). If found, set it value in the \param outValue
44  * and returns true. If \param theDocument is empty active document is used.
45  * theSearcher must be located later in the history than the found variable.
46  */
47 MODELAPI_EXPORT bool findVariable(FeaturePtr theSearcher, const std::string& theName,
48   double& outValue, ResultParameterPtr& theParam,
49   const DocumentPtr& theDocument = DocumentPtr());
50
51 /*!
52  * Returns the values of the next random color. The values are in range [0, 255]
53  * \param theValues a container of component of RGB value: red, green, blue
54  */
55 MODELAPI_EXPORT void findRandomColor(std::vector<int>& theValues);
56
57 /*!
58  * Searches for Part result that contains the reference to the given document.
59  * The result must be presented in the tree.
60  * \param theMain document that contains the searched feature
61  * \param theSub document that is searched, the resulting feature references to it
62  * \returns null if not found
63  */
64 MODELAPI_EXPORT ResultPtr findPartResult(const DocumentPtr& theMain, const DocumentPtr& theSub);
65
66 /*!
67  * Searches for Part the feature that contains in result the reference to the given document.
68  * The result may be disabled.
69  * \param theMain document that contains the searched feature
70  * \param theSub document that is searched, the resulting feature references to it
71  * \returns null if not found
72  */
73 MODELAPI_EXPORT FeaturePtr findPartFeature(const DocumentPtr& theMain, const DocumentPtr& theSub);
74
75 /*!
76  * Returns the composite feature - parent of this feature.
77  * \param theFeature the sub-element of composite
78  * \returns null if it is not sub-element of composite
79  */
80 MODELAPI_EXPORT CompositeFeaturePtr compositeOwner(const FeaturePtr& theFeature);
81
82 /*!
83  * Returns the compsolid result - parent of this result.
84  * \param theSub the sub-element of comp-solid
85  * \returns null if it is not sub-element of composite
86  */
87 MODELAPI_EXPORT ResultCompSolidPtr compSolidOwner(const ResultPtr& theSub);
88
89 /*!
90 * Returns true if the result contains a not empty list of sub results. It processes result compsolid.
91 * \param theResult a result object
92 * \returns boolean value
93 */
94 MODELAPI_EXPORT bool hasSubResults(const ResultPtr& theResult);
95
96 /*!
97 * Adds the results of the given feature to theResults list: including disabled and sub-results
98 */
99 MODELAPI_EXPORT void allResults(const FeaturePtr& theFeature, std::list<ResultPtr>& theResults);
100
101 }
102
103 #endif