示例#1
0
def volume (dataset) :
    "Returns the volume of each cell in a dataset."
    #def _cell_quality (dataset, quality) :
    if not dataset : raise RuntimeError('Need a dataset to compute volume')

    # create a dataset with only our array but the same geometry/topology
    ds = dataset.NewInstance()
    ds.UnRegister(None)
    ds.CopyStructure(dataset.VTKObject)

    filter = vtk.vtkCellSizeFilter()
    filter.SetInputData(ds)
    filter.ComputePointOff()
    filter.ComputeLengthOff()
    filter.ComputeAreaOff()
    filter.Update()

    varray = filter.GetOutput().GetCellData().GetArray("size")
    varray.SetName("CellQuality")
    ans = dsa.vtkDataArrayToVTKArray(varray, dataset)

    # The association information has been lost over the vtk filter
    # we must reconstruct it otherwise lower pipeline will be broken.
    ans.Association = dsa.ArrayAssociation.CELL

    return ans
示例#2
0
 def calc_cluster_sizes(self):
     for cluster_idx, cluster_key in enumerate(self.clusters.keys()):
         cluster_mesh = self.clusters[cluster_key]['mesh']
         cell_size_filter = vtk.vtkCellSizeFilter()
         cell_size_filter.SetInputData(cluster_mesh)
         cell_size_filter.ComputeAreaOn()
         cell_size_filter.ComputeSumOn()
         cell_size_filter.Update()
         cell_area_mesh = cell_size_filter.GetOutput()
         total_cluster_area = vtk_to_numpy(
             cell_area_mesh.GetFieldData().GetAbstractArray('Area'))
         self.clusters[cluster_key]['area'] = total_cluster_area[0]
示例#3
0
    def compute_cell_sizes(dataset, length=False, area=True, volume=True):
        """This filter computes sizes for 1D (length), 2D (area) and 3D (volume)
        cells.

        Parameters
        ----------
        length : bool
            Specify whether or not to compute the length of 1D cells.

        area : bool
            Specify whether or not to compute the area of 2D cells.

        volume : bool
            Specify whether or not to compute the volume of 3D cells.

        """
        alg = vtk.vtkCellSizeFilter()
        alg.SetInputDataObject(dataset)
        alg.SetComputeArea(area)
        alg.SetComputeVolume(volume)
        alg.SetComputeLength(length)
        alg.SetComputeVertexCount(False)
        alg.Update()
        return _get_output(alg)
stdParentBaselineWSS = parentBaselineWssWithin1cm.std()
meanParentAdjustedWSS = parentAdjustedWssWithin1cm.mean()
stdParentAdjustedWSS = parentAdjustedWssWithin1cm.std()

baselineLowShearThreshold = meanParentBaselineWSS - stdParentBaselineWSS
baselineLowShear = (baselineWSS < baselineLowShearThreshold).astype(np.uint8)
adjustedLowShearThreshold = meanParentAdjustedWSS - stdParentAdjustedWSS
adjustedLowShear = (adjustedWSS < adjustedLowShearThreshold).astype(np.uint8)

baselineLowShearArrayName = f'LowShearArea_{baselineTag}'
adjustedLowShearArrayName = f'LowShearArea_{adjustedTag}'
aneurysm_dsa.PointData.append(baselineLowShear, baselineLowShearArrayName)
aneurysm_dsa.PointData.append(adjustedLowShear, adjustedLowShearArrayName)

#%% plot lsas
cellSizer = vtk.vtkCellSizeFilter()
cellSizer.SetInputData(aneurysm)
cellSizer.ComputeLengthOff()
cellSizer.ComputeVertexCountOff()
cellSizer.ComputeVolumeOff()
cellSizer.Update()
aneurysm = cellSizer.GetOutput()

aneurysm_dsa = wdo(aneurysm)
cellAreas = aneurysm_dsa.CellData['Area'] # in mm2
aneurysmArea = cellAreas.sum()

baselineLsaSurface = vtkext.pyvtk.threshold(aneurysm, baselineLowShearArrayName, 
                                                 lo=1, allScalars=True)
baselineLsaSurface_dsa = wdo(baselineLsaSurface)
baselineLSA = baselineLsaSurface_dsa.CellData['Area'].sum()/aneurysmArea
 def measure_average_edge_length(self):
     print('Average edge length')
     size = vtk.vtkCellSizeFilter()
     size.SetInputConnection(self.mesh.GetOutputPort())
     size.Update()
     print(size)