vtkVisItContourFilter.C 17.2 KB
Newer Older
hrchilds's avatar
hrchilds committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
/*=========================================================================

  Program:   Visualization Toolkit
  Module:    $RCSfile: vtkVisItContourFilter.cxx,v $
  Language:  C++
  Date:      $Date: 2002/02/22 21:16:54 $
  Version:   $Revision: 1.66 $

  Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen 
  All rights reserved.
  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.

     This software is distributed WITHOUT ANY WARRANTY; without even 
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
     PURPOSE.  See the above copyright notice for more information.

=========================================================================*/
#include "vtkVisItContourFilter.h"
#include <vtkAppendPolyData.h>
hrchilds's avatar
hrchilds committed
20
#include <vtkCellData.h>
hrchilds's avatar
hrchilds committed
21 22
#include <vtkContourFilter.h>
#include <vtkDataSet.h>
hrchilds's avatar
hrchilds committed
23
#include <vtkFloatArray.h>
hrchilds's avatar
hrchilds committed
24 25
#include <vtkInformation.h>
#include <vtkInformationVector.h>
hrchilds's avatar
hrchilds committed
26
#include <vtkObjectFactory.h>
hrchilds's avatar
hrchilds committed
27 28
#include <vtkPointData.h>
#include <vtkPolyData.h>
hrchilds's avatar
hrchilds committed
29
#include <vtkRectilinearGrid.h>
hrchilds's avatar
hrchilds committed
30
#include <vtkStreamingDemandDrivenPipeline.h>
hrchilds's avatar
hrchilds committed
31
#include <vtkStructuredGrid.h>
hrchilds's avatar
hrchilds committed
32 33
#include <vtkSurfaceFromVolume.h>
#include <vtkTriangulationTables.h>
hrchilds's avatar
hrchilds committed
34 35
#include <vtkUnstructuredGrid.h>

36 37
#include <vtkCreateTriangleHelpers.h>

hrchilds's avatar
hrchilds committed
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
#include <math.h>
#include <vector>


vtkStandardNewMacro(vtkVisItContourFilter);

vtkVisItContourFilter::vtkVisItContourFilter()
{
  this->CellList = NULL;
  this->CellListSize = 0;
  this->Isovalue = 0.;
}

vtkVisItContourFilter::~vtkVisItContourFilter()
{
}

55
void vtkVisItContourFilter::SetCellList(const vtkIdType *cl, vtkIdType size)
hrchilds's avatar
hrchilds committed
56 57 58 59 60
{
    this->CellList = cl;
    this->CellListSize = size;
}

hrchilds's avatar
hrchilds committed
61 62 63 64
int vtkVisItContourFilter::RequestData(
  vtkInformation *request,
  vtkInformationVector **inputVector,
  vtkInformationVector *outputVector)
hrchilds's avatar
hrchilds committed
65
{
hrchilds's avatar
hrchilds committed
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
    vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
    vtkDataSet *input = vtkDataSet::SafeDownCast(
      inInfo->Get(vtkDataObject::DATA_OBJECT()));

    if (!input)
    {
        return 0;
    }

    vtkInformation *outInfo = outputVector->GetInformationObject(0);
    vtkPolyData *output = vtkPolyData::SafeDownCast(
      outInfo->Get(vtkDataObject::DATA_OBJECT()));

    if (!output)
    {
        return 0;
    }
hrchilds's avatar
hrchilds committed
83 84 85 86

    int do_type = input->GetDataObjectType();
    if (do_type == VTK_RECTILINEAR_GRID)
    {
hrchilds's avatar
hrchilds committed
87
        return RectilinearGridExecute(input, output);
hrchilds's avatar
hrchilds committed
88 89 90
    }
    else if (do_type == VTK_STRUCTURED_GRID)
    {
hrchilds's avatar
hrchilds committed
91
        return StructuredGridExecute(input, output);
hrchilds's avatar
hrchilds committed
92 93 94
    }
    else if (do_type == VTK_UNSTRUCTURED_GRID)
    {
hrchilds's avatar
hrchilds committed
95
        return UnstructuredGridExecute(input, output);
hrchilds's avatar
hrchilds committed
96 97 98
    }
    else
    {
hrchilds's avatar
hrchilds committed
99
        return GeneralExecute(input, output);
hrchilds's avatar
hrchilds committed
100 101 102 103
    }
}


