Skip to content
Open
Changes from 1 commit
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
29 changes: 29 additions & 0 deletions plugins/assimp/module/vtkF3DAssimpImporter.cxx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#include "vtkF3DAssimpImporter.h"

#include <assimp/ProgressHandler.hpp>
#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 @@ -42,6 +44,27 @@
#include <memory>
#include <regex>

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

bool Update(float percentage = -1.f) override
{
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 +74,12 @@ class vtkF3DAssimpImporter::vtkInternals
explicit vtkInternals(vtkF3DAssimpImporter* parent)
: Parent(parent)
{
auto progressHandler = new F3DAssimpProgressHandler(parent);

if (this->Importer.IsDefaultProgressHandler())
{
this->Importer.SetProgressHandler(static_cast<Assimp::ProgressHandler*>(progressHandler));
}
}

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