computes all sections of modified mesh along the given axis if a selected area is specified in the original mesh, then only points projected on it will be taken into consideration
| 144 | // computes all sections of modified mesh along the given axis |
| 145 | // if a selected area is specified in the original mesh, then only points projected on it will be taken into consideration |
| 146 | std::vector<PlaneSections> extractAllSections( const Mesh& mesh, const Box3f& box, Axis axis, float sectionStep, int steps, BypassDirection bypassDir, ProgressCallback cb ) |
| 147 | { |
| 148 | auto mainThreadId = std::this_thread::get_id(); |
| 149 | std::atomic<bool> keepGoing{ true }; |
| 150 | std::atomic<size_t> numDone{ 0 }; |
| 151 | |
| 152 | std::vector<PlaneSections> sections( steps ); |
| 153 | |
| 154 | const int axisIndex = int( axis ); |
| 155 | constexpr Vector3f normals[3] = { {1, 0, 0}, {0, 1, 0}, {0, 0 ,1} }; |
| 156 | const Vector3f normal = normals[axisIndex]; |
| 157 | const auto plane = MR::Plane3f::fromDirAndPt( normal, box.max ); |
| 158 | |
| 159 | tbb::parallel_for( tbb::blocked_range<int>( 0, steps ), [&] ( const tbb::blocked_range<int>& range ) |
| 160 | { |
| 161 | for ( int step = range.begin(); step < range.end(); ++step ) |
| 162 | { |
| 163 | if ( cb && !keepGoing.load( std::memory_order_relaxed ) ) |
| 164 | break; |
| 165 | |
| 166 | const float currentCoord = plane.d - sectionStep * step; |
| 167 | |
| 168 | auto stepSections = extractPlaneSections( mesh, Plane3f{ plane.n, currentCoord } ); |
| 169 | |
| 170 | if ( bypassDir == BypassDirection::Clockwise ) |
| 171 | { |
| 172 | sections[step] = std::move( stepSections ); |
| 173 | continue; |
| 174 | } |
| 175 | |
| 176 | sections[step].reserve( stepSections.size() ); |
| 177 | |
| 178 | for ( auto& section : stepSections ) |
| 179 | { |
| 180 | std::reverse( section.begin(), section.end() ); |
| 181 | sections[step].push_back( std::move( section ) ); |
| 182 | } |
| 183 | } |
| 184 | |
| 185 | if ( cb ) |
| 186 | numDone += range.size(); |
| 187 | |
| 188 | if ( cb && std::this_thread::get_id() == mainThreadId ) |
| 189 | { |
| 190 | if ( !cb( float( numDone ) / float( steps ) ) ) |
| 191 | keepGoing.store( false, std::memory_order_relaxed ); |
| 192 | } |
| 193 | } ); |
| 194 | |
| 195 | if ( !keepGoing.load( std::memory_order_relaxed ) || !reportProgress( cb, 1.0f ) ) |
| 196 | return {}; |
| 197 | |
| 198 | return sections; |
| 199 | } |
| 200 | |
| 201 | struct ExtractIsolinesResult |
| 202 | { |
no test coverage detected