104
vtkDataArray *
hrchilds's avatar
hrchilds committed
105
vtkVisItContourFilter::GetPointScalars(vtkDataSet *in_ds)
hrchilds's avatar
hrchilds committed
106 107 108 109 110 111 112 113 114 115 116 117 118 119
{
    vtkDataArray *arr = in_ds->GetPointData()->GetScalars();
    if (arr == NULL)
    {
        vtkErrorMacro( << "No scalar point data.");
        return NULL;
    }

    if (arr->GetNumberOfComponents() != 1)
    {
        vtkErrorMacro( << "Scalar point data is not really scalar.");
        return NULL;
    }

120
    return arr;
hrchilds's avatar
hrchilds committed
121 122
}

123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210
// ****************************************************************************
// Class: IsoDistanceFunction
//
// Purpose:
//   This functor computes a distance function as something of a callback
//   to vtkStructuredCreateTriangles.
//
// Notes:      
//
// Programmer: Brad Whitlock
// Creation:   Mon Mar 12 17:10:44 PDT 2012
//
// Modifications:
//   
// ****************************************************************************

template <typename T>
class IsoDistanceFunction
{
public:
    IsoDistanceFunction(const int *pt_dims, vtkDataArray *v, T iso) : 
        var((const T *)v->GetVoidPointer(0)), Isovalue(iso)
    {
        ptstrideY = (vtkIdType)pt_dims[0];
        ptstrideZ = (vtkIdType)(pt_dims[0] * pt_dims[1]);
    }

    inline T operator()(vtkIdType cellI,   vtkIdType cellJ,   vtkIdType cellK,
                        vtkIdType iOffset, vtkIdType jOffset, vtkIdType kOffset) const
    {
        vtkIdType ptId = (cellI + iOffset) + (cellJ + jOffset) * ptstrideY +
                         (cellK + kOffset) * ptstrideZ;
        return var[ptId] - Isovalue;
    }

    inline T operator()(vtkIdType ptId) const
    {
        return var[ptId] - Isovalue;
    }

    const T  *var;
    T         Isovalue;
    vtkIdType ptstrideY, ptstrideZ; 
};

// ****************************************************************************
// Class: IsoDistanceFunction
//
// Purpose:
//   This functor computes a distance function as something of a callback
//   to vtkStructuredCreateTriangles.
//
// Notes:      Use GetTuple1 to access data.
//
// Programmer: Brad Whitlock
// Creation:   Mon Mar 12 17:10:44 PDT 2012
//
// Modifications:
//   
// ****************************************************************************

class GeneralIsoDistanceFunction
{
public:
    GeneralIsoDistanceFunction(const int *pt_dims, vtkDataArray *v, double iso) : 
        var(v), Isovalue(iso)
    {
        ptstrideY = (vtkIdType)pt_dims[0];
        ptstrideZ = (vtkIdType)(pt_dims[0] * pt_dims[1]);
    }

    inline double operator()(vtkIdType cellI,   vtkIdType cellJ,   vtkIdType cellK,
                        vtkIdType iOffset, vtkIdType jOffset, vtkIdType kOffset) const
    {
        vtkIdType ptId = (cellI + iOffset) + (cellJ + jOffset) * ptstrideY +
                         (cellK + kOffset) * ptstrideZ;
        return var->GetTuple1(ptId) - Isovalue;
    }

    inline double operator()(vtkIdType ptId) const
    {
        return var->GetTuple1(ptId) - Isovalue;
    }

    vtkDataArray *var;
    double        Isovalue;
    vtkIdType     ptstrideY, ptstrideZ; 
};
hrchilds's avatar
hrchilds committed
211 212 213 214 215 216 217 218 219

// ****************************************************************************
//  Modifications:
//
//    Brad Whitlock, Thu Aug 12 14:45:24 PST 2004
//    Added float casts to the pow() arguments so it builds on MSVC7.Net.
//
//    Hank Childs, Wed Aug 25 13:21:02 PDT 2004
//    Better checks for degenerate datasets.
hrchilds's avatar
hrchilds committed
220
//
221 222 223 224
//    Brad Whitlock, Mon Mar  5 16:43:50 PST 2012
//    Moved code into StructuredCreateTriangles and instantiated for float
//    and double. Move distance function into IsoDistanceFunction.
//
hrchilds's avatar
hrchilds committed
225
// ****************************************************************************
hrchilds's avatar
hrchilds committed
226

