]> SALOME platform Git repositories - modules/shaper.git/blob - src/ModuleBase/ModuleBase_Tools.cpp
Salome HOME
8c0471d9503f8b3f5cfee81a9c47754f2f151740
[modules/shaper.git] / src / ModuleBase / ModuleBase_Tools.cpp
1 // File:        ModuleBase_Tools.cpp
2 // Created:     11 July 2014
3 // Author:      Vitaly Smetannikov
4
5 #include "ModuleBase_Tools.h"
6 #include <ModelAPI_ResultBody.h>
7 #include <ModelAPI_ResultConstruction.h>
8 #include <ModelAPI_Document.h>
9
10 namespace ModuleBase_Tools
11 {
12
13 //******************************************************************
14 boost::shared_ptr<GeomAPI_Shape> shape(ResultPtr theResult)
15 {
16   ResultBodyPtr aBody = boost::dynamic_pointer_cast<ModelAPI_ResultBody>(theResult);
17   if (aBody)
18     return aBody->shape();
19
20   ResultConstructionPtr aConstruct = boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(theResult);
21   if (aConstruct)
22     return aConstruct->shape();
23
24   return boost::shared_ptr<GeomAPI_Shape>();
25 }
26
27 //******************************************************************
28 FeaturePtr feature(ObjectPtr theObject)
29 {
30   FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(theObject);
31   if (!aFeature) {
32     ResultPtr aResult = boost::dynamic_pointer_cast<ModelAPI_Result>(theObject);
33     if (aResult) {
34       PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
35       DocumentPtr aDoc = aMgr->rootDocument();
36       return aDoc->feature(aResult);
37     }
38   }
39   return aFeature;
40 }
41
42 }