本文整理汇总了Python中PyMca5.Object3D.Object3DCTools类的典型用法代码示例。如果您正苦于以下问题:Python Object3DCTools类的具体用法?Python Object3DCTools怎么用?Python Object3DCTools使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Object3DCTools类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: buildPointList0
def buildPointList0(self):
"""
This is just to test memory and speed
"""
n1, n2, n3 = 256, 256, 256
zdata = numpy.arange(n1*n2*n3).astype(numpy.float32)
zdata.shape= -1, 1
(image,size,minmax)= spslut.transform(zdata,
(1,0),
(spslut.LINEAR,3.0),
"RGBX",
spslut.TEMP,
1,
(0, 1),
(0, 255),1)
image.shape = -1, 4
image[:,3] = 255
#self.vertexColors = image.astype(numpy.float32)
x = numpy.arange(n1).astype(numpy.float32)
y = numpy.arange(n2).astype(numpy.float32)
z = numpy.arange(n3).astype(numpy.float32)
#Object3DCTools.draw3DGridQuads(x, y, y)
#Object3DCTools.draw3DGridLines(x, y, z, image)
Object3DCTools.draw3DGridPoints(x, y, z, image)
self.zdata = zdata
示例2: _drawMesh
def _drawMesh(self):
alpha = 1.0 - self._configuration['common']['transparency']
if alpha < 0:
alpha = 0
elif alpha >= 1.0:
alpha = 255
else:
alpha = int(255 * alpha)
self.pixmap[:, 3] = alpha
shape = self._imageData.shape
self._imageData.shape = -1,1
if DRAW_MODES[self._configuration['common']['mode']] == "POINT":
if False:
Object3DCTools.drawXYZPoints(self.vertices,
self.pixmap)
else:
Object3DCTools.draw2DGridPoints(self._xValues,
self._yValues,
self._zValues,
self.pixmap)
elif DRAW_MODES[self._configuration['common']['mode']] == "WIRE":
Object3DCTools.draw2DGridLines(self._xValues,
self._yValues,
self._zValues,
self.pixmap)
elif DRAW_MODES[self._configuration['common']['mode']] == "SURFACE":
Object3DCTools.draw2DGridQuads(self._xValues,
self._yValues,
self._zValues,
self.pixmap)
self._imageData.shape = shape
示例3: __fillVerticesBufferObject
def __fillVerticesBufferObject(self):
if self.vertices is None:
self.vertices = Object3DCTools.get3DGridFromXYZ(self._x,
self._y,
self._z)
self.indices = numpy.arange(self.nVertices)
self._verticesBufferObject = buffers.VertexBuffer(self.vertices,
GL.GL_STATIC_DRAW)
self.vertices = None
示例4: buildPointListOLD
def buildPointListOLD(self):
if self.vertices is None:
self.vertices = Object3DCTools.get3DGridFromXYZ(self._x,
self._y,
self._z)
GL.glVertexPointerf(self.vertices)
GL.glColorPointerub(self.vertexColors)
GL.glEnableClientState(GL.GL_VERTEX_ARRAY)
GL.glEnableClientState(GL.GL_COLOR_ARRAY)
GL.glDrawArrays(GL.GL_POINTS, 0, self.nVertices)
示例5: buildPointList
def buildPointList(self, selection=False):
if selection:
if self.vertexSelectionColors is None:
self._getVertexSelectionColors()
if self._configuration['private']['colorfilter']:
tinyNumber = 1.0e-10
minValue = self._configuration['common']['colormap'][2] + tinyNumber
maxValue = self._configuration['common']['colormap'][3] - tinyNumber
Object3DCTools.draw3DGridPoints(self._x,
self._y,
self._z,
self.vertexSelectionColors,
self.values,
0,
[1, minValue, maxValue])
else:
Object3DCTools.draw3DGridPoints(self._x,
self._y,
self._z,
self.vertexSelectionColors,
self.values,
0,
self._configuration['private']['useminmax'])
else:
Object3DCTools.draw3DGridPoints(self._x,
self._y,
self._z,
self.vertexColors,
self.values,
self._configuration['private']['colorfilter'],
self._configuration['private']['useminmax'])
示例6: buildPointListXYZ
def buildPointListXYZ(self, selection=False):
if 1:
if selection:
if self.vertexSelectionColors is None:
self._getVertexSelectionColors()
if self._configuration['private']['colorfilter']:
tinyNumber = 1.0e-10
minValue = self._configuration['common']['colormap'][2] + tinyNumber
maxValue = self._configuration['common']['colormap'][3] - tinyNumber
Object3DCTools.drawXYZPoints(self.vertices,
self.vertexSelectionColors,
self.values,
None,
0,
[1, minValue, maxValue])
else:
Object3DCTools.drawXYZPoints(self.vertices,
self.vertexSelectionColors,
self.values,
None,
0,
self._configuration['private']['useminmax'])
else:
Object3DCTools.drawXYZPoints(self.vertices,
self.vertexColors,
self.values,
None,
self._configuration['private']['colorfilter'],
self._configuration['private']['useminmax'])
return
GL.glVertexPointerf(self.vertices)
if selection:
GL.glColorPointerub(self.vertexSelectionColors)
else:
GL.glColorPointerub(self.vertexColors)
GL.glEnableClientState(GL.GL_VERTEX_ARRAY)
GL.glEnableClientState(GL.GL_COLOR_ARRAY)
GL.glDrawArrays(GL.GL_POINTS, 0, self.nVertices)
示例7: buildWireList
def buildWireList(self):
Object3DCTools.draw3DGridLines(self._x,
self._y,
self._z,
self.vertexColors)
示例8: drawObject
def drawObject(self):
if self.values is None:
return
GL.glPushAttrib(GL.GL_ALL_ATTRIB_BITS)
GL.glShadeModel(GL.GL_FLAT)
if DEBUG:
t0=time.time()
if self.drawMode == 'NONE':
pass
elif (GL.glGetIntegerv(GL.GL_RENDER_MODE) == GL.GL_SELECT) or \
self._vertexSelectionMode:
GL.glPointSize(self._configuration['common']['pointsize'])
if self._xyz:
self.buildPointListXYZ(selection=True)
else:
self.buildPointList(selection=True)
elif self.drawMode == 'POINT':
GL.glShadeModel(GL.GL_FLAT)
GL.glPointSize(self._configuration['common']['pointsize'])
if self._xyz:
self.buildPointListXYZ(selection=False)
else:
self.buildPointList(selection=False)
elif self.drawMode == 'POINT_SELECTION':
GL.glShadeModel(GL.GL_FLAT)
GL.glPointSize(self._configuration['common']['pointsize'])
self.buildPointList(selection=True)
elif self.drawMode in ['LINES', 'WIRE']:
GL.glLineWidth(self._configuration['common']['linewidth'])
GL.glShadeModel(GL.GL_SMOOTH)
if self._xyz:
if self.facets is None:
self._getFacets()
Object3DCTools.drawXYZLines(self.vertices,
self.vertexColors,
self.values,
self.facets,
self._configuration['private']['colorfilter'],
self._configuration['private']['useminmax'])
#sys.exit(1)
elif self.__flat:
Object3DCTools.draw3DGridLines(self._x,
self._y,
self._z,
self.vertexColors,
self.values,
self._configuration['private']['colorfilter'],
self._configuration['private']['useminmax'])
else:
Object3DCTools.draw2DGridLines(self._x,
self._y,
self._z,
self.vertexColors,
self.values,
self._configuration['private']['colorfilter'],
self._configuration['private']['useminmax'])
elif self.drawMode == "SURFACE":
GL.glShadeModel(GL.GL_SMOOTH)
if self._xyz:
if self.facets is None:
self._getFacets()
Object3DCTools.drawXYZTriangles(self.vertices,
self.vertexColors,
self.values,
self.facets,
self._configuration['private']['colorfilter'],
self._configuration['private']['useminmax'])
elif self.__flat:
Object3DCTools.draw3DGridQuads(self._x,
self._y,
self._z,
self.vertexColors,
self.values,
self._configuration['private']['colorfilter'],
self._configuration['private']['useminmax'])
else:
Object3DCTools.draw2DGridQuads(self._x,
self._y,
self._z,
self.vertexColors,
self.values,
self._configuration['private']['colorfilter'],
self._configuration['private']['useminmax'])
else:
print("UNSUPPORTED MODE")
GL.glPopAttrib()
if DEBUG:
print("Drawing takes ", time.time() - t0)
示例9: setData
def setData(self, data, x=None, y=None, z=None, xyz=None):
self.values = data[:]
self._configuration['private']['useminmax'] = [0, self.values.min(), self.values.max()]
if (xyz is not None) and (x is None) and (y is None):
arr = Object3DCTools.getVertexArrayMeshAxes(xyz)
if arr is not None:
doit = True
x = arr[0]
if len(x) > 1:
if abs(x[1] - xyz[0,0]) > 1.0e-10:
#not proper C order
#prevent bad plotting of a regular grid
doit = False
x = None
if doit:
y = arr[1]
z = numpy.zeros(x.shape[0]*y.shape[0], numpy.float)
z[:] = xyz[:, 2]
xyz = None
if (x is None) and (y is None) and (xyz is None):
#regular mesh
self.xSize, self.ySize = data.shape
self.zSize = 1
self._x = numpy.arange(self.xSize).astype(numpy.float32)
self._y = numpy.arange(self.ySize).astype(numpy.float32)
if z is not None:
self._z = numpy.array(z).astype(numpy.float32)
if len(self._z.shape) == 0:
#assume just a number
self._z.shape = 1, 1
self.zSize = 1
else:
self._z.shape = -1, 1
self.zSize = self._z.shape[0]
self.__flat = False
else:
self._z = numpy.arange(self.zSize).astype(numpy.float32)
self._z.shape = 1, 1
self.zSize = 1
elif xyz is not None:
#full irregular mesh
self.__setXYZArray(xyz, values=data)
self.xSize = self.vertices.shape[0]
self.ySize = 1
self._x = self.vertices[:,0]
self._y = self.vertices[:,1]
self._z = self.vertices[:,2]
self._xyz = True
elif (x is not None) and (y is not None):
#regular mesh
self._x = numpy.array(x).astype(numpy.float32)
self._y = numpy.array(y).astype(numpy.float32)
self._x.shape = -1, 1
self._y.shape = -1, 1
self.xSize = self._x.shape[0]
self.ySize = self._y.shape[0]
if z is not None:
self._z = numpy.array(z).astype(numpy.float32)
if len(self._z.shape) == 0:
#assume just a number
self._z.shape = 1, 1
self.zSize = 1
else:
self._z.shape = -1, 1
self.zSize = self._z.shape[0]
self.__flat = False
else:
self._z = numpy.arange(self.zSize).astype(numpy.float32)
self._z.shape = 1, 1
self.zSize = 1
else:
raise ValueError("Unhandled case")
self.nVertices = self.xSize * self.ySize
self.values.shape = self.nVertices, 1
self.getColors()
self._obtainLimits()
示例10: Object3DMesh
object3D = Object3DMesh(os.path.basename(f))
else:
data = numpy.arange(200.).astype(numpy.float32)
data.shape = [40, 5]
object3D = Object3DMesh('builtin')
#several options: regular grid, irregular grid
if len(sys.argv) > 1:
#print "IMPOSSING A 1000 OFFSET"
#offset = 1000.0
offset = 0
#irregular grid
xSize, ySize = data.shape[0:2]
zSize = 1
xyz = Object3DCTools.get3DGridFromXYZ(numpy.arange(xSize).astype(numpy.float32)-offset,
numpy.arange(xSize).astype(numpy.float32)+offset,
numpy.arange(1)+1)
a = xyz[:,0] * 1
xyz[:,0] = xyz[:,1] * 1
xyz[:,1] = a[:]
#print xyz[0:3,:]
#print xyz.shape
#print Object3DCTools.getVertexArrayMeshAxes(xyz)
#sys.exit(0)
data.shape = 1, xSize * ySize
xyz[:,2] = data[:]
object3D.setData(data, xyz=xyz)
elif 0:
#flat
object3D.setData(data, z=4)
else:
示例11: drawObject
def drawObject(self):
if self.values is None:
return
if DEBUG:
t0=time.time()
GL.glPushAttrib(GL.GL_ALL_ATTRIB_BITS)
GL.glShadeModel(GL.GL_FLAT)
if self.drawMode == 'NONE':
pass
elif (GL.glGetIntegerv(GL.GL_RENDER_MODE) == GL.GL_SELECT) or \
self._vertexSelectionMode:
self.buildPointList(selection=True)
elif self.drawMode == 'POINT':
self.buildPointList(selection=False)
#self.buildPointListNEW(selection=False)
elif self.drawMode == 'POINT_SELECTION':
self.buildPointList(selection=True)
elif self.drawMode in ['LINES', 'WIRE']:
Object3DCTools.draw3DGridLines(self._x,
self._y,
self._z,
self.vertexColors,
self.values,
self._configuration['private']['colorfilter'],
self._configuration['private']['useminmax'])
elif self.drawMode == "SURFACE":
flag = 1
i = 0
for use, value, label, cr, cg, cb, ca in self._configuration['private']['isosurfaces']:
color = (cr, cg, cb, ca)
if None in color:
color = None
if use:
flag = 0
GL.glEnable(GL.GL_LIGHTING)
if color is not None:
GL.glColor4ub(color[0],
color[1],
color[2],
self._alpha)
colorflag = False
if self.__isosurfacesDict[i]['list'] > 0:
if self.__isosurfacesDict[i]['color'] == color:
colorflag = True
elif (self.__isosurfacesDict[i]['color'] != None) and\
(color != None):
colorflag = True
if self.__isosurfacesDict[i]['list'] > 0:
if (self.__isosurfacesDict[i]['value'] == value) and\
colorflag:
GL.glCallList(self.__isosurfacesDict[i]['list'])
i += 1
continue
GL.glDeleteLists(self.__isosurfacesDict[i]['list'],
1)
self.__isosurfacesDict[i]['value']= value
self.__isosurfacesDict[i]['color']= color
self.__isosurfacesDict[i]['list'] = GL.glGenLists(1)
GL.glNewList(self.__isosurfacesDict[i]['list'],
GL.GL_COMPILE)
GL.glBegin(GL.GL_TRIANGLES)
Object3DCTools.gridMarchingCubes(self._x, self._y, self._z, self.values, value, color, (1, 1, 1), 1)
#Object3DCTools.gridMarchingCubes(self._x, self._y, self._z, self.values, value, None, (1, 1, 1), 1)
GL.glEnd()
GL.glEndList()
GL.glCallList(self.__isosurfacesDict[i]['list'])
GL.glDisable(GL.GL_LIGHTING)
i += 1
if flag:
#This is useless, only isosurfaces makes sense
Object3DCTools.draw3DGridQuads(self._x,
self._y,
self._z,
self.vertexColors,
self.values,
self._configuration['private']['colorfilter'],
self._configuration['private']['useminmax'])
else:
print("UNSUPPORTED MODE")
GL.glPopAttrib()
if DEBUG:
print("Drawing takes ", time.time() - t0)