void optimizer_PlacementDone(object o) { optimizer.BoxLookAhead -= optimizer_BoxLookAhead; optimizer.PlacementDone -= optimizer_PlacementDone; optimizer = null; Clients.Caller.placementDone(); }
private void createOptimizer(string fileName, InitParams init, ProjectClass project = null) { //if (Session[OPTIMIZER] == null) //{ if (init.Stage == 1) { project = getProject(); } optimizer = new ColoOptimizer(fileName, init, project); Session[OPTIMIZER] = optimizer; // } // else // { // optimizer = Session[OPTIMIZER] as ColoOptimizer; // } }
public ActionResult GetLayers(string fileName) { InitParams ip = new InitParams() { FileName = fileName.Replace(".dxf", "") }; string fullFileName = getFileName(ip); optimizer = new ColoOptimizer(fullFileName); return(new JsonResult { JsonRequestBehavior = JsonRequestBehavior.AllowGet, Data = new { layers = optimizer.LayerNames } }); }
private void startColoOptimizer(InitParams init) { //XElement cfg = new XElement("Cfg", // new XElement("StaticLayers", // new XElement("Layer", "Layer 4", new XAttribute("IsUniverse", "True")), // new XElement("Layer", "pillars") // ), // new XElement("ColdWidth", "22"), // new XElement("SpaceAfterObstacle", "4"), // //new XElement("Direction", "R2L") //can be R2L or L2R // new XElement("Direction","L2R") //can be R2L or L2R //); //string fileName = @"..\..\Ken-L-Room-One-Pillar.dxf"; //string fileName = @"..\..\Ken-T-Room-One-Pillar-Lots-O-Racks.dxf"; //string fileName = @"..\..\Ken-Tough-Room.dxf"; //string fileName = @"..\..\32Degree-room.dxf"; string fileName = System.Web.HttpContext.Current.Server.MapPath(@"..\api\Ken-Tough-Room-Vertical-v2.dxf"); optimizer = new ColoOptimizer(fileName, init); optimizer.BoxLookAhead += optimizer_BoxLookAhead; optimizer.PlacementDone += optimizer_PlacementDone; }
internal void Move2NextLocation(Point nextLocation, ColoBox boxToPlace, ColoOptimizer optimizer, int boxId, int indexToStop) { if (boxId == 47) { } bool isValid = false; Point calcNextLocation = nextLocation; //isInsideBoundingBox = true; locationMachine.CurrentBoxToPlace = boxToPlace; //reseting the flag indicates we are hitting a tilted wall isMeetingTiltedWall = false; int i = 0; while (!isValid) { //opening a rack space if it required if (locationMachine.NeedOpenRackSpace) { calcNextLocation.X += locationMachine.direction.GetNextRackLocationAfterSpace(locationMachine.InitParam.RacksOpenningSpace); locationMachine.RacksCountBeforeSpace = 0; } boxToPlace.MoveOriginTo(calcNextLocation); //if (locationMachine.ROWSTARTS.IsAdvancedFromFirstPositionInALine) //{ // locationMachine.AssertBoxLocation(); //} //optimizer.OnBoxLookAhead(boxToPlace.PointsCollection, boxId,false); //this call makes sure that if a box cross a line either to outside the bounding box, or back inside, we are updating the state accordingly Point?nextAfterGap = locationMachine.UpdateMachineState(boxToPlace); if (nextAfterGap.HasValue) { locationMachine.RacksCountBeforeSpace = 0; boxToPlace.MoveOriginTo(nextAfterGap.Value); locationMachine.INSIDEBOUNDINGBOX.SetCurrent(); if (nextSpaceValid(boxToPlace)) { locationMachine.ResetOverride(); break; } locationMachine.INSIDEBOUNDINGBOX.SetCurrent(); } if (locationMachine.currentState == locationMachine.ROWSTARTS) { locationMachine.ROWSTARTS.IsAdvancedFromFirstPositionInALine = true; } //if we are in a situation that we are placing outside the bounding box (and there is more space to place inside) //we need to verify if we crossed back into the internal side of the bounding box. if we did, switch the stateMachine to indicate //that state (inside the box) //if (locationMachine.CurrentlyOutsideTheBox) //{ // if (locationMachine.LocationWithinBoundingBox) // { // locationMachine.INSIDEBOUNDINGBOX.SetCurrent(); // } //} ++i; if (i > indexToStop) { // break; } if (nextSpaceValid(boxToPlace)) { locationMachine.NextState(); //if we are out of the bounding box, the break should not hit until we either step out of the outer bounding box or until //we got back in if (!locationMachine.IsSteppedOutBoundingBox) { break; } } calcNextLocation = locationMachine.NextLocation; if (calcNextLocation.X == locationMachine.direction.ExtremeX) { throw new ExtremeFoundException(); } locationMachine.ResetOverride(); } locationMachine.RacksCountBeforeSpace++; }