[vtkusers] Symmetry for 3D models

Banks, Robert banks at wai.com
Wed Feb 24 12:29:24 EST 2010


Hi again,

Back to this I'm afraid.

So I tried using the translation filters to flip out the geometry of a 3D quarter symmetry model. Unfortunately, I realized that I can't just rotate the vtkPolyData as it also requires the data to be flipped. The correct way to do it is to mirror the data. I've tried to use the vtkReflectionFilter as this seems to do the correct job. However, I can't seem to render anything. The data I am manipulating is vtkPolyData which comes from a vtkGeometryFilter and has vtkPointData for the scalar values at the points.

If I use GetBounds() on the mirrored data that is produced, I get the correct geometry from the resultant data and if I use GetScalarRange() I also get the correct values within in the data structure.

Also, if I plot the vtkPolyData with a bounding outline, I see a box of the correct size, I'm just not able to render any of the color data, which is shown with no symmetry applied.....

I'm confused. Any help or obvious mistakes?

Thanks
Robbie

void SnapshotView3D::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 the source data to our new vtkAppendData
        vtkSmartPointer<vtkPolyData> currentData = pGridFilter->GetOutput();

        // Create translation to data for given symmetry
        vtkSmartPointer<vtkPolyData> pMirroredDataX = vtkSmartPointer<vtkPolyData>::New();
        vtkSmartPointer<vtkPolyData> pMirroredDataY = vtkSmartPointer<vtkPolyData>::New();
        vtkSmartPointer<vtkPolyData> pMirroredDataZ = vtkSmartPointer<vtkPolyData>::New();

        if(xFlipped){
                // Apply translation filter to data for given symmetry
                vtkSmartPointer<vtkReflectionFilter> pReflectFilterX = vtkSmartPointer<vtkReflectionFilter>::New();
                pReflectFilterX->SetInput(currentData);
                pReflectFilterX->SetPlaneToXMin();
                pReflectFilterX->CopyInputOn();
                pReflectFilterX->Update();

                pMirroredDataX->DeepCopy(pReflectFilterX->GetOutput());
        }

        if(yFlipped){
                // Apply translation filter to data for given symmetry
                vtkSmartPointer<vtkReflectionFilter> pReflectFilterY = vtkSmartPointer<vtkReflectionFilter>::New();
                if(xFlipped) pReflectFilterY->SetInput(pMirroredDataX);
                else pReflectFilterY->SetInput(currentData);
                pReflectFilterY->SetPlaneToYMin();
                pReflectFilterY->CopyInputOn();
                pReflectFilterY->Update();

                pMirroredDataY->DeepCopy(pReflectFilterY->GetOutput());
        }


        if(zFlipped){
                // Apply translation filter to data for given symmetry
                vtkSmartPointer<vtkReflectionFilter> pReflectFilterZ = vtkSmartPointer<vtkReflectionFilter>::New();
                if(xFlipped) pReflectFilterZ->SetInput(pMirroredDataX);
                else if(xFlipped && yFlipped) pReflectFilterZ->SetInput(pMirroredDataY);
                else pReflectFilterZ->SetInput(currentData);
                pReflectFilterZ->SetInput(currentData);
                pReflectFilterZ->SetPlaneToZMin();
                pReflectFilterZ->CopyInputOn();
                pReflectFilterZ->Update();

                pMirroredDataZ->DeepCopy(pReflectFilterZ->GetOutput());
        }

        vtkSmartPointer<vtkPolyData> pFinalData = vtkSmartPointer<vtkPolyData>::New();
        if(!xFlipped && !yFlipped && !zFlipped) pFinalData = currentData;
        else if(xFlipped && !yFlipped && !zFlipped) pFinalData = pMirroredDataX;
        else if(!xFlipped && yFlipped && !zFlipped) pFinalData = pMirroredDataY;
        else if(xFlipped && yFlipped && !zFlipped) pFinalData = pMirroredDataY;
        else if(!xFlipped && !yFlipped && zFlipped) pFinalData = pMirroredDataZ;
        else if(xFlipped && !yFlipped && zFlipped) pFinalData = pMirroredDataZ;
        else if(!xFlipped && yFlipped && zFlipped) pFinalData = pMirroredDataZ;
        else if(xFlipped && yFlipped && zFlipped) pFinalData = pMirroredDataZ;

        // Remap the data for display
        pMapper->SetInput(pFinalData);

        // Add Mapper to Actor
        pGeometryActor->SetMapper(pMapper);

        // Reset camera
        pRenderer->ResetCamera();
        pRenderer->GetRenderWindow()->Render();
}


Robbie Banks



---------------------------------------------------------------------------------------------------
Weidlinger Associates, Inc. made the following annotations.

“This message and any attachments are solely for the intended recipient and may contain confidential or privileged information. If you are not the intended recipient, any disclosure, copying, use, or distribution of the information included in this message and any attachments is prohibited. If you have received this communication in error, please notify us by reply e-mail and immediately and permanently delete this message and any attachments. Thank you.”

“Please consider our environment before printing this email.”


More information about the vtkusers mailing list