/// <summary> /// Returns whether 2 workplanes are equal based on origin, x,y,z vector axis /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <returns>True/False</returns> public static bool AreWorkplanesEqual(DG.Workplane a, DG.Workplane b) { bool result = a.Origin == b.Origin && a.XAxis == b.XAxis && a.YAxis == b.YAxis && a.ZAxis == b.ZAxis; return(result); }
/// <summary> /// Rebases the polyline from the specified workplane to the world. /// </summary> /// <param name="fromWorkplane">Workplane from which the line is to be rebased.</param> public void RebaseFromWorkplane(Workplane fromWorkplane) { foreach (Point objPoint in this) { objPoint.RebaseFromWorkplane(fromWorkplane); } }
/// <summary> /// Rebases the polyline from the world to the specified workplane. /// </summary> /// <param name="toWorkplane">Destination workplane.</param> public void RebaseToWorkplane(Workplane toWorkplane) { foreach (Point objPoint in this) { objPoint.RebaseToWorkplane(toWorkplane); } }
/// <summary> /// Rebases the model from the specified workplane to the world. /// </summary> /// <param name="fromWorkplane">Source workplane.</param> public void RebaseFromWorkplane(Workplane fromWorkplane) { foreach (DMTTriangleBlock block in _blocks) { for (int intVerticeNo = 0; intVerticeNo <= block.NoOfVertices - 1; intVerticeNo++) { block.TriangleVertices.ElementAt(intVerticeNo).RebaseFromWorkplane(fromWorkplane); } } }
/// <summary> /// Rebases Point from the world to the specified Workplane /// </summary> /// <param name="toWorkplane">Workplane to rebase the Point to.</param> public void RebaseToWorkplane(Workplane toWorkplane) { Vector fromOrigin = null; fromOrigin = this - toWorkplane.Origin; X = Vector.DotProduct(fromOrigin, toWorkplane.XAxis); Y = Vector.DotProduct(fromOrigin, toWorkplane.YAxis); Z = Vector.DotProduct(fromOrigin, toWorkplane.ZAxis); }
/// <summary> /// Rebases this vector to the specified workplane. /// </summary> /// <param name="toWorkplane">Workplane to rebase to.</param> public void RebaseToWorkplane(Workplane toWorkplane) { Vector rebasedVector = new Vector(); rebasedVector.I = DotProduct(this, toWorkplane.XAxis); rebasedVector.J = DotProduct(this, toWorkplane.YAxis); rebasedVector.K = DotProduct(this, toWorkplane.ZAxis); _i = rebasedVector.I; _j = rebasedVector.J; _k = rebasedVector.K; }
/// <summary> /// Rebases the Point from the specified workplane to the world. /// </summary> /// <param name="fromWorkplane">Workplane from which to rebase the point.</param> public void RebaseFromWorkplane(Workplane fromWorkplane) { MM x = _x; MM y = _y; MM z = _z; X = x * fromWorkplane.XAxis.I + y * fromWorkplane.YAxis.I + z * fromWorkplane.ZAxis.I; Y = x * fromWorkplane.XAxis.J + y * fromWorkplane.YAxis.J + z * fromWorkplane.ZAxis.J; Z = x * fromWorkplane.XAxis.K + y * fromWorkplane.YAxis.K + z * fromWorkplane.ZAxis.K; X += fromWorkplane.Origin.X; Y += fromWorkplane.Origin.Y; Z += fromWorkplane.Origin.Z; }
/// <summary> /// Rebases this vector from a specified workplane to the world. /// </summary> /// <param name="fromWorkplane">Workplane from which to rebase vector.</param> public void RebaseFromWorkplane(Workplane fromWorkplane) { Vector rebasedVector = new Vector(); double i = _i; double j = _j; double k = _k; rebasedVector.I = i * fromWorkplane.XAxis.I + j * fromWorkplane.YAxis.I + k * fromWorkplane.ZAxis.I; rebasedVector.J = i * fromWorkplane.XAxis.J + j * fromWorkplane.YAxis.J + k * fromWorkplane.ZAxis.J; rebasedVector.K = i * fromWorkplane.XAxis.K + j * fromWorkplane.YAxis.K + k * fromWorkplane.ZAxis.K; _i = rebasedVector.I; _j = rebasedVector.J; _k = rebasedVector.K; }
/// <summary> /// Creates a workplane based on information in a text file /// </summary> /// <param name="wpDataFile"></param> /// <returns></returns> public static DG.Workplane CreateWorkplaneFromFile(File wpDataFile) { List <string> wpLines = wpDataFile.ReadTextLines(); string wpOrigin = wpLines[0].Substring(wpLines[0].IndexOf(":") + 1).Trim(); string xVect = wpLines[1].Substring(wpLines[0].IndexOf(":") + 1).Trim(); string yVect = wpLines[2].Substring(wpLines[0].IndexOf(":") + 1).Trim(); string zVect = wpLines[3].Substring(wpLines[0].IndexOf(":") + 1).Trim(); Regex r = new Regex(@"\s+"); //strip multiple spaces wpOrigin = r.Replace(wpOrigin, @" "); xVect = r.Replace(xVect, @" "); yVect = r.Replace(yVect, @" "); zVect = r.Replace(zVect, @" "); System.Globalization.CultureInfo lCurrentCulture = System.Threading.Thread.CurrentThread.CurrentCulture; DG.Workplane dgWp = null; try { // Ensure always reading in English System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture; dgWp = new DG.Workplane(new DG.Point(wpOrigin), new DG.Vector(xVect, ' '), new DG.Vector(yVect, ' '), new DG.Vector(zVect, ' ')); } catch { } finally { System.Threading.Thread.CurrentThread.CurrentCulture = lCurrentCulture; } return(dgWp); }
/// <summary> /// Returns a clone of this Workplane. /// </summary> public Workplane Clone() { Workplane cloneWorkplane = new Workplane(_origin.Clone(), XAxis.Clone(), YAxis.Clone(), ZAxis.Clone()); return(cloneWorkplane); }