/// <summary> /// Specifically check if the trim parameters are likely set incorrectly to the sum of the lengths of the curve segments, /// if some of the curve segments are line segments. /// </summary> /// <param name="id">The id of the IFC entity containing the directrix, for messaging purposes.</param> /// <param name="ifcCurve">The IFCCurve entity containing the CurveLoop to be trimmed.</param> /// <param name="startVal">The starting trim parameter.</param> /// <param name="endVal">The ending trim parameter.</param> /// <param name="totalParamLength">The total parametric length of the curve, as defined by IFC.</param> /// <returns>False if the trim parameters are thought to be invalid or unnecessary, true otherwise.</returns> private static bool CheckIfTrimParametersAreNeeded(int id, IFCCurve ifcCurve, double startVal, double endVal, double totalParamLength) { // This check allows for some leniency in the setting of startVal and endVal; we assume that: // 1. If the parameter range is equal, that an offset value is OK; don't trim. // 2. If the start parameter is 0 and the curveParamLength is greater than the total length, don't trim. double curveParamLength = endVal - startVal; if (MathUtil.IsAlmostEqual(curveParamLength, totalParamLength)) { return(false); } if (MathUtil.IsAlmostZero(startVal) && totalParamLength < curveParamLength - MathUtil.Eps()) { return(false); } if (!(ifcCurve is IFCCompositeCurve)) { return(true); } double totalRawParametricLength = 0.0; foreach (IFCCurve curveSegment in (ifcCurve as IFCCompositeCurve).Segments) { if (!(curveSegment is IFCTrimmedCurve)) { return(true); } IFCTrimmedCurve trimmedCurveSegment = curveSegment as IFCTrimmedCurve; if (trimmedCurveSegment.Trim1 == null || trimmedCurveSegment.Trim2 == null) { return(true); } totalRawParametricLength += (trimmedCurveSegment.Trim2.Value - trimmedCurveSegment.Trim1.Value); } // Error in some Tekla files - lines are parameterized by length, instead of 1.0 (as is correct). // Warn and ignore the parameter length. This must come after the MathUtil.IsAlmostEqual(curveParamLength, totalParamLength) // check above, since we don't want to warn if curveParamLength == totalParamLength. if (MathUtil.IsAlmostEqual(curveParamLength, totalRawParametricLength)) { Importer.TheLog.LogWarning(id, "The total parameter length for this curve is equal to the sum of the parameter deltas, " + "and not the parameter length as defined in IFC. " + "Most likely, this is an error in the sending application, and the trim extents are being ignored. " + "If this trim was intended, please contact Autodesk.", true); return(false); } return(true); }
/// <summary> /// Specifically check if the trim parameters are likely set incorrectly to the sum of the lengths of the curve segments, /// if some of the curve segments are line segments. /// </summary> /// <param name="id">The id of the IFC entity containing the directrix, for messaging purposes.</param> /// <param name="ifcCurve">The IFCCurve entity containing the CurveLoop to be trimmed.</param> /// <param name="curveParamLength">The delta between the start and end parameters of the overall curve.</param> /// <returns>False if the trim parameters are thought to be invalid, true otherwise.</returns> private static bool CheckIfTrimParametersAreValidForSomeInvalidities(int id, IFCCurve ifcCurve, double curveParamLength) { if (!(ifcCurve is IFCCompositeCurve)) { return(true); } double totalRawParametricLength = 0.0; foreach (IFCCurve curveSegment in (ifcCurve as IFCCompositeCurve).Segments) { if (!(curveSegment is IFCTrimmedCurve)) { return(true); } IFCTrimmedCurve trimmedCurveSegment = curveSegment as IFCTrimmedCurve; if (trimmedCurveSegment.Trim1 == null || trimmedCurveSegment.Trim2 == null) { return(true); } totalRawParametricLength += (trimmedCurveSegment.Trim2.Value - trimmedCurveSegment.Trim1.Value); } if (MathUtil.IsAlmostEqual(curveParamLength, totalRawParametricLength)) { Importer.TheLog.LogWarning(id, "The total parameter length for this curve is equal to the sum of the parameter deltas, " + "and not the parameter length as defined in IFC. " + "Most likely, this is an error in the sending application, and the trim extents are being ignored. " + "If this trim was intended, please contact Autodesk.", true); return(false); } return(true); }