示例#1
0
        public List <Model> MergeAllRoomPairs(Model m_mod)
        {
            int missinglargest = 0;

            m_mod.CalculateAllRooms();
            IEnumerable <int> enumerable = fullist.Except(m_mod.modelRooms.Select(i => i.GetNumberAsInt()));

            if (enumerable.Any())
            {
                missinglargest = enumerable.Max();
            }
            //missinglargest = m_mod.modelRooms.Select(i => int.Parse(i.Number)).Union(fullist).Max();
            List <Model> returnList = new List <Model>();

            for (var i = 0; i < m_mod.modelRooms.Count; i++)
            {
                MyRoom room = m_mod.modelRooms[i];
                if (room.GetNumberAsInt() < missinglargest)
                {
                    continue;
                }

                for (var j = i + 1; j < m_mod.modelRooms.Count; j++)
                {
                    MyRoom modelRoom = m_mod.modelRooms[j];
                    if (modelRoom.GetNumberAsInt() < missinglargest)
                    {
                        continue;
                    }
                    //if (room2.Guid == room1.Guid) continue;

                    bool a = DoTheyHaveCommmonWall(room, modelRoom);
                    if (!a)
                    {
                        continue;
                    }

                    else
                    {
                        MyRoom room2;
                        MyRoom modelRoom2;
                        Model  m_mod2 = m_mod.DeepCopy(room, modelRoom, out room2, out modelRoom2);

                        Model newModel = MergeRooms(m_mod2, room2, modelRoom2);
                        returnList.Add(newModel);
                    }
                }
            }

            return(returnList);
        }
示例#2
0
        private Model RemoveCommonWalls(Model m, MyRoom room1, MyRoom room2)
        {
            List <MyLine> common = room1.BoundaryLines.Intersect(room2.BoundaryLines).ToList();

            foreach (MyLine line in common)
            {
                room1.BoundaryLines.Remove(line);
                room2.BoundaryLines.Remove(line);
                m.modelLines.Remove(line);
                foreach (MyRoom room in m.modelRooms)
                {
                    room.BoundaryLines.Remove(line);
                }
                line.EndMyPoint.RelatedLines.Remove(line);
                line.StartMyPoint.RelatedLines.Remove(line);
            }
            room1.BoundaryLines.AddRange(room2.BoundaryLines);
            room2.BoundaryLines.AddRange(room1.BoundaryLines);

            int  result1;
            int  result2;
            bool parsed1 = int.TryParse(room1.Number, out result1);
            bool parsed2 = int.TryParse(room2.Number, out result2);

            if (parsed1 && parsed2 && (result1 < result2 && room2.GetNumberAsInt() != 2))
            {
                m.modelRooms.Remove(room2);
                foreach (MyLine line in m.modelLines)
                {
                    line.relatedRooms.Remove(room2);
                }
            }
            else
            {
                m.modelRooms.Remove(room1);
                foreach (MyLine line in m.modelLines)
                {
                    line.relatedRooms.Remove(room1);
                }
            }

            return(m);
        }