-// SALOME OBJECT : kernel of SALOME component
+// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
-// 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
+// Copyright (C) 2003-2007 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, or (at your option) any later version.
+//
+// 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
//
+
+// SALOME OBJECT : kernel of SALOME component
// File : VTKViewer_GeometryFilter.cxx
// Author :
-// Module : SALOME
-// $Header$
#include "VTKViewer_AppendFilter.h"
#include <vtkObjectFactory.h>
#include <vtkPointData.h>
#include <vtkUnstructuredGrid.h>
+#include <vtkInformation.h>
+#include <vtkInformationVector.h>
#include <vtkPoints.h>
#endif
#endif
-vtkCxxRevisionMacro(VTKViewer_AppendFilter, "$Revision$");
-vtkStandardNewMacro(VTKViewer_AppendFilter);
+vtkStandardNewMacro(VTKViewer_AppendFilter)
VTKViewer_AppendFilter
::VTKViewer_AppendFilter()
void
VTKViewer_AppendFilter
-::SetPoints(vtkPoints* thePoints)
+::SetSharedPointsDataSet(vtkPointSet* thePointsDataSet)
{
- if(GetPoints() == thePoints)
+ if(GetSharedPointsDataSet() == thePointsDataSet)
return;
- myPoints = thePoints;
+ mySharedPointsDataSet = thePointsDataSet;
- this->Modified();
+ Modified();
}
-vtkPoints*
+vtkPointSet*
VTKViewer_AppendFilter
-::GetPoints()
+::GetSharedPointsDataSet()
{
- return myPoints.GetPointer();
+ return mySharedPointsDataSet.GetPointer();
}
-void
+int
VTKViewer_AppendFilter
-::Execute()
+::RequestData(
+ vtkInformation *request,
+ vtkInformationVector **inputVector,
+ vtkInformationVector *outputVector)
{
- if(myPoints.GetPointer())
- MakeOutput();
+ int aRet = 0;
+ if(GetSharedPointsDataSet())
+ aRet = MakeOutput(request,inputVector,outputVector);
else
- Superclass::Execute();
+ aRet = Superclass::RequestData(request,inputVector,outputVector);
if(myDoMappingFlag)
DoMapping();
+
+ return aRet;
}
vtkIdType aPntStartId = 0;
vtkIdType aCellStartId = 0;
- for(vtkIdType aDataSetId = 0; aDataSetId < this->NumberOfInputs; ++aDataSetId){
- vtkDataSet* aDataSet = (vtkDataSet *)(this->Inputs[aDataSetId]);
+ for(vtkIdType aDataSetId = 0; aDataSetId < this->GetNumberOfInputPorts(); ++aDataSetId){
+ vtkDataSet* aDataSet = (vtkDataSet *)(this->GetInput(aDataSetId));
// Do mapping of the nodes
- if(!myPoints.GetPointer()){
+ if(!GetSharedPointsDataSet()){
vtkIdType aNbPnts = aDataSet->GetNumberOfPoints();
myNodeRanges.push_back(aPntStartId + aNbPnts);
aPntStartId += aNbPnts;
inline
vtkIdType
GetOutputID(vtkIdType theInputID,
- vtkIdType theInputDataSetID,
- const VTKViewer_AppendFilter::TVectorIds& theRanges)
+ vtkIdType theInputDataSetID,
+ const VTKViewer_AppendFilter::TVectorIds& theRanges)
{
theInputID = theInputDataSetID = -1;
- vtkIdType aNbInputs = theRanges.size();
+ vtkIdType aNbInputs = (vtkIdType)theRanges.size(); //!< TODO: conversion from size_t to vtkIdType
if(theInputDataSetID < 0 || theInputDataSetID >= aNbInputs)
return -1;
vtkIdType
VTKViewer_AppendFilter
::GetPointOutputID(vtkIdType theInputID,
- vtkIdType theInputDataSetID)
+ vtkIdType theInputDataSetID)
{
- if(myPoints.GetPointer())
+ if(GetSharedPointsDataSet())
return theInputID;
return GetOutputID(theInputID,theInputDataSetID,myNodeRanges);
vtkIdType
VTKViewer_AppendFilter
::GetCellOutputID(vtkIdType theInputID,
- vtkIdType theInputDataSetID)
+ vtkIdType theInputDataSetID)
{
- if(myPoints.GetPointer())
+ if(GetSharedPointsDataSet())
return theInputID;
return GetOutputID(theInputID,theInputDataSetID,myCellRanges);
{
void
GetInputID(vtkIdType theOutputID,
- vtkIdType& theInputID,
- vtkIdType& theStartID,
- vtkIdType& theInputDataSetID,
- const VTKViewer_AppendFilter::TVectorIds& theRanges)
+ vtkIdType& theInputID,
+ vtkIdType& theStartID,
+ vtkIdType& theInputDataSetID,
+ const VTKViewer_AppendFilter::TVectorIds& theRanges)
{
theInputID = theStartID = theInputDataSetID = -1;
return;
vtkIdType aStartId = 0;
- vtkIdType aNbInputs = theRanges.size();
+ vtkIdType aNbInputs = (vtkIdType)theRanges.size(); //!< TODO: conversion from size_t to vtkIdType
for(vtkIdType aDataSetId = 0; aDataSetId < aNbInputs; ++aDataSetId){
vtkIdType aRange = theRanges[aDataSetId];
if(aRange > theOutputID){
- theInputID = theOutputID - aStartId;
- theInputDataSetID = aDataSetId;
- theStartID = aStartId;
- break;
+ theInputID = theOutputID - aStartId;
+ theInputDataSetID = aDataSetId;
+ theStartID = aStartId;
+ break;
}
aStartId = aRange;
}
void
VTKViewer_AppendFilter
::GetPointInputID(vtkIdType theOutputID,
- vtkIdType& theInputID,
- vtkIdType& theStartID,
- vtkIdType& theInputDataSetID)
+ vtkIdType& theInputID,
+ vtkIdType& theStartID,
+ vtkIdType& theInputDataSetID)
{
- if(myPoints.GetPointer()) {
+ if(GetSharedPointsDataSet()) {
theStartID = theInputDataSetID = 0;
theInputID = theOutputID;
return;
}
::GetInputID(theOutputID,
- theInputID,
- theStartID,
- theInputDataSetID,
- myNodeRanges);
+ theInputID,
+ theStartID,
+ theInputDataSetID,
+ myNodeRanges);
}
void
VTKViewer_AppendFilter
::GetCellInputID(vtkIdType theOutputID,
- vtkIdType& theInputID,
- vtkIdType& theStartID,
- vtkIdType& theInputDataSetID)
+ vtkIdType& theInputID,
+ vtkIdType& theStartID,
+ vtkIdType& theInputDataSetID)
{
::GetInputID(theOutputID,
- theInputID,
- theStartID,
- theInputDataSetID,
- myCellRanges);
+ theInputID,
+ theStartID,
+ theInputDataSetID,
+ myCellRanges);
}
-void
+int
VTKViewer_AppendFilter
-::MakeOutput()
+::MakeOutput(
+ vtkInformation *vtkNotUsed(request),
+ vtkInformationVector **inputVector,
+ vtkInformationVector *outputVector)
{
int idx;
- vtkIdType numPts, numCells, newCellId, cellId;
- vtkCellData *cd;
+ vtkIdType numPts, numCells, cellId;
+ // vtkCellData *cd;
vtkIdList *ptIds;
vtkDataSet *ds;
- vtkUnstructuredGrid *output = this->GetOutput();
+ int numInputs = this->GetNumberOfInputConnections(0);
+
+ // get the output info object
+ vtkInformation *outInfo = outputVector->GetInformationObject(0);
+
+ // get the ouptut
+ vtkUnstructuredGrid *output = vtkUnstructuredGrid::SafeDownCast(
+ outInfo->Get(vtkDataObject::DATA_OBJECT()));
//
- numPts = myPoints->GetNumberOfPoints();
+ numPts = mySharedPointsDataSet->GetNumberOfPoints();
if (numPts < 1) {
- return;
+ return 0;
}
//
numCells = 0;
- for (idx = 0; idx < this->NumberOfInputs; ++idx) {
- ds = (vtkDataSet *)(this->Inputs[idx]);
+ vtkInformation *inInfo = 0;
+ for (idx = 0; idx < numInputs;++idx) {
+ inInfo = inputVector[0]->GetInformationObject(idx);
+ ds = 0;
+ if (inInfo)
+ {
+ ds = vtkDataSet::SafeDownCast(inInfo->Get(vtkDataObject::DATA_OBJECT()));
+ }
if (ds != NULL) {
if ( ds->GetNumberOfPoints() <= 0 && ds->GetNumberOfCells() <= 0 ) {
continue; //no input, just skip
}//if non-empty dataset
}//for all inputs
if (numCells < 1) {
- return;
+ return 0;
}
//
// Now can allocate memory
// Append each input dataset together
//
// 1.points
- output->SetPoints(myPoints.GetPointer());
+ output->SetPoints(GetSharedPointsDataSet()->GetPoints());
+ output->GetPointData()->PassData(GetSharedPointsDataSet()->GetPointData());
// 2.cells
- for (idx = 0; idx < this->NumberOfInputs; ++idx) {
- ds = (vtkDataSet *)(this->Inputs[idx]);
+ for (idx = 0; idx < numInputs; ++idx) {
+ inInfo = inputVector[0]->GetInformationObject(idx);
+ ds = 0;
+ if (inInfo)
+ {
+ ds = vtkDataSet::SafeDownCast(inInfo->Get(vtkDataObject::DATA_OBJECT()));
+ }
if (ds != NULL) {
+
numCells = ds->GetNumberOfCells();
- cd = ds->GetCellData();
+ // cd = ds->GetCellData();
// copy cell and cell data
for (cellId=0; cellId<numCells; cellId++) {
ds->GetCellPoints(cellId, ptIds);
- newCellId = output->InsertNextCell(ds->GetCellType(cellId), ptIds);
+ output->InsertNextCell(ds->GetCellType(cellId), ptIds);
}
}
}
//
ptIds->Delete();
+ return 1;
}
+int VTKViewer_AppendFilter::FillInputPortInformation(int, vtkInformation *info)
+{
+ info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkDataSet");
+ info->Set(vtkAlgorithm::INPUT_IS_REPEATABLE(), 1);
+ return 1;
+}