Skip to content

Commit

Permalink
Fix creation of tessellated shapes from CAD files.
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkusFrankATcernch committed Jan 17, 2024
1 parent 7994031 commit 0cc276b
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions DDCAD/src/ASSIMPReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 0cc276b

Please sign in to comment.