mirror of
https://github.com/NGSolve/netgen.git
synced 2025-01-13 14:40:35 +05:00
* Face Colours - Bugfix - Black (RGB: 0,0,0) is also a valid colour for a face!!
This commit is contained in:
parent
63cacb0343
commit
6e65bbe80a
@ -15,6 +15,8 @@ namespace netgen
|
|||||||
// default colour
|
// default colour
|
||||||
#define DEFAULT_BCNUM 0
|
#define DEFAULT_BCNUM 0
|
||||||
|
|
||||||
|
// Default tolerance for colour matching (using Euclidean distance)
|
||||||
|
#define DEFAULT_EPS 2.5e-05
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -29,10 +31,9 @@ namespace netgen
|
|||||||
colours match is defined as "eps" and is currently
|
colours match is defined as "eps" and is currently
|
||||||
2.5e-5 (for square of distance)
|
2.5e-5 (for square of distance)
|
||||||
*/
|
*/
|
||||||
bool ColourMatch(Vec3d col1, Vec3d col2)
|
bool ColourMatch(Vec3d col1, Vec3d col2, double eps = DEFAULT_EPS)
|
||||||
{
|
{
|
||||||
// Match tolerance - Adjust if required
|
if(eps <= 0.0) eps = DEFAULT_EPS;
|
||||||
double eps = 2.5e-5;
|
|
||||||
|
|
||||||
bool colmatch = false;
|
bool colmatch = false;
|
||||||
|
|
||||||
@ -207,7 +208,7 @@ namespace netgen
|
|||||||
|
|
||||||
// Get the colour of the face being currently processed
|
// Get the colour of the face being currently processed
|
||||||
face_colour = mesh.GetFaceDescriptor(face_index).SurfColour();
|
face_colour = mesh.GetFaceDescriptor(face_index).SurfColour();
|
||||||
if((face_colour.Length2()) && (!ColourMatch(face_colour,Vec3d(DEFAULT_R,DEFAULT_G,DEFAULT_B))))
|
if(!ColourMatch(face_colour,Vec3d(DEFAULT_R,DEFAULT_G,DEFAULT_B)))
|
||||||
{
|
{
|
||||||
// Boolean variable to check if the boundary condition was applied
|
// Boolean variable to check if the boundary condition was applied
|
||||||
// or not... not applied would imply that the colour of the face
|
// or not... not applied would imply that the colour of the face
|
||||||
@ -316,7 +317,7 @@ namespace netgen
|
|||||||
Vec3d face_colour;
|
Vec3d face_colour;
|
||||||
|
|
||||||
face_colour = mesh.GetFaceDescriptor(face_index).SurfColour();
|
face_colour = mesh.GetFaceDescriptor(face_index).SurfColour();
|
||||||
if((face_colour.Length2()) && (!ColourMatch(face_colour,Vec3d(DEFAULT_R,DEFAULT_G,DEFAULT_B))))
|
if(!ColourMatch(face_colour,Vec3d(DEFAULT_R,DEFAULT_G,DEFAULT_B)))
|
||||||
{
|
{
|
||||||
for(int i = 1; i <= all_colours.Size(); i++)
|
for(int i = 1; i <= all_colours.Size(); i++)
|
||||||
{
|
{
|
||||||
@ -348,7 +349,7 @@ namespace netgen
|
|||||||
Vec3d face_colour;
|
Vec3d face_colour;
|
||||||
|
|
||||||
face_colour = mesh.GetFaceDescriptor(face_index).SurfColour();
|
face_colour = mesh.GetFaceDescriptor(face_index).SurfColour();
|
||||||
if((face_colour.Length2()) && (!ColourMatch(face_colour,Vec3d(DEFAULT_R,DEFAULT_G,DEFAULT_B))))
|
if(!ColourMatch(face_colour,Vec3d(DEFAULT_R,DEFAULT_G,DEFAULT_B)))
|
||||||
{
|
{
|
||||||
for(int i = 0; i < colours_sorted.Size(); i++)
|
for(int i = 0; i < colours_sorted.Size(); i++)
|
||||||
{
|
{
|
||||||
@ -388,7 +389,15 @@ namespace netgen
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
//void OCCAutoColourBcProps(Mesh & mesh, OCCGeometry & occgeometry, const char * bccolourfile)
|
/*! Philippose - 13/07/2009
|
||||||
|
Main function implementing automated assignment of
|
||||||
|
Boundary Condition numbers based on face colours
|
||||||
|
|
||||||
|
This functionality is currently implemtented at the mesh
|
||||||
|
level, and hence allows colour based assignment of boundary
|
||||||
|
conditions for any geometry type within netgen which
|
||||||
|
supports face colours
|
||||||
|
*/
|
||||||
void AutoColourBcProps(Mesh & mesh, const char * bccolourfile)
|
void AutoColourBcProps(Mesh & mesh, const char * bccolourfile)
|
||||||
{
|
{
|
||||||
// Go directly to the alternate algorithm if no colour profile file was specified
|
// Go directly to the alternate algorithm if no colour profile file was specified
|
||||||
@ -396,7 +405,8 @@ namespace netgen
|
|||||||
{
|
{
|
||||||
AutoColourAlg_Sorted(mesh);
|
AutoColourAlg_Sorted(mesh);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
ifstream ocf(bccolourfile);
|
ifstream ocf(bccolourfile);
|
||||||
|
|
||||||
// If there was an error opening the Colour profile file, jump to the alternate
|
// If there was an error opening the Colour profile file, jump to the alternate
|
||||||
@ -416,3 +426,4 @@ namespace netgen
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user