My Project
programmer's documentation
fvm_triangulate.h
Go to the documentation of this file.
1 #ifndef __FVM_TRIANGULATE_H__
2 #define __FVM_TRIANGULATE_H__
3 
4 /*============================================================================
5  * Triangulation of a polygon
6  *============================================================================*/
7 
8 /*
9  This file is part of Code_Saturne, a general-purpose CFD tool.
10 
11  Copyright (C) 1998-2019 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 #include "cs_defs.h"
31 
32 /*----------------------------------------------------------------------------
33  * Local headers
34  *----------------------------------------------------------------------------*/
35 
36 #include "fvm_defs.h"
37 
38 /*----------------------------------------------------------------------------*/
39 
41 
42 /*=============================================================================
43  * Macro definitions
44  *============================================================================*/
45 
46 /*============================================================================
47  * Type definitions
48  *============================================================================*/
49 
50 /*
51  * Pointer to structure maintaining the state of the current triangulation;
52  * the structure itself is private.
53  */
54 
55 typedef struct _fvm_triangulate_state_t fvm_triangulate_state_t;
56 
57 /*
58  * Describe how the resulting triangle connectivity is defined.
59  */
60 
61 typedef enum {
62 
63  FVM_TRIANGULATE_MESH_DEF, /* Definition by mesh vertex numbers */
64  FVM_TRIANGULATE_ELT_DEF /* Definition by local (element) vertex
65  position (1 to n) */
66 
68 
69 /*=============================================================================
70  * Static global variables
71  *============================================================================*/
72 
73 /*=============================================================================
74  * Public function prototypes
75  *============================================================================*/
76 
77 /*----------------------------------------------------------------------------
78  * Create a structure necessary to the polygon triangulation algorithm.
79  *
80  * parameters:
81  * n_vertices_max <-- maximum expected number of vertices per polygon.
82  *
83  * returns:
84  * pointer to polygon triangulation state structure.
85  *----------------------------------------------------------------------------*/
86 
88 fvm_triangulate_state_create(const int n_vertices_max);
89 
90 /*----------------------------------------------------------------------------
91  * Destroy a structure necessary to the polygon triangulation algorithm.
92  *
93  * parameters:
94  * this_state <-> pointer to structure that should be destroyed.
95  *
96  * returns:
97  * NULL pointer.
98  *----------------------------------------------------------------------------*/
99 
102 
103 /*----------------------------------------------------------------------------
104  * Triangulate a polygonal face.
105  *
106  * For a polygon with n vertices, we should obtain a triangluation with
107  * (n-2) triangles and (2n-3) edges. If the polygon_vertices argument
108  * is NULL, 1, 2, ...,n local numbering is implied.
109  *
110  * parameters:
111  * dim <-- spatial dimension (2 or 3).
112  * base <-- base numbering (usually 0 or 1)
113  * n_vertices <-- number of vertices defining the polygon.
114  * coords <-- coordinates of the triangulation's vertices.
115  * parent_vertex_num <-- optional indirection to vertex coordinates
116  * (base to n-base).
117  * polygon_vertices <-- polygon connectivity; size: n_vertices or empty.
118  * mode <-- triangles connectivity by vertex number or
119  * polygon vertex index.
120  * triangle_vertices --> triangles connectivity;
121  * size: (n_vertices - 2) * 3.
122  * state <-> associated triangulation state structure.
123  *
124  * returns:
125  * number of resulting triangles.
126  *----------------------------------------------------------------------------*/
127 
128 int
130  int base,
131  int n_vertices,
132  const cs_coord_t coords[],
133  const cs_lnum_t parent_vertex_num[],
134  const cs_lnum_t polygon_vertices[],
136  cs_lnum_t triangle_vertices[],
137  fvm_triangulate_state_t *const state);
138 
139 /*----------------------------------------------------------------------------
140  * Triangulate a quadrangle.
141  *
142  * A convex quadrangle is divided into two triangles along its shortest
143  * diagonal. A non-convex quadrangle may only be divided along the diagonal
144  * which lies inside the quadrangle.
145  *
146  * If the quadrangle_vertices argument is NULL, 1, 2, ...,n local numbering
147  * is implied.
148  *
149  * parameters:
150  * dim <-- spatial dimension (2 or 3).
151  * base <-- base numbering (usually 0 or 1)
152  * coords <-- coordinates of the triangulation's vertices.
153  * parent_vertex_num <-- optional indirection to vertex coordinates
154  * (base to n-base numbering).
155  * quadrangle_vertices <-- polygon connectivity; size: n_vertices or empty.
156  * triangle_vertices --> triangles connectivity; size: 2 * 3.
157  *
158  * returns:
159  * number of resulting triangles.
160  *----------------------------------------------------------------------------*/
161 
162 int
164  int base,
165  const cs_coord_t coords[],
166  const cs_lnum_t parent_vertex_num[],
167  const cs_lnum_t quadrangle_vertices[],
168  cs_lnum_t triangle_vertices[]);
169 
170 /*----------------------------------------------------------------------------*/
171 
173 
174 #endif /* __FVM_TRIANGULATE_H__ */
cs_defs.h
FVM_TRIANGULATE_ELT_DEF
Definition: fvm_triangulate.h:64
fvm_triangulate_state_destroy
fvm_triangulate_state_t * fvm_triangulate_state_destroy(fvm_triangulate_state_t *this_state)
Definition: fvm_triangulate.c:1018
END_C_DECLS
#define END_C_DECLS
Definition: cs_defs.h:468
BEGIN_C_DECLS
#define BEGIN_C_DECLS
Definition: cs_defs.h:467
fvm_triangulate_polygon
int fvm_triangulate_polygon(int dim, int base, int n_vertices, const cs_coord_t coords[], const cs_lnum_t parent_vertex_num[], const cs_lnum_t polygon_vertices[], fvm_triangulate_def_t mode, cs_lnum_t triangle_vertices[], fvm_triangulate_state_t *const state)
Definition: fvm_triangulate.c:1063
mode
void const cs_int_t * mode
Definition: cs_syr_coupling.h:132
fvm_triangulate_def_t
fvm_triangulate_def_t
Definition: fvm_triangulate.h:61
cs_lnum_t
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:298
fvm_triangulate_state_t
struct _fvm_triangulate_state_t fvm_triangulate_state_t
Definition: fvm_triangulate.h:55
fvm_triangulate_state_create
fvm_triangulate_state_t * fvm_triangulate_state_create(const int n_vertices_max)
Definition: fvm_triangulate.c:972
fvm_triangulate_quadrangle
int fvm_triangulate_quadrangle(int dim, int base, const cs_coord_t coords[], const cs_lnum_t parent_vertex_num[], const cs_lnum_t quadrangle_vertices[], cs_lnum_t triangle_vertices[])
Definition: fvm_triangulate.c:1278
FVM_TRIANGULATE_MESH_DEF
Definition: fvm_triangulate.h:63
cs_coord_t
double cs_coord_t
Definition: cs_defs.h:299
fvm_defs.h
coords
void const cs_int_t const cs_real_t const cs_real_t * coords
Definition: cs_measures_util.h:360