00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
#include "MeshLoader.h"
00013
#include <OpenCAL/ASELoader.h>
00014
#include <OpenCAL/MLoader.h>
00015
#include <OpenCAL/ASCLoader.h>
00016
#include <OpenCAL/PLYLoader.h>
00017
using namespace OpenCAL;
00018
00019
using namespace std;
00020
00021
00022
00023
00024
00025
00026 MeshLoader::MeshLoader()
00027 {
00028 }
00029
00030 MeshLoader::~MeshLoader()
00031 {
00032 }
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
void MeshLoader::loadMesh(
TriangleMesh *mesh,
const string &filename)
00045 {
00046
int dotpos = filename.rfind(
".");
00047 string ext = filename.substr(dotpos + 1);
00048
for(string::iterator it = ext.begin(); it != ext.end(); ++it)
00049 *it = tolower(*it);
00050 cout <<
"Filename extension: " << ext << endl;
00051
00052
if(ext ==
"ase")
00053
ASELoader::loadMesh(mesh, filename);
00054
else if(ext ==
"m")
00055
MLoader::loadMesh(mesh, filename);
00056
else if(ext ==
"asc")
00057
ASCLoader::loadMesh(mesh, filename);
00058
else if(ext ==
"ply")
00059
PLYLoader::loadMesh(mesh, filename);
00060
else
00061 cerr <<
"I don't recognise the type of your filename. I'm sorry..." << endl;
00062 }
00063
00064
00065
00066
00067
00068
00069
bool MeshLoader::startsWith(
const string &line,
const string &start)
00070 {
00071
if(line.length() == 0 || start.length() == 0)
return false;
00072
00073
unsigned int length = start.length();
00074
00075
return (line.compare(0, length, start) == 0);
00076 }