# High level understanding of OpenCascade Boundary Representation

Hi everyone,

As I may have mentioned before, I am working on implementing a meshing algorithm using the OpenCascade framework. Recently I've run into trouble as a result of not understanding some of the finer points of how OCC represents topology and geometry. Although I've looked through the code to help figure it out, a lot of the knowledge I'm missing is conceptual, and is hard to get from the source code.

Basically, the algorithm (which I am taking largely from a book on the finite element method) works like this: for each face, you map its boundary curve in space into the parameter plane of the corresponding surface. Then you mesh the parameter plane, thereby meshing the surface. It's more complicated than that (i.e., methods to remove the distortion due to curved geometry) but that's the basic idea.

There is one serious problem with this approach, namely that this: "...you map its boundary curve into the parameter plane of the corresponding surface. Then you mesh the parameter plane..." assumes that you can _find_ a bounded subspace in the parameter plane to mesh. If you are working with any kind of distorted planar surface, you know it exists. The closed boundary curve in space maps to a closed curve in the surface parameter space. I don't know how to find that curve, but I assume there is some way to do it in OpenCascade (it does everything!).

Suppose instead that you make a sphere. I had always assumed it would subdivide the sphere into as many surfaces as necessary to maintain the above properties. I was really surprised by what the topology explorer found:

1.) Only one face
2.) Only one wire, with parameter domain [0, 2]. Getting the BRepAdaptor_CompCurve for this wire, and placing 10 equally spaced points along the curve (with GCPnt_UniformAbsicca) gives only 5 unique points which repeat once in a "A, ..., B, B, ..., A" pattern, down one side of the sphere but for some omiting the second pole.
3.) Using BRepTools_WireExplorer on that wire, produces 4 different edges. In my experience up to this point with OpenCascade, wires curves with domain [0, N] have usually meant there were N edges. Obtaining a BRepAdaptor_Curve for each edge, I find that two are 3d curves, the other two are curves on the surface. The orientations for the curves on surfaces are REVERSED and FORWARD. For the 3d curves, FORWARD and EXTERNAL.

Honestly, I am not sure what to make of this. I do not even know what INTERNAL and EXTERNAL oriented edges are. I understand the example of basically planar, well behaved faces with holes in them. The boundary curve is REVERSED, the holes are FORWARD. They both serve to "trim" the surface in an easy to understand way. Closed boundary curves in space correspond to closed boundary curves in the parameter plane of the surface. But what is going on with the sphere? I am not sure where to look to find out why the topology is laid out where it is, and therehow how I will obtain my bounded parameter plane to mesh.