commit 70a2f4b644f62fc6385a868bbb710a6e985959e7
parent 33e249c0b06de150e566a725887a64a5e4527d40
Author: Eduardo Fontana Lazzari <edufonlaz@gmail.com>
Date: Wed, 12 Feb 2025 18:05:38 +0100
Implement the internal struct geometry
Diffstat:
4 files changed, 115 insertions(+), 5 deletions(-)
diff --git a/Makefile b/Makefile
@@ -34,7 +34,7 @@ default: build_library
################################################################################
# Library building
################################################################################
-SRC = src/sphin.c src/sphin_config.c src/sphin_volume.c src/sphin_surface.c
+SRC = src/sphin.c src/sphin_config.c src/sphin_volume.c src/sphin_surface.c src/sphin_geometry.c
OBJ = $(SRC:.c=.o)
DEP = $(SRC:.c=.d)
diff --git a/src/sphin_config.c b/src/sphin_config.c
@@ -26,6 +26,7 @@
#include "sphin.h"
#include "sphin_c.h"
#include "sphin_config.h"
+#include "sphin_surface.h"
#include "sphin_volume.h"
#include <rsys/cstr.h> /* res_to_cstr */
@@ -124,9 +125,7 @@ load_stream
while (NULL != txtrdr_get_line(txtrdr)) {
res = str_set(&line, txtrdr_get_cline(txtrdr));
- if (RES_OK != res) {
- goto error;
- }
+ if (RES_OK != res) { goto error; }
/* parse keyword */
token = strtok_r(str_get(&line), ":", &token_ptr);
@@ -143,7 +142,7 @@ load_stream
res = parse_volume(config, txtrdr, name);
}
else if (0 == strcmp(keyword, "surface")){
- // res = parse_surface(txtrdr, config, name); /* Not yet implemented */
+ res = parse_surface(config, txtrdr, name);
}
else {
res = RES_BAD_ARG;
diff --git a/src/sphin_geometry.c b/src/sphin_geometry.c
@@ -0,0 +1,58 @@
+/* Copyright (C) 2024 Centre National de la Recherche Scientifique
+ * Copyright (C) 2024 Clermont Auvergne INP
+ * Copyright (C) 2024 INSA Lyon
+ * Copyright (C) 2024 Institut Mines Télécom Albi-Carmaux
+ * Copyright (C) 2024 Institut National Polytechnique de Toulouse
+ * Copyright (C) 2024 |Méso|Star> (contact@meso-star.com)
+ * Copyright (C) 2024 PhotonLyX (info@photonlyx.com)
+ * Copyright (C) 2024 Université de Lorraine
+ * Copyright (C) 2024 Université Paul Sabatier
+ * Copyright (C) 2024 Université Toulouse - Jean Jaurès
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include "sphin_geometry.h"
+
+/*******************************************************************************
+ * Local functions
+ ******************************************************************************/
+void
+geometry_init
+ (struct mem_allocator* allocator,
+ struct geometry* geom)
+{
+ ASSERT(NULL != geom);
+ str_init(allocator, &geom->stl_filename);
+ geom->side = SPHIN_SIDE_NONE__;
+}
+
+void
+geometry_release
+ (struct geometry* geom)
+{
+ ASSERT(NULL != geom);
+ str_release(&geom->stl_filename);
+}
+
+res_T
+geometry_copy
+ (struct geometry* dst,
+ const struct geometry* src)
+{
+ ASSERT(NULL != dst);
+ ASSERT(NULL != src);
+ dst->side = src->side;
+ return str_copy(&dst->stl_filename, &src->stl_filename);
+}
+
diff --git a/src/sphin_geometry.h b/src/sphin_geometry.h
@@ -0,0 +1,53 @@
+/* Copyright (C) 2024 Centre National de la Recherche Scientifique
+ * Copyright (C) 2024 Clermont Auvergne INP
+ * Copyright (C) 2024 INSA Lyon
+ * Copyright (C) 2024 Institut Mines Télécom Albi-Carmaux
+ * Copyright (C) 2024 Institut National Polytechnique de Toulouse
+ * Copyright (C) 2024 |Méso|Star> (contact@meso-star.com)
+ * Copyright (C) 2024 PhotonLyX (info@photonlyx.com)
+ * Copyright (C) 2024 Université de Lorraine
+ * Copyright (C) 2024 Université Paul Sabatier
+ * Copyright (C) 2024 Université Toulouse - Jean Jaurès
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * 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 SPHIN_GEOMETRY_H
+#define SPHIN_GEOMETRY_H
+
+#include "sphin.h"
+
+#include <rsys/str.h>
+
+struct mem_allocator;
+
+struct geometry {
+ struct str stl_filename;
+ enum sphin_side side;
+};
+
+extern LOCAL_SYM void
+geometry_init
+ (struct mem_allocator* allocator,
+ struct geometry* geom);
+
+extern LOCAL_SYM void
+geometry_release
+ (struct geometry* geom);
+
+extern LOCAL_SYM res_T
+geometry_copy
+ (struct geometry* dst,
+ const struct geometry* src);
+
+#endif /* SPHIN_GEOMETRY_H */