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 0cc276b commit 6e28560
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 21 deletions.
20 changes: 0 additions & 20 deletions DDCAD/include/DDCAD/Utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,25 +54,6 @@ namespace dd4hep {
}
// Determine if the facet is degenerated by calculating its determinant
inline bool facetIsDegenerated(std::vector<ROOT::Geom::Vertex_t> const& vertices){
#if 0
const ROOT::Geom::Vertex_t& v1 = vertices[0];
const ROOT::Geom::Vertex_t& v2 = vertices[1];
const ROOT::Geom::Vertex_t& v3 = vertices[2];
constexpr double epsilon = std::numeric_limits<double>::epsilon();
// v1.x v2.x v3.x v1.x v2.x
//
// v1.y v2.y v3.y v1.y v2.y
//
// v1.z v2.z v3.z v1.z v2.z
double det = 0.0
+ v1.x() * v2.y() * v3.z()
+ v2.x() * v3.y() * v1.z()
+ v3.x() * v1.y() * v2.z()
- v1.z() * v2.y() * v3.x()
- v2.z() * v3.y() * v1.x()
- v3.z() * v1.y() * v2.x();
return std::fabs(det) < epsilon;
#else
using ROOT::Geom::Vertex_t;
// Compute normal using non-zero segments
constexpr double kTolerance = 1.e-20;
Expand All @@ -99,7 +80,6 @@ namespace dd4hep {
break;
}
return degenerated;
#endif
}
}
}
Expand Down
7 changes: 6 additions & 1 deletion DDCAD/src/ASSIMPReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,12 @@ ASSIMPReader::readVolumes(const std::string& source, double unit_length) const
/// 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]]});
bool degenerated = false;
if ( mesh->mFaces[i].mNumIndices == 3 )
degenerated = dd4hep::cad::facetIsDegenerated({vertices[idx[0]], vertices[idx[1]], vertices[idx[2]]});
else if ( mesh->mFaces[i].mNumIndices == 4 )
degenerated = dd4hep::cad::facetIsDegenerated({vertices[idx[0]], vertices[idx[1]], vertices[idx[2]], vertices[idx[3]]});

if ( degenerated ) {
printout(DEBUG, "ASSIMPReader", "+++ %s: Drop degenerated facet: %d %d %d",
name.c_str(), idx[0], idx[1], idx[2]);
Expand Down

0 comments on commit 6e28560

Please sign in to comment.