]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
Correct the computation of Cone properties
authorEl Hadi Moussi <moussi@phimeca.com>
Tue, 6 Aug 2024 15:47:13 +0000 (17:47 +0200)
committerEl Hadi Moussi <moussi@phimeca.com>
Tue, 6 Aug 2024 15:47:13 +0000 (17:47 +0200)
The size of q1_indices and q2_indices can be different

src/ShapeRecogn/Areas.cxx

index 5c2559f8ca5cd8f4dfc014269d69da83a0045691..f3d274fdf86c434b58b14da3131a5fc3ce0e35ca 100644 (file)
@@ -379,7 +379,8 @@ void Areas::computeConeProperties(mcIdType areaId)
     // std::vector<double> heights(q1_indices.size(), 0.0);
     // std::vector<double> distancesToApex(q1_indices.size(), 0.0);
     std::array<double, 3> p{0.0, 0.0, 0.0};
-    for (size_t i = 0; i < q1_indices.size(); ++i)
+    size_t min_q_size = std::min<size_t>(q1_indices.size(), q2_indices.size());
+    for (size_t i = 0; i < min_q_size; ++i)
     {
         for (size_t j = 0; j < 3; ++j)
             p[j] = (projectedNodes[3 * q1_indices[i] + j] - projectedNodes[3 * q2_indices[i] + j]);