欢迎来到我的博客
Civil 3D开发与应用,欢迎加入QQ群:484124761
AutoCAD开发,欢迎加入QQ群:193522571

Civil 3d中国本地化包DaylightWithExternalFile部件

civil 3d中国本地化包中有一个多级边坡部件,

DaylightWithExternalFile,

因为其中以一行代码有问题,

一直没法用,

以前也没仔细研究其中的错误出在哪里。

最近需要模仿其功能,

从文件读取部件(civil 3d中的subassembly)参数,

之后创建部件,

于是仔细研究了一下DaylightWithExternalFile,

其中的问题并不大,

只是为连接附代码时,

有一个连接的代码重复了。

抛开这个问题不说,

其中的读取文件到一个静态变量的原理,

却是值得学习的。

我模仿其中的代码,

已经实现了自己的需求:

 

将挡土墙的参数存储到csv文件,

之后读取csv文件并存储在一个静态变量中并创建部件。

只要能按照遇到的名称创建类似的csv文件,

就可以创建出不同规格的挡墙部件。

 

把DaylightWithExternalFile的代码放置这里,

供大家学习,

代码时反编译出来的,

很多地方没有精简修改,

读起来可能比较困难。

 对我来说,

下面几行代码是关键:

通过对比文件名称及文件修改时间,

来判断是否需要从文件中读取参数,

这样就能实现在需要时才从硬盘读取文件,

而不是每创建一个部件就读取一次硬盘文件。

            if (fileName != SAParamFromFile[1].ConfigFileName
                | File.GetLastWriteTimeUtc(fileName) != SAParamFromFile[1].ConfigFileLastWriteTimeUtc
                && !this.ReadParamsFromFile(fileName, corridorState))
                return;

 

// Decompiled with JetBrains decompiler
// Type: C3DChnStockSubassemblies.DaylightWithExternalFile
// Assembly: C3DChnStockSubassemblies, Version=2014.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: 9ACA6679-3F91-4EF5-83EB-2B76404E39E3
// Assembly location: D:\123\UserCommonAppDataFolder\C3DChnStockSubassemblies.dll

using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.Civil.DatabaseServices;
using Autodesk.Civil.Runtime;
using Microsoft.VisualBasic;
using Microsoft.VisualBasic.CompilerServices;
using Subassembly.Properties;
using System;
using System.IO;
using System.Runtime.CompilerServices;
using System.Text;

namespace Subassembly
{
    public class DaylightWithExternalFile : SATemplate
    {
        private static SAParamsFromFileStructure[] SAParamFromFile = new SAParamsFromFileStructure[3];
        private const int VerticalSlope = 9999;
        private const int HorizonSlope = 0;
        private const int SideDefault = 0;
        private object ConfigFileDefault;
        private const double MinCutHeightDefault = 0.5;
        private const double MinFillHeightDefault = 0.5;
        private const long PlaceLinedMaterialDefault = 4L;
        private const double MaterialThicknessDefault = 0.15;
        private const string MaterialNameDefault = "Rip Rap";

        public DaylightWithExternalFile()
        {
            this.ConfigFileDefault = Interaction.Environ("AECCCONTENT_DIR") + "External Configuration File.txt";
        }

        protected override void GetLogicalNamesImplement(CorridorState corridorState)
        {
            base.GetLogicalNamesImplement(corridorState);
            corridorState.ParamsLong.Add("TargetDTM", 1).DisplayName = "地形曲面";
        }

        protected override void GetInputParametersImplement(CorridorState corridorState)
        {
            base.GetInputParametersImplement(corridorState);
            ParamDoubleCollection paramsDouble = corridorState.ParamsDouble;
            ParamLongCollection paramsLong = corridorState.ParamsLong;
            ParamStringCollection paramsString = corridorState.ParamsString;
            paramsLong.Add("Side", 0);
            paramsString.Add("FileName", Conversions.ToString(this.ConfigFileDefault));
            paramsLong.Add("PlaceLinedMaterial", 4);
            paramsDouble.Add("MaterialThickness", 0.15);
            paramsString.Add("MaterialName", "Rip Rap");
        }

        protected override void GetOutputParametersImplement(CorridorState corridorState)
        {
            base.GetOutputParametersImplement(corridorState);
            ParamDoubleCollection paramsDouble = corridorState.ParamsDouble;
            IParam iparam1 = (IParam)paramsDouble.Add("Daylight Offset", 0.0);
            if (iparam1 != null)
                iparam1.Access = ((ParamAccessType)2);
            IParam iparam2 = (IParam)paramsDouble.Add("Daylight Elevation", 0.0);
            if (iparam2 == null)
                return;
            iparam2.Access = ((ParamAccessType)2);
        }

