Esempio n. 1
0
        /// <summary>
        /// Internal constructor
        /// </summary>
        /// <param name="baseline">The baseline that holds the baseline region.</param>
        /// <param name="blr">The internal AeccBaselineRegion</param>
        /// <param name="i">The baseline region index</param>
        internal BaselineRegion(Baseline baseline, AeccBaselineRegion blr, int i)
        {
            this._baseline = baseline;

            this._blr = blr;

            this._index = i;

            try
            {
                this._assembly = blr.AssemblyDbEntity.DisplayName;
            }
            catch (Exception ex)
            {
                Utils.Log(string.Format("ERROR: Assembly Name Failed\t{0}", ex.Message));

                this._assembly = this._index.ToString();
            }

            try
            {
                this._start = blr.StartStation; //  Math.Round(blr.StartStation, 5);  // TODO get rid of the roundings
            }
            catch (Exception ex)
            {
                Utils.Log(string.Format("ERROR: Start Station Failed\t{0}", ex.Message));

                throw new Exception("Start Station Failed\n\n" + ex.Message);
            }

            try
            {
                this._end = blr.EndStation; //  Math.Round(blr.EndStation, 5);
            }
            catch (Exception ex)
            {
                Utils.Log(string.Format("ERROR: End Station Failed\t{0}", ex.Message));

                throw new Exception("End Station Failed\n\n" + ex.Message);
            }

            try
            {
                this._stations = blr.GetSortedStations();
            }
            catch (Exception ex)
            {
                Utils.Log(string.Format("ERROR: Sorted Stations Failed\t{0}", ex.Message));

                throw new Exception("Sorted Stations Failed\n\n" + ex.Message);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Gets the featurelines by code and station
        /// </summary>
        /// <param name="code">the Featurelines code.</param>
        /// <param name="station">the station used to select the featurelines.</param>
        /// <returns></returns>
        public IList <Featureline> GetFeaturelinesByCodeStation(string code, double station)  // 1.1.0
        {
            Utils.Log(string.Format("Baseline.GetFeaturelinesByCodeStation({0}, {1}) Started...", code, station));

            IList <Featureline> blFeaturelines = new List <Featureline>();

            var b = this._baseline;

            // 20190122 -- Start

            AeccFeatureLines fs = null;

            try
            {
                fs = b.MainBaselineFeatureLines.FeatureLinesCol.Item(code);
            }
            catch (Exception ex)
            {
                Utils.Log(string.Format("ERROR 1: {0}", ex.Message));
            }

            if (fs != null)
            {
                AeccBaselineRegion reg = null;

                int regionIndex = 0;

                foreach (AeccBaselineRegion region in b.BaselineRegions)
                {
                    if (region.StartStation < station && region.EndStation > station || Math.Abs(station - region.StartStation) < 0.001 || Math.Abs(station - region.EndStation) < 0.001)
                    {
                        reg = region;
                        break;
                    }

                    ++regionIndex;
                }

                if (reg != null)
                {
                    foreach (var fl in fs.Cast <AeccFeatureLine>())
                    {
                        var pts = new List <Point>();

                        foreach (var pt in fl.FeatureLinePoints.Cast <AeccFeatureLinePoint>())
                        {
                            if (reg.StartStation < Math.Round(pt.Station, 5) && reg.EndStation > Math.Round(pt.Station, 5) ||
                                Math.Abs(Math.Round(pt.Station, 5) - reg.StartStation) < 0.001 ||
                                Math.Abs(Math.Round(pt.Station, 5) - reg.EndStation) < 0.001)
                            {
                                var p = pt.XYZ;

                                //try
                                //{
                                //    pts.Add(Point.ByCoordinates(p[0], p[1], p[2]));
                                //}
                                //catch { }

                                try
                                {
                                    pts.Add(Point.ByCoordinates(p[0], p[1], p[2]));
                                }
                                catch (Exception ex)
                                {
                                    // 'System.Collections.Generic.IList<Autodesk.DesignScript.Geometry.Point>' does not contain a definition for 'Add'
                                    Utils.Log(string.Format("ERROR 2: {0}", ex.Message));
                                }
                            }
                        }

                        var points = Point.PruneDuplicates(pts);

                        if (points.Count() > 1)
                        {
                            PolyCurve pc = PolyCurve.ByPoints(points);

                            double offset = this.GetArrayStationOffsetElevationByPoint(pc.StartPoint)[1];  // 1.1.0

                            Featureline.SideType side = Featureline.SideType.Right;

                            if (offset < 0)
                            {
                                side = Featureline.SideType.Left;
                            }

                            blFeaturelines.Add(new Featureline(this, pc, code, side, regionIndex));

                            Utils.Log(string.Format("Featureline added", ""));
                        }

                        foreach (var pt in points)
                        {
                            pt.Dispose();
                        }
                    }
                }
            }

            // 20190122 -- End

            #region OLD CODE
            //int regionIndex = 0;

            //foreach (AeccBaselineRegion region in b.BaselineRegions)
            //{
            //    if (region.StartStation < station && region.EndStation > station || Math.Abs(station - region.StartStation) < 0.001 || Math.Abs(station - region.EndStation) < 0.001)  // 1.1.0
            //    {
            //        foreach (AeccFeatureLines coll in b.MainBaselineFeatureLines.FeatureLinesCol.Cast<AeccFeatureLines>().Where(fl => fl.FeatureLineCodeInfo.CodeName == code))  // 1.1.0
            //        {
            //            foreach (AeccFeatureLine f in coll.Cast<AeccFeatureLine>().Where(x => x.CodeName == code))  // maybe redundant?
            //            {
            //                double start = f.FeatureLinePoints.Item(0).Station;  // 1.1.0
            //                double end = f.FeatureLinePoints.Item(f.FeatureLinePoints.Count - 1).Station;  // 1.1.0

            //                bool reverse = start < end ? false : true;  // 1.1.0

            //                IList<Point> points = new List<Point>();

            //                foreach (AeccFeatureLinePoint p in f.FeatureLinePoints)
            //                {
            //                    Point point = Point.ByCoordinates(p.XYZ[0], p.XYZ[1], p.XYZ[2]);

            //                    double s = Math.Round(p.Station, 3);  // 1.1.0

            //                    if (s >= region.StartStation || Math.Abs(s - region.StartStation) < 0.001)
            //                    {
            //                        if (s <= region.EndStation || Math.Abs(s - region.EndStation) < 0.001)
            //                        {
            //                            points.Add(point);
            //                        }
            //                    }
            //                }

            //                points = Point.PruneDuplicates(points);

            //                if (points.Count > 1)
            //                {
            //                    PolyCurve pc = PolyCurve.ByPoints(points);

            //                    if (reverse)  // 1.1.0
            //                    {
            //                        pc = pc.Reverse() as PolyCurve;
            //                    }

            //                    double offset = this.GetArrayStationOffsetElevationByPoint(pc.StartPoint)[1];  // 1.1.0

            //                    Featureline.SideType side = Featureline.SideType.Right;

            //                    if (offset < 0)
            //                    {
            //                        side = Featureline.SideType.Left;
            //                    }

            //                    blFeaturelines.Add(new Featureline(this, pc, f.CodeName, side, regionIndex));
            //                }
            //            }
            //        }
            //    }

            //    regionIndex++;
            //}
            #endregion

            Utils.Log(string.Format("Baseline.GetFeaturelinesByCodeStation() Completed.", code));

            return(blFeaturelines);
        }
Esempio n. 3
0
        /// <summary>
        /// Gets the featurelines by code and station
        /// </summary>
        /// <param name="code">the Featurelines code.</param>
        /// <param name="station">the station used to select the featurelines.</param>
        /// <returns></returns>
        public IList <Featureline> GetFeaturelinesByCodeStation(string code, double station)  // 1.1.0
        {
            Utils.Log(string.Format("Baseline.GetFeaturelinesByCodeStation({0}, {1}) Started...", code, station));

            IList <Featureline> blFeaturelines = new List <Featureline>();

            var b = this._baseline;

            // 20190122 -- Start

            AeccFeatureLines fs = null;

            try
            {
                fs = b.MainBaselineFeatureLines.FeatureLinesCol.Item(code);
            }
            catch (Exception ex)
            {
                Utils.Log(string.Format("ERROR 1: {0}", ex.Message));
            }

            if (fs != null)
            {
                AeccBaselineRegion reg = null;

                int regionIndex = 0;

                foreach (AeccBaselineRegion region in b.BaselineRegions)
                {
                    if (region.StartStation < station && region.EndStation > station || Math.Abs(station - region.StartStation) < 0.001 || Math.Abs(station - region.EndStation) < 0.001)
                    {
                        reg = region;
                        break;
                    }

                    ++regionIndex;
                }

                if (reg != null)
                {
                    foreach (var fl in fs.Cast <AeccFeatureLine>())
                    {
                        var pts = new List <Point>();

                        foreach (var pt in fl.FeatureLinePoints.Cast <AeccFeatureLinePoint>())
                        {
                            if (reg.StartStation < Math.Round(pt.Station, 5) && reg.EndStation > Math.Round(pt.Station, 5) ||
                                Math.Abs(Math.Round(pt.Station, 5) - reg.StartStation) < 0.001 ||
                                Math.Abs(Math.Round(pt.Station, 5) - reg.EndStation) < 0.001)
                            {
                                var p = pt.XYZ;

                                try
                                {
                                    pts.Add(Point.ByCoordinates(p[0], p[1], p[2]));
                                }
                                catch (Exception ex)
                                {
                                    Utils.Log(string.Format("ERROR 2: {0}", ex.Message));
                                }
                            }
                        }

                        var points = Point.PruneDuplicates(pts);

                        if (points.Count() > 1)
                        {
                            PolyCurve pc = PolyCurve.ByPoints(points);

                            double offset = this.GetArrayStationOffsetElevationByPoint(pc.StartPoint)[1];  // 1.1.0

                            Featureline.SideType side = Featureline.SideType.Right;

                            if (offset < 0)
                            {
                                side = Featureline.SideType.Left;
                            }

                            blFeaturelines.Add(new Featureline(this, pc, code, side, regionIndex));

                            Utils.Log(string.Format("Featureline added", ""));
                        }

                        foreach (var pt in points)
                        {
                            pt.Dispose();
                        }
                    }
                }
            }

            // 20190122 -- End

            Utils.Log(string.Format("Baseline.GetFeaturelinesByCodeStation() Completed.", code));

            return(blFeaturelines);
        }
Esempio n. 4
0
        /// <summary>
        /// Internal constructor
        /// </summary>
        /// <param name="baseline">The baseline that holds the baseline region.</param>
        /// <param name="blr">The internal AeccBaselineRegion</param>
        /// <param name="i">The baseline region index</param>
        internal BaselineRegion(Baseline baseline, AeccBaselineRegion blr, int i)
        {
            this._baseline = baseline;

            this._blr = blr;

            this._index = i;

            try
            {
                this._assembly = blr.AssemblyDbEntity.DisplayName;
            }
            catch (Exception ex)
            {
                Utils.Log(string.Format("ERROR: Assembly Name Failed\t{0}", ex.Message));

                this._assembly = this._index.ToString();

                //throw new Exception("Assembly Name Failed\n\n" + ex.Message);
            }

            try
            {
                this._start = blr.StartStation; //  Math.Round(blr.StartStation, 5);  // TODO get rid of the roundings
            }
            catch (Exception ex)
            {
                Utils.Log(string.Format("ERROR: Start Station Failed\t{0}", ex.Message));

                throw new Exception("Start Station Failed\n\n" + ex.Message);
            }

            try
            {
                this._end = blr.EndStation; //  Math.Round(blr.EndStation, 5);
            }
            catch (Exception ex)
            {
                Utils.Log(string.Format("ERROR: End Station Failed\t{0}", ex.Message));

                throw new Exception("End Station Failed\n\n" + ex.Message);
            }

            try
            {
                this._stations = blr.GetSortedStations();
            }
            catch (Exception ex)
            {
                Utils.Log(string.Format("ERROR: Sorted Stations Failed\t{0}", ex.Message));

                throw new Exception("Sorted Stations Failed\n\n" + ex.Message);
            }

            #region OLDCODE
            //foreach (AeccAppliedAssembly a in blr.AppliedAssemblies)
            //{
            //    try
            //    {
            //        this._appliedAssemblies.Add(new AppliedAssembly(this, a, a.Corridor));  // TODO: verify why this is a list instead of a single applied assembly...
            //        // break;
            //    }
            //    catch (Exception ex)
            //    {
            //        throw new Exception("Applied Assemblies Failed\n\n" + ex.Message);
            //    }
            //}

            //foreach (AppliedAssembly aa in this._appliedAssemblies)
            //{
            //    foreach (AeccAppliedSubassembly asa in aa._appliedSubassemblies)
            //    {
            //        try
            //        {
            //            this.Subassemblies.Add(new Subassembly(asa.SubassemblyDbEntity, asa.Corridor));
            //        }
            //        catch (Exception ex)
            //        {
            //            this.Subassemblies.Add(null);
            //            throw new Exception("Applied Subassemblies Failed\n\n" + ex.Message);
            //        }
            //    }
            //}
            #endregion
        }