+ if (!data()->isValid())
+ return ;
+ boost::shared_ptr<ModelAPI_AttributeRefList> aRefList =
+ boost::dynamic_pointer_cast<ModelAPI_AttributeRefList>(data()->attribute(SKETCH_ATTR_FEATURES));
+
+ boost::shared_ptr<GeomDataAPI_Point> anOrigin =
+ boost::dynamic_pointer_cast<GeomDataAPI_Point>(data()->attribute(SKETCH_ATTR_ORIGIN));
+ boost::shared_ptr<GeomDataAPI_Dir> aDirX =
+ boost::dynamic_pointer_cast<GeomDataAPI_Dir>(data()->attribute(SKETCH_ATTR_DIRX));
+ boost::shared_ptr<GeomDataAPI_Dir> aDirY =
+ boost::dynamic_pointer_cast<GeomDataAPI_Dir>(data()->attribute(SKETCH_ATTR_DIRY));
+ boost::shared_ptr<GeomDataAPI_Dir> aNorm =
+ boost::dynamic_pointer_cast<GeomDataAPI_Dir>(data()->attribute(SKETCH_ATTR_NORM));
+
+ std::list<boost::shared_ptr<ModelAPI_Feature> > aFeatures = aRefList->list();
+ if (aFeatures.empty())
+ return ;
+
+ std::list<boost::shared_ptr<ModelAPI_Feature> >::const_iterator anIt = aFeatures.begin(),
+ aLast = aFeatures.end();
+
+ boost::shared_ptr<SketchPlugin_Feature> aFeature;
+ std::list< boost::shared_ptr<GeomAPI_Shape> > aFeaturesPreview;
+ for (; anIt != aLast; anIt++) {
+ aFeature = boost::dynamic_pointer_cast<SketchPlugin_Feature>(*anIt);
+ boost::shared_ptr<GeomAPI_Shape> aPreview = aFeature->preview();
+ if (aPreview)
+ aFeaturesPreview.push_back(aPreview);
+ }
+
+ if (aFeaturesPreview.empty())
+ return ;
+ std::list< boost::shared_ptr<GeomAPI_Shape> > aLoops;
+ std::list< boost::shared_ptr<GeomAPI_Shape> > aWires;
+ GeomAlgoAPI_SketchBuilder::createFaces(anOrigin->pnt(), aDirX->dir(), aDirY->dir(), aNorm->dir(),
+ aFeaturesPreview, aLoops, aWires);
+
+ aLoops.insert(aLoops.end(), aWires.begin(), aWires.end());
+ boost::shared_ptr<GeomAPI_Shape> aCompound = GeomAlgoAPI_CompoundBuilder::compound(aLoops);
+ data()->store(aCompound);