Пример #1
0
        private void AddchsCSS(KarambaIDEA.Core.CrossSection crossSection)
        {
            CrossSectionParameter chs = new CrossSectionParameter();

            chs.Id = crossSection.id;
            MatSteel material = openModel.MatSteel.First(a => a.Id == crossSection.material.id);

            chs.Material = new ReferenceElement(material);
            chs.Name     = crossSection.name;
            double height  = crossSection.height / 1000 / 2; //adjust to radius
            double width   = crossSection.width / 1000;
            double tweb    = crossSection.thicknessWeb / 1000;
            double tflange = crossSection.thicknessFlange / 1000;
            double radius  = crossSection.radius / 1000;

            //CrossSectionFactory.FillCssRectangleHollow(hollow, width, height, tweb, tweb, tflange, tflange);
            CrossSectionFactory.FillOHollow(chs, height, tweb);
            //height
            //width
            //thickness
            //innerradius
            //outerradius
            //unkown
            //CrossSectionFactory.FillCssSteelChannel(hollow, height, width, tweb, tflange, radius, radius, 0);

            openModel.AddObject(chs);
        }
Пример #2
0
    public void Open()
    {
      Connection c = Connection.Create(@"..\..\..\testdata\mike11\novomr6.xns11");

      CrossSectionDataFactory cd = new CrossSectionDataFactory();

      var xsecs = cd.Open(@"..\..\..\testdata\mike11\novomr6.xns11", null);
      

      CrossSectionFactory cf = new CrossSectionFactory();
      var v= new CrossSectionPointList();
      v.Add(new CrossSectionPoint(0,5));
      v.Add(new CrossSectionPoint(1,2));
      v.Add(new CrossSectionPoint(2,2));
      v.Add(new CrossSectionPoint(3,5));

      cf.BuildOpen("tempo");
      cf.SetRawPoints(v);
      
      var cs = cf.GetCrossSection();

      CrossSectionData d = new CrossSectionData();
      d.Add(cs);
      d.Connection = Connection.Create(@"c:\temp\new.xns11");
      


      
     
      CrossSectionFactory cdd = new CrossSectionFactory();
     
     
    }
Пример #3
0
        public void Open()
        {
            Connection c = Connection.Create(@"..\..\..\testdata\mike11\novomr6.xns11");

            CrossSectionDataFactory cd = new CrossSectionDataFactory();

            var xsecs = cd.Open(@"..\..\..\testdata\mike11\novomr6.xns11", null);


            CrossSectionFactory cf = new CrossSectionFactory();
            var v = new CrossSectionPointList();

            v.Add(new CrossSectionPoint(0, 5));
            v.Add(new CrossSectionPoint(1, 2));
            v.Add(new CrossSectionPoint(2, 2));
            v.Add(new CrossSectionPoint(3, 5));

            cf.BuildOpen("tempo");
            cf.SetRawPoints(v);

            var cs = cf.GetCrossSection();

            CrossSectionData d = new CrossSectionData();

            d.Add(cs);
            d.Connection = Connection.Create(@"c:\temp\new.xns11");



            CrossSectionFactory cdd = new CrossSectionFactory();
        }
Пример #4
0
        private void AddWeldedI()
        {
            //Example of custom I section
            CrossSectionParameter cssWI = new CrossSectionParameter();

            cssWI.Material = new ReferenceElement(openStructModel.MatSteel.First());              // I have only one material, I take the first one
            cssWI.Name     = "I 400, welded";
            CrossSectionFactory.FillWeldedI(cssWI, 0.2, 0.4, 0.025, 0.020);
            openStructModel.AddObject(cssWI);
        }
Пример #5
0
        private void FillWeldedT()
        {
            CrossSectionParameter css = new CrossSectionParameter();

            css.Id       = 2;
            css.Material = new ReferenceElement(openStructModel.MatSteel.First());
            double b  = 0.2;
            double h  = 0.4;
            double tw = 0.02;
            double tf = 0.35;

            CrossSectionFactory.FillWeldedT(css, b, h, tw, tf);
            openStructModel.AddObject(css);
        }
