In order to control the element size gradation, an octree is built around the surface (or domain) to be discretized. The size of individual octants corresponds approximately to the required element spacing specified by the user (for example by discrete values and global weighting functions) while the nodes of the octants are storing the required spacing exactly. To ensure the gradual variation of element size the maximum one octree level difference of octants sharing an edge is enforced. This will obviously cause the mesh to be more dense in some regions in comparison to the required element size but simultaneously it will guarantee creation of well shaped triangles. During the actual mesh generation the required element size is extracted from the octree for a given location using the interpolation of octree nodal values of size.