#include "VISU_Convertor_impl.hxx"
#include "VISU_ConvertorUtils.hxx"
#include "VTKViewer_AppendFilter.h"
+#include "VISU_MergeFilter.hxx"
#include <vtkPoints.h>
#include <vtkUnstructuredGrid.h>
#include <vtkCellData.h>
#include <vtkCellLinks.h>
-#include <vtkMergeFilter.h>
#include <qstring.h>
#include <qfileinfo.h>
static int MYVTKDEBUG = 0;
#ifdef _DEBUG_
-static int MYDEBUG = 0;
-static int MYDEBUGWITHFILES = 0;
+static int MYDEBUG = 1;
+static int MYDEBUGWITHFILES = 1;
//#define _DEXCEPT_
#else
static int MYDEBUG = 0;
::GetFilter() const
{
if(!myFilter.GetPointer()){
- myFilter = vtkMergeFilter::New();
+ myFilter = VISU_MergeFilter::New();
myFilter->Delete();
}
return myFilter;
{
int aNbTuples = theField->myDataSize/theField->myNbComp;
std::string aFieldName = GenerateFieldName(theField,theValForTime);
- INITMSG(MYDEBUG,"GetTimeStampOnProfile - aNbTuples = "<<aNbTuples<<endl);
vtkDataSetAttributes* aDataSetAttributes;
switch(theField->myEntity){
aDataArray->SetName("VISU_FIELD");
aDataSetAttributes->AddArray(aDataArray);
+ int aNbComp2 = aNbComp;
+ if(aNbComp == 4)
+ aNbComp2 = 2;
+ else if(aNbComp > 4)
+ aNbComp2 = 3;
+
+ INITMSG(MYDEBUG,"GetTimeStampOnProfile "<<
+ "- aNbTuples = "<<aNbTuples<<
+ "; aNbComp = "<<aNbComp<<
+ "; aNbComp2 = "<<aNbComp2<<
+ endl);
+
+ int aSize = max(3,aNbComp);
+ TVector<float> aDataValues(aSize,0.0);
+
TGeom2Value& aGeom2Value = theValForTime->myGeom2Value;
TGeom2Value::const_iterator anIter = aGeom2Value.begin();
- TVector<float> aDataValues(aNbComp,0.0);
for(int aTupleId = 0; anIter != aGeom2Value.end(); anIter++){
EGeometry aEGeom = anIter->first;
const TMeshValue& aMeshValue = anIter->second;
INITMSG(MYDEBUG,
"- aEGeom = "<<aEGeom<<
"; aNbElem = "<<aNbElem<<
- "; aNbComp = "<<aNbComp<<
"; aNbGauss = "<<aNbGauss<<
endl);
- int aNbComp2 = aNbComp;
- if(aNbComp == 4)
- aNbComp2 = 2;
- else if(aNbComp > 4)
- aNbComp2 = 3;
-
for(int iElem = 0; iElem < aNbElem; iElem++, aTupleId++){
TCValueSliceArr aValueSliceArr = aMeshValue.GetCompValueSliceArr(iElem);
for(int iComp = 0; iComp < aNbComp; iComp++){
{
int aNbTuples = theSource->GetNumberOfPoints();
std::string aFieldName = GenerateFieldName(theField,theValForTime);
- INITMSG(MYDEBUG,"GetTimeStampOnGaussMesh - aNbTuples = "<<aNbTuples<<endl);
vtkDataSetAttributes* aDataSetAttributes;
switch(theField->myEntity){
aDataArray->SetName("VISU_FIELD");
aDataSetAttributes->AddArray(aDataArray);
+ int aNbComp2 = aNbComp;
+ if(aNbComp == 4)
+ aNbComp2 = 2;
+ else if(aNbComp > 4)
+ aNbComp2 = 3;
+
+ INITMSG(MYDEBUG,"GetTimeStampOnGaussMesh "<<
+ "- aNbTuples = "<<aNbTuples<<
+ "; aNbComp = "<<aNbComp<<
+ "; aNbComp2 = "<<aNbComp2<<
+ endl);
+
+ int aSize = max(3,aNbComp);
+ TVector<float> aDataValues(aSize,0.0);
+
const TGeom2Value& aGeom2Value = theValForTime->myGeom2Value;
PGaussMeshImpl aGaussMesh = theValForTime->myGaussMesh;
const TGeom2GaussSubMesh& aGeom2GaussSubMesh = aGaussMesh->myGeom2GaussSubMesh;
TGeom2GaussSubMesh::const_iterator anIter = aGeom2GaussSubMesh.begin();
- TVector<float> aDataValues(aNbComp,0.0);
for(int aTupleId = 0; anIter != aGeom2GaussSubMesh.end(); anIter++){
EGeometry aEGeom = anIter->first;
INITMSG(MYDEBUG,
"- aEGeom = "<<aEGeom<<
"; aNbElem = "<<aNbElem<<
- "; aNbComp = "<<aNbComp<<
"; aNbGauss = "<<aNbGauss<<
endl);
-// Copyright (C) 2003 CEA/DEN, EDF R&D
+// SALOME VTKViewer : build VTK viewer into Salome desktop
//
+// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
-// File : VISU_Convertor_impl.hxx
-// Author : Alexey PETROV
-// Module : VISU
+//
+// File :
+// Author :
+// Module : SALOME
+// $Header$
#ifndef VISU_Convertor_impl_HeaderFile
#define VISU_Convertor_impl_HeaderFile
class vtkCell;
class vtkPoints;
-class vtkMergeFilter;
class vtkUnstructuredGrid;
class VTKViewer_AppendFilter;
+class VISU_MergeFilter;
#include "VISU_Convertor.hxx"
#include "MED_SliceArray.hxx"
#ifndef VISU_ENABLE_QUADRATIC
-#define VISU_ENABLE_QUADRATIC
-#define VISU_USE_VTK_QUADRATIC
+//#define VISU_ENABLE_QUADRATIC
+//#define VISU_USE_VTK_QUADRATIC
#endif
namespace VISU
typedef vtkSmartPointer<TDataSet> TVTKSource;
typedef vtkSmartPointer<vtkPoints> TVTKPoints;
- typedef vtkSmartPointer<vtkMergeFilter> TVTKMergeFilter;
+ typedef vtkSmartPointer<VISU_MergeFilter> TVTKMergeFilter;
typedef vtkSmartPointer<VTKViewer_AppendFilter> TVTKAppendFilter;
--- /dev/null
+// SALOME VTKViewer : build VTK viewer into Salome desktop
+//
+// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File :
+// Author :
+// Module : SALOME
+// $Header$
+
+#include "VISU_MergeFilter.hxx"
+
+#include <vtkCellData.h>
+#include <vtkObjectFactory.h>
+#include <vtkPointData.h>
+#include <vtkPolyData.h>
+#include <vtkRectilinearGrid.h>
+#include <vtkStructuredGrid.h>
+#include <vtkStructuredPoints.h>
+#include <vtkUnstructuredGrid.h>
+
+namespace VISU
+{
+
+ class TFieldNode
+ {
+ public:
+ TFieldNode(const char* name, vtkDataSet* ptr=0)
+ {
+ int length = static_cast<int>(strlen(name));
+ if (length > 0) {
+ this->Name = new char[length+1];
+ strcpy(this->Name, name);
+ } else {
+ this->Name = 0;
+ }
+ this->Ptr = ptr;
+ this->Next = 0;
+ }
+ ~TFieldNode()
+ {
+ delete[] this->Name;
+ }
+
+ const char* GetName()
+ {
+ return Name;
+ }
+ vtkDataSet* Ptr;
+ TFieldNode* Next;
+ private:
+ TFieldNode(const TFieldNode&) {}
+ void operator=(const TFieldNode&) {}
+ char* Name;
+ };
+
+ class TFieldList
+ {
+ public:
+ TFieldList()
+ {
+ this->First = 0;
+ this->Last = 0;
+ }
+ ~TFieldList()
+ {
+ TFieldNode* node = this->First;
+ TFieldNode* next;
+ while(node){
+ next = node->Next;
+ delete node;
+ node = next;
+ }
+ }
+
+
+ void Add(const char* name, vtkDataSet* ptr)
+ {
+ TFieldNode* newNode = new TFieldNode(name, ptr);
+ if (!this->First) {
+ this->First = newNode;
+ this->Last = newNode;
+ } else {
+ this->Last->Next = newNode;
+ this->Last = newNode;
+ }
+ }
+
+ friend class TFieldListIterator;
+
+ private:
+ TFieldNode* First;
+ TFieldNode* Last;
+ };
+
+ class TFieldListIterator
+ {
+ public:
+ TFieldListIterator(TFieldList* list)
+ {
+ this->List = list;
+ this->Position = 0;
+ }
+ void Begin()
+ {
+ this->Position = this->List->First;
+ }
+ void Next()
+ {
+ if (this->Position) {
+ this->Position = this->Position->Next;
+ }
+ }
+ int End()
+ {
+ return this->Position ? 0 : 1;
+ }
+ TFieldNode* Get()
+ {
+ return this->Position;
+ }
+
+ private:
+ TFieldNode* Position;
+ TFieldList* List;
+ };
+
+}
+
+//------------------------------------------------------------------------------
+vtkStandardNewMacro(VISU_MergeFilter);
+
+//------------------------------------------------------------------------------
+
+// Create object with no input or output.
+VISU_MergeFilter::VISU_MergeFilter()
+{
+ this->FieldList = new VISU::TFieldList;
+}
+
+VISU_MergeFilter::~VISU_MergeFilter()
+{
+ delete this->FieldList;
+}
+
+void VISU_MergeFilter::SetScalars(vtkDataSet *input)
+{
+ this->vtkProcessObject::SetNthInput(1, input);
+}
+vtkDataSet *VISU_MergeFilter::GetScalars()
+{
+ if (this->NumberOfInputs < 2)
+ {
+ return NULL;
+ }
+ return (vtkDataSet *)(this->Inputs[1]);
+}
+
+void VISU_MergeFilter::SetVectors(vtkDataSet *input)
+{
+ this->vtkProcessObject::SetNthInput(2, input);
+}
+vtkDataSet *VISU_MergeFilter::GetVectors()
+{
+ if (this->NumberOfInputs < 3)
+ {
+ return NULL;
+ }
+ return (vtkDataSet *)(this->Inputs[2]);
+}
+
+void VISU_MergeFilter::SetNormals(vtkDataSet *input)
+{
+ this->vtkProcessObject::SetNthInput(3, input);
+}
+vtkDataSet *VISU_MergeFilter::GetNormals()
+{
+ if (this->NumberOfInputs < 4)
+ {
+ return NULL;
+ }
+ return (vtkDataSet *)(this->Inputs[3]);
+}
+
+void VISU_MergeFilter::SetTCoords(vtkDataSet *input)
+{
+ this->vtkProcessObject::SetNthInput(4, input);
+}
+vtkDataSet *VISU_MergeFilter::GetTCoords()
+{
+ if (this->NumberOfInputs < 5)
+ {
+ return NULL;
+ }
+ return (vtkDataSet *)(this->Inputs[4]);
+}
+
+void VISU_MergeFilter::SetTensors(vtkDataSet *input)
+{
+ this->vtkProcessObject::SetNthInput(5, input);
+}
+vtkDataSet *VISU_MergeFilter::GetTensors()
+{
+ if (this->NumberOfInputs < 6)
+ {
+ return NULL;
+ }
+ return (vtkDataSet *)(this->Inputs[5]);
+}
+
+void VISU_MergeFilter::AddField(const char* name, vtkDataSet* input)
+{
+ this->FieldList->Add(name, input);
+}
+
+void VISU_MergeFilter::Execute()
+{
+ vtkIdType numPts, numScalars=0, numVectors=0, numNormals=0, numTCoords=0;
+ vtkIdType numTensors=0;
+ vtkIdType numCells, numCellScalars=0, numCellVectors=0, numCellNormals=0;
+ vtkIdType numCellTCoords=0, numCellTensors=0;
+ vtkPointData *pd;
+ vtkDataArray *scalars = NULL;
+ vtkDataArray *vectors = NULL;
+ vtkDataArray *normals = NULL;
+ vtkDataArray *tcoords = NULL;
+ vtkDataArray *tensors = NULL;
+ vtkCellData *cd;
+ vtkDataArray *cellScalars = NULL;
+ vtkDataArray *cellVectors = NULL;
+ vtkDataArray *cellNormals = NULL;
+ vtkDataArray *cellTCoords = NULL;
+ vtkDataArray *cellTensors = NULL;
+ vtkDataSet *output = this->GetOutput();
+ vtkPointData *outputPD = output->GetPointData();
+ vtkCellData *outputCD = output->GetCellData();
+
+ vtkDebugMacro(<<"Merging data!");
+
+ // geometry needs to be copied
+ output->CopyStructure(this->GetInput());
+ if ( (numPts = this->GetInput()->GetNumberOfPoints()) < 1 )
+ {
+ vtkWarningMacro(<<"Nothing to merge!");
+ }
+ numCells = this->GetInput()->GetNumberOfCells();
+
+ if ( this->GetScalars() )
+ {
+ pd = this->GetScalars()->GetPointData();
+ scalars = pd->GetScalars();
+ if ( scalars != NULL )
+ {
+ numScalars = scalars->GetNumberOfTuples();
+ }
+ cd = this->GetScalars()->GetCellData();
+ cellScalars = cd->GetScalars();
+ if ( cellScalars != NULL )
+ {
+ numCellScalars = cellScalars->GetNumberOfTuples();
+ }
+ }
+
+ if ( this->GetVectors() )
+ {
+ pd = this->GetVectors()->GetPointData();
+ vectors = pd->GetVectors();
+ if ( vectors != NULL )
+ {
+ numVectors= vectors->GetNumberOfTuples();
+ }
+ cd = this->GetVectors()->GetCellData();
+ cellVectors = cd->GetVectors();
+ if ( cellVectors != NULL )
+ {
+ numCellVectors = cellVectors->GetNumberOfTuples();
+ }
+ }
+
+ if ( this->GetNormals() )
+ {
+ pd = this->GetNormals()->GetPointData();
+ normals = pd->GetNormals();
+ if ( normals != NULL )
+ {
+ numNormals= normals->GetNumberOfTuples();
+ }
+ cd = this->GetNormals()->GetCellData();
+ cellNormals = cd->GetNormals();
+ if ( cellNormals != NULL )
+ {
+ numCellNormals = cellNormals->GetNumberOfTuples();
+ }
+ }
+
+ if ( this->GetTCoords() )
+ {
+ pd = this->GetTCoords()->GetPointData();
+ tcoords = pd->GetTCoords();
+ if ( tcoords != NULL )
+ {
+ numTCoords= tcoords->GetNumberOfTuples();
+ }
+ cd = this->GetTCoords()->GetCellData();
+ cellTCoords = cd->GetTCoords();
+ if ( cellTCoords != NULL )
+ {
+ numCellTCoords = cellTCoords->GetNumberOfTuples();
+ }
+ }
+
+ if ( this->GetTensors() )
+ {
+ pd = this->GetTensors()->GetPointData();
+ tensors = pd->GetTensors();
+ if ( tensors != NULL )
+ {
+ numTensors = tensors->GetNumberOfTuples();
+ }
+ cd = this->GetTensors()->GetCellData();
+ cellTensors = cd->GetTensors();
+ if ( cellTensors != NULL )
+ {
+ numCellTensors = cellTensors->GetNumberOfTuples();
+ }
+ }
+
+ // merge data only if it is consistent
+ if ( numPts == numScalars )
+ {
+ outputPD->SetScalars(scalars);
+ }
+ if ( numCells == numCellScalars )
+ {
+ outputCD->SetScalars(cellScalars);
+ }
+
+ if ( numPts == numVectors )
+ {
+ outputPD->SetVectors(vectors);
+ }
+ if ( numCells == numCellVectors )
+ {
+ outputCD->SetVectors(cellVectors);
+ }
+
+ if ( numPts == numNormals )
+ {
+ outputPD->SetNormals(normals);
+ }
+ if ( numCells == numCellNormals )
+ {
+ outputCD->SetNormals(cellNormals);
+ }
+
+ if ( numPts == numTCoords )
+ {
+ outputPD->SetTCoords(tcoords);
+ }
+ if ( numCells == numCellTCoords )
+ {
+ outputCD->SetTCoords(cellTCoords);
+ }
+
+ if ( numPts == numTensors )
+ {
+ outputPD->SetTensors(tensors);
+ }
+ if ( numCells == numCellTensors )
+ {
+ outputCD->SetTensors(cellTensors);
+ }
+
+ VISU::TFieldListIterator it(this->FieldList);
+ vtkDataArray* da;
+ const char* name;
+ vtkIdType num;
+ for(it.Begin(); !it.End() ; it.Next())
+ {
+ pd = it.Get()->Ptr->GetPointData();
+ cd = it.Get()->Ptr->GetCellData();
+ name = it.Get()->GetName();
+ if ( (da=pd->GetArray(name)) )
+ {
+ num = da->GetNumberOfTuples();
+ if (num == numPts)
+ {
+ outputPD->AddArray(da);
+ }
+ }
+ if ( (da=cd->GetArray(name)) )
+ {
+ num = da->GetNumberOfTuples();
+ if (num == numCells) // To fix a VTK bug
+ {
+ outputCD->AddArray(da);
+ }
+ }
+ }
+}
--- /dev/null
+// SALOME VTKViewer : build VTK viewer into Salome desktop
+//
+// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File :
+// Author :
+// Module : SALOME
+// $Header$
+
+#ifndef VISU_MergeFilter_H
+#define VISU_MergeFilter_H
+
+#include <vtkDataSetToDataSetFilter.h>
+
+namespace VISU
+{
+ class TFieldList;
+}
+
+// Following class was redefined in order to fix VTK bug
+// (see code for more details)
+
+class VISU_MergeFilter : public vtkDataSetToDataSetFilter
+{
+public:
+ static VISU_MergeFilter *New();
+ vtkTypeMacro(VISU_MergeFilter,vtkDataSetToDataSetFilter);
+
+ // Description:
+ // Specify object from which to extract geometry information.
+ void SetGeometry(vtkDataSet *input) {this->SetInput(input);};
+ vtkDataSet *GetGeometry() {return this->GetInput();};
+
+ // Description:
+ // Specify object from which to extract scalar information.
+ void SetScalars(vtkDataSet *);
+ vtkDataSet *GetScalars();
+
+ // Description:
+ // Set / get the object from which to extract vector information.
+ void SetVectors(vtkDataSet *);
+ vtkDataSet *GetVectors();
+
+ // Description:
+ // Set / get the object from which to extract normal information.
+ void SetNormals(vtkDataSet *);
+ vtkDataSet *GetNormals();
+
+ // Description:
+ // Set / get the object from which to extract texture coordinates
+ // information.
+ void SetTCoords(vtkDataSet *);
+ vtkDataSet *GetTCoords();
+
+ // Description:
+ // Set / get the object from which to extract tensor data.
+ void SetTensors(vtkDataSet *);
+ vtkDataSet *GetTensors();
+
+ // Description:
+ // Set the object from which to extract a field and the name
+ // of the field
+ void AddField(const char* name, vtkDataSet* input);
+
+protected:
+ VISU_MergeFilter();
+ ~VISU_MergeFilter();
+
+ // Usual data generation method
+ void Execute();
+
+ VISU::TFieldList* FieldList;
+private:
+ VISU_MergeFilter(const VISU_MergeFilter&); // Not implemented.
+ void operator=(const VISU_MergeFilter&); // Not implemented.
+};
+
+#endif
+
+