KernelCAD Documentation

DInsight Home
Skip Navigation Links. Skip Navigation Links
IMeshBuilder_KC Interface

IMeshBuilder_KC Interface


The interface is implemented by Mesh Builder object created when this interface is queried from mesh via IMesh or other related interface. Mesh Builder is a temporary object which simplifies construction of a mesh. To save memory it is not recommended keeping a reference to this interface as it duplicates the data copied to the mesh object

Example: To build a thetrahedral:

Query IMesh > IMeshBuilder_KC and call (C#):

iBuilder.AddVertex(0, 0, 0); //0
iBuilder.AddVertex(1, 0, 0); //1
iBuilder.AddVertex(0, 1, 0); //2
iBuilder.AddVertex(0, 0, 1); //3
iBuilder.AddSimplex(0, 2, 1); //x,y plane
iBuilder.AddSimplex(0, 1, 3);
iBuilder.AddSimplex(0, 3, 2);
iBuilder.AddSimplex(1, 2, 3);
iMeshMods.FixupNormals(30, 0);    //IMesh > IMeshMods

See also Interface List

HRESULT SetCurrentNormal(double vx, double vy, double vz)

Defines the normal to be used for the following AddVertex() calls. The default is a zero vector. If normals are not supplied via this method the surface lighting may not be correct. In the case consider calling IMeshMods.FixupNormals() in the end of mesh construction process

HRESULT SetCurrentColor(float red, float green, float blue, float alpha)

Not implemented in this version

HRESULT AddVertex(double x, double y, double z, int* indxOut)

Adds the vertex to the mesh and returns its zero-based index, which one less than the number of AddVertex() calls since acquiring this interface or last Reset() call,  to be used in AddSimplex() or AddQuad() calls below

HRESULT AddSimplex(int i0, int i1, int i2)

Adds a new simplex to the mesh. i0, i1, i2 are indecies (= returned from) of the related AddVertex() calls

HRESULT AddQuad(int i0, int i1, int i2, int i3)

Adds a new simplex to the mesh. i0, i1, i2, i3 are indecies (= returned from) of the related AddVertex() calls


Clears all data from previous calls and returns to the initial state. This does not affect any changes to the underlying mesh done during previous calls