comparison OrthancStone/Sources/Toolbox/DicomStructureSet.cpp @ 1916:bd527bbc34df

cppcheck
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sun, 20 Mar 2022 18:23:39 +0100
parents f81cdf283859
children 98952be6fb97
comparison
equal deleted inserted replaced
1915:0d1235ca4abc 1916:bd527bbc34df
915 { 915 {
916 // Compute the normal of the polygon using 3 successive points 916 // Compute the normal of the polygon using 3 successive points
917 Vector normal; 917 Vector normal;
918 bool valid = false; 918 bool valid = false;
919 919
920 for (size_t i = 0; i + 2 < points.size(); i++) 920 for (size_t j = 0; j + 2 < points.size(); j++)
921 { 921 {
922 const Vector& a = points[i]; 922 const Vector& a = points[j];
923 const Vector& b = points[i + 1]; 923 const Vector& b = points[j + 1];
924 const Vector& c = points[i + 2]; 924 const Vector& c = points[j + 2];
925 LinearAlgebra::CrossProduct(normal, b - a, c - a); // (*) 925 LinearAlgebra::CrossProduct(normal, b - a, c - a); // (*)
926 LinearAlgebra::NormalizeVector(normal); 926 LinearAlgebra::NormalizeVector(normal);
927 927
928 if (LinearAlgebra::IsNear(boost::numeric::ublas::norm_2(normal), 1.0)) // (**) 928 if (LinearAlgebra::IsNear(boost::numeric::ublas::norm_2(normal), 1.0)) // (**)
929 { 929 {
935 if (valid) 935 if (valid)
936 { 936 {
937 // Check that all the points of the polygon lie in the plane defined by the normal 937 // Check that all the points of the polygon lie in the plane defined by the normal
938 double d1 = GeometryToolbox::ProjectAlongNormal(points[0], normal); 938 double d1 = GeometryToolbox::ProjectAlongNormal(points[0], normal);
939 939
940 for (size_t i = 1; i < points.size(); i++) 940 for (size_t j = 1; j < points.size(); j++)
941 { 941 {
942 double d2 = GeometryToolbox::ProjectAlongNormal(points[i], normal); 942 double d2 = GeometryToolbox::ProjectAlongNormal(points[j], normal);
943 943
944 if (!LinearAlgebra::IsNear(d1, d2)) 944 if (!LinearAlgebra::IsNear(d1, d2))
945 { 945 {
946 valid = false; 946 valid = false;
947 break; 947 break;