Example #1
0
        public void AddSupport()
        {
            Cylinder3d cyl = new Cylinder3d();

            cyl.Create(2.5, 1.5, 10, 15, 2);
            m_engine3d.AddObject(cyl);
            RaiseAppEvent(eAppEvent.eModelLoaded, "Model Created");
        }
Example #2
0
 public DistPoint3Cylinder3(Vector3D PointIn, Cylinder3d CylinderIn)
 {
     point = PointIn; cylinder = CylinderIn;
 }
Example #3
0
        /*
         * To start, we're going to intersect the entire scene and generate support objects
         * we can change this to generate support for individual objects if needed.
         */
        public ArrayList GenerateSupportObjects()
        {
            // ArrayList objects = new ArrayList();
            // iterate over the platform size by indicated mm step; // projected resolution in x,y
            // generate a 3d x/y point on z=0,
            // generate another on the z=zmax
            // use this ray to intersect the scene
            // foreach intersection point, generate a support
            // we gott make sure supports don't collide
            // I also have to take into account the
            // interface between the support and the model
            ArrayList lstsupports = new ArrayList();

            // double HX =  UVDLPApp.Instance().m_printerinfo.m_PlatXSize / 2; // half X size
            //  double HY =  UVDLPApp.Instance().m_printerinfo.m_PlatYSize / 2; // half Y size
            double ZVal = UVDLPApp.Instance().m_printerinfo.m_PlatZSize;


            //UVDLPApp.Instance().CalcScene();
            m_model.Update();
            double MinX = m_model.m_min.x;
            double MaxX = m_model.m_max.x;
            double MinY = m_model.m_min.y;
            double MaxY = m_model.m_max.y;

            bool intersected = false;
            int  scnt        = 0; // support count
            // iterate from -HX to HX step xtep;
            double dts     = (MaxX - MinX) / m_sc.xspace;
            int    its     = (int)dts;
            int    curstep = 0;

            for (double x = (MinX + (m_sc.xspace / 2)); x < MaxX; x += m_sc.xspace)
            {
                RaiseSupportEvent(UV_DLP_3D_Printer.SupportEvent.eProgress, "" + curstep + "/" + its, null);
                curstep++;
                for (double y = (MinY + (m_sc.yspace / 2)); y < MaxY; y += m_sc.yspace)
                {
                    Point3d bpoint, tpoint;
                    Point3d lowest = new Point3d(); // the lowest point of intersection on the z axis

                    bpoint = new Point3d();         // bottom point
                    tpoint = new Point3d();         // top point
                    bpoint.Set(x, y, 0.0, 1);
                    tpoint.Set(x, y, ZVal, 1);      // set to the max height
                    //intersect the scene with a ray

                    lowest.Set(0, 0, ZVal, 0);
                    intersected = false; // reset the intersected flag to be false
                    foreach (Polygon p in m_model.m_lstpolys)
                    {
                        Point3d intersect = new Point3d();
                        // try a less- costly sphere intersect here
                        if (RTUtils.IntersectSphere(bpoint, tpoint, ref intersect, p.m_center, p.m_radius))
                        {
                            // if it intersects,
                            if (RTUtils.IntersectPoly(p, bpoint, tpoint, ref intersect))
                            {
                                // and it's the lowest one
                                if (intersect.z <= lowest.z)
                                {
                                    //save this point
                                    intersected = true;
                                    lowest.Set(intersect);
                                }
                            }
                        }
                    }
                    // for some reason, we're getting negatively generating cylinders
                    // that extend to the -Z world axis
                    // and we're also unnessary support generate on the y -axis that
                    // do not intersect objects vertically in the x/y plane

                    if ((lowest.z < ZVal) && intersected && (lowest.z >= 0))
                    {
                        // now, generate and add a cylinder here
                        Cylinder3d cyl = new Cylinder3d();
                        cyl.Create(m_sc.brad, m_sc.trad, lowest.z, 20, m_sc.vdivs);
                        cyl.Translate((float)x, (float)y, 0);
                        cyl.Name      = "Support " + scnt;
                        cyl.IsSupport = true;
                        cyl.SetColor(Color.Yellow);
                        scnt++;
                        lstsupports.Add(cyl);
                        RaiseSupportEvent(UV_DLP_3D_Printer.SupportEvent.eSupportGenerated, cyl.Name, cyl);
                    }
                }
            }
            // return objects;
            RaiseSupportEvent(UV_DLP_3D_Printer.SupportEvent.eCompleted, "Support Generation Completed", null);
            m_generating = false;
            return(lstsupports);
        }
        /*
         * To start, we're going to intersect the entire scene and generate support objects
         * we can change this to generate support for individual objects if needed.
         */
        public static void GenerateSupportObjects(double xstep, double ystep)
        {
            // ArrayList objects = new ArrayList();
            // iterate over the platform size by indicated mm step; // projected resolution in x,y
            // generate a 3d x/y point on z=0,
            // generate another on the z=zmax
            // use this ray to intersect the scene
            // foreach intersection point, generate a support
            // we gott make sure supports don't collide
            // I also have to take into account the
            // interface between the support and the model

            double HX   = UVDLPApp.Instance().m_printerinfo.m_PlatXSize / 2; // half X size
            double HY   = UVDLPApp.Instance().m_printerinfo.m_PlatYSize / 2; // half Y size
            double ZVal = UVDLPApp.Instance().m_printerinfo.m_PlatZSize;

            UVDLPApp.Instance().CalcScene();
            bool intersected = false;

            // iterate from -HX to HX step xtep;
            for (double x = -HX; x < HX; x += xstep)
            {
                for (double y = -HY; y < 0 /*HY*/; y += ystep)
                {
                    Point3d bpoint, tpoint;
                    Point3d lowest = new Point3d(); // the lowest point of intersection on the z axis

                    bpoint = new Point3d();         // bottom point
                    tpoint = new Point3d();         // top point
                    bpoint.Set(x, y, 0.0, 1);
                    tpoint.Set(x, y, ZVal, 1);      // set to the max height
                    //intersect the scene with a ray

                    lowest.Set(0, 0, ZVal, 0);
                    intersected = false;
                    foreach (Polygon p in UVDLPApp.Instance().Scene.m_lstpolys)
                    {
                        Point3d intersect = new Point3d();
                        // try a less- costly sphere intersect here
                        if (RTUtils.IntersectSphere(bpoint, tpoint, ref intersect, p.m_center, p.m_radius))
                        {
                            // if it intersects,
                            if (RTUtils.IntersectPoly(p, bpoint, tpoint, ref intersect))
                            {
                                // and it's the lowest one
                                if (intersect.z <= lowest.z)
                                {
                                    //save this point
                                    intersected = true;
                                    lowest.Set(intersect);
                                }
                            }
                        }
                    }
                    // for some reason, we're getting negatively generating cylinders
                    // that extend to the -Z world axis
                    // and we're also unnessary support generate on the y -axis that
                    // do not intersect objects vertically in the x/y plane

                    if ((lowest.z < ZVal) && intersected && (lowest.z >= 0))
                    {
                        // now, generate and add a cylinder here
                        Cylinder3d cyl = new Cylinder3d();
                        cyl.Create(1, .5, lowest.z, 20, 1);
                        cyl.Translate((float)x, (float)y, 0);
                        UVDLPApp.Instance().Engine3D.AddObject(cyl);
                    }
                }
            }
            // return objects;
        }