commit 58f40f4f4f9b7c2010ce8dc9a5971bec69276638
parent c2aa0872de96d6fa765fb5ee2b476b3cdc7d8cb3
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date: Thu, 11 Jun 2020 10:33:47 +0200
Add log of degenerated triangles
Diffstat:
2 files changed, 45 insertions(+), 4 deletions(-)
diff --git a/src/stardis-parsing.c b/src/stardis-parsing.c
@@ -159,6 +159,21 @@ add_geom_ctx_position
d3_set_f3(pos, v);
}
+res_T
+add_geom_keep_degenerated
+ (const unsigned itri,
+ void* context,
+ int* abort)
+{
+ const struct add_geom_ctx* ctx = context;
+ struct darray_uint* degenerated;
+
+ ASSERT(abort && ctx && ctx->custom);
+ ASSERT(itri < ctx->stl_desc.triangles_count);
+ degenerated = ctx->custom;
+ return darray_uint_push_back(degenerated, &itri);
+}
+
static res_T
read_sides_and_files
(struct stardis* stardis,
@@ -172,13 +187,19 @@ read_sides_and_files
struct add_geom_ctx add_geom_ctx;
unsigned current_merge_errors;
struct sg3d_geometry_add_callbacks callbacks = SG3D_ADD_CALLBACKS_NULL__;
+ struct darray_uint degenerated;
+ struct str str;
res_T res = RES_OK;
ASSERT(stardis && tok_ctx);
+ darray_uint_init(stardis->allocator, °enerated);
+ str_init(stardis->allocator, &str);
callbacks.get_indices = add_geom_ctx_indices;
callbacks.get_properties = add_geom_ctx_properties;
callbacks.get_position = add_geom_ctx_position;
+ callbacks.degenerated_triangle = add_geom_keep_degenerated;
+ add_geom_ctx.custom = °enerated;
ERR(sg3d_geometry_get_unique_triangles_with_merge_conflict_count(
stardis->geometry.sg3d, ¤t_merge_errors));
@@ -253,6 +274,18 @@ read_sides_and_files
(unsigned)add_geom_ctx.stl_desc.triangles_count,
&callbacks,
&add_geom_ctx);
+ if(darray_uint_size_get(°enerated)) {
+ size_t c, n;
+ const unsigned* ids = darray_uint_cdata_get(°enerated);
+ c = darray_uint_size_get(°enerated);
+ logger_print(stardis->logger, LOG_WARNING,
+ "File '%s' included %zu degenerated triangles (removed)\n", tk, c);
+ ERR(str_printf(&str, "Degenerated triangles IDs: %u", ids[0]));
+ FOR_EACH(n, 1, c) ERR(str_printf(&str, ", %u", ids[n]));
+ ERR(str_printf(&str, "\n", ids[n]));
+ logger_print(stardis->logger, LOG_OUTPUT, str_cget(&str));
+ darray_uint_clear(°enerated);
+ }
if(res != RES_OK) {
logger_print(stardis->logger, LOG_ERROR,
@@ -266,7 +299,7 @@ read_sides_and_files
int is_for_compute =
(stardis->mode & COMPUTE_MODES) && !(stardis->mode & MODE_DUMP_VTK);
logger_print(stardis->logger, (is_for_compute ? LOG_ERROR : LOG_WARNING),
- "Merge conflicts found reading file %s (%u triangles).\n",
+ "Merge conflicts found reading file '%s' (%u triangles).\n",
tk, merge_errors - current_merge_errors);
if(is_for_compute) {
res = RES_BAD_ARG;
@@ -277,6 +310,8 @@ read_sides_and_files
}
end:
+ darray_uint_release(°enerated);
+ str_release(&str);
if(sstl) SSTL(ref_put(sstl));
return res;
error:
diff --git a/src/stardis-parsing.h b/src/stardis-parsing.h
@@ -117,24 +117,30 @@ struct add_geom_ctx {
/* Possible callbacks for sg3d_geometry_add calls
* when void* context is a struct add_geom_ctx */
-extern LOCAL_SYM void
+extern LOCAL_SYM void
add_geom_ctx_indices
(const unsigned itri,
unsigned ids[3],
void* context);
-extern LOCAL_SYM void
+extern LOCAL_SYM void
add_geom_ctx_properties
(const unsigned itri,
unsigned prop[3],
void* context);
-extern LOCAL_SYM void
+extern LOCAL_SYM void
add_geom_ctx_position
(const unsigned ivert,
double pos[3],
void* context);
+extern LOCAL_SYM res_T
+add_geom_count_degenerate
+(const unsigned itri,
+ void* context,
+ int* abort);
+
#ifdef NDEBUG
#define DEFAULT_NTHREADS SDIS_NTHREADS_DEFAULT
#else