~ubuntu-branches/ubuntu/utopic/slic3r/utopic

« back to all changes in this revision

Viewing changes to xs/src/admesh/stl.h

  • Committer: Package Import Robot
  • Author(s): Chow Loong Jin
  • Date: 2014-06-17 01:27:26 UTC
  • Revision ID: package-import@ubuntu.com-20140617012726-2wrs4zdo251nr4vg
Tags: upstream-1.1.4+dfsg
ImportĀ upstreamĀ versionĀ 1.1.4+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*  ADMesh -- process triangulated solid meshes
 
2
 *  Copyright (C) 1995, 1996  Anthony D. Martin
 
3
 *
 
4
 *  This program is free software; you can redistribute it and/or modify
 
5
 *  it under the terms of the GNU General Public License as published by
 
6
 *  the Free Software Foundation; either version 2, or (at your option)
 
7
 *  any later version.
 
8
 *
 
9
 *  This program is distributed in the hope that it will be useful,
 
10
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
 *  GNU General Public License for more details.
 
13
 *
 
14
 *  You should have received a copy of the GNU General Public License
 
15
 *  along with this program; if not, write to the Free Software
 
16
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
17
 *  
 
18
 *  Questions, comments, suggestions, etc to <amartin@engr.csulb.edu>
 
19
 */
 
20
 
 
21
#include <stdio.h>
 
22
 
 
23
#define STL_MAX(A,B) ((A)>(B)? (A):(B))
 
24
#define STL_MIN(A,B) ((A)<(B)? (A):(B))
 
25
#define ABS(X)  ((X) < 0 ? -(X) : (X))
 
26
 
 
27
#define LABEL_SIZE             80
 
28
#define NUM_FACET_SIZE         4
 
29
#define HEADER_SIZE            84
 
30
#define STL_MIN_FILE_SIZE      284
 
31
#define ASCII_LINES_PER_FACET  7
 
32
#define SIZEOF_EDGE_SORT       24
 
33
 
 
34
typedef struct 
 
35
{
 
36
  float x;
 
37
  float y;
 
38
  float z;
 
39
}stl_vertex;
 
40
 
 
41
typedef struct
 
42
{
 
43
  float x;
 
44
  float y;
 
45
  float z;
 
46
}stl_normal;
 
47
 
 
48
typedef char stl_extra[2];
 
49
 
 
50
typedef struct
 
51
{
 
52
  stl_normal normal;
 
53
  stl_vertex vertex[3];
 
54
  stl_extra  extra;
 
55
}stl_facet;
 
56
#define SIZEOF_STL_FACET       50
 
57
 
 
58
typedef enum {binary, ascii, inmemory} stl_type;
 
59
 
 
60
typedef struct
 
61
{
 
62
  stl_vertex p1;
 
63
  stl_vertex p2;
 
64
  int        facet_number;
 
65
}stl_edge;
 
66
 
 
67
typedef struct stl_hash_edge
 
68
{
 
69
  unsigned       key[6];
 
70
  int            facet_number;
 
71
  int            which_edge;
 
72
  struct stl_hash_edge  *next;
 
73
}stl_hash_edge;
 
74
 
 
75
typedef struct
 
76
{
 
77
  int   neighbor[3];
 
78
  char  which_vertex_not[3];
 
79
}stl_neighbors;
 
80
 
 
81
typedef struct
 
82
{
 
83
  int   vertex[3];
 
84
}v_indices_struct;
 
85
 
 
86
typedef struct
 
87
{
 
88
  char          header[81];
 
89
  stl_type      type;
 
90
  int           number_of_facets;
 
91
  stl_vertex    max;
 
92
  stl_vertex    min;
 
93
  stl_vertex    size;
 
94
  float         bounding_diameter;
 
95
  float         shortest_edge;
 
96
  float         volume;
 
97
  unsigned      number_of_blocks;
 
98
  int           connected_edges;
 
99
  int           connected_facets_1_edge;
 
100
  int           connected_facets_2_edge;
 
101
  int           connected_facets_3_edge;
 
102
  int           facets_w_1_bad_edge;
 
103
  int           facets_w_2_bad_edge;
 
104
  int           facets_w_3_bad_edge;
 
105
  int           original_num_facets;
 
106
  int           edges_fixed;
 
107
  int           degenerate_facets;
 
108
  int           facets_removed;
 
109
  int           facets_added;
 
110
  int           facets_reversed;
 
111
  int           backwards_edges;
 
112
  int           normals_fixed;
 
113
  int           number_of_parts;
 
114
  int           malloced;
 
115
  int           freed;
 
116
  int           facets_malloced;
 
117
  int           collisions;
 
118
  int           shared_vertices;
 
119
  int           shared_malloced;
 
120
}stl_stats;  
 
