visilibity 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,131 @@
1
+ require 'VisiLibity_native' # .(so|bundle)
2
+ require 'enumerator'
3
+
4
+ module VisiLibity
5
+
6
+ # Enables enumeration over Swig collections implementing size_method
7
+ # and index().
8
+ def self.SwigEnumerable(size_method=:size)
9
+ Module.new do
10
+ include Enumerable
11
+ # Must eval a string here because #each takes a block. Oh bother.
12
+ class_eval <<-RUBY
13
+ def each
14
+ (0...#{size_method}).each{|i| yield self.index(i)}
15
+ end
16
+ RUBY
17
+ end
18
+ end
19
+
20
+ def self.Inspectors(*fake_ivars)
21
+ Module.new do
22
+ define_method :inspect do
23
+ ivar_str = fake_ivars.map{|iv| "@#{iv}=#{send(iv).inspect}"}.join(" ")
24
+ "#<%s:0x%x %s>" % [self.class.name, object_id, ivar_str]
25
+ end
26
+ end
27
+ end
28
+
29
+ # C++ structs only get 0-arg constructors in swig. Trickery to override that.
30
+ class BoundingBox
31
+ include VisiLibity::Inspectors(:x_min, :x_max, :y_min, :y_max)
32
+ def self.new(x_min, x_max, y_min, y_max)
33
+ bb = allocate
34
+ bb.send(:initialize)
35
+ bb.x_min, bb.x_max = x_min, x_max
36
+ bb.y_min, bb.y_max = y_min, y_max
37
+ bb
38
+ end
39
+ end
40
+
41
+ class Point
42
+ def inspect
43
+ "(#{x},#{y})"
44
+ end
45
+ end
46
+
47
+ class LineSegment
48
+ include VisiLibity::Inspectors(:first, :second)
49
+ end
50
+
51
+ class Angle
52
+ include VisiLibity::Inspectors(:angle)
53
+ def angle
54
+ get()
55
+ end
56
+
57
+ def angle=(a)
58
+ set(a)
59
+ end
60
+ end
61
+
62
+ class PolarPoint
63
+ include VisiLibity::Inspectors(:range, :bearing)
64
+ end
65
+
66
+ class Ray
67
+ include VisiLibity::Inspectors(:base_point, :bearing)
68
+ end
69
+
70
+ class Polyline
71
+ include VisiLibity::SwigEnumerable(:size)
72
+ include VisiLibity::Inspectors(:vertices)
73
+
74
+ def vertices
75
+ to_a
76
+ end
77
+
78
+ def [](x)
79
+ index(x) # work around swig
80
+ end
81
+ end
82
+
83
+ class Polygon
84
+ include VisiLibity::SwigEnumerable(:n)
85
+ include VisiLibity::Inspectors(:vertices)
86
+
87
+ def vertices
88
+ to_a
89
+ end
90
+
91
+ def [](x)
92
+ index(x)
93
+ end
94
+ end
95
+
96
+ class Environment
97
+ include VisiLibity::Inspectors(:outer_boundary, :holes)
98
+
99
+ def outer_boundary
100
+ self[0]
101
+ end
102
+
103
+ def each_hole
104
+ (0..h-1).each{|i| yield self.index(i+1)}
105
+ end
106
+
107
+ def holes
108
+ Enumerable::Enumerator.new(self, :each_hole).to_a
109
+ end
110
+
111
+ def [](x)
112
+ index(x)
113
+ end
114
+ end
115
+
116
+ class Guards
117
+ include VisiLibity::SwigEnumerable(:n)
118
+ include VisiLibity::Inspectors(:guards)
119
+
120
+ def guards
121
+ to_a
122
+ end
123
+ end
124
+
125
+ class VisibilityPolygon # < Polygon
126
+ end
127
+
128
+ class VisibilityGraph
129
+ end
130
+
131
+ end
metadata ADDED
@@ -0,0 +1,64 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: visilibity
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Karl J. Obermeyer
8
+ - Brad Ediger
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2009-05-19 00:00:00 -05:00
14
+ default_executable:
15
+ dependencies: []
16
+
17
+ description:
18
+ email: opensource@madriska.com
19
+ executables: []
20
+
21
+ extensions:
22
+ - ext/VisiLibity/extconf.rb
23
+ extra_rdoc_files: []
24
+
25
+ files:
26
+ - ext/VisiLibity
27
+ - ext/VisiLibity/extconf.rb
28
+ - ext/VisiLibity/Makefile
29
+ - ext/VisiLibity/README.visilibity
30
+ - ext/VisiLibity/visilibity.cpp
31
+ - ext/VisiLibity/visilibity.hpp
32
+ - ext/VisiLibity/VisiLibity.i
33
+ - ext/VisiLibity/VisiLibity_wrap.cxx
34
+ - lib/visilibity.rb
35
+ - lib/VisiLibity_native.bundle
36
+ - Rakefile
37
+ has_rdoc: false
38
+ homepage: http://github.com/madriska/visilibity-ruby
39
+ post_install_message:
40
+ rdoc_options: []
41
+
42
+ require_paths:
43
+ - lib
44
+ required_ruby_version: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: "0"
49
+ version:
50
+ required_rubygems_version: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: "0"
55
+ version:
56
+ requirements: []
57
+
58
+ rubyforge_project: visilibity
59
+ rubygems_version: 1.3.1
60
+ signing_key:
61
+ specification_version: 2
62
+ summary: Ruby bindings to the VisiLibity library (www.visilibity.org)
63
+ test_files: []
64
+