Hi everyone,
I’m encountering an issue with RhinoBooleanUnion. I pass a valid list of Breps (checked for nulls), but I often get an Access Violation Exception (0xC0000005) inside tl.dll.
The inputs are generated via Offset and might be open Breps or have coincident faces. Here is the helper function I wrote:
ON_SimpleArray<ON_Brep\*> GetBooleanUnion(const ON_Brep\* brepA, const ON_Brep\* brepB)
{
// 1. Get the active document and tolerance
CRhinoDoc\* doc = RhinoApp().ActiveDoc();
if (!doc) return ON_SimpleArray<ON_Brep\*>(); // Safety check
double tolerance = doc->AbsoluteTolerance();
// 2. Output array to store the result
ON_SimpleArray<ON_Brep*> outputBreps;
// 3. Validation: Ensure inputs are not null
if (!brepA || !brepB)
{
RhinoApp().Print(L"Error: Invalid input Breps (NULL pointer).\n");
return outputBreps;
}
// 4. Prepare the Input List
// RhinoBooleanUnion requires a list (array) even if we only have 2 objects.
ON_SimpleArray<const ON_Brep*> inputBreps;
inputBreps.Append(brepA);
inputBreps.Append(brepB);
// 5. Execute Boolean Union
// bManifoldOnly = false (Set to false to avoid failures on open surfaces)
bool result = RhinoBooleanUnion(
inputBreps,
tolerance,
false, // bManifoldOnly
outputBreps
);
// 6. Check for success
if (result && outputBreps.Count() > 0)
{
// Success: The 'outputBreps' array now contains the united geometry.
// Note: The caller is responsible for managing the memory of the new Breps
// (e.g., adding them to the doc or deleting them).
return outputBreps;
}
// Failure: Return empty array
RhinoApp().Print(L"Boolean Union failed.\n");
return outputBreps;
}
Does anyone know why this crashes instead of just returning false? Should I be using RhinoCreateSolid or Join for open surfaces? Thanks!
