From 9dae5f8b9353b024be69a060165886045282209e Mon Sep 17 00:00:00 2001 From: pkv Date: Fri, 26 Aug 2005 08:36:53 +0000 Subject: [PATCH] To intorduce ID's mapping --- src/VTKViewer/Makefile.in | 2 + src/VTKViewer/VTKViewer_AppendFilter.cxx | 187 +++++++++++++++++++++++ src/VTKViewer/VTKViewer_AppendFilter.h | 58 +++++++ 3 files changed, 247 insertions(+) create mode 100644 src/VTKViewer/VTKViewer_AppendFilter.cxx create mode 100644 src/VTKViewer/VTKViewer_AppendFilter.h diff --git a/src/VTKViewer/Makefile.in b/src/VTKViewer/Makefile.in index 4c72c0d5c..9f85daf7a 100755 --- a/src/VTKViewer/Makefile.in +++ b/src/VTKViewer/Makefile.in @@ -18,6 +18,7 @@ EXPORT_HEADERS= VTKViewer_Actor.h \ VTKViewer_ConvexTool.h \ VTKViewer_Filter.h \ VTKViewer_GeometryFilter.h \ + VTKViewer_AppendFilter.h \ VTKViewer_Algorithm.h \ VTKViewer.h \ VTKViewer_InteractorStyle.h \ @@ -47,6 +48,7 @@ LIB_SRC= VTKViewer_Actor.cxx \ VTKViewer_ExtractUnstructuredGrid.cxx \ VTKViewer_Filter.cxx \ VTKViewer_GeometryFilter.cxx \ + VTKViewer_AppendFilter.cxx \ VTKViewer_InteractorStyle.cxx \ VTKViewer_PassThroughFilter.cxx \ VTKViewer_RectPicker.cxx \ diff --git a/src/VTKViewer/VTKViewer_AppendFilter.cxx b/src/VTKViewer/VTKViewer_AppendFilter.cxx new file mode 100644 index 000000000..53fa80b8c --- /dev/null +++ b/src/VTKViewer/VTKViewer_AppendFilter.cxx @@ -0,0 +1,187 @@ +// SALOME OBJECT : kernel of SALOME component +// +// 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 : VTKViewer_GeometryFilter.cxx +// Author : +// Module : SALOME +// $Header$ + +#include "VTKViewer_AppendFilter.h" + +#include "VTKViewer_ConvexTool.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +using namespace std; + + +#ifdef _DEBUG_ +//static int MYDEBUG = 0; +//static int MYDEBUGWITHFILES = 0; +#else +//static int MYDEBUG = 0; +//static int MYDEBUGWITHFILES = 0; +#endif + +#if defined __GNUC__ + #if __GNUC__ == 2 + #define __GNUC_2__ + #endif +#endif + +vtkCxxRevisionMacro(VTKViewer_AppendFilter, "$Revision$"); +vtkStandardNewMacro(VTKViewer_AppendFilter); + +VTKViewer_AppendFilter::VTKViewer_AppendFilter() +{} + + +VTKViewer_AppendFilter::~VTKViewer_AppendFilter() +{} + + +void VTKViewer_AppendFilter::Execute() +{ + vtkAppendFilter::Execute(); + DoMapping(); +} + +void VTKViewer_AppendFilter::Reset() +{ + myNodeIds.clear(); + myCellIds.clear(); + myNodeRanges.clear(); + myCellRanges.clear(); +} + +void VTKViewer_AppendFilter::DoMapping() +{ + int i, j, i1, i2; + vtkIdType aNbPnts, aNbCells, aId; + vtkDataSet *pDS; + // + Reset(); + // + for (i=0; iGetNumberOfPoints(); + i1=myNodeIds.size(); + i2=i1+aNbPnts-1; + myNodeRanges.push_back(i1); + myNodeRanges.push_back(i2); + // + for(j=0; jGetNumberOfCells(); + i1=myCellIds.size(); + i2=i1+aNbCells-1; + myCellRanges.push_back(i1); + myCellRanges.push_back(i2); + for(j=0; j=aNb) { + return aRetID; + } + // + aRetID=(int)myNodeIds[theVtkID]; + // + aNbRanges=myNodeRanges.size()/2; + for (i=0; i=i1 && theVtkID<=i2) { + theInputIndex=i; + } + } + // + return aRetID; +} + +int VTKViewer_AppendFilter::GetElemObjId(int theVtkID, + int& theInputIndex) +{ + int aNb, aNbRanges, aRetID, i, i1, i2, j; + // + aRetID=-1; + theInputIndex=-1; + // + aNb=myCellIds.size(); + if (theVtkID<0 || theVtkID>=aNb) { + return aRetID; + } + // + aRetID=(int)myCellIds[theVtkID]; + // + aNbRanges=myCellRanges.size()/2; + for (i=0; i=i1 && theVtkID<=i2) { + theInputIndex=i; + } + } + // + return aRetID; +} + + diff --git a/src/VTKViewer/VTKViewer_AppendFilter.h b/src/VTKViewer/VTKViewer_AppendFilter.h new file mode 100644 index 000000000..e73051fcf --- /dev/null +++ b/src/VTKViewer/VTKViewer_AppendFilter.h @@ -0,0 +1,58 @@ +#ifndef VTKVIEWER_APPENDFILTER_H +#define VTKVIEWER_APPENDFILTER_H + +#include "VTKViewer.h" + +#include + +#include +/*! \brief This class used same as vtkAppendFilter. See documentation on VTK for more information. + */ +class VTKVIEWER_EXPORT VTKViewer_AppendFilter : public vtkAppendFilter +{ +public: + /*! \fn static VTKViewer_AppendFilter *New() + */ + static VTKViewer_AppendFilter *New(); + + /*! \fn vtkTypeRevisionMacro(VTKViewer_AppendFilter, vtkAppendFilter) + * \brief VTK type revision macros. + */ + vtkTypeRevisionMacro(VTKViewer_AppendFilter, vtkAppendFilter); + + int GetElemObjId(int theVtkI, + int& theInputIndex); + + int GetNodeObjId(int theVtkID, + int& theInputIndex); + // +protected: + /*! \fn VTKViewer_AppendFilter(); + * \brief Constructor + */ + VTKViewer_AppendFilter(); + /*! \fn ~VTKViewer_AppendFilter(); + * \brief Destructor. + */ + ~VTKViewer_AppendFilter(); + /*! \fn void Execute(); + * \brief Filter culculation method. + */ + virtual void Execute(); + // + void DoMapping(); + + void Reset(); + // +private: + typedef std::vector TVectorId; + typedef std::vector VectorInt; + +private: + TVectorId myNodeIds; + TVectorId myCellIds; + VectorInt myNodeRanges; + VectorInt myCellRanges; +}; + +#endif -- 2.39.2