/// <summary> /// Loads a model from the specified path. /// </summary> /// <param name="path">The path.</param> /// <returns> /// A model. /// </returns> /// <exception cref="System.InvalidOperationException">File format not supported.</exception> public Model3DGroup Load(string path) { if (path == null) { return(null); } Model3DGroup model; var ext = Path.GetExtension(path); if (ext != null) { ext = ext.ToLower(); } switch (ext) { case ".3ds": { var r = new StudioReader(); model = r.Read(path); break; } case ".lwo": { var r = new LwoReader { DefaultMaterial = this.DefaultMaterial }; model = r.Read(path); break; } case ".obj": { var r = new ObjReader { DefaultMaterial = this.DefaultMaterial }; model = r.Read(path); break; } case ".objz": { var r = new ObjReader { DefaultMaterial = this.DefaultMaterial }; model = r.ReadZ(path); break; } case ".stl": { var r = new StLReader { DefaultMaterial = this.DefaultMaterial }; model = r.Read(path); break; } case ".off": { var r = new OffReader { DefaultMaterial = this.DefaultMaterial }; model = r.Read(path); break; } default: throw new InvalidOperationException("File format not supported."); } return(model); }
/// <summary> /// Loads a model from the specified path. /// </summary> /// <param name="path">The path.</param> /// <param name="dispatcher">The dispatcher used to create the model.</param> /// <param name="freeze">Freeze the model if set to <c>true</c>.</param> /// <returns>A model.</returns> /// <exception cref="System.InvalidOperationException">File format not supported.</exception> public Model3DGroup Load(string path, Dispatcher dispatcher = null, bool freeze = false) { if (path == null) { return(null); } if (dispatcher == null) { dispatcher = Dispatcher.CurrentDispatcher; } Model3DGroup model; var ext = Path.GetExtension(path); if (ext != null) { ext = ext.ToLower(); } switch (ext) { case ".3ds": { var r = new StudioReader(dispatcher) { DefaultMaterial = this.DefaultMaterial, Freeze = freeze }; model = r.Read(path, ApplyNormalToFace); break; } case ".lwo": { var r = new LwoReader(dispatcher) { DefaultMaterial = this.DefaultMaterial, Freeze = freeze }; model = r.Read(path); break; } case ".obj": { var r = new ObjReader(dispatcher) { DefaultMaterial = this.DefaultMaterial, Freeze = freeze }; model = r.Read(path); break; } case ".objz": { var r = new ObjReader(dispatcher) { DefaultMaterial = this.DefaultMaterial, Freeze = freeze }; model = r.ReadZ(path); break; } case ".stl": { var r = new StLReader(dispatcher) { DefaultMaterial = this.DefaultMaterial, Freeze = freeze }; model = r.Read(path); break; } case ".off": { var r = new OffReader(dispatcher) { DefaultMaterial = this.DefaultMaterial, Freeze = freeze }; model = r.Read(path); break; } default: throw new InvalidOperationException("File format not supported."); } //if (!freeze) //{ // dispatcher.Invoke(new Action(() => model.SetName(Path.GetFileName(path)))); //} return(model); }
public void Load(string fileName) { this.off = new OffReader(); using (var s = File.OpenRead(fileName)) { this.off.Load(s); } this.Levels = 1; this.UpdateModel(); view1.ZoomExtents(); }
public void Load(string fileName) { this.off = new OffReader(); this.off.Load(fileName); Levels = 1; UpdateModel(); view1.ZoomExtents(); }
/// <summary> /// Loads a model from the specified path. /// </summary> /// <param name="path"> /// The path. /// </param> /// <returns> /// A model. /// </returns> public static Model3DGroup Load(string path) { if (path == null) { return null; } Model3DGroup model = null; string ext = Path.GetExtension(path).ToLower(); switch (ext) { case ".3ds": { var r = new StudioReader(); model = r.Read(path); break; } case ".lwo": { var r = new LwoReader(); model = r.Read(path); break; } case ".obj": { var r = new ObjReader(); model = r.Read(path); break; } case ".objz": { var r = new ObjReader(); model = r.ReadZ(path); break; } case ".stl": { var r = new StLReader(); model = r.Read(path); break; } case ".off": { var r = new OffReader(); model = r.Read(path); break; } default: throw new InvalidOperationException("File format not supported."); } return model; }
/// <summary> /// Loads a model from the specified path. /// </summary> /// <param name="path">The path.</param> /// <param name="dispatcher">The dispatcher used to create the model.</param> /// <param name="freeze">Freeze the model if set to <c>true</c>.</param> /// <returns>A model.</returns> /// <exception cref="System.InvalidOperationException">File format not supported.</exception> public Model3DGroup Load(string path, Dispatcher dispatcher = null, bool freeze = false) { if (path == null) { return null; } if (dispatcher == null) { dispatcher = Dispatcher.CurrentDispatcher; } Model3DGroup model; var ext = Path.GetExtension(path); if (ext != null) { ext = ext.ToLower(); } switch (ext) { case ".3ds": { var r = new StudioReader(dispatcher) { DefaultMaterial = this.DefaultMaterial, Freeze = freeze }; model = r.Read(path); break; } case ".lwo": { var r = new LwoReader(dispatcher) { DefaultMaterial = this.DefaultMaterial, Freeze = freeze }; model = r.Read(path); break; } case ".obj": { var r = new ObjReader(dispatcher) { DefaultMaterial = this.DefaultMaterial, Freeze = freeze }; model = r.Read(path); break; } case ".objz": { var r = new ObjReader(dispatcher) { DefaultMaterial = this.DefaultMaterial, Freeze = freeze }; model = r.ReadZ(path); break; } case ".stl": { var r = new StLReader(dispatcher) { DefaultMaterial = this.DefaultMaterial, Freeze = freeze }; model = r.Read(path); break; } case ".off": { var r = new OffReader(dispatcher) { DefaultMaterial = this.DefaultMaterial, Freeze = freeze }; model = r.Read(path); break; } default: throw new InvalidOperationException("File format not supported."); } //if (!freeze) //{ // dispatcher.Invoke(new Action(() => model.SetName(Path.GetFileName(path)))); //} return model; }
public static Model3DGroup Load(string path, Dispatcher dispatcher = null, bool freeze = false, bool ignoreErrors = false) { if (path == null) { return null; } var defaultMaterial = Materials.Blue; if (dispatcher == null) { dispatcher = Dispatcher.CurrentDispatcher; } Model3DGroup model; var ext = Path.GetExtension(path).ToLower(); switch (ext) { case ".3ds": { var r = new StudioReader(dispatcher) { DefaultMaterial = defaultMaterial, Freeze = freeze }; model = r.Read(path); break; } case ".lwo": { var r = new LwoReader(dispatcher) { DefaultMaterial = defaultMaterial, Freeze = freeze }; model = r.Read(path); break; } case ".obj": { var r = new ObjReader(dispatcher) { DefaultMaterial = defaultMaterial, Freeze = freeze, IgnoreErrors = ignoreErrors }; model = r.Read(path); break; } case ".objx": { var r = new ObjReader(dispatcher) { DefaultMaterial = defaultMaterial, Freeze = freeze, IgnoreErrors = ignoreErrors }; model = r.ReadZ(path); break; } case ".stl": { var r = new StLReader(dispatcher) { DefaultMaterial = defaultMaterial, Freeze = freeze }; model = r.Read(path); break; } case ".off": { var r = new OffReader(dispatcher) { DefaultMaterial = defaultMaterial, Freeze = freeze }; model = r.Read(path); break; } default: throw new InvalidOperationException("File format not supported."); } return model; }