Code_Saturne
CFD tool
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-2012 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 "fvm_defs.h"
35 
36 /*----------------------------------------------------------------------------*/
37 
38 #ifdef __cplusplus
39 extern "C" {
40 #if 0
41 } /* Fake brace to force back Emacs auto-indentation back to column 0 */
42 #endif
43 #endif /* __cplusplus */
44 
45 /*=============================================================================
46  * Macro definitions
47  *============================================================================*/
48 
49 /*============================================================================
50  * Type definitions
51  *============================================================================*/
52 
53 /*
54  * Pointer to structure maintaining the state of the current triangulation;
55  * the structure itself is private.
56  */
57 
59 
60 /*
61  * Describe how the resulting triangle connectivity is defined.
62  */
63 
64 typedef enum {
65 
66  FVM_TRIANGULATE_MESH_DEF, /* Definition by mesh vertex numbers */
67  FVM_TRIANGULATE_ELT_DEF /* Definition by local (element) vertex
68  position (1 to n) */
69 
71 
72 /*=============================================================================
73  * Static global variables
74  *============================================================================*/
75 
76 /*=============================================================================
77  * Public function prototypes
78  *============================================================================*/
79 
80 /*----------------------------------------------------------------------------
81  * Create a structure necessary to the polygon triangulation algorithm.
82  *
83  * parameters:
84  * n_vertices_max <-- maximum expected number of vertices per polygon.
85  *
86  * returns:
87  * pointer to polygon triangulation state structure.
88  *----------------------------------------------------------------------------*/
89 
92 
93 /*----------------------------------------------------------------------------
94  * Destroy a structure necessary to the polygon triangulation algorithm.
95  *
96  * parameters:
97  * this_state <-> pointer to structure that should be destroyed.
98  *
99  * returns:
100  * NULL pointer.
101  *----------------------------------------------------------------------------*/
102 
105 
106 /*----------------------------------------------------------------------------
107  * Triangulate a polygonal face.
108  *
109  * For a polygon with n vertices, we should obtain a triangluation with
110  * (n-2) triangles and (2n-3) edges. If the polygon_vertices argument
111  * is NULL, 1, 2, ...,n local numbering is implied.
112  *
113  * parameters:
114  * dim <-- spatial dimension (2 or 3).
115  * n_vertices <-- number of vertices defining the polygon.
116  * coords <-- coordinates of the triangulation's vertices.
117  * parent_vertex_num <-- optional indirection to vertex coordinates (1 to n).
118  * polygon_vertices <-- polygon connectivity; size: n_vertices or empty.
119  * mode <-- triangles connectivity by vertex number or
120  * polygon vertex index (1 to n).
121  * triangle_vertices --> triangles connectivity;
122  * size: (n_vertices - 2) * 3.
123  * state <-> associated triangulation state structure.
124  *
125  * returns:
126  * number of resulting triangles.
127  *----------------------------------------------------------------------------*/
128 
129 int
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[],
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  * 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  const cs_coord_t coords[],
163  const cs_lnum_t parent_vertex_num[],
164  const cs_lnum_t quadrangle_vertices[],
166 
167 /*----------------------------------------------------------------------------*/
168 
169 #ifdef __cplusplus
170 }
171 #endif /* __cplusplus */
172 
173 #endif /* __FVM_TRIANGULATE_H__ */
Definition: fvm_triangulate.h:67
int * triangle_vertices
Definition: fvm_triangulate.c:76
Definition: fvm_triangulate.c:74
fvm_triangulate_def_t
Definition: fvm_triangulate.h:64
double cs_coord_t
Definition: cs_defs.h:261
cs_coord_t * coords
Definition: fvm_triangulate.c:77
int cs_lnum_t
Definition: cs_defs.h:260
fvm_triangulate_state_t * fvm_triangulate_state_destroy(fvm_triangulate_state_t *this_state)
Definition: fvm_triangulate.c:871
fvm_triangulate_state_t * fvm_triangulate_state_create(const int n_vertices_max)
Definition: fvm_triangulate.c:825
int fvm_triangulate_polygon(int dim, 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:914
Definition: fvm_triangulate.h:66
int n_vertices_max
Definition: fvm_triangulate.c:92
int fvm_triangulate_quadrangle(int dim, 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:1115