[vtkusers] Problem displaying scalar data on an unstructured (2d) grid
Ted Christiansen
ted at caept.com
Tue Aug 28 11:21:50 EDT 2001
Hello,
I am trying to display scalar data on an unstructured (2d) mesh. Here
is the code. Displaying the mesh works great. I am not sure if I am
using the right objects to display scalar data on the mesh, but it
compiles correctly. However, the as soon as I move the mouse in the
window after I turn on the display of the scalar data, vtkdll.dll has an
error. It is apparently compiled w/o DEBUG info so I can't tell where
the problem is.
Is there something obvious here that I am missing? Is there a good
example on how to do this? How can I determine the problem?
I appreciate any help you could offer. Thanks.
Ted
// store points
vtkPoints *m_vtkPoints;
m_vtkPoints = vtkPoints::New();
m_vtkPoints->Allocate(m_nodes.GetSize());
for (i=0;i<m_nodes.GetSize();i++) {
node = &m_nodes[i];
m_vtkPoints->InsertPoint(i, node->X(), node->Y(), node->Z());
}
// setup unstructured grid
// allocate memory for faces
vtkUnstructuredGrid *m_vtkUgrid;
m_vtkUgrid = vtkUnstructuredGrid::New();
m_vtkUgrid->Allocate(m_faces.GetSize());
for (i=0;i<m_faces.GetSize();i++) {
face = &m_faces[i];
switch(face->NodeCount()) {
case 3:
m_nodemap.Lookup(face->Node(0), index); tripts[0] = index;
m_nodemap.Lookup(face->Node(1), index); tripts[1] = index;
m_nodemap.Lookup(face->Node(2), index); tripts[2] = index;
m_vtkUgrid->InsertNextCell(VTK_TRIANGLE, 3, tripts);
break;
case 4:
m_nodemap.Lookup(face->Node(0), index); quadpts[0] = index;
m_nodemap.Lookup(face->Node(1), index); quadpts[1] = index;
m_nodemap.Lookup(face->Node(2), index); quadpts[2] = index;
m_nodemap.Lookup(face->Node(3), index); quadpts[3] = index;
m_vtkUgrid->InsertNextCell(VTK_QUAD, 4, quadpts);
break;
}
}
m_vtkUgrid->SetPoints(m_vtkPoints);
// create point data
vtkScalars *m_vtkContourData;
m_vtkContourData = vtkScalars::New();
// create lookup table
vtkLookupTable *m_vtkContourLookup;
m_vtkContourLookup = vtkLookupTable::New();
vtkDataSetMapper *m_vtkUgridMapper;
m_vtkUgridMapper = vtkDataSetMapper::New();
m_vtkUgridMapper->SetInput(m_vtkUgrid);
m_vtkUgridMapper->ImmediateModeRenderingOn();
vtkActor *m_vtkShadedActor;
m_vtkShadedActor = vtkActor::New();
m_vtkShadedActor->SetMapper(m_vtkUgridMapper);
m_vtkShadedActor->GetProperty()->SetColor(m_red, m_green, m_blue);
vtkActor *m_vtkWireframeActor;
m_vtkWireframeActor = vtkActor::New();
m_vtkWireframeActor->SetMapper(m_vtkUgridMapper);
m_vtkWireframeActor->GetProperty()->SetRepresentationToWireframe();
m_vtkWireframeActor->GetProperty()->SetColor(.5,.5,.5);
m_vtkProps->AddItem(m_vtkShadedActor);
m_vtkProps->AddItem(m_vtkWireframeActor);
// set range on lookup
m_vtkContourLookup->SetNumberOfColors(16);
m_vtkContourLookup->SetHueRange(0.0, 1.0);
m_vtkContourLookup->Build();
m_vtkUgridMapper->SetLookupTable(m_vtkContourLookup);
m_vtkUgridMapper->SetScalarRange(s->Min(), s->Max());
m_vtkUgrid->GetPointData()->SetScalars(m_vtkContourData);
m_vtkUgridMapper->ScalarVisibilityOn();
More information about the vtkusers
mailing list