hrchilds's avatar
hrchilds committed
227
int
hrchilds's avatar
hrchilds committed
228 229
vtkVisItContourFilter::StructuredGridExecute(vtkDataSet *input, 
                                             vtkPolyData *output)
hrchilds's avatar
hrchilds committed
230
{
hrchilds's avatar
hrchilds committed
231
    vtkStructuredGrid *sg = (vtkStructuredGrid *)input;
hrchilds's avatar
hrchilds committed
232 233
    int pt_dims[3];
    sg->GetDimensions(pt_dims);
hrchilds's avatar
hrchilds committed
234
    if (pt_dims[0] <= 1 || pt_dims[1] <= 1 || pt_dims[2] <= 1)
hrchilds's avatar
hrchilds committed
235
    {
hrchilds's avatar
hrchilds committed
236
        return GeneralExecute(input, output);
hrchilds's avatar
hrchilds committed
237
    }
238
    vtkIdType          nCells = sg->GetNumberOfCells();
hrchilds's avatar
hrchilds committed
239 240 241
    vtkCellData       *inCD   = sg->GetCellData();
    vtkPointData      *inPD   = sg->GetPointData();

242 243
    vtkIdType ptSizeGuess = (this->CellList == NULL
                         ? (vtkIdType) pow(float(nCells), 0.6667f) * 5 + 100
hrchilds's avatar
hrchilds committed
244
                         : CellListSize*5 + 100);
hrchilds's avatar
hrchilds committed
245 246 247

    vtkSurfaceFromVolume sfv(ptSizeGuess);

248
    vtkDataArray *var = GetPointScalars(input);
hrchilds's avatar
hrchilds committed
249
    if (var == NULL)
hrchilds's avatar
hrchilds committed
250
        return 0;
hrchilds's avatar
hrchilds committed
251

252
    if(var->GetDataType() == VTK_FLOAT)
hrchilds's avatar
hrchilds committed
253
    {
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268
        vtkStructuredCreateTriangles<float, IsoDistanceFunction<float> >(
            sfv, this->CellList, this->CellListSize, nCells,
            pt_dims, IsoDistanceFunction<float>(pt_dims, var, (float)this->Isovalue));
    }
    else if(var->GetDataType() == VTK_DOUBLE)
    {
        vtkStructuredCreateTriangles<double, IsoDistanceFunction<double> >(
            sfv, this->CellList, this->CellListSize, nCells,
            pt_dims, IsoDistanceFunction<double>(pt_dims, var, this->Isovalue));
    }
    else
    {
        vtkStructuredCreateTriangles<double, GeneralIsoDistanceFunction>(
            sfv, this->CellList, this->CellListSize, nCells,
            pt_dims, GeneralIsoDistanceFunction(pt_dims, var, this->Isovalue));
hrchilds's avatar
hrchilds committed
269 270
    }

271
    sfv.ConstructPolyData(inPD, inCD, output, sg->GetPoints());
hrchilds's avatar
hrchilds committed
272
    return 1;
hrchilds's avatar
hrchilds committed
273 274
}

hrchilds's avatar
hrchilds committed
275 276 277 278 279 280 281 282
// ****************************************************************************
//  Modifications:
//
//    Brad Whitlock, Thu Aug 12 14:45:24 PST 2004
//    Added float casts to the pow() arguments so it builds on MSVC7.Net.
//
//    Hank Childs, Wed Aug 25 13:21:02 PDT 2004
//    Better checks for degenerate datasets.
hrchilds's avatar
hrchilds committed
283
//
284 285 286 287 288
//    Brad Whitlock, Mon Mar  5 16:43:50 PST 2012
//    Moved code into StructuredCreateTriangles and instantiated for float
//    and double. Pass coordinate data arrays directly to sfv so we don't
//    assume just float.
//
hrchilds's avatar
hrchilds committed
289
// ****************************************************************************
hrchilds's avatar
hrchilds committed
290

hrchilds's avatar
hrchilds committed
291
int 
hrchilds's avatar
hrchilds committed
292 293
vtkVisItContourFilter::RectilinearGridExecute(vtkDataSet *input,
                                              vtkPolyData *output)
