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>
9 SketchPlugin_Feature::SketchPlugin_Feature()
14 SketchPlugin_Sketch* SketchPlugin_Feature::sketch()
17 // find sketch that references to this feature
18 int aSketches = document()->size("Construction");
19 for(int a = 0; a < aSketches && !mySketch; a++) {
20 boost::shared_ptr<SketchPlugin_Sketch> aSketch = boost::
21 dynamic_pointer_cast<SketchPlugin_Sketch>(document()->object("Construction", a));
23 std::list<ObjectPtr> aList =
24 aSketch->data()->reflist(SketchPlugin_Sketch::FEATURES_ID())->list();
25 std::list<ObjectPtr>::iterator aSub = aList.begin();
26 for(; aSub != aList.end(); aSub++) {
27 if ((*aSub)->data()->isEqual(data())) {
28 mySketch = aSketch.get();
38 boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_Feature::simpleAISObject(
39 boost::shared_ptr<ModelAPI_Result> theRes, boost::shared_ptr<GeomAPI_AISObject> thePrevious)
41 boost::shared_ptr<ModelAPI_ResultConstruction> aConstr =
42 boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(theRes);
44 boost::shared_ptr<GeomAPI_Shape> aPreview;
45 if (aConstr) aPreview = aConstr->shape();
47 boost::shared_ptr<GeomAPI_AISObject> aResult = thePrevious;
49 aResult = boost::shared_ptr<GeomAPI_AISObject>(new GeomAPI_AISObject());
50 aResult->createShape(aPreview);