/// <summary> /// Offsets an arc along the offset direction from the point on the arc. /// </summary> /// <param name="arc">The arc.</param> /// <param name="offsetPntOnArc">The point on the arc.</param> /// <param name="offset">The offset vector.</param> /// <returns>The offset Arc.</returns> private static Arc OffsetArc(Arc arc, XYZ offsetPntOnArc, XYZ offset) { if (arc == null || offset == null) { throw new ArgumentNullException(); } if (offset.IsZeroLength()) { return(arc); } XYZ axis = arc.Normal.Normalize(); XYZ offsetAlongAxis = axis.Multiply(offset.DotProduct(axis)); XYZ offsetOrthAxis = offset - offsetAlongAxis; XYZ offsetPntToCenter = (arc.Center - offsetPntOnArc).Normalize();; double signedOffsetLengthTowardCenter = offsetOrthAxis.DotProduct(offsetPntToCenter); double newRadius = arc.Radius - signedOffsetLengthTowardCenter; // signedOffsetLengthTowardCenter > 0, minus, < 0, add Arc offsetArc = m_appCreation.NewArc(arc.Center, newRadius, arc.get_EndParameter(0), arc.get_EndParameter(1), arc.XDirection, arc.YDirection); offsetArc = GeometryUtil.MoveCurve(offsetArc, offsetAlongAxis) as Arc; return(offsetArc); }
/// <summary> /// Checks if edges are congruent. /// </summary> /// <param name="faceEdgeDic">The collection contains potential path edges on the side faces.</param> /// <returns>True if congruent, false otherwise.</returns> private static bool AreEdgesSimpleCongruent(Dictionary <Face, List <Edge> > faceEdgeDic) { if (faceEdgeDic == null || faceEdgeDic.Count == 0) { return(false); } foreach (Face face in faceEdgeDic.Keys) { List <Edge> edges = faceEdgeDic[face]; if (edges.Count != 2) { return(false); } Curve curve0 = edges[0].AsCurveFollowingFace(face); Curve curve1 = edges[1].AsCurveFollowingFace(face); if (curve0 is Line) { if (!(curve1 is Line)) { return(false); } XYZ moveDir = curve1.get_EndPoint(1) - curve0.get_EndPoint(0); Curve movedCurve = GeometryUtil.MoveCurve(curve0, moveDir); if (movedCurve.Intersect(curve1) != SetComparisonResult.Equal) { return(false); } continue; } else if (curve0 is Arc) { if (!(curve1 is Arc)) { return(false); } Arc arc0 = curve0 as Arc; XYZ offsetVec = curve1.get_EndPoint(1) - curve0.get_EndPoint(0); Arc offsetArc = OffsetArc(arc0, curve0.get_EndPoint(0), offsetVec); if (offsetArc.Intersect(curve1) != SetComparisonResult.Equal) { return(false); } continue; } // not support other types of curves for now return(false); } return(true); }