using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using QuantumConcepts.Formats.StereoLithography; using System.Globalization; namespace QuantumConcepts.Formats.StereoLithography { /// A simple XYZ representation of a normal (). public class Normal : Vertex { /// Creates a new, empty . public Normal() : base() { } /// Creates a new using the provided coordinates. public Normal(float x, float y, float z) : base(x, y, z) { } /// Flips the normal so it faces the opposite direction. public void Invert() { this.X *= -1; this.Y *= -1; this.Z *= -1; } /// Returns the string representation of this . public override string ToString() { //return "normal {0} {1} {2}".FormatString(this.X, this.Y, this.Z); return String.Format(CultureInfo.InvariantCulture, "normal {0} {1} {2}", this.X, this.Y, this.Z); } /// Reads a single from the . /// The reader which contains a to be read at the current position public static Normal Read(StreamReader reader) { return Normal.FromVertex(Vertex.Read(reader)); } /// Reads a single from the . /// The reader which contains a to be read at the current position public static Normal Read(BinaryReader reader) { return Normal.FromVertex(Vertex.Read(reader)); } /// Converts the to a normal. /// This does nothing more than copy the X, Y and Z coordinates of the into a new instance. /// The to be converted into a . /// A or null if the is null. public static Normal FromVertex(Vertex vertex) { if (vertex == null) return null; return new Normal() { X = vertex.X, Y = vertex.Y, Z = vertex.Z }; } } }