Boolean Processor

This is the 3D Boolean processing interface.

In the case of a multi-threaded application, an application should manage access to 3d data on its own. In general, there should be no simultaneous access to objects and "boolean processor" from many threads. Separate "boolean processors" may be accessed from their own threads.

Constructor

Boolean Processory is created with ivCreateBoolean global function.

Destructor

void Processor::Destroy()

This method destroys 3d boolean processor. If you want to perform the next boolean operation, you may destroy this processor and create a new one or reset this processor with help of the Reset method. The last approach is more resource-friendly.

Parameters This method has no parameters.
Return Value Function does not return anything.

Methods

bool GetPrecision()

Retrieves current precision.

Parameters This method has no parameters.
Return Value Function return true for double precision and false for single precision.

Reserved for future, in current version function always moodule works with double precision.

Object* AddSource(int iChannel,Object*obj=NULL)

Creates new source channel or uses existing one as source channel.

Parameters Description
iChannel Index of source channel. 0 - for channel A , 1 for channel B.
obj Use NULL to create new channel, or pass existing object. In last case it may be possible to reuse result of previous operation or have a list of frequently used objects.
Return Value If the function succeeds, the return value is a pointer to the new object.

It may be possible to use many source objects for each channel. For instance, to subtract cylinders from cube to make set of holes in one step. However, these objects should not have intersections, or result will be wrong. In such case, process objects one by one.

bool Process(boolean_mode mode,unsigned int flags)

Executes boolean operation

Parameters This method has no parameters.
mode Type of boolean or another 3d operation. For list of possible operations, see below.
flags Optional parameters for boolean operation. For more detailed information, see below.
Return Value If the function succeeds, the return value is true.

Boolean operations

M_MERGE Just merge triangles in one object, no intersections, no clipping - nothing. May be used for test purposes
M_OR Union of two operands. All arguments should be solid ones.
M_SUB_AB Subtract second argument from first one. All arguments should be solid ones.
M_SUB_BA Subtract first argument from second one. All arguments should be solid ones.
M_CUT_AB Cut part from first argument by second argument. First argument may be non solid. E.g. you my remove part of plane by ball. You should receive disk
M_CUT_BA Same as previous mode, but with flipped arguments.
M_CUT_AB_neg Similar to M_CUT_AB, but removes opposite part from first object.
M_CUT_BA_neg Same as previous mode, but with flipped arguments.
M_CUT_2 Cut solid manifold object by a non-solid surface. This works in some limited cases when a second operand is a flat plane or surface very close to flat.
Part to keep depends on normal of the second operand or BV_CUT_OPPOSITE_PART property. Internally it detects when the second operand is a flat plane and works quite fast. In rest cases, it may work relatively slow ( just because it is not easy to detect which part should be kept), so it is better to create a solid object.

Boolean options

EXTRA_INFO Not used in current version
SINGLE_THREAD Internally, boolean may create many threads to work faster. This causes different results for each execution with same arguments. This is mostly related to order of triangles in produced geometry. if you want to avoid this, use this flag. Please note that processing speed will drop significantly.
REDUCE Execute reducer modifier after boolean. This is not a classic polygon reduction algoritm, but mostly mesh healing and optimization tool. For list of extra parameters, see SetValue method.
DEBUG_LOG Print debug information to output window of attached debugger.
POLYGONISE Execute polygonization tool. This tool creates polygons from triangles. Tool is the bonus option, it is limited and can't always restore big polygons with holes. However, it may try to do that. For list of extra parameters, see SetValue method.
NORMALS If set, normals for source object will be pre-generated. Default crease angle will be used. If custom angle is required, please request this feature.
TRIANGULATE Triangulate source mesh. This flag works independently and may be used if you want to just triangulate source object.
AUTOSUBD Allow subdivision of source objects to speed up processing. New functionality.
RESPECTMTLIDS Reducer property. Respect material IDs and do not join triangles with different material identifiers. Similar to BV_REDUCER_RESPECT_MTLIDS value.

