-
73.81%
Rate
-
31
Hits
-
11
Missed
- 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
-
-
-
-
-
- 1x
- 1x
- 1x
- 1x
- 1x
- 1x
-
- 1x
-
-
-
-
-
- 1x
-
-
-
- 4x
- 2x
- 2x
- 2x
- 2x
- 2x
-
- 2x
-
-
-
- 1x
- 12x
-
- 12x
- 2x
-
- 10x
-
-
-
-
- 1x
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 4x
- 4x
- 4x
- 2x
-
-
-
-
-
-
-
-
- 4x
- 4x
-
- 4x
-
-
- 2x
- 2x
-
-
-
-
-
-
- 1x
- -------------------------------------------------------------------------------
- -- PUMAS geometry of infinite extension
- -- Author: Valentin Niess
- -- License: GNU LGPL-3.0
- -------------------------------------------------------------------------------
- local ffi = require('ffi')
- local clib = require('pumas.clib')
- local error = require('pumas.error')
- local base = require('pumas.geometry.base')
- local uniform = require('pumas.medium.uniform')
- local metatype = require('pumas.metatype')
-
- local infinite = {}
-
-
- -------------------------------------------------------------------------------
- -- The infinite geometry metatype
- -------------------------------------------------------------------------------
- local InfiniteGeometry = {}
-
-
- local function new (self)
- local c = ffi.cast('struct pumas_geometry_infinite *',
- ffi.C.calloc(1, ffi.sizeof('struct pumas_geometry_infinite')))
- c.base.get = clib.pumas_geometry_infinite_get
- c.base.destroy = ffi.C.free
- if self._medium ~= nil then
- c.medium = ffi.cast('struct pumas_medium *', self._medium._c)
- end
- return ffi.cast('struct pumas_geometry *', c)
- end
-
-
- function InfiniteGeometry:__index (k)
- if k == 'medium' then
- return self._medium
- elseif k == '_new' then
- return new
- else
- return base.BaseGeometry.__index[k]
- end
- end
-
-
- function InfiniteGeometry:__newindex (k, v)
- if k == 'medium' then
- if v == self._medium then return end
- if v.__metatype ~= 'Medium' then
- error.raise{
- fname = k,
- expected = 'a Medium table',
- got = metatype.a(v)
- }
- end
- rawset(self,'_medium', v)
- self._invalidate()
- else
- rawset(self, k, v)
- end
- end
-
-
- -------------------------------------------------------------------------------
- -- The infinite geometry constructor
- -------------------------------------------------------------------------------
- do
- local function new_ (cls, medium)
- local mt = metatype(medium)
- if mt == 'string' then
- medium = uniform.UniformMedium(medium)
- elseif (mt ~= 'nil') and (mt ~= 'Medium') then
- error.raise {
- fname = 'InfiniteGeometry',
- argnum = 1,
- expected = 'a Medium table or a string',
- got = metatype.a(medium)
- }
- end
-
- local self = base.BaseGeometry:new()
- self._medium = medium
-
- return setmetatable(self, cls)
- end
-
- infinite.InfiniteGeometry = setmetatable(InfiniteGeometry,
- {__call = new_})
- end
-
-
- -------------------------------------------------------------------------------
- -- Return the package
- -------------------------------------------------------------------------------
- return infinite