* 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
This commit is contained in:
Philippose Rajan 2009-07-10 11:59:24 +00:00
parent 2b4e7aad8f
commit 04cb56a8ff

View File

@ -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) if (strcmp (str, "endmesh") == 0)
endmesh = true; endmesh = true;