> Do you have a small example demonstrating this bug (disable_render not
> working). It would help us find the problem.

Here goes. Not so small, but the smallest I could whip up in a short while. 
Now, I also found out who is to blame: the DepthSortPolyData on line 42. If I 
use con3 directly as input to surface, the errors disappear.

This is rather sad, since I need that filter to enable correct rendering of 
semi-opaque surfaces (thanks for bringing that to my knowledge, Gaël, btw).

> The publisher is doing the page layout right now. The volume will be
> March/Apri 2011 (vol. 13 issue. 2). It's a special edition on Python in
> Science. Should be interesting, hopefully.

Thanks, I'll update. Did you have a preprint url, too?

Cheers,
-Juha
#!/usr/bin/env python

from __future__ import division
import numpy,h5py,sys,time,os
from enthought.mayavi import mlab
from enthought.mayavi.sources.array_source import ArraySource

def generate_data(a,b):
    X,Y,Z = numpy.mgrid[-3:3:0.2,-3:3:0.2,-3:3:0.2]
    scale = 1.0
    L     = 2.5
    rsqr  = X*X+Y*Y+Z*Z
    rr    = numpy.sqrt(rsqr)
    fofr  = numpy.zeros_like(rr)
    fofr[rr/scale<L] = numpy.pi*(L-rr[rr/scale<L]/scale)/L
    U11   = numpy.cos(fofr) + 1j*numpy.sin(fofr)/rr*Z
    U21   = (1j*X - Y)*numpy.sin(fofr)/rr
    W     = U11**b/U21**a;
    #W=numpy.nan_to_num(W)
    norm  = numpy.abs(W)**2+1;
    phi1  = numpy.zeros_like(W.real)
    phi2  = numpy.zeros_like(W.real)
    phi3  = numpy.ones_like(W.real)
    phi1[numpy.isfinite(W)]  = 2*(W.real/norm)[numpy.isfinite(W)]
    phi2[numpy.isfinite(W)]  = 2*(W.imag/norm)[numpy.isfinite(W)]
    phi3[numpy.isfinite(W)]  = ((numpy.abs(W)**2-1)/norm)[numpy.isfinite(W)]
    return phi1,phi2,phi3
	

# plot something
phi1,phi2,phi3 = generate_data(3,2)
source=mlab.pipeline.scalar_field(phi3.T, name="phi", transpose_input_array=False)
ds=source.mlab_source.dataset
ds.point_data.scalars.name="phi3"
nid2 = ds.point_data.add_array(phi2.ravel())
ds.point_data.get_array(nid2).name = "phi2"
nid1 = ds.point_data.add_array(phi1.ravel())
ds.point_data.get_array(nid1).name = "phi1"
act3 = mlab.pipeline.set_active_attribute(source, point_scalars='phi3', name="activate_phi3")
con3 = mlab.pipeline.contour(act3, name="latitude_contour")
camera=mlab.gcf().scene.camera
sorted=mlab.pipeline.user_defined(con3, filter="DepthSortPolyData")
sorted.filter.camera=camera
con3plot = mlab.pipeline.surface(sorted, color=(1,1,1), opacity=0.5)
act3c = mlab.pipeline.set_active_attribute(source, point_scalars='phi3',
                                           name="activate_phi3_for_core")
# the pipeline will die if there are no points where phi3<0, so if that happens, we set strange limits...
if (act3c.mlab_source.scalars.min()>=0.0):
    up=act3c.mlab_source.scalars.max()
else:
    up=0.0

low=act3c.mlab_source.scalars.min()
filtered3 = mlab.pipeline.threshold(act3c, up=up, low=low, name="filtered phi3")
filtered3.auto_reset_upper=False
act2f3 = mlab.pipeline.set_active_attribute(filtered3, point_scalars='phi2', name="activate_phi2")
con2f3 = mlab.pipeline.contour(act2f3, name="phi2==0")
act1_on_2 = mlab.pipeline.set_active_attribute(con2f3, point_scalars='phi1', name="activate_phi1_on_phi2==0")
con1_on_2 = mlab.pipeline.contour(act1_on_2, name="phi1==0")
phi3core = mlab.pipeline.set_active_attribute(con1_on_2, point_scalars='phi3', name="activate_core")
coreplot = mlab.pipeline.surface(phi3core, color=(0,0,1), line_width=5.0, name="core")
act1c = mlab.pipeline.set_active_attribute(source, point_scalars='phi1',
                                           name="activate_phi1_for_core")
filtered1 = mlab.pipeline.threshold(act1c, up=0.0, name="filtered phi1")
filtered1.auto_reset_upper=False
act2f1 = mlab.pipeline.set_active_attribute(filtered1, point_scalars='phi2', name="activate_phi2")
con2f1 = mlab.pipeline.contour(act2f1, name="phi2==0")
act3_on_2 = mlab.pipeline.set_active_attribute(con2f1, point_scalars='phi3', name="activate_phi3_on_phi2==0")
con3_on_2 = mlab.pipeline.contour(act3_on_2, name="phi3==0")
phi1core = mlab.pipeline.set_active_attribute(con3_on_2, point_scalars='phi1', name="activate_phi1_preimage")
phi1plot = mlab.pipeline.surface(phi1core, color=(1,0,0), line_width=5.0, name="phi1==1")           
core = phi3core


# then replace some data...
phi1,phi2,phi3 = generate_data(3,3)
mlab.gcf().scene.disable_render=True
filtered1.auto_reset_upper=True
filtered3.auto_reset_upper=True
S=source
ds=S.mlab_source.dataset
for i in range(ds.point_data.number_of_arrays-1,-1,-1):
    if (ds.point_data.get_array(i) is not None):
        ds.point_data.remove_array(ds.point_data.get_array(i).name)

S.mlab_source.set(scalars=phi3.T)
ds.point_data.scalars.name = 'phi3'
ds.modified()
nid2 = ds.point_data.add_array(phi2.ravel())
ds.point_data.get_array(nid2).name = "phi2"
nid1 = ds.point_data.add_array(phi1.ravel())
ds.point_data.get_array(nid1).name = "phi1"
ds.modified()
filtered1.auto_reset_upper=False
filtered3.auto_reset_upper=False
filtered1.upper_threshold=0.0
filtered3.upper_threshold=0.0
filtered1.update_pipeline() # for SOME reason, this is NOT necessary for correct operation, nut
filtered3.update_pipeline() # this IS - go figure
ds.modified()
mlab.gcf().scene.disable_render=False
------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
MayaVi-users mailing list
MayaVi-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mayavi-users

Reply via email to