commit 48f01e731ec88835935c3e250fb5ca8da91015bb
parent 5a7eb74e05959dae7b4550bc29649393d6957938
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date: Thu, 12 Jun 2025 16:44:20 +0200
Fix API consistency
Move name[_prefix] args to the first slot for the few API calls where it
was not the case.
Diffstat:
5 files changed, 67 insertions(+), 67 deletions(-)
diff --git a/src/scad.c b/src/scad.c
@@ -891,7 +891,7 @@ scad_stl_export_split
ERR(check_device(FUNC_NAME));
- ERR(scad_geometry_explode(geometry, file_name, &parts, &count));
+ ERR(scad_geometry_explode(file_name, geometry, &parts, &count));
ASSERT(count*2 == geometry->gmsh_dimTags_n);
for(i = 0; i < count; i++) {
ERR(scad_stl_export(parts[i], NULL, orientation, binary));
diff --git a/src/scad.h b/src/scad.h
@@ -486,8 +486,8 @@ scad_geometries_boundary
* If provided, `name' must be unique. */
SCAD_API res_T
scad_geometry_copy
- (const struct scad_geometry* geom,
- const char* name, /* Can be NULL */
+ (const char* name, /* Can be NULL */
+ const struct scad_geometry* geom,
struct scad_geometry** out_copy);
/* Change the visibility of the geometry `geom'.
@@ -512,19 +512,19 @@ scad_geometry_rename
* If provided, `name' must be unique. */
SCAD_API res_T
scad_geometry_dilate
- (const struct scad_geometry* geom,
+ (const char* name, /* Can be NULL */
+ const struct scad_geometry* geom,
const double center[3],
const double scale[3],
- const char* name, /* Can be NULL */
struct scad_geometry** out_geometry);
/* Translate the geometry `geom' along (`dx', `dy', `dz').
* If provided, `name' must be unique. */
SCAD_API res_T
scad_geometry_translate
- (const struct scad_geometry* geom,
+ (const char* name, /* Can be NULL */
+ const struct scad_geometry* geom,
const double dxdydz[3],
- const char* name, /* Can be NULL */
struct scad_geometry** out_geometry);
/* Rotate the geometry `geom' by `angle' radians around the axis of revolution
@@ -532,19 +532,19 @@ scad_geometry_translate
* If provided, `name' must be unique. */
SCAD_API res_T
scad_geometry_rotate
- (const struct scad_geometry* geom,
+ (const char* name, /* Can be NULL */
+ const struct scad_geometry* geom,
const double pt[3],
const double dir[3],
const double angle,
- const char* name, /* Can be NULL */
struct scad_geometry** out_geometry);
/* Extrude the geometry `geom' using a translation along (`dx', `dy', `dz').
* If provided, `name' must be unique. */
SCAD_API res_T
scad_geometry_extrude
- (const struct scad_geometry* geom,
- const char* name, /* Can be NULL */
+ (const char* name, /* Can be NULL */
+ const struct scad_geometry* geom,
const double dxdydz[3],
struct scad_geometry** out_geometry);
@@ -558,8 +558,8 @@ scad_geometry_extrude
* initializing star-cad, it should be freed accordingly. */
SCAD_API res_T
scad_geometry_explode
- (const struct scad_geometry* geom,
- const char* prefix_name, /* Can be NULL */
+ (const char* prefix_name, /* Can be NULL */
+ const struct scad_geometry* geom,
struct scad_geometry*** out_geometries,
size_t* out_count);
@@ -616,10 +616,10 @@ scad_geometries_clear_mesh
* returned as a new geometry in `out_geometry'. */
SCAD_API res_T
scad_geometry_normal
- (struct scad_geometry* geom,
+ (const char* name, /* Can be NULL */
+ struct scad_geometry* geom,
double p[3],
double N[3],
- const char* name, /* Can be NULL */
struct scad_geometry** out_geometry);
/*******************************************************************************
@@ -635,8 +635,8 @@ scad_geometry_normal
* If `prefix_name' is provided, the resulting names must be unique. */
SCAD_API res_T
scad_step_import
- (const char* filename, /* name of step file */
- const char* prefix_name, /* Can be NULL */
+ (const char* prefix_name, /* Can be NULL */
+ const char* filename, /* name of step file */
struct scad_geometry*** out_geometries,
size_t* out_count);
diff --git a/src/scad_geometry.c b/src/scad_geometry.c
@@ -1731,11 +1731,11 @@ error:
res_T
scad_geometry_rotate
- (const struct scad_geometry* geom,
+ (const char* name, /* Can be NULL */
+ const struct scad_geometry* geom,
const double pt[3],
const double axis[3],
const double angle,
- const char* name, /* Can be NULL */
struct scad_geometry** out_geometry)
{
int ierr = 0;
@@ -1749,7 +1749,7 @@ scad_geometry_rotate
ERR(check_device(FUNC_NAME));
- ERR(scad_geometry_copy(geom, name, &out));
+ ERR(scad_geometry_copy(name, geom, &out));
gmshModelOccRotate(out->gmsh_dimTags, out->gmsh_dimTags_n, SPLIT3(pt),
SPLIT3(axis), angle, &ierr);
@@ -1767,8 +1767,8 @@ error:
res_T
scad_geometry_extrude
- (const struct scad_geometry* geom,
- const char* name,
+ (const char* name,
+ const struct scad_geometry* geom,
const double dxdydz[3],
struct scad_geometry** out_geometry)
{
@@ -1888,8 +1888,8 @@ error:
res_T
scad_geometry_explode
- (const struct scad_geometry* geom,
- const char* prefix_name, /* Can be NULL */
+ (const char* prefix_name, /* Can be NULL */
+ const struct scad_geometry* geom,
struct scad_geometry*** out_geometry,
size_t* out_n)
{
@@ -1967,8 +1967,8 @@ error:
res_T
scad_geometry_copy
- (const struct scad_geometry* geom,
- const char* name, /* Can be NULL */
+ (const char* name, /* Can be NULL */
+ const struct scad_geometry* geom,
struct scad_geometry** out_geometry)
{
res_T res = RES_OK;
@@ -2042,9 +2042,9 @@ error:
res_T
scad_geometry_translate
- (const struct scad_geometry* geom,
+ (const char* name, /* Can be NULL */
+ const struct scad_geometry* geom,
const double dxdydz[3],
- const char* name, /* Can be NULL */
struct scad_geometry** out_geometry)
{
int ierr = 0;
@@ -2058,7 +2058,7 @@ scad_geometry_translate
ERR(check_device(FUNC_NAME));
- ERR(scad_geometry_copy(geom, name, &out));
+ ERR(scad_geometry_copy(name, geom, &out));
gmshModelOccTranslate(out->gmsh_dimTags, out->gmsh_dimTags_n, SPLIT3(dxdydz),
&ierr);
@@ -2688,10 +2688,10 @@ error:
res_T
scad_geometry_normal
- (struct scad_geometry* geom,
+ (const char* name, /* Can be NULL */
+ struct scad_geometry* geom,
double p[3],
double N[3],
- const char* name, /* Can be NULL */
struct scad_geometry** out_geometry)
{
res_T res = RES_OK;
@@ -2805,10 +2805,10 @@ error:
res_T
scad_geometry_dilate
- (const struct scad_geometry* geom,
+ (const char* name,
+ const struct scad_geometry* geom,
const double center[3],
const double scale[3],
- const char* name,
struct scad_geometry** out_geometry)
{
res_T res = RES_OK;
@@ -2822,7 +2822,7 @@ scad_geometry_dilate
ERR(check_device(FUNC_NAME));
- ERR(scad_geometry_copy(geom, name, &out));
+ ERR(scad_geometry_copy(name, geom, &out));
gmshModelOccDilate(out->gmsh_dimTags, out->gmsh_dimTags_n, SPLIT3(center),
SPLIT3(scale), &ierr);
diff --git a/src/test_api.c b/src/test_api.c
@@ -214,9 +214,9 @@ main(int argc, char* argv[])
MEM_RM(&allocator, geom_array);
BAD(scad_geometry_copy(NULL, NULL, &geom));
- BAD(scad_geometry_copy(geom1, NULL, NULL));
- BAD(scad_geometry_copy(geom1, "sphere 1", NULL)); /* Name already in use */
- OK(scad_geometry_copy(geom1, "Sphere 1", &geom));
+ BAD(scad_geometry_copy(NULL, geom1, NULL));
+ BAD(scad_geometry_copy("sphere 1", geom1, NULL)); /* Name already in use */
+ OK(scad_geometry_copy("Sphere 1", geom1, &geom));
OK(scad_geometry_ref_put(geom));
BAD(scad_geometry_rename(NULL, NULL));
@@ -225,35 +225,35 @@ main(int argc, char* argv[])
BAD(scad_geometry_translate(NULL, NULL, NULL, NULL));
BAD(scad_geometry_translate(NULL, NULL, NULL, &geom));
- BAD(scad_geometry_translate(NULL, d1, NULL, NULL));
- BAD(scad_geometry_translate(NULL, d1, NULL, &geom));
- BAD(scad_geometry_translate(geom1, NULL, NULL, NULL));
- BAD(scad_geometry_translate(geom1, NULL, NULL, &geom));
- BAD(scad_geometry_translate(geom1, d1, NULL, NULL));
- OK(scad_geometry_translate(geom1, d1, NULL, &geom));
+ BAD(scad_geometry_translate(NULL, NULL, d1, NULL));
+ BAD(scad_geometry_translate(NULL, NULL, d1, &geom));
+ BAD(scad_geometry_translate(NULL, geom1, NULL, NULL));
+ BAD(scad_geometry_translate(NULL, geom1, NULL, &geom));
+ BAD(scad_geometry_translate(NULL, geom1, d1, NULL));
+ OK(scad_geometry_translate(NULL, geom1, d1, &geom));
OK(scad_geometry_ref_put(geom));
- BAD(scad_geometry_rotate(NULL, NULL, NULL, 1, NULL, NULL));
- BAD(scad_geometry_rotate(NULL, NULL, NULL, 1, NULL, &geom));
- BAD(scad_geometry_rotate(NULL, NULL, d1, 1, NULL, NULL));
- BAD(scad_geometry_rotate(NULL, NULL, d1, 1, NULL, &geom));
- BAD(scad_geometry_rotate(NULL, p1, NULL, 1, NULL, NULL));
- BAD(scad_geometry_rotate(NULL, p1, NULL, 1, NULL, &geom));
- BAD(scad_geometry_rotate(NULL, p1, d1, 1, NULL, NULL));
- BAD(scad_geometry_rotate(NULL, p1, d1, 1, NULL, &geom));
- BAD(scad_geometry_rotate(geom1, NULL, NULL, 1, NULL, NULL));
- BAD(scad_geometry_rotate(geom1, NULL, NULL, 1, NULL, &geom));
- BAD(scad_geometry_rotate(geom1, NULL, d1, 1, NULL, NULL));
- BAD(scad_geometry_rotate(geom1, NULL, d1, 1, NULL, &geom));
- BAD(scad_geometry_rotate(geom1, p1, NULL, 1, NULL, NULL));
- BAD(scad_geometry_rotate(geom1, p1, NULL, 1, NULL, &geom));
- BAD(scad_geometry_rotate(geom1, p1, d1, 1, NULL, NULL));
- OK(scad_geometry_rotate(geom1, p1, d1, 1, NULL, &geom));
+ BAD(scad_geometry_rotate(NULL, NULL, NULL, NULL, 1, NULL));
+ BAD(scad_geometry_rotate(NULL, NULL, NULL, NULL, 1, &geom));
+ BAD(scad_geometry_rotate(NULL, NULL, NULL, d1, 1, NULL));
+ BAD(scad_geometry_rotate(NULL, NULL, NULL, d1, 1, &geom));
+ BAD(scad_geometry_rotate(NULL, NULL, p1, NULL, 1, NULL));
+ BAD(scad_geometry_rotate(NULL, NULL, p1, NULL, 1, &geom));
+ BAD(scad_geometry_rotate(NULL, NULL, p1, d1, 1, NULL));
+ BAD(scad_geometry_rotate(NULL, NULL, p1, d1, 1, &geom));
+ BAD(scad_geometry_rotate(NULL, geom1, NULL, NULL, 1, NULL));
+ BAD(scad_geometry_rotate(NULL, geom1, NULL, NULL, 1, &geom));
+ BAD(scad_geometry_rotate(NULL, geom1, NULL, d1, 1, NULL));
+ BAD(scad_geometry_rotate(NULL, geom1, NULL, d1, 1, &geom));
+ BAD(scad_geometry_rotate(NULL, geom1, p1, NULL, 1, NULL));
+ BAD(scad_geometry_rotate(NULL, geom1, p1, NULL, 1, &geom));
+ BAD(scad_geometry_rotate(NULL, geom1, p1, d1, 1, NULL));
+ OK(scad_geometry_rotate(NULL, geom1, p1, d1, 1, &geom));
BAD(scad_geometry_extrude(NULL, NULL, d1, &geom));
- BAD(scad_geometry_extrude(poly, NULL, NULL, &geom));
- BAD(scad_geometry_extrude(poly, NULL, d1, NULL));
- OK(scad_geometry_extrude(poly, NULL, d1, &geom));
+ BAD(scad_geometry_extrude(NULL, poly, NULL, &geom));
+ BAD(scad_geometry_extrude(NULL, poly, d1, NULL));
+ OK(scad_geometry_extrude(NULL, poly, d1, &geom));
OK(scad_geometry_ref_put(poly));
OK(scad_geometry_ref_put(geom));
diff --git a/src/test_lifetime.c b/src/test_lifetime.c
@@ -36,13 +36,13 @@ alive_and_well
ASSERT(g && allocator);
- OK(scad_geometry_explode(g, "alive_and_well", &geom_array, &c));
+ OK(scad_geometry_explode("alive_and_well", g, &geom_array, &c));
OK(scad_geometry_ref_put(g));
OK(scad_synchronize());
for(i = 0; i < c; i++) {
double dir1[3] = {0, 0, 1};
struct scad_geometry* gg;
- OK(scad_geometry_extrude(geom_array[i], "a_n_w_extruded", dir1, &gg));
+ OK(scad_geometry_extrude("a_n_w_extruded", geom_array[i], dir1, &gg));
OK(scad_geometry_ref_put(geom_array[i]));
OK(scad_geometry_ref_put(gg));
}
@@ -86,7 +86,7 @@ main(int argc, char* argv[])
/* Check that a 3D derivative of a deleted 2D object is alive and well */
OK(scad_add_rectangle("rect", p1, base, &geom));
- OK(scad_geometry_extrude(geom, "cube", dir1, &geom1));
+ OK(scad_geometry_extrude("cube", geom, dir1, &geom1));
OK(scad_geometry_ref_put(geom));
OK(scad_geometries_boundary("boundary", &geom1, 1, &list, &list_n));
OK(scad_geometry_ref_put(geom1));
@@ -97,7 +97,7 @@ main(int argc, char* argv[])
/* Check that a 2D part of a deleted 3D object is alive and well */
OK(scad_add_rectangle("rect2", p1, base, &geom));
- OK(scad_geometry_extrude(geom, "cube2", dir1, &geom1));
+ OK(scad_geometry_extrude("cube2", geom, dir1, &geom1));
OK(scad_geometry_ref_put(geom1));
alive_and_well(geom, &allocator);
@@ -107,7 +107,7 @@ main(int argc, char* argv[])
OK(scad_geometry_get_count(list[i], ¢er_n));
ASSERT(center_n == 1);
OK(scad_geometry_get_centerofmass(list[i], center));
- OK(scad_geometry_normal(list[i], center, N, NULL, &geom));
+ OK(scad_geometry_normal(NULL, list[i], center, N, &geom));
}
OK(scad_geometry_ref_put(geom));
for(i = 0; i < list_n; i++) {