def verify_tri_polydata(): imprt = smtk.io.vtk.ImportVTKData() pd = make_TrianglePolyData() meshResource = smtk.mesh.Resource.create() imprt(pd, meshResource) if meshResource == None or not meshResource.isValid(): raise RuntimeError("resource should exist") if meshResource.numberOfMeshes() != 1: raise RuntimeError("resource should only have a single mesh") if meshResource.cells().size() != pd.GetNumberOfCells(): raise RuntimeError( "resource and polydata should have the same number of cells") meshes = meshResource.meshes(smtk.mesh.Dims2) if meshes.size() != 1: raise RuntimeError("wrong number of meshes") if meshes.cells() != meshResource.cells(): raise RuntimeError("cell sets should match") meshes1d = meshResource.meshes(smtk.mesh.Dims1) if meshes1d.size() != 0: raise RuntimeError("number of 1d cells should be 0") exprt = smtk.io.vtk.ExportVTKData() pd2 = vtk.vtkPolyData() exprt(meshes, pd2) test_same_datasets(pd, pd2)
def verify_tri_polydata(): manager = smtk.mesh.Manager.create() imprt = smtk.io.vtk.ImportVTKData() pd = make_TrianglePolyData() c = imprt(pd, manager) if c == None or not c.isValid(): raise RuntimeError("collection should exist") if c.numberOfMeshes() != 1: raise RuntimeError("collection should only have a single mesh") if c.cells().size() != pd.GetNumberOfCells(): raise RuntimeError( "collection and polydata should have the same number of cells") meshes = c.meshes(smtk.mesh.Dims2) if meshes.size() != 1: raise RuntimeError("wrong number of meshes") if meshes.cells() != c.cells(): raise RuntimeError("cell sets should match") meshes1d = c.meshes(smtk.mesh.Dims1) if meshes1d.size() != 0: raise RuntimeError("number of 1d cells should be 0") exprt = smtk.io.vtk.ExportVTKData() pd2 = vtk.vtkPolyData() exprt(meshes, pd2) test_same_datasets(pd, pd2)
def make_TrianglePolyData(): PB = vtk.vtkParametricBoy() PFS = vtk.vtkParametricFunctionSource() PFS.SetParametricFunction(PB) PFS.SetUResolution(400) PFS.SetVResolution(500) PFS.Update() result = vtk.vtkPolyData() result.ShallowCopy(PFS.GetOutput()) return result
def make_EmptyPolyData(): return vtk.vtkPolyData()