#include "vtkCellArray.h"
#include "vtkPointData.h"
#include "vtkCellData.h"
-//#include "vtkDataSetSurfaceFilter.h"
#include <math.h>
int vtkElevationSurfaceFilter::FillInputPortInformation(
int vtkNotUsed(port), vtkInformation* info)
{
- info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkPointSet");
+ info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkPolyData");
return 1;
}
int vtkElevationSurfaceFilter::RequestData(vtkInformation *request,
vtkInformationVector **input, vtkInformationVector *output)
{
- vtkPointSet *psIn = vtkPointSet::SafeDownCast(
+ vtkPolyData *pdIn = vtkPolyData::SafeDownCast(
input[0]->GetInformationObject(0)->Get(vtkDataObject::DATA_OBJECT()));
- //vtkPolyData *psIn = vtkPolyData::SafeDownCast(
- // input[0]->GetInformationObject(0)->Get(vtkDataObject::DATA_OBJECT()));
-
- /*vtkSmartPointer<vtkDataSetSurfaceFilter> surfaceFilter = vtkSmartPointer<vtkDataSetSurfaceFilter>::New();
- surfaceFilter->SetInput(psIn);
- vtkPolyData* psIn = vtkPolyData::SafeDownCast(surfaceFilter->GetOutput());*/
-
vtkUnstructuredGrid *usgOut = vtkUnstructuredGrid::SafeDownCast(
output->GetInformationObject(0)->Get(vtkDataObject::DATA_OBJECT()));
vtkDataArray* array = this->GetInputArrayToProcess(0, input);
- if(psIn == NULL || array == NULL || usgOut == NULL
+ if(pdIn == NULL || array == NULL || usgOut == NULL
|| array->GetNumberOfComponents() != 1)
{
vtkDebugMacro("vtkElevationSurfaceFilter no correctly configured");
double dir[3];
if(this->AutoDetectDirection)
{
- this->ComputeDirection(psIn, dir);
+ this->ComputeDirection(pdIn, dir);
}
else
{
dir[1] *= this->GetScaleFactor();
dir[2] *= this->GetScaleFactor();
- usgOut->Allocate(psIn->GetNumberOfCells());
+ usgOut->Allocate(pdIn->GetNumberOfCells());
vtkSmartPointer<vtkPoints> newPts = vtkSmartPointer<vtkPoints>::New();
usgOut->SetPoints(newPts);
- usgOut->GetPointData()->CopyAllocate(psIn->GetPointData(),
- 2*psIn->GetNumberOfPoints());
- usgOut->GetCellData()->CopyAllocate(psIn->GetCellData(),
- psIn->GetNumberOfCells());
+ usgOut->GetPointData()->CopyAllocate(pdIn->GetPointData(),
+ 2*pdIn->GetNumberOfPoints());
+ usgOut->GetCellData()->CopyAllocate(pdIn->GetCellData(),
+ pdIn->GetNumberOfCells());
- vtkIdType ncell = psIn->GetNumberOfCells();
+ vtkIdType ncell = pdIn->GetNumberOfCells();
vtkSmartPointer<vtkIdList> newIds = vtkSmartPointer<vtkIdList>::New();
vtkSmartPointer<vtkIdList> polyhedronIds = vtkSmartPointer<vtkIdList>::New();
- vtkSmartPointer<vtkIdList> neighbors = vtkSmartPointer<vtkIdList>::New();
for(vtkIdType cellId=0; cellId < ncell; cellId++)
{
- vtkCell* cell = psIn->GetCell(cellId);
+ vtkCell* cell = pdIn->GetCell(cellId);
if(cell->GetCellDimension() != 2)
continue;
double coords[VTK_CELL_SIZE*3];
for(int ptid = 0; ptid < oldPtsNumber; ptid++)
{
- psIn->GetPoint(oldIds->GetId(ptid), coords + 3*ptid);
+ pdIn->GetPoint(oldIds->GetId(ptid), coords + 3*ptid);
}
for(int ptid = 0; ptid < oldPtsNumber; ptid++)
{
coords[(ptid+oldPtsNumber)*3+1] = coords[ptid*3+1] + cellScalar*dir[1];
coords[(ptid+oldPtsNumber)*3+2] = coords[ptid*3+2] + cellScalar*dir[2];
}
- double minScalar;
- bool minInitialized = false;
- for(int ptid = 0; ptid < oldPtsNumber; ptid++)
- {
- neighbors->Initialize();
- psIn->GetPointCells(oldIds->GetId(ptid), neighbors);
- for(int neiCellIt = 0; neiCellIt < neighbors->GetNumberOfIds(); neiCellIt++)
- {
- vtkIdType neigCellId = neighbors->GetId(neiCellIt);
- if(neigCellId == cellId)
- continue;
- double neighborScalar = array->GetTuple1(neigCellId);
- if(neighborScalar != 0.0)
- {
- if(!minInitialized)
- minScalar = neighborScalar;
- else
- minScalar = (neighborScalar < minScalar ? neighborScalar : minScalar);
- minInitialized = true;
- }
- }
- if(!minInitialized)
- minScalar = 0.0;
- }
- for(int ptid = 0; ptid < oldPtsNumber; ptid++)
- {
- if(cellScalar != 0)
- {
- coords[(ptid)*3+0] = coords[ptid*3+0] + minScalar*dir[0];
- coords[(ptid)*3+1] = coords[ptid*3+1] + minScalar*dir[1];
- coords[(ptid)*3+2] = coords[ptid*3+2] + minScalar*dir[2];
- }
- else
- {
- coords[(ptid+oldPtsNumber)*3+0] = coords[ptid*3+0] + minScalar*dir[0];
- coords[(ptid+oldPtsNumber)*3+1] = coords[ptid*3+1] + minScalar*dir[1];
- coords[(ptid+oldPtsNumber)*3+2] = coords[ptid*3+2] + minScalar*dir[2];
- }
- }
for(int ptid=0; ptid<newPtsNumber; ptid++)
{
vtkIdType newId = newPts->InsertNextPoint(coords + 3*ptid);
newIds->SetId(ptid, newId);
- usgOut->GetPointData()->CopyData(psIn->GetPointData(),
+ usgOut->GetPointData()->CopyData(pdIn->GetPointData(),
oldIds->GetId(ptid % oldPtsNumber),
newIds->GetId(ptid));
}
}
}
newCellId = usgOut->InsertNextCell(newCellType, newIds);
- usgOut->GetCellData()->CopyData(psIn->GetCellData(),
+ usgOut->GetCellData()->CopyData(pdIn->GetCellData(),
cellId,
newCellId);
}
- usgOut->GetFieldData()->ShallowCopy(psIn->GetFieldData());
+ usgOut->GetFieldData()->ShallowCopy(pdIn->GetFieldData());
usgOut->Squeeze();
return 1;
}
-void vtkElevationSurfaceFilter::ComputeDirection(vtkPointSet* psIn, double *outDir)
+void vtkElevationSurfaceFilter::ComputeDirection(vtkPolyData* pdIn, double *outDir)
{
double tmp[2][3] = {{0, 0, 0}, {0, 0, 0}};
outDir[0] = outDir[1] = outDir[2] = 0;
- vtkPoints* pts = psIn->GetPoints();
+ vtkPoints* pts = pdIn->GetPoints();
vtkSmartPointer<vtkGenericCell> cell = vtkSmartPointer<vtkGenericCell>::New();
- for(vtkIdType cellId = 0; cellId < psIn->GetNumberOfCells(); cellId++)
+ for(vtkIdType cellId = 0; cellId < pdIn->GetNumberOfCells(); cellId++)
{
- psIn->GetCell(cellId, cell);
+ pdIn->GetCell(cellId, cell);
if(cell->GetCellDimension() != 2)
continue;