private void DetermineDepths(SoilSurfaceContainer soilSurfaceContainer)
 {
     foreach (FoundationCentreLine foundationCentreLine in Centrelines)
     {
         foundationCentreLine.CalculateDepths(soilSurfaceContainer);
     }
 }
        public void UpdateAllFoundations()
        {
            SoilSurfaceContainer soilSurfaceContainer = new SoilSurfaceContainer(this.HostDocument);

            LayerManager layerManager = DataService.Current.GetStore <DocumentStore>(HostDocument.Name).LayerManager;

            _foundationLayerName = layerManager.GetLayerName(FoundationCentreLine.FOUNDATION_LAYER);

            foreach (FoundationGroup group in _foundationGroups)
            {
                group.Delete();
            }

            _foundationGroups.Clear();

            ICollection <FoundationCentreLine> centrelines = GetCentrelines();

            centrelines = DetermineOverlayedLines(centrelines);
            GroupCentrelines(centrelines);

            foreach (FoundationGroup foundationGroup in _foundationGroups)
            {
                foundationGroup.Rebuild(soilSurfaceContainer);
            }

            RemoveCentrelines(centrelines);
        }
        public double CalculateRequiredWidth(SoilSurfaceContainer soilSurfaceContainer)
        {
            double      groundBearingPressure = soilSurfaceContainer.GetGroundBearingPressure(this.StartPoint, this.EndPoint);
            Transaction trans       = _document.TransactionManager.TopTransaction;
            double      appliedLoad = double.Parse(this[FoundationGroup.FOUNDATION_CENTRE_LOAD_KEY]);

            if (appliedLoad == 0)
            {
                throw new ArgumentOutOfRangeException("No applied load has been set.");
            }

            if (groundBearingPressure == 0)
            {
                throw new ArgumentOutOfRangeException("No ground bearing pressure has been set.");
            }

            FoundationWidth widthCalc = new FoundationWidth()
            {
                AppliedLoad           = appliedLoad,
                GroundBearingPressure = groundBearingPressure,
                WallThickness         = 0.3 // TODO: Add a way of specifying wall thickness
            };

            widthCalc.Run();

            if (!widthCalc.Calculated)
            {
                throw new InvalidOperationException("Width calculation failed.");
            }

            return(widthCalc.RequiredWidth.Value);
        }
        private void DetermineWidths(SoilSurfaceContainer soilSurfaceContainer)
        {
            foreach (FoundationCentreLine foundationCentreLine in Centrelines)
            {
                foundationCentreLine.AddWidths(soilSurfaceContainer);
            }

            foreach (FoundationNode foundationNode in Nodes)
            {
                foundationNode.TrimFoundations();
            }
        }
        public void Rebuild(SoilSurfaceContainer soilSurfaceContainer)
        {
            //DetermineDepths(soilSurfaceContainer);

            // TODO: Recalc widths based on depths

            AddRequiredBottomSteps();
            AddRequiredTopSteps();
            AdjustBottomSteps();
            AdjustTopSteps();
            DetermineWidths(soilSurfaceContainer);
        }
        private List <Point3d> GetPointsOfElevationChange(SoilSurfaceContainer soilSurfaceContainer, FeatureLine existingLine, FeatureLine proposedLine)
        {
            List <Point3d> elevationPoints = new List <Point3d>();

            elevationPoints.Add(StartPoint);

            foreach (Point3d point3d in existingLine.GetPoints(FeatureLinePointType.AllPoints))
            {
                elevationPoints.Add(point3d);
            }

            foreach (Point3d point3d in proposedLine.GetPoints(FeatureLinePointType.AllPoints))
            {
                elevationPoints.Add(point3d);
            }

            elevationPoints.Add(EndPoint);

            return(elevationPoints);
        }
        public void AddWidths(SoilSurfaceContainer soilSurfaceContainer)
        {
            RightOffsetCached = null;
            LeftOffsetCached  = null;
            double requiredWidth = CalculateRequiredWidth(soilSurfaceContainer);

            Transaction trans = _document.TransactionManager.TopTransaction;

            LeftOffsetCached        = this.CreateLeftOffset(requiredWidth / 2);
            LeftOffsetCached.Layer  = _foundationLayerName;
            RightOffsetCached       = this.CreateRightOffset(requiredWidth / 2);
            RightOffsetCached.Layer = _foundationLayerName;

            BlockTableRecord modelSpace = _document.Database.GetModelSpace(true);

            LeftOffset  = modelSpace.AppendEntity(LeftOffsetCached);
            RightOffset = modelSpace.AppendEntity(RightOffsetCached);

            trans.AddNewlyCreatedDBObject(LeftOffsetCached, true);
            trans.AddNewlyCreatedDBObject(RightOffsetCached, true);
        }
        public IReadOnlyList <DepthPoint> CalculateDepths(SoilSurfaceContainer soilSurfaceContainer)
        {
            // TODO: Add code for more than just the centre line
            // TODO: Add tree ring code

            FeatureLine existingLine = soilSurfaceContainer.GetFeatureLine(this.BaseObject, soilSurfaceContainer.ExistingGround);
            FeatureLine proposedLine = soilSurfaceContainer.GetFeatureLine(this.BaseObject, soilSurfaceContainer.ProposedGround);

            List <Point3d>    elevationPoints = GetPointsOfElevationChange(soilSurfaceContainer, existingLine, proposedLine);
            List <DepthPoint> depthPoints     = new List <DepthPoint>();

            foreach (Point3d elevationPoint in elevationPoints)
            {
                DepthPoint dp = new DepthPoint()
                {
                    DistanceParameter = existingLine.GetParameterAtPoint(elevationPoint),
                    RequiredDepth     = soilSurfaceContainer.GetDepthAtPoint(elevationPoint, existingLine, proposedLine)
                };

                depthPoints.Add(dp);
            }

            return(depthPoints.OrderBy(x => x.DistanceParameter).ToList());
        }