1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: ModelAPI_Tools.h
4 // Created: 06 Aug 2014
5 // Author: Vitaly Smetannikov
7 #ifndef ModelAPI_Tools_HeaderFile
8 #define ModelAPI_Tools_HeaderFile
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>
19 #include <GeomAPI_Shape.h>
23 namespace ModelAPI_Tools {
24 /// Returns shape from the given Result object
25 MODELAPI_EXPORT std::shared_ptr<GeomAPI_Shape> shape(const ResultPtr& theResult);
28 * Searches for variable with name \param theName in \param theDocument.
29 * If found, set it value in the \param outValue and returns true.
31 MODELAPI_EXPORT bool findVariable(const DocumentPtr& theDocument,
32 const std::string& theName, double& outValue, ResultParameterPtr& theParam);
35 * Searches for variable with name \param theName in the active document (Part), when
36 * in the root document (PartSet). If found, set it value in the \param outValue
37 * and returns true. If \param theDocument is empty active document is used.
39 MODELAPI_EXPORT bool findVariable(const std::string& theName, double& outValue, ResultParameterPtr& theParam,
40 const DocumentPtr& theDocument = DocumentPtr());
43 * Returns the values of the next random color. The values are in range [0, 255]
44 * \param theValues a container of component of RGB value: red, green, blue
46 MODELAPI_EXPORT void findRandomColor(std::vector<int>& theValues);
49 * Searches for Part result that contains the reference to the given document.
50 * \param theMain document that contains the searched feature
51 * \param theSub document that is searched, the resulting feature references to it
52 * \returns null if not found
54 MODELAPI_EXPORT ResultPtr findPartResult(const DocumentPtr& theMain, const DocumentPtr& theSub);
57 * Returns the composite feature - parent of this feature.
58 * \param theFeature the sub-element of composite
59 * \returns null if it is not sub-element of composite
61 MODELAPI_EXPORT CompositeFeaturePtr compositeOwner(const FeaturePtr& theFeature);
64 * Returns the compsolid result - parent of this result.
65 * \param theSub the sub-element of comp-solid
66 * \returns null if it is not sub-element of composite
68 MODELAPI_EXPORT ResultCompSolidPtr compSolidOwner(const ResultPtr& theSub);
71 * Returns true if the result contains a not empty list of sub results. It processes result compsolid.
72 * \param theResult a result object
73 * \returns boolean value
75 MODELAPI_EXPORT bool hasSubResults(const ResultPtr& theResult);