| 17 | { |
| 18 | |
| 19 | float regionWidth( const MeshPart& mp, const Vector3f& axis, const std::vector<EdgeLoop>& allBoundaries, const std::vector<int>& thisBdIndices ) |
| 20 | { |
| 21 | MR_TIMER; |
| 22 | auto metric = [&] ( EdgeId e0 )->float |
| 23 | { |
| 24 | bool incident = false; |
| 25 | for ( auto e : orgRing( mp.mesh.topology, e0.sym() ) ) |
| 26 | { |
| 27 | auto f = mp.mesh.topology.left( e ); |
| 28 | if ( f && mp.region->test( f ) ) |
| 29 | { |
| 30 | incident = true; |
| 31 | break; |
| 32 | } |
| 33 | } |
| 34 | if ( !incident ) |
| 35 | return FLT_MAX; |
| 36 | auto ev = mp.mesh.edgeVector( e0 ); |
| 37 | return std::sqrt( ev.lengthSq() - sqr( dot( ev, axis ) ) ); |
| 38 | }; |
| 39 | |
| 40 | |
| 41 | EdgePathsBuilder b( mp.mesh.topology, metric ); |
| 42 | for ( auto bdId : thisBdIndices ) |
| 43 | for ( auto e : allBoundaries[bdId] ) |
| 44 | b.addStart( mp.mesh.topology.org( e ), 0.0f ); |
| 45 | |
| 46 | float maxWidth = b.doneDistance(); |
| 47 | if ( maxWidth == FLT_MAX ) |
| 48 | maxWidth = 0.0f; |
| 49 | while ( !b.done() ) |
| 50 | { |
| 51 | b.growOneEdge(); |
| 52 | auto width = b.doneDistance(); |
| 53 | if ( width < FLT_MAX ) |
| 54 | maxWidth = width; |
| 55 | } |
| 56 | if ( maxWidth > 0.0f ) |
| 57 | return 2 * maxWidth; |
| 58 | |
| 59 | for ( auto bdId : thisBdIndices ) |
| 60 | for ( auto e : allBoundaries[bdId] ) |
| 61 | for ( auto oe : orgRing( mp.mesh.topology, e ) ) |
| 62 | { |
| 63 | auto width = metric( oe ); |
| 64 | if ( width < FLT_MAX && width > maxWidth ) |
| 65 | maxWidth = width; |
| 66 | } |
| 67 | return maxWidth; |
| 68 | } |
| 69 | |
| 70 | Expected<std::vector<FaceBitSet>> findOverhangs( const Mesh& mesh, const FindOverhangsSettings& settings ) |
| 71 | { |
no test coverage detected