Salome HOME
Merge branch 'master' of newgeom:newgeom.git into BR_PYTHON_PLUGIN
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_Feature.cpp
1 #include "SketchPlugin_Feature.h"
2 #include "SketchPlugin_Sketch.h"
3 #include <ModelAPI_Document.h>
4 #include <ModelAPI_Data.h>
5 #include <ModelAPI_Object.h>
6 #include <ModelAPI_AttributeRefList.h>
7 #include <ModelAPI_ResultConstruction.h>
8
9 SketchPlugin_Feature::SketchPlugin_Feature()
10 {
11   mySketch = 0;
12 }
13
14 /*
15 SketchPlugin_Sketch* SketchPlugin_Feature::sketch()
16 {
17   if (!mySketch) {
18     // find sketch that references to this feature
19     int aSketches = document()->size(ModelAPI_Feature::group());
20     for (int a = 0; a < aSketches && !mySketch; a++) {
21       ObjectPtr anObj = document()->object(ModelAPI_Feature::group(), a);
22       boost::shared_ptr<SketchPlugin_Sketch> aSketch = 
23         boost::dynamic_pointer_cast<SketchPlugin_Sketch>(anObj);
24       if (aSketch) {
25         std::list<ObjectPtr> aList = aSketch->data()->reflist(SketchPlugin_Sketch::FEATURES_ID())
26             ->list();
27         std::list<ObjectPtr>::iterator aSub = aList.begin();
28         for (; aSub != aList.end(); aSub++) {
29           if ((*aSub)->data()->isEqual(data())) {
30             mySketch = aSketch.get();
31             break;
32           }
33         }
34       }
35     }
36   }
37   return mySketch;
38 }*/
39
40 AISObjectPtr SketchPlugin_Feature::simpleAISObject(boost::shared_ptr<ModelAPI_Result> theRes,
41                                                    AISObjectPtr thePrevious)
42 {
43   boost::shared_ptr<ModelAPI_ResultConstruction> aConstr = boost::dynamic_pointer_cast<
44       ModelAPI_ResultConstruction>(theRes);
45
46   boost::shared_ptr<GeomAPI_Shape> aPreview;
47   if (aConstr)
48     aPreview = aConstr->shape();
49
50   AISObjectPtr aResult = thePrevious;
51   if (!aResult)
52     aResult = AISObjectPtr(new GeomAPI_AISObject());
53   aResult->createShape(aPreview);
54   return aResult;
55 }