private void removeToolStripMenuItem1_Click(object sender, EventArgs e) { object selection = treeView1.SelectedNode.Tag; Translation trsl = (Translation)selection; TranslationCollection tc = (TranslationCollection)treeView1.SelectedNode.Parent.Tag; tc.Remove(trsl); treeView1.SelectedNode.Remove(); }
private void addToolStripMenuItem1_Click(object sender, EventArgs e) { object selection = treeView1.SelectedNode.Tag; Translation trsl = new Translation(); TranslationCollection tc = (TranslationCollection)selection; tc.Add(trsl); TreeNode tn = treeView1.SelectedNode.Nodes.Add(trsl.ToString()); tn.ContextMenuStrip = cmsOneTranslation; tn.Tag = trsl; treeView1.SelectedNode = tn; }
private void refreshToolStripMenuItem_Click(object sender, EventArgs e) { object selection = treeView1.SelectedNode.Tag; TranslationCollection tc = (TranslationCollection)selection; tc.Sort(); treeView1.SelectedNode.Nodes.Clear(); foreach (Translation trsl in tc) { TreeNode tn = treeView1.SelectedNode.Nodes.Add(trsl.ToString()); tn.Tag = trsl; tn.ContextMenuStrip = cmsOneTranslation; } model3.mc.Prepare(); glControl1.Invalidate(); }
// loads from proprietary binary format public void LoadFrame(Stream str, bool update = false) { BinaryReader br = new BinaryReader(str); // read properties isDeformable = br.ReadBoolean(); isIndenter = br.ReadBoolean(); isFloor = br.ReadBoolean(); bool _hide = br.ReadBoolean(); // discard name = br.ReadString(); int nNodes = br.ReadInt32(); int nElems = br.ReadInt32(); int nCZs = br.ReadInt32(); int nFaces = br.ReadInt32(); int nEdges = br.ReadInt32(); // make sure that List<> objects are filled with proper # of elements if (!update) { nodes.Clear(); nodes.Capacity = nNodes; for (int i = 0; i < nNodes; i++) { nodes.Add(new Node()); } elems.Clear(); elems.Capacity = nElems; for (int i = 0; i < nElems; i++) { elems.Add(new Element()); } czs.Clear(); czs.Capacity = nCZs; for (int i = 0; i < nCZs; i++) { czs.Add(new CZ()); } faces.Clear(); faces.Capacity = nFaces; for (int i = 0; i < nFaces; i++) { faces.Add(new Face()); } edges.Clear(); edges.Capacity = nEdges; for (int i = 0; i < nEdges; i++) { edges.Add(new GranuleEdge()); } } else { // Debug.Assert(nNodes == nodes.Count && nElems == elems.Count && nCZs == czs.Count && // nFaces == faces.Count && nEdges == edges.Count, "mesh update: incorrect count"); Debug.Assert(nNodes == nodes.Count, "mesh update: incorrect node count"); Debug.Assert(nElems == elems.Count, "mesh update: incorrect element count"); Debug.Assert(nFaces == faces.Count, "mesh update: incorrect face count"); Debug.Assert(nEdges == edges.Count, "mesh update: incorrect edge count"); Debug.Assert(nCZs == czs.Count, "mesh update: incorrect czs count"); } LoadSaveMemAlloc(); by_snapshot = br.ReadBytes(byteSize); // convert byte array to bool, int and double arrays Buffer.BlockCopy(by_snapshot, 0, isn, 0, iSize * sizeof(int)); int offset = iSize * sizeof(int); Buffer.BlockCopy(by_snapshot, offset, bsn, 0, bSize * sizeof(bool)); offset += bSize * sizeof(bool); Buffer.BlockCopy(by_snapshot, offset, dsn, 0, dSize * sizeof(double)); // restore nodes int i_off = 0, d_off = 0, b_off = 0; Parallel.For(0, nNodes, i => { Node nd = nodes[i]; nd.id = i; nd.x0 = dsn[i * ndd_str + 0]; nd.y0 = dsn[i * ndd_str + 1]; nd.z0 = dsn[i * ndd_str + 2]; nd.ux = dsn[i * ndd_str + 3]; nd.uy = dsn[i * ndd_str + 4]; nd.uz = dsn[i * ndd_str + 5]; nd.vx = dsn[i * ndd_str + 6]; nd.vy = dsn[i * ndd_str + 7]; nd.vz = dsn[i * ndd_str + 8]; nd.ax = dsn[i * ndd_str + 9]; nd.ay = dsn[i * ndd_str + 10]; nd.az = dsn[i * ndd_str + 11]; nd.fx = nd.fy = nd.fz = 0; nd.cx = nd.x0 + nd.ux; nd.cy = nd.y0 + nd.uy; nd.cz = nd.z0 + nd.uz; nd.tx = nd.ty = nd.tz = nd.unx = nd.uny = nd.unz = 0; }); d_off += ndd_str * nodes.Count; // elements Parallel.For(0, nElems, i => { Element elem = elems[i]; for (int j = 0; j < 4; j++) { elem.vrts[j] = nodes[isn[i * eli_str + j]]; } elem.granule = isn[i * eli_str + 4]; }); i_off += eli_str * elems.Count; // cohesive zones Parallel.For(0, nCZs, i => { CZ cz = czs[i]; for (int j = 0; j < 6; j++) { cz.vrts[j] = nodes[isn[i_off + i * czi_str + j]]; } cz.faces[0] = faces[isn[i_off + i * czi_str + 6]]; cz.faces[1] = faces[isn[i_off + i * czi_str + 7]]; cz.immutableID = isn[i_off + i * czi_str + 8]; cz.pmax[0] = dsn[d_off + i * czd_str + 0]; cz.pmax[1] = dsn[d_off + i * czd_str + 1]; cz.pmax[2] = dsn[d_off + i * czd_str + 2]; cz.tmax[0] = dsn[d_off + i * czd_str + 3]; cz.tmax[1] = dsn[d_off + i * czd_str + 4]; cz.tmax[2] = dsn[d_off + i * czd_str + 5]; cz.avgDn = dsn[d_off + i * czd_str + 6]; cz.avgDt = dsn[d_off + i * czd_str + 7]; cz.avgTn = dsn[d_off + i * czd_str + 8]; cz.avgTt = dsn[d_off + i * czd_str + 9]; cz.maxAvgDn = dsn[d_off + i * czd_str + 10]; cz.maxAvgDt = dsn[d_off + i * czd_str + 11]; cz.failed = bsn[b_off + i + 0]; }); b_off += czb_str * czs.Count; i_off += czi_str * czs.Count; d_off += czd_str * czs.Count; // faces Parallel.For(0, nFaces, i => { Face f = faces[i]; f.id = i; for (int j = 0; j < 3; j++) { f.vrts[j] = nodes[isn[i_off + i * fi_str + j]]; } f.granule = isn[i_off + i * fi_str + 3]; f.exposed = bsn[b_off + i * fb_str + 0]; f.created = bsn[b_off + i * fb_str + 1]; int elem_id = isn[i_off + i * fi_str + 4]; f.elem = elem_id < 0 ? null : elems[elem_id]; }); b_off += fb_str * faces.Count; i_off += fi_str * faces.Count; // edges Parallel.For(0, nEdges, i => { GranuleEdge ge = edges[i]; ge.vrts[0] = nodes[isn[i_off + i * gei_str + 0]]; ge.vrts[1] = nodes[isn[i_off + i * gei_str + 1]]; ge.exposed = bsn[b_off + i]; }); if (!update) { BoundingBox(); ComputeVolume(); } IFormatter bf = new BinaryFormatter(); surfaceFragments = (List <SurfaceFragment>)bf.Deserialize(str); object tcollObject = bf.Deserialize(str); translationCollection = (TranslationCollection)tcollObject; foreach (SurfaceFragment sf in surfaceFragments) { sf.allFaces = faces; sf.ComputeArea(); } }