commit 41a577dc8c1f2434bbc98524451c0358c5e0a0b5
parent 67f3ed1e2785e05efd283f140769972eacc0e424
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date: Fri, 19 Apr 2024 14:57:16 +0200
Merge branch 'release_0.4.1'
Diffstat:
6 files changed, 69 insertions(+), 20 deletions(-)
diff --git a/README.md b/README.md
@@ -11,8 +11,10 @@ of tags doesn't ensure tag persistence accross geometry deletions.
The library uses [CMake](http://www.cmake.org) and the
[RCMake](https://gitlab.com/vaplv/rcmake/#tab-readme) package to build. It also
depends on the
-[Gmsh](https://gmsh.info/) and
-[RSys](https://gitlab.com/vaplv/rsys/#tab-readme) libraries.
+[Gmsh](https://gmsh.info/),
+[RSys](https://gitlab.com/vaplv/rsys/#tab-readme),
+[star-geometry-3d](https://gitlab.com/meso-star/star-geometry-3d) and
+[star-enclosures-3d](https://gitlab.com/meso-star/star-enclosures-3d) libraries.
First ensure that CMake is installed on your system. Then install the RCMake
package as well as all the aforementioned prerequisites. Then generate the
@@ -21,6 +23,13 @@ project from the `cmake/CMakeLists.txt` file by appending to the
## Release notes
+### Version 0.4.1
+
+- Add scad_dump_geometry() API call that can be called from a debugging session
+- Remove an invalid assert
+- Fix build that used gmsh library in Release when Debug should have been used
+- Improve logs
+
### Version 0.4
- Upgrade to gmsh 4.12.2
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
@@ -44,7 +44,7 @@ include_directories(
################################################################################
set(VERSION_MAJOR 0)
set(VERSION_MINOR 4)
-set(VERSION_PATCH 0)
+set(VERSION_PATCH 1)
set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
set(SCAD_FILES_SRC
@@ -64,7 +64,7 @@ rcmake_prepend_path(SCAD_FILES_INC_API ${SCAD_SOURCE_DIR})
rcmake_prepend_path(SCAD_FILES_DOC ${PROJECT_SOURCE_DIR}/../)
add_library(scad SHARED ${SCAD_FILES_SRC} ${SCAD_FILES_INC} ${SCAD_FILES_INC_API})
-target_link_libraries(scad RSys ${GMSH_LIBRARY} m StarGeom3D StarEnc3D)
+target_link_libraries(scad RSys gmsh StarGeom3D StarEnc3D m)
set_target_properties(scad PROPERTIES
DEFINE_SYMBOL SCAD_SHARED_BUILD
diff --git a/src/scad.c b/src/scad.c
@@ -203,7 +203,7 @@ get_2d_tags
sz = geometry->gmsh_dimTags_n;
data = geometry->gmsh_dimTags;
- ASSERT(sz > 0 && sz % 2 == 0);
+ ASSERT(sz % 2 == 0);
for(i = 0; i < sz; i += 2) {
int dim = data[i];
diff --git a/src/scad.h b/src/scad.h
@@ -577,6 +577,15 @@ scad_get_dimtag_refcount
(const int dim,
const int tag);
+/* Dump geometry `geom' with address/name, ref count and tags.
+ * To use it from gdb:
+ * (gdb) call scad_dump_geometry( <geom_ptr> )
+ */
+SCAD_API res_T
+scad_dump_geometry
+ (const struct scad_geometry* geom);
+END_DECLS
+
/* Dump all the geometries with address/name, ref count and tags.
* To use it from gdb:
* (gdb) call scad_dump_geometries()
diff --git a/src/scad_device.c b/src/scad_device.c
@@ -256,6 +256,45 @@ device_get_description
return desc;
}
+res_T
+scad_dump_geometry
+ (const struct scad_geometry* geom)
+{
+ res_T res = RES_OK;
+ struct scad_device* dev = get_device();
+ size_t i;
+
+ if(!geom) {
+ res = RES_BAD_ARG;
+ goto error;
+ }
+
+ ERR(check_device(FUNC_NAME));
+ if(htable_geometries_is_empty(&dev->allgeom)) {
+ printf("No geometry defined.\n");
+ return res;
+ }
+
+ if(str_is_empty(&geom->name)) {
+ printf("Unnamed geometry %p (count is %lu), tags: ",
+ (void*)geom, (long unsigned)geom->ref);
+ } else {
+ printf("Geometry '%s' (%p, count is %lu), tags: ",
+ str_cget(&geom->name), (void*)geom, (long unsigned)geom->ref);
+ }
+ for(i = 0; i < geom->gmsh_dimTags_n; i += 2) {
+ int dim = geom->gmsh_dimTags[i];
+ int tag = geom->gmsh_dimTags[i+1];
+ printf((i ? ", %d.%d" : "%d.%d"), dim, tag);
+ }
+ printf(".\n");
+
+exit:
+ return res;
+error:
+ goto exit;
+}
+
void
scad_dump_geometries
(void)
@@ -275,21 +314,8 @@ scad_dump_geometries
htable_geometries_end(&dev->allgeom, &end);
while(!htable_geometries_iterator_eq(&it, &end)) {
struct scad_geometry* geom = *htable_geometries_iterator_key_get(&it);
- size_t i;
+ SCAD(dump_geometry(geom));
htable_geometries_iterator_next(&it);
- if(str_is_empty(&geom->name)) {
- printf("Unnamed geometry %p (count is %lu), tags: ",
- (void*)geom, (long unsigned)geom->ref);
- } else {
- printf("Geometry '%s' (%p, count is %lu), tags: ",
- str_cget(&geom->name), (void*)geom, (long unsigned)geom->ref);
- }
- for(i = 0; i < geom->gmsh_dimTags_n; i += 2) {
- int dim = geom->gmsh_dimTags[i];
- int tag = geom->gmsh_dimTags[i+1];
- printf((i ? ", %d.%d" : "%d.%d"), dim, tag);
- }
- printf(".\n");
}
}
diff --git a/src/scad_geometry.c b/src/scad_geometry.c
@@ -1343,7 +1343,12 @@ scad_geometries_common_boundaries
ERR(geometry_create(name, &geom));
geom->gmsh_dimTags_n = tagoutn;
- if (tagoutn == 0) {
+ if(tagoutn == 0) {
+ if(name) {
+ log_message(dev, "Common boundary '%s' is empty.\n", name);
+ } else {
+ log_message(dev, "Unamed common boundary %p is empty.\n", (void*)geom);
+ }
geom->gmsh_dimTags = NULL;
} else {
geom->gmsh_dimTags = MEM_ALLOC(allocator, tagoutn * sizeof(*tagout));