[vtkusers] Symmetry questions
Banksie
banks at wai.com
Mon Feb 8 17:17:24 EST 2010
Hi again,
I'm a lot closer than I was, but I'm getting something a bit strange. When I
apply symmetry to one axis, everything works fine, but when I move to having
two axes with symmetry, I get a Seg Fault when it comes to the
pRenderer->GetRenderWindow->Render();
Command at the end of the code. I've attached the code below. Am I doing
something silly?
Thanks again
Robbie
void SnapshotView::slotSymmetry(const bool & flip, const int & axis)
{
// Determine which axes are flipped
if(axis==xAxis) xFlipped=flip;
if(axis==yAxis) yFlipped=flip;
if(axis==zAxis) zFlipped=flip;
// Add a vtkTranform to apply symmetry to the dataset
vtkTransform * pTranslationX = vtkTransform::New();
vtkTransform * pTranslationY = vtkTransform::New();
vtkTransform * pTranslationZ = vtkTransform::New();
// Add a new vtkPolyDataMapper to deal with the new symmetrical data
vtkPolyDataMapper * pMapperSymm = vtkPolyDataMapper::New();
// Add a new vtkPolyData to deal with the new symmetrical data
vtkPolyData * pNewData = vtkPolyData::New();
// Add a new vtkAppendData to deal with the new symmetrical data
vtkAppendPolyData * pAppendData = vtkAppendPolyData::New();
// Create translation to data for given symmetry
pTranslationX->Translate(1.0, 0.0, 0.0);
pTranslationY->Translate(0.0, 1.0, 0.0);
pTranslationZ->Translate(0.0, 0.0, 1.0);
// Add the source data pAppendData->AddInput(source->GetOutput()); to our
new vtkAppendData
pAppendData->AddInput(source->GetOutput());
vtkPolyData * pNewSourceData = source->GetOutput();
if(xFlipped){
// Apply translation filter to data for given symmetry
vtkTransformPolyDataFilter * pTransformFilter1 =
vtkTransformPolyDataFilter::New();
pTransformFilter1->SetInput(pNewSourceData);
pTransformFilter1->SetTransform(pTranslationX);
pTransformFilter1->Update();
// Create a vtkPolyData set and add it to the vtkAppendPolyData for the
symmetrical data
vtkPolyData * pData1 = pTransformFilter1->GetOutput();
pAppendData->AddInput(pData1);
}
if(yFlipped){
// Apply translation filter to data for given symmetry
vtkPolyData * pTempData = pAppendData->GetOutput();
vtkTransformPolyDataFilter * pTransformFilter2 =
vtkTransformPolyDataFilter::New();
pTransformFilter2->SetInput(pTempData);
pTransformFilter2->SetTransform(pTranslationY);
pTransformFilter2->Update();
// Create a vtkPolyData set and add it to the vtkAppendPolyData for the
symmetrical data
vtkPolyData * pData1 = pTransformFilter2->GetOutput();
pAppendData->AddInput(pData1);
}
if(zFlipped){
// Apply translation filter to data for given symmetry
vtkPolyData * pTempData2 = pAppendData->GetOutput();
vtkTransformPolyDataFilter * pTransformFilter3 =
vtkTransformPolyDataFilter::New();
pTransformFilter3->SetInput(pTempData2);
pTransformFilter3->SetTransform(pTranslationZ);
pTransformFilter3->Update();
// Create a vtkPolyData set and add it to the vtkAppendPolyData for the
symmetrical data
vtkPolyData * pData1 = pTransformFilter3->GetOutput();
pAppendData->AddInput(pData1);
}
// // Finally copy all the appended data to a new vtkPolyData set
pNewSourceData = pAppendData->GetOutput();
// Remap the data for display
pMapperSymm->SetInput(pNewSourceData);
// Add Mapper to Actor
pActor->SetMapper(pMapperSymm);
// Add Actor to renderer
pRenderer->AddActor(pActor);
// Reset camera
pRenderer->ResetCamera();
pRenderer->GetRenderWindow()->Render();
pTranslationX->Delete();
pTranslationY->Delete();
pTranslationZ->Delete();
pAppendData->Delete();
pNewData->Delete();
pNewSourceData->Delete();
}
David Doria-2 wrote:
>
> Robbie,
>
> You can use vtkAppendPolyData (
> http://www.vtk.org/Wiki/VTK/Examples/CombinePolydata) to combine the data
> sets, then use only one mapper and one actor.
>
> Give it a try and let us know if it works out.
>
> Thanks,
>
> David
>
--
View this message in context: http://old.nabble.com/Symmetry-questions-tp27474607p27507220.html
Sent from the VTK - Users mailing list archive at Nabble.com.
More information about the vtkusers
mailing list