mirror of
https://github.com/wassname/simpeg.git
synced 2026-06-29 23:42:50 +08:00
Fixed interface so the renderer uses Trackball interaction, extent and limits work.
Added a notebook, showing a simple example of using the vtkView
This commit is contained in:
@@ -189,6 +189,7 @@ class vtkTools(object):
|
||||
renwin = vtk.vtkRenderWindow()
|
||||
renwin.AddRenderer(ren)
|
||||
iren = vtk.vtkRenderWindowInteractor()
|
||||
iren.GetInteractorStyle().SetCurrentStyleToTrackballCamera()
|
||||
iren.SetRenderWindow(renwin)
|
||||
|
||||
return iren, renwin
|
||||
|
||||
@@ -30,7 +30,7 @@ class vtkView(object):
|
||||
self.name = 'VTK figure of SimPEG model'
|
||||
self.extent = [0,mesh.nCx-1,0,mesh.nCy-1,0,mesh.nCz-1]
|
||||
self.limits = [0, 1e12]
|
||||
self.viewProp = 0 # Int or name of the vector.
|
||||
self.viewprop = {'cell':0} # Name of the tyep and Int order of the array or name of the vector.
|
||||
self._mesh = mesh
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ class vtkView(object):
|
||||
else:
|
||||
raise(Exception,'{:s} is not allowed as a dictonary key. Can be \'cell\',\'face\',\'edge\'.'.format(propitem[0]))
|
||||
|
||||
def Show(self,imageType='cell'):
|
||||
def Show(self):
|
||||
"""
|
||||
Open the VTK figure window and show the mesh.
|
||||
|
||||
@@ -89,7 +89,7 @@ class vtkView(object):
|
||||
# Make renderwindow. Returns the interactor.
|
||||
self._iren, self._renwin = vtkSP.makeRenderWindow(self._ren)
|
||||
|
||||
|
||||
imageType = self.viewprop.keys()[0]
|
||||
# Sort out the actor
|
||||
if imageType == 'cell':
|
||||
self._vtkobj, self._core = vtkSP.makeRectiVTKVOIThres(self._cell,self.extent,self.limits)
|
||||
@@ -103,12 +103,12 @@ class vtkView(object):
|
||||
raise Exception("{:s} is not a vailid imageType. Has to be 'cell':'face':'edge'".format(imageType))
|
||||
|
||||
# Set the active scalar.
|
||||
if type(self.viewProp) == int:
|
||||
actScalar = self._vtkobj.GetCellData().GetArrayName(self.viewProp)
|
||||
elif type(self.viewProp) == str:
|
||||
actScalar = self.viewProp
|
||||
if type(self.viewprop.values()[0]) == int:
|
||||
actScalar = self._vtkobj.GetCellData().GetArrayName(self.viewprop.values()[0])
|
||||
elif type(self.viewprop.values()[0]) == str:
|
||||
actScalar = self.viewprop.values()[0]
|
||||
else :
|
||||
raise Exception('The vtkView.viewProp has the wrong format. Has to be interger or a string.')
|
||||
raise Exception('The vtkView.viewprop.values()[0] has the wrong format. Has to be interger or a string.')
|
||||
self._vtkobj.GetCellData().SetActiveScalars(actScalar)
|
||||
# Set up the plane, clipper and the user interaction.
|
||||
global intPlane, intActor
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"collapsed": false,
|
||||
"input": "#Make a mesh and model\nx0 = np.zeros(3)\nh1 = np.ones(20)*5\nh2 = np.ones(10)*10\nh3 = np.ones(5)*20\n\nmesh = simpeg.mesh.TensorMesh([h1,h2,h3],x0)\n",
|
||||
"input": "#Make a mesh and model\nx0 = np.zeros(3)\nh1 = np.ones(20)*50\nh2 = np.ones(10)*100\nh3 = np.ones(5)*200\n\nmesh = simpeg.mesh.TensorMesh([h1,h2,h3],x0)\n",
|
||||
"language": "python",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
@@ -43,14 +43,28 @@
|
||||
"outputs": [],
|
||||
"prompt_number": 4
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"collapsed": false,
|
||||
"input": "mesh.nCxx",
|
||||
"language": "python",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"output_type": "pyout",
|
||||
"prompt_number": 7,
|
||||
"text": "20"
|
||||
}
|
||||
],
|
||||
"prompt_number": 7
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"collapsed": false,
|
||||
"input": "",
|
||||
"language": "python",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"prompt_number": 4
|
||||
"outputs": []
|
||||
}
|
||||
],
|
||||
"metadata": {}
|
||||
|
||||
Reference in New Issue
Block a user