# Currently assuming that this is the region numbers that were produced by coloring!
        # TODO: If necessary, get from array to be more robust.
        region_ids = (0, 1)

        # Extract each surface in turn to find the smallest one
        subsurfaces = {}
        for k in region_ids:
            connectivityFilter = vtk.vtkPolyDataConnectivityFilter()
            connectivityFilter.SetInputData(self.ColoredSurface)
            connectivityFilter.SetExtractionModeToSpecifiedRegions()
            connectivityFilter.AddSpecifiedRegion(k)
            connectivityFilter.ColorRegionsOff()
            connectivityFilter.SetScalarConnectivity(0)
            connectivityFilter.Update()
            subsurfaces[k] = connectivityFilter.GetOutput()

        # The inner surface has smaller bounds
        if bnorm(subsurfaces[region_ids[0]]) < bnorm(subsurfaces[region_ids[1]]):
            self.InnerRegionId = region_ids[0]
            self.OuterRegionId = region_ids[1]
        else:
            self.InnerRegionId = region_ids[1]
            self.OuterRegionId = region_ids[0]
        self.InnerSurface = subsurfaces[self.InnerRegionId]
        self.OuterSurface = subsurfaces[self.OuterRegionId]

if __name__ == '__main__':
    main = pypes.pypeMain()
    main.Arguments = sys.argv
    main.Execute()
Пример #2
0
    def Execute(self):

        if self.Centerlines == None:
            self.PrintError('Error: No input centerlines.')

        centerlineBranchGeometry = vtkvmtk.vtkvmtkCenterlineBranchGeometry()
        centerlineBranchGeometry.SetInputData(self.Centerlines)
        centerlineBranchGeometry.SetRadiusArrayName(self.RadiusArrayName)
        centerlineBranchGeometry.SetGroupIdsArrayName(self.GroupIdsArrayName)
        centerlineBranchGeometry.SetBlankingArrayName(self.BlankingArrayName)
        centerlineBranchGeometry.SetLengthArrayName(self.LengthArrayName)
        centerlineBranchGeometry.SetCurvatureArrayName(self.CurvatureArrayName)
        centerlineBranchGeometry.SetTorsionArrayName(self.TorsionArrayName)
        centerlineBranchGeometry.SetTortuosityArrayName(
            self.TortuosityArrayName)
        centerlineBranchGeometry.SetLineSmoothing(self.LineSmoothing)
        centerlineBranchGeometry.SetNumberOfSmoothingIterations(
            self.NumberOfSmoothingIterations)
        centerlineBranchGeometry.SetSmoothingFactor(self.SmoothingFactor)

        centerlineBranchGeometry.Update()

        self.GeometryData = centerlineBranchGeometry.GetOutput()


if __name__ == '__main__':

    main = pypes.pypeMain()
    main.Arguments = sys.argv
    main.Execute()