<commit_before># pointsToSpheres.py copyright (c) 2005 by <NAME> <<EMAIL>>
# $Id$
# see module documentation

import gen_utils
from module_base import ModuleBase
from module_mixins import ScriptedConfigModuleMixin
import module_utils
import wx
import vtk

class pointsToSpheres(ScriptedConfigModuleMixin, ModuleBase):

    def __init__(self, module_manager):
        ModuleBase.__init__(self, module_manager)

        self._inputPoints = None
        self._internalPoints = None

        self._config.radius = 5
        self._config.thetaResolution = 8 # minimum 3
        self._config.phiResolution = 8 # minimum 3
        self._config.numInternalSpheres = 3

        configList = [('Sphere radius:', 'radius', 'base:float', 'text',
                       'The radius of the spheres that will be created '
                       'in world coordinate units.'),
                      ('Theta resolution:', 'thetaResolution', 'base:int',
                       'text',
                       'Number of points in the longitudinal direction.'),
                      ('Phi resolution:', 'phiResolution', 'base:int',
                       'text',
                       'Number of points in the latitudinal direction.'),
                      ('Number of internal spheres:', 'numInternalSpheres',
                       'base:int', 'text',
                       'Number of spheres to create in the interior.')]



        self._appendPolyData = vtk.vtkAppendPolyData()

        if False:
            # checked on 20090314: dummy not required anymore

            # we do need a dummy sphere, else the appender complains
            dummySphere = vtk.vtkSphereSource()
            dummySphere.SetRadius(0.0)

            # and a dummy calc, with -1 index
            # if we don't add the VolumeIndex array here as well, the append
            # polydata discards all the others
            calc = vtk.vtkArrayCalculator()
            calc.SetAttributeModeToUsePointData()
            calc.SetFunction('-1')
            calc.SetResultArrayName('VolumeIndex')
            calc.SetInput(dummySphere.GetOutput())
            
            self._appendPolyData.AddInput(calc.GetOutput())

        # this will be a list of lists containing tuples
        # (vtkArrayCalculator, vtkSphereSource)
        self._sphereSources = []

        # this will hold our shallow-copied output
        self._output = vtk.vtkPolyData()

        ScriptedConfigModuleMixin.__init__(
            self, configList,
            {'Module (self)' : self,
             'vtkAppendPolyData' : self._appendPolyData})

        self.sync_module_logic_with_config()

    def close(self):
        # we play it safe... (the graph_editor/module_manager should have
        # disconnected us by now)
        for input_idx in range(len(self.get_input_descriptions())):
            self.set_input(input_idx, None)

        # this will take care of all display thingies
        ScriptedConfigModuleMixin.close(self)
        
        # get rid of our reference
        del self._appendPolyData
        del self._sphereSources
        del self._output<commit_msg>Put dummy input back (it IS required after all), but now it's just an empty vtkPolyData, which is of course much better.<commit_after># pointsToSpheres.py copyright (c) 2005 by <NAME> <<EMAIL>>
# $Id$
# see module documentation

import gen_utils
from module_base import ModuleBase
from module_mixins import ScriptedConfigModuleMixin
import module_utils
import wx
import vtk

class pointsToSpheres(ScriptedConfigModuleMixin, ModuleBase):

    def __init__(self, module_manager):
        ModuleBase.__init__(self, module_manager)

        self._inputPoints = None
        self._internalPoints = None

        self._config.radius = 5
        self._config.thetaResolution = 8 # minimum 3
        self._config.phiResolution = 8 # minimum 3
        self._config.numInternalSpheres = 3

        configList = [('Sphere radius:', 'radius', 'base:float', 'text',
                       'The radius of the spheres that will be created '
                       'in world coordinate units.'),
                      ('Theta resolution:', 'thetaResolution', 'base:int',
                       'text',
                       'Number of points in the longitudinal direction.'),
                      ('Phi resolution:', 'phiResolution', 'base:int',
                       'text',
                       'Number of points in the latitudinal direction.'),
                      ('Number of internal spheres:', 'numInternalSpheres',
                       'base:int', 'text',
                       'Number of spheres to create in the interior.')]



        self._appendPolyData = vtk.vtkAppendPolyData()

        if False:
            # checked on 20090314: dummy input is very definitely
            # required 

            # we do need a dummy sphere, else the appender complains
            dummySphere = vtk.vtkSphereSource()
            dummySphere.SetRadius(0.0)

            # and a dummy calc, with -1 index
            # if we don't add the VolumeIndex array here as well, the append
            # polydata discards all the others
            calc = vtk.vtkArrayCalculator()
            calc.SetAttributeModeToUsePointData()
            calc.SetFunction('-1')
            calc.SetResultArrayName('VolumeIndex')
            calc.SetInput(dummySphere.GetOutput())
            
            self._appendPolyData.AddInput(calc.GetOutput())
        else:
            self._appendPolyData.AddInput(vtk.vtkPolyData())

        # this will be a list of lists containing tuples
        # (vtkArrayCalculator, vtkSphereSource)
        self._sphereSources = []

        # this will hold our shallow-copied output
        self._output = vtk.vtkPolyData()

        ScriptedConfigModuleMixin.__init__(
            self, configList,
            {'Module (self)' : self,
             'vtkAppendPolyData' : self._appendPolyData})

        self.sync_module_logic_with_config()

    def close(self):
        # we play it safe... (the graph_editor/module_manager should have
        # disconnected us by now)
        for input_idx in range(len(self.get_input_descriptions())):
            self.set_input(input_idx, None)

        # this will take care of all display thingies
        ScriptedConfigModuleMixin.close(self)
        
        # get rid of our reference
        del self._appendPolyData
        del self._sphereSources
        del self._output
{'fraction_non_alphanumeric': 0.08118596709096554, 'fraction_numerical': 0.006830176963675877, 'mean_word_length': 2.0477767265846736, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '339966', 'n_tokens_mistral': 1741, 'n_tokens_neox': 1616, 'n_words': 492}