Commit 3e456945 authored by George Zagaris's avatar George Zagaris
Browse files

ENH: Remove vtkPlane from class ivars

Restrict the scope of vtkPlane to the RequestData method instead
of storing it as a class ivar.

Change-Id: Ie1a8d2ed9d4f135d6a6f9c985254b465e3a56feb
parent 5bfba542
......@@ -58,7 +58,6 @@ vtkAMRCutPlane::vtkAMRCutPlane()
this->Normal[i] = 0.0;
}
this->Controller = vtkMultiProcessController::GetGlobalController();
this->Plane = NULL;
this->UseNativeCutter = 1;
}
......@@ -66,11 +65,6 @@ vtkAMRCutPlane::vtkAMRCutPlane()
vtkAMRCutPlane::~vtkAMRCutPlane()
{
this->blocksToLoad.clear();
if( this->Plane != NULL )
{
this->Plane->Delete();
}
this->Plane = NULL;
}
//------------------------------------------------------------------------------
......@@ -131,10 +125,11 @@ int vtkAMRCutPlane::RequestInformation(
vtkOverlappingAMR::SafeDownCast(
input->Get(vtkCompositeDataPipeline::COMPOSITE_DATA_META_DATA()));
this->Plane = this->GetCutPlane( metadata );
assert( "Cut plane is NULL" && (this->Plane != NULL) );
vtkPlane *cutPlane = this->GetCutPlane( metadata );
assert( "Cut plane is NULL" && (cutPlane != NULL) );
this->ComputeAMRBlocksToLoad(this->Plane, metadata);
this->ComputeAMRBlocksToLoad(cutPlane, metadata);
cutPlane->Delete();
}
this->Modified();
......@@ -182,10 +177,8 @@ int vtkAMRCutPlane::RequestData(
return 1;
}
if( this->Plane == NULL )
{
this->Plane = this->GetCutPlane( inputAMR );
}
vtkPlane *cutPlane = this->GetCutPlane( inputAMR );
assert("pre: cutPlane should not be NULL!" && (cutPlane != NULL) );
unsigned int blockIdx = 0;
unsigned int level = 0;
......@@ -201,7 +194,7 @@ int vtkAMRCutPlane::RequestData(
{
vtkCutter *myCutter = vtkCutter::New();
myCutter->SetInputData( grid );
myCutter->SetCutFunction( this->Plane );
myCutter->SetCutFunction( cutPlane );
myCutter->Update();
mbds->SetBlock( blockIdx, myCutter->GetOutput( ) );
++blockIdx;
......@@ -217,7 +210,7 @@ int vtkAMRCutPlane::RequestData(
{
if( grid != NULL )
{
this->CutAMRBlock( blockIdx, grid, mbds );
this->CutAMRBlock( cutPlane, blockIdx, grid, mbds );
++blockIdx;
}
else
......@@ -229,11 +222,13 @@ int vtkAMRCutPlane::RequestData(
} // END for all data
} // END for all levels
cutPlane->Delete();
return 1;
}
//------------------------------------------------------------------------------
void vtkAMRCutPlane::CutAMRBlock(
vtkPlane *cutPlane,
unsigned int blockIdx, vtkUniformGrid *grid, vtkMultiBlockDataSet *output )
{
assert("pre: multiblock output object is NULL!" && (output != NULL));
......@@ -242,7 +237,6 @@ void vtkAMRCutPlane::CutAMRBlock(
vtkUnstructuredGrid *mesh = vtkUnstructuredGrid::New();
vtkPoints *meshPts = vtkPoints::New();
meshPts->SetDataTypeToDouble();
// vtkCellArray *meshVerts = vtkCellArray::New();
vtkCellArray *cells = vtkCellArray::New();
// Maps points from the input grid to the output grid
......@@ -253,7 +247,7 @@ void vtkAMRCutPlane::CutAMRBlock(
for( ; cellIdx < grid->GetNumberOfCells(); ++cellIdx )
{
if( grid->IsCellVisible( cellIdx ) &&
this->PlaneIntersectsCell( grid->GetCell(cellIdx) ) )
this->PlaneIntersectsCell( cutPlane, grid->GetCell(cellIdx) ) )
{
extractedCells.push_back( cellIdx );
this->ExtractCellFromGrid(
......@@ -516,24 +510,25 @@ void vtkAMRCutPlane::InitializeCenter( double min[3], double max[3] )
}
//------------------------------------------------------------------------------
bool vtkAMRCutPlane::PlaneIntersectsCell( vtkCell *cell )
bool vtkAMRCutPlane::PlaneIntersectsCell( vtkPlane *pl, vtkCell *cell )
{
assert( "pre: plane is NULL" && (pl != NULL) );
assert( "pre: cell is NULL!" && (cell != NULL) );
return( this->PlaneIntersectsAMRBox( cell->GetBounds() ) );
return( this->PlaneIntersectsAMRBox( pl, cell->GetBounds() ) );
}
//------------------------------------------------------------------------------
bool vtkAMRCutPlane::PlaneIntersectsAMRBox( double bounds[6] )
bool vtkAMRCutPlane::PlaneIntersectsAMRBox(vtkPlane *pl, double bounds[6] )
{
assert( "pre: plane is NULL" && (this->Plane != NULL) );
assert( "pre: plane is NULL" && (pl != NULL) );
// Store A,B,C,D from the plane equation
double plane[4];
plane[0] = this->Plane->GetNormal()[0];
plane[1] = this->Plane->GetNormal()[1];
plane[2] = this->Plane->GetNormal()[2];
plane[3] = this->Plane->GetNormal()[0]*this->Plane->GetOrigin()[0] +
this->Plane->GetNormal()[1]*this->Plane->GetOrigin()[1] +
this->Plane->GetNormal()[2]*this->Plane->GetOrigin()[2];
plane[0] = pl->GetNormal()[0];
plane[1] = pl->GetNormal()[1];
plane[2] = pl->GetNormal()[2];
plane[3] = pl->GetNormal()[0]*pl->GetOrigin()[0] +
pl->GetNormal()[1]*pl->GetOrigin()[1] +
pl->GetNormal()[2]*pl->GetOrigin()[2];
return( this->PlaneIntersectsAMRBox( plane,bounds) );
}
......
......@@ -141,12 +141,12 @@ class VTK_AMR_EXPORT vtkAMRCutPlane : public vtkMultiBlockDataSetAlgorithm
// Description:
// Determines if a plane intersects with an AMR box
bool PlaneIntersectsAMRBox( double bounds[6] );
bool PlaneIntersectsAMRBox( vtkPlane* pl, double bounds[6] );
bool PlaneIntersectsAMRBox( double plane[4], double bounds[6] );
// Description:
// Determines if a plane intersects with a grid cell
bool PlaneIntersectsCell( vtkCell *cell );
bool PlaneIntersectsCell( vtkPlane *pl, vtkCell *cell );
// Description:
// A utility function that checks if the input AMR data is 2-D.
......@@ -155,6 +155,7 @@ class VTK_AMR_EXPORT vtkAMRCutPlane : public vtkMultiBlockDataSetAlgorithm
// Description:
// Applies cutting to an AMR block
void CutAMRBlock(
vtkPlane *cutPlane,
unsigned int blockIdx,
vtkUniformGrid *grid, vtkMultiBlockDataSet *dataSet );
......@@ -164,7 +165,6 @@ class VTK_AMR_EXPORT vtkAMRCutPlane : public vtkMultiBlockDataSetAlgorithm
bool initialRequest;
bool UseNativeCutter;
vtkMultiProcessController *Controller;
vtkPlane *Plane;
// BTX
std::vector<int> blocksToLoad;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment