Пример #1
0
        public void abmsurfbuilder_buildfromBoundingBox_returnSurf()
        {
            double xMin = -1.0;
            double yMin = -2.0;

            double xMax = 1.0;
            double yMax = 2.0;

            meshSize = .005;
            min      = new Vector3(xMin, yMin, 0);
            max      = new Vector3(xMax, yMax, 0);

            Surface2D <SurfacePoint> surface = Surface2DBuilder <SurfacePoint> .Build(new BoundingBox(min, max), meshSize);


            Assert.AreEqual(xMin, surface.Min.X);
            Assert.AreEqual(yMin, surface.Min.Y);
        }
        private List <ModelPathEntity> parseArc(double increment, PathEntity5Axis entity, CNCLib.XYZBCMachPosition startPoint)
        {
            try
            {
                List <ModelPathEntity> path = new List <ModelPathEntity>();
                ArcPathEntity          arc  = entity as ArcPathEntity;
                Vector3 vEnd       = new GeometryLib.Vector3(arc.Position.X, arc.Position.Y, arc.Position.Z);
                Vector3 vStart     = new Vector3(startPoint.X, startPoint.Y, startPoint.Z);
                double  segLength  = Math.Abs(arc.SweepAngle * arc.Radius);
                int     parseCount = (int)Math.Round(segLength / increment);
                if (parseCount == 0)
                {
                    parseCount = 1;
                }
                double dA = arc.SweepAngle / parseCount;

                for (int j = 0; j < parseCount; j++)
                {
                    ModelPathEntity pathSeg = new ModelPathEntity(arc);

                    pathSeg.Position = getNewArcEndpoint(arc, j * dA);
                    if (entity.JetOn == true)
                    {
                        pathSeg.JetOn = true;
                    }
                    else
                    {
                        pathSeg.JetOn = false;
                    }
                    path.Add(pathSeg);
                }
                return(path);
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #3
0
        /// <summary>
        /// return true and blocktype if line is a g-code line
        /// </summary>
        /// <param name="ncLine">line from program</param>
        /// <param name="blockT">block type</param>
        /// <returns>true if line is part of path</returns>

        private void CalcSweepAngle(ref ArcPathEntity arc, IMachinePosition startPoint)
        {
            Vector3 vRadius    = new Vector3();
            double  startAngle = 0;
            double  endAngle   = 0;
            double  radius     = 0;
            double  sweep      = 0;

            double dxprev = 0;
            double dyprev = 0;
            double dzprev = 0;

            Vector3 vEnd   = new GeometryLib.Vector3(arc.Position.X, arc.Position.Y, arc.Position.Z);
            Vector3 vStart = new Vector3(startPoint.X, startPoint.Y, startPoint.Z);

            switch (arc.ArcType)
            {
            case ArcSpecType.IJKAbsolute:

                arc.CenterPoint = new GeometryLib.Vector3(arc.Position.X - arc.Icoordinate, arc.Position.Y - arc.Jcoordinate, arc.Position.Z - arc.Kcoordinate);
                arc.Radius      = vEnd.Length;
                radius          = arc.Radius;
                dxprev          = startPoint.X - arc.Icoordinate;
                dyprev          = startPoint.Y - arc.Jcoordinate;
                dzprev          = startPoint.Z - arc.Kcoordinate;

                break;

            case ArcSpecType.Radius:

                break;

            case ArcSpecType.NCI:
                vRadius    = new Vector3(arc.Position.X - arc.CenterPoint.X, arc.Position.Y - arc.CenterPoint.Y, arc.Position.Z - arc.CenterPoint.Z);
                arc.Radius = vRadius.Length;
                break;

            default:
            case ArcSpecType.IJKRelative:
                vRadius         = new GeometryLib.Vector3(arc.Icoordinate, arc.Jcoordinate, arc.Kcoordinate);
                arc.Radius      = vRadius.Length;
                arc.CenterPoint = new Vector3(startPoint.X + arc.Icoordinate, startPoint.Y + arc.Jcoordinate, startPoint.Z + arc.Kcoordinate);
                break;
            }
            switch (arc.ArcPlane)
            {
            case ArcPlane.XY:
                startAngle = Math.Atan2(vStart.Y - arc.CenterPoint.Y, vStart.X - arc.CenterPoint.X);
                endAngle   = Math.Atan2(vEnd.Y - arc.CenterPoint.Y, vEnd.X - arc.CenterPoint.X);
                break;

            case ArcPlane.XZ:
                startAngle = Math.Atan2(vStart.Z - arc.CenterPoint.Z, vStart.X - arc.CenterPoint.X);
                endAngle   = Math.Atan2(vEnd.Z - arc.CenterPoint.Z, vEnd.X - arc.CenterPoint.X);
                break;

            case ArcPlane.YZ:
                startAngle = Math.Atan2(vStart.Z - arc.CenterPoint.Z, vStart.Y - arc.CenterPoint.Y);
                endAngle   = Math.Atan2(vEnd.Z - arc.CenterPoint.Z, vEnd.Y - arc.CenterPoint.Y);
                break;
            }
            sweep = endAngle - startAngle;

            if (arc.Type == BlockType.CWARC)
            {
                sweep = 2 * Math.PI - sweep;
                if (sweep > 0)
                {
                    sweep = -1 * sweep;
                }
            }
            else
            {
                if (sweep < 0)
                {
                    sweep = Math.Abs(sweep);
                }
            }

            if (arc.FullArcFlag)
            {
                sweep = 2 * Math.PI;
            }

            arc.SweepAngle    = sweep;
            arc.StartAngleRad = startAngle;
        }
Пример #4
0
 void init()
 {
     min      = new GeometryLib.Vector3(-1, -1, 0);
     max      = new GeometryLib.Vector3(1, 1, 0);
     meshSize = .005;
 }