From 3910d1b03597e35a145fe9c3c4e17db70287d312 Mon Sep 17 00:00:00 2001 From: enk Date: Tue, 26 Apr 2005 12:20:57 +0000 Subject: [PATCH] Added culculation of polygons by triangles for vtkConvexPointSet --- src/VTKFilter/Makefile.in | 6 ++-- src/VTKFilter/SALOME_GeometryFilter.cxx | 38 ++++++++++++++++++------- 2 files changed, 32 insertions(+), 12 deletions(-) diff --git a/src/VTKFilter/Makefile.in b/src/VTKFilter/Makefile.in index e8297f1f8..12cb23883 100644 --- a/src/VTKFilter/Makefile.in +++ b/src/VTKFilter/Makefile.in @@ -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 diff --git a/src/VTKFilter/SALOME_GeometryFilter.cxx b/src/VTKFilter/SALOME_GeometryFilter.cxx index 3fab9df81..5092e22fc 100644 --- a/src/VTKFilter/SALOME_GeometryFilter.cxx +++ b/src/VTKFilter/SALOME_GeometryFilter.cxx @@ -27,7 +27,9 @@ // $Header$ #include "SALOME_GeometryFilter.h" +#include "SALOME_ConvexTool.h" +#include #include #include #include @@ -43,8 +45,12 @@ #include #include #include + +#include +#include 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){ -- 2.39.2