MeshLib C++ Docs
Loading...
Searching...
No Matches
MRVDBProgressInterrupter.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRVoxelsFwd.h"
4
6#include <openvdb/util/NullInterrupter.h>
7#include <algorithm>
8#include <thread>
9
10namespace MR
11{
14
15
17struct ProgressInterrupter : openvdb::util::NullInterrupter
18{
20 , progressThreadId_{ std::this_thread::get_id() } {}
21 virtual bool wasInterrupted( int percent = -1 ) override
22 {
25 if ( cb_ && progressThreadId_ == std::this_thread::get_id() )
26 wasInterrupted_ = !cb_( float( std::clamp( percent, 0, 100 ) ) / 100.0f );
27 return wasInterrupted_;
28 }
29 bool getWasInterrupted() const { return wasInterrupted_; }
30
31private:
32 bool wasInterrupted_{ false };
34 std::thread::id progressThreadId_;
35};
36
37}
std::function< bool(float)> ProgressCallback
Definition MRMeshFwd.h:753
bool getWasInterrupted() const
Definition MRVDBProgressInterrupter.h:29
virtual bool wasInterrupted(int percent=-1) override
Definition MRVDBProgressInterrupter.h:21
ProgressInterrupter(ProgressCallback cb)
Definition MRVDBProgressInterrupter.h:19
only for bindings generation
Definition MRCameraOrientationPlugin.h:8