]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
To intorduce ID's mapping
authorpkv <pkv@opencascade.com>
Fri, 26 Aug 2005 08:36:53 +0000 (08:36 +0000)
committerpkv <pkv@opencascade.com>
Fri, 26 Aug 2005 08:36:53 +0000 (08:36 +0000)
src/VTKViewer/Makefile.in
src/VTKViewer/VTKViewer_AppendFilter.cxx [new file with mode: 0644]
src/VTKViewer/VTKViewer_AppendFilter.h [new file with mode: 0644]

index 4c72c0d5c1f1c3e37e003fbb754a70418b995ecd..9f85daf7a67611e562802a7ac2735ef8af81bfa3 100755 (executable)
@@ -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 (file)
index 0000000..53fa80b
--- /dev/null
@@ -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 <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;
+}
+
+
diff --git a/src/VTKViewer/VTKViewer_AppendFilter.h b/src/VTKViewer/VTKViewer_AppendFilter.h
new file mode 100644 (file)
index 0000000..e73051f
--- /dev/null
@@ -0,0 +1,58 @@
+#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