I've been trying to solve a problem for almost 2 months now and figured it was worth posting here to see if anyone could help.
I'm trying to write an IGES reader for a mesher. All I need to do is write functions to read the file, list all the surfaces and curves, do some parametric conversions, and then relate the curves to the surfaces.
To debug my code I've made a cube in solid works and saved it as an IGES file.
It's easiest to explain my problems with my code so here it goes...
//This class contains functions to communicate between //OCCT and FLITE
TopTools_IndexedMapOfShape edgemap, facemap;
void OCCT_LoadGeom(Standard_CString filename)
//This function reads the geometry file and translates to //OCCT
IFSelect_ReturnStatus stat = reader.ReadFile(filename);
//Store these in a single compound shape
shape = reader.OneShape();
//Split into two indexed maps, edgemap and facemap
//edgemap(i) gives the ith edge
The above function reads the file, then I have two functions (below) to report number of surfaces and curves...
Problem 1: When I read in the cube file I get 6 surfaces (correct) but 24 edges. Really I only want the 12 edges defining the cube, I thought this may have been because each edge was being counted twice (two different orientations), but I don't think this should happen using IndexedMapOfShape?
In the meshing code we need to know which curves are part of given surface. I wrote this function to do this...
Problem 2: Whatever value I give surfNum in the above function I always get 4 edges, and the indices returned are always 1,2,3,4
I have a feeling my problem is something to do with topology vs geometry, but I'm struggling to find documentation or examples to help me. If anyone could help I would really appricate it. I hope I've included enough information. I've attached my C++ source file to the post.
You have to be logged in to download the attached file
Just noticed I've posted this in the installation forum, I meant to post it in usage issues, could a mod move it?
I read those, and most of his blog, before I started - which is why I'm confused my stuff isn't working. I'm re-reading all the documentation now to see if I missed something!
Your #1 is most likely due to the fact that all your faces are topologically disconnected. So instead of 12 unique edges with 2 instances per each you really have 24 unique edges. This most likely comes from upstream - from your IGES file, where all faces are likely written as Type 144 Trimmed Surfaces. To address that you can:
- instruct your sending system (Solidworks) to use IGES version 5.1 and MSBO (Manifold-Solid-BRep-Objects) in order to store connectivity
- use STEP
- apply sewing in Open CASCADE.
The latter is time consuming and is sensitive to input geometry.
#2 is because you explore a wrong map. You should be exploring the local map and search for indices in the global.
As for "irritating" index numbering an easy work-around is to offset your pointer first:
for (int count =1; count <= numCurves; count++)
//Get the edge
const TopoDS_Edge& anEdge = TopoDS::Edge(localmap(count));