--- /dev/null
+// 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 <vtkSmartPointer.h>
+#include <vtkCellArray.h>
+#include <vtkCellData.h>
+#include <vtkGenericCell.h>
+#include <vtkHexahedron.h>
+#include <vtkMergePoints.h>
+#include <vtkObjectFactory.h>
+#include <vtkPointData.h>
+#include <vtkPolyData.h>
+#include <vtkPyramid.h>
+#include <vtkStructuredGrid.h>
+#include <vtkTetra.h>
+#include <vtkUnsignedCharArray.h>
+#include <vtkUnstructuredGrid.h>
+#include <vtkVoxel.h>
+#include <vtkWedge.h>
+#include <vtkDataSetCollection.h>
+
+#include <vector>
+#include <map>
+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; i<NumberOfInputs; ++i) {
+ pDS=(vtkDataSet *)Inputs[i];
+ //
+ // Nodes
+ aNbPnts=pDS->GetNumberOfPoints();
+ i1=myNodeIds.size();
+ i2=i1+aNbPnts-1;
+ myNodeRanges.push_back(i1);
+ myNodeRanges.push_back(i2);
+ //
+ for(j=0; j<aNbPnts; ++j) {
+ aId=(vtkIdType)j;
+ myNodeIds.push_back(aId);
+ }
+ //
+ // Cells
+ aNbCells=pDS->GetNumberOfCells();
+ i1=myCellIds.size();
+ i2=i1+aNbCells-1;
+ myCellRanges.push_back(i1);
+ myCellRanges.push_back(i2);
+ for(j=0; j<aNbCells; ++j) {
+ aId=(vtkIdType)j;
+ myCellIds.push_back(aId);
+ }
+ }
+}
+
+int VTKViewer_AppendFilter::GetNodeObjId(int theVtkID,
+ int& theInputIndex)
+{
+ int aNb, aNbRanges, aRetID, i, i1, i2, j;
+ //
+ aRetID=-1;
+ theInputIndex=-1;
+ //
+ aNb=myNodeIds.size();
+ if (theVtkID<0 || theVtkID>=aNb) {
+ return aRetID;
+ }
+ //
+ aRetID=(int)myNodeIds[theVtkID];
+ //
+ aNbRanges=myNodeRanges.size()/2;
+ for (i=0; i<aNbRanges; ++i) {
+ j=2*i;
+ i1=myNodeRanges[j];
+ i2=myNodeRanges[j+1];
+ if (theVtkID>=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<aNbRanges; ++i) {
+ j=2*i;
+ i1=myCellRanges[j];
+ i2=myCellRanges[j+1];
+ if (theVtkID>=i1 && theVtkID<=i2) {
+ theInputIndex=i;
+ }
+ }
+ //
+ return aRetID;
+}
+
+
--- /dev/null
+#ifndef VTKVIEWER_APPENDFILTER_H
+#define VTKVIEWER_APPENDFILTER_H
+
+#include "VTKViewer.h"
+
+#include <vtkAppendFilter.h>
+
+#include <vector>
+/*! \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<vtkIdType> TVectorId;
+ typedef std::vector<int> VectorInt;
+
+private:
+ TVectorId myNodeIds;
+ TVectorId myCellIds;
+ VectorInt myNodeRanges;
+ VectorInt myCellRanges;
+};
+
+#endif