[vtkusers] how to subsample and extract a VOI from a TIN

David, John john.david at uconn.edu
Thu Aug 16 23:07:55 EDT 2007


I modified a copy of demo_vtk_contour2D.cpp to subsample the implicit function and output the result as StructuredPoints.  I've been unable to figure out how to subsample and extract a VOI from a Delaunay triangulation.  Any pointers appreciated.

  Thanks and best regards

  EBo --

=============== modified code =================

    vtkQuadric *quadric = vtkQuadric::New();
    quadric->SetCoefficients(.5, 1, .2, 0, .1, 0, 0, .2, 0, 0);

    vtkSampleFunction *sample = vtkSampleFunction::New();
    sample->SetSampleDimensions(30, 30, 30);
    sample->SetImplicitFunction(quadric);
    sample->ComputeNormalsOff();

    /* subsample the data */
    vtkExtractVOI *extract = vtkExtractVOI::New();
    extract->SetInputConnection(sample->GetOutputPort());
    extract->SetVOI(0, 29, 0, 29, 15, 15);
    extract->SetSampleRate(1, 2, 3);

    /* convert the point data to cells */
    vtkPointDataToCellData *pd2cd = vtkPointDataToCellData::New();
    pd2cd->SetInputConnection(extract->GetOutputPort());
    pd2cd->Update();

    /* write out the cell data */
    vtkStructuredPointsWriter* writer1 = vtkStructuredPointsWriter::New();
    writer1->SetInputConnection( pd2cd->GetOutputPort() );
    writer1->SetFileName( "tst_grid_cell.vtk" );
    writer1->Write();



More information about the vtkusers mailing list