Hi,<br><br>I've been trying for a couple of days to draw an Unstructured Grid of vtkTetra points that I was previously drawing using volume render, but now want to draw using "normal" rendering because I want to be able to use the VRML exporation functionality. I've tried a lot of things, but the simplest thing (that I don't understand why it doesn't work) is the following code, which draws absolutely nothing. I'm confident that the rendering code is correct, because if I replace the visualization pipeline code with the "combxyz.bin", "combq.bin" vtkPLOT3DReader to vtkContourFilter example (i forgot the filename), I see the graph appear. Clearly what I'm doing doesn't work, but it would help me learn VTK if someone would explain what my code ACTUALLY does in the background (and hence why it fails):<br>
<br>=== start of code ===<br><br> // Create the UNstructured grid for the 3D model<br> vtkUnstructuredGrid *ugrid = vtkUnstructuredGrid::New();<br> vtkPoints *tetraPoints = vtkPoints::New();<br> vtkDoubleArray *scalars = vtkDoubleArray::New();<br>
<br> // generate 3D model<br> for (int p = 0; p < m_fusion->GetNumPoints(); p++)<br> {<br> vtkTetra *aTetra = vtkTetra::New();<br><br> CEvidencePoint *pt = m_fusion->GetPoint(p);<br> <br>
if (pt == NULL)<br> continue;<br><br> if (pt->evidence_for < 0.0)<br> pt->evidence_for = 0.0;<br><br> if (pt->evidence_for > 1.0)<br> pt->evidence_for = 1.0;<br>
<br> tetraPoints->InsertPoint((p * 4) + 0, (double)((pt->x * DEFAULT_X_WIDTH) / x_dim) + 0.0,<br> ((pt->y * DEFAULT_X_WIDTH) / x_dim) + 0.0,<br> ((pt->z * DEFAULT_X_WIDTH) / x_dim) + 0.0);<br>
scalars->InsertValue((p * 4) + 0, pt->evidence_for * 100);<br><br> tetraPoints->InsertPoint((p * 4) + 1, (double)((pt->x * DEFAULT_X_WIDTH) / x_dim) + 1.0,<br> ((pt->y * DEFAULT_X_WIDTH) / x_dim) + 0.0,<br>
((pt->z * DEFAULT_X_WIDTH) / x_dim) + 0.0);<br> scalars->InsertValue((p * 4) + 1, pt->evidence_for * 100);<br><br> tetraPoints->InsertPoint((p * 4) + 2, (double)((pt->x * DEFAULT_X_WIDTH) / x_dim) + 0.5,<br>
((pt->y * DEFAULT_X_WIDTH) / x_dim) + 1.0,<br> ((pt->z * DEFAULT_X_WIDTH) / x_dim) + 0.0);<br> scalars->InsertValue((p * 4) + 2, pt->evidence_for * 100);<br><br> tetraPoints->InsertPoint((p * 4) + 3, (double)((pt->x * DEFAULT_X_WIDTH) / x_dim) + 0.5,<br>
((pt->y * DEFAULT_X_WIDTH) / x_dim) + 0.5,<br> ((pt->z * DEFAULT_X_WIDTH) / x_dim) + 1.0);<br> scalars->InsertValue((p * 4) + 3, pt->evidence_for * 100);<br><br> for (int i = 0; i < 4; i++)<br>
(aTetra->GetPointIds())->InsertId(i, (p * 4) + i);<br><br> // add voxel to the list<br> ugrid->InsertNextCell(aTetra->GetCellType(), aTetra->GetPointIds());<br> <br> ugrid->SetPoints(tetraPoints);<br>
(ugrid->GetPointData())->SetScalars(scalars);<br><br> aTetra->Delete();<br> }<br><br> // transform to poly data<br> vtkUnstructuredGridGeometryFilter *ugrid_to_poly = vtkUnstructuredGridGeometryFilter::New();<br>
ugrid_to_poly->SetInput(ugrid);<br> ugrid_to_poly->Update();<br><br> vtkPolyDataNormals *normals = vtkPolyDataNormals::New();<br> normals->SetInputConnection(ugrid_to_poly->GetOutputPort());<br> normals->SetFeatureAngle(45.0);<br>
<br> vtkPolyDataMapper *mapper = vtkPolyDataMapper::New();<br> mapper->ScalarVisibilityOn();<br> mapper->SetInputConnection(normals->GetOutputPort());<br> mapper->SetScalarRange(0.0, 1500.0);<br> mapper->SetScalarModeToUsePointData();<br>
mapper->ColorByArrayComponent("Velocity Magnitude", 0.0);<br><br> vtkActor *graph = vtkActor::New();<br> <br> graph->SetMapper(mapper);<br> graph->SetNumberOfCloudPoints(1000.0);<br><br>
this->Props->AddItem(graph);<br><br>== end of code ==<br><br>I can also confirm that there ARE points of data (m_fusion->GetNumPoints() > 0) because the exact same code was correctly generating my unstructured grid when it was rendered using volume rendering.<br>
<br>I also tried without the vtkPolyDataNormals (not sure why it's even there anyway), and I get some assert on a ComputeBounds() somewhere in the rendering code.<br><br>Thanks,<br>Simon<br>