| 132 | } //anonymous namespace |
| 133 | |
| 134 | int reduceTotalAngle( MeshTopology& topology, const VertCoords& points, int numIters, const ReduceTotalAngleParams& region, const ProgressCallback& progressCallback ) |
| 135 | { |
| 136 | if ( numIters <= 0 ) |
| 137 | return 0; |
| 138 | MR_TIMER; |
| 139 | |
| 140 | UndirectedEdgeBitSet flipCandidates( topology.undirectedEdgeSize() ); |
| 141 | UndirectedEdgeBitSet nextFlipCandidates( topology.undirectedEdgeSize(), true ); |
| 142 | |
| 143 | int flipsDone = 0; |
| 144 | for ( int iter = 0; iter < numIters; ++iter ) |
| 145 | { |
| 146 | if ( progressCallback && !progressCallback( float( iter ) / numIters ) ) |
| 147 | return flipsDone; |
| 148 | |
| 149 | flipCandidates.reset(); |
| 150 | BitSetParallelFor( nextFlipCandidates, [&] ( UndirectedEdgeId e ) |
| 151 | { |
| 152 | if ( totalAngleIncreaseOnFlip( topology, points, e, region ) < 1 ) |
| 153 | flipCandidates.set( e ); |
| 154 | } ); |
| 155 | nextFlipCandidates.reset(); |
| 156 | int flipsDoneBeforeThisIter = flipsDone; |
| 157 | for ( UndirectedEdgeId ue : flipCandidates ) |
| 158 | { |
| 159 | const EdgeId e = ue; |
| 160 | if ( totalAngleIncreaseOnFlip( topology, points, e, region ) >= 1 ) |
| 161 | continue; |
| 162 | |
| 163 | ++flipsDone; |
| 164 | topology.flipEdge( e ); |
| 165 | |
| 166 | if ( iter + 1 >= numIters ) |
| 167 | continue; |
| 168 | |
| 169 | const auto e0 = topology.prev( e ); |
| 170 | nextFlipCandidates.set( e0 ); |
| 171 | if ( topology.right( e0 ) ) |
| 172 | { |
| 173 | nextFlipCandidates.set( topology.prev( e0 ) ); |
| 174 | nextFlipCandidates.set( topology.next( e0.sym() ) ); |
| 175 | } |
| 176 | |
| 177 | const auto e1 = topology.next( e.sym() ); |
| 178 | nextFlipCandidates.set( e1 ); |
| 179 | if ( topology.left( e1 ) ) |
| 180 | { |
| 181 | nextFlipCandidates.set( topology.next( e1 ) ); |
| 182 | nextFlipCandidates.set( topology.prev( e1.sym() ) ); |
| 183 | } |
| 184 | |
| 185 | const auto e2 = topology.prev( e.sym() ); |
| 186 | nextFlipCandidates.set( e2 ); |
| 187 | if ( topology.right( e2 ) ) |
| 188 | { |
| 189 | nextFlipCandidates.set( topology.prev( e2 ) ); |
| 190 | nextFlipCandidates.set( topology.next( e2.sym() ) ); |
| 191 | } |
no test coverage detected