~ubuntu-branches/ubuntu/lucid/meshlab/lucid

« back to all changes in this revision

Viewing changes to vcglib/wrap/io_trimesh/import_asc.h

  • Committer: Bazaar Package Importer
  • Author(s): Teemu Ikonen
  • Date: 2009-10-08 16:40:41 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20091008164041-0c2ealqv8b8uc20c
Tags: 1.2.2-1
* New upstream version
* Do not build filter_isoparametrization because liblevmar dependency
  is not (yet) in Debian
* Fix compilation with gcc-4.4, thanks to Jonathan Liu for the patch
  (closes: #539544)
* rules: Add compiler variables to the qmake call (for testing with new
  GCC versions)
* io_3ds.pro: Make LIBS and INCLUDEPATH point to Debian version of lib3ds
* io_epoch.pro: Make LIBS point to Debian version of libbz2
* control:
  - Move Homepage URL to the source package section
  - Update to standards-version 3.8.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
63
63
                // Error open
64
64
        E_CANTOPEN,                             // 1
65
65
        E_UNESPECTEDEOF,        // 2
 
66
        E_NO_POINTS,                            //3
66
67
};
67
68
 
68
69
static const char *ErrorMsg(int error)
72
73
        "No errors",
73
74
        "Can't open file",
74
75
        "Premature End of file",
 
76
        "Failed to import any point. Use simple ascii files with just x y z coords."
75
77
        };
76
78
 
77
 
  if(error>2 || error<0) return "Unknown error";
 
79
  if(error>3 || error<0) return "Unknown error";
78
80
  else return raw_error_msg[error];
79
81
};
80
82
 
112
114
                for(int i=0;i<lineskip;++i)
113
115
                                fgets(buf,1024,fp);
114
116
 
115
 
    /* Read a single facet from an ASCII .STL file */
 
117
    /* Read a single triplet of coords from an ASCII file of coords*/
116
118
    while(!feof(fp))
117
119
    {
118
120
      if(cb && (++cnt)%1000) cb( (ftell(fp)*100)/fileLen, "ASC Mesh Loading");  
119
121
                        if(feof(fp)) break;
120
 
                        fgets(buf,1024,fp);
 
122
            bool fgetOut=fgets(buf,1024,fp);
 
123
            if( fgetOut == 0 ) continue;
121
124
                        ret=sscanf(buf, "%f, %f, %f, %f\n", &pp.X(), &pp.Y(), &pp.Z(),&q);
 
125
                        if(ret==1) // lets try also non comma separated values
 
126
                                ret=sscanf(buf, "%f %f %f %f\n", &pp.X(), &pp.Y(), &pp.Z(),&q);
 
127
                        
122
128
                        if(ret>=3)
123
129
                                {
124
130
                                        VertexIterator vi=Allocator<MESH_TYPE>::AddVertices(m,1);
128
134
    }
129
135
                
130
136
    fclose(fp);
 
137
                if(m.vn==0) return E_NO_POINTS;
131
138
                if(!triangulate) return E_NOERROR;
132
139
                // now try to triangulate.
133
140
                // search for the first jump