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,
typedef vtkIdType TInputId;
typedef std::pair<TInputId, TCellId> TInputCellId;
- typedef vtkIdType TObjectId;
+ typedef std::pair<vtkIdType, vtkIdType> TObjectId;
typedef std::map<TObjectId, TInputCellId> TObject2InputIdMap;
{
if(vtkDataArray *aDataArray = theCellData->GetArray("VISU_CELLS_MAPPER")){
if(vtkIntArray *anIntArray = dynamic_cast<vtkIntArray*>(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;
// Copyright : Open CASCADE
#include "VISU_CommonCellsFilter.hxx"
+#include "VISU_ConvertorDef.hxx"
// VTK product headers
#include <vtkUnstructuredGrid.h>
#include <algorithm>
#include <vector>
#include <map>
+#include <set>
+
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+#endif
+
+// TTimerLog
+#include "VISU_ConvertorUtils.hxx"
namespace
{
- typedef std::vector<int> TSortedArray;
+ typedef std::pair<int,int> TPair;// pair first - object id, second - entity
+ //
+ typedef std::vector<int> TSortedArrayOne;
+ typedef std::set<TPair> TSortedArrayPair;
+ typedef std::set<int> TIdSet;
typedef std::map<int,int> 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(;aPointer<anEndPointer;){
+ TPair aPair;
+ aPair.first = *aPointer;
+ aPointer++;
+ aPair.second = *aPointer;
+ aPointer++;
+ aSortedArray.insert(aPair);
+ }
+ } else if (nbComp == 1) {
+ int aMaxId = theArray->GetNumberOfTuples();
+ int* aPointer = theArray->GetPointer(0);
+ int* anEndPointer = theArray->GetPointer(aMaxId + 1);
+ for(;aPointer<anEndPointer;){
+ TPair aPair;
+ aPair.first = *aPointer;
+ aPointer++;
+ aPair.second = (int)VISU::NODE_ENTITY;
+ aSortedArray.insert(aPair);
+ }
+
+ }
+ theSortedArray.swap(aSortedArray);
+ }
+
+ inline
+ void
+ GetSortedArrayOne(vtkIntArray *theArray,
+ TSortedArrayOne& theSortedArray)
{
int aMaxId = theArray->GetMaxId();
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);
}
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(aPtr<aPtrEnd){
+ aMapForSearch.insert(*aPtr);
+ aPtr++;
+ }
+ else if (nbComp == 2)
+ while(aPtr<aPtrEnd){
+ aMapForSearch.insert(*aPtr);
+ aPtr++;aPtr++;
+ }
int nbInputCells = inputUGrid->GetNumberOfCells();
- TSortedArray aPointCellIds;
for(int idCell=0;idCell<nbInputCells;idCell++){
- aPointCellIds.clear();
vtkCell* aCell = inputUGrid->GetCell(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;i<nbPointsInCell;i++){
+ int aSearchingId = ptIds->GetId(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);
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<vtkIntArray*>(theInputUG->GetCellData()->GetArray("VISU_CELLS_MAPPER"));
int* aInputCellsMapperPointer = aInputCellsMapper->GetPointer(0);
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();
}
}
VISU_CommonCellsFilter
::Execute()
{
+ VISU::TTimerLog aTimerLog(MYDEBUG,"VISU_CommonCellsFilter::Execute");
vtkUnstructuredGrid* anInputProfileUG = this->GetProfileUG();
vtkUnstructuredGrid* anInputCellsUG = this->GetCellsUG();
vtkIntArray* aPointIDS =
dynamic_cast<vtkIntArray*>(aInputCellData->GetArray("VISU_CELLS_MAPPER"));
if(aPointIDS){
+ int* aPtr = aPointIDS->GetPointer(0);
aPointIdsForCopy->SetNumberOfIds(aPointIDS->GetNumberOfTuples());
for(int i=0;i<aPointIDS->GetNumberOfTuples();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
//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;i<aPointIdsForCopy->GetNumberOfIds();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);
// Calculate output cells
int nbCells=0;
- TSortedArray aCellIdsForCopy;
+ TSortedArrayOne aCellIdsForCopy;
GetIdsForCopy(anInputCellsUG,aPointIDS,aCellIdsForCopy);
nbCells = aCellIdsForCopy.size();
// 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();
}
}
{
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;
}
{
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<vtkIntArray*>(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<vtkIntArray*>(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<vtkIntArray*>(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;
}
{
theDataSet->Update();
vtkDataSetAttributes *aDataSetAttributes = theDataSet->GetCellData();
- if(vtkDataArray *aDataArray = aDataSetAttributes->GetArray("VISU_CELLS_MAPPER")){
- if(vtkIntArray *anIntArray = dynamic_cast<vtkIntArray*>(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<vtkIntArray*>(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;
}
{
theDataSet->Update();
vtkDataSetAttributes *aDataSetAttributes = theDataSet->GetPointData();
- if(vtkDataArray *aDataArray = aDataSetAttributes->GetArray("VISU_POINTS_MAPPER")){
- if(vtkIntArray *anIntArray = dynamic_cast<vtkIntArray*>(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)
#include "VISU_IDMapper.hxx"
#include "MED_Utilities.hxx"
+#include "VTKViewer.h"
#include <vtkSystemIncludes.h>
#include <string>
class vtkPolyData;
class vtkTimerLog;
class vtkDataSet;
+class vtkCell;
#ifndef VISU_ENABLE_QUADRATIC
#define VISU_ENABLE_QUADRATIC
//---------------------------------------------------------------
VISU_CONVERTOR_EXPORT
vtkIdType
- GetElemVTKID(vtkDataSet *theDataSet, vtkIdType theID);
+ GetElemVTKID(vtkDataSet *theDataSet, vtkIdType theID, int theEntity = -1);
//---------------------------------------------------------------
GetElemObjID(vtkDataSet *theDataSet, vtkIdType theID);
+ //---------------------------------------------------------------
+ VISU_CONVERTOR_EXPORT
+ vtkCell*
+ GetElemCell(vtkDataSet *theDataSet, vtkIdType theObjID);
+
+
//---------------------------------------------------------------
VISU_CONVERTOR_EXPORT
vtkIdType
GetNodeObjID(vtkDataSet *theDataSet, vtkIdType theID);
+ //---------------------------------------------------------------
+ VISU_CONVERTOR_EXPORT
+ vtkFloatingPointType*
+ GetNodeCoord(vtkDataSet *theDataSet, vtkIdType theObjID);
+
//---------------------------------------------------------------
VISU_CONVERTOR_EXPORT
TGaussPointID
{
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();
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;
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;
}
}
{
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();
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);
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;
#include <algorithm>
#include <vector>
+#include <set>
#include <map>
namespace
{
//---------------------------------------------------------------
- typedef std::vector<int> TSortedArray;
+ typedef int TCellId;
+ typedef int TEntityId;
+ typedef std::pair<TCellId, TEntityId> TObjectId;
+
+ typedef std::set<TObjectId> TObjectIdSet;
+ typedef std::vector<TObjectId> TObjectIdArray;
+
+ typedef int TTupleId;
+ typedef std::map<TObjectId, TTupleId> 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<int,int> TId2IdMap;
-
-
- //---------------------------------------------------------------
- template <class TNumericType>
- 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<class TGetFieldData>
+ 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<vtkIntArray*>(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<class TGetFieldData>
+ 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<vtkIntArray*>(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<class TDataSet>
+ 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<class TDataSet>
+ 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<vtkPointSet*>(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;idCell<nbInputCells;idCell++){
- aPointCellIds.clear();
- vtkCell* aCell = theInputDataSet->GetCell(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<class TDataSet>
+ 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<vtkIntArray*>(theInputDataSet->GetCellData()->GetArray("VISU_CELLS_MAPPER"));
-
- int* aInputCellsMapperPointer = aInputCellsMapper->GetPointer(0);
-
- for(int aCellIndex=0;aCellIndex<theNbElements;aCellIndex++){
- int aCellId = theElementIdsForCopy[aCellIndex];
- vtkIdList* aOldPointIds = theInputDataSet->GetCell(aCellId)->GetPointIds();
- vtkIdList* aNewPointIds = vtkIdList::New();
- int nbPointIds = aOldPointIds->GetNumberOfIds();
- aNewPointIds->SetNumberOfIds(nbPointIds);
- for(int j=0;j<nbPointIds;j++){
- int aOldId = aOldPointIds->GetId(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);
}
}
+ //---------------------------------------------------------------
+ inline
+ void
+ CopyField(vtkDataSetAttributes* theInput,
+ const char* theFieldName,
+ vtkDataSetAttributes* theOutput,
+ vtkIdType theFixedNbTuples)
+ {
+ CopyArray(theInput->GetArray(theFieldName),
+ theOutput,
+ &vtkDataSetAttributes::AddArray,
+ theFixedNbTuples);
+ }
+
+
//---------------------------------------------------------------
inline
void
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<class TGetFieldData>
- 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<vtkIntArray*>(anIDMapper);
- }
+ CopyDataSetField(aDataSet,
+ aFieldName,
+ theOutput,
+ aNbPoints,
+ aNbCells);
}
- return NULL;
}
//---------------------------------------------------------------
template<class TDataSet>
- 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<vtkIntArray*>(aCellMapper);
- vtkIdType aGeomNbCells = aGeometryCellMapper->GetNumberOfTuples();
-
- vtkPointData *aPointData = theInput->GetPointData();
- vtkDataArray *aPointMapper = aPointData->GetArray("VISU_POINTS_MAPPER");
- vtkIntArray *aGeometryPointMapper = dynamic_cast<vtkIntArray*>(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<vtkIntArray*>(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<vtkIntArray*>(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<vtkIntArray*>(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<vtkIntArray*>(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;
- }
-
- //---------------------------------------------------------------
+ }
}
bool theIsMergingInputs)
{
return ::Execute(theInput,
- theOutput,
theScalarsDataSet,
theVectorsDataSet,
theNormalsDataSet,
theTCoordsDataSet,
theTensorsDataSet,
theFieldList,
- theIsMergingInputs);
+ theIsMergingInputs,
+ theOutput);
}
bool theIsMergingInputs)
{
return ::Execute(theInput,
- theOutput,
theScalarsDataSet,
theVectorsDataSet,
theNormalsDataSet,
theTCoordsDataSet,
theTensorsDataSet,
theFieldList,
- theIsMergingInputs);
+ theIsMergingInputs,
+ theOutput);
}
{
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();
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
if(myIsVTKMapping)
return theID;
- return GetCurrentPL()->GetNodeVTKID(theID);
+ return VISU::GetNodeVTKID(GetMapper()->GetInput(), theID);
}
vtkFloatingPointType*
if(myIsVTKMapping)
return Superclass::GetNodeCoord(theObjID);
- return GetCurrentPL()->GetNodeCoord(theObjID);
+ return VISU::GetNodeCoord(GetInput(), theObjID);
}
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
if(myIsVTKMapping)
return theID;
- return GetCurrentPL()->GetElemVTKID(theID);
+ return VISU::GetElemVTKID(GetMapper()->GetInput(), theID);
}
vtkCell*
if(myIsVTKMapping)
return Superclass::GetElemCell(theObjID);
- return GetCurrentPL()->GetElemCell(theObjID);
+ return VISU::GetElemCell(GetInput(), theObjID);
}
anInteractor->SetDolly(aDollyWas);
anInteractor->SetNumberOfFlyFrames(aNumberOfFlyFramesWas);
+ anInteractor->InvokeEvent(SVTK::ChangeRotationPoint, aNodeCoord);
+
mySelectionMode = aSelectionMode;
ChangeZoom(myPickingSettings,
#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 <vtkUnstructuredGrid.h>
#include <vtkDataSetMapper.h>
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());
//}
// "STRI ");
// aPresent->AddGeometry(anIDMapper->GetOutput());
//}
+ aPresent->Update();
return aPresent;
}
#include "VISU_ColoredPL.hxx"
#include "VISU_Extractor.hxx"
+#include "VISU_FieldTransform.hxx"
#include "VISU_LookupTable.hxx"
#include "VISU_MapperHolder.hxx"
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);
}
VISU_ColoredPL
::SetScaling(int theScaling)
{
+ if(GetScaling() == theScaling)
+ return;
+
myBarTable->SetScale(theScaling);
+
if(theScaling == VTK_SCALE_LOG10)
myFieldTransform->SetScalarTransform(&(VISU_FieldTransform::Log10));
else
}
//----------------------------------------------------------------------------
-vtkDataSet*
+vtkPointSet*
VISU_ColoredPL
-::InsertCustomPL()
+::GetClippedInput()
{
+ if(GetFieldTransformFilter()->GetInput())
+ GetFieldTransformFilter()->Update();
return GetFieldTransformFilter()->GetUnstructuredGridOutput();
}
VISU_ColoredPL
::Build()
{
- myExtractor->SetInput(GetClippedInput());
+ myExtractor->SetInput(Superclass::GetClippedInput());
myFieldTransform->SetInput(myExtractor->GetOutput());
GetMapperHolder()->SetLookupTable(GetMapperTable());
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);
//----------------------------------------------------------------------------
virtual
- vtkDataSet*
- InsertCustomPL();
+ vtkPointSet*
+ GetClippedInput();
+
+ //----------------------------------------------------------------------------
+ static
+ void
+ SetScalarMode(int theScalarMode,
+ vtkDataSet *theInput,
+ VISU_Extractor* theExtractor);
private:
vtkSmartPointer<VISU_LookupTable> myMapperTable;
#include "VISU_CutLinesPL.hxx"
+#include "VISU_FieldTransform.hxx"
#include "VISU_PipeLineUtils.hxx"
#include "VTKViewer_GeometryFilter.h"
vtkFloatingPointType aPosition = myPosition;
if(myCondition){
vtkFloatingPointType aBounds[6];
- GetClippedInput()->GetBounds(aBounds);
+ GetMergedInput()->GetBounds(aBounds);
vtkFloatingPointType aDir[3];
GetDir(aDir,
//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,
aDataSet->Update();
if(aDataSet->GetNumberOfCells() == 0)
- aDataSet = aGrid;
+ aDataSet = GetMergedInput();
vtkFloatingPointType aBounds[6];
aDataSet->GetBounds(aBounds);
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
#include "VISU_CutPlanesPL.hxx"
+#include "VISU_FieldTransform.hxx"
#include "VISU_PipeLineUtils.hxx"
#include "VTKViewer_GeometryFilter.h"
myBasePlane[0]);
vtkFloatingPointType aBounds[6];
- GetClippedInput()->GetBounds(aBounds);
+ GetMergedInput()->GetBounds(aBounds);
- vtkDataSet* aDataSet = GetFieldTransformFilter()->GetUnstructuredGridOutput();
CutWithPlanes(myAppendPolyData,
- aDataSet,
+ GetMergedInput(),
myNbParts,
aDir,
aBounds,
vtkFloatingPointType aPosition = myPartPosition[thePartNumber];
if(myPartCondition[thePartNumber]){
vtkFloatingPointType aDir[3], aBounds[6], aBoundPrj[3];
- GetClippedInput()->GetBounds(aBounds);
+ GetMergedInput()->GetBounds(aBounds);
GetDir(aDir,
myAng[theNum],
//----------------------------------------------------------------------------
-vtkDataSet*
+vtkPointSet*
VISU_DataSetMapperHolder
::GetClippedInput()
{
- vtkUnstructuredGrid* aDataSet = myExtractGeometry->GetOutput();
- aDataSet->Update();
- return aDataSet;
+ if(myExtractGeometry->GetInput())
+ myExtractGeometry->Update();
+ return myExtractGeometry->GetOutput();
}
SetLookupTable(VISU_LookupTable* theLookupTable);
virtual
- vtkDataSet*
+ vtkPointSet*
GetClippedInput();
private:
}
+//----------------------------------------------------------------------------
+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
{
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);
+ //}
}
{
VISU::CellDataToPoint(myWarpVector,
myCellDataToPointData,
- GetClippedInput(),
- GetFieldTransformFilter());
+ GetMergedInput());
+
return myWarpVector->GetOutput();
}
void
Init();
+ virtual
+ void
+ Update();
+
//! Gets memory size used by the instance (bytes).
virtual
unsigned long int
vtkFloatingPointType
GetScaleFactor(vtkDataSet* theDataSet);
+ static
+ vtkFloatingPointType
+ GetDefaultScale(VISU_ScalarMapPL* theScalarMapPL);
+
protected:
VISU_DeformedShapePL();
VISU_DeformedShapePL(const VISU_DeformedShapePL&);
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;
}
#include "VISU_FieldTransform.hxx"
#include "VTKViewer_Transform.h"
+#include "VISU_PipeLineUtils.hxx"
#include <vtkObjectFactory.h>
#include <vtkPointData.h>
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];
#include "VISU_PointSpriteMapperHolder.hxx"
#include "VISU_OpenGLPointSpriteMapper.hxx"
#include "VISU_DeformedShapePL.hxx"
+#include "VISU_FieldTransform.hxx"
#include "VISU_LookupTable.hxx"
#include "VISU_PipeLineUtils.hxx"
}
//----------------------------------------------------------------------------
-
-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();
}
virtual
void
- Update();
+ Build();
//! Gets memory size used by the instance (bytes).
virtual
VISU_MapperHolder
::SetIDMapper(const VISU::PIDMapper& theIDMapper)
{
+ if(myIDMapper == theIDMapper)
+ return;
+
myIDMapper = theIDMapper;
if(myPipeLine && GetInput())
SetLookupTable(VISU_LookupTable* theLookupTable) = 0;
virtual
- vtkDataSet*
+ vtkPointSet*
GetClippedInput() = 0;
//----------------------------------------------------------------------------
#define VISU_PipeLineUtils_HeaderFile
#include "VISUPipeline.hxx"
-#include "VISU_FieldTransform.hxx"
#include "VISU_ConvertorUtils.hxx"
#include <vtkProperty.h>
//----------------------------------------------------------------------------
- template<class TEndFilter>
+ template<class TOutputFilter>
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<class TEndFilter>
+ template<class TOutputFilter>
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
{
Superclass::Init();
- myOrientation = GetOrientation(GetClippedInput());
- SetScaleFactor(GetScaleFactor(GetClippedInput()));
+ myOrientation = GetOrientation(GetMergedInput());
+ SetScaleFactor(GetScaleFactor(GetMergedInput()));
}
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);
}
if ( !aPolyData || aPolyData->GetNumberOfCells() == 0 ) {
- myGeometryFilter->SetInput(anUnstructuredGrid);
+ myGeometryFilter->SetInput(aDataSet);
aPolyData = myGeometryFilter->GetOutput();
aPolyData->Update();
}
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]},
//----------------------------------------------------------------------------
-vtkDataSet*
+vtkPointSet*
VISU_PolyDataMapperHolder
::GetClippedInput()
{
- vtkPolyData* aDataSet = myExtractPolyDataGeometry->GetOutput();
- aDataSet->Update();
- return aDataSet;
+ if(myExtractPolyDataGeometry->GetInput())
+ myExtractPolyDataGeometry->Update();
+ return myExtractPolyDataGeometry->GetOutput();
}
SetLookupTable(VISU_LookupTable* theLookupTable);
virtual
- vtkDataSet*
+ vtkPointSet*
GetClippedInput();
private:
// Module : VISU
#include "VISU_ScalarMapOnDeformedShapePL.hxx"
+#include "VISU_FieldTransform.hxx"
#include "VISU_Extractor.hxx"
#include "VISU_LookupTable.hxx"
#include "VISU_DeformedShapePL.hxx"
* 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();
}
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();
}
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));
}
//----------------------------------------------------------------------------
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
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);
+ //}
}
//----------------------------------------------------------------------------
{
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())
VISU_ScalarMapOnDeformedShapePL
::UpdateScalars()
{
- myExtractorScalars->Update();
+ vtkDataSet* aScalars = GetScalars();
+ myScalarsExtractor->SetInput(aScalars);
+
+ if(VISU::IsDataOnCells(aScalars))
+ GetMapper()->SetScalarModeToUseCellData();
+ else
+ GetMapper()->SetScalarModeToUsePointData();
}
//----------------------------------------------------------------------------
::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();
}
//----------------------------------------------------------------------------
if(VISU::CheckIsSameValue(myScaleFactor, theScale))
return;
- myDeformVectors->SetScaleFactor(myScaleFactor);
+ myWarpVector->SetScaleFactor(theScale);
myScaleFactor = theScale;
}
VISU_ScalarMapOnDeformedShapePL
::GetScale()
{
- return myDeformVectors->GetScaleFactor();
+ return myWarpVector->GetScaleFactor();
}
//----------------------------------------------------------------------------
::SetMapScale(vtkFloatingPointType theMapScale)
{
Superclass::SetMapScale(theMapScale);
- myDeformVectors->SetScaleFactor(myScaleFactor*theMapScale);
+ myWarpVector->SetScaleFactor(myScaleFactor*theMapScale);
}
//----------------------------------------------------------------------------
VISU_ScalarMapOnDeformedShapePL
::GetScalarMode()
{
- return myExtractorScalars->GetScalarMode();
+ return myScalarsExtractor->GetScalarMode();
}
//----------------------------------------------------------------------------
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
VISU_ScalarMapOnDeformedShapePL
::GetSourceRange(vtkFloatingPointType theRange[2])
{
- myExtractorScalars->Update();
- myExtractorScalars->GetUnstructuredGridOutput()->GetScalarRange(theRange);
+ myScalarsExtractor->Update();
+ myScalarsExtractor->GetUnstructuredGridOutput()->GetScalarRange(theRange);
}
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]);
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<vtkDataSet> myScalars;
- VISU_Extractor* myExtractorScalars;
+ vtkWarpVector *myWarpVector;
+ VISU_MergeFilter *myScalarsMergeFilter;
+ vtkSmartPointer<vtkUnstructuredGrid> myScalars;
vtkCellDataToPointData* myCellDataToPointData;
+ VISU_FieldTransform* myScalarsFieldTransform;
+ VISU_Extractor* myScalarsExtractor;
};
#endif
{
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
{
if(IsExternalGeometryUsed()){
ClearGeometry();
- myAppendFilter->AddInput(Superclass::InsertCustomPL());
+ myAppendFilter->AddInput(GetClippedInput());
}
}
VISU_ScalarMapPL
::IsExternalGeometryUsed()
{
- vtkDataObject* aDataObject = myAppendFilter->GetInput();
- return aDataObject && aDataObject != Superclass::InsertCustomPL();
+ return myAppendFilter->GetInput() != GetClippedInput();
}
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();
}
VISU_ScalarMapPL*
New();
+ virtual
+ void
+ Update();
+
virtual
void
SetSourceGeometry();
void
ClearGeometry();
+ //----------------------------------------------------------------------------
+ virtual
+ vtkDataSet*
+ GetMergedInput();
+
protected:
//----------------------------------------------------------------------------
VISU_ScalarMapPL();
#include "VISU_StreamLinesPL.hxx"
#include "VISU_Extractor.hxx"
+#include "VISU_FieldTransform.hxx"
#include "VISU_UsedPointsFilter.hxx"
#include "VTKViewer_GeometryFilter.h"
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();
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();
myStream->Modified();
Modified();
}
- return isAccepted;
+ return anIsAccepted;
}
//----------------------------------------------------------------------------
-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();
}
{
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"<<exc.what());
}catch(...){
+ MSG(MYDEBUG,"Unknown exception was occured\n");
}
}
void
Init();
+ virtual
+ void
+ Build();
+
virtual
void
Update();
#include "VISU_VectorsPL.hxx"
+#include "VISU_FieldTransform.hxx"
#include "VISU_PipeLineUtils.hxx"
#include "VTKViewer_TransformFilter.h"
#include "VTKViewer_Transform.h"
//----------------------------------------------------------------------------
-vtkDataSet*
+void
VISU_VectorsPL
-::GetOutput()
+::Build()
{
- myBaseGlyph->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();
}
}
+//----------------------------------------------------------------------------
+vtkDataSet*
+VISU_VectorsPL
+::GetOutput()
+{
+ myBaseGlyph->Update();
+ return myBaseGlyph->GetOutput();
+}
+
+
//----------------------------------------------------------------------------
void
VISU_VectorsPL
void
Init();
+ virtual
+ void
+ Build();
+
virtual
void
Update();
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
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));
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();
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);
}
}
-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,
}
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);
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()
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()