How to convert shape to polygons/faces?

Hello,

I'm new to OpenCascade and would like to convert a loaded shape (TopoDS_Shape, AIS_Shape,) to a polygon representation that I can inspect / export?

I've been able to project a shape onto a plane (using Prs3d_Projector, HLRBRep_HLRToShape), but I'd like to also get it's polygonal representation.

Thanks,
Ben

Shing Liu's picture

Hi Ben,

Do you mean the mesh for the TopoDS_Shape?

Best Regards,
Shing Liu

Ben Cain's picture

Shing Liu,

I think that describes what I'm trying to do.

I'm trying to get a wireframe (or polygonal) representation of the imported CAD file.

The application I'm writing doesn't support CAD files directly (STEP, IGES), so I'm trying to get them into a representation that I can handle such as vertices and polygons/faces/mesh.

All I currently need from the CAD file is the outline in X/Y plane. I've been able to project an imported IGES disc object onto the X/Y plane. See the attached image of the disc before and after projected onto the X/Y plane. I need the outline vertices (for the red projected disc).

Any help is greatly appreciated. I'm very new to OpenCascade.

Thanks,
Ben

Attachments: 
Ben Cain's picture

I'm noticing some example source that will likely help:
occ-install-dir/samples/mfc/occtdemo/Tesselate

These examples didn't get built by default using custom.bat/msvc.bat, so I didn't initially notice it.

Shing Liu's picture

Hi Ben,

If you just want to display the outline of a shape, I think you can explorer the Edges of the shape, and get the representation data from an Edge by:

Handle_Poly_Polygon3D aPolygon = BRep_Tool::Polygon3D(const TopoDS_Edge &E, TopLoc_Location &L);

then project the aPolygon points into XOY plane.

Best Regards,
Shing