<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">from core.modules.vistrails_module import Module, ModuleError
from SelfeBase import SelfeData

class Readers(object):
    namespace='IO'

class GR3Reader(Readers, Module):
    def compute(self):
        if self.hasInputFromPort("File"):
            fn = self.getInputFromPort("File").name
        else:
            fn = self.getInputFromPort("Filename")

        fid = open(fn, 'r')
        buf = fid.read()
        fid.close()

        buf = buf.split('\n')
        file_id = buf[0]
        nums = buf[1]
        buf.pop(0)
        buf.pop(0)
        nums = nums.split(' ')
        pts = {}
        # Now we start reading points
        for i in range(int(nums[0])):
            (id, x, y, z) = buf.pop(0).split()
            pts[int(id)] = [float(x), float(y), float(z)]

            
    @classmethod
    def register(cls, reg, basic):
        reg.add_module(cls, namespace=cls.namespace)
        reg.add_input_port(cls, "Filename", (basic.String, "Filename"))
        reg.add_input_port(cls, "File", (basic.File, "File"))
        reg.add_output_port(cls, "Output", (SelfeData, "Output Data"))
</pre></body></html>