protected override void process_new_result(DMeshOutputStatus result) { bool bOK = (result.IsErrorOutput() == false); current_result_is_partial = bOK && result.Mesh.HasMetadata && result.Mesh.FindMetadata("is_partial") != null; }
protected override void process_new_result(DMeshOutputStatus result) { if (result.Mesh != null) { DSubmesh3 submesh = result.Mesh.FindMetadata("removed_submesh") as DSubmesh3; if (submesh != null) { RemovedSO.ReplaceMesh(submesh.SubMesh, true); result.Mesh.RemoveMetadata("removed_submesh"); } } }
void update_cut_op() { List <ModelingOpException> exceptions = null; if (cut_parameters_dirty) { CutOp.HoleSize = hole_size; CutOp.HoleSubdivisions = subdivisions; CutOp.ThroughHole = through_hole; CutOp.HoleDepth = hole_depth; cut_parameters_dirty = false; } try { DMeshOutputStatus result = ComputeOp.CheckForNewMesh(); is_computing = (result.State == DMeshOutputStatus.States.Computing); if (result.State == DMeshOutputStatus.States.Ready) { current_result_ok = (result.IsErrorOutput() == false); var setMesh = result.Mesh; if (result.Mesh.CompactMetric < 0.8) { setMesh = new DMesh3(result.Mesh, true); } CutPreviewSO.ReplaceMesh(setMesh, true); CutPreviewSO.AssignSOMaterial((current_result_ok) ? CutPreviewMaterial : ErrorMaterial); exceptions = result.ComputeExceptions; } } catch (Exception e) { DebugUtil.Log(2, Name + "Tool.PreRender: caught exception! " + e.Message); } if (ComputeOp.HaveBackgroundException) { Exception e = ComputeOp.ExtractBackgroundException(); if (VerboseOutput) { DebugUtil.Log(2, GetType().ToString() + ".PreRender: exception in background compute: " + e.Message); DebugUtil.Log(2, e.StackTrace); } } if (exceptions != null && VerboseOutput) { foreach (var mopex in exceptions) { DebugUtil.Log(2, GetType().ToString() + ".PreRender: exception in background compute " + mopex.op.GetType().ToString() + " : " + mopex.e.Message); DebugUtil.Log(2, mopex.e.StackTrace); } } }
protected override void process_new_result(TargetObject obj, DMeshOutputStatus result) { if (result.Mesh != null) { DMesh3 otherSideMesh = result.Mesh.FindMetadata("other_side") as DMesh3; if (otherSideMesh != null) { result.Mesh.RemoveMetadata("other_side"); } OtherSideMeshes[obj.SO] = otherSideMesh; } }
virtual public void PreRender() { if (in_shutdown()) { return; } try { is_computing = false; foreach (var obj in objects) { List <ModelingOpException> exceptions = null; DMeshOutputStatus result = obj.Compute.CheckForNewMesh(); is_computing |= (result.State == DMeshOutputStatus.States.Computing); if (result.State == DMeshOutputStatus.States.Ready) { process_new_result(obj, result); obj.current_result_ok = (result.IsErrorOutput() == false); var setMesh = result.Mesh; if (result.Mesh.CompactMetric < 0.8) { setMesh = new DMesh3(result.Mesh, true); } obj.Preview.ReplaceMesh(setMesh, true); obj.Preview.AssignSOMaterial((obj.current_result_ok) ? PreviewMaterial : ErrorMaterial); exceptions = result.ComputeExceptions; } if (obj.Compute.HaveBackgroundException) { Exception e = obj.Compute.ExtractBackgroundException(); DebugUtil.Log(2, GetType().ToString() + ".PreRender: exception in background compute: " + e.Message); DebugUtil.Log(2, e.StackTrace); } if (exceptions != null) { foreach (var mopex in exceptions) { DebugUtil.Log(2, GetType().ToString() + ".PreRender: exception in background compute " + mopex.op.GetType().ToString() + " : " + mopex.e.Message); DebugUtil.Log(2, mopex.e.StackTrace); } } } } catch (Exception e) { DebugUtil.Log(2, Name + "Tool.PreRender: caught exception! " + e.Message); } }
/// <summary> /// subclasses can override this to implement custom behavior /// </summary> protected virtual void process_new_result(DMeshOutputStatus result) { }
/// <summary> /// subclasses can override this to implement custom behavior /// </summary> protected virtual void process_new_result(TargetObject obj, DMeshOutputStatus result) { }
public DMeshOutputStatus CheckForNewMesh() { if (computing) { return(DMeshOutputStatus.Computing()); } else if (result_valid) { return(DMeshOutputStatus.Unavailable()); } else if (last_exception_timestamp == result_timestamp) { return(DMeshOutputStatus.Unavailable()); } else { // the compute we were waiting for has finished, extract the resulting mesh DMesh3 returnMesh = null; bool spawn_new_compute = false; lock (compute_thread_lock) { returnMesh = computed_result; computed_result = null; // situations where we will discard this result: // 1) it came back null. lets hope this is temporary... // 2) active_thread_data was null. This means we hadn't actually spawned // the compute thread yet. [TODO] maybe this should happen another way? // 3) the timestamp increment since we spawned the current comput thread. // Discard the result and spawn a new compute. bool use_result = (returnMesh != null) && (active_thread_data != null) && (active_thread_data.timestamp == result_timestamp); if (use_result) { result_valid = true; } else { result_valid = false; spawn_new_compute = true; } active_thread_data = null; LastComputeExceptions = ActiveComputeExceptions; ActiveComputeExceptions = null; } if (spawn_new_compute) { spawn_recompute(); } if (returnMesh == null) { return((computing) ? DMeshOutputStatus.Computing() : DMeshOutputStatus.Unavailable()); } else { return(DMeshOutputStatus.Ready(returnMesh, LastComputeExceptions)); } } }