Notifications
Clear all
[Closed] get Index of reversed Spline
Page 2 / 2
Prev
Oct 03, 2017 8:41 pm
Absolutly, I just realized it
Here is a much faster version, with no memory footprint.
(
fn IBitarrayToBitarray IBitArray =
(
result = #{}
if not IBitArray.isEmpty do
(
gi = (dotNetClass "Autodesk.Max.GlobalInterface").instance
tmp = gi.BitArray.Create IBitArray.Size
BitAnd = tmp.BitwiseAndWith
_clear = tmp.ClearAll
_set = tmp.Set
for j = 0 to IBitArray.Size-1 do
(
_clear()
_set j
if (BitAnd IBitArray).AnyBitSet do result[j+1] = true
)
)
return result
)
)
Oct 03, 2017 8:41 pm
Great, it’s much better now.
I got around ~3 seconds to convert 100k IBitArray.
1 Reply
Well, if you put it that way it sounds like terribly slow ;), and it is indeed.
If you can compile a C# method it should be pretty fast tough.
Oct 03, 2017 8:41 pm
Looks like I found a solution
fn IBitArrayToBitArray var IBitArray = (
global tmpMxsValue = var
local g = (dotnetclass "Autodesk.Max.GlobalInterface").Instance
local fpv = g.fpvalue.create asdotnetobject:true
g.ExecuteMAXScriptScript "::tmpMxsValue" true &fpv
fpv.bits.assign ibitarray
tmpMxsValue = undefined
var
)
(
for x in #(100,1000,10000,100000,1000000) do (
format "------------------- % -------------------
" x
gc()
t1=timestamp()
hf = heapfree
ba = #{}
for i=1 to x by 3 do ba[i] = true
format "mxs bitarray Time: %sec. Mem: % numberset:%
" ((timestamp()-t1)/1000 as float) (hf-heapfree) ba.numberset
gc()
t1=timestamp()
hf = heapfree
bb = (dotNetClass "Autodesk.Max.GlobalInterface").instance.BitArray.Create ba.count
func = bb.set
for b in ba do func (b-1)
format "bitarray to IBitArray Time: %sec. Mem: %
" ((timestamp()-t1)/1000 as float) (hf-heapfree)
gc()
t1=timestamp()
hf = heapfree
xx = #{}
IBitArrayToBitArray xx bb
format "Convert Time: %sec. Mem: % numberset:%
" ((timestamp()-t1)/1000 as float) (hf-heapfree) xx.numberset
)
)
Page 2 / 2
Prev