Creating Data Schema for Storage/Retrieval

I have written a simple program to create a PGeom_Line. I am interested in saving this to a file. I have the following code for this ->

--------------------------------------------

void main(int argc, char *argv[]) {

Handle(Geom_Line) aLine;

aLine = new Geom_Line( gp_Pnt(10.0,10.0,10.0),

gp_Dir(0.0,0.0,1.0) );

if ( aLine.IsNull() ) {

cout AddRoot ("Line", aPShape); s -> Write (f,d); if ( d->ErrorStatus() != Storage_VSOk ) {

cout << "storage errror\n";

return; }

f.Close(); }

-------------------------------------------------------------

But this fails with a core dump. There is also a message displayed that says 'ERR_MMAP_FAIL' before I get the core dump.

I have been raking my brains as to where I am wrong. I read in the Foundation Class Data Storage section about save and restore. It mentions you need to create a Data Schema based on Storage Schema. But there's no example on how to create the data schema.

I would appreciate help in creating the data schema. Please feel free to point me to other resources I could read to gain more insight.

Regards Mahesh

M. Gandyra's picture

I wonder if you try to read/save to/from a BRep file or if you really want to use the database storage/retrieval. In case you just want to write a BRep file use the following:

// If you just want to save your line to a BRep file, use topology:

Handle_Geom_Line aLine; // infinite line

aLine = new Geom_Line(gp_Pnt(10,10,10), gp_Dir(0,0,1));

BRepAPI_MakeCurve mkCrv(aLine);

TopoDS_Shape aShape = mkCrv.Shape();

// now save it to a BRep file:

Standard_CString aFileName="/myPath/fname.brep" // put your filename here

Standard_Boolean result = BRepTools::Write(aShape, aFileName);

// check the result (if you want)

If you want to read the file again:

//// ImportBRep ////////////////////////////////////////////////////////////////////////////////

// Read the BRep-file

TopoDS_Shape aShape;

BRep_Builder aBuilder;

Standard_CString aFileName="/myPath/fname.brep"; put you filename here

Standard_Boolean result = BRepTools::Read(aShape, aFileName, aBuilder);

if (!result || aShape.IsNull())

{

cerr {{ "Errors encountered in file: " {{ aFileName {{ " !!!" {{ endl;

return Standard_False;

}

// do something with the shape, i.e. display it:

HandleAIS_InteractiveContext myAISContext; // defined earlier

myAISContext->Display(new AIS_Shape(aShape));

If you want to import/export IGES, STEP, etc. you have to wait for the final release, I guess. - I am not sure about MATRA's planns on the topic of datatransfer. If you want to use storage/retrieval (like in designmanager/Euclid) - its quite much more complicated than that !!

Concerning the documentation: ask MATRA !

with regards M. Gandyra

------------------------------------------------------------------

University of Kaiserslautern, Research Group for Computer Application in Engineering Design

------------------------------------------------------------------

Dipl.-Ing. Michael Gandyra, Erwin-Schroedinger-Str., Postfach 3049, D-67653 Kaiserslautern

------------------------------------------------------------------

Phone: +49 631 205-2312, Fax: +49 631 205-3872, WWW: http://rkk.mv.uni-kl.de/mig, Email: gandyra@mv.uni-kl.de or gandyra@rumms.uni-mannheim.de

------------------------------------------------------------------