Voxelisation - 2nd Prototype

A forum dedicated to the Draft, Arch and BIM workbenches development.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
paullee
Veteran
Posts: 5135
Joined: Wed May 04, 2016 3:58 pm

Voxelisation - 2nd Prototype

Post by paullee »

[EDIT - Subject further updated 2021.9.24 - see https://forum.freecadweb.org/viewtopic. ... 06#p535506 ]
[Originally : Voxelisation - 1st Prototype ]

Watched and motivated by dimitar video on using Blender on architectural use, trying how voxelisation could be done in FreeCAD
dimitar wrote: Ping
By use of Python script only at the moment, it seems simple :)

[EDIT] Any idea if similar feature is built-in somewhere in FreeCAD ? (better implemented in C++ for Python would be comparatively quite slow in this)

phpBB [video]
paullee
Veteran
Posts: 5135
Joined: Wed May 04, 2016 3:58 pm

Re: Voxelisation

Post by paullee »

More test :)

Only my i3 built-in graphic does not cater 1038 Links object well :D Probably Link Array which is only 1 object with many Link Elements should optimise performance.

File size is only about 4xxKB.

phpBB [video]
carlopav
Veteran
Posts: 2062
Joined: Mon Dec 31, 2018 1:49 pm
Location: Venice, Italy

Re: Voxelisation

Post by carlopav »

nice, did you check with realthunder linkdaily if visualization the performance is better?
follow my experiments on BIM modelling for architecture design
paullee
Veteran
Posts: 5135
Joined: Wed May 04, 2016 3:58 pm

Re: Voxelisation

Post by paullee »

Thanks! Realthunder's implementation of Links has already lots to learn :D

I have treid his branch, testing this and that, and particularly lighting which is very impressive indeed ! Hope have more gap to test if performance would be better.

But I hope the 0.19/0.20_pre built-in Link with Elements should already helps this case, so 1 Link with 1038 Link Elements, rather than 1038 LInks.
paullee
Veteran
Posts: 5135
Joined: Wed May 04, 2016 3:58 pm

Re: Voxelisation

Post by paullee »

I am wrong :lol:

I am able to make 1 Link with 1038 elements but no improvement in graphic performance.

(File size is super small, with 1038 Links, it is 4xx KB; 1 Link with 1038 Elements, it is only 8xKB !!!)
Screenshot from 2021-08-14 18-34-33.png
Screenshot from 2021-08-14 18-34-33.png (346.52 KiB) Viewed 3469 times
otaolafr
Posts: 13
Joined: Tue Nov 10, 2020 4:54 pm

Re: Voxelisation

Post by otaolafr »

paullee wrote: Sat Aug 14, 2021 10:37 am I am wrong :lol:

I am able to make 1 Link with 1038 elements but no improvement in graphic performance.

(File size is super small, with 1038 Links, it is 4xx KB; 1 Link with 1038 Elements, it is only 8xKB !!!)

Screenshot from 2021-08-14 18-34-33.png
Hello,
paullee I am trying to do more or less the same workflow that you are doing with another application than architectural, the main difference is that I would like to fill up completely the original object (even if the "voxel" is not completely inside of it) and then intersect them with the solid. would it be possible to share the python script? I am having quite headache scripting with freecad....(actually, I came to the forum to ask some questions and saw your post ahahah). It would help me to learn a little bit and create my own script that does what I am looking for.
paullee
Veteran
Posts: 5135
Joined: Wed May 04, 2016 3:58 pm

Re: Voxelisation

Post by paullee »

otaolafr wrote: Sun Aug 15, 2021 5:45 pm I am trying to do more or less the same workflow that you are doing with another application than architectural, the main difference is that I would like to fill up completely the original object (even if the "voxel" is not completely inside of it) and then intersect them with the solid. would it be possible to share the python script? I am having quite headache scripting with freecad....(actually, I came to the forum to ask some questions and saw your post ahahah). It would help me to learn a little bit and create my own script that does what I am looking for.
The script is only a quick study to test out the idea, you may like to have a look if it help you to develop it further :)

