Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"list of string or filename")
if isinstance(glsl_code, str):
code += "\n"
code += fs.load(glsl_code) if op.isfile(glsl_code) else glsl_code
return code
for content in glsl_code:
code += "\n"
code += fs.load(content) if op.isfile(content) else content
return code
vs_dec_code = get_code(vs_dec) + "\n" + fs.load("billboard_dec.vert")
vs_impl_code = get_code(vs_impl) + "\n" + fs.load("billboard_impl.vert")
fs_dec_code = get_code(fs_dec) + "\n" + fs.load("billboard_dec.frag")
fs_impl_code = fs.load("billboard_impl.frag") + "\n" + get_code(fs_impl)
gs_dec_code = get_code(gs_dec)
gs_impl_code = get_code(gs_impl)
mapper = actor.GetMapper()
mapper.MapDataArrayToVertexAttribute(
"center", "center", vtk.vtkDataObject.FIELD_ASSOCIATION_POINTS, -1)
mapper.AddShaderReplacement(
vtk.vtkShader.Vertex, "//VTK::ValuePass::Dec", True,
vs_dec_code, False)
mapper.AddShaderReplacement(
vtk.vtkShader.Vertex, "//VTK::ValuePass::Impl", True,
vs_impl_code, False)
mapper.AddShaderReplacement(
# use spline interpolation
if (spline_subdiv is not None) and (spline_subdiv > 0):
spline_filter = set_input(vtk.vtkSplineFilter(), next_input)
spline_filter.SetSubdivideToSpecified()
spline_filter.SetNumberOfSubdivisions(spline_subdiv)
spline_filter.Update()
next_input = spline_filter.GetOutputPort()
poly_mapper = set_input(vtk.vtkPolyDataMapper(), next_input)
poly_mapper.ScalarVisibilityOn()
poly_mapper.SetScalarModeToUsePointFieldData()
poly_mapper.SelectColorArray("Colors")
poly_mapper.Update()
if depth_cue:
poly_mapper.SetGeometryShaderCode(fs.load("line.geom"))
@vtk.calldata_type(vtk.VTK_OBJECT)
def vtkShaderCallback(_caller, _event, calldata=None):
program = calldata
if program is not None:
program.SetUniformf("linewidth", linewidth)
poly_mapper.AddObserver(vtk.vtkCommand.UpdateShaderEvent,
vtkShaderCallback)
# Color Scale with a lookup table
if color_is_scalar:
if lookup_colormap is None:
lookup_colormap = colormap_lookup_table()
poly_mapper.SetLookupTable(lookup_colormap)
if not all(isinstance(i, (str)) for i in glsl_code):
raise IOError("The only supported format are string or filename,"
"list of string or filename")
if isinstance(glsl_code, str):
code += "\n"
code += fs.load(glsl_code) if op.isfile(glsl_code) else glsl_code
return code
for content in glsl_code:
code += "\n"
code += fs.load(content) if op.isfile(content) else content
return code
vs_dec_code = get_code(vs_dec) + "\n" + fs.load("billboard_dec.vert")
vs_impl_code = get_code(vs_impl) + "\n" + fs.load("billboard_impl.vert")
fs_dec_code = get_code(fs_dec) + "\n" + fs.load("billboard_dec.frag")
fs_impl_code = fs.load("billboard_impl.frag") + "\n" + get_code(fs_impl)
gs_dec_code = get_code(gs_dec)
gs_impl_code = get_code(gs_impl)
mapper = actor.GetMapper()
mapper.MapDataArrayToVertexAttribute(
"center", "center", vtk.vtkDataObject.FIELD_ASSOCIATION_POINTS, -1)
mapper.AddShaderReplacement(
vtk.vtkShader.Vertex, "//VTK::ValuePass::Dec", True,
vs_dec_code, False)
mapper.AddShaderReplacement(
vtk.vtkShader.Vertex, "//VTK::ValuePass::Impl", True,
verts, faces = fp.prim_box()
centers = np.array([[0, 0, 0], [8, 0, 0]])
repeated = fp.repeat_primitive(verts, faces, centers=centers, scale=5)
rep_verts, rep_faces, rep_colors, rep_centers = repeated
sdfactor = get_actor_from_primitive(rep_verts, rep_faces)
vtk_center = numpy_support.numpy_to_vtk(rep_centers)
vtk_center.SetNumberOfComponents(3)
vtk_center.SetName("center")
sdfactor.GetMapper().GetInput().GetPointData().AddArray(vtk_center)
vs_dec_code = fs.load("sdf_dec.vert")
vs_impl_code = fs.load("sdf_impl.vert")
fs_dec_code = fs.load("sdfmulti_dec.frag")
fs_impl_code = fs.load("sdfmulti_impl.frag")
mapper = sdfactor.GetMapper()
mapper.MapDataArrayToVertexAttribute(
"center", "center", vtk.vtkDataObject.FIELD_ASSOCIATION_POINTS, -1)
mapper.AddShaderReplacement(
vtk.vtkShader.Vertex, "//VTK::ValuePass::Dec", True,
vs_dec_code, False)
mapper.AddShaderReplacement(
vtk.vtkShader.Vertex, "//VTK::ValuePass::Impl", True,
vs_impl_code, False)
mapper.AddShaderReplacement(
vtk.vtkShader.Fragment, "//VTK::ValuePass::Dec", True,
def get_code(glsl_code):
code = ""
if not glsl_code:
return code
if not all(isinstance(i, (str)) for i in glsl_code):
raise IOError("The only supported format are string or filename,"
"list of string or filename")
if isinstance(glsl_code, str):
code += "\n"
code += fs.load(glsl_code) if op.isfile(glsl_code) else glsl_code
return code
for content in glsl_code:
code += "\n"
code += fs.load(content) if op.isfile(content) else content
return code
raise IOError("The only supported format are string or filename,"
"list of string or filename")
if isinstance(glsl_code, str):
code += "\n"
code += fs.load(glsl_code) if op.isfile(glsl_code) else glsl_code
return code
for content in glsl_code:
code += "\n"
code += fs.load(content) if op.isfile(content) else content
return code
vs_dec_code = get_code(vs_dec) + "\n" + fs.load("billboard_dec.vert")
vs_impl_code = get_code(vs_impl) + "\n" + fs.load("billboard_impl.vert")
fs_dec_code = get_code(fs_dec) + "\n" + fs.load("billboard_dec.frag")
fs_impl_code = fs.load("billboard_impl.frag") + "\n" + get_code(fs_impl)
gs_dec_code = get_code(gs_dec)
gs_impl_code = get_code(gs_impl)
mapper = actor.GetMapper()
mapper.MapDataArrayToVertexAttribute(
"center", "center", vtk.vtkDataObject.FIELD_ASSOCIATION_POINTS, -1)
mapper.AddShaderReplacement(
vtk.vtkShader.Vertex, "//VTK::ValuePass::Dec", True,
vs_dec_code, False)
mapper.AddShaderReplacement(
vtk.vtkShader.Vertex, "//VTK::ValuePass::Impl", True,
vs_impl_code, False)
centers = np.array([[0, 0, 0], [8, 0, 0]])
repeated = fp.repeat_primitive(verts, faces, centers=centers, scale=5)
rep_verts, rep_faces, rep_colors, rep_centers = repeated
sdfactor = get_actor_from_primitive(rep_verts, rep_faces)
vtk_center = numpy_support.numpy_to_vtk(rep_centers)
vtk_center.SetNumberOfComponents(3)
vtk_center.SetName("center")
sdfactor.GetMapper().GetInput().GetPointData().AddArray(vtk_center)
vs_dec_code = fs.load("sdf_dec.vert")
vs_impl_code = fs.load("sdf_impl.vert")
fs_dec_code = fs.load("sdfmulti_dec.frag")
fs_impl_code = fs.load("sdfmulti_impl.frag")
mapper = sdfactor.GetMapper()
mapper.MapDataArrayToVertexAttribute(
"center", "center", vtk.vtkDataObject.FIELD_ASSOCIATION_POINTS, -1)
mapper.AddShaderReplacement(
vtk.vtkShader.Vertex, "//VTK::ValuePass::Dec", True,
vs_dec_code, False)
mapper.AddShaderReplacement(
vtk.vtkShader.Vertex, "//VTK::ValuePass::Impl", True,
vs_impl_code, False)
mapper.AddShaderReplacement(
vtk.vtkShader.Fragment, "//VTK::ValuePass::Dec", True,
fs_dec_code, False)