Пример #6
0
        private void FillWeldedI()
        {
            CrossSectionParameter css = new CrossSectionParameter();

            css.Id       = 1;
            css.Material = new ReferenceElement(openStructModel.MatSteel.First());              // I have only one material, I take the first one
            double bu = 0.2;
            double hw = 0.4;
            double tw = 0.025;
            double tf = 0.02;

            CrossSectionFactory.FillWeldedI(css, bu, hw, tw, tf);
            openStructModel.AddObject(css);
        }
        /// <summary>
        /// Create a new circular cross section and add it to the CrossSectionData object
        /// </summary>
        /// <param name="csData">Cross section data object</param>
        public static void CreateAndAddCircularCrossSection(CrossSectionData csData)
        {
            // Creates a class representing a cross section with raw data attached.
            CrossSectionFactory builder = new CrossSectionFactory();

            builder.BuildCircular(2);

            // Defines the location of the current cross section. The Z-coordinate
            // is the bottom level of the cross section (unless defined by the
            // raw data (the open cross sections)).
            builder.SetLocation(new ZLocation("pipe A", 10)
            {
                Z = 0
            });

            // Set flow resistance
            FlowResistance flowResistance = new FlowResistance();

            flowResistance.ResistanceDistribution = ResistanceDistribution.ExponentVarying;
            flowResistance.ResistanceValue        = 75;
            flowResistance.ResistanceTopValue     = 85;
            flowResistance.ExpDepExponent         = 1.5;
            flowResistance.Formulation            = ResistanceFormulation.Manning_M;
            builder.SetFlowResistance(flowResistance);

            // Get cross section from builder
            CrossSectionLocated cs = builder.GetCrossSection();

            cs.TopoID = "1";

            // Calculates the processed levels, storage areas, radii, etc, ie, fill in all
            // ProcessedXXX properties.
            cs.BaseCrossSection.CalculateProcessedData();

            // Validates the data. The constraints are that the levels and the areas after sorting
            // must be monotonically increasing.
            IDiagnostics diagnostics = cs.Validate();

            if (diagnostics.ErrorCountRecursive > 0)
            {
                throw new Exception(String.Format("Number of errors: {0}", diagnostics.Errors.Count));
            }

            // Add the cross section
            csData.Add(cs);
        }
Пример #8
0
        private void FillCssIarc()
        {
            CrossSectionParameter css = new CrossSectionParameter();

            css.Id       = 8;
            css.Material = new ReferenceElement(openStructModel.MatSteel.First());
            double cssGeomB  = 0.25;
            double cssGeomH  = 0.45;
            double cssGeomS  = 0.02;
            double cssGeomT  = 0.03;
            double cssGeomR2 = 0.012;
            double tapperF   = Math.PI / 180.0 * 5.0;
            double r1        = 0.015;

            CrossSectionFactory.FillCssIarc(css, cssGeomB, cssGeomH, cssGeomS, cssGeomT, cssGeomR2, tapperF, r1);
            openStructModel.AddObject(css);
        }
Пример #9
0
        private void FillWeldedLMirrored()
        {
            CrossSectionParameter css = new CrossSectionParameter();

            css.Id       = 5;
            css.Material = new ReferenceElement(openStructModel.MatSteel.First());
            double B       = 0.2;
            double D       = 0.4;
            double t       = 0.025;
            double rw      = 0.004;
            double r2      = 0.002;
            double C       = 0.0;
            bool   mirrorZ = true;

            CrossSectionFactory.FillCssSteelAngle(css, B, D, t, rw, r2, C, mirrorZ);
            openStructModel.AddObject(css);
        }
Пример #10
0
        private void FillWeldedU()
        {
            CrossSectionParameter css = new CrossSectionParameter();

            css.Id       = 3;
            css.Material = new ReferenceElement(openStructModel.MatSteel.First());
            double b      = 0.2;
            double hw     = 0.4;
            double tw     = 0.025;
            double tf     = 0.02;
            double rw     = 0.004;
            double rf     = 0.002;
            double taperF = 0.001;

            CrossSectionFactory.FillWeldedU(css, b, hw, tw, tf, rw, rf, taperF);
            openStructModel.AddObject(css);
        }
