public EndothelialCell(Vector3 cellPosition, EndothelialCell.PipeOrientation orientation, float size, EndothelialCell parent)
     : base(cellPosition)
 {
     children = new List<EndothelialCell>();
     this.orientation = orientation;
     this.size = size;
     Environment.Instance.GetSectorAt(cellPosition).PipeValue += size;
     CirculatorySystem.Instance.PipeCells.Add(this);
     Environment.Instance.GetContentsAt(cellPosition).pipes.Add(this);
     travelingCells = new List<TissueCell>();
     this.parent = parent;
 }
        public CirculatorySystem(SimulationParameters.PipeParameters pipeParams, SimulationParameters.PipeLocations pipeCorners)
        {
            instance = this;

            this.pipeShrinkRate = pipeParams.PipeShrink;

            pipeCells = new List<EndothelialCell>();
            hungryCells = new List<TissueCell>();
            growingPipes = new List<GrowingPipe>();

            maxNumGrowthsPerTurn = pipeParams.MaxGrowthPerTurn;

            EndothelialCell root = new EndothelialCell(pipeCorners.location, pipeParams.PipeRootOrientation, pipeParams.PipeStartingWidth, null);
            setupPipes(root, pipeCorners.children);
        }
Example #3
0
 protected override bool canEnterPipe(EndothelialCell entryPoint)
 {
     return false;
 }
        public EndothelialCell GrowTowards(Vector3 target)
        {
            if (size <= CirculatorySystem.Instance.minSize)
                return this;

            PipeInfo pipeInfo = getGrowthDirection(this.cellLocation, target);
            Vector3 unitVector = pipeInfo.Direction;
            PipeOrientation orientation = pipeInfo.Orientation;

            Vector3 newCellPosition = this.CellLocation + unitVector;
            size = this.Size * CirculatorySystem.Instance.PipeShrinkRate;

            EndothelialCell newPipeCell = new EndothelialCell(newCellPosition, orientation, size, this);
            this.children.Add(newPipeCell);
            return newPipeCell;
        }
Example #5
0
 protected override bool canEnterPipe(EndothelialCell entryPoint)
 {
     if (Environment.random.NextDouble() < cellBehaviors.GetEnterPipeProbability())
         return true;
     return false;
 }
 public PipeTravelInfo(EndothelialCell entryPoint)
 {
     ContainingPipe = entryPoint;
     TravelDirection = randomlyChooseDirection();
 }
        private void setupPipes(EndothelialCell currPos, List<SimulationParameters.PipeLocations> children)
        {
            if (children == null || children.Count == 0)
                return;

            foreach (SimulationParameters.PipeLocations child in children)
            {
                EndothelialCell newestPiece = createPipe(currPos, child.location);
                setupPipes(newestPiece, child.children);
            }
        }
        private EndothelialCell pipeSearchParent(TissueCell target, EndothelialCell currPos, int currDistance)
        {
            if (currPos.Parent == null)
                return currPos;

            int tmpDistance = UtilityMethods.CityBlockDistance(currPos.Parent.CellLocation, target.CellLocation);
            if (tmpDistance < currDistance)
                return pipeSearchParent(target, currPos.Parent, tmpDistance);
            else
                return currPos;
        }
        private EndothelialCell pipeSearchChildren(TissueCell target, EndothelialCell currPos, int currDistance)
        {
            if (currPos.Children.Count == 0)
                return currPos;

            int tmpDistance;
            EndothelialCell bestChild = null;

            foreach (EndothelialCell child in currPos.Children)
            {
                tmpDistance = UtilityMethods.CityBlockDistance(child.CellLocation, target.CellLocation);
                if (tmpDistance < currDistance)
                {
                    currDistance = tmpDistance;
                    bestChild = child;
                }
            }

            if (bestChild == null)
                return currPos;
            else
                return pipeSearchChildren(target, bestChild, currDistance);
        }
        private EndothelialCell pipeSearch(TissueCell target, EndothelialCell startingLocation)
        {
            Vector3 targetLocation = target.CellLocation;
            int currDistance = UtilityMethods.CityBlockDistance(startingLocation.CellLocation, targetLocation);

            EndothelialCell parent = pipeSearchParent(target, startingLocation, currDistance);
            int pDistance = UtilityMethods.CityBlockDistance(parent.CellLocation, targetLocation);

            EndothelialCell child = pipeSearchChildren(target, startingLocation, currDistance);
            int cDistance = UtilityMethods.CityBlockDistance(child.CellLocation, targetLocation);

            if (pDistance < cDistance)
                return parent;
            return child;
        }
        // returns the EndothelialCell at target location
        private EndothelialCell createPipe(EndothelialCell from, Vector3 target)
        {
            EndothelialCell currCell = from;
            float size = from.Size;
            Vector3 currLoc = currCell.CellLocation;
            EndothelialCell.PipeInfo pipeInfo;

            while (currLoc != target)
            {
                size *= pipeShrinkRate;
                pipeInfo = EndothelialCell.getGrowthDirection(currLoc, target);
                currLoc = currLoc + pipeInfo.Direction;
                EndothelialCell newPipePiece = new EndothelialCell(currLoc, pipeInfo.Orientation, size, currCell);
                currCell.Children.Add(newPipePiece);
                currCell = newPipePiece;
            }

            return currCell;
        }