Skip to content
Open
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions plugins/assimp/module/vtkF3DAssimpImporter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <vtkActor.h>
#include <vtkActorCollection.h>
#include <vtkCamera.h>
#include <vtkCommand.h>
#include <vtkDoubleArray.h>
#include <vtkFloatArray.h>
#include <vtkImageData.h>
Expand Down Expand Up @@ -36,12 +37,39 @@

#include <assimp/Exceptional.h>
#include <assimp/Importer.hpp>
#include <assimp/ProgressHandler.hpp>
#include <assimp/postprocess.h>
#include <assimp/scene.h>

#include <memory>
#include <regex>

class F3DAssimpProgressHandler : public Assimp::ProgressHandler
{
public:
explicit F3DAssimpProgressHandler(vtkF3DAssimpImporter* parent)
: Parent(parent)
{
}

bool Update(float percentage) override
{
// special case: no progress to report, not an error
if (percentage == -1.f)
{
return true;
}

double reportPercentage = percentage < 0 ? double{ 1.0 } : static_cast<double>(percentage);
this->Parent->InvokeEvent(vtkCommand::ProgressEvent, static_cast<void*>(&reportPercentage));

return percentage < 0 ? false : true;
}

private:
vtkF3DAssimpImporter* Parent;
};

vtkStandardNewMacro(vtkF3DAssimpImporter);

class vtkF3DAssimpImporter::vtkInternals
Expand All @@ -51,6 +79,9 @@ class vtkF3DAssimpImporter::vtkInternals
explicit vtkInternals(vtkF3DAssimpImporter* parent)
: Parent(parent)
{
assert(this->Importer.IsDefaultProgressHandler());
auto progressHandler = new F3DAssimpProgressHandler(parent);
this->Importer.SetProgressHandler(progressHandler);
}

//----------------------------------------------------------------------------
Expand Down
Loading