Salome HOME
Porting to VTK 6.
[modules/visu.git] / src / CONVERTOR / VISU_GaussMergeFilter.cxx
index 810cae8760b3d043201b86c29b35aae6bf735d2b..f3f7652090b2e19f6fa5db286d503b66f93f5386 100644 (file)
@@ -60,105 +60,57 @@ VISU_GaussMergeFilter::~VISU_GaussMergeFilter()
 }
 
 //------------------------------------------------------------------------------
-void VISU_GaussMergeFilter::SetGeometry(vtkDataSet *input)
+void VISU_GaussMergeFilter::SetGeometryConnection(vtkAlgorithmOutput *input)
 {
-  this->Superclass::SetInputData(input);
+  this->Superclass::SetInputConnection(input);
 }
 
 //------------------------------------------------------------------------------
-vtkDataSet *VISU_GaussMergeFilter::GetGeometry()
+void VISU_GaussMergeFilter::SetGeometryData(vtkDataSet *input)
 {
-  if (this->GetNumberOfInputConnections(0) < 1)
-    {
-    return NULL;
-    }
-  return vtkDataSet::SafeDownCast(
-    this->GetExecutive()->GetInputData(0, 0));
+  this->Superclass::SetInputData(input);
 }
 
 //------------------------------------------------------------------------------
-void VISU_GaussMergeFilter::SetScalars(vtkDataSet *input)
+void VISU_GaussMergeFilter::SetScalarsData(vtkDataSet *input)
 {
   this->SetInputData(1, input);
 }
 
 //------------------------------------------------------------------------------
-vtkDataSet *VISU_GaussMergeFilter::GetScalars()
+void VISU_GaussMergeFilter::SetScalarsConnection(vtkAlgorithmOutput *input)
 {
-  if (this->GetNumberOfInputConnections(1) < 1)
-    {
-    return NULL;
-    }
-  return vtkDataSet::SafeDownCast(
-    this->GetExecutive()->GetInputData(1, 0));
+  this->SetInputConnection(1, input);
 }
 
 //------------------------------------------------------------------------------
-void VISU_GaussMergeFilter::SetVectors(vtkDataSet *input)
+void VISU_GaussMergeFilter::SetVectorsData(vtkDataSet *input)
 {
   this->SetInputData(2, input);
 }
 
 //------------------------------------------------------------------------------
-vtkDataSet *VISU_GaussMergeFilter::GetVectors()
-{
-  if (this->GetNumberOfInputConnections(2) < 1)
-    {
-    return NULL;
-    }
-  return vtkDataSet::SafeDownCast(
-    this->GetExecutive()->GetInputData(2, 0));
-}
-
-//------------------------------------------------------------------------------
-void VISU_GaussMergeFilter::SetNormals(vtkDataSet *input)
-{
-  this->SetInputData(3, input);
-}
-
-//------------------------------------------------------------------------------
-vtkDataSet *VISU_GaussMergeFilter::GetNormals()
+void VISU_GaussMergeFilter::SetVectorsConnection(vtkAlgorithmOutput *input)
 {
-  if (this->GetNumberOfInputConnections(3) < 1)
-    {
-    return NULL;
-    }
-  return vtkDataSet::SafeDownCast(
-    this->GetExecutive()->GetInputData(3, 0));
+  this->SetInputConnection(2, input);
 }
 
 //------------------------------------------------------------------------------
-void VISU_GaussMergeFilter::SetTCoords(vtkDataSet *input)
+void VISU_GaussMergeFilter::SetNormals(vtkAlgorithmOutput *input)
 {
-  this->SetInputData(4, input);
+  this->SetInputConnection(3, input);
 }
 
 //------------------------------------------------------------------------------
-vtkDataSet *VISU_GaussMergeFilter::GetTCoords()
+void VISU_GaussMergeFilter::SetTCoords(vtkAlgorithmOutput *input)
 {
-  if (this->GetNumberOfInputConnections(4) < 1)
-    {
-    return NULL;
-    }
-  return vtkDataSet::SafeDownCast(
-    this->GetExecutive()->GetInputData(4, 0));
+  this->SetInputConnection(4, input);
 }
 
 //------------------------------------------------------------------------------
