public Variables(double maxspace, Data.Cord stdloc, int beds, int rests, bool simple, string design, string roof) { MaxSpace = maxspace; WorldStdLocation = stdloc; how_many_bed = beds; how_many_rest = rests; is_simple = simple; RoomSize = new RoomSize(MaxSpace, how_many_bed, how_many_rest); RelationShipVariables = new RelationVar(); FloorMaterials = new Dictionary <Space.RoomType, Dictionary <string, string> >(); WallMaterials = new Dictionary <Space.RoomType, Dictionary <string, string> >(); FixedwindowMaterials = new Dictionary <Space.RoomType, Dictionary <string, string> >(); FlatroofMaterials = new Dictionary <Space.RoomType, Dictionary <string, string> >(); FullstairMaterials = new Dictionary <Space.RoomType, Dictionary <string, string> >(); StaticComponents = new Dictionary <StaticCompType, string>(); //디자인 템플렛에 맞추어, Material을 결정 DecideMaterialSet(design); //디자인 템플렛에 맞추어, Door이나 Window 타입을 결정 DecideStaticSet(design); RoofType = roof; }
/* * public void WriteRoom(Space.Room room) * { * writer.WriteStartElement("Room"); * * * this.WriteFloor(room.Floor); * * foreach(Model.Wall wall in room.Walls) * { * this.WriteWall(wall); * } * * * foreach (Model.Modelable model in room.Components) * { * model.WriteModel(this); * } * * writer.WriteEndElement(); * } * * public void WriteWall(Model.Wall wall) * { * writer.WriteStartElement("Wall"); * this.WriteVector("Start", wall.Start); * this.WriteVector("End", wall.End); * writer.WriteElementString("Width", XmlConvert.ToString(wall.Width)); * writer.WriteElementString("Height", XmlConvert.ToString(wall.Height)); * * writer.WriteStartElement("Holes"); * foreach (Data.Hole hole in wall.Holes) * { * writer.WriteStartElement("Hole"); * * writer.WriteElementString("x", XmlConvert.ToString(hole.X)); * writer.WriteElementString("y", XmlConvert.ToString(hole.Y)); * writer.WriteElementString("l", XmlConvert.ToString(hole.L)); * writer.WriteElementString("h", XmlConvert.ToString(hole.H)); * * writer.WriteEndElement(); * } * writer.WriteEndElement(); * * this.WriteMaterials(wall.Materials); * * writer.WriteEndElement(); * } * * public void WriteFloor(Model.Floor floor) * { * writer.WriteStartElement("Floor"); * * this.WriteVector("Location", floor.Location); * * writer.WriteStartElement("Move"); * writer.WriteElementString("x", "0"); * writer.WriteElementString("y", "0"); * writer.WriteElementString("z", XmlConvert.ToString(floor.Thickness)); * writer.WriteEndElement(); * * this.WriteVertices(floor.Vertices); * * this.WriteMaterials(floor.Materials); * * writer.WriteEndElement(); * } */ public void WriteVector(string vectorName, Data.Cord vector) { Writer.WriteStartElement(vectorName); Writer.WriteElementString("x", XmlConvert.ToString(vector.X)); Writer.WriteElementString("y", XmlConvert.ToString(vector.Y)); Writer.WriteElementString("z", XmlConvert.ToString(vector.Z)); Writer.WriteEndElement(); }
public Blueprint(Data.Cord worldCord) { this.WorldLocation = worldCord; this.Relations = new Dictionary <Space.RelationLevel, List <Space.RoomRelationShip> >(); foreach (Space.RelationLevel lv in Enum.GetValues(typeof(Space.RelationLevel))) { Relations.Add(lv, new List <Space.RoomRelationShip>()); } }
public Side(SideCardinalDirection position, SideType type, Cord start, Cord end) { this.Position = position; this.Type = type; Cord absP1 = (Cord)start.Clone(); Cord absP2 = (Cord)end.Clone(); double x1 = Math.Min(absP1.X, absP2.X); double x2 = Math.Max(absP1.X, absP2.X); double y1 = Math.Min(absP1.Y, absP2.Y); double y2 = Math.Max(absP1.Y, absP2.Y); Start = new Cord(x1, y1, absP1.Z); End = new Cord(x2, y2, absP2.Z); }
public object Clone() { Data.Cord tempStdLoc = WorldLocation; Dictionary <Space.RelationLevel, List <Space.RoomRelationShip> > tempRel = new Dictionary <Space.RelationLevel, List <Space.RoomRelationShip> >(); foreach (KeyValuePair <Space.RelationLevel, List <Space.RoomRelationShip> > entry in Relations) { List <Space.RoomRelationShip> list = new List <Space.RoomRelationShip>(); foreach (Space.RoomRelationShip target in entry.Value) { list.Add((Space.RoomRelationShip)target.Clone()); } tempRel.Add(entry.Key, list); } //TODO: 새로운 블루프린트를 만들 때, Relations 복사가 중복계산된다. return(new Blueprint(tempStdLoc, Writer, tempRel)); }
public Blueprint(Data.Cord worldstdloc, MyXmlWriter wirter, Dictionary <Space.RelationLevel, List <Space.RoomRelationShip> > rels) { this.WorldLocation = worldstdloc; Dictionary <Space.RelationLevel, List <Space.RoomRelationShip> > relations = new Dictionary <Space.RelationLevel, List <Space.RoomRelationShip> >(); foreach (KeyValuePair <Space.RelationLevel, List <Space.RoomRelationShip> > entry in rels) { List <Space.RoomRelationShip> list = new List <Space.RoomRelationShip>(); foreach (Space.RoomRelationShip rel in entry.Value) { list.Add(rel); } relations.Add(entry.Key, list); } this.Relations = relations; this.Writer = wirter; }
private List <Data.Cord> GetPosibleCords(Space.Room room, Data.Side target, bool is_simple) { List <Data.Cord> avalCords = new List <Data.Cord>(); Data.Cord start = new Data.Cord(); Data.Cord end = new Data.Cord(); switch (target.Position) { case Data.SideCardinalDirection.West: start = new Data.Cord(target.Start, -room.Size.Length, 0, 0); end = new Data.Cord(target.End, -room.Size.Length, -room.Size.Width, 0); break; case Data.SideCardinalDirection.North: start = new Data.Cord(target.Start, 0, 0, 0); end = new Data.Cord(target.End, -room.Size.Length, 0, 0); break; case Data.SideCardinalDirection.East: start = new Data.Cord(target.Start, 0, 0, 0); end = new Data.Cord(target.End, 0, -room.Size.Width, 0); break; case Data.SideCardinalDirection.South: start = new Data.Cord(target.Start, 0, -room.Size.Width, 0); end = new Data.Cord(target.End, -room.Size.Length, -room.Size.Width, 0); break; } avalCords.Add(start); avalCords.Add(end); if (!is_simple) { Data.Cord last = this.GetPosibleCord(avalCords, new Data.Side(target.Position, target.Type, start, end), Data.Config.MinimalOverlap); if (last != null) { avalCords.Add(last); } } return(avalCords); }
public Side GetContact(Side target) { if (this.IsParallelToX() && target.IsParallelToX()) { double max = Math.Max(this.Start.X, target.Start.X); double min = Math.Min(this.End.X, target.End.X); if (max < min) { Cord p1 = new Cord(min, this.Start.Y, this.Start.Z); Cord p2 = new Cord(max, this.End.Y, this.End.Z); return(new Side(this.Position, this.Type, p1, p2)); } else { return(null); } } else if (this.IsParallelToY() && target.IsParallelToY()) { double max = Math.Max(this.Start.Y, target.Start.Y); double min = Math.Min(this.End.Y, target.End.Y); if (max < min) { Cord p1 = new Cord(this.Start.X, min, this.Start.Z); Cord p2 = new Cord(this.End.X, max, this.End.Z); return(new Side(this.Position, this.Type, p1, p2)); } else { return(null); } } else { return(null); } }
private Data.Cord GetPosibleCord(List <Data.Cord> collect, Data.Side side, double length) { if (side.GetLength() < length) { return(null); } Data.Cord mid = side.GetMidCord(); Data.Cord before = GetPosibleCord(collect, new Data.Side(side.Position, side.Type, side.Start, mid), length); if (before != null) { collect.Add(before); } Data.Cord after = GetPosibleCord(collect, new Data.Side(side.Position, side.Type, mid, side.End), length); if (after != null) { collect.Add(after); } return(mid); }
/// <summary> /// define Cord to Relative /// </summary> public Cord(Cord Base, double relX, double relY, double relZ) { this.X = Base.X + relX; this.Y = Base.Y + relY; this.Z = Base.Z + relZ; }
public Config(Cord worldCord, double wallThick) { WallTickness = wallThick; WorldBase = worldCord; }
private void createModel(object sender, EventArgs e) { if (!Directory.EnumerateFiles(path).Any()) { DialogResult dialogResult = MessageBox.Show("Previous model already exist on " + path + "\nDo you want to overwrite on it?", "Create Models", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { System.IO.DirectoryInfo di = new DirectoryInfo(path); foreach (FileInfo file in di.GetFiles()) { file.Delete(); } } else if (dialogResult == DialogResult.No) { MessageBox.Show("Failed to create models because directory is not clean."); } } double x = System.Convert.ToDouble(this.numericUpDown_wsl_x.Value); double y = System.Convert.ToDouble(this.numericUpDown_wsl_y.Value); double z = System.Convert.ToDouble(this.numericUpDown_wsl_z.Value); Data.Cord worldloc = new Data.Cord(x, y, z); double max = System.Convert.ToDouble(this.numericUpDown_maxspace.Value); int bed = System.Convert.ToInt32(this.numericUpDown_bednum.Value); int rest = System.Convert.ToInt32(this.numericUpDown_restnum.Value); bool simple = true; if (this.radioButton_complicate.Checked) { simple = false; } else if (this.radioButton_simple.Checked) { simple = true; } string design = (string)this.comboBox_Design.SelectedItem; string roof = (string)this.comboBox_Roof.SelectedItem; Variables var = new Variables(max, worldloc, bed, rest, simple, design, roof); interpreter = new Interpreter(var); List <List <Blueprint> > all = interpreter.GenerateBlueprints(); //Debug Code int count = all.Count; /* * if (count > 50) * { * count = 50; * } */ for (int i = 0; i < count; i++) { for (int j = 0; j < all[i].Count; j++) { all[i][j].CreateXML(path + "\\test" + (i + 1) + "-" + (j + 1) + ".xml"); } } DialogResult closeit = MessageBox.Show("The calculations are complete. Do you want to close it?", "Archiva", MessageBoxButtons.YesNo); if (closeit == DialogResult.Yes) { this.Close(); } }
public List <Side> OccupyPart(Cord p1, Cord p2, SideType type) { return(OccupyPart(new Side(this.Position, this.Type, p1, p2), type)); }