How to print the details of the Topology

Hi Everyone!
How to print the topological data of the model in OCAF. For example
TopoDS_Shape B1 = BRepPrimAPI_MakeBox (200.,150.,100.);
In that how to print the topology of B1, i can visualize B1, but i can't get the details of B1.

please give me detailed explanation

thanks in advance
regards
sas

gerard's picture

Use TopExp_Explorer, you can explore a shape for faces, face for wires, wire for edges and edges for vertices.

You can also use BRepTools_WireExplorer to explore the wire for unique ordered vertices.

Hope this helps

gerard's picture

Or you can use BRepTools::Dump. never tried this one myself

Torsten Sadowski's picture

BRepTools::Dump(shape,cout) is very good for a quick look before deciding what to do next.

sas's picture

Hi Sadowski!
When i use BRepTools::Dump(shape,cout), program executes and just get crashed after showing Shape: abnormal program termination.
How to get ride of this error?
expecting reply

rgs
Sas

Torsten Sadowski's picture

Is shape a TopoDS_Shape and is it valid (not nil?)

Torsten

Sas's picture

Hi Sadowski!
TopoDS_Shape is Valid one. But don't know why the system crash. How to built the OCC library in Debug mode? Do you have any idea on that.

rgds
Sas

Hugues's picture

Hi,

I remember that the OCC library must be built in debug mode to get this function to work. If you try to call BRepTools::Write (shape, astream) it should fail too.

Sas's picture

Hi Hugues!

How to built OCC library in debug mode. You are correct BRepTools::Write(shape,astream) also fails in the current configuration. I am using VC++6.0 in Win XP.
Rgs
Sas

Sas's picture

HI Hugues!

i run the program in debug mode, but i get this and jump into binaries.

Unhandled exception in UUU.exe (Kernel32.dll):
0xE06D7363: Microsoft C++ Exception

help with this

Sas

Hugues's picture

Hi Sas,

To build the whole OpenCascade library in debug mode, you have to compile each project of the VC++ workspaces located in $(OCCDIR)/ros/adm/win32.
Check that the active configuration is "Win32 Debug" (Build->Set active configuration).
First, try to rebuild only TKBrep(the package where the class BRepTools is) in debug mode and link it against your program.
You may also have to put the compiled libraries in $(OCCDIR)/ros/win32/bin & lib, I cannot if it is done automatically.

Hope it can help, another solution is to write your shapes in a file through BRepTools::Write (const TopoDS_Shape& Sh, const Standard_CString File). This routine works in release mode(at least with my PC!).

Sas's picture

HI Hugues!

I can't make that, anyhow u told that i can use BRepTools::Write(const TopoDS_Ssape& sh, const Standard_CString File). Can u explain me how to use this.

Here is my code;

#include "stdafx.h"
#include
#include
int main(int argc, char** argv)
{
printf("Hello World!\n");

// build a simple box
BRepPrimAPI_MakeBox aBox(1,2,5);
aBox.Build();

// dump the topological structure to cout

BRepTools::Dump(aBox.Shape(),std::cout);

return 1;

}

When i run this code system gives, shape and crash.
How can i modify so that i can get the output in File.

pls help

rgs
Sas

Hugues's picture

Hi,

Replace the line :
BRepTools::Dump(aBox.Shape(),std::cout);

by(to output in file output.brep) :
BRepTools::Write(aBox.Shape(), "output.brep");

sas's picture

Hi,

Thanks for ur reply, finally got the output, but what does it represent? Do u have any idea about what the output means? it's from Box(1,2,3):

Locations 0
Curve2ds 24
1 0 0 1 0
1 0 0 1 0
1 3 0 0 -1
1 0 0 0 1
1 0 -2 1 0
1 0 0 1 0
1 0 0 0 -1
1 0 0 0 1
1 0 0 1 0
1 0 1 1 0
1 3 0 0 -1
1 1 0 0 1
1 0 -2 1 0
1 0 1 1 0
1 0 0 0 -1
1 1 0 0 1
1 0 0 0 1
1 0 0 1 0
1 3 0 0 1
1 0 0 1 0
1 0 0 0 1
1 0 2 1 0
1 3 0 0 1
1 0 2 1 0
Curves 12
1 0 0 0 0 0 1
1 0 0 3 0 1 0
1 0 2 0 0 0 1
1 0 0 0 0 1 0
1 1 0 0 0 0 1
1 1 0 3 0 1 0
1 1 2 0 0 0 1
1 1 0 0 0 1 0
1 0 0 0 1 0 0
1 0 0 3 1 0 0
1 0 2 0 1 0 0
1 0 2 3 1 0 0
Polygon3D 0
PolygonOnTriangulations 0
Surfaces 6
1 0 0 0 1 0 0 0 0 1 0 -1 0
1 0 0 0 0 1 0 0 0 1 1 0 0
1 0 0 3 0 0 1 1 0 0 0 1 0
1 0 2 0 0 1 0 0 0 1 1 0 0
1 0 0 0 0 0 1 1 0 0 0 1 0
1 1 0 0 1 0 0 0 0 1 0 -1 0
Triangulations 0

TShapes 34
Ve
1e-007
0 0 3
0 0

0101101
*
Ve
1e-007
0 0 0
0 0

