์ ์ ํ์ ๋ถํฌ๋ช ๋๋ฅผ ๊ธฐ๋ณธ๊ฐ(1.0)์ด ์๋ ๋ค๋ฅธ ๊ฐ์ผ๋ก ๋ณ๊ฒฝํ๋ฉด ์คํธ๋ฆผ๋ผ์ธ์ ๊ฐ๋ ค์ผ ํ๋ ๋ค๋ฅธ ๊ฐ์ฒด๊ฐ ์๋ ๊ฒฝ์ฐ์๋ ์ฅ๋ฉด์ ์ ๋ฉด์ ์ ์ ํ์ด ํ์๋ฉ๋๋ค.
์๋ฅผ ๋ค์ด, http://docs.enthought.com/mayavi/mayavi/auto/example_magnetic_field_lines.html์ ์ ๊ณต๋ ์๊ธฐ์ฅ์ ์๋ฅผ
์ฝ๋๋ฅผ ์๋ ๊ทธ๋๋ก ์คํํ๋ฉด ๋ค์ ์ฅ๋ฉด์ด ํ์๋ฉ๋๋ค.
๊ทธ๋ฌ๋ ํ๋๋ผ์ธ์ ๋ถํฌ๋ช
๋๋ฅผ ๋ณ๊ฒฝํ์ฌ ๊ธฐ๋ณธ๊ฐ 1.0์ ๋ค๋ฅด๊ฒ ํ๋ฉด( field_lines.actor.property.opacity = 0.99
ํ๊ฑฐ๋ Mayavi ํ์ดํ๋ผ์ธ์์ ์๋์ผ๋ก ๋ถํฌ๋ช
๋๋ฅผ ์กฐ์ ํ์ฌ) ๋ค์ ์ฅ๋ฉด๊ณผ ๊ฐ์ ๊ฒฐ๊ณผ๋ฅผ ์ป์ต๋๋ค.
ํ๋๋ผ์ธ์ ์ด์ ์ฅ๋ฉด์ ์ ๋ฉด์ ์์ง๋ง ๋ฑ๊ณ ์ ์ ์ด์ ์ด๋ฏธ์ง์ ๊ฐ์ด ์ฌ์ ํ ๋ชจํธํด์ผ ํฉ๋๋ค.
์ด๊ฒ์ ๊ฐ๊น์ด ์ฅ๋์ ๊ณ ์น ์ ์๋ ๋ฌธ์ ์ ๋๊น? ๊ทธ๋ ์ง ์๋ค๋ฉด ๋ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๋ ๋ค๋ฅธ ๋ฐฉ๋ฒ์ ์ฐพ์ ์ ์๋๋ก ์๋ ค์ฃผ์๋ฉด ๊ฐ์ฌํ๊ฒ ์ต๋๋ค. ๊ฐ์ฌํฉ๋๋ค
์ด๊ฒ์ ๋ค๋ฅธ ๊ฐ์ฒด์๋ ์ ์ฉ๋๋ ๊ฒ ๊ฐ์ต๋๋ค. ์ ๋ points3d์ ํจ๊ป contour3d๋ฅผ ์ฌ์ฉํ๊ณ ์์ผ๋ฉฐ ํฌ์ธํธ์ ๋ถํฌ๋ช ๋๋ฅผ 1.0์ด ์๋ ๋ค๋ฅธ ๊ฐ์ผ๋ก ์ค์ ํ๋ฉด ํ๋ฉด์ด ๋ ์ด์ ํฌ์ธํธ๋ฅผ ๊ฐ๋ฆฌ์ง ์๊ฒ ๋ฉ๋๋ค.
๋ ๊ฐ์ points3d ๊ฐ์ฒด์ ๋ํด ๋์ผํ ๋ฌธ์ ๋ผ๊ณ ์๊ฐํ๋ ๊ฒ์ด ๋ฌด์์ธ์ง ์ ์ ์์ต๋๋ค. ๋ค์์ ๋ถํฌ๋ช ๋๊ฐ .99๋ก ์ค์ ๋ ๊ฒฝ์ฐ ๋ ๋๋ง ์์์ ๋ฐ๋ผ ๋ ๋๋ง๋๋ 2๊ฐ์ ๊ตฌ ๋ชจ์์ด ์ด๋ป๊ฒ ๋ฌ๋ผ์ง๋์ง ๋ณด์ฌ์ฃผ๋ ๋ช ๊ฐ์ง ์์ ๋๋ค. ๊ทธ๋ฌ๋ ๋ถํฌ๋ช ๋๊ฐ 1๋ก ์ค์ ๋ ๊ฒฝ์ฐ์๋ ๊ทธ๋ ์ง ์์ต๋๋ค.
mlab.figure()
mlab.points3d(0,0,1,color=(.8,.8,.8),resolution=100,opacity=.99)
mlab.points3d(0,0,0,color=(.8,.8,.8),resolution=100,opacity=.99)
mlab.figure()
mlab.points3d(0,0,0,color=(.8,.8,.8),resolution=100,opacity=.99)
mlab.points3d(0,0,1,color=(.8,.8,.8),resolution=100,opacity=.99)
mlab.figure()
mlab.points3d(0,0,1,color=(.8,.8,.8),resolution=100)
mlab.points3d(0,0,0,color=(.8,.8,.8),resolution=100)
mlab.figure()
mlab.points3d(0,0,0,color=(.8,.8,.8),resolution=100)
mlab.points3d(0,0,1,color=(.8,.8,.8),resolution=100)
์ด ๋ฌธ์ ๋ ์กฐ๋ช ๋๋ light_manager('vtk' ๋๋ 'raymond')์ ์ ํ์ ์์กดํ์ง ์๋ ๊ฒ ๊ฐ์ต๋๋ค.
ํ ๊ฐ์ง ํด๊ฒฐ ๋ฐฉ๋ฒ์ ๋จผ์ ํ๋ฉด ์ํ์ผ๋ก ์ถ์ ๋ฐ๋ผ ๊น์ด๋ณ๋ก ๋ ๋๋งํ ๊ฐ์ฒด๋ฅผ ์ ๋ ฌํ๋ ๊ฒ์ผ ์ ์์ต๋๋ค.
์ ๋ฉด ์ปฌ๋ง ์ต์ ์ ์ผ์ผ ํ ์๋ ์์ต๋๋ค. ์ด ์๋:
mlab.figure()
g1 = mlab.points3d(0,0,1,color=(.8,.8,.8),resolution=100,opacity=.99)
g2 = mlab.points3d(0,0,0,color=(.8,.8,.8),resolution=100,opacity=.99)
g1.actor.property.frontface_culling = True
g2.actor.property.frontface_culling = True
๊ฐ์ฌํฉ๋๋ค Prabhu---frontface_culling์ด ๋น์ฃผ์ผ์ ๊ฐ์ ํ๋ค๊ณ ์๊ฐํ์ง๋ง ๋ ๋๋ง ์์๋ ์ฌ์ ํ ๋ฐํฌ๋ช ํ ๊ฒฝ์ฐ์๋ง ์์์์ต๋๋ค.
๋๋ ๊ทธ ๊ด์ฐฐ์ vtk๋ง์ผ๋ก ์ฌํํ์ต๋๋ค(๋ฎ์ ์์ค์ ๋ฌธ์ ์ ๋๋ค).
๋ ๋ง์ด ์ฝ์ ํ์ vtk์ ํ๋ ๋๋ ๋ ๊ฐ์ ์๋ฃจ์ ์ด ๋ด์ฅ๋์ด ์๋ค๊ณ ์๊ฐํ์ง๋ง ๋ค๋ฅธ ์๋ฃจ์ ์ ๋ ๋๋งํ๊ธฐ ์ ์ ๊ฐ์ฒด๋ฅผ ์ ๋ ฌํ๋ ๊ฒ์ผ ์ ์์ต๋๋ค.
๋ค์์ ๊ด๋ จ์ฑ์ด ์๋ ๊ฒ์ผ๋ก ๋ณด์ด๋ vtk์ ๋ํ ๋ช ๊ฐ์ง ๋งํฌ์
๋๋ค.
https://www.vtk.org/Wiki/VTK/Examples/Cxx/Visualization/CorrectlyRenderingTranslucentGeometry
https://www.vtk.org/Wiki/VTK/Depth_Peeling
๊ทธ๋ฆฌ๊ณ ๊ตฌ์ฒด ์ฌ๋ก๋ฅผ ์ฌํํ๋ ๋ฐ ์ฌ์ฉํ ๋ช ๊ฐ์ง ๋งํฌ:
https://lorensen.github.io/VTKExamples/site/Python/GeometricObjects/Sphere/
https://www.vtk.org/Wiki/VTK/Examples/Cxx/Visualization/Opacity
ํ ๋ก ์ ์ถ๊ฐํ๊ณ ์ ์ฉํ ๋งํฌ๋ฅผ ์ ๊ณตํด ์ฃผ์ ์ ๊ฐ์ฌํฉ๋๋ค. ์ ๋ VTK ๋๋ ๊น์ด ํ๋ง์ ๋ํด ์ ์์ง ๋ชปํ์ง๋ง, ์ ์๋ ์์ ์ ์ ๊ฐ ์์ ์ค์ธ ํ๋ก์ ํธ์์ ํจ๊ณผ๊ฐ ์์๋ ๊ฐ๋จํ ์๋ฃจ์ ์ ๋ค์์ ํฌํจํ๋ ๊ฒ์ด์์ต๋๋ค.
scene = mlab.gcf().scene
scene.renderer.set(use_depth_peeling=True)
๋น์ทํ ๋ฌธ์ ์ ๋ํ ์ด ์ง๋ฌธ์์ ์ฑํํ ..
๋์์ ์ฃผ์ ์ ๊ฐ์ฌํฉ๋๋ค Matt์ Prabhu.
์ค์ ์ฌ์ฉ ์ฌ๋ก์์๋ ์ด 2๊ตฌ ์์ ๋ณด๋ค ๋ ๋์์ด ๋๋ depth_peeling์ ์๋ํ์ต๋๋ค. ๊ทธ๋ฌ๋ ๊ตฌ๋ฅผ ์ฌ์ ๋ ฌํ๋ ๊ฒ๊ณผ ๋น๊ตํ ๋ ๊ฐ์ฅ์๋ฆฌ๊ฐ ๋ ๋ณด์ ๋๋ค...์คํฐ ์จ๋ฆฌ์ด์ฑ์ด ์ฉ์ด์ผ ์ ์๋ค๊ณ ์๊ฐํฉ๋๊น?
f=mlab.figure()
f.scene.renderer.use_depth_peeling=1
g0=mlab.points3d(0,0,1,color=(.8,.8,.8),resolution=100,opacity=.99)
g1=mlab.points3d(0,0,0,color=(.8,.8,.8),resolution=100,opacity=.99)
g0.actor.property.frontface_culling = True
g1.actor.property.frontface_culling = True
3D ํ๋กํ ์ ๊ฒฝ์ฐ ํฌ์ธํธ ๋ชฉ๋ก๊ณผ ์์ ๋ชฉ๋ก์ด ์์ต๋๋ค. ๋ฐ๋ผ์ ๊น์ด ํ๋ง ๋์ ์ด ํจ์๋ฅผ ์ฌ์ฉํ์ฌ ํ๋กํ ํ๊ธฐ ์ ์ ํด๋น ๋ชฉ๋ก์ ํจ๊ป ์ฌ์ ๋ ฌํ์ต๋๋ค.
def orderTransparentRender(cl,c):
'''Opacity < 1 rendering results in appearance of spheres incorrectly in front of or behind other spheres
One solution is setting f.scene.renderer.use_depth_peeling=1, however this seemed to result in less anti-aliased edges?
This function sorts the cluster list cl and color list c together.
'''
cz=zip(cl,c)
cz=sorted(cz,key=lambda x:-1*x[0][2])
cz=zip(*cz)
return cz[0],cz[1]
๊ทธ๋ ์ง ์์ผ๋ฉด ์ ๋ ฌ๋ ํธ์ถ๋ง ์์ผ๋ฉด ๋ฉ๋๋ค. ๋๋ ํ์ด์ฌ ๋ฌธ์์์ ๊ทธ๊ฒ์ ๋ฐฐ์ ์ต๋๋ค: https://wiki.python.org/moin/HowTo/Sorting. ์ฌ๊ธฐ์์ ํ์ด์ฌ์ zip
์ ๋ํด ๋ฐฐ์ ์ต๋๋ค. https://stackoverflow.com/questions/1663807/how-can-i-iterate-through-two-lists-in-parallel
์ต๊ทผ VTK ๋ฒ์ ์์๋ ๋ค์๊ณผ ๊ฐ์ด ์ ์๋ํฉ๋๋ค.
from mayavi import mlab
f = mlab.figure()
mlab.points3d(0,0,1,color=(.8,.8,.8),resolution=100,opacity=.99)
mlab.points3d(0,0,0,color=(.8,.8,.8),resolution=100,opacity=.99)
f.scene.renderer.use_depth_peeling = True
๋ํ ์ ์ฌ์ ์ผ๋ก ์ฌ์ฉํ ์ ์๋ f.scene.renderer.maximum_number_of_peels
๊ฐ ์์ต๋๋ค. ๊ธฐ๋ณธ์ ์ผ๋ก 4์ด์ง๋ง ๋ ๋๋ง ์๋๊ฐ ๋๋ ค์ง์ง๋ง ์ ํ ์์ด 0์ผ๋ก ์ค์ ํ ์ ์์ต๋๋ค. ์ด๊ฒ์ผ๋ก ๋์ง ํ ์ ์์ต๋๋ค.
์ด ๋ฌธ์ ๋ฅผ ๋ซ์๋ ๋ ๊น์? ์ด๊ฒ์ ๋ด๊ฐ ์ ์ ๋ณธ ๋ง์ ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๋ ๊ฒ ๊ฐ์ต๋๋ค.
๊ฐ์ฌํฉ๋๋ค. ๋๋ ์ด๊ฒ์ ๊ฐ์ง๊ณ ์ผํ ์ ์์ ๊ฒ์ด๋ค. ์ด ๋ฌธ์ ๋ฅผ ๋ซ์ ์ ์์ต๋๋ค.
๋งคํ ์ฌ์ฝ | ๋ฐ์ฌ ์ฐ๊ตฌ์
์
ฐํ๋ ๋ํ๊ต | ์ํ๊ณผ ํต๊ณํ๋ถ
www.matthewallcock.co.uk
2018๋
8์ 26์ผ ์ผ์์ผ 21:55 Prabhu Ramachandran, [email protected]
์ผ๋ค:
์ต๊ทผ VTK ๋ฒ์ ์์๋ ๋ค์๊ณผ ๊ฐ์ด ์ ์๋ํฉ๋๋ค.
Mayavi ๊ฐ์ ธ์ค๊ธฐ mlab์์
f = mlab.Figure()
mlab.points3d(0,0,1,์์=(.8,.8,.8),ํด์๋=100,๋ถํฌ๋ช ๋=.99)
mlab.points3d(0,0,0,์์=(.8,.8,.8),ํด์๋=100,๋ถํฌ๋ช ๋=.99)
f.scene.renderer.use_depth_peeling = True๋ํ f.scene.renderer.maximum_number_of_peels๊ฐ ์์ต๋๋ค.
์ ์ฌ์ ์ผ๋ก ์ฌ์ฉํฉ๋๋ค. ๊ธฐ๋ณธ๊ฐ์ 4์ด์ง๋ง ์๋์ค์ ๊ฒฝ์ฐ 0์ผ๋ก ์ค์ ํ ์ ์์ต๋๋ค.
์ ํํ์ง๋ง ๋ ๋๋ง ์๋๊ฐ ๋๋ ค์ง๋๋ค. ์ด๊ฒ์ผ๋ก ๋์ง ํ ์ ์์ต๋๋ค.์ด ๋ฌธ์ ๋ฅผ ๋ซ์๋ ๋ ๊น์? ์ด๊ฒ์ ๋ด๊ฐ ๊ฐ์ง ๋ง์ ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๋ ๊ฒ ๊ฐ์ต๋๋ค
์ ์ ๋ณธ.โ
์ค๋ ๋๋ฅผ ์์ฑํ๊ธฐ ๋๋ฌธ์ ์ด ๋ฉ์์ง๋ฅผ ๋ฐ๋ ๊ฒ์ ๋๋ค.
์ด ์ด๋ฉ์ผ์ ์ง์ ๋ต์ฅํ๊ณ GitHub์์ ํ์ธํ์ธ์.
https://github.com/enthought/mayavi/issues/491#issuecomment-416071420 ,
๋๋ ์ค๋ ๋ ์์๊ฑฐ
https://github.com/notifications/unsubscribe-auth/AP4RUC8AYAnDAV6-wE88hHw5cPP-x01gks5uUwtGgaJpZM4MT7Rp
.
๊ฐ์ฌํฉ๋๋ค.
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
์ต๊ทผ VTK ๋ฒ์ ์์๋ ๋ค์๊ณผ ๊ฐ์ด ์ ์๋ํฉ๋๋ค.
๋ํ ์ ์ฌ์ ์ผ๋ก ์ฌ์ฉํ ์ ์๋
f.scene.renderer.maximum_number_of_peels
๊ฐ ์์ต๋๋ค. ๊ธฐ๋ณธ์ ์ผ๋ก 4์ด์ง๋ง ๋ ๋๋ง ์๋๊ฐ ๋๋ ค์ง์ง๋ง ์ ํ ์์ด 0์ผ๋ก ์ค์ ํ ์ ์์ต๋๋ค. ์ด๊ฒ์ผ๋ก ๋์ง ํ ์ ์์ต๋๋ค.์ด ๋ฌธ์ ๋ฅผ ๋ซ์๋ ๋ ๊น์? ์ด๊ฒ์ ๋ด๊ฐ ์ ์ ๋ณธ ๋ง์ ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๋ ๊ฒ ๊ฐ์ต๋๋ค.