mirror of
https://github.com/NGSolve/netgen.git
synced 2025-01-26 21:00:34 +05:00
* New feature: View mesh surface elements of selected face colours
* Added a new menu entry under the "special" menu for allowing users to inspect the face colours existent in a mesh
This commit is contained in:
parent
5bf0c8d5e4
commit
e356a50199
@ -115,6 +115,7 @@ namespace netgen
|
||||
|
||||
if(!header_found)
|
||||
{
|
||||
ocf.close();
|
||||
throw NgException("AutoColourAlg_UserProfile: Invalid or empty Boundary Colour Profile file\n");
|
||||
return;
|
||||
}
|
||||
@ -125,6 +126,7 @@ namespace netgen
|
||||
{
|
||||
if(!ocf.good())
|
||||
{
|
||||
ocf.close();
|
||||
throw NgException("AutoColourAlg_UserProfile: Invalid or empty Boundary Colour Profile file\n");
|
||||
return;
|
||||
}
|
||||
@ -133,8 +135,8 @@ namespace netgen
|
||||
}
|
||||
else
|
||||
{
|
||||
PrintMessage(3, "AutoColourAlg_UserProfile: No Boundary Colour entries found.... no changes made!");
|
||||
ocf.close();
|
||||
PrintMessage(3, "AutoColourAlg_UserProfile: No Boundary Colour entries found.... no changes made!");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -164,7 +166,11 @@ namespace netgen
|
||||
>> bc_colours.Elem(i).Z();
|
||||
|
||||
if(!ocf.good())
|
||||
{
|
||||
ocf.close();
|
||||
throw NgException("Boundary Colour file error: Number of entries do not match specified list size!!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// Bound checking of the values
|
||||
// The RGB values should be between 0.0 and 1.0
|
||||
@ -450,6 +456,12 @@ namespace netgen
|
||||
PrintMessage(1, "AutoColourBcProps: Using Boundary Colour Profile file: ");
|
||||
PrintMessage(1, " ", bccolourfile);
|
||||
AutoColourAlg_UserProfile(mesh, ocf);
|
||||
|
||||
// Make sure the file is closed before exiting the function
|
||||
if(ocf.is_open())
|
||||
{
|
||||
ocf.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -44,6 +44,10 @@ namespace netgen
|
||||
*/
|
||||
//extern void OCCAutoColourBcProps(Mesh & mesh, OCCGeometry & occgeometry, const char *occcolourfile);
|
||||
extern void AutoColourBcProps(Mesh & mesh, const char *bccolourfile);
|
||||
|
||||
extern void GetFaceColours(Mesh & mesh, Array<Vec3d> & face_colours);
|
||||
|
||||
extern bool ColourMatch(Vec3d col1, Vec3d col2, double eps = 2.5e-05);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1530,6 +1530,99 @@ proc bcpropdialog { } {
|
||||
|
||||
|
||||
|
||||
#
|
||||
# Philippose - 25/07/2010
|
||||
# Display the face colours currently
|
||||
# available in the mesh
|
||||
#
|
||||
proc currmeshcoloursdialog { } {
|
||||
|
||||
set w .currmeshcolours_dlg
|
||||
|
||||
if {[winfo exists .currmeshcolours_dlg] == 1} {
|
||||
wm withdraw $w
|
||||
wm deiconify $w
|
||||
focus $w
|
||||
} {
|
||||
toplevel $w
|
||||
|
||||
global facecolslist
|
||||
|
||||
frame $w.facecols -borderwidth 3
|
||||
pack $w.facecols -side top -expand yes -fill x -fill y
|
||||
|
||||
listbox $w.facecols.list -yscroll "$w.facecols.scroll set" -selectmode single -setgrid 1 -width 32 -height 12
|
||||
scrollbar $w.facecols.scroll -command "$w.facecols.list yview"
|
||||
pack $w.facecols.scroll -side right -fill y
|
||||
pack $w.facecols.list -side left -expand 1 -fill both
|
||||
|
||||
Ng_CurrentFaceColours getcolours facecolslist
|
||||
set i 1
|
||||
foreach el $facecolslist {
|
||||
set hel [format "%d: (%.4f %.4f %.4f)" $i [ lindex $el 0 ] [ lindex $el 1 ] [ lindex $el 2 ]]
|
||||
incr i
|
||||
$w.facecols.list insert end $hel }
|
||||
|
||||
frame $w.bu1
|
||||
pack $w.bu1
|
||||
|
||||
button $w.bu1.showonly -text "show only" -command {
|
||||
Ng_CurrentFaceColours showonly [.currmeshcolours_dlg.facecols.list curselection]
|
||||
redraw
|
||||
}
|
||||
button $w.bu1.hideonly -text "hide only" -command {
|
||||
Ng_CurrentFaceColours hideonly [.currmeshcolours_dlg.facecols.list curselection]
|
||||
redraw
|
||||
}
|
||||
pack $w.bu1.showonly $w.bu1.hideonly -fill x -padx 3 -pady 3 -side left
|
||||
|
||||
frame $w.bu2
|
||||
pack $w.bu2
|
||||
|
||||
button $w.bu2.showalso -text "show" -command {
|
||||
Ng_CurrentFaceColours showalso [.currmeshcolours_dlg.facecols.list curselection]
|
||||
redraw
|
||||
}
|
||||
button $w.bu2.hidealso -text "hide" -command {
|
||||
Ng_CurrentFaceColours hidealso [.currmeshcolours_dlg.facecols.list curselection]
|
||||
redraw
|
||||
}
|
||||
pack $w.bu2.showalso $w.bu2.hidealso -fill x -padx 3 -pady 3 -side left
|
||||
|
||||
frame $w.bu3
|
||||
pack $w.bu3
|
||||
|
||||
button $w.bu3.showall -text "show all" -command {
|
||||
Ng_CurrentFaceColours showall
|
||||
redraw
|
||||
}
|
||||
button $w.bu3.hideall -text "hide all" -command {
|
||||
Ng_CurrentFaceColours hideall
|
||||
redraw
|
||||
}
|
||||
pack $w.bu3.showall $w.bu3.hideall -fill x -padx 3 -pady 3 -side left
|
||||
|
||||
frame $w.bu4
|
||||
pack $w.bu4
|
||||
|
||||
button $w.bu4.close -text "close" -command {
|
||||
destroy .currmeshcolours_dlg
|
||||
}
|
||||
pack $w.bu4.close -pady 3 -side right
|
||||
|
||||
pack $w.bu4 -side bottom
|
||||
|
||||
wm withdraw $w
|
||||
wm geom $w +100+100
|
||||
wm deiconify $w
|
||||
wm title $w "Inspect Mesh Colours"
|
||||
focus $w
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#
|
||||
# Philippose - 30/01/2009
|
||||
# Local Surface Mesh Size Selection
|
||||
|
@ -788,6 +788,11 @@ menu .ngmenu.special
|
||||
.ngmenu.special add cascade -label "Colour-based boundary conditions" -menu .ngmenu.special.colbndcond
|
||||
|
||||
menu .ngmenu.special.colbndcond
|
||||
.ngmenu.special.colbndcond add command -label "Inspect Colours in mesh" \
|
||||
-command { currmeshcoloursdialog }
|
||||
|
||||
.ngmenu.special.colbndcond add separator
|
||||
|
||||
.ngmenu.special.colbndcond add command -label "Automatic Assignment" \
|
||||
-command { Ng_AutoColourBcProps auto; redraw }
|
||||
|
||||
|
179
ng/ngpkg.cpp
179
ng/ngpkg.cpp
@ -1555,6 +1555,178 @@ namespace netgen
|
||||
|
||||
|
||||
|
||||
// Philippose - 25/07/2010
|
||||
// TCL interface function for extracting and eventually
|
||||
// setting or editing the current colours present in the mesh
|
||||
int Ng_CurrentFaceColours (ClientData clientData,
|
||||
Tcl_Interp * interp,
|
||||
int argc, tcl_const char *argv[])
|
||||
{
|
||||
if(argc < 1)
|
||||
{
|
||||
Tcl_SetResult (interp, (char *)"Ng_GetCurrentFaceColours needs arguments", TCL_STATIC);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
if(!mesh.Ptr())
|
||||
{
|
||||
Tcl_SetResult (interp, (char *)"Ng_GetCurrentFaceColours: Valid netgen mesh required...please mesh the Geometry first", TCL_STATIC);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
if(strcmp(argv[1], "getcolours") == 0)
|
||||
{
|
||||
stringstream outVar;
|
||||
Array<Vec3d> face_colours;
|
||||
GetFaceColours(*mesh, face_colours);
|
||||
|
||||
for(int i = 0; i < face_colours.Size();i++)
|
||||
{
|
||||
outVar << "{ " << face_colours[i].X(1)
|
||||
<< " " << face_colours[i].X(2)
|
||||
<< " " << face_colours[i].X(3)
|
||||
<< " } ";
|
||||
}
|
||||
|
||||
tcl_const char * valuevar = argv[2];
|
||||
Tcl_SetVar (interp, valuevar, (char*)outVar.str().c_str(), 0);
|
||||
}
|
||||
|
||||
if(strcmp(argv[1], "showalso") == 0)
|
||||
{
|
||||
Array<Vec3d> face_colours;
|
||||
GetFaceColours(*mesh,face_colours);
|
||||
|
||||
int colourind = atoi (argv[2]);
|
||||
|
||||
for(int i = 1; i <= mesh->GetNFD(); i++)
|
||||
{
|
||||
Array<SurfaceElementIndex> surfElems;
|
||||
mesh->GetSurfaceElementsOfFace(i,surfElems);
|
||||
|
||||
if(ColourMatch(face_colours[colourind],mesh->GetFaceDescriptor(i).SurfColour()))
|
||||
{
|
||||
for(int j = 0; j < surfElems.Size(); j++)
|
||||
{
|
||||
mesh->SurfaceElement(surfElems[j]).Visible(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mesh->SetNextTimeStamp();
|
||||
}
|
||||
|
||||
if(strcmp(argv[1], "hidealso") == 0)
|
||||
{
|
||||
Array<Vec3d> face_colours;
|
||||
GetFaceColours(*mesh,face_colours);
|
||||
|
||||
int colourind = atoi (argv[2]);
|
||||
|
||||
for(int i = 1; i <= mesh->GetNFD(); i++)
|
||||
{
|
||||
Array<SurfaceElementIndex> surfElems;
|
||||
mesh->GetSurfaceElementsOfFace(i,surfElems);
|
||||
|
||||
if(ColourMatch(face_colours[colourind],mesh->GetFaceDescriptor(i).SurfColour()))
|
||||
{
|
||||
for(int j = 0; j < surfElems.Size(); j++)
|
||||
{
|
||||
mesh->SurfaceElement(surfElems[j]).Visible(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mesh->SetNextTimeStamp();
|
||||
}
|
||||
|
||||
if(strcmp(argv[1], "showonly") == 0)
|
||||
{
|
||||
Array<Vec3d> face_colours;
|
||||
GetFaceColours(*mesh,face_colours);
|
||||
|
||||
int colourind = atoi (argv[2]);
|
||||
|
||||
for(int i = 1; i <= mesh->GetNFD(); i++)
|
||||
{
|
||||
Array<SurfaceElementIndex> surfElems;
|
||||
mesh->GetSurfaceElementsOfFace(i,surfElems);
|
||||
|
||||
if(ColourMatch(face_colours[colourind],mesh->GetFaceDescriptor(i).SurfColour()))
|
||||
{
|
||||
for(int j = 0; j < surfElems.Size(); j++)
|
||||
{
|
||||
mesh->SurfaceElement(surfElems[j]).Visible(1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(int j = 0; j < surfElems.Size(); j++)
|
||||
{
|
||||
mesh->SurfaceElement(surfElems[j]).Visible(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mesh->SetNextTimeStamp();
|
||||
}
|
||||
|
||||
if(strcmp(argv[1], "hideonly") == 0)
|
||||
{
|
||||
Array<Vec3d> face_colours;
|
||||
GetFaceColours(*mesh,face_colours);
|
||||
|
||||
int colourind = atoi (argv[2]);
|
||||
|
||||
for(int i = 1; i <= mesh->GetNFD(); i++)
|
||||
{
|
||||
Array<SurfaceElementIndex> surfElems;
|
||||
mesh->GetSurfaceElementsOfFace(i,surfElems);
|
||||
|
||||
if(ColourMatch(face_colours[colourind],mesh->GetFaceDescriptor(i).SurfColour()))
|
||||
{
|
||||
for(int j = 0; j < surfElems.Size(); j++)
|
||||
{
|
||||
mesh->SurfaceElement(surfElems[j]).Visible(0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(int j = 0; j < surfElems.Size(); j++)
|
||||
{
|
||||
mesh->SurfaceElement(surfElems[j]).Visible(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mesh->SetNextTimeStamp();
|
||||
}
|
||||
|
||||
if(strcmp(argv[1], "showall") == 0)
|
||||
{
|
||||
for(int i = 1; i <= mesh->GetNSE(); i++)
|
||||
{
|
||||
mesh->SurfaceElement(i).Visible(1);
|
||||
}
|
||||
|
||||
mesh->SetNextTimeStamp();
|
||||
}
|
||||
|
||||
if(strcmp(argv[1], "hideall") == 0)
|
||||
{
|
||||
for(int i = 1; i <= mesh->GetNSE(); i++)
|
||||
{
|
||||
mesh->SurfaceElement(i).Visible(0);
|
||||
}
|
||||
|
||||
mesh->SetNextTimeStamp();
|
||||
}
|
||||
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Philippose - 10/03/2009
|
||||
// TCL interface function for the Automatic Colour-based
|
||||
@ -4940,6 +5112,13 @@ namespace netgen
|
||||
Tcl_CreateCommand (interp, "Ng_AutoColourBcProps", Ng_AutoColourBcProps,
|
||||
(ClientData)NULL,
|
||||
(Tcl_CmdDeleteProc*) NULL);
|
||||
|
||||
// Philippose - 25/07/2010
|
||||
// Register the TCL Interface Command for handling the face colours
|
||||
// present in the mesh
|
||||
Tcl_CreateCommand(interp, "Ng_CurrentFaceColours", Ng_CurrentFaceColours,
|
||||
(ClientData)NULL,
|
||||
(Tcl_CmdDeleteProc*) NULL);
|
||||
|
||||
|
||||
// meshing
|
||||
|
Loading…
Reference in New Issue
Block a user