vtkStandardNewMacro(VISU_PrsMergerPL);
VISU_PrsMergerPL
-::VISU_PrsMergerPL():
- myMergeFilter(VISU_MergeFilter::New())
+::VISU_PrsMergerPL()
{
myScalars = NULL;
- myIsModified = true;
- myMergeFilter->Delete();
+ //myMergeFilter->Delete();
myMeshGeometryList.clear();
}
{
VISU_PrsMergerPL* aPipeLine = dynamic_cast<VISU_PrsMergerPL*>(thePipeLine);
if(this == aPipeLine){
- myIsModified = true;
Superclass::ShallowCopy(thePipeLine);
return;
}
if(this->checkGeometry(theGeometry)){
myMeshGeometryList.push_back(theGeometry);
if (MYDEBUG) MESSAGE("this->GetGeometry(0)->GetIDMapper()="<<this->GetGeometry(0)->GetIDMapper());
- myIsModified = true;
this->Execute();
if(aGeomNum == -1){
if(this->checkGeometry(theGeometry)){
myMeshGeometryList.push_back(theGeometry);
- myIsModified = true;
this->Execute();
::Build()
{
if(MYDEBUG) MESSAGE("VISU_PrsMergerPL::Build()");
- //this->Execute();
TSupperClass::Build(); // call DoHook method
}
myMapper->UseLookupTableScalarRangeOff();
}
-// VISU_ScalarMapPL::THook*
-// VISU_PrsMergerPL
-// ::DoHook()
-// {
-// if(MYDEBUG) MESSAGE("VISU_PrsMergerPL::DoHook()");
-// Execute();
-// return myOutput;
-// }
-
bool
VISU_PrsMergerPL
::checkGeometry(const VISU_PipeLine* thePipeLine)
void
VISU_PrsMergerPL
::Execute(){
+ /* Where are next situations:
+ * 1. Timestamp on entity=NODE
+ * 1.1 Group Cell - OK
+ * 1.2 Group Cell + Point - ERR (remove points groups)
+ * 1.3 Group Node - ERR (remove points groups)
+ * 2. Timesatamp on entity=CELL
+ * 2.1 Group Cell - OK
+ * 2.2 Group Point - ERR (remove points groups)
+ */
+
+
+
if(MYDEBUG) MESSAGE("VISU_PrsMergerPL::Execute()");
if(myMeshGeometryList.size() != 0)
{
+
+ VISU_MergeFilter* aMergeFilter = VISU_MergeFilter::New();
// Build mesh
typedef std::vector<int> TVec;
int anbGeoms;
int aGeomNbCells,aAllGeomNbCells,aScalarNbCells;
int aScalarNodeTuplesNum,aScalarCellTuplesNum,aScalarCellComponentNum;
- vtkFloatArray* aOutputCellScalars;
- VTKViewer_AppendFilter* aMergeGeoms;
+ VTKViewer_AppendFilter* aMergeGeoms = VTKViewer_AppendFilter::New();
aAllGeomNbCells = 0;
- myMergeFilter->RemoveAllInputs();
-
- aMergeGeoms = VTKViewer_AppendFilter::New();
-
- myMergeFilter->SetGeometry(aMergeGeoms->GetOutput());
-
VISU_ScalarMapPL* aScalarMap = dynamic_cast<VISU_ScalarMapPL*>(this->GetScalars());
- VISU_PrsMergerPL* aPrsMergerPL = dynamic_cast<VISU_PrsMergerPL*>(this->GetScalars());
- if (aPrsMergerPL) {
- if (MYDEBUG) MESSAGE("ERROR...");
- if (MYDEBUG) MESSAGE("\t this=" << this << " aPrsMergerPL=" << aPrsMergerPL);
- }
- if(aScalarMap != NULL){
- myMergeFilter->GetOutput()->GetPointData()->SetScalars(aScalarMap->GetOutput()->GetPointData()->GetScalars());
- }
+ const VISU::PIDMapper& aScalarMapper = myScalars->GetIDMapper();
anbGeoms = this->GetNbGeometry();
-
+
+ // aObjIds follows.
for(int i=0; i < anbGeoms; i++) {
VISU_PipeLine* aCurrGeometry = this->GetGeometry(i);
if (aCurrGeometry) {
}
}
- myMergeFilter->Update();
-
if (MYDEBUG){
// Geometry debug information
for(int i=0; i< anbGeoms; i++){
cout <<"\t\t" << anObjID << ";"<<aVTKID<<endl;
}
}
- }
-
- const VISU::PIDMapper& aScalarMapper = myScalars->GetIDMapper();
-
- // Scalars debug information
- if (MYDEBUG){
+ // Scalars debug information
int aNbCells = aScalarMapper->GetVTKOutput()->GetNumberOfCells();
cout << "myScalars:" << endl;
cout << "\tnumber of points:" << aScalarMapper->GetVTKOutput()->GetNumberOfPoints() << endl;
}
}
- aScalarCellTuplesNum = aScalarMapper->GetVTKOutput()->GetCellData()->GetNumberOfTuples();
- aScalarCellComponentNum = aScalarMapper->GetVTKOutput()->GetCellData()->GetNumberOfComponents();
-
-
- if(MYDEBUG) MESSAGE("aScalarMapper NumberOfTuples ="<<aScalarCellTuplesNum);
- if(MYDEBUG) MESSAGE("aScalarMapper NumberOfArrays ="<<aScalarMapper->GetVTKOutput()->GetCellData()->GetNumberOfArrays());
- if(MYDEBUG) MESSAGE("aScalarMapper NumberOfComponents="<<aScalarCellComponentNum);
+ 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;
- if (aScalarCellTuplesNum > 0) {
- // copy scalars from cell data
- if(myMergeFilter->GetOutput()->GetCellData()->GetNumberOfTuples() == 0 ){
+ // shallow copy of point data
+ if(aScalarMap != NULL){
+ aPDScalars->ShallowCopy(aScalarMap->GetOutput()->GetPointData());
+ aPDVectors->ShallowCopy(aScalarMap->GetOutput()->GetPointData());
+ }
- vtkCellData* cdM = myMergeFilter->GetOutput()->GetCellData();
- aOutputCellScalars = vtkFloatArray::New();
- aOutputCellScalars->SetNumberOfTuples(aAllGeomNbCells);
+ 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);
+ }
- if(MYDEBUG) cout << "Output: ObjId,VtkId,newId" << endl;
-
+ /*
+ *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 = aScalarMapper->GetVTKOutput()->GetCellData()->GetTuple(aVTKID);
+ float* aTuple = aVISU_FIELD_Array->GetTuple(aVTKID);
if(MYDEBUG){
cout <<"\t\t" << anObjID << ";"<<aVTKID<<";"<<i<<" tuples:";
- for(int k=0;k<aScalarCellComponentNum;k++)
+ for(int k=0;k<aNbComp;k++)
cout << aTuple[i] << ",";
cout << endl;
}
- aOutputCellScalars->SetTuple(i,aTuple);
+ aArrays->SetTuple(i,aTuple);
i++;
}
- cdM->SetScalars(aOutputCellScalars);
- aOutputCellScalars->Delete();
+ aDSArrays->GetCellData()->AddArray(aArrays);
+ if(MYDEBUG) MESSAGE("Copy VISU_FIELD .........done");
}
}
-
- if (MYDEBUG) cout << "\tmyMergeFilter->GetUnstructuredGridOutput()="
- <<myMergeFilter->GetUnstructuredGridOutput()<<endl;
+
+ /*
+ *copy scalars from cell data
+ */
+ aScalarCellTuplesNum = 0;
+ int compNum = 0;
+ if(aScalarMapCD->GetScalars()){
+ aScalarCellTuplesNum = aScalarMapCD->GetScalars()->GetNumberOfTuples();
+ compNum = aScalarMapCD->GetScalars()->GetNumberOfComponents();
+ }
+ 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++;
+ }
+ aCDScalars->SetScalars(aNewScalars);
+ aCDScalars->AddArray(aArrays);
+ aNewScalars->Delete();
+ if(MYDEBUG) MESSAGE("Copy Scalars .........Done");
+ }
- if(MYDEBUG) MESSAGE("myMergeFilter NumberOfTuples ="<<myMergeFilter->GetUnstructuredGridOutput()->GetCellData()->GetNumberOfTuples());
- if(MYDEBUG) MESSAGE("myMergeFilter NumberOfArrays ="<<myMergeFilter->GetUnstructuredGridOutput()->GetCellData()->GetNumberOfArrays());
- if(MYDEBUG) MESSAGE("myMergeFilter NumberOfComponents="<<myMergeFilter->GetUnstructuredGridOutput()->GetCellData()->GetNumberOfComponents());
+ /*
+ * 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());
+
+ 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);
+ i++;
+ }
+ aCDVectors->SetVectors(aNewVectors);
+ aCDVectors->AddArray(aArrays);
+ aDSArrays->GetCellData()->AddArray(aArrays);
+ aNewVectors->Delete();
+ if(MYDEBUG) MESSAGE("Copy Vectors .........Done");
+ }
+
+ aMergeFilter->SetGeometry(aMergeGeoms->GetOutput());
+
+ 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);
+ }
+ 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;
+ }
+
+ }
- SetInput(myMergeFilter->GetUnstructuredGridOutput());
+ SetInput(aMergeFilter->GetUnstructuredGridOutput());
+
+ aMergeGeoms->Delete();
+ aDSScalars->Delete();
+ aDSVectors->Delete();
- if (MYDEBUG) cout << "\tmyMergeFilter->GetOutput()="
- <<myMergeFilter->GetOutput()<<endl;
+ aDSArrays->Delete();
+ aArrays->Delete();
- aMergeGeoms->Delete();
- myOutput = myMergeFilter->GetOutput();
-
+ myOutput->ShallowCopy(aMergeFilter->GetOutput());
+
+ aMergeFilter->Delete();
}
else
{