hrchilds's avatar
hrchilds committed
294
{
hrchilds's avatar
hrchilds committed
295
    vtkRectilinearGrid *rg = (vtkRectilinearGrid *)input;
hrchilds's avatar
hrchilds committed
296 297
    int pt_dims[3];
    rg->GetDimensions(pt_dims);
hrchilds's avatar
hrchilds committed
298
    if (pt_dims[0] <= 1 || pt_dims[1] <= 1 || pt_dims[2] <= 1)
hrchilds's avatar
hrchilds committed
299
    {
hrchilds's avatar
hrchilds committed
300
        return GeneralExecute(input, output);
hrchilds's avatar
hrchilds committed
301 302
    }

303
    vtkIdType     nCells = rg->GetNumberOfCells();
hrchilds's avatar
hrchilds committed
304 305 306
    vtkCellData  *inCD   = rg->GetCellData();
    vtkPointData *inPD   = rg->GetPointData();

307 308 309
    vtkIdType ptSizeGuess = (this->CellList == NULL
                         ? (vtkIdType) pow(float(nCells), 0.6667f) * 5 + 100
                         : this->CellListSize*5 + 100);
hrchilds's avatar
hrchilds committed
310 311 312

    vtkSurfaceFromVolume sfv(ptSizeGuess);

313
    vtkDataArray *var = GetPointScalars(input);
hrchilds's avatar
hrchilds committed
314
    if (var == NULL)
hrchilds's avatar
hrchilds committed
315
        return 0;
hrchilds's avatar
hrchilds committed
316

317
    if(var->GetDataType() == VTK_FLOAT)
hrchilds's avatar
hrchilds committed
318
    {
319 320 321 322 323 324 325 326 327 328 329 330 331 332 333
        vtkStructuredCreateTriangles<float, IsoDistanceFunction<float> >(
            sfv, this->CellList, this->CellListSize, nCells,
            pt_dims, IsoDistanceFunction<float>(pt_dims, var, (float)this->Isovalue));
    }
    else if(var->GetDataType() == VTK_DOUBLE)
    {
        vtkStructuredCreateTriangles<double, IsoDistanceFunction<double> >(
            sfv, this->CellList, this->CellListSize, nCells,
            pt_dims, IsoDistanceFunction<double>(pt_dims, var, this->Isovalue));
    }
    else
    {
        vtkStructuredCreateTriangles<double, GeneralIsoDistanceFunction >(
            sfv, this->CellList, this->CellListSize, nCells,
            pt_dims, GeneralIsoDistanceFunction(pt_dims, var, this->Isovalue));
hrchilds's avatar
hrchilds committed
334 335
    }

336 337
    sfv.ConstructPolyData(inPD, inCD, output, pt_dims, 
        rg->GetXCoordinates(), rg->GetYCoordinates(), rg->GetZCoordinates());
hrchilds's avatar
hrchilds committed
338
    return 1;
hrchilds's avatar
hrchilds committed
339 340
}

hrchilds's avatar
hrchilds committed
341 342 343 344
// Modifications:
//   Brad Whitlock, Thu Aug 12 14:45:24 PST 2004
//   Added float casts to the pow() arguments so it builds on MSVC7.Net.
//
345 346 347
//   Brad Whitlock, Wed Apr 11 11:37:18 PDT 2012
//   When we can't contour a cell, insert faces too for polyhedral cells.
//
348 349 350
//   Kathleen Biagas, Fri Jan 25 16:04:46 PST 2013
//   Call Update on the filter, not the data object.
//
hrchilds's avatar
hrchilds committed
351 352
///////////////////////////////////////////////////////////////////////////////

hrchilds's avatar
hrchilds committed
353
int 
hrchilds's avatar
hrchilds committed
354 355
vtkVisItContourFilter::UnstructuredGridExecute(vtkDataSet *input,
                                               vtkPolyData *output)