Пример #11
0
        private void FillCssTarc()
        {
            CrossSectionParameter css = new CrossSectionParameter();

            css.Id       = 9;
            css.Material = new ReferenceElement(openStructModel.MatSteel.First());
            double cssGeomB  = 0.25;
            double cssGeomH  = 0.45;
            double cssGeomTw = 0.02;
            double cssGeomTf = 0.03;
            double cssGeomR  = 0.0012;
            double cssGeomR1 = 0.0010;
            double cssGeomR2 = 0.008;
            double tapperF   = Math.PI / 180.0 * 5.0;
            double tapperW   = Math.PI / 180.0 * 7.0;

            CrossSectionFactory.FillCssTarc(css, cssGeomB, cssGeomH, cssGeomTw, cssGeomTf, cssGeomR, cssGeomR1, cssGeomR2, tapperF, tapperW);
            openStructModel.AddObject(css);
        }
Пример #12
0
        /// <summary>
        /// Adds a new cross section to the CrossSectionData object
        /// </summary>
        /// <param name="csData">Cross section data object</param>
        public static void AddCrossSection(CrossSectionData csData)
        {
            // Note: Raw data must be ordered from left to right in order for hydraulic radius to be processed correctly

            // Creates a class representing a cross section with raw data attached.
            CrossSectionFactory builder = new CrossSectionFactory();

            builder.BuildOpen("");

            // Defines the location of the current cross section. The Z-coordinate
            // is the bottom level of the cross section (unless defined by the
            // raw data (the open cross sections)).
            builder.SetLocation(new ZLocation("river B", 500)
            {
                Z = 0
            });

            // Create a number of points
            CrossSectionPointList points = new CrossSectionPointList();

            points.Add(new CrossSectionPoint(-1.0, 2.0));
            points.Add(new CrossSectionPoint(0.0, 1.0));
            points.Add(new CrossSectionPoint(0.0, 0.0));
            points.Add(new CrossSectionPoint(1.0, 0.0));
            points.Add(new CrossSectionPoint(1.0, 1.0));
            points.Add(new CrossSectionPoint(2.0, 2.0));
            points.Add(new CrossSectionPoint(3.0, 2.0)); // dummy point, outside right levee bank marker
            // Sets the markers at left/right side and lowest point.
            builder.SetRawPoints(points);
            builder.SetLeftLeveeBank(points[0]);
            builder.SetLowestPoint(points[3]);
            builder.SetRightLeveeBank(points[5]);

            // Set flow resistance
            FlowResistance flowResistance = new FlowResistance();

            flowResistance.ResistanceDistribution = ResistanceDistribution.Uniform;
            flowResistance.ResistanceValue        = 1;
            flowResistance.Formulation            = ResistanceFormulation.Relative;
            builder.SetFlowResistance(flowResistance);
            builder.SetRadiusType(RadiusType.ResistanceRadius);

            // Get cross section from builder
            CrossSectionLocated cs = builder.GetCrossSection();

            cs.TopoID = "1";

            // Calculates the processed levels, storage areas, radii, etc, ie, fill in all
            // ProcessedXXX properties.
            cs.BaseCrossSection.CalculateProcessedData();

            // Validates the data. The constraints are that the levels and the areas after sorting
            // must be monotonically increasing.
            IDiagnostics diagnostics = cs.Validate();

            if (diagnostics.ErrorCountRecursive > 0)
            {
                throw new Exception(String.Format("Number of errors: {0}", diagnostics.Errors.Count));
            }

            // Add the cross section
            csData.Add(cs);
        }
        /// <summary>
        /// Import from text file to xns11 file
        /// </summary>
        /// <param name="txtFileName">Path and name of text file to import</param>
        /// <param name="xns11FileName">Path and name of xns11 file to create or update</param>
        /// <param name="xns11NewFileName">Path and name of xns11 file to write to</param>
        public static void Import(string txtFileName, string xns11FileName, string xns11NewFileName = null)
        {
            StreamReader reader = new StreamReader(txtFileName);

            CrossSectionDataFactory crossSectionDataFactory = new CrossSectionDataFactory();
            CrossSectionData        csData;

            if (File.Exists(xns11FileName))
            {
                csData = crossSectionDataFactory.Open(Connection.Create(xns11FileName), null);
            }
            else
            {
                csData = new CrossSectionData();
            }
            if (string.IsNullOrEmpty(xns11NewFileName))
            {
                xns11NewFileName = xns11FileName;
            }

            string line;

            // Read cross section info-line
            while ((line = reader.ReadLine()) != null)
            {
                // Split cross section info-line
                string[] split = line.SplitQuoted(',', '"');

                // extract info from info-line
                Location location     = new Location(split[1], double.Parse(split[2], CultureInfo.InvariantCulture));
                string   topoId       = split[3];
                double   datum        = double.Parse(split[4], CultureInfo.InvariantCulture);
                int      numRawPoints = int.Parse(split[5]);

                // Check if this cross section is to be processed
                if (split[0] == "1")
                {
                    ICrossSection cs = csData.FindCrossSection(location, topoId);

                    CrossSectionPointList points = new CrossSectionPointList();

                    // Read raw points
                    for (int i = 0; i < numRawPoints; i++)
                    {
                        line = reader.ReadLine();
                        if (line == null) // end-of-file
                        {
                            throw new EndOfStreamException("File ended prematurely");
                        }

                        string[] coords = line.Split(',');

                        double x = double.Parse(coords[0], CultureInfo.InvariantCulture);
                        double z = double.Parse(coords[1], CultureInfo.InvariantCulture);
                        points.Add(new CrossSectionPoint(x, z));
                    }

                    // Check if cross section already exists
                    if (cs != null)
                    {
                        // Check if it is a cross section with raw points
                        XSBaseRaw xsBaseRaw = cs.BaseCrossSection as XSBaseRaw;
                        if (xsBaseRaw == null)
                        {
                            throw new Exception("Cannot modify raw points of a cross section without raw points: " + location.ToString() + ", " + topoId);
                        }

                        // replace datum (in case datum changes)
                        cs.Location.Z = datum;
                        // Replace points
                        xsBaseRaw.Points = points;
                        // Set default markers
                        xsBaseRaw.UpdateMarkersToDefaults(true, true, true);
                        // Recalculate processed data
                        xsBaseRaw.ProcessingLevelsSpecs.NoOfLevels = 50;
                        xsBaseRaw.CalculateProcessedData();
                    }
                    else
                    {
                        // Create a new cross section
                        CrossSectionFactory builder = new CrossSectionFactory();
                        builder.BuildOpen("");

                        // Defines the location of the current cross section. The Z-coordinate
                        // for an open cross section with raw data is a Z-offset, and usually zero.
                        builder.SetLocation(new ZLocation(location.ID, location.Chainage)
                        {
                            Z = datum
                        });

                        // Set raw points and default markers
                        builder.SetRawPoints(points);
                        builder.SetDefaultMarkers();

                        // Define resistance properties as relative
                        FlowResistance flowResistance = new FlowResistance();
                        flowResistance.Formulation            = ResistanceFormulation.Relative;
                        flowResistance.ResistanceDistribution = ResistanceDistribution.Uniform;
                        flowResistance.ResistanceValue        = 1;
                        builder.SetFlowResistance(flowResistance);
                        builder.SetRadiusType(RadiusType.ResistanceRadius);

                        // Get the cross section
                        CrossSectionLocated csLocated = builder.GetCrossSection();
                        // Set topo-id
                        csLocated.TopoID = topoId;

                        // now, calculate processed data
                        csLocated.BaseCrossSection.ProcessingLevelsSpecs.Option     = ProcessingOption.AutomaticLevels;
                        csLocated.BaseCrossSection.ProcessingLevelsSpecs.NoOfLevels = 0;
                        csLocated.BaseCrossSection.CalculateProcessedData();

                        // Store cross section in database
                        csData.Add(csLocated);
                    }
                }
                else // this cross section should not be processed
                {
                    // Skip line containing raw points
                    for (int i = 0; i < numRawPoints; i++)
                    {
                        line = reader.ReadLine();
                        if (line == null) // end-of-file
                        {
                            throw new EndOfStreamException("File ended prematurely");
                        }
                    }
                }
            }
            csData.Connection = Connection.Create(xns11NewFileName);
            CrossSectionDataFactory.Save(csData);
        }