Monday, December 10, 2007

The OCAF attribute TDataStd_Geometry

It seems that the TDataStd_Geometry attribute cannot be used consistently with the TDataStd_Real. If for the later to create/retrieve a child label with an attribute it is possible to say:

TDataStd_Real::Set(L.FindChild(1), x);

for TDataStd_Geometry such a method is not implemented. Creating an TDataStd_Geometry is made like this:

- setting a point on a label:
TDF_Label childLabel = L.FindChild(1);
TNaming_Builder B(childLabel);
B.Generated(BRepBuilderAPI_MakeVertex(xCoord));
Handle_TDataStd_Geometry geometry = TDataStd_Geometry::Set(childLabel);
geometry->SetType(TDataStd_POINT);

- retrieving the point:
Handle(TDataStd_Geometry) firstPointGeometry;
gp_Pnt firstPoint;
if (!Label().FindChild(1).FindAttribute(TDataStd_Geometry::GetID(), firstPointGeometry)) return 1;
firstPointGeometry->Point(Label().FindChild(1), firstPoint);

No comments: