commit 07b0102d3ec3ab5e61beba7f4b9f68c5d685037e
parent 9d764a6e73f88e317d3fd049e41fa7714d140b81
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date: Wed, 5 Feb 2020 14:16:31 +0100
Rename everything sg2d (from sg2) for coherency reasons
Diffstat:
24 files changed, 906 insertions(+), 906 deletions(-)
diff --git a/README.md b/README.md
@@ -1,9 +1,9 @@
-Star-geometry-2D
+Star-geometry-2d
================
The purpose of this library is to help create clean and decorated 2D
geometries. These geometries are suitable to be partitioned into
-enclosures using the star-enclosures-2D library. It also provides
+enclosures using the star-enclosures-2d library. It also provides
mechanisms to construct segment-related app data, detect
inconsistencies and dump the resulting geometry in various formats (OBJ,
VTK, C code chunks).
@@ -11,7 +11,7 @@ VTK, C code chunks).
How to build
------------
-Star-geometry-2D relies on the [CMake](http://www.cmake.org) and the
+Star-geometry-2d relies on the [CMake](http://www.cmake.org) and the
[RCMake](https://gitlab.com/vaplv/rcmake/) package to build. It also
depends on the [RSys](https://gitlab.com/vaplv/rsys/) library.
@@ -26,7 +26,7 @@ Release notes
### Version 0.1
-First version and implementation of the Star-geometry-2D API.
+First version and implementation of the star-geometry-2d API.
- Creation of geometries in multiple steps, allowing advanced
deduplication and application-data management;
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
@@ -14,7 +14,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
cmake_minimum_required(VERSION 3.1)
-project(star-geometry-2D C)
+project(star-geometry-2d C)
enable_testing()
include(CMakeDependentOption)
@@ -56,31 +56,31 @@ set(VERSION_MINOR 1)
set(VERSION_PATCH 0)
set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
-set(SG2_FILES_SRC
- sg2_device.c
- sg2_geometry.c
+set(SG2D_FILES_SRC
+ sg2d_device.c
+ sg2d_geometry.c
)
-set(SG2_FILES_INC_API
- sg2.h
- sg2_s2d_helper.h
- sg2_senc2d_helper.h
- sgX2.h
+set(SG2D_FILES_INC_API
+ sg2d.h
+ sg2d_s2d_helper.h
+ sg2d_senc2d_helper.h
+ sgX2d.h
)
-set(SG2_FILES_INC
- sg2_device.h
- sg2_geometry.h
- sg2_misc.h
+set(SG2D_FILES_INC
+ sg2d_device.h
+ sg2d_geometry.h
+ sg2d_misc.h
)
-set(SG2_FILES_DOC COPYING README.md)
+set(SG2D_FILES_DOC COPYING README.md)
# Prepend each file by `STAR_GEOM_SOURCE_DIR'
-rcmake_prepend_path(SG2_FILES_SRC ${STAR_GEOM_SOURCE_DIR})
-rcmake_prepend_path(SG2_FILES_INC ${STAR_GEOM_SOURCE_DIR})
-rcmake_prepend_path(SG2_FILES_INC_API ${STAR_GEOM_SOURCE_DIR})
-rcmake_prepend_path(SG2_FILES_DOC ${PROJECT_SOURCE_DIR}/../)
+rcmake_prepend_path(SG2D_FILES_SRC ${STAR_GEOM_SOURCE_DIR})
+rcmake_prepend_path(SG2D_FILES_INC ${STAR_GEOM_SOURCE_DIR})
+rcmake_prepend_path(SG2D_FILES_INC_API ${STAR_GEOM_SOURCE_DIR})
+rcmake_prepend_path(SG2D_FILES_DOC ${PROJECT_SOURCE_DIR}/../)
if(CMAKE_COMPILER_IS_GNUCC)
set(MATH_LIB m)
@@ -90,19 +90,19 @@ if(MSVC)
endif()
-add_library(sg2 SHARED
- ${SG2_FILES_SRC}
- ${SG2_FILES_INC}
- ${SG2_FILES_INC_API})
-target_link_libraries(sg2 RSys ${MATH_LIB})
+add_library(sg2d SHARED
+ ${SG2D_FILES_SRC}
+ ${SG2D_FILES_INC}
+ ${SG2D_FILES_INC_API})
+target_link_libraries(sg2d RSys ${MATH_LIB})
-set_target_properties(sg2 PROPERTIES
- DEFINE_SYMBOL SG2_SHARED_BUILD
+set_target_properties(sg2d PROPERTIES
+ DEFINE_SYMBOL SG2D_SHARED_BUILD
VERSION ${VERSION}
SOVERSION ${VERSION_MAJOR})
-rcmake_copy_runtime_libraries(sg2)
+rcmake_copy_runtime_libraries(sg2d)
-rcmake_setup_devel(sg2 StarGeom2D ${VERSION} star/sg2_version.h)
+rcmake_setup_devel(sg2d StarGeom2D ${VERSION} star/sg2d_version.h)
################################################################################
# Add tests
@@ -111,12 +111,12 @@ if(NOT NO_TEST)
function(build_test _name)
add_executable(${_name}
${STAR_GEOM_SOURCE_DIR}/${_name}.c
- ${STAR_GEOM_SOURCE_DIR}/test_sg2_utils.h)
+ ${STAR_GEOM_SOURCE_DIR}/test_sg2d_utils.h)
foreach(other ${ARGN})
target_sources(${_name}
PUBLIC ${STAR_GEOM_SOURCE_DIR}/${other})
endforeach()
- target_link_libraries(${_name} RSys sg2)
+ target_link_libraries(${_name} RSys sg2d)
endfunction()
function(register_test _name)
@@ -129,36 +129,36 @@ if(NOT NO_TEST)
register_test(${_name} ${_name})
endfunction()
- new_test(test_sg2_device)
- new_test(test_sg2_geometry)
- new_test(test_sg2_geometry_2)
+ new_test(test_sg2d_device)
+ new_test(test_sg2d_geometry)
+ new_test(test_sg2d_geometry_2)
- rcmake_copy_runtime_libraries(test_sg2_device)
- rcmake_copy_runtime_libraries(test_sg2_geometry)
- rcmake_copy_runtime_libraries(test_sg2_geometry_2)
+ rcmake_copy_runtime_libraries(test_sg2d_device)
+ rcmake_copy_runtime_libraries(test_sg2d_geometry)
+ rcmake_copy_runtime_libraries(test_sg2d_geometry_2)
if(SMALL_ADDITIONAL_TESTS)
- new_test(test_sg2_square_behind_square)
- new_test(test_sg2_square_in_square)
- new_test(test_sg2_square_on_square)
- new_test(test_sg2_some_enclosures test_sg2_utils2.h)
- new_test(test_sg2_some_segments test_sg2_utils2.h)
- new_test(test_sg2_unspecified_properties)
+ new_test(test_sg2d_square_behind_square)
+ new_test(test_sg2d_square_in_square)
+ new_test(test_sg2d_square_on_square)
+ new_test(test_sg2d_some_enclosures test_sg2d_utils2.h)
+ new_test(test_sg2d_some_segments test_sg2d_utils2.h)
+ new_test(test_sg2d_unspecified_properties)
- rcmake_copy_runtime_libraries(test_sg2_square_behind_square)
- rcmake_copy_runtime_libraries(test_sg2_square_in_square)
- rcmake_copy_runtime_libraries(test_sg2_square_on_square)
- rcmake_copy_runtime_libraries(test_sg2_some_enclosures)
- rcmake_copy_runtime_libraries(test_sg2_some_segments)
- rcmake_copy_runtime_libraries(test_sg2_unspecified_properties)
+ rcmake_copy_runtime_libraries(test_sg2d_square_behind_square)
+ rcmake_copy_runtime_libraries(test_sg2d_square_in_square)
+ rcmake_copy_runtime_libraries(test_sg2d_square_on_square)
+ rcmake_copy_runtime_libraries(test_sg2d_some_enclosures)
+ rcmake_copy_runtime_libraries(test_sg2d_some_segments)
+ rcmake_copy_runtime_libraries(test_sg2d_unspecified_properties)
endif()
if(HUGE_ADDITIONAL_TESTS)
- new_test(test_sg2_many_enclosures test_sg2_utils2.h)
- new_test(test_sg2_many_segments test_sg2_utils2.h)
+ new_test(test_sg2d_many_enclosures test_sg2d_utils2.h)
+ new_test(test_sg2d_many_segments test_sg2d_utils2.h)
- rcmake_copy_runtime_libraries(test_sg2_many_enclosures)
- rcmake_copy_runtime_libraries(test_sg2_many_segments)
+ rcmake_copy_runtime_libraries(test_sg2d_many_enclosures)
+ rcmake_copy_runtime_libraries(test_sg2d_many_segments)
endif()
endif()
@@ -166,9 +166,9 @@ endif()
################################################################################
# Define output & install directories
################################################################################
-install(TARGETS sg2
+install(TARGETS sg2d
ARCHIVE DESTINATION bin
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin)
-install(FILES ${SG2_FILES_INC_API} DESTINATION include/star)
-install(FILES ${SG2_FILES_DOC} DESTINATION share/doc/star-geometry-2D)
+install(FILES ${SG2D_FILES_INC_API} DESTINATION include/star)
+install(FILES ${SG2D_FILES_DOC} DESTINATION share/doc/star-geometry-2d)
diff --git a/src/sg2.h b/src/sg2.h
@@ -22,21 +22,21 @@
#include <limits.h>
/* Library symbol management */
-#if defined(SG2_SHARED_BUILD)
- #define SG2_API extern EXPORT_SYM
-#elif defined(SG2_STATIC_BUILD)
- #define SG2_API extern LOCAL_SYM
+#if defined(SG2D_SHARED_BUILD)
+ #define SG2D_API extern EXPORT_SYM
+#elif defined(SG2D_STATIC_BUILD)
+ #define SG2D_API extern LOCAL_SYM
#else /* Use shared library */
- #define SG2_API extern IMPORT_SYM
+ #define SG2D_API extern IMPORT_SYM
#endif
/* Helper macro that asserts if the invocation of the star-geometry function
* `Func' returns an error. One should use this macro on star-geometry
* function calls for which no explicit error checking is performed. */
#ifndef NDEBUG
-#define SG2(Func) ASSERT(sg2_ ## Func == RES_OK)
+#define SG2(Func) ASSERT(sg2d_ ## Func == RES_OK)
#else
-#define SG2(Func) sg2_ ## Func
+#define SG2(Func) sg2d_ ## Func
#endif
/* Forward declaration of external opaque data types */
@@ -49,78 +49,78 @@ struct mem_allocator;
* functions get or release a reference on the data, i.e. they increment or
* decrement the reference counter, respectively. When this counter reaches 0,
* the object is silently destroyed and cannot be used anymore. */
-struct sg2_device;
-struct sg2_geometry;
+struct sg2d_device;
+struct sg2d_geometry;
/******************************************************************************
* The dimension of the geometry used in the library.
*****************************************************************************/
-#define SG2_GEOMETRY_DIMENSION 2
+#define SG2D_GEOMETRY_DIMENSION 2
/******************************************************************************
* A type to list the different user properties attached to segments.
*****************************************************************************/
-enum sg2_property_type {
- SG2_FRONT,
- SG2_BACK,
- SG2_INTFACE,
- SG2_PROP_TYPES_COUNT__
+enum sg2d_property_type {
+ SG2D_FRONT,
+ SG2D_BACK,
+ SG2D_INTFACE,
+ SG2D_PROP_TYPES_COUNT__
};
/******************************************************************************
* A type to list the different possible partitions of segments.
*****************************************************************************/
-enum sg2_obj_dump_content {
- SG2_OBJ_DUMP_MERGE_CONFLICTS = BIT(0),
- SG2_OBJ_DUMP_PROPERTY_CONFLICTS = BIT(1),
- SG2_OBJ_DUMP_VALID_PRIMITIVE = BIT(2),
- SG2_OBJ_DUMP_ALL =
- SG2_OBJ_DUMP_MERGE_CONFLICTS
- | SG2_OBJ_DUMP_PROPERTY_CONFLICTS
- | SG2_OBJ_DUMP_VALID_PRIMITIVE
+enum sg2d_obj_dump_content {
+ SG2D_OBJ_DUMP_MERGE_CONFLICTS = BIT(0),
+ SG2D_OBJ_DUMP_PROPERTY_CONFLICTS = BIT(1),
+ SG2D_OBJ_DUMP_VALID_PRIMITIVE = BIT(2),
+ SG2D_OBJ_DUMP_ALL =
+ SG2D_OBJ_DUMP_MERGE_CONFLICTS
+ | SG2D_OBJ_DUMP_PROPERTY_CONFLICTS
+ | SG2D_OBJ_DUMP_VALID_PRIMITIVE
};
/******************************************************************************
* A type to list the different qualifiers of C code variable output.
*****************************************************************************/
-enum sg2_c_dump_qualifiers {
- SG2_C_DUMP_CONST = BIT(0),
- SG2_C_DUMP_STATIC = BIT(1)
+enum sg2d_c_dump_qualifiers {
+ SG2D_C_DUMP_CONST = BIT(0),
+ SG2D_C_DUMP_STATIC = BIT(1)
};
/******************************************************************************
* The value that should be used for properties attached to segments (i.e.
* media or interface) when let unspecified.
- * SG2_UNSPECIFIED_PROPERTY can be used for a property that has already been
+ * SG2D_UNSPECIFIED_PROPERTY can be used for a property that has already been
* defined; in this case the previous value will remain.
*****************************************************************************/
-#define SG2_UNSPECIFIED_PROPERTY UINT_MAX
+#define SG2D_UNSPECIFIED_PROPERTY UINT_MAX
/*****************************************************************************
- * A type to hold callbacks for sg2_geometry_add.
+ * A type to hold callbacks for sg2d_geometry_add.
****************************************************************************/
-struct sg2_geometry_add_callbacks {
+struct sg2d_geometry_add_callbacks {
/* User function that provides vertices ids for added segments */
void(*get_indices)
- (const unsigned iseg, unsigned ids[SG2_GEOMETRY_DIMENSION], void* context);
+ (const unsigned iseg, unsigned ids[SG2D_GEOMETRY_DIMENSION], void* context);
/* User function that provides properties for added segments */
- void(*get_properties) /* Can be NULL <=> SG2_UNSPECIFIED_PROPERTY used */
+ void(*get_properties) /* Can be NULL <=> SG2D_UNSPECIFIED_PROPERTY used */
(const unsigned iseg,
/* It is OK to have side and interface properties sharing the same IDs,
* i.e. side and interface IDs both starting from 0 */
- unsigned properties[SG2_PROP_TYPES_COUNT__],
+ unsigned properties[SG2D_PROP_TYPES_COUNT__],
void* context);
/* User function that provides coordinates for added vertices */
void(*get_position)
- (const unsigned ivert, double pos[SG2_GEOMETRY_DIMENSION], void* context);
- /* Called if the iseg_th segment of the current sg2_geometry_add is a new
+ (const unsigned ivert, double pos[SG2D_GEOMETRY_DIMENSION], void* context);
+ /* Called if the iseg_th segment of the current sg2d_geometry_add is a new
* segment (i.e. not a duplicate) so that the client app can manage its own
* segment data/properties/attributes.
- * If return is not RES_OK, sg2_geometry_add stops immediately and returns
+ * If return is not RES_OK, sg2d_geometry_add stops immediately and returns
* whatever value add_segment returned. */
res_T(*add_segment) /* Can be NULL */
(const unsigned unique_id, const unsigned iseg, void* context);
- /* Called if the iseg_th segment of the current sg2_geometry_add is a
+ /* Called if the iseg_th segment of the current sg2d_geometry_add is a
* duplicate of the unique_id_th unique segment so that the client app can
* merge its own segment data, rule merge validity, and possibly change the
* recorded properties.
@@ -135,17 +135,17 @@ struct sg2_geometry_add_callbacks {
(const unsigned unique_id,
const unsigned iseg,
const int reversed_segment,
- unsigned segment_properties[SG2_PROP_TYPES_COUNT__],
- const unsigned merged_properties[SG2_PROP_TYPES_COUNT__],
+ unsigned segment_properties[SG2D_PROP_TYPES_COUNT__],
+ const unsigned merged_properties[SG2D_PROP_TYPES_COUNT__],
void* context,
int* merge_conflict_status);
/* Called if the iseg_th segment is degenerated. According to the value
- * of abort, sg2_geometry_add will stop and return RES_BAD_ARG or continue
+ * of abort, sg2d_geometry_add will stop and return RES_BAD_ARG or continue
* silently. */
res_T(*degenerated_segment) /* Can be NULL <=> Drop segment, don't abort */
(const unsigned iseg, void* context, int* abort);
};
-#define SG2_ADD_CALLBACKS_NULL__ { NULL, NULL, NULL, NULL, NULL, NULL }
+#define SG2D_ADD_CALLBACKS_NULL__ { NULL, NULL, NULL, NULL, NULL, NULL }
BEGIN_DECLS
@@ -153,11 +153,11 @@ BEGIN_DECLS
* A helper function on properties compatibility.
*****************************************************************************/
static INLINE int
-sg2_compatible_property
+sg2d_compatible_property
(const unsigned p1,
const unsigned p2)
{
- if(p1 == SG2_UNSPECIFIED_PROPERTY || p2 == SG2_UNSPECIFIED_PROPERTY) return 1;
+ if(p1 == SG2D_UNSPECIFIED_PROPERTY || p2 == SG2D_UNSPECIFIED_PROPERTY) return 1;
return (p1 == p2);
}
@@ -165,76 +165,76 @@ sg2_compatible_property
* star-geometry device. It is an handle toward the star-geometry library.
* It manages the star-geometry resources.
*****************************************************************************/
-SG2_API res_T
-sg2_device_create
+SG2D_API res_T
+sg2d_device_create
(struct logger* logger, /* Can be NULL <=> use default logger */
struct mem_allocator* allocator, /* Can be NULL <=> use default allocator */
const int verbose, /* Verbosity level */
- struct sg2_device** dev);
+ struct sg2d_device** dev);
-SG2_API res_T
-sg2_device_ref_get
- (struct sg2_device* dev);
+SG2D_API res_T
+sg2d_device_ref_get
+ (struct sg2d_device* dev);
-SG2_API res_T
-sg2_device_ref_put
- (struct sg2_device* dev);
+SG2D_API res_T
+sg2d_device_ref_put
+ (struct sg2d_device* dev);
/******************************************************************************
* star-geometry geometry.
- * It stores decorated geometry accumulated through calls to sg2_geometry_add,
+ * It stores decorated geometry accumulated through calls to sg2d_geometry_add,
* information related to this geometry and its creation process, including
* merge conflicts.
*****************************************************************************/
/* Create a geometry that can be used to accumulate vertices and segments
* decorated with properties. */
-SG2_API res_T
-sg2_geometry_create
- (struct sg2_device* dev,
- struct sg2_geometry** geometry);
+SG2D_API res_T
+sg2d_geometry_create
+ (struct sg2d_device* dev,
+ struct sg2d_geometry** geometry);
/* Reserve memory according to anticipated geometry size. */
-SG2_API res_T
-sg2_geometry_reserve
- (struct sg2_geometry* geometry,
+SG2D_API res_T
+sg2d_geometry_reserve
+ (struct sg2d_geometry* geometry,
const unsigned vertices_count,
const unsigned segments_count,
const unsigned properties_count);
/* Add a new set of 2D vertices and segments to the geometry; segments can
* be decorated with 3 properties (front and back media and interface) that can
- * be let unspecified using the SG2_UNSPECIFIED_PROPERTY special value.
+ * be let unspecified using the SG2D_UNSPECIFIED_PROPERTY special value.
* Vertices can be duplicates and are silently deduplicated, always valid.
* Segments can be duplicates, but this can be ruled invalid due to property
* inconsistency. Segment duplicates are silently deduplicated, even if
* invalid. Consistency is to be understood as the consistency of the
- * successive values for the same property across calls of sg2_geometry_add,
+ * successive values for the same property across calls of sg2d_geometry_add,
* not as the consistency of the values of the 3 properties of a segment at
* some given time (this question has its own callback (validate) in the
- * sg2_geometry_validate_properties API call).
+ * sg2d_geometry_validate_properties API call).
* Duplicate segments validity is either ruled by the user-provided
* merge_segment callback, or is just a matter of properties consistency if no
- * callback is provided. In either case, sg2_geometry_add never stops
+ * callback is provided. In either case, sg2d_geometry_add never stops
* prematurely nor returns an error code due to a merge conflict.
* - if provided, the callback must return the consistency status using the
* merge_conflict_status int* paramater (0 for consistent; any other value
* for inconsistent, this value being recorded); regardless of
* merge_conflict_status, the callback can change the properties of the
- * segment before the SG2_UNSPECIFIED_PROPERTY overwriting step;
- * - if not, a non-SG2_UNSPECIFIED_PROPERTY is only consistent with itself and
- * with SG2_UNSPECIFIED_PROPERTY (if inconsistent, merge_conflict_status is
+ * segment before the SG2D_UNSPECIFIED_PROPERTY overwriting step;
+ * - if not, a non-SG2D_UNSPECIFIED_PROPERTY is only consistent with itself and
+ * with SG2D_UNSPECIFIED_PROPERTY (if inconsistent, merge_conflict_status is
* set to 1 and recorded) ; regardless of merge_conflict_status, a
- * non-SG2_UNSPECIFIED_PROPERTY property is never overridden.
+ * non-SG2D_UNSPECIFIED_PROPERTY property is never overridden.
* When deduplicating segments, the first occurence remains (with its
* original index in user world). After consistency being computed, a final
- * step consists in rewriting SG2_UNSPECIFIED_PROPERTY properties if the merged
+ * step consists in rewriting SG2D_UNSPECIFIED_PROPERTY properties if the merged
* property is defined. */
-SG2_API res_T
-sg2_geometry_add
- (struct sg2_geometry* geometry,
+SG2D_API res_T
+sg2d_geometry_add
+ (struct sg2d_geometry* geometry,
const unsigned vertices_count,
const unsigned segments_count,
- const struct sg2_geometry_add_callbacks* callbacks,
+ const struct sg2d_geometry_add_callbacks* callbacks,
void* context); /* Can be NULL */
/* Apply a validation callback on each segment included in this geometry that
@@ -246,89 +246,89 @@ sg2_geometry_add
* different shades of conflict.
* If validation is processed again, the properties conflict count is reset,
* as well as the properties_conflict_status status of the segments. */
-SG2_API res_T
-sg2_geometry_validate_properties
- (struct sg2_geometry* geometry,
+SG2D_API res_T
+sg2d_geometry_validate_properties
+ (struct sg2d_geometry* geometry,
res_T(*validate)
(const unsigned iseg,
- const unsigned properties[SG2_PROP_TYPES_COUNT__],
+ const unsigned properties[SG2D_PROP_TYPES_COUNT__],
void* context,
int* properties_conflict_status),
void* context); /* Can be NULL */
/* Get the number of unique vertices. */
-SG2_API res_T
-sg2_geometry_get_unique_vertices_count
- (const struct sg2_geometry* geometry,
+SG2D_API res_T
+sg2d_geometry_get_unique_vertices_count
+ (const struct sg2d_geometry* geometry,
unsigned* count);
/* Get the ivtx_th vertex. */
-SG2_API res_T
-sg2_geometry_get_unique_vertex
- (const struct sg2_geometry* geometry,
+SG2D_API res_T
+sg2d_geometry_get_unique_vertex
+ (const struct sg2d_geometry* geometry,
const unsigned ivtx,
- double coord[SG2_GEOMETRY_DIMENSION]);
+ double coord[SG2D_GEOMETRY_DIMENSION]);
/* Get the number of segments added to the geometry, regardless of unicity. */
-SG2_API res_T
-sg2_geometry_get_added_segments_count
- (const struct sg2_geometry* geometry,
+SG2D_API res_T
+sg2d_geometry_get_added_segments_count
+ (const struct sg2d_geometry* geometry,
unsigned* count);
/* Get the number of unique segments. */
-SG2_API res_T
-sg2_geometry_get_unique_segments_count
- (const struct sg2_geometry* geometry,
+SG2D_API res_T
+sg2d_geometry_get_unique_segments_count
+ (const struct sg2d_geometry* geometry,
unsigned* count);
/* Get the vertex indices of the iseg_th unique segment. */
-SG2_API res_T
-sg2_geometry_get_unique_segment_vertices
- (const struct sg2_geometry* geometry,
+SG2D_API res_T
+sg2d_geometry_get_unique_segment_vertices
+ (const struct sg2d_geometry* geometry,
const unsigned iseg,
- unsigned indices[SG2_GEOMETRY_DIMENSION]);
+ unsigned indices[SG2D_GEOMETRY_DIMENSION]);
/* Get the properties of the iseg_th unique segment. */
-SG2_API res_T
-sg2_geometry_get_unique_segment_properties
- (const struct sg2_geometry* geometry,
+SG2D_API res_T
+sg2d_geometry_get_unique_segment_properties
+ (const struct sg2d_geometry* geometry,
const unsigned iseg,
- unsigned properties[SG2_PROP_TYPES_COUNT__]);
+ unsigned properties[SG2D_PROP_TYPES_COUNT__]);
/* Get the user ID of the iseg_th unique segment, that is the user world's
* index of the segment that first created this unique segment.
* User world index starts at 0 and increases for every segment that is
- * submitted to sg2_geometry_add calls, regardless of duplication or
- * sg2_geometry_add failures (non-RES_OK return value). */
-SG2_API res_T
-sg2_geometry_get_unique_segment_user_id
- (const struct sg2_geometry* geometry,
+ * submitted to sg2d_geometry_add calls, regardless of duplication or
+ * sg2d_geometry_add failures (non-RES_OK return value). */
+SG2D_API res_T
+sg2d_geometry_get_unique_segment_user_id
+ (const struct sg2d_geometry* geometry,
const unsigned iseg,
unsigned* user_id);
/* Get the number of segments with (at least) one unspecified side. */
-SG2_API res_T
-sg2_geometry_get_unique_segments_with_unspecified_side_count
- (const struct sg2_geometry* geometry,
+SG2D_API res_T
+sg2d_geometry_get_unique_segments_with_unspecified_side_count
+ (const struct sg2d_geometry* geometry,
unsigned* count);
/* Get the number of segments with unspecified interface. */
-SG2_API res_T
-sg2_geometry_get_unique_segments_with_unspecified_interface_count
- (const struct sg2_geometry* geometry,
+SG2D_API res_T
+sg2d_geometry_get_unique_segments_with_unspecified_interface_count
+ (const struct sg2d_geometry* geometry,
unsigned* count);
/* Get the number of segments flagged with a merge conflict. */
-SG2_API res_T
-sg2_geometry_get_unique_segments_with_merge_conflict_count
- (const struct sg2_geometry* geometry,
+SG2D_API res_T
+sg2d_geometry_get_unique_segments_with_merge_conflict_count
+ (const struct sg2d_geometry* geometry,
unsigned* count);
/* Get the number of segments flagged with a property conflict. Only meaningful
- * after sg2_geometry_validate_properties has been called. */
-SG2_API res_T
-sg2_geometry_get_unique_segments_with_properties_conflict_count
- (const struct sg2_geometry* geometry,
+ * after sg2d_geometry_validate_properties has been called. */
+SG2D_API res_T
+sg2d_geometry_get_unique_segments_with_properties_conflict_count
+ (const struct sg2d_geometry* geometry,
unsigned* count);
/* Dump a geometry in the provided stream in the OBJ format.
@@ -336,14 +336,14 @@ sg2_geometry_get_unique_segments_with_properties_conflict_count
* in this output are 3D with Z==0, as OBJ files cannot define 2D vertices.
* The dump is made of the vertices and some segments, without their
* properties. The dumped segments are defined by the flags argument, that
- * must be ORed enum sg2_obj_dump_content values.
+ * must be ORed enum sg2d_obj_dump_content values.
* The dumped segments are partitioned in the following groups:
* - Valid_segments
* - Merge_conflicts
* - Property_conflict */
-SG2_API res_T
-sg2_geometry_dump_as_obj
- (const struct sg2_geometry* geometry,
+SG2D_API res_T
+sg2d_geometry_dump_as_obj
+ (const struct sg2d_geometry* geometry,
FILE* stream,
const int flags);
@@ -359,11 +359,11 @@ sg2_geometry_dump_as_obj
* - Interface (interface ID, INT_MAX for both unspecified and conflicted)
* - Merge_conflict (merge conflict status)
* - Property_conflict (property conflict status)
- * - Created_at_sg2_geometry_add (rank of the sg2_geometry_add that created the
+ * - Created_at_sg2d_geometry_add (rank of the sg2d_geometry_add that created the
* segment) */
-SG2_API res_T
-sg2_geometry_dump_as_vtk
- (const struct sg2_geometry* geometry,
+SG2D_API res_T
+sg2d_geometry_dump_as_vtk
+ (const struct sg2d_geometry* geometry,
FILE* stream);
/* Dump the geometry as C code.
@@ -377,21 +377,21 @@ sg2_geometry_dump_as_vtk
* Where <N1> is 2 * vertices_count, <N2> is 2 * segments_count and <N3> is
* 3 * segments_count.
* The two qualifiers static and const are output or not according to flags;
- * flags must be ORed enum sg2_c_dump_qualifiers values. */
-SG2_API res_T
-sg2_geometry_dump_as_c_code
- (const struct sg2_geometry* geometry,
+ * flags must be ORed enum sg2d_c_dump_qualifiers values. */
+SG2D_API res_T
+sg2d_geometry_dump_as_c_code
+ (const struct sg2d_geometry* geometry,
FILE* stream,
const char* name_prefix, /* Can be NULL or "" */
const int flags);
-SG2_API res_T
-sg2_geometry_ref_get
- (struct sg2_geometry* geometry);
+SG2D_API res_T
+sg2d_geometry_ref_get
+ (struct sg2d_geometry* geometry);
-SG2_API res_T
-sg2_geometry_ref_put
- (struct sg2_geometry* geometry);
+SG2D_API res_T
+sg2d_geometry_ref_put
+ (struct sg2d_geometry* geometry);
END_DECLS
diff --git a/src/sg2_device.c b/src/sg2_device.c
@@ -14,7 +14,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "sg2.h"
-#include "sg2_device.h"
+#include "sg2d_device.h"
#include <rsys/logger.h>
#include <rsys/mem_allocator.h>
@@ -26,7 +26,7 @@
******************************************************************************/
static void
log_msg
- (struct sg2_device* dev,
+ (struct sg2d_device* dev,
const enum log_type stream,
const char* msg,
va_list vargs)
@@ -42,9 +42,9 @@ log_msg
static void
device_release(ref_T* ref)
{
- struct sg2_device* dev;
+ struct sg2d_device* dev;
ASSERT(ref);
- dev = CONTAINER_OF(ref, struct sg2_device, ref);
+ dev = CONTAINER_OF(ref, struct sg2d_device, ref);
MEM_RM(dev->allocator, dev);
}
@@ -52,14 +52,14 @@ device_release(ref_T* ref)
* Exported functions
******************************************************************************/
res_T
-sg2_device_create
+sg2d_device_create
(struct logger* logger,
struct mem_allocator* mem_allocator,
const int verbose,
- struct sg2_device** out_dev)
+ struct sg2d_device** out_dev)
{
struct logger* log = NULL;
- struct sg2_device* dev = NULL;
+ struct sg2d_device* dev = NULL;
struct mem_allocator* allocator = NULL;
res_T res = RES_OK;
@@ -70,7 +70,7 @@ sg2_device_create
log = logger ? logger : LOGGER_DEFAULT;
allocator = mem_allocator ? mem_allocator : &mem_default_allocator;
- dev = MEM_CALLOC(allocator, 1, sizeof(struct sg2_device));
+ dev = MEM_CALLOC(allocator, 1, sizeof(struct sg2d_device));
if(!dev) {
if(verbose) {
/* Do not use helper log functions since dev is not initialised */
@@ -98,7 +98,7 @@ error:
}
res_T
-sg2_device_ref_get(struct sg2_device* dev)
+sg2d_device_ref_get(struct sg2d_device* dev)
{
if(!dev) return RES_BAD_ARG;
ref_get(&dev->ref);
@@ -106,7 +106,7 @@ sg2_device_ref_get(struct sg2_device* dev)
}
res_T
-sg2_device_ref_put(struct sg2_device* dev)
+sg2d_device_ref_put(struct sg2d_device* dev)
{
if(!dev) return RES_BAD_ARG;
ref_put(&dev->ref, device_release);
@@ -117,7 +117,7 @@ sg2_device_ref_put(struct sg2_device* dev)
* Local functions
******************************************************************************/
void
-log_err(struct sg2_device* dev, const char* msg, ...)
+log_err(struct sg2d_device* dev, const char* msg, ...)
{
va_list vargs_list;
ASSERT(dev && msg);
@@ -128,7 +128,7 @@ log_err(struct sg2_device* dev, const char* msg, ...)
}
void
-log_warn(struct sg2_device* dev, const char* msg, ...)
+log_warn(struct sg2d_device* dev, const char* msg, ...)
{
va_list vargs_list;
ASSERT(dev && msg);
diff --git a/src/sg2_device.h b/src/sg2_device.h
@@ -13,8 +13,8 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
-#ifndef SG2_DEVICE_H__
-#define SG2_DEVICE_H__
+#ifndef SG2D_DEVICE_H__
+#define SG2D_DEVICE_H__
#include <rsys/ref_count.h>
@@ -22,7 +22,7 @@
struct logger;
struct mem_allocator;
-struct sg2_device {
+struct sg2d_device {
struct logger* logger;
struct mem_allocator* allocator;
int verbose;
@@ -34,7 +34,7 @@ struct sg2_device {
* with respect to the device verbose flag */
extern LOCAL_SYM void
log_err
- (struct sg2_device* dev,
+ (struct sg2d_device* dev,
const char* msg,
...)
#ifdef COMPILER_GCC
@@ -46,7 +46,7 @@ log_err
* with respect to the device verbose flag */
extern LOCAL_SYM void
log_warn
- (struct sg2_device* dev,
+ (struct sg2d_device* dev,
const char* msg,
...)
#ifdef COMPILER_GCC
@@ -54,4 +54,4 @@ log_warn
#endif
;
-#endif /* SG2_DEVICE_H__ */
+#endif /* SG2D_DEVICE_H__ */
diff --git a/src/sg2_geometry.c b/src/sg2_geometry.c
@@ -14,8 +14,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "sg2.h"
-#include "sg2_geometry.h"
-#include "sg2_device.h"
+#include "sg2d_geometry.h"
+#include "sg2d_device.h"
#include <rsys/double2.h>
@@ -27,10 +27,10 @@
static void
geometry_release(ref_T* ref)
{
- struct sg2_geometry* geom;
- struct sg2_device* dev;
+ struct sg2d_geometry* geom;
+ struct sg2d_device* dev;
ASSERT(ref);
- geom = CONTAINER_OF(ref, struct sg2_geometry, ref);
+ geom = CONTAINER_OF(ref, struct sg2d_geometry, ref);
dev = geom->dev;
darray_segment_release(&geom->unique_segments);
darray_vertex_release(&geom->unique_vertices);
@@ -59,18 +59,18 @@ seg_make_key(struct unsigned2* k, const unsigned t[2])
static void
dump_seg_property
- (const struct sg2_geometry* geom,
+ (const struct sg2d_geometry* geom,
FILE* stream,
- const enum sg2_property_type type)
+ const enum sg2d_property_type type)
{
size_t i;
const struct seg_descriptions* descriptions;
- ASSERT(geom && stream && type < SG2_PROP_TYPES_COUNT__);
+ ASSERT(geom && stream && type < SG2D_PROP_TYPES_COUNT__);
descriptions
= darray_seg_descriptions_cdata_get(&geom->seg_descriptions);
FOR_EACH(i, 0, darray_segment_size_get(&geom->unique_segments)) {
- unsigned property = SG2_UNSPECIFIED_PROPERTY;
+ unsigned property = SG2D_UNSPECIFIED_PROPERTY;
size_t tdefs_count
= darray_definition_size_get(&descriptions[i].defs[type]);
if(tdefs_count && descriptions[i].property_defined[type]) {
@@ -78,7 +78,7 @@ dump_seg_property
= darray_definition_cdata_get(&descriptions[i].defs[type]);
size_t j;
FOR_EACH(j, 0, tdefs_count) {
- if(tdefs->property_value != SG2_UNSPECIFIED_PROPERTY) {
+ if(tdefs->property_value != SG2D_UNSPECIFIED_PROPERTY) {
property = tdefs->property_value;
break; /* Found the defined value */
}
@@ -95,7 +95,7 @@ dump_seg_property
******************************************************************************/
res_T
geometry_register_segment
- (struct sg2_geometry* geom,
+ (struct sg2d_geometry* geom,
const struct segment* segment,
const unsigned segment_unique_id,
const unsigned set_id,
@@ -104,7 +104,7 @@ geometry_register_segment
res_T res = RES_OK;
struct seg_descriptions* seg_d;
int i;
- char keep_prop_def[SG2_PROP_TYPES_COUNT__];
+ char keep_prop_def[SG2D_PROP_TYPES_COUNT__];
ASSERT(geom && segment);
@@ -112,13 +112,13 @@ geometry_register_segment
seg_d = (darray_seg_descriptions_data_get(&geom->seg_descriptions)
+ segment_unique_id);
/* Record information */
- FOR_EACH(i, 0, SG2_PROP_TYPES_COUNT__) {
+ FOR_EACH(i, 0, SG2D_PROP_TYPES_COUNT__) {
struct darray_definition* definitions;
struct definition* defs;
int done = 0;
size_t j;
keep_prop_def[i] = seg_d->property_defined[i];
- if(segment->properties[i] == SG2_UNSPECIFIED_PROPERTY)
+ if(segment->properties[i] == SG2D_UNSPECIFIED_PROPERTY)
seg_d->defs_include_unspecified = 1;
else seg_d->property_defined[i] = 1;
definitions = seg_d->defs + i;
@@ -160,15 +160,15 @@ geometry_register_segment
}
}
- if((!keep_prop_def[SG2_FRONT] || !keep_prop_def[SG2_BACK])
- && seg_d->property_defined[SG2_FRONT] && seg_d->property_defined[SG2_BACK])
+ if((!keep_prop_def[SG2D_FRONT] || !keep_prop_def[SG2D_BACK])
+ && seg_d->property_defined[SG2D_FRONT] && seg_d->property_defined[SG2D_BACK])
{
/* Both sides are now defined */
ASSERT(geom->seg_with_unspecified_sides_count > 0);
geom->seg_with_unspecified_sides_count--;
}
- if(!keep_prop_def[SG2_INTFACE] && seg_d->property_defined[SG2_INTFACE]) {
+ if(!keep_prop_def[SG2D_INTFACE] && seg_d->property_defined[SG2D_INTFACE]) {
/* Interface is now defined */
ASSERT(geom->seg_with_unspecified_intface_count > 0);
geom->seg_with_unspecified_intface_count--;
@@ -182,7 +182,7 @@ error:
res_T
geometry_enlarge_seg_descriptions
- (struct sg2_geometry* geom,
+ (struct sg2d_geometry* geom,
const size_t sz)
{
res_T res = RES_OK;
@@ -202,18 +202,18 @@ error:
static void
dump_partition
- (const struct sg2_geometry* geom,
+ (const struct sg2d_geometry* geom,
FILE* stream,
const char* group_name,
- enum sg2_obj_dump_content partition)
+ enum sg2d_obj_dump_content partition)
{
const struct seg_descriptions* seg_descriptions;
const struct segment* segments;
size_t sz, i;
ASSERT(geom && stream && group_name);
- ASSERT(partition == SG2_OBJ_DUMP_MERGE_CONFLICTS
- || partition == SG2_OBJ_DUMP_PROPERTY_CONFLICTS
- || partition == SG2_OBJ_DUMP_VALID_PRIMITIVE);
+ ASSERT(partition == SG2D_OBJ_DUMP_MERGE_CONFLICTS
+ || partition == SG2D_OBJ_DUMP_PROPERTY_CONFLICTS
+ || partition == SG2D_OBJ_DUMP_VALID_PRIMITIVE);
seg_descriptions
= darray_seg_descriptions_cdata_get(&geom->seg_descriptions);
sz = darray_seg_descriptions_size_get(&geom->seg_descriptions);
@@ -221,13 +221,13 @@ dump_partition
fprintf(stream, "g %s\n", group_name);
FOR_EACH(i, 0, sz) {
int dump;
- if(partition == SG2_OBJ_DUMP_VALID_PRIMITIVE)
+ if(partition == SG2D_OBJ_DUMP_VALID_PRIMITIVE)
dump = !(seg_descriptions[i].merge_conflict
|| seg_descriptions[i].properties_conflict);
- else if(partition == SG2_OBJ_DUMP_MERGE_CONFLICTS)
+ else if(partition == SG2D_OBJ_DUMP_MERGE_CONFLICTS)
dump = seg_descriptions[i].merge_conflict;
else {
- ASSERT(partition == SG2_OBJ_DUMP_PROPERTY_CONFLICTS);
+ ASSERT(partition == SG2D_OBJ_DUMP_PROPERTY_CONFLICTS);
dump = seg_descriptions[i].properties_conflict;
}
if(!dump) continue;
@@ -242,11 +242,11 @@ dump_partition
* Exported functions
******************************************************************************/
res_T
-sg2_geometry_create
- (struct sg2_device* dev,
- struct sg2_geometry** out_geometry)
+sg2d_geometry_create
+ (struct sg2d_device* dev,
+ struct sg2d_geometry** out_geometry)
{
- struct sg2_geometry* geom = NULL;
+ struct sg2d_geometry* geom = NULL;
res_T res = RES_OK;
if(!dev || !out_geometry) {
@@ -254,7 +254,7 @@ sg2_geometry_create
goto error;
}
- geom = MEM_CALLOC(dev->allocator, 1, sizeof(struct sg2_geometry));
+ geom = MEM_CALLOC(dev->allocator, 1, sizeof(struct sg2d_geometry));
if(!geom) {
log_err(dev,
"%s: could not allocate the sg2.\n", FUNC_NAME);
@@ -291,8 +291,8 @@ error:
}
res_T
-sg2_geometry_reserve
- (struct sg2_geometry* geom,
+sg2d_geometry_reserve
+ (struct sg2d_geometry* geom,
const unsigned vertices_count,
const unsigned segments_count,
const unsigned properties_count)
@@ -314,11 +314,11 @@ error:
}
res_T
-sg2_geometry_add
- (struct sg2_geometry* geom,
+sg2d_geometry_add
+ (struct sg2d_geometry* geom,
const unsigned nverts,
const unsigned nsegs,
- const struct sg2_geometry_add_callbacks* callbacks,
+ const struct sg2d_geometry_add_callbacks* callbacks,
void* ctx) /* Can be NULL */
{
res_T res = RES_OK;
@@ -426,15 +426,15 @@ sg2_geometry_add
seg_descriptions
= darray_seg_descriptions_data_get(&geom->seg_descriptions);
if(!same)
- SWAP(unsigned, tmp.properties[SG2_FRONT], tmp.properties[SG2_BACK]);
+ SWAP(unsigned, tmp.properties[SG2D_FRONT], tmp.properties[SG2D_BACK]);
already_conflict = seg_descriptions[i].merge_conflict;
if(callbacks->merge_segment) {
/* Let the client app rule. */
ERR(callbacks->merge_segment(*p_seg, i, !same, seg[*p_seg].properties,
tmp.properties, ctx, &seg_descriptions[i].merge_conflict));
} else {
- FOR_EACH(j, 0, SG2_PROP_TYPES_COUNT__) {
- if(!sg2_compatible_property(seg[*p_seg].properties[j],
+ FOR_EACH(j, 0, SG2D_PROP_TYPES_COUNT__) {
+ if(!sg2d_compatible_property(seg[*p_seg].properties[j],
tmp.properties[j]))
{
seg_descriptions[i].merge_conflict = 1;
@@ -444,12 +444,12 @@ sg2_geometry_add
}
if(seg_descriptions[i].merge_conflict && !already_conflict)
geom->merge_conflict_count++;
- /* Replace SG2_UNSPECIFIED_PROPERTY properties */
- FOR_EACH(j, 0, SG2_PROP_TYPES_COUNT__) {
- if(seg[*p_seg].properties[j] == SG2_UNSPECIFIED_PROPERTY
- && tmp.properties[j] != SG2_UNSPECIFIED_PROPERTY) {
+ /* Replace SG2D_UNSPECIFIED_PROPERTY properties */
+ FOR_EACH(j, 0, SG2D_PROP_TYPES_COUNT__) {
+ if(seg[*p_seg].properties[j] == SG2D_UNSPECIFIED_PROPERTY
+ && tmp.properties[j] != SG2D_UNSPECIFIED_PROPERTY) {
seg[*p_seg].properties[j] = tmp.properties[j];
- if(j == SG2_FRONT || j == SG2_BACK)
+ if(j == SG2D_FRONT || j == SG2D_BACK)
geom->sides_with_defined_medium_count++;
}
}
@@ -464,9 +464,9 @@ sg2_geometry_add
seg_descriptions
= darray_seg_descriptions_data_get(&geom->seg_descriptions);
ERR(darray_segment_push_back(&geom->unique_segments, &tmp));
- FOR_EACH(j, 0, SG2_PROP_TYPES_COUNT__) {
- if((j == SG2_FRONT || j == SG2_BACK)
- && tmp.properties[j] != SG2_UNSPECIFIED_PROPERTY)
+ FOR_EACH(j, 0, SG2D_PROP_TYPES_COUNT__) {
+ if((j == SG2D_FRONT || j == SG2D_BACK)
+ && tmp.properties[j] != SG2D_UNSPECIFIED_PROPERTY)
geom->sides_with_defined_medium_count++;
}
ASSERT(unique_id == htable_seg_size_get(&geom->unique_segments_ids));
@@ -496,8 +496,8 @@ error:
}
res_T
-sg2_geometry_validate_properties
- (struct sg2_geometry* geom,
+sg2d_geometry_validate_properties
+ (struct sg2d_geometry* geom,
res_T(*validate)(const unsigned, const unsigned*, void*, int*),
void* ctx)
{
@@ -519,7 +519,7 @@ sg2_geometry_validate_properties
geom->properties_conflict_count = 0; /* Reset count */
FOR_EACH(i, 0, sz) {
unsigned p, j;
- unsigned props[SG2_PROP_TYPES_COUNT__];
+ unsigned props[SG2D_PROP_TYPES_COUNT__];
struct seg_descriptions* segd = seg_descriptions + i;
/* Validate only segment not flagged with merge_conflict */
if(segd->merge_conflict) {
@@ -527,11 +527,11 @@ sg2_geometry_validate_properties
continue;
}
/* Get properties for non-conflict segments */
- FOR_EACH(p, 0, SG2_PROP_TYPES_COUNT__) {
+ FOR_EACH(p, 0, SG2D_PROP_TYPES_COUNT__) {
const struct definition* defs = darray_definition_cdata_get(segd->defs + p);
- props[p] = SG2_UNSPECIFIED_PROPERTY;
+ props[p] = SG2D_UNSPECIFIED_PROPERTY;
FOR_EACH(j, 0, darray_definition_size_get(segd->defs + p)) {
- if(defs[j].property_value != SG2_UNSPECIFIED_PROPERTY) {
+ if(defs[j].property_value != SG2D_UNSPECIFIED_PROPERTY) {
props[p] = defs[j].property_value;
break;
}
@@ -550,8 +550,8 @@ error:
}
res_T
-sg2_geometry_get_unique_vertices_count
- (const struct sg2_geometry* geom,
+sg2d_geometry_get_unique_vertices_count
+ (const struct sg2d_geometry* geom,
unsigned* count)
{
res_T res = RES_OK;
@@ -570,8 +570,8 @@ error:
}
res_T
-sg2_geometry_get_unique_vertex
- (const struct sg2_geometry* geom,
+sg2d_geometry_get_unique_vertex
+ (const struct sg2d_geometry* geom,
const unsigned ivtx,
double coord[2])
{
@@ -592,8 +592,8 @@ error:
}
res_T
-sg2_geometry_get_added_segments_count
- (const struct sg2_geometry* geom,
+sg2d_geometry_get_added_segments_count
+ (const struct sg2d_geometry* geom,
unsigned* count)
{
res_T res = RES_OK;
@@ -609,8 +609,8 @@ error:
}
res_T
-sg2_geometry_get_unique_segments_count
- (const struct sg2_geometry* geom,
+sg2d_geometry_get_unique_segments_count
+ (const struct sg2d_geometry* geom,
unsigned* count)
{
res_T res = RES_OK;
@@ -629,8 +629,8 @@ error:
}
res_T
-sg2_geometry_get_unique_segment_vertices
- (const struct sg2_geometry* geom,
+sg2d_geometry_get_unique_segment_vertices
+ (const struct sg2d_geometry* geom,
const unsigned iseg,
unsigned indices[2])
{
@@ -652,10 +652,10 @@ error:
}
res_T
-sg2_geometry_get_unique_segment_properties
- (const struct sg2_geometry* geom,
+sg2d_geometry_get_unique_segment_properties
+ (const struct sg2d_geometry* geom,
const unsigned iseg,
- unsigned properties[SG2_PROP_TYPES_COUNT__])
+ unsigned properties[SG2D_PROP_TYPES_COUNT__])
{
res_T res = RES_OK;
const struct segment* segments;
@@ -667,7 +667,7 @@ sg2_geometry_get_unique_segment_properties
goto error;
}
segments = darray_segment_cdata_get(&geom->unique_segments);
- FOR_EACH(i, 0, SG2_PROP_TYPES_COUNT__)
+ FOR_EACH(i, 0, SG2D_PROP_TYPES_COUNT__)
properties[i] = segments[iseg].properties[i];
exit:
return res;
@@ -676,8 +676,8 @@ error:
}
res_T
-sg2_geometry_get_unique_segment_user_id
- (const struct sg2_geometry* geom,
+sg2d_geometry_get_unique_segment_user_id
+ (const struct sg2d_geometry* geom,
const unsigned iseg,
unsigned* user_id)
{
@@ -698,8 +698,8 @@ error:
}
res_T
-sg2_geometry_get_unique_segments_with_unspecified_side_count
- (const struct sg2_geometry* geom,
+sg2d_geometry_get_unique_segments_with_unspecified_side_count
+ (const struct sg2d_geometry* geom,
unsigned* count)
{
res_T res = RES_OK;
@@ -715,8 +715,8 @@ error:
}
res_T
-sg2_geometry_get_unique_segments_with_unspecified_interface_count
- (const struct sg2_geometry* geom,
+sg2d_geometry_get_unique_segments_with_unspecified_interface_count
+ (const struct sg2d_geometry* geom,
unsigned* count)
{
res_T res = RES_OK;
@@ -732,8 +732,8 @@ error:
}
res_T
-sg2_geometry_get_unique_segments_with_merge_conflict_count
- (const struct sg2_geometry* geom,
+sg2d_geometry_get_unique_segments_with_merge_conflict_count
+ (const struct sg2d_geometry* geom,
unsigned* count)
{
res_T res = RES_OK;
@@ -749,8 +749,8 @@ error:
}
res_T
-sg2_geometry_get_unique_segments_with_properties_conflict_count
- (const struct sg2_geometry* geom,
+sg2d_geometry_get_unique_segments_with_properties_conflict_count
+ (const struct sg2d_geometry* geom,
unsigned* count)
{
res_T res = RES_OK;
@@ -766,8 +766,8 @@ error:
}
res_T
-sg2_geometry_dump_as_obj
- (const struct sg2_geometry* geom,
+sg2d_geometry_dump_as_obj
+ (const struct sg2d_geometry* geom,
FILE* stream,
const int flags)
{
@@ -806,9 +806,9 @@ sg2_geometry_dump_as_obj
fprintf(stream, "v %g %g 0\n", SPLIT2(vertices[i].coord));
/* Dump segments by groups */
- dump_partition(geom, stream, "Valid_segments", SG2_OBJ_DUMP_VALID_PRIMITIVE);
- dump_partition(geom, stream, "Merge_conflicts", SG2_OBJ_DUMP_MERGE_CONFLICTS);
- dump_partition(geom, stream, "Property_conflicts", SG2_OBJ_DUMP_PROPERTY_CONFLICTS);
+ dump_partition(geom, stream, "Valid_segments", SG2D_OBJ_DUMP_VALID_PRIMITIVE);
+ dump_partition(geom, stream, "Merge_conflicts", SG2D_OBJ_DUMP_MERGE_CONFLICTS);
+ dump_partition(geom, stream, "Property_conflicts", SG2D_OBJ_DUMP_PROPERTY_CONFLICTS);
exit:
return res;
@@ -817,8 +817,8 @@ error:
}
res_T
-sg2_geometry_dump_as_vtk
- (const struct sg2_geometry* geom,
+sg2d_geometry_dump_as_vtk
+ (const struct sg2d_geometry* geom,
FILE* stream)
{
res_T res = RES_OK;
@@ -863,17 +863,17 @@ sg2_geometry_dump_as_vtk
/* Dump front medium */
fprintf(stream, "SCALARS Front_medium int\n");
fprintf(stream, "LOOKUP_TABLE default\n");
- dump_seg_property(geom, stream, SG2_FRONT);
+ dump_seg_property(geom, stream, SG2D_FRONT);
/* Dump back medium */
fprintf(stream, "SCALARS Back_medium int\n");
fprintf(stream, "LOOKUP_TABLE default\n");
- dump_seg_property(geom, stream, SG2_BACK);
+ dump_seg_property(geom, stream, SG2D_BACK);
/* Dump interface */
fprintf(stream, "SCALARS Interface int\n");
fprintf(stream, "LOOKUP_TABLE default\n");
- dump_seg_property(geom, stream, SG2_INTFACE);
+ dump_seg_property(geom, stream, SG2D_INTFACE);
/* Dump user_id */
fprintf(stream, "SCALARS User_ID int\n");
@@ -893,15 +893,15 @@ sg2_geometry_dump_as_vtk
FOR_EACH(i, 0, tsz)
fprintf(stream, "%d\n", descriptions[i].properties_conflict);
- /* Dump rank of the sg2_geometry_add that created the segment */
- fprintf(stream, "SCALARS Created_at_sg2_geometry_add int\n");
+ /* Dump rank of the sg2d_geometry_add that created the segment */
+ fprintf(stream, "SCALARS Created_at_sg2d_geometry_add int\n");
fprintf(stream, "LOOKUP_TABLE default\n");
FOR_EACH(i, 0, tsz) {
const struct definition* tdefs;
const unsigned* ranks;
- ASSERT(darray_definition_size_get(&descriptions[i].defs[SG2_FRONT]) > 0);
+ ASSERT(darray_definition_size_get(&descriptions[i].defs[SG2D_FRONT]) > 0);
/* Rank is the first set_id of the first definition of any property */
- tdefs = darray_definition_cdata_get(&descriptions[i].defs[SG2_FRONT]);
+ tdefs = darray_definition_cdata_get(&descriptions[i].defs[SG2D_FRONT]);
ranks = darray_uint_cdata_get(&tdefs[0].set_ids);
fprintf(stream, "%u\n", ranks[0]);
}
@@ -913,8 +913,8 @@ error:
}
res_T
-sg2_geometry_dump_as_c_code
- (const struct sg2_geometry* geom,
+sg2d_geometry_dump_as_c_code
+ (const struct sg2d_geometry* geom,
FILE* stream,
const char* name_prefix,
const int flags)
@@ -961,11 +961,11 @@ sg2_geometry_dump_as_c_code
goto error;
}
- if(flags & SG2_C_DUMP_CONST && flags & SG2_C_DUMP_STATIC)
+ if(flags & SG2D_C_DUMP_CONST && flags & SG2D_C_DUMP_STATIC)
qualifiers = "static const ";
- else if(flags & SG2_C_DUMP_CONST)
+ else if(flags & SG2D_C_DUMP_CONST)
qualifiers = "const ";
- else if(flags & SG2_C_DUMP_STATIC)
+ else if(flags & SG2D_C_DUMP_STATIC)
qualifiers = "static ";
else qualifiers = "";
@@ -1007,13 +1007,13 @@ sg2_geometry_dump_as_c_code
fprintf(stream,
"%sunsigned %s_properties[%u] =\n"
"{\n",
- qualifiers, name_prefix, (unsigned)(SG2_PROP_TYPES_COUNT__ * tsz));
+ qualifiers, name_prefix, (unsigned)(SG2D_PROP_TYPES_COUNT__ * tsz));
FOR_EACH(i, 0, tsz) {
int p;
fprintf(stream, " ");
- FOR_EACH(p, 0, SG2_PROP_TYPES_COUNT__) {
- if(segments[i].properties[p] == SG2_UNSPECIFIED_PROPERTY)
- fprintf(stream, " SG2_UNSPECIFIED_PROPERTY");
+ FOR_EACH(p, 0, SG2D_PROP_TYPES_COUNT__) {
+ if(segments[i].properties[p] == SG2D_UNSPECIFIED_PROPERTY)
+ fprintf(stream, " SG2D_UNSPECIFIED_PROPERTY");
else fprintf(stream," %u", segments[i].properties[p]);
if(i < tsz-1 || p < 2) fprintf(stream, ",");
if(p == 2) fprintf(stream, "\n");
@@ -1029,7 +1029,7 @@ error:
}
res_T
-sg2_geometry_ref_get(struct sg2_geometry* geom)
+sg2d_geometry_ref_get(struct sg2d_geometry* geom)
{
if(!geom) return RES_BAD_ARG;
ref_get(&geom->ref);
@@ -1037,7 +1037,7 @@ sg2_geometry_ref_get(struct sg2_geometry* geom)
}
res_T
-sg2_geometry_ref_put(struct sg2_geometry* geom)
+sg2d_geometry_ref_put(struct sg2d_geometry* geom)
{
if(!geom) return RES_BAD_ARG;
ref_put(&geom->ref, geometry_release);
diff --git a/src/sg2_geometry.h b/src/sg2_geometry.h
@@ -13,11 +13,11 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
-#ifndef SG2_GEOMETRY_H__
-#define SG2_GEOMETRY_H__
+#ifndef SG2D_GEOMETRY_H__
+#define SG2D_GEOMETRY_H__
#include "sg2.h"
-#include "sg2_misc.h"
+#include "sg2d_misc.h"
#include <rsys/ref_count.h>
#include <rsys/dynamic_array.h>
@@ -31,14 +31,14 @@
struct segment {
unsigned vertex_ids[2];
/* FRONT/BACK/INTERFACE property */
- unsigned properties[SG2_PROP_TYPES_COUNT__];
+ unsigned properties[SG2D_PROP_TYPES_COUNT__];
/* ID of the segment in user world, i.e. without deduplication */
unsigned user_id;
};
#define SEG_UNDEF__ {\
- { SG2_UNSPECIFIED_PROPERTY, SG2_UNSPECIFIED_PROPERTY },\
- { SG2_UNSPECIFIED_PROPERTY, SG2_UNSPECIFIED_PROPERTY, SG2_UNSPECIFIED_PROPERTY },\
- SG2_UNSPECIFIED_PROPERTY\
+ { SG2D_UNSPECIFIED_PROPERTY, SG2D_UNSPECIFIED_PROPERTY },\
+ { SG2D_UNSPECIFIED_PROPERTY, SG2D_UNSPECIFIED_PROPERTY, SG2D_UNSPECIFIED_PROPERTY },\
+ SG2D_UNSPECIFIED_PROPERTY\
}
#define DARRAY_NAME segment
#define DARRAY_DATA struct segment
@@ -109,7 +109,7 @@ init_definition
struct definition* data)
{
ASSERT(alloc && data);
- data->property_value = SG2_UNSPECIFIED_PROPERTY;
+ data->property_value = SG2D_UNSPECIFIED_PROPERTY;
darray_uint_init(alloc, &data->set_ids);
}
@@ -146,11 +146,11 @@ release_definition
/* A type to accumulate information for a segment.
* If there is more than 1 definition / field, it is a conflict */
struct seg_descriptions {
- struct darray_definition defs[SG2_PROP_TYPES_COUNT__];
+ struct darray_definition defs[SG2D_PROP_TYPES_COUNT__];
int merge_conflict;
int properties_conflict;
char defs_include_unspecified;
- char property_defined[SG2_PROP_TYPES_COUNT__];
+ char property_defined[SG2D_PROP_TYPES_COUNT__];
};
static FINLINE void
@@ -160,12 +160,12 @@ init_seg_descriptions
{
int i;
ASSERT(alloc && data);
- FOR_EACH(i, 0, SG2_PROP_TYPES_COUNT__)
+ FOR_EACH(i, 0, SG2D_PROP_TYPES_COUNT__)
darray_definition_init(alloc, data->defs + i);
data->merge_conflict = 0;
data->properties_conflict = 0;
data->defs_include_unspecified = 0;
- FOR_EACH(i, 0, SG2_PROP_TYPES_COUNT__)
+ FOR_EACH(i, 0, SG2D_PROP_TYPES_COUNT__)
data->property_defined[i] = 0;
}
@@ -177,12 +177,12 @@ copy_seg_descriptions
res_T res = RES_OK;
int i;
ASSERT(dst && src);
- FOR_EACH(i, 0, SG2_PROP_TYPES_COUNT__)
+ FOR_EACH(i, 0, SG2D_PROP_TYPES_COUNT__)
ERR(darray_definition_copy(&dst->defs[i], &src->defs[i]));
dst->merge_conflict = src->merge_conflict;
dst->properties_conflict = src->properties_conflict;
dst->defs_include_unspecified = src->defs_include_unspecified;
- FOR_EACH(i, 0, SG2_PROP_TYPES_COUNT__)
+ FOR_EACH(i, 0, SG2D_PROP_TYPES_COUNT__)
dst->property_defined[i] = src->property_defined[i];
exit:
return res;
@@ -196,7 +196,7 @@ release_seg_descriptions
{
int i;
ASSERT(data);
- FOR_EACH(i, 0, SG2_PROP_TYPES_COUNT__)
+ FOR_EACH(i, 0, SG2D_PROP_TYPES_COUNT__)
darray_definition_release(data->defs + i);
}
@@ -216,7 +216,7 @@ init_seg_intfaceid
unsigned* data)
{
ASSERT(data); (void)alloc;
- *data = SG2_UNSPECIFIED_PROPERTY;
+ *data = SG2D_UNSPECIFIED_PROPERTY;
}
#define DARRAY_NAME intface_id
@@ -225,9 +225,9 @@ init_seg_intfaceid
#include <rsys/dynamic_array.h>
/*******************************************************************************
- * Types to store geometry amid sg2_geometry_add calls.
+ * Types to store geometry amid sg2d_geometry_add calls.
******************************************************************************/
-struct sg2_geometry {
+struct sg2d_geometry {
/* Record unique (i.e. deduplicated) segments */
struct darray_segment unique_segments;
/* Record coordinates for unique (i.e. deduplicated) vertices */
@@ -250,7 +250,7 @@ struct sg2_geometry {
unsigned merge_conflict_count;
unsigned properties_conflict_count;
- struct sg2_device* dev;
+ struct sg2d_device* dev;
ref_T ref;
};
@@ -260,7 +260,7 @@ struct sg2_geometry {
extern LOCAL_SYM res_T
geometry_register_segment
- (struct sg2_geometry* geometry,
+ (struct sg2d_geometry* geometry,
const struct segment* segment,
const unsigned segment_unique_id,
const unsigned set_id,
@@ -269,7 +269,7 @@ geometry_register_segment
/* Add new undefined segment descriptions to a geometry */
extern LOCAL_SYM res_T
geometry_enlarge_seg_descriptions
- (struct sg2_geometry* geom,
+ (struct sg2d_geometry* geom,
const size_t sz);
-#endif /* SG2_GEOMETRY_H__ */
+#endif /* SG2D_GEOMETRY_H__ */
diff --git a/src/sg2_misc.h b/src/sg2_misc.h
@@ -13,9 +13,9 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
-#ifndef SG2_MISC_H__
-#define SG2_MISC_H__
+#ifndef SG2D_MISC_H__
+#define SG2D_MISC_H__
#define ERR(Expr) if((res = (Expr)) != RES_OK) goto error;
-#endif /* SG2_MISC_H__ */
+#endif /* SG2D_MISC_H__ */
diff --git a/src/sg2_s2d_helper.h b/src/sg2_s2d_helper.h
@@ -13,8 +13,8 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
-#ifndef SG2_SENC_2D_HELPER_H__
-#define SG2_SENC_2D_HELPER_H__
+#ifndef SG2D_SENC_2D_HELPER_H__
+#define SG2D_SENC_2D_HELPER_H__
#include "sg2.h"
#include <star/senc2d.h>
@@ -26,15 +26,15 @@
* Suitable for use as get_indice callback in s2d_mesh_setup_indexed_vertices
* calls. */
static FINLINE void
-sg2_s2d_geometry_get_indices
+sg2d_s2d_geometry_get_indices
(const unsigned iseg,
- unsigned indices[SG2_GEOMETRY_DIMENSION],
+ unsigned indices[SG2D_GEOMETRY_DIMENSION],
void* ctx)
{
- const struct sg2_geometry* geometry = ctx;
+ const struct sg2d_geometry* geometry = ctx;
res_T r;
ASSERT(indices && geometry);
- r = sg2_geometry_get_unique_segment_vertices(geometry, iseg, indices);
+ r = sg2d_geometry_get_unique_segment_vertices(geometry, iseg, indices);
ASSERT(r == RES_OK); (void)r;
}
@@ -42,20 +42,20 @@ sg2_s2d_geometry_get_indices
* Suitable for use as s2d_vertex_data getter for S2D_POSITION s2d_attrib_usage
* in s2d_mesh_setup_indexed_vertices calls. */
static FINLINE void
-sg2_s2d_geometry_get_position
+sg2d_s2d_geometry_get_position
(const unsigned ivert,
- float coord[SG2_GEOMETRY_DIMENSION],
+ float coord[SG2D_GEOMETRY_DIMENSION],
void* ctx)
{
- const struct sg2_geometry* geometry = ctx;
+ const struct sg2d_geometry* geometry = ctx;
double tmp[2];
res_T r;
ASSERT(coord && geometry);
- r = sg2_geometry_get_unique_vertex(geometry, ivert, tmp);
+ r = sg2d_geometry_get_unique_vertex(geometry, ivert, tmp);
ASSERT(r == RES_OK); (void)r;
f2_set_d2(coord, tmp);
}
END_DECLS
-#endif /* SG2_SENC_2D_HELPER_H__ */
+#endif /* SG2D_SENC_2D_HELPER_H__ */
diff --git a/src/sg2_senc2d_helper.h b/src/sg2_senc2d_helper.h
@@ -13,8 +13,8 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
-#ifndef SG2_SENC_2D_HELPER_H__
-#define SG2_SENC_2D_HELPER_H__
+#ifndef SG2D_SENC_2D_HELPER_H__
+#define SG2D_SENC_2D_HELPER_H__
#include "sg2.h"
#include <star/senc2d.h>
@@ -24,53 +24,53 @@
/* Get vertex indices for the iseg_th segment.
* Suitable for use as get_indices callback in senc2d_scene_create calls. */
static FINLINE void
-sg2_senc_geometry_get_indices
+sg2d_senc_geometry_get_indices
(const unsigned iseg,
- unsigned indices[SG2_GEOMETRY_DIMENSION],
+ unsigned indices[SG2D_GEOMETRY_DIMENSION],
void* ctx)
{
- const struct sg2_geometry* geometry = ctx;
+ const struct sg2d_geometry* geometry = ctx;
res_T r;
ASSERT(indices && geometry);
- r = sg2_geometry_get_unique_segment_vertices(geometry, iseg, indices);
+ r = sg2d_geometry_get_unique_segment_vertices(geometry, iseg, indices);
ASSERT(r == RES_OK); (void)r;
}
/* Get vertex indices for the iseg_th segment.
* Suitable for use as get_media callback in senc2d_scene_create calls. */
static FINLINE void
-sg2_senc_geometry_get_media
+sg2d_senc_geometry_get_media
(const unsigned iseg,
unsigned media[2],
void* ctx)
{
- const struct sg2_geometry* geometry = ctx;
- unsigned tmp[SG2_PROP_TYPES_COUNT__];
+ const struct sg2d_geometry* geometry = ctx;
+ unsigned tmp[SG2D_PROP_TYPES_COUNT__];
res_T r;
ASSERT(media && geometry);
- r = sg2_geometry_get_unique_segment_properties(geometry, iseg, tmp);
+ r = sg2d_geometry_get_unique_segment_properties(geometry, iseg, tmp);
ASSERT(r == RES_OK); (void)r;
- media[SENC2D_FRONT] = (tmp[SG2_FRONT] == SG2_UNSPECIFIED_PROPERTY)
- ? SENC2D_UNSPECIFIED_MEDIUM : tmp[SG2_FRONT];
- media[SENC2D_BACK] = (tmp[SG2_BACK] == SG2_UNSPECIFIED_PROPERTY)
- ? SENC2D_UNSPECIFIED_MEDIUM : tmp[SG2_BACK];
+ media[SENC2D_FRONT] = (tmp[SG2D_FRONT] == SG2D_UNSPECIFIED_PROPERTY)
+ ? SENC2D_UNSPECIFIED_MEDIUM : tmp[SG2D_FRONT];
+ media[SENC2D_BACK] = (tmp[SG2D_BACK] == SG2D_UNSPECIFIED_PROPERTY)
+ ? SENC2D_UNSPECIFIED_MEDIUM : tmp[SG2D_BACK];
}
/* Get vertex indices for the iseg_th segment.
* Suitable for use as get_position callback in senc2d_scene_create calls. */
static FINLINE void
-sg2_senc_geometry_get_position
+sg2d_senc_geometry_get_position
(const unsigned ivert,
- double coord[SG2_GEOMETRY_DIMENSION],
+ double coord[SG2D_GEOMETRY_DIMENSION],
void* ctx)
{
- const struct sg2_geometry* geometry = ctx;
+ const struct sg2d_geometry* geometry = ctx;
res_T r;
ASSERT(coord && geometry);
- r = sg2_geometry_get_unique_vertex(geometry, ivert, coord);
+ r = sg2d_geometry_get_unique_vertex(geometry, ivert, coord);
ASSERT(r == RES_OK); (void)r;
}
END_DECLS
-#endif /* SG2_SENC_2D_HELPER_H__ */
+#endif /* SG2D_SENC_2D_HELPER_H__ */
diff --git a/src/sgX2.h b/src/sgX2.h
@@ -17,8 +17,8 @@
#define STAR_GEOMETRY_X_2D_H__
#include <star/sg2.h>
-#include <star/sg2_senc2d_helper.h>
-#include <star/sg2_s2d_helper.h>
+#include <star/sg2d_senc2d_helper.h>
+#include <star/sg2d_s2d_helper.h>
#include <rsys/rsys.h>
#include <stdio.h>
@@ -28,7 +28,7 @@
* pattern:
*
* #if (DIM==2)
- * #include <star/sgX2.h>
+ * #include <star/sgX2d.h>
* #elif (DIM==3)
* #include <star/sgX3.h>
* #else
@@ -37,7 +37,7 @@
*
* Then use the sgX_... types and functions in your code.
*
- * Definitions from sgX2.h and sgX3.h cannot be visible at the same time
+ * Definitions from sgX2d.h and sgX3.h cannot be visible at the same time
* as some of them conflict.
*/
@@ -60,55 +60,55 @@ struct mem_allocator;
* functions get or release a reference on the data, i.e. they increment or
* decrement the reference counter, respectively. When this counter reaches 0,
* the object is silently destroyed and cannot be used anymore. */
-typedef struct sg2_device sgX_device;
-typedef struct sg2_geometry sgX_geometry;
+typedef struct sg2d_device sgX_device;
+typedef struct sg2d_geometry sgX_geometry;
/******************************************************************************
* The dimension of the geometry used in the library.
*****************************************************************************/
-#define SGX_GEOMETRY_DIMENSION SG2_GEOMETRY_DIMENSION
+#define SGX_GEOMETRY_DIMENSION SG2D_GEOMETRY_DIMENSION
/******************************************************************************
* A type to list the different user properties attached to segments.
*****************************************************************************/
enum sgX_property_type {
- SGX_FRONT = SG2_FRONT,
- SGX_BACK = SG2_BACK,
- SGX_INTFACE = SG2_INTFACE,
- SGX_PROP_TYPES_COUNT__ = SG2_PROP_TYPES_COUNT__
+ SGX_FRONT = SG2D_FRONT,
+ SGX_BACK = SG2D_BACK,
+ SGX_INTFACE = SG2D_INTFACE,
+ SGX_PROP_TYPES_COUNT__ = SG2D_PROP_TYPES_COUNT__
};
/******************************************************************************
* A type to list the different possible partitions of segments.
*****************************************************************************/
enum sgX_obj_dump_content {
- SGX_OBJ_DUMP_MERGE_CONFLICTS = SG2_OBJ_DUMP_MERGE_CONFLICTS,
- SGX_OBJ_DUMP_PROPERTY_CONFLICTS = SG2_OBJ_DUMP_PROPERTY_CONFLICTS,
- SGX_OBJ_DUMP_VALID_PRIMITIVE = SG2_OBJ_DUMP_VALID_PRIMITIVE,
- SGX_OBJ_DUMP_ALL = SG2_OBJ_DUMP_ALL
+ SGX_OBJ_DUMP_MERGE_CONFLICTS = SG2D_OBJ_DUMP_MERGE_CONFLICTS,
+ SGX_OBJ_DUMP_PROPERTY_CONFLICTS = SG2D_OBJ_DUMP_PROPERTY_CONFLICTS,
+ SGX_OBJ_DUMP_VALID_PRIMITIVE = SG2D_OBJ_DUMP_VALID_PRIMITIVE,
+ SGX_OBJ_DUMP_ALL = SG2D_OBJ_DUMP_ALL
};
/******************************************************************************
* A type to list the different qualifiers of C code variable output.
*****************************************************************************/
enum sgX_c_dump_qualifiers {
- SGX_C_DUMP_CONST = SG2_C_DUMP_CONST,
- SGX_C_DUMP_STATIC = SG2_C_DUMP_STATIC
+ SGX_C_DUMP_CONST = SG2D_C_DUMP_CONST,
+ SGX_C_DUMP_STATIC = SG2D_C_DUMP_STATIC
};
/******************************************************************************
* The value that should be used for properties attached to segments (i.e.
* media or interface) when let unspecified.
- * SG2_UNSPECIFIED_PROPERTY can be used for a property that has already been
+ * SG2D_UNSPECIFIED_PROPERTY can be used for a property that has already been
* defined; in this case the previous value will remain.
*****************************************************************************/
-#define SGX_UNSPECIFIED_PROPERTY SG2_UNSPECIFIED_PROPERTY
+#define SGX_UNSPECIFIED_PROPERTY SG2D_UNSPECIFIED_PROPERTY
/*****************************************************************************
- * A type to hold callbacks for sg2_geometry_add.
+ * A type to hold callbacks for sg2d_geometry_add.
****************************************************************************/
-typedef struct sg2_geometry_add_callbacks sgX_geometry_add_callbacks;
-#define SGX_ADD_CALLBACKS_NULL__ SG2_ADD_CALLBACKS_NULL__
+typedef struct sg2d_geometry_add_callbacks sgX_geometry_add_callbacks;
+#define SGX_ADD_CALLBACKS_NULL__ SG2D_ADD_CALLBACKS_NULL__
BEGIN_DECLS
@@ -120,7 +120,7 @@ sgX_compatible_property
(const unsigned p1,
const unsigned p2)
{
- return sg2_compatible_property(p1, p2);
+ return sg2d_compatible_property(p1, p2);
}
/******************************************************************************
@@ -134,26 +134,26 @@ sgX_device_create
const int verbose, /* Verbosity level */
sgX_device** dev)
{
- return sg2_device_create(logger, allocator, verbose, dev);
+ return sg2d_device_create(logger, allocator, verbose, dev);
}
static FINLINE res_T
sgX_device_ref_get
(sgX_device* dev)
{
- return sg2_device_ref_get(dev);
+ return sg2d_device_ref_get(dev);
}
static FINLINE res_T
sgX_device_ref_put
(sgX_device* dev)
{
- return sg2_device_ref_put(dev);
+ return sg2d_device_ref_put(dev);
}
/******************************************************************************
* star-geometry geometry.
- * It stores decorated geometry accumulated through calls to sg2_geometry_add,
+ * It stores decorated geometry accumulated through calls to sg2d_geometry_add,
* information related to this geometry and its creation process, including
* merge conflicts.
*****************************************************************************/
@@ -164,7 +164,7 @@ sgX_geometry_create
(sgX_device* dev,
sgX_geometry** geometry)
{
- return sg2_geometry_create(dev, geometry);
+ return sg2d_geometry_create(dev, geometry);
}
/* Reserve memory according to anticipated geometry size. */
@@ -175,37 +175,37 @@ sgX_geometry_reserve
const unsigned segments_count,
const unsigned properties_count)
{
- return sg2_geometry_reserve(
+ return sg2d_geometry_reserve(
geometry, vertices_count, segments_count, properties_count);
}
/* Add a new set of 2D vertices and segments to the geometry; segments can
* be decorated with 3 properties (front and back media and interface) that can
- * be let unspecified using the SG2_UNSPECIFIED_PROPERTY special value.
+ * be let unspecified using the SG2D_UNSPECIFIED_PROPERTY special value.
* Vertices can be duplicates and are silently deduplicated, always valid.
* Segments can be duplicates, but this can be ruled invalid due to property
* inconsistency. Segment duplicates are silently deduplicated, even if
* invalid. Consistency is to be understood as the consistency of the
- * successive values for the same property across calls of sg2_geometry_add,
+ * successive values for the same property across calls of sg2d_geometry_add,
* not as the consistency of the values of the 3 properties of a segment at
* some given time (this question has its own callback (validate) in the
- * sg2_geometry_validate_properties API call).
+ * sg2d_geometry_validate_properties API call).
* Duplicate segments validity is either ruled by the user-provided
* merge_segment callback, or is just a matter of properties consistency if no
- * callback is provided. In either case, sg2_geometry_add never stops
+ * callback is provided. In either case, sg2d_geometry_add never stops
* prematurely nor returns an error code due to a merge conflict.
* - if provided, the callback must return the consistency status using the
* merge_conflict_status int* paramater (0 for consistent; any other value
* for inconsistent, this value being recorded); regardless of
* merge_conflict_status, the callback can change the properties of the
- * segment before the SG2_UNSPECIFIED_PROPERTY overwriting step;
- * - if not, a non-SG2_UNSPECIFIED_PROPERTY is only consistent with itself and
- * with SG2_UNSPECIFIED_PROPERTY (if inconsistent, merge_conflict_status is
+ * segment before the SG2D_UNSPECIFIED_PROPERTY overwriting step;
+ * - if not, a non-SG2D_UNSPECIFIED_PROPERTY is only consistent with itself and
+ * with SG2D_UNSPECIFIED_PROPERTY (if inconsistent, merge_conflict_status is
* set to 1 and recorded) ; regardless of merge_conflict_status, a
- * non-SG2_UNSPECIFIED_PROPERTY property is never overridden.
+ * non-SG2D_UNSPECIFIED_PROPERTY property is never overridden.
* When deduplicating segments, the first occurence remains (with its
* original index in user world). After consistency being computed, a final
- * step consists in rewriting SG2_UNSPECIFIED_PROPERTY properties if the merged
+ * step consists in rewriting SG2D_UNSPECIFIED_PROPERTY properties if the merged
* property is defined. */
static FINLINE res_T
sgX_geometry_add
@@ -215,7 +215,7 @@ sgX_geometry_add
const sgX_geometry_add_callbacks* callbacks,
void* context) /* Can be NULL */
{
- return sg2_geometry_add(
+ return sg2d_geometry_add(
geometry, vertices_count, segments_count, callbacks, context);
}
@@ -238,7 +238,7 @@ sgX_geometry_validate_properties
int* properties_conflict_status),
void* context) /* Can be NULL */
{
- return sg2_geometry_validate_properties(geometry, validate, context);
+ return sg2d_geometry_validate_properties(geometry, validate, context);
}
/* Get the number of unique vertices. */
@@ -247,7 +247,7 @@ sgX_geometry_get_unique_vertices_count
(const sgX_geometry* geometry,
unsigned* count)
{
- return sg2_geometry_get_unique_vertices_count(geometry, count);
+ return sg2d_geometry_get_unique_vertices_count(geometry, count);
}
/* Get the ivtx_th vertex. */
@@ -257,7 +257,7 @@ sgX_geometry_get_unique_vertex
const unsigned ivtx,
double coord[SGX_GEOMETRY_DIMENSION])
{
- return sg2_geometry_get_unique_vertex(geometry, ivtx, coord);
+ return sg2d_geometry_get_unique_vertex(geometry, ivtx, coord);
}
/* Get the number of segments added to the geometry, regardless of unicity. */
@@ -266,7 +266,7 @@ sgX_geometry_get_added_primitives_count
(const sgX_geometry* geometry,
unsigned* count)
{
- return sg2_geometry_get_added_segments_count(geometry, count);
+ return sg2d_geometry_get_added_segments_count(geometry, count);
}
/* Get the number of unique segments. */
@@ -275,7 +275,7 @@ sgX_geometry_get_unique_primitives_count
(const sgX_geometry* geometry,
unsigned* count)
{
- return sg2_geometry_get_unique_segments_count(geometry, count);
+ return sg2d_geometry_get_unique_segments_count(geometry, count);
}
/* Get the vertex indices of the iseg_th unique segment. */
@@ -285,7 +285,7 @@ sgX_geometry_get_unique_primitive_vertices
const unsigned iseg,
unsigned indices[SGX_GEOMETRY_DIMENSION])
{
- return sg2_geometry_get_unique_segment_vertices(geometry, iseg, indices);
+ return sg2d_geometry_get_unique_segment_vertices(geometry, iseg, indices);
}
/* Get the properties of the iseg_th unique segment. */
@@ -293,24 +293,24 @@ static FINLINE res_T
sgX_geometry_get_unique_primitive_properties
(const sgX_geometry* geometry,
const unsigned iseg,
- unsigned properties[SG2_PROP_TYPES_COUNT__])
+ unsigned properties[SG2D_PROP_TYPES_COUNT__])
{
- return sg2_geometry_get_unique_segment_properties(
+ return sg2d_geometry_get_unique_segment_properties(
geometry, iseg, properties);
}
/* Get the user ID of the iseg_th unique segment, that is the user world's
* index of the segment that first created this unique segment.
* User world index starts at 0 and increases for every segment that is
- * submitted to sg2_geometry_add calls, regardless of duplication or
- * sg2_geometry_add failures (non-RES_OK return value). */
+ * submitted to sg2d_geometry_add calls, regardless of duplication or
+ * sg2d_geometry_add failures (non-RES_OK return value). */
static FINLINE res_T
sgX_geometry_get_unique_primitive_user_id
(const sgX_geometry* geometry,
const unsigned iseg,
unsigned* user_id)
{
- return sg2_geometry_get_unique_segment_user_id(geometry, iseg, user_id);
+ return sg2d_geometry_get_unique_segment_user_id(geometry, iseg, user_id);
}
/* Get the number of segments with (at least) one unspecified side. */
@@ -319,7 +319,7 @@ sgX_geometry_get_unique_primitives_with_unspecified_side_count
(const sgX_geometry* geometry,
unsigned* count)
{
- return sg2_geometry_get_unique_segments_with_unspecified_side_count(
+ return sg2d_geometry_get_unique_segments_with_unspecified_side_count(
geometry, count);
}
@@ -329,7 +329,7 @@ sgX_geometry_get_unique_primitives_with_unspecified_interface_count
(const sgX_geometry* geometry,
unsigned* count)
{
- return sg2_geometry_get_unique_segments_with_unspecified_interface_count(
+ return sg2d_geometry_get_unique_segments_with_unspecified_interface_count(
geometry, count);
}
@@ -339,18 +339,18 @@ sgX_geometry_get_unique_primitives_with_merge_conflict_count
(const sgX_geometry* geometry,
unsigned* count)
{
- return sg2_geometry_get_unique_segments_with_merge_conflict_count(
+ return sg2d_geometry_get_unique_segments_with_merge_conflict_count(
geometry, count);
}
/* Get the number of segments flagged with a property conflict. Only meaningful
- * after sg2_geometry_validate_properties has been called. */
+ * after sg2d_geometry_validate_properties has been called. */
static FINLINE res_T
sgX_geometry_get_unique_primitives_with_properties_conflict_count
(const sgX_geometry* geometry,
unsigned* count)
{
- return sg2_geometry_get_unique_segments_with_properties_conflict_count(
+ return sg2d_geometry_get_unique_segments_with_properties_conflict_count(
geometry, count);
}
@@ -359,7 +359,7 @@ sgX_geometry_get_unique_primitives_with_properties_conflict_count
* in this output are 3D with Z==0, as OBJ files cannot define 2D vertices.
* The dump is made of the vertices and some segments, without their
* properties. The dumped segments are defined by the flags argument, that
- * must be ORed enum sg2_obj_dump_content values.
+ * must be ORed enum sg2d_obj_dump_content values.
* The dumped segments are partitioned in the following groups:
* - Valid_segments
* - Merge_conflicts
@@ -370,7 +370,7 @@ sgX_geometry_dump_as_obj
FILE* stream,
const int flags)
{
- return sg2_geometry_dump_as_obj(geometry, stream, flags);
+ return sg2d_geometry_dump_as_obj(geometry, stream, flags);
}
/* Dump a geometry in the provided stream in the VTK ascii format.
@@ -385,14 +385,14 @@ sgX_geometry_dump_as_obj
* - Interface (interface ID, INT_MAX for both unspecified and conflicted)
* - Merge_conflict (merge conflict status)
* - Property_conflict (property conflict status)
- * - Created_at_sg2_geometry_add (rank of the sg2_geometry_add that created the
+ * - Created_at_sg2d_geometry_add (rank of the sg2d_geometry_add that created the
* segment) */
static FINLINE res_T
sgX_geometry_dump_as_vtk
(const sgX_geometry* geometry,
FILE* stream)
{
- return sg2_geometry_dump_as_vtk(geometry, stream);
+ return sg2d_geometry_dump_as_vtk(geometry, stream);
}
/* Dump the geometry as C code.
@@ -406,7 +406,7 @@ sgX_geometry_dump_as_vtk
* Where <N1> is 2 * vertices_count, <N2> is 2 * segments_count and <N3> is
* 3 * segments_count.
* The two qualifiers static and const are output or not according to flags;
- * flags must be ORed enum sg2_c_dump_qualifiers values. */
+ * flags must be ORed enum sg2d_c_dump_qualifiers values. */
static FINLINE res_T
sgX_geometry_dump_as_c_code
(const sgX_geometry* geometry,
@@ -414,21 +414,21 @@ sgX_geometry_dump_as_c_code
const char* name_prefix, /* Can be NULL or "" */
const int flags)
{
- return sg2_geometry_dump_as_c_code(geometry, stream, name_prefix, flags);
+ return sg2d_geometry_dump_as_c_code(geometry, stream, name_prefix, flags);
}
static FINLINE res_T
sgX_geometry_ref_get
(sgX_geometry* geometry)
{
- return sg2_geometry_ref_get(geometry);
+ return sg2d_geometry_ref_get(geometry);
}
static FINLINE res_T
sgX_geometry_ref_put
(sgX_geometry* geometry)
{
- return sg2_geometry_ref_put(geometry);
+ return sg2d_geometry_ref_put(geometry);
}
/******************************************************************************
@@ -443,7 +443,7 @@ sgX_sencX_geometry_get_indices
unsigned indices[SGX_GEOMETRY_DIMENSION],
void* ctx)
{
- sg2_senc_geometry_get_indices(itri, indices, ctx);
+ sg2d_senc_geometry_get_indices(itri, indices, ctx);
}
/* Get vertex indices for the itri_th triangle.
@@ -454,7 +454,7 @@ sgX_sencX_geometry_get_media
unsigned media[2],
void* ctx)
{
- sg2_senc_geometry_get_media(itri, media, ctx);
+ sg2d_senc_geometry_get_media(itri, media, ctx);
}
/* Get vertex indices for the itri_th triangle.
@@ -465,7 +465,7 @@ sgX_sencX_geometry_get_position
double coord[SGX_GEOMETRY_DIMENSION],
void* ctx)
{
- sg2_senc_geometry_get_position(ivert, coord, ctx);
+ sg2d_senc_geometry_get_position(ivert, coord, ctx);
}
/******************************************************************************
@@ -481,7 +481,7 @@ sgX_sXd_geometry_get_indices
unsigned indices[SGX_GEOMETRY_DIMENSION],
void* ctx)
{
- sg2_s2d_geometry_get_indices(itri, indices, ctx);
+ sg2d_s2d_geometry_get_indices(itri, indices, ctx);
}
/* Get coordinates for the ivert_th vertex.
@@ -493,7 +493,7 @@ sgX_sXd_geometry_get_position
float coord[SGX_GEOMETRY_DIMENSION],
void* ctx)
{
- sg2_s2d_geometry_get_position(ivert, coord, ctx);
+ sg2d_s2d_geometry_get_position(ivert, coord, ctx);
}
END_DECLS
diff --git a/src/test_sg2_device.c b/src/test_sg2_device.c
@@ -14,7 +14,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "sg2.h"
-#include "test_sg2_utils.h"
+#include "test_sg2d_utils.h"
#include <rsys/logger.h>
@@ -31,23 +31,23 @@ main(int argc, char** argv)
{
struct logger logger;
struct mem_allocator allocator;
- struct sg2_device* dev;
+ struct sg2d_device* dev;
(void)argc, (void)argv;
- BA(sg2_device_create(NULL, NULL, 0, NULL));
- OK(sg2_device_create(NULL, NULL, 0, &dev));
- BA(sg2_device_ref_get(NULL));
- OK(sg2_device_ref_get(dev));
- BA(sg2_device_ref_put(NULL));
- OK(sg2_device_ref_put(dev));
- OK(sg2_device_ref_put(dev));
+ BA(sg2d_device_create(NULL, NULL, 0, NULL));
+ OK(sg2d_device_create(NULL, NULL, 0, &dev));
+ BA(sg2d_device_ref_get(NULL));
+ OK(sg2d_device_ref_get(dev));
+ BA(sg2d_device_ref_put(NULL));
+ OK(sg2d_device_ref_put(dev));
+ OK(sg2d_device_ref_put(dev));
OK(mem_init_proxy_allocator(&allocator, &mem_default_allocator));
CHK(MEM_ALLOCATED_SIZE(&allocator) == 0);
- BA(sg2_device_create(NULL, &allocator, 0, NULL));
- OK(sg2_device_create(NULL, &allocator, 0, &dev));
- OK(sg2_device_ref_put(dev));
+ BA(sg2d_device_create(NULL, &allocator, 0, NULL));
+ OK(sg2d_device_create(NULL, &allocator, 0, &dev));
+ OK(sg2d_device_ref_put(dev));
CHK(MEM_ALLOCATED_SIZE(&allocator) == 0);
OK(logger_init(&allocator, &logger));
@@ -55,16 +55,16 @@ main(int argc, char** argv)
logger_set_stream(&logger, LOG_ERROR, log_stream, NULL);
logger_set_stream(&logger, LOG_WARNING, log_stream, NULL);
- BA(sg2_device_create(&logger, NULL, 0, NULL));
- OK(sg2_device_create(&logger, NULL, 1, &dev));
- OK(sg2_device_ref_put(dev));
+ BA(sg2d_device_create(&logger, NULL, 0, NULL));
+ OK(sg2d_device_create(&logger, NULL, 1, &dev));
+ OK(sg2d_device_ref_put(dev));
- BA(sg2_device_create(&logger, &allocator, 0, NULL));
- OK(sg2_device_create(&logger, &allocator, 0, &dev));
- OK(sg2_device_ref_put(dev));
+ BA(sg2d_device_create(&logger, &allocator, 0, NULL));
+ OK(sg2d_device_create(&logger, &allocator, 0, &dev));
+ OK(sg2d_device_ref_put(dev));
- OK(sg2_device_create(&logger, &allocator, 0, &dev));
- OK(sg2_device_ref_put(dev));
+ OK(sg2d_device_create(&logger, &allocator, 0, &dev));
+ OK(sg2d_device_ref_put(dev));
logger_release(&logger);
check_memory_allocator(&allocator);
diff --git a/src/test_sg2_geometry.c b/src/test_sg2_geometry.c
@@ -14,14 +14,14 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "sg2.h"
-#include "test_sg2_utils.h"
+#include "test_sg2d_utils.h"
#include <stdio.h>
static res_T
validate
(const unsigned iseg,
- const unsigned properties[SG2_PROP_TYPES_COUNT__],
+ const unsigned properties[SG2D_PROP_TYPES_COUNT__],
void* context,
int* properties_conflict)
{
@@ -35,8 +35,8 @@ merge_seg
(const unsigned user_id,
const unsigned iseg,
const int reversed_segment,
- unsigned segment_properties[SG2_PROP_TYPES_COUNT__],
- const unsigned merged_properties[SG2_PROP_TYPES_COUNT__],
+ unsigned segment_properties[SG2D_PROP_TYPES_COUNT__],
+ const unsigned merged_properties[SG2D_PROP_TYPES_COUNT__],
void* context,
int* merge_conflict)
{
@@ -64,121 +64,121 @@ int
main(int argc, char** argv)
{
struct mem_allocator allocator;
- struct sg2_device* dev;
- struct sg2_geometry* geom;
+ struct sg2d_device* dev;
+ struct sg2d_geometry* geom;
double coord[2];
unsigned indices[2];
unsigned degenerated[2] = { 0, 0 };
- unsigned properties[SG2_PROP_TYPES_COUNT__];
- struct sg2_geometry_add_callbacks callbacks = SG2_ADD_CALLBACKS_NULL__;
+ unsigned properties[SG2D_PROP_TYPES_COUNT__];
+ struct sg2d_geometry_add_callbacks callbacks = SG2D_ADD_CALLBACKS_NULL__;
unsigned user_id;
unsigned count, i;
struct context ctx = CONTEXT_NULL__;
(void)argc, (void)argv;
OK(mem_init_proxy_allocator(&allocator, &mem_default_allocator));
- OK(sg2_device_create(NULL, &allocator, 1, &dev));
-
- BA(sg2_geometry_create(NULL, &geom));
- BA(sg2_geometry_create(dev, NULL));
- OK(sg2_geometry_create(dev, &geom));
-
- BA(sg2_geometry_ref_get(NULL));
- OK(sg2_geometry_ref_get(geom));
-
- BA(sg2_geometry_ref_put(NULL));
- OK(sg2_geometry_ref_put(geom));
- OK(sg2_geometry_ref_put(geom));
-
- OK(sg2_geometry_create(dev, &geom));
-
- BA(sg2_geometry_validate_properties(NULL, NULL, NULL));
- BA(sg2_geometry_validate_properties(geom, NULL, NULL));
- BA(sg2_geometry_validate_properties(NULL, validate, NULL));
- OK(sg2_geometry_validate_properties(geom, validate, NULL));
-
- BA(sg2_geometry_get_unique_vertices_count(NULL, NULL));
- BA(sg2_geometry_get_unique_vertices_count(geom, NULL));
- BA(sg2_geometry_get_unique_vertices_count(NULL, &count));
- OK(sg2_geometry_get_unique_vertices_count(geom, &count));
-
- BA(sg2_geometry_get_added_segments_count(NULL, NULL));
- BA(sg2_geometry_get_added_segments_count(geom, NULL));
- BA(sg2_geometry_get_added_segments_count(NULL, &count));
- OK(sg2_geometry_get_added_segments_count(geom, &count));
-
- BA(sg2_geometry_get_unique_segments_count(NULL, NULL));
- BA(sg2_geometry_get_unique_segments_count(geom, NULL));
- BA(sg2_geometry_get_unique_segments_count(NULL, &count));
- OK(sg2_geometry_get_unique_segments_count(geom, &count));
-
- BA(sg2_geometry_get_unique_segments_with_unspecified_side_count(NULL, NULL));
- BA(sg2_geometry_get_unique_segments_with_unspecified_side_count(geom, NULL));
- BA(sg2_geometry_get_unique_segments_with_unspecified_side_count(NULL, &count));
- OK(sg2_geometry_get_unique_segments_with_unspecified_side_count(geom, &count));
-
- BA(sg2_geometry_get_unique_segments_with_unspecified_interface_count(NULL, NULL));
- BA(sg2_geometry_get_unique_segments_with_unspecified_interface_count(geom, NULL));
- BA(sg2_geometry_get_unique_segments_with_unspecified_interface_count(NULL, &count));
- OK(sg2_geometry_get_unique_segments_with_unspecified_interface_count(geom, &count));
-
- BA(sg2_geometry_get_unique_segments_with_merge_conflict_count(NULL, NULL));
- BA(sg2_geometry_get_unique_segments_with_merge_conflict_count(geom, NULL));
- BA(sg2_geometry_get_unique_segments_with_merge_conflict_count(NULL, &count));
- OK(sg2_geometry_get_unique_segments_with_merge_conflict_count(geom, &count));
-
- BA(sg2_geometry_get_unique_segments_with_properties_conflict_count(NULL, NULL));
- BA(sg2_geometry_get_unique_segments_with_properties_conflict_count(geom, NULL));
- BA(sg2_geometry_get_unique_segments_with_properties_conflict_count(NULL, &count));
- OK(sg2_geometry_get_unique_segments_with_properties_conflict_count(geom, &count));
-
- BA(sg2_geometry_dump_as_obj(NULL, NULL, 0));
- BA(sg2_geometry_dump_as_obj(geom, NULL, 0));
- BA(sg2_geometry_dump_as_obj(NULL, stdout, 0));
- BA(sg2_geometry_dump_as_obj(NULL, NULL, SG2_OBJ_DUMP_ALL));
- BA(sg2_geometry_dump_as_obj(geom, stdout, 0));
- BA(sg2_geometry_dump_as_obj(geom, NULL, SG2_OBJ_DUMP_ALL));
- BA(sg2_geometry_dump_as_obj(NULL, stdout, SG2_OBJ_DUMP_ALL));
+ OK(sg2d_device_create(NULL, &allocator, 1, &dev));
+
+ BA(sg2d_geometry_create(NULL, &geom));
+ BA(sg2d_geometry_create(dev, NULL));
+ OK(sg2d_geometry_create(dev, &geom));
+
+ BA(sg2d_geometry_ref_get(NULL));
+ OK(sg2d_geometry_ref_get(geom));
+
+ BA(sg2d_geometry_ref_put(NULL));
+ OK(sg2d_geometry_ref_put(geom));
+ OK(sg2d_geometry_ref_put(geom));
+
+ OK(sg2d_geometry_create(dev, &geom));
+
+ BA(sg2d_geometry_validate_properties(NULL, NULL, NULL));
+ BA(sg2d_geometry_validate_properties(geom, NULL, NULL));
+ BA(sg2d_geometry_validate_properties(NULL, validate, NULL));
+ OK(sg2d_geometry_validate_properties(geom, validate, NULL));
+
+ BA(sg2d_geometry_get_unique_vertices_count(NULL, NULL));
+ BA(sg2d_geometry_get_unique_vertices_count(geom, NULL));
+ BA(sg2d_geometry_get_unique_vertices_count(NULL, &count));
+ OK(sg2d_geometry_get_unique_vertices_count(geom, &count));
+
+ BA(sg2d_geometry_get_added_segments_count(NULL, NULL));
+ BA(sg2d_geometry_get_added_segments_count(geom, NULL));
+ BA(sg2d_geometry_get_added_segments_count(NULL, &count));
+ OK(sg2d_geometry_get_added_segments_count(geom, &count));
+
+ BA(sg2d_geometry_get_unique_segments_count(NULL, NULL));
+ BA(sg2d_geometry_get_unique_segments_count(geom, NULL));
+ BA(sg2d_geometry_get_unique_segments_count(NULL, &count));
+ OK(sg2d_geometry_get_unique_segments_count(geom, &count));
+
+ BA(sg2d_geometry_get_unique_segments_with_unspecified_side_count(NULL, NULL));
+ BA(sg2d_geometry_get_unique_segments_with_unspecified_side_count(geom, NULL));
+ BA(sg2d_geometry_get_unique_segments_with_unspecified_side_count(NULL, &count));
+ OK(sg2d_geometry_get_unique_segments_with_unspecified_side_count(geom, &count));
+
+ BA(sg2d_geometry_get_unique_segments_with_unspecified_interface_count(NULL, NULL));
+ BA(sg2d_geometry_get_unique_segments_with_unspecified_interface_count(geom, NULL));
+ BA(sg2d_geometry_get_unique_segments_with_unspecified_interface_count(NULL, &count));
+ OK(sg2d_geometry_get_unique_segments_with_unspecified_interface_count(geom, &count));
+
+ BA(sg2d_geometry_get_unique_segments_with_merge_conflict_count(NULL, NULL));
+ BA(sg2d_geometry_get_unique_segments_with_merge_conflict_count(geom, NULL));
+ BA(sg2d_geometry_get_unique_segments_with_merge_conflict_count(NULL, &count));
+ OK(sg2d_geometry_get_unique_segments_with_merge_conflict_count(geom, &count));
+
+ BA(sg2d_geometry_get_unique_segments_with_properties_conflict_count(NULL, NULL));
+ BA(sg2d_geometry_get_unique_segments_with_properties_conflict_count(geom, NULL));
+ BA(sg2d_geometry_get_unique_segments_with_properties_conflict_count(NULL, &count));
+ OK(sg2d_geometry_get_unique_segments_with_properties_conflict_count(geom, &count));
+
+ BA(sg2d_geometry_dump_as_obj(NULL, NULL, 0));
+ BA(sg2d_geometry_dump_as_obj(geom, NULL, 0));
+ BA(sg2d_geometry_dump_as_obj(NULL, stdout, 0));
+ BA(sg2d_geometry_dump_as_obj(NULL, NULL, SG2D_OBJ_DUMP_ALL));
+ BA(sg2d_geometry_dump_as_obj(geom, stdout, 0));
+ BA(sg2d_geometry_dump_as_obj(geom, NULL, SG2D_OBJ_DUMP_ALL));
+ BA(sg2d_geometry_dump_as_obj(NULL, stdout, SG2D_OBJ_DUMP_ALL));
/* BA because geometry is empty */
- BA(sg2_geometry_dump_as_obj(geom, stdout, SG2_OBJ_DUMP_ALL));
+ BA(sg2d_geometry_dump_as_obj(geom, stdout, SG2D_OBJ_DUMP_ALL));
- BA(sg2_geometry_dump_as_vtk(NULL, NULL));
- BA(sg2_geometry_dump_as_vtk(geom, NULL));
- BA(sg2_geometry_dump_as_vtk(NULL, stdout));
+ BA(sg2d_geometry_dump_as_vtk(NULL, NULL));
+ BA(sg2d_geometry_dump_as_vtk(geom, NULL));
+ BA(sg2d_geometry_dump_as_vtk(NULL, stdout));
/* BA because geometry is empty */
- BA(sg2_geometry_dump_as_vtk(geom, stdout));
-
- BA(sg2_geometry_dump_as_c_code(NULL, NULL, NULL, 0));
- BA(sg2_geometry_dump_as_c_code(geom, NULL, NULL, 0));
- BA(sg2_geometry_dump_as_c_code(NULL, stdout, NULL, 0));
- BA(sg2_geometry_dump_as_c_code(NULL, NULL, "test", 0));
- BA(sg2_geometry_dump_as_c_code(geom, NULL, "test", 0));
- BA(sg2_geometry_dump_as_c_code(NULL, stdout, "test", 0));
+ BA(sg2d_geometry_dump_as_vtk(geom, stdout));
+
+ BA(sg2d_geometry_dump_as_c_code(NULL, NULL, NULL, 0));
+ BA(sg2d_geometry_dump_as_c_code(geom, NULL, NULL, 0));
+ BA(sg2d_geometry_dump_as_c_code(NULL, stdout, NULL, 0));
+ BA(sg2d_geometry_dump_as_c_code(NULL, NULL, "test", 0));
+ BA(sg2d_geometry_dump_as_c_code(geom, NULL, "test", 0));
+ BA(sg2d_geometry_dump_as_c_code(NULL, stdout, "test", 0));
/* BA because geometry is empty */
- BA(sg2_geometry_dump_as_c_code(geom, stdout, NULL, 0));
- BA(sg2_geometry_dump_as_c_code(geom, stdout, "test", 0));
+ BA(sg2d_geometry_dump_as_c_code(geom, stdout, NULL, 0));
+ BA(sg2d_geometry_dump_as_c_code(geom, stdout, "test", 0));
- BA(sg2_geometry_add(NULL, 0, 0, &callbacks, NULL));
- OK(sg2_geometry_get_added_segments_count(geom, &count));
+ BA(sg2d_geometry_add(NULL, 0, 0, &callbacks, NULL));
+ OK(sg2d_geometry_get_added_segments_count(geom, &count));
CHK(count == 0);
- BA(sg2_geometry_add(geom, nvertices, nsegments, NULL, NULL));
- OK(sg2_geometry_get_added_segments_count(geom, &count));
+ BA(sg2d_geometry_add(geom, nvertices, nsegments, NULL, NULL));
+ OK(sg2d_geometry_get_added_segments_count(geom, &count));
CHK(count == nsegments);
/* Mandatory callbacks are NULL */
callbacks.get_indices = NULL;
callbacks.get_position = get_position;
- BA(sg2_geometry_add(geom, 0, 0, &callbacks, NULL));
+ BA(sg2d_geometry_add(geom, 0, 0, &callbacks, NULL));
callbacks.get_indices = get_indices;
callbacks.get_position = NULL;
- BA(sg2_geometry_add(geom, 0, 0, &callbacks, NULL));
+ BA(sg2d_geometry_add(geom, 0, 0, &callbacks, NULL));
callbacks.get_indices = NULL;
callbacks.get_position = NULL;
- BA(sg2_geometry_add(geom, 0, 0, &callbacks, NULL));
+ BA(sg2d_geometry_add(geom, 0, 0, &callbacks, NULL));
/* Add 0 items */
callbacks.get_indices = get_indices;
callbacks.get_position = get_position;
- OK(sg2_geometry_add(geom, 0, 0, &callbacks, NULL));
- OK(sg2_geometry_get_added_segments_count(geom, &count));
+ OK(sg2d_geometry_add(geom, 0, 0, &callbacks, NULL));
+ OK(sg2d_geometry_get_added_segments_count(geom, &count));
CHK(count == nsegments);
/* A 2D square.
@@ -194,97 +194,97 @@ main(int argc, char** argv)
callbacks.get_properties = get_properties;
callbacks.get_position = get_position;
- OK(sg2_geometry_add(geom, nvertices, nsegments, &callbacks, &ctx));
- OK(sg2_geometry_dump_as_obj(geom, stdout, SG2_OBJ_DUMP_ALL));
- OK(sg2_geometry_dump_as_vtk(geom, stdout));
- OK(sg2_geometry_dump_as_c_code(geom, stdout, NULL, 0));
- OK(sg2_geometry_dump_as_c_code(geom, stdout, "test",
- SG2_C_DUMP_STATIC | SG2_C_DUMP_CONST));
-
- BA(sg2_geometry_get_unique_vertex(NULL, nsegments, NULL));
- BA(sg2_geometry_get_unique_vertex(geom, nsegments, NULL));
- BA(sg2_geometry_get_unique_vertex(NULL, 0, NULL));
- BA(sg2_geometry_get_unique_vertex(NULL, nsegments, coord));
- BA(sg2_geometry_get_unique_vertex(geom, 0, NULL));
- BA(sg2_geometry_get_unique_vertex(geom, nsegments, coord));
- BA(sg2_geometry_get_unique_vertex(NULL, 0, coord));
- OK(sg2_geometry_get_unique_vertex(geom, 0, coord));
-
- BA(sg2_geometry_get_unique_segment_vertices(NULL, nsegments, NULL));
- BA(sg2_geometry_get_unique_segment_vertices(geom, nsegments, NULL));
- BA(sg2_geometry_get_unique_segment_vertices(NULL, 0, NULL));
- BA(sg2_geometry_get_unique_segment_vertices(NULL, nsegments, indices));
- BA(sg2_geometry_get_unique_segment_vertices(geom, 0, NULL));
- BA(sg2_geometry_get_unique_segment_vertices(geom, nsegments, indices));
- BA(sg2_geometry_get_unique_segment_vertices(NULL, 0, indices));
- OK(sg2_geometry_get_unique_segment_vertices(geom, 0, indices));
+ OK(sg2d_geometry_add(geom, nvertices, nsegments, &callbacks, &ctx));
+ OK(sg2d_geometry_dump_as_obj(geom, stdout, SG2D_OBJ_DUMP_ALL));
+ OK(sg2d_geometry_dump_as_vtk(geom, stdout));
+ OK(sg2d_geometry_dump_as_c_code(geom, stdout, NULL, 0));
+ OK(sg2d_geometry_dump_as_c_code(geom, stdout, "test",
+ SG2D_C_DUMP_STATIC | SG2D_C_DUMP_CONST));
+
+ BA(sg2d_geometry_get_unique_vertex(NULL, nsegments, NULL));
+ BA(sg2d_geometry_get_unique_vertex(geom, nsegments, NULL));
+ BA(sg2d_geometry_get_unique_vertex(NULL, 0, NULL));
+ BA(sg2d_geometry_get_unique_vertex(NULL, nsegments, coord));
+ BA(sg2d_geometry_get_unique_vertex(geom, 0, NULL));
+ BA(sg2d_geometry_get_unique_vertex(geom, nsegments, coord));
+ BA(sg2d_geometry_get_unique_vertex(NULL, 0, coord));
+ OK(sg2d_geometry_get_unique_vertex(geom, 0, coord));
+
+ BA(sg2d_geometry_get_unique_segment_vertices(NULL, nsegments, NULL));
+ BA(sg2d_geometry_get_unique_segment_vertices(geom, nsegments, NULL));
+ BA(sg2d_geometry_get_unique_segment_vertices(NULL, 0, NULL));
+ BA(sg2d_geometry_get_unique_segment_vertices(NULL, nsegments, indices));
+ BA(sg2d_geometry_get_unique_segment_vertices(geom, 0, NULL));
+ BA(sg2d_geometry_get_unique_segment_vertices(geom, nsegments, indices));
+ BA(sg2d_geometry_get_unique_segment_vertices(NULL, 0, indices));
+ OK(sg2d_geometry_get_unique_segment_vertices(geom, 0, indices));
FOR_EACH(i, 0 , 2) CHK(indices[i] == box_indices[i]);
- BA(sg2_geometry_get_unique_segment_properties(NULL, nsegments, NULL));
- BA(sg2_geometry_get_unique_segment_properties(geom, nsegments, NULL));
- BA(sg2_geometry_get_unique_segment_properties(NULL, 0, NULL));
- BA(sg2_geometry_get_unique_segment_properties(NULL, nsegments, properties));
- BA(sg2_geometry_get_unique_segment_properties(geom, 0, NULL));
- BA(sg2_geometry_get_unique_segment_properties(geom, nsegments, properties));
- BA(sg2_geometry_get_unique_segment_properties(NULL, 0, properties));
- OK(sg2_geometry_get_unique_segment_properties(geom, 0, properties));
- CHK(medium0[0] == properties[SG2_FRONT]);
- CHK(medium1[0] == properties[SG2_BACK]);
- CHK(intface0[0] == properties[SG2_INTFACE]);
-
- BA(sg2_geometry_get_unique_segment_user_id(NULL, nsegments, NULL));
- BA(sg2_geometry_get_unique_segment_user_id(geom, nsegments, NULL));
- BA(sg2_geometry_get_unique_segment_user_id(NULL, 0, NULL));
- BA(sg2_geometry_get_unique_segment_user_id(NULL, nsegments, &user_id));
- BA(sg2_geometry_get_unique_segment_user_id(geom, 0, NULL));
- BA(sg2_geometry_get_unique_segment_user_id(geom, nsegments, &user_id));
- BA(sg2_geometry_get_unique_segment_user_id(NULL, 0, &user_id));
- OK(sg2_geometry_get_unique_segment_user_id(geom, 0, &user_id));
+ BA(sg2d_geometry_get_unique_segment_properties(NULL, nsegments, NULL));
+ BA(sg2d_geometry_get_unique_segment_properties(geom, nsegments, NULL));
+ BA(sg2d_geometry_get_unique_segment_properties(NULL, 0, NULL));
+ BA(sg2d_geometry_get_unique_segment_properties(NULL, nsegments, properties));
+ BA(sg2d_geometry_get_unique_segment_properties(geom, 0, NULL));
+ BA(sg2d_geometry_get_unique_segment_properties(geom, nsegments, properties));
+ BA(sg2d_geometry_get_unique_segment_properties(NULL, 0, properties));
+ OK(sg2d_geometry_get_unique_segment_properties(geom, 0, properties));
+ CHK(medium0[0] == properties[SG2D_FRONT]);
+ CHK(medium1[0] == properties[SG2D_BACK]);
+ CHK(intface0[0] == properties[SG2D_INTFACE]);
+
+ BA(sg2d_geometry_get_unique_segment_user_id(NULL, nsegments, NULL));
+ BA(sg2d_geometry_get_unique_segment_user_id(geom, nsegments, NULL));
+ BA(sg2d_geometry_get_unique_segment_user_id(NULL, 0, NULL));
+ BA(sg2d_geometry_get_unique_segment_user_id(NULL, nsegments, &user_id));
+ BA(sg2d_geometry_get_unique_segment_user_id(geom, 0, NULL));
+ BA(sg2d_geometry_get_unique_segment_user_id(geom, nsegments, &user_id));
+ BA(sg2d_geometry_get_unique_segment_user_id(NULL, 0, &user_id));
+ OK(sg2d_geometry_get_unique_segment_user_id(geom, 0, &user_id));
/* Due to a failed attempt to add nsegments segments, user_id for the
* first successfully added segment is shifted */
CHK(user_id == nsegments);
/* Conflicts with merge_seg callback */
callbacks.merge_segment = merge_seg;
- OK(sg2_geometry_add(geom, nvertices, nsegments, &callbacks, &ctx));
- OK(sg2_geometry_get_unique_segments_with_merge_conflict_count(geom, &count));
+ OK(sg2d_geometry_add(geom, nvertices, nsegments, &callbacks, &ctx));
+ OK(sg2d_geometry_get_unique_segments_with_merge_conflict_count(geom, &count));
/* Due to merge_seg internals, all but the first segment have conflict */
CHK(count == nsegments - 1);
- OK(sg2_geometry_dump_as_obj(geom, stdout, SG2_OBJ_DUMP_ALL));
- OK(sg2_geometry_dump_as_vtk(geom, stdout));
+ OK(sg2d_geometry_dump_as_obj(geom, stdout, SG2D_OBJ_DUMP_ALL));
+ OK(sg2d_geometry_dump_as_vtk(geom, stdout));
/* BA because of conflicts */
- BA(sg2_geometry_dump_as_c_code(geom, stdout, "test", SG2_C_DUMP_STATIC));
- OK(sg2_geometry_ref_put(geom));
+ BA(sg2d_geometry_dump_as_c_code(geom, stdout, "test", SG2D_C_DUMP_STATIC));
+ OK(sg2d_geometry_ref_put(geom));
/* Conflicts without merge_seg callback */
- OK(sg2_geometry_create(dev, &geom));
+ OK(sg2d_geometry_create(dev, &geom));
callbacks.merge_segment = NULL;
- OK(sg2_geometry_add(geom, nvertices, nsegments, &callbacks, &ctx));
+ OK(sg2d_geometry_add(geom, nvertices, nsegments, &callbacks, &ctx));
ctx.front_media = medium1_top0;
- OK(sg2_geometry_add(geom, nvertices, nsegments, &callbacks, &ctx));
- OK(sg2_geometry_get_unique_segments_with_merge_conflict_count(geom, &count));
+ OK(sg2d_geometry_add(geom, nvertices, nsegments, &callbacks, &ctx));
+ OK(sg2d_geometry_get_unique_segments_with_merge_conflict_count(geom, &count));
FOR_EACH(i, 0, nsegments) if(medium0[i] != medium1_top0[i]) count--;
CHK(count == 0);
- OK(sg2_geometry_dump_as_obj(geom, stdout, SG2_OBJ_DUMP_ALL));
- OK(sg2_geometry_dump_as_vtk(geom, stdout));
+ OK(sg2d_geometry_dump_as_obj(geom, stdout, SG2D_OBJ_DUMP_ALL));
+ OK(sg2d_geometry_dump_as_vtk(geom, stdout));
/* BA because of conflicts */
- BA(sg2_geometry_dump_as_c_code(geom, stdout, "test", SG2_C_DUMP_CONST));
+ BA(sg2d_geometry_dump_as_c_code(geom, stdout, "test", SG2D_C_DUMP_CONST));
/* Degenerated segments */
ctx.indices = degenerated;
/* Without callback : OK */
- OK(sg2_geometry_add(geom, nvertices, 1, &callbacks, &ctx));
+ OK(sg2d_geometry_add(geom, nvertices, 1, &callbacks, &ctx));
/* With callback : OK */
callbacks.degenerated_segment = degenerated_segment;
ctx.custom = &i;
i = 0;
- OK(sg2_geometry_add(geom, nvertices, 1, &callbacks, &ctx));
+ OK(sg2d_geometry_add(geom, nvertices, 1, &callbacks, &ctx));
/* With callback : KO */
i= 1;
- BA(sg2_geometry_add(geom, nvertices, 1, &callbacks, &ctx));
+ BA(sg2d_geometry_add(geom, nvertices, 1, &callbacks, &ctx));
- OK(sg2_geometry_ref_put(geom));
- OK(sg2_device_ref_put(dev));
+ OK(sg2d_geometry_ref_put(geom));
+ OK(sg2d_device_ref_put(dev));
check_memory_allocator(&allocator);
mem_shutdown_proxy_allocator(&allocator);
diff --git a/src/test_sg2_geometry_2.c b/src/test_sg2_geometry_2.c
@@ -14,7 +14,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "sg2.h"
-#include "test_sg2_utils.h"
+#include "test_sg2d_utils.h"
#include <stdio.h>
@@ -43,8 +43,8 @@ merge_seg
(const unsigned unique_id,
const unsigned iseg,
const int reversed_segment,
- unsigned segment_properties[SG2_PROP_TYPES_COUNT__],
- const unsigned merged_properties[SG2_PROP_TYPES_COUNT__],
+ unsigned segment_properties[SG2D_PROP_TYPES_COUNT__],
+ const unsigned merged_properties[SG2D_PROP_TYPES_COUNT__],
void* context,
int* merge_conflict)
{
@@ -56,8 +56,8 @@ merge_seg
(void)segment_properties; (void)merged_properties;
add_geom_ctx = ctx->custom;
if(add_geom_ctx->merge_res == RES_OK) ++add_geom_ctx->merge_cpt;
- FOR_EACH(i, 0, SG2_PROP_TYPES_COUNT__)
- if(!sg2_compatible_property(segment_properties[i], merged_properties[i]))
+ FOR_EACH(i, 0, SG2D_PROP_TYPES_COUNT__)
+ if(!sg2d_compatible_property(segment_properties[i], merged_properties[i]))
*merge_conflict = 1;
return add_geom_ctx->merge_res;
}
@@ -65,7 +65,7 @@ merge_seg
static res_T
validate
(const unsigned iseg,
- const unsigned properties[SG2_PROP_TYPES_COUNT__],
+ const unsigned properties[SG2D_PROP_TYPES_COUNT__],
void* context,
int* properties_conflict)
{
@@ -77,7 +77,7 @@ validate
static res_T
validate2
(const unsigned iseg,
- const unsigned properties[SG2_PROP_TYPES_COUNT__],
+ const unsigned properties[SG2D_PROP_TYPES_COUNT__],
void* context,
int* properties_conflict)
{
@@ -90,10 +90,10 @@ int
main(int argc, char** argv)
{
struct mem_allocator allocator;
- struct sg2_device* dev;
- struct sg2_geometry* geom;
+ struct sg2d_device* dev;
+ struct sg2d_geometry* geom;
struct context ctx = CONTEXT_NULL__;
- struct sg2_geometry_add_callbacks callbacks = SG2_ADD_CALLBACKS_NULL__;
+ struct sg2d_geometry_add_callbacks callbacks = SG2D_ADD_CALLBACKS_NULL__;
struct add_geom_ctx add_geom_ctx;
unsigned property[12];
unsigned i;
@@ -102,8 +102,8 @@ main(int argc, char** argv)
(void)argc, (void)argv;
OK(mem_init_proxy_allocator(&allocator, &mem_default_allocator));
- OK(sg2_device_create(NULL, &allocator, 1, &dev));
- OK(sg2_geometry_create(dev, &geom));
+ OK(sg2d_device_create(NULL, &allocator, 1, &dev));
+ OK(sg2d_geometry_create(dev, &geom));
/* A 2D square.
* 2 enclosures (inside, outside) sharing the same segments,
@@ -116,7 +116,7 @@ main(int argc, char** argv)
add_geom_ctx.add_res = add_geom_ctx.merge_res = RES_OK;
/* Geometry with no media information on both sides */
- for(i = 0; i < property_count; i++) property[i] = SG2_UNSPECIFIED_PROPERTY;
+ for(i = 0; i < property_count; i++) property[i] = SG2D_UNSPECIFIED_PROPERTY;
ctx.front_media = property;
ctx.back_media = property;
ctx.intface = property;
@@ -130,142 +130,142 @@ main(int argc, char** argv)
/* If add fails, add geometry fails the same way */
add_geom_ctx.add_res = RES_BAD_ARG;
- BA(sg2_geometry_add(geom, nvertices, nsegments, &callbacks, &ctx));
+ BA(sg2d_geometry_add(geom, nvertices, nsegments, &callbacks, &ctx));
CHK(add_geom_ctx.add_cpt == 0);
- OK(sg2_geometry_get_unique_vertices_count(geom, &count));
+ OK(sg2d_geometry_get_unique_vertices_count(geom, &count));
CHK(count == nvertices);
- OK(sg2_geometry_get_added_segments_count(geom, &count));
+ OK(sg2d_geometry_get_added_segments_count(geom, &count));
CHK(count == nsegments);
- OK(sg2_geometry_get_unique_segments_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_count(geom, &count));
CHK(count == 0);
add_geom_ctx.add_res = RES_MEM_ERR;
- ME(sg2_geometry_add(geom, nvertices, nsegments, &callbacks, &ctx));
+ ME(sg2d_geometry_add(geom, nvertices, nsegments, &callbacks, &ctx));
CHK(add_geom_ctx.add_cpt == 0);
CHK(count == 0);
- OK(sg2_geometry_get_added_segments_count(geom, &count));
+ OK(sg2d_geometry_get_added_segments_count(geom, &count));
CHK(count == 2 * nsegments);
- OK(sg2_geometry_get_unique_segments_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_count(geom, &count));
CHK(count == 0);
- OK(sg2_geometry_get_unique_segments_with_unspecified_side_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_unspecified_side_count(geom, &count));
CHK(count == 0);
- OK(sg2_geometry_get_unique_segments_with_unspecified_interface_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_unspecified_interface_count(geom, &count));
CHK(count == 0);
- OK(sg2_geometry_get_unique_segments_with_merge_conflict_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_merge_conflict_count(geom, &count));
CHK(count == 0);
- OK(sg2_geometry_get_unique_segments_with_properties_conflict_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_properties_conflict_count(geom, &count));
CHK(count == 0);
/* Successful add geometry with add callback */
add_geom_ctx.add_res = RES_OK;
- OK(sg2_geometry_add(geom, nvertices, nsegments, &callbacks, &ctx));
+ OK(sg2d_geometry_add(geom, nvertices, nsegments, &callbacks, &ctx));
CHK(add_geom_ctx.add_cpt == nsegments);
CHK(add_geom_ctx.merge_cpt == 0);
- OK(sg2_geometry_get_unique_vertices_count(geom, &count));
+ OK(sg2d_geometry_get_unique_vertices_count(geom, &count));
CHK(count == nvertices);
- OK(sg2_geometry_get_added_segments_count(geom, &count));
+ OK(sg2d_geometry_get_added_segments_count(geom, &count));
CHK(count == 3 * nsegments);
- OK(sg2_geometry_get_unique_segments_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_count(geom, &count));
CHK(count == nsegments);
- OK(sg2_geometry_get_unique_segments_with_unspecified_side_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_unspecified_side_count(geom, &count));
CHK(count == nsegments);
- OK(sg2_geometry_get_unique_segments_with_unspecified_interface_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_unspecified_interface_count(geom, &count));
CHK(count == nsegments);
- OK(sg2_geometry_get_unique_segments_with_merge_conflict_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_merge_conflict_count(geom, &count));
CHK(count == 0);
- OK(sg2_geometry_get_unique_segments_with_properties_conflict_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_properties_conflict_count(geom, &count));
CHK(count == 0);
- OK(sg2_geometry_dump_as_c_code(geom, stdout, "test_unspecified",
- SG2_C_DUMP_STATIC | SG2_C_DUMP_CONST));
+ OK(sg2d_geometry_dump_as_c_code(geom, stdout, "test_unspecified",
+ SG2D_C_DUMP_STATIC | SG2D_C_DUMP_CONST));
/* Clear geometry */
SG2(geometry_ref_put(geom));
- OK(sg2_geometry_create(dev, &geom));
+ OK(sg2d_geometry_create(dev, &geom));
/* Successful add geometry without add callback */
add_geom_ctx.add_cpt = 0;
callbacks.add_segment = NULL;
- OK(sg2_geometry_add(geom, nvertices, nsegments, &callbacks, &ctx));
+ OK(sg2d_geometry_add(geom, nvertices, nsegments, &callbacks, &ctx));
CHK(add_geom_ctx.add_cpt == 0);
CHK(add_geom_ctx.merge_cpt == 0);
- OK(sg2_geometry_get_unique_vertices_count(geom, &count));
+ OK(sg2d_geometry_get_unique_vertices_count(geom, &count));
CHK(count == nvertices);
- OK(sg2_geometry_get_added_segments_count(geom, &count));
+ OK(sg2d_geometry_get_added_segments_count(geom, &count));
CHK(count == nsegments);
- OK(sg2_geometry_get_unique_segments_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_count(geom, &count));
CHK(count == nsegments);
- OK(sg2_geometry_get_unique_segments_with_unspecified_side_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_unspecified_side_count(geom, &count));
CHK(count == nsegments);
- OK(sg2_geometry_get_unique_segments_with_unspecified_interface_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_unspecified_interface_count(geom, &count));
CHK(count == nsegments);
- OK(sg2_geometry_get_unique_segments_with_merge_conflict_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_merge_conflict_count(geom, &count));
CHK(count == 0);
- OK(sg2_geometry_get_unique_segments_with_properties_conflict_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_properties_conflict_count(geom, &count));
CHK(count == 0);
/* If merge fails, add geometry fails the same way */
add_geom_ctx.merge_res = RES_BAD_ARG;
callbacks.add_segment = add_seg;
- BA(sg2_geometry_add(geom, nvertices, nsegments, &callbacks, &ctx));
+ BA(sg2d_geometry_add(geom, nvertices, nsegments, &callbacks, &ctx));
CHK(add_geom_ctx.merge_cpt == 0);
- OK(sg2_geometry_get_added_segments_count(geom, &count));
+ OK(sg2d_geometry_get_added_segments_count(geom, &count));
CHK(count == 2 * nsegments);
add_geom_ctx.merge_res = RES_MEM_ERR;
- ME(sg2_geometry_add(geom, nvertices, nsegments, &callbacks, &ctx));
+ ME(sg2d_geometry_add(geom, nvertices, nsegments, &callbacks, &ctx));
CHK(add_geom_ctx.merge_cpt == 0);
- OK(sg2_geometry_get_added_segments_count(geom, &count));
+ OK(sg2d_geometry_get_added_segments_count(geom, &count));
CHK(count == 3 * nsegments);
- OK(sg2_geometry_get_unique_vertices_count(geom, &count));
+ OK(sg2d_geometry_get_unique_vertices_count(geom, &count));
CHK(count == nvertices);
- OK(sg2_geometry_get_unique_segments_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_count(geom, &count));
CHK(count == nsegments);
- OK(sg2_geometry_get_unique_segments_with_unspecified_side_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_unspecified_side_count(geom, &count));
CHK(count == nsegments);
- OK(sg2_geometry_get_unique_segments_with_unspecified_interface_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_unspecified_interface_count(geom, &count));
CHK(count == nsegments);
- OK(sg2_geometry_get_unique_segments_with_merge_conflict_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_merge_conflict_count(geom, &count));
CHK(count == 0); /* merge failed but with a no-conflict status */
- OK(sg2_geometry_get_unique_segments_with_properties_conflict_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_properties_conflict_count(geom, &count));
CHK(count == 0);
/* Successful add geometry without merge callback */
callbacks.merge_segment = NULL;
- OK(sg2_geometry_add(geom, nvertices, nsegments, &callbacks, &ctx));
+ OK(sg2d_geometry_add(geom, nvertices, nsegments, &callbacks, &ctx));
CHK(add_geom_ctx.merge_cpt == 0);
- OK(sg2_geometry_get_unique_vertices_count(geom, &count));
+ OK(sg2d_geometry_get_unique_vertices_count(geom, &count));
CHK(count == nvertices);
- OK(sg2_geometry_get_added_segments_count(geom, &count));
+ OK(sg2d_geometry_get_added_segments_count(geom, &count));
CHK(count == 4 * nsegments);
- OK(sg2_geometry_get_unique_segments_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_count(geom, &count));
CHK(count == nsegments);
- OK(sg2_geometry_get_unique_segments_with_unspecified_side_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_unspecified_side_count(geom, &count));
CHK(count == nsegments);
- OK(sg2_geometry_get_unique_segments_with_unspecified_interface_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_unspecified_interface_count(geom, &count));
CHK(count == nsegments);
- OK(sg2_geometry_get_unique_segments_with_merge_conflict_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_merge_conflict_count(geom, &count));
CHK(count == 0);
- OK(sg2_geometry_get_unique_segments_with_properties_conflict_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_properties_conflict_count(geom, &count));
CHK(count == 0);
/* Successful add geometry with merge callback */
add_geom_ctx.merge_res = RES_OK;
callbacks.merge_segment = merge_seg;
- OK(sg2_geometry_add(geom, nvertices, nsegments, &callbacks, &ctx));
+ OK(sg2d_geometry_add(geom, nvertices, nsegments, &callbacks, &ctx));
CHK(add_geom_ctx.merge_cpt == nsegments);
add_geom_ctx.merge_cpt = 0;
- OK(sg2_geometry_get_unique_vertices_count(geom, &count));
+ OK(sg2d_geometry_get_unique_vertices_count(geom, &count));
CHK(count == nvertices);
- OK(sg2_geometry_get_added_segments_count(geom, &count));
+ OK(sg2d_geometry_get_added_segments_count(geom, &count));
CHK(count == 5 * nsegments);
- OK(sg2_geometry_get_unique_segments_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_count(geom, &count));
CHK(count == nsegments);
- OK(sg2_geometry_get_unique_segments_with_unspecified_side_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_unspecified_side_count(geom, &count));
CHK(count == nsegments);
- OK(sg2_geometry_get_unique_segments_with_unspecified_interface_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_unspecified_interface_count(geom, &count));
CHK(count == nsegments);
- OK(sg2_geometry_get_unique_segments_with_merge_conflict_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_merge_conflict_count(geom, &count));
CHK(count == 0); /* merge failed but with a no-conflict status */
- OK(sg2_geometry_get_unique_segments_with_properties_conflict_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_properties_conflict_count(geom, &count));
CHK(count == 0);
/* Geometry with media information on both sides */
@@ -274,65 +274,65 @@ main(int argc, char** argv)
/* Clear geometry */
SG2(geometry_ref_put(geom));
- OK(sg2_geometry_create(dev, &geom));
+ OK(sg2d_geometry_create(dev, &geom));
/* Successful add geometry with add callback
* First half of the segments, then all of them */
add_geom_ctx.add_res = RES_OK;
- OK(sg2_geometry_add(geom, nvertices, nsegments / 2, &callbacks, &ctx));
- OK(sg2_geometry_get_added_segments_count(geom, &count));
+ OK(sg2d_geometry_add(geom, nvertices, nsegments / 2, &callbacks, &ctx));
+ OK(sg2d_geometry_get_added_segments_count(geom, &count));
CHK(count == nsegments / 2);
- OK(sg2_geometry_add(geom, nvertices, nsegments, &callbacks, &ctx));
+ OK(sg2d_geometry_add(geom, nvertices, nsegments, &callbacks, &ctx));
CHK(add_geom_ctx.add_cpt == nsegments);
CHK(add_geom_ctx.merge_cpt == nsegments / 2);
add_geom_ctx.add_cpt = 0;
- OK(sg2_geometry_get_added_segments_count(geom, &count));
+ OK(sg2d_geometry_get_added_segments_count(geom, &count));
CHK(count == nsegments + nsegments / 2);
- OK(sg2_geometry_get_unique_vertices_count(geom, &count));
+ OK(sg2d_geometry_get_unique_vertices_count(geom, &count));
CHK(count == nvertices);
- OK(sg2_geometry_get_unique_segments_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_count(geom, &count));
CHK(count == nsegments);
- OK(sg2_geometry_get_unique_segments_with_unspecified_side_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_unspecified_side_count(geom, &count));
CHK(count == 0); /* media where defined */
- OK(sg2_geometry_get_unique_segments_with_unspecified_interface_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_unspecified_interface_count(geom, &count));
CHK(count == nsegments); /* interfaces where unspecified */
- OK(sg2_geometry_get_unique_segments_with_merge_conflict_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_merge_conflict_count(geom, &count));
CHK(count == 0);
- OK(sg2_geometry_get_unique_segments_with_properties_conflict_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_properties_conflict_count(geom, &count));
CHK(count == 0);
- OK(sg2_geometry_dump_as_vtk(geom, stdout));
+ OK(sg2d_geometry_dump_as_vtk(geom, stdout));
/* Second add was half duplicated, so numbering is shifted */
FOR_EACH(i, 0, nsegments) {
unsigned id;
- OK(sg2_geometry_get_unique_segment_user_id(geom, i, &id));
+ OK(sg2d_geometry_get_unique_segment_user_id(geom, i, &id));
CHK(i < nsegments / 2 ? id == i : id == i + nsegments / 2);
}
/* Clear geometry */
SG2(geometry_ref_put(geom));
- OK(sg2_geometry_create(dev, &geom));
+ OK(sg2d_geometry_create(dev, &geom));
add_geom_ctx.merge_cpt = 0;
/* Successful add geometry with add callback and no defined properties */
add_geom_ctx.add_res = RES_OK;
callbacks.get_properties = NULL;
- OK(sg2_geometry_add(geom, nvertices, nsegments, &callbacks, &ctx));
+ OK(sg2d_geometry_add(geom, nvertices, nsegments, &callbacks, &ctx));
CHK(add_geom_ctx.add_cpt == nsegments);
CHK(add_geom_ctx.merge_cpt == 0);
add_geom_ctx.add_cpt = 0;
- OK(sg2_geometry_get_unique_vertices_count(geom, &count));
+ OK(sg2d_geometry_get_unique_vertices_count(geom, &count));
CHK(count == nvertices);
- OK(sg2_geometry_get_added_segments_count(geom, &count));
+ OK(sg2d_geometry_get_added_segments_count(geom, &count));
CHK(count == nsegments);
- OK(sg2_geometry_get_unique_segments_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_count(geom, &count));
CHK(count == nsegments);
- OK(sg2_geometry_get_unique_segments_with_unspecified_side_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_unspecified_side_count(geom, &count));
CHK(count == nsegments); /* media where unspecified */
- OK(sg2_geometry_get_unique_segments_with_unspecified_interface_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_unspecified_interface_count(geom, &count));
CHK(count == nsegments); /* interfaces where unspecified */
- OK(sg2_geometry_get_unique_segments_with_merge_conflict_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_merge_conflict_count(geom, &count));
CHK(count == 0);
- OK(sg2_geometry_get_unique_segments_with_properties_conflict_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_properties_conflict_count(geom, &count));
CHK(count == 0);
/* Define interface */
@@ -341,22 +341,22 @@ main(int argc, char** argv)
/* Successful add geometry with merge callback and properties */
add_geom_ctx.merge_res = RES_OK;
callbacks.get_properties = get_properties;
- OK(sg2_geometry_add(geom, nvertices, nsegments, &callbacks, &ctx));
+ OK(sg2d_geometry_add(geom, nvertices, nsegments, &callbacks, &ctx));
CHK(add_geom_ctx.merge_cpt == nsegments);
add_geom_ctx.merge_cpt = 0;
- OK(sg2_geometry_get_unique_vertices_count(geom, &count));
+ OK(sg2d_geometry_get_unique_vertices_count(geom, &count));
CHK(count == nvertices);
- OK(sg2_geometry_get_added_segments_count(geom, &count));
+ OK(sg2d_geometry_get_added_segments_count(geom, &count));
CHK(count == 2 * nsegments);
- OK(sg2_geometry_get_unique_segments_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_count(geom, &count));
CHK(count == nsegments);
- OK(sg2_geometry_get_unique_segments_with_unspecified_side_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_unspecified_side_count(geom, &count));
CHK(count == 0); /* media where defined */
- OK(sg2_geometry_get_unique_segments_with_unspecified_interface_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_unspecified_interface_count(geom, &count));
CHK(count == 0); /* interfaces where defined */
- OK(sg2_geometry_get_unique_segments_with_merge_conflict_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_merge_conflict_count(geom, &count));
CHK(count == 0);
- OK(sg2_geometry_get_unique_segments_with_properties_conflict_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_properties_conflict_count(geom, &count));
CHK(count == 0);
/* Geometry with incompatible media information on both sides */
@@ -365,21 +365,21 @@ main(int argc, char** argv)
/* Add geometry without merge callback and conflicts */
callbacks.merge_segment = NULL;
- OK(sg2_geometry_add(geom, nvertices, nsegments, &callbacks, &ctx));
+ OK(sg2d_geometry_add(geom, nvertices, nsegments, &callbacks, &ctx));
CHK(add_geom_ctx.merge_cpt == 0);
- OK(sg2_geometry_get_unique_vertices_count(geom, &count));
+ OK(sg2d_geometry_get_unique_vertices_count(geom, &count));
CHK(count == nvertices);
- OK(sg2_geometry_get_added_segments_count(geom, &count));
+ OK(sg2d_geometry_get_added_segments_count(geom, &count));
CHK(count == 3 * nsegments);
- OK(sg2_geometry_get_unique_segments_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_count(geom, &count));
CHK(count == nsegments);
- OK(sg2_geometry_get_unique_segments_with_unspecified_side_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_unspecified_side_count(geom, &count));
CHK(count == 0); /* media where defined */
- OK(sg2_geometry_get_unique_segments_with_unspecified_interface_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_unspecified_interface_count(geom, &count));
CHK(count == 0); /* interfaces where defined */
- OK(sg2_geometry_get_unique_segments_with_merge_conflict_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_merge_conflict_count(geom, &count));
CHK(count == nsegments);
- OK(sg2_geometry_get_unique_segments_with_properties_conflict_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_properties_conflict_count(geom, &count));
CHK(count == 0);
/* Incompatible interface */
@@ -388,48 +388,48 @@ main(int argc, char** argv)
/* Successful add geometry with merge callback */
add_geom_ctx.merge_res = RES_OK;
callbacks.merge_segment = merge_seg;
- OK(sg2_geometry_add(geom, nvertices, nsegments, &callbacks, &ctx));
+ OK(sg2d_geometry_add(geom, nvertices, nsegments, &callbacks, &ctx));
CHK(add_geom_ctx.merge_cpt == nsegments);
add_geom_ctx.merge_cpt = 0;
- OK(sg2_geometry_get_unique_vertices_count(geom, &count));
+ OK(sg2d_geometry_get_unique_vertices_count(geom, &count));
CHK(count == nvertices);
- OK(sg2_geometry_get_added_segments_count(geom, &count));
+ OK(sg2d_geometry_get_added_segments_count(geom, &count));
CHK(count == 4 * nsegments);
- OK(sg2_geometry_get_unique_segments_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_count(geom, &count));
CHK(count == nsegments);
- OK(sg2_geometry_get_unique_segments_with_unspecified_side_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_unspecified_side_count(geom, &count));
CHK(count == 0); /* media where defined */
- OK(sg2_geometry_get_unique_segments_with_unspecified_interface_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_unspecified_interface_count(geom, &count));
CHK(count == 0); /* interfaces where defined */
- OK(sg2_geometry_get_unique_segments_with_merge_conflict_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_merge_conflict_count(geom, &count));
CHK(count == nsegments);
- OK(sg2_geometry_get_unique_segments_with_properties_conflict_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_properties_conflict_count(geom, &count));
CHK(count == 0);
/* Clear geometry */
SG2(geometry_ref_put(geom));
- OK(sg2_geometry_create(dev, &geom));
+ OK(sg2d_geometry_create(dev, &geom));
/* Successful add geometry with merge callback */
- OK(sg2_geometry_add(geom, nvertices, nsegments, &callbacks, &ctx));
- OK(sg2_geometry_get_unique_segments_with_merge_conflict_count(geom, &count));
+ OK(sg2d_geometry_add(geom, nvertices, nsegments, &callbacks, &ctx));
+ OK(sg2d_geometry_get_unique_segments_with_merge_conflict_count(geom, &count));
CHK(count == 0);
- OK(sg2_geometry_validate_properties(geom, validate, NULL));
- OK(sg2_geometry_get_unique_segments_with_properties_conflict_count(geom, &count));
+ OK(sg2d_geometry_validate_properties(geom, validate, NULL));
+ OK(sg2d_geometry_get_unique_segments_with_properties_conflict_count(geom, &count));
CHK(count == 0);
- OK(sg2_geometry_dump_as_obj(geom, stdout, SG2_OBJ_DUMP_ALL));
+ OK(sg2d_geometry_dump_as_obj(geom, stdout, SG2D_OBJ_DUMP_ALL));
- OK(sg2_geometry_validate_properties(geom, validate, NULL));
- OK(sg2_geometry_get_unique_segments_with_properties_conflict_count(geom, &count));
+ OK(sg2d_geometry_validate_properties(geom, validate, NULL));
+ OK(sg2d_geometry_get_unique_segments_with_properties_conflict_count(geom, &count));
CHK(count == 0);
- OK(sg2_geometry_validate_properties(geom, validate2, NULL));
- OK(sg2_geometry_get_unique_segments_with_properties_conflict_count(geom, &count));
+ OK(sg2d_geometry_validate_properties(geom, validate2, NULL));
+ OK(sg2d_geometry_get_unique_segments_with_properties_conflict_count(geom, &count));
CHK(count == nsegments / 2);
- OK(sg2_geometry_ref_put(geom));
- OK(sg2_device_ref_put(dev));
+ OK(sg2d_geometry_ref_put(geom));
+ OK(sg2d_device_ref_put(dev));
check_memory_allocator(&allocator);
mem_shutdown_proxy_allocator(&allocator);
diff --git a/src/test_sg2_many_enclosures.c b/src/test_sg2_many_enclosures.c
@@ -14,8 +14,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "sg2.h"
-#include "test_sg2_utils.h"
-#include "test_sg2_utils2.h"
+#include "test_sg2d_utils.h"
+#include "test_sg2d_utils2.h"
#include <rsys/double2.h>
@@ -31,9 +31,9 @@ int
main(int argc, char** argv)
{
struct mem_allocator allocator;
- struct sg2_device* dev;
- struct sg2_geometry* geom;
- struct sg2_geometry_add_callbacks callbacks = SG2_ADD_CALLBACKS_NULL__;
+ struct sg2d_device* dev;
+ struct sg2d_geometry* geom;
+ struct sg2d_geometry_add_callbacks callbacks = SG2D_ADD_CALLBACKS_NULL__;
unsigned circ_seg_count, circ_vrtx_count, count;
int i, j, k;
unsigned m_in, m_out, itf = 0;
@@ -41,8 +41,8 @@ main(int argc, char** argv)
(void)argc, (void)argv;
OK(mem_init_proxy_allocator(&allocator, &mem_default_allocator));
- OK(sg2_device_create(NULL, &allocator, 1, &dev));
- OK(sg2_geometry_create(dev, &geom));
+ OK(sg2d_device_create(NULL, &allocator, 1, &dev));
+ OK(sg2d_geometry_create(dev, &geom));
SG2(device_ref_put(dev));
callbacks.get_indices = get_indices;
@@ -61,7 +61,7 @@ main(int argc, char** argv)
&& sa_size(ctx.indices) / 2 < UINT_MAX);
circ_seg_count = (unsigned)sa_size(ctx.indices) / 2;
circ_vrtx_count = (unsigned)sa_size(ctx.positions) / 2;
- OK(sg2_geometry_reserve(geom, NB_CIRC * circ_vrtx_count,
+ OK(sg2d_geometry_reserve(geom, NB_CIRC * circ_vrtx_count,
NB_CIRC * circ_seg_count, 0));
FOR_EACH(i, 0, NB_CIRC_X) {
double center_x = 2 * (1 + NB_CIRC_Z) * (i - NB_CIRC_X / 2);
@@ -79,20 +79,20 @@ main(int argc, char** argv)
misalignment = (k % 2) ? -0.01 : +0.01;
#endif
d2(ctx.offset, center_x + misalignment, center_y + misalignment);
- OK(sg2_geometry_add(geom, circ_vrtx_count, circ_seg_count, &callbacks,
+ OK(sg2d_geometry_add(geom, circ_vrtx_count, circ_seg_count, &callbacks,
&ctx));
}
}
}
circle_release(&ctx);
- OK(sg2_geometry_get_unique_segments_with_merge_conflict_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_merge_conflict_count(geom, &count));
CHK(count == 0);
- OK(sg2_geometry_get_unique_segments_with_unspecified_interface_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_unspecified_interface_count(geom, &count));
CHK(count == 0);
- OK(sg2_geometry_get_unique_segments_with_unspecified_side_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_unspecified_side_count(geom, &count));
CHK(count == 0);
- OK(sg2_geometry_dump_as_obj(geom, stdout, SG2_OBJ_DUMP_ALL));
+ OK(sg2d_geometry_dump_as_obj(geom, stdout, SG2D_OBJ_DUMP_ALL));
SG2(geometry_ref_put(geom));
diff --git a/src/test_sg2_many_segments.c b/src/test_sg2_many_segments.c
@@ -14,8 +14,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "sg2.h"
-#include "test_sg2_utils.h"
-#include "test_sg2_utils2.h"
+#include "test_sg2d_utils.h"
+#include "test_sg2d_utils2.h"
#include <rsys/double2.h>
@@ -28,17 +28,17 @@ int
main(int argc, char** argv)
{
struct mem_allocator allocator;
- struct sg2_device* dev;
- struct sg2_geometry* geom;
- struct sg2_geometry_add_callbacks callbacks = SG2_ADD_CALLBACKS_NULL__;
+ struct sg2d_device* dev;
+ struct sg2d_geometry* geom;
+ struct sg2d_geometry_add_callbacks callbacks = SG2D_ADD_CALLBACKS_NULL__;
unsigned circ_seg_count, circ_vrtx_count, i, count;
unsigned m0 = 0, m1, itf = 0;
struct context ctx = CONTEXT_NULL__;
(void)argc, (void)argv;
OK(mem_init_proxy_allocator(&allocator, &mem_default_allocator));
- OK(sg2_device_create(NULL, &allocator, 1, &dev));
- OK(sg2_geometry_create(dev, &geom));
+ OK(sg2d_device_create(NULL, &allocator, 1, &dev));
+ OK(sg2d_geometry_create(dev, &geom));
SG2(device_ref_put(dev));
callbacks.get_indices = get_indices;
@@ -57,23 +57,23 @@ main(int argc, char** argv)
&& sa_size(ctx.indices) / 2 < UINT_MAX);
circ_seg_count = (unsigned)sa_size(ctx.indices) / 2;
circ_vrtx_count = (unsigned)sa_size(ctx.positions) / 2;
- OK(sg2_geometry_reserve(geom, NB_CIRC * circ_vrtx_count,
+ OK(sg2d_geometry_reserve(geom, NB_CIRC * circ_vrtx_count,
NB_CIRC * circ_seg_count, 0));
FOR_EACH(i, 0, NB_CIRC) {
m1 = i;
d2(ctx.offset, 0, i * 10);
- OK(sg2_geometry_add(geom, circ_vrtx_count, circ_seg_count, &callbacks,
+ OK(sg2d_geometry_add(geom, circ_vrtx_count, circ_seg_count, &callbacks,
&ctx));
}
circle_release(&ctx);
- OK(sg2_geometry_get_unique_segments_with_merge_conflict_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_merge_conflict_count(geom, &count));
CHK(count == 0);
- OK(sg2_geometry_get_unique_segments_with_unspecified_interface_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_unspecified_interface_count(geom, &count));
CHK(count == 0);
- OK(sg2_geometry_get_unique_segments_with_unspecified_side_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_unspecified_side_count(geom, &count));
CHK(count == 0);
- OK(sg2_geometry_dump_as_obj(geom, stdout, SG2_OBJ_DUMP_ALL));
+ OK(sg2d_geometry_dump_as_obj(geom, stdout, SG2D_OBJ_DUMP_ALL));
SG2(geometry_ref_put(geom));
diff --git a/src/test_sg2_some_enclosures.c b/src/test_sg2_some_enclosures.c
@@ -14,8 +14,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "sg2.h"
-#include "test_sg2_utils.h"
-#include "test_sg2_utils2.h"
+#include "test_sg2d_utils.h"
+#include "test_sg2d_utils2.h"
#include <rsys/double2.h>
@@ -31,9 +31,9 @@ int
main(int argc, char** argv)
{
struct mem_allocator allocator;
- struct sg2_device* dev;
- struct sg2_geometry* geom;
- struct sg2_geometry_add_callbacks callbacks = SG2_ADD_CALLBACKS_NULL__;
+ struct sg2d_device* dev;
+ struct sg2d_geometry* geom;
+ struct sg2d_geometry_add_callbacks callbacks = SG2D_ADD_CALLBACKS_NULL__;
unsigned circ_seg_count, circ_vrtx_count, count;
int i, j, k;
unsigned m_in, m_out, itf = 0;
@@ -41,8 +41,8 @@ main(int argc, char** argv)
(void)argc, (void)argv;
OK(mem_init_proxy_allocator(&allocator, &mem_default_allocator));
- OK(sg2_device_create(NULL, &allocator, 1, &dev));
- OK(sg2_geometry_create(dev, &geom));
+ OK(sg2d_device_create(NULL, &allocator, 1, &dev));
+ OK(sg2d_geometry_create(dev, &geom));
SG2(device_ref_put(dev));
callbacks.get_indices = get_indices;
@@ -61,7 +61,7 @@ main(int argc, char** argv)
&& sa_size(ctx.indices) / 2 < UINT_MAX);
circ_seg_count = (unsigned)sa_size(ctx.indices) / 2;
circ_vrtx_count = (unsigned)sa_size(ctx.positions) / 2;
- OK(sg2_geometry_reserve(geom, NB_CIRC * circ_vrtx_count,
+ OK(sg2d_geometry_reserve(geom, NB_CIRC * circ_vrtx_count,
NB_CIRC * circ_seg_count, 0));
FOR_EACH(i, 0, NB_CIRC_X) {
double center_x = 2 * (1 + NB_CIRC_Z) * (i - NB_CIRC_X / 2);
@@ -79,21 +79,21 @@ main(int argc, char** argv)
misalignment = (k % 2) ? -0.01 : +0.01;
#endif
d2(ctx.offset, center_x + misalignment, center_y + misalignment);
- OK(sg2_geometry_add(geom, circ_vrtx_count, circ_seg_count, &callbacks,
+ OK(sg2d_geometry_add(geom, circ_vrtx_count, circ_seg_count, &callbacks,
&ctx));
}
}
}
circle_release(&ctx);
- OK(sg2_geometry_get_unique_segments_with_merge_conflict_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_merge_conflict_count(geom, &count));
CHK(count == 0);
- OK(sg2_geometry_get_unique_segments_with_unspecified_interface_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_unspecified_interface_count(geom, &count));
CHK(count == 0);
- OK(sg2_geometry_get_unique_segments_with_unspecified_side_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_unspecified_side_count(geom, &count));
CHK(count == 0);
- OK(sg2_geometry_dump_as_c_code(geom, stdout, "some_enclosures",
- SG2_C_DUMP_CONST | SG2_C_DUMP_STATIC));
+ OK(sg2d_geometry_dump_as_c_code(geom, stdout, "some_enclosures",
+ SG2D_C_DUMP_CONST | SG2D_C_DUMP_STATIC));
SG2(geometry_ref_put(geom));
diff --git a/src/test_sg2_some_segments.c b/src/test_sg2_some_segments.c
@@ -14,8 +14,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "sg2.h"
-#include "test_sg2_utils.h"
-#include "test_sg2_utils2.h"
+#include "test_sg2d_utils.h"
+#include "test_sg2d_utils2.h"
#include <rsys/double2.h>
@@ -28,17 +28,17 @@ int
main(int argc, char** argv)
{
struct mem_allocator allocator;
- struct sg2_device* dev;
- struct sg2_geometry* geom;
- struct sg2_geometry_add_callbacks callbacks = SG2_ADD_CALLBACKS_NULL__;
+ struct sg2d_device* dev;
+ struct sg2d_geometry* geom;
+ struct sg2d_geometry_add_callbacks callbacks = SG2D_ADD_CALLBACKS_NULL__;
unsigned circ_seg_count, circ_vrtx_count, i, count;
unsigned m0 = 0, m1, itf = 0;
struct context ctx = CONTEXT_NULL__;
(void)argc, (void)argv;
OK(mem_init_proxy_allocator(&allocator, &mem_default_allocator));
- OK(sg2_device_create(NULL, &allocator, 1, &dev));
- OK(sg2_geometry_create(dev, &geom));
+ OK(sg2d_device_create(NULL, &allocator, 1, &dev));
+ OK(sg2d_geometry_create(dev, &geom));
SG2(device_ref_put(dev));
callbacks.get_indices = get_indices;
@@ -58,25 +58,25 @@ main(int argc, char** argv)
circ_seg_count = (unsigned)sa_size(ctx.indices) / 2;
circ_vrtx_count = (unsigned)sa_size(ctx.positions) / 2;
- OK(sg2_geometry_reserve(geom, NB_CIRC * circ_vrtx_count,
+ OK(sg2d_geometry_reserve(geom, NB_CIRC * circ_vrtx_count,
NB_CIRC * circ_seg_count, 0));
FOR_EACH(i, 0, NB_CIRC) {
m1 = i;
d2(ctx.offset, 0, i * 10);
- OK(sg2_geometry_add(geom, circ_vrtx_count, circ_seg_count, &callbacks,
+ OK(sg2d_geometry_add(geom, circ_vrtx_count, circ_seg_count, &callbacks,
&ctx));
}
circle_release(&ctx);
- OK(sg2_geometry_get_unique_segments_with_merge_conflict_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_merge_conflict_count(geom, &count));
CHK(count == 0);
- OK(sg2_geometry_get_unique_segments_with_unspecified_interface_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_unspecified_interface_count(geom, &count));
CHK(count == 0);
- OK(sg2_geometry_get_unique_segments_with_unspecified_side_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_unspecified_side_count(geom, &count));
CHK(count == 0);
- OK(sg2_geometry_dump_as_c_code(geom, stdout, "some_segments",
- SG2_C_DUMP_CONST | SG2_C_DUMP_STATIC));
+ OK(sg2d_geometry_dump_as_c_code(geom, stdout, "some_segments",
+ SG2D_C_DUMP_CONST | SG2D_C_DUMP_STATIC));
SG2(geometry_ref_put(geom));
diff --git a/src/test_sg2_square_behind_square.c b/src/test_sg2_square_behind_square.c
@@ -14,7 +14,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "sg2.h"
-#include "test_sg2_utils.h"
+#include "test_sg2d_utils.h"
#include <rsys/double2.h>
@@ -51,16 +51,16 @@ int
main(int argc, char** argv)
{
struct mem_allocator allocator;
- struct sg2_device* dev;
- struct sg2_geometry* geom;
+ struct sg2d_device* dev;
+ struct sg2d_geometry* geom;
struct context ctx = CONTEXT_NULL__;
- struct sg2_geometry_add_callbacks callbacks = SG2_ADD_CALLBACKS_NULL__;
+ struct sg2d_geometry_add_callbacks callbacks = SG2D_ADD_CALLBACKS_NULL__;
unsigned count;
(void)argc, (void)argv;
OK(mem_init_proxy_allocator(&allocator, &mem_default_allocator));
- OK(sg2_device_create(NULL, &allocator, 1, &dev));
- OK(sg2_geometry_create(dev, &geom));
+ OK(sg2d_device_create(NULL, &allocator, 1, &dev));
+ OK(sg2d_geometry_create(dev, &geom));
SG2(device_ref_put(dev));
callbacks.get_indices = get_indices;
@@ -74,22 +74,22 @@ main(int argc, char** argv)
ctx.intface = intface0;
/* First square (front: 0, back: 1), right-handed normal outside */
- OK(sg2_geometry_add(geom, nvertices, nsegments, &callbacks, &ctx));
+ OK(sg2d_geometry_add(geom, nvertices, nsegments, &callbacks, &ctx));
d2(ctx.offset, -0.5, 2);
ctx.scale = 3;
/* Second square (front: 0, back: 1), right-handed normal outside */
- OK(sg2_geometry_add(geom, nvertices, nsegments, &callbacks, &ctx));
+ OK(sg2d_geometry_add(geom, nvertices, nsegments, &callbacks, &ctx));
- OK(sg2_geometry_get_unique_segments_with_merge_conflict_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_merge_conflict_count(geom, &count));
CHK(count == 0);
- OK(sg2_geometry_get_unique_segments_with_unspecified_interface_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_unspecified_interface_count(geom, &count));
CHK(count == 0);
- OK(sg2_geometry_get_unique_segments_with_unspecified_side_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_unspecified_side_count(geom, &count));
CHK(count == 0);
- OK(sg2_geometry_dump_as_c_code(geom, stdout, "square_behind_square_2",
- SG2_C_DUMP_CONST | SG2_C_DUMP_STATIC));
+ OK(sg2d_geometry_dump_as_c_code(geom, stdout, "square_behind_square_2",
+ SG2D_C_DUMP_CONST | SG2D_C_DUMP_STATIC));
d2(ctx.offset, -1, 6);
ctx.scale = 5;
@@ -97,16 +97,16 @@ main(int argc, char** argv)
ctx.back_media = medium0;
/* Third square (front: 1, back: 0), right-handed normal outside */
- OK(sg2_geometry_add(geom, nvertices, nsegments, &callbacks, &ctx));
+ OK(sg2d_geometry_add(geom, nvertices, nsegments, &callbacks, &ctx));
- OK(sg2_geometry_get_unique_segments_with_merge_conflict_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_merge_conflict_count(geom, &count));
CHK(count == 0);
- OK(sg2_geometry_get_unique_segments_with_unspecified_interface_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_unspecified_interface_count(geom, &count));
CHK(count == 0);
- OK(sg2_geometry_get_unique_segments_with_unspecified_side_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_unspecified_side_count(geom, &count));
CHK(count == 0);
- OK(sg2_geometry_dump_as_c_code(geom, stdout, "square_behind_square_3",
- SG2_C_DUMP_CONST | SG2_C_DUMP_STATIC));
+ OK(sg2d_geometry_dump_as_c_code(geom, stdout, "square_behind_square_3",
+ SG2D_C_DUMP_CONST | SG2D_C_DUMP_STATIC));
SG2(geometry_ref_put(geom));
diff --git a/src/test_sg2_square_in_square.c b/src/test_sg2_square_in_square.c
@@ -14,7 +14,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "sg2.h"
-#include "test_sg2_utils.h"
+#include "test_sg2d_utils.h"
#include <rsys/double2.h>
@@ -41,16 +41,16 @@ int
main(int argc, char** argv)
{
struct mem_allocator allocator;
- struct sg2_device* dev;
- struct sg2_geometry* geom;
+ struct sg2d_device* dev;
+ struct sg2d_geometry* geom;
struct context ctx = CONTEXT_NULL__;
- struct sg2_geometry_add_callbacks callbacks = SG2_ADD_CALLBACKS_NULL__;
+ struct sg2d_geometry_add_callbacks callbacks = SG2D_ADD_CALLBACKS_NULL__;
unsigned count;
(void)argc, (void)argv;
OK(mem_init_proxy_allocator(&allocator, &mem_default_allocator));
- OK(sg2_device_create(NULL, &allocator, 1, &dev));
- OK(sg2_geometry_create(dev, &geom));
+ OK(sg2d_device_create(NULL, &allocator, 1, &dev));
+ OK(sg2d_geometry_create(dev, &geom));
SG2(device_ref_put(dev));
callbacks.get_indices = get_indices;
@@ -64,23 +64,23 @@ main(int argc, char** argv)
ctx.intface = intface0;
/* First square (front: 0, back: 1), right-handed normal outside */
- OK(sg2_geometry_add(geom, nvertices, nsegments, &callbacks, &ctx));
+ OK(sg2d_geometry_add(geom, nvertices, nsegments, &callbacks, &ctx));
d2(ctx.offset, -1, -1);
ctx.scale = 3;
ctx.reverse_vrtx = 1;
/* Second square (front: 0, back: 1), right-handed normal inside */
- OK(sg2_geometry_add(geom, nvertices, nsegments, &callbacks, &ctx));
+ OK(sg2d_geometry_add(geom, nvertices, nsegments, &callbacks, &ctx));
- OK(sg2_geometry_get_unique_segments_with_merge_conflict_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_merge_conflict_count(geom, &count));
CHK(count == 0);
- OK(sg2_geometry_get_unique_segments_with_unspecified_interface_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_unspecified_interface_count(geom, &count));
CHK(count == 0);
- OK(sg2_geometry_get_unique_segments_with_unspecified_side_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_unspecified_side_count(geom, &count));
CHK(count == 0);
- OK(sg2_geometry_dump_as_c_code(geom, stdout, "square_in_square_2",
- SG2_C_DUMP_CONST | SG2_C_DUMP_STATIC));
+ OK(sg2d_geometry_dump_as_c_code(geom, stdout, "square_in_square_2",
+ SG2D_C_DUMP_CONST | SG2D_C_DUMP_STATIC));
d2(ctx.offset, -4, -4);
ctx.scale = 10;
@@ -90,16 +90,16 @@ main(int argc, char** argv)
ctx.back_media = medium0;
/* Third square (front: 0, back: 1), right-handed normal inside */
- OK(sg2_geometry_add(geom, nvertices, nsegments, &callbacks, &ctx));
+ OK(sg2d_geometry_add(geom, nvertices, nsegments, &callbacks, &ctx));
- OK(sg2_geometry_get_unique_segments_with_merge_conflict_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_merge_conflict_count(geom, &count));
CHK(count == 0);
- OK(sg2_geometry_get_unique_segments_with_unspecified_interface_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_unspecified_interface_count(geom, &count));
CHK(count == 0);
- OK(sg2_geometry_get_unique_segments_with_unspecified_side_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_unspecified_side_count(geom, &count));
CHK(count == 0);
- OK(sg2_geometry_dump_as_c_code(geom, stdout, "square_in_square_3",
- SG2_C_DUMP_CONST | SG2_C_DUMP_STATIC));
+ OK(sg2d_geometry_dump_as_c_code(geom, stdout, "square_in_square_3",
+ SG2D_C_DUMP_CONST | SG2D_C_DUMP_STATIC));
SG2(geometry_ref_put(geom));
diff --git a/src/test_sg2_square_on_square.c b/src/test_sg2_square_on_square.c
@@ -14,7 +14,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "sg2.h"
-#include "test_sg2_utils.h"
+#include "test_sg2d_utils.h"
#include <rsys/double2.h>
@@ -38,16 +38,16 @@ int
main(int argc, char** argv)
{
struct mem_allocator allocator;
- struct sg2_device* dev;
- struct sg2_geometry* geom;
+ struct sg2d_device* dev;
+ struct sg2d_geometry* geom;
struct context ctx = CONTEXT_NULL__;
- struct sg2_geometry_add_callbacks callbacks = SG2_ADD_CALLBACKS_NULL__;
+ struct sg2d_geometry_add_callbacks callbacks = SG2D_ADD_CALLBACKS_NULL__;
unsigned count;
(void)argc, (void)argv;
OK(mem_init_proxy_allocator(&allocator, &mem_default_allocator));
- OK(sg2_device_create(NULL, &allocator, 1, &dev));
- OK(sg2_geometry_create(dev, &geom));
+ OK(sg2d_device_create(NULL, &allocator, 1, &dev));
+ OK(sg2d_geometry_create(dev, &geom));
SG2(device_ref_put(dev));
callbacks.get_indices = get_indices;
@@ -63,14 +63,14 @@ main(int argc, char** argv)
/* First square (front: 0 on top face, 1 elsewhere, back: 0),
* right-handed normal outside */
- OK(sg2_geometry_add(geom, nvertices, nsegments, &callbacks, &ctx));
+ OK(sg2d_geometry_add(geom, nvertices, nsegments, &callbacks, &ctx));
d2(ctx.offset, 1, 2);
ctx.front_media = medium1_bottom0;
/* Second square (front: 0 on bottom face, 1 elsewhere, back: 0),
* right-handed normal outside */
- OK(sg2_geometry_add(geom, nvertices, nsegments, &callbacks, &ctx));
+ OK(sg2d_geometry_add(geom, nvertices, nsegments, &callbacks, &ctx));
ctx.positions = box_vertices; /* Can use distorded square for square #3 */
d2(ctx.offset, 0, 0);
@@ -81,16 +81,16 @@ main(int argc, char** argv)
ctx.back_media = medium1;
/* Third square (front: 2, back: 1), right-handed normal inside */
- OK(sg2_geometry_add(geom, nvertices, nsegments, &callbacks, &ctx));
+ OK(sg2d_geometry_add(geom, nvertices, nsegments, &callbacks, &ctx));
- OK(sg2_geometry_get_unique_segments_with_merge_conflict_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_merge_conflict_count(geom, &count));
CHK(count == 0);
- OK(sg2_geometry_get_unique_segments_with_unspecified_interface_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_unspecified_interface_count(geom, &count));
CHK(count == 0);
- OK(sg2_geometry_get_unique_segments_with_unspecified_side_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_unspecified_side_count(geom, &count));
CHK(count == 0);
- OK(sg2_geometry_dump_as_c_code(geom, stdout, "square_on_square",
- SG2_C_DUMP_CONST | SG2_C_DUMP_STATIC));
+ OK(sg2d_geometry_dump_as_c_code(geom, stdout, "square_on_square",
+ SG2D_C_DUMP_CONST | SG2D_C_DUMP_STATIC));
SG2(geometry_ref_put(geom));
diff --git a/src/test_sg2_unspecified_properties.c b/src/test_sg2_unspecified_properties.c
@@ -14,7 +14,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "sg2.h"
-#include "test_sg2_utils.h"
+#include "test_sg2d_utils.h"
#include <stdio.h>
@@ -22,10 +22,10 @@ int
main(int argc, char** argv)
{
struct mem_allocator allocator;
- struct sg2_device* dev;
- struct sg2_geometry* geom;
+ struct sg2d_device* dev;
+ struct sg2d_geometry* geom;
struct context ctx = CONTEXT_NULL__;
- struct sg2_geometry_add_callbacks callbacks = SG2_ADD_CALLBACKS_NULL__;
+ struct sg2d_geometry_add_callbacks callbacks = SG2D_ADD_CALLBACKS_NULL__;
unsigned property[12];
unsigned i;
const unsigned property_count = sizeof(property) / sizeof(*property);
@@ -33,10 +33,10 @@ main(int argc, char** argv)
(void)argc, (void)argv;
OK(mem_init_proxy_allocator(&allocator, &mem_default_allocator));
- OK(sg2_device_create(NULL, &allocator, 1, &dev));
- OK(sg2_geometry_create(dev, &geom));
+ OK(sg2d_device_create(NULL, &allocator, 1, &dev));
+ OK(sg2d_geometry_create(dev, &geom));
- FOR_EACH(i, 0, property_count) property[i] = SG2_UNSPECIFIED_PROPERTY;
+ FOR_EACH(i, 0, property_count) property[i] = SG2D_UNSPECIFIED_PROPERTY;
callbacks.get_indices = get_indices;
callbacks.get_position = get_position;
@@ -51,90 +51,90 @@ main(int argc, char** argv)
ctx.front_media = property;
ctx.back_media = medium1;
ctx.intface = property;
- OK(sg2_geometry_add(geom, nvertices, nsegments, &callbacks, &ctx));
- OK(sg2_geometry_get_unique_segments_with_unspecified_side_count(geom, &count));
+ OK(sg2d_geometry_add(geom, nvertices, nsegments, &callbacks, &ctx));
+ OK(sg2d_geometry_get_unique_segments_with_unspecified_side_count(geom, &count));
CHK(count == nsegments);
- OK(sg2_geometry_get_added_segments_count(geom, &count));
+ OK(sg2d_geometry_get_added_segments_count(geom, &count));
CHK(count == nsegments);
/* Add same geometry with no properties on front/intface */
callbacks.get_properties = get_properties;
- OK(sg2_geometry_add(geom, nvertices, nsegments, &callbacks, &ctx));
- OK(sg2_geometry_get_unique_segments_with_unspecified_side_count(geom, &count));
+ OK(sg2d_geometry_add(geom, nvertices, nsegments, &callbacks, &ctx));
+ OK(sg2d_geometry_get_unique_segments_with_unspecified_side_count(geom, &count));
CHK(count == nsegments);
- OK(sg2_geometry_get_added_segments_count(geom, &count));
+ OK(sg2d_geometry_get_added_segments_count(geom, &count));
CHK(count == 2 * nsegments);
- OK(sg2_geometry_dump_as_c_code(geom, stdout, "front_unspecified",
- SG2_C_DUMP_STATIC | SG2_C_DUMP_CONST));
+ OK(sg2d_geometry_dump_as_c_code(geom, stdout, "front_unspecified",
+ SG2D_C_DUMP_STATIC | SG2D_C_DUMP_CONST));
/* Add same geometry, front/intface properties are defined for odd segments */
FOR_EACH(i, 0, sizeof(property) / sizeof(*property))
- property[i] = (i % 2) ? 0 : SG2_UNSPECIFIED_PROPERTY;
- OK(sg2_geometry_add(geom, nvertices, nsegments, &callbacks, &ctx));
- OK(sg2_geometry_get_unique_segments_with_unspecified_side_count(geom, &count));
+ property[i] = (i % 2) ? 0 : SG2D_UNSPECIFIED_PROPERTY;
+ OK(sg2d_geometry_add(geom, nvertices, nsegments, &callbacks, &ctx));
+ OK(sg2d_geometry_get_unique_segments_with_unspecified_side_count(geom, &count));
CHK(count == nsegments / 2);
- OK(sg2_geometry_get_unique_vertices_count(geom, &count));
+ OK(sg2d_geometry_get_unique_vertices_count(geom, &count));
CHK(count == nvertices);
- OK(sg2_geometry_get_added_segments_count(geom, &count));
+ OK(sg2d_geometry_get_added_segments_count(geom, &count));
CHK(count == 3 * nsegments);
- OK(sg2_geometry_get_unique_segments_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_count(geom, &count));
CHK(count == nsegments);
FOR_EACH(i, 0, count) {
- unsigned prop[SG2_PROP_TYPES_COUNT__];
- OK(sg2_geometry_get_unique_segment_properties(geom, i, prop));
- CHK(prop[SG2_FRONT] == ((i % 2) ? 0 : SG2_UNSPECIFIED_PROPERTY)
- && prop[SG2_BACK] == 1
- && prop[SG2_INTFACE] == ((i % 2) ? 0 : SG2_UNSPECIFIED_PROPERTY));
+ unsigned prop[SG2D_PROP_TYPES_COUNT__];
+ OK(sg2d_geometry_get_unique_segment_properties(geom, i, prop));
+ CHK(prop[SG2D_FRONT] == ((i % 2) ? 0 : SG2D_UNSPECIFIED_PROPERTY)
+ && prop[SG2D_BACK] == 1
+ && prop[SG2D_INTFACE] == ((i % 2) ? 0 : SG2D_UNSPECIFIED_PROPERTY));
}
/* Same information again, using a reversed box */
ctx.reverse_vrtx = 1;
SWAP(const unsigned*, ctx.front_media, ctx.back_media);
- OK(sg2_geometry_add(geom, nvertices, nsegments, &callbacks, &ctx));
- OK(sg2_geometry_get_unique_segments_with_unspecified_side_count(geom, &count));
+ OK(sg2d_geometry_add(geom, nvertices, nsegments, &callbacks, &ctx));
+ OK(sg2d_geometry_get_unique_segments_with_unspecified_side_count(geom, &count));
CHK(count == nsegments / 2);
- OK(sg2_geometry_get_added_segments_count(geom, &count));
+ OK(sg2d_geometry_get_added_segments_count(geom, &count));
CHK(count == 4 * nsegments);
- OK(sg2_geometry_dump_as_c_code(geom, stdout, "front_half_unspecified",
- SG2_C_DUMP_STATIC | SG2_C_DUMP_CONST));
+ OK(sg2d_geometry_dump_as_c_code(geom, stdout, "front_half_unspecified",
+ SG2D_C_DUMP_STATIC | SG2D_C_DUMP_CONST));
/* Define properties for remaining segments, using reversed box */
FOR_EACH(i, 0, sizeof(property) / sizeof(*property))
- property[i] = (i % 2) ? SG2_UNSPECIFIED_PROPERTY : 0;
- OK(sg2_geometry_add(geom, nvertices, nsegments, &callbacks, &ctx));
- OK(sg2_geometry_get_unique_segments_with_unspecified_side_count(geom, &count));
+ property[i] = (i % 2) ? SG2D_UNSPECIFIED_PROPERTY : 0;
+ OK(sg2d_geometry_add(geom, nvertices, nsegments, &callbacks, &ctx));
+ OK(sg2d_geometry_get_unique_segments_with_unspecified_side_count(geom, &count));
CHK(count == 0);
- OK(sg2_geometry_get_unique_vertices_count(geom, &count));
+ OK(sg2d_geometry_get_unique_vertices_count(geom, &count));
CHK(count == nvertices);
- OK(sg2_geometry_get_added_segments_count(geom, &count));
+ OK(sg2d_geometry_get_added_segments_count(geom, &count));
CHK(count == 5 * nsegments);
- OK(sg2_geometry_get_unique_segments_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_count(geom, &count));
CHK(count == nsegments);
FOR_EACH(i, 0, count) {
- unsigned prop[SG2_PROP_TYPES_COUNT__];
- OK(sg2_geometry_get_unique_segment_properties(geom, i, prop));
- CHK(prop[SG2_FRONT] == 0 && prop[SG2_BACK] == 1
- && prop[SG2_INTFACE] == 0);
+ unsigned prop[SG2D_PROP_TYPES_COUNT__];
+ OK(sg2d_geometry_get_unique_segment_properties(geom, i, prop));
+ CHK(prop[SG2D_FRONT] == 0 && prop[SG2D_BACK] == 1
+ && prop[SG2D_INTFACE] == 0);
}
- OK(sg2_geometry_dump_as_c_code(geom, stdout, "all_defined",
- SG2_C_DUMP_STATIC | SG2_C_DUMP_CONST));
+ OK(sg2d_geometry_dump_as_c_code(geom, stdout, "all_defined",
+ SG2D_C_DUMP_STATIC | SG2D_C_DUMP_CONST));
/* Define incoherent properties for some segments */
FOR_EACH(i, 0, sizeof(property) / sizeof(*property))
property[i] = (i % 2);
- OK(sg2_geometry_add(geom, nvertices, nsegments, &callbacks, &ctx));
- OK(sg2_geometry_get_unique_segments_with_merge_conflict_count(geom, &count));
+ OK(sg2d_geometry_add(geom, nvertices, nsegments, &callbacks, &ctx));
+ OK(sg2d_geometry_get_unique_segments_with_merge_conflict_count(geom, &count));
CHK(count == nsegments / 2);
- OK(sg2_geometry_get_unique_segments_with_properties_conflict_count(geom, &count));
+ OK(sg2d_geometry_get_unique_segments_with_properties_conflict_count(geom, &count));
CHK(count == 0);
- OK(sg2_geometry_get_added_segments_count(geom, &count));
+ OK(sg2d_geometry_get_added_segments_count(geom, &count));
CHK(count == 6 * nsegments);
- OK(sg2_geometry_ref_put(geom));
- OK(sg2_device_ref_put(dev));
+ OK(sg2d_geometry_ref_put(geom));
+ OK(sg2d_device_ref_put(dev));
check_memory_allocator(&allocator);
mem_shutdown_proxy_allocator(&allocator);
diff --git a/src/test_sg2_utils.h b/src/test_sg2_utils.h
@@ -13,8 +13,8 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
-#ifndef TEST_SG2_UTILS_H
-#define TEST_SG2_UTILS_H
+#ifndef TEST_SG2D_UTILS_H
+#define TEST_SG2D_UTILS_H
#include <rsys/mem_allocator.h>
#include <stdio.h>
@@ -125,14 +125,14 @@ get_position(const unsigned ivert, double pos[2], void* context)
static INLINE void
get_properties
(const unsigned iseg,
- unsigned property[SG2_PROP_TYPES_COUNT__],
+ unsigned property[SG2D_PROP_TYPES_COUNT__],
void* context)
{
const struct context* ctx = context;
ASSERT(property && ctx);
- property[ctx->reverse_med ? SG2_BACK : SG2_FRONT] = ctx->front_media[iseg];
- property[ctx->reverse_med ? SG2_FRONT : SG2_BACK] = ctx->back_media[iseg];
- property[SG2_INTFACE] = ctx->intface[iseg];
+ property[ctx->reverse_med ? SG2D_BACK : SG2D_FRONT] = ctx->front_media[iseg];
+ property[ctx->reverse_med ? SG2D_FRONT : SG2D_BACK] = ctx->back_media[iseg];
+ property[SG2D_INTFACE] = ctx->intface[iseg];
}
-#endif /* TEST_SG2_UTILS_H */
+#endif /* TEST_SG2D_UTILS_H */
diff --git a/src/test_sg2_utils2.h b/src/test_sg2_utils2.h
@@ -13,8 +13,8 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
-#ifndef TEST_SG2_UTILS2_H
-#define TEST_SG2_UTILS2_H
+#ifndef TEST_SG2D_UTILS2_H
+#define TEST_SG2D_UTILS2_H
#include <rsys/stretchy_array.h>
@@ -66,14 +66,14 @@ circle_release(struct context* ctx)
static INLINE void
get_uniform_properties
(const unsigned iseg,
- unsigned property[SG2_PROP_TYPES_COUNT__],
+ unsigned property[SG2D_PROP_TYPES_COUNT__],
void* context)
{
const struct context* ctx = context;
ASSERT(property && ctx); (void)iseg;
- property[ctx->reverse_med ? SG2_BACK : SG2_FRONT] = *ctx->front_media;
- property[ctx->reverse_med ? SG2_FRONT : SG2_BACK] = *ctx->back_media;
- property[SG2_INTFACE] = *ctx->intface;
+ property[ctx->reverse_med ? SG2D_BACK : SG2D_FRONT] = *ctx->front_media;
+ property[ctx->reverse_med ? SG2D_FRONT : SG2D_BACK] = *ctx->back_media;
+ property[SG2D_INTFACE] = *ctx->intface;
}
-#endif /* TEST_SG2_UTILS2_H */
+#endif /* TEST_SG2D_UTILS2_H */