From a14f185b6d42f9d857fd575723fea5fc27b93686 Mon Sep 17 00:00:00 2001 From: jfa Date: Fri, 28 Oct 2005 09:58:41 +0000 Subject: [PATCH] Fix for bug 10411: Attempt to create polyhedral volume calls error message --- src/VTKViewer/VTKViewer_ConvexTool.cxx | 37 +++++++++++++------------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/src/VTKViewer/VTKViewer_ConvexTool.cxx b/src/VTKViewer/VTKViewer_ConvexTool.cxx index 1c4a8a710..64e712e97 100644 --- a/src/VTKViewer/VTKViewer_ConvexTool.cxx +++ b/src/VTKViewer/VTKViewer_ConvexTool.cxx @@ -41,26 +41,27 @@ static float FACE_ANGLE_TOLERANCE=1.5; * \param theptIds - point ids. * \retval center - output array[3] with coordinates of geometry center. */ -static void GetCenter(vtkUnstructuredGrid* theGrid,TCell theptIds,float *center) +static void GetCenter(vtkUnstructuredGrid* theGrid,TCell theptIds,float center[3]) { - float *p; + float p[3]; center[0] = center[1] = center[2] = 0.0; - - int numIds=theptIds.size(); + + int numIds = theptIds.size(); + if (numIds == 0) return; // get the center of the cell - for (int i=0; i < numIds; i++) + for (int i = 0; i < numIds; i++) + { + theGrid->GetPoint(theptIds[i], p); + for (int j = 0; j < 3; j++) { - p = theGrid->GetPoint(theptIds[i]); - for (int j=0; j < 3; j++) - { - center[j] += p[j]; - } - } - for (int j=0; j<3; j++) - { - center[j] /= numIds; + center[j] += p[j]; } + } + for (int j = 0; j < 3; j++) + { + center[j] /= numIds; + } } /*! \fn static void ReverseIds(TCell &theIds) @@ -350,18 +351,18 @@ void GetPolygonalFaces(vtkUnstructuredGrid* theGrid,int cellId,TCellArray &outpu int numPts = convex->GetNumberOfPoints(); TCell convex_ids; TPTOIDS p2faces; // key=pointId , value facesIds set - + for(int i=0;iGetPointId(i)); - + GetCenter(theGrid,convex_ids,convex_center); for (vtkIdType faceId=0; faceId < aNbFaces; faceId++){ vtkCell *aFace = convex->GetFace(faceId); int numFacePts = aFace->GetNumberOfPoints(); TCell aIds; - - int i = 0; + + int i = 0; for(i=0;iGetPointId(i)); -- 2.39.2