def runPeriodise(self):
        """ Call periodise and modify position of triangle in the scene to fit inside pattern"""
        triangles, groups, materials, bands, albedo = self.as_primitive()
        o_string, labels = opt_string_and_labels(materials)
        can_string = triangles_string(triangles, labels)
        pat_string = pattern_string(self.pattern)
        newscene = vperiodise(can_string, pat_string)
        infile = newscene.split('\n')
        cscene = {}
        for line in infile:
            line = line.strip()
            if not line:
                continue
            if line.startswith('#'):
                continue
            fields = line.split()
            label = fields[2]
            if label not in cscene:
                cscene[label] = []
            coords = map(float, fields[-9:])
            cscene[label].append(map(tuple, [coords[:3], coords[3:6], coords[6:]]))

        self.scene = cscene

        return self
Beispiel #2
0
    def runPeriodise(self):
        """ Call periodise and modify position of triangle in the scene to fit inside pattern"""
        triangles, groups, materials, bands, albedo = self.as_primitive()
        o_string, labels = opt_string_and_labels(materials)
        can_string = triangles_string(triangles, labels)
        pat_string = pattern_string(self.pattern)
        newscene = vperiodise(can_string, pat_string)
        infile = newscene.split('\n')
        cscene = {}
        for line in infile:
            line = line.strip()
            if not line:
                continue
            if line.startswith('#'):
                continue
            fields = line.split()
            label = fields[2]
            if label not in cscene:
                cscene[label] = []
            coords = list(map(float, fields[-9:]))
            cscene[label].append(
                list(map(tuple, [coords[:3], coords[3:6], coords[6:]])))

        # should be changed to take into account the new structure
        self.scene = cscene

        return self
Beispiel #3
0
def WriteCan(caribuscene, filename):
    triangles, groups, materials, bands, albedo = caribuscene.as_primitive()
    if len(bands) == 1:
        o_string, labels = opt_string_and_labels(materials)
        can_string = triangles_string(triangles, labels)
        with open(filename, 'w') as output:
            output.write(can_string)
    return filename