From f86065a48b58d2d2330e5ad002c6424d3415594e Mon Sep 17 00:00:00 2001 From: pkv Date: Thu, 1 Sep 2005 07:00:50 +0000 Subject: [PATCH] add functionality to treat specific DataSets --- src/VTKViewer/VTKViewer_AppendFilter.cxx | 121 ++++++++++++++++++----- src/VTKViewer/VTKViewer_AppendFilter.h | 7 +- 2 files changed, 102 insertions(+), 26 deletions(-) diff --git a/src/VTKViewer/VTKViewer_AppendFilter.cxx b/src/VTKViewer/VTKViewer_AppendFilter.cxx index 4835f76c5..dce05c44e 100644 --- a/src/VTKViewer/VTKViewer_AppendFilter.cxx +++ b/src/VTKViewer/VTKViewer_AppendFilter.cxx @@ -73,7 +73,7 @@ vtkStandardNewMacro(VTKViewer_AppendFilter); VTKViewer_AppendFilter ::VTKViewer_AppendFilter() { - myDoMappingFlag=false;//modified by NIZNHY-PKV Tue Aug 30 10:09:50 2005ft + myDoMappingFlag=false; } VTKViewer_AppendFilter @@ -112,25 +112,35 @@ void VTKViewer_AppendFilter ::Execute() { - vtkAppendFilter::Execute(); + if (myPoints.GetPointer()) { + MakeOutput(); + } + else { + vtkAppendFilter::Execute(); + } if (myDoMappingFlag){ DoMapping(); } } -void VTKViewer_AppendFilter::Reset() +void +VTKViewer_AppendFilter +::Reset() { myNodeIds.clear(); myCellIds.clear(); myNodeRanges.clear(); myCellRanges.clear(); - //modified by NIZNHY-PKV Tue Aug 30 10:09:35 2005f myNodeMapObjIDVtkID.clear(); myCellMapObjIDVtkID.clear(); - //modified by NIZNHY-PKV Tue Aug 30 10:09:39 2005t } - -void VTKViewer_AppendFilter::DoMapping() +//================================================================== +// function: DoMapping +// purpose : +//================================================================== +void +VTKViewer_AppendFilter +::DoMapping() { int i, j, i1, i2, iNodeCnt, iCellCnt; IteratorOfDataMapOfIntegerInteger aMapIt; @@ -145,22 +155,24 @@ void VTKViewer_AppendFilter::DoMapping() pDS=(vtkDataSet *)Inputs[i]; // // Nodes - aNbPnts=pDS->GetNumberOfPoints(); - i1=myNodeIds.size(); - i2=i1+aNbPnts-1; - myNodeRanges.push_back(i1); - myNodeRanges.push_back(i2); - // - for(j=0; jGetNumberOfPoints(); + i1=myNodeIds.size(); + i2=i1+aNbPnts-1; + myNodeRanges.push_back(i1); + myNodeRanges.push_back(i2); // - aMapIt=myNodeMapObjIDVtkID.find(aId); - if (aMapIt==myNodeMapObjIDVtkID.end()) { - // if not found - myNodeMapObjIDVtkID[aId]=iNodeCnt; + for(j=0; jGetOutput(); + // + numPts = myPoints->GetNumberOfPoints(); + if (numPts < 1) { + return; + } + // + numCells = 0; + for (idx = 0; idx < this->NumberOfInputs; ++idx) { + ds = (vtkDataSet *)(this->Inputs[idx]); + if (ds != NULL) { + if ( ds->GetNumberOfPoints() <= 0 && ds->GetNumberOfCells() <= 0 ) { + continue; //no input, just skip + } + numCells += ds->GetNumberOfCells(); + }//if non-empty dataset + }//for all inputs + if (numCells < 1) { + return; + } + // + // Now can allocate memory + output->Allocate(numCells); + ptIds = vtkIdList::New(); + ptIds->Allocate(VTK_CELL_SIZE); + // + // Append each input dataset together + // + // 1.points + output->SetPoints(myPoints.GetPointer()); + // 2.cells + for (idx = 0; idx < this->NumberOfInputs; ++idx) { + ds = (vtkDataSet *)(this->Inputs[idx]); + if (ds != NULL) { + numCells = ds->GetNumberOfCells(); + cd = ds->GetCellData(); + // copy cell and cell data + for (cellId=0; cellIdGetCellPoints(cellId, ptIds); + newCellId = output->InsertNextCell(ds->GetCellType(cellId), ptIds); + } + } + } + // + ptIds->Delete(); +} + diff --git a/src/VTKViewer/VTKViewer_AppendFilter.h b/src/VTKViewer/VTKViewer_AppendFilter.h index d5cc9d7a1..f9c6b245a 100644 --- a/src/VTKViewer/VTKViewer_AppendFilter.h +++ b/src/VTKViewer/VTKViewer_AppendFilter.h @@ -66,27 +66,26 @@ protected: void DoMapping(); void Reset(); + + void MakeOutput(); + // vtkSmartPointer myPoints; private: typedef std::vector TVectorId; typedef std::vector VectorInt; - //pkv f typedef std::map DataMapOfIntegerInteger; typedef DataMapOfIntegerInteger::iterator IteratorOfDataMapOfIntegerInteger; typedef DataMapOfIntegerInteger::value_type PairOfDataMapOfIntegerInteger; - //pkv t private: bool myDoMappingFlag; TVectorId myNodeIds; TVectorId myCellIds; VectorInt myNodeRanges; VectorInt myCellRanges; - //pkv f DataMapOfIntegerInteger myNodeMapObjIDVtkID; DataMapOfIntegerInteger myCellMapObjIDVtkID; - //pkv t }; #endif -- 2.39.2