From: enk Date: Wed, 18 Apr 2007 09:49:39 +0000 (+0000) Subject: Fix for problem Bug NPAL14169 on comments from 2007-04-16 16:54. X-Git-Tag: V3_2_6~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=761d57713246af5b2a9cac209091719d733950e4;p=modules%2Fvisu.git Fix for problem Bug NPAL14169 on comments from 2007-04-16 16:54. --- diff --git a/src/CONVERTOR/VISU_CommonCellsFilter.cxx b/src/CONVERTOR/VISU_CommonCellsFilter.cxx index fb040b8f..6be2c3e2 100644 --- a/src/CONVERTOR/VISU_CommonCellsFilter.cxx +++ b/src/CONVERTOR/VISU_CommonCellsFilter.cxx @@ -68,11 +68,11 @@ namespace aPointCellIds.clear(); vtkCell* aCell = inputUGrid->GetCell(idCell); vtkIdList* ptIds = aCell->GetPointIds(); - int aMaxId = ptIds->GetNumberOfIds(); int nbPointsInCell = ptIds->GetNumberOfIds(); bool aGoodCell = true; for(int i=0;iGetId(i)); + int aSearchingId = ptIds->GetId(i); + TSortedArray::iterator aResult = find(aSortedPointIds.begin(),aSortedPointIds.end(),aSearchingId); if(aResult == aSortedPointIds.end()){ aGoodCell = false; break; diff --git a/src/CONVERTOR/VISU_MergeFilter.cxx b/src/CONVERTOR/VISU_MergeFilter.cxx index ec2d61f3..138db504 100644 --- a/src/CONVERTOR/VISU_MergeFilter.cxx +++ b/src/CONVERTOR/VISU_MergeFilter.cxx @@ -511,23 +511,20 @@ namespace aPointCellIds.clear(); vtkCell* aCell = inputUGrid->GetCell(idCell); vtkIdList* ptIds = aCell->GetPointIds(); - int aMaxId = ptIds->GetNumberOfIds(); - int* aPointer = ptIds->GetPointer(0); - int* anEndPointer = ptIds->GetPointer(aMaxId + 1); - TSortedArray aSortedArray(aPointer, anEndPointer); - std::sort(aSortedArray.begin(), aSortedArray.end()); - - int aMaxLength = std::max(aSortedArray.size(), aSortedPointIds.size()); - TSortedArray anIntersectionArray(aMaxLength); - TSortedArray::iterator anArrayIter = anIntersectionArray.begin(); - anArrayIter = std::set_intersection(aSortedArray.begin(), - aSortedArray.end(), - aSortedPointIds.begin(), - aSortedPointIds.end(), - anArrayIter); - anIntersectionArray.erase(anArrayIter, anIntersectionArray.end()); - if(anIntersectionArray.size() == aSortedArray.size()) + int nbPointsInCell = ptIds->GetNumberOfIds(); + bool aGoodCell = true; + for(int i=0;iGetId(i); + TSortedArray::iterator aResult = find(aSortedPointIds.begin(),aSortedPointIds.end(),aSearchingId); + if(aResult == aSortedPointIds.end()){ + aGoodCell = false; + break; + } + } + if(aGoodCell) aOutputCellIds.push_back(idCell); + else + continue; } outputSortedArray.swap(aOutputCellIds); @@ -605,11 +602,19 @@ void VISU_MergeFilter::Execute() int nbPointsInGeometr = anInput->GetNumberOfPoints(); vtkCellData *aCellData = anInput->GetCellData(); + vtkDataArray* aScalarsOnCellsArray = NULL; + if(aInputScalars->GetCellData()) + aScalarsOnCellsArray = aInputScalars->GetCellData()->GetArray("VISU_FIELD"); + vtkDataArray* aScalarsOnPointsArray = NULL; + if(aInputScalars->GetPointData()) + aScalarsOnPointsArray = aInputScalars->GetPointData()->GetArray("VISU_FIELD"); + vtkDataArray *aPointMapper = aPointData->GetArray("VISU_POINTS_MAPPER"); vtkIntArray *aGeometryPointMapper = dynamic_cast(aPointMapper); vtkDataArray *aCellMapper = aCellData->GetArray("VISU_CELLS_MAPPER"); vtkIntArray *aGeometryCellMapper = dynamic_cast(aCellMapper); - if(aGeometryCellMapper && (nbPointsInScalars == nbPointsInGeometr)){ + + if(aGeometryCellMapper && aScalarsOnCellsArray && (nbPointsInScalars == nbPointsInGeometr)){ vtkIntArray* aDataCellMapper = NULL; VISU::TFieldListIterator anIter(this->FieldList); for(anIter.Begin(); !anIter.End() ; anIter.Next()){ @@ -621,10 +626,13 @@ void VISU_MergeFilter::Execute() break; } } - + bool anIsDifferent = aDataCellMapper && aDataCellMapper->GetNumberOfTuples() != aGeometryCellMapper->GetNumberOfTuples(); - if(anIsDifferent || IsMergingInputs()){ + + if(anIsDifferent || IsMergingInputs() ){ + // The situation for merging CELLS from anInput as Geometry + // and scalars on cell data TSortedArray aGeometryCellArray; GetSortedArray(aGeometryCellMapper, aGeometryCellArray); @@ -688,7 +696,83 @@ void VISU_MergeFilter::Execute() return; } } + } else if (aGeometryCellMapper && aScalarsOnPointsArray && (nbPointsInScalars == nbPointsInGeometr)) { + // The situation for merging CELLS from anInput as Geometry + // and scalars on point data + vtkPointData* aInputScalarsPointData = aInputScalars->GetPointData(); + + vtkIntArray* aDataPointMapper = NULL; + VISU::TFieldListIterator anIter(this->FieldList); + for(anIter.Begin(); !anIter.End() ; anIter.Next()){ + const char* aFieldName = anIter.Get()->GetName(); + if(strcmp(aFieldName, "VISU_POINTS_MAPPER") == 0){ + vtkDataArray *aPointMapper = aInputScalarsPointData->GetArray(aFieldName); + aDataPointMapper = dynamic_cast(aPointMapper); + break; + } + } + + if(aDataPointMapper){ + TSortedArray aGeometryPointArray; + GetSortedArray(aGeometryPointMapper, aGeometryPointArray); + + TSortedArray aDataPointArray; + GetSortedArray(aDataPointMapper, aDataPointArray); + + { + TId2IdMap anObj2VTKGeometryPointsMap; + vtkIdType aNbCells = aDataPointMapper->GetNumberOfTuples(); + for(int aCellId = 0; aCellId < aNbCells; aCellId++){ + vtkIdType anObjID = aDataPointMapper->GetValue(aCellId); + anObj2VTKGeometryPointsMap[anObjID] = aCellId; + } + + TId2IdMap anObj2VTKGeometryCellsMap; + aNbCells = aGeometryCellMapper->GetNumberOfTuples(); + for(int aCellId = 0; aCellId < aNbCells; aCellId++){ + vtkIdType anObjID = aGeometryCellMapper->GetValue(aCellId); + anObj2VTKGeometryCellsMap[anObjID] = aCellId; + } + + // copy points to output + vtkUnstructuredGrid* aUnstructuredScalars = dynamic_cast(aInputScalars); + if(aUnstructuredScalars) + anOutput->SetPoints(aUnstructuredScalars->GetPoints()); + anOutput->GetPointData()->ShallowCopy(aInputScalars->GetPointData()); + + // Calculate output cells + int nbCells=0; + TSortedArray aCellIdsForCopy_fromCellMapper; + GetSortedArray(aGeometryCellMapper, aCellIdsForCopy_fromCellMapper); + nbCells = aCellIdsForCopy_fromCellMapper.size(); + + TSortedArray aCellIdsForCopy; + for(int i=0;iAllocate(nbCells); + vtkIntArray* theOuputIDSArray = vtkIntArray::New(); + theOuputIDSArray->SetName("VISU_CELLS_MAPPER"); + theOuputIDSArray->SetNumberOfComponents(1); + theOuputIDSArray->SetNumberOfTuples(nbCells); + + if(nbCells>0) + CopyElementsToOutput(anInput, + nbCells, + aCellIdsForCopy, + anObj2VTKGeometryPointsMap, + theOuputIDSArray, + anOutput); + theOuputIDSArray->Delete(); + + return; + } + } } else if (aGeometryCellMapper && (nbPointsInScalars < nbPointsInGeometr)) { + // The situation for merging CELLS from anInput as Geometry + // and scalars on point data (there the number of points of point data less than + // number of points of Geometry) vtkPointData* aInputScalarsPointData = aInputScalars->GetPointData(); @@ -736,9 +820,9 @@ void VISU_MergeFilter::Execute() { TId2IdMap anObj2VTKGeometryMap; - vtkIdType aNbCells = aDataPointMapper/*aGeometryPointMapper*/->GetNumberOfTuples(); + vtkIdType aNbCells = aDataPointMapper->GetNumberOfTuples(); for(int aCellId = 0; aCellId < aNbCells; aCellId++){ - vtkIdType anObjID = aDataPointMapper/*aGeometryPointMapper*/->GetValue(aCellId); + vtkIdType anObjID = aDataPointMapper->GetValue(aCellId); anObj2VTKGeometryMap[anObjID] = aCellId; }