public static void ShowFaceDirection(TopoDSFace face, Document Document) { var p1 = new gpPnt(); var v1 = new gpVec(); var v2 = new gpVec(); var sf = new BRepAdaptorSurface(face, true); var u = sf.FirstUParameter; var x = sf.LastUParameter; if (Precision.IsInfinite(u)) { u = (Precision.IsInfinite(x)) ? 0.0 : x; } else if (!Precision.IsInfinite(x)) { u = (u + x) / 2.0; } var v = sf.FirstVParameter; x = sf.LastVParameter; if (Precision.IsInfinite(v)) { v = (Precision.IsInfinite(x)) ? 0.0 : x; } else if (!Precision.IsInfinite(x)) { v = (v + x) / 2.0; } sf.D1(u, v, p1, v1, v2); var vector = v1.Crossed(v2); x = vector.Magnitude; // The direction vector length const double length = 70.0; if (x > 0.0000001) { vector.Multiply(length / x); } else { vector.SetCoord(length / 2.0, 0, 0); } var p2 = new gpPnt(p1.X, p1.Y, p1.Z); p2.Translate(vector); if (p1.IsEqual(p2, Precision.Confusion)) { return; } DrawArrow(Document, p1, p2, face.Orientation()); }
/// <summary> /// Builds a rectangle from 2 points received as parameter. /// Rectangle: /// P2--------P3 /// P1--------P4 /// </summary> /// <param name = "firstPoint"></param> /// <param name = "thirdPoint"></param> /// <param name = "direction"></param> /// <returns></returns> public static TopoDSFace BuildRectangle(gpPnt firstPoint, gpPnt thirdPoint, gpDir direction) { // Check for point coincidence if (firstPoint.IsEqual(thirdPoint, Precision.Confusion)) { return(null); } var secondPoint = new gpPnt(); var fourthPoint = new gpPnt(); GeomUtils.CalculateRectangleVertexes(firstPoint, thirdPoint, direction, ref secondPoint, ref fourthPoint); return(BuildRectangle(new Point3D(firstPoint), new Point3D(secondPoint), new Point3D(fourthPoint))); }
private static bool AreInSamePlace(gpPnt startPoint, gpPnt endPoint) { return(startPoint.IsEqual(endPoint, Precision.Confusion)); }