Reputation: 11
For some reason, it just won't load the mesh file. I can't tell if its because Im entering something wrong, or if I just dont have the file in the right folder. I have it in the same folder as the .exe right now, and I have it under my "source files" too (that could be wrong).
Mesh.cpp
#include "MeshTable.h"
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
void MeshTable::ReadMesh_M(const char *filename) {
points.clear();
faces.clear();
//the Vertex id in .m file begins from 1,
//we insert an empty point to align the index
points.push_back(Point());
std::ifstream input("C:\\Users\\Zach\\Documents\\Visual Studio 2010\\Projects\\MAIN\\Release\\dog.m");
while(input.good()) {
std::string line;
getline(input, line);
if (line.empty()) {
continue;
}
std::stringstream ss(line);
std::string title;
int id;
ss >> title;
if (title == "Vertex") {
Point pt;
ss >> id >> pt[0] >> pt[1] >> pt[2];
points.push_back(pt);
}
else if (title == "Face") {
Face face;
ss >> id >> face.pt_ids[0] >> face.pt_ids[1] >> face.pt_ids[2];
faces.push_back(face);
}
}
input.close();
}
void MeshTable::SaveMesh_M(const char *filename) {
std:: ofstream output(C:\\Users\\Zach\\Documents\\Visual Studio 2010\\Projects\\MAIN\\Release\\dog_out.m);
for (unsigned int i = 1; i < points.size(); ++i) {
const Point& pt = points[i];
output << "Vertex " << i << " " << pt[0] << " " << pt[1] << " " << pt[2] << "\n";
}
for (unsigned int i = 0; i < faces.size(); ++i) {
const Face& face = faces[i];
output << "Face " << i + 1 << " " << face.pt_ids[0] << " " << face.pt_ids[1] << " " << face.pt_ids[2] << "\n";
}
output.close();
}
It builds fine, but when I try to debug it, the OpenGL window pops open for like 3 seconds and then closes and says "The program '[3188] Main.exe: Native' has exited with code -1 (0xffffffff)." Which comes from my main.cpp.
if (argc != 2) {
std::cout << "Load a .m file as a mesh table.\n";
std::cout << "Usage: " << argv[0] << " input_mesh.m\n";
exit(-1);
}
EDIT Once I deleted this, it worked. My teacher gave me this (part) of the code so I dont really understand why that would make it not work.
if (argc != 2) {
std::cout << "Load a .m file as a mesh table.\n";
std::cout << "Usage: " << argv[0] << " input_mesh.m\n";
exit(-1);
}
Upvotes: 0
Views: 1084
Reputation: 26409
if (argc != 2) {
std::cout << "Load a .m file as a mesh table.\n";
std::cout << "Usage: " << argv[0] << " input_mesh.m\n";
exit(-1);
}
You need to pass name of mesh file into command line parameter when you run the program. I.e. it should be launched as "program.exe meshfile.m".
In VS 2008 debugging parameters/command line arguments could be specified in project properties->configuration properties->debugging->command arguments. In VS2010 they could be in similar locations.
Also, read "output" when you run the program. Code fragment provided by your teacher actually prints program usage.
Upvotes: 1