{
VISU_PrsMergerPL* aPipeLine = dynamic_cast<VISU_PrsMergerPL*>(thePipeLine);
if(this == aPipeLine){
- Superclass::ShallowCopy(thePipeLine);
+ TSupperClass::ShallowCopy(thePipeLine);
return;
}
if(aPipeLine){
}
SetScalars(aPipeLine->GetScalars(),true);
}
- Superclass::ShallowCopy(thePipeLine);
+ TSupperClass::ShallowCopy(thePipeLine);
}
bool
if(theGeometry == NULL) return -1;
int aGeomNum = this->GetGeometryNumber(theGeometry);
if(aGeomNum == -1){
- if(this->checkGeometry(theGeometry)){
+ bool aCheckGeom = this->checkGeometry(theGeometry);
+ if(aCheckGeom){
myMeshGeometryList.push_back(theGeometry);
if(theUpdate)
if(myMeshGeometryList.size() != 0)
{
-
- VISU_MergeFilter* aMergeFilter = VISU_MergeFilter::New();
- // Build mesh
- typedef std::vector<int> TVec;
-
- TVec aObjIds;// object ids from geometries
- int anbGeoms;
- int aGeomNbCells,aAllGeomNbCells,aScalarNbCells;
- int aScalarNodeTuplesNum,aScalarCellTuplesNum,aScalarCellComponentNum;
- VTKViewer_AppendFilter* aMergeGeoms = VTKViewer_AppendFilter::New();
- aAllGeomNbCells = 0;
+ typedef std::vector<int> TVec;
+ vtkUnstructuredGrid* output = vtkUnstructuredGrid::New();
+ TVec aObjIds; // vector with object ids
+ vtkFloatArray* newArray = vtkFloatArray::New();
+
VISU_ScalarMapPL* aScalarMap = dynamic_cast<VISU_ScalarMapPL*>(this->GetScalars());
const VISU::PIDMapper& aScalarMapper = myScalars->GetIDMapper();
-
- anbGeoms = this->GetNbGeometry();
-
- // aObjIds follows.
+
+ // copy points to output from input scalar map
+ output->SetPoints(aScalarMapper->GetVTKOutput()->GetPoints());
+
+ int newCellId;
+ int anbGeoms = this->GetNbGeometry();
for(int i=0; i < anbGeoms; i++) {
VISU_PipeLine* aCurrGeometry = this->GetGeometry(i);
- if (aCurrGeometry) {
- aCurrGeometry->Update();
- const VISU::PIDMapper& aGM = aCurrGeometry->GetIDMapper();
- int aNbCells = aGM->GetVTKOutput()->GetNumberOfCells();
- if(MYDEBUG) MESSAGE("Geom["<<i<<"] aNbCells="<<aNbCells);
- if (aNbCells >0 )
- if (aGM->GetVTKOutput()->GetCell(0)->GetCellType() == VTK_VERTEX )
- continue;
- aMergeGeoms->AddInput(aGM->GetVTKOutput());
- aAllGeomNbCells += aNbCells;
- for(int j=0; j < aNbCells; j++)
- aObjIds.push_back(aGM->GetElemObjID(j));
- }
- }
-
- if (MYDEBUG){
- // Geometry debug information
- for(int i=0; i< anbGeoms; i++){
- VISU_PipeLine* aCurrGeometry = this->GetGeometry(i);
- const VISU::PIDMapper& aGeomMapper = aCurrGeometry->GetIDMapper();
- aGeomNbCells = aGeomMapper->GetVTKOutput()->GetNumberOfCells();
- cout << "Input Geometry[" << i << "]:" << endl;
- cout << "\tnumber of points:" << aGeomMapper->GetVTKOutput()->GetNumberOfPoints() << endl;
- cout << "\tnumber of cells :" << aGeomMapper->GetVTKOutput()->GetNumberOfCells() << " cell type=" << aGeomMapper->GetVTKOutput()->GetCell(0)->GetCellType() << endl;
- int aNbCells = aGeomNbCells;
- for(int i=0; i<aNbCells; i++){
- int anObjID = aGeomMapper->GetElemObjID(i);
- int aVTKID = aGeomMapper->GetElemVTKID(anObjID);
- cout <<"\t\t" << anObjID << ";"<<aVTKID<<endl;
- }
- }
- // Scalars debug information
- int aNbCells = aScalarMapper->GetVTKOutput()->GetNumberOfCells();
- cout << "myScalars:" << endl;
- cout << "\tnumber of points:" << aScalarMapper->GetVTKOutput()->GetNumberOfPoints() << endl;
- cout << "\tnumber of cells :" << aNbCells << endl;
- for(int i=0; i<aNbCells; i++){
- int anObjID = aScalarMapper->GetElemObjID(i);
- int aVTKID = aScalarMapper->GetElemVTKID(anObjID);
- cout <<"\t\t" << anObjID << ";"<<aVTKID<<endl;
- }
- }
+ const VISU::PIDMapper& aGM = aCurrGeometry->GetIDMapper();
+ int aNbCells = aGM->GetVTKOutput()->GetNumberOfCells();
+ if (aNbCells >0 )
+ if (aGM->GetVTKOutput()->GetCell(0)->GetCellType() == VTK_VERTEX )
+ continue;
- vtkCellData* aScalarMapCD = aScalarMapper->GetVTKOutput()->GetCellData();
-
- vtkUnstructuredGrid* aDSScalars = vtkUnstructuredGrid::New();
- vtkUnstructuredGrid* aDSVectors = vtkUnstructuredGrid::New();
- vtkCellData* aCDScalars = aDSScalars->GetCellData();
- vtkCellData* aCDVectors = aDSVectors->GetCellData();
- vtkPointData* aPDScalars = aDSScalars->GetPointData();
- vtkPointData* aPDVectors = aDSVectors->GetPointData();
- vtkUnstructuredGrid* aDSArrays = vtkUnstructuredGrid::New();
- vtkFloatArray* aArrays = vtkFloatArray::New();
- vtkFloatArray *aVISU_FIELD_Array = NULL;
-
- // shallow copy of point data
- if(aScalarMap != NULL){
- aPDScalars->ShallowCopy(aScalarMap->GetOutput()->GetPointData());
- aPDVectors->ShallowCopy(aScalarMap->GetOutput()->GetPointData());
- }
+ vtkIdList* ptIds = vtkIdList::New();
+ ptIds->Allocate(VTK_CELL_SIZE);
- aCDScalars->Initialize();
- aCDVectors->Initialize();
-
-
- /*
- *copy arrays from point data
- */
- vtkPointData* aPDInput = aScalarMapper->GetVTKOutput()->GetPointData();
- aDSArrays->GetPointData()->SetScalars(aPDInput->GetScalars());
- aDSArrays->GetPointData()->SetVectors(aPDInput->GetVectors());
- int anbPArr = aPDInput->GetNumberOfArrays();
- if(anbPArr>0){
- vtkDataArray* aFieldArray = aPDInput->GetArray("VISU_FIELD");
- if(vtkFloatArray* aArr = dynamic_cast<vtkFloatArray*>(aFieldArray))
- aDSArrays->GetPointData()->AddArray(aArr);
- }
+ for(int j=0; j < aNbCells; j++){
- /*
- *copy array VISU_FIELD from cell data
- */
- int anbArr = aScalarMapCD->GetNumberOfArrays();
- if(anbArr>0){
- vtkDataArray* aFieldArray = aScalarMapCD->GetArray("VISU_FIELD");
- if(aVISU_FIELD_Array = dynamic_cast<vtkFloatArray*>(aFieldArray)){
- if(MYDEBUG) MESSAGE("Copy VISU_FIELD .........");
- int aNbComp = aVISU_FIELD_Array->GetNumberOfComponents();
- int nbTuple = aVISU_FIELD_Array->GetNumberOfTuples();
- aArrays->SetName(aVISU_FIELD_Array->GetName());
- aArrays->SetNumberOfComponents(aNbComp);
- aArrays->SetNumberOfTuples(aAllGeomNbCells);
-
- TVec::const_iterator aIdsIter = aObjIds.begin();
- for(int i=0; aIdsIter != aObjIds.end(); aIdsIter++){
- int anObjID = *aIdsIter;
- int aVTKID = aScalarMapper->GetElemVTKID(anObjID);
- float* aTuple = aVISU_FIELD_Array->GetTuple(aVTKID);
- if(MYDEBUG){
- cout <<"\t\t" << anObjID << ";"<<aVTKID<<";"<<i<<" tuples:";
- for(int k=0;k<aNbComp;k++)
- cout << aTuple[i] << ",";
- cout << endl;
- }
- aArrays->SetTuple(i,aTuple);
- i++;
- }
- aDSArrays->GetCellData()->AddArray(aArrays);
- if(MYDEBUG) MESSAGE("Copy VISU_FIELD .........done");
+ int anObjID = aGM->GetElemObjID(j);
+ aObjIds.push_back(anObjID);
+
+ // copy cells to output from input geoms
+ aGM->GetVTKOutput()->GetCellPoints(j, ptIds);
+ newCellId = output->InsertNextCell(aGM->GetVTKOutput()->GetCellType(j),ptIds);
}
- }
-
+ ptIds->Delete();
+ }
+
- /*
- *copy scalars from cell data
- */
- aScalarCellTuplesNum = 0;
- int compNum = 0;
- if(aScalarMapCD->GetScalars()){
- aScalarCellTuplesNum = aScalarMapCD->GetScalars()->GetNumberOfTuples();
- compNum = aScalarMapCD->GetScalars()->GetNumberOfComponents();
+ //copy array values
+ vtkDataArray* da;
+ if((da = aScalarMapper->GetVTKOutput()->GetPointData()->GetArray("VISU_FIELD"))){
+ output->GetPointData()->AddArray(da);
+ vtkDataArray* vc = aScalarMapper->GetVTKOutput()->GetPointData()->GetVectors();
+ if(vc)
+ output->GetPointData()->SetVectors(vc);
}
- if (aScalarCellTuplesNum > 0) {
- if(MYDEBUG) MESSAGE("Copy Scalars .........");
- if(MYDEBUG) MESSAGE("\taScalarCellTuplesNum="<<aScalarCellTuplesNum);
- if(MYDEBUG) MESSAGE("\tcompNum ="<<compNum);
- if(MYDEBUG) MESSAGE("\taAllGeomNbCells="<<aAllGeomNbCells);
- vtkFloatArray* aNewScalars = vtkFloatArray::New();
- aNewScalars->SetNumberOfComponents(compNum);
- aNewScalars->SetNumberOfTuples(aObjIds.size());
- aNewScalars->SetName(aScalarMapCD->GetScalars()->GetName());
-
- if(MYDEBUG) cout << "\tOutput: ObjId,VtkId,newId" << endl;
- TVec::const_iterator aIdsIter = aObjIds.begin();
- for(int i=0; aIdsIter != aObjIds.end(); aIdsIter++){
- int anObjID = *aIdsIter;
- int aVTKID = aScalarMapper->GetElemVTKID(anObjID);
- float* aTuple = aScalarMapCD->GetScalars()->GetTuple(aVTKID);
- if(MYDEBUG){
- cout <<"\t\t" << anObjID << ";"<<aVTKID<<";"<<i<<" tuples:";
- for(int k=0;k<compNum;k++)
- cout << aTuple[i] << ",";
- cout << endl;
- }
- aNewScalars->SetTuple(i,aTuple);
- i++;
+ if((da = aScalarMapper->GetVTKOutput()->GetCellData()->GetArray("VISU_FIELD"))){
+ if(MYDEBUG){
+ MESSAGE("aScalarMapper NumberOfComponents="<<da->GetNumberOfComponents());
+ MESSAGE("aScalarMapper NumberOfTuples ="<<da->GetNumberOfTuples());
}
- aCDScalars->SetScalars(aNewScalars);
- aCDScalars->AddArray(aArrays);
- aNewScalars->Delete();
- if(MYDEBUG) MESSAGE("Copy Scalars .........Done");
- }
-
- /*
- * copy vectors from cell data
- */
- aScalarCellTuplesNum = 0;
- if(aScalarMapCD->GetVectors()) {
- aScalarCellTuplesNum = aScalarMapCD->GetVectors()->GetNumberOfTuples();
- compNum = aScalarMapCD->GetVectors()->GetNumberOfComponents();
- }
- if (aScalarCellTuplesNum > 0) {
- if(MYDEBUG) MESSAGE("Copy Vectors .........");
- if(MYDEBUG) MESSAGE("\taScalarCellTuplesNum="<<aScalarCellTuplesNum);
- if(MYDEBUG) MESSAGE("\tcompNum ="<<compNum);
- if(MYDEBUG) MESSAGE("\taAllGeomNbCells="<<aAllGeomNbCells);
- vtkFloatArray* aNewVectors = vtkFloatArray::New();
- aNewVectors->SetNumberOfComponents(compNum);
- aNewVectors->SetNumberOfTuples(aAllGeomNbCells);
- aNewVectors->SetName(aScalarMapCD->GetVectors()->GetName());
+
+ newArray->SetNumberOfComponents(da->GetNumberOfComponents());
+ newArray->SetNumberOfTuples(aObjIds.size());
+ newArray->SetName("VISU_FIELD");
TVec::const_iterator aIdsIter = aObjIds.begin();
for(int i=0; aIdsIter != aObjIds.end(); aIdsIter++){
int anObjID = *aIdsIter;
int aVTKID = aScalarMapper->GetElemVTKID(anObjID);
- float* aTuple = aScalarMapCD->GetVectors()->GetTuple(aVTKID);
- if(MYDEBUG){
- cout <<"\t\t" << anObjID << ";"<<aVTKID<<";"<<i<<" tuples:";
- for(int k=0;k<compNum;k++)
- cout << aTuple[i] << ",";
- cout << endl;
- }
- aNewVectors->SetTuple(i,aTuple);
+ newArray->SetTuple(i,da->GetTuple(aVTKID));
i++;
}
- aCDVectors->SetVectors(aNewVectors);
- aCDVectors->AddArray(aArrays);
- aDSArrays->GetCellData()->AddArray(aArrays);
- aNewVectors->Delete();
- if(MYDEBUG) MESSAGE("Copy Vectors .........Done");
- }
-
- aMergeFilter->SetGeometry(aMergeGeoms->GetOutput());
+ output->GetCellData()->AddArray(newArray);
- aMergeGeoms->AddInput(aDSScalars);
- aMergeGeoms->AddInput(aDSVectors);
-
- if(aArrays->GetNumberOfTuples()>0)
- aMergeFilter->AddField("VISU_FIELD",aDSArrays);
-
- if(MYDEBUG){
- MESSAGE("PointData:");
- aDSArrays->GetPointData()->Print(cout);
- MESSAGE("CellData:");
- aDSArrays->GetCellData()->Print(cout);
+ // need in vectors array and scalars array
+ if(vtkDataArray* vc = aScalarMapper->GetVTKOutput()->GetCellData()->GetVectors()){
+ output->GetCellData()->SetVectors(newArray);
+ }
+ else if(vtkDataArray* sc = aScalarMapper->GetVTKOutput()->GetCellData()->GetScalars())
+ output->GetCellData()->SetScalars(newArray);
}
- aMergeFilter->SetScalars(aDSScalars);
- aMergeFilter->SetVectors(aDSVectors);
- aMergeFilter->Update();
-
+
if(MYDEBUG){
- MESSAGE("Output tuples:");
- int nbTuples = aMergeFilter->GetUnstructuredGridOutput()->GetCellData()->GetNumberOfTuples();
- for(int i=0;i<nbTuples;i++){
- int nc = aMergeFilter->GetUnstructuredGridOutput()->GetCellData()->GetNumberOfComponents();
- float* aTuple = aMergeFilter->GetUnstructuredGridOutput()->GetCellData()->GetTuple(i);
- cout << "\t\tTuple["<<i<<"]:";
- for(int k=0;k<nc;k++)
- cout << aTuple[k]<<",";
- cout << endl;
- }
-
+ MESSAGE("output:");
+ output->Print(cout);
}
- SetInput(aMergeFilter->GetUnstructuredGridOutput());
- aMergeGeoms->Delete();
- aDSScalars->Delete();
- aDSVectors->Delete();
-
- aDSArrays->Delete();
- aArrays->Delete();
+ SetInput(output);
- aMergeFilter->Delete();
+ output->Delete();
+ newArray->Delete();
}
else
{