Hello Marco,
Thanks for the reply! I applied the vtkTriangleFilter and the vtkCleanPolydata.
vtkSmartPointer input1;
vtkSmartPointer poly1;
vtkSmartPointer input2;
vtkSmartPointer poly2;
// Create a sphere
vtkSmartPointer sphereSource =
vtkSmartPointer::New();
sphereSource->SetCenter(0.0, 0.0, 0.0);
sphereSource->SetRadius(25.0);
// Make the surface smooth.
sphereSource->SetPhiResolution(50);
sphereSource->SetThetaResolution(50);
poly1 = sphereSource ->GetOutput();
//generation of cube source
vtkSmartPointer cubeSource =
vtkSmartPointer::New();
cubeSource->SetCenter(0.0, 0.0, 0.0);
cubeSource->SetXLength(50.0);
cubeSource->SetYLength(50.0);
cubeSource->SetZLength(50.0);
//cubeSource->Update();
poly2 = cubeSource->GetOutput(); //get PolyData
//-------------------------------------------------------------------------------------------------------------------------//
vtkSmartPointer tri1 =
vtkSmartPointer::New();
tri1->SetInputData(poly1);
vtkSmartPointer clean1 =
vtkSmartPointer::New();
clean1->SetInputConnection(tri1->GetOutputPort());
clean1->Update();
input1 = clean1->GetOutput();
vtkSmartPointer tri2 =
vtkSmartPointer::New();
tri2->SetInputData(poly2);
vtkSmartPointer clean2 =
vtkSmartPointer::New();
clean2->SetInputConnection(tri2->GetOutputPort());
clean2->Update();
input2 = clean2->GetOutput();
//input1 and input 2 mapper and actor
vtkSmartPointer input1Mapper =
vtkSmartPointer::New();
input1Mapper->SetInputData( input1 );
input1Mapper->ScalarVisibilityOff();
vtkSmartPointer input1Actor =
vtkSmartPointer::New();
input1Actor->SetMapper(input1Mapper);
input1Actor->GetProperty()->SetOpacity(0.4);
input1Actor->GetProperty()->SetColor(0.0, 1.0, 0.0);
vtkSmartPointer input2Mapper =
vtkSmartPointer::New();
input2Mapper->SetInputData(input2);
input2Mapper->ScalarVisibilityOff();
vtkSmartPointer input2Actor =
vtkSmartPointer::New();
input2Actor->SetMapper(input2Mapper);
input2Actor->GetProperty()->SetOpacity(0.4);
input2Actor->GetProperty()->SetColor(0.0, 0.501, 0.501); //color code yellow:(0,128,128)
vtkSmartPointer intersectionPolyDataFilter =
vtkSmartPointer::New();
intersectionPolyDataFilter->SetInputData( 0, input1);
intersectionPolyDataFilter->SetInputData( 1, input2);
intersectionPolyDataFilter->Update();
vtkSmartPointer intersectionMapper = vtkSmartPointer::New();
intersectionMapper->SetInputConnection( intersectionPolyDataFilter->GetOutputPort());
intersectionMapper->ScalarVisibilityOff();
vtkSmartPointer intersectionActor = vtkSmartPointer::New();
intersectionActor->SetMapper( intersectionMapper );
intersectionActor->GetProperty()->SetColor(0.0, 0.0, 1.0);
//code for renderer, renderwindow and renderwindow interactor
I am getting a log:: Can’t build OBB tree - no data available!
What can be done to get the filter working??
Best regards,
Anish