MCPcopy Create free account
hub / github.com/MeshInspector/MeshLib / regionWidth

Function regionWidth

source/MRMesh/MRMeshOverhangs.cpp:19–68  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17{
18
19float 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
70Expected<std::vector<FaceBitSet>> findOverhangs( const Mesh& mesh, const FindOverhangsSettings& settings )
71{

Callers 1

findOverhangsFunction · 0.85

Calls 13

orgRingFunction · 0.85
leftMethod · 0.80
sqrFunction · 0.70
dotFunction · 0.70
symMethod · 0.45
testMethod · 0.45
edgeVectorMethod · 0.45
lengthSqMethod · 0.45
addStartMethod · 0.45
orgMethod · 0.45
doneDistanceMethod · 0.45
doneMethod · 0.45

Tested by

no test coverage detected