How to use the TopTools::Dump(const TopoDS_Shape& Sh, Standard_OStream& S) function

This function is used to dumps the topological structure of on the stream .

Now,for example:I have a solid box.I want to output the box's topological structure and watch the topological structure.How can I use this function?
I use VC++6.0 tool.

Patrik Mueller's picture

Hi,

try this:

BRepTools::Write(mybox, theFilename);

Greets,

Patrik

xgybaby's picture

I establish a file object like this:ofstream myFile("test.txt"),but it is fail when I use the function BRepTools::Write(mybox, myFile).Is it a problem of parameter of the "myFile"?

Patrik Mueller's picture

If you use BRepTools you don't need a stream object - just your shape and the name of the output file ("test.txt")...

xgybaby's picture

I use BRepTools_ShapeSet::Write (const TopoDS_Shape &S, Standard_OStream &OS) function.The parameter is a ostream object,but the file name("test.txt") is not a this object.So I am still puzzled.

Patrik Mueller's picture

Hi,

here is some source from BRepTools::Write. You can see how to work with ostream:

Standard_Boolean BRepTools::Write(const TopoDS_Shape& Sh,
const Standard_CString File)
{

ofstream os;
// if (!fic.open(File,output)) return Standard_False;
os.open(File, ios::out);
if (!os.rdbuf()->is_open()) return Standard_False;

Standard_Boolean isGood = (os.good() && !os.eof());
if(!isGood)
return isGood;

BRepTools_ShapeSet SS;
SS.Add(Sh);

os << "DBRep_DrawableShape\n"; // for easy Draw read
SS.Write(os);
isGood = os.good();
if(isGood )
SS.Write(Sh,os);
os.flush();
isGood = os.good();
os.close();
isGood = os.good() && isGood;

return isGood;
}

Greets,

Patrik