From 04cb56a8ff86ffdcfe4c5ea28541b2449190fd63 Mon Sep 17 00:00:00 2001 From: Philippose Rajan Date: Fri, 10 Jul 2009 11:59:24 +0000 Subject: [PATCH] * Extended VOL format to include face colour data * Modified Mesh Save and Load functions to handle new type "face_colours" * Face colours handled as RGB triplets --- libsrc/meshing/meshclass.cpp | 62 ++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/libsrc/meshing/meshclass.cpp b/libsrc/meshing/meshclass.cpp index e49a554c..1b5d5077 100644 --- a/libsrc/meshing/meshclass.cpp +++ b/libsrc/meshing/meshclass.cpp @@ -771,6 +771,33 @@ namespace netgen } + // Philippose - 09/07/2009 + // Add mesh face colours to Netgen Vol file format + // The colours are saved in RGB triplets + int cnt_facedesc = GetNFD(); + if (cnt_facedesc) + { + outfile << endl << endl << "# Surfnr Red Green Blue" << endl; + outfile << "face_colours" << endl << cnt_facedesc << endl; + + outfile.precision(8); + outfile.setf(ios::fixed, ios::floatfield); + outfile.setf(ios::showpoint); + + for(i = 1; i <= cnt_facedesc; i++) + { + outfile.width(8); + outfile << GetFaceDescriptor(i).SurfNr()+1 << " "; + outfile.width(12); + outfile << GetFaceDescriptor(i).SurfColour().X() << " "; + outfile.width(12); + outfile << GetFaceDescriptor(i).SurfColour().Y() << " "; + outfile.width(12); + outfile << GetFaceDescriptor(i).SurfColour().Z(); + outfile << endl; + } + } + } @@ -1113,6 +1140,41 @@ namespace netgen } } + // Philippose - 09/07/2009 + // Add mesh face colours to Netgen Vol file format + // The colours are read in as RGB triplets + if (strcmp (str, "face_colours") == 0) + { + int cnt_facedesc = GetNFD(); + infile >> n; + if(n == cnt_facedesc) + { + for(i = 1; i <= n; i++) + { + int surfnr = 0; + Vec3d surfcolour(0.0,1.0,0.0); + + infile >> surfnr + >> surfcolour.X() + >> surfcolour.Y() + >> surfcolour.Z(); + + surfnr--; + + if(surfnr > 0) + { + for(int facedesc = 1; facedesc <= cnt_facedesc; facedesc++) + { + if(surfnr == GetFaceDescriptor(facedesc).SurfNr()) + { + GetFaceDescriptor(facedesc).SetSurfColour(surfcolour); + } + } + } + } + } + } + if (strcmp (str, "endmesh") == 0) endmesh = true;