A NURBS-Based Triangulation Method for 3D Ship Hull Simulation

—To design and implement a system of simulating the process of charging and discharging awkward length cargo with computer, key task is to construct high precision three-dimensional model of the hull. In view of problems exiting in distance subdivision method, we proposed one adaptive subdivision method for NURBS (Non-Uniform Rational B-Splines) curve based on energy function. In view of problems from repeated storage of coordinate points and non-linear search of adjacent field in tree structure, namely, when applying binary-tree and quad-tree to recursively divide surface, the intermediate result from each division needs to be saved, each vertex coordinate is repeatedly saved 3 to 4 times, we proposed quadrangle coding method produced automatically by triangle grid of ship hull based on NURBS. Simulation results show that this algorithm has obviously saved time and space, improved the algorithm efficiency, avoided crack between the grids and proved good application in shipping industries.


INTRODUCTION
Development of NURBS began in the 1950s by engineers who were in need of a mathematically precise representation of freeform surfaces like those used for ship hulls, aerospace exterior surfaces, and car bodies, which could be exactly reproduced whenever technically needed. Along with the development of CAD technology and modeling technology of curve and surface, NURBS has become main mathematical tool for ship hull representation and performance computation. Traditional methods for computation of ship hull statics performance adopted Simpson Rule based on a series of limited longitudinal sections or transverse sections and water planes to complete computing approximately. Compared to intelligent and automatic development trend of modern ship hull performance analysis, these methods are not suitable now. In theory, ship hull representation with NURBS can complete performance computation precisely, but the analytical method with surface integrals can't be applied directly into computation of ship hull geometric properties. To compute geometric properties such as volume or centroid of convex or concave polyhedrons, numerical methods should be adopted, that is, to approximate ship hull surface with triangular pieces and then to from enclosed polyhedron with these triangular pieces.
Key issue on surface-oriented 3D ship hull simulation is triangulation of the ship hull surface. This is called surface subdivision. To subdivide surface, some triangular pieces can be used to approximate the surface within given tolerance on each surface point. Generation algorithms for surface triangular meshes can be categorized into two kinds, reflection method and automatic mesh generation method. Reflection method is to adopt planar mesh generation method in parameter field to complete subdivision, and then reflect mesh nodes in parameter field to real space maintaining connection relationships of mesh nodes to obtain triangulation of the surface. But this method is a little aside from the approaching precision with the original surface, which cannot guarantee space form of the generated meshes. In general, automatic mesh generation methods are based on subdivision method [1] used with quadrilateral. The original surface is divided into small surface recursively based on surface curvature until precision requirements of surface pieces are satisfied. Then these quadrilateral meshes are transformed into triangular meshes directly. This method can control mesh density and have good space form. But if there is big size difference between adjacent meshes, crack will appear between surface meshes. Some researchers converted Bezier surface pieces in rectangular area to Bezier surface pieces in triangular area first, and subdivided the surface with Bezier [2]. Converting NURBS surface to rational Bezier surface and subdividing, but efficiency is unsatisfiable.
To subdivide surface, some triangular pieces can be used to approximate the surface within given tolerance on each surface point. Surface approximation error estimation [3][4][5] is crucial to surface subdivision. This paper adopted improved surface evenness checking method and quadrangle coding method to obtain discrete NURBS surface of ship hull. Based on this, cut corner arithmetic is applied to create crack prevention triangle grids.

A. Definition of NURBS Curve and Surface
Mathematical definition of the NURBS curve, NURBS surface is relatively simple [6][7][8]. The B-spline basis functions used in the construction of NURBS curves are usually denoted as , ( ) General form of a NURBS curve ( ) C u , which is a vector-valued piecewise rational polynomial function, is defined as: where i w are the corresponding weights, i d are control points, , ( ) i p N u are normalized B-spline basis functions of degree p. For NURBS, the relative parametric intervals (knot spans) need not be the same for all shape segments, i.e. the knot spacing is non-uniform, leading to a nonperiodic knot vector of the form: where a and b are repeated with multiplicity of p+1.
A NURBS-surface can be defined in a similar way. A NURBS surface is obtained as the tensor product of two NURBS curves, thus using two independent parameters u and v (with indices i and j respectively): where u and v are the parameters in each direction, p is the degree in the u-direction, q is the degree in the vdirection, NURBS can be evaluated effectively by using homogeneous coordinates. The following steps perform the evaluation: (1) add one dimension to the control points and multiply them by their corresponding weights; (2) calculate NURBS in homogeneous coordinates; (3) map "homogeneous" NURBS back to original coordinate system with: For u in [ i u , 1 i u + ), the only existing blending functions to consider in evaluation of the curve at u are

