/// <summary> /// Checks the doors of the room template. /// </summary> /// <param name="outline"></param> /// <param name="doorMode"></param> /// <returns></returns> public static ActionResult CheckDoors(PolygonGrid2D outline, IDoorModeGrid2D doorMode) { var result = new ActionResult(); try { var doors = doorMode.GetDoors(outline); if (doors.Count == 0) { if (doorMode is SimpleDoorModeGrid2D) { result.AddError($"The simple door mode is used but there are no valid door positions. Try to decrease door length and/or corner distance."); } else { result.AddError($"The manual door mode is used but no doors were added."); } } } // TODO: this is not optimal - the argument exception might be something different than invalid manual doors catch (ArgumentException e) { if (doorMode is ManualDoorModeGrid2D) { result.AddError($"It seems like some of the manual doors are not located on the outline of the room template."); } else { result.AddError(e.Message); } } return(result); }
/// <summary> /// Computes configuration space of given two polygons. /// </summary> /// <param name="polygon"></param> /// <param name="doorsMode"></param> /// <param name="fixedCenter"></param> /// <param name="fixedDoorsMode"></param> /// <param name="offsets"></param> /// <returns></returns> public ConfigurationSpaceGrid2D GetConfigurationSpace(PolygonGrid2D polygon, IDoorModeGrid2D doorsMode, PolygonGrid2D fixedCenter, IDoorModeGrid2D fixedDoorsMode, List <int> offsets = null) { var doorLinesFixed = fixedDoorsMode.GetDoors(fixedCenter); var doorLines = doorsMode.GetDoors(polygon); return(GetConfigurationSpace(polygon, doorLines, fixedCenter, doorLinesFixed, offsets)); }
public ConfigurationSpace GetConfigurationSpaceOverCorridor(PolygonGrid2D polygon, IDoorModeGrid2D doorsMode, PolygonGrid2D fixedPolygon, IDoorModeGrid2D fixedDoorsMode, PolygonGrid2D corridor, IDoorModeGrid2D corridorDoorsMode) { var doorLines = doorsMode.GetDoors(polygon); var doorLinesFixed = fixedDoorsMode.GetDoors(fixedPolygon); var doorLinesCorridor = corridorDoorsMode.GetDoors(corridor); return(GetConfigurationSpaceOverCorridor(polygon, doorLines, fixedPolygon, doorLinesFixed, corridor, doorLinesCorridor)); }
/// <summary> /// Checks the doors of the room template. /// </summary> /// <param name="outline"></param> /// <param name="doorMode"></param> /// <param name="selectedDoorMode"></param> /// <returns></returns> public static ActionResult CheckDoors(PolygonGrid2D outline, IDoorModeGrid2D doorMode, DoorsGrid2D.DoorMode selectedDoorMode) { var result = new ActionResult(); try { var doors = doorMode.GetDoors(outline); if (doors.Count == 0) { if (selectedDoorMode == DoorsGrid2D.DoorMode.Simple) { result.AddError( $"The simple door mode is used but there are no valid door positions. Try to decrease door length and/or margin."); } else { result.AddError($"The {selectedDoorMode} door mode is used but no doors were added."); } } } catch (DoorLineOutsideOfOutlineException e) { if (selectedDoorMode == DoorsGrid2D.DoorMode.Manual) { result.AddError( $"It seems like some of the manual doors are not located on the outline of the room template."); } else if (selectedDoorMode == DoorsGrid2D.DoorMode.Hybrid) { result.AddError( $"It seems like some of the hybrid door lines are not located on the outline of the room template."); } else { result.AddError(e.Message); } } catch (DuplicateDoorPositionException e) { if (selectedDoorMode == DoorsGrid2D.DoorMode.Hybrid) { result.AddError("There are duplicate/overlapping door lines with the same door length and socket."); } else { result.AddError(e.Message); } } return(result); }
public static ActionResult CheckWrongManualDoors(PolygonGrid2D outline, IDoorModeGrid2D doorMode, out int differentLengthsCount) { var result = new ActionResult(); differentLengthsCount = -1; if (doorMode is ManualDoorModeGrid2D) { var doors = doorMode.GetDoors(outline); var differentLengths = doors.Select(x => x.Length).Distinct().ToList(); differentLengthsCount = differentLengths.Count; if (differentLengthsCount >= 3) { result.AddError($"There are {differentLengthsCount} different lengths of manual doors. Please make sure that this is intentional. This is often caused by an incorrect use of the manual door (see the warning in the Doors component)."); } } return(result); }