1
// ---------------------------------------------------------
6
// C-callable API for El Topo
8
// ---------------------------------------------------------
18
// =========================================================
19
// STRUCTURES FOR SPECIFYING OPTIONS
20
// =========================================================
22
// ---------------------------------------------------------
24
/// Options common to static operations and position integration.
26
// ---------------------------------------------------------
28
struct ElTopoGeneralOptions
30
int m_verbose; // whether to output a lot of information to the console
31
int m_collision_safety; // whether to enforce an intersection-free mesh at all times
32
double m_proximity_epsilon;
35
// ---------------------------------------------------------
37
/// Options for static operations (mesh maintenance and topology change)
39
// ---------------------------------------------------------
41
struct ElTopoStaticOperationsOptions
43
/// whether to perform mesh maintenance
44
int m_perform_improvement;
46
/// whether to allow merging and separation
47
int m_allow_topology_changes;
49
/// maximum allowable change in volume when performing mesh maintenance
50
double m_max_volume_change;
52
/// edges shorter than this length will be collapsed
53
double m_min_edge_length;
55
/// edges longer then this length will be subdivided
56
double m_max_edge_length;
58
/// prevent triangles smaller than this area
59
double m_min_triangle_area;
61
/// prevent interior angles smaller than this
62
double m_min_triangle_angle;
64
/// prevent interior angles greater than this
65
double m_max_triangle_angle;
67
/// boolean, whether to use curvature adaptivity when splitting edges
68
int m_use_curvature_when_splitting;
70
/// whether to use curvature adaptivity when collapsing edges
71
int m_use_curvature_when_collapsing;
73
/// clamp curvature scaling to these values
74
double m_min_curvature_multiplier;
76
/// clamp curvature scaling to these values
77
double m_max_curvature_multiplier;
79
/// boolean, whether to allow vertices to move during improvement
80
int m_allow_vertex_movement;
82
/// Minimum edge length improvement in order to flip an edge
83
double m_edge_flip_min_length_change;
85
/// Elements within this distance will trigger a merge attempt
86
double m_merge_proximity_epsilon;
88
/// Type of subdivision to use when collapsing or splitting (butterfly, quadric error minimization, etc.)
89
void *m_subdivision_scheme;
91
/// boolean, whether to enforce collision-free surfaces (including during mesh maintenance operations)
92
int m_collision_safety;
94
/// boolean, whether to allow non-manifold (edges incident on more than two triangles)
95
int m_allow_non_manifold;
99
// ---------------------------------------------------------
101
/// Options for position integration
103
// ---------------------------------------------------------
105
struct ElTopoIntegrationOptions
107
/// friction coefficient to apply during collision resolution
108
double m_friction_coefficient;
110
/// integration timestep size
115
// ---------------------------------------------------------
117
/// A mesh object: list of triangles, vertex positions, and vertex masses
119
// ---------------------------------------------------------
124
/// Number of vertices
127
/// Vertex positions in 3D space. This array should be shaped like: [x0 y0 z0 x1 y1 z1 ... ]
128
double* vertex_locations;
130
/// Number of traingles
133
/// Triangles, indexing into the vertex array. [a0 b0 c0 a1 b1 c1 ... ], where triangle i has vertices (ai,bi,ci).
136
/// For each vertex i, array element i is 1 if the vertex is solid, 0 otherwise
137
double* vertex_masses;
142
// ---------------------------------------------------------
144
/// Defragment information, recording all vertex and triangle operations, and maps from old indices to new ones
146
// ---------------------------------------------------------
148
struct ElTopoDefragInformation
150
/// Number of entries in the vertex change history
151
int num_vertex_changes; // = N
153
/// Boolean, 0: vertex addition, non-zero: vertex removal
154
int* vertex_is_remove; // size N
156
/// The index of the affected vertex
157
int* vertex_index; // size N
159
/// If this is a vertex addition due to splitting, the split edge, stored as pairs of vertex indices
160
int* split_edge; // size 2*N
163
/// Number of entries in the triangle change history
164
int num_triangle_changes; // = N
166
/// Boolean, 0: triangle addition, non-zero: triangle removal
167
int* triangle_is_remove; // boolean, size N
169
/// The index of the affected triangle
170
int* triangle_index; // N
172
/// If this is a triangle addition, the new triangle, stored as a triplet of vertex indices
175
/// Size of the defragged triangle map
176
int defragged_triangle_map_size; // = N
178
/// For each triangle, a pair of indices (old, new), where old is the triangle index at before defrag, and new is the
179
/// triangle index after defrag
180
int* defragged_triangle_map; // 2*N
182
/// Size of the defragged vertex map
183
int defragged_vertex_map_size; // = N
185
/// For each vertex, a pair of indices (old, new), where old is the vertex index at before defrag, and new is the vertex
186
/// index after defrag
187
int* defragged_vertex_map; // 2*N
192
// =========================================================
194
// =========================================================
197
// ---------------------------------------------------------
199
/// Static operations: edge collapse, edge split, edge flip, null-space
200
/// smoothing, and topological changes
203
/// input_mesh: (Input) ElTopoMesh to be operated on
204
/// general_otions (Input) Structure specifying options common to
205
/// static operations and integration.
206
/// options (Input) Structure specifying options specific
207
/// to static operations.
208
/// defrag_info (Output, allocated by El Topo) Change history and defrag maps, recording the operations
209
/// performed at the vertex and triangle level.
210
/// output_mesh (Output, allocated by El Topo) Mesh data structure after remeshing and topology operations.
212
// ---------------------------------------------------------
214
void el_topo_static_operations( const struct ElTopoMesh* input_mesh,
215
const struct ElTopoGeneralOptions* general_options,
216
const struct ElTopoStaticOperationsOptions* options,
217
struct ElTopoDefragInformation* defrag_info,
218
struct ElTopoMesh* output_mesh );
220
// ---------------------------------------------------------
222
/// Free memory allocated by static operations.
224
// ---------------------------------------------------------
226
void el_topo_free_static_operations_results( struct ElTopoMesh* outputs, struct ElTopoDefragInformation* defrag_info );
229
// ---------------------------------------------------------
231
/// Surface vertex position integration.
234
/// input_mesh: (Input) Mesh data structure to be integrated forward.
235
/// in_vertex_new_locations (Input) Predicted vertex positions at the end of the time step.
236
/// general_otions (Input) Structure specifying options common to
237
/// static operations and integration.
238
/// options (Input) Structure specifying options specific
239
/// to integration operations.
240
/// out_vertex_locations (Output) Final vertex positions after integration.
241
/// out_dt (Output) Actual time step taken by the function.
244
// ---------------------------------------------------------
246
void el_topo_integrate(const struct ElTopoMesh* input_mesh,
247
const double* in_vertex_new_locations,
248
const struct ElTopoGeneralOptions* general_options,
249
const struct ElTopoIntegrationOptions* options,
250
double **out_vertex_locations,
254
// ---------------------------------------------------------
256
/// Free memory allocated by integration.
258
// ---------------------------------------------------------
260
void el_topo_free_integrate_results( double* out_vertex_locations );