/// <summary> /// Tests the express where-clause specified in param 'clause' /// </summary> /// <param name="clause">The express clause to test</param> /// <returns>true if the clause is satisfied.</returns> public bool ValidateClause(IfcSectionedSpineClause clause) { var retVal = false; try { switch (clause) { case IfcSectionedSpineClause.WR1: retVal = Functions.SIZEOF(CrossSections) == Functions.SIZEOF(CrossSectionPositions); break; case IfcSectionedSpineClause.WR2: retVal = Functions.SIZEOF(CrossSections.Where(temp => CrossSections.ItemAt(0).ProfileType != temp.ProfileType)) == 0; break; case IfcSectionedSpineClause.WR3: retVal = SpineCurve.Dim == 3; break; } } catch (Exception ex) { var log = Validation.ValidationLogging.CreateLogger <Xbim.Ifc2x3.GeometricModelResource.IfcSectionedSpine>(); log?.LogError(string.Format("Exception thrown evaluating where-clause 'IfcSectionedSpine.{0}' for #{1}.", clause, EntityLabel), ex); } return(retVal); }
/// <summary> /// Adds a cross section to this branch and gives it the right position /// </summary> /// <param name="cs"></param> public void AddCrossection(CrossSection cs) { CrossSections.Add(cs); M11Point p_upstream; M11Point p_downstream; //Find upstream POINTS. //The cross section is at the end of the branch. Cast to int to avoid rounding problems if (Math.Round(_points.Last().Chainage) == Math.Round(cs.Chainage)) { p_upstream = _points.Last(); } else { p_upstream = _points.FirstOrDefault(var => var.Chainage > cs.Chainage); } //Downstream point is the previous point p_downstream = _points[_points.IndexOf(p_upstream) - 1]; //Set the POINTS on the cross section cs.SetPoints(p_downstream, p_upstream); }
protected override void setJSON(JObject obj, BaseClassIfc host, SetJsonOptions options) { base.setJSON(obj, host, options); obj["Directrix"] = Directrix.getJson(this, options); obj["CrossSectionPositions"] = new JArray(CrossSectionPositions.Select(x => x.getJson(this, options))); obj["CrossSections"] = new JArray(CrossSections.Select(x => x.getJson(this, options))); obj["FixedAxisVertical"] = mFixedAxisVertical; }
public override string GetStepParameters() { var parameters = new List <string>(); parameters.Add(SpineCurve != null ? SpineCurve.ToStepValue() : "$"); parameters.Add(CrossSections != null ? CrossSections.ToStepValue() : "$"); parameters.Add(CrossSectionPositions != null ? CrossSectionPositions.ToStepValue() : "$"); return(string.Join(", ", parameters.ToArray())); }
/// <summary> /// Gets the bottomlevel of the branch. Interpolates linearly between points /// </summary> /// <param name="chainage"></param> /// <returns></returns> public double GetBottomLevelAtChainage(double chainage) { if (chainage <= ChainageStart) { return(CrossSections.First().BottomLevel); } if (chainage >= ChainageEnd) { return(CrossSections.Last().BottomLevel); } LinearSplineInterpolation lsp = new LinearSplineInterpolation(CrossSections.Select(xc => xc.Chainage).ToList(), CrossSections.Select(xc => xc.BottomLevel).ToList()); return(lsp.Interpolate(chainage)); }
internal override void parseJObject(JObject obj) { base.parseJObject(obj); JObject jobj = obj.GetValue("Directrix", StringComparison.InvariantCultureIgnoreCase) as JObject; if (jobj != null) { Directrix = mDatabase.ParseJObject <IfcCurve>(jobj); } CrossSectionPositions.AddRange(mDatabase.extractJArray <IfcDistanceExpression>(obj.GetValue("CrossSectionPositions", StringComparison.InvariantCultureIgnoreCase) as JArray)); CrossSections.AddRange(mDatabase.extractJArray <IfcProfileDef>(obj.GetValue("CrossSections", StringComparison.InvariantCultureIgnoreCase) as JArray)); JToken fixedAxisVertical = obj.GetValue("FixedAxisVertical", StringComparison.InvariantCultureIgnoreCase); if (fixedAxisVertical != null) { mFixedAxisVertical = fixedAxisVertical.Value <bool>(); } }