From fe1eb20cee239bb6f38b16958b263aa292d4b9c9 Mon Sep 17 00:00:00 2001 From: enk Date: Fri, 27 Oct 2006 14:22:39 +0000 Subject: [PATCH] *** empty log message *** --- src/PIPELINE/VISU_PrsMergerPL.cxx | 266 +++++++++++++++++++-------- src/PIPELINE/VISU_PrsMergerPL.hxx | 10 - src/VISUGUI/VisuGUI_ScalarBarDlg.cxx | 3 +- src/VISU_I/VISU_PrsMerger_i.cc | 23 +++ src/VISU_I/VISU_PrsMerger_i.hh | 6 + 5 files changed, 223 insertions(+), 85 deletions(-) diff --git a/src/PIPELINE/VISU_PrsMergerPL.cxx b/src/PIPELINE/VISU_PrsMergerPL.cxx index 6d592227..8e5ab8ca 100644 --- a/src/PIPELINE/VISU_PrsMergerPL.cxx +++ b/src/PIPELINE/VISU_PrsMergerPL.cxx @@ -61,13 +61,11 @@ using namespace std; vtkStandardNewMacro(VISU_PrsMergerPL); VISU_PrsMergerPL -::VISU_PrsMergerPL(): - myMergeFilter(VISU_MergeFilter::New()) +::VISU_PrsMergerPL() { myScalars = NULL; - myIsModified = true; - myMergeFilter->Delete(); + //myMergeFilter->Delete(); myMeshGeometryList.clear(); } @@ -91,7 +89,6 @@ VISU_PrsMergerPL { VISU_PrsMergerPL* aPipeLine = dynamic_cast(thePipeLine); if(this == aPipeLine){ - myIsModified = true; Superclass::ShallowCopy(thePipeLine); return; } @@ -115,7 +112,6 @@ VISU_PrsMergerPL if(this->checkGeometry(theGeometry)){ myMeshGeometryList.push_back(theGeometry); if (MYDEBUG) MESSAGE("this->GetGeometry(0)->GetIDMapper()="<GetGeometry(0)->GetIDMapper()); - myIsModified = true; this->Execute(); @@ -134,7 +130,6 @@ VISU_PrsMergerPL if(aGeomNum == -1){ if(this->checkGeometry(theGeometry)){ myMeshGeometryList.push_back(theGeometry); - myIsModified = true; this->Execute(); @@ -238,7 +233,6 @@ VISU_PrsMergerPL ::Build() { if(MYDEBUG) MESSAGE("VISU_PrsMergerPL::Build()"); - //this->Execute(); TSupperClass::Build(); // call DoHook method } @@ -249,15 +243,6 @@ VISU_PrsMergerPL 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) @@ -296,10 +281,24 @@ VISU_PrsMergerPL 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 TVec; @@ -307,29 +306,16 @@ VISU_PrsMergerPL 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(this->GetScalars()); - VISU_PrsMergerPL* aPrsMergerPL = dynamic_cast(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) { @@ -347,8 +333,6 @@ VISU_PrsMergerPL } } - myMergeFilter->Update(); - if (MYDEBUG){ // Geometry debug information for(int i=0; i< anbGeoms; i++){ @@ -365,12 +349,7 @@ VISU_PrsMergerPL cout <<"\t\t" << anObjID << ";"<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; @@ -382,59 +361,198 @@ VISU_PrsMergerPL } } - aScalarCellTuplesNum = aScalarMapper->GetVTKOutput()->GetCellData()->GetNumberOfTuples(); - aScalarCellComponentNum = aScalarMapper->GetVTKOutput()->GetCellData()->GetNumberOfComponents(); - - - if(MYDEBUG) MESSAGE("aScalarMapper NumberOfTuples ="<(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(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 << ";"<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()=" - <GetUnstructuredGridOutput()<GetScalars()){ + aScalarCellTuplesNum = aScalarMapCD->GetScalars()->GetNumberOfTuples(); + compNum = aScalarMapCD->GetScalars()->GetNumberOfComponents(); + } + if (aScalarCellTuplesNum > 0) { + if(MYDEBUG) MESSAGE("Copy Scalars ........."); + if(MYDEBUG) MESSAGE("\taScalarCellTuplesNum="<GetElemVTKID(anObjID); + float* aTuple = aScalarMapCD->GetScalars()->GetTuple(aVTKID); + if(MYDEBUG){ + cout <<"\t\t" << anObjID << ";"<SetTuple(i,aTuple); + i++; + } + aCDScalars->SetScalars(aNewScalars); + aCDScalars->AddArray(aArrays); + aNewScalars->Delete(); + if(MYDEBUG) MESSAGE("Copy Scalars .........Done"); + } - if(MYDEBUG) MESSAGE("myMergeFilter NumberOfTuples ="<GetUnstructuredGridOutput()->GetCellData()->GetNumberOfTuples()); - if(MYDEBUG) MESSAGE("myMergeFilter NumberOfArrays ="<GetUnstructuredGridOutput()->GetCellData()->GetNumberOfArrays()); - if(MYDEBUG) MESSAGE("myMergeFilter NumberOfComponents="<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="<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;iGetUnstructuredGridOutput()->GetCellData()->GetNumberOfComponents(); + float* aTuple = aMergeFilter->GetUnstructuredGridOutput()->GetCellData()->GetTuple(i); + cout << "\t\tTuple["<GetUnstructuredGridOutput()); + SetInput(aMergeFilter->GetUnstructuredGridOutput()); + + aMergeGeoms->Delete(); + aDSScalars->Delete(); + aDSVectors->Delete(); - if (MYDEBUG) cout << "\tmyMergeFilter->GetOutput()=" - <GetOutput()<Delete(); + aArrays->Delete(); - aMergeGeoms->Delete(); - myOutput = myMergeFilter->GetOutput(); - + myOutput->ShallowCopy(aMergeFilter->GetOutput()); + + aMergeFilter->Delete(); } else { diff --git a/src/PIPELINE/VISU_PrsMergerPL.hxx b/src/PIPELINE/VISU_PrsMergerPL.hxx index 7c09daea..6d76830e 100644 --- a/src/PIPELINE/VISU_PrsMergerPL.hxx +++ b/src/PIPELINE/VISU_PrsMergerPL.hxx @@ -29,8 +29,6 @@ #include "VISU_ScalarMapPL.hxx" -class VISU_MergeFilter; - class VISU_PrsMergerPL : public VISU_ScalarMapPL { typedef VISU_ScalarMapPL TSupperClass; @@ -150,16 +148,10 @@ public: void SetInitialRange(); protected: -// virtual -// THook* -// DoHook(); - TPipeLines myMeshGeometryList; TPipeLine myScalars; - TVTKSmartPtr myMergeFilter; - vtkFloatingPointType* myScalarRanges; VISU_ScalarMapPL::THook* myOutput; @@ -187,8 +179,6 @@ private: void Execute(); - bool myIsModified; - }; #endif diff --git a/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx b/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx index 5e91fa8e..136d5399 100644 --- a/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx +++ b/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx @@ -614,7 +614,8 @@ void VisuGUI_ScalarBarPane::initFromPrsObject(VISU::PrsMerger_i* thePrs) { for(;aGroupIter!=aGroupMap.end();aGroupIter++) { const string& aGroupName = aGroupIter->first; - myAllGroups->insertItem( QString(aGroupName) ); + if(thePrs->CheckGroup(&aGroupName[0])) + myAllGroups->insertItem( QString(aGroupName) ); } } diff --git a/src/VISU_I/VISU_PrsMerger_i.cc b/src/VISU_I/VISU_PrsMerger_i.cc index f6e049ce..8450d072 100644 --- a/src/VISU_I/VISU_PrsMerger_i.cc +++ b/src/VISU_I/VISU_PrsMerger_i.cc @@ -429,3 +429,26 @@ VISU::PrsMerger_i } return myseq._retn(); } + +bool +VISU::PrsMerger_i +::CheckGroup(const char* theGroupName) +{ + if (MYDEBUG) MESSAGE("PrsMerger_i::CheckGroup :|"<GetInput()->GetMeshOnGroup(aMeshName,theGroupName); + if (MYDEBUG) MESSAGE("anIDMapper="<GetVTKOutput()->GetNumberOfCells();i++) + if(anIDMapper->GetVTKOutput()->GetCellType(i) != 1){ + aAllPoints = false; + break; + } + + return (!aAllPoints); +} diff --git a/src/VISU_I/VISU_PrsMerger_i.hh b/src/VISU_I/VISU_PrsMerger_i.hh index 52edb3e3..861e4b34 100644 --- a/src/VISU_I/VISU_PrsMerger_i.hh +++ b/src/VISU_I/VISU_PrsMerger_i.hh @@ -197,6 +197,12 @@ namespace VISU{ */ virtual CORBA::Long GetMeshGeometryPlace(CORBA::Long theId){return CORBA::Long(1);};// must bee filled + /*! + * Return true, if group is good, esle false. + * May be used, if SetScalarMap(...) olready . + */ + bool CheckGroup(const char* theGroupName); + }; } -- 2.39.2