Version: 6.3.1
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions

vtkPVUpdateSuppressor Class Reference

#include <SMESH_vtkPVUpdateSuppressor.h>

Inheritance diagram for vtkPVUpdateSuppressor:
Inheritance graph
[legend]

Public Member Functions

 vtkTypeRevisionMacro (vtkPVUpdateSuppressor, vtkDataObjectAlgorithm)
void PrintSelf (ostream &os, vtkIndent indent)
virtual void ForceUpdate ()
 vtkSetMacro (UpdatePiece, int)
 vtkGetMacro (UpdatePiece, int)
 vtkSetMacro (UpdateNumberOfPieces, int)
 vtkGetMacro (UpdateNumberOfPieces, int)
void SetEnabled (int)
 vtkGetMacro (Enabled, int)
void SetUpdateTime (double utime)
 vtkGetMacro (UpdateTime, double)

Static Public Member Functions

static vtkPVUpdateSuppressorNew ()

Protected Member Functions

 vtkPVUpdateSuppressor ()
 ~vtkPVUpdateSuppressor ()
int RequestDataObject (vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
int RequestData (vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
virtual vtkExecutive * CreateDefaultExecutive ()

Protected Attributes

int UpdatePiece
int UpdateNumberOfPieces
double UpdateTime
bool UpdateTimeInitialized
int Enabled
vtkTimeStamp PipelineUpdateTime

Private Member Functions

 vtkPVUpdateSuppressor (const vtkPVUpdateSuppressor &)
void operator= (const vtkPVUpdateSuppressor &)

Detailed Description

Definition at line 28 of file SMESH_vtkPVUpdateSuppressor.h.


Constructor & Destructor Documentation

vtkPVUpdateSuppressor::vtkPVUpdateSuppressor ( ) [protected]

Definition at line 48 of file SMESH_vtkPVUpdateSuppressor.cxx.

References Enabled, UpdateNumberOfPieces, UpdatePiece, UpdateTime, and UpdateTimeInitialized.

{
  this->UpdatePiece = 0;
  this->UpdateNumberOfPieces = 1;

  this->UpdateTime = 0.0;
  this->UpdateTimeInitialized = false;

  this->Enabled = 1;

  //  vtkProcessModule* pm = vtkProcessModule::GetProcessModule();
  //
  //  if (pm)
  //    {
  //    this->UpdateNumberOfPieces = pm->GetNumberOfLocalPartitions();
  //    this->UpdatePiece = pm->GetPartitionId();
  //    }
}
vtkPVUpdateSuppressor::~vtkPVUpdateSuppressor ( ) [protected]

Definition at line 68 of file SMESH_vtkPVUpdateSuppressor.cxx.

{
}
vtkPVUpdateSuppressor.vtkPVUpdateSuppressor ( const vtkPVUpdateSuppressor ) [private]

Member Function Documentation

vtkExecutive * vtkPVUpdateSuppressor::CreateDefaultExecutive ( ) [protected, virtual]

Definition at line 161 of file SMESH_vtkPVUpdateSuppressor.cxx.

References Enabled, and New().

{
  vtkUpdateSuppressorPipeline* executive = vtkUpdateSuppressorPipeline::New();
  executive->SetEnabled(this->Enabled);
  return executive;
}
void vtkPVUpdateSuppressor::ForceUpdate ( ) [virtual]

Definition at line 101 of file SMESH_vtkPVUpdateSuppressor.cxx.

References PipelineUpdateTime, UpdateNumberOfPieces, UpdatePiece, UpdateTime, UpdateTimeInitialized, and vtkMyDebug.

{
  // Make sure that output type matches input type
  this->UpdateInformation();

  vtkDataObject *input = this->GetInput();
  if (input == 0)
    {
      vtkErrorMacro("No valid input.");
      return;
    }
  vtkDataObject *output = this->GetOutput();

  // int fixme; // I do not like this hack.  How can we get rid of it?
  // Assume the input is the collection filter.
  // Client needs to modify the collection filter because it is not
  // connected to a pipeline.
  vtkAlgorithm *source = input->GetProducerPort()->GetProducer();
  if (source && (source->IsA("vtkMPIMoveData")
      || source->IsA("vtkCollectPolyData") || source->IsA("vtkM2NDuplicate")
      || source->IsA("vtkM2NCollect")
      || source->IsA("vtkOrderedCompositeDistributor")
      || source->IsA("vtkClientServerMoveData")))
    {
      source->Modified();
    }

  vtkInformation* info = input->GetPipelineInformation();
  vtkStreamingDemandDrivenPipeline
      * sddp =
          vtkStreamingDemandDrivenPipeline::SafeDownCast(
                                                         vtkExecutive::PRODUCER()->GetExecutive(
                                                                                                info));
  if (sddp)
    {
      sddp->SetUpdateExtent(info, this->UpdatePiece,
                            this->UpdateNumberOfPieces, 0);
    }
  else
    {
      input->SetUpdatePiece(this->UpdatePiece);
      input->SetUpdateNumberOfPieces(this->UpdateNumberOfPieces);
      input->SetUpdateGhostLevel(0);
    } vtkMyDebug("ForceUpdate ");
  if (this->UpdateTimeInitialized)
    {
      info->Set(vtkCompositeDataPipeline::UPDATE_TIME_STEPS(),
                &this->UpdateTime, 1);
      vtkMyDebug(this->UpdateTime);
    } vtkMyDebug(endl);

  input->Update();
  // Input may have changed, we obtain the pointer again.
  input = this->GetInput();

  output->ShallowCopy(input);
  this->PipelineUpdateTime.Modified();
}
static vtkPVUpdateSuppressor* vtkPVUpdateSuppressor.New ( ) [static]

Referenced by CreateDefaultExecutive().

void vtkPVUpdateSuppressor.operator= ( const vtkPVUpdateSuppressor ) [private]
void vtkPVUpdateSuppressor::PrintSelf ( ostream &  os,
vtkIndent  indent 
)

Definition at line 222 of file SMESH_vtkPVUpdateSuppressor.cxx.

References Enabled, UpdateNumberOfPieces, UpdatePiece, and UpdateTime.

{
  this->Superclass::PrintSelf(os, indent);
  os << indent << "UpdatePiece: " << this->UpdatePiece << endl;
  os << indent << "UpdateNumberOfPieces: " << this->UpdateNumberOfPieces
      << endl;
  os << indent << "Enabled: " << this->Enabled << endl;
  os << indent << "UpdateTime: " << this->UpdateTime << endl;
}
int vtkPVUpdateSuppressor::RequestData ( vtkInformation *  request,
vtkInformationVector **  inputVector,
vtkInformationVector *  outputVector 
) [protected]

Definition at line 73 of file SMESH_ExtractGeometry.cxx.

References SMESH_ActorDef.New(), and ex13_hole1partial.x.

{
  // get the info objects
  vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
  vtkInformation *outInfo = outputVector->GetInformationObject(0);

  // get the input and ouptut
  vtkDataSet *input = vtkDataSet::SafeDownCast(
    inInfo->Get(vtkDataObject::DATA_OBJECT()));
  vtkUnstructuredGrid *output = vtkUnstructuredGrid::SafeDownCast(
    outInfo->Get(vtkDataObject::DATA_OBJECT()));

  vtkIdType ptId, numPts, numCells, i, cellId, newCellId, newId, *pointMap;
  vtkIdList *cellPts;
  vtkCell *cell;
  int numCellPts;
  vtkFloatingPointType *x;
  vtkFloatingPointType multiplier;
  vtkPoints *newPts;
  vtkIdList *newCellPts;
  vtkPointData *pd = input->GetPointData();
  vtkCellData *cd = input->GetCellData();
  vtkPointData *outputPD = output->GetPointData();
  vtkCellData *outputCD = output->GetCellData();
  int npts;
  numCells = input->GetNumberOfCells();
  numPts = input->GetNumberOfPoints();
  
  vtkDebugMacro(<< "Extracting geometry");

  if ( ! this->ImplicitFunction )
    {
    vtkErrorMacro(<<"No implicit function specified");
    return 0;
    }

  newCellPts = vtkIdList::New();
  newCellPts->Allocate(VTK_CELL_SIZE);

  if ( this->ExtractInside )
    {
    multiplier = 1.0;
    }
  else 
    {
    multiplier = -1.0;
    }

  // Loop over all points determining whether they are inside the
  // implicit function. Copy the points and point data if they are.
  //
  pointMap = new vtkIdType[numPts]; // maps old point ids into new
  for (i=0; i < numPts; i++)
    {
    pointMap[i] = -1;
    }

  output->Allocate(numCells/4); //allocate storage for geometry/topology
  newPts = vtkPoints::New();
  newPts->Allocate(numPts/4,numPts);
  outputPD->CopyAllocate(pd);
  outputCD->CopyAllocate(cd);
  vtkFloatArray *newScalars = NULL;
  
  if(myStoreMapping){
    myElemVTK2ObjIds.clear();
    myElemVTK2ObjIds.reserve(numCells);
    myNodeVTK2ObjIds.clear();
    myNodeVTK2ObjIds.reserve(numPts);
  }

  if ( ! this->ExtractBoundaryCells )
    {
    for ( ptId=0; ptId < numPts; ptId++ )
      {
      x = input->GetPoint(ptId);
      if ( (this->ImplicitFunction->FunctionValue(x)*multiplier) < 0.0 )
        {
        newId = newPts->InsertNextPoint(x);
        pointMap[ptId] = newId;
        myNodeVTK2ObjIds.push_back(ptId);
        outputPD->CopyData(pd,ptId,newId);
        }
      }
    }
  else
    {
    // To extract boundary cells, we have to create supplemental information
    if ( this->ExtractBoundaryCells )
      {
      vtkFloatingPointType val;
      newScalars = vtkFloatArray::New();
      newScalars->SetNumberOfValues(numPts);

      for (ptId=0; ptId < numPts; ptId++ )
        {
        x = input->GetPoint(ptId);
        val = this->ImplicitFunction->FunctionValue(x) * multiplier;
        newScalars->SetValue(ptId, val);
        if ( val < 0.0 )
          {
          newId = newPts->InsertNextPoint(x);
          pointMap[ptId] = newId;
          myNodeVTK2ObjIds.push_back(ptId);
          outputPD->CopyData(pd,ptId,newId);
          }
        }
      }
    }

  // Now loop over all cells to see whether they are inside implicit
  // function (or on boundary if ExtractBoundaryCells is on).
  //
  for (cellId=0; cellId < numCells; cellId++)
    {
    cell = input->GetCell(cellId);
    cellPts = cell->GetPointIds();
    numCellPts = cell->GetNumberOfPoints();

    newCellPts->Reset();
    if ( ! this->ExtractBoundaryCells ) //requires less work
      {
      for ( npts=0, i=0; i < numCellPts; i++, npts++)
        {
        ptId = cellPts->GetId(i);
        if ( pointMap[ptId] < 0 )
          {
          break; //this cell won't be inserted
          }
        else
          {
          newCellPts->InsertId(i,pointMap[ptId]);
          }
        }
      } //if don't want to extract boundary cells
    
    else //want boundary cells
      {
      for ( npts=0, i=0; i < numCellPts; i++ )
        {
        ptId = cellPts->GetId(i);
        if ( newScalars->GetValue(ptId) <= 0.0 )
          {
          npts++;
          }
        }
      if ( npts > 0 )
        {
        for ( i=0; i < numCellPts; i++ )
          {
          ptId = cellPts->GetId(i);
          if ( pointMap[ptId] < 0 )
            {
            x = input->GetPoint(ptId);
            newId = newPts->InsertNextPoint(x);
            pointMap[ptId] = newId;
            myNodeVTK2ObjIds.push_back(ptId);
            outputPD->CopyData(pd,ptId,newId);
            }
          newCellPts->InsertId(i,pointMap[ptId]);
          }
        }//a boundary or interior cell
      }//if mapping boundary cells
      
    if ( npts >= numCellPts || (this->ExtractBoundaryCells && npts > 0) )
      {
      newCellId = output->InsertNextCell(cell->GetCellType(),newCellPts);
      myElemVTK2ObjIds.push_back(cellId);
      outputCD->CopyData(cd,cellId,newCellId);
      }
    }//for all cells

  // Update ourselves and release memory
  //
  delete [] pointMap;
  newCellPts->Delete();
  output->SetPoints(newPts);
  newPts->Delete();
  
  if ( this->ExtractBoundaryCells )
    {
    newScalars->Delete();
    }

  output->Squeeze();
  return 1;
}
int vtkPVUpdateSuppressor::RequestDataObject ( vtkInformation *  request,
vtkInformationVector **  inputVector,
vtkInformationVector *  outputVector 
) [protected]

Definition at line 169 of file SMESH_vtkPVUpdateSuppressor.cxx.

{
  vtkInformation* inInfo = inputVector[0]->GetInformationObject(0);
  if (!inInfo)
    {
      return 0;
    }

  vtkDataObject *input = inInfo->Get(vtkDataObject::DATA_OBJECT());
  if (input)
    {
      // for each output
      for (int i = 0; i < this->GetNumberOfOutputPorts(); ++i)
        {
          vtkInformation* outInfo = outputVector->GetInformationObject(i);
          vtkDataObject *output = outInfo->Get(vtkDataObject::DATA_OBJECT());

          if (!output || !output->IsA(input->GetClassName()))
            {
              vtkDataObject* newOutput = input->NewInstance();
              newOutput->SetPipelineInformation(outInfo);
              newOutput->Delete();
              this->GetOutputPortInformation(i)->Set(
                                                     vtkDataObject::DATA_EXTENT_TYPE(),
                                                     newOutput->GetExtentType());
            }
        }
      return 1;
    }
  return 0;

}
void vtkPVUpdateSuppressor::SetEnabled ( int  enable)

Definition at line 84 of file SMESH_vtkPVUpdateSuppressor.cxx.

References Enabled.

{
  if (this->Enabled == enable)
    {
      return;
    }
  this->Enabled = enable;
  this->Modified();
  //  vtkUpdateSuppressorPipeline* executive =
  //    vtkUpdateSuppressorPipeline::SafeDownCast(this->GetExecutive());
  //  if (executive)
  //    {
  //    executive->SetEnabled(enable);
  //    }
}
void vtkPVUpdateSuppressor::SetUpdateTime ( double  utime)

Definition at line 73 of file SMESH_vtkPVUpdateSuppressor.cxx.

References UpdateTime, and UpdateTimeInitialized.

{
  this->UpdateTimeInitialized = true;
  if (this->UpdateTime != utime)
    {
      this->Modified();
      this->UpdateTime = utime;
    }
}
vtkPVUpdateSuppressor.vtkGetMacro ( UpdateNumberOfPieces  ,
int   
)
vtkPVUpdateSuppressor.vtkGetMacro ( UpdatePiece  ,
int   
)
vtkPVUpdateSuppressor.vtkGetMacro ( UpdateTime  ,
double   
)
vtkPVUpdateSuppressor.vtkGetMacro ( Enabled  ,
int   
)
vtkPVUpdateSuppressor.vtkSetMacro ( UpdateNumberOfPieces  ,
int   
)
vtkPVUpdateSuppressor.vtkSetMacro ( UpdatePiece  ,
int   
)
vtkPVUpdateSuppressor.vtkTypeRevisionMacro ( vtkPVUpdateSuppressor  ,
vtkDataObjectAlgorithm   
)

Field Documentation

vtkTimeStamp vtkPVUpdateSuppressor.PipelineUpdateTime [protected]

Definition at line 88 of file SMESH_vtkPVUpdateSuppressor.h.

Referenced by ForceUpdate().

Definition at line 81 of file SMESH_vtkPVUpdateSuppressor.h.

Referenced by ForceUpdate(), PrintSelf(), and vtkPVUpdateSuppressor().

Definition at line 80 of file SMESH_vtkPVUpdateSuppressor.h.

Referenced by ForceUpdate(), PrintSelf(), and vtkPVUpdateSuppressor().

Definition at line 84 of file SMESH_vtkPVUpdateSuppressor.h.

Referenced by ForceUpdate(), SetUpdateTime(), and vtkPVUpdateSuppressor().

Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS