# IRfBooleansSet Interface Reference

Inherits IRsObject.

List of all members.

## Public Member Functions
HRESULT | AddMesh (IRdMesh *spMesh, RtMatrixf &spMatrix, RtUlong dwIndex)
HRESULT | SetPolygonId (RtUlong dwTri, RtUlong dwNewId)
HRESULT | CreateDefaultTopologyGrouping ()
HRESULT | GetNumPolygons (RtUlong *pdwNumPolygons)
HRESULT | GetTrianglePolygon (RtUlong dwTriangle, RtUlong *pdwPolygon)
HRESULT | InvertGeometry ()
HRESULT | Intersect ()
HRESULT | CreateComponents ()
HRESULT | CreatePolygons ()
HRESULT | CleanupRemovedGeometry ()
HRESULT | GetNumComponents (RtUlong *pdwNumComponents)
HRESULT | GetComponentTriangleCount (RtUlong dwComponentId, RtUlong *pdwNumTriangles)
HRESULT | RemoveComponent (RtUlong dwComponentIndex)
HRESULT | GetMesh (IRdMesh **ppMesh)
HRESULT | CreateGeometryGroup (RtUlong *pGroupId)
HRESULT | AddMeshWithMaterialInfo (IRdMesh *pMesh, RtMatrixf &matrix, RtUlong ulIndex, RtMaterialIndexTranslation *pLookupTable, RtUlong dwLookupCount)
HRESULT | CenterAndScaleGeometry ()
HRESULT | CenterAndScaleGeometryBack ()
HRESULT | SetQuadMode (RtBool bQuadMode)
HRESULT | SetPrecision (RtFloat fPrecision)
HRESULT | SetKeepMaterials (RtBool bKeepMaterials)
HRESULT | BooleanMeshes (BSTR bszOperation)

## Detailed Description

Wrapper functions for booleans functionality.

## Member Function Documentation

HRESULT IRfBooleansSet::AddMesh | ( | IRdMesh * | spMesh,
|  | RtMatrixf & | spMatrix,
|  | RtUlong | dwIndex |
| ) |  |  |

Add mesh to booleans algorithm.

Parameters:

  | spMesh | [in] Mesh to add.
  | spMatrix | [in] Mesh transform matrix.
  | dwIndex | [in] Mesh index. Only meshes with 0 index and unequal indices are intersected together. Allocate new index using CreateGeometryGroup method.

Returns:
  S_OK if succeeded.

HRESULT IRfBooleansSet::SetPolygonId | ( | RtUlong | dwTri,
|  | RtUlong | dwNewId |
| ) |  |  |

SetPolygonId

Set index of a specified polygon.

Parameters:

  | dwTri | [in] Polygon triangle index to change polygon id.
  | dwNewId | [in] ID to set.

Returns:
  S_OK if succeeded.

HRESULT IRfBooleansSet::CreateDefaultTopologyGrouping | ( |  | ) |

CreateDefaultTopologyGrouping

Create default polygon groups depending on topology.

- Separate components are assigned different IDs so they are intersected together.

HRESULT IRfBooleansSet::GetNumPolygons | ( | RtUlong * | pdwNumPolygons | ) |

GetNumPolygons

Return total number of input polygons.

Parameters:

  | pdwNumPolygons | [out, retval] Number of polygons.

Returns:
  S_OK if succeeded.

HRESULT IRfBooleansSet::GetTrianglePolygon | ( | RtUlong | dwTriangle,
|  | RtUlong * | pdwPolygon |
| ) |  |  |

GetTrianglePolygon

Get polygon index for provided triangle.

Parameters:

  | dwTriangle | [in] Triangle for which polygon index is requested.
  | pdwPolygon | [out, retval] Filled with polygon index.

Returns:
  S_OK if succeeded.

HRESULT IRfBooleansSet::InvertGeometry | ( |  | ) |

InvertGeometry

Invert normals and trpolygon winding for whole geometry.

HRESULT IRfBooleansSet::Intersect | ( |  | ) |

Intersect

Intersect geometry together.

- Call after adding all meshes.
- After calling intersect, call CreateComponents to create components and CreatePolygons to reconstruct triangle polygon edges.

HRESULT IRfBooleansSet::CreateComponents | ( |  | ) |

CreateComponents

Create components from intersected geometry.Method intersects together all meshes added using AddMesh.

HRESULT IRfBooleansSet::CreatePolygons | ( |  | ) |

