~ubuntu-branches/ubuntu/trusty/blender/trusty

« back to all changes in this revision

Viewing changes to extern/eltopo/eltopo3d/eltopo.h

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-03-06 12:08:47 UTC
  • mfrom: (1.5.1) (14.1.8 experimental)
  • Revision ID: package-import@ubuntu.com-20130306120847-frjfaryb2zrotwcg
Tags: 2.66a-1ubuntu1
* Resynchronize with Debian (LP: #1076930, #1089256, #1052743, #999024,
  #1122888, #1147084)
* debian/control:
  - Lower build-depends on libavcodec-dev since we're not
    doing the libav9 transition in Ubuntu yet

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// ---------------------------------------------------------
2
 
//
3
 
//  eltopo.h
4
 
//  Tyson Brochu 2009
5
 
//
6
 
//  C-callable API for El Topo
7
 
//
8
 
// ---------------------------------------------------------
9
 
 
10
 
#ifndef ELTOPO_H
11
 
#define ELTOPO_H
12
 
 
13
 
#ifdef __cplusplus
14
 
extern "C" {
15
 
#endif
16
 
    
17
 
    
18
 
    // =========================================================
19
 
    //  STRUCTURES FOR SPECIFYING OPTIONS
20
 
    // =========================================================   
21
 
    
22
 
    // ---------------------------------------------------------
23
 
    ///
24
 
    /// Options common to static operations and position integration.
25
 
    ///
26
 
    // ---------------------------------------------------------
27
 
    
28
 
    struct ElTopoGeneralOptions
29
 
    {
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;
33
 
    };
34
 
    
35
 
    // ---------------------------------------------------------
36
 
    ///
37
 
    /// Options for static operations (mesh maintenance and topology change)
38
 
    ///
39
 
    // ---------------------------------------------------------
40
 
    
41
 
    struct ElTopoStaticOperationsOptions
42
 
    {
43
 
        /// whether to perform mesh maintenance
44
 
        int m_perform_improvement;            
45
 
        
46
 
        /// whether to allow merging and separation
47
 
        int m_allow_topology_changes;     
48
 
        
49
 
        /// maximum allowable change in volume when performing mesh maintenance
50
 
        double m_max_volume_change;       
51
 
        
52
 
        /// edges shorter than this length will be collapsed
53
 
        double m_min_edge_length;              
54
 
        
55
 
        /// edges longer then this length will be subdivided
56
 
        double m_max_edge_length;              
57
 
        
58
 
        /// prevent triangles smaller than this area
59
 
        double m_min_triangle_area;
60
 
        
61
 
        /// prevent interior angles smaller than this
62
 
        double m_min_triangle_angle;
63
 
        
64
 
        /// prevent interior angles greater than this
65
 
        double m_max_triangle_angle;   
66
 
        
67
 
        /// boolean, whether to use curvature adaptivity when splitting edges
68
 
        int m_use_curvature_when_splitting;
69
 
 
70
 
        /// whether to use curvature adaptivity when collapsing edges        
71
 
        int m_use_curvature_when_collapsing;
72
 
        
73
 
        /// clamp curvature scaling to these values
74
 
        double m_min_curvature_multiplier;
75
 
        
76
 
        /// clamp curvature scaling to these values
77
 
        double m_max_curvature_multiplier;
78
 
        
79
 
        /// boolean, whether to allow vertices to move during improvement
80
 
        int m_allow_vertex_movement;
81
 
        
82
 
        /// Minimum edge length improvement in order to flip an edge
83
 
        double m_edge_flip_min_length_change;
84
 
        
85
 
        /// Elements within this distance will trigger a merge attempt   
86
 
        double m_merge_proximity_epsilon;
87
 
        
88
 
        /// Type of subdivision to use when collapsing or splitting (butterfly, quadric error minimization, etc.)
89
 
        void *m_subdivision_scheme;   
90
 
        
91
 
        /// boolean, whether to enforce collision-free surfaces (including during mesh maintenance operations)
92
 
        int m_collision_safety;
93
 
        
94
 
        /// boolean, whether to allow non-manifold (edges incident on more than two triangles)
95
 
        int m_allow_non_manifold;
96
 
        
97
 
    };
98
 
    
99
 
    // ---------------------------------------------------------
100
 
    ///
101
 
    /// Options for position integration
102
 
    ///
103
 
    // ---------------------------------------------------------
104
 
    
105
 
    struct ElTopoIntegrationOptions
106
 
    {
107
 
        /// friction coefficient to apply during collision resolution
108
 
        double m_friction_coefficient;
109
 
        
110
 
        /// integration timestep size
111
 
        double m_dt;                     
112
 
    };
113
 
    
114
 
    
115
 
    // ---------------------------------------------------------
116
 
    ///
117
 
    /// A mesh object: list of triangles, vertex positions, and vertex masses
118
 
    ///
119
 
    // ---------------------------------------------------------
120
 
    
121
 
    struct ElTopoMesh
122
 
    {
123
 
        
124
 
        /// Number of vertices
125
 
        int num_vertices;
126
 
        
127
 
        /// Vertex positions in 3D space.  This array should be shaped like: [x0 y0 z0 x1 y1 z1 ... ]
128
 
        double* vertex_locations;
129
 
        
130
 
        /// Number of traingles
131
 
        int num_triangles;
132
 
        
133
 
        /// Triangles, indexing into the vertex array. [a0 b0 c0 a1 b1 c1 ... ], where triangle i has vertices (ai,bi,ci).
134
 
        int* triangles;
135
 
        
136
 
        /// For each vertex i, array element i is 1 if the vertex is solid, 0 otherwise
137
 
        double* vertex_masses;
138
 
        
139
 
    };
140
 
    
141
 
    
142
 
    // ---------------------------------------------------------
143
 
    ///
144
 
    /// Defragment information, recording all vertex and triangle operations, and maps from old indices to new ones
145
 
    ///
146
 
    // ---------------------------------------------------------
147
 
    
148
 
    struct ElTopoDefragInformation
149
 
    {
150
 
        /// Number of entries in the vertex change history
151
 
        int num_vertex_changes;     // = N
152
 
            
153
 
        /// Boolean, 0: vertex addition, non-zero: vertex removal
154
 
        int* vertex_is_remove;      // size N
155
 
        
156
 
        /// The index of the affected vertex
157
 
        int* vertex_index;          // size N
158
 
        
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
161
 
        
162
 
        
163
 
        /// Number of entries in the triangle change history
164
 
        int num_triangle_changes;  // = N
165
 
        
166
 
        /// Boolean, 0: triangle addition, non-zero: triangle removal
167
 
        int* triangle_is_remove;   // boolean, size N
168
 
        
169
 
        /// The index of the affected triangle
170
 
        int* triangle_index;       // N
171
 
        
172
 
        /// If this is a triangle addition, the new triangle, stored as a triplet of vertex indices
173
 
        int* new_tri;              // 3*N
174
 
        
175
 
        /// Size of the defragged triangle map
176
 
        int defragged_triangle_map_size;    // = N
177
 
        
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
181
 
 
182
 
        /// Size of the defragged vertex map
183
 
        int defragged_vertex_map_size;      // = N
184
 
        
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
188
 
        
189
 
    };
190
 
    
191
 
    
192
 
    // =========================================================
193
 
    //  API FUNCTIONS
194
 
    // =========================================================   
195
 
    
196
 
    
197
 
    // ---------------------------------------------------------
198
 
    ///
199
 
    /// Static operations: edge collapse, edge split, edge flip, null-space 
200
 
    /// smoothing, and topological changes
201
 
    ///
202
 
    /// Parameters:
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.
211
 
    ///
212
 
    // ---------------------------------------------------------
213
 
    
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 );
219
 
    
220
 
    // ---------------------------------------------------------
221
 
    ///
222
 
    /// Free memory allocated by static operations.
223
 
    ///
224
 
    // ---------------------------------------------------------
225
 
    
226
 
    void el_topo_free_static_operations_results( struct ElTopoMesh* outputs, struct ElTopoDefragInformation* defrag_info  );
227
 
    
228
 
    
229
 
    // ---------------------------------------------------------
230
 
    ///
231
 
    /// Surface vertex position integration.
232
 
    ///
233
 
    /// Parameters:
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.
242
 
    ///     
243
 
    ///
244
 
    // ---------------------------------------------------------
245
 
    
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,
251
 
                           double *out_dt );
252
 
    
253
 
    
254
 
    // ---------------------------------------------------------
255
 
    ///
256
 
    /// Free memory allocated by integration.
257
 
    ///
258
 
    // ---------------------------------------------------------
259
 
    
260
 
    void el_topo_free_integrate_results( double* out_vertex_locations );
261
 
    
262
 
    
263
 
#ifdef __cplusplus
264
 
}
265
 
#endif
266
 
 
267
 
#endif