From: enk Date: Wed, 22 Jun 2005 06:33:48 +0000 (+0000) Subject: Fix Bug IPAL8775: Unnecessary edges are created if to construct a oblique polyhedron. X-Git-Tag: T3_0_0_a4~58 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=7bc8528b24479ca7d61b0abdf47d0bfba34ea488;p=modules%2Fgui.git Fix Bug IPAL8775: Unnecessary edges are created if to construct a oblique polyhedron. --- diff --git a/src/VTKViewer/VTKViewer_ConvexTool.cxx b/src/VTKViewer/VTKViewer_ConvexTool.cxx index 80e7fee5e..f6e19392a 100644 --- a/src/VTKViewer/VTKViewer_ConvexTool.cxx +++ b/src/VTKViewer/VTKViewer_ConvexTool.cxx @@ -19,8 +19,9 @@ #include #include #include +#include -static float FACE_TOLERANCE = 0; +static float FACE_ANGLE_TOLERANCE=1.5; typedef std::set TUIDS; // unique ids typedef std::map TPTOIDS; // id points -> unique ids @@ -183,14 +184,18 @@ bool IsConnectedFacesOnOnePlane( vtkUnstructuredGrid* theGrid, } - float det = vtkMath::Determinant3x3(v1,v2,v3); -// float det = v1[0]*(v2[1]*v3[2]-v2[2]*v3[1]) - -// v1[1]*(v2[0]*v3[2]-v2[2]*v3[0]) + -// v1[2]*(v2[0]*v3[1]-v2[1]*v3[0]); - if(det < 0) - det = -det; + float vec_b1[3]; + vtkMath::Cross(v2,v1,vec_b1); + float vec_b2[3]; + vtkMath::Cross(v1,v3,vec_b2); + + float b1 = vtkMath::Norm(vec_b1); + + float b2 = vtkMath::Norm(vec_b2); - if( det <= FACE_TOLERANCE ) + float angle=180*acosf(vtkMath::Dot(vec_b1,vec_b2)/(b1*b2))/vtkMath::Pi(); + + if( angle <= FACE_ANGLE_TOLERANCE ) status = true; if (MYDEBUG){ for(int k=0;k<4;k++){ @@ -200,7 +205,7 @@ bool IsConnectedFacesOnOnePlane( vtkUnstructuredGrid* theGrid, } cout << p[k][2] << ") "; } - cout << endl; + cout << "angle="<2){