commit ec8bd77a3b42a4c7e397d09c7ac5f16faf327f80
parent 27da621f84f64ffece50e28384cd1b4d528b7b3e
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date: Tue, 3 Dec 2019 14:22:45 +0100
Add report dumps
Diffstat:
8 files changed, 273 insertions(+), 60 deletions(-)
diff --git a/src/sg3_device.c b/src/sg3_device.c
@@ -137,4 +137,3 @@ log_warn(struct sg3_device* dev, const char* msg, ...)
log_msg(dev, LOG_WARNING, msg, vargs_list);
va_end(vargs_list);
}
-
diff --git a/src/sg3_geometry.c b/src/sg3_geometry.c
@@ -18,6 +18,8 @@
#include "sg3_device.h"
#include "sg3_report.h"
+#include <limits.h>
+
/*******************************************************************************
* Helper functions
******************************************************************************/
@@ -28,18 +30,29 @@ geometry_release(ref_T* ref)
ASSERT(ref);
geometry = CONTAINER_OF(ref, struct sg3_geometry, ref);
- darray_triangle_release(&geometry->unique_triangles);
- darray_vertex_release(&geometry->unique_vertices);
+ v_n_t_ref_put(geometry->v_n_t);
htable_trg_release(&geometry->unique_triangles_ids);
htable_vrtx_release(&geometry->unique_vertices_ids);
if(geometry->report) {
- /* Don't reset geometry->report->associated!!! */
sg3_report_ref_put(geometry->report);
+ /* Don't reset geometry->report->associated!!! */
}
MEM_RM(geometry->dev->allocator, geometry);
}
+static void
+v_n_t_release(ref_T* ref)
+{
+ struct v_n_t* v_n_t;
+ ASSERT(ref);
+ v_n_t = CONTAINER_OF(ref, struct v_n_t, ref);
+
+ darray_triangle_release(&v_n_t->unique_triangles);
+ darray_vertex_release(&v_n_t->unique_vertices);
+ MEM_RM(v_n_t->dev->allocator, v_n_t);
+}
+
static FINLINE int /* Return 1 if reversed */
trg_make_key(struct unsigned3* k, const unsigned t[3])
{
@@ -133,8 +146,7 @@ sg3_geometry_create
}
geometry->dev = dev;
- darray_triangle_init(dev->allocator, &geometry->unique_triangles);
- darray_vertex_init(dev->allocator, &geometry->unique_vertices);
+ ERR(v_n_t_create(dev, &geometry->v_n_t));
htable_trg_init(dev->allocator, &geometry->unique_triangles_ids);
htable_vrtx_init(dev->allocator, &geometry->unique_vertices_ids);
geometry->triangle_count_including_duplicates = 0;
@@ -142,18 +154,22 @@ sg3_geometry_create
geometry->set_id = 0;
geometry->report = report;
+ ref_init(&geometry->ref);
+
if(report) {
report->associated = 1;
+ report->v_n_t = geometry->v_n_t;
sg3_report_ref_get(report);
+ /* The report has a reference on v_n_t */
+ v_n_t_ref_get(geometry->v_n_t);
}
- ref_init(&geometry->ref);
-
exit:
if(out_geometry) *out_geometry = geometry;
return res;
error:
if(geometry) {
+ if(geometry->v_n_t) v_n_t_ref_put(geometry->v_n_t);
SG3(geometry_ref_put(geometry));
geometry = NULL;
}
@@ -172,7 +188,7 @@ sg3_geometry_add
res_T(*add_trg)(const unsigned, const unsigned, void*), /* Can be NULL */
res_T(*merge_trg) /* Can be NULL */
(const unsigned, const unsigned, const int, unsigned*, const unsigned*,
- void*),
+ void*, int*),
void* ctx) /* Can be NULL */
{
res_T res = RES_OK;
@@ -192,14 +208,14 @@ sg3_geometry_add
}
alloc = geom->dev->allocator;
- nuverts = darray_vertex_size_get(&geom->unique_vertices);
- nutris = darray_triangle_size_get(&geom->unique_triangles);
+ nuverts = darray_vertex_size_get(&geom->v_n_t->unique_vertices);
+ nutris = darray_triangle_size_get(&geom->v_n_t->unique_triangles);
/* Make room for new geometry; suppose no more duplicates */
darray_uint_init(alloc, &unique_vertice_ids);
ERR(darray_uint_reserve(&unique_vertice_ids, nverts));
- ERR(darray_vertex_reserve(&geom->unique_vertices, nuverts + nverts));
- ERR(darray_triangle_reserve(&geom->unique_triangles, nutris + ntris));
+ ERR(darray_vertex_reserve(&geom->v_n_t->unique_vertices, nuverts + nverts));
+ ERR(darray_triangle_reserve(&geom->v_n_t->unique_triangles, nutris + ntris));
ERR(htable_vrtx_reserve(&geom->unique_vertices_ids, nuverts + nverts));
ERR(htable_trg_reserve(&geom->unique_triangles_ids, nutris + ntris));
if(geom->report) {
@@ -223,7 +239,7 @@ sg3_geometry_add
ASSERT(nuverts + actual_nuverts < UINT_MAX);
unique_v = (unsigned)(nuverts + actual_nuverts);
ASSERT(unique_v == htable_vrtx_size_get(&geom->unique_vertices_ids));
- ERR(darray_vertex_push_back(&geom->unique_vertices, &tmp));
+ ERR(darray_vertex_push_back(&geom->v_n_t->unique_vertices, &tmp));
ERR(htable_vrtx_set(&geom->unique_vertices_ids, &tmp, &unique_v));
++actual_nuverts;
}
@@ -232,9 +248,10 @@ sg3_geometry_add
}
/* Get triangles and deduplicate */
- trg = darray_triangle_data_get(&geom->unique_triangles);
+ trg = darray_triangle_data_get(&geom->v_n_t->unique_triangles);
FOR_EACH(i, 0, ntris) {
int j, reversed;
+ int merge_conflict = 0;
struct unsigned3 trg_key;
struct triangle tmp = TRG_UNDEF__;
unsigned* p_trg;
@@ -277,23 +294,26 @@ sg3_geometry_add
unsigned* uprop;
ASSERT(trg_key_eq(&trg_key, &utrg_key));
unique_id = *p_trg;
- if(!same) SWAP(unsigned, tmp.properties[SG3_FRONT], tmp.properties[SG3_BACK]);
+ if(!same)
+ SWAP(unsigned, tmp.properties[SG3_FRONT], tmp.properties[SG3_BACK]);
uprop = trg[*p_trg].properties;
if(merge_trg) {
/* Let the client app rule. */
ERR(merge_trg(trg[*p_trg].global_id, i, same, uprop, tmp.properties,
- ctx));
- /* If merge_triangle returns OK its OK even if media are incompatible. */
+ ctx, &merge_conflict));
+ /* If merge_triangle returns OK its OK even if media are incompatible */
} else {
FOR_EACH(j, 0, SG3_PROP_TYPES_COUNT__) {
if(!compatible_property(j, uprop[j], tmp.properties[j])) {
res = RES_BAD_ARG;
+ merge_conflict = 1;
goto error;
}
}
}
- /* Legit duplicate (or accepted by merge_triangle): replace undef media. */
- upd_ptr = darray_triangle_data_get(&geom->unique_triangles) + *p_trg;
+ /* Legit duplicate (or accepted by merge_triangle): replace undef media */
+ upd_ptr = darray_triangle_data_get(&geom->v_n_t->unique_triangles)
+ + *p_trg;
/* Replace possible undefined media */
FOR_EACH(j, 0, SG3_PROP_TYPES_COUNT__) {
if(upd_ptr->properties[j] == SG3_UNDEFINED_PROPERTY
@@ -309,7 +329,7 @@ sg3_geometry_add
unique_id = (unsigned)(nutris + actual_nutris);
if(add_trg)
ERR(add_trg(tmp.global_id, i, ctx));
- ERR(darray_triangle_push_back(&geom->unique_triangles, &tmp));
+ ERR(darray_triangle_push_back(&geom->v_n_t->unique_triangles, &tmp));
FOR_EACH(j, 0, SG3_PROP_TYPES_COUNT__) {
if((j == SG3_FRONT || j == SG3_BACK)
&& tmp.properties[j] != SG3_UNDEFINED_PROPERTY)
@@ -321,8 +341,10 @@ sg3_geometry_add
}
++actual_ntris;
/* Register triangle in report */
- if(geom->report)
- ERR(report_record_triangle(geom->report, &tmp, unique_id, geom->set_id));
+ if(geom->report) {
+ ERR(report_record_triangle(geom->report, &tmp, unique_id, geom->set_id,
+ merge_conflict));
+ }
}
ASSERT(nuverts + actual_nuverts
@@ -354,3 +376,56 @@ sg3_geometry_ref_put(struct sg3_geometry* geometry)
ref_put(&geometry->ref, geometry_release);
return RES_OK;
}
+
+/*******************************************************************************
+ * Local functions
+ ******************************************************************************/
+res_T
+v_n_t_create
+ (struct sg3_device* dev,
+ struct v_n_t** out_v_n_t)
+{
+ struct v_n_t* v_n_t = NULL;
+ res_T res = RES_OK;
+
+ if(!dev || !out_v_n_t) {
+ res = RES_BAD_ARG;
+ goto error;
+ }
+
+ v_n_t = MEM_CALLOC(dev->allocator, 1, sizeof(struct v_n_t));
+ if(!v_n_t) {
+ log_err(dev,
+ "%s: could not allocate the star-geometry v_n_t.\n", FUNC_NAME);
+ res = RES_MEM_ERR;
+ goto error;
+ }
+ v_n_t->dev = dev;
+ darray_triangle_init(dev->allocator, &v_n_t->unique_triangles);
+ darray_vertex_init(dev->allocator, &v_n_t->unique_vertices);
+ ref_init(&v_n_t->ref);
+
+exit:
+ if(out_v_n_t) *out_v_n_t = v_n_t;
+ return res;
+error:
+ if(v_n_t) {
+ v_n_t_ref_put(v_n_t);
+ v_n_t = NULL;
+ }
+ goto exit;
+}
+
+void
+v_n_t_ref_get(struct v_n_t* dev)
+{
+ ASSERT(dev);
+ ref_get(&dev->ref);
+}
+
+void
+v_n_t_ref_put(struct v_n_t* dev)
+{
+ ASSERT(dev);
+ ref_put(&dev->ref, v_n_t_release);
+}
+\ No newline at end of file
diff --git a/src/sg3_geometry_c.h b/src/sg3_geometry_c.h
@@ -25,7 +25,6 @@
/* Forward declaration of external opaque data types */
-
/*******************************************************************************
* A type to store triangles
******************************************************************************/
@@ -56,6 +55,28 @@ struct vertex {
#include <rsys/dynamic_array.h>
/*******************************************************************************
+ * A type to share vertices and triangles with reports
+ ******************************************************************************/
+struct v_n_t {
+ /* Record unique (i.e. deduplicated) triangles */
+ struct darray_triangle unique_triangles;
+ /* Record coordinates for unique (i.e. deduplicated) vertices */
+ struct darray_vertex unique_vertices;
+
+ struct sg3_device* dev;
+ ref_T ref;
+};
+
+extern res_T
+v_n_t_create(struct sg3_device* dev, struct v_n_t** v_n_t);
+
+extern void
+v_n_t_ref_get(struct v_n_t* dev);
+
+extern void
+v_n_t_ref_put(struct v_n_t* dev);
+
+/*******************************************************************************
* A type to map triangle vertices to IDs in unique_triangles
******************************************************************************/
struct unsigned3 { unsigned x[3]; };
@@ -96,10 +117,8 @@ vrtx_eq(const struct vertex* v1, const struct vertex* v2)
#include <rsys/hash_table.h>
struct sg3_geometry {
- /* Record unique (i.e. deduplicated) triangles */
- struct darray_triangle unique_triangles;
- /* Record coordinates for unique (i.e. deduplicated) vertices */
- struct darray_vertex unique_vertices;
+ /* Record unique (i.e. deduplicated) vertices and triangles */
+ struct v_n_t* v_n_t;
/* A table to map triangle vertices to IDs in unique_triangles */
struct htable_trg unique_triangles_ids;
@@ -116,5 +135,4 @@ struct sg3_geometry {
ref_T ref;
};
-
#endif /* SG3_GEOMETRY_C_H__ */
diff --git a/src/sg3_report.c b/src/sg3_report.c
@@ -29,6 +29,7 @@ report_release(ref_T* ref)
struct sg3_report* report;
ASSERT(ref);
report = CONTAINER_OF(ref, struct sg3_report, ref);
+ v_n_t_ref_put(report->v_n_t);
darray_accumulated_set_release(&report->accumulated_sets);
darray_trg_descriptions_release(&report->trg_descriptions);
MEM_RM(report->dev->allocator, report);
@@ -42,17 +43,16 @@ report_record_triangle
(struct sg3_report* report,
const struct triangle* triangle,
const unsigned triangle_unique_id,
- const unsigned set_id)
+ const unsigned set_id,
+ const int merge_conflict)
{
res_T res = RES_OK;
struct trg_descriptions* trg_d;
- struct accumulated_set* set;
int i;
ASSERT(report && triangle
&& set_id < darray_accumulated_set_size_get(&report->accumulated_sets));
- set = darray_accumulated_set_data_get(&report->accumulated_sets) + set_id;
trg_d = (darray_trg_descriptions_data_get(&report->trg_descriptions)
+ triangle_unique_id);
/* Record information */
@@ -71,30 +71,33 @@ report_record_triangle
size_t k;
FOR_EACH(k, 0, darray_uint_size_get(&defs[j].set_ids)) {
if(ids[k] == set_id) {
- /* Same information was there already */
+ /* Same value+set_id was there already */
done = 1;
break;
}
}
if(!done) {
- /* Need to add the set_id */
+ /* Need to add the set_id for this value */
ERR(darray_uint_push_back(&defs[j].set_ids, &set_id));
done = 1;
}
break;
}
}
+ ASSERT(merge_conflict|| done);
if(!done) {
/* This value was not listed already */
struct definition new_def;
new_def.property_value = triangle->properties[i];
+ ASSERT(merge_conflict == (darray_definition_size_get(definitions) > 0));
darray_uint_init(report->dev->allocator, &new_def.set_ids);
ERR(darray_uint_push_back(&new_def.set_ids, &set_id));
darray_definition_push_back(definitions, &new_def);
if(!trg_d->merge_conflict
&& (darray_definition_size_get(definitions) > 1))
{
- trg_d->merge_conflict = 1;
+ /* If more than 1 merge_conflict occur, the first one remains */
+ trg_d->merge_conflict = merge_conflict;
report->merge_conflict_count++;
}
}
@@ -106,6 +109,41 @@ error:
goto exit;
}
+static void
+dump_partition
+ (const struct sg3_report* report,
+ FILE* stream,
+ const char* group_name,
+ enum sg3_report_dump_content partition)
+{
+ const struct trg_descriptions* trg_descriptions;
+ const struct triangle* triangles;
+ size_t sz, i;
+ ASSERT(report && stream && group_name);
+ ASSERT(partition == SG3_MERGE_CONFLICTS
+ || partition == SG3_PROPERTY_CONFLICTS
+ || partition == SG3_VALID_TRIANGLE);
+ trg_descriptions
+ = darray_trg_descriptions_cdata_get(&report->trg_descriptions);
+ sz = darray_trg_descriptions_size_get(&report->trg_descriptions);
+ triangles = darray_triangle_cdata_get(&report->v_n_t->unique_triangles);
+ fprintf(stream, "g %s\n", group_name);
+ FOR_EACH(i, 0, sz) {
+ int dump;
+ if(partition == SG3_VALID_TRIANGLE)
+ dump = !(trg_descriptions[i].merge_conflict
+ || trg_descriptions[i].properties_conflict);
+ else if(partition == SG3_MERGE_CONFLICTS)
+ dump = trg_descriptions[i].merge_conflict;
+ else {
+ ASSERT(partition == SG3_MERGE_CONFLICTS);
+ dump = trg_descriptions[i].properties_conflict;
+ }
+ if(!dump) continue;
+ fprintf(stream, "f %u %u %u\n", SPLIT3(triangles[i].vertex_ids));
+ }
+}
+
/*******************************************************************************
* Exported functions
******************************************************************************/
@@ -159,7 +197,11 @@ sg3_report_validate_properties
struct trg_descriptions* trg_descriptions;
res_T res = RES_OK;
- if (!report || !validate) {
+ if(!report || !validate || !report->associated) {
+ if(report && !report->associated)
+ log_err(report->dev,
+ "%s: report is not associated to a geometry\n",
+ FUNC_NAME);
res = RES_BAD_ARG;
goto error;
}
@@ -200,7 +242,11 @@ sg3_report_get_merge_conflict_count
unsigned* count)
{
res_T res = RES_OK;
- if(!report || !count) {
+ if(!report || !count || !report->associated) {
+ if(report && !report->associated)
+ log_err(report->dev,
+ "%s: report is not associated to a geometry\n",
+ FUNC_NAME);
res = RES_BAD_ARG;
goto error;
}
@@ -217,7 +263,11 @@ sg3_report_get_properties_conflict_count
unsigned* count)
{
res_T res = RES_OK;
- if(!report || !count) {
+ if(!report || !count || !report->associated) {
+ if(report && !report->associated)
+ log_err(report->dev,
+ "%s: report is not associated to a geometry\n",
+ FUNC_NAME);
res = RES_BAD_ARG;
goto error;
}
@@ -235,10 +285,41 @@ sg3_report_dump_as_obj
int flags)
{
res_T res = RES_OK;
- if (!report || !stream || !flags) {
+ const struct vertex* vertices;
+ size_t sz, i;
+ if(!report || !stream || !flags || !report->associated) {
+ if(report && !report->associated)
+ log_err(report->dev,
+ "%s: report is not associated to a geometry\n",
+ FUNC_NAME);
res = RES_BAD_ARG;
goto error;
}
+ vertices = darray_vertex_cdata_get(&report->v_n_t->unique_vertices);
+ /* Headers */
+ fprintf(stream, "# Dump of star-geometry report\n");
+ fprintf(stream, "# Geometry counts:\n");
+ sz = darray_vertex_size_get(&report->v_n_t->unique_vertices);
+ ASSERT(sz <= UINT_MAX);
+ fprintf(stream, "# . %u vertices\n", (unsigned)0000000000);
+ sz = darray_triangle_size_get(&report->v_n_t->unique_triangles);
+ ASSERT(sz <= UINT_MAX);
+ fprintf(stream, "# . %u triangles\n", (unsigned)sz);
+ fprintf(stream,
+ "# . %u triangles flagged with a merge conflict\n",
+ report->merge_conflict_count);
+ fprintf(stream,
+ "# . %u triangles flagged with a property conflict\n",
+ report->merge_conflict_count);
+
+ /* Dump vertices */
+ FOR_EACH(i, 0, sz)
+ fprintf(stream, "v %f %f %f\n", SPLIT3(vertices[i].coord));
+
+ /* Dump triangles by groups */
+ dump_partition(report, stream, "Merge conflicts", SG3_MERGE_CONFLICTS);
+ dump_partition(report, stream, "Property conflicts", SG3_PROPERTY_CONFLICTS);
+ dump_partition(report, stream, "Valid triangles", SG3_VALID_TRIANGLE);
exit:
return res;
diff --git a/src/sg3_report.h b/src/sg3_report.h
@@ -25,14 +25,14 @@
#include <rsys/dynamic_array_uint.h>
#include <rsys/dynamic_array.h>
-#include <limits.h>
-
/* Forward declarations */
struct mem_allocator;
struct sg3_device;
struct sg3_report;
struct darray_description;
struct triangle;
+struct sg3_geometry;
+struct v_n_t;
/*******************************************************************************
* Types to record sources and values of triangle descriptions.
@@ -46,8 +46,6 @@ struct definition {
/* The IDs of the geometry sets that defined the value */
struct darray_uint set_ids;
};
-#define INVALID_RANK UINT_MAX
-#define INVALID_VALUE UINT_MAX
static FINLINE void
init_definition
@@ -55,7 +53,7 @@ init_definition
struct definition* data)
{
ASSERT(alloc && data);
- data->property_value = INVALID_VALUE;
+ data->property_value = SG3_UNDEFINED_PROPERTY;
darray_uint_init(alloc, &data->set_ids);
}
@@ -93,7 +91,7 @@ release_definition
* If there is more than 1 definition / field, it is a conflict */
struct trg_descriptions {
struct darray_definition defs[SG3_PROP_TYPES_COUNT__];
- char merge_conflict;
+ int merge_conflict;
int properties_conflict;
};
@@ -151,7 +149,7 @@ init_trg_intfaceid
unsigned* data)
{
ASSERT(data); (void)alloc;
- *data = INVALID_VALUE;
+ *data = SG3_UNDEFINED_PROPERTY;
}
#define DARRAY_NAME intface_id
@@ -174,7 +172,7 @@ init_accumulated_set
{
ASSERT(alloc && set);
str_init(alloc, &set->set_name);
- set->prop_value = INVALID_VALUE;
+ set->prop_value = SG3_UNDEFINED_PROPERTY;
}
static FINLINE void
@@ -215,6 +213,8 @@ struct sg3_report {
struct darray_accumulated_set accumulated_sets;
/* Record which set defined what */
struct darray_trg_descriptions trg_descriptions;
+ /* Record unique (i.e. deduplicated) vertices and triangles */
+ struct v_n_t* v_n_t;
/* Counts */
unsigned merge_conflict_count;
unsigned properties_conflict_count;
@@ -232,6 +232,7 @@ report_record_triangle
(struct sg3_report* report,
const struct triangle* triangle,
const unsigned triangle_unique_id,
- const unsigned set_id);
+ const unsigned set_id,
+ const int merge_conflict);
#endif /* SG3_REPORT_H__ */
diff --git a/src/star-geometry.h b/src/star-geometry.h
@@ -69,7 +69,10 @@ enum sg3_property_type {
******************************************************************************/
enum sg3_report_dump_content {
SG3_MERGE_CONFLICTS = BIT(0),
- SG3_PROPERTY_CONFLICTS = BIT(1)
+ SG3_PROPERTY_CONFLICTS = BIT(1),
+ SG3_VALID_TRIANGLE = BIT(2),
+ SG3_ALL_TRIANGLES =
+ SG3_MERGE_CONFLICTS | SG3_PROPERTY_CONFLICTS | SG3_VALID_TRIANGLE
};
/*******************************************************************************
@@ -144,11 +147,14 @@ sg3_report_get_properties_conflict_count
(const struct sg3_report* report,
unsigned* count);
-/* Dump a report in the provided stream in the OBJ format.
- * The dump is made of vertices and triangles that have been added to the
- * geometry associated with this report
+/* Dump a report in the provided stream in the OBJ format. The report must have
+ * been associatd to a geometry or dump will end in error.
+ * The OBJ dump is made of vertices and triangles, without and property, that
+ * have been added to the geometry associated with this report.
* The part of the report that is dumped is defined by the flags argument,
- * that should be ORed enum sg3_report_dump_content values. */
+ * that should be ORed enum sg3_report_dump_content values.
+ * If more than 1 flag is used, triangle partitions are dumped in different
+ * OBJ groups. */
SG3_API res_T
sg3_report_dump_as_obj
(const struct sg3_report* report,
@@ -229,13 +235,16 @@ sg3_geometry_add
* its own triangle data and rule merge validity.
* The reversed_triangle arg indicates if the triangle vertices' order is
* the same it was when the triangle was first added.
+ * The merge_conflict argument can be set to any value. Any non-0 value
+ * is accounted for a conflict and is kept as-is in report dumps, allowing
+ * different shades of conflict to be reported.
* triangle_properties and merged_properties contain the involved properties.
* If return is not RES_OK, sg3_geometry_add stops immediately and returns
* whatever value merge_triangle returned. */
res_T(*merge_triangle) /* Can be NULL */
(const unsigned global_id, const unsigned itri, const int reversed_triangle,
unsigned triangle_properties[3], const unsigned merged_properties[3],
- void* context),
+ void* context, int* merge_conflict),
void* context); /* Can be NULL */
SG3_API res_T
diff --git a/src/test_sg3_geometry.c b/src/test_sg3_geometry.c
@@ -42,7 +42,6 @@ main(int argc, char** argv)
OK(sg3_geometry_ref_put(geometry));
OK(sg3_geometry_ref_put(geometry));
-
OK(sg3_report_create(dev, &report));
OK(sg3_geometry_create(dev, report, &geometry));
/* Cannot associate 2 geometries to the same report */
@@ -57,4 +56,3 @@ main(int argc, char** argv)
CHK(mem_allocated_size() == 0);
return 0;
}
-
diff --git a/src/test_sg3_report.c b/src/test_sg3_report.c
@@ -18,6 +18,8 @@
#include <rsys/logger.h>
+#include <stdio.h>
+
static res_T
validate
(const unsigned itri,
@@ -36,6 +38,7 @@ main(int argc, char** argv)
struct mem_allocator allocator;
struct sg3_device* dev;
struct sg3_report* report;
+ struct sg3_geometry* geometry;
unsigned count;
(void)argc, (void)argv;
@@ -55,21 +58,50 @@ main(int argc, char** argv)
BA(sg3_report_validate_properties(NULL, NULL, NULL));
BA(sg3_report_validate_properties(report, NULL, NULL));
BA(sg3_report_validate_properties(NULL, validate, NULL));
- OK(sg3_report_validate_properties(report, validate, NULL));
+ /* Not associated to a geometry */
+ BA(sg3_report_validate_properties(report, validate, NULL));
BA(sg3_report_get_merge_conflict_count(NULL, NULL));
BA(sg3_report_get_merge_conflict_count(report, NULL));
BA(sg3_report_get_merge_conflict_count(NULL, &count));
- OK(sg3_report_get_merge_conflict_count(report, &count));
- CHK(count == 0);
+ /* Not associated to a geometry */
+ BA(sg3_report_get_merge_conflict_count(report, &count));
BA(sg3_report_get_properties_conflict_count(NULL, NULL));
BA(sg3_report_get_properties_conflict_count(report, NULL));
BA(sg3_report_get_properties_conflict_count(NULL, &count));
+ /* Not associated to a geometry */
+ BA(sg3_report_get_properties_conflict_count(report, &count));
+
+ BA(sg3_report_dump_as_obj(NULL, NULL, 0));
+ BA(sg3_report_dump_as_obj(report, NULL, 0));
+ BA(sg3_report_dump_as_obj(NULL, stdout, 0));
+ BA(sg3_report_dump_as_obj(NULL, NULL, SG3_ALL_TRIANGLES));
+ BA(sg3_report_dump_as_obj(report, stdout, 0));
+ BA(sg3_report_dump_as_obj(report, NULL, SG3_ALL_TRIANGLES));
+ BA(sg3_report_dump_as_obj(NULL, stdout, SG3_ALL_TRIANGLES));
+ /* Not associated to a geometry */
+ BA(sg3_report_dump_as_obj(report, stdout, SG3_ALL_TRIANGLES));
+
+ OK(sg3_geometry_create(dev, report, &geometry));
+ OK(sg3_report_validate_properties(report, validate, NULL));
+ OK(sg3_report_get_merge_conflict_count(report, &count));
+ CHK(count == 0);
OK(sg3_report_get_properties_conflict_count(report, &count));
CHK(count == 0);
+ OK(sg3_report_dump_as_obj(report, stdout, SG3_ALL_TRIANGLES));
+ OK(sg3_geometry_ref_put(geometry));
+ OK(sg3_report_ref_put(report));
+
+ OK(sg3_report_create(dev, &report));
+ OK(sg3_geometry_create(dev, report, &geometry));
+
+
+
+ OK(sg3_geometry_ref_put(geometry));
OK(sg3_report_ref_put(report));
+
OK(sg3_device_ref_put(dev));
check_memory_allocator(&allocator);
@@ -77,4 +109,3 @@ main(int argc, char** argv)
CHK(mem_allocated_size() == 0);
return 0;
}
-