Implemented TriangleMesh->merge

This commit is contained in:
Alessandro Ranellucci 2013-09-09 22:45:22 +02:00
parent 27e7c6b9f7
commit 3919ba83d8
6 changed files with 29 additions and 3 deletions

View file

@ -525,4 +525,23 @@ TriangleMesh::split() const
return meshes;
}
void
TriangleMesh::merge(const TriangleMesh* mesh)
{
// reset stats and metadata
int number_of_facets = this->stl.stats.number_of_facets;
stl_initialize(&this->stl);
stl_invalidate_shared_vertices(&this->stl);
// update facet count and allocate more memory
this->stl.stats.number_of_facets = number_of_facets + mesh->stl.stats.number_of_facets;
this->stl.stats.original_num_facets = this->stl.stats.number_of_facets;
stl_reallocate(&this->stl);
// copy facets
for (int i = 0; i < mesh->stl.stats.number_of_facets; i++) {
this->stl.facet_start[number_of_facets + i] = mesh->stl.facet_start[i];
}
}
}