@@ -111,12 +111,12 @@ struct ObjectRecognizer : public object_recognition_core::db::bases::ModelReader
111
111
std::vector<std::string> attachments_names = document.attachment_names ();
112
112
std::string mesh_path;
113
113
BOOST_FOREACH (const std::string & attachment_name, attachments_names) {
114
- if (attachment_name.find (" original " ) != 0 )
114
+ if (attachment_name.find (" mesh " ) != 0 )
115
115
continue ;
116
116
// Create a temporary file
117
117
char mesh_path_tmp[L_tmpnam];
118
118
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 );
120
120
121
121
// Load the mesh and save it to the temporary file
122
122
std::ofstream mesh_file;
@@ -155,6 +155,7 @@ struct ObjectRecognizer : public object_recognition_core::db::bases::ModelReader
155
155
const struct aiMesh * mesh = scene->mMeshes [i_mesh];
156
156
size_t size_ini = mesh_msg.vertices .size ();
157
157
mesh_msg.vertices .resize (size_ini + mesh->mNumVertices );
158
+ std::cout << " Mesh: " << i_mesh << " mNumVertices: " << mesh->mNumVertices << std::endl;
158
159
for (size_t j = 0 ; j < mesh->mNumVertices ; ++j) {
159
160
const aiVector3D& vertex = mesh->mVertices [j];
160
161
mesh_msg.vertices [size_ini + j].x = vertex.x ;
@@ -166,12 +167,23 @@ struct ObjectRecognizer : public object_recognition_core::db::bases::ModelReader
166
167
167
168
size_t size_ini_triangles = mesh_msg.triangles .size ();
168
169
mesh_msg.triangles .resize (size_ini_triangles + mesh->mNumFaces );
170
+ std::cout << " Mesh: " << i_mesh << " mNumFaces: " << mesh->mNumFaces << std::endl;
169
171
size_t j_triangles = size_ini_triangles;
170
172
for (size_t j = 0 ; j < mesh->mNumFaces ; ++j) {
171
173
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;
175
187
}
176
188
mesh_msg.triangles .resize (j_triangles);
177
189
}
0 commit comments