Salome HOME
Merge from V5_1_main 14/05/2010
[modules/visu.git] / src / PIPELINE / VISU_LabelPointsFilter.cxx
index b0f14eba0e65ea2515d7e9827e6c6e4a40bc4c56..3ec4db61c133de83cae8e008b5ab964d160421e3 100644 (file)
@@ -1,7 +1,4 @@
-//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
-//
-//  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 //  This library is free software; you can redistribute it and/or
 //  modify it under the terms of the GNU Lesser General Public
@@ -19,6 +16,7 @@
 //
 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+
 //  VISU OBJECT : interactive object for VISU entities implementation
 // File:    VISU_LabelPointsFilter.cxx
 // Author:  Vitaly Smetannikov
@@ -83,8 +81,8 @@ VISU_LabelPointsFilter::~VISU_LabelPointsFilter()
 
 //----------------------------------------------------------------------------
 int VISU_LabelPointsFilter::RequestData(vtkInformation* vtkNotUsed(request),
-                                       vtkInformationVector** inputVector,
-                                       vtkInformationVector* outputVector)
+                                        vtkInformationVector** inputVector,
+                                        vtkInformationVector* outputVector)
 {
   // get the info objects
   vtkInformation* inInfo = inputVector[0]->GetInformationObject(0);
@@ -100,8 +98,8 @@ int VISU_LabelPointsFilter::RequestData(vtkInformation* vtkNotUsed(request),
 }
 
 int VISU_LabelPointsFilter::RequestUpdateExtent(vtkInformation* vtkNotUsed(request),
-                                               vtkInformationVector** inputVector,
-                                               vtkInformationVector* outputVector)
+                                                vtkInformationVector** inputVector,
+                                                vtkInformationVector* outputVector)
 {
   // get the info objects
   vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
@@ -117,7 +115,7 @@ int VISU_LabelPointsFilter::RequestUpdateExtent(vtkInformation* vtkNotUsed(reque
 
 
 int VISU_LabelPointsFilter::GetRegions(vtkPolyData* theInput, 
-                                      vtkPolyData* theOutput)
+                                       vtkPolyData* theOutput)
 {
   vtkIdType cellId, i;
   vtkIdType numPts, numCells;
@@ -187,38 +185,38 @@ int VISU_LabelPointsFilter::GetRegions(vtkPolyData* theInput,
       aWave->InsertNextId(cellId);
       aPointNumber = 0;
       TraverseAndMark(aWave, aWave2, aVisited, aPointMap, 
-                     aRegionNumber, aPointNumber, aMesh);
+                      aRegionNumber, aPointNumber, aMesh);
       
       if (aPointNumber >= myPointsNb) {
-       std::set<vtkIdType, ltIdType> aIdxSet;
-       for (i=0; i < numPts; i++) {
-         if ( aPointMap[i] > -1 ) {
-           aIdxSet.insert(i);
-           aPointMap[i] = -1;
-         }
-       }
-       std::vector<vtkIdType> aIdx(aIdxSet.begin(), aIdxSet.end());
-       int aActualPts = aIdx.size();
-       int aNewId;
-       if (myPointsNb > 2) {
-         int k = aActualPts/(myPointsNb - 1);
-         int count;
-         for (i=0, count = 0; i < aActualPts; i+=k, count++) {
-           aNewId = newPts->InsertNextPoint(inPts->GetPoint(aIdx[i]));
-           aOutPD->CopyData(aInpPD, aIdx[i], aNewId);
-         }
-         if (count < myPointsNb) {
-           aNewId = newPts->InsertNextPoint(inPts->GetPoint(aIdx[aActualPts - 1]));
-           aOutPD->CopyData(aInpPD, aIdx[aActualPts - 1], aNewId);
-         }
-       } else {          
-         aNewId = newPts->InsertNextPoint(inPts->GetPoint(aIdx[0]));
-         aOutPD->CopyData(aInpPD, aIdx[0], aNewId);
-         if (myPointsNb == 2) {
-           aNewId = newPts->InsertNextPoint(inPts->GetPoint(aIdx[aActualPts - 1]));
-           aOutPD->CopyData(aInpPD, aIdx[aActualPts - 1], aNewId);
-         }
-       }
+        std::set<vtkIdType, ltIdType> aIdxSet;
+        for (i=0; i < numPts; i++) {
+          if ( aPointMap[i] > -1 ) {
+            aIdxSet.insert(i);
+            aPointMap[i] = -1;
+          }
+        }
+        std::vector<vtkIdType> aIdx(aIdxSet.begin(), aIdxSet.end());
+        int aActualPts = aIdx.size();
+        int aNewId;
+        if (myPointsNb > 2) {
+          int k = aActualPts/(myPointsNb - 1);
+          int count;
+          for (i=0, count = 0; i < aActualPts; i+=k, count++) {
+            aNewId = newPts->InsertNextPoint(inPts->GetPoint(aIdx[i]));
+            aOutPD->CopyData(aInpPD, aIdx[i], aNewId);
+          }
+          if (count < myPointsNb) {
+            aNewId = newPts->InsertNextPoint(inPts->GetPoint(aIdx[aActualPts - 1]));
+            aOutPD->CopyData(aInpPD, aIdx[aActualPts - 1], aNewId);
+          }
+        } else {          
+          aNewId = newPts->InsertNextPoint(inPts->GetPoint(aIdx[0]));
+          aOutPD->CopyData(aInpPD, aIdx[0], aNewId);
+          if (myPointsNb == 2) {
+            aNewId = newPts->InsertNextPoint(inPts->GetPoint(aIdx[aActualPts - 1]));
+            aOutPD->CopyData(aInpPD, aIdx[aActualPts - 1], aNewId);
+          }
+        }
       }
       aWave->Reset();
       aWave2->Reset(); 
@@ -247,12 +245,12 @@ int VISU_LabelPointsFilter::GetRegions(vtkPolyData* theInput,
 // traversal occurs across shared vertices.
 //
 void VISU_LabelPointsFilter::TraverseAndMark (vtkIdList* theWave, 
-                                             vtkIdList* theWave2, 
-                                             int* theVisited,
-                                             vtkIdType* thePointMap,
-                                             int& theRegionNumber,
-                                             vtkIdType& thePointNumber,
-                                             vtkPolyData* theMesh)
+                                              vtkIdList* theWave2, 
+                                              int* theVisited,
+                                              vtkIdType* thePointMap,
+                                              int& theRegionNumber,
+                                              vtkIdType& thePointNumber,
+                                              vtkPolyData* theMesh)
 {
   vtkIdType cellId, ptId, numIds, i;
   int j, k;
@@ -268,20 +266,20 @@ void VISU_LabelPointsFilter::TraverseAndMark (vtkIdList* theWave,
       if ( theVisited[cellId] < 0 ) {
         theVisited[cellId] = theRegionNumber;
         theMesh->GetCellPoints(cellId, npts, pts);
-       
+        
         for (j=0; j < npts; j++) {
           if ( thePointMap[ptId=pts[j]] < 0 ) {
             thePointMap[ptId] = thePointNumber++;
-         }       
+          }       
           theMesh->GetPointCells(ptId,ncells,cells);
-         
+          
           // check connectivity criterion (geometric + scalar)
           for (k=0; k < ncells; k++) {
             cellId = cells[k];
-           theWave2->InsertNextId(cellId);
-           //              }
-         }//for all cells using this point
-       }//for all points of this cell
+            theWave2->InsertNextId(cellId);
+            //              }
+          }//for all cells using this point
+        }//for all points of this cell
       }//if cell not yet visited
     }//for all cells in this wave