Salome HOME
Spell-checking
[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
18 #include <GeomAPI_Shape.h>
19
20 #include <vector>
21
22 namespace ModelAPI_Tools {
23 /// Returns shape from the given Result object
24 MODELAPI_EXPORT std::shared_ptr<GeomAPI_Shape> shape(const ResultPtr& theResult);
25
26 /*!
27  * Searches for variable with name \param theName in the active document (Part), when
28  * in the root document (PartSet). If found, set it value in the \param outValue
29  * and returns true.
30  */
31 MODELAPI_EXPORT bool findVariable(const std::string& theName, double& outValue, 
32   ResultParameterPtr& theParam);
33
34 /*!
35  * Searches for variable with name \param theName in the document. 
36  * If found, set it value in the \param outValue and returns true.
37  */
38 MODELAPI_EXPORT bool findVariable(const DocumentPtr& theDocument, const std::string& theName, 
39                                   double& outValue, ResultParameterPtr& theParam);
40
41 /*!
42  * Returns the values of the next random color. The values are in range [0, 255]
43  * \param theValues a container of component of RGB value: red, green, blue
44  */
45 MODELAPI_EXPORT void findRandomColor(std::vector<int>& theValues);
46
47 /*!
48  * Searches for Part result that contains the reference to the given document.
49  * \param theMain document that contains the searched feature
50  * \param theSub document that is searched, the resulting feature references to it
51  * \returns null if not found
52  */
53 MODELAPI_EXPORT ResultPtr findPartResult(const DocumentPtr& theMain, const DocumentPtr& theSub);
54
55 /*!
56  * Returns the composite feature - parent of this feature.
57  * \param theFeature the sub-element of composite
58  * \returns null if it is not sub-element of composite
59  */
60 MODELAPI_EXPORT CompositeFeaturePtr compositeOwner(const FeaturePtr& theFeature);
61
62 }
63
64 #endif