public void AmfFilesSaveObjectProperties() { AssetObject3D.AssetManager = new AssetManager(); var scene = new InteractiveScene(); scene.Children.Add(new Object3D { Mesh = PlatonicSolids.CreateCube(20, 20, 20), Name = "test1", OutputType = PrintOutputTypes.Support, Color = Color.Red, MaterialIndex = 2, }); scene.Children.Add(new Object3D { Mesh = PlatonicSolids.CreateCube(20, 20, 20), Name = "test2", Matrix = Matrix4X4.CreateTranslation(30, 0, 0) }); string tempPath = GetSceneTempPath(); Object3D.AssetsPath = Path.Combine(tempPath, "Assets"); string filePath = Path.Combine(tempPath, "exportTest.amf"); scene.SetSelection(scene.Children.ToList()); AmfDocument.Save(scene.SelectedItem, filePath); Assert.IsTrue(File.Exists(filePath)); IObject3D loadedItem = Object3D.Load(filePath, CancellationToken.None); Assert.IsTrue(loadedItem.Children.Count == 2); IObject3D item1 = loadedItem.Children.Last(); Assert.AreEqual("test1", item1.Name); Assert.AreEqual(PrintOutputTypes.Support, item1.OutputType); Assert.AreEqual(2, item1.MaterialIndex); Assert.AreEqual(Color.Red, item1.Color); Assert.AreEqual(12, item1.Mesh.Faces.Count); var aabb1 = item1.GetAxisAlignedBoundingBox(); Assert.True(new AxisAlignedBoundingBox(-10, -10, -10, 10, 10, 10).Equals(aabb1, .001)); IObject3D item2 = loadedItem.Children.First(); Assert.AreEqual("test2", item2.Name); Assert.AreEqual(Color.White, item2.Color); Assert.AreEqual(12, item2.Mesh.Faces.Count); var aabb2 = item2.GetAxisAlignedBoundingBox(); Assert.True(new AxisAlignedBoundingBox(20, -10, -10, 40, 10, 10).Equals(aabb2, .001)); }
private void CreateSampleFile() { var root = new Object3D(); root.Children.Add(new Object3D() { Mesh = PolygonMesh.PlatonicSolids.CreateCube(10, 5, 2) }); AmfDocument.Save( root, @"c:\temp\sample.amf"); }
public void NoElementWhitespaceTest() { // Amf xml lacking whitespace between elements string xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?><amf unit=\"millimeter\" version=\"1.1\"><object id=\"1\"><mesh><vertices><vertex><coordinates><x>-5</x><y>-2.5</y><z>1</z></coordinates></vertex><vertex><coordinates><x>-5</x><y>2.5</y><z>1</z></coordinates></vertex><vertex><coordinates><x>-5</x><y>-2.5</y><z>-1</z></coordinates></vertex><vertex><coordinates><x>-5</x><y>2.5</y><z>-1</z></coordinates></vertex><vertex><coordinates><x>5</x><y>-2.5</y><z>1</z></coordinates></vertex><vertex><coordinates><x>5</x><y>2.5</y><z>1</z></coordinates></vertex><vertex><coordinates><x>5</x><y>-2.5</y><z>-1</z></coordinates></vertex><vertex><coordinates><x>5</x><y>2.5</y><z>-1</z></coordinates></vertex></vertices><volume><triangle><v1>0</v1><v2>4</v2><v3>5</v3></triangle><triangle><v1>0</v1><v2>5</v2><v3>1</v3></triangle><triangle><v1>2</v1><v2>0</v2><v3>1</v3></triangle><triangle><v1>2</v1><v2>1</v2><v3>3</v3></triangle><triangle><v1>4</v1><v2>6</v2><v3>7</v3></triangle><triangle><v1>4</v1><v2>7</v2><v3>5</v3></triangle><triangle><v1>2</v1><v2>3</v2><v3>7</v3></triangle><triangle><v1>2</v1><v2>7</v2><v3>6</v3></triangle><triangle><v1>1</v1><v2>5</v2><v3>7</v3></triangle><triangle><v1>1</v1><v2>7</v2><v3>3</v3></triangle><triangle><v1>2</v1><v2>6</v2><v3>4</v3></triangle><triangle><v1>2</v1><v2>4</v2><v3>0</v3></triangle></volume></mesh></object></amf>"; // Wrap xml with MemoryStream, load, validate using (var memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(xml))) { var amfObject3D = AmfDocument.Load(memoryStream, CancellationToken.None); Assert.AreEqual(amfObject3D.Children.Count, 1); Assert.IsNotNull(amfObject3D.Children.First().Mesh); } }
public TemperatureTowerObject3D() { Name = "Temperature Tower".Localize(); Color = Color.White; if (shape == null) { using (Stream measureAmfStream = StaticData.Instance.OpenStream(Path.Combine("Stls", "CC - gaaZolee - AS.amf"))) { var amfObject = AmfDocument.Load(measureAmfStream, CancellationToken.None); shape = amfObject.Children.First().Mesh; } } }
public static long GetEstimatedMemoryUse(string fileLocation) { switch (Path.GetExtension(fileLocation).ToUpper()) { case ".STL": return(StlProcessing.GetEstimatedMemoryUse(fileLocation)); case ".AMF": return(AmfDocument.GetEstimatedMemoryUse(fileLocation)); case ".OBJ": throw new NotImplementedException(); } return(0); }