]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
Added culculation of polygons by triangles for vtkConvexPointSet
authorenk <enk@opencascade.com>
Tue, 26 Apr 2005 12:20:57 +0000 (12:20 +0000)
committerenk <enk@opencascade.com>
Tue, 26 Apr 2005 12:20:57 +0000 (12:20 +0000)
src/VTKFilter/Makefile.in
src/VTKFilter/SALOME_GeometryFilter.cxx

index e8297f1f83de1cc9da228fa9dc9109a6a208ee85..12cb23883c2285df50fe4750f2c1afa566fb6b3f 100644 (file)
@@ -37,7 +37,8 @@ EXPORT_HEADERS = SALOME_Transform.h \
                 SALOME_PassThroughFilter.h \
                 SALOME_ShrinkFilter.h \
                 SALOME_GeometryFilter.h \
-                SALOME_ExtractUnstructuredGrid.h
+                SALOME_ExtractUnstructuredGrid.h \
+                SALOME_ConvexTool.h
 
 # Libraries targets
 
@@ -47,7 +48,8 @@ LIB_SRC = SALOME_Transform.cxx \
          SALOME_PassThroughFilter.cxx \
          SALOME_ShrinkFilter.cxx \
          SALOME_GeometryFilter.cxx \
-         SALOME_ExtractUnstructuredGrid.cxx
+         SALOME_ExtractUnstructuredGrid.cxx \
+         SALOME_ConvexTool.cxx
 
 # Executables targets
 
index 3fab9df811294d80cee77c3ffc33a83173b8af09..5092e22fc5374bf386064ca160f675063f5cea36 100644 (file)
@@ -27,7 +27,9 @@
 //  $Header$
 
 #include "SALOME_GeometryFilter.h"
+#include "SALOME_ConvexTool.h"
 
+#include <vtkSmartPointer.h>
 #include <vtkCellArray.h>
 #include <vtkCellData.h>
 #include <vtkGenericCell.h>
 #include <vtkUnstructuredGrid.h>
 #include <vtkVoxel.h>
 #include <vtkWedge.h>
+
+#include <vector>
+#include <map>
 using namespace std;
 
+
 #ifdef _DEBUG_
 static int MYDEBUG = 0;
 static int MYDEBUGWITHFILES = 0;
@@ -62,7 +68,6 @@ static int MYDEBUGWITHFILES = 0;
 vtkCxxRevisionMacro(SALOME_GeometryFilter, "$Revision$");
 vtkStandardNewMacro(SALOME_GeometryFilter);
 
-
 SALOME_GeometryFilter::SALOME_GeometryFilter(): 
   myShowInside(0),
   myStoreMapping(0)
@@ -125,7 +130,7 @@ void SALOME_GeometryFilter::UnstructuredGridExecute()
   vtkPointData *outputPD = output->GetPointData();
   
   vtkCellData *outputCD = output->GetCellData();
-  vtkCellArray *Verts, *Lines, *Polys, *Strips;
+  //vtkCellArray *Verts, *Lines, *Polys, *Strips;
   vtkIdList *cellIds, *faceIds;
   char *cellVis;
   vtkIdType newCellId;
@@ -308,15 +313,28 @@ void SALOME_GeometryFilter::UnstructuredGridExecute()
           break;
          
        case VTK_CONVEX_POINT_SET:{
-         vtkCell* aCell = input->GetCell(cellId);
-         int aNbFaces = aCell->GetNumberOfFaces();
-         for (faceId=0; faceId < aNbFaces; faceId++){
-           vtkCell *aFace = aCell->GetFace(faceId);
-           numFacePts = aFace->GetNumberOfPoints();
-           aCellType = aFace->GetCellType();
-           for ( i=0; i < numFacePts; i++)
+         TCellArray tmpCellArray;
+         try{
+           CONVEX_TOOL::GetPolygonalFaces(input,cellId,tmpCellArray); // "SALOME_ConvexTool.cxx"
+         } catch (const std::exception& theExc){
+           cout << __FILE__ << "[" << __LINE__ << "] " << "Exception:" << theExc.what() << endl;
+         } catch (...) {
+           cout << __FILE__ << "[" << __LINE__ << "] " << "Exception was occured"<< endl;
+         }
+         TCellArray::iterator aFaceIter = tmpCellArray.begin();
+         for (;  aFaceIter!=tmpCellArray.end(); aFaceIter++){
+           TCell cell = aFaceIter->second;
+           numFacePts = cell.size();
+           if(numFacePts>3)
+             aCellType = VTK_POLYGON;
+           else if(numFacePts == 3)
+             aCellType = VTK_TRIANGLE;
+           else if(numFacePts<3)
+             continue;
+           
+           for ( i=0; i < numFacePts; i++)
              {
-               aNewPts[i] = aFace->GetPointId(i);
+               aNewPts[i] = cell[i];
              }
            newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
            if(myStoreMapping){