        protected override void DrawImplement(CorridorState corridorState)
        {
            ParamLongCollection paramsLong = corridorState.ParamsLong;
            ParamDoubleCollection paramsDouble = corridorState.ParamsDouble;
            ParamStringCollection paramsString = corridorState.ParamsString;
            ParamSurfaceCollection paramsSurface = corridorState.ParamsSurface;
            string fileName = paramsString.Value("FileName");
            if (fileName != SAParamFromFile[1].ConfigFileName
                | File.GetLastWriteTimeUtc(fileName) != SAParamFromFile[1].ConfigFileLastWriteTimeUtc
                && !this.ReadParamsFromFile(fileName, corridorState))
                return;
            string[,] sPointCodeArray = new string[12, 2];
            string[,] sLinkCodeArray = new string[9, 2];
            this.FillCodesFromTable(sPointCodeArray, sLinkCodeArray);
            long side;
            try
            {
                side = (long)paramsLong.Value("Side");
            }
            catch (Exception ex)
            {
                ProjectData.SetProjectError(ex);
                side = 0L;
                ProjectData.ClearProjectError();
            }
            double flip = 1.0;
            if (side == 1L)
                flip = -1.0;
            long placeLineMaterial;
            try
            {
                placeLineMaterial = (long)paramsLong.Value("PlaceLinedMaterial");
            }
            catch (Exception ex)
            {
                ProjectData.SetProjectError(ex);
                placeLineMaterial = 4L;
                ProjectData.ClearProjectError();
            }
            double materialThickness;
            try
            {
                materialThickness = paramsDouble.Value("MaterialThickness");
            }
            catch (Exception ex)
            {
                ProjectData.SetProjectError(ex);
                materialThickness = 0.15;
                ProjectData.ClearProjectError();
            }
            string materialName;
            try
            {
                materialName = paramsString.Value("MaterialName");
            }
            catch (Exception ex)
            {
                ProjectData.SetProjectError(ex);
                materialName = "Rip Rap";
                ProjectData.ClearProjectError();
            }
            double minCutHeight;
            try
            {
                minCutHeight = SAParamFromFile[1].MinCutFillHeight;
            }
            catch (Exception ex)
            {
                ProjectData.SetProjectError(ex);
                minCutHeight = 0.5;
                ProjectData.ClearProjectError();
            }
            double minFillHeight;
            try
            {
                minFillHeight = SAParamFromFile[2].MinCutFillHeight;
            }
            catch (Exception ex)
            {
                ProjectData.SetProjectError(ex);
                minFillHeight = 0.5;
                ProjectData.ClearProjectError();
            }
            int stepNum = (int)SAParamFromFile[1].StepNum;
            int i = 1;
            while (i <= stepNum)
            {
                if (SAParamFromFile[1].MaxCutOrFillHeight[i] <= 0.0)
                    Utilities.RecordError(corridorState, (CorridorError)(-2147221485), "MaxCut/FillHeight", "DaylightWithExternalFile");
                ++i;
            }
            i = 1;
            while (i <= stepNum)
            {
                if (SAParamFromFile[1].CutOrFillSlope[i] <= 0.0)
                    Utilities.RecordError(corridorState, (CorridorError)(-2147221485), "Cut/FillSlope", "DaylightWithExternalFile");
                ++i;
            }
            i = 1;
            while (i <= stepNum)
            {
                if (SAParamFromFile[1].BenchWidth[i] < 0.0)
                    Utilities.RecordError(corridorState, (CorridorError)(-2147221485), "BenchWidth", "DaylightWithExternalFile");
                ++i;
            }
            i = 1;
            stepNum = (int)SAParamFromFile[2].StepNum;
            while (i <= stepNum)
            {
                if (SAParamFromFile[2].MaxCutOrFillHeight[i] <= 0.0)
                    Utilities.RecordError(corridorState, (CorridorError)(-2147221485), "MaxCut/FillHeight", "DaylightWithExternalFile");
                ++i;
            }
            i = 1;
            while (i <= stepNum)
            {
                if (SAParamFromFile[2].CutOrFillSlope[i] <= 0.0)
                    Utilities.RecordError(corridorState, (CorridorError)(-2147221485), "Cut/FillSlope", "DaylightWithExternalFile");
                ++i;
            }
            i = 1;
            while (i <= stepNum)
            {
                if (SAParamFromFile[2].BenchWidth[i] < 0.0)
                    Utilities.RecordError(corridorState, (CorridorError)(-2147221485), "BenchWidth", "DaylightWithExternalFile");
                ++i;
            }
            if (materialThickness <= 0.0)
            {
                Utilities.RecordError(corridorState, (CorridorError)(-2147221485), "MaterialThickness", "DaylightWithExternalFile");
                materialThickness = 0.15;
            }
            PointInMem oOrigin = new PointInMem();
            PointInMem pointInMem1 = new PointInMem();
            PointInMem pointInMem2 = new PointInMem();
            Point[] pointArray1 = new Point[2];
            PointCollection points = corridorState.Points;
            LinkCollection links = corridorState.Links;
            var shapes = corridorState.Shapes;
            ObjectId oAlignmentId = ObjectId.Null;
            Utilities.GetAlignmentAndOrigin(corridorState, ref oAlignmentId, ref oOrigin);
            pointInMem1.Station = (oOrigin.Station);
            pointInMem1.Offset = (oOrigin.Offset);
            pointInMem1.Elevation = (oOrigin.Elevation);
            pointInMem2.Station = (oOrigin.Station);
            pointInMem2.Offset = (oOrigin.Offset);
            pointInMem2.Elevation = (oOrigin.Elevation);
            if (corridorState.Mode == CorridorMode.Layout)
            {
                double[] dHorzArray = new double[9];
                double[] dVertArray = new double[9];
                Point[] pts = new Point[9];
                Link[] linkArray = new Link[6];
                dHorzArray[0] = 0.0;
                dVertArray[0] = 0.0;
                double num19;
                double num20;
                if (Utilities.IsProjectUnitsFeet())
                {
                    num19 = 10.0;
                    num20 = 3.0;
                }
                else
                {
                    num19 = 3.0;
                    num20 = 1.0;
                }
                double Right = 2;
                dHorzArray[1] = 0.0;
                dVertArray[1] = 0.0;
                dHorzArray[2] = (flip * num19) / Right;
                dVertArray[2] = num19;
                dHorzArray[3] = flip * (num19 / Right + num20);
                dVertArray[3] = num19;
                dHorzArray[4] = flip * (((num19 / Right) + num20) + (num19 / Right) / 2);
                dVertArray[4] = dVertArray[3] + num19 / 2.0;
                dHorzArray[5] = flip * num19 / Right;
                dVertArray[5] = 0.0 - num19;
                dHorzArray[6] = flip * (num19 / Right + num20);
                dVertArray[6] = 0.0 - num19;
                dHorzArray[7] = flip * (((num19 / Right) + num20) + (num19 / Right) / 2);
                dVertArray[7] = dVertArray[6] - num19 / 2.0;
                dHorzArray[8] = dHorzArray[7];
                dVertArray[8] = 0.0;
                i = 1;
                do
                {
                    pts[i] = points.Add(dHorzArray[i], dVertArray[i], "");
                    ++i;
                }
                while (i <= 8);
                pts[2].Codes.Add(sPointCodeArray[2, 0]);
                pts[3].Codes.Add(sPointCodeArray[3, 0]);
                pts[3].Codes.Add(sPointCodeArray[1, 0]);
                pts[3].Codes.Add(sPointCodeArray[1, 1]);
                pts[4].Codes.Add(sPointCodeArray[7, 0]);
                pts[4].Codes.Add(sPointCodeArray[7, 1]);
                pts[5].Codes.Add(sPointCodeArray[5, 0]);
                pts[6].Codes.Add(sPointCodeArray[6, 0]);
                pts[6].Codes.Add(sPointCodeArray[4, 0]);
                pts[6].Codes.Add(sPointCodeArray[4, 1]);
                pts[7].Codes.Add(sPointCodeArray[8, 0]);
                pts[7].Codes.Add(sPointCodeArray[8, 1]);
                i = 1;
                do
                {
                    pointArray1[0] = pts[i];
                    pointArray1[1] = pts[checked(i + 1)];
                    linkArray[i - 1] = i != 3 ? links.Add((IPoint[])pointArray1, "") : links.Add((IPoint[])pointArray1, "", (CorridorLinkDisplay)3);
                    linkArray[i - 1].Codes.Add(sLinkCodeArray[1, 0]);
                    linkArray[i - 1].Codes.Add(sLinkCodeArray[5, 0]);
                    ++i;
                }
                while (i <= 3);
                linkArray[0].Codes.Add(sLinkCodeArray[4, 0]);
                linkArray[2].Codes.Add(sLinkCodeArray[2, 0]);
                linkArray[2].Codes.Add(sLinkCodeArray[2, 1]);
                //linkArray[0].Codes.Add(sLinkCodeArray[4, 0]);
                linkArray[1].Codes.Add(sLinkCodeArray[7, 0]);
                pointArray1[0] = pts[1];
                pointArray1[1] = pts[5];
                linkArray[3] = links.Add((IPoint[])pointArray1, "");
                linkArray[3].Codes.Add(sLinkCodeArray[1, 0]);
                linkArray[3].Codes.Add(sLinkCodeArray[5, 0]);
                i = 5;
                do
                {
                    pointArray1[0] = pts[i];
                    pointArray1[1] = pts[checked(i + 1)];
                    linkArray[i - 1] = i != 6 ? links.Add((IPoint[])pointArray1, "") : links.Add((IPoint[])pointArray1, "", (CorridorLinkDisplay)3);
                    linkArray[i - 1].Codes.Add(sLinkCodeArray[1, 0]);
                    linkArray[i - 1].Codes.Add(sLinkCodeArray[5, 0]);
                    checked { ++i; }
                }
                while (i <= 6);
                linkArray[3].Codes.Add(sLinkCodeArray[4, 0]);
                linkArray[4].Codes.Add(sLinkCodeArray[7, 0]);
                linkArray[5].Codes.Add(sLinkCodeArray[3, 0]);
                linkArray[5].Codes.Add(sLinkCodeArray[3, 1]);
            }
            else
            {
                ObjectId objectId;
                try
                {
                    objectId = paramsSurface.Value("TargetDTM");
                }
                catch (Exception ex)
                {
                    ProjectData.SetProjectError(ex);
                    corridorState.RecordError((CorridorError)(-2147221500), (CorridorErrorLevel)2, "Logical Name: 'TargetDTM'", "DaylightWithExternalFile", true);
                    ProjectData.ClearProjectError();
                    return;
                }
                Utilities.FillOrCut eFilOrCut = !corridorState.IsAboveSurface(objectId, oAlignmentId, (IPoint)oOrigin) ? Utilities.FillOrCut.CutSituation : Utilities.FillOrCut.FillSituation;
                bool[] bDaylightHasDitchArray = new bool[2]
                {
                    false,
                    false
                };
                bool[] bDaylightHasBenchArray = new bool[2];
                int index7 = 1;
                double[] dHorzArray = new double[2]
                {
                    0.0,
                    0.0
                };
                double[] dVertArray = new double[2]
                {
                    0.0,
                    0.0
                };
                bool flag = false;
                if (eFilOrCut == Utilities.FillOrCut.CutSituation)
                {
                    int index8 = 1;
                    while (!(corridorState.IsAboveSurface(objectId, oAlignmentId, (IPoint)pointInMem1) | corridorState.IntersectSurface(objectId, oAlignmentId, (IPoint)pointInMem1, side != 1L, 10000000000000.0) == null))
                    {
                        pointInMem2.Elevation = (pointInMem1.Elevation);
                        pointInMem2.Offset = (pointInMem1.Offset);
                        pointInMem1.Elevation = (pointInMem1.Elevation + DaylightWithExternalFile.SAParamFromFile[1].MaxCutOrFillHeight[index8]);
                        if (DaylightWithExternalFile.SAParamFromFile[1].CutOrFillSlope[index8] == 9999.0)
                            pointInMem1.Offset = (pointInMem1.Offset);
                        else
                            pointInMem1.Offset = (pointInMem1.Offset + flip * DaylightWithExternalFile.SAParamFromFile[1].MaxCutOrFillHeight[index8] / DaylightWithExternalFile.SAParamFromFile[1].CutOrFillSlope[index8]);
                        dHorzArray = (double[])Utils.CopyArray((Array)dHorzArray, (Array)new double[checked(Information.UBound((Array)dHorzArray, 1) + 1 + 1)]);
                        dVertArray = (double[])Utils.CopyArray((Array)dVertArray, (Array)new double[checked(Information.UBound((Array)dVertArray, 1) + 1 + 1)]);
                        if (corridorState.IsAboveSurface(objectId, oAlignmentId, (IPoint)pointInMem1) | (long)index7 == DaylightWithExternalFile.SAParamFromFile[1].StepNum & !DaylightWithExternalFile.SAParamFromFile[1].isInfinity)
                        {
                            if (!DaylightWithExternalFile.SAParamFromFile[1].IsActualDaylightUseFixedSlope)
                            {
                                IPoint ipoint1;
                                try
                                {
                                    ipoint1 = corridorState.IntersectSurface(objectId, oAlignmentId, (IPoint)pointInMem2, side != 1L, DaylightWithExternalFile.SAParamFromFile[1].CutOrFillSlope[index8]);
                                }
                                catch (Exception ex)
                                {
                                    ProjectData.SetProjectError(ex);
                                    ipoint1 = (IPoint)null;
                                    ProjectData.ClearProjectError();
                                }
                                if (ipoint1 != null)
                                {
                                    dHorzArray[Information.UBound((Array)dHorzArray, 1)] = ipoint1.Offset - oOrigin.Offset;
                                    dVertArray[Information.UBound((Array)dVertArray, 1)] = ipoint1.Elevation - oOrigin.Elevation;
                                    flag = true;
                                    if (index7 != 1 && Math.Abs(ipoint1.Elevation - pointInMem2.Elevation) < minCutHeight)
                                    {
                                        if (bDaylightHasBenchArray[checked(index7 - 1)] & !bDaylightHasDitchArray[checked(index7 - 1)])
                                        {
                                            dHorzArray = (double[])Utils.CopyArray((Array)dHorzArray, (Array)new double[checked(Information.UBound((Array)dHorzArray, 1) - 2 + 1)]);
                                            dVertArray = (double[])Utils.CopyArray((Array)dVertArray, (Array)new double[checked(Information.UBound((Array)dVertArray, 1) - 2 + 1)]);
                                        }
                                        else if (bDaylightHasBenchArray[checked(index7 - 1)] & bDaylightHasDitchArray[checked(index7 - 1)])
                                        {
                                            dHorzArray = (double[])Utils.CopyArray((Array)dHorzArray, (Array)new double[checked(Information.UBound((Array)dHorzArray, 1) - 5 + 1)]);
                                            dVertArray = (double[])Utils.CopyArray((Array)dVertArray, (Array)new double[checked(Information.UBound((Array)dVertArray, 1) - 5 + 1)]);
                                        }
                                        else
                                        {
                                            dHorzArray = (double[])Utils.CopyArray((Array)dHorzArray, (Array)new double[checked(Information.UBound((Array)dHorzArray, 1) - 1 + 1)]);
                                            dVertArray = (double[])Utils.CopyArray((Array)dVertArray, (Array)new double[checked(Information.UBound((Array)dVertArray, 1) - 1 + 1)]);
                                        }
                                        pointInMem2.Elevation = (dVertArray[checked(Information.UBound((Array)dVertArray, 1) - 1)] + oOrigin.Elevation);
                                        pointInMem2.Offset = (dHorzArray[checked(Information.UBound((Array)dHorzArray, 1) - 1)] + oOrigin.Offset);
                                        IPoint ipoint2;
                                        try
                                        {
                                            ipoint2 = index8 != 1 ? corridorState.IntersectSurface(objectId, oAlignmentId, (IPoint)pointInMem2, side != 1L, DaylightWithExternalFile.SAParamFromFile[1].CutOrFillSlope[checked(index8 - 1)]) : corridorState.IntersectSurface(objectId, oAlignmentId, (IPoint)pointInMem2, side != 1L, DaylightWithExternalFile.SAParamFromFile[1].CutOrFillSlope[index8]);
                                        }
                                        catch (Exception ex)
                                        {
                                            ProjectData.SetProjectError(ex);
                                            ipoint2 = (IPoint)null;
                                            ProjectData.ClearProjectError();
                                        }
                                        if (ipoint2 != null)
                                        {
                                            dHorzArray[Information.UBound((Array)dHorzArray, 1)] = ipoint2.Offset - oOrigin.Offset;
                                            dVertArray[Information.UBound((Array)dVertArray, 1)] = ipoint2.Elevation - oOrigin.Elevation;
                                            checked { --index7; }
                                            flag = true;
                                        }
                                        else
                                        {
                                            Utilities.RecordError(corridorState, (CorridorError)(-2147221479), "", "DaylightWithExternalFile");
                                            return;
                                        }
                                    }
                                    bDaylightHasBenchArray[index7] = false;
                                    bDaylightHasDitchArray[index7] = false;
                                    checked { ++index7; }
                                    break;
                                }
                                Utilities.RecordError(corridorState, (CorridorError)(-2147221479), "", "DaylightWithExternalFile");
                                return;
                            }
                            IPoint ipoint3;
                            try
                            {
                                ipoint3 = corridorState.IntersectSurface(objectId, oAlignmentId, (IPoint)pointInMem2, side != 1L, DaylightWithExternalFile.SAParamFromFile[1].ActualDaylightFixedSlope);
                            }
                            catch (Exception ex)
                            {
                                ProjectData.SetProjectError(ex);
                                ipoint3 = (IPoint)null;
                                ProjectData.ClearProjectError();
                            }
                            if (ipoint3 != null)
                            {
                                dHorzArray[Information.UBound((Array)dHorzArray, 1)] = ipoint3.Offset - oOrigin.Offset;
                                dVertArray[Information.UBound((Array)dVertArray, 1)] = ipoint3.Elevation - oOrigin.Elevation;
                                flag = true;
                                if (index7 != 1 && Math.Abs(ipoint3.Elevation - pointInMem2.Elevation) < minCutHeight)
                                {
                                    if (bDaylightHasBenchArray[checked(index7 - 1)] & !bDaylightHasDitchArray[checked(index7 - 1)])
                                    {
                                        dHorzArray = (double[])Utils.CopyArray((Array)dHorzArray, (Array)new double[checked(Information.UBound((Array)dHorzArray, 1) - 2 + 1)]);
                                        dVertArray = (double[])Utils.CopyArray((Array)dVertArray, (Array)new double[checked(Information.UBound((Array)dVertArray, 1) - 2 + 1)]);
                                    }
                                    else if (bDaylightHasBenchArray[checked(index7 - 1)] & bDaylightHasDitchArray[checked(index7 - 1)])
                                    {
                                        dHorzArray = (double[])Utils.CopyArray((Array)dHorzArray, (Array)new double[checked(Information.UBound((Array)dHorzArray, 1) - 5 + 1)]);
                                        dVertArray = (double[])Utils.CopyArray((Array)dVertArray, (Array)new double[checked(Information.UBound((Array)dVertArray, 1) - 5 + 1)]);
                                    }
                                    else
                                    {
                                        dHorzArray = (double[])Utils.CopyArray((Array)dHorzArray, (Array)new double[checked(Information.UBound((Array)dHorzArray, 1) - 1 + 1)]);
                                        dVertArray = (double[])Utils.CopyArray((Array)dVertArray, (Array)new double[checked(Information.UBound((Array)dVertArray, 1) - 1 + 1)]);
                                    }
                                    pointInMem2.Elevation = (dVertArray[checked(Information.UBound((Array)dVertArray, 1) - 1)] + oOrigin.Elevation);
                                    pointInMem2.Offset = (dHorzArray[checked(Information.UBound((Array)dHorzArray, 1) - 1)] + oOrigin.Offset);
                                    IPoint ipoint1;
                                    try
                                    {
                                        ipoint1 = corridorState.IntersectSurface(objectId, oAlignmentId, (IPoint)pointInMem2, side != 1L, DaylightWithExternalFile.SAParamFromFile[1].ActualDaylightFixedSlope);
                                    }
                                    catch (Exception ex)
                                    {
                                        ProjectData.SetProjectError(ex);
                                        ipoint1 = (IPoint)null;
                                        ProjectData.ClearProjectError();
                                    }
                                    if (ipoint1 != null)
                                    {
                                        dHorzArray[Information.UBound((Array)dHorzArray, 1)] = ipoint1.Offset - oOrigin.Offset;
                                        dVertArray[Information.UBound((Array)dVertArray, 1)] = ipoint1.Elevation - oOrigin.Elevation;
                                        checked { --index7; }
                                        flag = true;
                                    }
                                    else
                                    {
                                        Utilities.RecordError(corridorState, (CorridorError)(-2147221479), "", "DaylightWithExternalFile");
                                        return;
                                    }
                                }
                                bDaylightHasBenchArray[index7] = false;
                                bDaylightHasDitchArray[index7] = false;
                                checked { ++index7; }
                                break;
                            }
                            Utilities.RecordError(corridorState, (CorridorError)(-2147221479), "", "DaylightWithExternalFile");
                            return;
                        }
                        pointInMem2.Elevation = (pointInMem1.Elevation);
                        pointInMem2.Offset = (pointInMem1.Offset);
                        dHorzArray[Information.UBound((Array)dHorzArray, 1)] = pointInMem1.Offset - oOrigin.Offset;
                        dVertArray[Information.UBound((Array)dVertArray, 1)] = pointInMem1.Elevation - oOrigin.Elevation;
                        bDaylightHasBenchArray[index7] = false;
                        if (Conversions.ToBoolean(Operators.NotObject(this.FuzzyEqual(DaylightWithExternalFile.SAParamFromFile[1].BenchWidth[index8], 0.0))))
                        {
                            bDaylightHasBenchArray[index7] = true;
                            pointInMem1.Elevation = (pointInMem1.Elevation + DaylightWithExternalFile.SAParamFromFile[1].BenchWidth[index8] * DaylightWithExternalFile.SAParamFromFile[1].BenchSlope[index8]);
                            pointInMem1.Offset = (pointInMem1.Offset + flip * DaylightWithExternalFile.SAParamFromFile[1].BenchWidth[index8]);
                            dHorzArray = (double[])Utils.CopyArray((Array)dHorzArray, (Array)new double[checked(Information.UBound((Array)dHorzArray, 1) + 1 + 1)]);
                            dVertArray = (double[])Utils.CopyArray((Array)dVertArray, (Array)new double[checked(Information.UBound((Array)dVertArray, 1) + 1 + 1)]);
                            if (corridorState.IsAboveSurface(objectId, oAlignmentId, (IPoint)pointInMem1))
                            {
                                IPoint ipoint;
                                try
                                {
                                    ipoint = corridorState.IntersectSurface(objectId, oAlignmentId, (IPoint)pointInMem2, side != 1L, DaylightWithExternalFile.SAParamFromFile[1].BenchSlope[index8]);
                                }
                                catch (Exception ex)
                                {
                                    ProjectData.SetProjectError(ex);
                                    ipoint = (IPoint)null;
                                    ProjectData.ClearProjectError();
                                }
                                if (ipoint != null)
                                {
                                    dHorzArray[Information.UBound((Array)dHorzArray, 1)] = ipoint.Offset - oOrigin.Offset;
                                    dVertArray[Information.UBound((Array)dVertArray, 1)] = ipoint.Elevation - oOrigin.Elevation;
                                    flag = false;
                                    checked { ++index7; }
                                    break;
                                }
                                Utilities.RecordError(corridorState, (CorridorError)(-2147221479), "", "DaylightWithExternalFile");
                                return;
                            }
                            dHorzArray[Information.UBound((Array)dHorzArray, 1)] = pointInMem1.Offset - oOrigin.Offset;
                            dVertArray[Information.UBound((Array)dVertArray, 1)] = pointInMem1.Elevation - oOrigin.Elevation;
                            bDaylightHasDitchArray[index7] = false;
                            if (DaylightWithExternalFile.SAParamFromFile[1].DitchExistence[index8])
                            {
                                PointInMem point1 = new PointInMem();
                                PointInMem point2 = new PointInMem();
                                point1.Offset = (dHorzArray[checked(Information.UBound((Array)dHorzArray, 1) - 1)] + oOrigin.Offset);
                                point1.Elevation = (dVertArray[checked(Information.UBound((Array)dVertArray, 1) - 1)] + oOrigin.Elevation);
                                point2.Offset = (dHorzArray[Information.UBound((Array)dHorzArray, 1)] + oOrigin.Offset);
                                point2.Elevation = (dVertArray[Information.UBound((Array)dVertArray, 1)] + oOrigin.Elevation);
                                PointInMem pointInMem3 = new PointInMem();
                                PointInMem point3 = new PointInMem();
                                PointInMem intersectionPoint = new PointInMem();
                                pointInMem3.Elevation = (point2.Elevation - DaylightWithExternalFile.SAParamFromFile[1].DitchInnerHeight[index8]);
                                if (DaylightWithExternalFile.SAParamFromFile[1].DitchInnerSlope[index8] == 9999.0)
                                    pointInMem3.Offset = (point2.Offset);
                                else
                                    pointInMem3.Offset = (point2.Offset - flip * DaylightWithExternalFile.SAParamFromFile[1].DitchInnerHeight[index8] / DaylightWithExternalFile.SAParamFromFile[1].DitchInnerSlope[index8]);
                                point3.Elevation = (pointInMem3.Elevation + DaylightWithExternalFile.SAParamFromFile[1].DitchBottomWidth[index8] * DaylightWithExternalFile.SAParamFromFile[1].DitchBottomSlope[index8]);
                                point3.Offset = (pointInMem3.Offset - flip * DaylightWithExternalFile.SAParamFromFile[1].DitchBottomWidth[index8]);
                                if (Conversions.ToBoolean(this.LineIntersect(point1, point2, point3, -1.0 * flip * DaylightWithExternalFile.SAParamFromFile[1].DitchOuterSlope[index8], ref intersectionPoint)))
                                {
                                    if (Conversions.ToBoolean(Operators.NotObject(Operators.AndObject(Operators.AndObject(this.FuzzyEqualGreaterThan(intersectionPoint.Offset * flip, point1.Offset * flip), this.FuzzyEqualLessThan(intersectionPoint.Offset * flip, point2.Offset * flip)), Operators.OrObject(Operators.AndObject(this.FuzzyEqualGreaterThan(intersectionPoint.Elevation, point2.Elevation), this.FuzzyEqualLessThan(intersectionPoint.Elevation, point1.Elevation)), Operators.AndObject(this.FuzzyEqualGreaterThan(intersectionPoint.Elevation, point1.Elevation), this.FuzzyEqualLessThan(intersectionPoint.Elevation, point2.Elevation)))))))
                                    {
                                        Utilities.RecordWarning(corridorState, (CorridorError)0, string.Format(Resources.CUT_DITCH_WIDTH_WARNING, index7), "DaylightWithExternalFile");
                                    }
                                    else
                                    {
                                        dHorzArray = (double[])Utils.CopyArray((Array)dHorzArray, (Array)new double[checked(Information.UBound((Array)dHorzArray, 1) + 3 + 1)]);
                                        dVertArray = (double[])Utils.CopyArray((Array)dVertArray, (Array)new double[checked(Information.UBound((Array)dVertArray, 1) + 3 + 1)]);
                                        dHorzArray[checked(Information.UBound((Array)dHorzArray, 1) - 1)] = pointInMem3.Offset - oOrigin.Offset;
                                        dVertArray[checked(Information.UBound((Array)dVertArray, 1) - 1)] = pointInMem3.Elevation - oOrigin.Elevation;
                                        dHorzArray[checked(Information.UBound((Array)dHorzArray, 1) - 2)] = point3.Offset - oOrigin.Offset;
                                        dVertArray[checked(Information.UBound((Array)dVertArray, 1) - 2)] = point3.Elevation - oOrigin.Elevation;
                                        dHorzArray[checked(Information.UBound((Array)dHorzArray, 1) - 3)] = intersectionPoint.Offset - oOrigin.Offset;
                                        dVertArray[checked(Information.UBound((Array)dVertArray, 1) - 3)] = intersectionPoint.Elevation - oOrigin.Elevation;
                                        dHorzArray[Information.UBound((Array)dHorzArray, 1)] = point2.Offset - oOrigin.Offset;
                                        dVertArray[Information.UBound((Array)dVertArray, 1)] = point2.Elevation - oOrigin.Elevation;
                                        bDaylightHasDitchArray[index7] = true;
                                    }
                                }
                                else
                                    Utilities.RecordWarning(corridorState, (CorridorError)0, string.Format(Resources.CUT_DITCH_WIDTH_WARNING, index7), "DaylightWithExternalFile");
                            }
                        }
                        if ((long)index8 == DaylightWithExternalFile.SAParamFromFile[1].StepNum & DaylightWithExternalFile.SAParamFromFile[1].isInfinity)
                            checked { --index8; }
                        checked { ++index8; }
                        checked { ++index7; }
                        bDaylightHasDitchArray = (bool[])Utils.CopyArray((Array)bDaylightHasDitchArray, (Array)new bool[checked(Information.UBound((Array)bDaylightHasDitchArray, 1) + 1 + 1)]);
                        bDaylightHasBenchArray = (bool[])Utils.CopyArray((Array)bDaylightHasBenchArray, (Array)new bool[checked(Information.UBound((Array)bDaylightHasBenchArray, 1) + 1 + 1)]);
                        bDaylightHasDitchArray[Information.UBound((Array)bDaylightHasDitchArray, 1)] = false;
                        bDaylightHasBenchArray[Information.UBound((Array)bDaylightHasBenchArray, 1)] = false;
                    }
                }
                else if (eFilOrCut == Utilities.FillOrCut.FillSituation)
                {
                    int index8 = 1;
                    while (!(!corridorState.IsAboveSurface(objectId, oAlignmentId, (IPoint)pointInMem1) | corridorState.IntersectSurface(objectId, oAlignmentId, (IPoint)pointInMem1, side != 1L, -10000000000000.0) == null))
                    {
                        pointInMem2.Elevation = (pointInMem1.Elevation);
                        pointInMem2.Offset = (pointInMem1.Offset);
                        pointInMem1.Elevation = pointInMem1.Elevation - SAParamFromFile[2].MaxCutOrFillHeight[index8];
                        if (SAParamFromFile[2].CutOrFillSlope[index8] == 9999.0)
                            pointInMem1.Offset = (pointInMem1.Offset);
                        else
                            pointInMem1.Offset = (pointInMem1.Offset + flip * DaylightWithExternalFile.SAParamFromFile[2].MaxCutOrFillHeight[index8] / DaylightWithExternalFile.SAParamFromFile[2].CutOrFillSlope[index8]);
                        dHorzArray = (double[])Utils.CopyArray((Array)dHorzArray, (Array)new double[checked(Information.UBound((Array)dHorzArray, 1) + 1 + 1)]);
                        dVertArray = (double[])Utils.CopyArray((Array)dVertArray, (Array)new double[checked(Information.UBound((Array)dVertArray, 1) + 1 + 1)]);
                        if (!corridorState.IsAboveSurface(objectId, oAlignmentId, (IPoint)pointInMem1) | (long)index7 == DaylightWithExternalFile.SAParamFromFile[2].StepNum & !DaylightWithExternalFile.SAParamFromFile[2].isInfinity)
                        {
                            if (!DaylightWithExternalFile.SAParamFromFile[2].IsActualDaylightUseFixedSlope)
                            {
                                IPoint ipoint1;
                                try
                                {
                                    ipoint1 = corridorState.IntersectSurface(objectId, oAlignmentId, (IPoint)pointInMem2, side != 1L, -DaylightWithExternalFile.SAParamFromFile[2].CutOrFillSlope[index8]);
                                }
                                catch (Exception ex)
                                {
                                    ProjectData.SetProjectError(ex);
                                    ipoint1 = (IPoint)null;
                                    ProjectData.ClearProjectError();
                                }
                                if (ipoint1 != null)
                                {
                                    dHorzArray[Information.UBound((Array)dHorzArray, 1)] = ipoint1.Offset - oOrigin.Offset;
                                    dVertArray[Information.UBound((Array)dVertArray, 1)] = ipoint1.Elevation - oOrigin.Elevation;
                                    flag = true;
                                    if (index7 != 1 && Math.Abs(ipoint1.Elevation - pointInMem2.Elevation) < minFillHeight)
                                    {
                                        if (bDaylightHasBenchArray[checked(index7 - 1)] & !bDaylightHasDitchArray[checked(index7 - 1)])
                                        {
                                            dHorzArray = (double[])Utils.CopyArray((Array)dHorzArray, (Array)new double[checked(Information.UBound((Array)dHorzArray, 1) - 2 + 1)]);
                                            dVertArray = (double[])Utils.CopyArray((Array)dVertArray, (Array)new double[checked(Information.UBound((Array)dVertArray, 1) - 2 + 1)]);
                                        }
                                        else if (bDaylightHasBenchArray[checked(index7 - 1)] & bDaylightHasDitchArray[checked(index7 - 1)])
                                        {
                                            dHorzArray = (double[])Utils.CopyArray((Array)dHorzArray, (Array)new double[checked(Information.UBound((Array)dHorzArray, 1) - 5 + 1)]);
                                            dVertArray = (double[])Utils.CopyArray((Array)dVertArray, (Array)new double[checked(Information.UBound((Array)dVertArray, 1) - 5 + 1)]);
                                        }
                                        else
                                        {
                                            dHorzArray = (double[])Utils.CopyArray((Array)dHorzArray, (Array)new double[checked(Information.UBound((Array)dHorzArray, 1) - 1 + 1)]);
                                            dVertArray = (double[])Utils.CopyArray((Array)dVertArray, (Array)new double[checked(Information.UBound((Array)dVertArray, 1) - 1 + 1)]);
                                        }
                                        pointInMem2.Elevation = (dVertArray[checked(Information.UBound((Array)dVertArray, 1) - 1)] + oOrigin.Elevation);
                                        pointInMem2.Offset = (dHorzArray[checked(Information.UBound((Array)dHorzArray, 1) - 1)] + oOrigin.Offset);
                                        IPoint ipoint2;
                                        try
                                        {
                                            ipoint2 = index8 != 1 ? corridorState.IntersectSurface(objectId, oAlignmentId, (IPoint)pointInMem2, side != 1L, -DaylightWithExternalFile.SAParamFromFile[2].CutOrFillSlope[checked(index8 - 1)]) : corridorState.IntersectSurface(objectId, oAlignmentId, (IPoint)pointInMem2, side != 1L, -DaylightWithExternalFile.SAParamFromFile[2].CutOrFillSlope[index8]);
                                        }
                                        catch (Exception ex)
                                        {
                                            ProjectData.SetProjectError(ex);
                                            ipoint2 = (IPoint)null;
                                            ProjectData.ClearProjectError();
                                        }
                                        if (ipoint2 != null)
                                        {
                                            dHorzArray[Information.UBound((Array)dHorzArray, 1)] = ipoint2.Offset - oOrigin.Offset;
                                            dVertArray[Information.UBound((Array)dVertArray, 1)] = ipoint2.Elevation - oOrigin.Elevation;
                                            checked { --index7; }
                                            flag = true;
                                        }
                                        else
                                        {
                                            Utilities.RecordError(corridorState, (CorridorError)(-2147221479), "", "DaylightWithExternalFile");
                                            return;
                                        }
                                    }
                                    bDaylightHasBenchArray[index7] = false;
                                    bDaylightHasDitchArray[index7] = false;
                                    checked { ++index7; }
                                    break;
                                }
                                Utilities.RecordError(corridorState, (CorridorError)(-2147221479), "", "DaylightWithExternalFile");
                                return;
                            }
                            IPoint ipoint3;
                            try
                            {
                                ipoint3 = corridorState.IntersectSurface(objectId, oAlignmentId, (IPoint)pointInMem2, side != 1L, -DaylightWithExternalFile.SAParamFromFile[2].ActualDaylightFixedSlope);
                            }
                            catch (Exception ex)
                            {
                                ProjectData.SetProjectError(ex);
                                ipoint3 = (IPoint)null;
                                ProjectData.ClearProjectError();
                            }
                            if (ipoint3 != null)
                            {
                                dHorzArray[Information.UBound((Array)dHorzArray, 1)] = ipoint3.Offset - oOrigin.Offset;
                                dVertArray[Information.UBound((Array)dVertArray, 1)] = ipoint3.Elevation - oOrigin.Elevation;
                                flag = true;
                                if (index7 != 1 && Math.Abs(ipoint3.Elevation - pointInMem2.Elevation) < minFillHeight)
                                {
                                    if (bDaylightHasBenchArray[checked(index7 - 1)] & !bDaylightHasDitchArray[checked(index7 - 1)])
                                    {
                                        dHorzArray = (double[])Utils.CopyArray((Array)dHorzArray, (Array)new double[checked(Information.UBound((Array)dHorzArray, 1) - 2 + 1)]);
                                        dVertArray = (double[])Utils.CopyArray((Array)dVertArray, (Array)new double[checked(Information.UBound((Array)dVertArray, 1) - 2 + 1)]);
                                    }
                                    else if (bDaylightHasBenchArray[checked(index7 - 1)] & bDaylightHasDitchArray[checked(index7 - 1)])
                                    {
                                        dHorzArray = (double[])Utils.CopyArray((Array)dHorzArray, (Array)new double[checked(Information.UBound((Array)dHorzArray, 1) - 5 + 1)]);
                                        dVertArray = (double[])Utils.CopyArray((Array)dVertArray, (Array)new double[checked(Information.UBound((Array)dVertArray, 1) - 5 + 1)]);
                                    }
                                    else
                                    {
                                        dHorzArray = (double[])Utils.CopyArray((Array)dHorzArray, (Array)new double[checked(Information.UBound((Array)dHorzArray, 1) - 1 + 1)]);
                                        dVertArray = (double[])Utils.CopyArray((Array)dVertArray, (Array)new double[checked(Information.UBound((Array)dVertArray, 1) - 1 + 1)]);
                                    }
                                    pointInMem2.Elevation = (dVertArray[checked(Information.UBound((Array)dVertArray, 1) - 1)] + oOrigin.Elevation);
                                    pointInMem2.Offset = (dHorzArray[checked(Information.UBound((Array)dHorzArray, 1) - 1)] + oOrigin.Offset);
                                    IPoint ipoint1;
                                    try
                                    {
                                        ipoint1 = corridorState.IntersectSurface(objectId, oAlignmentId, (IPoint)pointInMem2, side != 1L, -DaylightWithExternalFile.SAParamFromFile[2].ActualDaylightFixedSlope);
                                    }
                                    catch (Exception ex)
                                    {
                                        ProjectData.SetProjectError(ex);
                                        ipoint1 = (IPoint)null;
                                        ProjectData.ClearProjectError();
                                    }
                                    if (ipoint1 != null)
                                    {
                                        dHorzArray[Information.UBound((Array)dHorzArray, 1)] = ipoint1.Offset - oOrigin.Offset;
                                        dVertArray[Information.UBound((Array)dVertArray, 1)] = ipoint1.Elevation - oOrigin.Elevation;
                                        checked { --index7; }
                                        flag = true;
                                    }
                                    else
                                    {
                                        Utilities.RecordError(corridorState, (CorridorError)(-2147221479), "", "DaylightWithExternalFile");
                                        return;
                                    }
                                }
                                bDaylightHasBenchArray[index7] = false;
                                bDaylightHasDitchArray[index7] = false;
                                checked { ++index7; }
                                break;
                            }
                            Utilities.RecordError(corridorState, (CorridorError)(-2147221479), "", "DaylightWithExternalFile");
                            return;
                        }
                        pointInMem2.Elevation = (pointInMem1.Elevation);
                        pointInMem2.Offset = (pointInMem1.Offset);
                        dHorzArray[Information.UBound((Array)dHorzArray, 1)] = pointInMem1.Offset - oOrigin.Offset;
                        dVertArray[Information.UBound((Array)dVertArray, 1)] = pointInMem1.Elevation - oOrigin.Elevation;
                        bDaylightHasBenchArray[index7] = false;
                        if (Conversions.ToBoolean(Operators.NotObject(this.FuzzyEqual(DaylightWithExternalFile.SAParamFromFile[2].BenchWidth[index8], 0.0))))
                        {
                            bDaylightHasBenchArray[index7] = true;
                            pointInMem1.Elevation = (pointInMem1.Elevation + DaylightWithExternalFile.SAParamFromFile[2].BenchWidth[index8] * DaylightWithExternalFile.SAParamFromFile[2].BenchSlope[index8]);
                            pointInMem1.Offset = (pointInMem1.Offset + flip * DaylightWithExternalFile.SAParamFromFile[2].BenchWidth[index8]);
                            dHorzArray = (double[])Utils.CopyArray((Array)dHorzArray, (Array)new double[checked(Information.UBound((Array)dHorzArray, 1) + 1 + 1)]);
                            dVertArray = (double[])Utils.CopyArray((Array)dVertArray, (Array)new double[checked(Information.UBound((Array)dVertArray, 1) + 1 + 1)]);
                            if (!corridorState.IsAboveSurface(objectId, oAlignmentId, (IPoint)pointInMem1))
                            {
                                IPoint ipoint;
                                try
                                {
                                    ipoint = corridorState.IntersectSurface(objectId, oAlignmentId, (IPoint)pointInMem2, side != 1L, DaylightWithExternalFile.SAParamFromFile[2].BenchSlope[index8]);
                                }
                                catch (Exception ex)
                                {
                                    ProjectData.SetProjectError(ex);
                                    ipoint = (IPoint)null;
                                    ProjectData.ClearProjectError();
                                }
                                if (ipoint != null)
                                {
                                    dHorzArray[Information.UBound((Array)dHorzArray, 1)] = ipoint.Offset - oOrigin.Offset;
                                    dVertArray[Information.UBound((Array)dVertArray, 1)] = ipoint.Elevation - oOrigin.Elevation;
                                    flag = false;
                                    bDaylightHasDitchArray[index7] = false;
                                    if (DaylightWithExternalFile.SAParamFromFile[2].DitchExistence[index8])
                                    {
                                        PointInMem point1 = new PointInMem();
                                        PointInMem point2 = new PointInMem();
                                        point1.Offset = (dHorzArray[checked(Information.UBound((Array)dHorzArray, 1) - 1)] + oOrigin.Offset);
                                        point1.Elevation = (dVertArray[checked(Information.UBound((Array)dVertArray, 1) - 1)] + oOrigin.Elevation);
                                        point2.Offset = (dHorzArray[Information.UBound((Array)dHorzArray, 1)] + oOrigin.Offset);
                                        point2.Elevation = (dVertArray[Information.UBound((Array)dVertArray, 1)] + oOrigin.Elevation);
                                        PointInMem pointInMem3 = new PointInMem();
                                        PointInMem point3 = new PointInMem();
                                        PointInMem intersectionPoint = new PointInMem();
                                        pointInMem3.Elevation = (point1.Elevation - DaylightWithExternalFile.SAParamFromFile[2].DitchInnerHeight[index8]);
                                        if (DaylightWithExternalFile.SAParamFromFile[2].DitchInnerSlope[index8] == 9999.0)
                                            pointInMem3.Offset = (point1.Offset);
                                        else
                                            pointInMem3.Offset = (point1.Offset + flip * DaylightWithExternalFile.SAParamFromFile[2].DitchInnerHeight[index8] / DaylightWithExternalFile.SAParamFromFile[2].DitchInnerSlope[index8]);
                                        point3.Elevation = (pointInMem3.Elevation + DaylightWithExternalFile.SAParamFromFile[2].DitchBottomWidth[index8] * DaylightWithExternalFile.SAParamFromFile[2].DitchBottomSlope[index8]);
                                        point3.Offset = (pointInMem3.Offset + flip * DaylightWithExternalFile.SAParamFromFile[2].DitchBottomWidth[index8]);
                                        if (Conversions.ToBoolean(this.LineIntersect(point1, point2, point3, flip * DaylightWithExternalFile.SAParamFromFile[2].DitchOuterSlope[index8], ref intersectionPoint)))
                                        {
                                            if (Conversions.ToBoolean(Operators.NotObject(Operators.AndObject(Operators.AndObject(this.FuzzyEqualGreaterThan(intersectionPoint.Offset * flip, point1.Offset * flip), this.FuzzyEqualLessThan(intersectionPoint.Offset * flip, point2.Offset * flip)), Operators.OrObject(Operators.AndObject(this.FuzzyEqualGreaterThan(intersectionPoint.Elevation, point2.Elevation), this.FuzzyEqualLessThan(intersectionPoint.Elevation, point1.Elevation)), Operators.AndObject(this.FuzzyEqualGreaterThan(intersectionPoint.Elevation, point1.Elevation), this.FuzzyEqualLessThan(intersectionPoint.Elevation, point2.Elevation)))))))
                                            {
                                                Utilities.RecordWarning(corridorState, (CorridorError)0, string.Format(Resources.FILL_DITCH_WIDTH_WARNING, index7), "DaylightWithExternalFile");
                                            }
                                            else
                                            {
                                                dHorzArray = (double[])Utils.CopyArray((Array)dHorzArray, (Array)new double[checked(Information.UBound((Array)dHorzArray, 1) + 3 + 1)]);
                                                dVertArray = (double[])Utils.CopyArray((Array)dVertArray, (Array)new double[checked(Information.UBound((Array)dVertArray, 1) + 3 + 1)]);
                                                dHorzArray[checked(Information.UBound((Array)dHorzArray, 1) - 3)] = pointInMem3.Offset - oOrigin.Offset;
                                                dVertArray[checked(Information.UBound((Array)dVertArray, 1) - 3)] = pointInMem3.Elevation - oOrigin.Elevation;
                                                dHorzArray[checked(Information.UBound((Array)dHorzArray, 1) - 2)] = point3.Offset - oOrigin.Offset;
                                                dVertArray[checked(Information.UBound((Array)dVertArray, 1) - 2)] = point3.Elevation - oOrigin.Elevation;
                                                dHorzArray[checked(Information.UBound((Array)dHorzArray, 1) - 1)] = intersectionPoint.Offset - oOrigin.Offset;
                                                dVertArray[checked(Information.UBound((Array)dVertArray, 1) - 1)] = intersectionPoint.Elevation - oOrigin.Elevation;
                                                dHorzArray[Information.UBound((Array)dHorzArray, 1)] = point2.Offset - oOrigin.Offset;
                                                dVertArray[Information.UBound((Array)dVertArray, 1)] = point2.Elevation - oOrigin.Elevation;
                                                bDaylightHasDitchArray[index7] = true;
                                            }
                                        }
                                        else
                                            Utilities.RecordWarning(corridorState, (CorridorError)0, string.Format(Resources.FILL_DITCH_WIDTH_WARNING, index7), "DaylightWithExternalFile");
                                    }
                                    checked { ++index7; }
                                    break;
                                }
                                Utilities.RecordError(corridorState, (CorridorError)(-2147221479), "", "DaylightWithExternalFile");
                                return;
                            }
                            dHorzArray[Information.UBound((Array)dHorzArray, 1)] = pointInMem1.Offset - oOrigin.Offset;
                            dVertArray[Information.UBound((Array)dVertArray, 1)] = pointInMem1.Elevation - oOrigin.Elevation;
                            bDaylightHasDitchArray[index7] = false;
                            if (DaylightWithExternalFile.SAParamFromFile[2].DitchExistence[index8])
                            {
                                PointInMem point1 = new PointInMem();
                                PointInMem point2 = new PointInMem();
                                point1.Offset = (dHorzArray[checked(Information.UBound((Array)dHorzArray, 1) - 1)] + oOrigin.Offset);
                                point1.Elevation = (dVertArray[checked(Information.UBound((Array)dVertArray, 1) - 1)] + oOrigin.Elevation);
                                point2.Offset = (dHorzArray[Information.UBound((Array)dHorzArray, 1)] + oOrigin.Offset);
                                point2.Elevation = (dVertArray[Information.UBound((Array)dVertArray, 1)] + oOrigin.Elevation);
                                PointInMem pointInMem3 = new PointInMem();
                                PointInMem point3 = new PointInMem();
                                PointInMem intersectionPoint = new PointInMem();
                                pointInMem3.Elevation = (point1.Elevation - DaylightWithExternalFile.SAParamFromFile[2].DitchInnerHeight[index8]);
                                if (DaylightWithExternalFile.SAParamFromFile[2].DitchInnerSlope[index8] == 9999.0)
                                    pointInMem3.Offset = (point1.Offset);
                                else
                                    pointInMem3.Offset = (point1.Offset + flip * DaylightWithExternalFile.SAParamFromFile[2].DitchInnerHeight[index8] / DaylightWithExternalFile.SAParamFromFile[2].DitchInnerSlope[index8]);
                                point3.Elevation = (pointInMem3.Elevation + DaylightWithExternalFile.SAParamFromFile[2].DitchBottomWidth[index8] * DaylightWithExternalFile.SAParamFromFile[2].DitchBottomSlope[index8]);
                                point3.Offset = (pointInMem3.Offset + flip * DaylightWithExternalFile.SAParamFromFile[2].DitchBottomWidth[index8]);
                                if (Conversions.ToBoolean(this.LineIntersect(point1, point2, point3, flip * DaylightWithExternalFile.SAParamFromFile[2].DitchOuterSlope[index8], ref intersectionPoint)))
                                {
                                    if (Conversions.ToBoolean(Operators.NotObject(Operators.AndObject(Operators.AndObject(this.FuzzyEqualGreaterThan(intersectionPoint.Offset * flip, point1.Offset * flip), this.FuzzyEqualLessThan(intersectionPoint.Offset * flip, point2.Offset * flip)), Operators.OrObject(Operators.AndObject(this.FuzzyEqualGreaterThan(intersectionPoint.Elevation, point2.Elevation), this.FuzzyEqualLessThan(intersectionPoint.Elevation, point1.Elevation)), Operators.AndObject(this.FuzzyEqualGreaterThan(intersectionPoint.Elevation, point1.Elevation), this.FuzzyEqualLessThan(intersectionPoint.Elevation, point2.Elevation)))))))
                                    {
                                        Utilities.RecordWarning(corridorState, (CorridorError)0, string.Format(Resources.FILL_DITCH_WIDTH_WARNING, index7), "DaylightWithExternalFile");
                                    }
                                    else
                                    {
                                        dHorzArray = (double[])Utils.CopyArray((Array)dHorzArray, (Array)new double[checked(Information.UBound((Array)dHorzArray, 1) + 3 + 1)]);
                                        dVertArray = (double[])Utils.CopyArray((Array)dVertArray, (Array)new double[checked(Information.UBound((Array)dVertArray, 1) + 3 + 1)]);
                                        dHorzArray[checked(Information.UBound((Array)dHorzArray, 1) - 3)] = pointInMem3.Offset - oOrigin.Offset;
                                        dVertArray[checked(Information.UBound((Array)dVertArray, 1) - 3)] = pointInMem3.Elevation - oOrigin.Elevation;
                                        dHorzArray[checked(Information.UBound((Array)dHorzArray, 1) - 2)] = point3.Offset - oOrigin.Offset;
                                        dVertArray[checked(Information.UBound((Array)dVertArray, 1) - 2)] = point3.Elevation - oOrigin.Elevation;
                                        dHorzArray[checked(Information.UBound((Array)dHorzArray, 1) - 1)] = intersectionPoint.Offset - oOrigin.Offset;
                                        dVertArray[checked(Information.UBound((Array)dVertArray, 1) - 1)] = intersectionPoint.Elevation - oOrigin.Elevation;
                                        dHorzArray[Information.UBound((Array)dHorzArray, 1)] = point2.Offset - oOrigin.Offset;
                                        dVertArray[Information.UBound((Array)dVertArray, 1)] = point2.Elevation - oOrigin.Elevation;
                                        bDaylightHasDitchArray[index7] = true;
                                    }
                                }
                                else
                                    Utilities.RecordWarning(corridorState, (CorridorError)0, string.Format(Resources.FILL_DITCH_WIDTH_WARNING, index7), "DaylightWithExternalFile");
                            }
                        }
                        if ((long)index8 == DaylightWithExternalFile.SAParamFromFile[2].StepNum & DaylightWithExternalFile.SAParamFromFile[2].isInfinity)
                            checked { --index8; }
                        checked { ++index8; }
                        checked { ++index7; }
                        bDaylightHasDitchArray = (bool[])Utils.CopyArray((Array)bDaylightHasDitchArray, (Array)new bool[checked(Information.UBound((Array)bDaylightHasDitchArray, 1) + 1 + 1)]);
                        bDaylightHasBenchArray = (bool[])Utils.CopyArray((Array)bDaylightHasBenchArray, (Array)new bool[checked(Information.UBound((Array)bDaylightHasBenchArray, 1) + 1 + 1)]);
                        bDaylightHasDitchArray[Information.UBound((Array)bDaylightHasDitchArray, 1)] = false;
                        bDaylightHasBenchArray[Information.UBound((Array)bDaylightHasBenchArray, 1)] = false;
                    }
                }
                int iStepCounter = checked(index7 - 1);
                this.AddCodeForPointAndLink(corridorState, ref iStepCounter, ref dHorzArray, ref dVertArray, ref bDaylightHasBenchArray, ref bDaylightHasDitchArray, ref eFilOrCut);
                paramsLong.Add("Side", checked((int)side));
                paramsString.Add("FileName", fileName);
                paramsLong.Add("PlaceLinedMaterial", checked((int)placeLineMaterial));
                paramsDouble.Add("MaterialThickness", materialThickness);
                paramsString.Add("MaterialName", materialName);
            }
        }

