Debian Codegraph @

vcg/wrap/io_trimesh/export_iv.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
25
26 /** Function to save in Inventor format file.
27 @param filename Name of the new inventor file
28 */
29 void Save_Iv(const char * filename)
30 {
31 FILE *fp;
32 fp = fopen(filename,"wb");
33 fprintf(fp,"#Inventor V2.1 ascii \n" );
34 fprintf(fp," \n" );
35 fprintf(fp,"Separator { \n " );
36 fprintf(fp,"ShapeHints {\n");
37 fprintf(fp,"vertexOrdering COUNTERCLOCKWISE\n");
38 fprintf(fp,"shapeType UNKNOWN_SHAPE_TYPE\n");
39 fprintf(fp,"}\n");
40 fprintf(fp,"MaterialBinding {\n");
41 fprintf(fp," value PER_FACE\n");
42 fprintf(fp,"}\n");
43 fprintf(fp,"Material{\n");
44 fprintf(fp," diffuseColor [\n");
45 fprintf(fp," ]\n");
46 fprintf(fp,"}\n");
47
48 fprintf(fp,"Coordinate3 { \n " );
49 fprintf(fp,"point [ " );
50
51 face_iterator fi;
52 vertex_iterator vi;
53 map<vertex_pointer,int> index;
54 int ind;
55 for(ind=0,vi=vert.begin(); vi!=vert.end(); ++vi,++ind)
56 {
57 fprintf(fp,"%f%s",(*vi).P()[0]," " );
58 fprintf(fp,"%f%s",(*vi).P()[1]," " );
59 fprintf(fp,"%f%s",(*vi).P()[2],",\n");
60 index[&*vi] = ind;
61 }
62 fprintf(fp," ] \n" );
63 fprintf(fp,"} \n" );
64
65 fprintf(fp,"IndexedFaceSet { \n" );
66 fprintf(fp,"coordIndex [ " );
67 for (fi=face.begin(); fi!=face.end(); ++fi)
68 {
69 for (int j = 0; j < 3; j++)
70 fprintf(fp,"%i%s",index[(*fi).V(j)],", ");
71 fprintf(fp,"%s","-1, \n");
72 }
73 fprintf(fp," ] \n" );
74 fprintf(fp," } \n" );
75 fprintf(fp," } \n" );
76
77 fclose(fp);
78 }