FIX: loading stl with NaN points crashes

Avoid loading NaN points.

Jira: STUDIO-3889
Change-Id: I8c00f24e0ae1ba3b637e5d9bb13de93b1b4e77ba
(cherry picked from commit 0d244c7f65b913922ca4fad59d93fd80725f2e49)
This commit is contained in:
Arthur 2023-08-14 18:05:22 +08:00 committed by Lane.Wei
parent ec91e700d8
commit 7e70e071e9
1 changed files with 11 additions and 1 deletions

View File

@ -237,7 +237,17 @@ static bool stl_read(stl_file *stl, FILE *fp, int first_facet, bool first, Impor
}
#endif
// Write the facet into memory.
// Write the facet into memory if none of facet vertices is NAN.
bool someone_is_nan = false;
for (size_t j = 0; j < 3; ++j) {
if (isnan(facet.vertex[j](0)) || isnan(facet.vertex[j](1)) || isnan(facet.vertex[j](2))) {
someone_is_nan = true;
break;
}
}
if(someone_is_nan)
continue;
stl->facet_start[i] = facet;
stl_facet_stats(stl, facet, first);
}