hrchilds's avatar
hrchilds committed
356 357 358 359 360 361 362 363 364 365 366
{
    // The routine here is a bit trickier than for the Rectilinear or
    // Structured grids.  We want to contour an unstructured grid -- but that
    // could mean any cell type.  We only have triangulation tables for
    // the finite element zoo.  So the gameplan is to contour any of the
    // elements of the finite element zoo.  If there are more elements left
    // over, contour them using the conventional VTK filters.  Finally,
    // append together the contours from the zoo with the contours from the
    // non-zoo elements.  If all the elements are from the zoo, then just
    // contour them with no appending.

hrchilds's avatar
hrchilds committed
367
    vtkUnstructuredGrid *ug = (vtkUnstructuredGrid *)input;
hrchilds's avatar
hrchilds committed
368

369
    vtkIdType          nCells = ug->GetNumberOfCells();
hrchilds's avatar
hrchilds committed
370 371 372 373
    vtkPoints         *inPts  = ug->GetPoints();
    vtkCellData       *inCD   = ug->GetCellData();
    vtkPointData      *inPD   = ug->GetPointData();

374 375
    vtkIdType ptSizeGuess = (this->CellList == NULL
                         ? (vtkIdType) pow(float(nCells), 0.6667f) * 5 + 100
hrchilds's avatar
hrchilds committed
376
                         : CellListSize*5 + 100);
hrchilds's avatar
hrchilds committed
377 378 379 380 381 382 383 384

    vtkSurfaceFromVolume sfv(ptSizeGuess);

    vtkUnstructuredGrid *stuff_I_cant_contour = vtkUnstructuredGrid::New();
    stuff_I_cant_contour->SetPoints(ug->GetPoints());
    stuff_I_cant_contour->GetPointData()->ShallowCopy(ug->GetPointData());
    stuff_I_cant_contour->Allocate(nCells);

385 386
    vtkDataArray *arr = GetPointScalars(input);
    if (arr == NULL)
hrchilds's avatar
hrchilds committed
387
        return 0;
hrchilds's avatar
hrchilds committed
388 389 390

    int nToProcess = (CellList != NULL ? CellListSize : nCells);
    int numIcantContour = 0;
391
    for (vtkIdType i = 0 ; i < nToProcess ; i++)
hrchilds's avatar
hrchilds committed
392
    {
393
        vtkIdType  cellId = (CellList != NULL ? CellList[i] : i);
hrchilds's avatar
hrchilds committed
394
        int        cellType = ug->GetCellType(cellId);
395
        vtkIdType  npts;
hrchilds's avatar
hrchilds committed
396 397
        vtkIdType *pts;
        ug->GetCellPoints(cellId, npts, pts);
398 399
        const int *triangulation_table = NULL;
        const int *vertices_from_edges = NULL;
hrchilds's avatar
hrchilds committed
400 401 402 403 404
        int tt_step = 0;
        bool canContour = false;
        switch (cellType)
        {
          case VTK_TETRA:
405 406
            triangulation_table = (const int *) tetTriangulationTable;
            vertices_from_edges = (const int *) tetVerticesFromEdges;
hrchilds's avatar
hrchilds committed
407 408 409 410 411
            tt_step = 7;
            canContour = true;
            break;
 
          case VTK_PYRAMID:
412 413
            triangulation_table = (const int *) pyramidTriangulationTable;
            vertices_from_edges = (const int *) pyramidVerticesFromEdges;
hrchilds's avatar
hrchilds committed
414 415 416 417 418
            tt_step = 13;
            canContour = true;
            break;
 
          case VTK_WEDGE:
419 420
            triangulation_table = (const int *) wedgeTriangulationTable;
            vertices_from_edges = (const int *) wedgeVerticesFromEdges;
hrchilds's avatar
hrchilds committed
421 422 423 424 425
            tt_step = 13;
            canContour = true;
            break;
 
          case VTK_HEXAHEDRON:
426 427
            triangulation_table = (const int *) hexTriangulationTable;
            vertices_from_edges = (const int *) hexVerticesFromEdges;
hrchilds's avatar
hrchilds committed
428 429 430 431 432 433 434 435 436 437 438
            tt_step = 16;
            canContour = true;
            break;

          default:
            canContour = false;
            break;
        }
 
        if (canContour)
        {
439 440
            int tmp[3] = {0,0,0};
            if(arr->GetDataType() == VTK_FLOAT)
hrchilds's avatar
hrchilds committed
441
            {
442 443 444 445 446
                vtkUnstructuredCreateTriangles<float, IsoDistanceFunction<float> >(
                    sfv, cellId, pts, npts,
                    triangulation_table, vertices_from_edges, tt_step,
                    IsoDistanceFunction<float>(tmp, arr, (float)this->Isovalue)
                );
hrchilds's avatar
hrchilds committed
447
            }
448 449 450 451 452 453 454 455 456
            else if(arr->GetDataType() == VTK_DOUBLE)
            {
                vtkUnstructuredCreateTriangles<double, IsoDistanceFunction<double> >(
                    sfv, cellId, pts, npts,
                    triangulation_table, vertices_from_edges, tt_step,
                    IsoDistanceFunction<double>(tmp, arr, this->Isovalue)
                );
            }
            else
hrchilds's avatar
hrchilds committed
457
            {
458 459 460 461 462
                vtkUnstructuredCreateTriangles<double, GeneralIsoDistanceFunction>(
                    sfv, cellId, pts, npts,
                    triangulation_table, vertices_from_edges, tt_step,
                    GeneralIsoDistanceFunction(tmp, arr, this->Isovalue)
                );
hrchilds's avatar
hrchilds committed
463 464 465 466 467 468 469 470
            }
        }
        else
        {
            if (numIcantContour == 0)
                stuff_I_cant_contour->GetCellData()->
                                       CopyAllocate(ug->GetCellData(), nCells);

471 472 473 474 475 476 477 478 479
            if(cellType == VTK_POLYHEDRON)
            {
                vtkIdType nFaces, *facePtIds;
                ug->GetFaceStream(cellId, nFaces, facePtIds);
                stuff_I_cant_contour->InsertNextCell(cellType, npts, pts, 
                     nFaces, facePtIds);
            }
            else
                stuff_I_cant_contour->InsertNextCell(cellType, npts, pts);
hrchilds's avatar
hrchilds committed
480 481 482 483 484 485 486 487 488 489 490 491
            stuff_I_cant_contour->GetCellData()->
                            CopyData(ug->GetCellData(), cellId, numIcantContour);
            numIcantContour++;
        }
    }

    if (numIcantContour > 0)
    {
        vtkPolyData *not_from_zoo  = vtkPolyData::New();
        ContourDataset(stuff_I_cant_contour, not_from_zoo);
        
        vtkPolyData *just_from_zoo = vtkPolyData::New();
492
        sfv.ConstructPolyData(inPD, inCD, just_from_zoo, inPts);
hrchilds's avatar
hrchilds committed
493 494

        vtkAppendPolyData *appender = vtkAppendPolyData::New();
495 496
        appender->AddInputData(not_from_zoo);
        appender->AddInputData(just_from_zoo);
497
        appender->Update();
hrchilds's avatar
hrchilds committed
498 499 500 501 502 503 504 505

        output->ShallowCopy(appender->GetOutput());
        appender->Delete();
        not_from_zoo->Delete();
        just_from_zoo->Delete();
    }
    else
    {
506
        sfv.ConstructPolyData(inPD, inCD, output, inPts);
hrchilds's avatar
hrchilds committed
507 508 509
    }

    stuff_I_cant_contour->Delete();
hrchilds's avatar
hrchilds committed
510
    return 1;
hrchilds's avatar
hrchilds committed
511 512 513
}


