aCon->BuildEntities();
aCon->BuildFields();
aCon->BuildMinMax();
+ aCon->BuildGroups();
+
const VISU::TMeshMap& aMeshMap = aCon->GetMeshMap();
//return;
VISU::TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin();
for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){
- //continue;
const string& aMeshName = aMeshMapIter->first;
const VISU::PMesh& aMesh = aMeshMapIter->second;
const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter;
+ //Importing groups
+ const VISU::TGroupMap& aGroupMap = aMesh->myGroupMap;
+ VISU::TGroupMap::const_iterator aGroupMapIter = aGroupMap.begin();
+ for(; aGroupMapIter != aGroupMap.end(); aGroupMapIter++){
+ const string& aGroupName = aGroupMapIter->first;
+ aCon->GetMeshOnGroup(aMeshName,aGroupName);
+ }
+
+ //continue;
+
//Import fields
aMeshOnEntityMapIter = aMeshOnEntityMap.begin();
for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){
for(; aValFieldIter != aValField.end(); aValFieldIter++){
int aTimeStamp = aValFieldIter->first;
- if(anEntity != VISU::NODE_ENTITY){
+ if(false && anEntity != VISU::NODE_ENTITY){
VISU::PGaussPtsIDMapper aGaussMesh =
aCon->GetTimeStampOnGaussPts(aMeshName,anEntity,aFieldName,aTimeStamp);
VISU::TVTKOutput* aDataSet = aGaussMesh->GetVTKOutput();
}
}
- //Importing groups
- const VISU::TGroupMap& aGroupMap = aMesh->myGroupMap;
- VISU::TGroupMap::const_iterator aGroupMapIter = aGroupMap.begin();
- for(; aGroupMapIter != aGroupMap.end(); aGroupMapIter++){
- const string& aGroupName = aGroupMapIter->first;
- aCon->GetMeshOnGroup(aMeshName,aGroupName);
- }
-
//continue;
//Import mesh on entity
//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);
// Module : VISU
#include "VISU_ConvertorUtils.hxx"
+#include "VISU_ConvertorDef.hxx"
#include <vtkUnstructuredGridWriter.h>
#include <vtkTimerLog.h>
}
+ //---------------------------------------------------------------
+ vtkIdType
+ 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 nbTuples = anIntArray->GetNumberOfTuples();
- int aMaxId = nbTuples * anIntArray->GetNumberOfComponents();
- int* aPointer = anIntArray->GetPointer(0);
- for(int i=0;i<nbTuples;i++){
- if ( *aPointer == theID ){
- aPointer++;
- if( *aPointer == theEntity)
- return i;
- aPointer++;
- continue;
- }
- aPointer++;aPointer++;
- }
- return -1;
- }
+ 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)){
- int nbComp = anIntArray->GetNumberOfComponents();
- return *anIntArray->GetPointer(theID*nbComp);
- }
- }
+ if(vtkDataArray *aDataArray = aDataSetAttributes->GetArray("VISU_CELLS_MAPPER"))
+ return GetObjectID(aDataArray, theID);
+
return -1;
}
+ //---------------------------------------------------------------
+ vtkCell*
+ GetElemCell(vtkDataSet *theDataSet, vtkIdType theObjID)
+ {
+ vtkIdType aVTKID = GetElemVTKID(theDataSet, theObjID);
+ return theDataSet->GetCell(aVTKID);
+ }
+
+
//---------------------------------------------------------------
vtkIdType
GetNodeVTKID(vtkDataSet *theDataSet, vtkIdType theID)
{
theDataSet->Update();
vtkDataSetAttributes *aDataSetAttributes = theDataSet->GetPointData();
- if(vtkDataArray *aDataArray = aDataSetAttributes->GetArray("VISU_POINTS_MAPPER")){
- if(vtkIntArray *anIntArray = dynamic_cast<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);
+ }
+
+
//---------------------------------------------------------------
TTimerLog
::TTimerLog(int theIsDebug,
class vtkUnstructuredGrid;
class vtkTimerLog;
class vtkDataSet;
+class vtkCell;
namespace MED
{
IsDataOnPoints(vtkDataSet* theDataSet);
vtkIdType
- GetElemVTKID(vtkDataSet *theDataSet, vtkIdType theID, int theEntity);
+ GetElemVTKID(vtkDataSet *theDataSet, vtkIdType theID, int theEntity = -1);
vtkIdType
GetElemObjID(vtkDataSet *theDataSet, vtkIdType theID);
+ vtkCell*
+ GetElemCell(vtkDataSet *theDataSet, vtkIdType theObjID);
+
vtkIdType
GetNodeVTKID(vtkDataSet *theDataSet, vtkIdType theID);
vtkIdType
GetNodeObjID(vtkDataSet *theDataSet, vtkIdType theID);
+ vtkFloatingPointType*
+ GetNodeCoord(vtkDataSet *theDataSet, vtkIdType theObjID);
+
class TTimerLog
{
int myIsDebug;
}
vtkIdType aNbTuples = aNbPoints;
+ int anEntity = int(VISU::NODE_ENTITY);
vtkIntArray *aDataArray = vtkIntArray::New();
aDataArray->SetName("VISU_POINTS_MAPPER");
- aDataArray->SetNumberOfComponents(1);
+ aDataArray->SetNumberOfComponents(2);
aDataArray->SetNumberOfTuples(aNbTuples);
+ int *aPtr = aDataArray->GetPointer(0);
for(vtkIdType aTupleId = 0; aTupleId < aNbTuples; aTupleId++){
vtkIdType anObjID = aCoords.GetObjID(aTupleId);
- aDataArray->SetValue(aTupleId, anObjID);
+ *aPtr++ = anObjID;
+ *aPtr++ = anEntity;
}
aPointSource->GetPointData()->AddArray(aDataArray);
aDataArray->Delete();
{
int aNbTuples = aNbCells;
+ int anEntity = int(theMeshOnEntity->myEntity);
vtkIntArray *aDataArray = vtkIntArray::New();
aDataArray->SetName("VISU_CELLS_MAPPER");
// the [0] component is element object ID
int *aPtr = aDataArray->GetPointer(0);
for(int aTupleId = 0; aTupleId < aNbTuples; aTupleId++){
int anObjID = theSubMesh->GetElemObjID(aTupleId);
- *aPtr = anObjID;
- aPtr++;
- *aPtr = (int)theMeshOnEntity->myEntity;
- aPtr++;
+ *aPtr++ = anObjID;
+ *aPtr++ = anEntity;
}
theSource->GetCellData()->AddArray(aDataArray);
-
aDataArray->Delete();
}
vtkIdType *pts = 0, npts = 0;
vtkIntArray *aDataArray = vtkIntArray::New();
+ int anEntity = int(theMeshOnEntity->myEntity);
aDataArray->SetName("VISU_CELLS_MAPPER");
// the [0] component is element object ID
// the [1] component is entity type
PrintCells(aCellId, aConnectivity, anArray[anID]);
aCellTypesArray->SetValue(aCellId, (unsigned char)aVGeom);
vtkIdType anObjID = aSubMesh.GetElemObjID(anID);
- *aPtr = anObjID;
- aPtr++;
- *aPtr = (int)theMeshOnEntity->myEntity;
- aPtr++;
anElemObj2VTKID[anObjID] = aCellId;
aMeshID[aCellId] = anObjID;
+ *aPtr++ = anObjID;
+ *aPtr++ = anEntity;
}
}
theSource->GetCellData()->AddArray(aDataArray);
{
int aNbTuples = aNbCells;
+ int anEntity = int(theMeshOnEntity->myEntity);
vtkIntArray *aDataArray = vtkIntArray::New();
aDataArray->SetName("VISU_CELLS_MAPPER");
// the [0] component is element object ID
// the [1] component is entity type
aDataArray->SetNumberOfComponents(2);
aDataArray->SetNumberOfTuples(aNbTuples);
- int *aPtr = aDataArray->GetPointer(0);
-
+ int *aPtr = aDataArray->GetPointer(0);
for(int aTupleId = 0; aTupleId < aNbTuples; aTupleId++){
int anObjID = theSubProfile->GetElemObjID(aTupleId);
- *aPtr = anObjID;
- aPtr++;
- *aPtr = (int)theMeshOnEntity->myEntity;
- aPtr++;
+ *aPtr++ = anObjID;
+ *aPtr++ = anEntity;
}
theSource->GetCellData()->AddArray(aDataArray);
aDataArray->Delete();
// $Header$
#include "VISU_MergeFilter.hxx"
+#include "VISU_ConvertorUtils.hxx"
#include <vtkCellData.h>
#include <vtkObjectFactory.h>
#else
static int MYDEBUG = 0;
#endif
-// TTimerLog
-#include "VISU_ConvertorUtils.hxx"
namespace VISU
{
-
+ //---------------------------------------------------------------
class TFieldNode
{
public:
char* Name;
};
+ //---------------------------------------------------------------
class TFieldList
{
public:
TFieldNode* Last;
};
+
+ //---------------------------------------------------------------
class TFieldListIterator
{
public:
this->FieldList = new VISU::TFieldList;
}
+
+//---------------------------------------------------------------
VISU_MergeFilter::~VISU_MergeFilter()
{
delete this->FieldList;
}
+
+//---------------------------------------------------------------
+unsigned long
+VISU_MergeFilter
+::GetMTime()
+{
+ int aNbInputs = GetNumberOfInputs();
+ vtkDataObject** aDataObjects = GetInputs();
+ unsigned long aTime = Superclass::GetMTime();
+ for(int anInputId = 0; anInputId < aNbInputs; anInputId++){
+ if(vtkDataObject* aDataObject = aDataObjects[anInputId])
+ aTime = std::max(aTime, aDataObject->GetMTime());
+ }
+ if(this->FieldList){
+ VISU::TFieldListIterator anIter(this->FieldList);
+ for(anIter.Begin(); !anIter.End() ; anIter.Next()){
+ if(vtkDataSet *aDataSet = anIter.Get()->Ptr)
+ aTime = std::max(aTime, aDataSet->GetMTime());
+ }
+ }
+ return aTime;
+}
+
+//---------------------------------------------------------------
void VISU_MergeFilter::SetScalars(vtkDataSet *input)
{
this->vtkProcessObject::SetNthInput(1, input);
return (vtkDataSet *)(this->Inputs[1]);
}
+
+//---------------------------------------------------------------
void VISU_MergeFilter::SetVectors(vtkDataSet *input)
{
this->vtkProcessObject::SetNthInput(2, input);
return (vtkDataSet *)(this->Inputs[2]);
}
+
+//---------------------------------------------------------------
void VISU_MergeFilter::SetNormals(vtkDataSet *input)
{
this->vtkProcessObject::SetNthInput(3, input);
return (vtkDataSet *)(this->Inputs[3]);
}
+
+//---------------------------------------------------------------
void VISU_MergeFilter::SetTCoords(vtkDataSet *input)
{
this->vtkProcessObject::SetNthInput(4, input);
return (vtkDataSet *)(this->Inputs[4]);
}
+
+//---------------------------------------------------------------
void VISU_MergeFilter::SetTensors(vtkDataSet *input)
{
this->vtkProcessObject::SetNthInput(5, input);
return (vtkDataSet *)(this->Inputs[5]);
}
+
+//---------------------------------------------------------------
void VISU_MergeFilter::AddField(const char* name, vtkDataSet* input)
{
this->FieldList->Add(name, input);
{
delete this->FieldList;
this->FieldList = new VISU::TFieldList;
+ this->Modified();
}
namespace
{
- typedef std::vector<int> TSortedArray;
+ //---------------------------------------------------------------
+ typedef int TCellId;
+ typedef int TEntityId;
+ typedef std::pair<TCellId, TEntityId> TObjectId;
- inline
+ typedef std::set<TObjectId> TObjectIdSet;
+ typedef std::vector<TObjectId> TObjectIdArray;
+
+ typedef int TTupleId;
+ typedef std::map<TObjectId, TTupleId> TObjectId2TupleIdMap;
+
+
+ //---------------------------------------------------------------
void
- GetSortedArray(vtkIntArray *theArray,
- TSortedArray& theSortedArray)
+ GetObjectIdSet(vtkIntArray *theArray,
+ TObjectIdSet& theObjectIdSet)
{
+ theObjectIdSet.clear();
int aMaxId = theArray->GetMaxId();
int* aPointer = theArray->GetPointer(0);
int* anEndPointer = theArray->GetPointer(aMaxId + 1);
- TSortedArray aSortedArray(aPointer, anEndPointer);
- std::sort(aSortedArray.begin(), aSortedArray.end());
- theSortedArray.swap(aSortedArray);
- }
-
- typedef std::map<int,int> TId2IdMap;
- typedef std::set<int> TIdSet;
-
- template <class TNumericType>
- void DeepCopySwitchOnOutput(TNumericType *theInputPtr,
- TNumericType *theOutputPtr,
- const TSortedArray& theIntersection,
- const TId2IdMap& theObj2VTKMap,
- vtkIdType theNbComp)
- {
- vtkIdType aNbIds = theIntersection.size();
- for(vtkIdType aTargetTupleId = 0; aTargetTupleId < aNbIds; aTargetTupleId++){
- vtkIdType aTargetId = aTargetTupleId*theNbComp;
- vtkIdType anObjId = theIntersection[aTargetTupleId];
- TId2IdMap::const_iterator anIter = theObj2VTKMap.find(anObjId);
- vtkIdType aSourceTupleId = anIter->second;
- vtkIdType aSourceId = aSourceTupleId*theNbComp;
- for(vtkIdType aComp = 0; aComp < theNbComp; aComp++){
- theOutputPtr[aTargetId++] = theInputPtr[aSourceId++];
- }
+ for(; aPointer != anEndPointer; aPointer += 2){
+ TCellId aCellId = *aPointer;
+ TEntityId anEntityId = *(aPointer + 1);
+ TObjectId anObjectId(aCellId, anEntityId);
+ theObjectIdSet.insert(anObjectId);
}
}
- typedef vtkDataArray* (vtkDataSetAttributes::* TGetAttribute)();
- typedef int (vtkDataSetAttributes::* TSetAttribute)(vtkDataArray*);
- inline
+ //---------------------------------------------------------------
void
- CopyArray(vtkDataArray* theDataArray,
- vtkDataSetAttributes* theOutput,
- TSetAttribute theSetAttribute,
- vtkIdType theFixedNbTuples)
+ GetObjectId2TupleIdMap(vtkIntArray *theArray,
+ TObjectId2TupleIdMap& theObjectId2TupleIdMap)
{
- if(theDataArray){
- vtkIdType aNbTuples = theDataArray->GetNumberOfTuples();
- if(theFixedNbTuples == aNbTuples)
- (theOutput->*theSetAttribute)(theDataArray);
+ theObjectId2TupleIdMap.clear();
+ int* aPointer = theArray->GetPointer(0);
+ int aNbTuples = theArray->GetNumberOfTuples();
+ for(vtkIdType aTupleId = 0; aTupleId < aNbTuples; aTupleId++, aPointer += 2){
+ TCellId aCellId = *aPointer;
+ TEntityId anEntityId = *(aPointer + 1);
+ TObjectId anObjectId(aCellId, anEntityId);
+ theObjectId2TupleIdMap[anObjectId] = aTupleId;
}
}
- inline
- void
- CopyAttribute(vtkDataSetAttributes* theInput,
- TGetAttribute theGetAttribute,
- vtkDataSetAttributes* theOutput,
- TSetAttribute theSetAttribute,
- vtkIdType theFixedNbTuples)
- {
- CopyArray((theInput->*theGetAttribute)(),
- theOutput, theSetAttribute,
- theFixedNbTuples);
- }
- vtkDataArray*
- DeepCopyArray(vtkDataArray* theDataArray,
- vtkDataSetAttributes* theOutput,
- TSetAttribute theSetAttribute,
- const TSortedArray& theIntersection,
- const TId2IdMap& theObj2VTKMap)
- {
- vtkDataArray *aDataArray = NULL;
- if(theDataArray){
- void *anInputPtr = theDataArray->GetVoidPointer(0);
- vtkIdType aNbTuples = theIntersection.size();
- vtkIdType aNbComp = theDataArray->GetNumberOfComponents();
-
- aDataArray = vtkDataArray::CreateDataArray(theDataArray->GetDataType());
- aDataArray->SetNumberOfComponents(aNbComp);
- aDataArray->SetNumberOfTuples(aNbTuples);
- void *anOutputPtr = aDataArray->GetVoidPointer(0);
-
- switch(theDataArray->GetDataType()){
- vtkTemplateMacro5(DeepCopySwitchOnOutput,
- (VTK_TT*)anInputPtr,
- (VTK_TT*)anOutputPtr,
- theIntersection,
- theObj2VTKMap,
- aNbComp);
- default:
- vtkGenericWarningMacro(<<"Unsupported data type!");
- }
+ //---------------------------------------------------------------
+ typedef vtkFieldData* (vtkDataSet::* TGetFieldData)();
- (theOutput->*theSetAttribute)(aDataArray);
- aDataArray->Delete();
- }
- return aDataArray;
- }
-
- void
- DeepCopyAttribute(vtkDataSetAttributes* theInput,
- TGetAttribute theGetAttribute,
- vtkDataSetAttributes* theOutput,
- TSetAttribute theSetAttribute,
- const TSortedArray& theIntersection,
- const TId2IdMap& theObj2VTKMap)
+ //---------------------------------------------------------------
+ struct TGetCellData
{
- DeepCopyArray((theInput->*theGetAttribute)(),
- theOutput,
- theSetAttribute,
- theIntersection,
- theObj2VTKMap);
- }
-
- inline
- void
- DeepCopyDataSetAttribute(vtkDataSet* theInput,
- TGetAttribute theGetAttribute,
- vtkDataSet* theOutput,
- TSetAttribute theSetAttribute,
- const TSortedArray& theIntersection,
- const TId2IdMap& theObj2VTKMap)
- {
- CopyAttribute(theInput->GetPointData(),
- theGetAttribute,
- theOutput->GetPointData(),
- theSetAttribute,
- theInput->GetNumberOfPoints());
- DeepCopyAttribute(theInput->GetCellData(),
- theGetAttribute,
- theOutput->GetCellData(),
- theSetAttribute,
- theIntersection,
- theObj2VTKMap);
- }
+ vtkFieldData*
+ operator()(vtkDataSet* theDataSet)
+ {
+ return theDataSet->GetCellData();
+ }
+ };
- inline
- void
- DeepCopyField(vtkDataSetAttributes* theInput,
- const char* theFieldName,
- vtkDataSetAttributes* theOutput,
- const TSortedArray& theIntersection,
- const TId2IdMap& theObj2VTKMap)
- {
- vtkDataArray* aDataArray =
- DeepCopyArray(theInput->GetArray(theFieldName),
- theOutput,
- &vtkFieldData::AddArray,
- theIntersection,
- theObj2VTKMap);
- if(aDataArray)
- aDataArray->SetName(theFieldName);
- }
- inline
- void
- CopyField(vtkDataSetAttributes* theInput,
- const char* theFieldName,
- vtkDataSetAttributes* theOutput,
- vtkIdType theFixedNbTuples)
+ //---------------------------------------------------------------
+ struct TGetPointData
{
- CopyArray(theInput->GetArray(theFieldName),
- theOutput,
- &vtkDataSetAttributes::AddArray,
- theFixedNbTuples);
- }
+ vtkFieldData*
+ operator()(vtkDataSet* theDataSet)
+ {
+ return theDataSet->GetPointData();
+ }
+ };
- inline
- void
- DeepCopyDataSetField(vtkDataSet* theInput,
- const char* theFieldName,
- vtkDataSet* theOutput,
- const TSortedArray& theIntersection,
- const TId2IdMap& theObj2VTKMap)
- {
- CopyField(theInput->GetPointData(), theFieldName,
- theOutput->GetPointData(),
- theInput->GetNumberOfPoints());
- DeepCopyField(theInput->GetCellData(), theFieldName,
- theOutput->GetCellData(),
- theIntersection, theObj2VTKMap);
- }
- inline
- void
- DeepCopyDataSetAttributes(VISU_MergeFilter *theFilter,
- vtkDataSet *theFilterOutput,
- VISU::TFieldList* theFieldList,
- const TSortedArray& theIntersection,
- const TId2IdMap& theObj2VTKMap)
+ //---------------------------------------------------------------
+ template<class TGetFieldData>
+ vtkIntArray*
+ GetIDMapper(VISU::TFieldList* theFieldList,
+ TGetFieldData theGetFieldData,
+ const char* theFieldName)
{
- if(vtkDataSet* aDataSet = theFilter->GetScalars())
- DeepCopyDataSetAttribute(aDataSet,
- &vtkDataSetAttributes::GetScalars,
- theFilterOutput,
- &vtkDataSetAttributes::SetScalars,
- theIntersection,
- theObj2VTKMap);
-
- if(vtkDataSet* aDataSet = theFilter->GetVectors())
- DeepCopyDataSetAttribute(aDataSet,
- &vtkDataSetAttributes::GetVectors,
- theFilterOutput,
- &vtkDataSetAttributes::SetVectors,
- theIntersection,
- theObj2VTKMap);
-
- if(vtkDataSet* aDataSet = theFilter->GetNormals())
- DeepCopyDataSetAttribute(aDataSet,
- &vtkDataSetAttributes::GetNormals,
- theFilterOutput,
- &vtkDataSetAttributes::SetNormals,
- theIntersection,
- theObj2VTKMap);
-
- if(vtkDataSet* aDataSet = theFilter->GetTCoords())
- DeepCopyDataSetAttribute(aDataSet,
- &vtkDataSetAttributes::GetTCoords,
- theFilterOutput,
- &vtkDataSetAttributes::SetTCoords,
- theIntersection,
- theObj2VTKMap);
-
- if(vtkDataSet* aDataSet = theFilter->GetTensors())
- DeepCopyDataSetAttribute(aDataSet,
- &vtkDataSetAttributes::GetTensors,
- theFilterOutput,
- &vtkDataSetAttributes::SetTensors,
- theIntersection,
- theObj2VTKMap);
-
VISU::TFieldListIterator anIter(theFieldList);
for(anIter.Begin(); !anIter.End() ; anIter.Next()){
- vtkDataSet *aDataSet = anIter.Get()->Ptr;
const char* aFieldName = anIter.Get()->GetName();
- DeepCopyDataSetField(aDataSet,
- aFieldName,
- theFilterOutput,
- theIntersection,
- theObj2VTKMap);
- }
- }
-
- inline
- void
- GetIdsForCopy(vtkUnstructuredGrid *inputUGrid,
- vtkIntArray* inputPointIds,
- TSortedArray& outputSortedArray)
- {
- if(inputUGrid){
- TSortedArray aSortedPointIds;
- TSortedArray aOutputCellIds;
-
- TIdSet aMapForSearch;
- int nbTuples = inputPointIds->GetNumberOfTuples();
- int nbComp = inputPointIds->GetNumberOfComponents();
- int * aPtr = inputPointIds->GetPointer(0);
- int * aPtrEnd = inputPointIds->GetPointer(nbTuples*nbComp+1);
- if(nbComp == 1)
- while(aPtr<aPtrEnd){
- aMapForSearch.insert(*aPtr);
- aPtr++;
- }
- else if (nbComp == 2)
- while(aPtr<aPtrEnd){
- aMapForSearch.insert(*aPtr);
- aPtr++;aPtr++;
- }
- int nbInputCells = inputUGrid->GetNumberOfCells();
-
- for(int idCell=0;idCell<nbInputCells;idCell++){
- vtkCell* aCell = inputUGrid->GetCell(idCell);
- vtkIdList* ptIds = aCell->GetPointIds();
- 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;
-
+ if(strcmp(aFieldName, theFieldName) == 0){
+ vtkDataSet* aDataSet = anIter.Get()->Ptr;
+ vtkFieldData *aFieldData = theGetFieldData(aDataSet);
+ vtkDataArray *anIDMapper = aFieldData->GetArray(theFieldName);
+ return dynamic_cast<vtkIntArray*>(anIDMapper);
}
-
- outputSortedArray.swap(aOutputCellIds);
}
+ return NULL;
}
- inline
- void
- CopyElementsToOutput(vtkUnstructuredGrid* theInputUG,
- int& theNbElements,
- TSortedArray& theElementIdsForCopy,
- TId2IdMap& theOldId2NewIdPointsMap,
- vtkUnstructuredGrid* theOutputUG)
- {
- vtkIntArray* theOutputIDSArray = vtkIntArray::New();
- theOutputIDSArray->SetName("VISU_CELLS_MAPPER");
- // the [0] component is element object ID
- // the [1] component is entity type
- theOutputIDSArray->SetNumberOfComponents(2);
- theOutputIDSArray->SetNumberOfTuples(theNbElements);
- int* aOutputIDSPtr = theOutputIDSArray->GetPointer(0);
-
- vtkIntArray* aInputCellsMapper =
- dynamic_cast<vtkIntArray*>(theInputUG->GetCellData()->GetArray("VISU_CELLS_MAPPER"));
-
- int* aInputCellsMapperPointer = aInputCellsMapper->GetPointer(0);
-
- for(int aCellIndex=0;aCellIndex<theNbElements;aCellIndex++){
- int aCellId = theElementIdsForCopy[aCellIndex];
- vtkIdList* aOldPointIds = theInputUG->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);
- }
- theOutputUG->InsertNextCell(theInputUG->GetCellType(aCellId),
- aNewPointIds);
-
- *aOutputIDSPtr = aInputCellsMapperPointer[2*aCellId];
- aOutputIDSPtr++;
- *aOutputIDSPtr = aInputCellsMapperPointer[2*aCellId+1];
- aOutputIDSPtr++;
-
- aNewPointIds->Delete();
- }
- theOutputUG->GetCellData()->AddArray(theOutputIDSArray);
- theOutputIDSArray->Delete();
- }
- inline
- void
- copyOneToOneComponent(vtkIntArray* input,
- vtkIntArray* output)
+ //---------------------------------------------------------------
+ template<class TGetFieldData>
+ vtkIntArray*
+ GetIDMapper(vtkDataSet* theIDMapperDataSet,
+ TGetFieldData theGetFieldData,
+ const char* theFieldName)
{
- int nbTuples = input->GetNumberOfTuples();
- int nbComp = input->GetNumberOfComponents();
- int* aInputPtr = input->GetPointer(0);
- int* aOutputPtr = output->GetPointer(0);
- if(nbComp == 2){
- for(int i=0;i<nbTuples;i++){
- *aOutputPtr = *aInputPtr;
- aOutputPtr++;
- aInputPtr++;
- aInputPtr++;
- }
- } else if (nbComp == 1){
- for(int i=0;i<nbTuples;i++){
- *aOutputPtr = *aInputPtr;
- aOutputPtr++;
- aInputPtr++;
- }
- }
+ vtkFieldData *aFieldData = theGetFieldData(theIDMapperDataSet);
+ vtkDataArray *anIDMapper = aFieldData->GetArray(theFieldName);
+ return dynamic_cast<vtkIntArray*>(anIDMapper);
}
- inline
+
+ //---------------------------------------------------------------
bool
- isTwoArraysSame(vtkIntArray* theFirst,
- vtkIntArray* theSecond)
+ IsDifferent(vtkIntArray *theFirstIDMapper,
+ vtkIntArray *theSecondIDMapper)
{
- int* theFirstPtr = theFirst->GetPointer(0);
- int* theSecondPtr = theSecond->GetPointer(0);
- int nbTuples1 = theFirst->GetNumberOfTuples();
- int nbTuples2 = theSecond->GetNumberOfTuples();
- if(nbTuples1 != nbTuples2)
- return false;
- for(int i=0;i<nbTuples1;i++,theFirstPtr++,theSecondPtr++){
- if(*theFirstPtr != *theSecondPtr)
- return false;
- }
-
- return true;
- }
-}
+ vtkIdType aFirstNbTuples = theFirstIDMapper->GetNumberOfTuples();
+ vtkIdType aSecondNbTuples = theSecondIDMapper->GetNumberOfTuples();
+ if(aFirstNbTuples != aSecondNbTuples)
+ return true;
-bool
-VISU_MergeFilter
-::MergeGeometryCellsAndDataOnCells()
-{
- if(MYDEBUG) cout << "MergeGeometryCellsAndDataOnCells" << endl;
- vtkUnstructuredGrid *anInput = this->GetInput();
- vtkUnstructuredGrid *anOutput = this->GetOutput();
- vtkCellData *aCellData = anInput->GetCellData();
- vtkDataArray *aCellMapper = aCellData->GetArray("VISU_CELLS_MAPPER"); // 1
- vtkIntArray *aGeometryCellMapper = dynamic_cast<vtkIntArray*>(aCellMapper);
-
- // The situation for merging CELLS from anInput as Geometry
- // and scalars on cell data
- vtkIntArray* aDataCellMapper = NULL;
- VISU::TFieldListIterator anIter(this->FieldList);
- for(anIter.Begin(); !anIter.End() ; anIter.Next()){
- vtkCellData *aCellData = anIter.Get()->Ptr->GetCellData();
- const char* aFieldName = anIter.Get()->GetName();
- if(strcmp(aFieldName, "VISU_CELLS_MAPPER") == 0){
- vtkDataArray *aCellMapper_tmp = aCellData->GetArray(aFieldName);
- aDataCellMapper = dynamic_cast<vtkIntArray*>(aCellMapper_tmp);
- break;
+ int aMaxId = theFirstIDMapper->GetMaxId();
+ int* aFirstPointer = theFirstIDMapper->GetPointer(0);
+ int* aSecondPointer = theSecondIDMapper->GetPointer(0);
+ for(int anId = 0; anId <= aMaxId; anId++){
+ if(*aFirstPointer++ != *aSecondPointer++)
+ return true;
}
- }
-
- bool anIsDifferent = aDataCellMapper &&
- aDataCellMapper->GetNumberOfTuples() != aGeometryCellMapper->GetNumberOfTuples();
-
- if(anIsDifferent || IsMergingInputs() ){
- TSortedArray aGeometryCellArray;
- vtkIntArray* aGeometryCellMapperOnly = vtkIntArray::New();
- vtkIntArray* aDataCellMapperOnly = vtkIntArray::New();
- aGeometryCellMapperOnly->SetNumberOfComponents(1);
- aGeometryCellMapperOnly->SetNumberOfTuples(aGeometryCellMapper->GetNumberOfTuples());
- aGeometryCellMapperOnly->SetName(aGeometryCellMapper->GetName());
- aDataCellMapperOnly->SetNumberOfComponents(1);
- aDataCellMapperOnly->SetNumberOfTuples(aDataCellMapper->GetNumberOfTuples());
- aDataCellMapperOnly->SetName(aDataCellMapper->GetName());
- copyOneToOneComponent(aGeometryCellMapper,aGeometryCellMapperOnly);
- copyOneToOneComponent(aDataCellMapper,aDataCellMapperOnly);
-
- GetSortedArray(aGeometryCellMapperOnly, aGeometryCellArray);
- TSortedArray aDataCellArray;
- GetSortedArray(aDataCellMapperOnly, aDataCellArray);
-
- int aMaxLength = std::max(aGeometryCellArray.size(), aDataCellArray.size());
- TSortedArray anIntersectionArray(aMaxLength);
- TSortedArray::iterator anArrayIter = anIntersectionArray.begin();
- anArrayIter = std::set_intersection(aGeometryCellArray.begin(),
- aGeometryCellArray.end(),
- aDataCellArray.begin(),
- aDataCellArray.end(),
- anArrayIter);
-
- anIntersectionArray.erase(anArrayIter, anIntersectionArray.end());
-
- bool anIsCompletelyCoincide =
- anIntersectionArray.size() == aGeometryCellArray.size() &&
- anIntersectionArray.size() == aDataCellArray.size();
-
- if(!anIsCompletelyCoincide || IsMergingInputs()){
- {
- TId2IdMap anObj2VTKGeometryMap;
- vtkIdType aNbCells = aGeometryCellMapperOnly->GetNumberOfTuples();
- int* aGPtr = aGeometryCellMapperOnly->GetPointer(0);
- for(int aCellId = 0; aCellId < aNbCells; aCellId++){
- vtkIdType anObjID = *aGPtr;
- aGPtr++;
- anObj2VTKGeometryMap[anObjID] = aCellId;
- }
-
- vtkIdType aNbTuples = anIntersectionArray.size();
- anOutput->Allocate(aNbTuples);
- vtkIdList *aCellIds = vtkIdList::New();
- for(int aTupleId = 0; aTupleId < aNbTuples; aTupleId++){
- vtkIdType anObjID = anIntersectionArray[aTupleId];
- vtkIdType aCellId = anObj2VTKGeometryMap[anObjID];
- vtkCell *aCell = anInput->GetCell(aCellId);
- aCellIds->Reset();
- vtkIdType aNbPointIds = aCell->PointIds->GetNumberOfIds();
- for(vtkIdType aPointId = 0; aPointId < aNbPointIds; aPointId++)
- aCellIds->InsertNextId(aCell->GetPointIds()->GetId(aPointId));
- anOutput->InsertNextCell(anInput->GetCellType(aCellId), aCellIds);
- }
- aCellIds->Delete();
- anOutput->SetPoints(anInput->GetPoints());
- }
- {
- TId2IdMap anObj2VTKDataMap;
- vtkIdType aNbCells = aDataCellMapperOnly->GetNumberOfTuples();
- int* aDPtr = aDataCellMapperOnly->GetPointer(0);
- for(int aCellId = 0; aCellId < aNbCells; aCellId++){
- vtkIdType anObjID = *aDPtr;
- aDPtr++;
- anObj2VTKDataMap[anObjID] = aCellId;
- }
-
- DeepCopyDataSetAttributes(this,
- anOutput,
- this->FieldList,
- anIntersectionArray,
- anObj2VTKDataMap);
- }
- aGeometryCellMapperOnly->Delete();
- aDataCellMapperOnly->Delete();
- return true;
- }
- aGeometryCellMapperOnly->Delete();
- aDataCellMapperOnly->Delete();
+ return false;
}
- return false;
-}
-bool
-VISU_MergeFilter
-::MergeGeometryCellsAndDataOnAllPoints()
-{
- if(MYDEBUG) cout << "MergeGeometryCellsAndDataOnAllPoints" << endl;
- // The situation for merging CELLS from anInput as Geometry
- // and scalars on point data
- vtkUnstructuredGrid *anInput = this->GetInput();
- vtkUnstructuredGrid *anOutput = this->GetOutput();
- vtkPointData *aPointData = anInput->GetPointData();
- vtkCellData *aCellData = anInput->GetCellData();
- vtkDataSet* aInputScalars = this->GetScalars();
- vtkPointData* aInputScalarsPointData = aInputScalars->GetPointData();
- vtkDataArray *aPointMapper = aPointData->GetArray("VISU_POINTS_MAPPER");
- vtkIntArray *aGeometryPointMapper = dynamic_cast<vtkIntArray*>(aPointMapper);
- vtkDataArray *aCellMapper = aCellData->GetArray("VISU_CELLS_MAPPER"); // 1
- vtkIntArray *aGeometryCellMapper = dynamic_cast<vtkIntArray*>(aCellMapper); // 1->2
-
- vtkIntArray* aDataPointMapper = NULL;
- VISU::TFieldListIterator anIter(this->FieldList);
- for(anIter.Begin(); !anIter.End() ; anIter.Next()){
- const char* aFieldName = anIter.Get()->GetName();
- if(strcmp(aFieldName, "VISU_POINTS_MAPPER") == 0){
- vtkDataArray *aPointMapper = aInputScalarsPointData->GetArray(aFieldName);
- aDataPointMapper = dynamic_cast<vtkIntArray*>(aPointMapper);
- break;
- }
+ //---------------------------------------------------------------
+ inline
+ void
+ GetIntersection(vtkIntArray *theFirstIDMapper,
+ vtkIntArray *theSecondIDMapper,
+ TObjectIdArray& theResult)
+ {
+ TObjectIdSet aFirstObjectIdSet;
+ GetObjectIdSet(theFirstIDMapper, aFirstObjectIdSet);
+
+ TObjectIdSet aSecondObjectIdSet;
+ GetObjectIdSet(theSecondIDMapper, aSecondObjectIdSet);
+
+ size_t aMaxLength = std::max(aFirstObjectIdSet.size(), aSecondObjectIdSet.size());
+ theResult.resize(aMaxLength);
+ TObjectIdArray::iterator anArrayIter = theResult.begin();
+ anArrayIter = std::set_intersection(aFirstObjectIdSet.begin(),
+ aFirstObjectIdSet.end(),
+ aSecondObjectIdSet.begin(),
+ aSecondObjectIdSet.end(),
+ anArrayIter);
+ theResult.erase(anArrayIter, theResult.end());
}
-
- if(aDataPointMapper){
- bool isArraysEqual = isTwoArraysSame(aDataPointMapper,aGeometryPointMapper);
- {
- TId2IdMap anObj2VTKGeometryPointsMap;
- vtkIdType aNbPoints = aDataPointMapper->GetNumberOfTuples();
- if(isArraysEqual){
- for(int aCellId = 0; aCellId < aNbPoints; aCellId++)
- anObj2VTKGeometryPointsMap[aCellId] = aCellId;
- } else {
- // situation: the numbering of points are different in geometry and in scalars
- cout << "------------------"<<endl;
- cout << "Warning! Incorrect data are used in "<<__FILE__<<"["<<__LINE__<<"]"<<endl;
- cout << "------------------"<<endl;
- }
- int aNbCells = aGeometryCellMapper->GetNumberOfTuples();
-
- // copy points to output
- vtkUnstructuredGrid* aUnstructuredScalars = dynamic_cast<vtkUnstructuredGrid*>(aInputScalars);
- if(aUnstructuredScalars)
- anOutput->SetPoints(aUnstructuredScalars->GetPoints());
- anOutput->GetPointData()->ShallowCopy(aInputScalars->GetPointData());
-
- // Calculate output cells
- TSortedArray aCellIdsForCopy;
- for(int i=0;i<aNbCells;i++)
- aCellIdsForCopy.push_back(i);
+
+ //---------------------------------------------------------------
+ void
+ CopyDataOnCells(vtkUnstructuredGrid *theInput,
+ vtkIntArray *theGeometryCellMapper,
+ vtkIntArray *theDataCellMapper,
+ vtkDataSet* theScalarsDataSet,
+ vtkDataSet* theVectorsDataSet,
+ vtkDataSet* theNormalsDataSet,
+ vtkDataSet* theTCoordsDataSet,
+ vtkDataSet* theTensorsDataSet,
+ VISU::TFieldList* theFieldList,
+ vtkUnstructuredGrid *theOutput)
+ {
+ if(IsDifferent(theGeometryCellMapper, theDataCellMapper)){
+ TObjectIdArray anIntersection;
+ GetIntersection(theGeometryCellMapper,
+ theDataCellMapper,
+ anIntersection);
+
+ TObjectId2TupleIdMap aGeomObjectId2TupleIdMap;
+ GetObjectId2TupleIdMap(theGeometryCellMapper, aGeomObjectId2TupleIdMap);
- // copy cells to output
- anOutput->Allocate(aNbCells);
+ TObjectId2TupleIdMap aDataObjectId2TupleIdMap;
+ GetObjectId2TupleIdMap(theDataCellMapper, aDataObjectId2TupleIdMap);
- if(aNbCells>0)
- CopyElementsToOutput(anInput,
- aNbCells,
- aCellIdsForCopy,
- anObj2VTKGeometryPointsMap,
- anOutput);
-
- return true;
- }
- }
- return false;
-}
-
-bool
-VISU_MergeFilter
-::MergeGeometryCellsAndDataOnNotAllPoints()
-{
- if(MYDEBUG) cout << "MergeGeometryCellsAndDataOnNotAllPoints" << endl;
- // The situation for merging CELLS from anInput as Geometry
- // and scalars on point data (there the number of points of point data less than
- // number of points of Geometry)
-
- vtkUnstructuredGrid *anInput = this->GetInput();
- vtkUnstructuredGrid *anOutput = this->GetOutput();
- vtkDataSet* aInputScalars = this->GetScalars();
- vtkPointData *aPointData = anInput->GetPointData();
+ vtkCellData *aCellData = theScalarsDataSet->GetCellData();
+ vtkCellData *anOutputCellData = theOutput->GetCellData();
+ anOutputCellData->CopyAllocate(aCellData);
+
+ vtkIdType aNbTuples = anIntersection.size();
+ theOutput->Allocate(aNbTuples);
+ vtkIdList *aCellIds = vtkIdList::New();
+ for(int aTupleId = 0; aTupleId < aNbTuples; aTupleId++){
+ TObjectId& anObjectId = anIntersection[aTupleId];
+ vtkIdType aCellId = aGeomObjectId2TupleIdMap[anObjectId];
+ vtkCell *aCell = theInput->GetCell(aCellId);
+ aCellIds->Reset();
+ vtkIdType aNbPointIds = aCell->PointIds->GetNumberOfIds();
+ for(vtkIdType anId = 0; anId < aNbPointIds; anId++)
+ aCellIds->InsertNextId(aCell->GetPointIds()->GetId(anId));
+ vtkIdType aCellType = theInput->GetCellType(aCellId);
+ vtkIdType aNewCellId = theOutput->InsertNextCell(aCellType, aCellIds);
+ vtkIdType aDataCellId = aDataObjectId2TupleIdMap[anObjectId];
+ anOutputCellData->CopyData(aCellData, aDataCellId, aNewCellId);
+ }
+ aCellIds->Delete();
- vtkPointData* aInputScalarsPointData = aInputScalars->GetPointData();
- vtkDataArray *aPointMapper = aPointData->GetArray("VISU_POINTS_MAPPER");
- vtkIntArray *aGeometryPointMapper = dynamic_cast<vtkIntArray*>(aPointMapper);
-
- vtkIntArray* aDataPointMapper = NULL;
- VISU::TFieldListIterator anIter(this->FieldList);
- for(anIter.Begin(); !anIter.End() ; anIter.Next()){
- const char* aFieldName = anIter.Get()->GetName();
- if(strcmp(aFieldName, "VISU_POINTS_MAPPER") == 0){
- vtkDataArray *aPointMapper = aInputScalarsPointData->GetArray(aFieldName);
- aDataPointMapper = dynamic_cast<vtkIntArray*>(aPointMapper);
- break;
- }
- }
- vtkIntArray* aDataCellMapper = NULL;
- VISU::TFieldListIterator anIter2(this->FieldList);
- for(anIter2.Begin(); !anIter2.End() ; anIter2.Next()){
- const char* aFieldName = anIter2.Get()->GetName();
- if(strcmp(aFieldName, "VISU_CELLS_MAPPER") == 0){
- vtkDataArray *aCellMapper_tmp = aInputScalarsPointData->GetArray(aFieldName);
- aDataCellMapper = dynamic_cast<vtkIntArray*>(aCellMapper_tmp);
- break;
+ theOutput->SetPoints(theInput->GetPoints());
+ }else{
+ theOutput->CopyStructure(theInput);
+ theOutput->GetCellData()->ShallowCopy(theScalarsDataSet->GetCellData());
}
+ theOutput->GetPointData()->ShallowCopy(theInput->GetPointData());
}
- vtkIntArray* aDataArray = NULL;
- VISU::TFieldListIterator anIter3(this->FieldList);
- for(anIter2.Begin(); !anIter3.End() ; anIter3.Next()){
- const char* aFieldName = anIter3.Get()->GetName();
- if(strcmp(aFieldName, "VISU_FIELD") == 0){
- vtkDataArray *aPointMapper_tmp = aInputScalarsPointData->GetArray(aFieldName);
- aDataArray = dynamic_cast<vtkIntArray*>(aPointMapper_tmp);
- break;
- }
- }
-
- bool anIsDifferent = aDataPointMapper &&
- aDataPointMapper->GetNumberOfTuples() != aGeometryPointMapper->GetNumberOfTuples();
- if(anIsDifferent){
- {
- vtkIntArray* aPointsIds = vtkIntArray::New();
-
- TId2IdMap anObj2VTKGeometryMap;
- vtkIdType aNbCells = aDataPointMapper->GetNumberOfTuples();
- aPointsIds->SetNumberOfTuples(aNbCells);
- aPointsIds->SetNumberOfComponents(1);
- vtkIdType aNbComp = aDataPointMapper->GetNumberOfComponents();
- int * aPtr = aDataPointMapper->GetPointer(0);
- int * aPtrOut = aPointsIds->GetPointer(0);
- if(aNbComp==2){
- for(int aCellId = 0; aCellId < aNbCells; aCellId++){
- vtkIdType anObjID = *aPtr;
- aPtr++;aPtr++;
- *aPtrOut = anObjID;
- aPtrOut++;
- anObj2VTKGeometryMap[anObjID] = aCellId;
- }
- } else if (aNbComp == 1 ){
- for(int aCellId = 0; aCellId < aNbCells; aCellId++){
- vtkIdType anObjID = *aPtr;
- aPtr++;
- *aPtrOut = anObjID;
- aPtrOut++;
- anObj2VTKGeometryMap[anObjID] = aCellId;
- }
+ //---------------------------------------------------------------
+ void
+ CopyDataOnPoints(vtkUnstructuredGrid *theInput,
+ vtkIntArray *theGeometryPointMapper,
+ vtkIntArray *theDataPointMapper,
+ vtkDataSet* theScalarsDataSet,
+ vtkDataSet* theVectorsDataSet,
+ vtkDataSet* theNormalsDataSet,
+ vtkDataSet* theTCoordsDataSet,
+ vtkDataSet* theTensorsDataSet,
+ VISU::TFieldList* theFieldList,
+ vtkUnstructuredGrid *theOutput)
+ {
+ if(IsDifferent(theGeometryPointMapper, theDataPointMapper)){
+ TObjectId2TupleIdMap aDataObjectId2PointIdMap;
+ GetObjectId2TupleIdMap(theDataPointMapper, aDataObjectId2PointIdMap);
+
+ vtkCellData *aCellData = theInput->GetCellData();
+ vtkCellData *anOutputCellData = theOutput->GetCellData();
+ anOutputCellData->CopyAllocate(aCellData);
+
+ vtkIdList *aCellIds = vtkIdList::New();
+ int aNbCells = theInput->GetNumberOfCells();
+ theOutput->Allocate(aNbCells);
+ for(int aCellId = 0; aCellId < aNbCells; aCellId++){
+ aCellIds->Reset();
+ vtkCell *aCell = theInput->GetCell(aCellId);
+ vtkIdType aNbPointIds = aCell->PointIds->GetNumberOfIds();
+ for(vtkIdType anId = 0; anId < aNbPointIds; anId++){
+ vtkIdType aPointId = aCell->GetPointIds()->GetId(anId);
+ int* aPointer = theGeometryPointMapper->GetPointer(aPointId * 2);
+ TCellId aCellId = *aPointer;
+ TEntityId anEntityId = *(aPointer + 1);
+ TObjectId anObjectId(aCellId, anEntityId);
+ TObjectId2TupleIdMap::iterator anIter = aDataObjectId2PointIdMap.find(anObjectId);
+ if(anIter != aDataObjectId2PointIdMap.end()){
+ aPointId = anIter->second;
+ aCellIds->InsertNextId(aPointId);
+ }else
+ goto PASS_INSERT_NEXT_CELL;
+ }
+ {
+ vtkIdType aCellType = theInput->GetCellType(aCellId);
+ vtkIdType aNewCellId = theOutput->InsertNextCell(aCellType, aCellIds);
+ anOutputCellData->CopyData(aCellData, aCellId, aNewCellId);
+ }
+ PASS_INSERT_NEXT_CELL:
+ continue;
}
+ aCellIds->Delete();
- vtkUnstructuredGrid* aUnstructuredScalars = dynamic_cast<vtkUnstructuredGrid*>(aInputScalars);
- if(aUnstructuredScalars)
- anOutput->SetPoints(aUnstructuredScalars->GetPoints());
-
- anOutput->GetPointData()->ShallowCopy(aInputScalars->GetPointData());
-
- // Calculate output cells
- int nbCells=0;
- TSortedArray aCellIdsForCopy;
- GetIdsForCopy(anInput,aPointsIds,aCellIdsForCopy);
- aPointsIds->Delete();
- nbCells = aCellIdsForCopy.size();
-
- // copy cells to output
- anOutput->Allocate(nbCells);
-
- if(nbCells>0)
- CopyElementsToOutput(anInput,
- nbCells,
- aCellIdsForCopy,
- anObj2VTKGeometryMap,
- anOutput);
- return true;
+ vtkPointSet* aScalarsDataSet = dynamic_cast<vtkPointSet*>(theScalarsDataSet);
+ theOutput->SetPoints(aScalarsDataSet->GetPoints());
+ }else{
+ theOutput->CopyStructure(theInput);
+ theOutput->GetCellData()->ShallowCopy(theInput->GetCellData());
}
-
+ theOutput->GetPointData()->ShallowCopy(theScalarsDataSet->GetPointData());
}
-
- return false;
}
+
+//---------------------------------------------------------------
void
VISU_MergeFilter
::SetMergingInputs(bool theIsMergingInputs)
Modified();
}
+
+//---------------------------------------------------------------
bool
VISU_MergeFilter
::IsMergingInputs()
}
+//---------------------------------------------------------------
void VISU_MergeFilter::Execute()
{
VISU::TTimerLog aTimerLog(MYDEBUG,"VISU_MergeFilter::Execute");
vtkUnstructuredGrid *anInput = this->GetInput();
vtkUnstructuredGrid *anOutput = this->GetOutput();
-
- vtkDataSet* aInputScalars = this->GetScalars();
- int nbPointsInScalars = aInputScalars->GetNumberOfPoints();
- int nbPointsInGeometr = anInput->GetNumberOfPoints();
- vtkCellData *aCellData = anInput->GetCellData();
-
- vtkDataArray* aScalarsOnCellsArray = NULL;
- if(aInputScalars->GetCellData())
- aScalarsOnCellsArray = aInputScalars->GetCellData()->GetArray("VISU_FIELD");
-
- vtkDataArray* aScalarsOnPointsArray = NULL;
- if(aInputScalars->GetPointData())
- aScalarsOnPointsArray = aInputScalars->GetPointData()->GetArray("VISU_FIELD");
-
- vtkDataArray *aCellMapper = aCellData->GetArray("VISU_CELLS_MAPPER");
- vtkIntArray *aGeometryCellMapper = dynamic_cast<vtkIntArray*>(aCellMapper);
-
- if (aGeometryCellMapper && aScalarsOnCellsArray && (nbPointsInScalars == nbPointsInGeometr)){
- if(MergeGeometryCellsAndDataOnCells())
- return;
- } else if (aGeometryCellMapper && aScalarsOnPointsArray && (nbPointsInScalars == nbPointsInGeometr)){
- if(MergeGeometryCellsAndDataOnAllPoints())
- return;
- } else if (aGeometryCellMapper && (nbPointsInScalars < nbPointsInGeometr)) {
- if(MergeGeometryCellsAndDataOnNotAllPoints())
- return;
+ if(IsMergingInputs()){
+ vtkCellData *aCellData = anInput->GetCellData();
+ if(vtkDataArray *aCellMapper = aCellData->GetArray("VISU_CELLS_MAPPER")){
+
+ bool anIsDataOnCells = false;
+ if(vtkDataSet* aDataSet = GetScalars())
+ if(vtkCellData* aCellData = aDataSet->GetCellData())
+ anIsDataOnCells = (aCellData->GetArray("VISU_FIELD") != NULL);
+
+ if(anIsDataOnCells){
+ vtkIntArray *aGeometryCellMapper = dynamic_cast<vtkIntArray*>(aCellMapper);
+
+ vtkIntArray* aDataCellMapper = GetIDMapper(this->FieldList,
+ TGetCellData(),
+ "VISU_CELLS_MAPPER");
+ CopyDataOnCells(anInput,
+ aGeometryCellMapper,
+ aDataCellMapper,
+ this->GetScalars(),
+ this->GetVectors(),
+ this->GetNormals(),
+ this->GetTCoords(),
+ this->GetTensors(),
+ this->FieldList,
+ anOutput);
+ }else{
+ vtkPointData *aPointData = anInput->GetPointData();
+ vtkDataArray *aPointMapper = aPointData->GetArray("VISU_POINTS_MAPPER");
+ vtkIntArray *aGeometryPointMapper = dynamic_cast<vtkIntArray*>(aPointMapper);
+
+ vtkIntArray* aDataPointMapper = GetIDMapper(this->FieldList,
+ TGetPointData(),
+ "VISU_POINTS_MAPPER");
+ CopyDataOnPoints(anInput,
+ aGeometryPointMapper,
+ aDataPointMapper,
+ this->GetScalars(),
+ this->GetVectors(),
+ this->GetNormals(),
+ this->GetTCoords(),
+ this->GetTensors(),
+ this->FieldList,
+ anOutput);
+ }
+ }
+ }else{
+ anOutput->CopyStructure(anInput);
+ this->BasicExecute(anOutput);
}
-
- anOutput->CopyStructure(anInput);
- this->BasicExecute(anOutput);
}
+
+//---------------------------------------------------------------
namespace
{
+ //---------------------------------------------------------------
+ typedef vtkDataArray* (vtkDataSetAttributes::* TGetAttribute)();
+ typedef int (vtkDataSetAttributes::* TSetAttribute)(vtkDataArray*);
+
+ inline
+ void
+ CopyArray(vtkDataArray* theDataArray,
+ vtkDataSetAttributes* theOutput,
+ TSetAttribute theSetAttribute,
+ vtkIdType theFixedNbTuples)
+ {
+ if(theDataArray){
+ vtkIdType aNbTuples = theDataArray->GetNumberOfTuples();
+ if(theFixedNbTuples == aNbTuples)
+ (theOutput->*theSetAttribute)(theDataArray);
+ }
+ }
+
+
+ //---------------------------------------------------------------
+ inline
+ void
+ CopyAttribute(vtkDataSetAttributes* theInput,
+ TGetAttribute theGetAttribute,
+ vtkDataSetAttributes* theOutput,
+ TSetAttribute theSetAttribute,
+ vtkIdType theFixedNbTuples)
+ {
+ CopyArray((theInput->*theGetAttribute)(),
+ theOutput, theSetAttribute,
+ theFixedNbTuples);
+ }
+
+
+ //---------------------------------------------------------------
inline
void
CopyDataSetAttribute(vtkDataSet *theInput,
theNbCells);
}
+
+ //---------------------------------------------------------------
+ inline
+ void
+ CopyField(vtkDataSetAttributes* theInput,
+ const char* theFieldName,
+ vtkDataSetAttributes* theOutput,
+ vtkIdType theFixedNbTuples)
+ {
+ CopyArray(theInput->GetArray(theFieldName),
+ theOutput,
+ &vtkDataSetAttributes::AddArray,
+ theFixedNbTuples);
+ }
+
+
+ //---------------------------------------------------------------
inline
void
CopyDataSetField(vtkDataSet* theInput,
vtkIdType theNbPoints,
vtkIdType theNbCells)
{
- CopyField(theInput->GetPointData(), theFieldName,
- theOutput->GetPointData(),
- theNbPoints);
- CopyField(theInput->GetCellData(), theFieldName,
- theOutput->GetCellData(),
- theNbCells);
+ if(theInput){
+ CopyField(theInput->GetPointData(),
+ theFieldName,
+ theOutput->GetPointData(),
+ theNbPoints);
+ CopyField(theInput->GetCellData(),
+ theFieldName,
+ theOutput->GetCellData(),
+ theNbCells);
+ }
}
}
-void VISU_MergeFilter::BasicExecute(vtkDataSet *output)
+
+//---------------------------------------------------------------
+void
+VISU_MergeFilter
+::BasicExecute(vtkDataSet *output)
{
vtkIdType numPts, numCells;
numCells);
}
}
+
+
+//---------------------------------------------------------------
static VISU_MergeFilter *New();
vtkTypeMacro(VISU_MergeFilter,vtkUnstructuredGridToUnstructuredGridFilter);
+ virtual
+ unsigned long
+ GetMTime();
+
// Description:
// Specify object from which to extract geometry information.
void SetGeometry(vtkUnstructuredGrid *input) {this->SetInput(input);};
bool myIsMergingInputs;
private:
- bool MergeGeometryCellsAndDataOnCells();
- bool MergeGeometryCellsAndDataOnAllPoints();
- bool MergeGeometryCellsAndDataOnNotAllPoints();
-
VISU_MergeFilter(const VISU_MergeFilter&); // Not implemented.
void operator=(const VISU_MergeFilter&); // Not implemented.
};
#include "VTKViewer_ShrinkFilter.h"
#include "VTKViewer_GeometryFilter.h"
#include "VTKViewer_PassThroughFilter.h"
+#include "VISU_ConvertorUtils.hxx"
#include <stdexcept>
#include <sstream>
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);
}
VISU_SphereWidget.hxx \
VISU_WidgetCtrl.hxx \
VISU_ScalarMapOnDeformedShapePL.hxx \
- VISU_PrsMergerPL.hxx
+ VISU_PrsMergerPL.hxx \
+ VISU_CellDataToPointData.hxx
# Libraries targets
VISU_WidgetCtrl.cxx \
VISU_ScalarBarCtrl.cxx \
VISU_ScalarMapOnDeformedShapePL.cxx \
- VISU_PrsMergerPL.cxx
+ VISU_PrsMergerPL.cxx \
+ VISU_CellDataToPointData.cxx
# Executables targets
#include "VISU_Convertor.hxx"
#include "VISU_MeshPL.hxx"
#include "VISU_ScalarMapPL.hxx"
+#include "VISU_PrsMergerPL.hxx"
#include "VISU_IsoSurfacesPL.hxx"
#include "VISU_CutPlanesPL.hxx"
#include "VISU_CutLinesPL.hxx"
#include "VISU_DeformedShapePL.hxx"
+#include "VISU_ScalarMapOnDeformedShapePL.hxx"
#include "VISU_VectorsPL.hxx"
#include "VISU_StreamLinesPL.hxx"
#include "VISU_GaussPointsPL.hxx"
#include "VISU_Plot3DPL.hxx"
-typedef VISU_GaussPointsPL TPresent;
+typedef VISU_DeformedShapePL TPresent;
#include <vtkUnstructuredGrid.h>
#include <vtkDataSetMapper.h>
iren->SetRenderWindow(renWin);
VISU_Convertor* aConvertor = CreateConvertor(argv[1]);
aConvertor->BuildEntities();
+ aConvertor->BuildGroups();
aConvertor->BuildFields();
aConvertor->BuildMinMax();
const VISU::TMeshMap& aMeshMap = aConvertor->GetMeshMap();
TPresent* aPresent = TPresent::New();
VISU::PIDMapper anIDMapper;
- if(anEntity != VISU::NODE_ENTITY){
- VISU::PGaussPtsIDMapper aGaussPtsIDMapper = aConvertor->GetTimeStampOnGaussPts(aMeshName,anEntity,aFieldName,aTimeStamp);
- aPresent->SetGaussPtsIDMapper(aGaussPtsIDMapper);
- }else{
+ if(anEntity == VISU::NODE_ENTITY){
continue;
+ //VISU::PGaussPtsIDMapper aGaussPtsIDMapper = aConvertor->GetTimeStampOnGaussPts(aMeshName,anEntity,aFieldName,aTimeStamp);
+ //aPresent->SetGaussPtsIDMapper(aGaussPtsIDMapper);
+ }else{
VISU::PIDMapper anIDMapper = aConvertor->GetTimeStampOnMesh(aMeshName,anEntity,aFieldName,aTimeStamp);
aPresent->SetIDMapper(anIDMapper);
}
aPresent->Build();
aPresent->Init();
-
- char aMainTexture[80];
- strcpy( aMainTexture, getenv( "VISU_ROOT_DIR" ) );
- strcat( aMainTexture, "/share/salome/resources/visu/sprite_texture.vti" );
- //cout << aMainTexture << endl;
-
- char anAlphaTexture[80];
- strcpy( anAlphaTexture, getenv( "VISU_ROOT_DIR" ) );
- strcat( anAlphaTexture, "/share/salome/resources/visu/sprite_alpha.vti" );
- //cout << anAlphaTexture << endl;
-
- vtkSmartPointer<vtkImageData> aTextureValue = VISU_GaussPointsPL::MakeTexture( aMainTexture, anAlphaTexture );
- aPresent->SetImageData( aTextureValue.GetPointer() );
-
aPresent->Update();
+ //aPresent->SetScalars(aPresent->GetInput());
+ //aPresent->Build();
+ //aPresent->Init();
+ //aPresent->RemoveAllGeom();
+ //{
+ // VISU::PIDMapper anIDMapper = aConvertor->GetMeshOnGroup(aMeshName,
+ // //"TUYAU ");
+ // "groupe1");
+ // VISU_MeshPL* aGeomPresent = VISU_MeshPL::New();
+ // aGeomPresent->SetIDMapper(anIDMapper);
+ // aGeomPresent->Build();
+ // aPresent->AddBackGeometry(aGeomPresent);
+ //}
+ aPresent->Update();
+
+// char aMainTexture[80];
+// strcpy( aMainTexture, getenv( "VISU_ROOT_DIR" ) );
+// strcat( aMainTexture, "/share/salome/resources/visu/sprite_texture.vti" );
+// //cout << aMainTexture << endl;
+//
+// char anAlphaTexture[80];
+// strcpy( anAlphaTexture, getenv( "VISU_ROOT_DIR" ) );
+// strcat( anAlphaTexture, "/share/salome/resources/visu/sprite_alpha.vti" );
+// //cout << anAlphaTexture << endl;
+//
+// vtkSmartPointer<vtkImageData> aTextureValue = VISU_GaussPointsPL::MakeTexture( aMainTexture, anAlphaTexture );
+// aPresent->SetImageData( aTextureValue.GetPointer() );
+//
+// aPresent->Update();
vtkActor* anActor = vtkActor::New();
anActor->SetMapper(aPresent->GetMapper());
--- /dev/null
+// VISU OBJECT : interactive object for VISU entities implementation
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+// File: VISU_CellDataToPointData.cxx
+// Author: Alexey PETROV
+// Module : VISU
+
+
+#include "VISU_CellDataToPointData.hxx"
+
+#include <vtkCellData.h>
+#include <vtkDataSet.h>
+#include <vtkIdList.h>
+#include <vtkObjectFactory.h>
+#include <vtkPointData.h>
+
+vtkStandardNewMacro(VISU_CellDataToPointData);
+
+VISU_CellDataToPointData
+::VISU_CellDataToPointData()
+{}
+
+#define VTK_MAX_CELLS_PER_POINT 4096
+
+void VISU_CellDataToPointData::Execute()
+{
+ vtkIdType cellId, ptId;
+ vtkIdType numCells, numPts;
+ vtkDataSet *input= this->GetInput();
+ vtkDataSet *output= this->GetOutput();
+ vtkCellData *inPD=input->GetCellData();
+ vtkPointData *outPD=output->GetPointData();
+ vtkIdList *cellIds;
+ float weight;
+ float *weights;
+
+ vtkDebugMacro(<<"Mapping cell data to point data");
+
+ // First, copy the input to the output as a starting point
+ output->CopyStructure( input );
+
+ cellIds = vtkIdList::New();
+ cellIds->Allocate(VTK_MAX_CELLS_PER_POINT);
+
+ if ( (numPts=input->GetNumberOfPoints()) < 1 )
+ {
+ vtkErrorMacro(<<"No input point data!");
+ cellIds->Delete();
+ return;
+ }
+ weights = new float[VTK_MAX_CELLS_PER_POINT];
+
+ outPD->CopyAllocate(inPD,numPts);
+
+ int abort=0;
+ vtkIdType progressInterval=numPts/20 + 1;
+ for (ptId=0; ptId < numPts && !abort; ptId++)
+ {
+ if ( !(ptId % progressInterval) )
+ {
+ this->UpdateProgress((float)ptId/numPts);
+ abort = GetAbortExecute();
+ }
+
+ input->GetPointCells(ptId, cellIds);
+ numCells = cellIds->GetNumberOfIds();
+ if ( numCells > 0 )
+ {
+ weight = 1.0 / numCells;
+ for (cellId=0; cellId < numCells; cellId++)
+ {
+ weights[cellId] = weight;
+ }
+ outPD->InterpolatePoint(inPD, ptId, cellIds, weights);
+ }
+ else
+ {
+ outPD->NullPoint(ptId);
+ }
+ }
+
+ // Pass the point data first. The fields and attributes
+ // which also exist in the cell data of the input will
+ // be missed
+ {
+ vtkPointData* anInputPointData = input->GetPointData();
+ vtkPointData* anOutputPointData = output->GetPointData();
+
+ int aNbAttributeTypes = vtkDataSetAttributes::NUM_ATTRIBUTES;
+ for(int anAttribueType = 0; anAttribueType < aNbAttributeTypes; anAttribueType++){
+ if(vtkDataArray* anInputAttribute = anInputPointData->GetAttribute(anAttribueType)){
+ if(anOutputPointData->GetAttribute(anAttribueType) == NULL){
+ int anArrayId = anOutputPointData->AddArray(anInputAttribute);
+ anOutputPointData->SetActiveAttribute(anArrayId, anAttribueType);
+ }
+ }
+ }
+
+ int aNbOfInputArrays = anInputPointData->GetNumberOfArrays();
+ for(int anArrayId = 0; anArrayId < aNbOfInputArrays; anArrayId++){
+ if(anInputPointData->IsArrayAnAttribute(anArrayId) < 0){
+ vtkDataArray* anInputArray = anInputPointData->GetArray(anArrayId);
+ if(anOutputPointData->GetArray(anInputArray->GetName()) == NULL)
+ anOutputPointData->AddArray(anInputArray);
+ }
+ }
+ }
+
+ if ( this->GetPassCellData() )
+ {
+ output->GetCellData()->PassData(input->GetCellData());
+ }
+
+ cellIds->Delete();
+ delete [] weights;
+}
--- /dev/null
+// VISU OBJECT : interactive object for VISU entities implementation
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+// File: VISU_CellDataToPointData.hxx
+// Author: Alexey PETROV
+// Module : VISU
+
+
+#ifndef VISU_CellDataToPointData_HeaderFile
+#define VISU_CellDataToPointData_HeaderFile
+
+#include <vtkCellDataToPointData.h>
+
+class VISU_CellDataToPointData : public vtkCellDataToPointData
+{
+public:
+ static VISU_CellDataToPointData *New();
+ vtkTypeMacro(VISU_CellDataToPointData, vtkCellDataToPointData);
+
+protected:
+ VISU_CellDataToPointData();
+
+ void Execute();
+
+private:
+ VISU_CellDataToPointData(const VISU_CellDataToPointData&); // Not implemented.
+ void operator=(const VISU_CellDataToPointData&); // Not implemented.
+};
+
+#endif
+
+
vtkFloatingPointType aPosition = myPosition;
if(myCondition){
vtkFloatingPointType aDir[3], aBounds[6], aBoundPrj[3];
- GetInput2()->GetBounds(aBounds);
+ GetMergedInput()->GetBounds(aBounds);
GetDir(aDir,myAng[0],myBasePlane[0]);
GetBoundProject(aBoundPrj,aBounds,aDir);
aPosition = aBoundPrj[0] + aBoundPrj[2]*myDisplacement[0];
vtkAppendPolyData *anAppendPolyData = vtkAppendPolyData::New();
//Build base plane
vtkFloatingPointType aDir[2][3], aBaseBounds[6];
- GetInput2()->GetBounds(aBaseBounds);
+ vtkPointSet* aPointSet = GetMergedInput();
+ aPointSet->GetBounds(aBaseBounds);
GetDir(aDir[0],myAng[0],myBasePlane[0]);
- vtkUnstructuredGrid* anUnstructuredGrid =
- myFieldTransform->GetUnstructuredGridOutput();
- CutWithPlanes(anAppendPolyData,anUnstructuredGrid,1,aDir[0],aBaseBounds,
- myPosition,myCondition,myDisplacement[0]);
+ CutWithPlanes(anAppendPolyData,
+ aPointSet,
+ 1,
+ aDir[0],
+ aBaseBounds,
+ myPosition,
+ myCondition,
+ myDisplacement[0]);
//Build lines
vtkFloatingPointType aBounds[6];
vtkDataSet *aDataSet = anAppendPolyData->GetOutput();
aDataSet->Update();
if(aDataSet->GetNumberOfCells() == 0)
- aDataSet = anUnstructuredGrid;
+ aDataSet = aPointSet;
aDataSet->GetBounds(aBounds);
GetDir(aDir[1],myAng[1],myBasePlane[1]);
- VISU_CutPlanesPL::CutWithPlanes(myAppendPolyData,aDataSet,GetNbParts(),aDir[1],aBounds,
- myPartPosition,myPartCondition,myDisplacement[1]);
+ VISU_CutPlanesPL::CutWithPlanes(myAppendPolyData,
+ aDataSet,
+ GetNbParts(),
+ aDir[1],
+ aBounds,
+ myPartPosition,
+ myPartCondition,
+ myDisplacement[1]);
anAppendPolyData->Register(myAppendPolyData);
anAppendPolyData->Delete();
//Calculate values for building of table
myAng[0][0] = myAng[0][1] = myAng[0][2] = 0.0;
}
-VISU_ScalarMapPL::THook*
+VISU_ScalarMapPL::TInsertCustomPL*
VISU_CutPlanesPL
-::DoHook()
+::InsertCustomPL()
{
return myAppendPolyData->GetOutput();
}
VISU_CutPlanesPL
::Update()
{
+ Superclass::Update();
+
ClearAppendPolyData(myAppendPolyData);
SetPartPosition();
+
vtkFloatingPointType aDir[3];
GetDir(aDir,myAng[0],myBasePlane[0]);
- vtkFloatingPointType aBounds[6];
- GetInput2()->GetBounds(aBounds);
- vtkDataSet* aDataSet = myFieldTransform->GetUnstructuredGridOutput();
- CutWithPlanes(myAppendPolyData,aDataSet,myNbParts,aDir,aBounds,
- myPartPosition,myPartCondition,myDisplacement[0]);
- Superclass::Update();
+ vtkFloatingPointType aBounds[6];
+ vtkPointSet* aMergedInput = GetMergedInput();
+ aMergedInput->GetBounds(aBounds);
+
+ CutWithPlanes(myAppendPolyData,
+ aMergedInput,
+ myNbParts,
+ aDir,
+ aBounds,
+ myPartPosition,
+ myPartCondition,
+ myDisplacement[0]);
}
void
vtkFloatingPointType aPosition = myPartPosition[thePartNumber];
if(myPartCondition[thePartNumber]){
vtkFloatingPointType aDir[3], aBounds[6], aBoundPrj[3];
- GetInput2()->GetBounds(aBounds);
+ GetMergedInput()->GetBounds(aBounds);
GetDir(aDir,myAng[theNum],myBasePlane[theNum]);
GetBoundProject(aBoundPrj,aBounds,aDir);
if (myNbParts > 1){
vtkFloatingPointType theDisplacement);
protected:
virtual
- THook*
- DoHook();
+ TInsertCustomPL*
+ InsertCustomPL();
void
SetPartPosition(int theNum = 0);
#include "VISU_DeformedShapePL.hxx"
-#include "VISU_PipeLineUtils.hxx"
+#include "VISU_CellDataToPointData.hxx"
#include "VTKViewer_Transform.h"
+#include "VISU_PipeLineUtils.hxx"
#include <vtkWarpVector.h>
::VISU_DeformedShapePL()
{
myWarpVector = vtkWarpVector::New();
- myCellDataToPointData = vtkCellDataToPointData::New();
+ myCellDataToPointData = VISU_CellDataToPointData::New();
}
VISU_DeformedShapePL
if(VISU_DeformedShapePL *aPipeLine = dynamic_cast<VISU_DeformedShapePL*>(thePipeLine)){
SetScale(aPipeLine->GetScale());
}
- TSupperClass::ShallowCopy(thePipeLine);
+ Superclass::ShallowCopy(thePipeLine);
}
vtkFloatingPointType
VISU_DeformedShapePL
::GetScaleFactor(vtkDataSet* theDataSet)
{
- if(!theDataSet) return 0.0;
+ if(!theDataSet)
+ return 0.0;
theDataSet->Update();
int aNbCells = theDataSet->GetNumberOfCells();
int aNbPoints = theDataSet->GetNumberOfPoints();
VISU_DeformedShapePL
::Init()
{
- TSupperClass::Init();
+ Superclass::Init();
+
vtkFloatingPointType aScalarRange[2];
GetSourceRange(aScalarRange);
- vtkDataSet* aDataSet = GetInput2();
- //vtkDataSet* aDataSet = GetScalars()->GetInput();
+ vtkDataSet* aDataSet = GetMergedInput();
vtkFloatingPointType aScaleFactor = VISU_DeformedShapePL::GetScaleFactor( aDataSet );
static double EPS = 1.0 / VTK_LARGE_FLOAT;
SetScale(0.0);
}
-VISU_ScalarMapPL::THook*
+void
VISU_DeformedShapePL
-::DoHook()
+::Build()
{
- VISU::CellDataToPoint(myWarpVector,myCellDataToPointData,GetInput2(),myFieldTransform);
- return myWarpVector->GetOutput();
+ Superclass::Build();
+
+ VISU::CellDataToPoint(myWarpVector,
+ myCellDataToPointData,
+ GetMergedInput());
+ //{
+ // std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-myMergeFilter3-.vtk";
+ // VISU::WriteToFile(dynamic_cast<vtkUnstructuredGrid*>(GetMergedInput()), aFileName);
+ //}
+ //{
+ // std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-myMergeFilter3.vtk";
+ // VISU::WriteToFile(myCellDataToPointData->GetUnstructuredGridOutput(), aFileName);
+ //}
+ //{
+ // std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-myMergeFilter3+.vtk";
+ // VISU::WriteToFile(myWarpVector->GetUnstructuredGridOutput(), aFileName);
+ //}
}
-void
+VISU_ScalarMapPL::TInsertCustomPL*
VISU_DeformedShapePL
-::Update()
+::InsertCustomPL()
{
- TSupperClass::Update();
+ return myWarpVector->GetOutput();
}
void
VISU_DeformedShapePL
::SetMapScale(vtkFloatingPointType theMapScale)
{
- TSupperClass::SetMapScale(theMapScale);
+ Superclass::SetMapScale(theMapScale);
myWarpVector->SetScaleFactor(myScaleFactor*theMapScale);
Modified();
#include "VISU_PrsMergerPL.hxx"
-class vtkCellDataToPointData;
+class VISU_CellDataToPointData;
class SALOME_Transform;
+
class vtkWarpVector;
class VISU_DeformedShapePL : public VISU_PrsMergerPL
{
- typedef VISU_PrsMergerPL TSupperClass;
-
protected:
VISU_DeformedShapePL();
VISU_DeformedShapePL(const VISU_DeformedShapePL&);
~VISU_DeformedShapePL();
public:
- vtkTypeMacro(VISU_DeformedShapePL,TSupperClass);
+ vtkTypeMacro(VISU_DeformedShapePL, VISU_PrsMergerPL);
static
VISU_DeformedShapePL*
virtual
void
- Update();
+ Build();
virtual
void
protected:
virtual
- THook*
- DoHook();
+ TInsertCustomPL*
+ InsertCustomPL();
vtkFloatingPointType myScaleFactor;
vtkWarpVector *myWarpVector;
- vtkCellDataToPointData* myCellDataToPointData;
+ VISU_CellDataToPointData* myCellDataToPointData;
};
#include "VISU_GaussPointsPL.hxx"
#include "VISU_DeformedShapePL.hxx"
-#include "VISU_PipeLineUtils.hxx"
+#include "VISU_CellDataToPointData.hxx"
#include "SALOME_ExtractGeometry.h"
#include "VISU_DeformedShapePL.hxx"
#include "VISU_OpenGLPointSpriteMapper.hxx"
#include "VTKViewer_PassThroughFilter.h"
+#include "VISU_PipeLineUtils.hxx"
+
#include <vtkPointSource.h>
#include <vtkElevationFilter.h>
#include <vtkImageGaussianSource.h>
myGeomFilter = vtkGeometryFilter::New();
myWarpVector = vtkWarpVector::New();
- myCellDataToPointData = vtkCellDataToPointData::New();
+ myCellDataToPointData = VISU_CellDataToPointData::New();
myCellDataToPointData->SetPassCellData(true);
myGlyph = vtkGlyph3D::New();
myGlyph->SetColorModeToColorByScalar();
myGlyph->ClampingOn();
- myExtractor->SetInput( myExtractGeometry->GetOutput() );
- myFieldTransform->SetInput( myExtractor->GetOutput() );
-
myCellDataToPointData->SetInput( myFieldTransform->GetUnstructuredGridOutput() );
mySphereSource = vtkSphereSource::New();
{
if(GetInput()){
if(!myPSMapper->GetInput()){
- GetInput2()->Update();
+ GetClippedInput()->Update();
Build();
Init();
}
#include <vector>
+class SALOME_Transform;
+class VISU_CellDataToPointData;
class VTKViewer_PassThroughFilter;
class VISU_OpenGLPointSpriteMapper;
class vtkImageData;
class vtkPointSet;
-class vtkCellDataToPointData;
class vtkWarpVector;
-class SALOME_Transform;
//! Pipeline for the Gauss Points presentation.
/*!
bool myIsDeformed;
vtkFloatingPointType myScaleFactor;
vtkWarpVector *myWarpVector;
- vtkCellDataToPointData* myCellDataToPointData;
+ VISU_CellDataToPointData* myCellDataToPointData;
std::vector<VTKViewer_PassThroughFilter*> myPassFilter;
vtkGlyph3D* myGlyph;
#include "VISU_IsoSurfacesPL.hxx"
+#include "VISU_CellDataToPointData.hxx"
#include "VISU_PipeLineUtils.hxx"
#include <vtkContourFilter.h>
::VISU_IsoSurfacesPL()
{
myContourFilter = vtkContourFilter::New();
- myCellDataToPointData = vtkCellDataToPointData::New();
+ myCellDataToPointData = VISU_CellDataToPointData::New();
myIsShrinkable = false;
}
vtkFloatingPointType aRange[2] = {aPipeLine->GetMin(), aPipeLine->GetMax()};
SetRange(aRange);
}
- TSupperClass::ShallowCopy(thePipeLine);
+ Superclass::ShallowCopy(thePipeLine);
}
int
VISU_IsoSurfacesPL
::SetScaling(int theScaling)
{
- TSupperClass::SetScaling(theScaling);
+ Superclass::SetScaling(theScaling);
SetRange(myRange);
}
void
VISU_IsoSurfacesPL
::Init()
{
- TSupperClass::Init();
+ Superclass::Init();
SetNbParts(10);
vtkFloatingPointType aScalarRange[2];
SetRange(aScalarRange);
}
-VISU_ScalarMapPL::THook*
+VISU_ScalarMapPL::TInsertCustomPL*
VISU_IsoSurfacesPL
-::DoHook()
+::InsertCustomPL()
{
- VISU::CellDataToPoint(myContourFilter,myCellDataToPointData,GetInput2(),myFieldTransform);
return myContourFilter->GetOutput();
}
void
VISU_IsoSurfacesPL
-::Update()
+::Build()
{
- TSupperClass::Update();
+ Superclass::Build();
+
+ VISU::CellDataToPoint(myContourFilter,
+ myCellDataToPointData,
+ GetMergedInput());
}
void
VISU_IsoSurfacesPL
::SetMapScale(vtkFloatingPointType theMapScale)
{
- TSupperClass::SetMapScale(theMapScale);
+ Superclass::SetMapScale(theMapScale);
vtkFloatingPointType aRange[2] = {GetMax() - theMapScale*(GetMax()-GetMin()), GetMax()};
vtkFloatingPointType aNewRange[2] = {aRange[0], aRange[1]};
#include "VISU_PrsMergerPL.hxx"
+class VISU_CellDataToPointData;
+
class vtkContourFilter;
-class vtkCellDataToPointData;
class VISU_IsoSurfacesPL : public VISU_PrsMergerPL
{
- typedef VISU_ScalarMapPL TSupperClass;
-
protected:
VISU_IsoSurfacesPL();
VISU_IsoSurfacesPL(const VISU_IsoSurfacesPL&);
~VISU_IsoSurfacesPL();
public:
- vtkTypeMacro(VISU_IsoSurfacesPL,TSupperClass);
+ vtkTypeMacro(VISU_IsoSurfacesPL, VISU_PrsMergerPL);
static
VISU_IsoSurfacesPL*
virtual
void
- Update();
+ Build();
virtual
- THook*
- DoHook();
+ TInsertCustomPL*
+ InsertCustomPL();
virtual
void
protected:
int myNbParts;
vtkFloatingPointType myRange[2];
- vtkCellDataToPointData* myCellDataToPointData;
+ VISU_CellDataToPointData* myCellDataToPointData;
vtkContourFilter *myContourFilter;
};
void VISU_MeshPL::Build()
{
- myMapper->SetInput(GetInput2());
+ myMapper->SetInput(GetClippedInput());
}
void VISU_MeshPL::Init()
GetImplicitFunction()->Delete();
}
-TInput*
+VISU_PipeLine::TInput*
VISU_PipeLine
::GetInput() const
{
return GetMapper()->GetInput();
}
-TInput*
+VISU_PipeLine::TInput*
VISU_PipeLine
-::GetInput2() const
+::GetClippedInput()
{
- vtkUnstructuredGrid* aDataSet = myExtractGeometry->GetOutput();
- aDataSet->Update();
- return aDataSet;
+ if(myExtractGeometry->GetInput())
+ myExtractGeometry->Update();
+ return myExtractGeometry->GetOutput();
}
void
VISU_PipeLine
-::SetInput(TInput* theInput)
+::SetInput(VISU_PipeLine::TInput* theInput)
{
if(theInput)
theInput->Update();
{
if(GetInput()){
if(!myMapper->GetInput()){
- GetInput2()->Update();
+ GetClippedInput()->Update();
Build();
}
myMapper->Update();
// Check, that at least one cell present after clipping.
// This check was introduced because of bug IPAL8849.
- vtkUnstructuredGrid* aClippedGrid = GetInput2();
+ vtkUnstructuredGrid* aClippedGrid = GetClippedInput();
if (aClippedGrid->GetNumberOfCells() < 1) {
return false;
}
class SALOME_ExtractGeometry;
-typedef VISU::TVTKOutput TInput;
-class VISU_PipeLine : public vtkObject{
+class VISU_PipeLine : public vtkObject
+{
public:
vtkTypeMacro(VISU_PipeLine,vtkObject);
virtual
SameAs(VISU_PipeLine *thePipeLine);
public:
+ typedef VISU::TVTKOutput TInput;
+
virtual
void
SetInput(TInput* theInput);
virtual
TInput*
- GetInput2() const;
+ GetClippedInput();
virtual
void
#ifndef VISU_PipeLineUtils_HeaderFile
#define VISU_PipeLineUtils_HeaderFile
+#include "VISU_CellDataToPointData.hxx"
#include "VISU_FieldTransform.hxx"
#include "VISU_LookupTable.hxx"
#include "VISU_Extractor.hxx"
#include <vtkDataSetMapper.h>
#include <vtkUnstructuredGrid.h>
-#include <vtkCellDataToPointData.h>
#include <vtkCellCenters.h>
#include <vtkPointData.h>
#include <vtkCellData.h>
const vtkFloatingPointType B[3],
vtkFloatingPointType C[3]); // C = A - B
- template<class TItem>
+ template<class TOutputFilter>
void
- CellDataToPoint(TItem* theTItem,
- vtkCellDataToPointData *theFilter,
- vtkDataSet* theDataSet,
- VISU_FieldTransform *theFieldTransform)
+ CellDataToPoint(TOutputFilter* theOutputFilter,
+ VISU_CellDataToPointData *theCellDataToPointData,
+ vtkPointSet* theDataSet)
{
if(VISU::IsDataOnCells(theDataSet)){
- theFilter->SetInput(theFieldTransform->GetUnstructuredGridOutput());
- theFilter->PassCellDataOn();
- theTItem->SetInput(theFilter->GetUnstructuredGridOutput());
+ theCellDataToPointData->SetInput(theDataSet);
+ theCellDataToPointData->PassCellDataOn();
+ theOutputFilter->SetInput(theCellDataToPointData->GetUnstructuredGridOutput());
}else
- theTItem->SetInput(theFieldTransform->GetUnstructuredGridOutput());
+ theOutputFilter->SetInput(theDataSet);
}
- template<class TItem>
+ template<class TOutputFilter>
void
- ToCellCenters(TItem* theTItem,
- vtkCellCenters *theFilter,
- vtkDataSet* theDataSet,
- VISU_FieldTransform *theFieldTransform)
+ ToCellCenters(TOutputFilter* theOutputFilter,
+ vtkCellCenters *theCellCenters,
+ vtkPointSet* theDataSet)
{
if(VISU::IsDataOnCells(theDataSet)){
- theFilter->SetInput(theFieldTransform->GetUnstructuredGridOutput());
- theFilter->VertexCellsOn();
- theTItem->SetInput(theFilter->GetOutput());
+ theCellCenters->SetInput(theDataSet);
+ theCellCenters->VertexCellsOn();
+ theOutputFilter->SetInput(theCellCenters->GetOutput());
}else
- theTItem->SetInput(theFieldTransform->GetUnstructuredGridOutput());
+ theOutputFilter->SetInput(theDataSet);
}
}
#include "VISU_Plot3DPL.hxx"
#include "VISU_CutPlanesPL.hxx"
+#include "VISU_CellDataToPointData.hxx"
#include "VISU_PipeLineUtils.hxx"
#include <vtkAppendPolyData.h>
#include <vtkCutter.h>
#include <vtkPlane.h>
-#include <vtkCellDataToPointData.h>
#include <vtkGeometryFilter.h>
#include <vtkContourFilter.h>
#include <vtkWarpScalar.h>
vtkStandardNewMacro(VISU_Plot3DPL);
VISU_Plot3DPL::VISU_Plot3DPL():
- myCellDataToPointData(vtkCellDataToPointData::New(),true),
+ myCellDataToPointData(VISU_CellDataToPointData::New(),true),
myAppendPolyData(vtkAppendPolyData::New(),true),
myGeometryFilter(vtkGeometryFilter::New(),true),
myContourFilter(vtkContourFilter::New(),true),
SetContourPrs( aPipeLine->GetIsContourPrs() );
SetNumberOfContours( aPipeLine->GetNumberOfContours() );
}
- TSupperClass::ShallowCopy(thePipeLine);
+ Superclass::ShallowCopy(thePipeLine);
}
VISU_CutPlanesPL::PlaneOrientation
VISU_Plot3DPL::
Init()
{
- TSupperClass::Init();
+ Superclass::Init();
- myOrientation = GetOrientation(GetInput2());
- SetScaleFactor(GetScaleFactor(GetInput2()));
+ myOrientation = GetOrientation(GetMergedInput());
+ SetScaleFactor(GetScaleFactor(GetMergedInput()));
}
-VISU_ScalarMapPL::THook*
+VISU_ScalarMapPL::TInsertCustomPL*
VISU_Plot3DPL::
-DoHook()
+InsertCustomPL()
{
return myAppendPolyData->GetOutput();
}
vtkPolyData* aPolyData = 0;
vtkCutter *aCutPlane = 0;
- vtkUnstructuredGrid* anUnstructuredGrid =
- myFieldTransform->GetUnstructuredGridOutput();
+ vtkPointSet* aPointSet = GetMergedInput();
if ( !IsPlanarInput() )
{
aCutPlane = vtkCutter::New();
- aCutPlane->SetInput(anUnstructuredGrid);
+ aCutPlane->SetInput(aPointSet);
vtkPlane *aPlane = vtkPlane::New();
aPlane->SetOrigin(anOrigin);
}
if ( !aPolyData || aPolyData->GetNumberOfCells() == 0 ) {
- myGeometryFilter->SetInput(anUnstructuredGrid);
+ myGeometryFilter->SetInput(aPointSet);
aPolyData = myGeometryFilter->GetOutput();
aPolyData->Update();
}
myWarpScalar->SetNormal(aPlaneNormal);
- TSupperClass::Update();
+ Superclass::Update();
}
void
void VISU_Plot3DPL::GetBasePlane(vtkFloatingPointType theOrigin[3],
vtkFloatingPointType theNormal[3],
- bool theCenterOrigine ) const
+ bool theCenterOrigine )
{
VISU_CutPlanesPL::GetDir(theNormal,myAngle,myOrientation);
if ( theCenterOrigine ) {
// move theOrigin to the center of aBounds projections to the plane
- GetInput2()->GetBounds(aBounds);
+ GetMergedInput()->GetBounds(aBounds);
vtkFloatingPointType boundPoints[8][3] = {
{aBounds[0],aBounds[2],aBounds[4]},
{aBounds[1],aBounds[2],aBounds[4]},
void VISU_Plot3DPL::SetMapScale(vtkFloatingPointType theMapScale)
{
- TSupperClass::SetMapScale(theMapScale);
+ Superclass::SetMapScale(theMapScale);
if ( myIsContour ) {
vtkFloatingPointType aRange[2];
#include "VISU_PrsMergerPL.hxx"
#include "VISU_CutPlanesPL.hxx"
+class VISU_CellDataToPointData;
+
class vtkWarpScalar;
class vtkContourFilter;
class vtkGeometryFilter;
-class vtkCellDataToPointData;
class VISU_Plot3DPL : public VISU_PrsMergerPL{
- typedef VISU_ScalarMapPL TSupperClass;
protected:
VISU_Plot3DPL();
VISU_Plot3DPL(const VISU_Plot3DPL&);
public:
- vtkTypeMacro(VISU_Plot3DPL,TSupperClass);
+ vtkTypeMacro(VISU_Plot3DPL, VISU_PrsMergerPL);
static VISU_Plot3DPL* New();
virtual ~VISU_Plot3DPL();
void GetBasePlane (vtkFloatingPointType theOrigin[3],
vtkFloatingPointType theNormal[3],
- bool theCenterOrigine = false ) const;
+ bool theCenterOrigine = false );
void GetMinMaxPosition( vtkFloatingPointType& minPos,
vtkFloatingPointType& maxPos ) const;
void SetMapScale(vtkFloatingPointType theMapScale);
protected:
- virtual THook* DoHook();
+ virtual TInsertCustomPL* InsertCustomPL();
vtkFloatingPointType myAngle[3];
bool myIsRelative, myIsContour;
vtkFloatingPointType myPosition, myScaleFactor;
VISU_CutPlanesPL::PlaneOrientation myOrientation;
- TVTKSmartPtr<vtkCellDataToPointData> myCellDataToPointData;
+ TVTKSmartPtr<VISU_CellDataToPointData> myCellDataToPointData;
TVTKSmartPtr<vtkAppendPolyData> myAppendPolyData;
TVTKSmartPtr<vtkGeometryFilter> myGeometryFilter;
TVTKSmartPtr<vtkContourFilter> myContourFilter;
#include "VISU_MergeFilter.hxx"
#include "VISU_PipeLineUtils.hxx"
+#include "VISU_ConvertorDef.hxx"
#include <vtkMapper.h>
#include <vtkDataSet.h>
VISU_PrsMergerPL
::VISU_PrsMergerPL():
myAppendFilter(VISU_AppendFilter::New()),
- myMergeFilter(VISU_MergeFilter::New()),
- myScalars(NULL)
+ myMergeFilter(VISU_MergeFilter::New())
{
myAppendFilter->SetMergingInputs(true);
myAppendFilter->Delete();
::RemoveAllGeom()
{
myMeshGeometryList.clear();
- this->Execute();
}
void
if (MYDEBUG) MESSAGE("ShallowCopy");
VISU_PrsMergerPL* aPipeLine = dynamic_cast<VISU_PrsMergerPL*>(thePipeLine);
if(this == aPipeLine){
- TSupperClass::ShallowCopy(thePipeLine);
+ Superclass::ShallowCopy(thePipeLine);
return;
}
if(aPipeLine){
if (MYDEBUG) MESSAGE("aNbGeoms="<<aNbGeoms);
myMeshGeometryList.clear();
for(int i=0; i<aNbGeoms; i++){
- AddBackGeometry(aPipeLine->GetGeometry(i),false);
+ AddBackGeometry(aPipeLine->GetGeometry(i));
}
- SetScalars(aPipeLine->GetScalars(),true);
}
- TSupperClass::ShallowCopy(thePipeLine);
+ Superclass::ShallowCopy(thePipeLine);
}
bool
VISU_PrsMergerPL
-::SetGeometry(VISU_PipeLine* theGeometry,bool theUpdate)
+::SetGeometry(VISU_PipeLine* theGeometry)
{
if(MYDEBUG) MESSAGE("VISU_PrsMergerPL::SetGeometry()");
myMeshGeometryList.clear();
if(this->checkGeometry(theGeometry)){
myMeshGeometryList.push_back(theGeometry);
if (MYDEBUG) MESSAGE("this->GetGeometry(0)->GetIDMapper()="<<this->GetGeometry(0)->GetIDMapper());
-
- if(theUpdate)
- this->Execute();
-
return true;
} else
return false;
int
VISU_PrsMergerPL
-::AddBackGeometry(VISU_PipeLine* theGeometry,bool theUpdate)
+::AddBackGeometry(VISU_PipeLine* theGeometry)
{
if(MYDEBUG) MESSAGE("VISU_PrsMergerPL::AddBackGeometry() "<<theGeometry);
- if(theGeometry == NULL) return -1;
+ if(theGeometry == NULL)
+ return -1;
int aGeomNum = this->GetGeometryNumber(theGeometry);
if(aGeomNum == -1){
bool aCheckGeom = this->checkGeometry(theGeometry);
if(aCheckGeom){
myMeshGeometryList.push_back(theGeometry);
-
- if(theUpdate)
- this->Execute();
-
- return (myMeshGeometryList.size()-1);
+ return (myMeshGeometryList.size() - 1);
} else {
return -1;
}
for(;aIter != myMeshGeometryList.end();aIter++){
if( myMeshGeometryList[theId] == (*aIter)){
myMeshGeometryList.erase(aIter);
- this->Execute();
break;
}
}
return NULL;
}
-VISU_PipeLine*
-VISU_PrsMergerPL
-::GetScalars()
-{
- return myScalars.GetPointer();
-}
-
int
VISU_PrsMergerPL
::GetNbGeometry()
return myMeshGeometryList.size();
}
-bool
+//=======================================================================
+vtkIdType
VISU_PrsMergerPL
-::SetScalars(VISU_PipeLine* theInput,bool theUpdate)
+::GetNodeObjID(vtkIdType theID)
{
- if(MYDEBUG) MESSAGE("VISU_PrsMergerPL::SetScalars()");
- if ( this->checkScalars( theInput ) ){
- myScalars = theInput;
- VISU_ScalarMapPL* aScalarMap = dynamic_cast<VISU_ScalarMapPL*>(this->GetScalars());
- myScalarRanges = aScalarMap->GetScalarRange();
- if(theUpdate)
- this->Execute();
- return true;
- } else
- return false;
+ return VISU::GetNodeObjID(myMergeFilter->GetOutput(), theID);
}
-void
+vtkIdType
VISU_PrsMergerPL
-::Init()
+::GetNodeVTKID(vtkIdType theID)
{
- Superclass::Init();
- if(MYDEBUG) MESSAGE("VISU_PrsMergerPL::Init() this="<<this);
- this->Execute();
+ return VISU::GetNodeVTKID(myMergeFilter->GetOutput(), theID);
}
-void
+vtkFloatingPointType*
VISU_PrsMergerPL
-::Update()
+::GetNodeCoord(int theObjID)
{
- if(MYDEBUG) MESSAGE("VISU_PrsMergerPL::Update()");
- Superclass::Update();
- Execute();
+ return VISU::GetNodeCoord(myMergeFilter->GetOutput(), theObjID);
}
-void
+//=======================================================================
+vtkIdType
VISU_PrsMergerPL
-::Build()
+::GetElemObjID(vtkIdType theID)
{
- if(MYDEBUG) MESSAGE("VISU_PrsMergerPL::Build()");
- TSupperClass::Build(); // call DoHook method
+ return VISU::GetElemObjID(myMergeFilter->GetOutput(), theID);
}
-void
+vtkIdType
VISU_PrsMergerPL
-::SetInitialRange()
+::GetElemVTKID(vtkIdType theID)
{
- myMapper->UseLookupTableScalarRangeOff();
+ return VISU::GetElemVTKID(myMergeFilter->GetOutput(), theID);
}
-bool
+vtkCell*
VISU_PrsMergerPL
-::checkGeometry(const VISU_PipeLine* thePipeLine)
+::GetElemCell(vtkIdType theObjID)
{
- const VISU::PIDMapper& aMapper = thePipeLine->GetIDMapper();
- int aNbPoints = aMapper->GetVTKOutput()->GetNumberOfPoints();
-// if (this->GetNbGeometry() > 0){
-// const VISU::PIDMapper& aMapper2 = this->GetGeometry(0)->GetIDMapper();
-// int aNbPoints2 = aMapper2->GetVTKOutput()->GetNumberOfPoints();
-// if(aNbPoints2 != aNbPoints)
-// return false;
-// } else if (this->GetScalars()) {
-// const VISU::PIDMapper& aMapper2 = this->GetScalars()->GetIDMapper();
-// int aNbPoints2 = aMapper2->GetVTKOutput()->GetNumberOfPoints();
-// if(aNbPoints2 != aNbPoints)
-// return false;
-// }
- if(aNbPoints < 1)
- return false;
- return true;
+ return VISU::GetElemCell(myMergeFilter->GetOutput(), theObjID);
}
-bool
+//=======================================================================
+void
VISU_PrsMergerPL
-::checkScalars(const VISU_PipeLine* thePipeLine)
+::Build()
{
- const VISU::PIDMapper& aMapper = thePipeLine->GetIDMapper();
- int aNbPoints = aMapper->GetVTKOutput()->GetNumberOfPoints();
-// if (this->GetNbGeometry() > 0){
-// const VISU::PIDMapper& aMapper2 = this->GetGeometry(0)->GetIDMapper();
-// int aNbPoints2 = aMapper2->GetVTKOutput()->GetNumberOfPoints();
-// if(aNbPoints2 != aNbPoints)
-// return false;
-// }
- if(aNbPoints < 1)
- return false;
- return true;
+ Superclass::Build();
+
+ UpdateGeometry();
+
+ myMergeFilter->SetGeometry(myAppendFilter->GetOutput());
+
+ myMergeFilter->SetScalars(GetClippedInput());
+ myMergeFilter->SetVectors(GetClippedInput());
+
+ myMergeFilter->RemoveFields();
+ myMergeFilter->AddField("VISU_FIELD", GetClippedInput());
+ myMergeFilter->AddField("VISU_CELLS_MAPPER", GetClippedInput());
+ myMergeFilter->AddField("VISU_POINTS_MAPPER", GetClippedInput());
}
void
VISU_PrsMergerPL
-::Execute(){
- /* Where are next situations:
- * 1. Timestamp on entity=NODE
- * 1.1 Group Cell - OK
- * 1.2 Group Cell + Point - ERR (remove points groups)
- * 1.3 Group Node - ERR (remove points groups)
- * 2. Timesatamp on entity=CELL
- * 2.1 Group Cell - OK
- * 2.2 Group Point - ERR (remove points groups)
- */
- if(MYDEBUG) MESSAGE("VISU_PrsMergerPL::Execute()");
-
+::UpdateGeometry()
+{
myAppendFilter->RemoveAllInputs();
if(!myMeshGeometryList.empty()){
- const VISU::PIDMapper& aScalarsIDMapper = myScalars->GetIDMapper();
- VISU::TVTKOutput* aScalarsOutput = aScalarsIDMapper->GetVTKOutput();
-
- // copy points to output from input first geometry
-
- VISU::TVTKOutput* aGeomOutput = NULL;
vtkIdType aNbGeoms = this->GetNbGeometry();
for(vtkIdType aGeomId = 0; aGeomId < aNbGeoms; aGeomId++){
VISU_PipeLine* aGeomPipeLine = this->GetGeometry(aGeomId);
const VISU::PIDMapper& aGeomIDMapper = aGeomPipeLine->GetIDMapper();
- aGeomOutput = aGeomIDMapper->GetVTKOutput();
- vtkIdType aNbCells = aGeomOutput->GetNumberOfCells();
-// if(aNbCells > 0)
-// if(aGeomOutput->GetCell(0)->GetCellType() == VTK_VERTEX )
-// continue;
-
+ VISU::TVTKOutput* aGeomOutput = aGeomIDMapper->GetVTKOutput();
myAppendFilter->AddInput(aGeomOutput);
}
-
- myAppendFilter->SetSharedPointsDataSet(aGeomOutput);
- myAppendFilter->Update();
-
- vtkUnstructuredGrid* aGeomDataSet = myAppendFilter->GetOutput();
- myMergeFilter->SetGeometry(aGeomDataSet);
-
- //copy array values
- myMergeFilter->SetScalars(aScalarsOutput);
- myMergeFilter->SetVectors(aScalarsOutput);
-
- myMergeFilter->RemoveFields();
- myMergeFilter->AddField("VISU_FIELD", aScalarsOutput);
- myMergeFilter->AddField("VISU_CELLS_MAPPER", aScalarsOutput);
- myMergeFilter->AddField("VISU_POINTS_MAPPER", aScalarsOutput);
-
- myMergeFilter->Update();
- SetInput(myMergeFilter->GetOutput());
}else{
- if(myScalars != NULL){
- if(VISU_ScalarMapPL* aScalarMap = dynamic_cast<VISU_ScalarMapPL*>(this->GetScalars()))
- SetInput(aScalarMap->GetInput());
- }
+ VISU::TVTKOutput* aScalarsOutput = myFieldTransform->GetUnstructuredGridOutput();
+ myAppendFilter->AddInput(aScalarsOutput);
}
}
+
+void
+VISU_PrsMergerPL
+::Update()
+{
+ Superclass::Update();
+
+ UpdateGeometry();
+ //{
+ // std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-aScalarsOutput.vtk";
+ // VISU::WriteToFile(myFieldTransform->GetUnstructuredGridOutput(), aFileName);
+ //}
+ //{
+ // std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-aGeomDataSet.vtk";
+ // VISU::WriteToFile(myAppendFilter->GetOutput(), aFileName);
+ //}
+ //{
+ // std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-myMergeFilter.vtk";
+ // VISU::WriteToFile(myMergeFilter->GetOutput(), aFileName);
+ //}
+}
+
+VISU_ScalarMapPL::TInsertCustomPL*
+VISU_PrsMergerPL
+::InsertCustomPL()
+{
+ return GetMergedInput();
+}
+
+vtkPointSet*
+VISU_PrsMergerPL
+::GetMergedInput()
+{
+ if(myMergeFilter->GetInput())
+ myMergeFilter->Update();
+ return myMergeFilter->GetOutput();
+}
+
+void
+VISU_PrsMergerPL
+::SetInitialRange()
+{
+ myMapper->UseLookupTableScalarRangeOff();
+}
+
+bool
+VISU_PrsMergerPL
+::checkGeometry(const VISU_PipeLine* thePipeLine)
+{
+ const VISU::PIDMapper& aMapper = thePipeLine->GetIDMapper();
+ int aNbPoints = aMapper->GetVTKOutput()->GetNumberOfPoints();
+ if(aNbPoints < 1)
+ return false;
+ return true;
+}
class VISU_PrsMergerPL : public VISU_ScalarMapPL
{
- typedef VISU_ScalarMapPL TSupperClass;
-
protected:
VISU_PrsMergerPL();
VISU_PrsMergerPL(const VISU_PrsMergerPL&);
typedef TVTKSmartPtr<VISU_PipeLine> TPipeLine;
typedef std::vector<TPipeLine> TPipeLines;
- vtkTypeMacro(VISU_PrsMergerPL,TSupperClass);
+ vtkTypeMacro(VISU_PrsMergerPL, VISU_ScalarMapPL);
static
VISU_PrsMergerPL*
void
ShallowCopy(VISU_PipeLine *thePipeLine);
+ virtual
+ vtkIdType
+ GetNodeObjID(vtkIdType theID);
+
+ virtual
+ vtkIdType
+ GetNodeVTKID(vtkIdType theID);
+
+ virtual
+ vtkFloatingPointType*
+ GetNodeCoord(vtkIdType theObjID);
+
+ virtual
+ vtkIdType
+ GetElemObjID(vtkIdType theID);
+
+ virtual
+ vtkIdType
+ GetElemVTKID(vtkIdType theID);
+
+ virtual
+ vtkCell*
+ GetElemCell(vtkIdType theObjID);
+
/*!
* Add geometry of presentation to myMeshGeometryList.
* \params theGeometry - visu pipeline with geometry.
*/
virtual
bool
- SetGeometry(VISU_PipeLine* theGeometry,bool theUpdate=true);
+ SetGeometry(VISU_PipeLine* theGeometry);
/*!
* Add geometry to back of myMeshGeometryList.
*/
virtual
int
- AddBackGeometry(VISU_PipeLine* theGeometry,bool theUpdate=true);
+ AddBackGeometry(VISU_PipeLine* theGeometry);
/*!
* Get geometry id of myMeshGeometryList.
int
GetNbGeometry();
- /*!
- * Sets scalar values and ids by VISU_ScalarMapPL object.
- * \params theInput - visu pipeline with scalar values
- * \params theUpdate - update pipeline if true.
- * \retval TRUE - if scalars and geometry on the common mesh, esle FALSE.
- */
- virtual
- bool
- SetScalars(VISU_PipeLine* theInput,bool theUpdate=false);
-
- /*!
- * Gets input VISU_ScalarMapPL, which contain scalar values and ids.
- */
- virtual
- VISU_PipeLine*
- GetScalars();
-
- virtual
- void
- Init();
-
virtual
void
Build();
-
+
/*!
* Calculate presentation, by merging of Geometry and Scalar Values.
*/
void SetInitialRange();
protected:
- TPipeLines myMeshGeometryList;
- vtkSmartPointer<VISU_AppendFilter> myAppendFilter;
- vtkSmartPointer<VISU_MergeFilter> myMergeFilter;
-
- vtkFloatingPointType* myScalarRanges;
- TPipeLine myScalars;
+ virtual
+ TInsertCustomPL*
+ InsertCustomPL();
+
+ virtual
+ vtkPointSet*
+ GetMergedInput();
+
+ void
+ UpdateGeometry();
-private:
-
/*!
* Check if thePipeLine and "first element of list myMeshGeometryList" or
* "myScalars", has
bool
checkGeometry(const VISU_PipeLine* thePipeLine);
-
- /*!
- * Check if thePipeLine and first element of list myMeshGeometryList, has
- * common DataPoints (simple check number of points).
- * \retval TRUE - if has common points, esle FALSE.
- */
- bool
- checkScalars(const VISU_PipeLine* thePipeLine);
-
- void
- Execute();
+ TPipeLines myMeshGeometryList;
+ vtkSmartPointer<VISU_AppendFilter> myAppendFilter;
+ vtkSmartPointer<VISU_MergeFilter> myMergeFilter;
};
#endif
#include "VISU_ScalarMapOnDeformedShapePL.hxx"
#include "VISU_DeformedShapePL.hxx"
+
+#include "VISU_CellDataToPointData.hxx"
#include "VISU_MergeFilter.hxx"
#include "VISU_PipeLineUtils.hxx"
#include <vtkWarpVector.h>
#include <vtkUnstructuredGrid.h>
-#include <vtkCellDataToPointData.h>
#include <vtkPointDataToCellData.h>
#include "VISU_Convertor.hxx"
VISU_ScalarMapOnDeformedShapePL
::VISU_ScalarMapOnDeformedShapePL()
{
- myDeformVectors = vtkWarpVector::New();
- myMergeFilter = VISU_MergeFilter::New();
+ myWarpVector = vtkWarpVector::New();
+
+ myMergeScalarsFilter = VISU_MergeFilter::New();
+ myMergeScalarsFilter->SetMergingInputs(true);
+
myExtractorScalars = VISU_Extractor::New();
- myCellDataToPointData = vtkCellDataToPointData::New();
+
+ myCellDataToPointData = VISU_CellDataToPointData::New();
+
+ myScalars = myMergeFilter->GetOutput();
}
/*!
VISU_ScalarMapOnDeformedShapePL
::~VISU_ScalarMapOnDeformedShapePL()
{
- myDeformVectors->UnRegisterAllOutputs();
- myDeformVectors->Delete();
+ myWarpVector->UnRegisterAllOutputs();
+ myWarpVector->Delete();
- myMergeFilter->UnRegisterAllOutputs();
- myMergeFilter->Delete();
+ myMergeScalarsFilter->UnRegisterAllOutputs();
+ myMergeScalarsFilter->Delete();
myExtractorScalars->UnRegisterAllOutputs();
myExtractorScalars->Delete();
myCellDataToPointData->Delete();
}
-/*!
- * Initial method
- */
+//=======================================================================
void
VISU_ScalarMapOnDeformedShapePL
-::Init()
+::Build()
{
- if (GetScalarsUnstructuredGrid() == NULL) SetScalars(GetInput2());
-
- Superclass::Init();
-
- vtkFloatingPointType aScalarRange[2];
- GetSourceRange(aScalarRange);
- static double EPS = 1.0 / VTK_LARGE_FLOAT;
- if(aScalarRange[1] > EPS)
- SetScale(VISU_DeformedShapePL::GetScaleFactor(GetInput2())/aScalarRange[1]);
- else
- SetScale(0.0);
+ Superclass::Build();
- myMapper->SetColorModeToMapScalars();
- myMapper->ScalarVisibilityOn();
+ VISU::CellDataToPoint(myWarpVector,
+ myCellDataToPointData,
+ GetMergedInput());
+
+ // Sets geometry for merge filter
+ myMergeScalarsFilter->SetGeometry(myWarpVector->GetUnstructuredGridOutput());
- // Sets input for field transformation filter
- myFieldTransform->SetInput(myExtractor->GetOutput());
+ UpdateScalars();
+ vtkDataSet* aScalarsDataSet = myExtractorScalars->GetOutput();
+ myMergeScalarsFilter->SetScalars(aScalarsDataSet);
+ myMergeScalarsFilter->AddField("VISU_CELLS_MAPPER", aScalarsDataSet);
+ myMergeScalarsFilter->AddField("VISU_POINTS_MAPPER", aScalarsDataSet);
}
-/*!
- * Build method
- * Building of deformation and puts result to merge filter.
- */
+//=======================================================================
void
VISU_ScalarMapOnDeformedShapePL
-::Build()
+::UpdateScalars()
{
- // Set input for extractor
- myExtractor->SetInput(GetInput2());
-
- VISU::CellDataToPoint(myDeformVectors,myCellDataToPointData,
- GetInput2(),myFieldTransform);
-
- // Sets geometry for merge filter
- myMergeFilter->SetGeometry(myDeformVectors->GetUnstructuredGridOutput());
- myMergeFilter->SetScalars(myExtractorScalars->GetOutput());
- myMergeFilter->AddField("VISU_CELLS_MAPPER", myExtractorScalars->GetOutput());
- myMergeFilter->Update();
+ vtkPointSet* aScalars = GetScalars();
+ vtkCellData *aInCellData = GetInput()->GetCellData();
+
+ if(aScalars->GetPointData()->GetScalars())
+ myExtractorScalars->SetInput(aScalars);
+ else if(aScalars->GetCellData()->GetScalars() &&
+ !aInCellData->GetAttribute(vtkDataSetAttributes::VECTORS)){
+ //Approximate cell data values to point data by VISU_CellDataToPointData filter.
+ VISU_CellDataToPointData* aCellDataToPointData = VISU_CellDataToPointData::New();
+ aCellDataToPointData->SetInput(aScalars);
+ aCellDataToPointData->Update();
+ myExtractorScalars->SetInput(aCellDataToPointData->GetUnstructuredGridOutput());
+ aCellDataToPointData->Delete();
+ } else {
+ myExtractorScalars->SetInput(aScalars);
+ }
+}
+
- // Sets data to mapper
- myMapper->SetInput(myMergeFilter->GetOutput());
+//=======================================================================
+VISU_ScalarMapPL::TInsertCustomPL*
+VISU_ScalarMapOnDeformedShapePL
+::InsertCustomPL()
+{
+ myMapper->SetColorModeToMapScalars();
+ myMapper->ScalarVisibilityOn();
+
+ return myMergeScalarsFilter->GetOutput();
}
-/*!
- * Update method
- */
void
VISU_ScalarMapOnDeformedShapePL
::Update()
{
- this->UpdateScalars();
-
- vtkFloatingPointType* aRange = GetScalarRange();
- vtkFloatingPointType aScalarRange[2] = {aRange[0], aRange[1]};
-
- if(myBarTable->GetScale() == VTK_SCALE_LOG10)
- VISU_LookupTable::ComputeLogRange(aRange,aScalarRange);
- myMapperTable->SetRange(aScalarRange);
-
- myMapperTable->Build();
- myBarTable->Build();
+ Superclass::Update();
- myMapper->SetLookupTable(myMapperTable);
- myMapper->SetScalarRange(aScalarRange);
-
- VISU_PipeLine::Update();
+ UpdateScalars();
+ //{
+ // std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-aScalarsOutput2.vtk";
+ // VISU::WriteToFile(myExtractorScalars->GetUnstructuredGridOutput(), aFileName);
+ //}
+ //{
+ // std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-aGeomDataSet2.vtk";
+ // VISU::WriteToFile(myWarpVector->GetUnstructuredGridOutput(), aFileName);
+ //}
+ //{
+ // std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-myMergeFilter2.vtk";
+ // VISU::WriteToFile(myMergeScalarsFilter->GetOutput(), aFileName);
+ //}
}
/*!
- * Update scalars method.
- * Put scalars to merge filter.
+ * Initial method
*/
void
VISU_ScalarMapOnDeformedShapePL
-::UpdateScalars()
+::Init()
{
- myExtractorScalars->Update();
+ Superclass::Init();
+
+ vtkFloatingPointType aScalarRange[2];
+ GetSourceRange(aScalarRange);
+
+ vtkDataSet* aDataSet = GetMergedInput();
+ vtkFloatingPointType aScaleFactor = VISU_DeformedShapePL::GetScaleFactor( aDataSet );
+
+ static double EPS = 1.0 / VTK_LARGE_FLOAT;
+ if(fabs(aScalarRange[1]) > EPS)
+ SetScale(aScaleFactor / aScalarRange[1]);
+ else
+ SetScale(0.0);
}
/*!
VISU_ScalarMapOnDeformedShapePL *aPipeLine = dynamic_cast<VISU_ScalarMapOnDeformedShapePL*>(thePipeLine);
if(aPipeLine){
SetScale(aPipeLine->GetScale());
- SetScalars(aPipeLine->GetScalarsUnstructuredGrid());
+ SetScalars(aPipeLine->GetScalars());
}
Superclass::ShallowCopy(thePipeLine);
}
::SetScalars(vtkDataSet *theScalars)
{
myScalars = theScalars;
- vtkUnstructuredGrid* aScalars = GetScalarsUnstructuredGrid();
- vtkCellData *aInCellData = GetInput()->GetCellData();
-
- std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-SetScalars.vtk";
- VISU::WriteToFile(aScalars, aFileName);
- if(aScalars->GetPointData()->GetScalars())
- myExtractorScalars->SetInput(aScalars);
- else if(aScalars->GetCellData()->GetScalars() &&
- !aInCellData->GetAttribute(vtkDataSetAttributes::VECTORS)){
- //Approximate cell data values to point data by vtkCellDataToPointData filter.
- vtkCellDataToPointData* aCellDataToPointData = vtkCellDataToPointData::New();
- aCellDataToPointData->SetInput(aScalars);
- aCellDataToPointData->Update();
- myExtractorScalars->SetInput(aCellDataToPointData->GetUnstructuredGridOutput());
- aCellDataToPointData->Delete();
- } else {
- myExtractorScalars->SetInput(aScalars);
- }
- Update();
- Modified();
}
/*!
* Get pointer to input scalars.
*/
-vtkUnstructuredGrid*
+vtkPointSet*
VISU_ScalarMapOnDeformedShapePL
-::GetScalarsUnstructuredGrid()
+::GetScalars()
{
return myScalars.GetPointer();
}
{
if(myScaleFactor == theScale) return;
myScaleFactor = theScale;
- myDeformVectors->SetScaleFactor(myScaleFactor);
+ myWarpVector->SetScaleFactor(myScaleFactor);
Modified();
}
VISU_ScalarMapOnDeformedShapePL
::SetMapScale(vtkFloatingPointType theMapScale)
{
- TSupperClass::SetMapScale(theMapScale); // enk::added
- myDeformVectors->SetScaleFactor(myScaleFactor*theMapScale);
+ Superclass::SetMapScale(theMapScale); // enk::added
+ myWarpVector->SetScaleFactor(myScaleFactor*theMapScale);
Modified();
}
#include "VISU_PrsMergerPL.hxx"
class VISU_MergeFilter;
+class VISU_CellDataToPointData;
+
class vtkWarpVector;
class vtkUnstructuredGrid;
-class vtkCellDataToPointData;
-class vtkPointDataToCellData;
class VISU_ScalarMapOnDeformedShapePL : public VISU_PrsMergerPL
{
-
- typedef VISU_PrsMergerPL TSupperClass;
-
protected:
VISU_ScalarMapOnDeformedShapePL();
VISU_ScalarMapOnDeformedShapePL(const VISU_ScalarMapOnDeformedShapePL&);
public:
- vtkTypeMacro(VISU_ScalarMapOnDeformedShapePL,VISU_PrsMergerPL);
+ vtkTypeMacro(VISU_ScalarMapOnDeformedShapePL, VISU_PrsMergerPL);
static VISU_ScalarMapOnDeformedShapePL* New();
virtual void GetSourceRange(vtkFloatingPointType theRange[2]);
virtual void SetScalars(vtkDataSet *theScalars);
- virtual vtkUnstructuredGrid* GetScalarsUnstructuredGrid();
+ virtual vtkPointSet* GetScalars();
public:
- //! Redefined method for initialization of the pipeline.
+ //! Redefined method for building of the pipeline.
virtual
void
- Init();
+ Build();
- //! Redefined method for building the pipeline.
+ //! Redefined method for initialization of the pipeline.
virtual
void
- Build();
+ Init();
- //! Redefined method for updating the pipeline.
virtual
void
Update();
- //! Update scalars.
+ virtual
void
UpdateScalars();
-
+
virtual void SetMapScale(vtkFloatingPointType theMapScale = 1.0);
protected:
+ //! Redefined method for customization of pipeline building
+ virtual
+ TInsertCustomPL*
+ InsertCustomPL();
+
vtkFloatingPointType myScaleFactor;
- vtkWarpVector *myDeformVectors;
- VISU_MergeFilter *myMergeFilter;
+ vtkWarpVector *myWarpVector;
+ VISU_MergeFilter *myMergeScalarsFilter;
vtkSmartPointer<vtkUnstructuredGrid> myScalars;
VISU_Extractor* myExtractorScalars;
- vtkCellDataToPointData* myCellDataToPointData;
+ VISU_CellDataToPointData* myCellDataToPointData;
};
#endif
//----------------------------------------------------------------------------
-VISU_ScalarMapPL::THook*
+VISU_PipeLine::TInput*
VISU_ScalarMapPL
-::DoHook()
+::GetClippedInput()
+{
+ if(myExtractGeometry->GetInput())
+ myFieldTransform->Update();
+ return myFieldTransform->GetUnstructuredGridOutput();
+}
+
+
+VISU_ScalarMapPL::TInsertCustomPL*
+VISU_ScalarMapPL
+::InsertCustomPL()
{
myMapper->SetColorModeToMapScalars();
myMapper->ScalarVisibilityOn();
- return myFieldTransform->GetUnstructuredGridOutput();
+
+ return GetClippedInput();
}
VISU_ScalarMapPL
::Build()
{
- myMapper->SetInput(DoHook());
+ myMapper->SetInput(InsertCustomPL());
}
#include "VISU_ScalarBarActor.hxx"
class vtkCell;
-class vtkDataSet;
+class vtkPointSet;
class VISU_Extractor;
class VISU_FieldTransform;
//----------------------------------------------------------------------------
protected:
- typedef vtkDataSet THook;
- virtual THook* DoHook();
+ typedef vtkPointSet TInsertCustomPL;
+
+ virtual
+ TInsertCustomPL*
+ InsertCustomPL();
+
+ virtual
+ TInput*
+ GetClippedInput();
VISU_LookupTable* myMapperTable;
VISU_LookupTable* myBarTable;
int theDirection,
int isOnlyTry)
{
- vtkPointSet* aDataSet = theSource? theSource: myFieldTransform->GetUnstructuredGridOutput();
+ vtkPointSet* aDataSet = theSource? theSource: GetMergedInput();
aDataSet->Update();
vtkIdType aNbOfPoints = aDataSet->GetNumberOfPoints();
vtkPointSet* aPointSet = myExtractor->GetOutput();
if((!isOnlyTry && isAccepted) || (isOnlyTry && isAccepted == 1)){
mySource = theSource;
myPercents = thePercents;
- if(VISU::IsDataOnCells(GetInput2())){
+ if(VISU::IsDataOnCells(GetMergedInput())){
myCenters->SetInput(aDataSet);
myCenters->VertexCellsOn();
aDataSet = myCenters->GetOutput();
VISU_StreamLinesPL
::GetMaxIntegrationStep(vtkPointSet* theDataSet)
{
- if(!theDataSet) return -1.0;
+ if(!theDataSet)
+ return -1.0;
theDataSet->Update();
vtkFloatingPointType aLength = theDataSet->GetLength();
vtkFloatingPointType* aBounds = theDataSet->GetBounds();
VISU_StreamLinesPL
::GetBasePropagationTime(vtkPointSet* theDataSet)
{
- if(!theDataSet) return -1.0;
+ if(!theDataSet)
+ return -1.0;
theDataSet->Update();
vtkFloatingPointType aPropagationTime = theDataSet->GetLength()/GetVelocityCoeff(theDataSet);
return aPropagationTime;
}
+void
+VISU_StreamLinesPL
+::Build()
+{
+ Superclass::Build();
+
+ VISU::CellDataToPoint(myStream,
+ myCellDataToPointData,
+ GetMergedInput());
+
+ vtkFloatingPointType aBounds[6];
+ GetMergedInput()->GetBounds(aBounds);
+
+ myGeomFilter->SetExtent(aBounds);
+ myGeomFilter->ExtentClippingOn();
+ myGeomFilter->SetInput(myStream->GetOutput());
+}
+
void
VISU_StreamLinesPL
::Init()
{
Superclass::Init();
- vtkPointSet* aDataSet = myExtractor->GetOutput();
+
+ vtkPointSet* aDataSet = GetMergedInput();
vtkFloatingPointType anIntStep = GetBaseIntegrationStep(aDataSet);
vtkFloatingPointType aPropagationTime = GetBasePropagationTime(aDataSet);
vtkFloatingPointType aStepLength = GetBaseStepLength(aDataSet);
SetParams(anIntStep,aPropagationTime,aStepLength);
}
-VISU_ScalarMapPL::THook*
+VISU_ScalarMapPL::TInsertCustomPL*
VISU_StreamLinesPL
-::DoHook()
+::InsertCustomPL()
{
- GetInput2()->Update();
- VISU::CellDataToPoint(myStream,myCellDataToPointData,GetInput2(),myFieldTransform);
- vtkFloatingPointType *aBounds = GetInput2()->GetBounds();
- myGeomFilter->SetExtent(aBounds);
- myGeomFilter->ExtentClippingOn();
- myGeomFilter->SetInput(myStream->GetOutput());
return myGeomFilter->GetOutput();
}
public:
virtual
- THook*
- DoHook();
+ TInsertCustomPL*
+ InsertCustomPL();
+
+ virtual
+ void
+ Build();
virtual
void
}
-VISU_ScalarMapPL::THook*
+void
VISU_VectorsPL
-::DoHook()
+::Build()
{
- VISU::ToCellCenters(myBaseGlyph,myCenters,GetInput2(),myFieldTransform);
+ Superclass::Build();
+
+ VISU::ToCellCenters(myBaseGlyph,
+ myCenters,
+ GetMergedInput());
myBaseGlyph->SetVectorModeToUseVector();
myBaseGlyph->SetScaleModeToScaleByVector();
myBaseGlyph->SetColorModeToColorByScalar();
- VISU::ToCellCenters(myTransformFilter,myCenters,GetInput2(),myFieldTransform);
+ VISU::ToCellCenters(myTransformFilter,
+ myCenters,
+ GetMergedInput());
myTransformedGlyph->SetInput(myTransformFilter->GetOutput());
myTransformedGlyph->SetVectorModeToUseVector();
myTransformedGlyph->SetScaleModeToScaleByVector();
myTransformedGlyph->SetColorModeToColorByScalar();
+}
+
+VISU_ScalarMapPL::TInsertCustomPL*
+VISU_VectorsPL
+::InsertCustomPL()
+{
return myTransformedGlyph->GetOutput();
}
void
Init();
+ virtual
+ void
+ Build();
+
virtual
void
Update();
protected:
virtual
- THook*
- DoHook();
+ TInsertCustomPL*
+ InsertCustomPL();
GlyphType myTypeGlyph;
GlyphPos myPosGlyph;
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->GetPL()->GetMapper()->GetInput();
- int aMaxId = (aDataSet->*theMethod)();
- if (anId < 0) anId = 0;
- if (anId >= aMaxId) anId = aMaxId - 1;
+ int anObjId = theText.toInt();
+ VISU_PipeLine* aPipeLine = aPrs3d->GetPL();
+ int aVTKId = (aPipeLine->*theMethod)(anObjId);
+ if(aVTKId < 0)
+ return false;
TColStd_MapOfInteger newIndices;
- newIndices.Add(anId);
+ newIndices.Add(anObjId);
aSelector->AddOrRemoveIndex(anIO, newIndices, false);
aViewWindow->highlight(anIO, true, true);
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()
try{
TSuperClass::CreateActor(theActor,theIO);
theActor->GetPipeLine()->Delete();
+ theActor->SetVTKMapping(true);
UpdateActor(theActor);
return true;
}catch(...){
Prs3d_i(theResult,theAddToStudy),
ColoredPrs3d_i(theResult,theAddToStudy),
ScalarMap_i(theResult,theAddToStudy),
- myPrsMergerPL(NULL),
- myScalarsPL(VISU_ScalarMapPL::New())
+ myPrsMergerPL(NULL)
{
}
Prs3d_i(theResult,theSObject),
ColoredPrs3d_i(theResult,theSObject),
ScalarMap_i(theResult,theSObject),
- myPrsMergerPL(NULL),
- myScalarsPL(VISU_ScalarMapPL::New())
+ myPrsMergerPL(NULL)
{
}
VISU_MeshPL* aTmpMesh = VISU_MeshPL::New();
aTmpMesh->SetIDMapper(anIDMapper);
- aRetVal = myPrsMergerPL->AddBackGeometry(aTmpMesh,false);
+ aRetVal = myPrsMergerPL->AddBackGeometry(aTmpMesh);
if(aRetVal >-1 ){
myMeshPLList.push_back(aTmpMesh);
myEntity = (VISU::TEntity)theEntity;
myFieldName = theFieldName;
myIteration = theStampsNum;
-
- myScalarsPL->SetIDMapper(anIDMapper);
- myPrsMergerPL->SetScalars(myScalarsPL);
}
void
VISU::PrsMerger_i::
SetScalarMap(VISU_PipeLine* thePipeLine)
-{
- if (MYDEBUG) MESSAGE("VISU::PrsMerger_i::SetScalarMap");
- VISU_ScalarMapPL* aInputScalars = dynamic_cast<VISU_ScalarMapPL*>(thePipeLine);
- VISU::PIDMapper anIDMapper = aInputScalars->GetIDMapper();
- myScalarsPL->SetIDMapper(anIDMapper);
- if(aInputScalars)
- myPrsMergerPL->SetScalars(myScalarsPL);
-}
+{}
void
VISU::PrsMerger_i::
VISU::PrsMerger_i
::CheckGroup(const char* theGroupName)
{
- if (MYDEBUG) MESSAGE("PrsMerger_i::CheckGroup :|"<<theGroupName<<"|");
- if(myEntity == NODE_ENTITY)
- return true;
- string aMeshName = myMeshName;
- string aGroupName = theGroupName;
-
- VISU::PIDMapper anIDMapper;
- anIDMapper = myResult->GetInput()->GetMeshOnGroup(aMeshName,theGroupName);
- if (MYDEBUG) MESSAGE("anIDMapper="<<anIDMapper);
- if(!anIDMapper) return false;
-
- bool aAllPoints = true;
- int aNbCellsInGeom = anIDMapper->GetVTKOutput()->GetNumberOfCells();
- if(aNbCellsInGeom>0){
- int aVtkCellType = anIDMapper->GetVTKOutput()->GetCellType(0);
- if (MYDEBUG) MESSAGE("CellType="<<aVtkCellType);
- switch(myEntity){
- case CELL_ENTITY:
- if(aVtkCellType != VTK_LINE &&
- aVtkCellType != VTK_POLY_LINE &&
- aVtkCellType != VTK_VERTEX &&
- aVtkCellType != VTK_PIXEL)
- aAllPoints = false;
- break;
- case EDGE_ENTITY:
- if(aVtkCellType == VTK_LINE ||
- aVtkCellType == VTK_POLY_LINE)
- aAllPoints = false;
- break;
- case FACE_ENTITY:
- if(aVtkCellType == VTK_TRIANGLE ||
- aVtkCellType == VTK_TRIANGLE_STRIP ||
- aVtkCellType == VTK_POLYGON ||
- aVtkCellType == VTK_QUAD)
- aAllPoints = false;
- break;
- }
- }
-
- if (MYDEBUG) MESSAGE("return="<<!aAllPoints);
- return (!aAllPoints);
+ // Always true, there is no restrictions
+ return true;
}
VISU_PrsMergerPL* myPrsMergerPL;
VISU_PrsMergerPL::TPipeLines myMeshPLList;
- VISU_ScalarMapPL* myScalarsPL;
SALOMEDS::Color myColor;
bool myIsColored;
throw std::runtime_error("There is no TimeStamp with the parameters !!!");
myScalarMapPL->SetIDMapper(anIDMapper);
+ myScalarMapPL->Build();
// mkr : 23.11.2006 - PAL13908 - save animation range if range is fixed -->
if ( myIsFixedRange )
myScalarMapPL->SetScalarMode(0);
else
myScalarMapPL->Init();
// mkr : 23.11.2006 <--
- myScalarMapPL->Build();
}
void