예제 #1
0
        public void WhenAppendingBinarySTLFile_ThenEnsureDuplicatePointsRemoval()
        {
            var      inputFile = new File(TestFiles.FetchTestFile("GetTrianglesByMesh.stl"));
            DMTModel mainMesh  = DMTModelReader.ReadFile(inputFile);

            Assert.AreEqual(944, mainMesh.TotalNoOfTriangles);
            Assert.AreEqual(944, mainMesh.TotalNoOfVertices);

            var exportedFile = File.CreateTemporaryFile("stl", true);

            DMTModelWriter.WriteFile(mainMesh, exportedFile);

            DMTModel exportedMesh = DMTModelReader.ReadFile(inputFile);

            Assert.AreEqual(944, exportedMesh.TotalNoOfTriangles);
            Assert.AreEqual(944, exportedMesh.TotalNoOfVertices);
        }
예제 #2
0
        /// <summary>
        /// Creates a new Mesh from a DMT Model.
        /// </summary>
        /// <param name="powerSHAPE">This is the PowerSHAPE Automation object.</param>
        /// <param name="model">The DMT model from which to create the model.</param>
        internal PSMesh(PSAutomation powerSHAPE, DMTModel model) : base(powerSHAPE)
        {
            // Write the DMT to a temporary file
            FileSystem.File tempFile = FileSystem.File.CreateTemporaryFile("dmt");
            DMTModelWriter.WriteFile(model, tempFile);

            // Import the DMT into PowerSHAPE
            _powerSHAPE.DoCommand("FILE IMPORT '" + tempFile.Path + "'");

            // Delete the temporary file
            tempFile.Delete();

            PSMesh newMesh = (PSMesh)_powerSHAPE.ActiveModel.CreatedItems[0];

            // Set the Id
            _id = newMesh.Id;
        }
예제 #3
0
        public void WhenWritingSTLFileFromDMTFile_ThenCheckOutput()
        {
            DMTModel importedModel = DMTModelReader.ReadFile(new File(TestFiles.NormalDmt));
            var      outputFile    = new File(string.Format("{0}\\output.stl", Path.GetTempPath()));

            DMTModelWriter.WriteFile(importedModel, outputFile);
            DMTModel writtenModel = DMTModelReader.ReadFile(outputFile);

            // Ensure that model is written correctly
            Assert.AreEqual(importedModel.BoundingBox.MaxX, writtenModel.BoundingBox.MaxX);
            Assert.AreEqual(importedModel.BoundingBox.MaxY, writtenModel.BoundingBox.MaxY);
            Assert.AreEqual(importedModel.BoundingBox.MaxZ, writtenModel.BoundingBox.MaxZ);
            Assert.AreEqual(importedModel.BoundingBox.MinX, writtenModel.BoundingBox.MinX);
            Assert.AreEqual(importedModel.BoundingBox.MinY, writtenModel.BoundingBox.MinY);
            Assert.AreEqual(importedModel.BoundingBox.MinZ, writtenModel.BoundingBox.MinZ);

            outputFile.Delete();
        }
예제 #4
0
        /// <summary>
        /// Creates a reference surface model from a DMTModel.
        /// </summary>
        /// <param name="DMT">The DMTModel to set as a reference surface model.</param>
        public PMModel CreateReferenceModel(DMTModel DMT)
        {
            try
            {
                PMModel newModel = null;

                // Write the DMT Model to a file
                File tempFile = File.CreateTemporaryFile("dmt");
                DMTModelWriter.WriteFile(DMT, tempFile);

                // Then import it into PowerMILL (this includes adding it to the list)
                newModel = CreateReferenceModel(tempFile);

                // Delete the file
                tempFile.Delete();
                return(newModel);
            }
            catch
            {
                return(null);
            }
        }