Boolean 3D Mesh Object

This is 3D Boolean Mesh Object. Mesh consists of vertices and polygons. Optionally it may have UV coordinates, normals, colors, material ids, etc.

Constructor

Boolean 3D Mesh is created with AddSource method.

Destructor

Object may be destroyed automatically by Processor or in the result of calling to Release method.

Methods

int Release()

Decrements the reference count for an object.

Parameters This method has no parameters.
Return Value The method returns the new reference count. This value is intended to be used only for test purposes.

When the reference count on an object reaches zero, Release must cause the object to free itself.

int AdRef()

Increments the reference count for an object. You should call this method whenever you want to reuse objects in upcoming operations.

Parameters This method has no parameters.
Return Value The method returns the new reference count. This value is intended to be used only for test purposes.

If you don't want to use the result of the previous operation as a source in the next operation or use one object many times you may ignore AddRef/Release methods.

Set Data Methods

bool BOOLAPI SetTM(const double*tm,int size=16)

Method defines global object transformation matrix. For the same purpose, you may transform points and normals on your own.

Parameters Description
tm Point to array of doubles represents matrix. Matrix may be made from 16 or 12 numbers.
size Size of array. Valid values are 12 and 16.
Return Value If the function succeeds, the return value is true.

bool SetPoints(const Point3f*points,unsigned numPoints)
bool SetPointsD(const Point3d*points,unsigned numPoints)

Method sets points of 3d object. Points may be in single or double precision. In both cases, calculations are performed in double precision.

Parameters Description
points Pointer to array of 3d points.
numPoints Number of points in array. Number of floats/doubles is 3 times bigger then numPoints.
Return Value If the function succeeds, the return value is true.

bool SetNormals(const Point3f*normals,unsigned count)

This method sets normals of 3d object. Normals should be in single precision. This is optional call, normals are not required for boolean operation.

Parameters Description
normals Pointer to array of 3d normals.
count Number of normals in an array. The count of normals may differ from the count of points.
Return Value If the function succeeds, the return value is true.

bool SetColors(const Point3f*colors,unsigned count)

This method sets the per-vertex colors of 3d object. Colors should be in single-precision. This is an optional call, colors are not required for boolean operation.

Parameters Description
colors Pointer to array of 3d normals.
count Number of colors in an array. The count of colors may differ from the count of points.
Return Value If the function succeeds, the return value is true.

Instead of colors, you may pass any data here. For instance, it may be 3d UV coordinates.

bool SetUV(const p2d*uv,unsigned count)

This method sets the per-vertex UV coordinates of 3d object. UV should be in single-precision. This is an optional call, UV coordinates are not required for boolean operation.

Parameters Description
uv Pointer to array of 2d UV coordinates.
count Number of UV coordinates in an array. The count of colors may differ from the count of points.
Return Value If the function succeeds, the return value is true.

UV poinst are shared by all UV channels

bool SetNumFaces(unsigned faceCount)

This method initiates an internal array of faces ( or in other words: polygons or triangles). Face indices should be defined later.

Parameters Description
faceCount Number of faces to create.
Return Value If the function succeeds, the return value is true.

unsigned NewFace(unsigned faceSize,const unsigned *vids)

This method creates a single face. Faces should be created one by one, from 0 to faceCount-1.

Parameters Description
faceSize Number of vertices in the face. For a triangle, this number should be 3.
vids Pointer to array of vertex indices for this face/polygon.
Return Value If the function succeeds, the return value is a zero-based index of the face. This value may be used as an argument for methods that defined additional attributes of the face.

If a polygon has holes, outer and inner loops should be placed in vids array. Outer loop first, inner loops are located after that, one by one. faceSize will hold a number of points in outer and inner contours. The start of each inner contour should be defined by SetHole method.

For each face, this is the first method to call. Definition of extra attributes (Normals, UV, Material id) should be after that.

bool SetHole(unsigned iFace,unsigned holeIndex)

This method creates a hole in an already created face. To create the next hole, call this method again with an index of the next hole.

