Estoy intentando añadir elementos "Vertex" a un vector de tipo Vertex pero sin embargo al ejecutar el programa y la rutina para hacerlo me sale el error del titulo del post.
Alguien me sabria explicar que es y como podria resolverlo?
Aqui teneis el codigo:
Funcion que da error
Código:
Declaracion del vector (header de joint):#include "joint.h" #include <QDebug> Joint::Joint() {} void Joint::addVertex(Vertex &v) { vertexVector.push_back(v); } Vertex Joint::getVertex(int i) { return vertexVector[i]; } int Joint::numberVertex() { return vertexVector.size(); } void Joint::addJoint(Joint j) { nextJoint->push_back(j); }
Código:
Llamada a la funcion en la clase llamada xml:#ifndef JOINT_H #define JOINT_H #include "vector" #include "vertex.h" class Joint { public: Joint(); void addVertex(Vertex &); void addJoint(Joint); Vertex getVertex(int); int numberVertex(); private: std::vector<Vertex> vertexVector; std::vector<Joint> *nextJoint; }; #endif // JOINT_H
Código:
El codigo de la funcion en xml.h:bool xml::loadData(const char* fileName, std::vector<Joint> *joints) { qDebug() << "Checkpoint 2" <<endl; TiXmlDocument doc(fileName); bool loadOkay = doc.LoadFile(); qDebug() << "Checkpoint 3" <<endl; if (loadOkay) { printf("\n%s:\n", fileName); qDebug() << "Checkpoint 4" <<endl; ProcessFile(joints, &doc ); // defined later in the tutorial } else { printf("Failed to load file \"%s\"\n", fileName); } return loadOkay; } void xml::ProcessFile(std::vector<Joint> *joints, TiXmlDocument* pParent ) { char * cstr, *word; string line; size_t found; Vertex v; ifstream file; file.open ("C:/Users/Marcus/Desktop/C++/ABB_IRB1600_145-0.STL"); if (file.is_open()) { while ( file.good() ) { getline(file,line); found = line.find("vertex"); if(found != 0 && found < 1000) { line.erase(0,16); cstr = new char [line.size()+1]; strcpy (cstr, line.c_str()); word = strtok(cstr," "); v.x = atof(word); word = strtok(NULL," "); v.y = atof(word); word = strtok(NULL," "); v.z = atof(word); word = strtok(NULL," "); //ERROR AQUI!!!! /**-|-|-|-|-|-|-|-|-|-|-|-|-|-**/ joints->front().addVertex(v); /**-|-|-|-|-|-|-|-|-|-|-|-|-|-**/ } } } file.close(); }
Código:
void ProcessFile(std::vector<Joint> *joints, TiXmlDocument* pParent);