-// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
//
-// 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 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.
+// 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
+// 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
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// SALOME VTKViewer : build VTK viewer into Salome desktop
// $Header$
//
#include "VISU_MergeFilterUtilities.hxx"
+#include "VISU_ConvertorUtils.hxx"
#include <vtkCellData.h>
#include <vtkObjectFactory.h>
using namespace VISU;
+ void CopyVectorsOnCells(vtkDataSet *theVectorsDataSet,
+ vtkDataSet *theOutput)
+ {
+ vtkDataArray *anInputVectors = theVectorsDataSet->GetCellData()->GetVectors();
+ vtkDataArray *anOutputVectors = vtkDataArray::CreateDataArray(anInputVectors->GetDataType());
+
+ //Clear output vector data
+ theOutput->GetCellData()->SetVectors(NULL);
+
+ //Copy vectors data
+ vtkIntArray* anOutputIDMapper = GetIDMapper(theOutput,
+ TGetCellData(),
+ "VISU_CELLS_MAPPER");
+
+ vtkIntArray* anInputIDMapper = GetIDMapper(theVectorsDataSet,
+ TGetCellData(),
+ "VISU_CELLS_MAPPER");
+
+ TObjectIdArray anIntersection;
+ GetIntersection(anOutputIDMapper,
+ anInputIDMapper,
+ anIntersection);
+
+ vtkIdType aNbTuples = anIntersection.size();
+ anOutputVectors->SetNumberOfComponents(anInputVectors->GetNumberOfComponents());
+ anOutputVectors->SetNumberOfTuples(aNbTuples);
+ theOutput->GetCellData()->SetVectors(anOutputVectors);
+ anOutputVectors->Delete();
+
+ TObjectId2TupleIdMap anOutputObjectId2TupleIdMap;
+ GetObjectId2TupleIdMap(anOutputIDMapper, anOutputObjectId2TupleIdMap);
+
+ TObjectId2TupleIdMap anInputObjectId2TupleIdMap;
+ GetObjectId2TupleIdMap(anInputIDMapper, anInputObjectId2TupleIdMap);
+
+ for(vtkIdType iTupleId = 0; iTupleId < aNbTuples; iTupleId++ ){
+ TObjectId &anObjectId = anIntersection[iTupleId];
+ vtkIdType anOutputCellId = anOutputObjectId2TupleIdMap[anObjectId];
+ vtkIdType anInputCellId = anInputObjectId2TupleIdMap[anObjectId];
+ anOutputVectors->SetTuple(anOutputCellId,anInputVectors->GetTuple(anInputCellId));
+ }
+ }
+
+ void CopyVectorsOnPoints(vtkDataSet *theVectorsDataSet,
+ vtkDataSet *theOutput)
+ {
+ vtkDataArray *anInputVectors = theVectorsDataSet->GetPointData()->GetVectors();
+
+ //Clear output vector data
+ theOutput->GetPointData()->SetVectors(NULL);
+
+ vtkDataArray *anOutputVectors = vtkDataArray::CreateDataArray(anInputVectors->GetDataType());
+
+ //Copy vectors data
+ vtkIntArray* anOutputIDMapper = GetIDMapper(theOutput,
+ TGetPointData(),
+ "VISU_POINTS_MAPPER");
+
+ vtkIntArray* anInputIDMapper = GetIDMapper(theVectorsDataSet,
+ TGetPointData(),
+ "VISU_POINTS_MAPPER");
+ TObjectIdArray anIntersection;
+
+ GetIntersection(anOutputIDMapper,
+ anInputIDMapper,
+ anIntersection);
+
+ vtkIdType aNbTuples = anIntersection.size();
+ anOutputVectors->SetNumberOfComponents(anInputVectors->GetNumberOfComponents());
+ anOutputVectors->SetNumberOfTuples(aNbTuples);
+
+
+
+ TObjectId2TupleIdMap anOutputObjectId2TupleIdMap;
+ GetObjectId2TupleIdMap(anOutputIDMapper, anOutputObjectId2TupleIdMap);
+
+ TObjectId2TupleIdMap anInputObjectId2TupleIdMap;
+ GetObjectId2TupleIdMap(anInputIDMapper, anInputObjectId2TupleIdMap);
+
+ for(vtkIdType iTupleId = 0; iTupleId < aNbTuples; iTupleId++ ){
+ TObjectId& anObjectId = anIntersection[iTupleId];
+ vtkIdType anOutputPointId = anOutputObjectId2TupleIdMap[anObjectId];
+ vtkIdType anInputPointId = anInputObjectId2TupleIdMap[anObjectId];
+ anOutputVectors->SetTuple(anOutputPointId,anInputVectors->GetTuple(anInputPointId));
+ }
+
+ theOutput->GetPointData()->SetVectors(anOutputVectors);
+ anOutputVectors->Delete();
+ }
+
+
//---------------------------------------------------------------
template<class TDataSet>
-
void
CopyDataOnCells(TDataSet *theInput,
vtkIntArray *theGeometryCellMapper,
}
}
- void CopyVectorsOnCells(vtkDataSet *theVectorsDataSet,
- vtkDataSet *theOutput)
- {
- vtkDataArray *anInputVectors = theVectorsDataSet->GetCellData()->GetVectors();
- vtkDataArray *anOutputVectors = vtkDataArray::CreateDataArray(anInputVectors->GetDataType());
-
- //Clear output vector data
- theOutput->GetCellData()->SetVectors(NULL);
-
- //Copy vectors data
- vtkIntArray* anOutputIDMapper = GetIDMapper(theOutput,
- TGetCellData(),
- "VISU_CELLS_MAPPER");
-
- vtkIntArray* anInputIDMapper = GetIDMapper(theVectorsDataSet,
- TGetCellData(),
- "VISU_CELLS_MAPPER");
-
- TObjectIdArray anIntersection;
- GetIntersection(anOutputIDMapper,
- anInputIDMapper,
- anIntersection);
-
- vtkIdType aNbTuples = anIntersection.size();
- anOutputVectors->SetNumberOfComponents(anInputVectors->GetNumberOfComponents());
- anOutputVectors->SetNumberOfTuples(aNbTuples);
- theOutput->GetCellData()->SetVectors(anOutputVectors);
- anOutputVectors->Delete();
-
- TObjectId2TupleIdMap anOutputObjectId2TupleIdMap;
- GetObjectId2TupleIdMap(anOutputIDMapper, anOutputObjectId2TupleIdMap);
-
- TObjectId2TupleIdMap anInputObjectId2TupleIdMap;
- GetObjectId2TupleIdMap(anInputIDMapper, anInputObjectId2TupleIdMap);
-
- for(vtkIdType iTupleId = 0; iTupleId < aNbTuples; iTupleId++ ){
- TObjectId &anObjectId = anIntersection[iTupleId];
- vtkIdType anOutputCellId = anOutputObjectId2TupleIdMap[anObjectId];
- vtkIdType anInputCellId = anInputObjectId2TupleIdMap[anObjectId];
- anOutputVectors->SetTuple(anOutputCellId,anInputVectors->GetTuple(anInputCellId));
- }
- }
-
//---------------------------------------------------------------
template<class TDataSet>
void
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();
+ if(!VISU::IsElnoData(theScalarsDataSet)) {
+ 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();
+ } else {
+ vtkIntArray* anInputCellIDMapper = GetIDMapper(theInput,
+ TGetCellData(),
+ "VISU_CELLS_MAPPER");
+
+ vtkIntArray* anScalarsCellIDMapper = GetIDMapper(theScalarsDataSet,
+ TGetCellData(),
+ "VISU_CELLS_MAPPER");
+
+ vtkIntArray *anInputArray = dynamic_cast<vtkIntArray*>(anInputCellIDMapper);
+ int aNbComp = anInputArray->GetNumberOfComponents();
+ TCellId inCellObjId = -1;
+ TEntityId inEntityId = -1;
+ TCellId scalarCellVtkId = -1;
+ vtkCell* inputCell = NULL;
+ vtkCell* scalarCell = NULL;
+
+ for(int aCellId = 0; aCellId < aNbCells; aCellId++) {
+ aCellIds->Reset();
+ int* anInPointer = anInputArray->GetPointer(aCellId*aNbComp);
+ inCellObjId = *anInPointer;
+ inEntityId = *(anInPointer+1);
+ if(inCellObjId == -1) continue;
+ scalarCellVtkId = VISU::GetVTKID(anScalarsCellIDMapper,inCellObjId,inEntityId);
+ if(scalarCellVtkId == -1) continue;
+ scalarCell = theScalarsDataSet->GetCell(scalarCellVtkId);
+ inputCell = theInput->GetCell(aCellId);
+ vtkIdType aCellType = inputCell->GetCellType();
+ if(scalarCell->GetCellType() == aCellType) {
+ aCellIds->DeepCopy(scalarCell->PointIds);
+ vtkIdType aNewCellId = theOutput->InsertNextCell(aCellType, aCellIds);
+ anOutputCellData->CopyData(aCellData, aCellId, aNewCellId);
+ }
+ }
+ }
// Copy geometry points
// 1. Create vtkPoints instance of the same data type
if(anIter != aGeomObjectId2TupleIdMap.end()){
// If the point exists in the geometry put it to output
int aGeometryPointId = anIter->second;
- vtkFloatingPointType aCoords[3];
+ double aCoords[3];
anGeometryPoints->GetPoint(aGeometryPointId, aCoords);
anOutputPoints->SetPoint(aPointId, aCoords);
}else{
// If no, the point from data should be used
- vtkFloatingPointType aCoords[3];
+ double aCoords[3];
aDataPoints->GetPoint(aPointId, aCoords);
anOutputPoints->SetPoint(aPointId, aCoords);
}
}
}
}
-
- void CopyVectorsOnPoints(vtkDataSet *theVectorsDataSet,
- vtkDataSet *theOutput)
- {
- vtkDataArray *anInputVectors = theVectorsDataSet->GetPointData()->GetVectors();
-
- //Clear output vector data
- theOutput->GetPointData()->SetVectors(NULL);
-
- vtkDataArray *anOutputVectors = vtkDataArray::CreateDataArray(anInputVectors->GetDataType());
-
- //Copy vectors data
- vtkIntArray* anOutputIDMapper = GetIDMapper(theOutput,
- TGetPointData(),
- "VISU_POINTS_MAPPER");
-
- vtkIntArray* anInputIDMapper = GetIDMapper(theVectorsDataSet,
- TGetPointData(),
- "VISU_POINTS_MAPPER");
- TObjectIdArray anIntersection;
-
- GetIntersection(anOutputIDMapper,
- anInputIDMapper,
- anIntersection);
-
- vtkIdType aNbTuples = anIntersection.size();
- anOutputVectors->SetNumberOfComponents(anInputVectors->GetNumberOfComponents());
- anOutputVectors->SetNumberOfTuples(aNbTuples);
-
-
-
- TObjectId2TupleIdMap anOutputObjectId2TupleIdMap;
- GetObjectId2TupleIdMap(anOutputIDMapper, anOutputObjectId2TupleIdMap);
-
- TObjectId2TupleIdMap anInputObjectId2TupleIdMap;
- GetObjectId2TupleIdMap(anInputIDMapper, anInputObjectId2TupleIdMap);
-
- for(vtkIdType iTupleId = 0; iTupleId < aNbTuples; iTupleId++ ){
- TObjectId& anObjectId = anIntersection[iTupleId];
- vtkIdType anOutputPointId = anOutputObjectId2TupleIdMap[anObjectId];
- vtkIdType anInputPointId = anInputObjectId2TupleIdMap[anObjectId];
- anOutputVectors->SetTuple(anOutputPointId,anInputVectors->GetTuple(anInputPointId));
- }
-
- theOutput->GetPointData()->SetVectors(anOutputVectors);
- anOutputVectors->Delete();
- }
-
//---------------------------------------------------------------
typedef vtkDataArray* (vtkDataSetAttributes::* TGetAttribute)();
}
return NULL;
}
-
+ // Explicit symbol export when compiling with g++ and optimizations,
+ // needed by VISUConvertor during linking
+ #if (__GNUG__ && __OPTIMIZE__)
+ template vtkIntArray*
+ GetIDMapper<TGetPointData>(TFieldList*, TGetPointData, const char* );
+ #endif
//---------------------------------------------------------------
template<class TGetFieldData>