inline int InsertCell(vtkUnstructuredGrid *theInput,
- vtkCellArray *theConnectivity,
- vtkUnsignedCharArray* theCellTypesArray,
- vtkIdTypeArray*& theFaces,
- vtkIdTypeArray*& theFaceLocations,
- vtkIdType theCellId,
- vtkIdList *theIdList,
- bool theStoreMapping,
- vtkIdType theOutId,
- VTKViewer_ExtractUnstructuredGrid::TVectorId& theOut2InId,
- VTKViewer_ExtractUnstructuredGrid::TMapId& theIn2OutId)
+ vtkCellArray *theConnectivity,
+ vtkUnsignedCharArray* theCellTypesArray,
+ vtkIdTypeArray*& theFaces,
+ vtkIdTypeArray*& theFaceLocations,
+ vtkIdType theCellId,
+ vtkIdList *theIdList,
+ bool theStoreMapping,
+ vtkIdType theOutId,
+ VTKViewer_ExtractUnstructuredGrid::TVectorId& theOut2InId,
+ VTKViewer_ExtractUnstructuredGrid::TMapId& theIn2OutId)
{
- vtkCell *aCell = theInput->GetCell(theCellId);
+ vtkCell *aCell = theInput->GetCell(theCellId);
vtkIdList *aPntIds = aCell->GetPointIds();
- vtkIdType aNbIds = aPntIds->GetNumberOfIds();
- vtkIdType aCellId = -1;
+ vtkIdType aNbIds = aPntIds->GetNumberOfIds();
+ vtkIdType aCellId = -1;
theIdList->SetNumberOfIds(aNbIds);
for(vtkIdType i = 0; i < aNbIds; i++){
theIdList->SetId(i,aPntIds->GetId(i));
/*vtkIdType anID = */theCellTypesArray->InsertNextValue(aCellType);
if(theStoreMapping){
- theOut2InId.push_back(theCellId);
- theIn2OutId[theCellId] = theOutId;
+ theOut2InId.push_back( theCellId );
+ theIn2OutId.insert( theIn2OutId.end(), std::make_pair( theCellId, theOutId ));
}
return aCellId;
}
theCellTypesArray->InsertNextValue(VTK_VERTEX);
if(theStoreMapping){
theOut2InId.push_back(theCellId);
- theIn2OutId[theCellId] = theOutId;
+ theIn2OutId.insert( theIn2OutId.end(), std::make_pair( theCellId, theOutId ));
}
}
myOut2InId.clear(); myIn2OutId.clear();
+ // use a vector of cellTypes to avoid searching in myCellTypes map
+ // for a better performance (IPAL53103)
+ TVectorId cellTypesVec( VTK_NUMBER_OF_CELL_TYPES, -1 );
+ for ( TSetId::iterator type = myCellTypes.begin(); type != myCellTypes.end(); ++type )
+ {
+ if ( *type >= (int)cellTypesVec.size() ) cellTypesVec.resize( *type+1, -1 );
+ if ( *type > 0 )
+ cellTypesVec[ *type ] = *type;
+ }
+
/* if(MYDEBUG){
MESSAGE("Execute - anInput->GetNumberOfCells() = "<<anInput->GetNumberOfCells());
MESSAGE("Execute - myCellTypes.size() = "<<myCellTypes.size());
for(vtkIdType aCellId = 0, anOutId = 0; aCellId < aNbElems; aCellId++,anOutId++){
if(myStoreMapping){
myOut2InId.push_back(aCellId);
- myIn2OutId[aCellId] = anOutId;
+ myIn2OutId.insert( myIn2OutId.end(), std::make_pair( aCellId, anOutId ));
}
}
}
for(vtkIdType aCellId = 0, anOutId = 0; aCellId < aNbElems; aCellId++,anOutId++){
if(myCellIds.find(aCellId) != myCellIds.end()){
vtkIdType newId = InsertCell(anInput,aConnectivity,aCellTypesArray,newFaces,newFaceLocations,aCellId,anIdList,
- myStoreMapping,anOutId,myOut2InId,myIn2OutId);
- anOutput->GetCellData()->CopyData(anInput->GetCellData(),aCellId,newId);
+ myStoreMapping,anOutId,myOut2InId,myIn2OutId);
+ anOutput->GetCellData()->CopyData(anInput->GetCellData(),aCellId,newId);
}
}
}else{
for(vtkIdType aCellId = 0, anOutId = 0; aCellId < aNbElems; aCellId++,anOutId++){
if(myCellIds.find(aCellId) == myCellIds.end()){
vtkIdType newId = InsertCell(anInput,aConnectivity,aCellTypesArray,newFaces,newFaceLocations,aCellId,anIdList,
- myStoreMapping,anOutId,myOut2InId,myIn2OutId);
- anOutput->GetCellData()->CopyData(anInput->GetCellData(),aCellId,newId);
+ myStoreMapping,anOutId,myOut2InId,myIn2OutId);
+ anOutput->GetCellData()->CopyData(anInput->GetCellData(),aCellId,newId);
}
}
}
if(myChangeMode == eAdding){
for(vtkIdType aCellId = 0, anOutId = 0; aCellId < aNbElems; aCellId++,anOutId++){
vtkIdType aType = anInput->GetCellType(aCellId);
- if(myCellTypes.find(aType) != myCellTypes.end()){
+ if ( cellTypesVec[ aType ] == aType ) {
vtkIdType newId = InsertCell(anInput,aConnectivity,aCellTypesArray,newFaces,newFaceLocations,aCellId,anIdList,
- myStoreMapping,anOutId,myOut2InId,myIn2OutId);
- anOutput->GetCellData()->CopyData(anInput->GetCellData(),aCellId,newId);
+ myStoreMapping,anOutId,myOut2InId,myIn2OutId);
+ anOutput->GetCellData()->CopyData(anInput->GetCellData(),aCellId,newId);
}
}
}else{
for(vtkIdType aCellId = 0, anOutId = 0; aCellId < aNbElems; aCellId++,anOutId++){
vtkIdType aType = anInput->GetCellType(aCellId);
- if(myCellTypes.find(aType) == myCellTypes.end()){
+ if ( cellTypesVec[ aType ] != aType ) {
vtkIdType newId = InsertCell(anInput,aConnectivity,aCellTypesArray,newFaces,newFaceLocations,aCellId,anIdList,
- myStoreMapping,anOutId,myOut2InId,myIn2OutId);
- anOutput->GetCellData()->CopyData(anInput->GetCellData(),aCellId,newId);
+ myStoreMapping,anOutId,myOut2InId,myIn2OutId);
+ anOutput->GetCellData()->CopyData(anInput->GetCellData(),aCellId,newId);
}
}
}
if(myChangeMode == eAdding){
for(vtkIdType aCellId = 0, anOutId = 0; aCellId < aNbElems; aCellId++,anOutId++){
vtkIdType aType = anInput->GetCellType(aCellId);
- if(myCellTypes.find(aType) != myCellTypes.end()){
+ if ( cellTypesVec[ aType ] == aType ) {
if(myCellIds.find(aCellId) != myCellIds.end()){
vtkIdType newId = InsertCell(anInput,aConnectivity,aCellTypesArray,newFaces,newFaceLocations,aCellId,anIdList,
- myStoreMapping,anOutId,myOut2InId,myIn2OutId);
- anOutput->GetCellData()->CopyData(anInput->GetCellData(),aCellId,newId);
+ myStoreMapping,anOutId,myOut2InId,myIn2OutId);
+ anOutput->GetCellData()->CopyData(anInput->GetCellData(),aCellId,newId);
}
}
}
}else{
for(vtkIdType aCellId = 0, anOutId = 0; aCellId < aNbElems; aCellId++,anOutId++){
vtkIdType aType = anInput->GetCellType(aCellId);
- if(myCellTypes.find(aType) == myCellTypes.end()){
+ if ( cellTypesVec[ aType ] != aType ) {
if(myCellIds.find(aCellId) == myCellIds.end()){
vtkIdType newId = InsertCell(anInput,aConnectivity,aCellTypesArray,newFaces,newFaceLocations,aCellId,anIdList,
- myStoreMapping,anOutId,myOut2InId,myIn2OutId);
- anOutput->GetCellData()->CopyData(anInput->GetCellData(),aCellId,newId);
+ myStoreMapping,anOutId,myOut2InId,myIn2OutId);
+ anOutput->GetCellData()->CopyData(anInput->GetCellData(),aCellId,newId);
}
}
}
if(myChangeMode == eAdding){
for(vtkIdType aCellId = 0, anOutId = 0; aCellId < aNbElems; aCellId++,anOutId++){
vtkIdType aType = anInput->GetCellType(aCellId);
- if(myCellTypes.find(aType) != myCellTypes.end()){
+ if ( cellTypesVec[ aType ] == aType ) {
InsertPointCell(aConnectivity,aCellTypesArray,aCellId,anIdList,
myStoreMapping,anOutId,myOut2InId,myIn2OutId);
}
}else{
for(vtkIdType aCellId = 0, anOutId = 0; aCellId < aNbElems; aCellId++,anOutId++){
vtkIdType aType = anInput->GetCellType(aCellId);
- if(myCellTypes.find(aType) == myCellTypes.end()){
+ if ( cellTypesVec[ aType ] != aType ) {
InsertPointCell(aConnectivity,aCellTypesArray,aCellId,anIdList,
myStoreMapping,anOutId,myOut2InId,myIn2OutId);
}
if(myChangeMode == eAdding){
for(vtkIdType aCellId = 0, anOutId = 0; aCellId < aNbElems; aCellId++,anOutId++){
vtkIdType aType = anInput->GetCellType(aCellId);
- if(myCellTypes.find(aType) != myCellTypes.end()){
+ if ( cellTypesVec[ aType ] == aType ) {
if(myCellIds.find(aCellId) != myCellIds.end()){
InsertPointCell(aConnectivity,aCellTypesArray,aCellId,anIdList,
myStoreMapping,anOutId,myOut2InId,myIn2OutId);
}else{
for(vtkIdType aCellId = 0, anOutId = 0; aCellId < aNbElems; aCellId++,anOutId++){
vtkIdType aType = anInput->GetCellType(aCellId);
- if(myCellTypes.find(aType) == myCellTypes.end()){
+ if ( cellTypesVec[ aType ] != aType ) {
if(myCellIds.find(aCellId) == myCellIds.end()){
InsertPointCell(aConnectivity,aCellTypesArray,aCellId,anIdList,
myStoreMapping,anOutId,myOut2InId,myIn2OutId);