<div dir="ltr">I am still unable to plot correct contours on a vtkHyperOctree. Again, as a simple test case I would like to plot lines of constant x on a unit square. For this, I have defined a 2D vtkHyperOctree of 16 cells (4x4). The grid is plotted correctly, but the contours are incorrect. Here is the my xml grid file (vto file):<br>
<br><?xml version="1.0"?><br><VTKFile type="HyperOctree" version="0.1" byte_order="LittleEndian" compressor="vtkZLibDataCompressor"><br> <HyperOctree Dimension="2" Size="1 1 0.5" Origin="0.5 0 0"><br>
<Topology><br> <DataArray type="Int32" Name="Topology" NumberOfTuples="21" format="ascii" RangeMin="0" RangeMax="1"><br> 0 0 1 1 1 1<br>
0 1 1 1 1 0<br> 1 1 1 1 0 1<br> 1 1 1<br> </DataArray><br> </Topology><br> <PointData Scalars="LinearFunction"><br> <DataArray type="Float64" Name="LinearFunction" format="ascii" RangeMin="0.125" RangeMax="0.875"><br>
0.125 0.375 0.125 0.375 0.625 0.875<br> 0.625 0.875 0.125 0.375 0.125 0.375<br> 0.625 0.875 0.625 0.875<br> </DataArray><br> </PointData><br> <CellData><br> </CellData><br>
</HyperOctree><br></VTKFile><br><br>I read in this file and render with the code below:<br><br>#include "vtkActor.h"<br>#include "vtkDataSetMapper.h"<br>#include "vtkPolyDataMapper.h"<br>
#include "vtkOutputWindow.h"<br>#include "vtkPointData.h"<br>#include "vtkCellData.h"<br>#include "vtkRenderer.h"<br>#include "vtkRenderWindow.h"<br>#include "vtkRenderWindowInteractor.h"<br>
#include "vtkHyperOctree.h"<br>#include "vtkXMLHyperOctreeReader.h"<br>#include "vtkProperty.h"<br>#include "vtkHyperOctreeContourFilter.h"<br>#include "vtkLookupTable.h"<br>
int main(int argc, char* argv[])<br>{<br> int NCONTOURS = 5;<br> vtkOutputWindow::GetInstance()->PromptUserOn();<br><br> // read in *.vto grid<br> vtkXMLHyperOctreeReader *xmlReader=vtkXMLHyperOctreeReader::New();<br>
xmlReader->SetFileName(argv[1]);<br> xmlReader->Update();<br><br> vtkHyperOctreeContourFilter *contour=vtkHyperOctreeContourFilter::New();<br> <br> double *range=xmlReader->GetOutput()->GetPointData()->GetScalars()->GetRange();<br>
contour->SetNumberOfContours(NCONTOURS);<br> contour->GenerateValues(NCONTOURS,range[0],range[1]);<br> contour->SetInputConnection(0,xmlReader->GetOutputPort(0));<br> contour->Update();<br> <br> vtkPolyDataMapper *smapper;<br>
smapper=vtkPolyDataMapper::New();<br><br> vtkLookupTable *lut3d = vtkLookupTable::New();<br> lut3d->SetHueRange(0.667,0.0);<br> smapper->SetInputConnection(0,contour->GetOutputPort(0)); <br> smapper->SetLookupTable(lut3d);<br>
smapper->SetScalarRange(xmlReader->GetOutput()->GetPointData()->GetScalars()->GetRange());<br><br> // setup actor<br> vtkActor *actor = vtkActor::New();<br> actor->SetMapper(smapper);<br><br> // render now<br>
vtkRenderer *ren = vtkRenderer::New();<br> ren->AddActor(actor);<br><br> vtkRenderWindow *renWin = vtkRenderWindow::New();<br> renWin->AddRenderer(ren);<br> vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();<br>
iren->SetRenderWindow(renWin);<br> renWin->SetFullScreen(1); <br> renWin->Render();<br> iren->Start();<br><br> // free memory here<br> xmlReader->Delete();<br> smapper->Delete();<br> actor->Delete();<br>
ren->Delete();<br> renWin->Delete();<br> iren->Delete();<br> return 0;<br>}<br><br>Using the above, the grid is rendered correctly but the contours are completely incorrect. I must have something fundamentally wrong here, and I am unable to find any documentation to point me in the right direction. I would be extremely grateful if anyone could help me figure this out.<br>
<br>Thanks,<br><br>-Rob<br>
</div>