6.2
general documentation
cs_stl.h
Go to the documentation of this file.
1 #ifndef __CS_STL_H__
2 #define __CS_STL_H__
3 
4 /*============================================================================
5  * STL reader and writer.
6  *============================================================================*/
7 
8 /*
9  This file is part of Code_Saturne, a general-purpose CFD tool.
10 
11  Copyright (C) 1998-2020 EDF S.A.
12 
13  This program is free software; you can redistribute it and/or modify it under
14  the terms of the GNU General Public License as published by the Free Software
15  Foundation; either version 2 of the License, or (at your option) any later
16  version.
17 
18  This program is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
20  FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
21  details.
22 
23  You should have received a copy of the GNU General Public License along with
24  this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
25  Street, Fifth Floor, Boston, MA 02110-1301, USA.
26 */
27 
28 /*----------------------------------------------------------------------------*/
29 
30 /*----------------------------------------------------------------------------
31  * Local headers
32  *----------------------------------------------------------------------------*/
33 
34 #include "cs_defs.h"
35 
36 /*----------------------------------------------------------------------------*/
37 
39 
40 /*=============================================================================
41  * Macro definitions
42  *============================================================================*/
43 
44 /*============================================================================
45  * Type definitions
46  *============================================================================*/
47 
48 /*----------------------------------------------------------------------------
49  * Structure defining an STL mesh
50  *----------------------------------------------------------------------------*/
51 
52 typedef struct {
53 
54  char name[10];
56  char header[80];
60  float *normals;
62  float *coords;
65  fvm_nodal_t *ext_mesh;
67 } cs_stl_mesh_t ;
68 
69 /*----------------------------------------------------------------------------
70  * Structure containing the number of STL meshes and their associated pointers
71  *----------------------------------------------------------------------------*/
72 
73 typedef struct {
74 
81 
82 /*=============================================================================
83  * Static global variables
84  *============================================================================*/
85 
87 
88 /*=============================================================================
89  * Public function prototypes
90  *============================================================================*/
91 
92 /*-----------------------------------------------------------------------------
93  * Add a new STL mesh structure.
94  *
95  * parameters:
96  * path <-- path of the STL mesh
97  *
98  * returns:
99  * pointer to the new STL mesh structure
100  *----------------------------------------------------------------------------*/
101 
103 cs_stl_mesh_add(const char *path);
104 
105 /*----------------------------------------------------------------------------
106  * Return a pointer to a STL mesh based on its name if present.
107  *
108  * parameters:
109  * name <-- name of the STL mesh
110  *
111  * returns:
112  * pointer to the STL mesh structure, or NULL
113  *----------------------------------------------------------------------------*/
114 
116 cs_stl_mesh_get_by_name(const char *name);
117 
118 /*----------------------------------------------------------------------------
119  * Free all allocated STL mesh structures
120  *----------------------------------------------------------------------------*/
121 
122 void
124 
125 /*----------------------------------------------------------------------------
126  * Read a binary STL file and store its content in a STL mesh structure.
127  *
128  * parameters:
129  * stl_mesh <-- pointer to the associated STL mesh structure
130  * path <-- path to the STL file
131  *----------------------------------------------------------------------------*/
132 
133 void
135  const char *path);
136 
137 /*----------------------------------------------------------------------------
138  * Write a binary STL file according to a given STL mesh structure.
139  *
140  * parameters:
141  * stl_mesh <-- pointer to the associated STL mesh structure
142  * path <-- path to the STL file
143  *----------------------------------------------------------------------------*/
144 
145 void
147  const char *path);
148 
149 /*----------------------------------------------------------------------------*/
150 
152 
153 #endif /* __CS_STL_H__ */
cs_lnum_t n_faces
Definition: cs_stl.h:58
cs_stl_mesh_t ** mesh_list
Definition: cs_stl.h:75
void cs_stl_file_read(cs_stl_mesh_t *stl_mesh, const char *path)
Read a binary STL file and store its content in a STL mesh structure.
Definition: cs_stl.c:237
Definition: cs_stl.h:73
#define BEGIN_C_DECLS
Definition: cs_defs.h:495
float * coords
Definition: cs_stl.h:62
float * normals
Definition: cs_stl.h:60
Definition: cs_stl.h:52
cs_stl_mesh_t * cs_stl_mesh_add(const char *path)
Add a new STL mesh structure.
Definition: cs_stl.c:141
void cs_stl_file_write(cs_stl_mesh_t *stl_mesh, const char *path)
Write a binary STL file according to a given STL mesh structure.
Definition: cs_stl.c:399
cs_stl_mesh_info_t * cs_glob_stl_meshes
fvm_nodal_t * ext_mesh
Definition: cs_stl.h:65
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:301
cs_stl_mesh_t * cs_stl_mesh_get_by_name(const char *name)
Return a pointer to a STL mesh based on its name if present.
Definition: cs_stl.c:181
#define END_C_DECLS
Definition: cs_defs.h:496
void cs_stl_mesh_destroy_all(void)
Free all allocated STL mesh structures.
Definition: cs_stl.c:202
cs_lnum_t n_meshes
Definition: cs_stl.h:78