public void SetZValueCausesPropertyChangedForXYZCrossSection() { IChannel channel = new Channel { Geometry = new LineString(new[] { new Coordinate(0, 0), new Coordinate(20, 0) }) }; var crossSection = new CrossSection { Branch = channel }; NetworkHelper.AddBranchFeatureToBranch(channel, crossSection, 10.0); var yzCoordinates = new List<ICoordinate> { new Coordinate(0.0, 0.0), new Coordinate(100.0, 0.0), }; crossSection.Geometry = CrossSectionHelper.CreateCrossSectionGeometryForXyzCrossSectionFromYZ(channel.Geometry, crossSection.Offset, yzCoordinates); int callCount = 0; ((INotifyPropertyChanged)(crossSection)).PropertyChanged += (s, e) => { callCount++; Assert.AreEqual("Geometry", e.PropertyName); }; crossSection.SetZValue(0, 100); Assert.AreEqual(1, callCount); }
public void YZValuesCanFlowIfValidationIsTurnedOff() { var crossSection = new CrossSection { CrossSectionType = CrossSectionType.HeightFlowStorageWidth }; /* crossection flows back like this: * / \ | | \ / */ crossSection.HeightFlowStorageWidthData.Add(new HeightFlowStorageWidth(0, 1, 1)); crossSection.HeightFlowStorageWidthData.Add(new HeightFlowStorageWidth(10, 20, 20)); crossSection.HeightFlowStorageWidthData.Add(new HeightFlowStorageWidth(20, 1, 1)); //set up the crossection to not throw an exception. crossSection.ThrowExceptionIfTabulatedCrossSectionIsNotMonotonousAscending = false; var xValues = crossSection.YZValues.Select(c => c.X).ToList(); Assert.AreEqual(new[] { -0.5, -10, -0.5, 0.5, 10, 0.5 }, xValues); var yValues = crossSection.YZValues.Select(c => c.Y).ToList(); Assert.AreEqual(new[] { 20, 10, 0, 0, 10, 20 }, yValues); }
private double CalculateTorsionConstant(CrossSection cs) { double a = 0.5 * Math.Max(cs.Height, cs.Width); double b = 0.5 * Math.Min(cs.Height, cs.Width); return(a * Math.Pow(b, 3) * (16 / 3 - 17 / 5 * b / a * (1 - Math.Pow(b, 4) / (12 * Math.Pow(a, 4))))); }
public static IfcArbitraryClosedProfileDef MakeBridgeDeckProfile(IfcStore m, CrossSection cross) { var DeckProfile = m.Instances.New <IfcArbitraryClosedProfileDef>(); DeckProfile.ProfileType = IfcProfileTypeEnum.AREA; DeckProfile.ProfileName = "ConcreteDeck"; var BoundedCurve = m.Instances.New <IfcPolyline>(); var CurvePointsSet = new List <IfcCartesianPoint>(); var p0 = MakeCartesianPoint(m, -cross.widthOfBridge / 2 * 1000, 0); // CurvePointsSet.Add(MakeCartesianPoint(m, -cross.widthOfBridge / 2 *1000, 0)); CurvePointsSet.Add(p0); CurvePointsSet.Add(MakeCartesianPoint(m, -cross.widthOfBridge / 2 * 1000, -cross.vertical_offset_dis + 80)); for (int i = 0; i < cross.lateral_offset_dis.Length; i++) { CurvePointsSet.Add(MakeCartesianPoint(m, cross.lateral_offset_dis[i] * 1000 - 240 - 1000 * cross.girder_upper_flange_width / 2, -cross.vertical_offset_dis + 80)); CurvePointsSet.Add(MakeCartesianPoint(m, cross.lateral_offset_dis[i] * 1000 - 1000 * cross.girder_upper_flange_width / 2, -cross.vertical_offset_dis)); CurvePointsSet.Add(MakeCartesianPoint(m, cross.lateral_offset_dis[i] * 1000 + 1000 * cross.girder_upper_flange_width / 2, -cross.vertical_offset_dis)); CurvePointsSet.Add(MakeCartesianPoint(m, cross.lateral_offset_dis[i] * 1000 + 240 + 1000 * cross.girder_upper_flange_width / 2, -cross.vertical_offset_dis + 80)); } CurvePointsSet.Add(MakeCartesianPoint(m, cross.widthOfBridge / 2 * 1000, -cross.vertical_offset_dis + 80)); CurvePointsSet.Add(MakeCartesianPoint(m, cross.widthOfBridge / 2 * 1000, 0)); CurvePointsSet.Add(p0); BoundedCurve = MakePolyLine(m, CurvePointsSet); DeckProfile.OuterCurve = BoundedCurve; return(DeckProfile); }
public ReactionInfoView(CrossSection crossSection) { CrossSection = crossSection; InitializeComponent(); reactionNameLabel.Text = CrossSection.Name; endfName.Text = ""; }
protected override void PostDrawObjects(DrawEventArgs e) { base.PostDrawObjects(e); if (ProjectPlugIn.Instance.CurrentBeam != null) { Beam b = ProjectPlugIn.Instance.CurrentBeam; if (b.CurrentLoadCase == null) { return; } CrossSection cs = ProjectPlugIn.Instance.CurrentBeam.CrossSec; if (b.CurrentLoadCase != null && b.CurrentLoadCase.GetType() == typeof(SimpleLoadCase)) { double crackwidth = ((SimpleLoadCase)b.CurrentLoadCase).CrackWidthCalc.CrackWidth; Point3d location = ((SimpleLoadCase)b.CurrentLoadCase).CrackWidthCalc.CrackPoint; BoundingBox bb = b.CrossSec.GetBoundingBox(Plane.WorldXY); double size = bb.Diagonal.Length; e.Display.DrawCircle(new Circle(location, size / 60), Color.Red); e.Display.Draw3dText(new Text3d(Math.Round(crackwidth, 3).ToString() + " mm", new Plane(location + new Point3d(size / 50, 0, 0), Vector3d.ZAxis), size / 50), System.Drawing.Color.Red); } } }
public void SetDefaultGeometryWithBrancheGeometry() { const double defaultLength = 2; var hydroNetwork = new HydroNetwork(); var channel = new Channel {Geometry = new LineString(new[] {new Coordinate(0, 0), new Coordinate(20, 0)})}; var crossSection = new CrossSection { CrossSectionType = CrossSectionType.GeometryBased, Geometry = new LineString(new[] {new Coordinate(10, 0), new Coordinate(10, 0)}), ThalWay = defaultLength/2 }; hydroNetwork.Branches.Add(channel); NetworkHelper.AddBranchFeatureToBranch(channel, crossSection, crossSection.Offset); crossSection.Offset = 12; CrossSectionHelper.SetDefaultGeometry(crossSection, defaultLength); Assert.AreEqual(defaultLength, crossSection.Geometry.Length); Assert.AreEqual(2, crossSection.Geometry.Coordinates.Length); Assert.AreEqual(12, crossSection.Geometry.Coordinates[0].X); Assert.AreEqual(12, crossSection.Geometry.Coordinates[1].X); Assert.AreEqual(-defaultLength/2, crossSection.Geometry.Coordinates[0].Y); Assert.AreEqual(defaultLength/2, crossSection.Geometry.Coordinates[1].Y); }
public RFCroSec(CrossSection croSec) { Comment = croSec.Comment; ID = croSec.ID; UserDefined = croSec.UserDefined; IsValid = croSec.IsValid; No = croSec.No; Tag = croSec.Tag; Description = croSec.Description; MatNo = croSec.MaterialNo; RotationAngle = croSec.Rotation * 180 / Math.PI; A = croSec.AxialArea; Ay = croSec.ShearAreaY; Az = croSec.ShearAreaZ; Iy = croSec.BendingMomentY; Iz = croSec.BendingMomentZ; Jt = croSec.TorsionMoment; TempWidth = croSec.TemperatureLoadWidth; TempDepth = croSec.TemperatureLoadDepth; UserDefined = croSec.UserDefined; TextID = croSec.TextID; Shape = null; ToModify = false; ToDelete = false; }
public void CrossSectionWithXYZDefinitionCanNotShareDefiniton() { var crossSectionDefinitionXYZ = new CrossSectionDefinitionXYZ(); var crossSection = new CrossSection(crossSectionDefinitionXYZ); crossSection.ShareDefinitionAndChangeToProxy(); }
public void SetReferenceLevelGeometry() { var crossSection = new CrossSection(); var coordinates = new List <ICoordinate> { new Coordinate(0, 0, 0), new Coordinate(10, 0, 0), new Coordinate(30, 0, 0), new Coordinate(40, 0, 0) }; crossSection.Geometry = new LineString(coordinates.ToArray()); Assert.AreEqual(0.0, crossSection.LowestPoint, 1.0e-6); Assert.AreEqual(0.0, crossSection.HighestPoint, 1.0e-6); crossSection.LevelShift(111); Assert.AreEqual(111.0, crossSection.Geometry.Coordinates[0].Z, 1.0e-6); Assert.AreEqual(111.0, crossSection.Geometry.Coordinates[0].Z, 1.0e-6); Assert.AreEqual(111.0, crossSection.LowestPoint, 1.0e-6); Assert.AreEqual(111.0, crossSection.HighestPoint, 1.0e-6); }
public void SetZValueCausesPropertyChangedForXYZCrossSection() { IChannel channel = new Channel { Geometry = new LineString(new[] { new Coordinate(0, 0), new Coordinate(20, 0) }) }; var crossSection = new CrossSection { Branch = channel }; NetworkHelper.AddBranchFeatureToBranch(channel, crossSection, 10.0); var yzCoordinates = new List <ICoordinate> { new Coordinate(0.0, 0.0), new Coordinate(100.0, 0.0), }; crossSection.Geometry = CrossSectionHelper.CreateCrossSectionGeometryForXyzCrossSectionFromYZ(channel.Geometry, crossSection.Offset, yzCoordinates); int callCount = 0; ((INotifyPropertyChanged)(crossSection)).PropertyChanged += (s, e) => { callCount++; Assert.AreEqual("Geometry", e.PropertyName); }; crossSection.SetZValue(0, 100); Assert.AreEqual(1, callCount); }
/// <summary> /// Creates a simple test network of 1 branch amd 2 nodes. The branch has '3' parts, in the center of /// the first aand last is a cross section. /// n /// / /// / /// cs /// / /// -------/ /// / /// cs /// / /// n /// </summary> /// <returns></returns> private static IHydroNetwork CreateTestNetwork() { var network = new Hydro.HydroNetwork(); var branch1 = new Channel { Geometry = new LineString(new[] { new Coordinate(0, 0), new Coordinate(30, 40), new Coordinate(70, 40), new Coordinate(100, 100) }) }; var node1 = new HydroNode {Network = network, Geometry = new Point(new Coordinate(0, 0))}; var node2 = new HydroNode {Network = network, Geometry = new Point(new Coordinate(100, 100))}; network.Branches.Add(branch1); network.Nodes.Add(node1); network.Nodes.Add(node2); var crossSection1 = new CrossSection { Geometry = new LineString(new[] {new Coordinate(15, 20), new Coordinate(15, 20)}) }; double offset1 = Math.Sqrt(15 * 15 + 20 * 20); crossSection1.Offset = offset1; var crossSection2 = new CrossSection { Geometry = new LineString(new[] {new Coordinate(85, 70), new Coordinate(85, 70)}) }; double offset2 = Math.Sqrt(30 * 30 + 40 * 40) + 40 + Math.Sqrt(15 * 15 + 20 * 20); crossSection2.Offset = offset2; branch1.Source = node1; branch1.Target = node2; NetworkHelper.AddBranchFeatureToBranch(branch1, crossSection1, crossSection1.Offset); NetworkHelper.AddBranchFeatureToBranch(branch1, crossSection2, crossSection2.Offset); return network; }
public void SetDefaultGeometryWithBrancheGeometry() { const double defaultLength = 2; var hydroNetwork = new HydroNetwork(); var channel = new Channel { Geometry = new LineString(new[] { new Coordinate(0, 0), new Coordinate(20, 0) }) }; var crossSection = new CrossSection { CrossSectionType = CrossSectionType.GeometryBased, Geometry = new LineString(new[] { new Coordinate(10, 0), new Coordinate(10, 0) }), ThalWay = defaultLength / 2 }; hydroNetwork.Branches.Add(channel); NetworkHelper.AddBranchFeatureToBranch(channel, crossSection, crossSection.Offset); crossSection.Offset = 12; CrossSectionHelper.SetDefaultGeometry(crossSection, defaultLength); Assert.AreEqual(defaultLength, crossSection.Geometry.Length); Assert.AreEqual(2, crossSection.Geometry.Coordinates.Length); Assert.AreEqual(12, crossSection.Geometry.Coordinates[0].X); Assert.AreEqual(12, crossSection.Geometry.Coordinates[1].X); Assert.AreEqual(-defaultLength / 2, crossSection.Geometry.Coordinates[0].Y); Assert.AreEqual(defaultLength / 2, crossSection.Geometry.Coordinates[1].Y); }
/// <summary> /// Create a new branch at the point the raycast hits /// </summary> /// <param name="hit"></param> void CreateBranch(RaycastHit hit) { Debug.Log("Creating Branch"); // create a branch object GameObject branchObject = Instantiate(branchPrefab, hit.point + hit.normal * vine.maxRadius, Quaternion.identity); Branch branch = branchObject.GetComponent <Branch>(); branch.vine = vine; branchObject.transform.position = hit.point + hit.normal * vine.maxRadius; // position it according to the raycast hit information // create the first cross section at the hit location; translate the direction into local branch space Vector3 sectionNormal = Vector3.up - Vector3.Project(Vector3.up, hit.normal); CrossSection section = new CrossSection(Vector3.zero, sectionNormal, vine.startRadius); section.surfaceDirection = branchObject.transform.InverseTransformPoint(hit.point) - section.position; //calculating surface direction in local space section.CalculateVertices(vine.sides); section.concavity = 0f; // add the first cross section to the branch cross section list branch.addCrossSection(section); CrossSection section2 = new CrossSection(Vector3.zero, sectionNormal, vine.startRadius); section2.position += vine.sectionLength / 2 * sectionNormal; section2.surfaceDirection = section.surfaceDirection; // just give them the same direction section2.CalculateVertices(vine.sides); section2.concavity = 0f; // add a second cross section branch.addCrossSection(section2); }
private BoundingBox CreateBoundingBox() { BoundingBox bb = new BoundingBox(); if (ProjectPlugIn.Instance.CurrentBeam != null && ProjectPlugIn.Instance.CurrentBeam.CrossSec != null) { Beam b = ProjectPlugIn.Instance.CurrentBeam; CrossSection cs = ProjectPlugIn.Instance.CurrentBeam.CrossSec; List <ICalcGeometry> calcGeometries = new List <ICalcGeometry>(); calcGeometries.AddRange(cs.GetReinforcements()); List <GeometryLarge> glList = cs.GetGeometryLarges(); glList.ForEach(gl => calcGeometries.AddRange(gl.CalcMesh.MeshSegments)); foreach (ICalcGeometry item in calcGeometries) { if (item.ResultMesh != null) { bb.Union(item.ResultMesh.GetBoundingBox(false)); } } } return(bb); }
public static dynamic GetTSObject(CrossSection dynObject) { if (dynObject is null) { return(null); } return(dynObject.teklaObject); }
public void BuildBridge_Construction_Test() { const string INPATH = "../../TestFiles/alignment.ifc"; const string OUTPATH = "../../TestFiles/aligment&construction.ifc"; //generate the parameter of offset distance var t1 = new Technical_Demand(); var t2 = new CrossSection(); t2.calculate_girder_parament(ref t1); var t3 = new longitudinal_lateral_connection(); t3.get_parameters(ref t1, ref t3, ref t2); var para = new Technical_Demand(); var cross = new CrossSection(); cross.calculate_girder_parament(ref para); const int START = 30000, END = 60000; double startGap = 40; double endGap = 40; var thickness = cross.GetThickness(); var sectionParam = new List <double>() { cross.girder_upper_flange_width *1000, cross.girder_lower_flange_width *1000, cross.girder_web_height *1000 }; var plateThicknessList = new List <List <(double, double)> >() { new List <(double, double)>() { (START + startGap, thickness[0]), (END - endGap, thickness[0]) }, new List <(double, double)>() { (START + startGap, thickness[1]), (END - endGap, thickness[1]) }, new List <(double, double)>() { (START + startGap, thickness[2]), (END - endGap, thickness[2]) } }; using (var bridgeconstruction = new Bridge_Construction(INPATH, OUTPATH)) { bridgeconstruction.SetGaps(startGap, endGap); bridgeconstruction.SetCrossSection(cross); bridgeconstruction.SetBridgeAlong(START, END, 0, 0); bridgeconstruction.SetOverallSection(sectionParam); //bridgeconstruction.CreatePlateList(END - endGap, cross); bridgeconstruction.SetThickness(plateThicknessList); bridgeconstruction.buildDeck(); } }
/// <summary> /// Constructor /// </summary> /// <param name="girderMaterial">Girder material type (enumeration type)</param> /// <param name="crossSection">Girder cross-secion type (enumeration type)</param> /// <param name="lengthInMm">Girder length in millimeters</param> /// <param name="heightInMm">Girder height in millimeters</param> /// <param name="widthInMm">Girder width in millimeters</param> public StressTestCase(Material girderMaterial, CrossSection crossSection, int lengthInMm, int heightInMm, int widthInMm) { this.GirderMaterial = girderMaterial; this.CrossSection = crossSection; this.LengthInMm = lengthInMm; this.HeightInMm = heightInMm; this.WidthInMm = widthInMm; // TODO - Initialize TestCaseResult to null }
protected override void PostDrawObjects(DrawEventArgs e) { base.PostDrawObjects(e); if (ProjectPlugIn.Instance.CurrentBeam != null) { Beam b = ProjectPlugIn.Instance.CurrentBeam; if (b.CurrentLoadCase == null) { return; } CrossSection cs = ProjectPlugIn.Instance.CurrentBeam.CrossSec; List <ICalcGeometry> calcGeometries = new List <ICalcGeometry>(); calcGeometries.AddRange(cs.GetReinforcements()); List <GeometryLarge> glList = cs.GetGeometryLarges(); glList.ForEach(gl => calcGeometries.AddRange(gl.CalcMesh.MeshSegments)); Tuple <double, double> minAndMax = cs.MinAndMaxStress ?? Tuple.Create(0.0, 0.0); double minValue = minAndMax.Item1; double maxValue = minAndMax.Item2; foreach (ICalcGeometry icalcG in calcGeometries) { if (b.CrossSec.MaterialResultShown == Enumerates.MaterialType.Concrete && icalcG.Material.GetType() == typeof(ConcreteMaterial) || b.CrossSec.MaterialResultShown == Enumerates.MaterialType.Steel && icalcG.Material.GetType() == typeof(SteelMaterial)) { ColorRGB color; Mesh m = icalcG.ResultMesh; if (m == null) { continue; } double value = 0.7 - 0.7 * (icalcG.Stresses[b.CurrentLoadCase] - minValue) / (maxValue - minValue); if (value < 0 || value > 0.7) { color = Utils.HSL2RGB(1, 1, 1); } else { color = Utils.HSL2RGB(value, 1, 0.5); } m.VertexColors.Clear(); for (int k = 0; k < m.Vertices.Count; k++) { m.VertexColors.Add(color); } e.Display.DrawMeshFalseColors(m); } } } }
public void AddCrossSectionToBranch() { var crossSection = new CrossSection(); var branch = new Channel(new HydroNode("from"), new HydroNode("To")); NetworkHelper.AddBranchFeatureToBranch(branch, crossSection, crossSection.Offset); Assert.AreEqual(branch, crossSection.Branch); //branch.BranchFeatures.Clear(); //Assert.IsNull(crossSection.Branch); }
public void DefaultFriction() { CrossSection crossSection = CreateDefaultCrossSection(); double friction = crossSection.GetCrossSectionRoughnessSection(0.0).Roughness; RoughnessType roughnessType = crossSection.GetCrossSectionRoughnessSection(0.0).RoughnessType; Assert.AreEqual(45.0, friction, 1.0e-6); Assert.AreEqual(RoughnessType.Chezy, roughnessType); }
public void RoughnessValueAndType() { CrossSection crossSection = CreateDefaultCrossSection(); const double offset = 10.0; crossSection.SetRoughness(offset, 88.0, RoughnessType.DeBosandBijkerk, "9"); Assert.AreEqual(RoughnessType.DeBosandBijkerk, crossSection.GetCrossSectionRoughnessSection(offset).RoughnessType); Assert.AreEqual(88.0, crossSection.GetCrossSectionRoughnessSection(offset).Roughness, 1.0e-6); Assert.AreEqual("9", crossSection.GetCrossSectionRoughnessSection(offset).Name); }
public void RoughnessDefaultType() { CrossSection crossSection = CreateDefaultCrossSection(); crossSection.DefaultRoughnessValue = 10.0; RoughnessType roughnessType = crossSection.GetCrossSectionRoughnessSection(0.0).RoughnessType; Assert.AreEqual(RoughnessType.Chezy, roughnessType); }
public McrClc() { Material = new Material(); CrossSection = new CrossSection(); Beam = new Beam(); Load = new Load(); MomentDistribution = new MomentDistribution(); _context = new Context(this); }
public void SetPointsTest1() { CrossSection target = new CrossSection(); IXYPoint p1 = new HydroNumerics.Geometry.XYPoint(0, 0); IXYPoint p2 = new HydroNumerics.Geometry.XYPoint(10, 2); target.SetPoints(p1, p2, 0, 10, 5); Assert.AreEqual(5, target.MidStreamLocation.X); Assert.AreEqual(1, target.MidStreamLocation.Y); }
public void RoughnessDefaultValue() { CrossSection crossSection = CreateDefaultCrossSection(); crossSection.DefaultRoughnessValue = 10.0; double friction = crossSection.GetCrossSectionRoughnessSection(0.0).Roughness; Assert.AreEqual(10.0, friction, 1.0e-6); }
public void Clone() { var crossSection = new CrossSection(); //don set static members ..will mess up other tests //crossSection.DefaultRoughnessType = RoughnessType.StricklerKn; //action ! clone var clone = (CrossSection)crossSection.Clone(); Assert.AreEqual(crossSection.DefaultRoughnessType, clone.DefaultRoughnessType); }
public void BuildBridge_Construction_Test2() { const string INPATH = "../../TestFiles/alignment.ifc"; const string OUTPATH = "../../TestFiles/aligment&construction1.ifc"; var t1 = new Technical_Demand(); var t2 = new CrossSection(); t2.calculate_girder_parament(ref t1); var t3 = new longitudinal_lateral_connection(); t3.get_parameters_truss(ref t1, ref t3, ref t2); var para = new Technical_Demand(); var cross = new CrossSection(); cross.calculate_girder_parament(ref para); cross.calculate_stiffener_info(cross.girder_web_height, cross.girder_web_thickness); t3.Calculate_stiffener_info(ref t2); //the parameter order is B_UPPER,B_LOWER,WEB const int START = 30000, END = 60000, STARTGAP = 20, ENDGAP = 20, LATOFFSET = 0; double VEROFFSET = -cross.vertical_offset_dis; var sectionParams = new List <double>() { cross.girder_upper_flange_width *1000, cross.girder_lower_flange_width * 1000, cross.girder_web_height * 1000 }; var thickness = new List <List <(double, double)> >() { new List <(double, double)>() { (STARTGAP, cross.girder_upper_flange_thickness * 1000), (END - START - ENDGAP, cross.girder_upper_flange_thickness * 1000) }, new List <(double, double)>() { (STARTGAP, cross.girder_lower_flange_thickness * 1000), (END - START - ENDGAP, cross.girder_lower_flange_thickness * 1000) }, new List <(double, double)>() { (STARTGAP, cross.girder_web_thickness * 1000), (END - START - ENDGAP, cross.girder_web_thickness * 1000) } }; using (var bridgeconstruction = new Bridge_Construction(INPATH, OUTPATH)) { bridgeconstruction.SetCrossSection(cross); bridgeconstruction.SetBridgeAlong(START, END, VEROFFSET, LATOFFSET); bridgeconstruction.setLongitudinal_lateral_connection(t3); bridgeconstruction.SetGaps(STARTGAP, ENDGAP); bridgeconstruction.SetOverallSection(sectionParams); bridgeconstruction.SetThickness(thickness); bridgeconstruction.build(); } }
private static void AddTestCrossSectionAt(IHydroNetwork network, IChannel branch, double offset) { var crossSection = new CrossSection { Network = network, Geometry = new LineString(new[] { new Coordinate(offset, 0), new Coordinate(offset, 0) }), Offset = offset }; branch.BranchFeatures.Add(crossSection); }
public virtual void CopyFrom(CrossSection selectedSection) { Name = selectedSection.Name; Area = selectedSection.Area; MajorElasticSectionModulus = selectedSection.MajorElasticSectionModulus; MajorPlasticSectionModulus = selectedSection.MajorPlasticSectionModulus; MinorElasticSectionModulus = selectedSection.MinorElasticSectionModulus; MinorPlasticSectionModulus = selectedSection.MinorPlasticSectionModulus; MajorSecondMomentOfArea = selectedSection.MajorSecondMomentOfArea; MinorSecondMomentOfArea = selectedSection.MinorSecondMomentOfArea; Height = selectedSection.Height; }
public void ReadCrossSectionsTest() { M11Branch hygum = target.network.Branches.First(var => var.Name == "HYGUM_NOR_KANAL"); CrossSection cs = hygum.CrossSections.First(var => var.Chainage == 1926); Assert.AreEqual(4.8, cs.MaxHeightMrk1and3, 0.000001); double d = cs.MaxHeightMrk1and3; cs.MaxHeightMrk1and3 = d + 1; Assert.AreEqual(d + 1, cs.MaxHeightMrk1and3); }
/// <summary> /// Create element 1D /// </summary> /// <param name="model">Idea open model</param> /// <param name="css">Cross section</param> /// <param name="segment">Line segment</param> /// <returns>Element 1D</returns> private static Element1D CreateElement1D(OpenModel model, CrossSection css, LineSegment3D segment) { Element1D element1D = new Element1D(); element1D.Id = model.GetMaxId(element1D) + 1; element1D.Name = "E" + element1D.Id.ToString(); element1D.Segment = new ReferenceElement(segment); element1D.CrossSectionBegin = new ReferenceElement(css); element1D.CrossSectionEnd = new ReferenceElement(css); return(element1D); }
private static CrossSection CreateDefaultCrossSection() { IChannel channel = new Channel { Geometry = new LineString(new[] { new Coordinate(0, 0), new Coordinate(20, 0) }) }; var crossSection = new CrossSection { Branch = channel, CrossSectionType = CrossSectionType.YZTable }; CrossSectionHelper.CreateDefaultYZTableAndGeometryForYZCrossSection(crossSection, 100.0); return(crossSection); }
public void ChangeRoughnessTypeCausesPropertyChanged() { IChannel channel = new Channel { Geometry = new LineString(new[] { new Coordinate(0, 0), new Coordinate(20, 0) }) }; var crossSection = new CrossSection { Branch = channel, CrossSectionType = CrossSectionType.YZTable }; CrossSectionHelper.CreateDefaultYZTableAndGeometryForYZCrossSection(crossSection, 100.0); crossSection.SetRoughness(10.0, 1.0, RoughnessType.Chezy, ""); int callCount = 0; ((INotifyPropertyChanged)(crossSection)).PropertyChanged += (s, e) => { callCount++; Assert.AreEqual("RoughnessType", e.PropertyName); }; crossSection.RoughnessSections[0].RoughnessType = RoughnessType.StricklerKn; Assert.AreEqual(1, callCount); }
public void AddDefaultZToGeometry() { var crossSection = new CrossSection(); // just a horizontal line from 10 to 40. Now just set z to 0 to make it work. // could be something more fancy. var coordinates = new List<ICoordinate> { new Coordinate(0, 0), new Coordinate(10, 0), new Coordinate(20, 0), new Coordinate(30, 0), new Coordinate(40, 0) }; crossSection.Geometry = new LineString(coordinates.ToArray()); CrossSectionHelper.AddDefaultZToGeometry(crossSection); Assert.AreEqual(10.0, crossSection.Geometry.Coordinates[0].Z); Assert.AreEqual(5.0, crossSection.Geometry.Coordinates[1].Z); Assert.AreEqual(0.0, crossSection.Geometry.Coordinates[2].Z); Assert.AreEqual(5.0, crossSection.Geometry.Coordinates[3].Z); Assert.AreEqual(10.0, crossSection.Geometry.Coordinates[4].Z); }
public void CloneNetworkWithManyCrossSectionWithProcessedData() { var stopwatch = new Stopwatch(); stopwatch.Start(); var network = new HydroNetwork(); var fromNode = new Node(); var toNode = new Node(); var branch = new Channel(fromNode, toNode, 5000); network.Nodes.Add(fromNode); network.Nodes.Add(toNode); network.Branches.Add(branch); for (var i = 0.0; i <= 5000; i++) { var crossSection = new CrossSection { Offset = i }; var processedData = crossSection.ConveyanceData; // makes sure it is created branch.BranchFeatures.Add(crossSection); } stopwatch.Stop(); log.DebugFormat("It took {0} ms to create network containing 5000 cross-sections", stopwatch.ElapsedMilliseconds); stopwatch = new Stopwatch(); stopwatch.Start(); var networkClone = network.Clone(); stopwatch.Stop(); log.DebugFormat("It took {0} ms to clone network containing 5000 cross-sections", stopwatch.ElapsedMilliseconds); stopwatch.ElapsedMilliseconds .Should("Clone of network containing many cross-sections with processed data should be reasonable") .Be.LessThan(13000); }
public void YZValuesCanFlowIfValidationIsTurnedOff() { var crossSection = new CrossSection { CrossSectionType = CrossSectionType.HeightFlowStorageWidth }; /* crossection flows back like this: / \ | | \ / */ crossSection.HeightFlowStorageWidthData.Add(new HeightFlowStorageWidth(0, 1, 1)); crossSection.HeightFlowStorageWidthData.Add(new HeightFlowStorageWidth(10, 20, 20)); crossSection.HeightFlowStorageWidthData.Add(new HeightFlowStorageWidth(20, 1, 1)); //set up the crossection to not throw an exception. crossSection.ThrowExceptionIfTabulatedCrossSectionIsNotMonotonousAscending = false; var xValues = crossSection.YZValues.Select(c => c.X).ToList(); Assert.AreEqual(new[]{-0.5,-10,-0.5,0.5,10,0.5},xValues); var yValues = crossSection.YZValues.Select(c => c.Y).ToList(); Assert.AreEqual(new[] { 20, 10, 0, 0, 10, 20}, yValues); }
public void YZProfileFromTabulatedCrossSections() { var branchGeometry = new LineString(new[] { new Coordinate(111, 0), new Coordinate(11, 0) }); var channel = new Channel { Geometry = branchGeometry }; var crossSection = new CrossSection { CrossSectionType = CrossSectionType.HeightFlowStorageWidth, Offset = 10 }; NetworkHelper.AddBranchFeatureToBranch(channel, crossSection, crossSection.Offset); crossSection.HeightFlowStorageWidthData.Add(new HeightFlowStorageWidth(-10.0, 15, 25)); crossSection.HeightFlowStorageWidthData.Add(new HeightFlowStorageWidth(0.0, 20, 30)); CrossSectionHelper.ConvertCrossSectionType(crossSection, CrossSectionType.YZTable); Assert.AreEqual(CrossSectionType.YZTable, crossSection.CrossSectionType); Assert.AreEqual(4, crossSection.YZValues.Count); }
public void YZValuesGivesExceptionWhenMonotonousAscending() { var crossSection = new CrossSection { CrossSectionType = CrossSectionType.HeightFlowStorageWidth }; /* 'invalid' since it flows back like this: / \ | | \ / */ crossSection.HeightFlowStorageWidthData.Add(new HeightFlowStorageWidth(0,1,1)); crossSection.HeightFlowStorageWidthData.Add(new HeightFlowStorageWidth(10, 20, 20)); crossSection.HeightFlowStorageWidthData.Add(new HeightFlowStorageWidth(20,1, 1)); //action! this should result in a exception var values = crossSection.YZValues; }
public void GeometryToYzToGeometryOrThereAndBackAgain() { var branchGeometry = new LineString(new[] { new Coordinate(111, 0), new Coordinate(11, 0) }); var channel = new Channel { Geometry = branchGeometry }; IList<ICoordinate> yzCoordinates = new List<ICoordinate> { // note: x, y of coordinate are interpreted as the yz for // the cross section. new Coordinate(0.0, 0.0), new Coordinate(5.0, -20.0), new Coordinate(15.0, -20.0), new Coordinate(20.0, 0.0) }; IGeometry geometry = CrossSectionHelper.CreateCrossSectionGeometryForXyzCrossSectionFromYZ(branchGeometry, 30, yzCoordinates); CrossSection crossSection = new CrossSection { Geometry = geometry, Offset = 10 }; NetworkHelper.AddBranchFeatureToBranch(channel, crossSection, crossSection.Offset); Assert.AreEqual(CrossSectionType.GeometryBased, crossSection.CrossSectionType); const int coordinateCount = 4; Assert.AreEqual(coordinateCount, crossSection.Geometry.Coordinates.Length); Assert.AreEqual(coordinateCount, crossSection.YZValues.Count); CrossSectionHelper.ConvertCrossSectionType(crossSection, CrossSectionType.YZTable); Assert.AreEqual(coordinateCount, crossSection.YZValues.Count); Assert.AreEqual(2, crossSection.Geometry.Coordinates.Length); Assert.AreEqual(4, crossSection.YZValues.Count); CrossSectionHelper.ConvertCrossSectionType(crossSection, CrossSectionType.GeometryBased); Assert.AreEqual(CrossSectionType.GeometryBased, crossSection.CrossSectionType); Assert.AreEqual(coordinateCount, crossSection.Geometry.Coordinates.Length); }
public void BranchCrossSectionShouldRaiseCollectionChangedEvent() { var crossSection = new CrossSection(); var branch = new Channel(new HydroNode("from"), new HydroNode("To")); int count = 0; Post.Cast<Channel, INotifyCollectionChanged>(branch).CollectionChanged += delegate { count++; }; NetworkHelper.AddBranchFeatureToBranch(branch, crossSection, crossSection.Offset); Assert.AreEqual(1, count); branch.BranchFeatures.Clear(); Assert.AreEqual(2, count); }
public void SetReferenceLevelGeometry() { var crossSection = new CrossSection(); var coordinates = new List<ICoordinate> { new Coordinate(0, 0, 0), new Coordinate(10, 0, 0), new Coordinate(30, 0, 0), new Coordinate(40, 0, 0) }; crossSection.Geometry = new LineString(coordinates.ToArray()); Assert.AreEqual(0.0, crossSection.LowestPoint, 1.0e-6); Assert.AreEqual(0.0, crossSection.HighestPoint, 1.0e-6); crossSection.LevelShift(111); Assert.AreEqual(111.0, crossSection.Geometry.Coordinates[0].Z, 1.0e-6); Assert.AreEqual(111.0, crossSection.Geometry.Coordinates[0].Z, 1.0e-6); Assert.AreEqual(111.0, crossSection.LowestPoint, 1.0e-6); Assert.AreEqual(111.0, crossSection.HighestPoint, 1.0e-6); }
public void ListenCarefulllyItShouldGeometryChangeforLevelShiftOnlyOnce() { CrossSection crossSection = new CrossSection { CrossSectionType = CrossSectionType.YZTable }; crossSection.YZValues.Add(new Coordinate(0, 0)); crossSection.YZValues.Add(new Coordinate(20, 0)); int callCount = 0; ((INotifyPropertyChanged)(crossSection)).PropertyChanged += (s, e) => { if (e.PropertyName == "Geometry") { callCount++; } }; crossSection.LevelShift(111); Assert.AreEqual(1, callCount); }
public void AddingYZValuesDoesNotCauseCollectionChanged() { //collection changed of YZValues are bubbled a lot. This is a big performance penaly var crossSection = new CrossSection(); crossSection.CrossSectionType = CrossSectionType.YZTable; ((INotifyCollectionChanged)(crossSection)).CollectionChanged += (s, e) => { Assert.Fail("Should not be called!"); }; crossSection.YZValues.Add(new Coordinate(0, 0, 0)); }
private static CrossSection CreateDefaultCrossSection() { IChannel channel = new Channel { Geometry = new LineString(new[] { new Coordinate(0, 0), new Coordinate(20, 0) }) }; var crossSection = new CrossSection { Branch = channel, CrossSectionType = CrossSectionType.YZTable }; CrossSectionHelper.CreateDefaultYZTableAndGeometryForYZCrossSection(crossSection, 100.0); return crossSection; }
public void Clone() { var crossSection = new CrossSection(); //don set static members ..will mess up other tests //crossSection.DefaultRoughnessType = RoughnessType.StricklerKn; //action ! clone var clone = (CrossSection)crossSection.Clone(); Assert.AreEqual(crossSection.DefaultRoughnessType,clone.DefaultRoughnessType); }
public void SetReferenceLevelHeightWidthWidthTest() { CrossSection crossSection = new CrossSection { CrossSectionType = CrossSectionType.HeightFlowStorageWidth }; crossSection.HeightFlowStorageWidthData.Add(new HeightFlowStorageWidth(0, 10.0, 10.0)); crossSection.HeightFlowStorageWidthData.Add(new HeightFlowStorageWidth(10, 100.0, 100.0)); Assert.AreEqual(0.0, crossSection.LowestPoint, 1.0e-6); Assert.AreEqual(10.0, crossSection.HighestPoint, 1.0e-6); crossSection.LevelShift(111); Assert.AreEqual(111.0, crossSection.HeightFlowStorageWidthData[0].Height, 1.0e-6); Assert.AreEqual(121.0, crossSection.HeightFlowStorageWidthData[1].Height, 1.0e-6); Assert.AreEqual(111.0, crossSection.LowestPoint, 1.0e-6); Assert.AreEqual(121.0, crossSection.HighestPoint, 1.0e-6); }
public void SetReferenceLevelYZTest() { CrossSection crossSection = new CrossSection { CrossSectionType = CrossSectionType.YZTable }; crossSection.YZValues.Add(new Coordinate(0, 0)); crossSection.YZValues.Add(new Coordinate(0, -10)); crossSection.YZValues.Add(new Coordinate(20, -10)); crossSection.YZValues.Add(new Coordinate(20, 0)); Assert.AreEqual(-10.0, crossSection.LowestPoint, 1.0e-6); Assert.AreEqual(0.0, crossSection.HighestPoint, 1.0e-6); crossSection.LevelShift(111); Assert.AreEqual(111.0, crossSection.YZValues[0].Y, 1.0e-6); Assert.AreEqual(101.0, crossSection.YZValues[1].Y, 1.0e-6); Assert.AreEqual(101.0, crossSection.YZValues[2].Y, 1.0e-6); Assert.AreEqual(111.0, crossSection.YZValues[3].Y, 1.0e-6); Assert.AreEqual(101.0, crossSection.LowestPoint, 1.0e-6); Assert.AreEqual(111.0, crossSection.HighestPoint, 1.0e-6); }
public void TestDefaultCrossSectionGeometry() { var crossSection = new CrossSection(); CrossSectionHelper.CreateDefaultYZTableAndGeometryForYZCrossSection(crossSection, 100.0); }
private static void AddTestCrossSectionAt(IHydroNetwork network, IChannel branch, double offset) { var crossSection = new CrossSection { Network = network, Geometry = new LineString(new[] {new Coordinate(offset, 0), new Coordinate(offset, 0)}), Offset = offset }; branch.BranchFeatures.Add(crossSection); }
public void SaveToMike11(string m11name) { NWK11File nwk = new NWK11File(); double x0 = double.MaxValue; double x1 = double.MinValue; double y0 = double.MaxValue; double y1 = double.MinValue; int pointcount =1; //This is necessary because it fails if DHI.CrossSection.Dll tries to load UFS.dll DFS0 d = new DFS0(@"v"); d.Dispose(); CrossSectionCollection csc = new CrossSectionCollection(); csc.Connection.FilePath = Path.ChangeExtension(m11name, ".xns11"); csc.Connection.Bridge = csc.Connection.AvailableBridges[0]; foreach (var b in Branches) { var newbranch = nwk.MIKE_11_Network_editor.BRANCHES.AddBranch(); newbranch.definitions.Par1 = b.Name; double lastchainage = 0; for (int i = 0; i < b.Links.Count; i++) { var bp = nwk.MIKE_11_Network_editor.POINTS.AddPoint(); bp.Par1 = pointcount; bp.Par2 = b.Links[i].UpstreamNode.Location.X; bp.Par3 = b.Links[i].UpstreamNode.Location.Y; x0 = Math.Min(b.Links[i].UpstreamNode.Location.X, x0); x1 = Math.Max(b.Links[i].UpstreamNode.Location.X, x1); y0 = Math.Min(b.Links[i].UpstreamNode.Location.Y, y0); y1 = Math.Max(b.Links[i].UpstreamNode.Location.Y, y1); if (i == 0) { bp.Par4 = 1; } else { bp.Par4 = 0; lastchainage += b.Links[i - 1].Length; } bp.Par5 = lastchainage; newbranch.points.AddValue(pointcount); //CrossSections CrossSection cs = new CrossSection(new DHI.Generic.RouteLocation(b.Name, "Topo-id", lastchainage, b.Links[i].pfslink.Par5)); if (b.Links[i].Xsec != null && b.Links[i].Xsec.TypeNo == 4) { double bottom = double.MaxValue; int bottomindex = 0; int index = 0; foreach (var dat in b.Links[i].Xsec.Datas) { var z = dat.GetValue(1); if (z < bottom) { bottom = z; bottomindex = index; } cs.Points.AddPoint(new CrossSectionPoint(dat.GetValue(0), z)); index++; } if (bottom == 0) cs.Datum = b.Links[i].UpstreamNode.pfsnode.InvertLevel; cs.Points.SetMarkerAt(1, 0); cs.Points.SetMarkerAt(3, b.Links[i].Xsec.Datas.Count - 1); cs.Points.SetMarkerAt(2, bottomindex); csc.Add(cs); } else if (b.Links[i].pfslink.Par4 == 1) //Assume circular { cs.Geometry = DHI.Mike1D.CrossSections.Geometry.ClosedCircular; cs.SetDiameter(b.Links[i].pfslink.Par7); cs.Datum = b.Links[i].UpstreamNode.pfsnode.InvertLevel; csc.Add(cs); } if (i == b.Links.Count - 1) { lastchainage += b.Links[i].Length; var connectionlink = b.Links[i].DownstreamNode.Links.FirstOrDefault(l => l.UpstreamNode == b.Links[i].DownstreamNode); if (connectionlink != null) //Create a connection { var branch = Branches.Single(br => br.Links.Contains(connectionlink)); newbranch.connections.Par3 = branch.Name; newbranch.connections.Par4 = branch.GetChainage(connectionlink); } pointcount++; var bpn = nwk.MIKE_11_Network_editor.POINTS.AddPoint(); bpn.Par1 = pointcount; bpn.Par2 = b.Links[i].DownstreamNode.Location.X; bpn.Par3 = b.Links[i].DownstreamNode.Location.Y; bpn.Par4 = 0; bpn.Par5 = lastchainage; newbranch.points.AddValue(pointcount); } pointcount++; } newbranch.definitions.Par3 = 0; newbranch.definitions.Par4 = (int) lastchainage; newbranch.definitions.Par6 = 1000; newbranch.definitions.Par7 = 3; } nwk.MIKE_11_Network_editor.DATA_AREA.x0 =(int) (x0- 0.1* (x1-x0)); nwk.MIKE_11_Network_editor.DATA_AREA.x1 = (int)(x1 + 0.1 * (x1 - x0)); nwk.MIKE_11_Network_editor.DATA_AREA.y0 = (int)(y0 - 0.1 * (y1 - y0)); nwk.MIKE_11_Network_editor.DATA_AREA.y1 = (int)(y1 + 0.1 * (y1 - y0)); nwk.FileName = m11name; nwk.Save(); csc.Connection.Save(); }
public void SetDefaultGeometryNoBranche() { var crossSection = new CrossSection(); CrossSectionHelper.SetDefaultGeometry(crossSection, 1); }