public void ShowModels(List<MeshRecord> meshes)
 {
     int sz = meshes.Count > 4 ? 4 : meshes.Count;
     MeshRecord[] r = new MeshRecord[4];
     for (int i = 0; i < sz; ++i)
     {
         r[i] = meshes[i];
     }
     this.meshView1.SetModel(r[0]);
     this.meshView2.SetModel(r[1]);
     this.meshView3.SetModel(r[2]);
     this.meshView4.SetModel(r[3]);
 }
        public void OpenMeshFile()
        {
            openFileDialog1.FileName = "";
            openFileDialog1.Filter = "Mesh files (*.obj)|*.obj";
            openFileDialog1.CheckFileExists = true;

            DialogResult ret = openFileDialog1.ShowDialog(this);

            if (ret == DialogResult.OK)
            {
                StreamReader sr = new StreamReader(openFileDialog1.FileName);
                Mesh m = new Mesh(sr);
                sr.Close();
                MeshRecord rec = new MeshRecord(openFileDialog1.FileName, m);

                meshes.Add(rec);
                currentMeshRecord = rec;
                TabPage page = new TabPage(rec.ToString());
                page.Tag = rec;
                tabControlModelList.TabPages.Add(page);
                tabControlModelList.SelectedTab = page;
                meshView1.SetModel(rec);
                propertyGridModel.SelectedObject = rec;
                PrintText("Loaded mesh " + openFileDialog1.FileName + "\n");

                // ----------------------------------------------------------------------
                // initialize the harminic field
                // ----------------------------------------------------------------------
                CrossBoundaryBrushes.Option opt = new CrossBoundaryBrushes.Option();
                opt.Part_Type = true;
                currentMeshRecord.CrossBoundaryBrushes =
                    new CrossBoundaryBrushes(currentMeshRecord.Mesh, opt);
                currentMeshRecord.CrossBoundaryBrushes.InitialHarminicField();

                this.meshView1.Refresh();

            }
        }
 private void tabControlModelList_Selected(object sender, TabControlEventArgs e)
 {
     if (tabControlModelList.SelectedTab != null)
     {
         MeshRecord rec = (MeshRecord)tabControlModelList.SelectedTab.Tag;
         meshView1.SetModel(rec);
         propertyGridModel.SelectedObject = rec;
         currentMeshRecord = rec;
     }
     else
     {
         meshView1.SetModel(null);
         propertyGridModel.SelectedObject = null;
         currentMeshRecord = null;
     }
 }
 private void buttonCloseTab_Click(object sender, EventArgs e)
 {
     if (currentMeshRecord != null)
     {
         meshes.Remove(currentMeshRecord);
         currentMeshRecord = (MeshRecord)tabControlModelList.SelectedTab.Tag;
     }
     CloseTab();
 }
 public void SetModel(MeshRecord rec)
 {
     if (currMeshRecord != null)
         currMeshRecord.ModelViewMatrix = currTransformation;
     if (rec != null)
         currTransformation = rec.ModelViewMatrix;
     currMeshRecord = rec;
     this.Refresh();
 }