
Some time ago, before I started writing this blog. I implemented a structure/mechanism in FreeREP for dealing with non planar surfaces. In particular there needs to be a way to triangulate such things for display and to define various trimmings on the surfaces. With non planar surfaces, various things we take for granted, just don't make sense. For example, say you want to see if a curve is clockwise/anticlockwise, and this curve lies on the surface of the sphere. There really is no way to define cw/ccw on the surface of a sphere. Supposing you did make some arbitrary definition, calculating which one it is will become abhorrently complex.
To deal with these problems in general, geometry kernel's usually implement parametric surfaces. This is where you use a D dimensional field to do operations on a D dimensional object embedded in a >D dimensional space. The simplest example is actually a planar surface. Calculating, for example, the area of a planar face should be easy. No matter what plane they are on. But calculating the double integral for 3d arcs and lines is not easy. So instead we project the 3d lines and arcs onto a 2d plane. Now we have much easier integrals to deal with. As it turns out we can do something similar with any surface. The key is to find a good mapping. One that makes calculations easy, and most importantly preserves certain geometrical properties. In particular 2 non intersecting curves in D dimensional space. Cannot intersect in parametric space.
With FreeREP, i thought I had the master plan. With spheres and cones, it is possible to limit the maximum surface size to a portion of the sphere or cone. This means representing a whole cone with 4 surfaces, and a whole sphere with 8. Then each of these surfaces defines a plane that has a normal which the average normal over the projected surface. As it happens, the maximum deviation of the real normal to the plane normal is never more than PI/4. Then stuff is really easy. To project a curve onto its surface all we do is set the Z coordinate to 0.
Welcome IGES. I knew it wouldn't last. The above scheme gets really screwy with nurbs. You would have to split the surface along totally random curves that would be both hard to find, and hard to define. But so soon? I never imagined. The trouble came with implementing IGES surfaces of revolution. These are effectively defined in parametric space. A space very unlike FreeREP's. I considered some quick and dirty options for the conversion of spaces, but they all were hacks and wouldn't work for the general case. The only robust solution would be to implement there notion of parametric space, project the curves into it, and use 2d boolean operations to see how there parametric space overlapped the FreeREP faces bounds. But 2d boolean ops are actually very difficult to get working right, and FreeREP doesn't yet have the tools to deal with numerical issues, so that seemed aways off. Instead I decided to implement proper parametric spaces in FreeREP.
The triangulator has undergone major modifications. Nothing serious but things have different names and pass slightly different parameters. So alot of stuff is broken, ie everything. I have succefully created a hemisphere on a single surface in parametric space S(tX).
There are still a couple of bugs, but things should come back together pretty easily now.
