From: apo Date: Tue, 8 May 2007 13:38:43 +0000 (+0000) Subject: The deep revision of the PrsMerger and ScalarMapOnDeformedShape presentations (bound... X-Git-Tag: T_PAL_15278 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=bd0b79a3f172bd51ce906dd54b4ceece6dec1e1d;p=modules%2Fvisu.git The deep revision of the PrsMerger and ScalarMapOnDeformedShape presentations (bound to the Bug NPAL15278) --- diff --git a/src/CONVERTOR/VISUConvertor.cxx b/src/CONVERTOR/VISUConvertor.cxx index 60ce6567..0a470a0e 100644 --- a/src/CONVERTOR/VISUConvertor.cxx +++ b/src/CONVERTOR/VISUConvertor.cxx @@ -62,17 +62,28 @@ void parseFile(const char* theFileName) aCon->BuildEntities(); aCon->BuildFields(); aCon->BuildMinMax(); + aCon->BuildGroups(); + const VISU::TMeshMap& aMeshMap = aCon->GetMeshMap(); //return; VISU::TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin(); for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){ - //continue; const string& aMeshName = aMeshMapIter->first; const VISU::PMesh& aMesh = aMeshMapIter->second; const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap; VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter; + //Importing groups + const VISU::TGroupMap& aGroupMap = aMesh->myGroupMap; + VISU::TGroupMap::const_iterator aGroupMapIter = aGroupMap.begin(); + for(; aGroupMapIter != aGroupMap.end(); aGroupMapIter++){ + const string& aGroupName = aGroupMapIter->first; + aCon->GetMeshOnGroup(aMeshName,aGroupName); + } + + //continue; + //Import fields aMeshOnEntityMapIter = aMeshOnEntityMap.begin(); for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){ @@ -88,7 +99,7 @@ void parseFile(const char* theFileName) for(; aValFieldIter != aValField.end(); aValFieldIter++){ int aTimeStamp = aValFieldIter->first; - if(anEntity != VISU::NODE_ENTITY){ + if(false && anEntity != VISU::NODE_ENTITY){ VISU::PGaussPtsIDMapper aGaussMesh = aCon->GetTimeStampOnGaussPts(aMeshName,anEntity,aFieldName,aTimeStamp); VISU::TVTKOutput* aDataSet = aGaussMesh->GetVTKOutput(); @@ -117,14 +128,6 @@ void parseFile(const char* theFileName) } } - //Importing groups - const VISU::TGroupMap& aGroupMap = aMesh->myGroupMap; - VISU::TGroupMap::const_iterator aGroupMapIter = aGroupMap.begin(); - for(; aGroupMapIter != aGroupMap.end(); aGroupMapIter++){ - const string& aGroupName = aGroupMapIter->first; - aCon->GetMeshOnGroup(aMeshName,aGroupName); - } - //continue; //Import mesh on entity diff --git a/src/CONVERTOR/VISU_CommonCellsFilter.cxx b/src/CONVERTOR/VISU_CommonCellsFilter.cxx index 2473ea64..e0dd2220 100644 --- a/src/CONVERTOR/VISU_CommonCellsFilter.cxx +++ b/src/CONVERTOR/VISU_CommonCellsFilter.cxx @@ -290,12 +290,16 @@ VISU_CommonCellsFilter //anOutput->GetPointData()->GetArray("VISU_CELLS_MAPPER")->SetName("VISU_POINTS_MAPPER"); // apply VISU_POINTS_MAPPER + int anEntity = int(VISU::NODE_ENTITY); vtkIntArray* aNewPointsIdsArray = vtkIntArray::New(); aNewPointsIdsArray->SetName("VISU_POINTS_MAPPER"); - aNewPointsIdsArray->SetNumberOfComponents(1); + aNewPointsIdsArray->SetNumberOfComponents(2); aNewPointsIdsArray->SetNumberOfTuples(aPointIdsForCopy->GetNumberOfIds()); - for(int i=0;iGetNumberOfIds();i++) - aNewPointsIdsArray->SetValue(i,aPointIdsForCopy->GetId(i)); + int *aPtr = aNewPointsIdsArray->GetPointer(0); + for(int i = 0; i < aPointIdsForCopy->GetNumberOfIds(); i++){ + *aPtr++ = aPointIdsForCopy->GetId(i); + *aPtr++ = anEntity; + } anOutput->GetPointData()->AddArray(aNewPointsIdsArray); diff --git a/src/CONVERTOR/VISU_ConvertorUtils.cxx b/src/CONVERTOR/VISU_ConvertorUtils.cxx index 7839fab8..573d1664 100644 --- a/src/CONVERTOR/VISU_ConvertorUtils.cxx +++ b/src/CONVERTOR/VISU_ConvertorUtils.cxx @@ -25,6 +25,7 @@ // Module : VISU #include "VISU_ConvertorUtils.hxx" +#include "VISU_ConvertorDef.hxx" #include #include @@ -81,6 +82,37 @@ namespace VISU } + //--------------------------------------------------------------- + vtkIdType + GetVTKID(vtkDataArray *theIDDataArray, vtkIdType theID, int theEntity) + { + if(vtkIntArray *anIntArray = dynamic_cast(theIDDataArray)){ + int aNbTuples = anIntArray->GetNumberOfTuples(); + int* aPointer = anIntArray->GetPointer(0); + for(int aTupleId = 0; aTupleId < aNbTuples; aTupleId++){ + if(*aPointer == theID && *(aPointer + 1) == theEntity){ + return aTupleId; + } + aPointer += 2; + } + } + return -1; + } + + + //--------------------------------------------------------------- + vtkIdType + GetObjectID(vtkDataArray *theIDDataArray, vtkIdType theID) + { + if(vtkIntArray *anIntArray = dynamic_cast(theIDDataArray)){ + int aNbComp = anIntArray->GetNumberOfComponents(); + int* aPointer = anIntArray->GetPointer(theID*aNbComp); + return *aPointer; + } + return -1; + } + + //--------------------------------------------------------------- vtkIdType GetElemVTKID(vtkDataSet *theDataSet, vtkIdType theID, int theEntity) @@ -88,22 +120,29 @@ namespace VISU theDataSet->Update(); vtkDataSetAttributes *aDataSetAttributes = theDataSet->GetCellData(); if(vtkDataArray *aDataArray = aDataSetAttributes->GetArray("VISU_CELLS_MAPPER")){ - if(vtkIntArray *anIntArray = dynamic_cast(aDataArray)){ - int nbTuples = anIntArray->GetNumberOfTuples(); - int aMaxId = nbTuples * anIntArray->GetNumberOfComponents(); - int* aPointer = anIntArray->GetPointer(0); - for(int i=0;iUpdate(); vtkDataSetAttributes *aDataSetAttributes = theDataSet->GetCellData(); - if(vtkDataArray *aDataArray = aDataSetAttributes->GetArray("VISU_CELLS_MAPPER")){ - if(vtkIntArray *anIntArray = dynamic_cast(aDataArray)){ - int nbComp = anIntArray->GetNumberOfComponents(); - return *anIntArray->GetPointer(theID*nbComp); - } - } + if(vtkDataArray *aDataArray = aDataSetAttributes->GetArray("VISU_CELLS_MAPPER")) + return GetObjectID(aDataArray, theID); + return -1; } + //--------------------------------------------------------------- + vtkCell* + GetElemCell(vtkDataSet *theDataSet, vtkIdType theObjID) + { + vtkIdType aVTKID = GetElemVTKID(theDataSet, theObjID); + return theDataSet->GetCell(aVTKID); + } + + //--------------------------------------------------------------- vtkIdType GetNodeVTKID(vtkDataSet *theDataSet, vtkIdType theID) { theDataSet->Update(); vtkDataSetAttributes *aDataSetAttributes = theDataSet->GetPointData(); - if(vtkDataArray *aDataArray = aDataSetAttributes->GetArray("VISU_POINTS_MAPPER")){ - if(vtkIntArray *anIntArray = dynamic_cast(aDataArray)){ - int aMaxId = anIntArray->GetMaxId(); - int* aPointer = anIntArray->GetPointer(0); - int* anEndPointer = anIntArray->GetPointer(aMaxId + 1); - int* aPtr = std::find(aPointer, anEndPointer, theID); - return aPtr - aPointer; - } - } + if(vtkDataArray *aDataArray = aDataSetAttributes->GetArray("VISU_POINTS_MAPPER")) + return GetVTKID(aDataArray, theID, VISU::NODE_ENTITY); + return -1; } @@ -150,15 +189,22 @@ namespace VISU { theDataSet->Update(); vtkDataSetAttributes *aDataSetAttributes = theDataSet->GetPointData(); - if(vtkDataArray *aDataArray = aDataSetAttributes->GetArray("VISU_POINTS_MAPPER")){ - if(vtkIntArray *anIntArray = dynamic_cast(aDataArray)){ - return anIntArray->GetValue(theID); - } - } + if(vtkDataArray *aDataArray = aDataSetAttributes->GetArray("VISU_POINTS_MAPPER")) + return GetObjectID(aDataArray, theID); + return -1; } + //--------------------------------------------------------------- + vtkFloatingPointType* + GetNodeCoord(vtkDataSet *theDataSet, vtkIdType theObjID) + { + vtkIdType aVTKID = GetNodeVTKID(theDataSet, theObjID); + return theDataSet->GetPoint(aVTKID); + } + + //--------------------------------------------------------------- TTimerLog ::TTimerLog(int theIsDebug, diff --git a/src/CONVERTOR/VISU_ConvertorUtils.hxx b/src/CONVERTOR/VISU_ConvertorUtils.hxx index f70b69f5..8d324dbf 100644 --- a/src/CONVERTOR/VISU_ConvertorUtils.hxx +++ b/src/CONVERTOR/VISU_ConvertorUtils.hxx @@ -37,6 +37,7 @@ class vtkUnstructuredGrid; class vtkTimerLog; class vtkDataSet; +class vtkCell; namespace MED { @@ -56,17 +57,23 @@ namespace VISU IsDataOnPoints(vtkDataSet* theDataSet); vtkIdType - GetElemVTKID(vtkDataSet *theDataSet, vtkIdType theID, int theEntity); + GetElemVTKID(vtkDataSet *theDataSet, vtkIdType theID, int theEntity = -1); vtkIdType GetElemObjID(vtkDataSet *theDataSet, vtkIdType theID); + vtkCell* + GetElemCell(vtkDataSet *theDataSet, vtkIdType theObjID); + vtkIdType GetNodeVTKID(vtkDataSet *theDataSet, vtkIdType theID); vtkIdType GetNodeObjID(vtkDataSet *theDataSet, vtkIdType theID); + vtkFloatingPointType* + GetNodeCoord(vtkDataSet *theDataSet, vtkIdType theObjID); + class TTimerLog { int myIsDebug; diff --git a/src/CONVERTOR/VISU_Convertor_impl.cxx b/src/CONVERTOR/VISU_Convertor_impl.cxx index e63d3b60..cbf89c25 100644 --- a/src/CONVERTOR/VISU_Convertor_impl.cxx +++ b/src/CONVERTOR/VISU_Convertor_impl.cxx @@ -1226,13 +1226,16 @@ namespace } vtkIdType aNbTuples = aNbPoints; + int anEntity = int(VISU::NODE_ENTITY); vtkIntArray *aDataArray = vtkIntArray::New(); aDataArray->SetName("VISU_POINTS_MAPPER"); - aDataArray->SetNumberOfComponents(1); + aDataArray->SetNumberOfComponents(2); aDataArray->SetNumberOfTuples(aNbTuples); + int *aPtr = aDataArray->GetPointer(0); for(vtkIdType aTupleId = 0; aTupleId < aNbTuples; aTupleId++){ vtkIdType anObjID = aCoords.GetObjID(aTupleId); - aDataArray->SetValue(aTupleId, anObjID); + *aPtr++ = anObjID; + *aPtr++ = anEntity; } aPointSource->GetPointData()->AddArray(aDataArray); aDataArray->Delete(); @@ -1291,6 +1294,7 @@ namespace { int aNbTuples = aNbCells; + int anEntity = int(theMeshOnEntity->myEntity); vtkIntArray *aDataArray = vtkIntArray::New(); aDataArray->SetName("VISU_CELLS_MAPPER"); // the [0] component is element object ID @@ -1300,13 +1304,10 @@ namespace int *aPtr = aDataArray->GetPointer(0); for(int aTupleId = 0; aTupleId < aNbTuples; aTupleId++){ int anObjID = theSubMesh->GetElemObjID(aTupleId); - *aPtr = anObjID; - aPtr++; - *aPtr = (int)theMeshOnEntity->myEntity; - aPtr++; + *aPtr++ = anObjID; + *aPtr++ = anEntity; } theSource->GetCellData()->AddArray(aDataArray); - aDataArray->Delete(); } vtkIdType *pts = 0, npts = 0; @@ -1348,6 +1349,7 @@ namespace vtkIntArray *aDataArray = vtkIntArray::New(); + int anEntity = int(theMeshOnEntity->myEntity); aDataArray->SetName("VISU_CELLS_MAPPER"); // the [0] component is element object ID // the [1] component is entity type @@ -1388,12 +1390,10 @@ namespace PrintCells(aCellId, aConnectivity, anArray[anID]); aCellTypesArray->SetValue(aCellId, (unsigned char)aVGeom); vtkIdType anObjID = aSubMesh.GetElemObjID(anID); - *aPtr = anObjID; - aPtr++; - *aPtr = (int)theMeshOnEntity->myEntity; - aPtr++; anElemObj2VTKID[anObjID] = aCellId; aMeshID[aCellId] = anObjID; + *aPtr++ = anObjID; + *aPtr++ = anEntity; } } theSource->GetCellData()->AddArray(aDataArray); @@ -1574,20 +1574,18 @@ namespace { int aNbTuples = aNbCells; + int anEntity = int(theMeshOnEntity->myEntity); vtkIntArray *aDataArray = vtkIntArray::New(); aDataArray->SetName("VISU_CELLS_MAPPER"); // the [0] component is element object ID // the [1] component is entity type aDataArray->SetNumberOfComponents(2); aDataArray->SetNumberOfTuples(aNbTuples); - int *aPtr = aDataArray->GetPointer(0); - + int *aPtr = aDataArray->GetPointer(0); for(int aTupleId = 0; aTupleId < aNbTuples; aTupleId++){ int anObjID = theSubProfile->GetElemObjID(aTupleId); - *aPtr = anObjID; - aPtr++; - *aPtr = (int)theMeshOnEntity->myEntity; - aPtr++; + *aPtr++ = anObjID; + *aPtr++ = anEntity; } theSource->GetCellData()->AddArray(aDataArray); aDataArray->Delete(); diff --git a/src/CONVERTOR/VISU_MergeFilter.cxx b/src/CONVERTOR/VISU_MergeFilter.cxx index f7b384ff..29ad6ec6 100644 --- a/src/CONVERTOR/VISU_MergeFilter.cxx +++ b/src/CONVERTOR/VISU_MergeFilter.cxx @@ -27,6 +27,7 @@ // $Header$ #include "VISU_MergeFilter.hxx" +#include "VISU_ConvertorUtils.hxx" #include #include @@ -50,12 +51,10 @@ static int MYDEBUG = 0; #else static int MYDEBUG = 0; #endif -// TTimerLog -#include "VISU_ConvertorUtils.hxx" namespace VISU { - + //--------------------------------------------------------------- class TFieldNode { public: @@ -88,6 +87,7 @@ namespace VISU char* Name; }; + //--------------------------------------------------------------- class TFieldList { public: @@ -127,6 +127,8 @@ namespace VISU TFieldNode* Last; }; + + //--------------------------------------------------------------- class TFieldListIterator { public: @@ -173,11 +175,37 @@ VISU_MergeFilter::VISU_MergeFilter(): this->FieldList = new VISU::TFieldList; } + +//--------------------------------------------------------------- VISU_MergeFilter::~VISU_MergeFilter() { delete this->FieldList; } + +//--------------------------------------------------------------- +unsigned long +VISU_MergeFilter +::GetMTime() +{ + int aNbInputs = GetNumberOfInputs(); + vtkDataObject** aDataObjects = GetInputs(); + unsigned long aTime = Superclass::GetMTime(); + for(int anInputId = 0; anInputId < aNbInputs; anInputId++){ + if(vtkDataObject* aDataObject = aDataObjects[anInputId]) + aTime = std::max(aTime, aDataObject->GetMTime()); + } + if(this->FieldList){ + VISU::TFieldListIterator anIter(this->FieldList); + for(anIter.Begin(); !anIter.End() ; anIter.Next()){ + if(vtkDataSet *aDataSet = anIter.Get()->Ptr) + aTime = std::max(aTime, aDataSet->GetMTime()); + } + } + return aTime; +} + +//--------------------------------------------------------------- void VISU_MergeFilter::SetScalars(vtkDataSet *input) { this->vtkProcessObject::SetNthInput(1, input); @@ -191,6 +219,8 @@ vtkDataSet *VISU_MergeFilter::GetScalars() return (vtkDataSet *)(this->Inputs[1]); } + +//--------------------------------------------------------------- void VISU_MergeFilter::SetVectors(vtkDataSet *input) { this->vtkProcessObject::SetNthInput(2, input); @@ -204,6 +234,8 @@ vtkDataSet *VISU_MergeFilter::GetVectors() return (vtkDataSet *)(this->Inputs[2]); } + +//--------------------------------------------------------------- void VISU_MergeFilter::SetNormals(vtkDataSet *input) { this->vtkProcessObject::SetNthInput(3, input); @@ -217,6 +249,8 @@ vtkDataSet *VISU_MergeFilter::GetNormals() return (vtkDataSet *)(this->Inputs[3]); } + +//--------------------------------------------------------------- void VISU_MergeFilter::SetTCoords(vtkDataSet *input) { this->vtkProcessObject::SetNthInput(4, input); @@ -230,6 +264,8 @@ vtkDataSet *VISU_MergeFilter::GetTCoords() return (vtkDataSet *)(this->Inputs[4]); } + +//--------------------------------------------------------------- void VISU_MergeFilter::SetTensors(vtkDataSet *input) { this->vtkProcessObject::SetNthInput(5, input); @@ -243,6 +279,8 @@ vtkDataSet *VISU_MergeFilter::GetTensors() return (vtkDataSet *)(this->Inputs[5]); } + +//--------------------------------------------------------------- void VISU_MergeFilter::AddField(const char* name, vtkDataSet* input) { this->FieldList->Add(name, input); @@ -252,699 +290,283 @@ void VISU_MergeFilter::RemoveFields() { delete this->FieldList; this->FieldList = new VISU::TFieldList; + this->Modified(); } namespace { - typedef std::vector TSortedArray; + //--------------------------------------------------------------- + typedef int TCellId; + typedef int TEntityId; + typedef std::pair TObjectId; - inline + typedef std::set TObjectIdSet; + typedef std::vector TObjectIdArray; + + typedef int TTupleId; + typedef std::map TObjectId2TupleIdMap; + + + //--------------------------------------------------------------- void - GetSortedArray(vtkIntArray *theArray, - TSortedArray& theSortedArray) + GetObjectIdSet(vtkIntArray *theArray, + TObjectIdSet& theObjectIdSet) { + theObjectIdSet.clear(); int aMaxId = theArray->GetMaxId(); int* aPointer = theArray->GetPointer(0); int* anEndPointer = theArray->GetPointer(aMaxId + 1); - TSortedArray aSortedArray(aPointer, anEndPointer); - std::sort(aSortedArray.begin(), aSortedArray.end()); - theSortedArray.swap(aSortedArray); - } - - typedef std::map TId2IdMap; - typedef std::set TIdSet; - - template - void DeepCopySwitchOnOutput(TNumericType *theInputPtr, - TNumericType *theOutputPtr, - const TSortedArray& theIntersection, - const TId2IdMap& theObj2VTKMap, - vtkIdType theNbComp) - { - vtkIdType aNbIds = theIntersection.size(); - for(vtkIdType aTargetTupleId = 0; aTargetTupleId < aNbIds; aTargetTupleId++){ - vtkIdType aTargetId = aTargetTupleId*theNbComp; - vtkIdType anObjId = theIntersection[aTargetTupleId]; - TId2IdMap::const_iterator anIter = theObj2VTKMap.find(anObjId); - vtkIdType aSourceTupleId = anIter->second; - vtkIdType aSourceId = aSourceTupleId*theNbComp; - for(vtkIdType aComp = 0; aComp < theNbComp; aComp++){ - theOutputPtr[aTargetId++] = theInputPtr[aSourceId++]; - } + for(; aPointer != anEndPointer; aPointer += 2){ + TCellId aCellId = *aPointer; + TEntityId anEntityId = *(aPointer + 1); + TObjectId anObjectId(aCellId, anEntityId); + theObjectIdSet.insert(anObjectId); } } - typedef vtkDataArray* (vtkDataSetAttributes::* TGetAttribute)(); - typedef int (vtkDataSetAttributes::* TSetAttribute)(vtkDataArray*); - inline + //--------------------------------------------------------------- void - CopyArray(vtkDataArray* theDataArray, - vtkDataSetAttributes* theOutput, - TSetAttribute theSetAttribute, - vtkIdType theFixedNbTuples) + GetObjectId2TupleIdMap(vtkIntArray *theArray, + TObjectId2TupleIdMap& theObjectId2TupleIdMap) { - if(theDataArray){ - vtkIdType aNbTuples = theDataArray->GetNumberOfTuples(); - if(theFixedNbTuples == aNbTuples) - (theOutput->*theSetAttribute)(theDataArray); + theObjectId2TupleIdMap.clear(); + int* aPointer = theArray->GetPointer(0); + int aNbTuples = theArray->GetNumberOfTuples(); + for(vtkIdType aTupleId = 0; aTupleId < aNbTuples; aTupleId++, aPointer += 2){ + TCellId aCellId = *aPointer; + TEntityId anEntityId = *(aPointer + 1); + TObjectId anObjectId(aCellId, anEntityId); + theObjectId2TupleIdMap[anObjectId] = aTupleId; } } - inline - void - CopyAttribute(vtkDataSetAttributes* theInput, - TGetAttribute theGetAttribute, - vtkDataSetAttributes* theOutput, - TSetAttribute theSetAttribute, - vtkIdType theFixedNbTuples) - { - CopyArray((theInput->*theGetAttribute)(), - theOutput, theSetAttribute, - theFixedNbTuples); - } - vtkDataArray* - DeepCopyArray(vtkDataArray* theDataArray, - vtkDataSetAttributes* theOutput, - TSetAttribute theSetAttribute, - const TSortedArray& theIntersection, - const TId2IdMap& theObj2VTKMap) - { - vtkDataArray *aDataArray = NULL; - if(theDataArray){ - void *anInputPtr = theDataArray->GetVoidPointer(0); - vtkIdType aNbTuples = theIntersection.size(); - vtkIdType aNbComp = theDataArray->GetNumberOfComponents(); - - aDataArray = vtkDataArray::CreateDataArray(theDataArray->GetDataType()); - aDataArray->SetNumberOfComponents(aNbComp); - aDataArray->SetNumberOfTuples(aNbTuples); - void *anOutputPtr = aDataArray->GetVoidPointer(0); - - switch(theDataArray->GetDataType()){ - vtkTemplateMacro5(DeepCopySwitchOnOutput, - (VTK_TT*)anInputPtr, - (VTK_TT*)anOutputPtr, - theIntersection, - theObj2VTKMap, - aNbComp); - default: - vtkGenericWarningMacro(<<"Unsupported data type!"); - } + //--------------------------------------------------------------- + typedef vtkFieldData* (vtkDataSet::* TGetFieldData)(); - (theOutput->*theSetAttribute)(aDataArray); - aDataArray->Delete(); - } - return aDataArray; - } - - void - DeepCopyAttribute(vtkDataSetAttributes* theInput, - TGetAttribute theGetAttribute, - vtkDataSetAttributes* theOutput, - TSetAttribute theSetAttribute, - const TSortedArray& theIntersection, - const TId2IdMap& theObj2VTKMap) + //--------------------------------------------------------------- + struct TGetCellData { - DeepCopyArray((theInput->*theGetAttribute)(), - theOutput, - theSetAttribute, - theIntersection, - theObj2VTKMap); - } - - inline - void - DeepCopyDataSetAttribute(vtkDataSet* theInput, - TGetAttribute theGetAttribute, - vtkDataSet* theOutput, - TSetAttribute theSetAttribute, - const TSortedArray& theIntersection, - const TId2IdMap& theObj2VTKMap) - { - CopyAttribute(theInput->GetPointData(), - theGetAttribute, - theOutput->GetPointData(), - theSetAttribute, - theInput->GetNumberOfPoints()); - DeepCopyAttribute(theInput->GetCellData(), - theGetAttribute, - theOutput->GetCellData(), - theSetAttribute, - theIntersection, - theObj2VTKMap); - } + vtkFieldData* + operator()(vtkDataSet* theDataSet) + { + return theDataSet->GetCellData(); + } + }; - inline - void - DeepCopyField(vtkDataSetAttributes* theInput, - const char* theFieldName, - vtkDataSetAttributes* theOutput, - const TSortedArray& theIntersection, - const TId2IdMap& theObj2VTKMap) - { - vtkDataArray* aDataArray = - DeepCopyArray(theInput->GetArray(theFieldName), - theOutput, - &vtkFieldData::AddArray, - theIntersection, - theObj2VTKMap); - if(aDataArray) - aDataArray->SetName(theFieldName); - } - inline - void - CopyField(vtkDataSetAttributes* theInput, - const char* theFieldName, - vtkDataSetAttributes* theOutput, - vtkIdType theFixedNbTuples) + //--------------------------------------------------------------- + struct TGetPointData { - CopyArray(theInput->GetArray(theFieldName), - theOutput, - &vtkDataSetAttributes::AddArray, - theFixedNbTuples); - } + vtkFieldData* + operator()(vtkDataSet* theDataSet) + { + return theDataSet->GetPointData(); + } + }; - inline - void - DeepCopyDataSetField(vtkDataSet* theInput, - const char* theFieldName, - vtkDataSet* theOutput, - const TSortedArray& theIntersection, - const TId2IdMap& theObj2VTKMap) - { - CopyField(theInput->GetPointData(), theFieldName, - theOutput->GetPointData(), - theInput->GetNumberOfPoints()); - DeepCopyField(theInput->GetCellData(), theFieldName, - theOutput->GetCellData(), - theIntersection, theObj2VTKMap); - } - inline - void - DeepCopyDataSetAttributes(VISU_MergeFilter *theFilter, - vtkDataSet *theFilterOutput, - VISU::TFieldList* theFieldList, - const TSortedArray& theIntersection, - const TId2IdMap& theObj2VTKMap) + //--------------------------------------------------------------- + template + vtkIntArray* + GetIDMapper(VISU::TFieldList* theFieldList, + TGetFieldData theGetFieldData, + const char* theFieldName) { - if(vtkDataSet* aDataSet = theFilter->GetScalars()) - DeepCopyDataSetAttribute(aDataSet, - &vtkDataSetAttributes::GetScalars, - theFilterOutput, - &vtkDataSetAttributes::SetScalars, - theIntersection, - theObj2VTKMap); - - if(vtkDataSet* aDataSet = theFilter->GetVectors()) - DeepCopyDataSetAttribute(aDataSet, - &vtkDataSetAttributes::GetVectors, - theFilterOutput, - &vtkDataSetAttributes::SetVectors, - theIntersection, - theObj2VTKMap); - - if(vtkDataSet* aDataSet = theFilter->GetNormals()) - DeepCopyDataSetAttribute(aDataSet, - &vtkDataSetAttributes::GetNormals, - theFilterOutput, - &vtkDataSetAttributes::SetNormals, - theIntersection, - theObj2VTKMap); - - if(vtkDataSet* aDataSet = theFilter->GetTCoords()) - DeepCopyDataSetAttribute(aDataSet, - &vtkDataSetAttributes::GetTCoords, - theFilterOutput, - &vtkDataSetAttributes::SetTCoords, - theIntersection, - theObj2VTKMap); - - if(vtkDataSet* aDataSet = theFilter->GetTensors()) - DeepCopyDataSetAttribute(aDataSet, - &vtkDataSetAttributes::GetTensors, - theFilterOutput, - &vtkDataSetAttributes::SetTensors, - theIntersection, - theObj2VTKMap); - VISU::TFieldListIterator anIter(theFieldList); for(anIter.Begin(); !anIter.End() ; anIter.Next()){ - vtkDataSet *aDataSet = anIter.Get()->Ptr; const char* aFieldName = anIter.Get()->GetName(); - DeepCopyDataSetField(aDataSet, - aFieldName, - theFilterOutput, - theIntersection, - theObj2VTKMap); - } - } - - inline - void - GetIdsForCopy(vtkUnstructuredGrid *inputUGrid, - vtkIntArray* inputPointIds, - TSortedArray& outputSortedArray) - { - if(inputUGrid){ - TSortedArray aSortedPointIds; - TSortedArray aOutputCellIds; - - TIdSet aMapForSearch; - int nbTuples = inputPointIds->GetNumberOfTuples(); - int nbComp = inputPointIds->GetNumberOfComponents(); - int * aPtr = inputPointIds->GetPointer(0); - int * aPtrEnd = inputPointIds->GetPointer(nbTuples*nbComp+1); - if(nbComp == 1) - while(aPtrGetNumberOfCells(); - - for(int idCell=0;idCellGetCell(idCell); - vtkIdList* ptIds = aCell->GetPointIds(); - int nbPointsInCell = ptIds->GetNumberOfIds(); - bool aGoodCell = true; - for(int i=0;iGetId(i); - TIdSet::iterator aResult = aMapForSearch.find(aSearchingId); - if(aResult == aMapForSearch.end()){ - aGoodCell = false; - break; - } - } - if(aGoodCell) - aOutputCellIds.push_back(idCell); - else - continue; - + if(strcmp(aFieldName, theFieldName) == 0){ + vtkDataSet* aDataSet = anIter.Get()->Ptr; + vtkFieldData *aFieldData = theGetFieldData(aDataSet); + vtkDataArray *anIDMapper = aFieldData->GetArray(theFieldName); + return dynamic_cast(anIDMapper); } - - outputSortedArray.swap(aOutputCellIds); } + return NULL; } - inline - void - CopyElementsToOutput(vtkUnstructuredGrid* theInputUG, - int& theNbElements, - TSortedArray& theElementIdsForCopy, - TId2IdMap& theOldId2NewIdPointsMap, - vtkUnstructuredGrid* theOutputUG) - { - vtkIntArray* theOutputIDSArray = vtkIntArray::New(); - theOutputIDSArray->SetName("VISU_CELLS_MAPPER"); - // the [0] component is element object ID - // the [1] component is entity type - theOutputIDSArray->SetNumberOfComponents(2); - theOutputIDSArray->SetNumberOfTuples(theNbElements); - int* aOutputIDSPtr = theOutputIDSArray->GetPointer(0); - - vtkIntArray* aInputCellsMapper = - dynamic_cast(theInputUG->GetCellData()->GetArray("VISU_CELLS_MAPPER")); - - int* aInputCellsMapperPointer = aInputCellsMapper->GetPointer(0); - - for(int aCellIndex=0;aCellIndexGetCell(aCellId)->GetPointIds(); - vtkIdList* aNewPointIds = vtkIdList::New(); - int nbPointIds = aOldPointIds->GetNumberOfIds(); - aNewPointIds->SetNumberOfIds(nbPointIds); - for(int j=0;jGetId(j); - int aNewId = theOldId2NewIdPointsMap[aOldId]; - aNewPointIds->SetId(j,aNewId); - } - theOutputUG->InsertNextCell(theInputUG->GetCellType(aCellId), - aNewPointIds); - - *aOutputIDSPtr = aInputCellsMapperPointer[2*aCellId]; - aOutputIDSPtr++; - *aOutputIDSPtr = aInputCellsMapperPointer[2*aCellId+1]; - aOutputIDSPtr++; - - aNewPointIds->Delete(); - } - theOutputUG->GetCellData()->AddArray(theOutputIDSArray); - theOutputIDSArray->Delete(); - } - inline - void - copyOneToOneComponent(vtkIntArray* input, - vtkIntArray* output) + //--------------------------------------------------------------- + template + vtkIntArray* + GetIDMapper(vtkDataSet* theIDMapperDataSet, + TGetFieldData theGetFieldData, + const char* theFieldName) { - int nbTuples = input->GetNumberOfTuples(); - int nbComp = input->GetNumberOfComponents(); - int* aInputPtr = input->GetPointer(0); - int* aOutputPtr = output->GetPointer(0); - if(nbComp == 2){ - for(int i=0;iGetArray(theFieldName); + return dynamic_cast(anIDMapper); } - inline + + //--------------------------------------------------------------- bool - isTwoArraysSame(vtkIntArray* theFirst, - vtkIntArray* theSecond) + IsDifferent(vtkIntArray *theFirstIDMapper, + vtkIntArray *theSecondIDMapper) { - int* theFirstPtr = theFirst->GetPointer(0); - int* theSecondPtr = theSecond->GetPointer(0); - int nbTuples1 = theFirst->GetNumberOfTuples(); - int nbTuples2 = theSecond->GetNumberOfTuples(); - if(nbTuples1 != nbTuples2) - return false; - for(int i=0;iGetNumberOfTuples(); + vtkIdType aSecondNbTuples = theSecondIDMapper->GetNumberOfTuples(); + if(aFirstNbTuples != aSecondNbTuples) + return true; -bool -VISU_MergeFilter -::MergeGeometryCellsAndDataOnCells() -{ - if(MYDEBUG) cout << "MergeGeometryCellsAndDataOnCells" << endl; - vtkUnstructuredGrid *anInput = this->GetInput(); - vtkUnstructuredGrid *anOutput = this->GetOutput(); - vtkCellData *aCellData = anInput->GetCellData(); - vtkDataArray *aCellMapper = aCellData->GetArray("VISU_CELLS_MAPPER"); // 1 - vtkIntArray *aGeometryCellMapper = dynamic_cast(aCellMapper); - - // The situation for merging CELLS from anInput as Geometry - // and scalars on cell data - vtkIntArray* aDataCellMapper = NULL; - VISU::TFieldListIterator anIter(this->FieldList); - for(anIter.Begin(); !anIter.End() ; anIter.Next()){ - vtkCellData *aCellData = anIter.Get()->Ptr->GetCellData(); - const char* aFieldName = anIter.Get()->GetName(); - if(strcmp(aFieldName, "VISU_CELLS_MAPPER") == 0){ - vtkDataArray *aCellMapper_tmp = aCellData->GetArray(aFieldName); - aDataCellMapper = dynamic_cast(aCellMapper_tmp); - break; + int aMaxId = theFirstIDMapper->GetMaxId(); + int* aFirstPointer = theFirstIDMapper->GetPointer(0); + int* aSecondPointer = theSecondIDMapper->GetPointer(0); + for(int anId = 0; anId <= aMaxId; anId++){ + if(*aFirstPointer++ != *aSecondPointer++) + return true; } - } - - bool anIsDifferent = aDataCellMapper && - aDataCellMapper->GetNumberOfTuples() != aGeometryCellMapper->GetNumberOfTuples(); - - if(anIsDifferent || IsMergingInputs() ){ - TSortedArray aGeometryCellArray; - vtkIntArray* aGeometryCellMapperOnly = vtkIntArray::New(); - vtkIntArray* aDataCellMapperOnly = vtkIntArray::New(); - aGeometryCellMapperOnly->SetNumberOfComponents(1); - aGeometryCellMapperOnly->SetNumberOfTuples(aGeometryCellMapper->GetNumberOfTuples()); - aGeometryCellMapperOnly->SetName(aGeometryCellMapper->GetName()); - aDataCellMapperOnly->SetNumberOfComponents(1); - aDataCellMapperOnly->SetNumberOfTuples(aDataCellMapper->GetNumberOfTuples()); - aDataCellMapperOnly->SetName(aDataCellMapper->GetName()); - copyOneToOneComponent(aGeometryCellMapper,aGeometryCellMapperOnly); - copyOneToOneComponent(aDataCellMapper,aDataCellMapperOnly); - - GetSortedArray(aGeometryCellMapperOnly, aGeometryCellArray); - TSortedArray aDataCellArray; - GetSortedArray(aDataCellMapperOnly, aDataCellArray); - - int aMaxLength = std::max(aGeometryCellArray.size(), aDataCellArray.size()); - TSortedArray anIntersectionArray(aMaxLength); - TSortedArray::iterator anArrayIter = anIntersectionArray.begin(); - anArrayIter = std::set_intersection(aGeometryCellArray.begin(), - aGeometryCellArray.end(), - aDataCellArray.begin(), - aDataCellArray.end(), - anArrayIter); - - anIntersectionArray.erase(anArrayIter, anIntersectionArray.end()); - - bool anIsCompletelyCoincide = - anIntersectionArray.size() == aGeometryCellArray.size() && - anIntersectionArray.size() == aDataCellArray.size(); - - if(!anIsCompletelyCoincide || IsMergingInputs()){ - { - TId2IdMap anObj2VTKGeometryMap; - vtkIdType aNbCells = aGeometryCellMapperOnly->GetNumberOfTuples(); - int* aGPtr = aGeometryCellMapperOnly->GetPointer(0); - for(int aCellId = 0; aCellId < aNbCells; aCellId++){ - vtkIdType anObjID = *aGPtr; - aGPtr++; - anObj2VTKGeometryMap[anObjID] = aCellId; - } - - vtkIdType aNbTuples = anIntersectionArray.size(); - anOutput->Allocate(aNbTuples); - vtkIdList *aCellIds = vtkIdList::New(); - for(int aTupleId = 0; aTupleId < aNbTuples; aTupleId++){ - vtkIdType anObjID = anIntersectionArray[aTupleId]; - vtkIdType aCellId = anObj2VTKGeometryMap[anObjID]; - vtkCell *aCell = anInput->GetCell(aCellId); - aCellIds->Reset(); - vtkIdType aNbPointIds = aCell->PointIds->GetNumberOfIds(); - for(vtkIdType aPointId = 0; aPointId < aNbPointIds; aPointId++) - aCellIds->InsertNextId(aCell->GetPointIds()->GetId(aPointId)); - anOutput->InsertNextCell(anInput->GetCellType(aCellId), aCellIds); - } - aCellIds->Delete(); - anOutput->SetPoints(anInput->GetPoints()); - } - { - TId2IdMap anObj2VTKDataMap; - vtkIdType aNbCells = aDataCellMapperOnly->GetNumberOfTuples(); - int* aDPtr = aDataCellMapperOnly->GetPointer(0); - for(int aCellId = 0; aCellId < aNbCells; aCellId++){ - vtkIdType anObjID = *aDPtr; - aDPtr++; - anObj2VTKDataMap[anObjID] = aCellId; - } - - DeepCopyDataSetAttributes(this, - anOutput, - this->FieldList, - anIntersectionArray, - anObj2VTKDataMap); - } - aGeometryCellMapperOnly->Delete(); - aDataCellMapperOnly->Delete(); - return true; - } - aGeometryCellMapperOnly->Delete(); - aDataCellMapperOnly->Delete(); + return false; } - return false; -} -bool -VISU_MergeFilter -::MergeGeometryCellsAndDataOnAllPoints() -{ - if(MYDEBUG) cout << "MergeGeometryCellsAndDataOnAllPoints" << endl; - // The situation for merging CELLS from anInput as Geometry - // and scalars on point data - vtkUnstructuredGrid *anInput = this->GetInput(); - vtkUnstructuredGrid *anOutput = this->GetOutput(); - vtkPointData *aPointData = anInput->GetPointData(); - vtkCellData *aCellData = anInput->GetCellData(); - vtkDataSet* aInputScalars = this->GetScalars(); - vtkPointData* aInputScalarsPointData = aInputScalars->GetPointData(); - vtkDataArray *aPointMapper = aPointData->GetArray("VISU_POINTS_MAPPER"); - vtkIntArray *aGeometryPointMapper = dynamic_cast(aPointMapper); - vtkDataArray *aCellMapper = aCellData->GetArray("VISU_CELLS_MAPPER"); // 1 - vtkIntArray *aGeometryCellMapper = dynamic_cast(aCellMapper); // 1->2 - - vtkIntArray* aDataPointMapper = NULL; - VISU::TFieldListIterator anIter(this->FieldList); - for(anIter.Begin(); !anIter.End() ; anIter.Next()){ - const char* aFieldName = anIter.Get()->GetName(); - if(strcmp(aFieldName, "VISU_POINTS_MAPPER") == 0){ - vtkDataArray *aPointMapper = aInputScalarsPointData->GetArray(aFieldName); - aDataPointMapper = dynamic_cast(aPointMapper); - break; - } + //--------------------------------------------------------------- + inline + void + GetIntersection(vtkIntArray *theFirstIDMapper, + vtkIntArray *theSecondIDMapper, + TObjectIdArray& theResult) + { + TObjectIdSet aFirstObjectIdSet; + GetObjectIdSet(theFirstIDMapper, aFirstObjectIdSet); + + TObjectIdSet aSecondObjectIdSet; + GetObjectIdSet(theSecondIDMapper, aSecondObjectIdSet); + + size_t aMaxLength = std::max(aFirstObjectIdSet.size(), aSecondObjectIdSet.size()); + theResult.resize(aMaxLength); + TObjectIdArray::iterator anArrayIter = theResult.begin(); + anArrayIter = std::set_intersection(aFirstObjectIdSet.begin(), + aFirstObjectIdSet.end(), + aSecondObjectIdSet.begin(), + aSecondObjectIdSet.end(), + anArrayIter); + theResult.erase(anArrayIter, theResult.end()); } - - if(aDataPointMapper){ - bool isArraysEqual = isTwoArraysSame(aDataPointMapper,aGeometryPointMapper); - { - TId2IdMap anObj2VTKGeometryPointsMap; - vtkIdType aNbPoints = aDataPointMapper->GetNumberOfTuples(); - if(isArraysEqual){ - for(int aCellId = 0; aCellId < aNbPoints; aCellId++) - anObj2VTKGeometryPointsMap[aCellId] = aCellId; - } else { - // situation: the numbering of points are different in geometry and in scalars - cout << "------------------"<GetNumberOfTuples(); - - // copy points to output - vtkUnstructuredGrid* aUnstructuredScalars = dynamic_cast(aInputScalars); - if(aUnstructuredScalars) - anOutput->SetPoints(aUnstructuredScalars->GetPoints()); - anOutput->GetPointData()->ShallowCopy(aInputScalars->GetPointData()); - - // Calculate output cells - TSortedArray aCellIdsForCopy; - for(int i=0;iAllocate(aNbCells); + TObjectId2TupleIdMap aDataObjectId2TupleIdMap; + GetObjectId2TupleIdMap(theDataCellMapper, aDataObjectId2TupleIdMap); - if(aNbCells>0) - CopyElementsToOutput(anInput, - aNbCells, - aCellIdsForCopy, - anObj2VTKGeometryPointsMap, - anOutput); - - return true; - } - } - return false; -} - -bool -VISU_MergeFilter -::MergeGeometryCellsAndDataOnNotAllPoints() -{ - if(MYDEBUG) cout << "MergeGeometryCellsAndDataOnNotAllPoints" << endl; - // The situation for merging CELLS from anInput as Geometry - // and scalars on point data (there the number of points of point data less than - // number of points of Geometry) - - vtkUnstructuredGrid *anInput = this->GetInput(); - vtkUnstructuredGrid *anOutput = this->GetOutput(); - vtkDataSet* aInputScalars = this->GetScalars(); - vtkPointData *aPointData = anInput->GetPointData(); + vtkCellData *aCellData = theScalarsDataSet->GetCellData(); + vtkCellData *anOutputCellData = theOutput->GetCellData(); + anOutputCellData->CopyAllocate(aCellData); + + vtkIdType aNbTuples = anIntersection.size(); + theOutput->Allocate(aNbTuples); + vtkIdList *aCellIds = vtkIdList::New(); + for(int aTupleId = 0; aTupleId < aNbTuples; aTupleId++){ + TObjectId& anObjectId = anIntersection[aTupleId]; + vtkIdType aCellId = aGeomObjectId2TupleIdMap[anObjectId]; + vtkCell *aCell = theInput->GetCell(aCellId); + aCellIds->Reset(); + vtkIdType aNbPointIds = aCell->PointIds->GetNumberOfIds(); + for(vtkIdType anId = 0; anId < aNbPointIds; anId++) + aCellIds->InsertNextId(aCell->GetPointIds()->GetId(anId)); + vtkIdType aCellType = theInput->GetCellType(aCellId); + vtkIdType aNewCellId = theOutput->InsertNextCell(aCellType, aCellIds); + vtkIdType aDataCellId = aDataObjectId2TupleIdMap[anObjectId]; + anOutputCellData->CopyData(aCellData, aDataCellId, aNewCellId); + } + aCellIds->Delete(); - vtkPointData* aInputScalarsPointData = aInputScalars->GetPointData(); - vtkDataArray *aPointMapper = aPointData->GetArray("VISU_POINTS_MAPPER"); - vtkIntArray *aGeometryPointMapper = dynamic_cast(aPointMapper); - - vtkIntArray* aDataPointMapper = NULL; - VISU::TFieldListIterator anIter(this->FieldList); - for(anIter.Begin(); !anIter.End() ; anIter.Next()){ - const char* aFieldName = anIter.Get()->GetName(); - if(strcmp(aFieldName, "VISU_POINTS_MAPPER") == 0){ - vtkDataArray *aPointMapper = aInputScalarsPointData->GetArray(aFieldName); - aDataPointMapper = dynamic_cast(aPointMapper); - break; - } - } - vtkIntArray* aDataCellMapper = NULL; - VISU::TFieldListIterator anIter2(this->FieldList); - for(anIter2.Begin(); !anIter2.End() ; anIter2.Next()){ - const char* aFieldName = anIter2.Get()->GetName(); - if(strcmp(aFieldName, "VISU_CELLS_MAPPER") == 0){ - vtkDataArray *aCellMapper_tmp = aInputScalarsPointData->GetArray(aFieldName); - aDataCellMapper = dynamic_cast(aCellMapper_tmp); - break; + theOutput->SetPoints(theInput->GetPoints()); + }else{ + theOutput->CopyStructure(theInput); + theOutput->GetCellData()->ShallowCopy(theScalarsDataSet->GetCellData()); } + theOutput->GetPointData()->ShallowCopy(theInput->GetPointData()); } - vtkIntArray* aDataArray = NULL; - VISU::TFieldListIterator anIter3(this->FieldList); - for(anIter2.Begin(); !anIter3.End() ; anIter3.Next()){ - const char* aFieldName = anIter3.Get()->GetName(); - if(strcmp(aFieldName, "VISU_FIELD") == 0){ - vtkDataArray *aPointMapper_tmp = aInputScalarsPointData->GetArray(aFieldName); - aDataArray = dynamic_cast(aPointMapper_tmp); - break; - } - } - - bool anIsDifferent = aDataPointMapper && - aDataPointMapper->GetNumberOfTuples() != aGeometryPointMapper->GetNumberOfTuples(); - if(anIsDifferent){ - { - vtkIntArray* aPointsIds = vtkIntArray::New(); - - TId2IdMap anObj2VTKGeometryMap; - vtkIdType aNbCells = aDataPointMapper->GetNumberOfTuples(); - aPointsIds->SetNumberOfTuples(aNbCells); - aPointsIds->SetNumberOfComponents(1); - vtkIdType aNbComp = aDataPointMapper->GetNumberOfComponents(); - int * aPtr = aDataPointMapper->GetPointer(0); - int * aPtrOut = aPointsIds->GetPointer(0); - if(aNbComp==2){ - for(int aCellId = 0; aCellId < aNbCells; aCellId++){ - vtkIdType anObjID = *aPtr; - aPtr++;aPtr++; - *aPtrOut = anObjID; - aPtrOut++; - anObj2VTKGeometryMap[anObjID] = aCellId; - } - } else if (aNbComp == 1 ){ - for(int aCellId = 0; aCellId < aNbCells; aCellId++){ - vtkIdType anObjID = *aPtr; - aPtr++; - *aPtrOut = anObjID; - aPtrOut++; - anObj2VTKGeometryMap[anObjID] = aCellId; - } + //--------------------------------------------------------------- + void + CopyDataOnPoints(vtkUnstructuredGrid *theInput, + vtkIntArray *theGeometryPointMapper, + vtkIntArray *theDataPointMapper, + vtkDataSet* theScalarsDataSet, + vtkDataSet* theVectorsDataSet, + vtkDataSet* theNormalsDataSet, + vtkDataSet* theTCoordsDataSet, + vtkDataSet* theTensorsDataSet, + VISU::TFieldList* theFieldList, + vtkUnstructuredGrid *theOutput) + { + if(IsDifferent(theGeometryPointMapper, theDataPointMapper)){ + TObjectId2TupleIdMap aDataObjectId2PointIdMap; + GetObjectId2TupleIdMap(theDataPointMapper, aDataObjectId2PointIdMap); + + vtkCellData *aCellData = theInput->GetCellData(); + vtkCellData *anOutputCellData = theOutput->GetCellData(); + anOutputCellData->CopyAllocate(aCellData); + + vtkIdList *aCellIds = vtkIdList::New(); + int aNbCells = theInput->GetNumberOfCells(); + theOutput->Allocate(aNbCells); + for(int aCellId = 0; aCellId < aNbCells; aCellId++){ + aCellIds->Reset(); + vtkCell *aCell = theInput->GetCell(aCellId); + vtkIdType aNbPointIds = aCell->PointIds->GetNumberOfIds(); + for(vtkIdType anId = 0; anId < aNbPointIds; anId++){ + vtkIdType aPointId = aCell->GetPointIds()->GetId(anId); + int* aPointer = theGeometryPointMapper->GetPointer(aPointId * 2); + TCellId aCellId = *aPointer; + TEntityId anEntityId = *(aPointer + 1); + TObjectId anObjectId(aCellId, anEntityId); + TObjectId2TupleIdMap::iterator anIter = aDataObjectId2PointIdMap.find(anObjectId); + if(anIter != aDataObjectId2PointIdMap.end()){ + aPointId = anIter->second; + aCellIds->InsertNextId(aPointId); + }else + goto PASS_INSERT_NEXT_CELL; + } + { + vtkIdType aCellType = theInput->GetCellType(aCellId); + vtkIdType aNewCellId = theOutput->InsertNextCell(aCellType, aCellIds); + anOutputCellData->CopyData(aCellData, aCellId, aNewCellId); + } + PASS_INSERT_NEXT_CELL: + continue; } + aCellIds->Delete(); - vtkUnstructuredGrid* aUnstructuredScalars = dynamic_cast(aInputScalars); - if(aUnstructuredScalars) - anOutput->SetPoints(aUnstructuredScalars->GetPoints()); - - anOutput->GetPointData()->ShallowCopy(aInputScalars->GetPointData()); - - // Calculate output cells - int nbCells=0; - TSortedArray aCellIdsForCopy; - GetIdsForCopy(anInput,aPointsIds,aCellIdsForCopy); - aPointsIds->Delete(); - nbCells = aCellIdsForCopy.size(); - - // copy cells to output - anOutput->Allocate(nbCells); - - if(nbCells>0) - CopyElementsToOutput(anInput, - nbCells, - aCellIdsForCopy, - anObj2VTKGeometryMap, - anOutput); - return true; + vtkPointSet* aScalarsDataSet = dynamic_cast(theScalarsDataSet); + theOutput->SetPoints(aScalarsDataSet->GetPoints()); + }else{ + theOutput->CopyStructure(theInput); + theOutput->GetCellData()->ShallowCopy(theInput->GetCellData()); } - + theOutput->GetPointData()->ShallowCopy(theScalarsDataSet->GetPointData()); } - - return false; } + +//--------------------------------------------------------------- void VISU_MergeFilter ::SetMergingInputs(bool theIsMergingInputs) @@ -956,6 +578,8 @@ VISU_MergeFilter Modified(); } + +//--------------------------------------------------------------- bool VISU_MergeFilter ::IsMergingInputs() @@ -964,45 +588,102 @@ VISU_MergeFilter } +//--------------------------------------------------------------- void VISU_MergeFilter::Execute() { VISU::TTimerLog aTimerLog(MYDEBUG,"VISU_MergeFilter::Execute"); vtkUnstructuredGrid *anInput = this->GetInput(); vtkUnstructuredGrid *anOutput = this->GetOutput(); - - vtkDataSet* aInputScalars = this->GetScalars(); - int nbPointsInScalars = aInputScalars->GetNumberOfPoints(); - int nbPointsInGeometr = anInput->GetNumberOfPoints(); - vtkCellData *aCellData = anInput->GetCellData(); - - vtkDataArray* aScalarsOnCellsArray = NULL; - if(aInputScalars->GetCellData()) - aScalarsOnCellsArray = aInputScalars->GetCellData()->GetArray("VISU_FIELD"); - - vtkDataArray* aScalarsOnPointsArray = NULL; - if(aInputScalars->GetPointData()) - aScalarsOnPointsArray = aInputScalars->GetPointData()->GetArray("VISU_FIELD"); - - vtkDataArray *aCellMapper = aCellData->GetArray("VISU_CELLS_MAPPER"); - vtkIntArray *aGeometryCellMapper = dynamic_cast(aCellMapper); - - if (aGeometryCellMapper && aScalarsOnCellsArray && (nbPointsInScalars == nbPointsInGeometr)){ - if(MergeGeometryCellsAndDataOnCells()) - return; - } else if (aGeometryCellMapper && aScalarsOnPointsArray && (nbPointsInScalars == nbPointsInGeometr)){ - if(MergeGeometryCellsAndDataOnAllPoints()) - return; - } else if (aGeometryCellMapper && (nbPointsInScalars < nbPointsInGeometr)) { - if(MergeGeometryCellsAndDataOnNotAllPoints()) - return; + if(IsMergingInputs()){ + vtkCellData *aCellData = anInput->GetCellData(); + if(vtkDataArray *aCellMapper = aCellData->GetArray("VISU_CELLS_MAPPER")){ + + bool anIsDataOnCells = false; + if(vtkDataSet* aDataSet = GetScalars()) + if(vtkCellData* aCellData = aDataSet->GetCellData()) + anIsDataOnCells = (aCellData->GetArray("VISU_FIELD") != NULL); + + if(anIsDataOnCells){ + vtkIntArray *aGeometryCellMapper = dynamic_cast(aCellMapper); + + vtkIntArray* aDataCellMapper = GetIDMapper(this->FieldList, + TGetCellData(), + "VISU_CELLS_MAPPER"); + CopyDataOnCells(anInput, + aGeometryCellMapper, + aDataCellMapper, + this->GetScalars(), + this->GetVectors(), + this->GetNormals(), + this->GetTCoords(), + this->GetTensors(), + this->FieldList, + anOutput); + }else{ + vtkPointData *aPointData = anInput->GetPointData(); + vtkDataArray *aPointMapper = aPointData->GetArray("VISU_POINTS_MAPPER"); + vtkIntArray *aGeometryPointMapper = dynamic_cast(aPointMapper); + + vtkIntArray* aDataPointMapper = GetIDMapper(this->FieldList, + TGetPointData(), + "VISU_POINTS_MAPPER"); + CopyDataOnPoints(anInput, + aGeometryPointMapper, + aDataPointMapper, + this->GetScalars(), + this->GetVectors(), + this->GetNormals(), + this->GetTCoords(), + this->GetTensors(), + this->FieldList, + anOutput); + } + } + }else{ + anOutput->CopyStructure(anInput); + this->BasicExecute(anOutput); } - - anOutput->CopyStructure(anInput); - this->BasicExecute(anOutput); } + +//--------------------------------------------------------------- namespace { + //--------------------------------------------------------------- + typedef vtkDataArray* (vtkDataSetAttributes::* TGetAttribute)(); + typedef int (vtkDataSetAttributes::* TSetAttribute)(vtkDataArray*); + + inline + void + CopyArray(vtkDataArray* theDataArray, + vtkDataSetAttributes* theOutput, + TSetAttribute theSetAttribute, + vtkIdType theFixedNbTuples) + { + if(theDataArray){ + vtkIdType aNbTuples = theDataArray->GetNumberOfTuples(); + if(theFixedNbTuples == aNbTuples) + (theOutput->*theSetAttribute)(theDataArray); + } + } + + + //--------------------------------------------------------------- + inline + void + CopyAttribute(vtkDataSetAttributes* theInput, + TGetAttribute theGetAttribute, + vtkDataSetAttributes* theOutput, + TSetAttribute theSetAttribute, + vtkIdType theFixedNbTuples) + { + CopyArray((theInput->*theGetAttribute)(), + theOutput, theSetAttribute, + theFixedNbTuples); + } + + + //--------------------------------------------------------------- inline void CopyDataSetAttribute(vtkDataSet *theInput, @@ -1024,6 +705,23 @@ namespace theNbCells); } + + //--------------------------------------------------------------- + inline + void + CopyField(vtkDataSetAttributes* theInput, + const char* theFieldName, + vtkDataSetAttributes* theOutput, + vtkIdType theFixedNbTuples) + { + CopyArray(theInput->GetArray(theFieldName), + theOutput, + &vtkDataSetAttributes::AddArray, + theFixedNbTuples); + } + + + //--------------------------------------------------------------- inline void CopyDataSetField(vtkDataSet* theInput, @@ -1032,17 +730,25 @@ namespace vtkIdType theNbPoints, vtkIdType theNbCells) { - CopyField(theInput->GetPointData(), theFieldName, - theOutput->GetPointData(), - theNbPoints); - CopyField(theInput->GetCellData(), theFieldName, - theOutput->GetCellData(), - theNbCells); + if(theInput){ + CopyField(theInput->GetPointData(), + theFieldName, + theOutput->GetPointData(), + theNbPoints); + CopyField(theInput->GetCellData(), + theFieldName, + theOutput->GetCellData(), + theNbCells); + } } } -void VISU_MergeFilter::BasicExecute(vtkDataSet *output) + +//--------------------------------------------------------------- +void +VISU_MergeFilter +::BasicExecute(vtkDataSet *output) { vtkIdType numPts, numCells; @@ -1106,3 +812,6 @@ void VISU_MergeFilter::BasicExecute(vtkDataSet *output) numCells); } } + + +//--------------------------------------------------------------- diff --git a/src/CONVERTOR/VISU_MergeFilter.hxx b/src/CONVERTOR/VISU_MergeFilter.hxx index fb18bb51..f37d9061 100644 --- a/src/CONVERTOR/VISU_MergeFilter.hxx +++ b/src/CONVERTOR/VISU_MergeFilter.hxx @@ -47,6 +47,10 @@ public: static VISU_MergeFilter *New(); vtkTypeMacro(VISU_MergeFilter,vtkUnstructuredGridToUnstructuredGridFilter); + virtual + unsigned long + GetMTime(); + // Description: // Specify object from which to extract geometry information. void SetGeometry(vtkUnstructuredGrid *input) {this->SetInput(input);}; @@ -108,10 +112,6 @@ protected: bool myIsMergingInputs; private: - bool MergeGeometryCellsAndDataOnCells(); - bool MergeGeometryCellsAndDataOnAllPoints(); - bool MergeGeometryCellsAndDataOnNotAllPoints(); - VISU_MergeFilter(const VISU_MergeFilter&); // Not implemented. void operator=(const VISU_MergeFilter&); // Not implemented. }; diff --git a/src/OBJECT/VISU_Actor.cxx b/src/OBJECT/VISU_Actor.cxx index c2f6a388..0aeb54ae 100644 --- a/src/OBJECT/VISU_Actor.cxx +++ b/src/OBJECT/VISU_Actor.cxx @@ -31,6 +31,7 @@ #include "VTKViewer_ShrinkFilter.h" #include "VTKViewer_GeometryFilter.h" #include "VTKViewer_PassThroughFilter.h" +#include "VISU_ConvertorUtils.hxx" #include #include @@ -411,12 +412,7 @@ VISU_Actor if(myIsVTKMapping) return Superclass::GetNodeObjId(theID); - vtkIdType anID = myGeomFilter->GetNodeObjId(theID); - - if(myIsShrunk) - anID = myShrinkFilter->GetNodeObjId(anID); - - return GetCurrentPL()->GetNodeObjID(anID); + return VISU::GetNodeObjID(GetMapper()->GetInput(), theID); } vtkIdType @@ -426,7 +422,7 @@ VISU_Actor if(myIsVTKMapping) return theID; - return GetCurrentPL()->GetNodeVTKID(theID); + return VISU::GetNodeVTKID(GetMapper()->GetInput(), theID); } vtkFloatingPointType* @@ -436,7 +432,7 @@ VISU_Actor if(myIsVTKMapping) return Superclass::GetNodeCoord(theObjID); - return GetCurrentPL()->GetNodeCoord(theObjID); + return VISU::GetNodeCoord(GetInput(), theObjID); } @@ -448,12 +444,7 @@ VISU_Actor if(myIsVTKMapping) return Superclass::GetElemObjId(theID); - vtkIdType anID = myGeomFilter->GetElemObjId(theID); - - if(myIsShrunk) - anID = myShrinkFilter->GetElemObjId(anID); - - return GetCurrentPL()->GetElemObjID(anID); + return VISU::GetElemObjID(GetMapper()->GetInput(), theID); } vtkIdType @@ -463,7 +454,7 @@ VISU_Actor if(myIsVTKMapping) return theID; - return GetCurrentPL()->GetElemVTKID(theID); + return VISU::GetElemVTKID(GetMapper()->GetInput(), theID); } vtkCell* @@ -473,7 +464,7 @@ VISU_Actor if(myIsVTKMapping) return Superclass::GetElemCell(theObjID); - return GetCurrentPL()->GetElemCell(theObjID); + return VISU::GetElemCell(GetInput(), theObjID); } diff --git a/src/PIPELINE/Makefile.in b/src/PIPELINE/Makefile.in index 64ee4b76..690882d6 100644 --- a/src/PIPELINE/Makefile.in +++ b/src/PIPELINE/Makefile.in @@ -58,7 +58,8 @@ EXPORT_HEADERS = \ VISU_SphereWidget.hxx \ VISU_WidgetCtrl.hxx \ VISU_ScalarMapOnDeformedShapePL.hxx \ - VISU_PrsMergerPL.hxx + VISU_PrsMergerPL.hxx \ + VISU_CellDataToPointData.hxx # Libraries targets @@ -89,7 +90,8 @@ LIB_SRC = \ VISU_WidgetCtrl.cxx \ VISU_ScalarBarCtrl.cxx \ VISU_ScalarMapOnDeformedShapePL.cxx \ - VISU_PrsMergerPL.cxx + VISU_PrsMergerPL.cxx \ + VISU_CellDataToPointData.cxx # Executables targets diff --git a/src/PIPELINE/VISUPipeLine.cxx b/src/PIPELINE/VISUPipeLine.cxx index 2af09bb9..7c93e0c9 100644 --- a/src/PIPELINE/VISUPipeLine.cxx +++ b/src/PIPELINE/VISUPipeLine.cxx @@ -27,16 +27,18 @@ #include "VISU_Convertor.hxx" #include "VISU_MeshPL.hxx" #include "VISU_ScalarMapPL.hxx" +#include "VISU_PrsMergerPL.hxx" #include "VISU_IsoSurfacesPL.hxx" #include "VISU_CutPlanesPL.hxx" #include "VISU_CutLinesPL.hxx" #include "VISU_DeformedShapePL.hxx" +#include "VISU_ScalarMapOnDeformedShapePL.hxx" #include "VISU_VectorsPL.hxx" #include "VISU_StreamLinesPL.hxx" #include "VISU_GaussPointsPL.hxx" #include "VISU_Plot3DPL.hxx" -typedef VISU_GaussPointsPL TPresent; +typedef VISU_DeformedShapePL TPresent; #include #include @@ -67,6 +69,7 @@ int main(int argc, char** argv){ iren->SetRenderWindow(renWin); VISU_Convertor* aConvertor = CreateConvertor(argv[1]); aConvertor->BuildEntities(); + aConvertor->BuildGroups(); aConvertor->BuildFields(); aConvertor->BuildMinMax(); const VISU::TMeshMap& aMeshMap = aConvertor->GetMeshMap(); @@ -120,32 +123,47 @@ int main(int argc, char** argv){ TPresent* aPresent = TPresent::New(); VISU::PIDMapper anIDMapper; - if(anEntity != VISU::NODE_ENTITY){ - VISU::PGaussPtsIDMapper aGaussPtsIDMapper = aConvertor->GetTimeStampOnGaussPts(aMeshName,anEntity,aFieldName,aTimeStamp); - aPresent->SetGaussPtsIDMapper(aGaussPtsIDMapper); - }else{ + if(anEntity == VISU::NODE_ENTITY){ continue; + //VISU::PGaussPtsIDMapper aGaussPtsIDMapper = aConvertor->GetTimeStampOnGaussPts(aMeshName,anEntity,aFieldName,aTimeStamp); + //aPresent->SetGaussPtsIDMapper(aGaussPtsIDMapper); + }else{ VISU::PIDMapper anIDMapper = aConvertor->GetTimeStampOnMesh(aMeshName,anEntity,aFieldName,aTimeStamp); aPresent->SetIDMapper(anIDMapper); } aPresent->Build(); aPresent->Init(); - - char aMainTexture[80]; - strcpy( aMainTexture, getenv( "VISU_ROOT_DIR" ) ); - strcat( aMainTexture, "/share/salome/resources/visu/sprite_texture.vti" ); - //cout << aMainTexture << endl; - - char anAlphaTexture[80]; - strcpy( anAlphaTexture, getenv( "VISU_ROOT_DIR" ) ); - strcat( anAlphaTexture, "/share/salome/resources/visu/sprite_alpha.vti" ); - //cout << anAlphaTexture << endl; - - vtkSmartPointer aTextureValue = VISU_GaussPointsPL::MakeTexture( aMainTexture, anAlphaTexture ); - aPresent->SetImageData( aTextureValue.GetPointer() ); - aPresent->Update(); + //aPresent->SetScalars(aPresent->GetInput()); + //aPresent->Build(); + //aPresent->Init(); + //aPresent->RemoveAllGeom(); + //{ + // VISU::PIDMapper anIDMapper = aConvertor->GetMeshOnGroup(aMeshName, + // //"TUYAU "); + // "groupe1"); + // VISU_MeshPL* aGeomPresent = VISU_MeshPL::New(); + // aGeomPresent->SetIDMapper(anIDMapper); + // aGeomPresent->Build(); + // aPresent->AddBackGeometry(aGeomPresent); + //} + aPresent->Update(); + +// char aMainTexture[80]; +// strcpy( aMainTexture, getenv( "VISU_ROOT_DIR" ) ); +// strcat( aMainTexture, "/share/salome/resources/visu/sprite_texture.vti" ); +// //cout << aMainTexture << endl; +// +// char anAlphaTexture[80]; +// strcpy( anAlphaTexture, getenv( "VISU_ROOT_DIR" ) ); +// strcat( anAlphaTexture, "/share/salome/resources/visu/sprite_alpha.vti" ); +// //cout << anAlphaTexture << endl; +// +// vtkSmartPointer aTextureValue = VISU_GaussPointsPL::MakeTexture( aMainTexture, anAlphaTexture ); +// aPresent->SetImageData( aTextureValue.GetPointer() ); +// +// aPresent->Update(); vtkActor* anActor = vtkActor::New(); anActor->SetMapper(aPresent->GetMapper()); diff --git a/src/PIPELINE/VISU_CellDataToPointData.cxx b/src/PIPELINE/VISU_CellDataToPointData.cxx new file mode 100644 index 00000000..30532952 --- /dev/null +++ b/src/PIPELINE/VISU_CellDataToPointData.cxx @@ -0,0 +1,135 @@ +// VISU OBJECT : interactive object for VISU entities implementation +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// File: VISU_CellDataToPointData.cxx +// Author: Alexey PETROV +// Module : VISU + + +#include "VISU_CellDataToPointData.hxx" + +#include +#include +#include +#include +#include + +vtkStandardNewMacro(VISU_CellDataToPointData); + +VISU_CellDataToPointData +::VISU_CellDataToPointData() +{} + +#define VTK_MAX_CELLS_PER_POINT 4096 + +void VISU_CellDataToPointData::Execute() +{ + vtkIdType cellId, ptId; + vtkIdType numCells, numPts; + vtkDataSet *input= this->GetInput(); + vtkDataSet *output= this->GetOutput(); + vtkCellData *inPD=input->GetCellData(); + vtkPointData *outPD=output->GetPointData(); + vtkIdList *cellIds; + float weight; + float *weights; + + vtkDebugMacro(<<"Mapping cell data to point data"); + + // First, copy the input to the output as a starting point + output->CopyStructure( input ); + + cellIds = vtkIdList::New(); + cellIds->Allocate(VTK_MAX_CELLS_PER_POINT); + + if ( (numPts=input->GetNumberOfPoints()) < 1 ) + { + vtkErrorMacro(<<"No input point data!"); + cellIds->Delete(); + return; + } + weights = new float[VTK_MAX_CELLS_PER_POINT]; + + outPD->CopyAllocate(inPD,numPts); + + int abort=0; + vtkIdType progressInterval=numPts/20 + 1; + for (ptId=0; ptId < numPts && !abort; ptId++) + { + if ( !(ptId % progressInterval) ) + { + this->UpdateProgress((float)ptId/numPts); + abort = GetAbortExecute(); + } + + input->GetPointCells(ptId, cellIds); + numCells = cellIds->GetNumberOfIds(); + if ( numCells > 0 ) + { + weight = 1.0 / numCells; + for (cellId=0; cellId < numCells; cellId++) + { + weights[cellId] = weight; + } + outPD->InterpolatePoint(inPD, ptId, cellIds, weights); + } + else + { + outPD->NullPoint(ptId); + } + } + + // Pass the point data first. The fields and attributes + // which also exist in the cell data of the input will + // be missed + { + vtkPointData* anInputPointData = input->GetPointData(); + vtkPointData* anOutputPointData = output->GetPointData(); + + int aNbAttributeTypes = vtkDataSetAttributes::NUM_ATTRIBUTES; + for(int anAttribueType = 0; anAttribueType < aNbAttributeTypes; anAttribueType++){ + if(vtkDataArray* anInputAttribute = anInputPointData->GetAttribute(anAttribueType)){ + if(anOutputPointData->GetAttribute(anAttribueType) == NULL){ + int anArrayId = anOutputPointData->AddArray(anInputAttribute); + anOutputPointData->SetActiveAttribute(anArrayId, anAttribueType); + } + } + } + + int aNbOfInputArrays = anInputPointData->GetNumberOfArrays(); + for(int anArrayId = 0; anArrayId < aNbOfInputArrays; anArrayId++){ + if(anInputPointData->IsArrayAnAttribute(anArrayId) < 0){ + vtkDataArray* anInputArray = anInputPointData->GetArray(anArrayId); + if(anOutputPointData->GetArray(anInputArray->GetName()) == NULL) + anOutputPointData->AddArray(anInputArray); + } + } + } + + if ( this->GetPassCellData() ) + { + output->GetCellData()->PassData(input->GetCellData()); + } + + cellIds->Delete(); + delete [] weights; +} diff --git a/src/PIPELINE/VISU_CellDataToPointData.hxx b/src/PIPELINE/VISU_CellDataToPointData.hxx new file mode 100644 index 00000000..172ebc3c --- /dev/null +++ b/src/PIPELINE/VISU_CellDataToPointData.hxx @@ -0,0 +1,51 @@ +// VISU OBJECT : interactive object for VISU entities implementation +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// File: VISU_CellDataToPointData.hxx +// Author: Alexey PETROV +// Module : VISU + + +#ifndef VISU_CellDataToPointData_HeaderFile +#define VISU_CellDataToPointData_HeaderFile + +#include + +class VISU_CellDataToPointData : public vtkCellDataToPointData +{ +public: + static VISU_CellDataToPointData *New(); + vtkTypeMacro(VISU_CellDataToPointData, vtkCellDataToPointData); + +protected: + VISU_CellDataToPointData(); + + void Execute(); + +private: + VISU_CellDataToPointData(const VISU_CellDataToPointData&); // Not implemented. + void operator=(const VISU_CellDataToPointData&); // Not implemented. +}; + +#endif + + diff --git a/src/PIPELINE/VISU_CutLinesPL.cxx b/src/PIPELINE/VISU_CutLinesPL.cxx index 3da0ca4a..86fcaeee 100644 --- a/src/PIPELINE/VISU_CutLinesPL.cxx +++ b/src/PIPELINE/VISU_CutLinesPL.cxx @@ -89,7 +89,7 @@ VISU_CutLinesPL vtkFloatingPointType aPosition = myPosition; if(myCondition){ vtkFloatingPointType aDir[3], aBounds[6], aBoundPrj[3]; - GetInput2()->GetBounds(aBounds); + GetMergedInput()->GetBounds(aBounds); GetDir(aDir,myAng[0],myBasePlane[0]); GetBoundProject(aBoundPrj,aBounds,aDir); aPosition = aBoundPrj[0] + aBoundPrj[2]*myDisplacement[0]; @@ -122,22 +122,33 @@ VISU_CutLinesPL vtkAppendPolyData *anAppendPolyData = vtkAppendPolyData::New(); //Build base plane vtkFloatingPointType aDir[2][3], aBaseBounds[6]; - GetInput2()->GetBounds(aBaseBounds); + vtkPointSet* aPointSet = GetMergedInput(); + aPointSet->GetBounds(aBaseBounds); GetDir(aDir[0],myAng[0],myBasePlane[0]); - vtkUnstructuredGrid* anUnstructuredGrid = - myFieldTransform->GetUnstructuredGridOutput(); - CutWithPlanes(anAppendPolyData,anUnstructuredGrid,1,aDir[0],aBaseBounds, - myPosition,myCondition,myDisplacement[0]); + CutWithPlanes(anAppendPolyData, + aPointSet, + 1, + aDir[0], + aBaseBounds, + myPosition, + myCondition, + myDisplacement[0]); //Build lines vtkFloatingPointType aBounds[6]; vtkDataSet *aDataSet = anAppendPolyData->GetOutput(); aDataSet->Update(); if(aDataSet->GetNumberOfCells() == 0) - aDataSet = anUnstructuredGrid; + aDataSet = aPointSet; aDataSet->GetBounds(aBounds); GetDir(aDir[1],myAng[1],myBasePlane[1]); - VISU_CutPlanesPL::CutWithPlanes(myAppendPolyData,aDataSet,GetNbParts(),aDir[1],aBounds, - myPartPosition,myPartCondition,myDisplacement[1]); + VISU_CutPlanesPL::CutWithPlanes(myAppendPolyData, + aDataSet, + GetNbParts(), + aDir[1], + aBounds, + myPartPosition, + myPartCondition, + myDisplacement[1]); anAppendPolyData->Register(myAppendPolyData); anAppendPolyData->Delete(); //Calculate values for building of table diff --git a/src/PIPELINE/VISU_CutPlanesPL.cxx b/src/PIPELINE/VISU_CutPlanesPL.cxx index b858181d..c897d301 100644 --- a/src/PIPELINE/VISU_CutPlanesPL.cxx +++ b/src/PIPELINE/VISU_CutPlanesPL.cxx @@ -91,9 +91,9 @@ VISU_CutPlanesPL myAng[0][0] = myAng[0][1] = myAng[0][2] = 0.0; } -VISU_ScalarMapPL::THook* +VISU_ScalarMapPL::TInsertCustomPL* VISU_CutPlanesPL -::DoHook() +::InsertCustomPL() { return myAppendPolyData->GetOutput(); } @@ -102,17 +102,26 @@ void VISU_CutPlanesPL ::Update() { + Superclass::Update(); + ClearAppendPolyData(myAppendPolyData); SetPartPosition(); + vtkFloatingPointType aDir[3]; GetDir(aDir,myAng[0],myBasePlane[0]); - vtkFloatingPointType aBounds[6]; - GetInput2()->GetBounds(aBounds); - vtkDataSet* aDataSet = myFieldTransform->GetUnstructuredGridOutput(); - CutWithPlanes(myAppendPolyData,aDataSet,myNbParts,aDir,aBounds, - myPartPosition,myPartCondition,myDisplacement[0]); - Superclass::Update(); + vtkFloatingPointType aBounds[6]; + vtkPointSet* aMergedInput = GetMergedInput(); + aMergedInput->GetBounds(aBounds); + + CutWithPlanes(myAppendPolyData, + aMergedInput, + myNbParts, + aDir, + aBounds, + myPartPosition, + myPartCondition, + myDisplacement[0]); } void @@ -290,7 +299,7 @@ VISU_CutPlanesPL vtkFloatingPointType aPosition = myPartPosition[thePartNumber]; if(myPartCondition[thePartNumber]){ vtkFloatingPointType aDir[3], aBounds[6], aBoundPrj[3]; - GetInput2()->GetBounds(aBounds); + GetMergedInput()->GetBounds(aBounds); GetDir(aDir,myAng[theNum],myBasePlane[theNum]); GetBoundProject(aBoundPrj,aBounds,aDir); if (myNbParts > 1){ diff --git a/src/PIPELINE/VISU_CutPlanesPL.hxx b/src/PIPELINE/VISU_CutPlanesPL.hxx index 0be096b9..a5e77a3e 100644 --- a/src/PIPELINE/VISU_CutPlanesPL.hxx +++ b/src/PIPELINE/VISU_CutPlanesPL.hxx @@ -190,8 +190,8 @@ public: vtkFloatingPointType theDisplacement); protected: virtual - THook* - DoHook(); + TInsertCustomPL* + InsertCustomPL(); void SetPartPosition(int theNum = 0); diff --git a/src/PIPELINE/VISU_DeformedShapePL.cxx b/src/PIPELINE/VISU_DeformedShapePL.cxx index 0a69dc9b..db852b99 100644 --- a/src/PIPELINE/VISU_DeformedShapePL.cxx +++ b/src/PIPELINE/VISU_DeformedShapePL.cxx @@ -26,8 +26,9 @@ #include "VISU_DeformedShapePL.hxx" -#include "VISU_PipeLineUtils.hxx" +#include "VISU_CellDataToPointData.hxx" #include "VTKViewer_Transform.h" +#include "VISU_PipeLineUtils.hxx" #include @@ -37,7 +38,7 @@ VISU_DeformedShapePL ::VISU_DeformedShapePL() { myWarpVector = vtkWarpVector::New(); - myCellDataToPointData = vtkCellDataToPointData::New(); + myCellDataToPointData = VISU_CellDataToPointData::New(); } VISU_DeformedShapePL @@ -57,14 +58,15 @@ VISU_DeformedShapePL if(VISU_DeformedShapePL *aPipeLine = dynamic_cast(thePipeLine)){ SetScale(aPipeLine->GetScale()); } - TSupperClass::ShallowCopy(thePipeLine); + Superclass::ShallowCopy(thePipeLine); } vtkFloatingPointType VISU_DeformedShapePL ::GetScaleFactor(vtkDataSet* theDataSet) { - if(!theDataSet) return 0.0; + if(!theDataSet) + return 0.0; theDataSet->Update(); int aNbCells = theDataSet->GetNumberOfCells(); int aNbPoints = theDataSet->GetNumberOfPoints(); @@ -103,12 +105,12 @@ void VISU_DeformedShapePL ::Init() { - TSupperClass::Init(); + Superclass::Init(); + vtkFloatingPointType aScalarRange[2]; GetSourceRange(aScalarRange); - vtkDataSet* aDataSet = GetInput2(); - //vtkDataSet* aDataSet = GetScalars()->GetInput(); + vtkDataSet* aDataSet = GetMergedInput(); vtkFloatingPointType aScaleFactor = VISU_DeformedShapePL::GetScaleFactor( aDataSet ); static double EPS = 1.0 / VTK_LARGE_FLOAT; @@ -118,26 +120,41 @@ VISU_DeformedShapePL SetScale(0.0); } -VISU_ScalarMapPL::THook* +void VISU_DeformedShapePL -::DoHook() +::Build() { - VISU::CellDataToPoint(myWarpVector,myCellDataToPointData,GetInput2(),myFieldTransform); - return myWarpVector->GetOutput(); + Superclass::Build(); + + VISU::CellDataToPoint(myWarpVector, + myCellDataToPointData, + GetMergedInput()); + //{ + // std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-myMergeFilter3-.vtk"; + // VISU::WriteToFile(dynamic_cast(GetMergedInput()), aFileName); + //} + //{ + // std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-myMergeFilter3.vtk"; + // VISU::WriteToFile(myCellDataToPointData->GetUnstructuredGridOutput(), aFileName); + //} + //{ + // std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-myMergeFilter3+.vtk"; + // VISU::WriteToFile(myWarpVector->GetUnstructuredGridOutput(), aFileName); + //} } -void +VISU_ScalarMapPL::TInsertCustomPL* VISU_DeformedShapePL -::Update() +::InsertCustomPL() { - TSupperClass::Update(); + return myWarpVector->GetOutput(); } void VISU_DeformedShapePL ::SetMapScale(vtkFloatingPointType theMapScale) { - TSupperClass::SetMapScale(theMapScale); + Superclass::SetMapScale(theMapScale); myWarpVector->SetScaleFactor(myScaleFactor*theMapScale); Modified(); diff --git a/src/PIPELINE/VISU_DeformedShapePL.hxx b/src/PIPELINE/VISU_DeformedShapePL.hxx index 4cb3aa8b..f6def0ed 100644 --- a/src/PIPELINE/VISU_DeformedShapePL.hxx +++ b/src/PIPELINE/VISU_DeformedShapePL.hxx @@ -29,14 +29,13 @@ #include "VISU_PrsMergerPL.hxx" -class vtkCellDataToPointData; +class VISU_CellDataToPointData; class SALOME_Transform; + class vtkWarpVector; class VISU_DeformedShapePL : public VISU_PrsMergerPL { - typedef VISU_PrsMergerPL TSupperClass; - protected: VISU_DeformedShapePL(); VISU_DeformedShapePL(const VISU_DeformedShapePL&); @@ -45,7 +44,7 @@ protected: ~VISU_DeformedShapePL(); public: - vtkTypeMacro(VISU_DeformedShapePL,TSupperClass); + vtkTypeMacro(VISU_DeformedShapePL, VISU_PrsMergerPL); static VISU_DeformedShapePL* @@ -70,7 +69,7 @@ public: virtual void - Update(); + Build(); virtual void @@ -82,12 +81,12 @@ public: protected: virtual - THook* - DoHook(); + TInsertCustomPL* + InsertCustomPL(); vtkFloatingPointType myScaleFactor; vtkWarpVector *myWarpVector; - vtkCellDataToPointData* myCellDataToPointData; + VISU_CellDataToPointData* myCellDataToPointData; }; diff --git a/src/PIPELINE/VISU_GaussPointsPL.cxx b/src/PIPELINE/VISU_GaussPointsPL.cxx index 3ffc7564..a27a63ae 100644 --- a/src/PIPELINE/VISU_GaussPointsPL.cxx +++ b/src/PIPELINE/VISU_GaussPointsPL.cxx @@ -28,12 +28,14 @@ #include "VISU_GaussPointsPL.hxx" #include "VISU_DeformedShapePL.hxx" -#include "VISU_PipeLineUtils.hxx" +#include "VISU_CellDataToPointData.hxx" #include "SALOME_ExtractGeometry.h" #include "VISU_DeformedShapePL.hxx" #include "VISU_OpenGLPointSpriteMapper.hxx" #include "VTKViewer_PassThroughFilter.h" +#include "VISU_PipeLineUtils.hxx" + #include #include #include @@ -64,7 +66,7 @@ VISU_GaussPointsPL myGeomFilter = vtkGeometryFilter::New(); myWarpVector = vtkWarpVector::New(); - myCellDataToPointData = vtkCellDataToPointData::New(); + myCellDataToPointData = VISU_CellDataToPointData::New(); myCellDataToPointData->SetPassCellData(true); myGlyph = vtkGlyph3D::New(); @@ -72,9 +74,6 @@ VISU_GaussPointsPL myGlyph->SetColorModeToColorByScalar(); myGlyph->ClampingOn(); - myExtractor->SetInput( myExtractGeometry->GetOutput() ); - myFieldTransform->SetInput( myExtractor->GetOutput() ); - myCellDataToPointData->SetInput( myFieldTransform->GetUnstructuredGridOutput() ); mySphereSource = vtkSphereSource::New(); @@ -172,7 +171,7 @@ VISU_GaussPointsPL { if(GetInput()){ if(!myPSMapper->GetInput()){ - GetInput2()->Update(); + GetClippedInput()->Update(); Build(); Init(); } diff --git a/src/PIPELINE/VISU_GaussPointsPL.hxx b/src/PIPELINE/VISU_GaussPointsPL.hxx index 4acd793f..0c86a8e3 100644 --- a/src/PIPELINE/VISU_GaussPointsPL.hxx +++ b/src/PIPELINE/VISU_GaussPointsPL.hxx @@ -33,6 +33,8 @@ #include +class SALOME_Transform; +class VISU_CellDataToPointData; class VTKViewer_PassThroughFilter; class VISU_OpenGLPointSpriteMapper; @@ -43,9 +45,7 @@ class vtkDataArray; class vtkImageData; class vtkPointSet; -class vtkCellDataToPointData; class vtkWarpVector; -class SALOME_Transform; //! Pipeline for the Gauss Points presentation. /*! @@ -267,7 +267,7 @@ protected: bool myIsDeformed; vtkFloatingPointType myScaleFactor; vtkWarpVector *myWarpVector; - vtkCellDataToPointData* myCellDataToPointData; + VISU_CellDataToPointData* myCellDataToPointData; std::vector myPassFilter; vtkGlyph3D* myGlyph; diff --git a/src/PIPELINE/VISU_IsoSurfacesPL.cxx b/src/PIPELINE/VISU_IsoSurfacesPL.cxx index c8b9eaea..f8fa6b7b 100644 --- a/src/PIPELINE/VISU_IsoSurfacesPL.cxx +++ b/src/PIPELINE/VISU_IsoSurfacesPL.cxx @@ -27,6 +27,7 @@ #include "VISU_IsoSurfacesPL.hxx" +#include "VISU_CellDataToPointData.hxx" #include "VISU_PipeLineUtils.hxx" #include @@ -37,7 +38,7 @@ VISU_IsoSurfacesPL ::VISU_IsoSurfacesPL() { myContourFilter = vtkContourFilter::New(); - myCellDataToPointData = vtkCellDataToPointData::New(); + myCellDataToPointData = VISU_CellDataToPointData::New(); myIsShrinkable = false; } @@ -60,7 +61,7 @@ VISU_IsoSurfacesPL vtkFloatingPointType aRange[2] = {aPipeLine->GetMin(), aPipeLine->GetMax()}; SetRange(aRange); } - TSupperClass::ShallowCopy(thePipeLine); + Superclass::ShallowCopy(thePipeLine); } int @@ -82,7 +83,7 @@ void VISU_IsoSurfacesPL ::SetScaling(int theScaling) { - TSupperClass::SetScaling(theScaling); + Superclass::SetScaling(theScaling); SetRange(myRange); } void @@ -118,7 +119,7 @@ void VISU_IsoSurfacesPL ::Init() { - TSupperClass::Init(); + Superclass::Init(); SetNbParts(10); vtkFloatingPointType aScalarRange[2]; @@ -126,27 +127,30 @@ VISU_IsoSurfacesPL SetRange(aScalarRange); } -VISU_ScalarMapPL::THook* +VISU_ScalarMapPL::TInsertCustomPL* VISU_IsoSurfacesPL -::DoHook() +::InsertCustomPL() { - VISU::CellDataToPoint(myContourFilter,myCellDataToPointData,GetInput2(),myFieldTransform); return myContourFilter->GetOutput(); } void VISU_IsoSurfacesPL -::Update() +::Build() { - TSupperClass::Update(); + Superclass::Build(); + + VISU::CellDataToPoint(myContourFilter, + myCellDataToPointData, + GetMergedInput()); } void VISU_IsoSurfacesPL ::SetMapScale(vtkFloatingPointType theMapScale) { - TSupperClass::SetMapScale(theMapScale); + Superclass::SetMapScale(theMapScale); vtkFloatingPointType aRange[2] = {GetMax() - theMapScale*(GetMax()-GetMin()), GetMax()}; vtkFloatingPointType aNewRange[2] = {aRange[0], aRange[1]}; diff --git a/src/PIPELINE/VISU_IsoSurfacesPL.hxx b/src/PIPELINE/VISU_IsoSurfacesPL.hxx index bd29bbb9..3ab0cf4f 100644 --- a/src/PIPELINE/VISU_IsoSurfacesPL.hxx +++ b/src/PIPELINE/VISU_IsoSurfacesPL.hxx @@ -29,13 +29,12 @@ #include "VISU_PrsMergerPL.hxx" +class VISU_CellDataToPointData; + class vtkContourFilter; -class vtkCellDataToPointData; class VISU_IsoSurfacesPL : public VISU_PrsMergerPL { - typedef VISU_ScalarMapPL TSupperClass; - protected: VISU_IsoSurfacesPL(); VISU_IsoSurfacesPL(const VISU_IsoSurfacesPL&); @@ -44,7 +43,7 @@ protected: ~VISU_IsoSurfacesPL(); public: - vtkTypeMacro(VISU_IsoSurfacesPL,TSupperClass); + vtkTypeMacro(VISU_IsoSurfacesPL, VISU_PrsMergerPL); static VISU_IsoSurfacesPL* @@ -85,11 +84,11 @@ public: virtual void - Update(); + Build(); virtual - THook* - DoHook(); + TInsertCustomPL* + InsertCustomPL(); virtual void @@ -98,7 +97,7 @@ public: protected: int myNbParts; vtkFloatingPointType myRange[2]; - vtkCellDataToPointData* myCellDataToPointData; + VISU_CellDataToPointData* myCellDataToPointData; vtkContourFilter *myContourFilter; }; diff --git a/src/PIPELINE/VISU_MeshPL.cxx b/src/PIPELINE/VISU_MeshPL.cxx index b4730bc3..e08b3413 100644 --- a/src/PIPELINE/VISU_MeshPL.cxx +++ b/src/PIPELINE/VISU_MeshPL.cxx @@ -43,7 +43,7 @@ VISU_MeshPL::VISU_MeshPL() void VISU_MeshPL::Build() { - myMapper->SetInput(GetInput2()); + myMapper->SetInput(GetClippedInput()); } void VISU_MeshPL::Init() diff --git a/src/PIPELINE/VISU_PipeLine.cxx b/src/PIPELINE/VISU_PipeLine.cxx index 91e05edb..ea4f8da7 100644 --- a/src/PIPELINE/VISU_PipeLine.cxx +++ b/src/PIPELINE/VISU_PipeLine.cxx @@ -122,7 +122,7 @@ VISU_PipeLine GetImplicitFunction()->Delete(); } -TInput* +VISU_PipeLine::TInput* VISU_PipeLine ::GetInput() const { @@ -136,18 +136,18 @@ VISU_PipeLine return GetMapper()->GetInput(); } -TInput* +VISU_PipeLine::TInput* VISU_PipeLine -::GetInput2() const +::GetClippedInput() { - vtkUnstructuredGrid* aDataSet = myExtractGeometry->GetOutput(); - aDataSet->Update(); - return aDataSet; + if(myExtractGeometry->GetInput()) + myExtractGeometry->Update(); + return myExtractGeometry->GetOutput(); } void VISU_PipeLine -::SetInput(TInput* theInput) +::SetInput(VISU_PipeLine::TInput* theInput) { if(theInput) theInput->Update(); @@ -164,7 +164,7 @@ VISU_PipeLine { if(GetInput()){ if(!myMapper->GetInput()){ - GetInput2()->Update(); + GetClippedInput()->Update(); Build(); } myMapper->Update(); @@ -227,7 +227,7 @@ VISU_PipeLine // Check, that at least one cell present after clipping. // This check was introduced because of bug IPAL8849. - vtkUnstructuredGrid* aClippedGrid = GetInput2(); + vtkUnstructuredGrid* aClippedGrid = GetClippedInput(); if (aClippedGrid->GetNumberOfCells() < 1) { return false; } diff --git a/src/PIPELINE/VISU_PipeLine.hxx b/src/PIPELINE/VISU_PipeLine.hxx index c90080ce..4af292ee 100644 --- a/src/PIPELINE/VISU_PipeLine.hxx +++ b/src/PIPELINE/VISU_PipeLine.hxx @@ -79,9 +79,9 @@ class vtkPlane; class SALOME_ExtractGeometry; -typedef VISU::TVTKOutput TInput; -class VISU_PipeLine : public vtkObject{ +class VISU_PipeLine : public vtkObject +{ public: vtkTypeMacro(VISU_PipeLine,vtkObject); virtual @@ -104,6 +104,8 @@ public: SameAs(VISU_PipeLine *thePipeLine); public: + typedef VISU::TVTKOutput TInput; + virtual void SetInput(TInput* theInput); @@ -213,7 +215,7 @@ protected: virtual TInput* - GetInput2() const; + GetClippedInput(); virtual void diff --git a/src/PIPELINE/VISU_PipeLineUtils.hxx b/src/PIPELINE/VISU_PipeLineUtils.hxx index 7b87e362..1056358d 100644 --- a/src/PIPELINE/VISU_PipeLineUtils.hxx +++ b/src/PIPELINE/VISU_PipeLineUtils.hxx @@ -27,6 +27,7 @@ #ifndef VISU_PipeLineUtils_HeaderFile #define VISU_PipeLineUtils_HeaderFile +#include "VISU_CellDataToPointData.hxx" #include "VISU_FieldTransform.hxx" #include "VISU_LookupTable.hxx" #include "VISU_Extractor.hxx" @@ -37,7 +38,6 @@ #include #include -#include #include #include #include @@ -68,34 +68,32 @@ namespace VISU const vtkFloatingPointType B[3], vtkFloatingPointType C[3]); // C = A - B - template + template void - CellDataToPoint(TItem* theTItem, - vtkCellDataToPointData *theFilter, - vtkDataSet* theDataSet, - VISU_FieldTransform *theFieldTransform) + CellDataToPoint(TOutputFilter* theOutputFilter, + VISU_CellDataToPointData *theCellDataToPointData, + vtkPointSet* theDataSet) { if(VISU::IsDataOnCells(theDataSet)){ - theFilter->SetInput(theFieldTransform->GetUnstructuredGridOutput()); - theFilter->PassCellDataOn(); - theTItem->SetInput(theFilter->GetUnstructuredGridOutput()); + theCellDataToPointData->SetInput(theDataSet); + theCellDataToPointData->PassCellDataOn(); + theOutputFilter->SetInput(theCellDataToPointData->GetUnstructuredGridOutput()); }else - theTItem->SetInput(theFieldTransform->GetUnstructuredGridOutput()); + theOutputFilter->SetInput(theDataSet); } - template + template void - ToCellCenters(TItem* theTItem, - vtkCellCenters *theFilter, - vtkDataSet* theDataSet, - VISU_FieldTransform *theFieldTransform) + ToCellCenters(TOutputFilter* theOutputFilter, + vtkCellCenters *theCellCenters, + vtkPointSet* theDataSet) { if(VISU::IsDataOnCells(theDataSet)){ - theFilter->SetInput(theFieldTransform->GetUnstructuredGridOutput()); - theFilter->VertexCellsOn(); - theTItem->SetInput(theFilter->GetOutput()); + theCellCenters->SetInput(theDataSet); + theCellCenters->VertexCellsOn(); + theOutputFilter->SetInput(theCellCenters->GetOutput()); }else - theTItem->SetInput(theFieldTransform->GetUnstructuredGridOutput()); + theOutputFilter->SetInput(theDataSet); } } diff --git a/src/PIPELINE/VISU_Plot3DPL.cxx b/src/PIPELINE/VISU_Plot3DPL.cxx index 4d0ebf65..a1132899 100644 --- a/src/PIPELINE/VISU_Plot3DPL.cxx +++ b/src/PIPELINE/VISU_Plot3DPL.cxx @@ -27,13 +27,13 @@ #include "VISU_Plot3DPL.hxx" #include "VISU_CutPlanesPL.hxx" +#include "VISU_CellDataToPointData.hxx" #include "VISU_PipeLineUtils.hxx" #include #include #include -#include #include #include #include @@ -44,7 +44,7 @@ using namespace std; vtkStandardNewMacro(VISU_Plot3DPL); VISU_Plot3DPL::VISU_Plot3DPL(): - myCellDataToPointData(vtkCellDataToPointData::New(),true), + myCellDataToPointData(VISU_CellDataToPointData::New(),true), myAppendPolyData(vtkAppendPolyData::New(),true), myGeometryFilter(vtkGeometryFilter::New(),true), myContourFilter(vtkContourFilter::New(),true), @@ -77,7 +77,7 @@ ShallowCopy(VISU_PipeLine *thePipeLine) SetContourPrs( aPipeLine->GetIsContourPrs() ); SetNumberOfContours( aPipeLine->GetNumberOfContours() ); } - TSupperClass::ShallowCopy(thePipeLine); + Superclass::ShallowCopy(thePipeLine); } VISU_CutPlanesPL::PlaneOrientation @@ -133,15 +133,15 @@ void VISU_Plot3DPL:: Init() { - TSupperClass::Init(); + Superclass::Init(); - myOrientation = GetOrientation(GetInput2()); - SetScaleFactor(GetScaleFactor(GetInput2())); + myOrientation = GetOrientation(GetMergedInput()); + SetScaleFactor(GetScaleFactor(GetMergedInput())); } -VISU_ScalarMapPL::THook* +VISU_ScalarMapPL::TInsertCustomPL* VISU_Plot3DPL:: -DoHook() +InsertCustomPL() { return myAppendPolyData->GetOutput(); } @@ -156,13 +156,12 @@ Update() vtkPolyData* aPolyData = 0; vtkCutter *aCutPlane = 0; - vtkUnstructuredGrid* anUnstructuredGrid = - myFieldTransform->GetUnstructuredGridOutput(); + vtkPointSet* aPointSet = GetMergedInput(); if ( !IsPlanarInput() ) { aCutPlane = vtkCutter::New(); - aCutPlane->SetInput(anUnstructuredGrid); + aCutPlane->SetInput(aPointSet); vtkPlane *aPlane = vtkPlane::New(); aPlane->SetOrigin(anOrigin); @@ -176,7 +175,7 @@ Update() } if ( !aPolyData || aPolyData->GetNumberOfCells() == 0 ) { - myGeometryFilter->SetInput(anUnstructuredGrid); + myGeometryFilter->SetInput(aPointSet); aPolyData = myGeometryFilter->GetOutput(); aPolyData->Update(); } @@ -213,7 +212,7 @@ Update() myWarpScalar->SetNormal(aPlaneNormal); - TSupperClass::Update(); + Superclass::Update(); } void @@ -325,7 +324,7 @@ GetPlanePosition() const void VISU_Plot3DPL::GetBasePlane(vtkFloatingPointType theOrigin[3], vtkFloatingPointType theNormal[3], - bool theCenterOrigine ) const + bool theCenterOrigine ) { VISU_CutPlanesPL::GetDir(theNormal,myAngle,myOrientation); @@ -341,7 +340,7 @@ void VISU_Plot3DPL::GetBasePlane(vtkFloatingPointType theOrigin[3], if ( theCenterOrigine ) { // move theOrigin to the center of aBounds projections to the plane - GetInput2()->GetBounds(aBounds); + GetMergedInput()->GetBounds(aBounds); vtkFloatingPointType boundPoints[8][3] = { {aBounds[0],aBounds[2],aBounds[4]}, {aBounds[1],aBounds[2],aBounds[4]}, @@ -388,7 +387,7 @@ void VISU_Plot3DPL::GetMinMaxPosition( vtkFloatingPointType& minPos, void VISU_Plot3DPL::SetMapScale(vtkFloatingPointType theMapScale) { - TSupperClass::SetMapScale(theMapScale); + Superclass::SetMapScale(theMapScale); if ( myIsContour ) { vtkFloatingPointType aRange[2]; diff --git a/src/PIPELINE/VISU_Plot3DPL.hxx b/src/PIPELINE/VISU_Plot3DPL.hxx index 59012133..52e69ff2 100644 --- a/src/PIPELINE/VISU_Plot3DPL.hxx +++ b/src/PIPELINE/VISU_Plot3DPL.hxx @@ -30,19 +30,19 @@ #include "VISU_PrsMergerPL.hxx" #include "VISU_CutPlanesPL.hxx" +class VISU_CellDataToPointData; + class vtkWarpScalar; class vtkContourFilter; class vtkGeometryFilter; -class vtkCellDataToPointData; class VISU_Plot3DPL : public VISU_PrsMergerPL{ - typedef VISU_ScalarMapPL TSupperClass; protected: VISU_Plot3DPL(); VISU_Plot3DPL(const VISU_Plot3DPL&); public: - vtkTypeMacro(VISU_Plot3DPL,TSupperClass); + vtkTypeMacro(VISU_Plot3DPL, VISU_PrsMergerPL); static VISU_Plot3DPL* New(); virtual ~VISU_Plot3DPL(); @@ -94,7 +94,7 @@ public: void GetBasePlane (vtkFloatingPointType theOrigin[3], vtkFloatingPointType theNormal[3], - bool theCenterOrigine = false ) const; + bool theCenterOrigine = false ); void GetMinMaxPosition( vtkFloatingPointType& minPos, vtkFloatingPointType& maxPos ) const; @@ -113,14 +113,14 @@ public: void SetMapScale(vtkFloatingPointType theMapScale); protected: - virtual THook* DoHook(); + virtual TInsertCustomPL* InsertCustomPL(); vtkFloatingPointType myAngle[3]; bool myIsRelative, myIsContour; vtkFloatingPointType myPosition, myScaleFactor; VISU_CutPlanesPL::PlaneOrientation myOrientation; - TVTKSmartPtr myCellDataToPointData; + TVTKSmartPtr myCellDataToPointData; TVTKSmartPtr myAppendPolyData; TVTKSmartPtr myGeometryFilter; TVTKSmartPtr myContourFilter; diff --git a/src/PIPELINE/VISU_PrsMergerPL.cxx b/src/PIPELINE/VISU_PrsMergerPL.cxx index 61aa4fcd..121ff067 100644 --- a/src/PIPELINE/VISU_PrsMergerPL.cxx +++ b/src/PIPELINE/VISU_PrsMergerPL.cxx @@ -35,6 +35,7 @@ #include "VISU_MergeFilter.hxx" #include "VISU_PipeLineUtils.hxx" +#include "VISU_ConvertorDef.hxx" #include #include @@ -66,8 +67,7 @@ vtkStandardNewMacro(VISU_PrsMergerPL); VISU_PrsMergerPL ::VISU_PrsMergerPL(): myAppendFilter(VISU_AppendFilter::New()), - myMergeFilter(VISU_MergeFilter::New()), - myScalars(NULL) + myMergeFilter(VISU_MergeFilter::New()) { myAppendFilter->SetMergingInputs(true); myAppendFilter->Delete(); @@ -85,7 +85,6 @@ VISU_PrsMergerPL ::RemoveAllGeom() { myMeshGeometryList.clear(); - this->Execute(); } void @@ -95,7 +94,7 @@ VISU_PrsMergerPL if (MYDEBUG) MESSAGE("ShallowCopy"); VISU_PrsMergerPL* aPipeLine = dynamic_cast(thePipeLine); if(this == aPipeLine){ - TSupperClass::ShallowCopy(thePipeLine); + Superclass::ShallowCopy(thePipeLine); return; } if(aPipeLine){ @@ -103,16 +102,15 @@ VISU_PrsMergerPL if (MYDEBUG) MESSAGE("aNbGeoms="<GetGeometry(i),false); + AddBackGeometry(aPipeLine->GetGeometry(i)); } - SetScalars(aPipeLine->GetScalars(),true); } - TSupperClass::ShallowCopy(thePipeLine); + Superclass::ShallowCopy(thePipeLine); } bool VISU_PrsMergerPL -::SetGeometry(VISU_PipeLine* theGeometry,bool theUpdate) +::SetGeometry(VISU_PipeLine* theGeometry) { if(MYDEBUG) MESSAGE("VISU_PrsMergerPL::SetGeometry()"); myMeshGeometryList.clear(); @@ -120,10 +118,6 @@ VISU_PrsMergerPL if(this->checkGeometry(theGeometry)){ myMeshGeometryList.push_back(theGeometry); if (MYDEBUG) MESSAGE("this->GetGeometry(0)->GetIDMapper()="<GetGeometry(0)->GetIDMapper()); - - if(theUpdate) - this->Execute(); - return true; } else return false; @@ -132,20 +126,17 @@ VISU_PrsMergerPL int VISU_PrsMergerPL -::AddBackGeometry(VISU_PipeLine* theGeometry,bool theUpdate) +::AddBackGeometry(VISU_PipeLine* theGeometry) { if(MYDEBUG) MESSAGE("VISU_PrsMergerPL::AddBackGeometry() "<GetGeometryNumber(theGeometry); if(aGeomNum == -1){ bool aCheckGeom = this->checkGeometry(theGeometry); if(aCheckGeom){ myMeshGeometryList.push_back(theGeometry); - - if(theUpdate) - this->Execute(); - - return (myMeshGeometryList.size()-1); + return (myMeshGeometryList.size() - 1); } else { return -1; } @@ -177,7 +168,6 @@ VISU_PrsMergerPL for(;aIter != myMeshGeometryList.end();aIter++){ if( myMeshGeometryList[theId] == (*aIter)){ myMeshGeometryList.erase(aIter); - this->Execute(); break; } } @@ -195,13 +185,6 @@ VISU_PrsMergerPL return NULL; } -VISU_PipeLine* -VISU_PrsMergerPL -::GetScalars() -{ - return myScalars.GetPointer(); -} - int VISU_PrsMergerPL ::GetNbGeometry() @@ -209,150 +192,140 @@ VISU_PrsMergerPL return myMeshGeometryList.size(); } -bool +//======================================================================= +vtkIdType VISU_PrsMergerPL -::SetScalars(VISU_PipeLine* theInput,bool theUpdate) +::GetNodeObjID(vtkIdType theID) { - if(MYDEBUG) MESSAGE("VISU_PrsMergerPL::SetScalars()"); - if ( this->checkScalars( theInput ) ){ - myScalars = theInput; - VISU_ScalarMapPL* aScalarMap = dynamic_cast(this->GetScalars()); - myScalarRanges = aScalarMap->GetScalarRange(); - if(theUpdate) - this->Execute(); - return true; - } else - return false; + return VISU::GetNodeObjID(myMergeFilter->GetOutput(), theID); } -void +vtkIdType VISU_PrsMergerPL -::Init() +::GetNodeVTKID(vtkIdType theID) { - Superclass::Init(); - if(MYDEBUG) MESSAGE("VISU_PrsMergerPL::Init() this="<Execute(); + return VISU::GetNodeVTKID(myMergeFilter->GetOutput(), theID); } -void +vtkFloatingPointType* VISU_PrsMergerPL -::Update() +::GetNodeCoord(int theObjID) { - if(MYDEBUG) MESSAGE("VISU_PrsMergerPL::Update()"); - Superclass::Update(); - Execute(); + return VISU::GetNodeCoord(myMergeFilter->GetOutput(), theObjID); } -void +//======================================================================= +vtkIdType VISU_PrsMergerPL -::Build() +::GetElemObjID(vtkIdType theID) { - if(MYDEBUG) MESSAGE("VISU_PrsMergerPL::Build()"); - TSupperClass::Build(); // call DoHook method + return VISU::GetElemObjID(myMergeFilter->GetOutput(), theID); } -void +vtkIdType VISU_PrsMergerPL -::SetInitialRange() +::GetElemVTKID(vtkIdType theID) { - myMapper->UseLookupTableScalarRangeOff(); + return VISU::GetElemVTKID(myMergeFilter->GetOutput(), theID); } -bool +vtkCell* VISU_PrsMergerPL -::checkGeometry(const VISU_PipeLine* thePipeLine) +::GetElemCell(vtkIdType theObjID) { - const VISU::PIDMapper& aMapper = thePipeLine->GetIDMapper(); - int aNbPoints = aMapper->GetVTKOutput()->GetNumberOfPoints(); -// if (this->GetNbGeometry() > 0){ -// const VISU::PIDMapper& aMapper2 = this->GetGeometry(0)->GetIDMapper(); -// int aNbPoints2 = aMapper2->GetVTKOutput()->GetNumberOfPoints(); -// if(aNbPoints2 != aNbPoints) -// return false; -// } else if (this->GetScalars()) { -// const VISU::PIDMapper& aMapper2 = this->GetScalars()->GetIDMapper(); -// int aNbPoints2 = aMapper2->GetVTKOutput()->GetNumberOfPoints(); -// if(aNbPoints2 != aNbPoints) -// return false; -// } - if(aNbPoints < 1) - return false; - return true; + return VISU::GetElemCell(myMergeFilter->GetOutput(), theObjID); } -bool +//======================================================================= +void VISU_PrsMergerPL -::checkScalars(const VISU_PipeLine* thePipeLine) +::Build() { - const VISU::PIDMapper& aMapper = thePipeLine->GetIDMapper(); - int aNbPoints = aMapper->GetVTKOutput()->GetNumberOfPoints(); -// if (this->GetNbGeometry() > 0){ -// const VISU::PIDMapper& aMapper2 = this->GetGeometry(0)->GetIDMapper(); -// int aNbPoints2 = aMapper2->GetVTKOutput()->GetNumberOfPoints(); -// if(aNbPoints2 != aNbPoints) -// return false; -// } - if(aNbPoints < 1) - return false; - return true; + Superclass::Build(); + + UpdateGeometry(); + + myMergeFilter->SetGeometry(myAppendFilter->GetOutput()); + + myMergeFilter->SetScalars(GetClippedInput()); + myMergeFilter->SetVectors(GetClippedInput()); + + myMergeFilter->RemoveFields(); + myMergeFilter->AddField("VISU_FIELD", GetClippedInput()); + myMergeFilter->AddField("VISU_CELLS_MAPPER", GetClippedInput()); + myMergeFilter->AddField("VISU_POINTS_MAPPER", GetClippedInput()); } 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()"); - +::UpdateGeometry() +{ myAppendFilter->RemoveAllInputs(); if(!myMeshGeometryList.empty()){ - const VISU::PIDMapper& aScalarsIDMapper = myScalars->GetIDMapper(); - VISU::TVTKOutput* aScalarsOutput = aScalarsIDMapper->GetVTKOutput(); - - // copy points to output from input first geometry - - VISU::TVTKOutput* aGeomOutput = NULL; vtkIdType aNbGeoms = this->GetNbGeometry(); for(vtkIdType aGeomId = 0; aGeomId < aNbGeoms; aGeomId++){ VISU_PipeLine* aGeomPipeLine = this->GetGeometry(aGeomId); const VISU::PIDMapper& aGeomIDMapper = aGeomPipeLine->GetIDMapper(); - aGeomOutput = aGeomIDMapper->GetVTKOutput(); - vtkIdType aNbCells = aGeomOutput->GetNumberOfCells(); -// if(aNbCells > 0) -// if(aGeomOutput->GetCell(0)->GetCellType() == VTK_VERTEX ) -// continue; - + VISU::TVTKOutput* aGeomOutput = aGeomIDMapper->GetVTKOutput(); myAppendFilter->AddInput(aGeomOutput); } - - myAppendFilter->SetSharedPointsDataSet(aGeomOutput); - myAppendFilter->Update(); - - vtkUnstructuredGrid* aGeomDataSet = myAppendFilter->GetOutput(); - myMergeFilter->SetGeometry(aGeomDataSet); - - //copy array values - myMergeFilter->SetScalars(aScalarsOutput); - myMergeFilter->SetVectors(aScalarsOutput); - - myMergeFilter->RemoveFields(); - myMergeFilter->AddField("VISU_FIELD", aScalarsOutput); - myMergeFilter->AddField("VISU_CELLS_MAPPER", aScalarsOutput); - myMergeFilter->AddField("VISU_POINTS_MAPPER", aScalarsOutput); - - myMergeFilter->Update(); - SetInput(myMergeFilter->GetOutput()); }else{ - if(myScalars != NULL){ - if(VISU_ScalarMapPL* aScalarMap = dynamic_cast(this->GetScalars())) - SetInput(aScalarMap->GetInput()); - } + VISU::TVTKOutput* aScalarsOutput = myFieldTransform->GetUnstructuredGridOutput(); + myAppendFilter->AddInput(aScalarsOutput); } } + +void +VISU_PrsMergerPL +::Update() +{ + Superclass::Update(); + + UpdateGeometry(); + //{ + // std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-aScalarsOutput.vtk"; + // VISU::WriteToFile(myFieldTransform->GetUnstructuredGridOutput(), aFileName); + //} + //{ + // std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-aGeomDataSet.vtk"; + // VISU::WriteToFile(myAppendFilter->GetOutput(), aFileName); + //} + //{ + // std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-myMergeFilter.vtk"; + // VISU::WriteToFile(myMergeFilter->GetOutput(), aFileName); + //} +} + +VISU_ScalarMapPL::TInsertCustomPL* +VISU_PrsMergerPL +::InsertCustomPL() +{ + return GetMergedInput(); +} + +vtkPointSet* +VISU_PrsMergerPL +::GetMergedInput() +{ + if(myMergeFilter->GetInput()) + myMergeFilter->Update(); + return myMergeFilter->GetOutput(); +} + +void +VISU_PrsMergerPL +::SetInitialRange() +{ + myMapper->UseLookupTableScalarRangeOff(); +} + +bool +VISU_PrsMergerPL +::checkGeometry(const VISU_PipeLine* thePipeLine) +{ + const VISU::PIDMapper& aMapper = thePipeLine->GetIDMapper(); + int aNbPoints = aMapper->GetVTKOutput()->GetNumberOfPoints(); + if(aNbPoints < 1) + return false; + return true; +} diff --git a/src/PIPELINE/VISU_PrsMergerPL.hxx b/src/PIPELINE/VISU_PrsMergerPL.hxx index a8956716..443ccf8b 100644 --- a/src/PIPELINE/VISU_PrsMergerPL.hxx +++ b/src/PIPELINE/VISU_PrsMergerPL.hxx @@ -35,8 +35,6 @@ class VISU_MergeFilter; class VISU_PrsMergerPL : public VISU_ScalarMapPL { - typedef VISU_ScalarMapPL TSupperClass; - protected: VISU_PrsMergerPL(); VISU_PrsMergerPL(const VISU_PrsMergerPL&); @@ -49,7 +47,7 @@ public: typedef TVTKSmartPtr TPipeLine; typedef std::vector TPipeLines; - vtkTypeMacro(VISU_PrsMergerPL,TSupperClass); + vtkTypeMacro(VISU_PrsMergerPL, VISU_ScalarMapPL); static VISU_PrsMergerPL* @@ -59,6 +57,30 @@ public: void ShallowCopy(VISU_PipeLine *thePipeLine); + virtual + vtkIdType + GetNodeObjID(vtkIdType theID); + + virtual + vtkIdType + GetNodeVTKID(vtkIdType theID); + + virtual + vtkFloatingPointType* + GetNodeCoord(vtkIdType theObjID); + + virtual + vtkIdType + GetElemObjID(vtkIdType theID); + + virtual + vtkIdType + GetElemVTKID(vtkIdType theID); + + virtual + vtkCell* + GetElemCell(vtkIdType theObjID); + /*! * Add geometry of presentation to myMeshGeometryList. * \params theGeometry - visu pipeline with geometry. @@ -67,7 +89,7 @@ public: */ virtual bool - SetGeometry(VISU_PipeLine* theGeometry,bool theUpdate=true); + SetGeometry(VISU_PipeLine* theGeometry); /*! * Add geometry to back of myMeshGeometryList. @@ -78,7 +100,7 @@ public: */ virtual int - AddBackGeometry(VISU_PipeLine* theGeometry,bool theUpdate=true); + AddBackGeometry(VISU_PipeLine* theGeometry); /*! * Get geometry id of myMeshGeometryList. @@ -120,31 +142,10 @@ public: int GetNbGeometry(); - /*! - * Sets scalar values and ids by VISU_ScalarMapPL object. - * \params theInput - visu pipeline with scalar values - * \params theUpdate - update pipeline if true. - * \retval TRUE - if scalars and geometry on the common mesh, esle FALSE. - */ - virtual - bool - SetScalars(VISU_PipeLine* theInput,bool theUpdate=false); - - /*! - * Gets input VISU_ScalarMapPL, which contain scalar values and ids. - */ - virtual - VISU_PipeLine* - GetScalars(); - - virtual - void - Init(); - virtual void Build(); - + /*! * Calculate presentation, by merging of Geometry and Scalar Values. */ @@ -158,15 +159,17 @@ public: void SetInitialRange(); protected: - TPipeLines myMeshGeometryList; - vtkSmartPointer myAppendFilter; - vtkSmartPointer myMergeFilter; - - vtkFloatingPointType* myScalarRanges; - TPipeLine myScalars; + virtual + TInsertCustomPL* + InsertCustomPL(); + + virtual + vtkPointSet* + GetMergedInput(); + + void + UpdateGeometry(); -private: - /*! * Check if thePipeLine and "first element of list myMeshGeometryList" or * "myScalars", has @@ -176,17 +179,9 @@ private: bool checkGeometry(const VISU_PipeLine* thePipeLine); - - /*! - * Check if thePipeLine and first element of list myMeshGeometryList, has - * common DataPoints (simple check number of points). - * \retval TRUE - if has common points, esle FALSE. - */ - bool - checkScalars(const VISU_PipeLine* thePipeLine); - - void - Execute(); + TPipeLines myMeshGeometryList; + vtkSmartPointer myAppendFilter; + vtkSmartPointer myMergeFilter; }; #endif diff --git a/src/PIPELINE/VISU_ScalarMapOnDeformedShapePL.cxx b/src/PIPELINE/VISU_ScalarMapOnDeformedShapePL.cxx index 1a0e3e4b..9ca1f7b6 100644 --- a/src/PIPELINE/VISU_ScalarMapOnDeformedShapePL.cxx +++ b/src/PIPELINE/VISU_ScalarMapOnDeformedShapePL.cxx @@ -26,6 +26,8 @@ #include "VISU_ScalarMapOnDeformedShapePL.hxx" #include "VISU_DeformedShapePL.hxx" + +#include "VISU_CellDataToPointData.hxx" #include "VISU_MergeFilter.hxx" #include "VISU_PipeLineUtils.hxx" @@ -34,7 +36,6 @@ #include #include -#include #include #include "VISU_Convertor.hxx" @@ -53,10 +54,16 @@ vtkStandardNewMacro(VISU_ScalarMapOnDeformedShapePL) VISU_ScalarMapOnDeformedShapePL ::VISU_ScalarMapOnDeformedShapePL() { - myDeformVectors = vtkWarpVector::New(); - myMergeFilter = VISU_MergeFilter::New(); + myWarpVector = vtkWarpVector::New(); + + myMergeScalarsFilter = VISU_MergeFilter::New(); + myMergeScalarsFilter->SetMergingInputs(true); + myExtractorScalars = VISU_Extractor::New(); - myCellDataToPointData = vtkCellDataToPointData::New(); + + myCellDataToPointData = VISU_CellDataToPointData::New(); + + myScalars = myMergeFilter->GetOutput(); } /*! @@ -66,11 +73,11 @@ VISU_ScalarMapOnDeformedShapePL VISU_ScalarMapOnDeformedShapePL ::~VISU_ScalarMapOnDeformedShapePL() { - myDeformVectors->UnRegisterAllOutputs(); - myDeformVectors->Delete(); + myWarpVector->UnRegisterAllOutputs(); + myWarpVector->Delete(); - myMergeFilter->UnRegisterAllOutputs(); - myMergeFilter->Delete(); + myMergeScalarsFilter->UnRegisterAllOutputs(); + myMergeScalarsFilter->Delete(); myExtractorScalars->UnRegisterAllOutputs(); myExtractorScalars->Delete(); @@ -79,91 +86,104 @@ VISU_ScalarMapOnDeformedShapePL myCellDataToPointData->Delete(); } -/*! - * Initial method - */ +//======================================================================= void VISU_ScalarMapOnDeformedShapePL -::Init() +::Build() { - if (GetScalarsUnstructuredGrid() == NULL) SetScalars(GetInput2()); - - Superclass::Init(); - - vtkFloatingPointType aScalarRange[2]; - GetSourceRange(aScalarRange); - static double EPS = 1.0 / VTK_LARGE_FLOAT; - if(aScalarRange[1] > EPS) - SetScale(VISU_DeformedShapePL::GetScaleFactor(GetInput2())/aScalarRange[1]); - else - SetScale(0.0); + Superclass::Build(); - myMapper->SetColorModeToMapScalars(); - myMapper->ScalarVisibilityOn(); + VISU::CellDataToPoint(myWarpVector, + myCellDataToPointData, + GetMergedInput()); + + // Sets geometry for merge filter + myMergeScalarsFilter->SetGeometry(myWarpVector->GetUnstructuredGridOutput()); - // Sets input for field transformation filter - myFieldTransform->SetInput(myExtractor->GetOutput()); + UpdateScalars(); + vtkDataSet* aScalarsDataSet = myExtractorScalars->GetOutput(); + myMergeScalarsFilter->SetScalars(aScalarsDataSet); + myMergeScalarsFilter->AddField("VISU_CELLS_MAPPER", aScalarsDataSet); + myMergeScalarsFilter->AddField("VISU_POINTS_MAPPER", aScalarsDataSet); } -/*! - * Build method - * Building of deformation and puts result to merge filter. - */ +//======================================================================= void VISU_ScalarMapOnDeformedShapePL -::Build() +::UpdateScalars() { - // Set input for extractor - myExtractor->SetInput(GetInput2()); - - VISU::CellDataToPoint(myDeformVectors,myCellDataToPointData, - GetInput2(),myFieldTransform); - - // Sets geometry for merge filter - myMergeFilter->SetGeometry(myDeformVectors->GetUnstructuredGridOutput()); - myMergeFilter->SetScalars(myExtractorScalars->GetOutput()); - myMergeFilter->AddField("VISU_CELLS_MAPPER", myExtractorScalars->GetOutput()); - myMergeFilter->Update(); + vtkPointSet* aScalars = GetScalars(); + vtkCellData *aInCellData = GetInput()->GetCellData(); + + if(aScalars->GetPointData()->GetScalars()) + myExtractorScalars->SetInput(aScalars); + else if(aScalars->GetCellData()->GetScalars() && + !aInCellData->GetAttribute(vtkDataSetAttributes::VECTORS)){ + //Approximate cell data values to point data by VISU_CellDataToPointData filter. + VISU_CellDataToPointData* aCellDataToPointData = VISU_CellDataToPointData::New(); + aCellDataToPointData->SetInput(aScalars); + aCellDataToPointData->Update(); + myExtractorScalars->SetInput(aCellDataToPointData->GetUnstructuredGridOutput()); + aCellDataToPointData->Delete(); + } else { + myExtractorScalars->SetInput(aScalars); + } +} + - // Sets data to mapper - myMapper->SetInput(myMergeFilter->GetOutput()); +//======================================================================= +VISU_ScalarMapPL::TInsertCustomPL* +VISU_ScalarMapOnDeformedShapePL +::InsertCustomPL() +{ + myMapper->SetColorModeToMapScalars(); + myMapper->ScalarVisibilityOn(); + + return myMergeScalarsFilter->GetOutput(); } -/*! - * Update method - */ void VISU_ScalarMapOnDeformedShapePL ::Update() { - this->UpdateScalars(); - - vtkFloatingPointType* aRange = GetScalarRange(); - vtkFloatingPointType aScalarRange[2] = {aRange[0], aRange[1]}; - - if(myBarTable->GetScale() == VTK_SCALE_LOG10) - VISU_LookupTable::ComputeLogRange(aRange,aScalarRange); - myMapperTable->SetRange(aScalarRange); - - myMapperTable->Build(); - myBarTable->Build(); + Superclass::Update(); - myMapper->SetLookupTable(myMapperTable); - myMapper->SetScalarRange(aScalarRange); - - VISU_PipeLine::Update(); + UpdateScalars(); + //{ + // std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-aScalarsOutput2.vtk"; + // VISU::WriteToFile(myExtractorScalars->GetUnstructuredGridOutput(), aFileName); + //} + //{ + // std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-aGeomDataSet2.vtk"; + // VISU::WriteToFile(myWarpVector->GetUnstructuredGridOutput(), aFileName); + //} + //{ + // std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-myMergeFilter2.vtk"; + // VISU::WriteToFile(myMergeScalarsFilter->GetOutput(), aFileName); + //} } /*! - * Update scalars method. - * Put scalars to merge filter. + * Initial method */ void VISU_ScalarMapOnDeformedShapePL -::UpdateScalars() +::Init() { - myExtractorScalars->Update(); + Superclass::Init(); + + vtkFloatingPointType aScalarRange[2]; + GetSourceRange(aScalarRange); + + vtkDataSet* aDataSet = GetMergedInput(); + vtkFloatingPointType aScaleFactor = VISU_DeformedShapePL::GetScaleFactor( aDataSet ); + + static double EPS = 1.0 / VTK_LARGE_FLOAT; + if(fabs(aScalarRange[1]) > EPS) + SetScale(aScaleFactor / aScalarRange[1]); + else + SetScale(0.0); } /*! @@ -177,7 +197,7 @@ VISU_ScalarMapOnDeformedShapePL VISU_ScalarMapOnDeformedShapePL *aPipeLine = dynamic_cast(thePipeLine); if(aPipeLine){ SetScale(aPipeLine->GetScale()); - SetScalars(aPipeLine->GetScalarsUnstructuredGrid()); + SetScalars(aPipeLine->GetScalars()); } Superclass::ShallowCopy(thePipeLine); } @@ -191,34 +211,14 @@ VISU_ScalarMapOnDeformedShapePL ::SetScalars(vtkDataSet *theScalars) { myScalars = theScalars; - vtkUnstructuredGrid* aScalars = GetScalarsUnstructuredGrid(); - vtkCellData *aInCellData = GetInput()->GetCellData(); - - std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-SetScalars.vtk"; - VISU::WriteToFile(aScalars, aFileName); - if(aScalars->GetPointData()->GetScalars()) - myExtractorScalars->SetInput(aScalars); - else if(aScalars->GetCellData()->GetScalars() && - !aInCellData->GetAttribute(vtkDataSetAttributes::VECTORS)){ - //Approximate cell data values to point data by vtkCellDataToPointData filter. - vtkCellDataToPointData* aCellDataToPointData = vtkCellDataToPointData::New(); - aCellDataToPointData->SetInput(aScalars); - aCellDataToPointData->Update(); - myExtractorScalars->SetInput(aCellDataToPointData->GetUnstructuredGridOutput()); - aCellDataToPointData->Delete(); - } else { - myExtractorScalars->SetInput(aScalars); - } - Update(); - Modified(); } /*! * Get pointer to input scalars. */ -vtkUnstructuredGrid* +vtkPointSet* VISU_ScalarMapOnDeformedShapePL -::GetScalarsUnstructuredGrid() +::GetScalars() { return myScalars.GetPointer(); } @@ -232,7 +232,7 @@ VISU_ScalarMapOnDeformedShapePL { if(myScaleFactor == theScale) return; myScaleFactor = theScale; - myDeformVectors->SetScaleFactor(myScaleFactor); + myWarpVector->SetScaleFactor(myScaleFactor); Modified(); } @@ -253,8 +253,8 @@ void VISU_ScalarMapOnDeformedShapePL ::SetMapScale(vtkFloatingPointType theMapScale) { - TSupperClass::SetMapScale(theMapScale); // enk::added - myDeformVectors->SetScaleFactor(myScaleFactor*theMapScale); + Superclass::SetMapScale(theMapScale); // enk::added + myWarpVector->SetScaleFactor(myScaleFactor*theMapScale); Modified(); } diff --git a/src/PIPELINE/VISU_ScalarMapOnDeformedShapePL.hxx b/src/PIPELINE/VISU_ScalarMapOnDeformedShapePL.hxx index 6e731ab7..686637da 100644 --- a/src/PIPELINE/VISU_ScalarMapOnDeformedShapePL.hxx +++ b/src/PIPELINE/VISU_ScalarMapOnDeformedShapePL.hxx @@ -30,16 +30,13 @@ #include "VISU_PrsMergerPL.hxx" class VISU_MergeFilter; +class VISU_CellDataToPointData; + class vtkWarpVector; class vtkUnstructuredGrid; -class vtkCellDataToPointData; -class vtkPointDataToCellData; class VISU_ScalarMapOnDeformedShapePL : public VISU_PrsMergerPL { - - typedef VISU_PrsMergerPL TSupperClass; - protected: VISU_ScalarMapOnDeformedShapePL(); @@ -47,7 +44,7 @@ protected: VISU_ScalarMapOnDeformedShapePL(const VISU_ScalarMapOnDeformedShapePL&); public: - vtkTypeMacro(VISU_ScalarMapOnDeformedShapePL,VISU_PrsMergerPL); + vtkTypeMacro(VISU_ScalarMapOnDeformedShapePL, VISU_PrsMergerPL); static VISU_ScalarMapOnDeformedShapePL* New(); @@ -62,37 +59,41 @@ public: virtual void GetSourceRange(vtkFloatingPointType theRange[2]); virtual void SetScalars(vtkDataSet *theScalars); - virtual vtkUnstructuredGrid* GetScalarsUnstructuredGrid(); + virtual vtkPointSet* GetScalars(); public: - //! Redefined method for initialization of the pipeline. + //! Redefined method for building of the pipeline. virtual void - Init(); + Build(); - //! Redefined method for building the pipeline. + //! Redefined method for initialization of the pipeline. virtual void - Build(); + Init(); - //! Redefined method for updating the pipeline. virtual void Update(); - //! Update scalars. + virtual void UpdateScalars(); - + virtual void SetMapScale(vtkFloatingPointType theMapScale = 1.0); protected: + //! Redefined method for customization of pipeline building + virtual + TInsertCustomPL* + InsertCustomPL(); + vtkFloatingPointType myScaleFactor; - vtkWarpVector *myDeformVectors; - VISU_MergeFilter *myMergeFilter; + vtkWarpVector *myWarpVector; + VISU_MergeFilter *myMergeScalarsFilter; vtkSmartPointer myScalars; VISU_Extractor* myExtractorScalars; - vtkCellDataToPointData* myCellDataToPointData; + VISU_CellDataToPointData* myCellDataToPointData; }; #endif diff --git a/src/PIPELINE/VISU_ScalarMapPL.cxx b/src/PIPELINE/VISU_ScalarMapPL.cxx index 0fa68d13..ddf4a6d3 100644 --- a/src/PIPELINE/VISU_ScalarMapPL.cxx +++ b/src/PIPELINE/VISU_ScalarMapPL.cxx @@ -194,13 +194,24 @@ VISU_ScalarMapPL //---------------------------------------------------------------------------- -VISU_ScalarMapPL::THook* +VISU_PipeLine::TInput* VISU_ScalarMapPL -::DoHook() +::GetClippedInput() +{ + if(myExtractGeometry->GetInput()) + myFieldTransform->Update(); + return myFieldTransform->GetUnstructuredGridOutput(); +} + + +VISU_ScalarMapPL::TInsertCustomPL* +VISU_ScalarMapPL +::InsertCustomPL() { myMapper->SetColorModeToMapScalars(); myMapper->ScalarVisibilityOn(); - return myFieldTransform->GetUnstructuredGridOutput(); + + return GetClippedInput(); } @@ -216,7 +227,7 @@ void VISU_ScalarMapPL ::Build() { - myMapper->SetInput(DoHook()); + myMapper->SetInput(InsertCustomPL()); } diff --git a/src/PIPELINE/VISU_ScalarMapPL.hxx b/src/PIPELINE/VISU_ScalarMapPL.hxx index de07ce2a..f989ae1f 100644 --- a/src/PIPELINE/VISU_ScalarMapPL.hxx +++ b/src/PIPELINE/VISU_ScalarMapPL.hxx @@ -32,7 +32,7 @@ #include "VISU_ScalarBarActor.hxx" class vtkCell; -class vtkDataSet; +class vtkPointSet; class VISU_Extractor; class VISU_FieldTransform; @@ -140,8 +140,15 @@ public: //---------------------------------------------------------------------------- protected: - typedef vtkDataSet THook; - virtual THook* DoHook(); + typedef vtkPointSet TInsertCustomPL; + + virtual + TInsertCustomPL* + InsertCustomPL(); + + virtual + TInput* + GetClippedInput(); VISU_LookupTable* myMapperTable; VISU_LookupTable* myBarTable; diff --git a/src/PIPELINE/VISU_StreamLinesPL.cxx b/src/PIPELINE/VISU_StreamLinesPL.cxx index c9cdc8ed..65d48171 100644 --- a/src/PIPELINE/VISU_StreamLinesPL.cxx +++ b/src/PIPELINE/VISU_StreamLinesPL.cxx @@ -165,7 +165,7 @@ VISU_StreamLinesPL int theDirection, int isOnlyTry) { - vtkPointSet* aDataSet = theSource? theSource: myFieldTransform->GetUnstructuredGridOutput(); + vtkPointSet* aDataSet = theSource? theSource: GetMergedInput(); aDataSet->Update(); vtkIdType aNbOfPoints = aDataSet->GetNumberOfPoints(); vtkPointSet* aPointSet = myExtractor->GetOutput(); @@ -177,7 +177,7 @@ VISU_StreamLinesPL if((!isOnlyTry && isAccepted) || (isOnlyTry && isAccepted == 1)){ mySource = theSource; myPercents = thePercents; - if(VISU::IsDataOnCells(GetInput2())){ + if(VISU::IsDataOnCells(GetMergedInput())){ myCenters->SetInput(aDataSet); myCenters->VertexCellsOn(); aDataSet = myCenters->GetOutput(); @@ -327,7 +327,8 @@ vtkFloatingPointType VISU_StreamLinesPL ::GetMaxIntegrationStep(vtkPointSet* theDataSet) { - if(!theDataSet) return -1.0; + if(!theDataSet) + return -1.0; theDataSet->Update(); vtkFloatingPointType aLength = theDataSet->GetLength(); vtkFloatingPointType* aBounds = theDataSet->GetBounds(); @@ -425,7 +426,8 @@ vtkFloatingPointType VISU_StreamLinesPL ::GetBasePropagationTime(vtkPointSet* theDataSet) { - if(!theDataSet) return -1.0; + if(!theDataSet) + return -1.0; theDataSet->Update(); vtkFloatingPointType aPropagationTime = theDataSet->GetLength()/GetVelocityCoeff(theDataSet); return aPropagationTime; @@ -495,28 +497,41 @@ VISU_StreamLinesPL } +void +VISU_StreamLinesPL +::Build() +{ + Superclass::Build(); + + VISU::CellDataToPoint(myStream, + myCellDataToPointData, + GetMergedInput()); + + vtkFloatingPointType aBounds[6]; + GetMergedInput()->GetBounds(aBounds); + + myGeomFilter->SetExtent(aBounds); + myGeomFilter->ExtentClippingOn(); + myGeomFilter->SetInput(myStream->GetOutput()); +} + void VISU_StreamLinesPL ::Init() { Superclass::Init(); - vtkPointSet* aDataSet = myExtractor->GetOutput(); + + vtkPointSet* aDataSet = GetMergedInput(); vtkFloatingPointType anIntStep = GetBaseIntegrationStep(aDataSet); vtkFloatingPointType aPropagationTime = GetBasePropagationTime(aDataSet); vtkFloatingPointType aStepLength = GetBaseStepLength(aDataSet); SetParams(anIntStep,aPropagationTime,aStepLength); } -VISU_ScalarMapPL::THook* +VISU_ScalarMapPL::TInsertCustomPL* VISU_StreamLinesPL -::DoHook() +::InsertCustomPL() { - GetInput2()->Update(); - VISU::CellDataToPoint(myStream,myCellDataToPointData,GetInput2(),myFieldTransform); - vtkFloatingPointType *aBounds = GetInput2()->GetBounds(); - myGeomFilter->SetExtent(aBounds); - myGeomFilter->ExtentClippingOn(); - myGeomFilter->SetInput(myStream->GetOutput()); return myGeomFilter->GetOutput(); } diff --git a/src/PIPELINE/VISU_StreamLinesPL.hxx b/src/PIPELINE/VISU_StreamLinesPL.hxx index 7c020dac..ed1bf9b2 100644 --- a/src/PIPELINE/VISU_StreamLinesPL.hxx +++ b/src/PIPELINE/VISU_StreamLinesPL.hxx @@ -129,8 +129,12 @@ public: public: virtual - THook* - DoHook(); + TInsertCustomPL* + InsertCustomPL(); + + virtual + void + Build(); virtual void diff --git a/src/PIPELINE/VISU_VectorsPL.cxx b/src/PIPELINE/VISU_VectorsPL.cxx index 3fa4bd66..d772d9bd 100644 --- a/src/PIPELINE/VISU_VectorsPL.cxx +++ b/src/PIPELINE/VISU_VectorsPL.cxx @@ -142,21 +142,33 @@ VISU_VectorsPL } -VISU_ScalarMapPL::THook* +void VISU_VectorsPL -::DoHook() +::Build() { - VISU::ToCellCenters(myBaseGlyph,myCenters,GetInput2(),myFieldTransform); + Superclass::Build(); + + VISU::ToCellCenters(myBaseGlyph, + myCenters, + GetMergedInput()); myBaseGlyph->SetVectorModeToUseVector(); myBaseGlyph->SetScaleModeToScaleByVector(); myBaseGlyph->SetColorModeToColorByScalar(); - VISU::ToCellCenters(myTransformFilter,myCenters,GetInput2(),myFieldTransform); + VISU::ToCellCenters(myTransformFilter, + myCenters, + GetMergedInput()); myTransformedGlyph->SetInput(myTransformFilter->GetOutput()); myTransformedGlyph->SetVectorModeToUseVector(); myTransformedGlyph->SetScaleModeToScaleByVector(); myTransformedGlyph->SetColorModeToColorByScalar(); +} + +VISU_ScalarMapPL::TInsertCustomPL* +VISU_VectorsPL +::InsertCustomPL() +{ return myTransformedGlyph->GetOutput(); } diff --git a/src/PIPELINE/VISU_VectorsPL.hxx b/src/PIPELINE/VISU_VectorsPL.hxx index fd83f022..5245650f 100644 --- a/src/PIPELINE/VISU_VectorsPL.hxx +++ b/src/PIPELINE/VISU_VectorsPL.hxx @@ -104,6 +104,10 @@ public: void Init(); + virtual + void + Build(); + virtual void Update(); @@ -125,8 +129,8 @@ public: protected: virtual - THook* - DoHook(); + TInsertCustomPL* + InsertCustomPL(); GlyphType myTypeGlyph; GlyphPos myPosGlyph; diff --git a/src/VISUGUI/VisuGUI_Selection.cxx b/src/VISUGUI/VisuGUI_Selection.cxx index d67f4bcc..29b645ce 100644 --- a/src/VISUGUI/VisuGUI_Selection.cxx +++ b/src/VISUGUI/VisuGUI_Selection.cxx @@ -494,9 +494,7 @@ void VisuGUI_SelectionDlg::onSelectionEvent() { int aVTKID = anVISUActor->GetElemVTKID(anID); if (aCell != NULL) { int aNbOfPoints = aCell->GetNumberOfPoints(); - if ( aNbOfPoints <= 1 ) { // Cell is point - clearFields(); - } else { + if ( aNbOfPoints > 0 ) { myCellIDValLbl->setText( QString::number(anID) ); myCellScalarValLbl->setText(getValue(aCellData, aVTKID)); myCellVectorValLbl->setText(getVector(aCellData, aVTKID)); @@ -550,6 +548,8 @@ void VisuGUI_SelectionDlg::onSelectionEvent() { myListPoints->setText(i, 7, getValue(aPntData, id)); myListPoints->setText(i, 8, getVector(aPntData, id)); } + for(int aColumnId = 0; aColumnId < 9; aColumnId++) + myListPoints->adjustColumn(aColumnId); } } else { clearFields(); @@ -569,12 +569,10 @@ void VisuGUI_SelectionDlg::clearFields() { myIValLbl->setText( "-" );//ENK: 23.11.2006 - PAL13176 myJValLbl->setText( "-" );//ENK: 23.11.2006 - PAL13176 myKValLbl->setText( "-" );//ENK: 23.11.2006 - PAL13176 - myIDValLbl->setText( "" ); myScalarValLbl->setText(""); myVectorValLbl->setText(""); break; case 1: - myCellIDValLbl->setText( "" ); myCellScalarValLbl->setText(""); myCellVectorValLbl->setText(""); myListPoints->setNumRows(0); @@ -589,10 +587,10 @@ void VisuGUI_SelectionDlg::clearFields() { } } -typedef vtkIdType (vtkDataSet::* TDataSetMethod)(); +typedef vtkIdType (VISU_PipeLine::* TGetVTKIdMethod)(vtkIdType theID); bool onIdEdit (const QString& theText, - TDataSetMethod theMethod, + TGetVTKIdMethod theMethod, bool theIsCell, const SalomeApp_Module* theModule, LightApp_SelectionMgr* theSelectionMgr, @@ -634,14 +632,14 @@ bool onIdEdit (const QString& theText, } if (aPrs3d) { - int anId = theText.toInt(); - vtkDataSet* aDataSet = aPrs3d->GetPL()->GetMapper()->GetInput(); - int aMaxId = (aDataSet->*theMethod)(); - if (anId < 0) anId = 0; - if (anId >= aMaxId) anId = aMaxId - 1; + int anObjId = theText.toInt(); + VISU_PipeLine* aPipeLine = aPrs3d->GetPL(); + int aVTKId = (aPipeLine->*theMethod)(anObjId); + if(aVTKId < 0) + return false; TColStd_MapOfInteger newIndices; - newIndices.Add(anId); + newIndices.Add(anObjId); aSelector->AddOrRemoveIndex(anIO, newIndices, false); aViewWindow->highlight(anIO, true, true); @@ -657,9 +655,14 @@ bool onIdEdit (const QString& theText, void VisuGUI_SelectionDlg::onPointIdEdit (const QString& theText) { if (myFl) return; - TDataSetMethod aMethod = &vtkDataSet::GetNumberOfPoints; - bool anIsSelected = onIdEdit(theText,aMethod,false,myModule,mySelectionMgr, - myMeshName,tr("WRN_NO_AVAILABLE_DATA"), + TGetVTKIdMethod aMethod = &VISU_PipeLine::GetNodeVTKID; + bool anIsSelected = onIdEdit(theText, + aMethod, + false, + myModule, + mySelectionMgr, + myMeshName, + tr("WRN_NO_AVAILABLE_DATA"), myFieldName); if (anIsSelected) // as selection manager doesn't send signal currentSelectionChanged() @@ -671,9 +674,14 @@ void VisuGUI_SelectionDlg::onPointIdEdit (const QString& theText) void VisuGUI_SelectionDlg::onCellIdEdit (const QString& theText) { if (myFl) return; - TDataSetMethod aMethod = &vtkDataSet::GetNumberOfCells; - bool anIsSelected = onIdEdit(theText,aMethod,true,myModule,mySelectionMgr, - myMeshName,tr("WRN_NO_AVAILABLE_DATA"), + TGetVTKIdMethod aMethod = &VISU_PipeLine::GetElemVTKID; + bool anIsSelected = onIdEdit(theText, + aMethod, + true, + myModule, + mySelectionMgr, + myMeshName, + tr("WRN_NO_AVAILABLE_DATA"), myFieldName); if (anIsSelected) // as selection manager doesn't send signal currentSelectionChanged() diff --git a/src/VISU_I/VISU_GaussPoints_i.cc b/src/VISU_I/VISU_GaussPoints_i.cc index 6b88d23c..279e186b 100644 --- a/src/VISU_I/VISU_GaussPoints_i.cc +++ b/src/VISU_I/VISU_GaussPoints_i.cc @@ -572,6 +572,7 @@ VISU::GaussPoints_i try{ TSuperClass::CreateActor(theActor,theIO); theActor->GetPipeLine()->Delete(); + theActor->SetVTKMapping(true); UpdateActor(theActor); return true; }catch(...){ diff --git a/src/VISU_I/VISU_PrsMerger_i.cc b/src/VISU_I/VISU_PrsMerger_i.cc index 9591257b..74a41aef 100644 --- a/src/VISU_I/VISU_PrsMerger_i.cc +++ b/src/VISU_I/VISU_PrsMerger_i.cc @@ -89,8 +89,7 @@ PrsMerger_i(Result_i* theResult, Prs3d_i(theResult,theAddToStudy), ColoredPrs3d_i(theResult,theAddToStudy), ScalarMap_i(theResult,theAddToStudy), - myPrsMergerPL(NULL), - myScalarsPL(VISU_ScalarMapPL::New()) + myPrsMergerPL(NULL) { } @@ -101,8 +100,7 @@ PrsMerger_i(Result_i* theResult, Prs3d_i(theResult,theSObject), ColoredPrs3d_i(theResult,theSObject), ScalarMap_i(theResult,theSObject), - myPrsMergerPL(NULL), - myScalarsPL(VISU_ScalarMapPL::New()) + myPrsMergerPL(NULL) { } @@ -313,7 +311,7 @@ AddMeshOnGroup(const char* theMeshName, VISU_MeshPL* aTmpMesh = VISU_MeshPL::New(); aTmpMesh->SetIDMapper(anIDMapper); - aRetVal = myPrsMergerPL->AddBackGeometry(aTmpMesh,false); + aRetVal = myPrsMergerPL->AddBackGeometry(aTmpMesh); if(aRetVal >-1 ){ myMeshPLList.push_back(aTmpMesh); @@ -387,22 +385,12 @@ SetScalarMap(const char* theMeshName, myEntity = (VISU::TEntity)theEntity; myFieldName = theFieldName; myIteration = theStampsNum; - - myScalarsPL->SetIDMapper(anIDMapper); - myPrsMergerPL->SetScalars(myScalarsPL); } void VISU::PrsMerger_i:: SetScalarMap(VISU_PipeLine* thePipeLine) -{ - if (MYDEBUG) MESSAGE("VISU::PrsMerger_i::SetScalarMap"); - VISU_ScalarMapPL* aInputScalars = dynamic_cast(thePipeLine); - VISU::PIDMapper anIDMapper = aInputScalars->GetIDMapper(); - myScalarsPL->SetIDMapper(anIDMapper); - if(aInputScalars) - myPrsMergerPL->SetScalars(myScalarsPL); -} +{} void VISU::PrsMerger_i:: @@ -533,46 +521,7 @@ bool VISU::PrsMerger_i ::CheckGroup(const char* theGroupName) { - if (MYDEBUG) MESSAGE("PrsMerger_i::CheckGroup :|"<GetInput()->GetMeshOnGroup(aMeshName,theGroupName); - if (MYDEBUG) MESSAGE("anIDMapper="<GetVTKOutput()->GetNumberOfCells(); - if(aNbCellsInGeom>0){ - int aVtkCellType = anIDMapper->GetVTKOutput()->GetCellType(0); - if (MYDEBUG) MESSAGE("CellType="<SetIDMapper(anIDMapper); + myScalarMapPL->Build(); // mkr : 23.11.2006 - PAL13908 - save animation range if range is fixed --> if ( myIsFixedRange ) myScalarMapPL->SetScalarMode(0); else myScalarMapPL->Init(); // mkr : 23.11.2006 <-- - myScalarMapPL->Build(); } void