        private void AddCodeForPointAndLink(CorridorState corridorState, ref int iStepCounter, ref double[] dHorzArray, ref double[] dVertArray, ref bool[] bDaylightHasBenchArray, ref bool[] bDaylightHasDitchArray, ref Utilities.FillOrCut eFilOrCut)
        {
            string[,] sPointCodeArray = new string[12, 2];
            string[,] sLinkCodeArray = new string[9, 2];
            this.FillCodesFromTable(sPointCodeArray, sLinkCodeArray);
            Point[] oLinkPointArray = new Point[2];
            PointCollection points = corridorState.Points;
            LinkCollection links = corridorState.Links;
            ShapeCollection shapes = corridorState.Shapes;
            Link[] linkArray = new Link[4];
            int index1 = 1;
            ParamLongCollection paramsLong = corridorState.ParamsLong;
            ParamDoubleCollection paramsDouble = corridorState.ParamsDouble;
            ParamStringCollection paramsString = corridorState.ParamsString;
            //corridorState.ParamsSurface;
            long num1;
            try
            {
                num1 = (long)paramsLong.Value("Side");
            }
            catch (Exception ex)
            {
                ProjectData.SetProjectError(ex);
                num1 = 0L;
                ProjectData.ClearProjectError();
            }
            double num2 = 1.0;
            if (num1 == 1L)
                num2 = -1.0;
            long num3;
            try
            {
                num3 = (long)paramsLong.Value("PlaceLinedMaterial");
            }
            catch (Exception ex)
            {
                ProjectData.SetProjectError(ex);
                num3 = 4L;
                ProjectData.ClearProjectError();
            }
            double materialThickness;
            try
            {
                materialThickness = paramsDouble.Value("MaterialThickness");
            }
            catch (Exception ex)
            {
                ProjectData.SetProjectError(ex);
                materialThickness = 0.15;
                ProjectData.ClearProjectError();
            }
            string str;
            try
            {
                str = paramsString.Value("MaterialName");
            }
            catch (Exception ex)
            {
                ProjectData.SetProjectError(ex);
                str = "Rip Rap";
                ProjectData.ClearProjectError();
            }
            int index2 = eFilOrCut != Utilities.FillOrCut.CutSituation ? 4 : 1;
            if (iStepCounter < 1)
                return;
            oLinkPointArray[0] = points.Add(dHorzArray[index1], dVertArray[index1], "");
            int index3 = checked(index1 + 1);
            oLinkPointArray[0].Codes.Add(sPointCodeArray[index2, 0]);
            oLinkPointArray[0].Codes.Add(sPointCodeArray[index2, 1]);
            if (eFilOrCut == Utilities.FillOrCut.CutSituation)
            {
                if (!string.IsNullOrEmpty(DaylightWithExternalFile.SAParamFromFile[1].CustomCodePointDaylightStart[1]))
                {
                    string[] strArray = DaylightWithExternalFile.SAParamFromFile[1].CustomCodePointDaylightStart[1].Split(',');
                    int num4 = 0;
                    int num5 = Information.UBound((Array)strArray, 1);
                    int index4 = num4;
                    while (index4 <= num5)
                    {
                        if (!string.IsNullOrEmpty(strArray[index4]))
                            oLinkPointArray[0].Codes.Add(strArray[index4]);
                        checked { ++index4; }
                    }
                }
            }
            else if (!string.IsNullOrEmpty(SAParamFromFile[2].CustomCodePointDaylightStart[1]))
            {
                string[] strArray = SAParamFromFile[2].CustomCodePointDaylightStart[1].Split(',');
                int num4 = 0;
                int num5 = Information.UBound((Array)strArray, 1);
                int index4 = num4;
                while (index4 <= num5)
                {
                    if (!string.IsNullOrEmpty(strArray[index4]))
                        oLinkPointArray[0].Codes.Add(strArray[index4]);
                    checked { ++index4; }
                }
            }
            int num6 = 1;
            int num7 = iStepCounter;
            int index5 = num6;
            while (index5 <= num7)
            {
                oLinkPointArray[1] = points.Add(dHorzArray[index3], dVertArray[index3], "");
                checked { ++index3; }
                string[] strArray1;
                if (eFilOrCut == Utilities.FillOrCut.CutSituation)
                {
                    if (index5 == iStepCounter)
                    {
                        oLinkPointArray[1].Codes.Add(sPointCodeArray[7, 0]);
                        oLinkPointArray[1].Codes.Add(sPointCodeArray[7, 1]);
                    }
                    strArray1 = new string[1];
                    long num4 = (long)index5 <= DaylightWithExternalFile.SAParamFromFile[1].StepNum ? (long)index5 : DaylightWithExternalFile.SAParamFromFile[1].StepNum;
                    if (!string.IsNullOrEmpty(DaylightWithExternalFile.SAParamFromFile[1].CustomCodePointDaylightEnd[checked((int)num4)]))
                    {
                        string[] strArray2 = DaylightWithExternalFile.SAParamFromFile[1].CustomCodePointDaylightEnd[checked((int)num4)].Split(',');
                        int num5 = 0;
                        int num8 = Information.UBound((Array)strArray2, 1);
                        int index4 = num5;
                        while (index4 <= num8)
                        {
                            if (!string.IsNullOrEmpty(strArray2[index4]))
                                oLinkPointArray[1].Codes.Add(strArray2[index4]);
                            checked { ++index4; }
                        }
                    }
                }
                else
                {
                    if (index5 == iStepCounter)
                    {
                        oLinkPointArray[1].Codes.Add(sPointCodeArray[8, 0]);
                        oLinkPointArray[1].Codes.Add(sPointCodeArray[8, 1]);
                    }
                    strArray1 = new string[1];
                    long num4 = (long)index5 <= DaylightWithExternalFile.SAParamFromFile[2].StepNum ? (long)index5 : DaylightWithExternalFile.SAParamFromFile[2].StepNum;
                    if (!string.IsNullOrEmpty(DaylightWithExternalFile.SAParamFromFile[2].CustomCodePointDaylightEnd[checked((int)num4)]))
                    {
                        string[] strArray2 = DaylightWithExternalFile.SAParamFromFile[2].CustomCodePointDaylightEnd[checked((int)num4)].Split(',');
                        int num5 = 0;
                        int num8 = Information.UBound((Array)strArray2, 1);
                        int index4 = num5;
                        while (index4 <= num8)
                        {
                            if (!string.IsNullOrEmpty(strArray2[index4]))
                                oLinkPointArray[1].Codes.Add(strArray2[index4]);
                            checked { ++index4; }
                        }
                    }
                }
                Link link1 = links.Add((IPoint[])oLinkPointArray, "");
                link1.Codes.Add(sLinkCodeArray[2, 0]);
                link1.Codes.Add(sLinkCodeArray[1, 0]);
                link1.Codes.Add(sLinkCodeArray[5, 0]);
                if (index5 == iStepCounter)
                {
                    if (eFilOrCut == Utilities.FillOrCut.CutSituation)
                        link1.Codes.Add(sLinkCodeArray[2, 1]);
                    else
                        link1.Codes.Add(sLinkCodeArray[3, 1]);
                }
                strArray1 = new string[1];
                if (eFilOrCut == Utilities.FillOrCut.CutSituation)
                {
                    long num4 = (long)index5 <= DaylightWithExternalFile.SAParamFromFile[1].StepNum ? (long)index5 : DaylightWithExternalFile.SAParamFromFile[1].StepNum;
                    if (!string.IsNullOrEmpty(DaylightWithExternalFile.SAParamFromFile[1].CustomCodeLinkDaylight[checked((int)num4)]))
                    {
                        string[] strArray2 = DaylightWithExternalFile.SAParamFromFile[1].CustomCodeLinkDaylight[checked((int)num4)].Split(',');
                        int num5 = 0;
                        int num8 = Information.UBound((Array)strArray2, 1);
                        int index4 = num5;
                        while (index4 <= num8)
                        {
                            if (!string.IsNullOrEmpty(strArray2[index4]))
                                link1.Codes.Add(strArray2[index4]);
                            checked { ++index4; }
                        }
                    }
                }
                else
                {
                    long num4 = (long)index5 <= DaylightWithExternalFile.SAParamFromFile[2].StepNum ? (long)index5 : DaylightWithExternalFile.SAParamFromFile[2].StepNum;
                    if (!string.IsNullOrEmpty(DaylightWithExternalFile.SAParamFromFile[2].CustomCodeLinkDaylight[checked((int)num4)]))
                    {
                        string[] strArray2 = DaylightWithExternalFile.SAParamFromFile[2].CustomCodeLinkDaylight[checked((int)num4)].Split(',');
                        int num5 = 0;
                        int num8 = Information.UBound((Array)strArray2, 1);
                        int index4 = num5;
                        while (index4 <= num8)
                        {
                            if (!string.IsNullOrEmpty(strArray2[index4]))
                                link1.Codes.Add(strArray2[index4]);
                            checked { ++index4; }
                        }
                    }
                }
                if (num3 == 0L | num3 == 1L)
                {
                    double xOffset = 0.0;
                    double yOffset = 0.0;
                    this.CalcMaterialXYOffset(oLinkPointArray, materialThickness, ref xOffset, ref yOffset);
                    Point point1;
                    Point point2;
                    if (eFilOrCut == Utilities.FillOrCut.CutSituation)
                    {
                        point1 = points.Add(oLinkPointArray[0].Offset + num2 * xOffset, oLinkPointArray[0].Elevation - yOffset, "");
                        point2 = points.Add(oLinkPointArray[1].Offset + num2 * xOffset, oLinkPointArray[1].Elevation - yOffset, "");
                    }
                    else
                    {
                        point1 = points.Add(oLinkPointArray[0].Offset - num2 * xOffset, oLinkPointArray[0].Elevation - yOffset, "");
                        point2 = points.Add(oLinkPointArray[1].Offset - num2 * xOffset, oLinkPointArray[1].Elevation - yOffset, "");
                    }
                    linkArray[0] = link1;
                    oLinkPointArray[0] = link1.Points[1];
                    oLinkPointArray[1] = point2;
                    linkArray[1] = links.Add((IPoint[])oLinkPointArray, "");
                    oLinkPointArray[0] = point2;
                    oLinkPointArray[1] = point1;
                    linkArray[2] = links.Add((IPoint[])oLinkPointArray, sLinkCodeArray[5, 0]);
                    oLinkPointArray[0] = point1;
                    oLinkPointArray[1] = link1.Points[0];
                    linkArray[3] = links.Add((IPoint[])oLinkPointArray, "");
                    shapes.Add(linkArray, str);
                    oLinkPointArray[0] = link1.Points[0];
                    oLinkPointArray[1] = link1.Points[1];
                }
                oLinkPointArray[0] = oLinkPointArray[1];
                if (bDaylightHasBenchArray[index5])
                {
                    if (eFilOrCut == Utilities.FillOrCut.CutSituation)
                    {
                        oLinkPointArray[1].Codes.Add(sPointCodeArray[2, 0]);
                        oLinkPointArray[1] = points.Add(dHorzArray[index3], dVertArray[index3], "");
                        checked { ++index3; }
                        oLinkPointArray[1].Codes.Add(sPointCodeArray[3, 0]);
                        Link link2 = links.Add((IPoint[])oLinkPointArray, "");
                        link2.Codes.Add(sLinkCodeArray[7, 0]);
                        link2.Codes.Add(sLinkCodeArray[1, 0]);
                        link2.Codes.Add(sLinkCodeArray[5, 0]);
                        strArray1 = new string[1];
                        long num4 = (long)index5 <= DaylightWithExternalFile.SAParamFromFile[1].StepNum ? (long)index5 : DaylightWithExternalFile.SAParamFromFile[1].StepNum;
                        if (!string.IsNullOrEmpty(DaylightWithExternalFile.SAParamFromFile[1].CustomCodeLinkBench[checked((int)num4)]))
                        {
                            string[] strArray2 = DaylightWithExternalFile.SAParamFromFile[1].CustomCodeLinkBench[checked((int)num4)].Split(',');
                            int num5 = 0;
                            int num8 = Information.UBound((Array)strArray2, 1);
                            int index4 = num5;
                            while (index4 <= num8)
                            {
                                if (!string.IsNullOrEmpty(strArray2[index4]))
                                    link2.Codes.Add(strArray2[index4]);
                                checked { ++index4; }
                            }
                        }
                        if (num3 == 0L | num3 == 2L)
                        {
                            double xOffset = 0.0;
                            double yOffset = 0.0;
                            this.CalcMaterialXYOffset(oLinkPointArray, materialThickness, ref xOffset, ref yOffset);
                            double dblVal1 = (oLinkPointArray[0].Offset - oLinkPointArray[1].Offset) * (oLinkPointArray[0].Elevation - oLinkPointArray[1].Elevation);
                            Point point1;
                            Point point2;
                            if (Conversions.ToBoolean(this.FuzzyEqual(dblVal1, 0.0)))
                            {
                                point1 = points.Add(oLinkPointArray[0].Offset, oLinkPointArray[0].Elevation - materialThickness, "");
                                point2 = points.Add(oLinkPointArray[1].Offset, oLinkPointArray[1].Elevation - materialThickness, "");
                            }
                            else if (dblVal1 > 0.0)
                            {
                                point1 = points.Add(oLinkPointArray[0].Offset + xOffset, oLinkPointArray[0].Elevation - yOffset, "");
                                point2 = points.Add(oLinkPointArray[1].Offset + xOffset, oLinkPointArray[1].Elevation - yOffset, "");
                            }
                            else
                            {
                                point1 = points.Add(oLinkPointArray[0].Offset - xOffset, oLinkPointArray[0].Elevation - yOffset, "");
                                point2 = points.Add(oLinkPointArray[1].Offset - xOffset, oLinkPointArray[1].Elevation - yOffset, "");
                            }
                            linkArray[0] = link2;
                            oLinkPointArray[0] = link2.Points[1];
                            oLinkPointArray[1] = point2;
                            linkArray[1] = links.Add((IPoint[])oLinkPointArray, "");
                            oLinkPointArray[0] = point2;
                            oLinkPointArray[1] = point1;
                            linkArray[2] = links.Add((IPoint[])oLinkPointArray, sLinkCodeArray[5, 0]);
                            oLinkPointArray[0] = point1;
                            oLinkPointArray[1] = link2.Points[0];
                            linkArray[3] = links.Add((IPoint[])oLinkPointArray, "");
                            shapes.Add(linkArray, str);
                            oLinkPointArray[0] = link2.Points[0];
                            oLinkPointArray[1] = link2.Points[1];
                        }
                        oLinkPointArray[0] = oLinkPointArray[1];
                        if (bDaylightHasDitchArray[index5])
                        {
                            oLinkPointArray[1].Codes.Add("Ditchtop_In_Cut");
                            oLinkPointArray[1] = points.Add(dHorzArray[index3], dVertArray[index3], "");
                            int index4 = checked(index3 + 1);
                            oLinkPointArray[1].Codes.Add("Ditch_In_Cut");
                            Link link3 = links.Add((IPoint[])oLinkPointArray, "");
                            link3.Codes.Add(sLinkCodeArray[1, 0]);
                            link3.Codes.Add(sLinkCodeArray[5, 0]);
                            if (num3 == 0L | num3 == 3L)
                            {
                                double xOffset = 0.0;
                                double yOffset = 0.0;
                                this.CalcMaterialXYOffset(oLinkPointArray, materialThickness, ref xOffset, ref yOffset);
                                Point point1 = points.Add(oLinkPointArray[0].Offset - num2 * xOffset, oLinkPointArray[0].Elevation - yOffset, "");
                                Point point2 = points.Add(oLinkPointArray[1].Offset - num2 * xOffset, oLinkPointArray[1].Elevation - yOffset, "");
                                linkArray[0] = link3;
                                oLinkPointArray[0] = link3.Points[1];
                                oLinkPointArray[1] = point2;
                                linkArray[1] = links.Add((IPoint[])oLinkPointArray, "");
                                oLinkPointArray[0] = point2;
                                oLinkPointArray[1] = point1;
                                linkArray[2] = links.Add((IPoint[])oLinkPointArray, sLinkCodeArray[5, 0]);
                                oLinkPointArray[0] = point1;
                                oLinkPointArray[1] = link3.Points[0];
                                linkArray[3] = links.Add((IPoint[])oLinkPointArray, "");
                                shapes.Add(linkArray, str);
                                oLinkPointArray[0] = link3.Points[0];
                                oLinkPointArray[1] = link3.Points[1];
                            }
                            oLinkPointArray[0] = oLinkPointArray[1];
                            oLinkPointArray[1] = points.Add(dHorzArray[index4], dVertArray[index4], "");
                            int index6 = checked(index4 + 1);
                            oLinkPointArray[1].Codes.Add("Ditch_Out_Cut");
                            Link link4 = links.Add((IPoint[])oLinkPointArray, "");
                            link4.Codes.Add(sLinkCodeArray[8, 0]);
                            link4.Codes.Add(sLinkCodeArray[1, 0]);
                            link4.Codes.Add(sLinkCodeArray[5, 0]);
                            if (num3 == 0L | num3 == 3L)
                            {
                                double xOffset = 0.0;
                                double yOffset = 0.0;
                                this.CalcMaterialXYOffset(oLinkPointArray, materialThickness, ref xOffset, ref yOffset);
                                double dblVal1 = (oLinkPointArray[0].Offset - oLinkPointArray[1].Offset) * (oLinkPointArray[0].Elevation - oLinkPointArray[1].Elevation);
                                Point point1;
                                Point point2;
                                if (Conversions.ToBoolean(this.FuzzyEqual(dblVal1, 0.0)))
                                {
                                    point1 = points.Add(oLinkPointArray[0].Offset, oLinkPointArray[0].Elevation - materialThickness, "");
                                    point2 = points.Add(oLinkPointArray[1].Offset, oLinkPointArray[1].Elevation - materialThickness, "");
                                }
                                else if (dblVal1 > 0.0)
                                {
                                    point1 = points.Add(oLinkPointArray[0].Offset + xOffset, oLinkPointArray[0].Elevation - yOffset, "");
                                    point2 = points.Add(oLinkPointArray[1].Offset + xOffset, oLinkPointArray[1].Elevation - yOffset, "");
                                }
                                else
                                {
                                    point1 = points.Add(oLinkPointArray[0].Offset - xOffset, oLinkPointArray[0].Elevation - yOffset, "");
                                    point2 = points.Add(oLinkPointArray[1].Offset - xOffset, oLinkPointArray[1].Elevation - yOffset, "");
                                }
                                linkArray[0] = link4;
                                oLinkPointArray[0] = link4.Points[1];
                                oLinkPointArray[1] = point2;
                                linkArray[1] = links.Add((IPoint[])oLinkPointArray, "");
                                oLinkPointArray[0] = point2;
                                oLinkPointArray[1] = point1;
                                linkArray[2] = links.Add((IPoint[])oLinkPointArray, sLinkCodeArray[5, 0]);
                                oLinkPointArray[0] = point1;
                                oLinkPointArray[1] = link4.Points[0];
                                linkArray[3] = links.Add((IPoint[])oLinkPointArray, "");
                                shapes.Add(linkArray, str);
                                oLinkPointArray[0] = link4.Points[0];
                                oLinkPointArray[1] = link4.Points[1];
                            }
                            oLinkPointArray[0] = oLinkPointArray[1];
                            oLinkPointArray[1] = points.Add(dHorzArray[index6], dVertArray[index6], "");
                            index3 = checked(index6 + 1);
                            oLinkPointArray[1].Codes.Add("Ditchtop_Out_Cut");
                            strArray1 = new string[1];
                            long num5 = (long)index5 <= DaylightWithExternalFile.SAParamFromFile[1].StepNum ? (long)index5 : DaylightWithExternalFile.SAParamFromFile[1].StepNum;
                            if (!string.IsNullOrEmpty(DaylightWithExternalFile.SAParamFromFile[1].CustomCodePointBenchEnd[checked((int)num5)]))
                            {
                                string[] strArray2 = DaylightWithExternalFile.SAParamFromFile[1].CustomCodePointBenchEnd[checked((int)num5)].Split(',');
                                int num8 = 0;
                                int num9 = Information.UBound((Array)strArray2, 1);
                                int index7 = num8;
                                while (index7 <= num9)
                                {
                                    if (!string.IsNullOrEmpty(strArray2[index7]))
                                        oLinkPointArray[1].Codes.Add(strArray2[index7]);
                                    checked { ++index7; }
                                }
                            }
                            if (index5 < iStepCounter)
                            {
                                strArray1 = new string[1];
                                long num8 = (long)checked(index5 + 1) <= DaylightWithExternalFile.SAParamFromFile[1].StepNum ? (long)checked(index5 + 1) : DaylightWithExternalFile.SAParamFromFile[1].StepNum;
                                if (!string.IsNullOrEmpty(DaylightWithExternalFile.SAParamFromFile[1].CustomCodePointDaylightStart[checked((int)num8)]))
                                {
                                    string[] strArray2 = DaylightWithExternalFile.SAParamFromFile[1].CustomCodePointDaylightStart[checked((int)num8)].Split(',');
                                    int num9 = 0;
                                    int num10 = Information.UBound((Array)strArray2, 1);
                                    int index7 = num9;
                                    while (index7 <= num10)
                                    {
                                        if (!string.IsNullOrEmpty(strArray2[index7]))
                                            oLinkPointArray[1].Codes.Add(strArray2[index7]);
                                        checked { ++index7; }
                                    }
                                }
                            }
                            Link link5 = links.Add((IPoint[])oLinkPointArray, "");
                            link5.Codes.Add(sLinkCodeArray[1, 0]);
                            link5.Codes.Add(sLinkCodeArray[5, 0]);
                            if (num3 == 0L | num3 == 3L)
                            {
                                double xOffset = 0.0;
                                double yOffset = 0.0;
                                this.CalcMaterialXYOffset(oLinkPointArray, materialThickness, ref xOffset, ref yOffset);
                                Point point1 = points.Add(oLinkPointArray[0].Offset + num2 * xOffset, oLinkPointArray[0].Elevation - yOffset, "");
                                Point point2 = points.Add(oLinkPointArray[1].Offset + num2 * xOffset, oLinkPointArray[1].Elevation - yOffset, "");
                                linkArray[0] = link5;
                                oLinkPointArray[0] = link5.Points[1];
                                oLinkPointArray[1] = point2;
                                linkArray[1] = links.Add((IPoint[])oLinkPointArray, "");
                                oLinkPointArray[0] = point2;
                                oLinkPointArray[1] = point1;
                                linkArray[2] = links.Add((IPoint[])oLinkPointArray, sLinkCodeArray[5, 0]);
                                oLinkPointArray[0] = point1;
                                oLinkPointArray[1] = link5.Points[0];
                                linkArray[3] = links.Add((IPoint[])oLinkPointArray, "");
                                shapes.Add(linkArray, str);
                                oLinkPointArray[0] = link5.Points[0];
                                oLinkPointArray[1] = link5.Points[1];
                            }
                            oLinkPointArray[0] = oLinkPointArray[1];
                        }
                        else
                        {
                            strArray1 = new string[1];
                            long num5 = (long)index5 <= DaylightWithExternalFile.SAParamFromFile[1].StepNum ? (long)index5 : DaylightWithExternalFile.SAParamFromFile[1].StepNum;
                            if (!string.IsNullOrEmpty(DaylightWithExternalFile.SAParamFromFile[1].CustomCodePointBenchEnd[checked((int)num5)]))
                            {
                                string[] strArray2 = DaylightWithExternalFile.SAParamFromFile[1].CustomCodePointBenchEnd[checked((int)num5)].Split(',');
                                int num8 = 0;
                                int num9 = Information.UBound((Array)strArray2, 1);
                                int index4 = num8;
                                while (index4 <= num9)
                                {
                                    if (!string.IsNullOrEmpty(strArray2[index4]))
                                        oLinkPointArray[1].Codes.Add(strArray2[index4]);
                                    checked { ++index4; }
                                }
                            }
                            if (index5 < iStepCounter)
                            {
                                strArray1 = new string[1];
                                long num8 = (long)checked(index5 + 1) <= DaylightWithExternalFile.SAParamFromFile[1].StepNum ? (long)checked(index5 + 1) : DaylightWithExternalFile.SAParamFromFile[1].StepNum;
                                if (!string.IsNullOrEmpty(DaylightWithExternalFile.SAParamFromFile[1].CustomCodePointDaylightStart[checked((int)num8)]))
                                {
                                    string[] strArray2 = DaylightWithExternalFile.SAParamFromFile[1].CustomCodePointDaylightStart[checked((int)num8)].Split(',');
                                    int num9 = 0;
                                    int num10 = Information.UBound((Array)strArray2, 1);
                                    int index4 = num9;
                                    while (index4 <= num10)
                                    {
                                        if (!string.IsNullOrEmpty(strArray2[index4]))
                                            oLinkPointArray[1].Codes.Add(strArray2[index4]);
                                        checked { ++index4; }
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        if (bDaylightHasDitchArray[index5])
                        {
                            oLinkPointArray[1].Codes.Add("Ditchtop_In_Fill");
                            oLinkPointArray[1] = points.Add(dHorzArray[index3], dVertArray[index3], "");
                            int index4 = checked(index3 + 1);
                            oLinkPointArray[1].Codes.Add("Ditch_In_Fill");
                            Link link2 = links.Add((IPoint[])oLinkPointArray, "");
                            link2.Codes.Add(sLinkCodeArray[1, 0]);
                            link2.Codes.Add(sLinkCodeArray[5, 0]);
                            if (num3 == 0L | num3 == 3L)
                            {
                                double xOffset = 0.0;
                                double yOffset = 0.0;
                                this.CalcMaterialXYOffset(oLinkPointArray, materialThickness, ref xOffset, ref yOffset);
                                Point point1 = points.Add(oLinkPointArray[0].Offset - num2 * xOffset, oLinkPointArray[0].Elevation - yOffset, "");
                                Point point2 = points.Add(oLinkPointArray[1].Offset - num2 * xOffset, oLinkPointArray[1].Elevation - yOffset, "");
                                linkArray[0] = link2;
                                oLinkPointArray[0] = link2.Points[1];
                                oLinkPointArray[1] = point2;
                                linkArray[1] = links.Add((IPoint[])oLinkPointArray, "");
                                oLinkPointArray[0] = point2;
                                oLinkPointArray[1] = point1;
                                linkArray[2] = links.Add((IPoint[])oLinkPointArray, sLinkCodeArray[5, 0]);
                                oLinkPointArray[0] = point1;
                                oLinkPointArray[1] = link2.Points[0];
                                linkArray[3] = links.Add((IPoint[])oLinkPointArray, "");
                                shapes.Add(linkArray, str);
                                oLinkPointArray[0] = link2.Points[0];
                                oLinkPointArray[1] = link2.Points[1];
                            }
                            oLinkPointArray[0] = oLinkPointArray[1];
                            oLinkPointArray[1] = points.Add(dHorzArray[index4], dVertArray[index4], "");
                            int index6 = checked(index4 + 1);
                            oLinkPointArray[1].Codes.Add("Ditch_Out_Fill");
                            Link link3 = links.Add((IPoint[])oLinkPointArray, "");
                            link3.Codes.Add(sLinkCodeArray[8, 0]);
                            link3.Codes.Add(sLinkCodeArray[1, 0]);
                            link3.Codes.Add(sLinkCodeArray[5, 0]);
                            if (num3 == 0L | num3 == 3L)
                            {
                                double xOffset = 0.0;
                                double yOffset = 0.0;
                                this.CalcMaterialXYOffset(oLinkPointArray, materialThickness, ref xOffset, ref yOffset);
                                double dblVal1 = (oLinkPointArray[0].Offset - oLinkPointArray[1].Offset) * (oLinkPointArray[0].Elevation - oLinkPointArray[1].Elevation);
                                Point point1;
                                Point point2;
                                if (Conversions.ToBoolean(this.FuzzyEqual(dblVal1, 0.0)))
                                {
                                    point1 = points.Add(oLinkPointArray[0].Offset, oLinkPointArray[0].Elevation - materialThickness, "");
                                    point2 = points.Add(oLinkPointArray[1].Offset, oLinkPointArray[1].Elevation - materialThickness, "");
                                }
                                else if (dblVal1 > 0.0)
                                {
                                    point1 = points.Add(oLinkPointArray[0].Offset + xOffset, oLinkPointArray[0].Elevation - yOffset, "");
                                    point2 = points.Add(oLinkPointArray[1].Offset + xOffset, oLinkPointArray[1].Elevation - yOffset, "");
                                }
                                else
                                {
                                    point1 = points.Add(oLinkPointArray[0].Offset - xOffset, oLinkPointArray[0].Elevation - yOffset, "");
                                    point2 = points.Add(oLinkPointArray[1].Offset - xOffset, oLinkPointArray[1].Elevation - yOffset, "");
                                }
                                linkArray[0] = link3;
                                oLinkPointArray[0] = link3.Points[1];
                                oLinkPointArray[1] = point2;
                                linkArray[1] = links.Add((IPoint[])oLinkPointArray, "");
                                oLinkPointArray[0] = point2;
                                oLinkPointArray[1] = point1;
                                linkArray[2] = links.Add((IPoint[])oLinkPointArray, sLinkCodeArray[5, 0]);
                                oLinkPointArray[0] = point1;
                                oLinkPointArray[1] = link3.Points[0];
                                linkArray[3] = links.Add((IPoint[])oLinkPointArray, "");
                                shapes.Add(linkArray, str);
                                oLinkPointArray[0] = link3.Points[0];
                                oLinkPointArray[1] = link3.Points[1];
                            }
                            oLinkPointArray[0] = oLinkPointArray[1];
                            oLinkPointArray[1] = points.Add(dHorzArray[index6], dVertArray[index6], "");
                            index3 = checked(index6 + 1);
                            Link link4 = links.Add((IPoint[])oLinkPointArray, "");
                            link4.Codes.Add(sLinkCodeArray[1, 0]);
                            link4.Codes.Add(sLinkCodeArray[5, 0]);
                            if (num3 == 0L | num3 == 3L)
                            {
                                double xOffset = 0.0;
                                double yOffset = 0.0;
                                this.CalcMaterialXYOffset(oLinkPointArray, materialThickness, ref xOffset, ref yOffset);
                                Point point1 = points.Add(oLinkPointArray[0].Offset + num2 * xOffset, oLinkPointArray[0].Elevation - yOffset, "");
                                Point point2 = points.Add(oLinkPointArray[1].Offset + num2 * xOffset, oLinkPointArray[1].Elevation - yOffset, "");
                                linkArray[0] = link4;
                                oLinkPointArray[0] = link4.Points[1];
                                oLinkPointArray[1] = point2;
                                linkArray[1] = links.Add((IPoint[])oLinkPointArray, "");
                                oLinkPointArray[0] = point2;
                                oLinkPointArray[1] = point1;
                                linkArray[2] = links.Add((IPoint[])oLinkPointArray, sLinkCodeArray[5, 0]);
                                oLinkPointArray[0] = point1;
                                oLinkPointArray[1] = link4.Points[0];
                                linkArray[3] = links.Add((IPoint[])oLinkPointArray, "");
                                shapes.Add(linkArray, str);
                                oLinkPointArray[0] = link4.Points[0];
                                oLinkPointArray[1] = link4.Points[1];
                            }
                            oLinkPointArray[0] = oLinkPointArray[1];
                        }
                        oLinkPointArray[1].Codes.Add(sPointCodeArray[5, 0]);
                        oLinkPointArray[1].Codes.Add("Ditchtop_Out_Fill");
                        oLinkPointArray[1] = points.Add(dHorzArray[index3], dVertArray[index3], "");
                        checked { ++index3; }
                        oLinkPointArray[1].Codes.Add(sPointCodeArray[6, 0]);
                        strArray1 = new string[1];
                        long num4 = (long)index5 <= DaylightWithExternalFile.SAParamFromFile[2].StepNum ? (long)index5 : DaylightWithExternalFile.SAParamFromFile[2].StepNum;
                        if (!string.IsNullOrEmpty(DaylightWithExternalFile.SAParamFromFile[2].CustomCodePointBenchEnd[checked((int)num4)]))
                        {
                            string[] strArray2 = DaylightWithExternalFile.SAParamFromFile[2].CustomCodePointBenchEnd[checked((int)num4)].Split(',');
                            int num5 = 0;
                            int num8 = Information.UBound((Array)strArray2, 1);
                            int index4 = num5;
                            while (index4 <= num8)
                            {
                                if (!string.IsNullOrEmpty(strArray2[index4]))
                                    oLinkPointArray[1].Codes.Add(strArray2[index4]);
                                checked { ++index4; }
                            }
                        }
                        if (index5 < iStepCounter)
                        {
                            strArray1 = new string[1];
                            long num5 = (long)checked(index5 + 1) <= DaylightWithExternalFile.SAParamFromFile[2].StepNum ? (long)checked(index5 + 1) : DaylightWithExternalFile.SAParamFromFile[2].StepNum;
                            if (!string.IsNullOrEmpty(DaylightWithExternalFile.SAParamFromFile[2].CustomCodePointDaylightStart[checked((int)num5)]))
                            {
                                string[] strArray2 = DaylightWithExternalFile.SAParamFromFile[2].CustomCodePointDaylightStart[checked((int)num5)].Split(',');
                                int num8 = 0;
                                int num9 = Information.UBound((Array)strArray2, 1);
                                int index4 = num8;
                                while (index4 <= num9)
                                {
                                    if (!string.IsNullOrEmpty(strArray2[index4]))
                                        oLinkPointArray[1].Codes.Add(strArray2[index4]);
                                    checked { ++index4; }
                                }
                            }
                        }
                        Link link5 = links.Add((IPoint[])oLinkPointArray, "");
                        link5.Codes.Add(sLinkCodeArray[7, 0]);
                        link5.Codes.Add(sLinkCodeArray[1, 0]);
                        link5.Codes.Add(sLinkCodeArray[5, 0]);
                        strArray1 = new string[1];
                        long num10 = (long)index5 <= DaylightWithExternalFile.SAParamFromFile[2].StepNum ? (long)index5 : DaylightWithExternalFile.SAParamFromFile[2].StepNum;
                        if (!string.IsNullOrEmpty(DaylightWithExternalFile.SAParamFromFile[2].CustomCodeLinkBench[checked((int)num10)]))
                        {
                            string[] strArray2 = DaylightWithExternalFile.SAParamFromFile[2].CustomCodeLinkBench[checked((int)num10)].Split(',');
                            int num5 = 0;
                            int num8 = Information.UBound((Array)strArray2, 1);
                            int index4 = num5;
                            while (index4 <= num8)
                            {
                                if (!string.IsNullOrEmpty(strArray2[index4]))
                                    link5.Codes.Add(strArray2[index4]);
                                checked { ++index4; }
                            }
                        }
                        if (num3 == 0L | num3 == 2L)
                        {
                            double xOffset = 0.0;
                            double yOffset = 0.0;
                            this.CalcMaterialXYOffset(oLinkPointArray, materialThickness, ref xOffset, ref yOffset);
                            double dblVal1 = (oLinkPointArray[0].Offset - oLinkPointArray[1].Offset) * (oLinkPointArray[0].Elevation - oLinkPointArray[1].Elevation);
                            Point point1;
                            Point point2;
                            if (Conversions.ToBoolean(this.FuzzyEqual(dblVal1, 0.0)))
                            {
                                point1 = points.Add(oLinkPointArray[0].Offset, oLinkPointArray[0].Elevation - materialThickness, "");
                                point2 = points.Add(oLinkPointArray[1].Offset, oLinkPointArray[1].Elevation - materialThickness, "");
                            }
                            else if (dblVal1 > 0.0)
                            {
                                point1 = points.Add(oLinkPointArray[0].Offset + xOffset, oLinkPointArray[0].Elevation - yOffset, "");
                                point2 = points.Add(oLinkPointArray[1].Offset + xOffset, oLinkPointArray[1].Elevation - yOffset, "");
                            }
                            else
                            {
                                point1 = points.Add(oLinkPointArray[0].Offset - xOffset, oLinkPointArray[0].Elevation - yOffset, "");
                                point2 = points.Add(oLinkPointArray[1].Offset - xOffset, oLinkPointArray[1].Elevation - yOffset, "");
                            }
                            linkArray[0] = link5;
                            oLinkPointArray[0] = link5.Points[1];
                            oLinkPointArray[1] = point2;
                            linkArray[1] = links.Add((IPoint[])oLinkPointArray, "");
                            oLinkPointArray[0] = point2;
                            oLinkPointArray[1] = point1;
                            linkArray[2] = links.Add((IPoint[])oLinkPointArray, sLinkCodeArray[5, 0]);
                            oLinkPointArray[0] = point1;
                            oLinkPointArray[1] = link5.Points[0];
                            linkArray[3] = links.Add((IPoint[])oLinkPointArray, "");
                            shapes.Add(linkArray, str);
                            oLinkPointArray[0] = link5.Points[0];
                            oLinkPointArray[1] = link5.Points[1];
                        }
                        oLinkPointArray[0] = oLinkPointArray[1];
                    }
                }
                oLinkPointArray[0] = oLinkPointArray[1];
                checked { ++index5; }
            }
        }

        private void FillCodesFromTable(string[,] sPointCodeArray, string[,] sLinkCodeArray)
        {
            sPointCodeArray[1, 0] = CodesSpecific.Codes.HingeCut.Code;
            sPointCodeArray[1, 1] = CodesSpecific.Codes.Hinge.Code;
            sPointCodeArray[2, 0] = CodesSpecific.Codes.BenchIn.Code;
            sPointCodeArray[3, 0] = CodesSpecific.Codes.BenchOut.Code;
            sPointCodeArray[4, 0] = CodesSpecific.Codes.HingeFill.Code;
            sPointCodeArray[4, 1] = CodesSpecific.Codes.Hinge.Code;
            sPointCodeArray[5, 0] = CodesSpecific.Codes.BenchIn.Code;
            sPointCodeArray[6, 0] = CodesSpecific.Codes.BenchOut.Code;
            sPointCodeArray[7, 0] = CodesSpecific.Codes.Daylight.Code;
            sPointCodeArray[7, 1] = CodesSpecific.Codes.DaylightCut.Code;
            sPointCodeArray[8, 0] = CodesSpecific.Codes.Daylight.Code;
            sPointCodeArray[8, 1] = CodesSpecific.Codes.DaylightFill.Code;
            sPointCodeArray[9, 0] = "Before_Rounding";
            sPointCodeArray[10, 0] = CodesSpecific.Codes.DitchIn.Code;
            sPointCodeArray[11, 0] = CodesSpecific.Codes.DitchOut.Code;
            sLinkCodeArray[1, 0] = CodesSpecific.Codes.Top.Code;
            sLinkCodeArray[2, 0] = CodesSpecific.Codes.Daylight.Code;
            sLinkCodeArray[2, 1] = CodesSpecific.Codes.DaylightCut.Code;
            sLinkCodeArray[3, 0] = CodesSpecific.Codes.Daylight.Code;
            sLinkCodeArray[3, 1] = CodesSpecific.Codes.DaylightFill.Code;
            sLinkCodeArray[4, 0] = CodesSpecific.Codes.Daylight.Code;
            sLinkCodeArray[5, 0] = CodesSpecific.Codes.Datum.Code;
            sLinkCodeArray[6, 0] = CodesSpecific.Codes.Slope_Link.Code;
            sLinkCodeArray[7, 0] = CodesSpecific.Codes.Bench.Code;
            sLinkCodeArray[8, 0] = CodesSpecific.Codes.Ditch.Code;
        }

        [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
        private bool ReadParamsFromFile(string filePath, CorridorState corridorState)
        {
            Application.DocumentManager.CurrentDocument.Editor.WriteMessage("\n读取文件一次");
            bool flag = false;
            if (Strings.Len(FileSystem.Dir(filePath, FileAttribute.Normal)) != 0
                & Operators.CompareString(Path.GetExtension(filePath), ".txt", false) == 0)
            {
                int errorLine = 1;
                int errorParam = 1;
                SATxtConfigFileParser configFileParser = new SATxtConfigFileParser(filePath, Encoding.Default);
                configFileParser.SetDelimiters(" ");
                if (configFileParser.Parse(ref SAParamFromFile
                    , ref corridorState, ref errorLine, ref errorParam))
                {
                    flag = true;
                    SAParamFromFile[1].ConfigFileName = filePath;
                    SAParamFromFile[1].ConfigFileLastWriteTimeUtc = File.GetLastWriteTimeUtc(filePath);
                    SAParamFromFile[2].ConfigFileName = filePath;
                    SAParamFromFile[2].ConfigFileLastWriteTimeUtc = File.GetLastWriteTimeUtc(filePath);
                }
                else
                    Utilities.RecordError(corridorState, (CorridorError)0, string.Format(Resources.CUT_FILL_PARAM_ERROR, errorParam, errorLine), "DaylightWithExternalFile");
            }
            else if (Operators.CompareString(Path.GetExtension(filePath), ".txt", false) != 0)
                Utilities.RecordError(corridorState, (CorridorError)0, Resources.CONFIG_FILE_TYPE_ERROR, "DaylightWithExternalFile");
            else if (Strings.Len(FileSystem.Dir(filePath, FileAttribute.Normal)) == 0)
                Utilities.RecordError(corridorState, (CorridorError)0, Resources.CONFIG_FILE_NOT_FOUND, "DaylightWithExternalFile");
            return flag;
        }

        private object LineIntersect(PointInMem point1, PointInMem point2, PointInMem point3, double k, ref PointInMem intersectionPoint)
        {
            object obj = false;
            if (Conversions.ToBoolean(Operators.NotObject(this.FuzzyEqual(point1.Offset, point2.Offset))))
            {
                double num1 = (point1.Elevation - point2.Elevation) / (point1.Offset - point2.Offset);
                double num2 = (point1.Offset * point2.Elevation - point1.Elevation * point2.Offset) / (point1.Offset - point2.Offset);
                if (Conversions.ToBoolean(this.FuzzyEqual(k, 9999.0)))
                {
                    intersectionPoint.Offset = (point3.Offset);
                    intersectionPoint.Elevation = (num1 * intersectionPoint.Offset + num2);
                    obj = true;
                }
                else
                {
                    double num3 = k;
                    double num4 = point3.Elevation - num3 * point3.Offset;
                    if (num1 == num3)
                    {
                        obj = false;
                    }
                    else
                    {
                        intersectionPoint.Offset = ((num4 - num2) / (num1 - num3));
                        intersectionPoint.Elevation = (num1 * intersectionPoint.Offset + num2);
                        obj = true;
                    }
                }
            }
            return obj;
        }

        private object FuzzyEqual(double dblVal1, double dblVal2)
        {
            object obj = false;
            double num = 1E-06;
            if (Math.Abs(dblVal1 - dblVal2) < num)
                obj = true;
            return obj;
        }

        private object FuzzyEqualGreaterThan(double dblVal1, double dblVal2)
        {
            object obj = false;
            double num = 1E-06;
            if (Conversions.ToBoolean(Operators.OrObject((dblVal1 - dblVal2 > num ? 1 : 0), this.FuzzyEqual(dblVal1, dblVal2))))
                obj = true;
            return obj;
        }

        private object FuzzyEqualLessThan(double dblVal1, double dblVal2)
        {
            object obj = false;
            double num = 1E-06;
            if (Conversions.ToBoolean(Operators.OrObject((dblVal2 - dblVal1 > num ? 1 : 0), this.FuzzyEqual(dblVal1, dblVal2))))
                obj = true;
            return obj;
        }

        private void CalcMaterialXYOffset(Point[] oLinkPointArray, double materialThickness, ref double xOffset, ref double yOffset)
        {
            xOffset = 0.0;
            yOffset = 0.0;
            if (Conversions.ToBoolean(this.FuzzyEqual(oLinkPointArray[0].Offset, oLinkPointArray[1].Offset)))
            {
                xOffset = materialThickness;
                yOffset = 0.0;
            }
            else
            {
                double num1 = Math.Abs(oLinkPointArray[1].Offset - oLinkPointArray[0].Offset);
                double num2 = Math.Abs(oLinkPointArray[1].Elevation - oLinkPointArray[0].Elevation);
                double num3 = Math.Sqrt(num1 * num1 + num2 * num2);
                xOffset = materialThickness * (num2 / num3);
                yOffset = materialThickness * (num1 / num3);
            }
        }

        public struct SAParamsFromFileStructure
        {
            public string ConfigFileName;
            public DateTime ConfigFileLastWriteTimeUtc;
            public bool IsCut;
            public bool isInfinity;
            public long StepNum;
            public double MinCutFillHeight;
            public bool IsActualDaylightUseFixedSlope;
            public double ActualDaylightFixedSlope;
            public double[] MaxCutOrFillHeight;
            public double[] CutOrFillSlope;
            public double[] BenchWidth;
            public double[] BenchSlope;
            public bool[] DitchExistence;
            public double[] DitchInnerHeight;
            public double[] DitchInnerSlope;
            public double[] DitchBottomWidth;
            public double[] DitchBottomSlope;
            public double[] DitchOuterSlope;
            public string[] CustomCodePointDaylightStart;
            public string[] CustomCodePointDaylightEnd;
            public string[] CustomCodePointBenchEnd;
            public string[] CustomCodeLinkDaylight;
            public string[] CustomCodeLinkBench;
        }

        public enum PlacedMaterialType : long
        {
            AllLinks,
            DaylightLinks,
            BenchLinks,
            DitchLinks,
            None,
        }
    }
}

 

posted @ 2022-04-04 09:10  david96007  阅读(1140)  评论(0编辑  收藏  举报