Challenge

Week - 5 - Checking and correcting the Normals

AIM:

  • Write a code to display normal as explained in Lecture 5
  • Create a widget containing two buttons for “reverse normals” and “normal off”
  • Also assign these procedures to keyboard buttons of your choice.
  • check the null case also

PROCEDURE:

  • *setnormalsdisplaytpeis used to display the type of visualization whether with direction of normal (0) or color(1)
  • Then the elements displayed in were selected using *createmarkcommand.
  • Normals were displayed for the selected element with color representation using*normalsdisplay elems.
  • Functions were created for the reversing the normals and select the elements using proc and these functions are called by assigning the respective buttons.
  • To reverse the normals of the selected elements *normalsreverse command is used.
  • hm_framework is used to create a separate tab.

CODE

*clearmarkall 1
*setnormalsdisplaytype 1
*createmark elements 1 "displayed"
*normalsdisplay elements 1
*clearmarkall 1; *clearmarkall 2;
*createmarkpanel elements 2 "Select the elements you want to reverse normals for"
set a [hm_marklength elements 2]
set normals .window
catch {destroy $normals}
toplevel $normals -class TopLevel
wm title $normals "Normals"
wm geometry $normals 200x300+100+30;
wm deiconify $normals

button $normals.01 -text "reverse normals" -command {
if {$a != 0} {*normalsreverse elements 2; *createmark elements 1 "displayed"; *normalsdisplay elements 1} else {puts [set prompt [box]]}}; place $normals.01 -x 10 -y 10
button $normals.02 -text "normals off" -command {*normalsoff}; place $normals.02 -x 10 -y 30
proc box {} {tk_messageBox -message "no elements were selected" -icon error -type ok -title prompt}

RESULTS:

  • A code is written to display Widget has created which contains two buttons for "reverse normal & off".

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.