CreatePolygons

Reconstruct polygon boundaries.

HRESULT IRfBooleansSet::CleanupRemovedGeometry | ( |  | ) |

CleanupRemovedGeometry

Remove geometry marked for removing; update data streams.

HRESULT IRfBooleansSet::GetNumComponents | ( | RtUlong * | pdwNumComponents | ) |

GetNumComponents

Get number of intersected components.

Parameters:

  | pdwNumComponents | [out, retval] Filled with components count.

Returns:
  S_OK if succeeded.

HRESULT IRfBooleansSet::GetComponentTriangleCount | ( | RtUlong | dwComponentId,
|  | RtUlong * | pdwNumTriangles |
| ) |  |  |

GetComponentTriangleCount

Get number of triangles for specified component.

Parameters:

  | dwComponentId | [in] Component ID.
  | pdwNumTriangles | [out, retval] Number of triangles within component.

Returns:
  S_OK if succeeded.

HRESULT IRfBooleansSet::RemoveComponent | ( | RtUlong | dwComponentIndex | ) |

RemoveComponent

Mark all component triangles for removal. Physicaly remove geometry by calling CleanupRemovedGeometry after removing all components.

Parameters:

  | dwComponentIndex | [in] Component ID to mark for removing.

Returns:
  S_OK if succeeded.

HRESULT IRfBooleansSet::GetMesh | ( | IRdMesh ** | ppMesh | ) |

GetMesh

Create mesh.

Parameters:

  | ppMesh | [out, retval] Filled with created mesh.

Returns:
  S_OK if succeeded.

HRESULT IRfBooleansSet::CreateGeometryGroup | ( | RtUlong * | pGroupId | ) |

CreateGeometryGroup

Create geometry group.

Parameters:

  | pGroupId | [out, retval] Create new geometry group.

Returns:
  id of new geometry group.

HRESULT IRfBooleansSet::AddMeshWithMaterialInfo | ( | IRdMesh * | pMesh,
|  | RtMatrixf & | matrix,
|  | RtUlong | ulIndex,
|  | RtMaterialIndexTranslation * | pLookupTable,
|  | RtUlong | dwLookupCount |
| ) |  |  |

AddMeshWithMaterialInfo

Adds mesh with material lookup table. pTranslations array specifies lookup table for translating mesh material indices.

Parameters:

  | pMesh | [in] Mesh to add.
  | matrix | [in] Mesh world transform.
  | index | [in] Geometry group. See AddMesh for more info.
  | pTranslations | [in] Material lookup table.
  | dwLookupCount | [in] Number of entries in lookup table.

HRESULT IRfBooleansSet::CenterAndScaleGeometry | ( |  | ) |

CenterAndScaleGeometry

Centers and scales geometry to improve float point calculations.

HRESULT IRfBooleansSet::CenterAndScaleGeometryBack | ( |  | ) |

CenterAndScaleGeometryBack

Performs inverse scaling of geometry after operation.

HRESULT IRfBooleansSet::SetQuadMode | ( | RtBool | bQuadMode | ) |

SetQuadMode

Sets the status of quad mode.

Parameters:

  | bQuadMode | [in] Set to true to enable quat mode

HRESULT IRfBooleansSet::SetPrecision | ( | RtFloat | fPrecision | ) |

SetPrecision

Parameters:

  | fPrecision | [in] Set snapping distance.

HRESULT IRfBooleansSet::SetKeepMaterials | ( | RtBool | bKeepMaterials | ) |

SetKeepMaterials

Parameters:

  | bKeepMaterials | [in] Set to true if 2nd mesh materials should be kept or extracted from 1st mesh

HRESULT IRfBooleansSet::BooleanMeshes | ( | BSTR | bszOperation | ) |

BooleanMeshes

Intersect and filter meshes with specified operation.

To union 2 meshes, proceed as follows:

     spBoolSet->SetPrecision(fPrecision);
     spBoolSet->SetKeepMaterials(bKeepMat);
     spBoolSet->SetQuadMode(bQuadMode);
     spBoolSet->AddMesh(spMesh1, matrix1, CreateGeometryGroup());
     spBoolSet->AddMesh(spMesh2, matrix2, CreateGeometryGroup());
     spBoolSet->BooleanMeshes(L"Union");
     spBoolSet->GetMesh(&spResult);

Parameters:

  | bszOperation | [in] Union, Intersection, Subtraction, Cut, Merge, Add