+ if (!data()->isValid())
+ return ;
+ boost::shared_ptr<ModelAPI_AttributeRefList> aRefList =
+ boost::dynamic_pointer_cast<ModelAPI_AttributeRefList>(
+ data()->attribute(SketchPlugin_Sketch::FEATURES_ID()));
+
+ boost::shared_ptr<GeomDataAPI_Point> anOrigin =
+ boost::dynamic_pointer_cast<GeomDataAPI_Point>(data()->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
+ boost::shared_ptr<GeomDataAPI_Dir> aDirX =
+ boost::dynamic_pointer_cast<GeomDataAPI_Dir>(data()->attribute(SketchPlugin_Sketch::DIRX_ID()));
+ boost::shared_ptr<GeomDataAPI_Dir> aDirY =
+ boost::dynamic_pointer_cast<GeomDataAPI_Dir>(data()->attribute(SketchPlugin_Sketch::DIRY_ID()));
+ boost::shared_ptr<GeomDataAPI_Dir> aNorm =
+ boost::dynamic_pointer_cast<GeomDataAPI_Dir>(data()->attribute(SketchPlugin_Sketch::NORM_ID()));
+
+ std::list<ObjectPtr> aFeatures = aRefList->list();
+ if (aFeatures.empty())
+ return ;
+
+ std::list<ObjectPtr>::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);
+ if (aFeature) {
+
+ const std::list<boost::shared_ptr<ModelAPI_Result> >& aRes = aFeature->results();
+ std::list<boost::shared_ptr<ModelAPI_Result> >::const_iterator aResIter = aRes.cbegin();
+ for(; aResIter != aRes.cend(); aResIter++) {
+ boost::shared_ptr<ModelAPI_ResultConstruction> aConstr =
+ boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(*aResIter);
+ if (aConstr) {
+ boost::shared_ptr<GeomAPI_Shape> aShape = aConstr->shape();
+ if (aShape)
+ aFeaturesPreview.push_back(aShape);
+ }
+ }
+ }
+ }
+
+ 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);
+ boost::shared_ptr<ModelAPI_ResultConstruction> aConstr = document()->createConstruction(data());
+ aConstr->setShape(aCompound);
+ setResult(aConstr);