bool Interrupt()

Termitaes current operartion. Must be called from another thread.

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

Method is reserved for future version and will be implemented upon receiving first request.

Object* GetResult()

Retrieves produced geometry after successful call to Process method.

Parameters This method has no parameters.
Return Value If the function succeeds, the return value is a pointer to the object. This object will be released automatically by Processor. In order to kepp this object in memory and use it in the next operation use AddRef method.

bool SetCallback(KEEPGOINGPROC proc,void*lParam)

Sets execution callback function.

Parameters Description
proc A pointer to an application-defined callback function.
lParam An application-defined value to be passed to the callback function.
Return Value If the function succeeds, the return value is true.

Method is reserved for future version.

bool SetValue(BOOL_VALUE id, double value)

Sets the property value of boolean processor.

Parameters Description
id Index of the property to set. For list of possible properties, see table below.
value The new value for the property.
Return Value If the function succeeds, the return value is true.

Properties

BV_TOLERANCE Relative Treshold in Advanced Properties of boolean modifier. See boolean modifer in FinalMesh for more information.
BV_FLAT_DISTANCE Max. Distance in Advanced Properties of boolean modifier. See boolean modifer for more information.
BV_FLAT_ANGLE Max Angle in Advanced Properties of boolean modifier. See boolean modifer for more information.
BV_REDUCER_VJOIN Reducer property. Join points closer than specified distance - this is to remove almost the same point
BV_REDUCER_ANGLE_TRESHOLD Reducer property. Angle in radians, usually should be very small about 0.1 of deg
BV_REDUCER_EDGE_TRESHOLD Reducer property. Collapse or remove edges, smaller than required distance
BV_REDUCER_MAX_EDGE_SIZE Reducer property. Keep edges larger than specified size
BV_REDUCER_PROTECT_EDGES Reducer property. Protect outer edges and do not combine them with each other. This is boolean value. false == 0.0, true !=0.0
BV_REDUCER_RELATIVE Reducer property. All values are realtive to bounding box size or absolute. This is boolean value. false == 0.0, true !=0.0
BV_REDUCER_RESPECT_MTLIDS Reducer property. Respect material IDs and do not join triangles with different material identifiers. Similar to RESPECTMTLIDS option.
BV_POLY_MAX_SIZE Polygonizer property. Max size of polygons to detect. Interger value.
BV_POLY_ALLOW_HOLES Polygonizer property. Detect holes or not. This is a boolean value. false means 0.0, true any value not equal to 0.0
BV_CUT_OPPOSITE_PART Property of M_CUT_2 operation. This is a boolean value, allows to define which part of first argument should be included in result. false means 0.0, true any value not equal to 0.0
BV_CUT_INVERT_PLANE

Property of M_CUT_2 operation. This property defines how the cut-plane will be included in the result. Allowed values are defined by BOOL_CUT_PLANE enumeration:

  • CUT_PLANE_NORMAL - insert cut plane as is.
  • CUT_PLANE_FLIP - insert inverted cut plane.
  • CUT_PLANE_NONE - do not include cut plane at all.

void Processor::Reset()

Method removes all source and result objects. It prepares this processor for the next operation.

Parameters This method has no parameters.
Return Value Function does not return anything.

Object* Processor::NewObject()

Inline method. It creates a new object. This object is not attached to the boolean library. This object may be added later with AddSource method.

Parameters This method has no parameters.
Return Value If the function succeeds, the return value is a pointer to the new object.

Debugging

bool dbgSetSaveFileName(const wchar_t*pszName)

Method sets file name for further Process call.

Parameters Description
pszName zero terminated string with full file name.
Return Value If the function succeeds, the return value is true.

This method is used for debugging purposes. If dbgSetSaveFileName method was called before Process method, then FinalMesh file with a specified file name will be generated. Internally, the library creates standard FinalMesh polygonal objects and a hierarchy of modifiers. You may open this file in FinalMesh and check almost everything, including input data, properties, how data is processed, and what is the result.

In this article