<HTML><HEAD><link type="text/css" href="../css/main_styles.css" rel="stylesheet"></HEAD>
<BODY><TITLE>%measure_angle_between_2lines</TITLE><H1>%measure_angle_between_2lines  </H1><P CLASS="Paragraph">Classname: <B>%measure_angle_between_2lines  </B></P><P CLASS="Paragraph">Inherits from: <B><A href=..\checkmate\xug_base_checker.html>%ug_base_checker </A></B></P><PRE STYLE=\"text-align : left;\" CLASS=\"Code\"> </PRE><PRE STYLE=\"text-align : left;\" CLASS=\"Code\">
<B>Description:</B>
    This checker validates the angle between two lines, given
    a normal vector that uses the right-hand rule to define
    the angle measured from the first line to the second line.
    The user can select either a line or a vector to represent the line.
Parameters:
    ( List )   first_line        - first line selected.
                                   Might be selected interactively via
                                   the class selection dialog.
    ( List )   second_line       - second line selected.
                                   Might be selected interactively
                                   via the class selection dialog.
    ( vector ) first_line_vector - first line selected.
                                   Might be selected interactively via
                                   the Vector constructor dialog.
    ( vector ) second_line_vector - second line selected.
                                    Might be selected interactively via
                                    the Vector constructor dialog.
    ( Vector ) view_direction_vector    - A normal vector that uses the right-hand rule
                                   to dertermine the measurement direction
                                   of the angle from the first line to the second line.
    ( List )    pass_range       - A list of one or two range limits for the pass range criterion.
                                   Each range bound has two members.  The first member
                                   defines the condition which can be LT, LE, GT or GE keyword.
                                   LT is "less than". LE is "less than or equal to".
                                   GT is "greater than". GE is "greater than or equal to".
                                   The second member is integer or real value for the
                                   range limit. For example, {{GT, 0.0}, {LE, 1.0}} or {{LE, -1}}.
                                   If a range list has two limits, then the first limit defines the lower
                                   limit; the second limit defines the upper limit. Otherwise, the checker
                                   will return an invalid range error.
    ( List )    warning_range    - A list of one or two range limits for the warning range criterion.
    ( List )    Fail_range       - A list of one or two range limits for the failure range criterion.
    ( String )  error_message    - error message to be logged
    ( String )  warning_message  - warning message to be logged
    (Boolean)  disabled? -    If it is true, the checker is disabled.
                                            Default is False.
    (Boolean)  save_log_in_part -  The flag indicates whether the checking results can
                                       be saved to the part file
                                       Default is True.
Results:
    PASS         -- The measured angle passes the checking criteria.
    WARNING      -- The measured angle is marginal against the warning range.
    FAIL         -- The measured angle falls in the fail criteria.
</PRE><PRE><FONT COLOR= blue>DefClass: %measure_angle_between_2lines ( %ug_base_checker );
</FONT></PRE><DIV><PRE STYLE=\"text-align : left;\" CLASS=\"Code\"><FONT COLOR=blue>   ( String )    %test_category: "Template.Measurement";
   ( String )    %displayed_name: "Check Angle Range Between Two Lines";

</SPAN></FONT></PRE></DIV><DIV><PRE STYLE=\"text-align : left;\" CLASS=\"Code\"><FONT COLOR=blue>   ( Boolean Parameter )    Disabled?: False;
   ( Boolean Parameter )    save_log_in_part: true;
</SPAN></FONT></PRE></DIV><PRE STYLE=\"text-align : left;\" CLASS=\"Code\">   Attributes for this class</PRE><DIV><PRE STYLE=\"text-align : left;\" CLASS=\"Code\"><FONT COLOR=blue>   ( List )             first_line_mask:  {point, line, curve, edge};
   ( String )           first_line_label: "First Line";

</SPAN></FONT></PRE></DIV><DIV><PRE STYLE=\"text-align : left;\" CLASS=\"Code\"><FONT COLOR=blue>   ( List )             second_line_mask:  {point, line, curve, edge};
   ( String )           second_line_label: "Second Line";

</SPAN></FONT></PRE></DIV><DIV><PRE STYLE=\"text-align : left;\" CLASS=\"Code\"><FONT COLOR=blue>   ( String )           pass_range_label: "Pass Range";

</SPAN></FONT></PRE></DIV><DIV><PRE STYLE=\"text-align : left;\" CLASS=\"Code\"><FONT COLOR=blue>   ( String )           warning_range_label: "Warning Range";

