Skip to content

Commit 973a37b

Browse files
committed
viewer: run workflows in background
1 parent 59bc935 commit 973a37b

File tree

10 files changed

+572
-226
lines changed

10 files changed

+572
-226
lines changed

apps/Viewer/Scene.cpp

Lines changed: 304 additions & 155 deletions
Large diffs are not rendered by default.

apps/Viewer/Scene.h

Lines changed: 48 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,6 @@
3636
namespace VIEWER {
3737

3838
class Scene {
39-
public:
40-
typedef MVS::PointCloud::Octree OctreePoints;
41-
typedef MVS::Mesh::Octree OctreeMesh;
42-
4339
public:
4440
struct EstimateROIWorkflowOptions {
4541
float scaleROI{1.1f};
@@ -153,6 +149,35 @@ class Scene {
153149
static SEACAVE::EventQueue events; // internal events queue (processed by the working threads)
154150
static SEACAVE::Thread thread; // worker thread
155151

152+
// workflow state tracking
153+
enum WorkflowState {
154+
WF_STATE_IDLE = 0,
155+
WF_STATE_RUNNING,
156+
WF_STATE_COMPLETED,
157+
WF_STATE_FAILED
158+
};
159+
enum WorkflowType {
160+
WF_NONE = 0,
161+
WF_ESTIMATE_ROI,
162+
WF_DENSIFY,
163+
WF_RECONSTRUCT,
164+
WF_REFINE,
165+
WF_TEXTURE
166+
};
167+
std::atomic<WorkflowState> workflowState;
168+
std::atomic<WorkflowType> currentWorkflowType;
169+
std::atomic<bool> geometryModified;
170+
double workflowStartTime;
171+
SEACAVE::CriticalSection workflowMutex;
172+
173+
// Workflow history for stats display
174+
struct WorkflowHistoryEntry {
175+
WorkflowType type;
176+
double duration;
177+
bool success;
178+
};
179+
std::vector<WorkflowHistoryEntry> workflowHistory;
180+
156181
public:
157182
explicit Scene(ARCHIVE_TYPE _nArchiveType = ARCHIVE_MVS);
158183
~Scene();
@@ -172,12 +197,23 @@ class Scene {
172197
bool Save(const String& fileName = String(), bool bRescaleImages = false);
173198
bool Export(const String& fileName, const String& exportType = String(), bool bViews = true) const;
174199

175-
// Workflows
176-
bool RunEstimateROIWorkflow(const EstimateROIWorkflowOptions& options, bool bUpdateGeometry = true);
177-
bool RunDensifyWorkflow(const DensifyWorkflowOptions& options, bool bUpdateGeometry=true);
178-
bool RunReconstructMeshWorkflow(const ReconstructMeshWorkflowOptions& options, bool bUpdateGeometry=true);
179-
bool RunRefineMeshWorkflow(const RefineMeshWorkflowOptions& options, bool bUpdateGeometry=true);
180-
bool RunTextureMeshWorkflow(const TextureMeshWorkflowOptions& options, bool bUpdateGeometry=true);
200+
// Workflows (async execution)
201+
bool RunEstimateROIWorkflow(const EstimateROIWorkflowOptions& options);
202+
bool RunDensifyWorkflow(const DensifyWorkflowOptions& options);
203+
bool RunReconstructMeshWorkflow(const ReconstructMeshWorkflowOptions& options);
204+
bool RunRefineMeshWorkflow(const RefineMeshWorkflowOptions& options);
205+
bool RunTextureMeshWorkflow(const TextureMeshWorkflowOptions& options);
206+
207+
// Workflow state management
208+
bool IsWorkflowRunning() const { return workflowState.load() == WF_STATE_RUNNING; }
209+
WorkflowState GetWorkflowState() const { return workflowState.load(); }
210+
WorkflowType GetCurrentWorkflowType() const { return currentWorkflowType.load(); }
211+
double GetWorkflowElapsedTime() const;
212+
void CheckWorkflowCompletion(); // Called from main loop to check if workflow completed
213+
bool IsGeometryModified() const { return geometryModified.load(); }
214+
void SetGeometryModified(bool modified = true) { geometryModified.store(modified); }
215+
const std::vector<WorkflowHistoryEntry>& GetWorkflowHistory() const { return workflowHistory; }
216+
void ClearWorkflowHistory() { workflowHistory.clear(); }
181217

182218
// Geometry operations
183219
void RemoveSelectedGeometry();
@@ -212,8 +248,8 @@ class Scene {
212248
void CropToBounds();
213249
void TogleSceneBox();
214250

215-
// Internal geometry operation
216-
void UpdateGeometryAfterModification();
251+
// Workflow finalization (called from main thread after workflow completes)
252+
void FinalizeWorkflow(bool success);
217253

218254
static void* ThreadWorker(void*);
219255
};

apps/Viewer/SelectionController.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,8 @@ void Scene::RemoveSelectedGeometry() {
245245
scene.mesh.RemoveFaces(selectedIndices);
246246
}
247247

248-
// Rebuild octrees and update rendering
249-
updateGeometryAfterModification();
248+
// Update rendering
249+
window.UploadRenderData();
250250
}
251251
```
252252

0 commit comments

Comments
 (0)