X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FVTKViewer%2FVTKViewer_AppendFilter.cxx;h=820d711064142933391a78b7f82d6b78c728139b;hb=d6bd12111347879cd8dbe1a15ac4d6ba32ce0d6b;hp=222d2f1ab9584e2756184b6e4180ca60d9021d8f;hpb=101fd10f1e736daa5d7f0f0ee5499b951460832a;p=modules%2Fgui.git diff --git a/src/VTKViewer/VTKViewer_AppendFilter.cxx b/src/VTKViewer/VTKViewer_AppendFilter.cxx index 222d2f1ab..820d71106 100644 --- a/src/VTKViewer/VTKViewer_AppendFilter.cxx +++ b/src/VTKViewer/VTKViewer_AppendFilter.cxx @@ -1,30 +1,28 @@ -// SALOME OBJECT : kernel of SALOME component +// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // -// 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 +// 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" @@ -35,6 +33,8 @@ #include #include #include +#include +#include #include @@ -44,7 +44,6 @@ #endif #endif -vtkCxxRevisionMacro(VTKViewer_AppendFilter, "$Revision$"); vtkStandardNewMacro(VTKViewer_AppendFilter); VTKViewer_AppendFilter @@ -78,41 +77,43 @@ 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; } -//================================================================== -// function: DoMapping -// purpose : -//================================================================== void VTKViewer_AppendFilter ::DoMapping() @@ -123,10 +124,10 @@ VTKViewer_AppendFilter 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; @@ -138,14 +139,13 @@ VTKViewer_AppendFilter } } -//--------------------------------------------------------------- namespace { inline vtkIdType GetOutputID(vtkIdType theInputID, - vtkIdType theInputDataSetID, - const VTKViewer_AppendFilter::TVectorIds& theRanges) + vtkIdType theInputDataSetID, + const VTKViewer_AppendFilter::TVectorIds& theRanges) { theInputID = theInputDataSetID = -1; @@ -161,37 +161,35 @@ namespace 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); } -//--------------------------------------------------------------- namespace { 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; @@ -207,10 +205,10 @@ namespace 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; } @@ -220,60 +218,74 @@ namespace 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 @@ -282,7 +294,7 @@ VTKViewer_AppendFilter }//if non-empty dataset }//for all inputs if (numCells < 1) { - return; + return 0; } // // Now can allocate memory @@ -293,21 +305,35 @@ VTKViewer_AppendFilter // 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; cellIdGetCellPoints(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; +}