Week - 7 - Checking and correcting the edges
OBJECTIVE:
PART A:
- Create a code that displayed free and T edges for displayed elements
- Free edge colour red and T edge cyan
- Except for edges, all other components must be made transparent
- Also, temp nodes must be automatically created for “free nodes” for a tolerance value of 0.01
PART B:
- Also, create a code to turn off the free edge display and restore the window to the way it was.
- Map these codes over a key and also create a tk widget for the same
PROCEDURE:
- Firstly, create a window with three buttons to display free edges, t edges and to hide them.
- Then we need to create a code that displayed free and T edges for displayed elements.
- Here, inside the if statement, the *hm_marklength command is used to prevent null cases.
- The * findedges command is used to find free and t edges.
- This will create ^edges component.
- A collector is created named free edges and T edges and the elements in the ^edges component is moved to the Free edges and t edges components.
- Now the ^edges component is empty and is deleted.
- *setdisplayattributes command is used to change between different styles of display.
CODE:
set a .window
catch {destroy $a}
toplevel $a -class Toplevel
wm title $a "EDGE CORRECTION"
wm geometry $a 300x200+100+100
wm resizable $a 0 0
wm deiconify $a
button $a.11 -text "FREE EDGES" -command {free_edges} -bg yellow -font {times 10 bold}; place $a.11 -x 20 -y 20 -width 250 -height 40
button $a.21 -text "T EDGES" -command {t_edges} -bg yellow -font {times 10 bold}; place $a.21 -x 20 -y 80 -width 250 -height 40
button $a.31 -text "HIDE" -command {hide} -bg yellow -font {times 10 bold}; place $a.31 -x 20 -y 140 -width 250 -height 40
proc free_edges {} {
*clearmarkall 1;
*createmark elems 1 "displayed"
if {[hm_marklength elems 1]!=0} {
*createmark comps 1 "Free_Edges"
if {[hm_marklength comps 1]!=0} { *deletemark comps 1}
*createmark elems 1 "displayed"
*findedges1 elems 1 0 0 0 30
*createentity comps name="Free_Edges" color=3
*createmark elems 2 "by collector" {^edges}
if {[hm_marklength elems 2]!=0} { *movemark elems 2 "Free_Edges"}
*createmark comps 2 "^edges"; *deletemark comps 2
*setdisplayattributes 4 1
*setcomponentdisplayattributes "Free_Edges" 2 1
p_equiv
}
}
proc t_edges {} {
*setdisplayattributes 4 1
*clearmarkall 1;
*createmark elems 1 "displayed"
if {[hm_marklength elems 1]!=0} {
*createmark comps 1 "T_Edges"
if {[hm_marklength comps 1]!=0} { *deletemark comps 1}
*createmark elems 1 "displayed"
*findedges1 elems 1 1 0 0 30
*createentity comps name="T_Edges" color=30
*createmark elems 2 "by collector" {^edges}
if {[hm_marklength elems 2]!=0} { *movemark elems 2 "T_Edges"}
*createmark comps 2 "^edges"; *deletemark comps 2
*setdisplayattributes 4 1
*setcomponentdisplayattributes "T_Edges" 4 1
p_equiv
}
}
proc p_equiv {} {
*clearmarkall 1;
*clearmarkall 2;
*createmark elems 1 "displayed"
*equivalence elems 1 0.01 3 0 0
*createmark nodes 1 "retrieve"
*nodemarkaddtempmark 1
}
proc hide {} {
*clearmarkall 1;
*clearmarkall 2;
*createmark comps 1 "all"
if {[hm_entityinfo exist comps ^edges]==1} { puts 3;*createmark comps 1 "^edges"; *deletemark comps 1}
*createmark comps 1 "all"
if {[hm_entityinfo exist comps Free_Edges]==1} { puts 2; *createmark comps 1 "Free_Edges"; *deletemark comps 1}
*createmark comps 1 "all"
if {[hm_entityinfo exist comps T_Edges]==1} { puts 1; *createmark comps 1 "T_Edges"; *deletemark comps 1}
*setdisplayattributes 2 1
}
GRAPHICAL USER INTERFACE:

CONCLUSION:
- Learned to display Free edges and T edges in an easier and comfortable way for the user to work with.
- Made the identification and correction of edges easier.