121
 
 
122
typedef struct
 
123
{
 
124
  FILE          *fp;
 
125
  stl_facet     *facet_start;
 
126
  stl_edge      *edge_start;
 
127
  stl_hash_edge **heads;
 
128
  stl_hash_edge *tail;
 
129
  int           M;
 
130
  stl_neighbors *neighbors_start;
 
131
  v_indices_struct *v_indices;
 
132
  stl_vertex    *v_shared;
 
133
  stl_stats     stats;
 
134
}stl_file;
 
135
 
 
136
 
 
137
extern void stl_open(stl_file *stl, char *file);
 
138
extern void stl_close(stl_file *stl);
 
139
extern void stl_stats_out(stl_file *stl, FILE *file, char *input_file);
 
140
extern void stl_print_edges(stl_file *stl, FILE *file);
 
141
extern void stl_print_neighbors(stl_file *stl, char *file);
 
142
extern void stl_write_ascii(stl_file *stl, const char *file, const char *label);
 
143
extern void stl_write_binary(stl_file *stl, const char *file, const char *label);
 
144
extern void stl_check_facets_exact(stl_file *stl);
 
145
extern void stl_check_facets_nearby(stl_file *stl, float tolerance);
 
146
extern void stl_remove_unconnected_facets(stl_file *stl);
 
147
extern void stl_write_vertex(stl_file *stl, int facet, int vertex);
 
148
extern void stl_write_facet(stl_file *stl, char *label, int facet);
 
149
extern void stl_write_edge(stl_file *stl, char *label, stl_hash_edge edge);
 
150
extern void stl_write_neighbor(stl_file *stl, int facet);
 
151
extern void stl_write_quad_object(stl_file *stl, char *file);
 
152
extern void stl_verify_neighbors(stl_file *stl);
 
153
extern void stl_fill_holes(stl_file *stl);
 
154
extern void stl_fix_normal_directions(stl_file *stl);
 
155
extern void stl_fix_normal_values(stl_file *stl);
 
156
extern void stl_reverse_all_facets(stl_file *stl);
 
157
extern void stl_translate_relative(stl_file *stl, float x, float y, float z);
 
158
extern void stl_scale_versor(stl_file *stl, float versor[3]);
 
159
extern void stl_scale(stl_file *stl, float factor);
 
160
extern void stl_rotate_x(stl_file *stl, float angle);
 
161
extern void stl_rotate_y(stl_file *stl, float angle);
 
162
extern void stl_rotate_z(stl_file *stl, float angle);
 
163
extern void stl_mirror_xy(stl_file *stl);
 
164
extern void stl_mirror_yz(stl_file *stl);
 
165
extern void stl_mirror_xz(stl_file *stl);
 
166
extern void stl_open_merge(stl_file *stl, char *file);
 
167
extern void stl_invalidate_shared_vertices(stl_file *stl);
 
168
extern void stl_generate_shared_vertices(stl_file *stl);
 
169
extern void stl_write_obj(stl_file *stl, char *file);
 
170
extern void stl_write_off(stl_file *stl, char *file);
 
171
extern void stl_write_dxf(stl_file *stl, char *file, char *label);
 
172
extern void stl_write_vrml(stl_file *stl, char *file);
 
173
extern void stl_calculate_normal(float normal[], stl_facet *facet);
 
174
extern void stl_normalize_vector(float v[]);
 
175
extern void stl_calculate_volume(stl_file *stl);
 
176
 
 
177
extern void stl_initialize(stl_file *stl);
 
178
static void stl_count_facets(stl_file *stl, char *file);
 
179
extern void stl_allocate(stl_file *stl);
 
180
static void stl_read(stl_file *stl, int first_facet, int first);
 
181
extern void stl_facet_stats(stl_file *stl, stl_facet facet, int first);
 
182
extern void stl_reallocate(stl_file *stl);
 
183
extern void stl_add_facet(stl_file *stl, stl_facet *new_facet);
 
184
extern void stl_get_size(stl_file *stl);