From: apo Date: Wed, 16 May 2007 11:37:07 +0000 (+0000) Subject: Adjust to last modifications in the V3_2_0_maintainance CVS branch X-Git-Tag: mergeto_BR_Dev_For_4_0_21May07~23 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=7e07b88089c3c6f3a449c727ac4fe1c1e5bda20d;p=modules%2Fvisu.git Adjust to last modifications in the V3_2_0_maintainance CVS branch --- diff --git a/src/CONVERTOR/VISU_AppendFilter.cxx b/src/CONVERTOR/VISU_AppendFilter.cxx index 7f7f6e37..7207f68b 100644 --- a/src/CONVERTOR/VISU_AppendFilter.cxx +++ b/src/CONVERTOR/VISU_AppendFilter.cxx @@ -55,12 +55,14 @@ VISU_AppendFilter vtkInformationVector **theInputVector, vtkInformationVector *theOutputVector) { - bool anIsExecuted = VISU::UnstructuredGridRequestData(theInputVector, - this->GetNumberOfInputConnections(0), - theOutputVector, - GetSharedPointSet(), - IsMergingInputs(), - IsMappingInputs()); + bool anIsExecuted = false; + if(GetNumberOfInputConnections(0) > 1) + anIsExecuted = VISU::UnstructuredGridRequestData(theInputVector, + this->GetNumberOfInputConnections(0), + theOutputVector, + GetSharedPointSet(), + IsMergingInputs(), + IsMappingInputs()); if(!anIsExecuted) anIsExecuted = Superclass::RequestData(theRequest, theInputVector, diff --git a/src/CONVERTOR/VISU_AppendFilterUtilities.cxx b/src/CONVERTOR/VISU_AppendFilterUtilities.cxx index b739788e..18b58571 100644 --- a/src/CONVERTOR/VISU_AppendFilterUtilities.cxx +++ b/src/CONVERTOR/VISU_AppendFilterUtilities.cxx @@ -57,7 +57,7 @@ namespace typedef vtkIdType TInputId; typedef std::pair TInputCellId; - typedef vtkIdType TObjectId; + typedef std::pair TObjectId; typedef std::map TObject2InputIdMap; @@ -69,11 +69,12 @@ namespace { if(vtkDataArray *aDataArray = theCellData->GetArray("VISU_CELLS_MAPPER")){ if(vtkIntArray *anIntArray = dynamic_cast(aDataArray)){ - int aMaxId = anIntArray->GetMaxId(); - int* aPointer = anIntArray->GetPointer(0); - int* anEndPointer = anIntArray->GetPointer(aMaxId + 1); - for(vtkIdType aCellId = 0; aPointer != anEndPointer; aPointer++, aCellId++){ - TObjectId anObjectId = *aPointer; + int *aPointer = anIntArray->GetPointer(0); + int aNbCells = anIntArray->GetNumberOfTuples(); + for(vtkIdType aCellId = 0; aCellId < aNbCells; aCellId++){ + int aObjId = *aPointer++; + int anEntity = *aPointer++; + TObjectId anObjectId(aObjId, anEntity); TObject2InputIdMap::iterator anIter = theResult.find(anObjectId); if(anIter != theResult.end()) continue; diff --git a/src/CONVERTOR/VISU_CommonCellsFilter.cxx b/src/CONVERTOR/VISU_CommonCellsFilter.cxx index 6ca42755..e0dd2220 100644 --- a/src/CONVERTOR/VISU_CommonCellsFilter.cxx +++ b/src/CONVERTOR/VISU_CommonCellsFilter.cxx @@ -4,6 +4,7 @@ // Copyright : Open CASCADE #include "VISU_CommonCellsFilter.hxx" +#include "VISU_ConvertorDef.hxx" // VTK product headers #include @@ -21,21 +22,70 @@ #include #include #include +#include + +#ifdef _DEBUG_ +static int MYDEBUG = 0; +#else +static int MYDEBUG = 0; +#endif + +// TTimerLog +#include "VISU_ConvertorUtils.hxx" namespace { - typedef std::vector TSortedArray; + typedef std::pair TPair;// pair first - object id, second - entity + // + typedef std::vector TSortedArrayOne; + typedef std::set TSortedArrayPair; + typedef std::set TIdSet; typedef std::map TId2IdMap; inline void - GetSortedArray(vtkIntArray *theArray, - TSortedArray& theSortedArray) + GetSortedArrayAsPair(vtkIntArray *theArray, + TSortedArrayPair& theSortedArray) + { + TSortedArrayPair aSortedArray; + int nbComp = theArray->GetNumberOfComponents(); + if(nbComp == 2){ + int aMaxId = theArray->GetNumberOfTuples()*theArray->GetNumberOfComponents(); + int* aPointer = theArray->GetPointer(0); + int* anEndPointer = theArray->GetPointer(aMaxId + 1); + for(;aPointerGetNumberOfTuples(); + int* aPointer = theArray->GetPointer(0); + int* anEndPointer = theArray->GetPointer(aMaxId + 1); + for(;aPointerGetMaxId(); int* aPointer = theArray->GetPointer(0); int* anEndPointer = theArray->GetPointer(aMaxId + 1); - TSortedArray aSortedArray(aPointer, anEndPointer); + TSortedArrayOne aSortedArray(aPointer, anEndPointer); std::sort(aSortedArray.begin(), aSortedArray.end()); theSortedArray.swap(aSortedArray); } @@ -44,37 +94,46 @@ namespace void GetIdsForCopy(vtkUnstructuredGrid *inputUGrid, vtkIntArray* inputPointIds, - TSortedArray& outputSortedArray) + TSortedArrayOne& outputSortedArray) { if(inputUGrid){ - TSortedArray aSortedPointIds; - TSortedArray aOutputCellIds; - GetSortedArray(inputPointIds,aSortedPointIds); - + TSortedArrayOne aSortedPointIds; + TSortedArrayOne 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(); - TSortedArray aPointCellIds; for(int idCell=0;idCellGetCell(idCell); vtkIdList* ptIds = aCell->GetPointIds(); - int aMaxId = ptIds->GetNumberOfIds(); - int* aPointer = ptIds->GetPointer(0); - int* anEndPointer = ptIds->GetPointer(aMaxId + 1); - TSortedArray aSortedArray(aPointer, anEndPointer); - std::sort(aSortedArray.begin(), aSortedArray.end()); - - int aMaxLength = std::max(aSortedArray.size(), aSortedPointIds.size()); - TSortedArray anIntersectionArray(aMaxLength); - TSortedArray::iterator anArrayIter = anIntersectionArray.begin(); - anArrayIter = std::set_intersection(aSortedArray.begin(), - aSortedArray.end(), - aSortedPointIds.begin(), - aSortedPointIds.end(), - anArrayIter); - anIntersectionArray.erase(anArrayIter, anIntersectionArray.end()); - if(anIntersectionArray.size() == aSortedArray.size()) + 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; + } outputSortedArray.swap(aOutputCellIds); @@ -85,11 +144,16 @@ namespace void CopyElementsToOutput(vtkUnstructuredGrid* theInputUG, int& theNbElements, - TSortedArray& theElementIdsForCopy, + TSortedArrayOne& theElementIdsForCopy, TId2IdMap& theOldId2NewIdPointsMap, - vtkIntArray* theOuputIDSArray, vtkUnstructuredGrid* theOutputUG) { + vtkIntArray* theOuputIDSArray = vtkIntArray::New(); + theOuputIDSArray->SetName("VISU_CELLS_MAPPER"); + theOuputIDSArray->SetNumberOfComponents(2); + theOuputIDSArray->SetNumberOfTuples(theNbElements); + int* aOuputIDSPtr = theOuputIDSArray->GetPointer(0); + vtkIntArray* aInputCellsMapper = dynamic_cast(theInputUG->GetCellData()->GetArray("VISU_CELLS_MAPPER")); int* aInputCellsMapperPointer = aInputCellsMapper->GetPointer(0); @@ -107,13 +171,18 @@ namespace const int aOldCellId = theElementIdsForCopy[aCellIndex]; theOutputUG->InsertNextCell(theInputUG->GetCellType(aOldCellId), aNewPointIds); - if(aInputCellsMapperPointer) - theOuputIDSArray->InsertNextValue(aInputCellsMapperPointer[aOldCellId]); - else - theOuputIDSArray->InsertNextValue(aOldCellId); + + *aOuputIDSPtr = aInputCellsMapperPointer[2*aOldCellId]; + aOuputIDSPtr++; + *aOuputIDSPtr = aInputCellsMapperPointer[2*aOldCellId+1]; + aOuputIDSPtr++; aNewPointIds->Delete(); } + + theOutputUG->GetCellData()->AddArray(theOuputIDSArray); + + theOuputIDSArray->Delete(); } } @@ -163,6 +232,7 @@ void VISU_CommonCellsFilter ::Execute() { + VISU::TTimerLog aTimerLog(MYDEBUG,"VISU_CommonCellsFilter::Execute"); vtkUnstructuredGrid* anInputProfileUG = this->GetProfileUG(); vtkUnstructuredGrid* anInputCellsUG = this->GetCellsUG(); @@ -198,9 +268,11 @@ VISU_CommonCellsFilter vtkIntArray* aPointIDS = dynamic_cast(aInputCellData->GetArray("VISU_CELLS_MAPPER")); if(aPointIDS){ + int* aPtr = aPointIDS->GetPointer(0); aPointIdsForCopy->SetNumberOfIds(aPointIDS->GetNumberOfTuples()); for(int i=0;iGetNumberOfTuples();i++){ - aPointIdsForCopy->SetId(i,aPointIDS->GetValue(i)); + aPointIdsForCopy->SetId(i,*aPtr); + aPtr++;aPtr++; } aOutputPointSet->SetNumberOfPoints(aPointIdsForCopy->GetNumberOfIds()); // aOutputPointSet copy points from anInputProfileUG to aOutputPointSet, which @@ -218,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); @@ -234,7 +310,7 @@ VISU_CommonCellsFilter // Calculate output cells int nbCells=0; - TSortedArray aCellIdsForCopy; + TSortedArrayOne aCellIdsForCopy; GetIdsForCopy(anInputCellsUG,aPointIDS,aCellIdsForCopy); nbCells = aCellIdsForCopy.size(); @@ -242,22 +318,15 @@ VISU_CommonCellsFilter // copy cells to output int aAllocMem = nbCells; anOutput->Allocate(aAllocMem); - vtkIntArray* theOuputIDSArray = vtkIntArray::New(); - theOuputIDSArray->SetName("VISU_CELLS_MAPPER"); - theOuputIDSArray->SetNumberOfComponents(1); - theOuputIDSArray->SetNumberOfTuples(aAllocMem); - + if(nbCells>0 && anInputCellsUG) CopyElementsToOutput(anInputCellsUG, nbCells, aCellIdsForCopy, aOldId2NewIdPointsMap, - theOuputIDSArray, anOutput); - anOutput->GetCellData()->AddArray(theOuputIDSArray); - - theOuputIDSArray->Delete(); + aPointIdsForCopy->Delete(); } } diff --git a/src/CONVERTOR/VISU_ConvertorUtils.cxx b/src/CONVERTOR/VISU_ConvertorUtils.cxx index 88a703b1..35db58b1 100644 --- a/src/CONVERTOR/VISU_ConvertorUtils.cxx +++ b/src/CONVERTOR/VISU_ConvertorUtils.cxx @@ -220,9 +220,7 @@ namespace VISU { theDataSet->Update(); vtkDataSetAttributes *aDataSetAttributes = theDataSet->GetPointData(); - if(aDataSetAttributes->GetArray("VISU_POINTS_MAPPER")) - return aDataSetAttributes->GetNumberOfArrays() > 1; - return aDataSetAttributes->GetNumberOfArrays() > 0; + return aDataSetAttributes->GetArray("VISU_FIELD") != NULL; } @@ -232,26 +230,71 @@ namespace VISU { theDataSet->Update(); vtkDataSetAttributes *aDataSetAttributes = theDataSet->GetCellData(); - if(aDataSetAttributes->GetArray("VISU_CELLS_MAPPER")) - return aDataSetAttributes->GetNumberOfArrays() > 1; - return aDataSetAttributes->GetNumberOfArrays() > 0; + return aDataSetAttributes->GetArray("VISU_FIELD") != NULL; } //--------------------------------------------------------------- vtkIdType - GetElemVTKID(vtkDataSet *theDataSet, vtkIdType theID) + 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) { theDataSet->Update(); vtkDataSetAttributes *aDataSetAttributes = theDataSet->GetCellData(); if(vtkDataArray *aDataArray = aDataSetAttributes->GetArray("VISU_CELLS_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(theEntity < 0){ + { + vtkIdType anID = GetVTKID(aDataArray, theID, VISU::CELL_ENTITY); + if(anID != -1) + return anID; + } + { + vtkIdType anID = GetVTKID(aDataArray, theID, VISU::FACE_ENTITY); + if(anID != -1) + return anID; + } + { + vtkIdType anID = GetVTKID(aDataArray, theID, VISU::EDGE_ENTITY); + if(anID != -1) + return anID; + } + { + vtkIdType anID = GetVTKID(aDataArray, theID, VISU::NODE_ENTITY); + if(anID != -1) + return anID; + } + }else + return GetVTKID(aDataArray, theID, theEntity); } return -1; } @@ -263,30 +306,31 @@ namespace VISU { theDataSet->Update(); vtkDataSetAttributes *aDataSetAttributes = theDataSet->GetCellData(); - if(vtkDataArray *aDataArray = aDataSetAttributes->GetArray("VISU_CELLS_MAPPER")){ - if(vtkIntArray *anIntArray = dynamic_cast(aDataArray)){ - return anIntArray->GetValue(theID); - } - } + 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; } @@ -297,15 +341,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); + } + + //--------------------------------------------------------------- TGaussPointID GetObjID(vtkDataSet *theDataSet, vtkIdType theID) diff --git a/src/CONVERTOR/VISU_ConvertorUtils.hxx b/src/CONVERTOR/VISU_ConvertorUtils.hxx index f2e04fde..6455a061 100644 --- a/src/CONVERTOR/VISU_ConvertorUtils.hxx +++ b/src/CONVERTOR/VISU_ConvertorUtils.hxx @@ -33,6 +33,7 @@ #include "VISU_IDMapper.hxx" #include "MED_Utilities.hxx" +#include "VTKViewer.h" #include #include @@ -42,6 +43,7 @@ class vtkUnstructuredGrid; class vtkPolyData; class vtkTimerLog; class vtkDataSet; +class vtkCell; #ifndef VISU_ENABLE_QUADRATIC #define VISU_ENABLE_QUADRATIC @@ -98,7 +100,7 @@ namespace VISU //--------------------------------------------------------------- VISU_CONVERTOR_EXPORT vtkIdType - GetElemVTKID(vtkDataSet *theDataSet, vtkIdType theID); + GetElemVTKID(vtkDataSet *theDataSet, vtkIdType theID, int theEntity = -1); //--------------------------------------------------------------- @@ -107,6 +109,12 @@ namespace VISU GetElemObjID(vtkDataSet *theDataSet, vtkIdType theID); + //--------------------------------------------------------------- + VISU_CONVERTOR_EXPORT + vtkCell* + GetElemCell(vtkDataSet *theDataSet, vtkIdType theObjID); + + //--------------------------------------------------------------- VISU_CONVERTOR_EXPORT vtkIdType @@ -119,6 +127,11 @@ namespace VISU GetNodeObjID(vtkDataSet *theDataSet, vtkIdType theID); + //--------------------------------------------------------------- + VISU_CONVERTOR_EXPORT + vtkFloatingPointType* + GetNodeCoord(vtkDataSet *theDataSet, vtkIdType theObjID); + //--------------------------------------------------------------- VISU_CONVERTOR_EXPORT TGaussPointID diff --git a/src/CONVERTOR/VISU_Convertor_impl.cxx b/src/CONVERTOR/VISU_Convertor_impl.cxx index 46342752..9f67b8fe 100644 --- a/src/CONVERTOR/VISU_Convertor_impl.cxx +++ b/src/CONVERTOR/VISU_Convertor_impl.cxx @@ -126,13 +126,16 @@ namespace { int aNbTuples = aNbCells; + int anEntity = int(theMeshOnEntity->myEntity); vtkIntArray *aDataArray = vtkIntArray::New(); aDataArray->SetName("VISU_CELLS_MAPPER"); - aDataArray->SetNumberOfComponents(1); + aDataArray->SetNumberOfComponents(2); aDataArray->SetNumberOfTuples(aNbTuples); + int *aDataArrayPtr = aDataArray->GetPointer(0); for(int aTupleId = 0; aTupleId < aNbTuples; aTupleId++){ int anObjID = theSubMesh->GetElemObjID(aTupleId); - aDataArray->SetValue(aTupleId, anObjID); + *aDataArrayPtr++ = anObjID; + *aDataArrayPtr++ = anEntity; } theSource->GetCellData()->AddArray(aDataArray); aDataArray->Delete(); @@ -176,9 +179,11 @@ namespace aMeshID.resize(aNbCells); vtkIntArray *aDataArray = vtkIntArray::New(); + int anEntity = int(theMeshOnEntity->myEntity); aDataArray->SetName("VISU_CELLS_MAPPER"); - aDataArray->SetNumberOfComponents(1); + aDataArray->SetNumberOfComponents(2); aDataArray->SetNumberOfTuples(aNbCells); + int *aDataArrayPtr = aDataArray->GetPointer(0); VISU::TID2ID& anElemObj2VTKID = theFamily->myElemObj2VTKID; @@ -213,9 +218,10 @@ namespace PrintCells(aCellId, aConnectivity, anArray[anID]); aCellTypesArray->SetValue(aCellId, (unsigned char)aVGeom); vtkIdType anObjID = aSubMesh.GetElemObjID(anID); - aDataArray->SetValue(aCellId, anObjID); anElemObj2VTKID[anObjID] = aCellId; aMeshID[aCellId] = anObjID; + *aDataArrayPtr++ = anObjID; + *aDataArrayPtr++ = anEntity; } } @@ -303,13 +309,16 @@ namespace { int aNbTuples = aNbCells; + int anEntity = int(theMeshOnEntity->myEntity); vtkIntArray *aDataArray = vtkIntArray::New(); aDataArray->SetName("VISU_CELLS_MAPPER"); - aDataArray->SetNumberOfComponents(1); + aDataArray->SetNumberOfComponents(2); aDataArray->SetNumberOfTuples(aNbTuples); + int *aDataArrayPtr = aDataArray->GetPointer(0); for(int aTupleId = 0; aTupleId < aNbTuples; aTupleId++){ int anObjID = theSubProfile->GetElemObjID(aTupleId); - aDataArray->SetValue(aTupleId, anObjID); + *aDataArrayPtr++ = anObjID; + *aDataArrayPtr++ = anEntity; } theSource->GetCellData()->AddArray(aDataArray); aDataArray->Delete(); @@ -608,6 +617,10 @@ VISU_Convertor_impl const VISU::TGeom2SubMesh& aGeom2SubMesh = aMeshOnEntity->myGeom2SubMesh; VISU::TGeom2SubMesh::const_iterator anIter = aGeom2SubMesh.begin(); + VISU::TID2ID& anElemObj2VTKID = aMeshOnEntity->myElemObj2VTKID; + VISU::TSubMeshArr& aSubMeshArr = aMeshOnEntity->mySubMeshArr; + aSubMeshArr.resize(aGeom2SubMesh.size()); + for(vtkIdType anID = 0, aCellID = 0; anIter != aGeom2SubMesh.end(); anIter++, anID++){ VISU::EGeometry aEGeom = anIter->first; vtkIdType aVGeom = VISUGeom2VTK(aEGeom); @@ -626,7 +639,14 @@ VISU_Convertor_impl aSubMesh->myStartID = aCellID; GetCellsOnSubMesh(aSource, aMeshOnEntity, aSubMesh, aVGeom); anAppendFilter->AddInput(aSource.GetPointer()); - aCellID += aSource->GetNumberOfCells(); + + vtkIdType aNbCells = aSource->GetNumberOfCells(); + for(vtkIdType aCell = 0; aCell < aNbCells; aCell++, aCellID++){ + vtkIdType anObjID = aSubMesh->GetElemObjID(aCell); + anElemObj2VTKID[anObjID] = aCellID; + } + + aSubMeshArr[anID] = aSubMesh; } aMeshOnEntity->myNamedPointCoords = aMesh->myNamedPointCoords; diff --git a/src/CONVERTOR/VISU_MergeFilterUtilities.cxx b/src/CONVERTOR/VISU_MergeFilterUtilities.cxx index 585e7e0e..362ebba2 100644 --- a/src/CONVERTOR/VISU_MergeFilterUtilities.cxx +++ b/src/CONVERTOR/VISU_MergeFilterUtilities.cxx @@ -42,368 +42,347 @@ #include #include +#include #include namespace { //--------------------------------------------------------------- - typedef std::vector TSortedArray; + typedef int TCellId; + typedef int TEntityId; + typedef std::pair TObjectId; + + typedef std::set TObjectIdSet; + typedef std::vector TObjectIdArray; + + typedef int TTupleId; + typedef std::map TObjectId2TupleIdMap; //--------------------------------------------------------------- - inline 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); + for(; aPointer != anEndPointer; aPointer += 2){ + TCellId aCellId = *aPointer; + TEntityId anEntityId = *(aPointer + 1); + TObjectId anObjectId(aCellId, anEntityId); + theObjectIdSet.insert(anObjectId); + } } //--------------------------------------------------------------- - typedef std::map TId2IdMap; - - - //--------------------------------------------------------------- - template - void DeepCopySwitchOnOutput(TNumericType *theInputPtr, - TNumericType *theOutputPtr, - const TSortedArray& theIntersection, - const TId2IdMap& theObj2VTKMap, - vtkIdType theNbComp) + void + GetObjectId2TupleIdMap(vtkIntArray *theArray, + TObjectId2TupleIdMap& theObjectId2TupleIdMap) { - 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++]; - } + 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; } } //--------------------------------------------------------------- - typedef vtkDataArray* (vtkDataSetAttributes::* TGetAttribute)(); - typedef int (vtkDataSetAttributes::* TSetAttribute)(vtkDataArray*); - + typedef vtkFieldData* (vtkDataSet::* TGetFieldData)(); //--------------------------------------------------------------- - inline - void - CopyArray(vtkDataArray* theDataArray, - vtkDataSetAttributes* theOutput, - TSetAttribute theSetAttribute, - vtkIdType theFixedNbTuples) + struct TGetCellData { - if(theDataArray){ - vtkIdType aNbTuples = theDataArray->GetNumberOfTuples(); - if(theFixedNbTuples == aNbTuples) - (theOutput->*theSetAttribute)(theDataArray); + vtkFieldData* + operator()(vtkDataSet* theDataSet) + { + return theDataSet->GetCellData(); } - } + }; //--------------------------------------------------------------- - inline - void - CopyAttribute(vtkDataSetAttributes* theInput, - TGetAttribute theGetAttribute, - vtkDataSetAttributes* theOutput, - TSetAttribute theSetAttribute, - vtkIdType theFixedNbTuples) + struct TGetPointData { - CopyArray((theInput->*theGetAttribute)(), - theOutput, theSetAttribute, - theFixedNbTuples); - } + vtkFieldData* + operator()(vtkDataSet* theDataSet) + { + return theDataSet->GetPointData(); + } + }; //--------------------------------------------------------------- - vtkDataArray* - DeepCopyArray(vtkDataArray* theDataArray, - vtkDataSetAttributes* theOutput, - TSetAttribute theSetAttribute, - const TSortedArray& theIntersection, - const TId2IdMap& theObj2VTKMap) + template + vtkIntArray* + GetIDMapper(VISU::TFieldList* theFieldList, + TGetFieldData theGetFieldData, + const char* theFieldName) { - 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!"); + VISU::TFieldListIterator anIter(theFieldList); + for(anIter.Begin(); !anIter.End() ; anIter.Next()){ + const char* aFieldName = anIter.Get()->GetName(); + if(strcmp(aFieldName, theFieldName) == 0){ + vtkDataSet* aDataSet = anIter.Get()->Ptr; + vtkFieldData *aFieldData = theGetFieldData(aDataSet); + vtkDataArray *anIDMapper = aFieldData->GetArray(theFieldName); + return dynamic_cast(anIDMapper); } - - (theOutput->*theSetAttribute)(aDataArray); - aDataArray->Delete(); } - return aDataArray; + return NULL; } //--------------------------------------------------------------- - void - DeepCopyAttribute(vtkDataSetAttributes* theInput, - TGetAttribute theGetAttribute, - vtkDataSetAttributes* theOutput, - TSetAttribute theSetAttribute, - const TSortedArray& theIntersection, - const TId2IdMap& theObj2VTKMap) + template + vtkIntArray* + GetIDMapper(vtkDataSet* theIDMapperDataSet, + TGetFieldData theGetFieldData, + const char* theFieldName) { - DeepCopyArray((theInput->*theGetAttribute)(), - theOutput, - theSetAttribute, - theIntersection, - theObj2VTKMap); + vtkFieldData *aFieldData = theGetFieldData(theIDMapperDataSet); + vtkDataArray *anIDMapper = aFieldData->GetArray(theFieldName); + return dynamic_cast(anIDMapper); } //--------------------------------------------------------------- - inline - void - DeepCopyDataSetAttribute(vtkDataSet* theInput, - TGetAttribute theGetAttribute, - vtkDataSet* theOutput, - TSetAttribute theSetAttribute, - const TSortedArray& theIntersection, - const TId2IdMap& theObj2VTKMap) + bool + IsDifferent(vtkIntArray *theFirstIDMapper, + vtkIntArray *theSecondIDMapper) { - CopyAttribute(theInput->GetPointData(), - theGetAttribute, - theOutput->GetPointData(), - theSetAttribute, - theInput->GetNumberOfPoints()); - DeepCopyAttribute(theInput->GetCellData(), - theGetAttribute, - theOutput->GetCellData(), - theSetAttribute, - theIntersection, - theObj2VTKMap); + vtkIdType aFirstNbTuples = theFirstIDMapper->GetNumberOfTuples(); + vtkIdType aSecondNbTuples = theSecondIDMapper->GetNumberOfTuples(); + if(aFirstNbTuples != aSecondNbTuples) + return true; + + 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; + } + + return false; } //--------------------------------------------------------------- inline void - DeepCopyField(vtkDataSetAttributes* theInput, - const char* theFieldName, - vtkDataSetAttributes* theOutput, - const TSortedArray& theIntersection, - const TId2IdMap& theObj2VTKMap) + GetIntersection(vtkIntArray *theFirstIDMapper, + vtkIntArray *theSecondIDMapper, + TObjectIdArray& theResult) { - vtkDataArray* aDataArray = - DeepCopyArray(theInput->GetArray(theFieldName), - theOutput, - &vtkFieldData::AddArray, - theIntersection, - theObj2VTKMap); - if(aDataArray) - aDataArray->SetName(theFieldName); + 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()); } //--------------------------------------------------------------- - inline - void - CopyField(vtkDataSetAttributes* theInput, - const char* theFieldName, - vtkDataSetAttributes* theOutput, - vtkIdType theFixedNbTuples) + template + void + CopyDataOnCells(TDataSet *theInput, + vtkIntArray *theGeometryCellMapper, + vtkIntArray *theDataCellMapper, + vtkDataSet* theScalarsDataSet, + vtkDataSet* theVectorsDataSet, + vtkDataSet* theNormalsDataSet, + vtkDataSet* theTCoordsDataSet, + vtkDataSet* theTensorsDataSet, + VISU::TFieldList* theFieldList, + TDataSet *theOutput) { - CopyArray(theInput->GetArray(theFieldName), - theOutput, - &vtkDataSetAttributes::AddArray, - theFixedNbTuples); - } - + if(IsDifferent(theGeometryCellMapper, theDataCellMapper)){ + TObjectIdArray anIntersection; + GetIntersection(theGeometryCellMapper, + theDataCellMapper, + anIntersection); + + TObjectId2TupleIdMap aGeomObjectId2TupleIdMap; + GetObjectId2TupleIdMap(theGeometryCellMapper, aGeomObjectId2TupleIdMap); + + TObjectId2TupleIdMap aDataObjectId2TupleIdMap; + GetObjectId2TupleIdMap(theDataCellMapper, aDataObjectId2TupleIdMap); + + 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(); - //--------------------------------------------------------------- - 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); + theOutput->SetPoints(theInput->GetPoints()); + }else{ + theOutput->CopyStructure(theInput); + theOutput->GetCellData()->ShallowCopy(theScalarsDataSet->GetCellData()); + } + theOutput->GetPointData()->ShallowCopy(theInput->GetPointData()); } - - + + //--------------------------------------------------------------- - inline - void - DeepCopyDataSetAttributes(vtkDataSet *theFilterOutput, - vtkDataSet* theScalarsDataSet, - vtkDataSet* theVectorsDataSet, - vtkDataSet* theNormalsDataSet, - vtkDataSet* theTCoordsDataSet, - vtkDataSet* theTensorsDataSet, - VISU::TFieldList* theFieldList, - const TSortedArray& theIntersection, - const TId2IdMap& theObj2VTKMap) + template + void + CopyDataOnPoints(TDataSet *theInput, + vtkIntArray *theGeometryPointMapper, + vtkIntArray *theDataPointMapper, + vtkDataSet* theScalarsDataSet, + vtkDataSet* theVectorsDataSet, + vtkDataSet* theNormalsDataSet, + vtkDataSet* theTCoordsDataSet, + vtkDataSet* theTensorsDataSet, + VISU::TFieldList* theFieldList, + TDataSet *theOutput) { - if(theScalarsDataSet) - DeepCopyDataSetAttribute(theScalarsDataSet, - &vtkDataSetAttributes::GetScalars, - theFilterOutput, - &vtkDataSetAttributes::SetScalars, - theIntersection, - theObj2VTKMap); - - if(theVectorsDataSet) - DeepCopyDataSetAttribute(theVectorsDataSet, - &vtkDataSetAttributes::GetVectors, - theFilterOutput, - &vtkDataSetAttributes::SetVectors, - theIntersection, - theObj2VTKMap); - - if(theNormalsDataSet) - DeepCopyDataSetAttribute(theNormalsDataSet, - &vtkDataSetAttributes::GetNormals, - theFilterOutput, - &vtkDataSetAttributes::SetNormals, - theIntersection, - theObj2VTKMap); - - if(theTCoordsDataSet) - DeepCopyDataSetAttribute(theTCoordsDataSet, - &vtkDataSetAttributes::GetTCoords, - theFilterOutput, - &vtkDataSetAttributes::SetTCoords, - theIntersection, - theObj2VTKMap); - - if(theTensorsDataSet) - DeepCopyDataSetAttribute(theTensorsDataSet, - &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); + 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(); + + // Copy geometry points + // 1. Create vtkPoints instance of the same data type + vtkPointSet* aScalarsDataSet = dynamic_cast(theScalarsDataSet); + vtkPoints* anGeometryPoints = theInput->GetPoints(); + vtkPoints* aDataPoints = aScalarsDataSet->GetPoints(); + vtkPoints* anOutputPoints = vtkPoints::New(aDataPoints->GetDataType()); + theOutput->SetPoints(anOutputPoints); + anOutputPoints->Delete(); + + // 2. Perform mapping of geometry points + TObjectId2TupleIdMap aGeomObjectId2TupleIdMap; + GetObjectId2TupleIdMap(theGeometryPointMapper, aGeomObjectId2TupleIdMap); + + // 3. Loop over all data points + int aNbDataPoints = theDataPointMapper->GetNumberOfTuples(); + anOutputPoints->SetNumberOfPoints(aNbDataPoints); + for(int aPointId = 0; aPointId < aNbDataPoints; aPointId++){ + int* aPointer = theDataPointMapper->GetPointer(aPointId * 2); + TCellId aCellId = *aPointer; + TEntityId anEntityId = *(aPointer + 1); + TObjectId anObjectId(aCellId, anEntityId); + TObjectId2TupleIdMap::iterator anIter = aGeomObjectId2TupleIdMap.find(anObjectId); + if(anIter != aDataObjectId2PointIdMap.end()){ + // If the point exists in the geometry put it to output + int aGeometryPointId = anIter->second; + vtkFloatingPointType aCoords[3]; + anGeometryPoints->GetPoint(aGeometryPointId, aCoords); + anOutputPoints->SetPoint(aPointId, aCoords); + }else{ + // If no, the point from data should be used + vtkFloatingPointType aCoords[3]; + aDataPoints->GetPoint(aPointId, aCoords); + anOutputPoints->SetPoint(aPointId, aCoords); + } + } + }else{ + theOutput->CopyStructure(theInput); + theOutput->GetCellData()->ShallowCopy(theInput->GetCellData()); } + theOutput->GetPointData()->ShallowCopy(theScalarsDataSet->GetPointData()); } //--------------------------------------------------------------- + typedef vtkDataArray* (vtkDataSetAttributes::* TGetAttribute)(); + typedef int (vtkDataSetAttributes::* TSetAttribute)(vtkDataArray*); + inline void - GetIdsForCopy(vtkDataSet* theInputDataSet, - vtkIntArray* inputPointIds, - TSortedArray& outputSortedArray) + CopyArray(vtkDataArray* theDataArray, + vtkDataSetAttributes* theOutput, + TSetAttribute theSetAttribute, + vtkIdType theFixedNbTuples) { - if(theInputDataSet){ - TSortedArray aSortedPointIds; - TSortedArray aOutputCellIds; - GetSortedArray(inputPointIds,aSortedPointIds); - - int nbInputCells = theInputDataSet->GetNumberOfCells(); - - TSortedArray aPointCellIds; - for(int idCell=0;idCellGetCell(idCell); - vtkIdList* ptIds = aCell->GetPointIds(); - int aMaxId = ptIds->GetNumberOfIds(); - int* aPointer = ptIds->GetPointer(0); - int* anEndPointer = ptIds->GetPointer(aMaxId + 1); - TSortedArray aSortedArray(aPointer, anEndPointer); - std::sort(aSortedArray.begin(), aSortedArray.end()); - - int aMaxLength = std::max(aSortedArray.size(), aSortedPointIds.size()); - TSortedArray anIntersectionArray(aMaxLength); - TSortedArray::iterator anArrayIter = anIntersectionArray.begin(); - anArrayIter = std::set_intersection(aSortedArray.begin(), - aSortedArray.end(), - aSortedPointIds.begin(), - aSortedPointIds.end(), - anArrayIter); - anIntersectionArray.erase(anArrayIter, anIntersectionArray.end()); - if(anIntersectionArray.size() == aSortedArray.size()) - aOutputCellIds.push_back(idCell); - } - - outputSortedArray.swap(aOutputCellIds); + if(theDataArray){ + vtkIdType aNbTuples = theDataArray->GetNumberOfTuples(); + if(theFixedNbTuples == aNbTuples) + (theOutput->*theSetAttribute)(theDataArray); } } //--------------------------------------------------------------- - template + inline void - CopyElementsToOutput(vtkDataSet* theInputDataSet, - int& theNbElements, - TSortedArray& theElementIdsForCopy, - TId2IdMap& theOldId2NewIdPointsMap, - vtkIntArray* theOuputIDSArray, - TDataSet* theOutputDataSet) + CopyAttribute(vtkDataSetAttributes* theInput, + TGetAttribute theGetAttribute, + vtkDataSetAttributes* theOutput, + TSetAttribute theSetAttribute, + vtkIdType theFixedNbTuples) { - vtkIntArray* aInputCellsMapper = - dynamic_cast(theInputDataSet->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); - } - const int aOldCellId = theElementIdsForCopy[aCellIndex]; - theOutputDataSet->InsertNextCell(theInputDataSet->GetCellType(aOldCellId), - aNewPointIds); - if(aInputCellsMapperPointer) - theOuputIDSArray->InsertNextValue(aInputCellsMapperPointer[aOldCellId]); - else - theOuputIDSArray->InsertNextValue(aOldCellId); - - aNewPointIds->Delete(); - } - theOutputDataSet->GetCellData()->AddArray(theOuputIDSArray); + CopyArray((theInput->*theGetAttribute)(), + theOutput, theSetAttribute, + theFixedNbTuples); } @@ -430,6 +409,21 @@ namespace } + //--------------------------------------------------------------- + inline + void + CopyField(vtkDataSetAttributes* theInput, + const char* theFieldName, + vtkDataSetAttributes* theOutput, + vtkIdType theFixedNbTuples) + { + CopyArray(theInput->GetArray(theFieldName), + theOutput, + &vtkDataSetAttributes::AddArray, + theFixedNbTuples); + } + + //--------------------------------------------------------------- inline void @@ -439,312 +433,154 @@ 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); + } } - //--------------------------------------------------------------- - struct TGetCellData + void + BasicExecute(vtkDataSet *theInput, + vtkDataSet* theScalarsDataSet, + vtkDataSet* theVectorsDataSet, + vtkDataSet* theNormalsDataSet, + vtkDataSet* theTCoordsDataSet, + vtkDataSet* theTensorsDataSet, + VISU::TFieldList* theFieldList, + vtkDataSet *theOutput) { - vtkFieldData* - operator()(vtkDataSet* theDataSet) - { - return theDataSet->GetCellData(); - } - }; + theOutput->CopyStructure(theInput); + vtkIdType aNbPoints = theInput->GetNumberOfPoints(); + vtkIdType aNbCells = theInput->GetNumberOfCells(); + + // merge data only if it is consistent + if(theScalarsDataSet) + CopyDataSetAttribute(theScalarsDataSet, + &vtkDataSetAttributes::GetScalars, + theOutput, + &vtkDataSetAttributes::SetScalars, + aNbPoints, + aNbCells); - //--------------------------------------------------------------- - struct TGetPointData - { - vtkFieldData* - operator()(vtkDataSet* theDataSet) - { - return theDataSet->GetPointData(); - } - }; + if(theVectorsDataSet) + CopyDataSetAttribute(theVectorsDataSet, + &vtkDataSetAttributes::GetVectors, + theOutput, + &vtkDataSetAttributes::SetVectors, + aNbPoints, + aNbCells); + if(theNormalsDataSet) + CopyDataSetAttribute(theNormalsDataSet, + &vtkDataSetAttributes::GetNormals, + theOutput, + &vtkDataSetAttributes::SetNormals, + aNbPoints, + aNbCells); - //--------------------------------------------------------------- - typedef vtkFieldData* (vtkDataSet::* TGetFieldData)(); + if(theTCoordsDataSet) + CopyDataSetAttribute(theTCoordsDataSet, + &vtkDataSetAttributes::GetTCoords, + theOutput, + &vtkDataSetAttributes::SetTCoords, + aNbPoints, + aNbCells); + + if(theTensorsDataSet) + CopyDataSetAttribute(theTensorsDataSet, + &vtkDataSetAttributes::GetTensors, + theOutput, + &vtkDataSetAttributes::SetTensors, + aNbPoints, + aNbCells); - template - vtkIntArray* - GetIDMapper(VISU::TFieldList* theFieldList, - TGetFieldData theGetFieldData, - const char* theFieldName) - { VISU::TFieldListIterator anIter(theFieldList); for(anIter.Begin(); !anIter.End() ; anIter.Next()){ + vtkDataSet *aDataSet = anIter.Get()->Ptr; const char* aFieldName = anIter.Get()->GetName(); - if(strcmp(aFieldName, theFieldName) == 0){ - vtkDataSet* aDataSet = anIter.Get()->Ptr; - vtkFieldData *aFieldData = theGetFieldData(aDataSet); - vtkDataArray *anIDMapper = aFieldData->GetArray(aFieldName); - return dynamic_cast(anIDMapper); - } + CopyDataSetField(aDataSet, + aFieldName, + theOutput, + aNbPoints, + aNbCells); } - return NULL; } //--------------------------------------------------------------- template - bool + bool Execute(TDataSet *theInput, - TDataSet *theOutput, vtkDataSet* theScalarsDataSet, vtkDataSet* theVectorsDataSet, vtkDataSet* theNormalsDataSet, vtkDataSet* theTCoordsDataSet, vtkDataSet* theTensorsDataSet, VISU::TFieldList* theFieldList, - bool theIsMergingInputs) + bool theIsMergingInputs, + TDataSet *theOutput) { - vtkCellData *aCellData = theInput->GetCellData(); - if(vtkDataArray *aCellMapper = aCellData->GetArray("VISU_CELLS_MAPPER")){ - vtkIntArray *aGeometryCellMapper = dynamic_cast(aCellMapper); - vtkIdType aGeomNbCells = aGeometryCellMapper->GetNumberOfTuples(); - - vtkPointData *aPointData = theInput->GetPointData(); - vtkDataArray *aPointMapper = aPointData->GetArray("VISU_POINTS_MAPPER"); - vtkIntArray *aGeometryPointMapper = dynamic_cast(aPointMapper); - vtkIdType aGeomNbPoints = aGeometryPointMapper->GetNumberOfTuples(); - - - vtkIntArray* aDataPointMapper = GetIDMapper(theFieldList, - TGetPointData(), - "VISU_POINTS_MAPPER"); - vtkIdType aDataNbPoints = aDataPointMapper->GetNumberOfTuples(); - - vtkIntArray* aDataCellMapper = GetIDMapper(theFieldList, - TGetCellData(), - "VISU_CELLS_MAPPER"); - vtkIdType aDataNbCells = aDataCellMapper->GetNumberOfTuples(); - - if(aDataNbPoints == aGeomNbPoints){ - bool anIsDifferent = aDataCellMapper && aDataNbCells != aGeomNbCells; - if(anIsDifferent || theIsMergingInputs){ - TSortedArray aGeometryCellArray; - GetSortedArray(aGeometryCellMapper, aGeometryCellArray); - - TSortedArray aDataCellArray; - GetSortedArray(aDataCellMapper, 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 || theIsMergingInputs){ - { - TId2IdMap anObj2VTKGeometryMap; - vtkIdType aNbCells = aGeometryCellMapper->GetNumberOfTuples(); - for(int aCellId = 0; aCellId < aNbCells; aCellId++){ - vtkIdType anObjID = aGeometryCellMapper->GetValue(aCellId); - anObj2VTKGeometryMap[anObjID] = aCellId; - } - - vtkIdType aNbTuples = anIntersectionArray.size(); - theOutput->Allocate(aNbTuples); - vtkIdList *aCellIds = vtkIdList::New(); - for(int aTupleId = 0; aTupleId < aNbTuples; aTupleId++){ - vtkIdType anObjID = anIntersectionArray[aTupleId]; - vtkIdType aCellId = anObj2VTKGeometryMap[anObjID]; - vtkCell *aCell = theInput->GetCell(aCellId); - aCellIds->Reset(); - vtkIdType aNbPointIds = aCell->PointIds->GetNumberOfIds(); - for(vtkIdType aPointId = 0; aPointId < aNbPointIds; aPointId++) - aCellIds->InsertNextId(aCell->GetPointIds()->GetId(aPointId)); - theOutput->InsertNextCell(theInput->GetCellType(aCellId), aCellIds); - } - aCellIds->Delete(); - theOutput->SetPoints(theInput->GetPoints()); - } - { - TId2IdMap anObj2VTKDataMap; - vtkIdType aNbCells = aDataCellMapper->GetNumberOfTuples(); - for(int aCellId = 0; aCellId < aNbCells; aCellId++){ - vtkIdType anObjID = aDataCellMapper->GetValue(aCellId); - anObj2VTKDataMap[anObjID] = aCellId; - } - - DeepCopyDataSetAttributes(theOutput, - theScalarsDataSet, - theVectorsDataSet, - theNormalsDataSet, - theTCoordsDataSet, - theTensorsDataSet, - theFieldList, - anIntersectionArray, - anObj2VTKDataMap); - } - return true; - } - } - }else if(aDataNbPoints < aGeomNbPoints){ - vtkIntArray* aDataPointMapper = NULL; - vtkPointData* aInputScalarsPointData = theScalarsDataSet->GetPointData(); - VISU::TFieldListIterator anIter(theFieldList); - 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(theFieldList); - 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; - } + if(theIsMergingInputs){ + vtkCellData *aCellData = theInput->GetCellData(); + if(vtkDataArray *aCellMapper = aCellData->GetArray("VISU_CELLS_MAPPER")){ + bool anIsDataOnCells = false; + if(vtkDataSet* aDataSet = theScalarsDataSet) + if(vtkCellData* aCellData = aDataSet->GetCellData()) + anIsDataOnCells = (aCellData->GetArray("VISU_FIELD") != NULL); + if(anIsDataOnCells){ + vtkIntArray *aGeometryCellMapper = dynamic_cast(aCellMapper); + vtkIntArray* aDataCellMapper = GetIDMapper(theFieldList, + TGetCellData(), + "VISU_CELLS_MAPPER"); + CopyDataOnCells(theInput, + aGeometryCellMapper, + aDataCellMapper, + theScalarsDataSet, + theVectorsDataSet, + theNormalsDataSet, + theTCoordsDataSet, + theTensorsDataSet, + theFieldList, + theOutput); + }else{ + vtkPointData *aPointData = theInput->GetPointData(); + vtkDataArray *aPointMapper = aPointData->GetArray("VISU_POINTS_MAPPER"); + vtkIntArray *aGeometryPointMapper = dynamic_cast(aPointMapper); + vtkIntArray* aDataPointMapper = GetIDMapper(theFieldList, + TGetPointData(), + "VISU_POINTS_MAPPER"); + CopyDataOnPoints(theInput, + aGeometryPointMapper, + aDataPointMapper, + theScalarsDataSet, + theVectorsDataSet, + theNormalsDataSet, + theTCoordsDataSet, + theTensorsDataSet, + theFieldList, + theOutput); } - - bool anIsDifferent = aDataPointMapper && - aDataPointMapper->GetNumberOfTuples() != aGeometryPointMapper->GetNumberOfTuples(); - if(anIsDifferent){ - TSortedArray aGeometryPointArray; - GetSortedArray(aGeometryPointMapper, aGeometryPointArray); - - TSortedArray aDataPointArray; - GetSortedArray(aDataPointMapper, aDataPointArray); - - int aMaxLength = std::max(aGeometryPointArray.size(), aDataPointArray.size()); - TSortedArray anIntersectionArray(aMaxLength); - TSortedArray::iterator anArrayIter = anIntersectionArray.begin(); - anArrayIter = std::set_intersection(aGeometryPointArray.begin(), - aGeometryPointArray.end(), - aDataPointArray.begin(), - aDataPointArray.end(), - anArrayIter); - - anIntersectionArray.erase(anArrayIter, anIntersectionArray.end()); - - { - TId2IdMap anObj2VTKGeometryMap; - vtkIdType aNbCells = aDataPointMapper/*aGeometryPointMapper*/->GetNumberOfTuples(); - for(int aCellId = 0; aCellId < aNbCells; aCellId++){ - vtkIdType anObjID = aDataPointMapper/*aGeometryPointMapper*/->GetValue(aCellId); - anObj2VTKGeometryMap[anObjID] = aCellId; - } - - vtkIdType aNbTuples = anIntersectionArray.size(); - - if(aNbTuples == aDataNbPoints){ - vtkPointSet* aScalarsPointSet = vtkPointSet::SafeDownCast(theScalarsDataSet); - theOutput->SetPoints(aScalarsPointSet->GetPoints()); - theOutput->GetPointData()->ShallowCopy(aScalarsPointSet->GetPointData()); - - // Calculate output cells - int nbCells=0; - TSortedArray aCellIdsForCopy; - GetIdsForCopy(theInput, aDataPointMapper, aCellIdsForCopy); - nbCells = aCellIdsForCopy.size(); - - // copy cells to output - theOutput->Allocate(nbCells); - vtkIntArray* theOuputIDSArray = vtkIntArray::New(); - theOuputIDSArray->SetName("VISU_CELLS_MAPPER"); - theOuputIDSArray->SetNumberOfComponents(1); - theOuputIDSArray->SetNumberOfTuples(nbCells); - - if(nbCells>0) - CopyElementsToOutput(theInput, - nbCells, - aCellIdsForCopy, - anObj2VTKGeometryMap, - theOuputIDSArray, - theOutput); - theOuputIDSArray->Delete(); - return true; - } else { - // not implemented yet - } - } - } - } - } - { - theOutput->CopyStructure(theInput); - vtkIdType aNbPoints = theOutput->GetNumberOfPoints(); - vtkIdType aNbCells = theOutput->GetNumberOfCells(); - - // merge data only if it is consistent - if(theScalarsDataSet) - CopyDataSetAttribute(theScalarsDataSet, - &vtkDataSetAttributes::GetScalars, - theOutput, - &vtkDataSetAttributes::SetScalars, - aNbPoints, - aNbCells); - - if(theVectorsDataSet) - CopyDataSetAttribute(theVectorsDataSet, - &vtkDataSetAttributes::GetVectors, - theOutput, - &vtkDataSetAttributes::SetVectors, - aNbPoints, - aNbCells); - - if(theNormalsDataSet) - CopyDataSetAttribute(theNormalsDataSet, - &vtkDataSetAttributes::GetNormals, - theOutput, - &vtkDataSetAttributes::SetNormals, - aNbPoints, - aNbCells); - - if(theTCoordsDataSet) - CopyDataSetAttribute(theTCoordsDataSet, - &vtkDataSetAttributes::GetTCoords, - theOutput, - &vtkDataSetAttributes::SetTCoords, - aNbPoints, - aNbCells); - - if(theTensorsDataSet) - CopyDataSetAttribute(theTensorsDataSet, - &vtkDataSetAttributes::GetTensors, - theOutput, - &vtkDataSetAttributes::SetTensors, - aNbPoints, - aNbCells); - - VISU::TFieldListIterator anIter(theFieldList); - for(anIter.Begin(); !anIter.End() ; anIter.Next()){ - vtkDataSet *aDataSet = anIter.Get()->Ptr; - const char* aFieldName = anIter.Get()->GetName(); - CopyDataSetField(aDataSet, - aFieldName, - theOutput, - aNbPoints, - aNbCells); } + }else{ + BasicExecute(theInput, + theScalarsDataSet, + theVectorsDataSet, + theNormalsDataSet, + theTCoordsDataSet, + theTensorsDataSet, + theFieldList, + theOutput); } return true; - } - - //--------------------------------------------------------------- + } } @@ -764,14 +600,14 @@ namespace VISU bool theIsMergingInputs) { return ::Execute(theInput, - theOutput, theScalarsDataSet, theVectorsDataSet, theNormalsDataSet, theTCoordsDataSet, theTensorsDataSet, theFieldList, - theIsMergingInputs); + theIsMergingInputs, + theOutput); } @@ -788,14 +624,14 @@ namespace VISU bool theIsMergingInputs) { return ::Execute(theInput, - theOutput, theScalarsDataSet, theVectorsDataSet, theNormalsDataSet, theTCoordsDataSet, theTensorsDataSet, theFieldList, - theIsMergingInputs); + theIsMergingInputs, + theOutput); } diff --git a/src/CONVERTOR/VISU_PointCoords.cxx b/src/CONVERTOR/VISU_PointCoords.cxx index 59bdb639..bfdf7aef 100644 --- a/src/CONVERTOR/VISU_PointCoords.cxx +++ b/src/CONVERTOR/VISU_PointCoords.cxx @@ -373,13 +373,16 @@ namespace VISU { vtkIdType aNbTuples = GetNbPoints(); + 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 = GetObjID(aTupleId); - aDataArray->SetValue(aTupleId, anObjID); + *aPtr++ = anObjID; + *aPtr++ = anEntity; } myPointSet->GetPointData()->AddArray(aDataArray); aDataArray->Delete(); diff --git a/src/OBJECT/VISU_Actor.cxx b/src/OBJECT/VISU_Actor.cxx index d3632dcb..853d56c5 100644 --- a/src/OBJECT/VISU_Actor.cxx +++ b/src/OBJECT/VISU_Actor.cxx @@ -425,12 +425,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 @@ -440,7 +435,7 @@ VISU_Actor if(myIsVTKMapping) return theID; - return GetCurrentPL()->GetNodeVTKID(theID); + return VISU::GetNodeVTKID(GetMapper()->GetInput(), theID); } vtkFloatingPointType* @@ -450,7 +445,7 @@ VISU_Actor if(myIsVTKMapping) return Superclass::GetNodeCoord(theObjID); - return GetCurrentPL()->GetNodeCoord(theObjID); + return VISU::GetNodeCoord(GetInput(), theObjID); } @@ -462,12 +457,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 @@ -477,7 +467,7 @@ VISU_Actor if(myIsVTKMapping) return theID; - return GetCurrentPL()->GetElemVTKID(theID); + return VISU::GetElemVTKID(GetMapper()->GetInput(), theID); } vtkCell* @@ -487,7 +477,7 @@ VISU_Actor if(myIsVTKMapping) return Superclass::GetElemCell(theObjID); - return GetCurrentPL()->GetElemCell(theObjID); + return VISU::GetElemCell(GetInput(), theObjID); } diff --git a/src/OBJECT/VISU_GaussPtsAct.cxx b/src/OBJECT/VISU_GaussPtsAct.cxx index 18c8a26c..ea046177 100644 --- a/src/OBJECT/VISU_GaussPtsAct.cxx +++ b/src/OBJECT/VISU_GaussPtsAct.cxx @@ -854,6 +854,8 @@ VISU_GaussPtsAct anInteractor->SetDolly(aDollyWas); anInteractor->SetNumberOfFlyFrames(aNumberOfFlyFramesWas); + anInteractor->InvokeEvent(SVTK::ChangeRotationPoint, aNodeCoord); + mySelectionMode = aSelectionMode; ChangeZoom(myPickingSettings, diff --git a/src/PIPELINE/VISUPipeLine.cxx b/src/PIPELINE/VISUPipeLine.cxx index 7a07a676..100ad4b0 100644 --- a/src/PIPELINE/VISUPipeLine.cxx +++ b/src/PIPELINE/VISUPipeLine.cxx @@ -33,13 +33,14 @@ #include "VISU_VectorsPL.hxx" #include "VISU_StreamLinesPL.hxx" #include "VISU_GaussPointsPL.hxx" +#include "VISU_ScalarMapOnDeformedShapePL.hxx" #include "VISU_Plot3DPL.hxx" #include "VISU_ScalarBarActor.hxx" #include "VISU_Convertor.hxx" #include "VISU_ConvertorUtils.hxx" -typedef VISU_ScalarMapPL TPresent; +typedef VISU_ScalarMapOnDeformedShapePL TPresent; #include #include @@ -133,10 +134,17 @@ CreateColoredPL(VISU_Convertor* theConvertor, theFieldName, theTimeStampNumber); aPresent->SetUnstructuredGridIDMapper(anUnstructuredGridIDMapper); + //aPresent->ClearGeometry(); //{ // VISU::PUnstructuredGridIDMapper anIDMapper = // theConvertor->GetMeshOnGroup(theMeshName, + // "groupe1"); + // aPresent->AddGeometry(anIDMapper->GetOutput()); + //} + //{ + // VISU::PUnstructuredGridIDMapper anIDMapper = + // theConvertor->GetMeshOnGroup(theMeshName, // "TUBEH "); // aPresent->AddGeometry(anIDMapper->GetOutput()); //} @@ -146,6 +154,7 @@ CreateColoredPL(VISU_Convertor* theConvertor, // "STRI "); // aPresent->AddGeometry(anIDMapper->GetOutput()); //} + aPresent->Update(); return aPresent; } diff --git a/src/PIPELINE/VISU_ColoredPL.cxx b/src/PIPELINE/VISU_ColoredPL.cxx index d58cfb93..2020ef06 100644 --- a/src/PIPELINE/VISU_ColoredPL.cxx +++ b/src/PIPELINE/VISU_ColoredPL.cxx @@ -28,6 +28,7 @@ #include "VISU_ColoredPL.hxx" #include "VISU_Extractor.hxx" +#include "VISU_FieldTransform.hxx" #include "VISU_LookupTable.hxx" #include "VISU_MapperHolder.hxx" @@ -88,25 +89,42 @@ VISU_ColoredPL return myExtractor->GetScalarMode(); } + +//---------------------------------------------------------------------------- void VISU_ColoredPL -::SetScalarMode(int theScalarMode) +::SetScalarMode(int theScalarMode, + vtkDataSet *theInput, + VISU_Extractor* theExtractor) { - if(vtkDataSet *anInput = GetInput()){ - if(VISU::IsDataOnPoints(anInput)){ - vtkPointData *aPointData = anInput->GetPointData(); - if(!aPointData->GetAttribute(vtkDataSetAttributes::VECTORS)) - if(theScalarMode == 0) + if(theInput){ + if(VISU::IsDataOnPoints(theInput)){ + vtkPointData *aPointData = theInput->GetPointData(); + if(!aPointData->GetAttribute(vtkDataSetAttributes::VECTORS)) { + if(theScalarMode == 0){ return; - }else{ - vtkCellData *aCellData = anInput->GetCellData(); - if(!aCellData->GetAttribute(vtkDataSetAttributes::VECTORS)) - if(theScalarMode == 0) + } + } + } else { + vtkCellData *aCellData = theInput->GetCellData(); + if(!aCellData->GetAttribute(vtkDataSetAttributes::VECTORS)){ + if(theScalarMode==0){ return; + } + } } } - myExtractor->SetScalarMode(theScalarMode); + theExtractor->SetScalarMode(theScalarMode); +} + + +//---------------------------------------------------------------------------- +void +VISU_ColoredPL +::SetScalarMode(int theScalarMode) +{ + SetScalarMode(theScalarMode, GetInput(), myExtractor); } @@ -132,7 +150,11 @@ void VISU_ColoredPL ::SetScaling(int theScaling) { + if(GetScaling() == theScaling) + return; + myBarTable->SetScale(theScaling); + if(theScaling == VTK_SCALE_LOG10) myFieldTransform->SetScalarTransform(&(VISU_FieldTransform::Log10)); else @@ -174,10 +196,12 @@ VISU_ColoredPL } //---------------------------------------------------------------------------- -vtkDataSet* +vtkPointSet* VISU_ColoredPL -::InsertCustomPL() +::GetClippedInput() { + if(GetFieldTransformFilter()->GetInput()) + GetFieldTransformFilter()->Update(); return GetFieldTransformFilter()->GetUnstructuredGridOutput(); } @@ -187,7 +211,7 @@ void VISU_ColoredPL ::Build() { - myExtractor->SetInput(GetClippedInput()); + myExtractor->SetInput(Superclass::GetClippedInput()); myFieldTransform->SetInput(myExtractor->GetOutput()); GetMapperHolder()->SetLookupTable(GetMapperTable()); @@ -202,7 +226,7 @@ void VISU_ColoredPL ::Update() { - vtkFloatingPointType *aRange = myFieldTransform->GetScalarRange(); + vtkFloatingPointType *aRange = GetScalarRange(); vtkFloatingPointType aScalarRange[2] = {aRange[0], aRange[1]}; if(myBarTable->GetScale() == VTK_SCALE_LOG10) VISU_LookupTable::ComputeLogRange(aRange,aScalarRange); diff --git a/src/PIPELINE/VISU_ColoredPL.hxx b/src/PIPELINE/VISU_ColoredPL.hxx index e8a9f02f..bb683e0e 100644 --- a/src/PIPELINE/VISU_ColoredPL.hxx +++ b/src/PIPELINE/VISU_ColoredPL.hxx @@ -142,8 +142,15 @@ protected: //---------------------------------------------------------------------------- virtual - vtkDataSet* - InsertCustomPL(); + vtkPointSet* + GetClippedInput(); + + //---------------------------------------------------------------------------- + static + void + SetScalarMode(int theScalarMode, + vtkDataSet *theInput, + VISU_Extractor* theExtractor); private: vtkSmartPointer myMapperTable; diff --git a/src/PIPELINE/VISU_CutLinesPL.cxx b/src/PIPELINE/VISU_CutLinesPL.cxx index 0d3487ee..7727e4c5 100644 --- a/src/PIPELINE/VISU_CutLinesPL.cxx +++ b/src/PIPELINE/VISU_CutLinesPL.cxx @@ -25,6 +25,7 @@ #include "VISU_CutLinesPL.hxx" +#include "VISU_FieldTransform.hxx" #include "VISU_PipeLineUtils.hxx" #include "VTKViewer_GeometryFilter.h" @@ -103,7 +104,7 @@ VISU_CutLinesPL vtkFloatingPointType aPosition = myPosition; if(myCondition){ vtkFloatingPointType aBounds[6]; - GetClippedInput()->GetBounds(aBounds); + GetMergedInput()->GetBounds(aBounds); vtkFloatingPointType aDir[3]; GetDir(aDir, @@ -153,16 +154,16 @@ VISU_CutLinesPL //Build base plane vtkFloatingPointType aBaseBounds[6]; - GetClippedInput()->GetBounds(aBaseBounds); + GetMergedInput()->GetBounds(aBaseBounds); vtkFloatingPointType aDir[2][3]; GetDir(aDir[0], myAng[0], myBasePlane[0]); - vtkUnstructuredGrid* aGrid = GetFieldTransformFilter()->GetUnstructuredGridOutput(); CutWithPlanes(anAppendPolyData, - aGrid,1, + GetMergedInput(), + 1, aDir[0], aBaseBounds, myPosition, @@ -173,7 +174,7 @@ VISU_CutLinesPL aDataSet->Update(); if(aDataSet->GetNumberOfCells() == 0) - aDataSet = aGrid; + aDataSet = GetMergedInput(); vtkFloatingPointType aBounds[6]; aDataSet->GetBounds(aBounds); @@ -190,6 +191,10 @@ VISU_CutLinesPL myPartPosition, myPartCondition, myDisplacement[1]); + //{ + // std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-myAppendPolyData.vtk"; + // VISU::WriteToFile(myAppendPolyData->GetOutput(), aFileName); + //} anAppendPolyData->Delete(); //Calculate values for building of table diff --git a/src/PIPELINE/VISU_CutPlanesPL.cxx b/src/PIPELINE/VISU_CutPlanesPL.cxx index 1c238bcb..431080ee 100644 --- a/src/PIPELINE/VISU_CutPlanesPL.cxx +++ b/src/PIPELINE/VISU_CutPlanesPL.cxx @@ -26,6 +26,7 @@ #include "VISU_CutPlanesPL.hxx" +#include "VISU_FieldTransform.hxx" #include "VISU_PipeLineUtils.hxx" #include "VTKViewer_GeometryFilter.h" @@ -131,11 +132,10 @@ VISU_CutPlanesPL myBasePlane[0]); vtkFloatingPointType aBounds[6]; - GetClippedInput()->GetBounds(aBounds); + GetMergedInput()->GetBounds(aBounds); - vtkDataSet* aDataSet = GetFieldTransformFilter()->GetUnstructuredGridOutput(); CutWithPlanes(myAppendPolyData, - aDataSet, + GetMergedInput(), myNbParts, aDir, aBounds, @@ -382,7 +382,7 @@ VISU_CutPlanesPL vtkFloatingPointType aPosition = myPartPosition[thePartNumber]; if(myPartCondition[thePartNumber]){ vtkFloatingPointType aDir[3], aBounds[6], aBoundPrj[3]; - GetClippedInput()->GetBounds(aBounds); + GetMergedInput()->GetBounds(aBounds); GetDir(aDir, myAng[theNum], diff --git a/src/PIPELINE/VISU_DataSetMapperHolder.cxx b/src/PIPELINE/VISU_DataSetMapperHolder.cxx index 7ead8b37..313c6d68 100644 --- a/src/PIPELINE/VISU_DataSetMapperHolder.cxx +++ b/src/PIPELINE/VISU_DataSetMapperHolder.cxx @@ -144,13 +144,13 @@ VISU_DataSetMapperHolder //---------------------------------------------------------------------------- -vtkDataSet* +vtkPointSet* VISU_DataSetMapperHolder ::GetClippedInput() { - vtkUnstructuredGrid* aDataSet = myExtractGeometry->GetOutput(); - aDataSet->Update(); - return aDataSet; + if(myExtractGeometry->GetInput()) + myExtractGeometry->Update(); + return myExtractGeometry->GetOutput(); } diff --git a/src/PIPELINE/VISU_DataSetMapperHolder.hxx b/src/PIPELINE/VISU_DataSetMapperHolder.hxx index a53749f6..45fa07fe 100644 --- a/src/PIPELINE/VISU_DataSetMapperHolder.hxx +++ b/src/PIPELINE/VISU_DataSetMapperHolder.hxx @@ -152,7 +152,7 @@ protected: SetLookupTable(VISU_LookupTable* theLookupTable); virtual - vtkDataSet* + vtkPointSet* GetClippedInput(); private: diff --git a/src/PIPELINE/VISU_DeformedShapePL.cxx b/src/PIPELINE/VISU_DeformedShapePL.cxx index 6d45630a..16896392 100644 --- a/src/PIPELINE/VISU_DeformedShapePL.cxx +++ b/src/PIPELINE/VISU_DeformedShapePL.cxx @@ -100,6 +100,24 @@ VISU_DeformedShapePL } +//---------------------------------------------------------------------------- +vtkFloatingPointType +VISU_DeformedShapePL +::GetDefaultScale(VISU_ScalarMapPL* theScalarMapPL) +{ + vtkFloatingPointType aSourceRange[2]; + theScalarMapPL->GetSourceRange(aSourceRange); + + static vtkFloatingPointType EPS = 1.0 / VTK_LARGE_FLOAT; + if(fabs(aSourceRange[1]) > EPS){ + vtkDataSet* aDataSet = theScalarMapPL->GetMergedInput(); + vtkFloatingPointType aScaleFactor = VISU_DeformedShapePL::GetScaleFactor(aDataSet); + return aScaleFactor / aSourceRange[1]; + } + return 0.0; +} + + //---------------------------------------------------------------------------- void VISU_DeformedShapePL @@ -129,17 +147,20 @@ VISU_DeformedShapePL { Superclass::Init(); - vtkFloatingPointType aScalarRange[2]; - GetSourceRange(aScalarRange); + SetScale(VISU_DeformedShapePL::GetDefaultScale(this)); +} - vtkDataSet* aDataSet = GetClippedInput(); - 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); +//---------------------------------------------------------------------------- +void +VISU_DeformedShapePL +::Update() +{ + Superclass::Update(); + //{ + // std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-myWarpVector.vtk"; + // VISU::WriteToFile(myWarpVector->GetUnstructuredGridOutput(), aFileName); + //} } @@ -150,8 +171,8 @@ VISU_DeformedShapePL { VISU::CellDataToPoint(myWarpVector, myCellDataToPointData, - GetClippedInput(), - GetFieldTransformFilter()); + GetMergedInput()); + return myWarpVector->GetOutput(); } diff --git a/src/PIPELINE/VISU_DeformedShapePL.hxx b/src/PIPELINE/VISU_DeformedShapePL.hxx index 2550a340..e09b4cf7 100644 --- a/src/PIPELINE/VISU_DeformedShapePL.hxx +++ b/src/PIPELINE/VISU_DeformedShapePL.hxx @@ -57,6 +57,10 @@ public: void Init(); + virtual + void + Update(); + //! Gets memory size used by the instance (bytes). virtual unsigned long int @@ -70,6 +74,10 @@ public: vtkFloatingPointType GetScaleFactor(vtkDataSet* theDataSet); + static + vtkFloatingPointType + GetDefaultScale(VISU_ScalarMapPL* theScalarMapPL); + protected: VISU_DeformedShapePL(); VISU_DeformedShapePL(const VISU_DeformedShapePL&); diff --git a/src/PIPELINE/VISU_Extractor.cxx b/src/PIPELINE/VISU_Extractor.cxx index d96e2f71..e44145e3 100644 --- a/src/PIPELINE/VISU_Extractor.cxx +++ b/src/PIPELINE/VISU_Extractor.cxx @@ -168,41 +168,28 @@ VISU_Extractor vtkInformationVector **theInputVector, vtkInformationVector *theOutputVector) { - vtkDataSet *input = VISU::GetInput(theInputVector, 0); - vtkDataSet *output = VISU::GetOutput(theOutputVector); - - output->CopyStructure(input); - if(VISU::IsDataOnPoints(input)){ - output->GetPointData()->CopyVectorsOn(); - output->GetPointData()->CopyScalarsOff(); - - vtkIdType aNbOfTuples = input->GetNumberOfPoints(); - vtkPointData *inData = input->GetPointData(), *outData = output->GetPointData(); - if(inData->GetAttribute(vtkDataSetAttributes::VECTORS)) - ExecuteScalars(aNbOfTuples, myScalarMode, inData, outData); - else - output->GetPointData()->CopyScalarsOn(); - outData->PassData(inData); - outData->AddArray(inData->GetArray("VISU_FIELD")); - }else{ - output->GetCellData()->CopyVectorsOn(); - output->GetCellData()->CopyScalarsOff(); - - vtkIdType aNbOfTuples = input->GetNumberOfCells(); - vtkCellData *inData = input->GetCellData(), *outData = output->GetCellData(); - if(inData->GetAttribute(vtkDataSetAttributes::VECTORS)) - ExecuteScalars(aNbOfTuples, myScalarMode, inData, outData); - else - output->GetCellData()->CopyScalarsOn(); - outData->PassData(inData); - outData->AddArray(inData->GetArray("VISU_FIELD")); + vtkDataSet *anInput = VISU::GetInput(theInputVector, 0); + vtkDataSet *anOutput = VISU::GetOutput(theOutputVector); + + anOutput->CopyStructure(anInput); + + vtkPointData *anInputPointData = anInput->GetPointData(); + vtkPointData *anOutputPointData = anOutput->GetPointData(); + anOutputPointData->PassData(anInputPointData); + if(VISU::IsDataOnPoints(anInput)){ + int aNbElems = anInput->GetNumberOfPoints(); + if(anInputPointData->GetAttribute(vtkDataSetAttributes::VECTORS)) + ExecuteScalars(aNbElems, myScalarMode, anInputPointData, anOutputPointData); + } + + vtkCellData *anInputCellData = anInput->GetCellData(); + vtkCellData *anOutputCellData = anOutput->GetCellData(); + anOutputCellData->PassData(anInputCellData); + if(VISU::IsDataOnCells(anInput)){ + int aNbElems = anInput->GetNumberOfCells(); + if(anInputCellData->GetAttribute(vtkDataSetAttributes::VECTORS)) + ExecuteScalars(aNbElems, myScalarMode, anInputCellData, anOutputCellData); } - - if(vtkDataArray *aDataArray = input->GetCellData()->GetArray("VISU_CELLS_MAPPER")) - output->GetCellData()->AddArray(aDataArray); - - if(vtkDataArray *aDataArray = input->GetPointData()->GetArray("VISU_POINTS_MAPPER")) - output->GetPointData()->AddArray(aDataArray); return 1; } diff --git a/src/PIPELINE/VISU_FieldTransform.cxx b/src/PIPELINE/VISU_FieldTransform.cxx index ebba6c1c..7816f8ef 100644 --- a/src/PIPELINE/VISU_FieldTransform.cxx +++ b/src/PIPELINE/VISU_FieldTransform.cxx @@ -22,6 +22,7 @@ #include "VISU_FieldTransform.hxx" #include "VTKViewer_Transform.h" +#include "VISU_PipeLineUtils.hxx" #include #include @@ -127,10 +128,7 @@ void VISU_FieldTransform ::SetScalarRange(vtkFloatingPointType theScalarRange[2]) { - vtkFloatingPointType aDelta = - fabs(myScalarRange[0] - theScalarRange[0]) + - fabs(myScalarRange[1] - theScalarRange[1]); - if(aDelta < Tolerance) + if(VISU::CheckIsSameRange(theScalarRange, myScalarRange)) return; myScalarRange[0] = theScalarRange[0]; diff --git a/src/PIPELINE/VISU_GaussPointsPL.cxx b/src/PIPELINE/VISU_GaussPointsPL.cxx index 982ee719..1d8bcbe5 100644 --- a/src/PIPELINE/VISU_GaussPointsPL.cxx +++ b/src/PIPELINE/VISU_GaussPointsPL.cxx @@ -30,6 +30,7 @@ #include "VISU_PointSpriteMapperHolder.hxx" #include "VISU_OpenGLPointSpriteMapper.hxx" #include "VISU_DeformedShapePL.hxx" +#include "VISU_FieldTransform.hxx" #include "VISU_LookupTable.hxx" #include "VISU_PipeLineUtils.hxx" diff --git a/src/PIPELINE/VISU_IsoSurfacesPL.cxx b/src/PIPELINE/VISU_IsoSurfacesPL.cxx index 950330c2..aaf427b7 100644 --- a/src/PIPELINE/VISU_IsoSurfacesPL.cxx +++ b/src/PIPELINE/VISU_IsoSurfacesPL.cxx @@ -156,25 +156,25 @@ VISU_IsoSurfacesPL } //---------------------------------------------------------------------------- - -vtkDataSet* +void VISU_IsoSurfacesPL -::InsertCustomPL() +::Build() { + Superclass::Build(); + VISU::CellDataToPoint(myContourFilter, myCellDataToPointData, - GetClippedInput(), - GetFieldTransformFilter()); - return myContourFilter->GetOutput(); + GetMergedInput()); } //---------------------------------------------------------------------------- -void + +vtkDataSet* VISU_IsoSurfacesPL -::Update() +::InsertCustomPL() { - Superclass::Update(); + return myContourFilter->GetOutput(); } diff --git a/src/PIPELINE/VISU_IsoSurfacesPL.hxx b/src/PIPELINE/VISU_IsoSurfacesPL.hxx index 8dd9f41d..d53aeb35 100644 --- a/src/PIPELINE/VISU_IsoSurfacesPL.hxx +++ b/src/PIPELINE/VISU_IsoSurfacesPL.hxx @@ -75,7 +75,7 @@ public: virtual void - Update(); + Build(); //! Gets memory size used by the instance (bytes). virtual diff --git a/src/PIPELINE/VISU_MapperHolder.cxx b/src/PIPELINE/VISU_MapperHolder.cxx index 857daad9..dc025499 100644 --- a/src/PIPELINE/VISU_MapperHolder.cxx +++ b/src/PIPELINE/VISU_MapperHolder.cxx @@ -124,6 +124,9 @@ void VISU_MapperHolder ::SetIDMapper(const VISU::PIDMapper& theIDMapper) { + if(myIDMapper == theIDMapper) + return; + myIDMapper = theIDMapper; if(myPipeLine && GetInput()) diff --git a/src/PIPELINE/VISU_MapperHolder.hxx b/src/PIPELINE/VISU_MapperHolder.hxx index 22ea018a..756abdee 100644 --- a/src/PIPELINE/VISU_MapperHolder.hxx +++ b/src/PIPELINE/VISU_MapperHolder.hxx @@ -145,7 +145,7 @@ public: SetLookupTable(VISU_LookupTable* theLookupTable) = 0; virtual - vtkDataSet* + vtkPointSet* GetClippedInput() = 0; //---------------------------------------------------------------------------- diff --git a/src/PIPELINE/VISU_PipeLineUtils.hxx b/src/PIPELINE/VISU_PipeLineUtils.hxx index 0df2f53e..5622c0ed 100644 --- a/src/PIPELINE/VISU_PipeLineUtils.hxx +++ b/src/PIPELINE/VISU_PipeLineUtils.hxx @@ -28,7 +28,6 @@ #define VISU_PipeLineUtils_HeaderFile #include "VISUPipeline.hxx" -#include "VISU_FieldTransform.hxx" #include "VISU_ConvertorUtils.hxx" #include @@ -74,39 +73,37 @@ namespace VISU //---------------------------------------------------------------------------- - template + template void - CellDataToPoint(TEndFilter* theEndFilter, - vtkCellDataToPointData *theFilter, - vtkDataSet* theDataSet, - VISU_FieldTransform *theFieldTransform) + CellDataToPoint(TOutputFilter* theOutputFilter, + vtkCellDataToPointData *theCellDataToPointData, + vtkDataSet* theDataSet) + { if(VISU::IsDataOnCells(theDataSet)){ - theFilter->SetInput(theFieldTransform->GetUnstructuredGridOutput()); - theFilter->PassCellDataOn(); - theEndFilter->SetInput(theFilter->GetUnstructuredGridOutput()); + theCellDataToPointData->SetInput(theDataSet); + theCellDataToPointData->PassCellDataOn(); + theOutputFilter->SetInput(theCellDataToPointData->GetUnstructuredGridOutput()); }else - theEndFilter->SetInput(theFieldTransform->GetUnstructuredGridOutput()); + theOutputFilter->SetInput(theDataSet); } - //---------------------------------------------------------------------------- - template + template void - ToCellCenters(TEndFilter* theEndFilter, - vtkCellCenters *theFilter, - vtkDataSet* theDataSet, - VISU_FieldTransform *theFieldTransform) + ToCellCenters(TOutputFilter* theOutputFilter, + vtkCellCenters *theCellCenters, + vtkDataSet* theDataSet) + { if(VISU::IsDataOnCells(theDataSet)){ - theFilter->SetInput(theFieldTransform->GetUnstructuredGridOutput()); - theFilter->VertexCellsOn(); - theEndFilter->SetInput(theFilter->GetOutput()); + theCellCenters->SetInput(theDataSet); + theCellCenters->VertexCellsOn(); + theOutputFilter->SetInput(theCellCenters->GetOutput()); }else - theEndFilter->SetInput(theFieldTransform->GetUnstructuredGridOutput()); + theOutputFilter->SetInput(theDataSet); } - //---------------------------------------------------------------------------- //! Checks whether the float values are the same or not bool diff --git a/src/PIPELINE/VISU_Plot3DPL.cxx b/src/PIPELINE/VISU_Plot3DPL.cxx index 7f606c7b..5b26e979 100644 --- a/src/PIPELINE/VISU_Plot3DPL.cxx +++ b/src/PIPELINE/VISU_Plot3DPL.cxx @@ -159,8 +159,8 @@ VISU_Plot3DPL { Superclass::Init(); - myOrientation = GetOrientation(GetClippedInput()); - SetScaleFactor(GetScaleFactor(GetClippedInput())); + myOrientation = GetOrientation(GetMergedInput()); + SetScaleFactor(GetScaleFactor(GetMergedInput())); } @@ -184,13 +184,12 @@ VISU_Plot3DPL vtkPolyData* aPolyData = 0; vtkCutter *aCutPlane = 0; - vtkUnstructuredGrid* anUnstructuredGrid = - GetFieldTransformFilter()->GetUnstructuredGridOutput(); + vtkDataSet* aDataSet = GetMergedInput(); if ( !IsPlanarInput() ) { aCutPlane = vtkCutter::New(); - aCutPlane->SetInput(anUnstructuredGrid); + aCutPlane->SetInput(aDataSet); vtkPlane *aPlane = vtkPlane::New(); aPlane->SetOrigin(anOrigin); @@ -204,7 +203,7 @@ VISU_Plot3DPL } if ( !aPolyData || aPolyData->GetNumberOfCells() == 0 ) { - myGeometryFilter->SetInput(anUnstructuredGrid); + myGeometryFilter->SetInput(aDataSet); aPolyData = myGeometryFilter->GetOutput(); aPolyData->Update(); } @@ -442,7 +441,7 @@ VISU_Plot3DPL if ( theCenterOrigine ) { // move theOrigin to the center of aBounds projections to the plane - GetClippedInput()->GetBounds(aBounds); + GetMergedInput()->GetBounds(aBounds); vtkFloatingPointType boundPoints[8][3] = { {aBounds[0],aBounds[2],aBounds[4]}, {aBounds[1],aBounds[2],aBounds[4]}, diff --git a/src/PIPELINE/VISU_PolyDataMapperHolder.cxx b/src/PIPELINE/VISU_PolyDataMapperHolder.cxx index 2045f712..0b9cd227 100644 --- a/src/PIPELINE/VISU_PolyDataMapperHolder.cxx +++ b/src/PIPELINE/VISU_PolyDataMapperHolder.cxx @@ -144,13 +144,13 @@ VISU_PolyDataMapperHolder //---------------------------------------------------------------------------- -vtkDataSet* +vtkPointSet* VISU_PolyDataMapperHolder ::GetClippedInput() { - vtkPolyData* aDataSet = myExtractPolyDataGeometry->GetOutput(); - aDataSet->Update(); - return aDataSet; + if(myExtractPolyDataGeometry->GetInput()) + myExtractPolyDataGeometry->Update(); + return myExtractPolyDataGeometry->GetOutput(); } diff --git a/src/PIPELINE/VISU_PolyDataMapperHolder.hxx b/src/PIPELINE/VISU_PolyDataMapperHolder.hxx index 077dd91c..dc9848ec 100644 --- a/src/PIPELINE/VISU_PolyDataMapperHolder.hxx +++ b/src/PIPELINE/VISU_PolyDataMapperHolder.hxx @@ -152,7 +152,7 @@ protected: SetLookupTable(VISU_LookupTable* theLookupTable); virtual - vtkDataSet* + vtkPointSet* GetClippedInput(); private: diff --git a/src/PIPELINE/VISU_ScalarMapOnDeformedShapePL.cxx b/src/PIPELINE/VISU_ScalarMapOnDeformedShapePL.cxx index db6a3cb3..65ece955 100644 --- a/src/PIPELINE/VISU_ScalarMapOnDeformedShapePL.cxx +++ b/src/PIPELINE/VISU_ScalarMapOnDeformedShapePL.cxx @@ -25,6 +25,7 @@ // Module : VISU #include "VISU_ScalarMapOnDeformedShapePL.hxx" +#include "VISU_FieldTransform.hxx" #include "VISU_Extractor.hxx" #include "VISU_LookupTable.hxx" #include "VISU_DeformedShapePL.hxx" @@ -48,18 +49,23 @@ vtkStandardNewMacro(VISU_ScalarMapOnDeformedShapePL) * Constructor. Creating new instances of vtkWarpVector,vtkMergeFilter,vtkUnstructuredGrid * Where: * \li myDeformVectors is vtkWarpVector - deformation vectors data - * \li myMergeFilter is vtkMergeFilter - merge filter. + * \li myScalarsMergeFilter is vtkMergeFilter - merge filter. * Merge filter which unify the deformation and scalars * \li myScalars is vtk shared pointer to vtkUnstructuredGrid - scalars data */ VISU_ScalarMapOnDeformedShapePL -::VISU_ScalarMapOnDeformedShapePL() +::VISU_ScalarMapOnDeformedShapePL(): + myScaleFactor(0.0) { - SetIsShrinkable(true); + myWarpVector = vtkWarpVector::New(); + + myScalarsMergeFilter = VISU_MergeFilter::New(); + myScalarsMergeFilter->SetMergingInputs(true); + + myScalarsExtractor = VISU_Extractor::New(); + + myScalarsFieldTransform = VISU_FieldTransform::New(); - myDeformVectors = vtkWarpVector::New(); - myMergeFilter = VISU_MergeFilter::New(); - myExtractorScalars = VISU_Extractor::New(); myCellDataToPointData = vtkCellDataToPointData::New(); } @@ -71,20 +77,14 @@ VISU_ScalarMapOnDeformedShapePL VISU_ScalarMapOnDeformedShapePL ::~VISU_ScalarMapOnDeformedShapePL() { - // commented: porting to vtk5.0 - // myDeformVectors->UnRegisterAllOutputs(); - myDeformVectors->Delete(); + myWarpVector->Delete(); - // commented: porting to vtk5.0 - // myMergeFilter->UnRegisterAllOutputs(); - myMergeFilter->Delete(); + myScalarsMergeFilter->Delete(); - // commented: porting to vtk5.0 - // myExtractorScalars->UnRegisterAllOutputs(); - myExtractorScalars->Delete(); + myScalarsExtractor->Delete(); + + myScalarsFieldTransform->Delete(); - // commented: porting to vtk5.0 - // myCellDataToPointData->UnRegisterAllOutputs(); myCellDataToPointData->Delete(); } @@ -96,22 +96,9 @@ void VISU_ScalarMapOnDeformedShapePL ::Init() { - if(GetScalars() == NULL) - SetScalars(GetClippedInput()); - Superclass::Init(); - vtkFloatingPointType aScalarRange[2]; - GetSourceRange(aScalarRange); - - static double EPS = 1.0 / VTK_LARGE_FLOAT; - if(aScalarRange[1] > EPS) - SetScale(VISU_DeformedShapePL::GetScaleFactor(GetClippedInput()) / aScalarRange[1]); - else - SetScale(0.0); - - GetMapper()->SetColorModeToMapScalars(); - GetMapper()->ScalarVisibilityOn(); + SetScale(VISU_DeformedShapePL::GetDefaultScale(this)); } //---------------------------------------------------------------------------- @@ -123,21 +110,40 @@ void VISU_ScalarMapOnDeformedShapePL ::Build() { - VISU::CellDataToPoint(myDeformVectors, + Superclass::Build(); +} + + +//---------------------------------------------------------------------------- +vtkDataSet* +VISU_ScalarMapOnDeformedShapePL +::InsertCustomPL() +{ + GetMapper()->SetColorModeToMapScalars(); + GetMapper()->ScalarVisibilityOn(); + + VISU::CellDataToPoint(myWarpVector, myCellDataToPointData, - GetClippedInput(), - GetFieldTransformFilter()); + GetMergedInput()); + myScalars = GetMergedInput(); + + UpdateScalars(); + + myScalarsFieldTransform->SetInput(myScalarsExtractor->GetOutput()); + // Sets geometry for merge filter - myMergeFilter->SetGeometry(myDeformVectors->GetUnstructuredGridOutput()); - myMergeFilter->SetScalars(myExtractorScalars->GetOutput()); - myMergeFilter->AddField("VISU_CELLS_MAPPER", myExtractorScalars->GetOutput()); - myMergeFilter->Update(); + myScalarsMergeFilter->SetGeometry(myWarpVector->GetUnstructuredGridOutput()); - // Sets data to mapper - GetDataSetMapper()->SetInput(myMergeFilter->GetOutput()); + vtkDataSet* aScalarsDataSet = myScalarsFieldTransform->GetOutput(); + myScalarsMergeFilter->SetScalars(aScalarsDataSet); + myScalarsMergeFilter->AddField("VISU_CELLS_MAPPER", aScalarsDataSet); + myScalarsMergeFilter->AddField("VISU_POINTS_MAPPER", aScalarsDataSet); + + return myScalarsMergeFilter->GetOutput(); } + //---------------------------------------------------------------------------- /*! * Update method @@ -146,22 +152,21 @@ void VISU_ScalarMapOnDeformedShapePL ::Update() { - this->UpdateScalars(); - - vtkFloatingPointType* aRange = GetScalarRange(); - vtkFloatingPointType aScalarRange[2] = {aRange[0], aRange[1]}; - - if(GetBarTable()->GetScale() == VTK_SCALE_LOG10) - VISU_LookupTable::ComputeLogRange(aRange,aScalarRange); - GetMapperTable()->SetRange(aScalarRange); - - GetMapperTable()->Build(); - GetBarTable()->Build(); - - GetMapper()->SetLookupTable(GetMapperTable()); - GetMapper()->SetScalarRange(aScalarRange); - - VISU_PipeLine::Update(); + Superclass::Update(); + + UpdateScalars(); + //{ + // std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-myScalarsExtractor.vtk"; + // VISU::WriteToFile(myScalarsExtractor->GetUnstructuredGridOutput(), aFileName); + //} + //{ + // std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-myWarpVector.vtk"; + // VISU::WriteToFile(myWarpVector->GetUnstructuredGridOutput(), aFileName); + //} + //{ + // std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-myScalarsMergeFilter.vtk"; + // VISU::WriteToFile(myScalarsMergeFilter->GetUnstructuredGridOutput(), aFileName); + //} } //---------------------------------------------------------------------------- @@ -171,13 +176,13 @@ VISU_ScalarMapOnDeformedShapePL { unsigned long int aSize = Superclass::GetMemorySize(); - if(vtkDataSet* aDataSet = myDeformVectors->GetOutput()) + if(vtkDataSet* aDataSet = myWarpVector->GetOutput()) aSize += aDataSet->GetActualMemorySize() * 1024; - if(vtkDataSet* aDataSet = myExtractorScalars->GetOutput()) + if(vtkDataSet* aDataSet = myScalarsExtractor->GetOutput()) aSize += aDataSet->GetActualMemorySize() * 1024; - if(vtkDataSet* aDataSet = myMergeFilter->GetOutput()) + if(vtkDataSet* aDataSet = myScalarsMergeFilter->GetOutput()) aSize += aDataSet->GetActualMemorySize() * 1024; if(myCellDataToPointData->GetInput()) @@ -196,7 +201,13 @@ void VISU_ScalarMapOnDeformedShapePL ::UpdateScalars() { - myExtractorScalars->Update(); + vtkDataSet* aScalars = GetScalars(); + myScalarsExtractor->SetInput(aScalars); + + if(VISU::IsDataOnCells(aScalars)) + GetMapper()->SetScalarModeToUseCellData(); + else + GetMapper()->SetScalarModeToUsePointData(); } //---------------------------------------------------------------------------- @@ -227,22 +238,6 @@ VISU_ScalarMapOnDeformedShapePL ::SetScalars(vtkDataSet *theScalars) { myScalars = theScalars; - vtkCellData *aCellData = GetInput()->GetCellData(); - bool anIsVectorsOnCells = aCellData->GetAttribute(vtkDataSetAttributes::VECTORS); - - if(VISU::IsDataOnPoints(theScalars)) - myExtractorScalars->SetInput(theScalars); - else if(VISU::IsDataOnCells(theScalars) && !anIsVectorsOnCells){ - //Approximate cell data values to point data by vtkCellDataToPointData filter. - vtkCellDataToPointData* aCellDataToPointData = vtkCellDataToPointData::New(); - aCellDataToPointData->SetInput(theScalars); - aCellDataToPointData->Update(); - myExtractorScalars->SetInput(aCellDataToPointData->GetOutput()); - aCellDataToPointData->Delete(); - } else { - myExtractorScalars->SetInput(theScalars); - } - Update(); } //---------------------------------------------------------------------------- @@ -267,7 +262,7 @@ VISU_ScalarMapOnDeformedShapePL if(VISU::CheckIsSameValue(myScaleFactor, theScale)) return; - myDeformVectors->SetScaleFactor(myScaleFactor); + myWarpVector->SetScaleFactor(theScale); myScaleFactor = theScale; } @@ -279,7 +274,7 @@ vtkFloatingPointType VISU_ScalarMapOnDeformedShapePL ::GetScale() { - return myDeformVectors->GetScaleFactor(); + return myWarpVector->GetScaleFactor(); } //---------------------------------------------------------------------------- @@ -291,7 +286,7 @@ VISU_ScalarMapOnDeformedShapePL ::SetMapScale(vtkFloatingPointType theMapScale) { Superclass::SetMapScale(theMapScale); - myDeformVectors->SetScaleFactor(myScaleFactor*theMapScale); + myWarpVector->SetScaleFactor(myScaleFactor*theMapScale); } //---------------------------------------------------------------------------- @@ -302,7 +297,7 @@ int VISU_ScalarMapOnDeformedShapePL ::GetScalarMode() { - return myExtractorScalars->GetScalarMode(); + return myScalarsExtractor->GetScalarMode(); } //---------------------------------------------------------------------------- @@ -313,10 +308,48 @@ void VISU_ScalarMapOnDeformedShapePL ::SetScalarMode(int theScalarMode) { - myExtractorScalars->SetScalarMode(theScalarMode); - Modified(); + VISU_ScalarMapPL::SetScalarMode(theScalarMode, GetScalars(), myScalarsExtractor); } +//---------------------------------------------------------------------------- +void +VISU_ScalarMapOnDeformedShapePL +::SetScaling(int theScaling) +{ + if(GetScaling() == theScaling) + return; + + GetBarTable()->SetScale(theScaling); + + if(theScaling == VTK_SCALE_LOG10) + myScalarsFieldTransform->SetScalarTransform(&(VISU_FieldTransform::Log10)); + else + myScalarsFieldTransform->SetScalarTransform(&(VISU_FieldTransform::Ident)); +} + + +//---------------------------------------------------------------------------- +void +VISU_ScalarMapOnDeformedShapePL +::SetScalarRange(vtkFloatingPointType theRange[2]) +{ + if(VISU::CheckIsSameRange(theRange, GetScalarRange())) + return; + + myScalarsFieldTransform->SetScalarRange(theRange); + GetBarTable()->SetRange(theRange); +} + + +//---------------------------------------------------------------------------- +vtkFloatingPointType* +VISU_ScalarMapOnDeformedShapePL +::GetScalarRange() +{ + return myScalarsFieldTransform->GetScalarRange(); +} + + //---------------------------------------------------------------------------- /*! * Gets ranges of extracted scalars @@ -328,6 +361,6 @@ void VISU_ScalarMapOnDeformedShapePL ::GetSourceRange(vtkFloatingPointType theRange[2]) { - myExtractorScalars->Update(); - myExtractorScalars->GetUnstructuredGridOutput()->GetScalarRange(theRange); + myScalarsExtractor->Update(); + myScalarsExtractor->GetUnstructuredGridOutput()->GetScalarRange(theRange); } diff --git a/src/PIPELINE/VISU_ScalarMapOnDeformedShapePL.hxx b/src/PIPELINE/VISU_ScalarMapOnDeformedShapePL.hxx index ee068823..041a37d2 100644 --- a/src/PIPELINE/VISU_ScalarMapOnDeformedShapePL.hxx +++ b/src/PIPELINE/VISU_ScalarMapOnDeformedShapePL.hxx @@ -63,6 +63,18 @@ public: void SetScalarMode(int theScalarMode = 0); + virtual + void + SetScaling(int theScaling); + + virtual + void + SetScalarRange(vtkFloatingPointType theRange[2]); + + virtual + vtkFloatingPointType* + GetScalarRange(); + virtual void GetSourceRange(vtkFloatingPointType theRange[2]); @@ -110,19 +122,25 @@ protected: virtual ~VISU_ScalarMapOnDeformedShapePL(); - VISU_ScalarMapOnDeformedShapePL(const VISU_ScalarMapOnDeformedShapePL&); + virtual + vtkDataSet* + InsertCustomPL(); virtual void DoShallowCopy(VISU_PipeLine *thePipeLine, bool theIsCopyInput); +private: + VISU_ScalarMapOnDeformedShapePL(const VISU_ScalarMapOnDeformedShapePL&); + vtkFloatingPointType myScaleFactor; - vtkWarpVector *myDeformVectors; - VISU_MergeFilter *myMergeFilter; - vtkSmartPointer myScalars; - VISU_Extractor* myExtractorScalars; + vtkWarpVector *myWarpVector; + VISU_MergeFilter *myScalarsMergeFilter; + vtkSmartPointer myScalars; vtkCellDataToPointData* myCellDataToPointData; + VISU_FieldTransform* myScalarsFieldTransform; + VISU_Extractor* myScalarsExtractor; }; #endif diff --git a/src/PIPELINE/VISU_ScalarMapPL.cxx b/src/PIPELINE/VISU_ScalarMapPL.cxx index 8f5d3754..8faea853 100644 --- a/src/PIPELINE/VISU_ScalarMapPL.cxx +++ b/src/PIPELINE/VISU_ScalarMapPL.cxx @@ -85,10 +85,45 @@ VISU_ScalarMapPL { Superclass::Build(); + SetSourceGeometry(); + + vtkPointSet* aDataSet = GetClippedInput(); + myAppendFilter->SetSharedPointSet(aDataSet); + + myMergeFilter->SetGeometry(myAppendFilter->GetOutput()); + myMergeFilter->SetScalars(aDataSet); + myMergeFilter->SetVectors(aDataSet); + + myMergeFilter->RemoveFields(); + myMergeFilter->AddField("VISU_FIELD", aDataSet); + myMergeFilter->AddField("VISU_CELLS_MAPPER", aDataSet); + myMergeFilter->AddField("VISU_POINTS_MAPPER", aDataSet); + GetDataSetMapper()->SetInput(InsertCustomPL()); } +//---------------------------------------------------------------------------- +void +VISU_ScalarMapPL +::Update() +{ + Superclass::Update(); + //{ + // std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-aScalarsOutput.vtk"; + // VISU::WriteToFile(GetFieldTransformFilter()->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->GetUnstructuredGridOutput(), aFileName); + //} +} + + //---------------------------------------------------------------------------- void VISU_ScalarMapPL @@ -117,7 +152,7 @@ VISU_ScalarMapPL { if(IsExternalGeometryUsed()){ ClearGeometry(); - myAppendFilter->AddInput(Superclass::InsertCustomPL()); + myAppendFilter->AddInput(GetClippedInput()); } } @@ -155,8 +190,7 @@ bool VISU_ScalarMapPL ::IsExternalGeometryUsed() { - vtkDataObject* aDataObject = myAppendFilter->GetInput(); - return aDataObject && aDataObject != Superclass::InsertCustomPL(); + return myAppendFilter->GetInput() != GetClippedInput(); } @@ -174,19 +208,17 @@ vtkDataSet* VISU_ScalarMapPL ::InsertCustomPL() { - vtkDataSet* aDataSet = Superclass::InsertCustomPL(); - myAppendFilter->AddInput(aDataSet); - - vtkPointSet* aPointSet = GetDataSetMapperHolder()->GetUnstructuredGridInput(); - myAppendFilter->SetSharedPointSet(aPointSet); + return GetMergedInput(); +} - myMergeFilter->SetGeometry(myAppendFilter->GetOutput()); - myMergeFilter->SetScalars(aDataSet); - myMergeFilter->SetVectors(aDataSet); - myMergeFilter->AddField("VISU_FIELD", aDataSet); - myMergeFilter->AddField("VISU_CELLS_MAPPER", aDataSet); - myMergeFilter->AddField("VISU_POINTS_MAPPER", aDataSet); +//---------------------------------------------------------------------------- +vtkDataSet* +VISU_ScalarMapPL +::GetMergedInput() +{ + if(myMergeFilter->GetInput()) + myMergeFilter->Update(); return myMergeFilter->GetOutput(); } diff --git a/src/PIPELINE/VISU_ScalarMapPL.hxx b/src/PIPELINE/VISU_ScalarMapPL.hxx index 01c6ab66..13020793 100644 --- a/src/PIPELINE/VISU_ScalarMapPL.hxx +++ b/src/PIPELINE/VISU_ScalarMapPL.hxx @@ -48,6 +48,10 @@ public: VISU_ScalarMapPL* New(); + virtual + void + Update(); + virtual void SetSourceGeometry(); @@ -71,6 +75,11 @@ public: void ClearGeometry(); + //---------------------------------------------------------------------------- + virtual + vtkDataSet* + GetMergedInput(); + protected: //---------------------------------------------------------------------------- VISU_ScalarMapPL(); diff --git a/src/PIPELINE/VISU_StreamLinesPL.cxx b/src/PIPELINE/VISU_StreamLinesPL.cxx index bdcbbf09..5eebee0b 100644 --- a/src/PIPELINE/VISU_StreamLinesPL.cxx +++ b/src/PIPELINE/VISU_StreamLinesPL.cxx @@ -27,6 +27,7 @@ #include "VISU_StreamLinesPL.hxx" #include "VISU_Extractor.hxx" +#include "VISU_FieldTransform.hxx" #include "VISU_UsedPointsFilter.hxx" #include "VTKViewer_GeometryFilter.h" @@ -186,10 +187,9 @@ VISU_StreamLinesPL vtkDataSet* theSource, vtkFloatingPointType thePercents, int theDirection, - int isOnlyTry) + int theIsOnlyTry) { - vtkDataSet* aDataSet = theSource? theSource: - GetFieldTransformFilter()->GetUnstructuredGridOutput(); + vtkDataSet* aDataSet = theSource? theSource: GetMergedInput(); aDataSet->Update(); vtkIdType aNbOfPoints = aDataSet->GetNumberOfPoints(); @@ -207,15 +207,15 @@ VISU_StreamLinesPL theStepLength = CorrectStepLength(theStepLength, aPointSet); - size_t isAccepted = FindPossibleParams(aPointSet, - theStepLength, - thePropogationTime, - thePercents); + size_t anIsAccepted = FindPossibleParams(aPointSet, + theStepLength, + thePropogationTime, + thePercents); - if((!isOnlyTry && isAccepted) || (isOnlyTry && isAccepted == 1)){ + if((!theIsOnlyTry && anIsAccepted) || (theIsOnlyTry && anIsAccepted == 1)){ mySource = theSource; myPercents = thePercents; - if(VISU::IsDataOnCells(GetClippedInput())){ + if(VISU::IsDataOnCells(GetMergedInput())){ myCenters->SetInput(aDataSet); myCenters->VertexCellsOn(); aDataSet = myCenters->GetOutput(); @@ -232,7 +232,7 @@ VISU_StreamLinesPL myStream->Modified(); Modified(); } - return isAccepted; + return anIsAccepted; } @@ -638,22 +638,26 @@ VISU_StreamLinesPL //---------------------------------------------------------------------------- -vtkDataSet* +void VISU_StreamLinesPL -::InsertCustomPL() +::Build() { - GetClippedInput()->Update(); + Superclass::Build(); VISU::CellDataToPoint(myStream, myCellDataToPointData, - GetClippedInput(), - GetFieldTransformFilter()); + GetMergedInput()); - vtkFloatingPointType *aBounds = GetClippedInput()->GetBounds(); - myGeomFilter->SetExtent(aBounds); - myGeomFilter->ExtentClippingOn(); myGeomFilter->SetInput(myStream->GetOutput()); + myGeomFilter->ExtentClippingOn(); +} + +//---------------------------------------------------------------------------- +vtkDataSet* +VISU_StreamLinesPL +::InsertCustomPL() +{ return myGeomFilter->GetOutput(); } @@ -665,7 +669,18 @@ VISU_StreamLinesPL { try{ Superclass::Update(); + + vtkFloatingPointType aBounds[6]; + GetMergedInput()->GetBounds(aBounds); + myGeomFilter->SetExtent(aBounds); + //{ + // std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-myStream.vtk"; + // VISU::WriteToFile(myStream->GetOutput(), aFileName); + //} + }catch(std::exception& exc){ + MSG(true, "Follow exception was occured :\n"<Update(); - return myBaseGlyph->GetOutput(); -} + Superclass::Build(); - -//---------------------------------------------------------------------------- -vtkDataSet* -VISU_VectorsPL -::InsertCustomPL() -{ VISU::ToCellCenters(myBaseGlyph, myCenters, - GetClippedInput(), - GetFieldTransformFilter()); - + GetMergedInput()); myBaseGlyph->SetVectorModeToUseVector(); myBaseGlyph->SetScaleModeToScaleByVector(); myBaseGlyph->SetColorModeToColorByScalar(); VISU::ToCellCenters(myTransformFilter, myCenters, - GetClippedInput(), - GetFieldTransformFilter()); - + GetMergedInput()); myTransformedGlyph->SetInput(myTransformFilter->GetOutput()); myTransformedGlyph->SetVectorModeToUseVector(); myTransformedGlyph->SetScaleModeToScaleByVector(); myTransformedGlyph->SetColorModeToColorByScalar(); +} + +//---------------------------------------------------------------------------- +vtkDataSet* +VISU_VectorsPL +::InsertCustomPL() +{ return myTransformedGlyph->GetOutput(); } @@ -308,6 +304,16 @@ VISU_VectorsPL } +//---------------------------------------------------------------------------- +vtkDataSet* +VISU_VectorsPL +::GetOutput() +{ + myBaseGlyph->Update(); + return myBaseGlyph->GetOutput(); +} + + //---------------------------------------------------------------------------- void VISU_VectorsPL diff --git a/src/PIPELINE/VISU_VectorsPL.hxx b/src/PIPELINE/VISU_VectorsPL.hxx index 9e480e68..cbdcd300 100644 --- a/src/PIPELINE/VISU_VectorsPL.hxx +++ b/src/PIPELINE/VISU_VectorsPL.hxx @@ -84,6 +84,10 @@ public: void Init(); + virtual + void + Build(); + virtual void Update(); diff --git a/src/VISUGUI/VISU_msg_en.po b/src/VISUGUI/VISU_msg_en.po index 2836e826..f23dbd24 100644 --- a/src/VISUGUI/VISU_msg_en.po +++ b/src/VISUGUI/VISU_msg_en.po @@ -675,10 +675,10 @@ msgid "VisuGUI_ScalarMapOnDeformedShapeDlg::SCALE_FACTOR" msgstr "Scale Factor:" msgid "VisuGUI_ScalarMapOnDeformedShapeDlg::FIELD_ITEM" -msgstr "Fields" +msgstr "Scalar Field:" msgid "VisuGUI_ScalarMapOnDeformedShapeDlg::TIMESTAMP_ITEM" -msgstr "Time stamp" +msgstr "Current Time Stamp:" #: VisuGUI_EditContainerDlg.cxx diff --git a/src/VISUGUI/VisuGUI_Selection.cxx b/src/VISUGUI/VisuGUI_Selection.cxx index 710582ca..0e74d231 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->GetPipeLine()->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->GetPipeLine(); + 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()