[vtkusers] Problem with SetRepresentation
Gerrick Bivins
gbivins at objectreservoir.com
Sat Jan 10 22:00:37 EST 2009
Hi Patrik,
Make sure to explicitly call Render on the vtkWindow after you make changes
to the pipeline, ie after calling SetRepresentation.
Gerrick
On 1/10/09 8:51 PM, "paddi.m at gmx.net" <paddi.m at gmx.net> wrote:
> Hi,
>
>
> I try to use different presentations for my actors inside VTK 5.2. As an
> interactor I use the wxVTKRenderWindowInteractor. It doesn't matter
> which representation I choose I always see the whole surface (like
> SetRepresentationToSurface). But if I check my actor before adding it to
> a renderer the vtkProperty has the right value :-(
>
> I know it should be simple - but I don't see an error...
>
> Thanks in advance,
>
> Patrik
>
> vtkProp* Im_VTKUtil::BuildMesh(Im_MeshPtr theMesh)
> {
> vtkProp* result = NULL;
> if (theMesh)
> {
> Im_OSUtils theHelper;
> std::string matName;
>
> vtkProperty* vtkMaterial = NULL;
> theMesh->CalcNormals();
> if (theMesh->GetMaterial())
> vtkMaterial = BuildMaterial(theMesh->GetMaterial(),
> theMesh->GetDisplayMode());
> // matName = theHelper.ToAscii(theMesh->GetMaterial()->GetName());
> long nbFaces = theMesh->NbFaces();
> long nbPoints = theMesh->NbVertices();
>
> Im_Vec3D v1;
>
> vtkPolyData *meshpoly = vtkPolyData::New();
> vtkPoints *points = vtkPoints::New();
> vtkCellArray *polys = vtkCellArray::New();
> // vtkFloatArray *scalars = vtkFloatArray::New();
>
> for (long i = 0; i < nbPoints; i++)
> {
> v1 = theMesh->GetVertex(i);
> points->InsertPoint(i, v1.X(), v1.Y(), v1.Z());
> }
>
> long i1, i2, i3;
>
> for (long i = 0; i < nbFaces; i++)
> {
> if (theMesh->GetFaceIndices(i1, i2, i3, i))
> {
> polys->InsertNextCell(3);
> polys->InsertCellPoint(i1);
> polys->InsertCellPoint(i2);
> polys->InsertCellPoint(i3);
> }
> }
> meshpoly->SetPoints(points);
> meshpoly->SetPolys(polys);
>
> vtkPolyDataNormals *normals = vtkPolyDataNormals::New();
> normals->SetInput(meshpoly);
> normals->SetFeatureAngle(60.0);
>
> vtkPolyDataMapper *meshMapper = vtkPolyDataMapper::New();
> meshMapper->SetInput(normals->GetOutput());
>
> /*
> vtkPainterPolyDataMapper * meshMapper = vtkPainterPolyDataMapper::New();
> meshMapper->SetInput(normals->GetOutput());
> */
> vtkActor *meshActor = vtkActor::New();
> meshActor->SetMapper(meshMapper);
> if (NULL != vtkMaterial)
> meshActor->SetProperty(vtkMaterial);
> result = meshActor;
> }
> return result;
> }
>
> vtkProperty* Im_VTKUtil::BuildMaterial(Im_MaterialPtr theMaterial, const
> Im_Entity3D::Im_EntityDisplayMode& theDisplayMode)
> {
> vtkProperty* result = NULL;
> if (theMaterial)
> {
> Im_Color tmpColor;
> result = vtkProperty::New();
>
> SetDisplayMode(result, theDisplayMode);
>
> tmpColor = theMaterial->GetAmbient()->GetPropertyValue();
> result->SetAmbientColor(tmpColor.GetRed(), tmpColor.GetGreen(),
> tmpColor.GetBlue());
>
> tmpColor = theMaterial->GetDiffuse()->GetPropertyValue();
> result->SetDiffuseColor(tmpColor.GetRed(), tmpColor.GetGreen(),
> tmpColor.GetBlue());
>
> tmpColor = theMaterial->GetSpecular()->GetPropertyValue();
> result->SetSpecularColor(tmpColor.GetRed(), tmpColor.GetGreen(),
> tmpColor.GetBlue());
>
> result->SetSpecularPower(theMaterial->GetShininess());
> result->SetOpacity(abs(1-theMaterial->GetTransparency()));
>
> }
> return result;
>
> }
>
> void Im_VTKUtil::SetDisplayMode(vtkProperty* theMaterial, const
> Im_Entity3D::Im_EntityDisplayMode& theDisplayMode)
> {
> if (NULL != theMaterial)
> {
> switch (theDisplayMode)
> {
> case Im_Entity3D::Im_Points:
> theMaterial->SetRepresentationToPoints();
> break;
> case Im_Entity3D::Im_Box:
> case Im_Entity3D::Im_WireFrame:
> theMaterial->SetRepresentationToWireframe();
> break;
> default:
> theMaterial->SetRepresentationToSurface();
> break;
> }
> }
> }
>
> Thanks
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
More information about the vtkusers
mailing list