diff --git a/DDCAD/src/ASSIMPReader.cpp b/DDCAD/src/ASSIMPReader.cpp index 5a22c5b3bd1500e0f7ae97ae9198c33acfd84028..78e9e7f5c7469cdab603488cf6af0d52e824b69f 100644 --- a/DDCAD/src/ASSIMPReader.cpp +++ b/DDCAD/src/ASSIMPReader.cpp @@ -111,16 +111,27 @@ ASSIMPReader::readVolumes(const std::string& source, double unit_length) const name = _toString(result.size(), "tessellated_%ld"); } + /// NOTE: IMPORTANT! + /// ALWAYS add facets using the physical vertices! + /// TGeoTessellated takes care that the vertex map is unique and + /// assigns the proper indices to the facet. for(unsigned int i=0; i < mesh->mNumFaces; i++) { const unsigned int* idx = mesh->mFaces[i].mIndices; bool degenerated = dd4hep::cad::facetIsDegenerated({vertices[idx[0]], vertices[idx[1]], vertices[idx[2]]}); - if ( !degenerated ) { - shape->AddFacet(idx[0], idx[1], idx[2]); - continue; + if ( degenerated ) { + printout(DEBUG, "ASSIMPReader", "+++ %s: Drop degenerated facet: %d %d %d", + name.c_str(), idx[0], idx[1], idx[2]); + } + else if ( mesh->mFaces[i].mNumIndices == 3 ) { + shape->AddFacet(vertices[idx[0]], vertices[idx[1]], vertices[idx[2]]); + } + else if ( mesh->mFaces[i].mNumIndices == 4 ) { + shape->AddFacet(vertices[idx[0]], vertices[idx[1]], vertices[idx[2]], vertices[idx[3]]); + } + else { + printout(INFO, "ASSIMPReader", "+++ %s: Fancy facet with %d indices.", + name.c_str(), mesh->mFaces[i].mNumIndices); } - printout(INFO, "ASSIMPReader", "+++ %s: Drop degenerated facet: %d %d %d", - name.c_str(), idx[0], idx[1], idx[2]); - } if ( shape->GetNfacets() > 2 ) { std::string mat_name;