]> SALOME platform Git repositories - modules/shaper.git/blob - src/SketchPlugin/SketchPlugin_Feature.cpp
Salome HOME
Initial version of redesign of working with results
[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
8 SketchPlugin_Feature::SketchPlugin_Feature()
9 {
10   mySketch = 0;
11 }
12
13 SketchPlugin_Sketch* SketchPlugin_Feature::sketch()
14 {
15   if (!mySketch) {
16     // find sketch that references to this feature
17     int aSketches = document()->size("Construction");
18     for(int a = 0; a < aSketches && !mySketch; a++) {
19       boost::shared_ptr<SketchPlugin_Sketch> aSketch = boost::
20         dynamic_pointer_cast<SketchPlugin_Sketch>(document()->object("Construction", a));
21       if (aSketch) {
22         std::list<FeaturePtr > aList = 
23           aSketch->data()->reflist(SKETCH_ATTR_FEATURES)->list();
24         std::list<FeaturePtr >::iterator aSub = aList.begin();
25         for(; aSub != aList.end(); aSub++) {
26           if ((*aSub)->data()->isEqual(data())) {
27             mySketch = aSketch.get();
28             break;
29           }
30         }
31       }
32     }
33   }
34   return mySketch;
35 }
36
37 boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_Feature::prepareAISShape(
38                         boost::shared_ptr<GeomAPI_AISObject> thePrevious)
39 {
40   document()->result();
41   boost::shared_ptr<GeomAPI_Shape> aPreview = preview();
42   boost::shared_ptr<GeomAPI_AISObject> aResult = thePrevious;
43   if (!aResult)
44     aResult = boost::shared_ptr<GeomAPI_AISObject>(new GeomAPI_AISObject());
45   aResult->createShape(aPreview);
46   return aResult;
47 }