예제 #1
0
    def __init__(self, profile):
        """Clip the STL and set attributes on the SWIG-proxied C++
        GeometryGenerator object.
        """
        GeometryGenerator.__init__(self)
        self._profile = profile
        self.generator = Generation.PolyDataGenerator()
        self._SetCommonGeneratorProperties()
        self.generator.SetSeedPointWorking(
            profile.SeedPoint.x / profile.VoxelSize,
            profile.SeedPoint.y / profile.VoxelSize,
            profile.SeedPoint.z / profile.VoxelSize)

        # This will create the pipeline for the clipped surface
        clipper = Clipper(profile)

        # Scale by the voxel size
        trans = vtkTransform()
        scale = 1. / profile.VoxelSize
        trans.Scale(scale, scale, scale)

        transformer = vtkTransformFilter()
        transformer.SetTransform(trans)
        transformer.SetInputConnection(
            clipper.ClippedSurfaceSource.GetOutputPort())

        # Uncomment this an insert the output path to debug pipeline construction
        # write = StageWriter('/Users/rupert/working/compare/aneurysm').WriteOutput
        # i = 0
        # for alg in getpipeline(transformer):
        #     print i
        #     i += 1
        #     print alg
        #     write(alg)

        transformer.Update()
        self.ClippedSurface = transformer.GetOutput()
        self.generator.SetClippedSurface(self.ClippedSurface)

        originWorking, nSites = self._ComputeOriginWorking()
        self.generator.SetOriginWorking(*(float(x) for x in originWorking))
        self.generator.SetSiteCounts(*(int(x) for x in nSites))
        self.OriginMetres = Vector(originWorking * self.VoxelSizeMetres)
        return