export_iv.h
Go to the documentation of this file.
00001 /****************************************************************************
00002 * VCGLib                                                            o o     *
00003 * Visual and Computer Graphics Library                            o     o   *
00004 *                                                                _   O  _   *
00005 * Copyright(C) 2004                                                \/)\/    *
00006 * Visual Computing Lab                                            /\/|      *
00007 * ISTI - Italian National Research Council                           |      *
00008 *                                                                    \      *
00009 * All rights reserved.                                                      *
00010 *                                                                           *
00011 * This program is free software; you can redistribute it and/or modify      *   
00012 * it under the terms of the GNU General Public License as published by      *
00013 * the Free Software Foundation; either version 2 of the License, or         *
00014 * (at your option) any later version.                                       *
00015 *                                                                           *
00016 * This program is distributed in the hope that it will be useful,           *
00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of            *
00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             *
00019 * GNU General Public License (http://www.gnu.org/licenses/gpl.txt)          *
00020 * for more details.                                                         *
00021 *                                                                           *
00022 ****************************************************************************/
00023 
00024 
00025 
00029 void Save_Iv(const char * filename) 
00030 {
00031   FILE *fp;
00032   fp = fopen(filename,"wb");
00033   fprintf(fp,"#Inventor V2.1 ascii \n" );
00034   fprintf(fp," \n" );
00035   fprintf(fp,"Separator { \n " );
00036   fprintf(fp,"ShapeHints {\n");
00037   fprintf(fp,"vertexOrdering  COUNTERCLOCKWISE\n");
00038   fprintf(fp,"shapeType       UNKNOWN_SHAPE_TYPE\n");
00039   fprintf(fp,"}\n");
00040   fprintf(fp,"MaterialBinding {\n");
00041   fprintf(fp,"  value PER_FACE\n");
00042   fprintf(fp,"}\n");
00043   fprintf(fp,"Material{\n");
00044   fprintf(fp,"  diffuseColor [\n");
00045   fprintf(fp,"  ]\n");
00046   fprintf(fp,"}\n");
00047   
00048   fprintf(fp,"Coordinate3 { \n " );
00049   fprintf(fp,"point [  " );
00050 
00051         face_iterator fi;
00052         vertex_iterator vi;
00053         map<vertex_pointer,int> index;
00054         int ind;
00055         for(ind=0,vi=vert.begin(); vi!=vert.end(); ++vi,++ind)
00056         {
00057                 fprintf(fp,"%f%s",(*vi).P()[0]," " );
00058     fprintf(fp,"%f%s",(*vi).P()[1]," " );
00059                 fprintf(fp,"%f%s",(*vi).P()[2],",\n");
00060                 index[&*vi] = ind;
00061         }
00062   fprintf(fp," ] \n" );
00063   fprintf(fp,"} \n" ); 
00064 
00065   fprintf(fp,"IndexedFaceSet { \n" );
00066   fprintf(fp,"coordIndex [ " );
00067   for (fi=face.begin(); fi!=face.end(); ++fi)
00068   {
00069                 for (int j = 0; j < 3; j++)
00070                         fprintf(fp,"%i%s",index[(*fi).V(j)],", ");
00071                 fprintf(fp,"%s","-1, \n");
00072         }
00073   fprintf(fp," ] \n" );
00074   fprintf(fp," } \n" );
00075   fprintf(fp," } \n" );
00076 
00077   fclose(fp);
00078 }


shape_reconstruction
Author(s): Roberto Martín-Martín
autogenerated on Sat Jun 8 2019 18:30:52