Esempio n. 1
0
        private void loadGraphicsObject(List <ColoBox> staticObjects, LayoutManager manager, List <ColoBox> boxes2relo)
        {
            foreach (ColoBox box in boxes)
            {
                if (staticLayers.Contains(box.Layer))// == "wals")
                {
                    //manager = new LayoutManager(box);
                    staticObjects.Add(box);
                    continue;
                }

                if (box.Layer == "racks")
                {
                    ColoBox cloned = box.Clone();
                    if (manager != null)
                    {
                        cloned.LayoutManager = manager;
                    }

                    boxes2relo.Add(cloned);
                }
            }
        }
Esempio n. 2
0
        public ColoOptimizer(string fileName, InitParams init, ProjectClass project = null)
        {
            this.fileName   = fileName;
            this.initParams = init;

            RawBorder.Tolerance = 0.5;//init.Tolerance;
            if (!init.UseExistingData)
            {
                try
                {
                    dxf = DxfDocument.Load(fileName);
                }
                catch (Exception)
                {
                }


                staticLayers = init.StaticLayers.Aggregate(new List <string>(), (lst, entry) => { lst.Add(entry.Name); if (entry.IsUniverse)
                                                                                                  {
                                                                                                      universeLayer = entry.Name;
                                                                                                  }
                                                                                                  return(lst); });
                boxes = new List <ColoBox>();
                loadPolylinesToBoxes(project);
            }
            else
            {
                //string sJson = File.ReadAllText(init.DataFile);
                Boxes2relo    = new List <ColoBox>();
                staticObjects = new List <ColoBox>();
                manager       = new LayoutManager(this.initParams);
                //loading all the Boxes2relo
                for (int i = 0; i < project.Racks.Length; ++i)
                {
                    Point p1 = new Point {
                        X = 0, Y = 0
                    };
                    Point p2 = new Point {
                    };
                    for (int j = 0; j < project.Racks[i].Quantity; ++j)
                    {
                        ColoBox box = new ColoBox("racks", i * j);
                        box.LayoutManager = manager;
                        double maxX = project.Racks[i].Width;
                        double maxY = project.Racks[i].Height;
                        box.AddPoint(0, 0);
                        box.AddPoint(maxX, 0);
                        box.AddPoint(maxX, maxY);
                        box.AddPoint(0, maxY);

                        Boxes2relo.Add(box);
                    }
                }

                //loading the universe
                ColoBox universeBox = new ColoBox();
                universeBox.LayoutManager = manager;
                for (int i = 0; i < project.UniverseNodes.Length; ++i)
                {
                    universeBox.AddPoint(project.UniverseNodes[i].X, project.UniverseNodes[i].Y);
                }
                staticObjects.Add(universeBox);


                //loading the obstacles
                ColoBox obst = null;
                for (int i = 0; i < project.Obstacles.Length; ++i)
                {
                    obst               = new ColoBox();
                    obst.Layer         = "pillar";
                    obst.LayoutManager = manager;
                    for (int j = 0; j < project.Obstacles[i].Points.Length; ++j)
                    {
                        obst.AddPoint(project.Obstacles[i].Points[j].X, project.Obstacles[i].Points[j].Y);
                    }
                    staticObjects.Add(obst);
                }
            }
        }
Esempio n. 3
0
        private void loadPolylinesToBoxes(ProjectClass project)
        {
            int id = 0;
            HashSet <string>  layerNames = new HashSet <string>();
            List <LwPolyline> polylines  = new List <LwPolyline>();


            List <Line> lines = new List <Line>();

            lines.AddRange(dxf.Lines);
            lines.AddRange(getAllBlockLines(dxf.Blocks));
            foreach (var line in lines)
            {
                if (!layerNames.Contains(line.Layer.Name))
                {
                    layerNames.Add(line.Layer.Name);
                }
                ColoBox box = new ColoBox(line.Layer.Name, id++);
                boxes.Add(box);
                box.AddPoint(line.StartPoint.X, line.StartPoint.Y);
                box.AddPoint(line.EndPoint.X, line.EndPoint.Y);
            }


            polylines.AddRange(dxf.LwPolylines);
            polylines.AddRange(getAllPolylines(dxf.Inserts));
            polylines.AddRange(getAllPolylinesFromBlocks(dxf.Blocks));



            //every Polyline from DXF turns into a box (ColoBox)
            foreach (LwPolyline pl in polylines)
            {
                if (!layerNames.Contains(pl.Layer.Name))
                {
                    layerNames.Add(pl.Layer.Name);
                }
                if (pl.Layer.Name == "Layer 4")
                {
                }
                ColoBox box = new ColoBox(pl.Layer.Name, id++);
                boxes.Add(box);
                foreach (var v in pl.Vertexes)
                {
                    box.AddPoint(v.Location.X, v.Location.Y);
                }
            }

            foreach (Spline sp in dxf.Splines)
            {
                if (!layerNames.Contains(sp.Layer.Name))
                {
                    layerNames.Add(sp.Layer.Name);
                }
                if (sp.Layer.Name == "Layer 4")
                {
                }
                ColoBox box = new ColoBox(sp.Layer.Name, id++);
                boxes.Add(box);
                foreach (var v in sp.ControlPoints)
                {
                    box.AddPoint(v.Location.X, v.Location.Y);
                }
            }

            Boxes2relo    = new List <ColoBox>();
            staticObjects = new List <ColoBox>();
            manager       = new LayoutManager(this.initParams);



            loadGraphicsObject(staticObjects, manager, Boxes2relo);
            if (initParams.Stage == 1 && project != null)
            {
                ColoBox bounding = new ColoBox();
                double  minX     = project.BoundingBox[0].X;
                double  minY     = project.BoundingBox[0].Y;
                double  maxX     = project.BoundingBox[1].X;
                double  maxY     = project.BoundingBox [1].Y;
                bounding.AddPoint(minX, minY);
                bounding.AddPoint(minX, maxY);
                bounding.AddPoint(maxX, maxY);
                bounding.AddPoint(maxX, minY);
                staticObjects.Add(bounding);
            }
        }