-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- renamed vectorize-run.pl to vrg-run.pl (the old one is overridden) - added builtin infix operators "eq", "neq", and ":=" to xclips. git-svn-id: http://svn.berlios.de/svnroot/repos/unisimu/VRG@815 625e195c-0704-0410-94f2-f261ee9f2fe7
- Loading branch information
agent
committed
Nov 7, 2006
1 parent
6ac7659
commit 1228a34
Showing
7 changed files
with
111 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,85 @@ | ||
use strict; | ||
use warnings; | ||
|
||
my $profile = shift; | ||
my $data = `$^X pro.pl -s $profile -g go -t halt -q`; | ||
my $pro_src = "(deffacts vector_facts \"$profile\"\n"; | ||
open my $in, '<', \$data; | ||
while (<$in>) { | ||
next if !/^\S+ \S+ \S+$/; | ||
chomp; | ||
$pro_src .= " ($_)\n"; | ||
} | ||
$pro_src .= ")\n"; | ||
close $in; | ||
print $pro_src; | ||
use CLIPS_Visualize; | ||
use Getopt::Std; | ||
use CLIPS; | ||
|
||
my %opts; | ||
getopts('v', \%opts) or help(); | ||
$CLIPS::Verbose = $opts{v}; | ||
|
||
my %infix = ( | ||
'parallel' => '//', | ||
'orthogonal' => 'T', | ||
'cross' => 'X', | ||
'on' => 'on', | ||
); | ||
|
||
my %prefix = ( | ||
'line' => '\\\\', | ||
'plane' => '\\#', | ||
); | ||
|
||
my $infile = shift or help();; | ||
my $clips = CLIPS->new('vectorize.clp', $infile, 'vector-eval.clp'); | ||
$clips->watch('rules'); | ||
$clips->watch('facts'); | ||
$clips->reset; | ||
$clips->focus('Vectorize'); | ||
$clips->rules if $opts{v}; | ||
$clips->facts('*', \my $init_facts); | ||
$clips->get_current_module; | ||
$clips->agenda; | ||
$clips->run(\my $run_log); | ||
$clips->facts('Eval', \my $facts); | ||
$clips->focus('Eval'); | ||
$clips->facts('*', \$init_facts); | ||
$clips->run(\$run_log); | ||
$clips->eof; | ||
#warn "FACTS: ", $facts; | ||
while ($facts =~ /\(vector-relation ([^\)]+)\)/g) { | ||
print "$1\n"; | ||
} | ||
|
||
if ($opts{v}) { | ||
my $painter = CLIPS::Visualize->new($init_facts, $run_log); | ||
$painter->draw( | ||
outfile => "a.png", | ||
fact_filter => \&format_fact, | ||
trim => 1, | ||
); | ||
} | ||
|
||
sub help { | ||
die "usage: $0 [-v] infile\n"; | ||
} | ||
|
||
sub format_fact { | ||
my $clips = $_[0]; | ||
if ($clips =~ /(?x) ^ \( (space|vector)-relation \s+ (\S+) \s+ (\S+) \s+ (\S+) \) $/) { | ||
#warn "$1, $2, $3"; | ||
my ($type, $rel, $a, $b) = ($1, $2, $3, $4); | ||
my $prefix = ''; | ||
if ($rel =~ s/^not_//) { | ||
$prefix = '~'; | ||
} | ||
my $infix = $infix{$rel}; | ||
if ($infix) { | ||
return $type eq 'space' ? "$a [$prefix$infix] $b" : "$a <$prefix$infix> $b"; | ||
} | ||
} | ||
elsif ($clips =~ /(?x) ^ \( (line|plane) \s+ (\S+) \) $/) { | ||
#warn "$1, $2"; | ||
my ($type, $a) = ($1, $2); | ||
my $prefix = $prefix{$type}; | ||
return "$prefix $a"; | ||
} | ||
elsif ($clips =~ /(?x) ^ \( (\S+) ((?:\s+ \S+)*) \) $/) { | ||
my ($func, $args) = ($1, $2); | ||
$args =~ s/^\s+//g; | ||
my @args = split /\s+/, $args; | ||
return "$func(" . join(',', @args) . ')'; | ||
} | ||
$clips; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters