-// 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
//
// 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
//----------------------------------------------------------------------------
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);
}
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);
int VISU_LabelPointsFilter::GetRegions(vtkPolyData* theInput,
- vtkPolyData* theOutput)
+ vtkPolyData* theOutput)
{
vtkIdType cellId, i;
vtkIdType numPts, numCells;
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();
// 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;
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