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-2015 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  * polygon_vertices <-- polygon connectivity; size: n_vertices or empty.
117  * mode <-- triangles connectivity by vertex number or
118  * polygon vertex index (1 to n).
119  * triangle_vertices --> triangles connectivity;
120  * size: (n_vertices - 2) * 3.
121  * state <-> associated triangulation state structure.
122  *
123  * returns:
124  * number of resulting triangles.
125  *----------------------------------------------------------------------------*/
126 
127 int
129  int base,
130  int n_vertices,
131  const cs_coord_t coords[],
132  const cs_lnum_t parent_vertex_num[],
133  const cs_lnum_t polygon_vertices[],
135  cs_lnum_t triangle_vertices[],
136  fvm_triangulate_state_t *const state);
137 
138 /*----------------------------------------------------------------------------
139  * Triangulate a quadrangle.
140  *
141  * A convex quadrangle is divided into two triangles along its shortest
142  * diagonal. A non-convex quadrangle may only be divided along the diagonal
143  * which lies inside the quadrangle.
144  *
145  * If the quadrangle_vertices argument is NULL, 1, 2, ...,n local numbering
146  * is implied.
147  *
148  * parameters:
149  * dim <-- spatial dimension (2 or 3).
150  * base <-- base numbering (usually 0 or 1)
151  * coords <-- coordinates of the triangulation's vertices.
152  * parent_vertex_num <-- optional indirection to vertex coordinates
153  * quadrangle_vertices <-- polygon connectivity; size: n_vertices or empty.
154  * triangle_vertices --> triangles connectivity; size: 2 * 3.
155  *
156  * returns:
157  * number of resulting triangles.
158  *----------------------------------------------------------------------------*/
159 
160 int
162  int base,
163  const cs_coord_t coords[],
164  const cs_lnum_t parent_vertex_num[],
165  const cs_lnum_t quadrangle_vertices[],
166  cs_lnum_t triangle_vertices[]);
167 
168 /*----------------------------------------------------------------------------*/
169 
171 
172 #endif /* __FVM_TRIANGULATE_H__ */
Definition: fvm_triangulate.h:64
#define BEGIN_C_DECLS
Definition: cs_defs.h:429
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:1113
fvm_triangulate_def_t
Definition: fvm_triangulate.h:61
double cs_coord_t
Definition: cs_defs.h:293
fvm_triangulate_state_t * fvm_triangulate_state_destroy(fvm_triangulate_state_t *this_state)
Definition: fvm_triangulate.c:866
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:910
struct _fvm_triangulate_state_t fvm_triangulate_state_t
Definition: fvm_triangulate.h:55
fvm_triangulate_state_t * fvm_triangulate_state_create(const int n_vertices_max)
Definition: fvm_triangulate.c:820
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:292
#define END_C_DECLS
Definition: cs_defs.h:430
Definition: fvm_triangulate.h:63