B. Generation of Ship Hull NURBS Surface
Ship hull surface is very complicated. There are many methods to generate ship hull surface, including early cubic splines with disadvantages of poor global control capability. Now B-spline has been widely applied in ship hull surface representation. One typical case of ship hull surface representation is automatic generation of smooth ship hull surface based on ship offset table. Here, we adopted deformed bow and stern transection curves method to generate single ship hull NURBS surface.
Deformed diagram is shown in Fig.1. In Fig.1, the first number of number pair is ordinal of transection curves and the second number is node ordinal of the transection curve.   If ship bow and stern have no intersections with bottom flat line, we adopted coding method shown in Fig.  1 to ensure relatively uniform distribution in transection curve.
By interpolation in ascending order to unify udirection curves with times, number of control points and nodes vectors, here, we suppose number of control points for n u-direction curves is m.
Apply inverse computation of NURBS curve to get control points Compute NURBS basis function based on original nodes vector in v-oriented. Set i-th control vertex as data points in i-direction curve. Inverse computation to get a series of control points in v-direction curve as control points of ship hull NURBS.

III. SHIP HULL NURBS SURFACE SUBDIVISION
For given ship hull NURBS surface, it is required to estimate the max distance between planar triangular pieces with interpolation surface if a group of planar triangular pieces to substitute ship hull NERBS surface. If the max distance is less than specified tolerance, this kind of approximation is allowed. Filip gave a good estimation method for to approximate parametric surface with right triangular pieces, but it is only suitable for 2 C curves and surfaces [3]. Sheng [9] presented estimation method to approximate surface piece with arbitrary triangles, and Vigo [10] improved his method with complicated form, it is hard to apply in practical application. Reference [4] proposed a more comparable accurate estimation method based on convex hull property of NURBS curve and surface. But error is large if curve or surface with big bending for this method without concerning of discrete accuracy for surface boundary. We improved these methods and given detailed algorithm.
Suppose control points for given NURBS surface Maximize distance between control points except quadrangle control points and approximate plane is CD or EF. If CD and EF is smaller than given discrete tolerance, there will be large error to substitute surface piece in Fig.  2 with approximate planes according to reference [4]. Improved algorithm is as follows.
(1) Determine normal vector N for approximate plane of quadrangle points.  (2) Determine equation coefficients of the approximate plane for quadrangle points.
Consider the average P of quadrangle vectors as one point on the approximate plane, then the approximate plane equation can be expressed as follows: P P P P (9) (3) Compute maximize distance p d from control points to the approximate plane.
For given ship hull NURBS surface, the above method is applied to determine whether the surface piece is PAPER A NURBS-BASED TRIANGULATION METHOD FOR 3D SHIP HULL SIMULATION smooth. If it is not smooth, Oslo algorithm is adopted to insert points to divide one NURBS surface piece to two NURBS pieces along the biggest bending direction until each NURBS surface is smooth by iterative subdivision.