-void VISU_GaussMergeFilter::SetTensors(vtkDataSet *input)
+void VISU_GaussMergeFilter::SetTensors(vtkAlgorithmOutput *input)
 {
-  this->SetInputData(5, input);
-}
-
-//------------------------------------------------------------------------------
-vtkDataSet *VISU_GaussMergeFilter::GetTensors()
-{
-  if (this->GetNumberOfInputConnections(5) < 1)
-    {
-    return NULL;
-    }
-  return vtkDataSet::SafeDownCast(
-    this->GetExecutive()->GetInputData(5, 0));
+  this->SetInputConnection(5, input);
 }
 
 //------------------------------------------------------------------------------
@@ -204,10 +156,21 @@ VISU_GaussMergeFilter
               vtkInformationVector **theInputVector,
               vtkInformationVector *theOutputVector)
 {
-  if(vtkUnstructuredGrid *anInput = dynamic_cast<vtkUnstructuredGrid*>(this->GetInput())){
-    vtkPolyData *anOutput = dynamic_cast<vtkPolyData*>(this->GetOutput());
-    return ExecuteGauss(anInput,
-                        anOutput);
+  vtkInformation *inInfo0 = theInputVector[0]->GetInformationObject(0);
+  vtkInformation *inInfo1 = theInputVector[1]->GetInformationObject(0);
+  vtkInformation *outInfo = theOutputVector->GetInformationObject(0);
+
+  // get the input and output
+  vtkDataSet *anInput = vtkDataSet::SafeDownCast(inInfo0->Get(vtkDataObject::DATA_OBJECT()));
+  vtkDataSet *aScalars = theInputVector[1]->GetNumberOfInformationObjects() > 0 ?
+    vtkDataSet::SafeDownCast(inInfo1->Get(vtkDataObject::DATA_OBJECT())) : NULL;
+  vtkDataSet *anOutput = vtkDataSet::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT()));
+
+  if(vtkUnstructuredGrid *anInputUG = dynamic_cast<vtkUnstructuredGrid*>(this->GetInput())){
+    vtkPolyData *anOutputPD = dynamic_cast<vtkPolyData*>(this->GetOutput());
+    return ExecuteGauss(anInputUG,
+                        aScalars,
+                        anOutputPD);
   }
 
   return Superclass::RequestData(theRequest,
@@ -288,6 +251,7 @@ VISU_GaussMergeFilter
 bool 
 VISU_GaussMergeFilter
 ::ExecuteGauss(vtkUnstructuredGrid* theInput,
+               vtkDataSet*          theScalarsDataSet,
                vtkPolyData*         theOutput)
 {
   if(IsMergingInputs()){
@@ -340,7 +304,7 @@ VISU_GaussMergeFilter
         for(vtkIdType i = 0;i < anIntersection.size();i++)
           aNbTuples += aDataCellId2TupleGaussIdMap[anIntersection[i].first].size();
         
-        vtkPointSet* aScalarsDataSet = dynamic_cast<vtkPointSet*>(GetScalars());
+        vtkPointSet* aScalarsDataSet = dynamic_cast<vtkPointSet*>(theScalarsDataSet);
         vtkPoints* aDataPoints = aScalarsDataSet->GetPoints();
         vtkPoints* anOutputPoints = vtkPoints::New(aDataPoints->GetDataType());
         
@@ -366,13 +330,13 @@ VISU_GaussMergeFilter
           
           for(vtkIdType i = 0; i < aCellIdArray.size();i++) {
             vtkIdType aCellId = aCellIdArray[i];
-            vtkCell *aCell = GetScalars()->GetCell(aCellId);
+            vtkCell *aCell = theScalarsDataSet->GetCell(aCellId);
             
             aCellIds->Reset();
             aCellIds->InsertNextId(aNewTupleId);
             aNewTupleId++;
           
-            vtkIdType aCellType = GetScalars()->GetCellType(aCellId);
+            vtkIdType aCellType = theScalarsDataSet->GetCellType(aCellId);
             vtkIdType aNewCellId = theOutput->InsertNextCell(aCellType, aCellIds);
           
             anOutputCellData->CopyData(anInputCellData, aCellId, aNewCellId);