BACKGROUND OF THE INVENTION
1. Field of the Invention
This invention relates to a method and an apparatus for generating an image representing an iso-valued surface, i.e. a set of points with a specified scalar value, from a set of points each having a scalar value, where the points are distributed in three dimensional space. The points and associated scalar values are generated by methods such as the three-dimensional finite element method (3D FEM).
2. Prior Art
"Volume Rendering" has recently been studied in the field of medical image processing, and has some application to the visualization of numerical simulation results. Though volume rendering is applicable to the three-dimensional finite difference method (3D FDM), it cannot be applied directly to the 3D FEM, which has no regular connections among neighboring grids (elements), because volume rendering assumes that a scalar field is defined on orthogonal grids.
The FEM divides an area to be analyzed into polyhedrons called elements, approximates the potential distribution in each element to a simple function, and obtains a scalar value at each node point. Generally, this method defines node points P irregularly, depending upon the nature of the area to be analyzed, as shown in FIG. 10.
When the volume rendering method is applied to the FEM output, scalar values defined on irregular grid points (node points) must be mapped to a regular grid Q (hexahedron). Information contained in the original 3D FEM analysis results may be lost, as in the case of the node points in region R of FIG. 10, unless the grid to which the 3D FEM results are mapped is positioned appropriately. Not a little information is lost in mapping, because the appropriateness depends heavily on the arrangement of the irregular grid of the FEM.
One method of extracting iso-valued surfaces without mapping node point information to a hexahedral grid is presented in the inventor's paper, "Visualization of Equi-Valued Surfaces and Stream Lines," I-DEAS/CAEDS International Conference Proceedings, Oct. 1988, pp. 87-97. This method is also disclosed in "Method for Reconstructing Solid Elements into Linear Tetrahedral Elements," IBM Technical Disclosure Bulletin, 06-89, pp. 340-342. The method in these papers creates a node point and a scalar value for it at each of the face centers and the volume center of each volume element, and then divides each volume element into linear tetrahedral elements defined by the node points. FIG. 11 shows the division of a parabolic wedge element into thirty-six linear tetrahedral elements.
FIG. 12 shows one example of a created tetrahedral element. Assume that the scalar values of vertices P, Q, R, and S are 8, 2, 4, and 0, respectively. Visualization of the iso-valued surface with the scalar value 6 is considered below. Points X, Y, and Z, where the scalar value is 6, are searched by linear interpolation. The triangle defined by those three points X, Y, and Z is the approximation of the iso-valued surface within the tetrahedron PQRS.
The prior art method obtains geometric data of the iso-valued surface approximated by triangles, in other words, position data and connection data of the triangles, and performs shading on the basis of the data. However, the volume of the geometric data of the triangles is apt to be enormous. In particular, when multiple iso-valued surfaces are visualized as semi-transparently shaded images, a large volume of computer storage is required, and considerable time is required to generate the image data, because the geometric data of the triangles must be generated for each iso-valued surface.
SUMMARY OF THE INVENTION
The present invention is directed to generating image data of a shaded iso-valued surface directly, without using intermediate geometric data of triangles to represent the iso-valued surface.
The method operates by dividing three dimensional space into tetrahedral elements that have as vertices the points provided with scalar values thereby generating an element list relating tetrahedral elements to their vertices. Next, for each tetrahedral element, a tetrahedral element representative normal vector is generated representing the normal vectors of all iso-valued surfaces contained in the tetrahedral element. This normal vector is generated based on the position data and scalar values of the vertices of the element. Next, a vertex representative normal vector is generated for each vertex of the tetrahedral element based on the representative normal vectors of the tetrahedral elements that comprise the vertex. Finally image data is generated representing the iso-valued surface with the specified scalar value according to the element list of tetrahedral elements and the vertex representative normal vector data.
BRIEF DESCRIPTION OF THE DRAWING
FIG. 1 is a flow chart schematically illustrating data processing in accordance with the invention.
FIG. 2 is a perspective view of one example of a tetrahedron.
FIG. 3 is a graph illustrating the change in scalar values in a tetrahedral element along a viewing ray.
FIG. 4 is a perspective view of one example of a hexahedral element.
FIG. 5 is a graph illustrating the change in scalar values in a hexahedral element along a viewing ray.
FIG. 6 is an illustration of a tetrahedral element in a perspective coordinate system.
FIG. 7 is an illustration of the data required for pixel value calculation.
FIG. 8 is an illustration of a circumscribed rectangle of a tetrahedral element in a perspective coordinate system.
FIG. 9 is an illustration of an assignment of colors to iso-valued surfaces.
FIG. 10 is an illustration of mapping of an FEM grid to an orthogonal grid.
FIG. 11 is an illustration of the division of a parabolic wedge element into thirty-six linear tetrahedral elements.
FIG. 12 is an illustration of the extraction of geometric data of an iso-valued surface from a tetrahedral element.
DESCRIPTION OF THE PREFERRED EMBODIMENT
All iso-valued surfaces within a tetrahedron have the same normal vector, and scalar values change linearly along any segment, which is a very convenient property for direct shading. The proposed invention utilizes this property of a tetrahedron. The steps of the invention are described with reference to FIG. 1.
Position data and scalar values are given to points distributed in a three dimensional space, and stored in a storage device.
(a) First, the space is virtually divided into tetrahedral elements that have as vertices the points provided with scalar values. An element list relating each tetrahedral element to its vertices is generated and stored in the storage device (block 10).
(b) The element list is referenced and data for a tetrahedral element representative normal vector contained in each tetrahedral element are generated based on the position data and the scalar values of the vertices of that tetrahedral element (block 12).
(c) For each vertex of each tetrahedral element, data of the normal vector associated with that vertex (hereafter referred to as the vertex representative normal vector) are generated based on the tetrahedral element representative normal vectors of the tetrahedral elements that comprise the vertex. The generated data are stored in the storage device (block 14).
(d) Image data representing the iso-valued surface with the specified scalar value are generated according to the element list and the vertex representative normal vector data stored in the storage device (block 16). Pixel values are generated for each of the viewing rays.
In step (a), the space is divided into tetrahedral elements as defined only by the node points with previously assigned scalar values. Alternatively, new node points may be added so that the space may be divided into tetrahedral elements as defined by the node points, including the new ones.
OPERATION
The invention will be explained with reference to an example in which the image data of an iso-valued surface are generated from 3D FEM analysis results.
a) Generation of Tetrahedral Element List
Tetrahedral model data, that is, (i) data of each vertex of a tetrahedron, (ii) a list of the IDs of vertices defining the tetrahedron, and (iii) the scalar value at each vertex of the tetrahedron, are generated from the results of a 3D FEM analysis. Since the method for generating the model from the general 3D FEM results consisting of various finite elements without regular connection was explained simply with reference to FIG. 11 and reference providing the details was provided, no detailed explanation is given here.
b) Generation of Tetrahedral Element Representative Vector Data
The approximate equation that gives the distribution of scalar values within a tetrahedron is given in the form of a linear combination of X, Y, and Z. That is, the equation giving a scalar value SCAL within a tetrahedron is given uniquely as follows:
This is because a.sub.0, a.sub.x, a.sub.y, and a.sub.z are determined uniquely by solving four simultaneous equations set up by substituting the position data of the four vertices of the tetrahedron, (X.sub.1, Y.sub.1, Z.sub.1), (X.sub.2, Y.sub.2, Z.sub.2), (X.sub.3, Y.sub.3, Z.sub.3), (X.sub.4, Y.sub.4, Z.sub.4) and their scalar values, SCAL1, SCAL2, SCAL3, and SCAL4, which are known beforehand, for equation (1). Such representation of the scalar values within the tetrahedron in the form of equation (1) makes it possible to think of the tetrahedron as a heap of iso-valued surfaces with a normal vector (a.sub.x, a.sub.y, a.sub.z). Therefore, the vector (a.sub.x, a.sub.y, a.sub.z) can be regarded as representative of normal vectors of the iso-valued surfaces actually contained in the tetrahedron. In other words, (a.sub.x, a.sub.y, a.sub.z) is the tetrahedral element representative vector. For further details of the equations used to generate the normal vector, see the Program Example A-4.
c) Generation of Vertex Representative Normal Vector Data
Next, vertex representative normal vector data are generated for each vertex of the tetrahedron. A vertex of a tetrahedron is generally shared with adjacent tetrahedral elements. Therefore, the simple average of normal vector data of the tetrahedron that are defined by the vertex is regarded as the vertex representative normal vector data in this embodiment. If the vertex is on the edge of the 3D space and defines only one tetrahedral element, the representative normal vector of the tetrahedral element directly becomes the representative normal vector of the vertex. For further details of the equations and program code used to calculate the normal vector at each vertex, see Program Example A-5.
d) Pixel Value Calculation
A tetrahedron is searched along each of a set of viewing rays starting from a given view-point, and is selected for processing if:
(1) the tetrahedron intersects the viewing ray, and
(2) the scalar value being visualized is equal to or smaller than the maximum of the scalar values at the four vertices, and is equal to or greater than the minimum of the scalar values of the four vertices.
For each such tetrahedron found,
(3) the entry and exit points of the viewing ray to the tetrahedron, fent and fext, are obtained, and
(4) the normal vectors of the iso-valued surfaces at fent and fext, FNORM and FNORM', and their scalar values, SCL and SCL', are obtained by interpolation using the values at the three vertices of the triangles including fent and fext. In FIG. 2, TNORM is the tetrahedral element representative normal vector and VNORM is the vertex representative normal vector.
Process (2) is carried out by referring to the tetrahedral element list and classifying the tetrahedral elements according to their relation to the scalar value to be visualized. An example of program code used to classify the tetrahedrons is presented in Program Example A-3.
For each tetrahedron in which the scalar value being visualized lies between the two scalar values calculated by the interpolation,
(5) the intersection P between the iso-valued surface and the viewing ray is obtained, and
(6) the normal vector of the iso-valued surface SNORM at the intersection is calculated by interpolation.
Scalar values are distributed linearly on a segment piercing a tetrahedron, because scalar values are given by a linear expression of X, Y, and Z (formula 1) at points within it. Accordingly, evaluation of the scalar values at the entry and exit points of a ray to a tetrahedron, fent and fext, and comparison of the results with a scalar value C (five, for example), determine whether the iso-valued surface intersects the ray. Division of the space into hexahedral elements (the hexahedral model) is considered with reference to FIGS. 4 and 5. In order to obtain a point with a scalar value being visualized on a segment piercing a hexahedral element, a cubic equation has to be solved, because the distribution of scalar values on the segment is represented by a cubic function in a coordinate system with the segment as a coordinate axis. In other words, more than one iso-valued surface may be found on the segment. In addition, the calculation necessary to solve a cubic equation is very expensive in time and cost. On the other hand, if the space is divided into tetrahedral elements, as in the present invention (the tetrahedral model), it can easily be judged whether the iso-valued surface intersects the viewing ray with only the scalar values at fent and fext. This is an advantage of the tetrahedral model over the hexahedral model.
For ease of understanding, an iso-valued surface with scalar value five that comprises two triangles is illustrated in FIG. 2. It should be noted that geometric data on the iso-valued surface (triangle data) are never generated in the present invention. Without such geometric data, normal vector data on the iso-valued surface at the intersection with the viewing ray are generated by using vertex representative normal vector data, which are given for each vertex. Because one vertex is typically shared by more than four tetrahedral elements, the volume of vertex representative normal vector data never becomes large relative to the number of tetrahedral elements. Further, vertex representative normal vector data are used in common for any iso-valued surfaces with any scalar values. Therefore, when multiple iso-valued surfaces are displayed semi-transparently, the prior art method generates a large volume of triangle geometric data for each of the iso-valued surfaces, while the present invention utilizes vertex representative normal vector data repeatedly, which results in a much smaller volume of data being required for image generation.
Pixel value calculation is performed according to the position data of the intersection between the viewing ray and the iso-valued surface and the normal vector data of the iso-valued surface at the intersection. Such calculation is done in accordance with a known method such as Phong's model. For further details, and a program code example, see the description relative to FIG. 7 and Program Example A-7.
In accordance with the invention, different viewing rays have intersections at different positions on the same iso-valued surface in the same tetrahedral element, so that the interpolated normal vector data are also different. Therefore, the edges of triangles displayed on the screen are not highlighted relative to the enclosed areas. It is of course possible to modify the calculated pixel values in order to smooth the displayed image.
The essential part of data flow in accordance with the invention is mentioned above. Process (1) is performed in a perspective coordinate system and processes (3) to (6) are performed in an eye coordinate system. The processes in each coordinate system are described below in greater detail.
e) Processes in a Perspective Coordinate System
In this kind of coordinate system, a viewing ray is mapped to coordinates (IU, IV), as shown in FIG. 6. A search is made to determine which tetrahedron intersects the viewing ray. In the example of FIG. 6, the viewing ray enters triangle 1-2-3 and exits triangle 4-1-2. Z values (IW, IW') are interpolated on each of the triangles intersected by the viewing ray.
Subroutine TRJUDG (TRPT, IU, IV, IFLUG, S, T) is used to determine whether or not viewing ray (IU, IV) intersects triangle ((TRPT (i,j), i=1,2), j=1,3) (see attached material). In this subroutine, IU and IV are represented as follows:
If 0.ltoreq.S.ltoreq.1, 0<T<1, and 0<S+T<1, point (IU, IV) is judged to be inside or on the edge of the triangle and IFLUG=1 is returned. IFLUG is used to determine whether the viewing ray is inside or outside the triangle. IW and IW' are interpolated according to (S,T).
f) Processes in an Eye Coordinate System
Next, the position data of fent and fext, namely (UE, VE, WE) and (UE', VE', WE') are obtained by transforming the two points (IU, IV, IW), (IU, IV, IW') into the eye coordinate system (see FIG. 7).
S and T, mentioned above, cannot be used for the interpolation of scalar values and normal vector at fent and fext, because a perspective transformation does not preserve the segment ratio. Therefore, (S, T) in the eye coordinate system is obtained by applying TRJUDG again to (UE, VE) and UE', VE'). Scalar values and normal vector at fent and fext, ((SCL, SCL'), (FNORM, FNORM')), are interpolated according to this (S, T). Calculation of coordinates and normal vector at a point on an iso-valued surface according to these data takes advantages of the fact that scalar values and normal vectors change linearly along any segment within a tetrahedron. That is, a point (X.sub.C, Y.sub.C, Z.sub.C) on the segment that links point A, (X.sub.A, Y.sub.A, Z.sub.A), and point B, (X.sub.B, Y.sub.B, Z.sub.B), is represented as follows: ##EQU1##
Scalar value distribution in a tetrahedron is represented by:
Accordingly, scalar value distribution along the segment AB is represented as follows: ##EQU2## This is linear distribution.
Assuming that the scalar value being visualized is C, the weight coefficients for linear interpolation p, q (p+q=1) are as follows:
The coordinate values (UEQ, VEQ, WEQ) and normal vector (SNORM(j)(j=1,3)) are as follows:
The light direction vector (LTD(j)(j=1,3)) is obtained from (UEQ, VEQ, WEQ) and the position data of the light source point XL, and the cosine DOTDF of the angle between the light and the normal, which is required to calculate the diffuse reflection, is calculated. Further, the reflected light direction vector (RFD(j)(j=1,3)) is obtained from the light direction vector, DOTDF, and the normal vector, and the cosine DOTRF of the angle between the viewing ray and the normal, which is required to calculate the specular reflection, is calculated. Pixel values ((IPIXEL(i,j), i=1,3, j=1,1024) are obtained from the two calculated cosines.
Output Data
An image file for RGB (3.times.1024 .times.1024 pixels, eight bits per pixel) is created.
One use of the invention, for generating image data on iso-valued surfaces, is described above. Needless to say, various other examples are conceivable. For example, in the above embodiment, the vertex representative normal vector is calculated by obtaining a simple average of the representative normal vectors of the tetrahedrons sharing the vertex. In another embodiment, however, it can be calculated by obtaining the average of the representative normal vectors weighted by the solid angles of the tetrahedrons. The weighting factor can be the distance between the vertex and the gravity center of the tetrahedron sharing it in still another embodiment.
Further, the space is virtually divided into tetrahedral elements as defined by the node points that are generated and distributed irregularly by 3D FEM and those that are added later in the above embodiment. However, the invention can be applied to the case where scalar values are provided with the points on the structured grid. Koide et al., in "Tetrahedral Grid Method for Equi-valued Surface Generation," Proceedings of the 35th annual convention of Information Processing Society of Japan, 13G-10 (1987), disclose a method for the division of such a structured grid addition, which is equivalent to node point addition in the above embodiment, is never performed. The process after the division of the structured grid space into tetrahedral elements is the same as in the above embodiment.
In accordance with the invention, image data of an iso-valued surface formed by a set of points with the same scalar value are generated at high speed and without the need for much memory when scalar values are provided beforehand with points distributed in 3D space.
Program Examples
Here, Npoint denotes the total number of vertices, Ntetra denotes the total number of tetrahedrons, and NCRT denotes the total number of iso-valued surfaces.
Here, MAT1 is a subroutine that multiples (pointi(i),i=1,4), a point represented by a homogenous coordinate system, by transformation matrix MATE (4,4) and returns the result to (pointo(i), i=1,4). MATE (4,4) is an eye transformation matrix determined on the basis of XA (3) and XF (3).
MATP (4,4) is a perspective transformation matrix determined on the basis of K (half of the screen size) and H (the distance between the eye of and the plane of projection). Default values are determined as follows: ##EQU3##
An eye transformation and a perspective transformation are also performed for eye point XA (3) and the results are stored in XAE (3) and XAP (3), respectively.
The perspective coordinates of (IU, IV) are normalized to a screen size of 1024.times.1024 during step 1 (See FIG. 8). Therefore, the area subject to pixel value calculation is known for the IV component on the basis of IVMAX and IVMIN. Next, the areas subject to pixel value calculation, IUMAX(IV) and IUMIN(IV), are found for each IV by using the obtained VOX(4, NTETRA) (See FIG. 6).
3. Classification of tetrahedrons based on scalar values at vertices
Tetrahedrons are classified according to which of the scalar values to be visualized (CRT(i)) they contain. A binary number of ICRT digits is given. A rule is adopted that the i-th digit is set to 1 if the scalar value CRT(i) is contained in the tetrahedron. The resultant number is stored into the array ICLASS(NTETRA).
4. Normal Vector Calculation for Each Tetrahedron
Assume that the scalar value distribution is described as shown in the following equation:
The normal vector TNORM of iso-valued surfaces in the tetrahedron can then be calculated as follows: ##EQU4##
The following equations are satisfied at the four vertices of the tetrahedron.
The following equations are obtained by calculating (1)-(4), (2)-(4), and (3)-(4) to eliminate a.sub.0. ##EQU5##
TNORM is obtained by solving the above equations for (a.sub.x, a.sub.y, a.sub.z).
Here, GAUSS (A, B, X) is a subroutine for solving simultaneous equations with three unknowns by the Gauss elimination method. A is a coefficient matrix, B is a right-hand side vector and X is a solution vector.
5. Normal Vector Calculation at Each Vertex
VNORM (j,i) (j=1,3, i=Npoint) is obtained for each vertex on the basis of TNORM (j,i) (j=1,3, i=Ntetra), which is calculated for each tetrahedron. For each vertex, the assigned TNORM (j,i) is added and the sum is divided by the number of tetrahedra connected to the vertex.
6. Assignment of Color to Iso-Valued Surface
The ratio of R (red), G (green), and B (blue) is predetermined according to the scalar value, as shown in FIG. 9.
7. Pixel Value Calculation
Each time the calculation of pixel values (PIXEL (1024,3)) is completed for one scan line (with constant IV), the results are written into an external file. All pixels have the value 0 in the upper background area (IV=IVMAX+1,1024).
For each pixel (IU, IV) in the pixel value calculation area (IV=IVMIN, IVMAX), a tetrahedron that contains it is searched. The scalar values SCL(2) at the entry and exit points to the tetrahedron of the ray that corresponds to the pixel, fent and fext, are then obtained and compared with the scalar value to be visualized, CRT(ICRT), to determine whether an iso-valued surface exists, the pixel value is calculated by using Phong's model and the result is stored into array PIC(i,j) (i=1,100;j=1,4) together with the Z value of the iso-valued surface. When every tetrahedron has been stored, the array is sorted by using PIC (i,4) (i=1,100) in descending order as keys.
Here, KT is the transparency of the iso-valued surface and NFACE is the number of iso-valued surfaces. The information on all the iso-valued surfaces intersected by one viewing ray influences the pixel value calculation for the ray in such imaging of multiple semi-transparent iso-valued surfaces.
When this work is completed for one scan line, the results are written into the external file. The details are given in the list below, where comments are marked.