X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FVTKViewer%2FVTKViewer_ExtractUnstructuredGrid.cxx;h=233529c4bdb6681c666b5ac01a2f8b5bd4b2a63a;hb=refs%2Fheads%2Fngr%2Fpython3_dev_pv5.4;hp=6737674082d73a71a115c78492a1e36a3e72580c;hpb=399155730966dfc225fbb24f66204b05664385f2;p=modules%2Fgui.git diff --git a/src/VTKViewer/VTKViewer_ExtractUnstructuredGrid.cxx b/src/VTKViewer/VTKViewer_ExtractUnstructuredGrid.cxx index 673767408..233529c4b 100755 --- a/src/VTKViewer/VTKViewer_ExtractUnstructuredGrid.cxx +++ b/src/VTKViewer/VTKViewer_ExtractUnstructuredGrid.cxx @@ -1,29 +1,27 @@ -// VISU CONVERTOR : +// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, 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 // -// File: VISU_ExtractUnstructuredGrid.cxx -// Author: Alexey PETROV -// Module : VISU +// File: VTKViewer_ExtractUnstructuredGrid.cxx +// Author: Alexey PETROV #include "VTKViewer_ExtractUnstructuredGrid.h" #include "VTKViewer_CellLocationsArray.h" @@ -34,14 +32,12 @@ #include #include #include +#include +#include +#include +#include -using namespace std; - -#ifdef _DEBUG_ -static int MYDEBUG = 0; -#else -static int MYDEBUG = 0; -#endif +#include "utilities.h" #if defined __GNUC__ #if __GNUC__ == 2 @@ -49,103 +45,350 @@ static int MYDEBUG = 0; #endif #endif +#define VTK_XVERSION (VTK_MAJOR_VERSION*10000+VTK_MINOR_VERSION*100+VTK_BUILD_VERSION) + vtkStandardNewMacro(VTKViewer_ExtractUnstructuredGrid); VTKViewer_ExtractUnstructuredGrid::VTKViewer_ExtractUnstructuredGrid(): - myExtractionMode(eCells), myChangeMode(ePassAll) + myExtractionMode(eCells), myChangeMode(ePassAll), myStoreMapping( false ), myPassAll( false ) {} -VTKViewer_ExtractUnstructuredGrid::~VTKViewer_ExtractUnstructuredGrid(){} - +VTKViewer_ExtractUnstructuredGrid::~VTKViewer_ExtractUnstructuredGrid() +{} -void VTKViewer_ExtractUnstructuredGrid::RegisterCell(vtkIdType theCellId){ -// if(0 && MYDEBUG) MESSAGE("RegisterCell - theCellId = "<Allocate(theCellTypesArray->GetSize()); + theFaceLocations = vtkIdTypeArray::New(); + theFaceLocations->Allocate(theCellTypesArray->GetSize()); + // FaceLocations must be padded until the current position + for (vtkIdType i = 0; i <= theCellTypesArray->GetMaxId(); i++) + { + theFaceLocations->InsertNextValue(-1); + } + } + // insert face location + theFaceLocations->InsertNextValue(theFaces->GetMaxId() + 1); - vtkIdType aCellType = aCell->GetCellType(); - theCellTypesArray->InsertNextValue(aCellType); + // insert cell connectivity and faces stream + vtkIdType nfaces = 0; + vtkIdType* face = 0; + vtkIdType realnpts; + theInput->GetFaceStream(theCellId, nfaces, face); + vtkUnstructuredGrid::DecomposeAPolyhedronCell( + nfaces, face, realnpts, theConnectivity, theFaces); + } +#endif + + /*vtkIdType anID = */theCellTypesArray->InsertNextValue(aCellType); if(theStoreMapping){ - theOut2InId.push_back(theCellId); - theIn2OutId[theCellId] = theOutId; + theOut2InId.push_back( theCellId ); + //theIn2OutId.insert( theIn2OutId.end(), std::make_pair( theCellId, theOutId )); } + return aCellId; } inline void InsertPointCell(vtkCellArray *theConnectivity, - vtkUnsignedCharArray* theCellTypesArray, - vtkIdType theCellId, - vtkIdList *theIdList, - bool theStoreMapping, - vtkIdType theOutId, - VTKViewer_ExtractUnstructuredGrid::TVectorId& theOut2InId, - VTKViewer_ExtractUnstructuredGrid::TMapId& theIn2OutId) + vtkUnsignedCharArray* theCellTypesArray, + vtkIdType theCellId, + vtkIdList *theIdList, + bool theStoreMapping, + vtkIdType theOutId, + VTKViewer_ExtractUnstructuredGrid::TVectorId& theOut2InId/*, + VTKViewer_ExtractUnstructuredGrid::TMapId& theIn2OutId*/) { theIdList->SetId(0,theCellId); theConnectivity->InsertNextCell(theIdList); theCellTypesArray->InsertNextValue(VTK_VERTEX); if(theStoreMapping){ theOut2InId.push_back(theCellId); - theIn2OutId[theCellId] = theOutId; + //theIn2OutId.insert( theIn2OutId.end(), std::make_pair( theCellId, theOutId )); } } -void VTKViewer_ExtractUnstructuredGrid::Execute(){ - vtkUnstructuredGrid *anInput = this->GetInput(); - vtkUnstructuredGrid *anOutput = this->GetOutput(); - myOut2InId.clear(); myIn2OutId.clear(); + +int VTKViewer_ExtractUnstructuredGrid::RequestData(vtkInformation *vtkNotUsed(request), + vtkInformationVector **inputVector, + vtkInformationVector *outputVector) +{ + // get the info objects + vtkInformation *inInfo = inputVector[0]->GetInformationObject(0); + vtkInformation *outInfo = outputVector->GetInformationObject(0); + + // get the input and ouptut + vtkUnstructuredGrid *anInput = + vtkUnstructuredGrid::SafeDownCast(inInfo->Get(vtkDataObject::DATA_OBJECT())); + vtkUnstructuredGrid *anOutput = + vtkUnstructuredGrid::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT())); + + //vtkUnstructuredGrid *anInput = this->GetInput(); + //vtkUnstructuredGrid *anOutput = this->GetOutput(); + + myPassAll = false; + TVectorId().swap( myOut2InId ); + + // use a vector of cellTypes to avoid searching in myCellTypes map + // for a better performance (IPAL53103) + TVectorId cellTypesVec( VTK_NUMBER_OF_CELL_TYPES, -1 ); + for ( TSetId::iterator type = myCellTypes.begin(); type != myCellTypes.end(); ++type ) + { + if ( *type >= (int)cellTypesVec.size() ) cellTypesVec.resize( *type+1, -1 ); + if ( *type > 0 ) + cellTypesVec[ *type ] = *type; + } /* if(MYDEBUG){ MESSAGE("Execute - anInput->GetNumberOfCells() = "<GetNumberOfCells()); @@ -154,182 +397,212 @@ void VTKViewer_ExtractUnstructuredGrid::Execute(){ MESSAGE("Execute - myExtractionMode = "<GetNumberOfCells() = "<GetNumberOfCells()); if(myStoreMapping){ @@ -344,4 +623,5 @@ void VTKViewer_ExtractUnstructuredGrid::Execute(){ MESSAGE("Execute - myIn2OutId.size() = "<