</SPAN></FONT></PRE></DIV><DIV><PRE STYLE=\"text-align : left;\" CLASS=\"Code\"><FONT COLOR=blue>   ( String )           fail_range_label: "Fail Range";

</SPAN></FONT></PRE></DIV><DIV><PRE STYLE=\"text-align : left;\" CLASS=\"Code\"><FONT COLOR=blue>   ( String )           error_msg_label: "Error Message";

</SPAN></FONT></PRE></DIV><DIV><PRE STYLE=\"text-align : left;\" CLASS=\"Code\"><FONT COLOR=blue>   ( List Parameter )   first_line:       {};
   ( List Parameter )   second_line:       {};
   ( Vector Parameter ) first_line_vector:     vector(0,0,0);
   ( Vector Parameter ) second_line_vector:    vector(0,0,0);
   ( Vector Parameter ) view_direction_vector: vector(0,0,1);
   ( List Parameter )   pass_range: {};
   ( List Parameter )   warning_range: {};
   ( List Parameter )   fail_range: {};
   ( String Parameter ) error_msg: "The angle falls in the fail range.";
   ( String Parameter ) warning_msg: "The angle falls in the warning range.";
</SPAN></FONT></PRE></DIV><PRE STYLE=\"text-align : left;\" CLASS=\"Code\">   Checker function</PRE><DIV><PRE STYLE=\"text-align : left;\" CLASS=\"Code\"><FONT COLOR=blue>   ( String )           warning_msg_label: "Warning Message";

</SPAN></FONT></PRE></DIV><DIV><PRE STYLE=\"text-align : left;\" CLASS=\"Code\"><FONT COLOR=blue>   (Any Uncached)   do_check: 
   if (Empty?(pass_range:) & Empty?(fail_range:) & Empty?(warning_range:) )
   then
        ug_mqc_empty_param_warning()
   else
   @{ 
       
       $status << mqc_validate_3ranges(pass_range:, warning_range:, fail_range:); 
        
       if ($status) then 
       @{ 
           $msg << "Error in checking due to invalid range specification.";
           ug_mqc_log(LOG_ERROR, {}, $msg);  
       } 
       else 
       @{ 
           $count_1 << length(first_line:);
           $count_2 << length(second_line:);
           
           $valid_object_1 << if ( $count_1 > 0 ) then 
                               mqc_is_valid_object_identifier(nth(1, first_line:))
                            else
                               true; 
                                 
           $valid_object_2 << if ( $count_2 > 0 ) then
                                mqc_is_valid_object_identifier(nth(1, second_line:))
                            else
                               true; 
                
           if ( $valid_object_1 = true & $valid_object_2 = true ) then
           @{     
           $vec1 << if ($count_1 > 0) then
           @{
               $point1 << ug_curve_askStartPoint(ug_refObject(nth(1,first_line:), ""));
               $point2 << ug_curve_askEndPoint(ug_refObject(nth(1,first_line:), ""));
               $vec << $point2 - $point1;
               unitize($vec);
           }
           else
           @{
               unitize(first_line_vector:);
           };

           $vec2 << if ($count_2 > 0) then
           @{
               $point1 << ug_curve_askStartPoint(ug_refObject(nth(1,second_line:), ""));
               $point2 << ug_curve_askEndPoint(ug_refObject(nth(1,second_line:), ""));
               $vec << $point2 - $point1;
               unitize($vec);
           }
           else
           @{
               unitize(second_line_vector:);
           };

           $nvec << unitize(view_direction_vector:); 
           $angle << Angle2Vectors($vec1, $vec2, $nvec); 
     
           $result << mqc_check_range($angle, warning_range:); 
           if $result = True then                          
                @{  
                  $msg << warning_msg: + " The measured angle is " + 
                          format("%f"; $angle)+ " degrees.";   
                  ug_mqc_log(LOG_WARNING, {}, $msg);  
                 }      
           else do_nothing;  
  
           $result << mqc_check_range($angle, fail_range:);                           
           if $result = True then  
                @{  
                  $msg << error_msg: + " The measured angle is " +
                          format("%f"; $angle) + " degrees.";   
                  ug_mqc_log(LOG_ERROR, {}, $msg);  
                 }  
           else do_nothing; 
           }
           else
           @{
               $msg << "Fail to check due to invalid line geometry objects.";   
               ug_mqc_log(LOG_ERROR, {}, $msg);  
           };
           
       }; 
        
   };

</SPAN></FONT></PRE></DIV></TABLE><p class=EndLine>&nbsp;</p><p class=blank>&nbsp;</p></BODY></HTML>