0101101
*
Ed
1e-007 1 1 0
1 1 0 0 3
2 1 1 0 0 3
2 2 2 0 0 3
0

0101000
-34 0 +33 0 *
Ve
1e-007
0 2 3
0 0

0101101
*
Ed
1e-007 1 1 0
1 2 0 0 2
2 3 1 0 0 2
2 4 3 0 0 2
0

0101000
-31 0 +34 0 *
Ve
1e-007
0 2 0
0 0

0101101
*
Ed
1e-007 1 1 0
1 3 0 0 3
2 5 1 0 0 3
2 6 4 0 0 3
0

0101000
-31 0 +29 0 *
Ed
1e-007 1 1 0
1 4 0 0 2
2 7 1 0 0 2
2 8 5 0 0 2
0

0101000
-29 0 +33 0 *
Wi

0101000
-32 0 -30 0 +28 0 +27 0 *
Fa
0 1e-007 1 0

0111000
+26 0 *
Ve
1e-007
1 0 3
0 0

0101101
*
Ve
1e-007
1 0 0
0 0

0101101
*
Ed
1e-007 1 1 0
1 5 0 0 3
2 9 6 0 0 3
2 10 2 0 0 3
0

0101000
-24 0 +23 0 *
Ve
1e-007
1 2 3
0 0

0101101
*
Ed
1e-007 1 1 0
1 6 0 0 2
2 11 6 0 0 2
2 12 3 0 0 2
0

0101000
-21 0 +24 0 *
Ve
1e-007
1 2 0
0 0

0101101
*
Ed
1e-007 1 1 0
1 7 0 0 3
2 13 6 0 0 3
2 14 4 0 0 3
0

0101000
-21 0 +19 0 *
Ed
1e-007 1 1 0
1 8 0 0 2
2 15 6 0 0 2
2 16 5 0 0 2
0

0101000
-19 0 +23 0 *
Wi

0101000
-22 0 -20 0 +18 0 +17 0 *
Fa
0 1e-007 6 0

0111000
+16 0 *
Ed
1e-007 1 1 0
1 9 0 0 1
2 17 2 0 0 1
2 18 5 0 0 1
0

0101000
-23 0 +33 0 *
Ed
1e-007 1 1 0
1 10 0 0 1
2 19 2 0 0 1
2 20 3 0 0 1
0

0101000
-24 0 +34 0 *
Wi

0101000
-14 0 -22 0 +13 0 +32 0 *
Fa
0 1e-007 2 0

0111000
+12 0 *
Ed
1e-007 1 1 0
1 11 0 0 1
2 21 4 0 0 1
2 22 5 0 0 1
0

0101000
-19 0 +29 0 *
Ed
1e-007 1 1 0
1 12 0 0 1
2 23 4 0 0 1
2 24 3 0 0 1
0

0101000
-21 0 +31 0 *
Wi

0101000
-10 0 -18 0 +9 0 +28 0 *
Fa
0 1e-007 4 0

0111000
+8 0 *
Wi

0101000
-27 0 -10 0 +17 0 +14 0 *
Fa
0 1e-007 5 0

0111000
+6 0 *
Wi

0101000
-30 0 -9 0 +20 0 +13 0 *
Fa
0 1e-007 3 0

0111000
+4 0 *
Sh

0101100
-25 0 +15 0 -11 0 +7 0 -5 0 +3 0 *
So

1100000
+2 0 *

+1 0

it's location 0,0,0, and what is curve2ds and curves?
and if possible give small explanation about the output.

thanks
Sas

Rob Bachrach's picture

The file format is pretty complex and, as far as I know, undocumented. You can get details by looking at the source code for a bunch of classes in BRepTools, TopTools, and GeomTools. I'll give a brief introduction:

This file works from the bottom up. The low level details are first, followed by items that reference lower level detailed items.

-Locations would contain any transformation matrices in your shape. This file has none.
- Curve2ds contains 2D curve representations. In your case, these are the edges of your geometry with respect to the faces. There are 24 because the box has 12 edges, each shared by 2 faces. So, each edge appears twice, once for each face. The first number on each line is the curve type (1=line), followed by a 2D point and a 2D direction to define the line.
- Curves contains 3D curve representations. These are the curves making your 12 edges in 3D space. This is a similar format to the 2D curves, but with 3D points and vectors.
- Polygon3D, PolygonOnTriangulation, and Triangulations all refer to any mesh that may be on your part. These are not always written and may not always exist.
- Surfaces refers to the 3D surfaces of the faces of your part. As with curves, the first number on the line is the type. Since all of your faces are planar, the type is 1. This is followed by a point on the plane and the normal direction.
- The TShapes section lists all the TopoDS_Shapes. It starts with vertices, then edges, wires, faces, shells, solids, etc... Each shape begins with the type (Ve=Vertex, Ed=Edge, etc.). It is then followed by a definition based on the geometry type (see BRepTools_ShapeSet::WriteGeometry(const TopoDS_Shape& S, Standard_OStream& OS) in BRepTools_ShapeSet.cxx for more details. In the case of an edge, this includes the curve index and parameters. In the case of a face, it includes the surface index and parameters. Finally, the shape is followed by indexes to its subshapes (vertexes for edges, edges for wires, wires for faces, etc.).

Good luck. If you really want to understand the format, you have to look at the OCC source. I hope this helps.