Home Page > KernelCAD Components > Interfaces > Sections > Mesh interfaces > IMesh
IMesh Interface
IMesh(64) Interface
 GetVertexIterator
 GetSimplexIterator
 GetVertexCoord
 GetNormal
 GetSimplexVertices
 IsValid
IMesh interface gives basic direct access to meshed surface displayed by
objects in KernelCAD models. KernelCAD mesh consists of two lists: vertices and
simplexes (See IIterator). Simplexes in this product are always triangles.
Each simplex connects three vertices to create a triangulated surface.
This is a readonly interface for simplified access. For more functionality
see IMeshMods, IMeshEx, IMeshTopol,
IVertex
and ISimplex
interfaces.
Mesh keeps information about normals of the surface, which are very important
for correct rendering. Normals are applied at vertex points and are stored in
vertices. See IVertex interface. See also GetNormal method below.
IMesh can be queried from the correspondent ISection
interface.
See also Morph sample, IIterator,
IMeshMods, IMeshEx, IMeshTopol,
IVertex, ISimplex,
Interface List
HRESULT GetVertexIterator(IIterator** iter)
Parameters
iter  [out] Returned reference to IIterator
interface implemented by the list of all vertices in the mesh
Returns
 S_OK in case of
success.
Remarks:
Gives access to IIterator interface implemented by the list of
all vertices in the mesh.
HRESULT GetSimplexIterator(IIterator** iter)
Parameters
iter  [out] Returned reference to IIterator
interface implemented by the list of all simplexes in the mesh
Returns
 S_OK in case of
success.
Remarks:
Gives access to IIterator interface implemented by the list of
all simplexes in the mesh.

HRESULT GetVertexCoord(int vertex, double* x, double* y, double* z )
Parameters
vertex  [in]
position of the vertex in the vertex
list of the mesh.
x, y, z  [out]  Returned coordinates of the vertex.
Returns
 S_OK in case of
success.
Remarks:
Returns coordinates of a vertex given by its
position in the vertex
list.
HRESULT GetNormal(int vertex, double* vx, double* vy, double* vz )
Parameters
vertex  [in]
position of the vertex in the vertex
list of the mesh.
vx, vy, vz  [out]  Returned coordinates of the first normal.
Returns
 S_OK in case of
success.
Remarks:
Returns coordinates of normal to the surface at the vertex point. The vertex
is given by its position in the vertex list. Note that when there is a
singularity at the point, the surface can have several normals. In this case the
first normal is returned. To obtain information about other normals use IVertex
interface, which can be obtained via path: IMesh>IMeshEx>IMeshEx.GetVertex>IVertex
HRESULT GetSimplexVertices(int simplex, int* vert0, int* vert1, int* vert2 )
Parameters
simplex  [in]
position of the simplex in the simplex
list of the mesh.
vert0, vert1, vert2  [out]  Returned positions
of vertices of
the simplex.
Returns
 S_OK in case of
success.
Remarks:
This method returns information about structure of the mesh, namely how
vertices are joined in triples by simplexes.
HRESULT IsValid(VARIANT_BOOL* ret)
Checks for errors, including cases when some simplexes have zero area. If the mesh is invalid KernelCAD > GetModel() > IModel > IError_KC > GetError*() will return the error description

