From e6a6ab89e638ff4e9edf7f9527998740ce4654b5 Mon Sep 17 00:00:00 2001 From: Christopher Lackner Date: Mon, 4 Oct 2021 09:27:33 +0200 Subject: [PATCH] write transparency in mesh file and also read it if avail The indexing is a little weird but consistent to before so leave it like this --- libsrc/meshing/bcfunctions.cpp | 6 +++--- libsrc/meshing/meshclass.cpp | 39 ++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/libsrc/meshing/bcfunctions.cpp b/libsrc/meshing/bcfunctions.cpp index a1cad516..fd7441ad 100644 --- a/libsrc/meshing/bcfunctions.cpp +++ b/libsrc/meshing/bcfunctions.cpp @@ -259,12 +259,12 @@ namespace netgen if(bc_index == 0) { PrintMessage(3, "BC Property: ",DEFAULT_BCNUM); - // PrintMessage(3, " RGB Face Colour = ",ref_colour,"","\n"); + PrintMessage(3, " RGB Face Colour = ",Vec3d{ref_colour[0], ref_colour[1], ref_colour[2]},"","\n"); } else if(bc_used.Elem(bc_index)) { PrintMessage(3, "BC Property: ",bc_num.Elem(bc_index)); - // PrintMessage(3, " RGB Face Colour = ",ref_colour,"","\n"); + PrintMessage(3, " RGB Face Colour = ",Vec3d{ref_colour[0], ref_colour[1], ref_colour[2]},"","\n"); } } } @@ -401,7 +401,7 @@ namespace netgen PrintMessage(3, "BC Property: ",i + DEFAULT_BCNUM); PrintMessage(3, " Nr. of Surface Elements = ", faces_sorted[i]); PrintMessage(3, " Colour Index = ", colours_sorted[i]); - // PrintMessage(3, " RGB Face Colour = ",ref_colour,"","\n"); + PrintMessage(3, " RGB Face Colour = ",Vec3d{ref_colour[0], ref_colour[1], ref_colour[2]},"","\n"); } } diff --git a/libsrc/meshing/meshclass.cpp b/libsrc/meshing/meshclass.cpp index 2a3c1895..7ffa7f09 100644 --- a/libsrc/meshing/meshclass.cpp +++ b/libsrc/meshing/meshclass.cpp @@ -1080,6 +1080,15 @@ namespace netgen outfile << GetFaceDescriptor(i).SurfColour()[2]; outfile << endl; } + + outfile << "face_transparencies" << endl << cnt_facedesc << endl; + for(i = 1; i <= cnt_facedesc; i++) + { + outfile.width(8); + outfile << GetFaceDescriptor(i).SurfNr()+1 << " "; + outfile.width(12); + outfile << GetFaceDescriptor(i).SurfColour()[3] << endl; + } } outfile << endl << endl << "endmesh" << endl << endl; @@ -1570,6 +1579,36 @@ namespace netgen } } + if (strcmp (str, "face_transparencies") == 0) + { + int cnt_facedesc = GetNFD(); + infile >> n; + int index = 1; + if(n == cnt_facedesc) + { + for(int index = 1; index <= n; index++) + { + int surfnr; + double transp; + infile >> surfnr >> transp; + surfnr--; + if(surfnr > 0) + { + for(int facedesc = 1; facedesc <= cnt_facedesc; facedesc++) + { + if(surfnr == GetFaceDescriptor(facedesc).SurfNr()) + { + auto& fd = GetFaceDescriptor(facedesc); + auto scol = fd.SurfColour(); + scol[3] = transp; + fd.SetSurfColour(scol); + } + } + } + } + } + } + if (strcmp (str, "endmesh") == 0) endmesh = true;