public DPGeometryModel3DGroup LoadModel3DGroup(string xamlFile) { try { using (var fileStream = new FileStream(xamlFile, FileMode.Open, FileAccess.Read, FileShare.Read)) { using (var currentWork = new StepWork("Load 3D Mode", fileStream) { MaxSteps = fileStream.Length }) { using (var reader = new XmlTextReader(fileStream)) { if (!MoveToNextNode(reader, XmlNodeType.Element, "Model3DGroup")) { return(null); } var ret = new DPGeometryModel3DGroup(); if (!reader.IsEmptyElement) { while (true) { var geometryModel3D = LoadGeometryModel3D(reader); if (geometryModel3D == null) { break; } ret.GeometryModel3DList.Add(geometryModel3D); currentWork.CurrentStep = fileStream.Position; } } reader.Close(); return(ret); } } } } catch (Exception ex) { return(null); } }
public DPGeometryModel3DGroup GetSimplifiedGeometryModel3DGroup(UInt32 resolution) { var bounds = GetBounds(); if (bounds.IsEmpty) { return(null); } if (Double.IsNaN(bounds.SizeX) || Double.IsNaN(bounds.SizeY) || Double.IsNaN(bounds.SizeZ)) { return(null); } var max = Math.Max(bounds.SizeX, bounds.SizeY); var unitSize = Math.Max(max, bounds.SizeZ) / resolution; var ret = new DPGeometryModel3DGroup(); using (var currentWork = new StepWork("Compress 3D Mode", this) { MaxSteps = GeometryModel3DList.Count }) { foreach (var item in GeometryModel3DList) { var geometryModel3D = item.GetSimplifiedGeometryModel3D(unitSize); if (geometryModel3D != null) { ret.GeometryModel3DList.Add(geometryModel3D); } currentWork.CurrentStep++; } } return(ret); }