def __init__(self, module_manager):
     SimpleVTKClassModuleBase.__init__(
         self, module_manager,
         vtk.vtkInterpolateDataSetAttributes(), 'Processing.',
         ('vtkDataSet',), ('vtkDataSet',),
         replaceDoc=True,
         inputFunctions=None, outputFunctions=None)
 def __init__(self, module_manager):
     SimpleVTKClassModuleBase.__init__(
         self,
         module_manager,
         vtk.vtkInterpolateDataSetAttributes(),
         'Processing.', ('vtkDataSet', ), ('vtkDataSet', ),
         replaceDoc=True,
         inputFunctions=None,
         outputFunctions=None)
예제 #3
0
blobbyV.SetSampleDimensions(50,50,12)
blobbyV.SetModelBounds(-0.5,1.5,-0.5,1.5,-0.5,0.5)
# create implicit models of each
blobbyT = vtk.vtkImplicitModeller()
blobbyT.SetInputConnection(letterT.GetOutputPort())
blobbyT.SetMaximumDistance(.2)
blobbyT.SetSampleDimensions(50,50,12)
blobbyT.SetModelBounds(-0.5,1.5,-0.5,1.5,-0.5,0.5)
# create implicit models of each
blobbyK = vtk.vtkImplicitModeller()
blobbyK.SetInputConnection(letterK.GetOutputPort())
blobbyK.SetMaximumDistance(.2)
blobbyK.SetSampleDimensions(50,50,12)
blobbyK.SetModelBounds(-0.5,1.5,-0.5,1.5,-0.5,0.5)
# Interpolate the data
interpolate = vtk.vtkInterpolateDataSetAttributes()
interpolate.AddInputConnection(blobbyV.GetOutputPort())
interpolate.AddInputConnection(blobbyT.GetOutputPort())
interpolate.AddInputConnection(blobbyK.GetOutputPort())
interpolate.SetT(0.0)
# extract an iso surface
blobbyIso = vtk.vtkContourFilter()
blobbyIso.SetInputConnection(interpolate.GetOutputPort())
blobbyIso.SetValue(0,0.1)
# map to rendering primitives
blobbyMapper = vtk.vtkPolyDataMapper()
blobbyMapper.SetInputConnection(blobbyIso.GetOutputPort())
blobbyMapper.ScalarVisibilityOff()
# now an actor
blobby = vtk.vtkActor()
blobby.SetMapper(blobbyMapper)
예제 #4
0
    def recalculateTime(self, time):

        if len(self.times) <= 0:
            return 'TimeManager: Error: .pvd file with 0 entries'

        if len(self.times) == 1:
            pi = pf = 0
        else:
            # posicion mayor tal que time >= t
            pi = 0
            while pi < len(self.times) and time >= self.times[pi].get('time'):
                pi += 1
            if pi > 0:
                pi -= 1

            # posicion menor tal que time <= t
            pf = 0
            while pf < len(self.times) and time > self.times[pf].get('time'):
                pf += 1
            if pf >= len(self.times):
                pf -= 1

        print 'pi, pf', pi, pf

        if pi == pf:
            return self.recalculate(pi)

        # para que non interpole tempo/frecuencia
        if self.interpolation is not True:
            return self.recalculate(pi)  # redondea cara á esquerda

        ti = self.times[pi].get('time')
        tf = self.times[pf].get('time')

        print 'ti, tf', ti, tf

        if ti == tf:
            return self.recalculate(pi)

        # [0,1]
        factor = (time - ti) / (tf - ti)

        print 'factor', factor

        # tambien posible reutilizar ficheros de mode == 1

        mnames = []

        # si ha cambiado el primer fichero ...
        if not (self.mode == 2 and self.index1 == pi):
            print '#1 si ha cambiado el primer fichero ..'
            tracker = self.tracker.get_tracker(pi)
            if isinstance(tracker, basestring):
                return tracker
            else:
                src = tracker.get_src(mnames)
                if isinstance(src, basestring):
                    return src
            self.tracker1 = tracker
            self.src1 = src

        # si ha cambiado el segundo fichero ...
        if not (self.mode == 2 and self.index2 == pf):
            print '#2 si ha cambiado el segundo fichero ...'
            tracker = self.tracker.get_tracker(pf)
            if isinstance(tracker, basestring):
                return tracker
            else:
                src = tracker.get_src(mnames)
                if isinstance(src, basestring):
                    return src
            self.tracker2 = tracker
            self.src2 = src

        # si ha cambiado algun fichero
        if not (self.mode == 2 and self.index1 == pi and self.index2 == pf):
            print '#3 si ha cambiado algun fichero'

            self.src = vtk.vtkInterpolateDataSetAttributes()

            #self.src.AddInput(self.src1.GetOutput())
            #self.src.AddInput(self.src2.GetOutput())

            #workaround: porque solo interpola atributos activos
            if self.attr_fn is not None and self.attr_sv is not None and self.attr_pc is not None:
                a1 = vtk.vtkAssignAttribute()
                a2 = vtk.vtkAssignAttribute()
                a1.Assign(self.attr_fn, self.attr_sv, self.attr_pc)
                a2.Assign(self.attr_fn, self.attr_sv, self.attr_pc)
                a1.SetInputConnection(self.src1.GetOutputPort())
                a2.SetInputConnection(self.src2.GetOutputPort())
                self.src.AddInputConnection(a1.GetOutputPort())
                self.src.AddInputConnection(a2.GetOutputPort())
            else:
                self.src.AddInputConnection(self.src1.GetOutputPort())
                self.src.AddInputConnection(self.src2.GetOutputPort())

            self.changes['new'] = True
            self.changes['changed'] = True

        # si aprendo como reutilizar self.src, [SetInput], no construye un self.src nuevo siempre

        self.src.SetT(factor)
        self.src.Update()

        self.mesh_names = mnames
        self.mode = 2
        self.time = time
        self.indexA = None
        self.index1 = pi
        self.index2 = pf
        self.changes['changed'] = True

        return True