private void SplitWall(Wall newWall, List <Point> intersectionPoints)
 {
     if (!newWall.Beginning().Equals(intersectionPoints.First()))
     {
         InsertUnintersectedWall(new Wall(newWall.Beginning(), intersectionPoints.First()));
     }
     for (int i = 0; i < intersectionPoints.Count - 1; i++)
     {
         CreateAndPlaceWall(intersectionPoints[i], intersectionPoints[i + 1]);
     }
     if (!intersectionPoints.Last().Equals(newWall.End()))
     {
         CreateAndPlaceWall(intersectionPoints.Last(), newWall.End());
     }
 }
Ejemplo n.º 2
0
        private bool SharesSpace(Wall otherWall)
        {
            bool overlaps = Equals(otherWall);

            overlaps |= DoesContainPoint(otherWall.Beginning()) || DoesContainPoint(otherWall.End());
            overlaps |= otherWall.DoesContainPoint(Beginning()) || otherWall.DoesContainPoint(End());
            return(overlaps);
        }
 private void PartWall(Wall aWall, Point splitPoint)
 {
     // we are replacing the old walls with two halves
     materials.RemoveWall(aWall);
     openingManager.RemoveOpening(splitPoint);
     CreateAndPlaceWall(aWall.Beginning(), splitPoint);
     CreateAndPlaceWall(splitPoint, aWall.End());
 }
        private void PlaceUnintersectedWall(Wall aWall)
        {
            Beam BeginningBeam = new Beam(aWall.Beginning());
            Beam EndBeam       = new Beam(aWall.End());

            PlaceBeamIfNotExists(BeginningBeam);
            PlaceBeamIfNotExists(EndBeam);
            materials.AddWall(aWall);
        }
        public void RemoveWall(Point from, Point to)
        {
            Wall aWall = new Wall(from, to);

            if (materials.ContainsWall(aWall))
            {
                materials.RemoveWall(aWall);
                openingManager.RemoveOpeningsOfWall(aWall);
                AdjustIntersection(aWall.Beginning());
                AdjustIntersection(aWall.End());
            }
        }
Ejemplo n.º 6
0
        //this method uses vector algebra to get the piece of wall ocuppied by an opening
        private Wall PieceOfOccupiedWall(Opening anOpening, Wall itsWall)
        {
            float opLength         = anOpening.Length();
            Point beginning        = itsWall.Beginning();
            Point end              = itsWall.End();
            Point positiveVector   = beginning - end;
            Point negativeVector   = end - beginning;
            Point beginningOfPiece = anOpening.GetPosition().PointInSameLineAtSomeDistance(negativeVector, opLength / 2);
            Point endOfPiece       = anOpening.GetPosition().PointInSameLineAtSomeDistance(positiveVector, opLength / 2);
            Wall  piece            = new Wall(beginningOfPiece, endOfPiece);

            return(piece);
        }
Ejemplo n.º 7
0
        public Wall MergeCollinearContinuous(Wall otherWall)
        {//as beginning is closer to origin than end, this logic always work
            Point newBeginning;
            Point newEnd;

            if (Beginning().IsCloserToOriginThan(otherWall.Beginning()))
            {
                newBeginning = Beginning();
                newEnd       = otherWall.End();
            }
            else
            {
                newBeginning = otherWall.Beginning();
                newEnd       = End();
            }
            return(new Wall(newBeginning, newEnd));
        }
        private void MergeWalls(Wall wall1, Wall wall2)
        {
            Point intersection;

            if (wall1.Beginning().Equals(wall2.Beginning()) || wall1.Beginning().Equals(wall2.End()))
            {
                intersection = wall1.Beginning();
            }
            else
            {
                intersection = wall1.End();
            }

            Wall newWall = wall1.MergeCollinearContinuous(wall2);

            materials.RemoveWall(wall1);
            materials.RemoveWall(wall2);
            RemoveBeamInPoint(intersection);
            materials.AddWall(newWall);
        }
        private void InsertOversizedWall(Wall newWall)
        {
            int   maxLengthWallsCount   = (int)(newWall.Length() / Constants.MAX_WALL_LENGTH);
            float lengthOfRemainingWall = newWall.Length() % Constants.MAX_WALL_LENGTH;
            Point vector = newWall.End() - newWall.Beginning();
            Point from   = newWall.Beginning();
            Point to;

            for (int i = 0; i < maxLengthWallsCount; i++)
            {
                to = from.PointInSameLineAtSomeDistance(vector, Constants.MAX_WALL_LENGTH);
                CreateAndPlaceWall(from, to);
                from = to;
            }
            if (lengthOfRemainingWall > 0)
            {
                to = from.PointInSameLineAtSomeDistance(vector, lengthOfRemainingWall);
                CreateAndPlaceWall(from, to);
            }
        }
Ejemplo n.º 10
0
 private bool OutOfWallBorder(Wall occupied, Wall entire)
 {
     return(occupied.DoesContainPoint(entire.Beginning()) || occupied.DoesContainPoint(entire.End()));
 }
Ejemplo n.º 11
0
 public bool IsConnected(Wall otherWall)
 {
     return(BelongsToEdge(otherWall.Beginning()) || BelongsToEdge(otherWall.End()));
 }
        private bool TakesAColumnPlace(Wall newWall)
        {
            bool existColumnInWallPlace = false;

            foreach (ISinglePointComponent column in materials.GetColumns())
            {
                if (newWall.DoesContainComponent(column) || column.GetPosition().Equals(newWall.End()) || column.GetPosition().Equals(newWall.Beginning()))
                {
                    existColumnInWallPlace = true;
                }
            }
            return(existColumnInWallPlace);
        }
 private bool WallInRange(Wall newWall)
 {
     return(PointInRange(newWall.Beginning()) && PointInRange(newWall.End()));
 }
 private void PlaceNewWall(Wall newWall)
 {
     PlaceUnintersectedWall(newWall);
     AdjustIntersection(newWall.Beginning());
     AdjustIntersection(newWall.End());
 }