Insert_Mesh

Functions

HC_KEY DInsert_Mesh (int rows, int columns, const HCD_POINT *points)
 Similar to Insert_Mesh(), but accepts parameters of type double for increased precision. Unlike Insert_Marker, the parameters are not truncated. More...
 
HC_KEY DInsert_Mesh_By_Ref (int rows, int columns, const HC_DPOINT *points)
 Similar to Insert_Mesh_By_Ref(), but operates on double-precision data. More...
 
HC_KEY Insert_Mesh (int rows, int columns, const HC_POINT *points)
 Puts a rectangular array of faces into the database. More...
 

Detailed Description

Function Documentation

◆ DInsert_Mesh()

HC_KEY DInsert_Mesh ( int  rows,
int  columns,
const HCD_POINT *  points 
)

Similar to Insert_Mesh(), but accepts parameters of type double for increased precision. Unlike Insert_Marker, the parameters are not truncated.

Parameters
rows- Number of rows of vertices in the mesh.
columns- Number of columns of vertices in the mesh.
points- A rows x columns array of x-y-z triplets of the coordinates of the vertices of the mesh. You can also use a simple rows x columns x 3 array of double. A one-dimensional array of double (with the entries packed row by row) may be used in place of the full 2-D/3-D array. Passed by reference always.
Returns
The key to the inserted geometry.

DETAILS

No additional details. See Insert_Mesh().

◆ DInsert_Mesh_By_Ref()

HC_KEY DInsert_Mesh_By_Ref ( int  rows,
int  columns,
const HC_DPOINT *  points 
)

Similar to Insert_Mesh_By_Ref(), but operates on double-precision data.

Parameters
rows- Number of rows of vertices in the mesh.
columns- Number of columns of vertices in the mesh.
points- A rows x columns array of x-y-z triplets of the coordinates of the vertices of the mesh. You can also use a simple rows x columns x 3 array of floats. A one-dimensional array of floats (with the entries packed row by row) may be used in place of the full 2-D/3-D array. Passed by reference always.
Returns
The key to the inserted geometry.

◆ Insert_Mesh()

HC_KEY Insert_Mesh ( int  rows,
int  columns,
const HC_POINT *  points 
)

Puts a rectangular array of faces into the database.

Parameters
rows- Number of rows of vertices in the mesh.
columns- Number of columns of vertices in the mesh.
points- A rows x columns array of x-y-z triplets of the coordinates of the vertices of the mesh. You can also use a simple rows x columns x 3 array of floats. A one-dimensional array of floats (with the entries packed row by row) may be used in place of the full 2-D/3-D array. Passed by reference always.
Returns
The key to the inserted geometry, or -1 if an error occurred.

DETAILS

A mesh, in HOOPS, is a 2-D array of 3-D points. Picture a checkerboard, for example - an 8-by-8 array of squares. Picture the squares as if they were defined by a 9-by-9 array of grid points on the corners. Finally, picture being able to grab any one of those points and pull it off in any direction to a new 3-D location, implicitly distorting the attached squares. That distorted object is a 9-by-9 HOOPS mesh.

For drawing purposes, meshes are made of markers (at the vertices), edges, and faces. Visibility and other drawing attributes for any of these can be set as usual on the segment. Or they can be set locally and individually within the mesh by doing an Open_Face() , Open_Edge() , or Open_Vertex() and then setting the attribute. See the Open routines later in this chapter for details.

One difference between a mesh and a shell in HOOPS Visualize is that the shell requires you to give a "face list" to tell the system which vertices to connect to form the edges and faces. In a mesh, the connections are automatic. Another difference is that meshes (in the situations in which they can be used) tend to be both stored and displayed more efficiently than shells.

The faces of a mesh are arbitrary quadrilaterals. Since arbitrary quadrilaterals are usually not planar, Visualize divides each one into two triangles in order to light and draw them. Specifically, the quadrilateral between vertices (r, c) and (r+1, c+1) will be triangulated by adding an edge from (r+1, c) to (r, c+1). That diagonal edge will be visible whenever edges are visible, unless you use Open_Edge() and Set_Visibility() to turn it off.

Open_Edge() and Open_Vertex() require "vertex numbers" to be passed in, and Show_Selection_Element() returns vertex numbers to you. For a rows x columns mesh with a vertex at (r, c), the "vertex number" is just r * columns + c.

The Open_Face() similarly requires a "face number". For a rows x columns mesh, the mesh triangle between (r, c), (r+1, c), and (r, c+1) is numbered 2*(r * (columns - 1)+ c). The triangle between (r + 1, c + 1), (r, c + 1), and (r + 1, c) - is numbered 2*(r * (columns - 1)

  • c)+1.

The _By_Ref() ("by reference") routines differ from the regular routines only in that HOOPS Visualize is allowed not to make a copy of your data (at the system's option). Instead, Visualize remembers where your mesh data was located. Then whenever the mesh needs to be recomputed the memory originally referenced by points is used. This can speed up the call to Insert_Mesh() and save significant memory. But be careful—when you insert "by reference" you are guaranteeing that the data is going to remain valid and that you're not going to touch it (except via Edit_Mesh() ) until such time as the whole mesh database entry gets deleted. Also, as mentioned, the system makes a copy of the data anyhow if it needs to, so don't assume that edits will be observable back in the original array.

NOTES

If you want the effect of the triangulating running the other way—from (r, c) to (r+1, c+1) rather than from (r+1, c) to (r, c+1)—the only way at present to do it is to flip around your points matrix before passing it into HOOPS.

When running on machines that can handle "triangle strips", a mesh will automatically be sent directly to the hardware as one or more such strips. If you want to take advantage of such hardware, a mesh is the proper choice. HOOPS does not have a separate "triangle strip" primitive.

It is permissible for a mesh to be degenerate - the number of points in a mesh can be zero and points can be redundant.

In the present implementation there are no "sharp" edges or vertices. In other words, smooth-shading, if turned on, will always proceed across the shared edges and vertices, thus "rounding off" the edge or vertex. The only way to disable the smooth shading across an edge is to divide the mesh into two separate meshes.

Prior to HOOPS version 14 (and beyond 14 if the "legacy mesh face numbering" setting is enabled – see Define_System_Options), face IDs were assigned as follows: for a rows x columns mesh, the mesh triangle between (r, c), (r+1, c), and (r, c+1) is numbered r * columns + c. The "other" triangle cornered at (r, c)—the one between (r, c), (r-1, c), and (r, c-1)—is numbered -(r * columns + c).

The mesh as a whole may intersect itself.

If you work with a C compiler with an "int" defined as only 16 bits, you may experience problems. You might be able to create a mesh with rows and columns each as large as 32767. But be warned that Open_Face() , Open_Edge() , Open_Vertex() , and Show_Selection_Element() deal with rows times columns offsets and might overflow.

RESTRICTIONS

HOOPS Visualize cannot handle self-intersecting polygons in shells and meshes. In addition, shells with holes are not handled correctly if a polygon edge and a hole share the same vertex.

See also
Define_System_Options, Edit_Mesh, Insert_Shell, Insert_Grid, Insert_Polygon, Insert_Polyline, Open_Geometry, Open_Face, Open_Edge, Open_Vertex, Renumber_Key, Set_Rendering_Options, Set_Visibility, Set_Face_Pattern, Set_Edge_Pattern, Set_Edge_Weight, Set_Color.