Warning, file /education/kstars/kstars/data/tools/HTMesh-0.01/test-draw.pl was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 use HTMesh;
0002 
0003 if (0) {
0004     for my $i ( 1..10) {
0005         print "making new HTMesh ... \n";
0006         my $htm = HTMesh->new(8);
0007         sleep 1;
0008     }
0009     exit;
0010 }
0011 
0012 my $EDGES_ONLY = 0;
0013 my $RECT = 0;
0014 my %LINES;
0015 
0016 my $level = 2;
0017 my $size  = 90;
0018 my $mesh = HTMesh->new($level);
0019 
0020 my ($ra, $dec) = (6.75, -16.72);
0021 
0022 #my ($ra, $dec) = (4.5, -18.5);
0023 
0024 my $kstars = `dcopfind -a 'kstars*'`;
0025 chomp $kstars;
0026 $kstars .= " KStarsInterface ";
0027 
0028 tell_kstars("eraseLines");
0029 tell_kstars("setRaDec $ra $dec");
0030 
0031 if ($RECT) {
0032     $mesh->intersect_rect($ra, $dec, $size, $size);
0033 }
0034 else {
0035     $mesh->intersect_circle($ra, $dec, $size);
0036 }
0037 
0038 while ( $mesh->has_next() ) {
0039     my @tri = $mesh->next_triangle();
0040     kstars_display(@tri);
0041 }
0042 show_edges();
0043 
0044 tell_kstars("setRaDec $ra $dec");
0045 
0046 #============================================================================
0047 #============================================================================
0048 
0049 sub tell_kstars {
0050     #print "dcop $kstars @_\n";
0051     return `dcop $kstars @_`;
0052 }
0053 
0054 sub kstars_display {
0055     my @pts;
0056     for my $i (1..3) {
0057         my ($ra, $dec) = (shift, shift);
0058         push @pts, [map sprintf("%.4f", $_), $ra, $dec];
0059     }
0060     push @pts, $pts[0];
0061     for my $i (0..2) {
0062         my @op = sort {$$a[0] <=> $$b[0] || $$a[1] <=> $$b[1] }
0063             $pts[$i], $pts[$i+1];
0064         my $line = "@{$op[0]} @{$op[1]}";
0065         $LINES{$line}++ or do {
0066             $EDGES_ONLY or tell_kstars("drawLine", $line, "green");
0067         };
0068     }
0069 }
0070         
0071 sub show_edges {
0072     for my $line (keys %LINES) {
0073         #print "$LINES{$line} $line\n";
0074         $LINES{$line} == 1 and tell_kstars("drawLine", $line, "purple");
0075     }
0076 }