Beispiel #1
0
        virtual protected DMesh3 make_shape_arrow()
        {
            float radius       = (float)ShapeWidth / 2;
            float total_height = (float)ShapeHeight;
            float head_height  = total_height * (0.4f);
            float stick_height = total_height * (0.6f);
            float tip_radius   = radius * 0.01f;
            float stick_radius = radius * 0.5f;

            Vector3d origin = new Vector3d(0, ShapeHeight / 2, 0);
            Radial3DArrowGenerator arrowgen = new Radial3DArrowGenerator()
            {
                HeadBaseRadius   = radius, TipRadius = tip_radius, HeadLength = head_height,
                StickRadius      = stick_radius, StickLength = stick_height,
                Slices           = Math.Max(2, Subdivisions),
                NoSharedVertices = false,
                Clockwise        = true
            };
            DMesh3 mesh = arrowgen.Generate().MakeDMesh();;
            // fuuuuck
            MeshAutoRepair repair = new MeshAutoRepair(mesh);

            repair.Apply();
            return(mesh);
        }
Beispiel #2
0
        protected virtual void LoadMesh(CommandLineOptions o, out DMesh3 mesh)
        {
            if (printGeneratorManager.AcceptsParts)
            {
                string fMeshFilePath = Path.GetFullPath(o.MeshFilePath);
                ConsoleWriteSeparator();
                logger.WriteLine($"PARTS");
                logger.WriteLine();

                logger.Write("Loading mesh " + fMeshFilePath + "...");
                mesh = StandardMeshReader.ReadMesh(fMeshFilePath);
                logger.WriteLine(" done.");

                logger.Write("Repairing mesh... ");
                bool repaired = new MeshAutoRepair(mesh).Apply();
                logger.WriteLine(repaired ? "repaired." : "not repaired.");

                if (o.CenterXY)
                {
                    CenterMeshAboveOrigin(mesh);
                }
                if (o.DropZ)
                {
                    DropMeshToBuildPlate(mesh);
                }
            }
            else
            {
                mesh = null;
            }
        }
        public virtual void Update()
        {
            base.begin_update();
            int start_timestamp = this.CurrentInputTimestamp;

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

            try {
                DMesh3 inputmesh = MeshSource.GetDMeshUnsafe();

                DMesh3 meshIn = new DMesh3(inputmesh);

                MeshAutoRepair repair = new MeshAutoRepair(meshIn);
                repair.RemoveMode        = (MeshAutoRepair.RemoveModes)(int) remove_inside_mode;
                repair.MinEdgeLengthTol  = min_edge_length;
                repair.ErosionIterations = erosion_iters;
                repair.Progress          = new ProgressCancel(is_invalidated);

                bool bOK = repair.Apply();

                if (bOK && invert_result)
                {
                    meshIn.ReverseOrientation(true);
                }

                if (is_invalidated())
                {
                    meshIn = null;
                }

                if (bOK)
                {
                    ResultMesh = meshIn;
                }
                else
                {
                    ResultMesh = base.make_failure_output(inputmesh);
                }
                base.complete_update();
            } catch (Exception e) {
                PostOnOperatorException(e);
                ResultMesh = base.make_failure_output(MeshSource.GetDMeshUnsafe());
                base.complete_update();
            }
        }