Commit 5bb0ed14 authored by Robert Maynard's avatar Robert Maynard Committed by Kitware Robot

Merge topic '16004_fix_pdb_reader'

3440a530 Adding a test for PDB reader.
e929907f Style fixes for vtkPDBReader.
42d0faa4 Fixed "atom" reader for PDB format
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Reviewed-by: Marcus D. Hanwell's avatarMarcus D. Hanwell <marcus.hanwell@kitware.com>
Merge-request: !1627
parents f9ee65e3 3440a530
Pipeline #18830 pending with stage
......@@ -8,6 +8,7 @@ vtk_add_test_python(
# TestPolygonWriters.py # needs vtkCGMWriter (not built)
TestXYZMol.py
caffeine.py
caffeine_notrailingwhitespaces.py
motor.py
testHexaPenta.py
TestChacoReader.py
......
#!/usr/bin/env python
import vtk
from vtk.test import Testing
from vtk.util.misc import vtkGetDataRoot
VTK_DATA_ROOT = vtkGetDataRoot()
ren1 = vtk.vtkRenderer()
ren1.SetBackground(0,0,0)
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren1)
renWin.SetSize(300,300)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
pdb0 = vtk.vtkPDBReader()
pdb0.SetFileName("" + str(VTK_DATA_ROOT) + "/Data/caffeine_notrailingspaces.pdb")
pdb0.SetHBScale(1.0)
pdb0.SetBScale(1.0)
Sphere0 = vtk.vtkSphereSource()
Sphere0.SetCenter(0,0,0)
Sphere0.SetRadius(1)
Sphere0.SetThetaResolution(8)
Sphere0.SetStartTheta(0)
Sphere0.SetEndTheta(360)
Sphere0.SetPhiResolution(8)
Sphere0.SetStartPhi(0)
Sphere0.SetEndPhi(180)
Glyph0 = vtk.vtkGlyph3D()
Glyph0.SetInputConnection(pdb0.GetOutputPort())
Glyph0.SetOrient(1)
Glyph0.SetColorMode(1)
#Glyph0 ScalingOn
Glyph0.SetScaleMode(2)
Glyph0.SetScaleFactor(.25)
Glyph0.SetSourceConnection(Sphere0.GetOutputPort())
Mapper5 = vtk.vtkPolyDataMapper()
Mapper5.SetInputConnection(Glyph0.GetOutputPort())
Mapper5.SetImmediateModeRendering(1)
Mapper5.UseLookupTableScalarRangeOff()
Mapper5.SetScalarVisibility(1)
Mapper5.SetScalarModeToDefault()
Actor5 = vtk.vtkLODActor()
Actor5.SetMapper(Mapper5)
Actor5.GetProperty().SetRepresentationToSurface()
Actor5.GetProperty().SetInterpolationToGouraud()
Actor5.GetProperty().SetAmbient(0.15)
Actor5.GetProperty().SetDiffuse(0.85)
Actor5.GetProperty().SetSpecular(0.1)
Actor5.GetProperty().SetSpecularPower(100)
Actor5.GetProperty().SetSpecularColor(1,1,1)
Actor5.GetProperty().SetColor(1,1,1)
Actor5.SetNumberOfCloudPoints(30000)
ren1.AddActor(Actor5)
Tuber0 = vtk.vtkTubeFilter()
Tuber0.SetInputConnection(pdb0.GetOutputPort())
Tuber0.SetNumberOfSides(8)
Tuber0.SetCapping(0)
Tuber0.SetRadius(0.2)
Tuber0.SetVaryRadius(0)
Tuber0.SetRadiusFactor(10)
Mapper7 = vtk.vtkPolyDataMapper()
Mapper7.SetInputConnection(Tuber0.GetOutputPort())
Mapper7.SetImmediateModeRendering(1)
Mapper7.UseLookupTableScalarRangeOff()
Mapper7.SetScalarVisibility(1)
Mapper7.SetScalarModeToDefault()
Actor7 = vtk.vtkLODActor()
Actor7.SetMapper(Mapper7)
Actor7.GetProperty().SetRepresentationToSurface()
Actor7.GetProperty().SetInterpolationToGouraud()
Actor7.GetProperty().SetAmbient(0.15)
Actor7.GetProperty().SetDiffuse(0.85)
Actor7.GetProperty().SetSpecular(0.1)
Actor7.GetProperty().SetSpecularPower(100)
Actor7.GetProperty().SetSpecularColor(1,1,1)
Actor7.GetProperty().SetColor(1,1,1)
ren1.AddActor(Actor7)
# enable user interface interactor
#iren SetUserMethod {wm deiconify .vtkInteract}
iren.Initialize()
# prevent the tk window from showing up then start the event loop
# --- end of script --
......@@ -70,7 +70,6 @@ void vtkPDBReader::ReadSpecificMolecule(FILE* fp)
sscanf(&linebuf[0],"%6s", c);
std::string command = c;
StdStringToUpper(command);
if (command == "ATOM" || command == "HETATM")
{
sscanf(&linebuf[12], "%4s", dum1);
......@@ -78,10 +77,13 @@ void vtkPDBReader::ReadSpecificMolecule(FILE* fp)
chain = linebuf[21];
sscanf(&linebuf[22], "%d", &resi);
sscanf(&linebuf[30],"%8f%8f%8f", x, x+1, x+2);
sscanf(&linebuf[76], "%2s", elem);
if (strnlen(linebuf, 80) >= 78)
{
sscanf(&linebuf[76], "%2s", elem);
}
if (elem[0] == '\0')
{
// if element symbol was not specified, just use the "Atom name".
strncpy(elem, dum1, 2);
}
......
cf10316cf0caee2e2eac92e23d5f8630
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment