Boolean API

For sample usage please see at test.cpp in test project.


Copy ivmodule.dll to your project. Folder is not improtant. For 32 bit project use 32 bit version, for 64 bit project use 64 bit version.

Include ivboolean.h and declare pointers to 3 functions: iv3dInit, iv3dDone, iv3dCreate. Where iv3dInit - initialization of module, iv3dDone - destroying 3d module. iv3dCreate - create boolean processor object.

  	  IV3DINIT iv3dInit=NULL;
	  IV3DDONE iv3dDone=NULL;
	  HINSTANCE ivModule=0;

This may be global variables or data members of any object, structure. Naming is not critical. Load and initialize dll only once. You may execute boolean operation many times from multiple threads.


Implementation below is quite standard.

bool MyLoadLibrary()
		iv3dCreate=(IVBOOLCREATEPROC )GetProcAddress(hi,"ivCreateBoolean");
		if(iv3dCreate && iv3dInit && iv3dDone)
			return true;
	return false;

This function, loads dll, locates 3 functions and in case if all functions were found, initialises 3d library.

Boolean Operation

Firstly you need to create boolean processor:


It is safe to call it from any thread.

Source Data

Now you should define source objects - A and B. Each operand can be made from many objects. You should avoid self intersections on your own. Source object is created with AddSource method. Parameter is type of operand. 0 - A, 1- B.

ivbool3d::Object*obj=proc->AddSource(0);//A channel


Vertices are defined with function: obj->SetPoints, parameters are array of points and number of points. Each point is made of 3 float components: x,yz.

Normals: obj->SetNormals. Normal is same 3d point

UV Coordinates: obj->SetUV. Each component is made of two float values.

Vertices should be added before faces. UV and Normals are optional, but if you want to process them, you should provide separate UV and normal faces.


Firstly you should define number of faces with help of obj->SetNumFaces method.

Each face can have different number of points. In case of 3 it will be triangle, 4 - quad, etc. Polygons will be triangulated automatically. Face is created with obj->NewFace method. Parameters are: number of points in face and pointer into array of indices. Method returns index of face. In case of no errors, index is incremented from 0 to numFaces-1.

Normal faces should be created with SetNormalFace method. First parameter is index of face, second indices to array of normals.

UV faces should be created with SetUVFace0 method. First parameter is index of face, second indices to array of UV coordinates. For second UV channel, use SetUVFace1, etc. Different UV channes share same array of UV coordinates.

Material index may be set with SetMtlID method. First parameter is index of face, second - index of material.


When source objects are set, call Process method.

First parameter is type of boolean operation: OR, AND, SUB, CUT, UNION and variations.

Second parameter is combinations of flags:

Get Results

If process was successfull, you may call GetResult method and get constructed object. This method return object and you should use it's method in order to retrieve points, normals, uv, faces.

Next Boolean operation

After first execution, you may destroy boolean object by calling Destroy metod, create new boolean object via iv3dCreate. Or you may clear boolean object with call Reset method instead. This will prepare boolean object for next operation. Second way may be little bit faster.


On done, call iv3dDone function and unload dll with FreeLibrary function.


If you have problems with filling in source objects, you may save current state to finalmesh file, load it into finalmesh and check. In order to do that, before calling Process, call dbgSetSaveFileName method with name of finalmesh file. After this, during execution of Process method, file will be saved and ready for inspection.