BooleanOperationFilter crashes my application with : Access Violation Exception
Hello, I have an access violation exception with
This is the function that throw the exception
vtkSmartPointer<vtkPolyData> MeshesBuilderMock::booleanOperationIntersection(vtkSmartPointer<vtkPolyData> meshA, vtkSmartPointer<vtkPolyData> meshB)
{
auto booleanOperation = vtkSmartPointer<vtkBooleanOperationPolyDataFilter>::New();
booleanOperation->SetOperationToIntersection();
booleanOperation->SetInputData(0, meshA);
booleanOperation->SetInputData(1, meshB);
booleanOperation->Update();
return booleanOperation->GetOutput();
}
There are two STL files that I have created this way :
vtkSmartPointer<vtkPolyData> MeshesBuilderMock::getCube(double x, double y, double z, vtkSmartPointer<vtkTransform> transform)
{
auto cubeSource = vtkSmartPointer<vtkCubeSource>::New();
cubeSource->SetXLength(x);
cubeSource->SetYLength(y);
cubeSource->SetZLength(z);
auto triangleFilter = vtkSmartPointer<vtkTriangleFilter>::New();
triangleFilter->SetInputConnection(cubeSource->GetOutputPort());
triangleFilter->Update();
auto transformFilter = vtkSmartPointer<vtkTransformPolyDataFilter>::New();
transformFilter->SetInputConnection(triangleFilter->GetOutputPort());
transformFilter->SetTransform(transform);
transformFilter->Update();
return transformFilter->GetOutput();
}
TEST_METHOD(TestCubeAndCrossThatGoesTwoSideOutWithAppend)
{
auto translation1 = vtkSmartPointer<vtkTransform>::New();
translation1->Translate(0.0, 0.0, 1.0);
auto meshA = getCube(120, 120, 100, translation1);
Utils::writeSTLFile(meshA, "D:\\temp\\TestCudeAndCrossThatGoesOutBothSides\\meshA11.stl");
auto translation2 = vtkSmartPointer<vtkTransform>::New();
translation2->Translate(35.0, -35.0, 0.0);
auto cubeB1 = MeshesBuilderMock::getCube(60, 30, 100, translation2);
auto translation3 = vtkSmartPointer<vtkTransform>::New();
translation3->Translate(60.0, 0.0, 0.0);
auto cubeB2 = getCube(30, 60, 100.0005, translation3);
auto meshB = vtkSmartPointer<vtkAppendPolyData>::New();
meshB->AddInputData(cubeB1);
meshB->AddInputData(cubeB2);
meshB->Update();
Utils::writeSTLFile(meshB->GetOutput(), "D:\\temp\\TestCudeAndCrossThatGoesOutBothSides\\meshB11.stl");
/*** THE REST OF THE METHOD HERE**/
}
All commented functions crahes with access violation, the others not :
vtkSmartPointer<vtkPolyData> loopBoolean;
//loopBoolean = booleanOperationIntersection(meshA, meshB->GetOutput());
//Utils::writeSTLFile(loopBoolean, "D:\\temp\\TestCudeAndCrossThatGoesOutBothSides\\booleanOperationIntersectionAB11.stl");
loopBoolean = MeshesBuilderMock::booleanOperationIntersection(meshB->GetOutput(), meshA);
Utils::writeSTLFile(loopBoolean, "D:\\temp\\TestCudeAndCrossThatGoesOutBothSides\\booleanOperationIntersectionBA11.stl");
//loopBoolean = booleanOperationSubstraction(meshA, meshB->GetOutput());
//Utils::writeSTLFile(loopBoolean, "D:\\temp\\TestCudeAndCrossThatGoesOutBothSides\\booleanOperationSubstractionAB11.stl");
loopBoolean = MeshesBuilderMock::booleanOperationSubstraction(meshB->GetOutput(), meshA);
Utils::writeSTLFile(loopBoolean, "D:\\temp\\TestCudeAndCrossThatGoesOutBothSides\\booleanOperationSubstractionBA11.stl");
//loopBoolean = booleanOperationUnion(meshA, meshB->GetOutput());
//Utils::writeSTLFile(loopBoolean, "D:\\temp\\TestCudeAndCrossThatGoesOutBothSides\\booleanOperationUnionAB11.stl");
loopBoolean = booleanOperationUnion(meshB->GetOutput(), meshA);
Utils::writeSTLFile(loopBoolean, "D:\\temp\\TestCudeAndCrossThatGoesOutBothSides\\booleanOperationUnionBA11.stl");