public void GetBoundariesFromAMeshWithFiveBoundariesTest() { DMTModel modelToZone = DMTModelReader.ReadFile(new File(TestFiles.FetchTestFile("MeshForBoundaryCount.dmt"))); var boundaries = modelToZone.Boundaries(); Assert.AreEqual(boundaries.Count, 5, "Failed to calculate Boundaries. Mesh only has five boundaries."); }
public void GetBoundaryNodesTest() { DMTModel modelToZone = DMTModelReader.ReadFile(new File(TestFiles.FetchTestFile("BaseLeftFootTopSurface.dmt"))); var boundaryNodes = modelToZone.BoundaryNodes(); Assert.AreEqual(boundaryNodes.Count, 313, "Failed to calculate BoundaryNodes."); }
public void ProjectPointsTest() { DMTModel modelToZone = DMTModelReader.ReadFile(new File(TestFiles.SmallModel)); var nearestPoint = modelToZone.ProjectPoint(new Point(-28.186, -4.1135, 1000)); Assert.AreNotEqual(nearestPoint, null); }
public void GetBoundariesFromAMeshWithOneBoundaryTest() { DMTModel modelToZone = DMTModelReader.ReadFile(new File(TestFiles.FetchTestFile("BaseLeftFootTopSurface.dmt"))); var boundaries = modelToZone.Boundaries(); Assert.AreEqual(boundaries.Count, 1, "Failed to calculate Boundaries. Mesh should have only one boundary."); }
public void CreateMeshFromDMTTest() { // Create DMT model DMTModel dmt = DMTModelReader.ReadFile(new FileSystem.File(TestFiles.SINGLE_SURFACE_DMT)); // Create mesh from dmt _powerSHAPE.ActiveModel.Meshes.CreateMeshFromDMT(dmt); Assert.AreEqual(_powerSHAPE.ActiveModel.Meshes.Count, 1, "Failed to add mesh to collection"); }
public void WhenMoveByVector_ThenAllBlocksShouldBeMoved() { DMTModel modelToMove = DMTModelReader.ReadFile(new File(TestFiles.SmallModel)); var movement = new Vector(1, 4, 2); var originalVertices = modelToMove.TriangleBlocks[0].Vertices.Cast <DMTVertex>().ToList(); originalVertices.ForEach(x => x.Position = x.Position + movement); modelToMove.Move(movement); var newVertices = modelToMove.TriangleBlocks[0].Vertices.Cast <DMTVertex>().ToList(); CollectionAssert.AreEqual(originalVertices, newVertices); }
public void DMTPointProjectionTest() { // Ensures result of projecting a known point is as expected. DMTModel dmtModel = DMTModelReader.ReadFile(new File(TestFiles.FetchTestFile("Point Projection.dmt"))); // testPoint correlates with PowerSHAPE model. var testPoint = new Point(0, 0, 998.465026855469); // NOTE: ProjectPoints(...) is implicitly tested by a call to ProjectPoint(...). Point projectedPoint = dmtModel.ProjectPoint(new Point(0, 0, 2000)); Assert.AreEqual(testPoint, projectedPoint); Assert.Pass(); }
public void WhenAppendingBinarySTLFile_ThenCheckOutput() { DMTModel importedModel = DMTModelReader.ReadFile(new File(TestFiles.NormalStl)); // Ensure that model is loaded correctly Assert.AreEqual(importedModel.BoundingBox.MaxX, -54); Assert.AreEqual(importedModel.BoundingBox.MaxY, 111); Assert.AreEqual(importedModel.BoundingBox.MaxZ, 70); Assert.AreEqual(importedModel.BoundingBox.MinX, -124); Assert.AreEqual(importedModel.BoundingBox.MinY, 41); Assert.AreEqual(importedModel.BoundingBox.MinZ, 0); Assert.AreEqual(importedModel.TotalNoOfTriangles, 12); Assert.AreEqual(importedModel.TotalNoOfVertices, 8); }
public void WhenReadingDMTWithTwoTriangleBlocks_ThenCheckOutput() { var inputFile = new File(TestFiles.FetchTestFile("TwoBlocks.dmt")); DMTModel mainMesh = DMTModelReader.ReadFile(inputFile); Assert.AreEqual(4, mainMesh.TotalNoOfTriangles); Assert.AreEqual(8, mainMesh.TotalNoOfVertices); Assert.AreEqual(-62.08, Math.Round(mainMesh.BoundingBox.MinX, 2)); Assert.AreEqual(78.64, Math.Round(mainMesh.BoundingBox.MaxX, 2)); Assert.AreEqual(5.70, Math.Round(mainMesh.BoundingBox.MinY, 2)); Assert.AreEqual(76.08, Math.Round(mainMesh.BoundingBox.MaxY, 2)); Assert.AreEqual(0, Math.Truncate(mainMesh.BoundingBox.MinZ)); Assert.AreEqual(0, Math.Truncate(mainMesh.BoundingBox.MaxZ)); }
public void WhenAppendingDMTFile_ThenCheckOutput() { DMTModel importedModel = DMTModelReader.ReadFile(new File(TestFiles.NormalDmt)); // Ensure that model is loaded correctly Assert.AreEqual(-54, importedModel.BoundingBox.MaxX.Value); Assert.AreEqual(111, importedModel.BoundingBox.MaxY.Value); Assert.AreEqual(70, importedModel.BoundingBox.MaxZ.Value); Assert.AreEqual(-124, importedModel.BoundingBox.MinX.Value); Assert.AreEqual(41, importedModel.BoundingBox.MinY.Value); Assert.AreEqual(0, importedModel.BoundingBox.MinZ.Value); Assert.AreEqual(12, importedModel.TotalNoOfTriangles); Assert.AreEqual(8, importedModel.TotalNoOfVertices); Assert.AreEqual(8, importedModel.TriangleBlocks.First().VertexNormals.Count); }
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); }
/// <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; }
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(); }
public void AddTriangleTest() { var model = new DMTModel(); var block = new DMTTriangleBlock(); model.AddTriangleBlock(block); block.AddTriangle(new Point(-119, 6, 0), new Point(-50, 67, 0), new Point(-13, 4, 0)); block.AddTriangle(new Point(-13, 4, 0), new Point(-50, 67, 0), new Point(47, 58, 0)); // Ensure that model is written correctly Assert.AreEqual(model.BoundingBox.MaxX, 47); Assert.AreEqual(model.BoundingBox.MaxY, 67); Assert.AreEqual(model.BoundingBox.MaxZ, 0); Assert.AreEqual(model.BoundingBox.MinX, -119); Assert.AreEqual(model.BoundingBox.MinY, 4); Assert.AreEqual(model.BoundingBox.MinZ, 0); Assert.AreEqual(block.NoOfTriangles, 2); Assert.AreEqual(block.NoOfVertices, 6); }
/// <summary> /// Exports the model into a DMT file and then reads the DMT model into a DMTModel object. /// </summary> public DMTModel ToDMTModel() { try { // Export the model to a temporary file FileSystem.File tempFile = FileSystem.File.CreateTemporaryFile("dmt"); WriteToDMTFile(tempFile); // Read the file in as a DMT Object DMTModel objDMTModel = DMTModelReader.ReadFile(tempFile); // Delete the file tempFile.Delete(); return(objDMTModel); } catch { return(null); } }
/// <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); } }