Parameters Description
iFace Index of face.
holeIndex Index of hole in vids array.
Return Value If the function succeeds, the return value is true.

bool SetMtlID(unsigned iFace,unsigned mtlId)

This method defines a material index for an already created face.

Parameters Description
iFace Index of face.
mtlId Index of material. This may be index of material, part ID, face ID or any UINT32 number
Return Value If the function succeeds, the return value is true.

bool SetNormalFace(unsigned iFace,const unsigned *ni)

This method defines normal indices for the specified face.

Parameters Description
iFace Index of face.
ni Pointer to array of normal indices for this face. Each index is number of normal in normals array.
Return Value If the function succeeds, the return value is true.

bool SetUVFace0(unsigned iFace,const unsigned *uvi)
bool SetUVFace1(unsigned iFace,const unsigned *uvi)
bool SetUVFace2(unsigned iFace,const unsigned *uvi)
bool SetUVFace3(unsigned iFace,const unsigned *uvi)

This method defines UV indices for the specified face. Boolean library supports up to 4 UV channels. Upon requirement, this number may be extended to 16.  SetUVFace0 works with 0 UV channel, SetUVFace1 works with 1 UV channel, and so on.

Parameters Description
iFace Index of face.
ni Pointer to array of UV indices for this face. Each index is number of UV coordinate in UV array.
Return Value If the function succeeds, the return value is true.

bool SetColorFace(unsigned iFace,const unsigned *ci)

This method defines color indices for the specified face.

Parameters Description
iFace Index of face.
ni Pointer to array of color indices for this face. Each index is number of color in colors array.
Return Value If the function succeeds, the return value is true.

Retrieving Data Methods

bool GetPoints(const Point3f**points,unsigned &numPoints)
bool GetPointsD(const Point3d**points,unsigned &numPoints)

This method retrieves a pointer to an internal array of 3d points. Points may be in single or double precision. If points are in double-precision, the single-precision version will fail. Boolean operations always produce double precision data.

Parameters Description
points Pointer to array of 3d points.
numPoints Reference to number of points in array.
Return Value If the function succeeds, the return value is true.

You may call the single-precision version first, if it fails call the double-precision version.

const ivbool3d::Point3f*p32=NULL;
const ivbool3d::Point3d*p64=NULL;
unsigned count;
if(!obj->GetPoints(&p32,count))
obj->GetPointsD(&p64,count);

bool GetNormals(const Point3f**n,unsigned&count)

This method retrieves a pointer to an internal array of normals. Normals are stored in single precision (float) format.

Parameters Description
n Pointer to array of 3d normals.
count Reference to number of normals in array.
Return Value If the function succeeds, the return value is true.

bool GetColors(const Point3f**c,unsigned&count)

This method retrieves a pointer to an internal array of per-vertex colors. Colors are stored in single-precision (float) format.

Parameters Description
n Pointer to array of 3d colors.
count Reference to number of colors in array.
Return Value If the function succeeds, the return value is true.

bool GetUV(const p2d**uv,unsigned&count)

This method retrieves a pointer to an internal array of UV coordinates. UV coordinates are stored in single-precision (float) format.

Parameters Description
n Pointer to array of UV coordinates.
count Reference to number of UV coordinates in array.
Return Value If the function succeeds, the return value is true.

bool GetFace(unsigned iFace,Face*face)

Method retrieves information about face.

Parameters Description
iFace Index of face
face A pointer to a Face structure to receive the information.
Return Value If the function succeeds, the return value is true.

Data in Face structure are pointed to internal structures and valid only till next call to GetFace function.

unsigned GetNumFaces()

Retrieves number of faces in this object.

Parameters This method has no parameters.
Return Value Function returns number of faces in this object.

bool OptimizePoints()

This method removes duplicated points and changes indices in faces accordingly. This is helper function, introduced for LoadSTL function in our test code.

Parameters This method has no parameters.
Return Value If the function succeeds, the return value is true.

In this article