예제 #1
0
        /***************************************************/

        // Mesh the model.
        public void MeshModel(Rhino.RhinoDoc doc, MeshUtil.GmshParams gmshParams, string gmshPath, bool reducedIntegration)
        {
            if (this._GmshFileBuilt)
            {
                throw new Exception("A file has been created for this model. Run the analysis with GmshRunFromFile to execute the alrady created file.");
            }

            this.BuildGmshFile(doc, gmshParams);
            this.MeshModelFromFile(gmshPath, reducedIntegration);
        }
예제 #2
0
        /***************************************************/

        // Build CalculiX input file.
        public virtual void BuildGmshFile(Rhino.RhinoDoc doc, MeshUtil.GmshParams gmshParams)
        {
            doc.Views.RedrawEnabled = false;

            // Hide all existing Rhino objects.
            Rhino.DocObjects.ObjectEnumeratorSettings all;
            all = new Rhino.DocObjects.ObjectEnumeratorSettings();
            all.ObjectTypeFilter = Rhino.DocObjects.ObjectType.AnyObject;
            foreach (Rhino.DocObjects.RhinoObject ro in doc.Objects.GetObjectList(all))
            {
                doc.Objects.Hide(ro.Id, true);
            }

            // Add bar curves to Rhino.
            for (int i = this._bars.Count - 1; i >= 0; i--)
            {
                doc.Objects.Add(this._bars[i].Curve);
            }

            // Add panel surfaces to Rhino.
            for (int i = this._panels.Count - 1; i >= 0; i--)
            {
                doc.Objects.Add(this._panels[i].Surface);
            }

            // Export the geometry to .iges files.
            string curveFilePath   = this.GetModelFilePath() + "_Curves.iges";
            string surfaceFilePath = this.GetModelFilePath() + "_Surfaces.iges";

            if (File.Exists(curveFilePath))
            {
                File.Delete(curveFilePath);
            }
            if (File.Exists(surfaceFilePath))
            {
                File.Delete(surfaceFilePath);
            }

            string exportCrvCom = "-_export _selcrv _enter \"" + curveFilePath + "\" _enter";
            string exportSrfCom = "-_export _selsrf _enter \"" + surfaceFilePath + "\" _enter";

            Rhino.RhinoApp.RunScript(exportCrvCom, false);
            Rhino.RhinoApp.RunScript(exportSrfCom, false);
            Rhino.RhinoDoc.ActiveDoc.Views.RedrawEnabled = true;

            string name = this._name;

            if (this._directory == GuanacoUtil.TempDir)
            {
                name += this.GetTempSuffix();
            }

            System.IO.TextWriter tw = new System.IO.StreamWriter(this.GetModelFilePath(GuanacoUtil.FileType.geo));
            foreach (String s in MeshUtil.GmshInput(name, doc.ModelAbsoluteTolerance, gmshParams))
            {
                tw.WriteLine(s);
            }
            tw.Close();

            this._GmshFileBuilt = true;
        }