Challenge

Week - 7 - Checking and correcting the edges

Aim:

To create a code that performs checking and correcting the edges

Objective:

To create a code that displayed free and T edges for displayed elements

To create a code that assigns red color to free edges and cyan color to T edges

To create a code that makes all other component must be transparent expect for edges

To create a code that creates temp nodes automatically for free edges

To create a code to turn off free edges display and restore the window to the way it was

To create a tk widget that performs all these operations

Code:

set a .window
catch {destroy $a}
toplevel $a -class TopLevel

wm title $a "Free Edges"
wm geometry $a 300x200+100+50; update
wm resizable $a 0 0
wm deiconify $a 

button $a.01 -text "Free Edges" -command {free_edges} -bg red -font {times 10 bold};	place $a.01 -x 20 -y 20 -width 100 -height 30
button $a.02 -text "T edges" -command {T_edges} -bg cyan -font {times 10 bold};			place $a.02 -x 140 -y 20 -width 100 -height 30
button $a.03 -text "both" -command {both} -bg white -font {times 10 bold};				place $a.03 -x 70 -y 70 -width 100 -height 30
button $a.04 -text "off" -command {off} -bg grey -font {times 10 bold};					place $a.04 -x 70 -y 120 -width 100 -height 30
	

proc free_edges {} {
*setdisplayattributes 4 1
*createmark components 1 "free_edges"
set a [hm_getmark components 1]
if {$a !=0} {
*createmark elements 1 "displayed"
*findedges1 elements 1 0 0 0 30
*setvalue components name={^edges} name={free_edges}
*createmark components 1 "free_edges"
*setvalue components mark=1 color=3

*createmark elements 1 "displayed"
*equivalence elements 1 0.01 0 0 30
*createmark elements 1 "displayed"
*equivalence elements 1 0.01 3 0 30
*createmark nodes 1 "retrieve"
*nodemarkaddtempmark 1

*setcomponentdisplayattributes "free_edges" 2 1
}
}

proc T_edges {} {
*setdisplayattributes 4 1

*createmark components 1 "T_edges"
set b [hm_getmark components 1]
if {$b !=0} {
*createmark elements 1 "displayed"
*findedges1 elements 1 1 0 0 30
*setvalue components name={^edges} name={T_edges}
*createmark components 1 "T_edges"
*setvalue components mark=1 color=30

*createmark elements 1 "displayed"
*equivalence elements 1 0.01 0 0 30
*createmark elements 1 "displayed"
*equivalence elements 1 0.01 3 0 30
*createmark nodes 1 "retrieve"
*nodemarkaddtempmark 1

*setcomponentdisplayattributes "T_edges" 2 1

}
}


proc both {} {
free_edges
T_edges
*setcomponentdisplayattributes "free_edges" 2 1
*setcomponentdisplayattributes "T_edges" 2 1
}

proc off {} {
*createmark components 1 "free_edges"
*hideentitybymark 1 1 2
*createmark components 1 "T_edges"
*hideentitybymark 1 1 2
*createstringarray 2 "elements_on" "geometry_off"
*setdisplayattributes 2 1
}

Procedure and code explanation:

Create a procedure called 'free_edges'

*setdisplayattributes is a command that transparent all the components.

We need to give a null case condition if there is no exixt component.

*createmark elements 1 "displayed" is a command that used to store all the displayed elements into a mark id 1.

*findedges1 elements 1 0 0 0 30 is the command that is used to find the edges. 1 represent the mark id and 0 indicated free edges and 30 is the break andle of the free edges.

*setvalue components name={^edges} name={free_edges} is used to change the name of the component.

*setvalue components mark=1 color=3 is used to change the color to red.

*equivalence elements 1 0.01 0 0 30 is checking where nodes to be equivalence for the tolerance value of 0.01 for the free edges

*equivalence elements 1 0.01 3 0 30 is saves the nodes which needs to be equivalence.

*createmark nodes 1 "retrieve" is used to retrive the saved nodes.

*nodemarkaddtempmark 1 is adding the nodes.

*setcomponentdisplayattributes "free_edges" 2 1 is the command that used to display thr free edges and T edges into the solid mesh representation.

Use the same procedure to check the T edges. Replae the procedure name into T_edges and use edge type as 1.

Also create a procedure that performs both operations and create a procedure to turn off free edge display and restore the window to the way it was. *createmark components 1 "free_edges"; *hideentitybymark 1 1 2 is the command that is used to turn off the free edges. Using this same method to turn off the T_edges.

*setdisplayattributes 2 1 is the command that used to resore the shaded element and mesh line.

set a .window is the command. .window is the window name or path by which it will be referred saved in.

catch {destroy $a} is the command where catch is used to hide errors and destroy is used to close any previously existing window by same name.

toplevel $a -class TopLevel is the command that builds the window.

wm title $a "Free Edges" is the command that is used to create title of the window.

wm geometry $a 300x200+100+50 is the command that is used to create dimension of the window. 300x200 is width and height of the window. +100+50 is the origin of the hypermesh window where the windoe shoud be placed.

wm resizable $a 0 0 is the command that is used to fix the window means we can not resize the window by dragging. If you put 1 0, you can drag or resize the window on x axix, if you put 0 1, you can drag or resize it on y axix and if you put 1 1, you can drag and resize on both axis.

wm deiconify $a is the command that is used to make the window as active window.

We have to create buttons for all the operations. The syntax for create button is button $windowpath -text "text" -command {something}; place $windowpath -x value -y value -width value - height value. Using this syntax 'Free edges', 'T edges', 'both' and 'off' buttons are created.

Output:

Free edges operation:

T edges operation:

'both' button operation:

Nodes need to be eqivalence:

'off' button operation:

Conclusion:

Sucessfully created code that checking and correcting the edges. Also created tk widgets for the operations.

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.