private static void test05() //****************************************************************************80 // // Purpose: // // TEST05 tests STLA_FACE_NORMAL_COMPUTE. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 21 September 2005 // // Author: // // John Burkardt // { const int FACE_NUM = 12; const int NODE_NUM = 8; int face; int[] face_node = { 1, 3, 2, 2, 3, 4, 1, 6, 5, 1, 2, 6, 3, 7, 4, 4, 7, 8, 5, 6, 8, 5, 8, 7, 1, 5, 7, 1, 7, 3, 2, 4, 6, 6, 4, 8 }; double[] face_normal = { 0.0, 0.0, -1.0, 0.0, 0.0, -1.0, 0.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, +1.0, 0.0, 0.0, +1.0, 0.0, 0.0, 0.0, +1.0, 0.0, 0.0, +1.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, +1.0, 0.0, 0.0, +1.0, 0.0, 0.0 }; double[] node_xyz = { 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0 }; STL_ASCII.STLData data = new(); const int offset = 1; STL_ASCII.stla_offset_set(ref data, offset); Console.WriteLine(""); Console.WriteLine("TEST05"); Console.WriteLine(" STLA_FACE_NORMAL_COMPUTE computes the face normal"); Console.WriteLine(" vectors for an STLA file."); Console.WriteLine(""); Console.WriteLine(" We have an STLA solid, and its exact normals."); Console.WriteLine(" We now call STLA_FACE_NORMAL_COMPUTE to"); Console.WriteLine(" recompute the normals."); double[] face_normal2 = STL_ASCII.stla_face_normal_compute(ref data, NODE_NUM, FACE_NUM, node_xyz, face_node); Console.WriteLine(""); Console.WriteLine(" We print out the maximum error, defined as"); Console.WriteLine(" |1 - dot ( n1, n2 )|"); Console.WriteLine(" where n1 and n2 are the exact and computed normals."); double dot_max = 0.0; for (face = 0; face < FACE_NUM; face++) { dot_max = Math.Max(dot_max, Math.Abs(1.0 - typeMethods.r8vec_dot(3, face_normal, face_normal2, +face * 3, +face * 3))); } Console.WriteLine(""); Console.WriteLine(" Maximum error = " + dot_max + ""); }
private static void test04(string output_file_name) //****************************************************************************80 // // Purpose: // // TEST04 tests STLA_WRITE. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 13 September 2005 // // Author: // // John Burkardt // { const int FACE_NUM = 12; const int NODE_NUM = 8; int[] face_node = { 1, 3, 2, 2, 3, 4, 1, 6, 5, 1, 2, 6, 3, 7, 4, 4, 7, 8, 5, 6, 8, 5, 8, 7, 1, 5, 7, 1, 7, 3, 2, 4, 6, 6, 4, 8 }; double[] face_normal = { 0.0, 0.0, -1.0, 0.0, 0.0, -1.0, 0.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, +1.0, 0.0, 0.0, +1.0, 0.0, 0.0, 0.0, +1.0, 0.0, 0.0, +1.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, +1.0, 0.0, 0.0, +1.0, 0.0, 0.0 }; double[] node_xyz = { 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0 }; STL_ASCII.STLData data = new(); Console.WriteLine(""); Console.WriteLine("TEST04"); Console.WriteLine(" STLA_WRITE writes an ASCII STL file."); const int offset = 1; STL_ASCII.stla_offset_set(ref data, offset); STL_ASCII.stla_write(ref data, output_file_name, NODE_NUM, FACE_NUM, node_xyz, face_node, face_normal); Console.WriteLine(""); Console.WriteLine(" Graphics data was written to the STLA file \"" + output_file_name + "\"."); }