J'ai besoin d'aide pour démarrer en Python (dont je ne sais presque rien) pour voxéliser un maillage 3D généré depuis Rhino. L'entrée de données sera un fichier .OBJ et il en sera de même pour la sortie. Le but ultime de cet usage est de trouver la distance la plus courte entre deux points dans un bâtiment. Mais c'est pour plus tard. Pour le moment, je dois d'abord voxéliser un maillage 3D. La primitive voxelization peut simplement être un simple cube. Jusqu'à présent, je peux lire à partir d'un analyseur de fichier OBJ et hors de l'obj analysé avec les préfixes V, VT, VN, F dépouillés, et en utilisant ces coordonnées pour trouver la boîte de délimitation de l'objet 3D. Quelle devrait être la bonne façon de voxéliser le mesh?En Python, comment voxéliser un maillage 3D?
import objParser
import math
inputFile = 'test.obj'
vList = []; vtList = []; vnList = []; fList = []
def parseOBJ(inputFile):
list = []
vList, vtList, vnList, fList = objParser.getObj(inputFile)
print 'in parseOBJ'
#print vList, vtList, vnList, fList
return vList, vtList, vnList, fList
def findBBox(vList):
i = 0; j=0; x_min = float('inf'); x_max = float('-inf'); y_min = float('inf');
y_max = float('-inf'); z_min = float('inf'); z_max = float('-inf');
xWidth = 0; yWidth = 0; zWidth =0
print 'in findBBox'
while i < len(vList):
#find min and max x value
if vList[i][j] < x_min:
x_min = float(vList[i][j])
elif vList[i][j] > x_max:
x_max = float(vList[i][j])
#find min and max y value
if vList[i][j + 1] < y_min:
y_min = float(vList[i][j + 1])
elif vList[i][j + 1] > y_max:
y_max = float(vList[i][j + 1])
#find min and max x value
if vList[i][j + 2] < z_min:
z_min = vList[i][j + 2]
elif vList[i][j + 2] > z_max:
z_max = vList[i][j + 2]
#incriment the counter int by 3 to go to the next set of (x, y, z)
i += 3; j=0
xWidth = x_max - x_min
yWidth = y_max - y_min
zWidth = z_max - z_min
length = xWidth, yWidth, zWidth
volume = xWidth* yWidth* zWidth
print 'x_min, y_min, z_min : ', x_min, y_min, z_min
print 'x_max, y_max, z_max : ', x_max, y_max, z_max
print 'xWidth, yWidth, zWidth : ', xWidth, yWidth, zWidth
return length, volume
def init():
list = parseOBJ(inputFile)
findBBox(list[0])
print init()
Binvox a déménagé à [cet emplacement] (http://www.patrickmin.com/binvox/) –
Merci pour l'info @A_A, j'ai mis à jour le lien . – kolenda