IV. TRIANGULATION FOR SHIP HULL NURBS SURFACE
AND SIMULATION RESULTS Ship hull NURBS surface can be triangulated on the premise of surface subdivision. There are many kinds of triangulation such as [4] [12][13][14][15][16]. Nakajima [15] adopted quadtree to process finite mesh grids and Synder [16] applied quadtree to represent hierarchy structure of surface iterative subdivision to avoid crack on the surface. Paper [4] used binary tree to divide one surface piece into two pieces. Although binary tree or quadtree has clear geometric level property, it is lack of efficiency in running time and saving space. The reason is that each leaf node query needs to save every subdivided surface piece. The same vertex needs to be saved at least three times except boundary vertex, which results in more running time with a waste of saving space To solve the problems mentioned above, uniform segmentation is applied in u-direction and v-direction of matrix parameter domain at first in our method. The maximize numbers M, N for segmentation nodes are powers of 2 (for example, 1024), we can get rectangular grids in parameter domain. Minimize edge length of the grid is 1 and grid nodes form node matrix in parameter domain. For this matrix, address of node vertex object is saved with null original value. Row number of the matrix corresponds to v-direction number and column number corresponds to u-direction number, which is shown in Fig.  4.
Then uv coding is began for quadrangle points of each smooth enough surface piece and each uv code corresponds to one unique node of the node matrix, which is shown in Fig. 5.
In Fig. 5, U b and V b are uv coding of points in the lower left corner of the surface piece, which are points with minimize uv parameters. And U s and V s are extent of surface piece in uv-direction. E r is approximate error and E 0 is the given tolerance.
From Fig. 5, we can know one ship hull NURBS surface subdivision can be represented as one node matrix with address of node coordinates object saving and one rectangular object linked list with topology information of a smooth enough surface piece saving based on quadrangle coding method. That is, one rectangular object linked list and one node matrix can represent each smooth enough surface piece. In Fig. 5, U direction means udirection coordinate axis of parameter domain and U b , V s are ordinal number of node matrix in u-direction and vdirection in parametric domain. Compared to methods of binary tree or quadtree, quadrangle coding method saved coordinates of angular points for smooth enough planar surface pieces and each coordinate of angular point is saved only once. We don't need to save mediate segmentation results and all objects access can be linearly searched based on uv coding.
For example, uv coding for rectangular objects of two smooth enough surface piece 1 and 2 in Fig. 4 is as follows.
smoothness checking E r <E 0 or U s 1 or V s 1 Figure 5. Principle of quadrangle coding For surface piece 1, U min =1, U max =3, V min =2, V max =4. For surface piece 2, U min =8, U max =8, V min =1, V max =4. The corresponding area of node matrix in parameter domain is shown in Fig. 5. Here, U min , U max , V min , V max are ordinal number of node in u-direction and v-direction in parametric domain. Based on node matrix, it can be decided that there exists one not null segmentation point between two end points on the minimize edge in udirection for rectangular object 1. With the same principle, the minimize edge in u-direction for rectangular object 2 consists of four segmentation points. Segmentation points of all rectangular objects including end points can be reordered into one circular list and triangulation can be carried out based on segmentation angle method as follows.
PAPER A NURBS-BASED TRIANGULATION METHOD FOR 3D SHIP HULL SIMULATION (1) If number of segmentation points is 4, then two triangles are subdivided directly. Else, goes to the next step.
(2) Query three successive points in u-direction or vdirection and the fourth point is in different direction. If it is the case, point 2, 3 and 4 are connected and point 3 is cut off. Query continues until there are no three points like this, goes to the next step.
(3) Successive three points form one triangle and the mediate point is cut off. The same operation continues until there are three points left.
For three points to form one triangle, if these three points are collinear or almost collinear, no triangle needs to be created and the mediate point needs to be cut off. Crack can be completely avoided by adopting the above triangulation method, and detailed triangulation process is shown Fig. 6.
Adaptive triangulation mesh generation for ship hull NURBS surface is shown in Fig. 7. Simulation result of 3D ship hull is shown in Fig. 8.

V. CONCLUSIONS
Aiming at solving problems in simulation of 3D ship hull and display of real image, this paper put forward an innovative arithmetic for adaptive triangular mesh generation of ship hull surface based on NURBS by applying NURBS curve and surface theory. This arithmetic, while combining quadrangle coding and improved surface evenness checking which are proposed for the first time in this paper, is capable of subdivision quadrangle grid quickly and effectively when recursively subdivide NURBS surface of ship hull, and at the same time satisfies the given precision requirements in the height direction and boundary of the surface. On the basis of the above one quadrangle grid is divided into two or more triangle grids by using cut corner arithmetic. The test indicates that the triangle surface created in accordance with the arithmetic stated in this paper approximates ship hull better, and consequently avoids crack between grids; in addition, it also shows that the quadrangle coding proposed in this paper distinctly saves time and space in comparison with binary-tree, quard-tree subdivision, hence improves the efficiency of the arithmetic.