You may find many variables are hard-coded with the model file attached.

Good luck :D


Test_ Voxel_ 3_ Link w ElementCount.FCStd
(81.88 KiB) Downloaded 68 times

Code: Select all


doc = App.ActiveDocument
obj = doc.getObject('Cut001')
box = doc.getObject('Group')
v = doc.addObject('App::Link')
v.setLink(box)
vv = doc.addObject('App::Link')
vv.setLink(v)
vv.ShowElement=False
count = 0
pList = []
if True:  # Just to make below run in python console in 1 go
  for xx in range (0,10):
    for yy in range(0,10):
        for zz in range(0,16):
            xl = xx*1000
            yl = yy*1000
            zl = zz*1000
            v = None
            if obj.Shape.isInside(App.Vector(xl,yl,zl),0,True): # if point lies on a face it's considered inside
                count = count + 1
                pList.append(App.Placement(App.Vector(xl,yl,zl),App.Rotation(App.Vector(0,0,1),0)))
  print(count)
  vv.ElementCount = count
  vv.PlacementList = pList

otaolafr
Posts: 13
Joined: Tue Nov 10, 2020 4:54 pm

Re: Voxelisation

Post by otaolafr »

paullee wrote: Mon Aug 16, 2021 12:29 am
otaolafr wrote: Sun Aug 15, 2021 5:45 pm I am trying to do more or less the same workflow that you are doing with another application than architectural, the main difference is that I would like to fill up completely the original object (even if the "voxel" is not completely inside of it) and then intersect them with the solid. would it be possible to share the python script? I am having quite headache scripting with freecad....(actually, I came to the forum to ask some questions and saw your post ahahah). It would help me to learn a little bit and create my own script that does what I am looking for.
The script is only a quick study to test out the idea, you may like to have a look if it help you to develop it further :)

You may find many variables are hard-coded with the model file attached.

Good luck :D



Test_ Voxel_ 3_ Link w ElementCount.FCStd

Code: Select all


doc = App.ActiveDocument
obj = doc.getObject('Cut001')
box = doc.getObject('Group')
v = doc.addObject('App::Link')
v.setLink(box)
vv = doc.addObject('App::Link')
vv.setLink(v)
vv.ShowElement=False
count = 0
pList = []
if True:  # Just to make below run in python console in 1 go
  for xx in range (0,10):
    for yy in range(0,10):
        for zz in range(0,16):
            xl = xx*1000
            yl = yy*1000
            zl = zz*1000
            v = None
            if obj.Shape.isInside(App.Vector(xl,yl,zl),0,True): # if point lies on a face it's considered inside
                count = count + 1
                pList.append(App.Placement(App.Vector(xl,yl,zl),App.Rotation(App.Vector(0,0,1),0)))
  print(count)
  vv.ElementCount = count
  vv.PlacementList = pList

thanks a lot! :D
paullee
Veteran
Posts: 5135
Joined: Wed May 04, 2016 3:58 pm

Re: Voxelisation - 1st Prototype

Post by paullee »

Architectural Worflow Test 2 : 1st Prototype

phpBB [video]
paullee
Veteran
Posts: 5135
Joined: Wed May 04, 2016 3:58 pm

Re: Voxelisation - 1st Prototype

Post by paullee »

Forgot to outline the current / conceiving workflow for comment / suggestion: -


Current Prototype

1. Create the 'voxelisation' object
2. Select the shape object to 'voxelise'
3. Adjust the size of 'voxel'
4. Recompute to return the result

Further Development

5. Can select the shape of voxel, like the previos example with 4 Walls, Windows, Slab etc.
6. Now the size (boundbox) of selected shape is used to 'voxelise' and used as each 'voxel'
Post Reply