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