Debian Codegraph @

vcg/wrap/io_trimesh/import_ply.h

raw symbols SCIP
1 /****************************************************************************
2 * VCGLib o o *
3 * Visual and Computer Graphics Library o o *
4 * _ O _ *
5 * Copyright(C) 2004 \/)\/ *
6 * Visual Computing Lab /\/| *
7 * ISTI - Italian National Research Council | *
8 * \ *
9 * All rights reserved. *
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 * This program is distributed in the hope that it will be useful, *
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
19 * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) *
20 * for more details. *
21 * *
22 ****************************************************************************/
23 /****************************************************************************
24 History
25
26 $Log: import_ply.h,v $
27 Revision 1.40 2008/04/15 14:12:21 cignoni
28 added yet another type of face indexes (now 8 different ways!)
29
30 Revision 1.39 2008/03/22 10:24:44 cignoni
31 added yet another combination of unsigned/signed elements in faces specification to comply to mathematica ply's
32
33 Revision 1.38 2007/11/19 16:31:55 ponchio
34 loadmask in Open is now written.
35
36 Revision 1.37 2007/10/19 22:13:37 cignoni
37 added support for per-vertex normal for reading ply point clouds
38
39 Revision 1.36 2007/07/02 12:33:34 cignoni
40 wedge colors now are loaded into face color if they are available.
41
42 Revision 1.35 2007/03/12 16:40:17 tarini
43 Texture coord name change! "TCoord" and "Texture" are BAD. "TexCoord" is GOOD.
44
45 Revision 1.34 2007/03/03 02:28:59 cignoni
46 Removed initialization of a single face in the main parsing loop. Single face cannot exist anymore with OCF. Moved into the tristrip parsing section.
47
48 Revision 1.33 2007/02/14 15:30:13 ganovelli
49 added treatment of HasPerVertexFlags absent
50
51 Revision 1.32 2007/02/02 00:29:33 tarini
52 added a few typecasts to QualityTypefor vertices and faces (avoids warinings when short int or int is used for Quality).
53
54 Revision 1.31 2006/12/18 09:46:39 callieri
55 camera+shot revamp: changed field names to something with more sense, cleaning of various functions, correction of minor bugs/incongruences, removal of the infamous reference in shot.
56
57 Revision 1.30 2006/11/27 10:36:13 cignoni
58 Removed flags initialization. no more necessary
59
60 Revision 1.29 2006/10/14 00:18:42 cignoni
61 Allowed the correct loading of meshes with 0 faces
62
63 Revision 1.28 2006/05/16 15:01:30 cignoni
64 Wedge colors are loaded into facecolor only if specified in the incoming pi.mask
65
66 Revision 1.27 2006/05/03 21:21:21 cignoni
67 Corrected bug: mismatch in the index of confidence vertex property (8 instead of 11)
68 Changed HasPerFaceColor to the new syntax (HasPerFaceColor(m) instead of FaceType::HasFaceColor() )
69
70 Revision 1.26 2006/02/03 09:46:24 corsini
71 Remove signed/unsigned warning
72
73 Revision 1.25 2006/01/11 10:37:12 cignoni
74 Removed warning for unused vars
75
76 Revision 1.24 2006/01/10 13:20:42 cignoni
77 Changed ply::PlyMask to io::Mask
78
79 Revision 1.23 2006/01/04 16:17:03 cignoni
80 Corrected use of mask and callback in function Open(m,filename,mask,callback);
81
82 Revision 1.22 2005/12/30 22:30:43 cignoni
83 Added support for per vertex color stored as 'diffuse_xxx' property
84
85 Revision 1.21 2005/12/02 10:04:18 cignoni
86 forgotten a couple of std::
87
88 Revision 1.20 2005/12/02 00:01:30 cignoni
89 Added loading of texturenames (normalmap still to do)
90
91 Revision 1.19 2005/11/25 10:23:27 cignoni
92 Added safe zero initialization of index of wedge texture
93
94 Revision 1.18 2005/11/23 16:59:55 callieri
95 corrected protected access methods (camera, similarity) of shot
96
97 Revision 1.17 2005/11/12 18:13:30 cignoni
98 Added support for non triangular faces (simple fan triangulation) and removed flags intiailization.
99
100 Revision 1.16 2005/10/14 15:09:56 cignoni
101 Added LoadMask without plyinfo and some comment on the mask usage
102
103 Revision 1.15 2005/06/10 15:05:00 cignoni
104 Made inline PlyType specializations
105
106 Revision 1.14 2005/04/14 15:09:38 ponchio
107 New gcc 3.3.3 (with bugs and features) now compiles.
108
109 Revision 1.13 2005/03/18 00:14:39 cignoni
110 removed small gcc compiling issues
111
112 Revision 1.12 2005/02/08 17:28:22 tarini
113 changed 120 "const static" to "static const", and added missing "format" fields to all PropDescriptor literals, to keep Mingw compiler happy
114
115 Revision 1.11 2005/01/03 10:35:47 cignoni
116 Improved the compatibility for ply format for faces having the list size (e.g. number of vertexes of a face) as a char instead of a uchar.
117 Added a couple of new face descriptors, corrected a bug in error reporting function (and restructured) and translated a few comments.
118 Thanks to Patrick Min for the careful bug reporting
119
120 Revision 1.10 2004/10/07 14:51:10 ganovelli
121 added setidentity della camera
122
123 Revision 1.9 2004/10/07 14:19:06 ganovelli
124 shot/camera io added
125
126 Revision 1.8 2004/06/23 15:36:43 cignoni
127 Restructured management of error, now the standard open for any mesh type return the error code, the default success value is zero
128 Any import class has a method ErrorMsg that give a verbal description of an error code.
129
130 Revision 1.7 2004/06/11 17:09:41 ganovelli
131 inclusion of vector..minorchanges
132
133 Revision 1.6 2004/05/28 14:11:13 ganovelli
134 changes to comply io_mask moving in vcg::ply namesp
135
136 Revision 1.5 2004/05/12 10:19:30 ganovelli
137 new line added at the end of file
138
139 Revision 1.4 2004/05/04 02:36:07 ganovelli
140 #ifndef __VCGLIB_IMPORTERPLY added
141
142 Revision 1.3 2004/04/03 13:30:01 cignoni
143 missing include allocate.h
144
145 Revision 1.2 2004/03/09 21:26:47 cignoni
146 cr lf mismatch
147
148 Revision 1.1 2004/03/03 15:00:51 cignoni
149 Initial commit
150
151 ****************************************************************************/
152 #ifndef __VCGLIB_IMPORTERPLY
153 #define __VCGLIB_IMPORTERPLY
154
155 #include<wrap/callback.h>
156 #include<wrap/ply/plylib.h>
157 #include<wrap/io_trimesh/io_mask.h>
158 #include<wrap/io_trimesh/io_ply.h>
159 #include<vcg/complex/trimesh/allocate.h>
160 #include<vcg/space/color4.h>
161 #include <vector>
162
163 namespace vcg {
164 namespace tri {
165 namespace io {
166
167 template <class TYPE>
168 int PlyType () { return 0;}
169
170
171 // 10/6/05 Cignoni this specialization must be inlined becouse otherwise if we include this
172 // .h in two different cpp we should get a double definition error during linking
173
174 template <> inline int PlyType <float >() { return ply::T_FLOAT; }
175 template <> inline int PlyType <double>() { return ply::T_DOUBLE; }
176 template <> inline int PlyType <int >() { return ply::T_INT; }
177 template <> inline int PlyType <short >() { return ply::T_SHORT; }
178 template <> inline int PlyType <unsigned char >() { return ply::T_UCHAR; }
179
180 /**
181 This class encapsulate a filter for opening ply meshes.
182 The ply file format is quite extensible...
183 */
184 template <class OpenMeshType>
185 class ImporterPLY
186 {
187 public:
188
189 typedef ::vcg::ply::PropDescriptor PropDescriptor ;
190 typedef typename OpenMeshType::VertexPointer VertexPointer;
191 typedef typename OpenMeshType::ScalarType ScalarType;
192 typedef typename OpenMeshType::VertexType VertexType;
193 typedef typename OpenMeshType::FaceType FaceType;
194 typedef typename OpenMeshType::VertexIterator VertexIterator;
195 typedef typename OpenMeshType::FaceIterator FaceIterator;
196
197 //template <class T> int PlyType () { assert(0); return 0;}
198
199 #define MAX_USER_DATA 256
200 // Struttura ausiliaria per la lettura del file ply
201 struct LoadPly_FaceAux
202 {
203 unsigned char size;
204 int v[512];
205 int flags;
206 float q;
207 float texcoord[32];
208 unsigned char ntexcoord;
209 int texcoordind;
210 float colors[32];
211 unsigned char ncolors;
212
213 unsigned char r;
214 unsigned char g;
215 unsigned char b;
216
217 unsigned char data[MAX_USER_DATA];
218 };
219
220 struct LoadPly_TristripAux
221 {
222 int size;
223 int *v;
224 unsigned char data[MAX_USER_DATA];
225 };
226
227 // Struttura ausiliaria per la lettura del file ply
228 template<class S>
229 struct LoadPly_VertAux
230 {
231 S p[3];
232 S n[3];
233 int flags;
234 float q;
235 unsigned char r;
236 unsigned char g;
237 unsigned char b;
238 unsigned char data[MAX_USER_DATA];
239 };
240
241 // Struttura ausiliaria caricamento camera
242 struct LoadPly_Camera
243 {
244 float view_px;
245 float view_py;
246 float view_pz;
247 float x_axisx;
248 float x_axisy;
249 float x_axisz;
250 float y_axisx;
251 float y_axisy;
252 float y_axisz;
253 float z_axisx;
254 float z_axisy;
255 float z_axisz;
256 float focal;
257 float scalex;
258 float scaley;
259 float centerx;
260 float centery;
261 int viewportx;
262 int viewporty;
263 float k1;
264 float k2;
265 float k3;
266 float k4;
267 };
268
269 static const PropDescriptor &VertDesc(int i)
270 {
271 static const PropDescriptor pv[15]={
272 /*00*/ {"vertex", "x", ply::T_FLOAT, PlyType<ScalarType>(),offsetof(LoadPly_VertAux<ScalarType>,p),0,0,0,0,0 ,0},
273 /*01*/ {"vertex", "y", ply::T_FLOAT, PlyType<ScalarType>(),offsetof(LoadPly_VertAux<ScalarType>,p) + sizeof(ScalarType),0,0,0,0,0 ,0},
274 /*02*/ {"vertex", "z", ply::T_FLOAT, PlyType<ScalarType>(),offsetof(LoadPly_VertAux<ScalarType>,p) + 2*sizeof(ScalarType),0,0,0,0,0 ,0},
275 /*03*/ {"vertex", "flags", ply::T_INT, ply::T_INT, offsetof(LoadPly_VertAux<ScalarType>,flags),0,0,0,0,0 ,0},
276 /*04*/ {"vertex", "quality", ply::T_FLOAT, ply::T_FLOAT, offsetof(LoadPly_VertAux<ScalarType>,q),0,0,0,0,0 ,0},
277 /*05*/ {"vertex", "red" , ply::T_UCHAR, ply::T_UCHAR, offsetof(LoadPly_VertAux<ScalarType>,r),0,0,0,0,0 ,0},
278 /*06*/ {"vertex", "green", ply::T_UCHAR, ply::T_UCHAR, offsetof(LoadPly_VertAux<ScalarType>,g),0,0,0,0,0 ,0},
279 /*07*/ {"vertex", "blue" , ply::T_UCHAR, ply::T_UCHAR, offsetof(LoadPly_VertAux<ScalarType>,b),0,0,0,0,0 ,0},
280 /*08*/ {"vertex", "diffuse_red" , ply::T_UCHAR, ply::T_UCHAR, offsetof(LoadPly_VertAux<ScalarType>,r),0,0,0,0,0 ,0},
281 /*09*/ {"vertex", "diffuse_green", ply::T_UCHAR, ply::T_UCHAR, offsetof(LoadPly_VertAux<ScalarType>,g),0,0,0,0,0 ,0},
282 /*10*/ {"vertex", "diffuse_blue" , ply::T_UCHAR, ply::T_UCHAR, offsetof(LoadPly_VertAux<ScalarType>,b),0,0,0,0,0 ,0},
283 /*11*/ {"vertex", "confidence",ply::T_FLOAT, ply::T_FLOAT, offsetof(LoadPly_VertAux<ScalarType>,q),0,0,0,0,0 ,0},
284 /*12*/ {"vertex", "nx", ply::T_FLOAT, PlyType<ScalarType>(),offsetof(LoadPly_VertAux<ScalarType>,n),0,0,0,0,0 ,0},
285 /*13*/ {"vertex", "ny", ply::T_FLOAT, PlyType<ScalarType>(),offsetof(LoadPly_VertAux<ScalarType>,n) + sizeof(ScalarType),0,0,0,0,0 ,0},
286 /*14*/ {"vertex", "nz", ply::T_FLOAT, PlyType<ScalarType>(),offsetof(LoadPly_VertAux<ScalarType>,n) + 2*sizeof(ScalarType),0,0,0,0,0 ,0},
287 };
288 return pv[i];
289 }
290
291
292 static const PropDescriptor &FaceDesc(int i)
293 {
294 static const PropDescriptor qf[16]=
295 {
296 /* 0 */ {"face", "vertex_indices", ply::T_INT, ply::T_INT, offsetof(LoadPly_FaceAux,v), 1,0,ply::T_UCHAR,ply::T_UCHAR,offsetof(LoadPly_FaceAux,size) ,0},
297 /* 1 */ {"face", "flags", ply::T_INT, ply::T_INT, offsetof(LoadPly_FaceAux,flags), 0,0,0,0,0 ,0},
298 /* 2 */ {"face", "quality", ply::T_FLOAT, ply::T_FLOAT, offsetof(LoadPly_FaceAux,q), 0,0,0,0,0 ,0},
299 /* 3 */ {"face", "texcoord", ply::T_FLOAT, ply::T_FLOAT, offsetof(LoadPly_FaceAux,texcoord), 1,0,ply::T_UCHAR,ply::T_UCHAR,offsetof(LoadPly_FaceAux,ntexcoord) ,0},
300 /* 4 */ {"face", "color", ply::T_FLOAT, ply::T_FLOAT, offsetof(LoadPly_FaceAux,colors), 1,0,ply::T_UCHAR,ply::T_UCHAR,offsetof(LoadPly_FaceAux,ncolors) ,0},
301 /* 5 */ {"face", "texnumber", ply::T_INT, ply::T_INT, offsetof(LoadPly_FaceAux,texcoordind), 0,0,0,0,0 ,0},
302 /* 6 */ {"face", "red" , ply::T_UCHAR, ply::T_UCHAR, offsetof(LoadPly_FaceAux,r), 0,0,0,0,0 ,0},
303 /* 7 */ {"face", "green", ply::T_UCHAR, ply::T_UCHAR, offsetof(LoadPly_FaceAux,g), 0,0,0,0,0 ,0},
304 /* 8 */ {"face", "blue" , ply::T_UCHAR, ply::T_UCHAR, offsetof(LoadPly_FaceAux,b), 0,0,0,0,0 ,0},
305 /* 9 */ {"face", "vertex_index", ply::T_INT, ply::T_INT, offsetof(LoadPly_FaceAux,v), 1,0,ply::T_UCHAR,ply::T_CHAR,offsetof(LoadPly_FaceAux,size) ,0},
306 /* 10 */ {"face", "vertex_index", ply::T_INT, ply::T_INT, offsetof(LoadPly_FaceAux,v), 1,0,ply::T_CHAR, ply::T_CHAR,offsetof(LoadPly_FaceAux,size) ,0},
307 /* 11 */ {"face", "vertex_index", ply::T_INT, ply::T_INT, offsetof(LoadPly_FaceAux,v), 1,0,ply::T_INT, ply::T_CHAR,offsetof(LoadPly_FaceAux,size) ,0},
308 /* 12 */ {"face", "vertex_indices", ply::T_INT, ply::T_INT, offsetof(LoadPly_FaceAux,v), 1,0,ply::T_CHAR, ply::T_CHAR,offsetof(LoadPly_FaceAux,size) ,0},
309 /* 13 */ {"face", "vertex_indices", ply::T_UINT, ply::T_INT, offsetof(LoadPly_FaceAux,v), 1,0,ply::T_UCHAR,ply::T_CHAR,offsetof(LoadPly_FaceAux,size) ,0},
310 /* 14 */ {"face", "vertex_indices", ply::T_UINT, ply::T_INT, offsetof(LoadPly_FaceAux,v), 1,0,ply::T_INT, ply::T_CHAR,offsetof(LoadPly_FaceAux,size) ,0},
311 /* 15 */ {"face", "vertex_indices", ply::T_INT, ply::T_INT, offsetof(LoadPly_FaceAux,v), 1,0,ply::T_INT, ply::T_CHAR,offsetof(LoadPly_FaceAux,size) ,0},
312 };
313 return qf[i];
314 }
315 static const PropDescriptor &TristripDesc(int i)
316 {
317 static const PropDescriptor qf[1]=
318 {
319 {"tristrips","vertex_indices", ply::T_INT, ply::T_INT, offsetof(LoadPly_TristripAux,v), 1,1,ply::T_INT,ply::T_INT,offsetof(LoadPly_TristripAux,size) ,0},
320 };
321 return qf[i];
322 }
323
324
325 static const PropDescriptor &CameraDesc(int i)
326 {
327 static const PropDescriptor cad[23] =
328 {
329 {"camera","view_px",ply::T_FLOAT,ply::T_FLOAT,offsetof(LoadPly_Camera,view_px),0,0,0,0,0 ,0},
330 {"camera","view_py",ply::T_FLOAT,ply::T_FLOAT,offsetof(LoadPly_Camera,view_py),0,0,0,0,0 ,0},
331 {"camera","view_pz",ply::T_FLOAT,ply::T_FLOAT,offsetof(LoadPly_Camera,view_pz),0,0,0,0,0 ,0},
332 {"camera","x_axisx",ply::T_FLOAT,ply::T_FLOAT,offsetof(LoadPly_Camera,x_axisx),0,0,0,0,0 ,0},
333 {"camera","x_axisy",ply::T_FLOAT,ply::T_FLOAT,offsetof(LoadPly_Camera,x_axisy),0,0,0,0,0 ,0},
334 {"camera","x_axisz",ply::T_FLOAT,ply::T_FLOAT,offsetof(LoadPly_Camera,x_axisz),0,0,0,0,0 ,0},
335 {"camera","y_axisx",ply::T_FLOAT,ply::T_FLOAT,offsetof(LoadPly_Camera,y_axisx),0,0,0,0,0 ,0},
336 {"camera","y_axisy",ply::T_FLOAT,ply::T_FLOAT,offsetof(LoadPly_Camera,y_axisy),0,0,0,0,0 ,0},
337 {"camera","y_axisz",ply::T_FLOAT,ply::T_FLOAT,offsetof(LoadPly_Camera,y_axisz),0,0,0,0,0 ,0},
338 {"camera","z_axisx",ply::T_FLOAT,ply::T_FLOAT,offsetof(LoadPly_Camera,z_axisx),0,0,0,0,0 ,0},
339 {"camera","z_axisy",ply::T_FLOAT,ply::T_FLOAT,offsetof(LoadPly_Camera,z_axisy),0,0,0,0,0 ,0},
340 {"camera","z_axisz",ply::T_FLOAT,ply::T_FLOAT,offsetof(LoadPly_Camera,z_axisz),0,0,0,0,0 ,0},
341 {"camera","focal" ,ply::T_FLOAT,ply::T_FLOAT,offsetof(LoadPly_Camera,focal ),0,0,0,0,0 ,0},
342 {"camera","scalex" ,ply::T_FLOAT,ply::T_FLOAT,offsetof(LoadPly_Camera,scalex ),0,0,0,0,0 ,0},
343 {"camera","scaley" ,ply::T_FLOAT,ply::T_FLOAT,offsetof(LoadPly_Camera,scaley ),0,0,0,0,0 ,0},
344 {"camera","centerx",ply::T_FLOAT,ply::T_FLOAT,offsetof(LoadPly_Camera,centerx),0,0,0,0,0 ,0},
345 {"camera","centery",ply::T_FLOAT,ply::T_FLOAT,offsetof(LoadPly_Camera,centery),0,0,0,0,0 ,0},
346 {"camera","viewportx",ply::T_INT,ply::T_INT ,offsetof(LoadPly_Camera,viewportx),0,0,0,0,0 ,0},
347 {"camera","viewporty",ply::T_INT,ply::T_INT ,offsetof(LoadPly_Camera,viewporty),0,0,0,0,0 ,0},
348 {"camera","k1" ,ply::T_FLOAT,ply::T_FLOAT,offsetof(LoadPly_Camera,k1 ),0,0,0,0,0 ,0},
349 {"camera","k2" ,ply::T_FLOAT,ply::T_FLOAT,offsetof(LoadPly_Camera,k2 ),0,0,0,0,0 ,0},
350 {"camera","k3" ,ply::T_FLOAT,ply::T_FLOAT,offsetof(LoadPly_Camera,k3 ),0,0,0,0,0 ,0},
351 {"camera","k4" ,ply::T_FLOAT,ply::T_FLOAT,offsetof(LoadPly_Camera,k4 ),0,0,0,0,0 ,0}
352 };
353 return cad[i];
354 }
355 /// Standard call for knowing the meaning of an error code
356 static const char *ErrorMsg(int error)
357 {
358 static std::vector<std::string> ply_error_msg;
359 if(ply_error_msg.empty())
360 {
361 ply_error_msg.resize(PlyInfo::E_MAXPLYINFOERRORS );
362 ply_error_msg[ply::E_NOERROR ]="No errors";
363 ply_error_msg[ply::E_CANTOPEN ]="Can't open file";
364 ply_error_msg[ply::E_NOTHEADER ]="Header not found";
365 ply_error_msg[ply::E_UNESPECTEDEOF ]="Eof in header";
366 ply_error_msg[ply::E_NOFORMAT ]="Format not found";
367 ply_error_msg[ply::E_SYNTAX ]="Syntax error on header";
368 ply_error_msg[ply::E_PROPOUTOFELEMENT]="Property without element";
369 ply_error_msg[ply::E_BADTYPENAME ]="Bad type name";
370 ply_error_msg[ply::E_ELEMNOTFOUND ]="Element not found";
371 ply_error_msg[ply::E_PROPNOTFOUND ]="Property not found";
372 ply_error_msg[ply::E_BADTYPE ]="Bad type on addtoread";
373 ply_error_msg[ply::E_INCOMPATIBLETYPE]="Incompatible type";
374 ply_error_msg[ply::E_BADCAST ]="Bad cast";
375
376 ply_error_msg[PlyInfo::E_NO_VERTEX ]="No vertex field found";
377 ply_error_msg[PlyInfo::E_NO_FACE ]="No face field found";
378 ply_error_msg[PlyInfo::E_SHORTFILE ]="Unespected eof";
379 ply_error_msg[PlyInfo::E_NO_3VERTINFACE ]="Face with more than 3 vertices";
380 ply_error_msg[PlyInfo::E_BAD_VERT_INDEX ]="Bad vertex index in face";
381 ply_error_msg[PlyInfo::E_NO_6TCOORD ]="Face with no 6 texture coordinates";
382 ply_error_msg[PlyInfo::E_DIFFER_COLORS ]="Number of color differ from vertices";
383 }
384
385 if(error>PlyInfo::E_MAXPLYINFOERRORS || error<0) return "Unknown error";
386 else return ply_error_msg[error].c_str();
387 };
388
389
390 /// Standard call for reading a mesh
391 static int Open( OpenMeshType &m, const char * filename, CallBackPos *cb=0)
392 {
393 PlyInfo pi;
394 pi.cb=cb;
395 return Open(m, filename, pi);
396 }
397
398 /// Read a mesh and store in loadmask the loaded field
399 /// Note that loadmask is not read! just modified. You cannot specify what fields
400 /// have to be read. ALL the data for which your mesh HasSomething and are present
401 /// in the file are read in.
402 static int Open( OpenMeshType &m, const char * filename, int & loadmask, CallBackPos *cb =0)
403 {
404 PlyInfo pi;
405 pi.cb=cb;
406 int r = Open(m, filename,pi);
407 loadmask=pi.mask;
408 return r;
409 }
410
411
412 /// read a mesh with all the possible option specified in the PlyInfo obj.
413 static int Open( OpenMeshType &m, const char * filename, PlyInfo &pi )
414 {
415 assert(filename!=0);
416 std::vector<VertexPointer> index;
417 LoadPly_FaceAux fa;
418 LoadPly_TristripAux tsa;
419 LoadPly_VertAux<ScalarType> va;
420
421 pi.mask = 0;
422 bool multit = false; // true if texture has a per face int spec the texture index
423
424 va.flags = 42;
425
426 pi.status = ::vcg::ply::E_NOERROR;
427
428 // init defaults
429 VertexType tv;
430 //tv.ClearFlags();
431 if( VertexType::HasQuality() ) tv.Q()=(typename OpenMeshType::VertexType::QualityType)1.0;
432 if( VertexType::HasColor() ) tv.C()=Color4b(Color4b::White);
433
434 // Descrittori delle strutture
435
436 //bool isvflags = false; // Il file contiene i flags
437
438
439 // The main descriptor of the ply file
440 vcg::ply::PlyFile pf;
441
442 // Open the file and parse the header
443 if( pf.Open(filename,vcg::ply::PlyFile::MODE_READ)==-1 )
444 {
445 pi.status = pf.GetError();
446 return pi.status;
447 }
448 pi.header = pf.GetHeader();
449
450 // Descrittori della camera
451 { // Check that all the camera properties are present.
452 bool found = true;
453 for(int i=0;i<23;++i)
454 {
455 if( pf.AddToRead(CameraDesc(i))==-1 ) {
456 found = false;
457 break;
458 }
459 }
460 if(found) pi.mask |= Mask::IOM_CAMERA;
461 }
462
463 // Descrittori dati standard (vertex coord e faces)
464 if( pf.AddToRead(VertDesc(0))==-1 ) { pi.status = PlyInfo::E_NO_VERTEX; return pi.status; }
465 if( pf.AddToRead(VertDesc(1))==-1 ) { pi.status = PlyInfo::E_NO_VERTEX; return pi.status; }
466 if( pf.AddToRead(VertDesc(2))==-1 ) { pi.status = PlyInfo::E_NO_VERTEX; return pi.status; }
467 if( pf.AddToRead(FaceDesc(0))==-1 ) // Se fallisce si prova anche la sintassi di rapidform con index al posto di indices
468 {
469 int ii; const int FaceVariantNum = 7;
470 for(ii=0;ii< FaceVariantNum;++ii)
471 if( pf.AddToRead(FaceDesc(9+ii))!=-1 ) break;
472 if(ii==FaceVariantNum) if(pf.AddToRead(TristripDesc(0))==-1) // Se fallisce tutto si prova a vedere se ci sono tristrip alla levoy.
473 { pi.status = PlyInfo::E_NO_FACE; return pi.status; }
474 }
475 // Descrittori facoltativi dei flags
476
477 if(VertexType::HasFlags() && pf.AddToRead(VertDesc(3))!=-1 )
478 pi.mask |= Mask::IOM_VERTFLAGS;
479
480 if( VertexType::HasNormal() )
481 {
482 if( pf.AddToRead(VertDesc(12))!=-1
483 && pf.AddToRead(VertDesc(13))!=-1
484 && pf.AddToRead(VertDesc(14))!=-1 )
485 pi.mask |= Mask::IOM_VERTNORMAL;
486 }
487
488 if( VertexType::HasQuality() )
489 {
490 if( pf.AddToRead(VertDesc(4))!=-1 ||
491 pf.AddToRead(VertDesc(11))!=-1 )
492 pi.mask |= Mask::IOM_VERTQUALITY;
493 }
494
495 if( VertexType::HasColor() )
496 {
497 if( pf.AddToRead(VertDesc(5))!=-1 )
498 {
499 pf.AddToRead(VertDesc(6));
500 pf.AddToRead(VertDesc(7));
501 pi.mask |= Mask::IOM_VERTCOLOR;
502 }
503 if( pf.AddToRead(VertDesc(8))!=-1 )
504 {
505 pf.AddToRead(VertDesc(9));
506 pf.AddToRead(VertDesc(10));
507 pi.mask |= Mask::IOM_VERTCOLOR;
508 }
509 }
510
511 // se ci sono i flag per vertice ci devono essere anche i flag per faccia
512 if( pf.AddToRead(FaceDesc(1))!=-1 )
513 pi.mask |= Mask::IOM_FACEFLAGS;
514
515 if( FaceType::HasFaceQuality())
516 {
517 if( pf.AddToRead(FaceDesc(2))!=-1 )
518 pi.mask |= Mask::IOM_FACEQUALITY;
519 }
520
521 if( FaceType::HasFaceColor() )
522 {
523 if( pf.AddToRead(FaceDesc(6))!=-1 )
524 {
525 pf.AddToRead(FaceDesc(7));
526 pf.AddToRead(FaceDesc(8));
527 pi.mask |= Mask::IOM_FACECOLOR;
528 }
529 }
530
531
532 if( FaceType::HasWedgeTexCoord() )
533 {
534 if( pf.AddToRead(FaceDesc(3))!=-1 )
535 {
536 if(pf.AddToRead(FaceDesc(5))==0) {
537 multit=true; // try to read also the multi texture indicies
538 pi.mask |= Mask::IOM_WEDGTEXMULTI;
539 }
540 pi.mask |= Mask::IOM_WEDGTEXCOORD;
541 }
542 }
543
544 if( FaceType::HasWedgeColor() || FaceType::HasFaceColor() || VertexType::HasColor())
545 {
546 if( pf.AddToRead(FaceDesc(4))!=-1 )
547 {
548 pi.mask |= Mask::IOM_WEDGCOLOR;
549 }
550 }
551
552 // Descrittori definiti dall'utente,
553 std::vector<PropDescriptor> VPV(pi.vdn); // property descriptor relative al tipo LoadPly_VertexAux
554 std::vector<PropDescriptor> FPV(pi.fdn); // property descriptor relative al tipo LoadPly_FaceAux
555 if(pi.vdn>0){
556 // Compute the total size needed to load additional per vertex data.
557 size_t totsz=0;
558 for(int i=0;i<pi.vdn;i++){
559 VPV[i] = pi.VertexData[i];
560 VPV[i].offset1=offsetof(LoadPly_VertAux<ScalarType>,data)+totsz;
561 totsz+=pi.VertexData[i].memtypesize();
562 if( pf.AddToRead(VPV[i])==-1 ) { pi.status = pf.GetError(); return pi.status; }
563 }
564 if(totsz > MAX_USER_DATA)
565 {
566 pi.status = vcg::ply::E_BADTYPE;
567 return pi.status;
568 }
569 }
570 if(pi.fdn>0){
571 size_t totsz=0;
572 for(int i=0;i<pi.fdn;i++){
573 FPV[i] = pi.FaceData[i];
574 FPV[i].offset1=offsetof(LoadPly_FaceAux,data)+totsz;
575 totsz+=pi.FaceData[i].memtypesize();
576 if( pf.AddToRead(FPV[i])==-1 ) { pi.status = pf.GetError(); return pi.status; }
577 }
578 if(totsz > MAX_USER_DATA)
579 {
580 pi.status = vcg::ply::E_BADTYPE;
581 return pi.status;
582 }
583 }
584
585 /**************************************************************/
586 /* Main Reading Loop */
587 /**************************************************************/
588 m.Clear();
589 for(int i=0;i<int(pf.elements.size());i++)
590 {
591 int n = pf.ElemNumber(i);
592
593 if( !strcmp( pf.ElemName(i),"camera" ) )
594 {
595 pf.SetCurElement(i);
596
597 LoadPly_Camera ca;
598
599 for(int j=0;j<n;++j)
600 {
601 if( pf.Read( (void *)&(ca) )==-1 )
602 {
603 pi.status = PlyInfo::E_SHORTFILE;
604 return pi.status;
605 }
606 //camera.valid = true;
607
608 // extrinsic
609 m.shot.Extrinsics.SetIdentity();
610 // view point
611 m.shot.Extrinsics.tra[0] = -ca.view_px;
612 m.shot.Extrinsics.tra[1] = -ca.view_py;
613 m.shot.Extrinsics.tra[2] = -ca.view_pz;
614
615 // axis (i.e. rotation).
616 m.shot.Extrinsics.rot[0][0] = ca.x_axisx;
617 m.shot.Extrinsics.rot[0][1] = ca.x_axisy;
618 m.shot.Extrinsics.rot[0][2] = ca.x_axisz;
619
620 m.shot.Extrinsics.rot[1][0] = ca.y_axisx;
621 m.shot.Extrinsics.rot[1][1] = ca.y_axisy;
622 m.shot.Extrinsics.rot[1][2] = ca.y_axisz;
623
624 m.shot.Extrinsics.rot[2][0] = ca.z_axisx;
625 m.shot.Extrinsics.rot[2][1] = ca.z_axisy;
626 m.shot.Extrinsics.rot[2][2] = ca.z_axisz;
627
628 //intrinsic
629 m.shot.Intrinsics.FocalMm = ca.focal;
630 m.shot.Intrinsics.PixelSizeMm[0] = ca.scalex;
631 m.shot.Intrinsics.PixelSizeMm[1] = ca.scaley;
632 m.shot.Intrinsics.CenterPx[0] = ca.centerx;
633 m.shot.Intrinsics.CenterPx[1] = ca.centery;
634 m.shot.Intrinsics.ViewportPx[0] = ca.viewportx;
635 m.shot.Intrinsics.ViewportPx[1] = ca.viewporty;
636 m.shot.Intrinsics.k[0] = ca.k1;
637 m.shot.Intrinsics.k[1] = ca.k2;
638 m.shot.Intrinsics.k[2] = ca.k3;
639 m.shot.Intrinsics.k[3] = ca.k4;
640
641 }
642 }
643 else if( !strcmp( pf.ElemName(i),"vertex" ) )
644 {
645 int j;
646
647 pf.SetCurElement(i);
648 VertexIterator vi=Allocator<OpenMeshType>::AddVertices(m,n);
649
650 for(j=0;j<n;++j)
651 {
652 if(pi.cb && (j%1000)==0) pi.cb(j*50/n,"Vertex Loading");
653 //(*vi).UberFlags()=0; // No more necessary, since 9/2005 flags are set to zero in the constuctor.
654 if( pf.Read( (void *)&(va) )==-1 )
655 {
656 pi.status = PlyInfo::E_SHORTFILE;
657 return pi.status;
658 }
659
660 (*vi).P()[0] = va.p[0];
661 (*vi).P()[1] = va.p[1];
662 (*vi).P()[2] = va.p[2];
663
664 if( m.HasPerVertexFlags() && (pi.mask & Mask::IOM_VERTFLAGS) )
665 (*vi).UberFlags() = va.flags;
666
667 if( pi.mask & Mask::IOM_VERTQUALITY )
668 (*vi).Q() = (typename OpenMeshType::VertexType::QualityType)va.q;
669
670 if( pi.mask & Mask::IOM_VERTNORMAL )
671 {
672 (*vi).N()[0]=va.n[0];
673 (*vi).N()[1]=va.n[1];
674 (*vi).N()[2]=va.n[2];
675 }
676
677 if( pi.mask & Mask::IOM_VERTCOLOR )
678 {
679 (*vi).C()[0] = va.r;
680 (*vi).C()[1] = va.g;
681 (*vi).C()[2] = va.b;
682 (*vi).C()[3] = 255;
683 }
684
685
686 for(int k=0;k<pi.vdn;k++)
687 memcpy((char *)(&*vi) + pi.VertexData[k].offset1,
688 (char *)(&va) + VPV[k].offset1,
689 VPV[k].memtypesize());
690 ++vi;
691 }
692
693 index.resize(n);
694 for(j=0,vi=m.vert.begin();j<n;++j,++vi)
695 index[j] = &*vi;
696 }
697 else if( !strcmp( pf.ElemName(i),"face") && (n>0) )/************************************************************/
698 {
699 int j;
700
701 FaceIterator fi=Allocator<OpenMeshType>::AddFaces(m,n);
702 pf.SetCurElement(i);
703
704 for(j=0;j<n;++j)
705 {
706 int k;
707
708 if(pi.cb && (j%1000)==0) pi.cb(50+j*50/n,"Face Loading");
709 if( pf.Read(&fa)==-1 )
710 {
711 pi.status = PlyInfo::E_SHORTFILE;
712 return pi.status;
713 }
714 if(fa.size!=3)
715 { // Non triangular face are manageable ONLY if there are no Per Wedge attributes
716 if( ( pi.mask & Mask::IOM_WEDGCOLOR ) || ( pi.mask & Mask::IOM_WEDGTEXCOORD ) )
717 {
718 pi.status = PlyInfo::E_NO_3VERTINFACE;
719 return pi.status;
720 }
721 }
722
723 if(m.HasPerFaceFlags() &&( pi.mask & Mask::IOM_FACEFLAGS) )
724 {
725 (*fi).UberFlags() = fa.flags;
726 }
727
728 if( pi.mask & Mask::IOM_FACEQUALITY )
729 {
730 (*fi).Q() = (typename OpenMeshType::FaceType::QualityType) fa.q;
731 }
732
733 if( pi.mask & Mask::IOM_FACECOLOR )
734 {
735 (*fi).C()[0] = fa.r;
736 (*fi).C()[1] = fa.g;
737 (*fi).C()[2] = fa.b;
738 (*fi).C()[3] = 255;
739 }
740
741 if( pi.mask & Mask::IOM_WEDGTEXCOORD )
742 {
743 for(int k=0;k<3;++k)
744 {
745 (*fi).WT(k).u() = fa.texcoord[k*2+0];
746 (*fi).WT(k).v() = fa.texcoord[k*2+1];
747 if(multit) (*fi).WT(k).n() = fa.texcoordind;
748 else (*fi).WT(k).n()=0; // safely intialize texture index
749 }
750 }
751
752 if( pi.mask & Mask::IOM_WEDGCOLOR )
753 {
754 if(FaceType::HasWedgeColor()){
755 for(int k=0;k<3;++k)
756 {
757 (*fi).WC(k)[0] = (unsigned char)(fa.colors[k*3+0]*255);
758 (*fi).WC(k)[1] = (unsigned char)(fa.colors[k*3+1]*255);
759 (*fi).WC(k)[2] = (unsigned char)(fa.colors[k*3+2]*255);
760 }
761 }
762 //if(FaceType::HasFaceColor()){
763 //if(pi.mask & Mask::IOM_FACECOLOR){
764 if(HasPerFaceColor(m)) {
765 (*fi).C()[0] = (unsigned char)((fa.colors[0*3+0]*255+fa.colors[1*3+0]*255+fa.colors[2*3+0]*255)/3.0f);
766 (*fi).C()[1] = (unsigned char)((fa.colors[0*3+1]*255+fa.colors[1*3+1]*255+fa.colors[2*3+1]*255)/3.0f);
767 (*fi).C()[2] = (unsigned char)((fa.colors[0*3+2]*255+fa.colors[1*3+2]*255+fa.colors[2*3+2]*255)/3.0f);
768 }
769 }
770 /// Now the temporary struct 'fa' is ready to be copied into the real face '*fi'
771 /// This loop
772 for(k=0;k<3;++k)
773 {
774 if( fa.v[k]<0 || fa.v[k]>=m.vn )
775 {
776 pi.status = PlyInfo::E_BAD_VERT_INDEX;
777 return pi.status;
778 }
779 (*fi).V(k) = index[ fa.v[k] ];
780 }
781
782 for(k=0;k<pi.fdn;k++)
783 memcpy((char *)(&(*fi)) + pi.FaceData[k].offset1,
784 (char *)(&fa) + FPV[k].offset1,
785 FPV[k].memtypesize());
786 ++fi;
787
788 // Non Triangular Faces Loop
789 // It performs a simple fan triangulation.
790 if(fa.size>3)
791 {
792 int curpos=int(fi-m.face.begin());
793 Allocator<OpenMeshType>::AddFaces(m,fa.size-3);
794 fi=m.face.begin()+curpos;
795 }
796 for(int qq=0;qq<fa.size-3;++qq)
797 {
798 (*fi).V(0) = index[ fa.v[0] ];
799 for(k=1;k<3;++k)
800 {
801 if( fa.v[2+qq]<0 || fa.v[2+qq]>=m.vn )
802 {
803 pi.status = PlyInfo::E_BAD_VERT_INDEX;
804 return pi.status;
805 }
806 (*fi).V(k) = index[ fa.v[1+qq+k] ];
807 }
808
809 for(k=0;k<pi.fdn;k++)
810 memcpy((char *)(&(*fi)) + pi.FaceData[k].offset1,
811 (char *)(&fa) + FPV[k].offset1, FPV[k].memtypesize());
812 ++fi;
813 }
814
815 }
816 }else if( !strcmp( pf.ElemName(i),"tristrips") )//////////////////// LETTURA TRISTRIP DI STANFORD
817 {
818 // Warning the parsing of tristrips could not work if OCF types are used
819 FaceType tf;
820 if( FaceType::HasFaceQuality() ) tf.Q()=(typename OpenMeshType::FaceType::QualityType)1.0;
821 if( FaceType::HasWedgeColor() ) tf.WC(0)=tf.WC(1)=tf.WC(2)=Color4b(Color4b::White);
822 if( HasPerFaceColor(m) ) tf.C()=Color4b(Color4b::White);
823
824 int j;
825 pf.SetCurElement(i);
826 int numvert_tmp = (int)m.vert.size();
827 for(j=0;j<n;++j)
828 {
829 int k;
830 if(pi.cb && (j%1000)==0) pi.cb(50+j*50/n,"Tristrip Face Loading");
831 if( pf.Read(&tsa)==-1 )
832 {
833 pi.status = PlyInfo::E_SHORTFILE;
834 return pi.status;
835 }
836 int remainder=0;
837 //int startface=m.face.size();
838 for(k=0;k<tsa.size-2;++k)
839 {
840 if(pi.cb && (k%1000)==0) pi.cb(50+k*50/tsa.size,"Tristrip Face Loading");
841 if(tsa.v[k]<0 || tsa.v[k]>=numvert_tmp ) {
842 pi.status = PlyInfo::E_BAD_VERT_INDEX;
843 return pi.status;
844 }
845 if(tsa.v[k+2]==-1)
846 {
847 k+=2;
848 if(k%2) remainder=0;
849 else remainder=1;
850 continue;
851 }
852 tf.V(0) = index[ tsa.v[k+0] ];
853 tf.V(1) = index[ tsa.v[k+1] ];
854 tf.V(2) = index[ tsa.v[k+2] ];
855 if((k+remainder)%2) math::Swap (tf.V(0), tf.V(1) );
856 m.face.push_back( tf );
857 }
858 }
859 }
860 else
861 {
862 // Skippaggio elementi non gestiti
863 int n = pf.ElemNumber(i);
864 pf.SetCurElement(i);
865
866 for(int j=0;j<n;j++)
867 {
868 if( pf.Read(0)==-1)
869 {
870 pi.status = PlyInfo::E_SHORTFILE;
871 return pi.status;
872 }
873 }
874 }
875 }
876
877 // Parsing texture names
878 m.textures.clear();
879 m.normalmaps.clear();
880
881 for(int co=0;co<int(pf.comments.size());++co)
882 {
883 std::string TFILE = "TextureFile";
884 std::string NFILE = "TextureNormalFile";
885 std::string &c = pf.comments[co];
886 // char buf[256];
887 std::string bufstr,bufclean;
888 int i,n;
889
890 if( TFILE == c.substr(0,TFILE.length()) )
891 {
892 bufstr = c.substr(TFILE.length()+1);
893 n = static_cast<int>(bufstr.length());
894 for(i=0;i<n;i++)
895 if( bufstr[i]!=' ' && bufstr[i]!='\t' && bufstr[i]>32 && bufstr[i]<125 ) bufclean.push_back(bufstr[i]);
896
897 char buf2[255];
898 ply::interpret_texture_name( bufclean.c_str(),filename,buf2 );
899 m.textures.push_back( std::string(buf2) );
900 }
901 /*if( !strncmp(c,NFILE,strlen(NFILE)) )
902 {
903 strcpy(buf,c+strlen(NFILE)+1);
904 n = strlen(buf);
905 for(i=j=0;i<n;i++)
906 if( buf[i]!=' ' && buf[i]!='\t' && buf[i]>32 && buf[i]<125 ) buf[j++] = buf[i];
907
908 buf[j] = 0;
909 char buf2[255];
910 __interpret_texture_name( buf,filename,buf2 );
911 m.normalmaps.push_back( string(buf2) );
912 }*/
913 }
914
915 // vn and fn should be correct but if someone wrongly saved some deleted elements they can be wrong.
916 m.vn = 0;
917 VertexIterator vi;
918 for(vi=m.vert.begin();vi!=m.vert.end();++vi)
919 if( ! (*vi).IsD() )
920 ++m.vn;
921
922 m.fn = 0;
923 FaceIterator fi;
924 for(fi=m.face.begin();fi!=m.face.end();++fi)
925 if( ! (*fi).IsD() )
926 ++m.fn;
927
928 return 0;
929 }
930
931
932 // Caricamento camera da un ply
933 int LoadCamera(const char * filename)
934 {
935 vcg::ply::PlyFile pf;
936 if( pf.Open(filename,vcg::ply::PlyFile::MODE_READ)==-1 )
937 {
938 this->pi.status = pf.GetError();
939 return this->pi.status;
940 }
941
942
943 bool found = true;
944 int i;
945 for(i=0;i<23;++i)
946 {
947 if( pf.AddToRead(CameraDesc(i))==-1 )
948 {
949 found = false;
950 break;
951 }
952 }
953
954 if(!found)
955 return this->pi.status;
956
957 for(i=0;i<int(pf.elements.size());i++)
958 {
959 int n = pf.ElemNumber(i);
960
961 if( !strcmp( pf.ElemName(i),"camera" ) )
962 {
963 pf.SetCurElement(i);
964
965 LoadPly_Camera ca;
966
967 for(int j=0;j<n;++j)
968 {
969 if( pf.Read( (void *)&(ca) )==-1 )
970 {
971 this->pi.status = PlyInfo::E_SHORTFILE;
972 return this->pi.status;
973 }
974 this->camera.valid = true;
975 this->camera.view_p[0] = ca.view_px;
976 this->camera.view_p[1] = ca.view_py;
977 this->camera.view_p[2] = ca.view_pz;
978 this->camera.x_axis[0] = ca.x_axisx;
979 this->camera.x_axis[1] = ca.x_axisy;
980 this->camera.x_axis[2] = ca.x_axisz;
981 this->camera.y_axis[0] = ca.y_axisx;
982 this->camera.y_axis[1] = ca.y_axisy;
983 this->camera.y_axis[2] = ca.y_axisz;
984 this->camera.z_axis[0] = ca.z_axisx;
985 this->camera.z_axis[1] = ca.z_axisy;
986 this->camera.z_axis[2] = ca.z_axisz;
987 this->camera.f = ca.focal;
988 this->camera.s[0] = ca.scalex;
989 this->camera.s[1] = ca.scaley;
990 this->camera.c[0] = ca.centerx;
991 this->camera.c[1] = ca.centery;
992 this->camera.viewport[0] = ca.viewportx;
993 this->camera.viewport[1] = ca.viewporty;
994 this->camera.k[0] = ca.k1;
995 this->camera.k[1] = ca.k2;
996 this->camera.k[2] = ca.k3;
997 this->camera.k[3] = ca.k4;
998 }
999 break;
1000 }
1001 }
1002
1003 return 0;
1004 }
1005
1006
1007 static bool LoadMask(const char * filename, int &mask)
1008 {
1009 PlyInfo pi;
1010 return LoadMask(filename, mask,pi);
1011 }
1012 static bool LoadMask(const char * filename, int &mask, PlyInfo &pi)
1013 {
1014 mask=0;
1015 vcg::ply::PlyFile pf;
1016 if( pf.Open(filename,vcg::ply::PlyFile::MODE_READ)==-1 )
1017 {
1018 pi.status = pf.GetError();
1019 return false;
1020 }
1021
1022 if( pf.AddToRead(VertDesc(0))!=-1 &&
1023 pf.AddToRead(VertDesc(1))!=-1 &&
1024 pf.AddToRead(VertDesc(2))!=-1 ) mask |= Mask::IOM_VERTCOORD;
1025
1026 if( pf.AddToRead(VertDesc(12))!=-1 &&
1027 pf.AddToRead(VertDesc(13))!=-1 &&
1028 pf.AddToRead(VertDesc(14))!=-1 ) mask |= Mask::IOM_VERTNORMAL;
1029
1030 if( pf.AddToRead(VertDesc(3))!=-1 ) mask |= Mask::IOM_VERTFLAGS;
1031 if( pf.AddToRead(VertDesc(4))!=-1 ) mask |= Mask::IOM_VERTQUALITY;
1032 if( pf.AddToRead(VertDesc(11))!=-1 ) mask |= Mask::IOM_VERTQUALITY;
1033 if( ( pf.AddToRead(VertDesc(5))!=-1 ) &&
1034 ( pf.AddToRead(VertDesc(6))!=-1 ) &&
1035 ( pf.AddToRead(VertDesc(7))!=-1 ) ) mask |= Mask::IOM_VERTCOLOR;
1036
1037 if( pf.AddToRead(FaceDesc(0))!=-1 ) mask |= Mask::IOM_FACEINDEX;
1038 if( pf.AddToRead(FaceDesc(1))!=-1 ) mask |= Mask::IOM_FACEFLAGS;
1039
1040 if( pf.AddToRead(FaceDesc(2))!=-1 ) mask |= Mask::IOM_FACEQUALITY;
1041 if( pf.AddToRead(FaceDesc(3))!=-1 ) mask |= Mask::IOM_WEDGTEXCOORD;
1042 if( pf.AddToRead(FaceDesc(5))!=-1 ) mask |= Mask::IOM_WEDGTEXMULTI;
1043 if( pf.AddToRead(FaceDesc(4))!=-1 ) mask |= Mask::IOM_WEDGCOLOR;
1044 if( ( pf.AddToRead(FaceDesc(6))!=-1 ) &&
1045 ( pf.AddToRead(FaceDesc(7))!=-1 ) &&
1046 ( pf.AddToRead(FaceDesc(8))!=-1 ) ) mask |= Mask::IOM_FACECOLOR;
1047
1048
1049 return true;
1050 }
1051
1052
1053 }; // end class
1054
1055
1056
1057 } // end namespace tri
1058 } // end namespace io
1059 } // end namespace vcg
1060
1061 #endif