Fabian Gerold - 2013-09-28

I have a 2d geometry that consists of several LineSeg elements (straight lines as boundary).
During meshing, the length of these segments is computed many times.

But not the very cheap
LineSeg<D> :: Length ()
method is called, but the quite expensive method
SplineSeg<D> :: Length ()

This is because the geometry obect (netgen::SplineGeometry2d) holds pointers to SplineSegExt objects, which work as a wrapper for the LineSeg objects.

LineSeg and SplineSegExt are both derived from SplineSeg.
Meshing algorithms just call the Length() method on SplineSegExt objects, but it is not implemented there. So the Length() method from SplineSeg is called, which is really expensive.

To solve this, there is an easy solution: adding this method
virtual double Length () const { return seg.Length(); }
in the class SplineSegExt calls the right Length() method of the wrapped segment object.