hrchilds's avatar
hrchilds committed
514
int 
hrchilds's avatar
hrchilds committed
515
vtkVisItContourFilter::GeneralExecute(vtkDataSet *input, vtkPolyData* output)
hrchilds's avatar
hrchilds committed
516
{
hrchilds's avatar
hrchilds committed
517
    return ContourDataset(input, output);
hrchilds's avatar
hrchilds committed
518 519
}

hrchilds's avatar
hrchilds committed
520 521 522
int
vtkVisItContourFilter::ContourDataset(vtkDataSet *in_ds,
                                      vtkPolyData *out_pd)
hrchilds's avatar
hrchilds committed
523 524 525 526 527
{
    vtkContourFilter *contour = vtkContourFilter::New();
    contour->SetNumberOfContours(1);
    contour->SetValue(0, Isovalue);

528
    contour->SetInputData(in_ds);
hrchilds's avatar
hrchilds committed
529 530 531 532 533
    contour->Update();

    out_pd->ShallowCopy(contour->GetOutput());
    
    contour->Delete();
hrchilds's avatar
hrchilds committed
534
    return 1;
hrchilds's avatar
hrchilds committed
535 536 537 538 539 540 541 542
}

void vtkVisItContourFilter::PrintSelf(ostream& os, vtkIndent indent)
{
  this->Superclass::PrintSelf(os,indent);

  os << indent << "Isovalue: " << Isovalue << "\n";
}
hrchilds's avatar
hrchilds committed
543 544 545 546 547 548 549

int 
vtkVisItContourFilter::FillInputPortInformation(int, vtkInformation *info)
{
  info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkDataSet");
  return 1;
}