Ejemplo n.º 1
0
 public GraphTubeMesher(GraphSupportGenerator support_gen)
 {
     Graph               = support_gen.Graph;
     TipVertices         = support_gen.TipVertices;
     GroundVertices      = support_gen.GroundVertices;
     SamplerCellSizeHint = support_gen.CellSize;
 }
Ejemplo n.º 2
0
        public virtual void Update()
        {
            base.begin_update();
            int start_timestamp = this.CurrentInputTimestamp;

            if (MeshSource == null)
            {
                throw new Exception("GenerateGraphSupportsOp: must set valid MeshSource to compute!");
            }

            try {
                ResultMesh = null;

                DMesh3 mesh = MeshSource.GetDMeshUnsafe();

                GraphSupportGenerator supportgen = new GraphSupportGenerator(mesh, get_cached_spatial(), GridCellSize);
                supportgen.OverhangAngleDeg           = this.overhang_angle;
                supportgen.ForceMinY                  = (float)this.min_y;
                supportgen.ProcessBottomUp            = this.bottom_up;
                supportgen.OverhangAngleOptimizeDeg   = this.support_min_angle;
                supportgen.OptimizationRounds         = this.optimize_rounds;
                supportgen.GraphSurfaceDistanceOffset = this.post_diam / 2 + surface_offset_distance;

                supportgen.Progress = new ProgressCancel(is_invalidated);
                supportgen.Generate();
                DGraph3 graph = supportgen.Graph;

                if (is_invalidated())
                {
                    goto skip_to_end;
                }

                GraphTubeMesher mesher = new GraphTubeMesher(supportgen);
                mesher.TipRadius           = this.tip_diam / 2;
                mesher.PostRadius          = this.post_diam / 2;
                mesher.GroundRadius        = this.base_diam / 2;
                mesher.SamplerCellSizeHint = supportgen.CellSize / 2;
                mesher.Progress            = new ProgressCancel(is_invalidated);
                mesher.Generate();

                if (is_invalidated())
                {
                    goto skip_to_end;
                }

                ResultMesh = mesher.ResultMesh;
                Reducer reducer = new Reducer(ResultMesh);
                reducer.Progress = new ProgressCancel(is_invalidated);
                reducer.ReduceToEdgeLength(mesher.ActualCellSize / 2);

skip_to_end:
                if (is_invalidated())
                {
                    ResultMesh = null;
                }
                base.complete_update();
            } catch (Exception e) {
                PostOnOperatorException(e);
                ResultMesh = base.make_failure_output(MeshSource.GetDMeshUnsafe());
                base.complete_update();
            }
        }