#include <GeomAlgoAPI_FaceBuilder.h>
#include <GeomAlgoAPI_CompoundBuilder.h>
#include <GeomAlgoAPI_SketchBuilder.h>
+#include <ModelAPI_ResultConstruction.h>
const int SKETCH_PLANE_COLOR = Colors::COLOR_BROWN; /// the plane edge color
data()->addAttribute(SKETCH_ATTR_FEATURES, ModelAPI_AttributeRefList::type());
}
-void SketchPlugin_Sketch::execute()
+void SketchPlugin_Sketch::execute(boost::shared_ptr<ModelAPI_Result>& theResult)
{
+ if (!isPlaneSet()) {
+ std::list<boost::shared_ptr<GeomAPI_Shape> > aFaces;
+
+ addPlane(1, 0, 0, aFaces); // YZ plane
+ addPlane(0, 1, 0, aFaces); // XZ plane
+ addPlane(0, 0, 1, aFaces); // XY plane
+ boost::shared_ptr<GeomAPI_Shape> aCompound = GeomAlgoAPI_CompoundBuilder::compound(aFaces);
+ boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(theResult)->setShape(aCompound);
+ return;
+ }
if (!data()->isValid())
return ;
boost::shared_ptr<ModelAPI_AttributeRefList> aRefList =
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);
+ boost::shared_ptr<ModelAPI_ResultConstruction> aRes =
+ boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(document()->result(aFeature));
+ if (aRes) {
+ boost::shared_ptr<GeomAPI_Shape> aShape = aRes->shape();
+ if (aShape)
+ aFeaturesPreview.push_back(aShape);
+ }
}
if (aFeaturesPreview.empty())
aLoops.insert(aLoops.end(), aWires.begin(), aWires.end());
boost::shared_ptr<GeomAPI_Shape> aCompound = GeomAlgoAPI_CompoundBuilder::compound(aLoops);
- data()->store(aCompound);
+ boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(theResult)->setShape(aCompound);
}
boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_Sketch::getAISObject(
return anAIS;
}
-const boost::shared_ptr<GeomAPI_Shape>& SketchPlugin_Sketch::preview()
-{
- if (isPlaneSet()) {
- setPreview(boost::shared_ptr<GeomAPI_Shape>());
- }
- else {
- std::list<boost::shared_ptr<GeomAPI_Shape> > aFaces;
-
- addPlane(1, 0, 0, aFaces); // YZ plane
- addPlane(0, 1, 0, aFaces); // XZ plane
- addPlane(0, 0, 1, aFaces); // XY plane
- boost::shared_ptr<GeomAPI_Shape> aCompound = GeomAlgoAPI_CompoundBuilder::compound(aFaces);
- setPreview(aCompound);
- }
- return getPreview();
-}
-
const void SketchPlugin_Sketch::addSub(const FeaturePtr& theFeature)
{
boost::dynamic_pointer_cast<SketchPlugin_Feature>(theFeature)->setSketch(this);