Skip to content

Commit 2c149db

Browse files
committed
Fix reading mesh file from data base and print some messages about assimp output.
1 parent a5673e6 commit 2c149db

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

src/object/ObjectRecognizer.cpp

+17-5
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,12 @@ struct ObjectRecognizer : public object_recognition_core::db::bases::ModelReader
111111
std::vector<std::string> attachments_names = document.attachment_names();
112112
std::string mesh_path;
113113
BOOST_FOREACH(const std::string & attachment_name, attachments_names) {
114-
if (attachment_name.find("original") != 0)
114+
if (attachment_name.find("mesh") != 0)
115115
continue;
116116
// Create a temporary file
117117
char mesh_path_tmp[L_tmpnam];
118118
tmpnam(mesh_path_tmp);
119-
mesh_path = std::string(mesh_path_tmp) + attachment_name.substr(8);
119+
mesh_path = std::string(mesh_path_tmp) + attachment_name.substr(4);
120120

121121
// Load the mesh and save it to the temporary file
122122
std::ofstream mesh_file;
@@ -155,6 +155,7 @@ struct ObjectRecognizer : public object_recognition_core::db::bases::ModelReader
155155
const struct aiMesh* mesh = scene->mMeshes[i_mesh];
156156
size_t size_ini = mesh_msg.vertices.size();
157157
mesh_msg.vertices.resize(size_ini + mesh->mNumVertices);
158+
std::cout << "Mesh: " << i_mesh << " mNumVertices: " << mesh->mNumVertices << std::endl;
158159
for (size_t j = 0; j < mesh->mNumVertices; ++j) {
159160
const aiVector3D& vertex = mesh->mVertices[j];
160161
mesh_msg.vertices[size_ini + j].x = vertex.x;
@@ -166,12 +167,23 @@ struct ObjectRecognizer : public object_recognition_core::db::bases::ModelReader
166167

167168
size_t size_ini_triangles = mesh_msg.triangles.size();
168169
mesh_msg.triangles.resize(size_ini_triangles + mesh->mNumFaces);
170+
std::cout << "Mesh: " << i_mesh << " mNumFaces: " << mesh->mNumFaces << std::endl;
169171
size_t j_triangles = size_ini_triangles;
170172
for (size_t j = 0; j < mesh->mNumFaces; ++j) {
171173
const aiFace& face = mesh->mFaces[j];
172-
for (size_t k = 0; k < 3; ++k)
173-
mesh_msg.triangles[j_triangles].vertex_indices[k] = size_ini + face.mIndices[k];
174-
++j_triangles;
174+
std::cout << "after " << j << std::endl;
175+
std::cout << "face[" << j << "] address: " << mesh->mFaces << std::endl;
176+
std::cout << "face[" << j << "].mNumIndices: " << face.mNumIndices << std::endl;
177+
if (face.mNumIndices == 3){
178+
for (size_t k = 0; k < 3; ++k){
179+
std::cout << "size_ini: " << size_ini << std::endl;
180+
std::cout << "face.mIndices[" << k << "]" << face.mIndices[k] << std::endl;
181+
mesh_msg.triangles[j_triangles].vertex_indices[k] = size_ini + face.mIndices[k];
182+
}
183+
++j_triangles;
184+
}
185+
else
186+
std::cout << "Face[" << j << "] is not a triangle" << std::endl;
175187
}
176188
mesh_msg.triangles.resize(j_triangles);
177189
}

0 commit comments

Comments
 (0)