Skip to content

Commit

Permalink
Correctly handle quadrilinear facets in tessellated shapes.
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkusFrankATcernch committed Jan 17, 2024
1 parent 11aa339 commit c0120cd
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
20 changes: 13 additions & 7 deletions DDCAD/include/DDCAD/Utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,30 @@ namespace dd4hep {
/// Namespace for implementation details of the AIDA detector description toolkit
namespace cad {

#if ROOT_VERSION_CODE >= ROOT_VERSION(6,31,1)
inline std::string streamFacet(TGeoFacet const& facet,
TGeoTessellated const& shape) {
TGeoTessellated const& shape) {
using ::operator<<;
std::stringstream str;
#if ROOT_VERSION_CODE >= ROOT_VERSION(6,31,1)
str << "{";
for (int i = 0; i < facet.GetNvert(); ++i) {
str << shape.GetVertex(facet[i]);
if (i != facet.GetNvert() - 1)
str << ", ";
str << shape.GetVertex(facet[i]);
if (i != facet.GetNvert() - 1)
str << ", ";
}
str << "}";
return str.str();
}
#else
inline std::string streamFacet(TGeoFacet const& facet,
TGeoTessellated const& /* shape */) {
using ::operator<<;
std::stringstream str;
str << facet;
#endif
return str.str();
}

#endif

inline std::string streamVertices(ROOT::Geom::Vertex_t const& v1,
ROOT::Geom::Vertex_t const& v2,
ROOT::Geom::Vertex_t const& v3) {
Expand Down
9 changes: 9 additions & 0 deletions DDCAD/src/ASSIMPReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,21 @@ ASSIMPReader::readVolumes(const std::string& source, double unit_length) const
printout(DEBUG, "ASSIMPReader", "+++ %s: Drop degenerated facet: %d %d %d",
name.c_str(), idx[0], idx[1], idx[2]);
}
#if ROOT_VERSION_CODE >= ROOT_VERSION(6,31,1)
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
else if ( mesh->mFaces[i].mNumIndices == 3 ) {
shape->AddFacet(idx[0], idx[1], idx[2]);
}
else if ( mesh->mFaces[i].mNumIndices == 4 ) {
shape->AddFacet(idx[0], idx[1], idx[2], idx[3]);
}
#endif
else {
printout(INFO, "ASSIMPReader", "+++ %s: Fancy facet with %d indices.",
name.c_str(), mesh->mFaces[i].mNumIndices);
Expand Down

0 comments on commit c0120cd

Please sign in to comment.