File: povray.rules

package info (click to toggle)
polymake 4.14-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 35,888 kB
  • sloc: cpp: 168,933; perl: 43,407; javascript: 31,575; ansic: 3,007; java: 2,654; python: 632; sh: 268; xml: 117; makefile: 61
file content (153 lines) | stat: -rw-r--r-- 4,063 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#  Copyright (c) 1997-2024
#  Ewgenij Gawrilow, Michael Joswig, and the polymake team
#  Technische Universität Berlin, Germany
#  https://polymake.org
#
#  This program is free software; you can redistribute it and/or modify it
#  under the terms of the GNU General Public License as published by the
#  Free Software Foundation; either version 2, or (at your option) any
#  later version: http://www.gnu.org/licenses/gpl.txt.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#-------------------------------------------------------------------------------

package Povray;

CREDIT povray
  Persistence of Vision Ray tracer, a tool for creating 3-d photo-realistic images.
  http://www.povray.org

# a povray renderer, e.g. povray
custom $viewer;

CONFIGURE_OPT {
   find_program($viewer, "povray");
}

# options for povray rendering
custom $cmd_options = "+D +A0.5";

# width of picture
custom $width = 400;

# height of picture
custom $height = 300;

# length of arrow head
custom $headLength = 0.3;

# relative width of arrow head
custom $headWidth = 2;

# thickness of the points
custom $points_thickness = 0.06;

# thickness of the lines/tubes
custom $lines_thickness = 0.03;

# @category Visualization
# Use [[wiki:external_software#povray|POVRAY]] for drawing.
label povray

################################################################################
#
#  Implementing the Viewer interface
#
package Povray::Viewer;

use Povray;
use BackgroundViewer;
use Polymake::Struct [ '@ISA' => 'SimpleViewer' ];

sub file_suffix { ".pov" }

sub new {
   unless (defined $viewer) {
      die <<'.';
requires a complete PoVRay package;
please specify the output File option or call reconfigure("common::povray.rules");
.
   }
   &_new;
}

sub command {
   my ($self, $filename)=@_;
   my $outputfile = $self->graphics->title;
   $outputfile =~ s|[ /.]|_|g;
   if (-e "${outputfile}.tga") {
      my $i = 1;
      ++$i while (-e "${outputfile}_${i}.tga");
      $outputfile .= "_${i}.tga";
   } else {
      $outputfile .= ".tga";
   }
   "$viewer +P -V $cmd_options +W$width +H$height +O$outputfile $filename; echo CREATED $outputfile"
}

sub append {
   my $self=shift;
   $self->graphics->append(@_);
}

global_method povray.geometry: draw(Visual::PointSet, @) {
   my ($self, $P)=@_;
   $self->append(new Povray::PointSet($P));
}

global_method povray.geometry: draw(Visual::Polygon, @) {
   my ($self, $P)=@_;
   if (@{$P->Vertices} >= 3) {
      $self->append(new Povray::Solid($P));
   } else {
      $self->append(new Povray::Wire(new Visual::DegeneratedPolygon($P)));
   }
}

global_method povray.geometry: draw(Visual::Polygons, @) {
   my ($self, $P)=@_;
   $self->append(new Povray::Solid($P));
}

global_method povray.geometry: draw(Visual::Wire, @) {
   my ($self, $G)=@_;
   $self->append(new Povray::Wire($G));
}

#  Writes to a POV file without rendering

package Povray::File::Writer;
import Visual::FileWriter;

###########################################################################################

package application;

# @category Visualization
# Run [[wiki:external_software#povray|POVRAY]] to display given visual objects.
#
# @param Visual::Object vis_obj ... objects to display
#
# @option [complete file] String File "filename" or "AUTO"
#  Store the object description in a POVRAY source file without actual rendering.
#  The ''.pov'' suffix is automatically added to the file name.
#
#  Specify //AUTO// if you want the filename be automatically derived
#  from the drawing title.
#
#  You can also use any expression allowed for the ''open'' function,
#  including "-" for terminal output, "&HANDLE" for an already opened file handle,
#  or "| program" for a pipe.

user_function povray(Visual::Object+, { File => undef }) {
   visualize_explicit(@_, "Povray");
}


# Local Variables:
# mode: perl
# cperl-indent-level:3
# End: