1 // File: Model_ResultBody.cpp
2 // Created: 08 Jul 2014
3 // Author: Mikhail PONIKAROV
5 #include <Model_ResultBody.h>
6 #include <Model_Data.h>
7 #include <TNaming_Builder.hxx>
8 #include <TNaming_NamedShape.hxx>
9 #include <TopoDS_Shape.hxx>
10 #include <GeomAPI_Shape.h>
12 Model_ResultBody::Model_ResultBody(const boost::shared_ptr<ModelAPI_Feature>& theFeature)
17 void Model_ResultBody::store(const boost::shared_ptr<GeomAPI_Shape>& theShape)
19 boost::shared_ptr<Model_Data> aData = boost::dynamic_pointer_cast<Model_Data>(data());
21 TDF_Label& aShapeLab = aData->shapeLab();
22 // TODO: to add the naming mechanism for shape storage in the next iteration
23 TNaming_Builder aBuilder(aShapeLab);
24 if (!theShape) return; // bad shape
25 TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();
26 if (aShape.IsNull()) return; // null shape inside
28 aBuilder.Generated(aShape);
32 boost::shared_ptr<GeomAPI_Shape> Model_ResultBody::shape()
34 boost::shared_ptr<Model_Data> aData = boost::dynamic_pointer_cast<Model_Data>(data());
36 TDF_Label& aShapeLab = aData->shapeLab();
37 Handle(TNaming_NamedShape) aName;
38 if (aShapeLab.FindAttribute(TNaming_NamedShape::GetID(), aName)) {
39 TopoDS_Shape aShape = aName->Get();
40 if (!aShape.IsNull()) {
41 boost::shared_ptr<GeomAPI_Shape> aRes(new GeomAPI_Shape);
42 aRes->setImpl(new TopoDS_Shape(aShape));
47 return boost::shared_ptr<GeomAPI_Shape>();
50 boost::shared_ptr<ModelAPI_Feature> Model_ResultBody::owner()