diff --git a/libsrc/meshing/Makefile.am b/libsrc/meshing/Makefile.am index 0dec170e..2bfbae19 100644 --- a/libsrc/meshing/Makefile.am +++ b/libsrc/meshing/Makefile.am @@ -8,7 +8,7 @@ topology.hpp boundarylayer.hpp global.hpp hpref_trig.hpp meshing.hpp \ validate.hpp classifyhpel.hpp hpref_hex.hpp improve2.hpp meshtool.hpp \ clusters.hpp hprefinement.hpp improve3.hpp meshtype.hpp \ hpref_prism.hpp localh.hpp msghandler.hpp curvedelems.hpp \ - hpref_pyramid.hpp meshclass.hpp ruler2.hpp + hpref_pyramid.hpp meshclass.hpp ruler2.hpp bcfunctions.hpp @@ -23,5 +23,5 @@ libmesh_la_SOURCES = adfront2.cpp adfront3.cpp bisect.cpp boundarylayer.cpp \ pyramid2rls.cpp pyramidrls.cpp quadrls.cpp refine.cpp \ ruler2.cpp ruler3.cpp secondorder.cpp smoothing2.5.cpp \ smoothing2.cpp smoothing3.cpp specials.cpp tetrarls.cpp \ - topology.cpp triarls.cpp validate.cpp zrefine.cpp \ + topology.cpp triarls.cpp validate.cpp zrefine.cpp bcfunctions.cpp \ parallelmesh.cpp paralleltop.cpp paralleltop.hpp diff --git a/libsrc/meshing/bcfunctions.cpp b/libsrc/meshing/bcfunctions.cpp new file mode 100644 index 00000000..6e67f856 --- /dev/null +++ b/libsrc/meshing/bcfunctions.cpp @@ -0,0 +1,418 @@ + +#include +#include + + +namespace netgen +{ + // Default colour to be used for boundary condition number "0" + #define DEFAULT_R 0.0 + #define DEFAULT_G 1.0 + #define DEFAULT_B 0.0 + + // Boundary condition number to use if a face does not have a + // colour assigned to it, or if the colour is the above defined + // default colour + #define DEFAULT_BCNUM 0 + + + + + + /*! Philippose - 11/07/2009 + Function to check if two RGB colours are equal + + Note#1: Currently uses unweighted Euclidean Distance + for colour matching. + + Note#2: The tolerance used for deciding whether two + colours match is defined as "eps" and is currently + 2.5e-5 (for square of distance) + */ + bool ColourMatch(Vec3d col1, Vec3d col2) + { + // Match tolerance - Adjust if required + double eps = 2.5e-5; + + bool colmatch = false; + + if(Dist2(col1,col2) < eps) colmatch = true; + + return colmatch; + } + + + + + + /*! Philippose - 11/07/2009 + Function to create a list of all the unique colours + available in a given mesh + */ + void GetFaceColours(Mesh & mesh, Array & face_colours) + { + face_colours.SetSize(1); + face_colours.Elem(1) = mesh.GetFaceDescriptor(1).SurfColour(); + + for(int i = 1; i <= mesh.GetNFD(); i++) + { + Vec3d face_colour = mesh.GetFaceDescriptor(i).SurfColour(); + bool col_found = false; + + for(int j = 1; j <= face_colours.Size(); j++) + { + if(ColourMatch(face_colours.Elem(j),face_colour)) + { + col_found = true; + break; + } + } + + if(!col_found) face_colours.Append(face_colour); + } + + if(printmessage_importance >= 3) + { + cout << endl << "-------- Face Colours --------" << endl; + for( int i = 1; i <= face_colours.Size(); i++) + { + cout << face_colours.Elem(i) << endl; + } + cout << "------------------------------" << endl; + } + } + + + + + + + /*! Philippose - 11/07/2009 + Assign boundary condition numbers based on a user defined + colour profile file. + + The default profile file is "netgen.ocf" + + If the mesh contains colours not defined in the profile, + netgen automatically starts assigning each new colour a + new boundary condition number starting from the highest + boundary condition number specified in the profile file. + */ + void AutoColourAlg_UserProfile(Mesh & mesh, ifstream & ocf) + { + char ocf_inp[100]; + bool header_found = false; + + // Number of colour specifications in the + // user profile file + int numentries = 0; + while((ocf.good()) && (!header_found)) + { + ocf >> ocf_inp; + if(strcmp(ocf_inp,"boundary_colours") == 0) header_found = true; + } + + if(!header_found) + { + throw NgException("AutoColourAlg_UserProfile: Invalid or empty Boundary Colour Profile file\n"); + return; + } + + // Read in the number of entries from file + ocf >> numentries; + if(numentries > 0) + { + if(!ocf.good()) + { + throw NgException("AutoColourAlg_UserProfile: Invalid or empty Boundary Colour Profile file\n"); + return; + } + + PrintMessage(3, "Number of colour entries: ", numentries); + } + else + { + PrintMessage(3, "AutoColourAlg_UserProfile: No Boundary Colour entries found.... no changes made!"); + ocf.close(); + return; + } + + // Arrays to hold the specified RGB colour triplets as well + // as the associated boundary condition number + Array bc_colours(numentries); + Array bc_num(numentries); + + // Actually read in the data from the file + for(int i = 1; i <= numentries; i++) + { + int bcnum; + double col_red, col_green, col_blue; + + ocf >> bcnum; + // Boundary condition number 0 is reserved for + // faces which have the default colour Green (0.0,1.0,0.0) + if(bcnum < 1) bcnum = 1; + + bc_num.Elem(i) = bcnum; + ocf >> bc_colours.Elem(i).X() + >> bc_colours.Elem(i).Y() + >> bc_colours.Elem(i).Z(); + + if(!ocf.good()) + throw NgException("Boundary Colour file error: Number of entries do not match specified list size!!\n"); + + // Bound checking of the values + // The RGB values should be between 0.0 and 1.0 + if(bc_colours.Elem(bcnum).X() < 0.0) bc_colours.Elem(bcnum).X() = 0.0; + if(bc_colours.Elem(bcnum).X() > 1.0) bc_colours.Elem(bcnum).X() = 1.0; + if(bc_colours.Elem(bcnum).Y() < 0.0) bc_colours.Elem(bcnum).X() = 0.0; + if(bc_colours.Elem(bcnum).Y() > 1.0) bc_colours.Elem(bcnum).X() = 1.0; + if(bc_colours.Elem(bcnum).Z() < 0.0) bc_colours.Elem(bcnum).X() = 0.0; + if(bc_colours.Elem(bcnum).Z() > 1.0) bc_colours.Elem(bcnum).X() = 1.0; + } + + PrintMessage(3, "Successfully loaded Boundary Colour Profile file...."); + ocf.close(); + + // Find the highest boundary condition number in the list + // All colours in the geometry which are not specified in the + // list will be given boundary condition numbers higher than this + // number + int max_bcnum = 0; + for(int i = 1; i <= bc_num.Size();i++) + { + if(bc_num.Elem(i) > max_bcnum) max_bcnum = bc_num.Elem(i); + } + + PrintMessage(3, "Highest boundary number in list = ",max_bcnum); + + Array all_colours; + + // Extract all the colours to see how many there are + GetFaceColours(mesh,all_colours); + PrintMessage(3,"\nNumber of colours defined in Mesh: ", all_colours.Size()); + + if(all_colours.Size() == 0) + { + PrintMessage(3,"No colour data detected in Mesh... no changes made!"); + return; + } + + int nfd = mesh.GetNFD(); + + for(int face_index = 1; face_index <= nfd; face_index++) + { + // Temporary container for individual face colours + Vec3d face_colour; + + // Get the colour of the face being currently processed + face_colour = mesh.GetFaceDescriptor(face_index).SurfColour(); + if((face_colour.Length2()) && (!ColourMatch(face_colour,Vec3d(DEFAULT_R,DEFAULT_G,DEFAULT_B)))) + { + // Boolean variable to check if the boundary condition was applied + // or not... not applied would imply that the colour of the face + // does not exist in the list of colours in the profile file + bool bc_assigned = false; + + for(int col_index = 1; col_index <= bc_colours.Size(); col_index++) + { + if((ColourMatch(face_colour,bc_colours.Elem(col_index))) && (!bc_assigned)) + { + mesh.GetFaceDescriptor(face_index).SetBCProperty(bc_num.Elem(col_index)); + bc_assigned = true; + break; + } + } + + // If the colour was not found in the list, add it to the list, and assign + // the next free boundary condition number to it + if(!bc_assigned) + { + max_bcnum++; + bc_num.Append(max_bcnum); + bc_colours.Append(face_colour); + + mesh.GetFaceDescriptor(face_index).SetBCProperty(max_bcnum); + } + } + else + { + // Set the boundary condition number to the default one + mesh.GetFaceDescriptor(face_index).SetBCProperty(DEFAULT_BCNUM); + } + } + } + + + + + + /*! Philippose - 11/07/2009 + Assign boundary condition numbers based on the colours + assigned to each face in the mesh using an automated + algorithm. + + The particular algorithm used has been briefly explained + in the header file "occauxfunctions.hpp" + */ + void AutoColourAlg_Sorted(Mesh & mesh) + { + Array all_colours; + Array faces_sorted; + Array colours_sorted; + + // Extract all the colours to see how many there are + GetFaceColours(mesh,all_colours); + + // Delete the default colour from the list since it will be accounted + // for automatically + for(int i = 1; i <= all_colours.Size(); i++) + { + if(ColourMatch(all_colours.Elem(i),Vec3d(DEFAULT_R,DEFAULT_G,DEFAULT_B))) + { + all_colours.DeleteElement(i); + break; + } + } + PrintMessage(3,"\nNumber of colours defined in Mesh: ", all_colours.Size()); + + if(all_colours.Size() == 0) + { + PrintMessage(3,"No colour data detected in Mesh... no changes made!"); + return; + } + + // One more slot than the number of colours are required, to + // account for individual faces which have no colour data + // assigned to them in the CAD software + faces_sorted.SetSize(all_colours.Size()+1); + colours_sorted.SetSize(all_colours.Size()+1); + faces_sorted = 0; + + // Slave Array to identify the colours the faces were assigned to, + // after the bubble sort routine to sort the automatic boundary + // identifiers according to the number of surface mesh elements + // of a given colour + for(int i = 0; i <= all_colours.Size(); i++) colours_sorted[i] = i; + + // Used to hold the number of surface elements without any OCC + // colour definition + int no_colour_faces = 0; + + // Index in the faces array assigned to faces without any + // or the default colour definition + int no_colour_index = 0; + + int nfd = mesh.GetNFD(); + + // Extract the number of surface elements having a given colour + // And save this number into an array for later sorting + for(int face_index = 1; face_index <= nfd; face_index++) + { + Array se_face; + + mesh.GetSurfaceElementsOfFace(face_index, se_face); + + Vec3d face_colour; + + face_colour = mesh.GetFaceDescriptor(face_index).SurfColour(); + if((face_colour.Length2()) && (!ColourMatch(face_colour,Vec3d(DEFAULT_R,DEFAULT_G,DEFAULT_B)))) + { + for(int i = 1; i <= all_colours.Size(); i++) + { + if(ColourMatch(face_colour, all_colours.Elem(i))) + { + faces_sorted[i] = faces_sorted[i] + se_face.Size(); + } + } + } + else + { + // Add the number of surface elements without any colour + // definition separately + no_colour_faces = no_colour_faces + se_face.Size(); + } + } + + // Sort the face colour indices according to the number of surface + // mesh elements which have a specific colour + BubbleSort(faces_sorted,colours_sorted); + + // Now update the array position assigned for surface elements + // without any colour definition with the number of elements + faces_sorted[no_colour_index] = no_colour_faces; + + // Now actually assign the BC Property to the respective faces + for(int face_index = 1; face_index <= nfd; face_index++) + { + Vec3d face_colour; + + face_colour = mesh.GetFaceDescriptor(face_index).SurfColour(); + if((face_colour.Length2()) && (!ColourMatch(face_colour,Vec3d(DEFAULT_R,DEFAULT_G,DEFAULT_B)))) + { + for(int i = 0; i < colours_sorted.Size(); i++) + { + Vec3d ref_colour; + if(i != no_colour_index) ref_colour = all_colours.Elem(colours_sorted[i]); + + if(ColourMatch(face_colour, ref_colour)) + { + mesh.GetFaceDescriptor(face_index).SetBCProperty(i); + } + } + } + else + { + mesh.GetFaceDescriptor(face_index).SetBCProperty(DEFAULT_BCNUM); + } + + PrintMessage(4,"Face number: ",face_index," ; BC Property = ",mesh.GetFaceDescriptor(face_index).BCProperty()); + } + + // User Information of the results of the operation + PrintMessage(3,"Colour based Boundary Condition Property details:"); + for(int i = 0; i < faces_sorted.Size(); i++) + { + Vec3d ref_colour(0.0,1.0,0.0); + + if(colours_sorted[i] > 0) ref_colour = all_colours.Elem(colours_sorted[i]); + + PrintMessage(3, "BC Property: ",i); + PrintMessage(3, " Nr. of Surface Elements = ", faces_sorted[i]); + PrintMessage(3, " Colour Index = ", colours_sorted[i]); + PrintMessage(3, " RGB Face Colour = ",ref_colour,"","\n"); + } + } + + + + + + //void OCCAutoColourBcProps(Mesh & mesh, OCCGeometry & occgeometry, const char * bccolourfile) + void AutoColourBcProps(Mesh & mesh, const char * bccolourfile) + { + // Go directly to the alternate algorithm if no colour profile file was specified + if(!bccolourfile) + { + AutoColourAlg_Sorted(mesh); + } + + ifstream ocf(bccolourfile); + + // If there was an error opening the Colour profile file, jump to the alternate + // algorithm after printing a message + if(!ocf) + { + PrintMessage(1,"AutoColourBcProps: Error loading Boundary Colour Profile file ", + bccolourfile, " ....","Switching to alternate algorithm!"); + + AutoColourAlg_Sorted(mesh); + } + // If the file opens successfully, call the function which assigns boundary conditions + // based on the colour profile file + else + { + AutoColourAlg_UserProfile(mesh, ocf); + } + } +} diff --git a/libsrc/meshing/bcfunctions.hpp b/libsrc/meshing/bcfunctions.hpp new file mode 100644 index 00000000..ddfaeecf --- /dev/null +++ b/libsrc/meshing/bcfunctions.hpp @@ -0,0 +1,49 @@ +#ifndef FILE_BCFUNCTIONS +#define FILE_BCFUNCTIONS + +// Philippose - 14/03/2009 +// Auxiliary functions for OCC Geometry +// Use this file and the corresponding ".cpp" +// file to add miscellaneous functionality +// to the OpenCascade Geometry support in Netgen +namespace netgen +{ + /*! \brief Automatically assign boundary conditions for meshes + + This function allows the boundary condition numbers of a + mesh created in Netgen to be automatically assigned based on + the colours of each face. + + Currently, two algorithms are utilised to assign the BC Properties: + 1. Automatic assignment using a user defined colour profile file + which defines which RGB colours are to be assigned to which + BC Property number + - A default profile file exists in the Netgen folder called + "netgen.ocf" + + 2. The second algorithm uses the following automated algorithm: + - Extract all the colours present in the mesh + - Use colour index 0 (zero) for all faces with no colour defined + - Calculate the number of faces of the surface mesh for each colour + - Sort the number of surface elements in ascending order, with the + colour indices as a slave + - Use the indices of the sorted array as the BC property number + + Example: If there are 3 colours, present in the mesh and the number + of surface elements for each colour are: + - Colour 0: 8500 + - Colour 1: 120 + - Colour 2: 2200 + - Colour 3: 575 + + The above is sorted in ascending order and assigned as BC Properties: + - BC Prop 0: 120 : Colour 1 + - BC Prop 1: 575 : Colour 3 + - BC Prop 2: 2200 : Colour 2 + - BC Prop 3: 8500 : Colour 0 (no colour defined) + */ + //extern void OCCAutoColourBcProps(Mesh & mesh, OCCGeometry & occgeometry, const char *occcolourfile); + extern void AutoColourBcProps(Mesh & mesh, const char *bccolourfile); +} +#endif + diff --git a/libsrc/occ/Makefile.am b/libsrc/occ/Makefile.am index 43e528e7..dc19174e 100644 --- a/libsrc/occ/Makefile.am +++ b/libsrc/occ/Makefile.am @@ -1,4 +1,4 @@ -noinst_HEADERS = occauxfunctions.hpp occgeom.hpp occmeshsurf.hpp \ +noinst_HEADERS = occgeom.hpp occmeshsurf.hpp \ Partition_Inter2d.hxx Partition_Loop2d.hxx Partition_Loop.hxx \ Partition_Inter3d.hxx Partition_Loop3d.hxx Partition_Spliter.hxx \ Partition_Inter2d.ixx Partition_Loop2d.ixx Partition_Loop.ixx \ @@ -18,4 +18,4 @@ noinst_LTLIBRARIES = libocc.la libocc_la_SOURCES = Partition_Inter2d.cxx Partition_Inter3d.cxx \ Partition_Loop.cxx Partition_Loop2d.cxx Partition_Loop3d.cxx Partition_Spliter.cxx \ - occconstruction.cpp occgenmesh.cpp occgeom.cpp occmeshsurf.cpp occauxfunctions.cpp + occconstruction.cpp occgenmesh.cpp occgeom.cpp occmeshsurf.cpp diff --git a/libsrc/occ/occauxfunctions.cpp b/libsrc/occ/occauxfunctions.cpp deleted file mode 100644 index f1eadb05..00000000 --- a/libsrc/occ/occauxfunctions.cpp +++ /dev/null @@ -1,304 +0,0 @@ -#ifdef OCCGEOMETRY - -#include -#include - -#include - -namespace netgen -{ - void OCCAutoColourAlg_UserProfile(Mesh & mesh, OCCGeometry & occgeometry, ifstream & ocf) - { - int numentries = 0; - - ocf >> numentries; - if(numentries > 0) - { - if(!ocf.good()) - { - throw NgException("OCCAutoColourAlg_UserProfile: Invalid or empty Boundary Colour Profile file\n"); - return; - } - - PrintMessage(3, "Number of colour entries: ", numentries); - } - else - { - PrintMessage(3, "OCCAutoColourAlg_UserProfile: No Boundary Colour entries found.... no changes made!"); - ocf.close(); - return; - } - - Array bc_colours(numentries); - Array bc_num(numentries); - - for(int i = 1; i <= numentries; i++) - { - int bcnum; - double col_red, col_green, col_blue; - - ocf >> bcnum; - if(bcnum < 1) bcnum = 1; - - bc_num.Elem(i) = bcnum; - ocf >> bc_colours.Elem(i).X() - >> bc_colours.Elem(i).Y() - >> bc_colours.Elem(i).Z(); - - if(!ocf.good()) - throw NgException("Boundary Colour file error: Number of entries do not match specified list size!!\n"); - - if(bc_colours.Elem(bcnum).X() < 0.0) bc_colours.Elem(bcnum).X() = 0.0; - if(bc_colours.Elem(bcnum).X() > 1.0) bc_colours.Elem(bcnum).X() = 1.0; - if(bc_colours.Elem(bcnum).Y() < 0.0) bc_colours.Elem(bcnum).X() = 0.0; - if(bc_colours.Elem(bcnum).Y() > 1.0) bc_colours.Elem(bcnum).X() = 1.0; - if(bc_colours.Elem(bcnum).Z() < 0.0) bc_colours.Elem(bcnum).X() = 0.0; - if(bc_colours.Elem(bcnum).Z() > 1.0) bc_colours.Elem(bcnum).X() = 1.0; - } - - PrintMessage(3, "Successfully loaded Boundary Colour Profile file...."); - ocf.close(); - - // Find the highest boundary condition number in the list - // All colours in the geometry which are not specified in the - // list will be given boundary condition numbers higher than this - // number - int max_bcnum = 0; - for(int i = 1; i <= bc_num.Size();i++) - { - if(bc_num.Elem(i) > max_bcnum) max_bcnum = bc_num.Elem(i); - } - - PrintMessage(3, "Highest boundary number in list = ",max_bcnum); - - TDF_LabelSequence all_colours; - - // Extract all the colours to see how many there are - occgeometry.face_colours->GetColors(all_colours); - PrintMessage(3,"\nNumber of colours defined in OCC Mesh: ", all_colours.Length()); - - if(all_colours.Length() == 0) - { - PrintMessage(3,"No colour data detected in OCC Mesh... no changes made!"); - return; - } - - int nfd = mesh.GetNFD(); - - for(int face_index = 1; face_index <= nfd; face_index++) - { - // Note: From the logic in file "occgenmesh.cpp", function "FindEdges" - // the Face Descriptor Number of an OCC face has a one-to-one mapping - // to the face number in the OCC face map (fmap) - TopoDS_Face face = TopoDS::Face(occgeometry.fmap(face_index)); - Quantity_Color face_colour; - - if(occgeometry.face_colours->GetColor(face,XCAFDoc_ColorSurf,face_colour)) - { - // Boolean variable to check if the boundary condition was applied - // or not... not applied would imply that the colour of the face - // does not exist in the list of colours in the profile file - bool bc_assigned = false; - - for(int col_index = 1; col_index <= bc_colours.Size(); col_index++) - { - Quantity_Color bc_colour; - - double col_red = bc_colours.Elem(col_index).X(); - double col_green = bc_colours.Elem(col_index).Y(); - double col_blue = bc_colours.Elem(col_index).Z(); - - bc_colour.SetValues(col_red,col_green,col_blue,Quantity_TOC_RGB); - - if((face_colour == bc_colour) && (!bc_assigned)) - { - mesh.GetFaceDescriptor(face_index).SetBCProperty(bc_num.Elem(col_index)); - bc_assigned = true; - break; - } - } - - // If the colour was not found in the list, add it to the list, and assign - // the next free boundary condition number to it - if(!bc_assigned) - { - double col_red = face_colour.Red(); - double col_green = face_colour.Green(); - double col_blue = face_colour.Blue(); - - Vec3d new_colour(col_red,col_green,col_blue); - - max_bcnum++; - bc_num.Append(max_bcnum); - bc_colours.Append(new_colour); - - mesh.GetFaceDescriptor(face_index).SetBCProperty(max_bcnum); - } - } - else - { - mesh.GetFaceDescriptor(face_index).SetBCProperty(0); - } - } - } - - - - void OCCAutoColourAlg_Sorted(Mesh & mesh, OCCGeometry & occgeometry) - { - TDF_LabelSequence all_colours; - Array faces_sorted; - Array colours_sorted; - - // Extract all the colours to see how many there are - occgeometry.face_colours->GetColors(all_colours); - PrintMessage(3,"\nNumber of colours defined in OCC Mesh: ", all_colours.Length()); - - if(all_colours.Length() == 0) - { - PrintMessage(3,"No colour data detected in OCC Mesh... no changes made!"); - return; - } - - // One more slot than the number of colours are required, to - // account for individual faces which have no colour data - // assigned to them in the CAD software - faces_sorted.SetSize(all_colours.Length()+1); - colours_sorted.SetSize(all_colours.Length()+1); - faces_sorted = 0; - - // Slave Array to identify the colours the faces were assigned to, - // after the bubble sort routine to sort the automatic boundary - // identifiers according to the number of surface mesh elements - // of a given colour - for(int i = 0; i <= all_colours.Length(); i++) colours_sorted[i] = i; - - // Used to hold the number of surface elements without any OCC - // colour definition - int no_colour_faces = 0; - - // Index in the faces array assigned to faces without an - // OCC Colour definition - int no_colour_index = 0; - - int nfd = mesh.GetNFD(); - - // Extract the number of surface elements having a given OCC colour - // And save this number into an array for later sorting - for(int face_index = 1; face_index <= nfd; face_index++) - { - Array se_face; - - mesh.GetSurfaceElementsOfFace(face_index, se_face); - - // Note: From the logic in file "occgenmesh.cpp", function "FindEdges" - // the Face Descriptor Number of an OCC face has a one-to-one mapping - // to the face number in the OCC face map (fmap) - TopoDS_Face face = TopoDS::Face(occgeometry.fmap(face_index)); - Quantity_Color face_colour; - - if(occgeometry.face_colours->GetColor(face,XCAFDoc_ColorSurf,face_colour)) - { - for(int i = 1; i <= all_colours.Length(); i++) - { - Quantity_Color ref_colour; - occgeometry.face_colours->GetColor(all_colours.Value(i),ref_colour); - if(face_colour == ref_colour) - { - faces_sorted[i] = faces_sorted[i] + se_face.Size(); - } - } - } - else - { - // Add the number of surface elements without any colour - // definition separately - no_colour_faces = no_colour_faces + se_face.Size(); - } - } - - // Sort the face colour indices according to the number of surface - // mesh elements which have a specific colour - BubbleSort(faces_sorted,colours_sorted); - - // Now update the array position assigned for surface elements - // without any colour definition with the number of elements - faces_sorted[no_colour_index] = no_colour_faces; - - // Now actually assign the BC Property to the respective faces - for(int face_index = 1; face_index <= nfd; face_index++) - { - TopoDS_Face face = TopoDS::Face(occgeometry.fmap(face_index)); - Quantity_Color face_colour; - - if(occgeometry.face_colours->GetColor(face,XCAFDoc_ColorSurf,face_colour)) - { - for(int i = 0; i < colours_sorted.Size(); i++) - { - Quantity_Color ref_colour; - if(i != no_colour_index) - occgeometry.face_colours->GetColor(all_colours.Value(colours_sorted[i]),ref_colour); - - if(face_colour == ref_colour) - { - mesh.GetFaceDescriptor(face_index).SetBCProperty(i); - } - } - } - else - { - mesh.GetFaceDescriptor(face_index).SetBCProperty(no_colour_index); - } - - PrintMessage(4,"Face number: ",face_index," ; BC Property = ",mesh.GetFaceDescriptor(face_index).BCProperty()); - } - - // User Information of the results of the operation - PrintMessage(3,"OCC Colour based Boundary Condition Property details:"); - for(int i = 0; i < faces_sorted.Size(); i++) - { - Quantity_Color ref_colour; - - ref_colour.SetValues(1.0,1.0,0.0,Quantity_TOC_RGB); - - if(colours_sorted[i] > 0) occgeometry.face_colours->GetColor(all_colours.Value(colours_sorted[i]),ref_colour); - - PrintMessage(3, "BC Property: ",i); - PrintMessage(3, " Nr. of Surface Elements = ", faces_sorted[i]); - PrintMessage(3, " OCC Colour Index = ", colours_sorted[i]); - PrintMessage(3, " RGB Face Colour = (",ref_colour.Red(),"," - ,ref_colour.Green(),"," - ,ref_colour.Blue(),")","\n"); - } - } - - - - void OCCAutoColourBcProps(Mesh & mesh, OCCGeometry & occgeometry, const char * occcolourfile) - { - // Go directly to the alternate algorithm if no colour profile file was specified - if(!occcolourfile) - { - OCCAutoColourAlg_Sorted(mesh,occgeometry); - } - - ifstream ocf(occcolourfile); - - // If there was an error opening the Colour profile file, jump to the alternate - // algorithm after printing a message - if(!ocf) - { - PrintMessage(1,"OCCAutoColourBcProps: Error loading Boundary Colour Profile file ", - occcolourfile, " ....","Switching to alternate algorithm!"); - - OCCAutoColourAlg_Sorted(mesh,occgeometry); - } - // If the file opens successfully, call the function which assigns boundary conditions - // based on the colour profile file - else - { - OCCAutoColourAlg_UserProfile(mesh,occgeometry,ocf); - } - } -} -#endif // #ifdef OCCGEOMETRY diff --git a/libsrc/occ/occauxfunctions.hpp b/libsrc/occ/occauxfunctions.hpp deleted file mode 100644 index 828dff6a..00000000 --- a/libsrc/occ/occauxfunctions.hpp +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef FILE_OCCAUXFUNCTIONS -#define FILE_OCCAUXFUNCTIONS - -// Philippose - 14/03/2009 -// Auxiliary functions for OCC Geometry -// Use this file and the corresponding ".cpp" -// file to add miscellaneous functionality -// to the OpenCascade Geometry support in Netgen - -namespace netgen -{ - /*! \brief Automatically assign boundary conditions for OCC meshes - - This function allows the boundary condition numbers of a - mesh created using an OpenCascade (STEP / IGES) geometry - to be assigned automatically. - - The boundary conditions are assigned based on the face - colour information (if any) contained in the geometry. - - Currently the following process is used to assign the BC Properties: - - Extract all the colours present in the OCC Geometry - - Use colour index 0 (zero) for all faces with no colour defined - - Calculate the number of faces of the surface mesh for each colour - - Sort the number of surface elements in ascending order, with the - colour indices as a slave - - Use the indices of the sorted array as the BC property number - - Example: If there are 3 colours, present in the file and the number - of surface elements for each colour are: - - Colour 0: 8500 - - Colour 1: 120 - - Colour 2: 2200 - - Colour 3: 575 - - The above is sorted in ascending order and assigned as BC Properties: - - BC Prop 0: 120 : Colour 1 - - BC Prop 1: 575 : Colour 3 - - BC Prop 2: 2200 : Colour 2 - - BC Prop 3: 8500 : Colour 0 (no colour defined) - */ - extern void OCCAutoColourBcProps(Mesh & mesh, OCCGeometry & occgeometry, const char *occcolourfile); - -} -#endif - diff --git a/windows/netgen.vcproj b/windows/netgen.vcproj index b4dd85a9..94ddfc40 100644 --- a/windows/netgen.vcproj +++ b/windows/netgen.vcproj @@ -408,6 +408,10 @@ RelativePath="..\libsrc\general\autoptr.hpp" > + + @@ -433,11 +437,11 @@ > - - @@ -745,11 +745,11 @@ > + + @@ -1238,10 +1242,6 @@ RelativePath="..\ng\ngpkg.cpp" > - - diff --git a/windows/netgen_MSVC2005.vcproj b/windows/netgen_MSVC2005.vcproj index cacf5a40..c5412064 100644 --- a/windows/netgen_MSVC2005.vcproj +++ b/windows/netgen_MSVC2005.vcproj @@ -68,7 +68,6 @@ LinkIncremental="0" AdditionalLibraryDirectories=""$(SolutionDir)..\..\ext_libs\tcl\lib";"$(SolutionDir)..\..\ext_libs\pthread-w32\lib"" GenerateManifest="true" - EnableUAC="false" GenerateDebugInformation="true" SubSystem="1" ImportLibrary="$(OutDir)\nginterface.lib" @@ -157,7 +156,6 @@ LinkIncremental="0" AdditionalLibraryDirectories=""$(SolutionDir)..\..\ext_libs\tcl\lib";"$(SolutionDir)..\..\ext_libs\pthread-w32\lib"" GenerateManifest="true" - EnableUAC="false" GenerateDebugInformation="false" SubSystem="1" OptimizeReferences="2" @@ -250,7 +248,6 @@ LinkIncremental="0" AdditionalLibraryDirectories=""$(SolutionDir)..\..\ext_libs\tcl\lib";"$(SolutionDir)..\..\ext_libs\pthread-w32\lib";"$(CASROOT)\win32\lib"" GenerateManifest="true" - EnableUAC="false" EmbedManagedResourceFile="" GenerateDebugInformation="false" SubSystem="1" @@ -341,7 +338,6 @@ LinkIncremental="0" AdditionalLibraryDirectories=""$(SolutionDir)..\..\ext_libs\tcl\lib";"$(SolutionDir)..\..\ext_libs\pthread-w32\lib";"$(CASROOT)\win32\lib"" GenerateManifest="true" - EnableUAC="false" GenerateDebugInformation="true" SubSystem="1" ImportLibrary="$(OutDir)\nginterface.lib" @@ -416,6 +412,10 @@ RelativePath="..\libsrc\general\autoptr.hpp" > + + @@ -441,11 +441,11 @@ > - - @@ -753,11 +749,11 @@ > + + @@ -1246,10 +1246,6 @@ RelativePath="..\ng\ngpkg.cpp" > - - @@ -1651,7 +1647,7 @@ Name="Resource Files" >