/// <summary> /// Called prior to loading the vert data. Allocates the memory arrays to hold /// the pristine vertex data. /// </summary> /// <param name="Format">Which type of vertex this mesh uses.</param> /// <param name="Count">How many verts are in the mesh.</param> public void AllocateVertexBuffer(MeshFormat Format, int Count) { m_MeshFormat = Format; m_VertexCount = Count; if (m_MeshFormat == MeshFormat.Model) { //local (non-DX) copy of verts m_ModelVerts = new MODEL_VERT[Count]; for (int i = 0; i < Count; i++) { m_ModelVerts[i] = new MODEL_VERT(); } //allocate DX buffer (this is the one that will get recreated on device reset) m_VertexBuffer = new VertexBuffer(typeof(CustomVertex.PositionNormalTextured), m_ModelVerts.Length, MdxRender.Dev, Usage.Dynamic | Usage.WriteOnly, CustomVertex.PositionNormalTextured.Format, Pool.Default); } else if (m_MeshFormat == MeshFormat.Bsp) { //local (non-DX) copy of verts m_BspVerts = new PositionTexture2[Count]; for (int i = 0; i < Count; i++) { m_BspVerts[i] = new PositionTexture2(); } //allocate DX buffer (this is the one that will get recreated on device reset) m_VertexBuffer = new VertexBuffer(typeof(PositionTexture2), m_BspVerts.Length, MdxRender.Dev, Usage.WriteOnly, PositionTexture2.Format, Pool.Default); } //add an event handler to recreate verts on device reset m_VertexBuffer.Created += new EventHandler(this.OnVertexBufferCreate); }
public void Clear() { this.ReturnCode = 0; this.MeshChanged = false; this.Nodes = string.Empty; this.Simples = string.Empty; this.Volume = string.Empty; this.Electrodes = string.Empty; this.output_mesh = MeshFormat.Invalid; this.layout = string.Empty; }
private void Load() { try { XmlDocument doc = new XmlDocument(); doc.Load(this.path); XmlElement root = doc.DocumentElement; this.ReturnCode = int.Parse(root["return_code"].InnerText, CultureInfo.InvariantCulture); this.Nodes = root["nodes"].InnerText; this.Simples = root["simples"].InnerText; this.Volume = root["volume"].InnerText; this.Electrodes = root["electrodes"].InnerText; this.layout = root["layout"].InnerText; this.MeshChanged = int.Parse(root["mesh_changed"].InnerText, CultureInfo.InvariantCulture) == 1; switch (int.Parse(root["output_format"].InnerText, CultureInfo.InvariantCulture)) { case 0: this.output_mesh = MeshFormat.NETGEN; break; case 1: this.output_mesh = MeshFormat.WinRECO; break; default: this.output_mesh = MeshFormat.Invalid; break; } } catch (Exception) { this.Clear(); } }
private void LoadXML() { this.doc = new XmlDocument(); this.doc.Load(this.path); this.mesh_format = MeshFormat.Invalid; this.mesg_available = false; if (int.Parse(this.doc.SelectSingleNode("TomoKISStudio/Paths/i3DmeshFileType").InnerText, CultureInfo.InvariantCulture) == 1) { this.mesh_format = MeshFormat.WinRECO; } if (int.Parse(this.doc.SelectSingleNode("TomoKISStudio/Paths/i3DmeshFileType").InnerText, CultureInfo.InvariantCulture) == 0) { this.mesh_format = MeshFormat.NETGEN; } if (this.doc.SelectSingleNode("TomoKISStudio/Paths/d3DMesh_LayoutFile") == null) { this.layout_file = string.Empty; } else { this.layout_file = this.doc.SelectSingleNode("TomoKISStudio/Paths/d3DMesh_LayoutFile").InnerText; if (!File.Exists(this.layout_file)) { this.layout_file = string.Empty; } } this.electr_radius = this.screen_radius = 0; try { this.electr_radius = double.Parse(doc.SelectSingleNode("TomoKISStudio/Paths/d3DMesh_ElecSurfRadius").InnerText, CultureInfo.InvariantCulture); this.screen_radius = double.Parse(doc.SelectSingleNode("TomoKISStudio/Paths/d3DMesh_ScreenSurfRadius").InnerText, CultureInfo.InvariantCulture); } catch { } if (this.mesh_format == MeshFormat.NETGEN) { this.volume = this.doc.SelectSingleNode("TomoKISStudio/Paths/s3DMeshFileName_Netgen").InnerText; if (!File.Exists(this.volume)) { this.mesg_available = false; return; } this.mesg_available = true; return; } if (this.mesh_format == MeshFormat.WinRECO) { this.nodes = this.doc.SelectSingleNode("TomoKISStudio/Paths/s3DMeshFileName_vtx").InnerText; this.simples = this.doc.SelectSingleNode("TomoKISStudio/Paths/s3DMeshFileName_smpl_Elec").InnerText; if (!File.Exists(this.nodes) || !File.Exists(this.simples)) { this.mesg_available = false; return; } this.mesg_available = true; return; } }