Hierarchical Multi-resolution Data Structure forMolecular Visualization
DIPLOMA THESIS
submitted in partial fulfillmentofthe requirements forthe degree of
Diplom-Ingenieurin
in
Visual Computing
by
Milena Nowak, BSc Registration Number 0927584
to the Faculty of Informatics at the TU Wien
Advisor: Prof.Dipl.-Ing. Dr.techn. Stefan Bruckner
Vienna, 27th July,2020 Milena Nowak Stefan Bruckner
Technische UniversitätWien A-1040 Wien Karlsplatz 13 Tel. +43-1-58801-0 www.tuwien.ac.at
Erklärungzur Verfassungder Arbeit
Milena Nowak, BSc Speckbachergasse 13, 1160 Wien
Hiermit erkläreich,dass ichdieseArbeit selbständig verfasst habe, dassich dieverwen- detenQuellenund Hilfsmittel vollständig angegebenhabeund dassich dieStellender Arbeit–einschließlichTabellen, Karten undAbbildungen –, die anderenWerken oder dem InternetimWortlaut oder dem Sinn nach entnommen sind, auf jeden Fall unter Angabeder Quelle als Entlehnung kenntlich gemacht habe.
Wien, 27. Juli 2020 Milena Nowak
iii
Acknowledgements
There is areasonthe first person who receives thanks is generally the person who supervised the thesis. In Norwegian,the role is described as "leading theway"towards finishingadegree. Thatjob, it turnsout,involves alot of work. Therefore, Iwouldfirst and foremostliketothank StefanBrucknerfor his patience and clarity. But academicsupport is notthe onlykind needed,somythanks alsogotoMarte, who’s companymade long workinghoursduring short autumndaysalot more pleasant, and Rebecca, for her invaluable moral support and feedback. Iwould also like to thank everyone who madeitpossiblefor me to spendmost of my degree in Bergen, as well as my family formaking it clear that Ihavetheir support -and ahome -nomatter whereIam.
v
Kurzfassung
Biomolekulare Datensätzesind nicht nurkomplex,sie wachsen auchmit der Entwicklung des Forschungsgebietes. Um ihre Eigenschaften zu erforschen, verwendenExperten un- ter anderemdreidimensionale Modelle der Datensätze,die ausMillionen individueller Moleküle bestehen. Beider visuellen Analyse derModelle kann es außerdem hilfreich sein, durchverschiedene Darstellungsformenstrukturelle Eigenschaften zur Geltungzu bringen. Daher gibteseinen Bedarf an flexiblenDatenstrukturen,die es ermöglichten, effizientmit solche Datensätze zu arbeiten. Vorhandene Lösungsansätze im Bereich großer, aufPunktwolken aufbauender Datensätze verwenden in den meisten Fällen rasterbasierte Strukturen in verschiedenen Auflösungen. AnderePublikation konzentrieren sichdagegenauf die Verbesserungder Oberflächendar- stellung,oder auf sichwiederholendeStrukturen innerhalb großer Datensätze. Wirschlagen eine Octree Datenstruktur vor, die die Daten räumlichsoaufteilt, dass jeder Datenblock eine ähnliche Menge Datenpunktebeinhaltet, undmehrere, interpo- lierbaren Auflösungsstufenzur Verfügung .Der Aufbau der Datenstruktur erfolgt in einem Vorverarbeitungsschritt,dessen Resultat gespeichert wird,und daher nurein Mal nötigist.Zusätzlicheffektivierenwir die Darstellungdurchdie Verwendung eines Least RecentlyUsed Cache, derdas LadensichtbarerDatenblöcke verwaltet, und durch perspektivenabhängige Detaildarstellung. In unserer Auswertungzeigen wir,dass insbesonderedas Anpassendes dargestellten Detailgrades die Frameratensignifikant erhöht. Die Kombination einerhöheren Auflösung im Vordergrund, beigleichzeitiger Reduktionder Daten im Hintergrund,erhöht die Geschwindigkeit deutlich, ohne, dass dievisuelle Qualitätbeeinträchtig wird. Durch die Optionen, Detailszureduzierenund nurDatenblöcke zu laden, die im Blickfeld der Kamera sind,wird es möglich, Datensätze anzuzeigen,die ansonsten die Kapazität der uns zur VerfügungstehendenRessourcen überlastenwürden.Der Vorteil der auf der Dichtedes Datensatzes basierenden räumlichen AufteilungimGegensatz zu einer regelmäßigen Aufteilung zeigtsichbesondersbei derVerwendung vonAlgorithmen, die beider Berechnung Nachbarschaften in Betracht ziehen. Daskönnte insbesondere bei der Implementierung einesSolventExcluded Surface (SES) Oberflächenmodelles, einer der wichtigsten,aberrechnerischaufwändigen,Darstellungsformen solcher Datensätze, vongroßemVorteilsein. Die vonuns vorgeschlagene Datenstrukturist für Datensätze optimiert,die mehrere Millionen Punkte in einemeinzigen Zeitschritt beinhalten.
vii
Abstract
The complexityofbiomoleculardatasetsisboth high, andstill rising. Three-dimensional models of moleculesare used in researchtotest and investigatetheirproperties. Such models canconsist of several millions of atoms. Additionally,visual enhancementmethods and molecular surfacemodels are helpfulwhenvisualizing molecules.There is therefore a demand for efficientand flexible data structures to accommodatesuchlarge point-based data sets. Existing solutions in the fieldofmolecular visualization for large datasets include the use of, in most cases, regular grid-baseddata structures, as well as levels of detail. Other papers focus on repeating structures or improvingthe efficiency of surface models. We propose an octree-based data structure thatdivides space into areas of similardensity, and provides several levels of detail. Our approachisoptimized forasingletime-step, moving much of thecomputational overhead into apre-processing step.This allows us to speed up frame rates for interactivevisualizations usingvisibilityculling, leastrecently used caching based on the pre-built octreedata structure,and levelofdetail solutions such as depth-basedlevel of detail rendering. In our evaluation, we showthatlevel of detailrendering significantly improvesframe rates, especially in the case of distance-based level of detail selection while keepingthe amount of detailsinthe foregroundhigh. Both the possibilitytoreducethe resolutionand the caching strategythat allows us to only upload visible parts of the data setmakeitpossible to render datasets thatpreviously exhausted thecapacities of our test set-up.Wefound themain advantage of adensitybased octree, insteadofaregular divisionofspace, to be in neighbourhood-based calculations,suchasthe clustering algorithm required to build levels of detail. This could prove particularlyuseful forthe implementation of aSolvent Excluded Surface(SES) representation model,whichwouldbeanimportantfeature to include when developingthe framework further.
ix
Contents
Kurzfassung vii
Abstract ix
Contentsxi
1Introduction1 1.1 Background ...... 2 1.2 Motivation...... 4 1.3 Contribution ...... 5 1.4 Structure...... 5
2State of the Art 7 2.1 Frameworks andSystems forthe Visualization of Biomolecular Data... 7 2.2 Rendering of Point-based Data ...... 11 2.3 Methods forHandling Large Point-based Data Sets ...... 14 2.4 Biomolecular Representation Modelsand EnhancementMethods..... 21 2.5 Summary and Conclusion ...... 23
3Data Structure25 3.1 Overview of the Components for CPU DataHandling...... 26 3.2 The OctreeDataStructure ...... 27 3.3 Summary and Conclusion ...... 37
4Rendering39 4.1 Managing and Rendering the Octree DataStructure ...... 39 4.2 SmoothlyBlendingBetween LODs ...... 47 4.3 Molecular Surface Rendering ...... 50 4.4 Visual Enhancementfor Molecular Rendering ...... 54 4.5 Summary and Conclusion ...... 59
5Implementation 61 5.1 Libraries ...... 62 5.2 Implementation Choices...... 63
xi 6Results 67 6.1TestData ...... 67 6.2Configuring and Pre-processing the Data Structure ...... 67 6.3Rendering...... 70 6.4Enhancement Methods...... 80 6.5Conclusion and Comparison to Similar Solutions ...... 83
7Discussion 91
8Conclusion 95
List of Figures 97
List of Tables99
Bibliography101 CHAPTER 1
Introduction
Theart andscience of visualization itselflong predates the field of visualcomputing. Withinliterature,severalvarying definitions of theterm visualization exist.Broadly speaking, visualization could be described as themeaningful transformation of data or information into graphical representations.More specifically,according to Senay and Ignatius[SI94], "Theprimary objectiveindata visualization is to gain insight into an information space by mapping dataontographicalprimitives." The necessary ingredients are therefore data thatyou want to explore or explain, suitable toolsto achievethe desired illustration or rendering, and of coursecertain skills andknowledge to do itsuccessfully.Traditional visualization techniquesgenerally rely on hand-drawn 2D illustrations.Possiblythe most well-known historicalexample of 2D visualizationis an 1869 graphicbyCharles JosephMinard showninFigure 1.1a. It depicts the marchof Napoleon’s army into Russia in 1812and 1813, and according to Tufte [Tuf83],"It may well be the best statistical graphiceverproduced.”
The same frameworksand techniquesthatare used to communicate patternsorinteresting featuresinadata set, canoftenalsobeused to explore data. The term scientific visualization often referstoaspecific type of datavisualization, created in order to communicate or explore data obtained in ascientificfield.Senayand Ignatius [SI94]focus theirdefinitiononthe aspect of exploration, statingthat"Scientific data visualization supportsscientists andrelations, to prove or disprovehypotheses, anddiscovernew phenomena using graphical techniques."Anothersimilarly famous historicalvisualization, the mapofthe choleraoutbreakinLondon in 1854 by Dr. JohnSnow, is an example of data visualization being used to investigateahypothesis. Using thestatistical visualization shown in Figure 1.1b, Dr.Snowwas able to support hishypothesisthatthe epidemic wascaused by water fromacontaminated well, and convincethe authoritiestoremove the handle of thewell. While Tufte[Tuf97]pointsout thatitisproblematic to use densitybasedvisualization techniques without factoring in populationdensity, the graphic
1 1. Introduction
remains famous as it wasused to successfully explore andconvincinglycommunicatea hypothesis that waslater proventobecorrect. Ourwork is concerned withmolecular visualization,whichcan be considered aspecific branchofscientific data visualization.The definitiongiven by Senayand Ignatius is particularly relevanttoour work,whichfocuses on facilitating interactive explorationof molecular data. As we willsee in Section 1.1, there areseveral widelyusedconventions on howtovisualizemolecules usingcomputer graphics. An exampleofnon-digital 3D data visualization from thefield of molecular graphics is theoriginal so-called ball-and-stick model, developed by AugustWilhelm Hofmann.Hebuilt the models forexplaining structuralformulae out of croquet balls and presented them while lecturinginLondon in 1865 (see Travis [Tra92]).Versions of the ball-and-stickmodel are still usedincurrent molecularvisualizationsinthe field of computer graphics.
1.1 Background
Before moving on to the questionofhow we usescientific visualization in the field of biomolecules, alookatthe basicsofthe matter to be visualized providessome useful context. In theintroductory remarksofhis bookonmolecular cellbiology,Lodish[Lod00] explainsthe convoluted structuresbiological matter consists of. Withinanorganism, there are organs,whichconsist of tissue,those in turnconsist of cells, and cells are composedofatoms. All biological systems are madeupofthe same typesofatoms andare organized based on similar principles at the cellular level. Biomoleculesare dividedinto macromolecules, such as proteins, lipids,and nucleic acids, and smallmolecules. Molecules are thematerial from which cellsare built, but theyalso have otherfunctions, such as carryingmessagesfromcell to cell. Albeitavery short summary of thecomplextopicof molecular biology,this should provide some idea of whyimproving theunderstanding of what he calls "the molecules of life" is important. Lodish suggests thatinorder to learn about biological systems, we have to regard them one segmentatatime. In ordertodo that, it is helpfultohavesuitable visualizations at one’sdisposal. To makemolecular structures intelligible,including theirproperties and interactions, is the primary purpose of molecular visualization accordingtoKozlíkováetal. [KKF+17]. Theyalso provide an overview overthe historyofmolecular illustrations prior to the digitalage. Before (interactive) visualizationscouldbecreated by computer graphics, depictions were drawn by hand. Atoms were already illustrated as spheres in the17th century.In1873, vander Waals [VdW73]approximated the volumeoccupiedbyindividual atoms andmoleculesusing experiments. The resulting approximateradii for chemical elementshave been used to visualize atoms and molecules ever since. More elaborate atomicmodels describedinthe early 20th century leadtosuggestionsofmore detailed illustrations.However, the majorityofrecent papers on molecular visualizations we reviewedinthe contextofthis work still use vander Waals spheres as thebasis of their visualizations. According to Francoeur [Fra02], theearliest efforts to usecomputer graphics to create
2 1.1. Background
(a) Thevisualizationrefered to as "Napoleon’s March"designed by Minard in 1869 is amuch cited exampleofdataorinformation visualization.(From Tufte [Tuf83], who considersthistobe an excellentstatistical graphic)
(b) Dr. Snow used amap-based visualization of (c)Illustrations of the so-called ball-and-stick apart of London that washit particularily hard molecular model made from croquet balls that by the choleraepidemic in 1854 to convince were introduced by Hofmann in 1865. (From authorities of hishypothesis thatthorigin of Travis [Tra92]) 3 theepidemic wasacontaminatedwell. (From Tufte[Tuf97])
Figure 1.1: Historical examplesofdata visualizations 1. Introduction
interactive representations of molecular structures were made by ateamaroundCyrus Levinthal at theMassachusettsInstitute of Technologyinthe mid-1960s.Techniques in the subfield of theinteractive visualizationofbiomolecularstructures have mostly been developedduring thelasttwo decades (see Kozlíkováetal. [KKF+17]).Marschner and Shirley [MS15], definecomputer graphics as "anyuse of computerstocreate and manipulate images", which includestechnicalillustrations and animations.When the aimisaninteractiveapplication, as is the caseinour work, the particular challenge is to createthe images within the required timeframe, thatisgenerally in real-time. Martin [Mar65]pointsout thatdifferent authorities define theterm real-timedifferently. So rather thanspecifyingany particularframe-rate, he defines areal-timesystem as one which receives andprocessesdata, andreturns the results "sufficiently quickly to affect the functioning of the environmentatthattime.", whichisarather system-oriented definition. Laplante andOvaska[LO11]introduce the term with the claim thatmost people wouldunderstand real-time to meansomething alongthe lines of "atonce" or "instantaneously". As an intuitivedefinition, they call asystem interactivewhen,inorder to avoid system failure, it needstoprocessinformation withinaspecifiedinterval, which is similartothe definitiongiven by Martin [Mar65]. Theliteraturewereviewed, generally usesthe term real-time without giving aprecise threshold in termsofframes persecond (fps), but rather provides the reader with the achieved frame-rates.Asanapproximate guideline, we can pointtothe speed at whichthe human eyecan process images, which is 10-12 imagesper second, or thespeeds used in filmmaking history, 16 or 24 frames persecond (see Read and Meyer [RM00]).
1.2Motivation
Thebasic question of whybiomoleculesare worth investigatingshould, amongother possibleanswers, be answerable by the simple fact thatthey arethe buildingblocks the human bodyismade of. When it comes to whyweneedvisualizations,Jones et al.[JJS05]point outthatthere arechemicalphenomenathatrequire visualization tools to investigateand describe them, as they are not obvious withoutvisualization. They also note that such tools can be used to visually communicate complex molecular interactions and dynamics that are difficult to describeusing only words. In particular, theinteractivevisualization of complex molecular dataishighly valuedbydomain experts. Craigetal. [CMB13]emphasize that interactive animations can communicate structural information much more effectively thanstatic images. An importantcomputational aspectofthe complexityofmolecular dataisthe amount of data to be processed at interactiverates. Molecular structures can containmillions of atoms, creating very large data sets. Forexample, the largest single molecule we useinour tests,contains2,440,800 atoms, while ourlargestartificially createdtest set contains 122,040,000 atoms. As we will seeinChapter 2and Chapter 3, there are certain limitations to the amountofdatathatcan be processed at the same time. While the exact constraints depend on the system, the fact thatthere is alimit remains true across hardware and software capabilities.
4 1.3. Contribution
According to our research, atoms in most molecular datasets are represented as point- based data(see Chapter 2). It is thereforepossibletotakeinspirationfromexisting solutions forlarge point-baseddata sets. However, moleculardatasetsposesome specific challengesthatare not necessarily relevant forother point-based data sets.Inparticular, several differentsurface models formolecular representationshave been proposed and are requested by domainexperts. Notable surfacemodels include the SolventAccessible Surface(Lee andRichards [LR71]),SolventExcluded Surface(Richards [Ric77]),Ligand ExcludedSurface (Lindowetal. [LBH14]),and the GaussianSurface (Blinn[Bli82]). These are, in variousdegrees,computationally expensiveand partially dependent on neighborhood queries (formore detailsee Chapter 2and Chapter 4orrefer to Kozlíková et al. [KKF+17]).Our aim is to implementadatastructure forpoint-basedmolecular datathatisefficientfor neighborhood queries,and flexible in rendering the data.
1.3 Contribution
We propose ahierarchical multi-resolution structure based on an octree, andlevels of detail. Thedata structure, including levelsofdetail, is built in apre-processing step once,and thenstoredfor later use. All levelsare therefore available at runtime,allowing smooth interpolation between resolutions.Manyofthe octree-basedsolutions we came across in our researchdivide the data setinaregularway and use theinternalnodes of theoctrees to store differentlevels of detail.Incontrast to this approach, we divide the data set spatially on the originallevel of detail.The spatialextentofanindividual block or node in thetree is determined by the number of data points within it. Ablock in a sparse region can thus have alarger spatial extent or boundingbox thanone in adense region. We store the datafor all levels of detail in theleaf nodes.Thisapproach combines manyofthe advantages of regulargrids, suchasthe possibilityto"pickand mix" different resolutions for individual blocks, with advantagesofhierarchical spatialdivision,for examplegreatercontrol overthe amountofdatastoredineachleaf. We demonstrate the use of our modular structure foroptimization strategies including coarsevisibility culling,mixed levels of detail, depth-dependentlevel of detail, and datamanagement viaaleast recently used (LRU)cache.Asour basic surface rendering model, we provide an implementation of theGaussian SurfaceModel as proposed by Bruckner [Bru19]. In addition,weincludeenhancementoptions such as depth of field and ambientocclusion. The project is implemented in C++and OpenGL.
1.4Structure
Afteranalyzingthe currentstate of theart in Chapter 2, we first introduce ourdata structure(Chapter 3),and then go on to rendering aspects of ourimplementation (Chapter 4). In thechapter concerning the data structure, we focus mainlyonthe CPU side of theimplementation, explainingthe divisionofdata into an octree,and the clustering-based level of detail calculation.The chapter on renderingincludesbothGPU and CPU components, including the LRUcache,level of detail blending,and screen-space
5 1. Introduction
enhancementand surface methods.Inaseparate implementation chapter(Chapter 5), we provide additionalinformation about libraries, choice of important data types, and other factorsthatconcern theconcreteimplementation in C++/OpenGL,rather than algorithms andconcepts.Finally,weprovide numerical and visual results (Chapter6), and discussapplications and limitations(Chapter 7)
6 CHAPTER 2
State of the Art
In our work, we aim to renderlarge setsofbiomolecular data at interactiverates, and buildaframework thatallows the efficientcalculation of neighborhood-based algorithms. Rendering biomolecular datahas along history in visualizationand computer graphics. Individualatomsare usually defined by theirposition and rendered as spheres,sothey canbeconsidered point-baseddata. Similar datasets based on points are also used forothervisualizationtasks, for examplefluid simulations. Theindividualdata points are commonly called particles,especially whenthey are theresult of asimulation.We start this chapter by givinganoverviewoverprevious work in the field of biomolecular visualization. In thefollowing section, we takeacloserlookatpoint-based rendering methods. As our goal is to enablereal-timerenderingoflarge datasets, we look into previous work specificallytargetinglarge point-based data. Here, we payparticular attention to theproposed datastructuresand level of detailmethods.Inthe finalpart of this chapter, we coverresearchonthe representation of biomolecular data, as well as enhancementmethods for point-baseddata.
2.1 Frameworks and Systems forthe Visualizationof Biomolecular Data
Thedata we visualize is biomoleculardataconsisting of up to acoupleofmillions of atoms. Our aimisinteractioninreal-time, and in our current implementation, we focus on asingle time-step.Inthis section, we look at implementationsthatpropose solutions to very similarchallenges.Inarecent state of theart report, Kozlíkováetal. [KKF+17] give an extensiveoverview overdevelopments and results in the field ofvisualization of biomolecular structures. Manyresearcherspublishthe results of their work in the form of toolkits.Itisoutside the scopeofthis thesis to compile acomprehensivelist, so we only mention some of the
7 2. Stateofthe Art
most well-knownand relevant availabletools. Thefollowing papers giveamore detailed overview over toolkits: Chaventetal. [CLK+11]focus on toolsand implementations that use theGPU to accelerate the visualizationoflarge molecular datasets.Johnson and Hertig[JH14]provide awell-structured overview overtools and methodsfor thevisual analysis and communication of biomolecular datafromauser’s pointofview.Dubbeldam et al. [DVVC19]present asurvey of existing (bio-)chemicaltools and visualization software. An early exampleofatoolkit formolecular visualization is RASMOL, amolecular visualization tool presentedbySayle and Milner-White.[SMW95]. Oneofthe most frequently cited tools is VMDbyHumphrey et al.[HDS96]. It is mainly used for molecular dynamics simulations. BothChimera by Pettersen et al. [PGH+04]and PyMOL by Schrödinger et al.[Sch15]are popularextendable frameworksfor molecular datamostly written in Python. Herraez[Her06] proposesJMol as atooltoinvestigatebiomolecular data,but also emphasizes possibilities to integrate it into educationalweb pages.Paraview by Ahrens et al. [AGL05]isfrequently usedfor large molecular datasets,though it is a visualization tool made to handle large point-basedvolume data sets generally.Megamol by Grottel et al. [GKM+14]isanother framework withthe capabilitytorender different kindsofpoint-baseddata, though itsfocus is on molecular data. Theyuse acombination of GPU rasterization, ray-casting of glyphs, and image-spacefiltering to interactively render millionsofatoms. Though we focus on asingle time-stepinour implementation,molecular dynamics simulationimplementations often applysimilaroptimization strategies to ours, as they usually have to handle very large data sets.The main difference is thatthe trade-off for computationally expensivepre-processing is more problematicwhenrendering animations. Hao et al. [HVS04]for example choose to useasimpler data structure,asthey aim to render multiple time stepswithout asignificant amountofpre-processing.Instead, they focus their effortsonocclusion culling schemes and levels of detail. Max[Max04]renders largemoleculardatasetsatinteractiverates. He also focuses on asingle time step, and achieves interactivitybyusingahierarchical level of detail data structure.Heuses individual atoms as leaves in their tree.Incontrast,weuse leafnodes to groupthe data into neighborhood clusters. Siggetal. [SWBG06]use GPU splatting of molecular data. Their implementation is somewhat similar to ours, as they use the same kind of data and visualize it basedonvdW surfaces.However, they do notuse anyadvanced data structure andonly renderdata sets up to severalthousands of atoms in real-time. Sharmaetal. [SKNV04]presentanapproachtointeractively visualize large atomistic data sets. Theyuse ahierarchicalview frustum-culling algorithmbasedonanoctree data structure to remove atomsoutsidethe field-of-view.Then,they select atoms which have ahighprobabilityofbeing visible.The selected atomsare rendered as spheresat various LODs, with aresolutionderived from an exponentialfunctionofthe distance fromthe viewer.They do notinclude anyadvancedsurface visualizationtechniques in their viewer. Their octree consists of three levels. Eachoctree node containsthe coordinate bounds of its subspace.Anode at level2containsapointertoastructure
8 2.1. Frameworksand Systems forthe Visualization of Biomolecular Data
Figure2.1:Octree data structure by Sharma et al. [SKNV04]thatdivides the data set into threelevels of detail, as illustrated in theirpublication thatstoresthe atomdatawithin its bounds,asillustratedinFigure 2.1. This is asimilar approachtoours, thoughwedonot use afixed number of levels. Instead, we subdivide eachregion until no node containsnomore than thegiven maximum amount of atoms.
Grottel et al. [GRDE10]presentavisualizationframework formolecular dynamics simulations. They choose asimple data structureand ratherfocus on optimization strategies. They employseveral differentmethods: data quantization, data caching in videomemory,and atwo-level occlusion culling strategy involving hardwareocclusion queriesand maximum depth mipmaps. As molecular dynamics usually implies time- dependent data sets, aparticular aim is to alleviate the datatransfer bottleneck.Lindow et al. [LBH12]render large molecular data sets by making useofrepetitivecomponents found in molecular data. According to the authors, theirwork is closelyrelated to thatof Sharmaetal. [SKNV04], andGrottel et al.[GRDE10]. Theystore atomsofindividual componentsinagrid. The gridisthen storedinathree-dimensionaltexture. This texture is then renderedusing ray-castinginanapproachsimilar to methods proposed forvolume rendering. Materialsare renderedatatomic scale, bridging fiveordersof magnitude in scalefromthe smallest detailstothe overall structure of the data sets. Theyexploit the fact thatbiological structuresconsistofmanyrecurring molecular substructures. Eachrecurring component is represented by asingle grid. All instances of acomponentare rendered by applyingdifferent transformations to thatgrid. The
9 2. Stateofthe Art
authorsuse aray-castingalgorithmsimilar to classical voxel rendering methods which utilizes the boundingbox of thedata. Ray-castingisimplemented in the fragment shader. Occlusionculling isaccomplished implicitly on the atomic level, based on the underlyinggrid. Additionally,they usedeferred shading to emphasizethe global shapeof biological structures.Falk et al.[FKE13], whoextendthe algorithmproposed by Lindow et al.[LBH12], usethe same kind of data sets, whichconsistofmanyinstances of only a couple of differentmolecules. The biggest change they propose is hierarchical ray-casting. When atraversed grid cellonlycovers onepixel, the algorithm does not render thedata, but only determineswhetherthe cell is emptyornot by making atexture lookup. The same principle is usedonentire molecules inthe scene whentheir boundingbox only covers one pixel. Le Muzicetal. [LMPSV14]optimize this approachbyusingaLOD schemeand by building visualization elements on theflyrather thanusingagrid, which allows them to alter atom positions dynamically.They storeatom positions in atexture buffer, and use tessellation and geometryshaderstoemit atoms,trying to maximize the amountofatoms emitted pervertex call. In addition, they also makeuse of repetitive structures.Paruleketal. [PJR+14]focus on supporting computationally expensive surface abstractions in real-time forlarge individual molecules. They achievethatby building ahierarchybased on spatial clustering inabottom up approach. Clusters are formed basedontheir location, and eachcluster is represented by asphere with aradius thatbounds allparticles inside the cluster.For the next level, the errorthreshold is raised, and the new spheres are usedasinputfor theclustering algorithm. Theprocess is stopped, when only asingle cluster remains. Then, they combine thathierarchy with surface abstractions at differentlevels of computational complexitytobuildaseamless model. Guo et al. [GNL+15]implementaview-dependentmacro-molecule rendering framework, whichincludeslevels of detail. Theybuild theirhierarchicalmodel usinga spatial clustering methodsimilar to the one by Parulek et al. [PJR+14]and cluster atoms until onlyasingleone isleft. In order to find the mostsuitable distance metric, they compare theirobjectspaceerrorasshown in Figure 2.2. LOD selection and view frustum culling are performedonthe CPU.LikeLindowetal. [LBH12]and Falk et al. [FKE13], they use repetitivestructuresfoundinmacro-molecules to optimizeperformance. For theirGPU ray-casting,they usethe methodproposed by Grottel et al. [GKM+14].
The grid-basedapproachbyMatthews et al. [MEK+17]isoptimized forvisualenhance- menteffects such as shadows and ambientocclusion. As theirdatastructure needs to be recomputed everytime the scene changesinorder to ensurethe qualityofvisualeffects, they build it on the GPU.They presentthe results of theirmethodwith moleculesofup to about300.000 atoms. It is importanttonote that quantitativeresults of frameworks aimed at optimizingcomputationally expensivevisualeffects cannot be directly com- pared to implementations that focus on utilizingrepetitivestructures or on rendering a maximum amountofsimple spheres at interactiverates. Similarly,the difference between renderingindividualmolecules and repetitivemolecular structures should be noted.
10 2.2. Rendering of Point-based Data
Figure2.2: Comparisonsofthe object spaceerrorofdifferentdistance metrics by Guo et al. [GNL+15]
2.2 Rendering of Point-based Data
Classical representations of molecular dataare based on spheres. Early examples that are still in use includevan der Waalsrepresentations, as proposed by vander Waals [VdW73], and theball-and-stickrepresentations, first used by Hoffmann [Hof65]inlecturesatthe RoyalInstitution of GreatBritain.Thoughproposedapproaches vary,theyusually fall into one of three categories.The data is eitherpolygonizedusing algorithms like Marching Cubes(Lorensenand Cline[LC87]),sampled into adensity volume representation, or spheres are rendered directly using splatting.Asplat or glyph is atwo-dimensional graphical element thatisprojectedontothe 2D viewing plane for eachvoxel or point. According to Ibrahim et al. [IWR+17], ray-castingusing per-fragmentraysbased on splatsfor eachparticle, has been accepted as thestate of the art,atleast inmolecular dynamics visualization.However, differentrendering techniques, accelerationstrategies, and datastructures have always been developedinparallel. In arecent report, Reinaet al. [RGE19] coverthe developmentofpoint-based visualization in the last decade.
Polygonalmeshes generally yield satisfying visualresults, but the approachcreatesa largenumberoftriangles, and does not scale well beyond acoupleofthousand particles. Mülleretal. [MCG03]implementbothpoint splatting, and Marching Cubes-based surface reconstruction forSPH simulations. They find the results achieved by iso-surface triangulation via marching cubes morevisually convincing. It does, however, slow down rendering,whichisnot desirableinreal-time rendering of large datasets. Hao et
11 2. Stateofthe Art
al. [HVS04]use occlusionculling to optimizerendering of time-varyingmolecules. They buildper-frame occlusionmaps on-the-fly.Atomsfromthe sorted listofpotentialatoms foreachframe are projected onto the image plane in afront-to-backorder. Insteadof checking foroverlapofthe circles representing atoms, theyuse twonested squares, one that completelyfits within the circle, whichisused to build the occlusionmap, and one that covers the entire circle to checkifthe atom has been blockedbypreviously rendered atoms. Theyalso include amethod thatchooses an appropriatetessellation resolution according to the amountofspace the atom takes up in the finalrendering. Keiser et al. [KAD+06]propose an alternativemeshing strategyusing 3D Delaunaytriangulation of particles.Bothmethodsimprove performance, buteventhe reducedmeshisstill computationally expensivetorender, compared with other representations.Researchin recentyears hasmainlyfocusedonvery large and dynamicdatasets,sotessellationhas mostly been replaced by othermethods.
Sampling particlesintoavolume allows theuse of GPU-acceleratedvolume rendering, using optimizations such as earlyray termination and emptyspaceskipping as proposed by Krüger and Westermann [KW03]. Mostmethods sample point-baseddata on some type of regular grid.Quiaoetal. [QEE+05]visualizepoint-based atomic simulation data by sampling to aCartesian grid, taking advantage of graphics texture memory.Navrátilet al.[NJB07]use aregular grid, extractingiso-surfaces using Marching Cubes, which they then render using the toolkit ParaView(Ahrens et al.[AGL05]).Theirmethod allows them to visualize severalhundred time-steps containingtwo million particles.Fraedrich et al.[FAW10]sample particle data insidethe view volume into aperspectivegrid. They compare order-dependent splatting to volumeray-casting, as well as ahybrid approach. In theirhybrid method,they add iso-surfacesfor finedetails which, according to their research, cannotberenderedaccuratelyusing splatting. Lindowetal. [LBH12]render largemolecular data sets by making useofrepetitive components found in molecular data.They store atoms of individual componentsinagrid,whichisthen stored in a three-dimensionaltexture. Thegrid is renderedusingaray-casting methodbased on the work of Hadwiger et al.[HSS+05]. Falk et al.[FKE13]extend this algorithm by hierarchical ray-casting, which omitsgrid cells thatcover onlypartofapixel. Reichl et al. [RTW13]visualizelarge SPH simulations using acompressed octree grid, streaming data asynchronously to the GPU.They perform decompression on the GPU,which allowsthem to integrate it into GPU-based out-of-core volumeray-casting. Knollet al. [KWN+14]propose amulti-core CPU methodfor direct volume rendering of particle datausing radial basisfunction kernels. They apply it to both astrophysicaland molecular data sets.Schatz et al. [SMK+16]propose ahybrid multi-scale rendering architecture for very largedata sets. Large parts of the data set are rendered as ahierarchical density volume, while finedetails are visualized using direct particle rendering.
Splatting wasone of thefirst methods used forpoint-based data, and is still relevant today. Most of theearliest works,for exampleCsurietal. [CHP+79]and Reeves [Ree83], useaform of particlesplatting to implementspecialeffects,suchassmoke. Westover [Wes89]introduces an interactive volume renderingmethod basedonsplatting. Laur
12 2.2. Rendering of Point-based Data and Hanrahan [LH91]propose hierarchicalsplatting,also forvolumetric datasets.They combine the splattingmethodwith aprogressive refinementalgorithm,based on a pyramidicalvolume representation. Rusinkiewicz and Levoy [RL00]use hierarchical splatting as apointrendering methodfor meshes. They construct ahierarchy of bounding spheres basedonak-d tree to representthe surface. Extendingthis approach, Max [Max04]proposes amethodfor molecular data. Instead of an arbitraryhierarchy, the natural structure of molecular dataisused. In ordertobetterapproximate the shapes of objects, thepaper proposesthe use of ellipsoids instead of spheres. Hopf and Ertl [HE03]extend the methodtoSmoothedParticle Hydrodynamics (SPH)simulations. They buildahierarchicaldatastructure usingPCA clustering.
Reina and Ertl [RE05]build amolecular dynamics visualization framework based on the work of Hopf and Ertl[HE03]. They generate implicit surfacestorender splats directly on the GPU, thus reducingthe bottleneck between CPU andGPU.Toledo and Levy [TL04] propose ray-tracingbasedGPU implementations of newgraphics primitives likespheres, cylinders, and ellipsoids. Intersection and lighting are computedinafragmentshader based on an analytic representation of theprimitives. Bajajetal. [BDST04]alsorender primitives directly on the GPU.For spheres,they usethe texture-based methoddescribed in one of NVIDIA’s Cg Tutorials by Fernandoand Kilgard[FK03]. Siggetal. [SWBG06] propose an algorithm for GPU-accelerated renderingofquadratic surfaces andapply it to molecular data. Each quadraticprimitive is represented andrendered as asingle vertex. That allows themtocompute ascreen-space boundingbox in avertex shader with perspective correctness. In our work, we usethe same basic approach, rendering one vertex peratom.Inorder to drawthe quad representing the atomcorrectly,weuse the bounding boxofthe atomdefined by its radius and theposition of itscenter and compute the ray-sphere intersectionanalytically.
Laterapproaches focus on optimizing splattingmethods for even largerdata sets. Grib- bleetal. [GIK+07]propose interactiveray tracing for glyph-based representations on multilevelgridstovisualize large time-varyingdata sets. Theirapproachisbased on the coherentgrid traversal algorithmproposed by Wald et al. [WIK+06]. Fraedrichet al. [FSW09]sort SPH data into apage-treeand render it out-of-core. Pages are blocks of data, usually grouped by spatial proximity. To render them,Fraedrichetal. rasterize particlesplats, creating aproxy geometry based on equilateral triangles. They work with datasets containing more than 10 billion particles. Falk et al. [FGE10]propose a combination of splatting, texture slicingand ray-casting to render large dynamic particle simulations.Grottel et al.[GRDE10]also base theirvisualizationonglyphs.They propose to usesplatsand adeferredshadingpass that estimates theirnormal vectors in image spaceinstead of ray-casting individual glyphs. Another paperbyGrottelet al. [GKSE12]proposes an ambientocclusion algorithmfor molecular dynamicsbased on density information collectedinreal-time. Theybuild adensity volume by splatting a spherefor eachparticle into thecorresponding volume cell.The densityvolume is then usedtocreate the ambientocclusioneffect in object-space. In their framework MegaMol, Grotteletal. [GKM+14]renderspherical glyphs using point-based GPUray-castingin
13 2. Stateofthe Art
their basicrenderingmode. Le Muzic et al.[LMPSV14]saveall the required atom positions in atexturebuffer. Each atom is represented by asingle vertex, the center of theatom. They are rendered as spheres using splatting in the fragmentshader. In order to test their framework, they created ascenecontaining30billionatoms, whichtheyare able to render at 10 fps using levels of detail. Wald et al. [WKJ+15]implement abalancedk-d tree datastructure forlarge point-baseddata sets. Theyuse CPUray-tracing to render theprimitives encoded inthe tree. Zirr andDachsbacher [ZD17]propose aGPU based voxelization technique forparticlesets suchasSPH data. Theyrender splats on aperspective gridand then compress the obtained information by only storingthe entry andexit surface depths foreachray.Inorder to accelerate ray-casting, theyuse ascreen-aligned implicit quadtree with differentlevels correspondingtoperspective grids withdecreasing resolution.They notethatthe approachcan be distributed across multiple GPUs. Xiao et al. [XZY17]combine particlesplatting,ray-castingand surface normal estimation techniques.Splatting is used to accelerateray-casting while surfacenormals areestimated using using Principal ComponentAnalysis.They also employGPU-based ray-casting.
2.3Methods forHandling Large Point-based DataSets
Mostpublications thatfocus on very largeparticle datasetscontaintime-steps, suchas molecular dynamics visualizationsand SPHsimulations.Cosmological data sets, suchas those used by Schatzetal. [SMK+16]containuptotrillions of particles. Our current framework is aimed at molecular datasets containing millions of atoms. An importantquestion in handling large datasets is whentoprocess data. Whether it shouldbepre-processed, streamed, or processed on demand, dependsboth on thetype of data, and on therequirements of theframework.Our implementation relies on pre- processing to build the data structure. Pre-processing has to be doneonce for eachnew data structure. As we save the calculated structure to abinary file, it cansubsequently be loadedinsteadofcalculatingitagain.Contrary to this approach, on-demandmethods onlyprocess the data the visualization requires whenever it is needed. This canslow down the application,but mayalso decrease thetotal amountofcomputations, and space necessary. Data requests canbevisibility-driven or query-driven. Streaming is similar to on-demand visualization, except that thedataisnot demanded, butsentwhen it becomesavailable i.e., when calculationsare finished. Alreadyavailable parts of the data setcan be rendered on-the-fly, without thedelayofhaving to wait for the entire data settobeprocessed. This can speed up the creationofvisualizations considerably.The disadvantage is that the user haslesscontrol over availabledata than in an on-demand based system. Large datasets are commonlydividedintosmaller sub-sets.Several terms are used, butinthe context of this work, we will refertothese sets as pages. Paging makes the amountofdataeasiertohandle,bothinthe pre-processing and the rendering stage. It is especially important forextreme-scale datasets thatare toolarge to fit into memory.
14 2.3. Methods for HandlingLarge Point-based DataSets
Datastructures thatdivide largedatasets into smallersub-sets canbeused to implement visibility culling.Blocksofdata that are entirelyinvisible can be discardedearly, saving computational cost. Sharma et al. [SKNV04]visualizedatasets consisting of up to a billion atoms. Theybuild an octreedata structure,whichthey usefor hierarchical view frustum culling. Zhuetal. [ZCW+04]propose amethodfor distributedrendering of large molecular datasets. Their approachuses agrid andfocuses on partitioning the data set anddistributing computations in ordertohandle large datasets. Gribble et al. [GIK+07]propose interactive ray-tracing of multilevel grids. Theyachieveinteractive frame rates fordata of up to 35 million particles. Freaedrichetal. [FSW09]traverse theirhierarchical datastructure everyframe in order to determine the nodes thathave to be rendered. Their test data set contains 10 billion particles, and they manage to achieveinteractiveframe rates. Grottel et al. [GRDE10]use atwo-level occlusionculling strategyfor large molecular dynamicsvisualization. Theyfirst perform per-cell culling to reduce the upload to the GPU.Afterthat, amaximumdepth mipmap is usedtocull individual glyphsinthe geometryprocessing stage. We sortour data into an octree data structure, and employapage-basedculling strategy where we discard pages,when their bounding boxisentirely outside the view frustum.
2.3.1 Common Data Structures Despitethe continuous growth of hardware capacities, datasets can becometoo large to fit into GPU memory,and forextreme-scale data even CPUmemory. In that case,the data needs to be brokenupintosmaller parts. When using paging strategies to render data sets thatare toolarge to fit into memory,partsofthe data are resident out-of-core, and have to be fetchedbefore rendering. Usually, thecurrently requireddataisrequested. Aworking set that fits into memory is then composed and uploaded or updated as needed. Manyprocessingmethodsrequire information from theneighbors of individual points. Going throughall data points in aset is computationally expensive, especially forvery largedata sets. Reducing thenumberofpoints that have to be considered in each step canspeed up renderingconsiderably.Samet [Sam90]gives acomprehensiveoverview over differentdata structures for point-based data. Whichdatastructure is used depends on thetypeofdata, as well as the priorities of the researchers.The most commontypes of datastructuresfor point-baseddata are regular grids, and different variationsoftrees.Some researchers build structures tailored to a specific data type.Bajaj et al.[BDST04]for example do not useaconventionaldata structure, but sorttheir dataintoastructurethey call FlexibleChainComplex, which is based on the hierarchy in Protein Data Bank (PDB)files.Inthis section, we focus on thetwo most common types, i.e.,grid and tree datastructures.Westart with some examplesofgrid-baseddatastructures, but focus in particularonimplementationsbased on octrees, as we usesuchadata structureinour ownwork. Haradaetal. [HKK07]dynamically constructasliced datastructure forparticle-based fluid simulations.They dividethe voxel gridintoslicesperpendicular to one axis, and define boundingboxes foreachslice. Memory forthe gridisdynamically allocated,
15 2. Stateofthe Art
Figure2.3:Data slices shown in Haradaetal. [HKK07]. Theycompareafixed grid data structure (left) with the dynamic gridthey propose (right) .
achievingimprovedcache efficiency,asitculls most of the emptyvoxels.Figure2.3 shows acomparison between afixed andadynamically allocatedgrid. In addition to presenting the conceptualdatastructure, they implementand testitboth on the CPUand GPU. Gribbleetal. [GIK+07]use hierarchicalmultilevel regular grids for particlebasedvolu- metric data. As they want to optimise theirmethod fortime-varying data sets, grids are constructed on-the-fly. Grottl et al.[GRDE10]use ray-casting on aregulargrid, whichhas thesame extentasthe bounding boxofthe data set. They employGPU ray-casting and deferredshadingwith smooth normal vectorgeneration. They arguethat the simplicityofthe datastructure allowsahigher number of occlusion queries. Fraedrich et al. [FAW10]sample particles onto auniform 3D grid. Instead of thesimulation domain, the grid is fixed to the view volume. Therefore, only theview frustumisdiscretized. Spacingbetween gridvertices along theview rayincreaseslogarithmically, resulting in a decreasingsampling rate alongthe viewing direction. Anotherimplementation that uses aregulargrid is presented by Matthewsetal. [MEK+17]. Theyinvestigatebothafixed gridand acompact grid forvisualization of molecular trajectories. Due to more efficient memory access,they conclude that thecompactgrid outperforms the fixed gridfor large proteins. Rusinkiewicz andLevoy [RL00]implement ahierarchy of bounding spheresbased on a k-d tree to represent the surface of asolid object.They useitfor viewfrustum culling, back-faceculling,alevel of detail scheme, and rendering.Pfister et al. [PZVBG00] sample geometricmodels into pointprimitives called Layered Depth Cubes (LDC). These primitives are then stored in an octree data structure. The lowest levelofthe octree
16 2.3. Methods for HandlingLarge Point-based DataSets contains theresolution acquired duringsampling. Blocks on higher levels are constructed by sub-samplingbyafactor of two. During rendering, the octreeistraversedfrom lowest to highest resolutionblocks. View-frustumcullingisperformed using the block’s bounding box. Hopf and Ertl [HE03]argue thathierarchical datastructures impose higher memory requirements, so theydecouplethe cluster hierarchy fromthe actual pointdata. They store theinformation about points in acontinuousarray, while the hierarchical datastructureonlystores pointers. In order to reducememoryrequirements, they store pointcoordinates relativetoclustercoordinates.Figure 2.4conceptually shows thehierarchy levels.The finest level, shown on therightside, containsthe actualpoint information.
Losassoetal. [LGF04]propose an unrestricted octree grid to refine andcoarsen particle datasets to simulate water and smoke. Max [Max04]buildsatree hierarchy with individual atoms as leaves. Coarserlevels of detailare represented as ellipsoidal objects, and are storedatthe internalnodes of thetree.Sharmaetal. [SKNV04]visualize datasets containing up to abillion atoms. Theiroctreeconsistsofthreelevels.Nodes at level2containpointers to the atoms stored in the correspondingsubspace. Lee et al. [LPK06]use abounding tree to achieveview dependent mesh simplification as well as viewfrustum culling. Raschdorf andKolonko[RK09]compare differentdata structures forlarge particle simulationdata sets. Theypresentahybrid data structure consisting of aloose octree combined with local neighborhood lists. Reichl et al.[RTW13]visualize largeSPH simulations usingacompressedoctree grid from whichthey streamdata asynchronously to the GPU. Wald et al.[WKJ+15]adapt thebalanced k-d tree proposed by Bentley [Ben75], and use CPUray-tracing to render it. Rather thanusing thetree to store differentlevels of detail, they useittoreorderthe original data set.
We implementanoctree data structureininour framework. The resolution of the tree is determined by aspecifiedmaximumnumberofpointsper page. Contrarytomany implementations, data, including level of detail resolutions, is onlystored in leafnodes.
2.3.2 LevelsofDetail
Visualizing severalmillionatomsindividually can become quitecomputationally expensive, even whenrenderingsimple surface models. However, display resolutions limit the amount of informationthat can be shownatonce, so optimization is possible. If the view is "zoomed in", whichmeans thatatomsare visible in detail,large parts of the data setare outside theview frustum, and can be culled. In a"zoomed out" view,less or no data maybeculled, but many individual atoms are clustered in aspace thatisrendered as less thanasingle pixel.Thatmeans thatthe data structurecan be shownatalower resolution, withoutgreatimpactonthe visual result. In such casesorwhenthe only goal is to visualize the generalshape of amoleculewithout need fordetails level of detail strategies can be used.Keiser et al.[KAD+06]arguethatthe resolutionofthe chosen levelofdetail should be highenoughtoshowfine-scale surface detail, while reducing the number of particles as much as possible in order to minimize the computational overhead.
17 2. Stateofthe Art
Figure2.4: The hierarchy levels as implemented andillustratedbyHopf and Ertl [HE03]. The illustrated hierarchy is decoupled fromthe storage of the underlyingpointdata. Points arestored in acontinuous array,while the hierarchicaldatastructure illustrated in the figureonly stores pointers.
18 2.3. Methods for HandlingLarge Point-based DataSets
Figure 2.5:Level of detail construction as implemented by Fraedrichetal. [FAW10]. The data structure is constructed bottom-up.Particlesare copiedtothe next level as long as their diameter is larger than the gridsampling resolution, thosethat aresmaller are merged.
They implement amulti-resolutionparticle-basedfluid simulation. Levelsofdetail are created by splitting and merging individualparticles.
Forgeneralpoint-based data, levelsofdetail are usuallycreated by clustering data points, based on the positions and in some cases radiiofthe points. Most level of detail structures are builtbottom-up. Pfister et al. [PZVBG00]storethe resolutionacquired during sampling at the lowest level of theoctree. Blocksonhigher levelsare constructed by sub-sampling by afactor of two.During rendering,the levels aretraversed from lowest to highest resolution. Hopf and Ertl [HE03]create their LOD hierarchy using principal component analysissplits. The multilevelgrid proposed by Gribble et al. [GIK+07]also constitutes alevel of detail scheme. Theoriginal particlesare stored at the finestlevel. Theresolution of thegrid is determined suchthatthe number of cellsisamultiple of the totalnumberofparticles. Coarser levels are imposed over the previous level, where each block correspondstoM×M×Mblocksofthe underlying level. In the implementation discussed in thepublication, theyuse atwo-level hierarchy.Fraedrich et al.[FAW10] alsobuild their data structure bottom-up. As longasthe diameter of aparticle is larger
19 2. Stateofthe Art
Figure2.6:Atincreasing distance from thecamera, Le Muzicetal. [LMPSV14]skip atoms, adaptingthe radiusaccordingly
than thegrid sampling resolution, it is copiedtothe next level, as showninFigure 2.5 on the left. Particlesthathavediameters smallerthanthatare merged andenlarged to the gridspacing.Reichl et al.[RTW13]build their level of detail hierarchy bottom up in asimilarway.However, they store it in an adaptiveoctreedatastructure,rather than a hierarchical grid. Le Muzic et al.[LMPSV14]use tessellation shaderstolower the number of rendered atoms according to increasingcamera distance.Figure 2.6 shows the same molecule renderedatdifferentlevels of detail. One of thegoals istoimplementsmooth transitions between neighboring LODs. Theysort theatoms by increasing distance from the center of themolecule’s boundingbox.Based on that distance, they decide how manyatomsare skipped and increasethe radius linearly. Formolecular visualization, it is possible to usethe naturalhierarchy of biomolecular datatoimplementlevels of detail. This approachisproposed by severalpapers, such as theFlexible ChainComplex by Bajajetal. [BDST04]. In their method, eachlevel is associated withageometric representation. Atoms are rendered as single spheres,and residues represented by abounding sphere. Secondarystructuresare represented by setsofcylinders and helices.Van derZwanetal. [VDZLBI11]implement continuous transitions between threeseparate visualabstraction models: the vdW surface, the so-calledball-and-stickmodel, and acartoonrendering.Waltemateetal. [WSB14]also base theirvisualization on the naturalcharacteristics of biomolecular data.They present an interactivetool, which makes it possibletocombine themesoscopic andmolecular levelincell visualization.The result is avisualization of wholecells, with an interactive magnifierthatallows the usertoinvestigatethe structure andbehavioronamolecular level. The methodthey propose is basedoninstantly computedlocal parameterizations that are usedtomap patches of membrane structuresontoregions selectedbythe user. They render the mesoscopic level basedontrianglemeshes,and the atomic levelusing asplatting technique based on local ray-casting of spheres.Parulek et al. [PJR+14] propose alevel of detail concept thatcombinesthreedifferent surface models in one
20 2.4. Biomolecular RepresentationModelsand EnhancementMethods visualization. TheyblendSES,Gaussian kernels and vander Waals surfaces, based on linear interpolation,and implementashading scheme that allowsthem to create seamless transitions between the representations. Guo et al. [GNL+15]use avolume baseddistance metric to selectappropriate levels of detail depending on the viewpoint.
2.4 BiomolecularRepresentation Models and EnhancementMethods
Atoms in molecular data sets canbetreated likeany othertypeofpoint-baseddata. Depending on the complexityofthe scene and capability of thehardware,simple point- or sphere-basedrepresentations maybethe most suitable, or indeed only possible visualization model. In many cases, however, alot of additional insightcan be gained by using more complex models.
2.4.1 Representation Models
The vander Waals(vdW) surface is defined by the unionofspheresproportional to the covalentradius of theindividualatoms. It is simple and efficient, andthereforethe most commonlyusedrepresentation for atomic data. Additionally,itserves as abasis for many other surface models. Lee and Richards [LR71]propose Solvent Accessible Surfaces(SAS) as an extension of vdW surfaces. They illustratewhichregions of amolecule can be accessed by asolvent. Conceptually, the surface is createdatthe positionofthe probe’s center, while rolling over the surface, which is the same as extending the vdW radiusof each atom by the radius of the probe. The disadvantage of theSAS is that it inflates thesurfaceofthe molecule. Richards[Ric77]addresses this issue with the introduction of Solvent ExcludedSurfaces(SES). Insteadofusing the center of the solventsphere, its boundary is used. Thismeans thatthe volumeofthe resultingmolecular surface is closer to thevdW surface, while still illustrating accessibility. SolventExcluded Surfaces show the boundaryofthe volume with respect to aspecific solvent.They arevery useful in the explorationand development of substances,e.g., when developingand testing pharmaceuticals. Therefore, they are included in most molecular visualization toolkits. However, the calculation of an SEStends to be computationallyexpensive.Itcan either be computed by discretizingspace, or by determiningthe implicit surface equations of itssurface patches.Lindow et al. [LBPH10]implementaparallelizedversionofthe contour-buildupalgorithm originallyproposed by Totrovand Abagyan [TA96]. Krone et al. [KGE11]also propose aparallelizedoptimization of thecontour-buildup algorithm on the GPU. They subdivide calculationtasks in order to optimize them forparallel processing. Parulek and Viola [PV12]presentamethodthatcalculates theSES while allowing the usertochangeparametersinteractively. They use local neighborhoods to compute implicit functions representing the surface.Hermosilla et al.[HKG+17]develop agrid-based GPU implementation using ray-marching, which allowssmoothtransitions between differentlevels of detail. As one of theirmaingoals is to ensure real-time
21 2. Stateofthe Art
interaction, they computeanSES using alow-resolution gridinreal-time, and refine the surface progressively in the background. Anothersurface representation is the Molecular Skin Surface (MSS), which appliesthe skin surface algorithm proposedbyEdelsbrunner [Ede99]tovdW spheres.The MSS hasthe advantage of being C1-continuous (so the derivative does not change wheretwo curvedsurfaces cross). Thedisadvantage on theotherhand is thatithas no biophysical background.While an SESapproximates asolventmolecule withasphere, Lindowet al. [LBH14]propose to usethe ligand’s actual vdWsurface instead,showing the surface thataparticular ligandcan access in more detail. This so-calledLigand ExcludedSurface is even more computationally expensive thanthe SES, so it is usually onlyapplied when pre-computation is feasible.Ininteractivecontexts, the SESorevensimpler models are still preferredbymost researchers. Blinn[Bli82]proposes an approximation of molecular surfaces using aGaussian convo- lutionkernel, commonly known as Metaballs. Parulek and Brambilla[PB13]presenta modelthatclosely resembles theSES,while approaching the rendering performance of the Gaussianmodel. It is based on iterativeblending of implicit functions,and is visual- izedusingGPU-based ray-casting. Krone et al.[KSES12]compute interactivesurface representations of large dynamic particledatasets.They build avolumetricdensity mapbased on Gaussian kernels,using aGPU-accelerated marchingcubes algorithm. Structuraldetails canbeadjustedinteractively.Inour framework, we usethe method presented by Bruckner [Bru19]. It is an image-space approachtothe computationof Gaussianmolecular surfaces. As themolecular surface only needs to be computed for visible parts of the molecule,unnecessary computations can be skipped. An on-the-fly list-baseddata structure is constructed for everyframe.Tocreate the list, the atomsin the molecule are rendered as spheresintwo separaterenderingpasses. The first pass is usedtoidentify all intersecting vander Waalsspheres forevery viewing ray. In the second pass,the sphere of influencefor eachatom is rendered in the same way. Foreach pixel, alinked list of the intersections of the spheresofinfluenceisstored. Those are the only spheres thatpotentially contribute to thevisible surface. In order to minimize computationsinoccluded regions further, visibility-based raytraversalisused.
2.4.2EnhancementMethods forPoint-based Data Differentshadingmethodscan be usedtoenhance complex molecular visualizations. Color can be mapped either to individual chemicalelements, or other properties,such as which amino acid chainitbelongs to. In addition, effectssuchasdepth of field, ambientocclusion and,edge-cueing can guide the viewer’s eyetoimportantareasofthe visualization and combat visual clutter. Ambientocclusiondescribes the amountofambientlightthatreaches each pointina scene.Objects on the insideofstructures,orthat are occluded by directneighbors are darker, so ambientocclusionhelpsthe viewertocorrectlyjudge the depth of structures. Tarini et al.[TCM06]propose aset of techniques to enhancethe user’s understanding
22 2.5. Summaryand Conclusion of rendered molecules.Inorder to compute ambientocclusion,they use severalrender passes, creating shadow-maps fromthe z-buffer.They achieveacontour line effect by drawing aline around each rendered primitive. The thicknessofthe lines can be rendered dependent on the difference in depth betweenthe primitives it separates.Additionally, they propose to drawhalos aroundatoms. Thebigger thedistance between apoint in the halo and itsbackground, the more opaquethe algorithm draws it.Grottel et al. [GKSE12] implementanobject-space ambientocclusion algorithm based on localneighborhood information. Their approachisbased on theaggregation of particledataintoacoarse resolution densityvolume, which is then usedtocalculatethe ambientocclusionfactor. Staibetal. [SGG15]propose an illumination model that supports transparency,ambient occlusion, surface reflection, and ambient illuminationbasedonthe emission-absorption model of volumerendering. It runs in real-time for millionsofparticlesand is based on analytic solutions to the volumerendering integral.McGuire et al.[MOBH11]present ascreen space ambientocclusionmethod.Rather than approximating the equations governing indirect illumination in an efficientbut error-prone way,they use the full radiometricmodel until the screen-space sampling step.Simplification is still possible by using the fall-off functiontocancelexpensiveoperations. Skånebergetal. [SVGR15] aim to communicatetheir spatial arrangement,but also to visualize pairwise atom interaction strengths. In order to achievethat, they propose an analytic approachfor capturing ambientocclusionand interreflections of molecular structures in real-time.The neighborhood search required to calculate the influence of atoms, is based on agrid data structure. Thecell size canbeset anddefines acut-offdistance forthe interreflections. Matthews et al. [MEK+17]also useambientocclusiontoenhance depth, and shadows to help the user perceiverelativemotions of partsofthe protein. Their algorithm is similar to thatofSkåneberg et al. [SVGR15]. Theyuse aregulargrid to accelerateshadow casting,but findneighbors peratom rather thanper fragment. Anotherenhancementmethod widely usedtodrawattention to acertain regionorfeature, is depth of field.Depth of field is an optical effect knownfromphotography,where objectsonand aroundafocus plane are sharp, while therest is blurred. Theblurring factoriscalledcircle of confusion.Itcan be calculated based on focal length, distance, and aperture. Thecloser the focusedobject is to the camera,the narrowerthe fieldof focus. Examplesofthis methodcan be foundinseveralpublications.One example is the methodproposed by Falk et al.[FKE13]. They use an image space methodtocreate the effect. They calculate the size of the circle of confusion, whichisthen used to sample a mipmap chain of thecolor and depth buffer. In our framework, we implementadepth of field effect basedonthe work presented by Bukowskietal. [BHOM13].
2.5 Summary and Conclusion
Boththe field of biomolecularvisualizationand large point-baseddata setshavebeen researched widely and successfully.However, biomolecular visualization methods generally eitherfocus on smallerdata sets, or relyheavily on apriori structural knowledgeabout the data.Methodsaimedatpoint-based datasets on theother hand can usually handle
23 2. Stateofthe Art
extreme scale data efficiently,but do notprovide anyofthe surface methods thatare often expectedinbiomolecularresearch. We therefore conclude that there is aneed fora framework that can handlelarge datasets without anyparticular knowledge about the structure of the data thatnonetheless allowsthe useofsurface models andenhancement methods.The most common datastructures forhandling large data setsappeartobe regular grids and to alesser extent variousforms of trees,inparticular octrees.Levels of detail for point-based data are mostoften implementedusing abottom up approach to spatialclustering.Asamain surfacemodel,biomolecular visualizationmethods generally usevdW surfaces and often additionally includethe possibilityofcomputing theSES. Popularenhancement methods for point-based data include in particularambient occlusionand depth of field.
24 3 CHAPTER
Data Structure
Thegoal of our implementation is to render large sets of molecular dataatinteractive rates,inorder to help users to better understand the data. As discussed in the previous chapter,there are severaldifferentapproachestosimilarproblems. Our solution is a novelcombination of several establishedapproaches. We dividethe description and discussionofour methodology into two parts. In thischapter,wefocus on the underlying data structure, while rendering aspects of our implementation are covered in aseparate chapter. Large datasets require structure management, especially whenthe systemisexpected to perform at interactiverates. Thegoal is to reducethe sizeofthe working set, i.e., the data thatneeds to be processed at aspecific time,while keeping as much information availableasnecessary or possible.Asitisunlikely thatall details of alarge dataset need to be visible at the same time, it is possibletomanage thedata in suchaway thatonly the parts thatare currently required, are fetched and processed. Similarly, some parts of large datasets areusuallyinthe fardistance, whichmeans that they only occupya very small portion of anygiven screen, or they are at least partially covered. Therefore, renderingdata at differentresolutions can alsobepartofasolution. Implementations that target extreme-scaledata sets, suchasFraedrichetal. [FSW09], needtosolvethe problem thatthe data does notfitintothe memory of current work- stations.Inorder to make visualizationsoftheentire datasets feasible, theyhave to be dividedinasuitable way.Manyimplementations provide level of detail schemes, whichreducethe amountofdatathatneeds to be processed for agiven frame, without necessarily reducing thevisual quality.Weaim to optimizerenderingfor datasetsofup to severalmillions of atoms, without requiring additional informationabout the data set. As we will see in Chapter 6, achievableframe ratesare highly dependent on the amountofpoints or atoms that are actually within the viewfrustum forthe current frame.Therefore,camera position and level of detail, on whichthe number of visible data points depends, have agreater influence on theperformance than the number of
25 3. Data Structure
atoms in theoriginaldataset. This makesitsomewhat difficulttodirectly compare numbers.Implementations that rely on repeating instancesofmolecules,suchasfor exampleLeMuzicetal. [LMPSV14], can render up to billionsofatoms. Those that focus on graphical aspects, such as enhancementorsurface models, like for exampleMatthews et al. [MEK+17]orParulek et al.[PJR+14], do not go beyond afew hundred thousand atoms in their test sets.Whatweare investigating, is howtoclose this gap, and develop adatastructure andrenderingsetupthatmakes it possibletorender several tensof millions of atoms withoutpriorstructural information, using differentmolecular surface models, and applyingenhancementeffects. As we want our datastructure to be able to handle large datasets,weneedtodivide the data into manageable blocks. There are two mainbottlenecks where very large data sets canbecome problematic. Processing or pre-processing steps thatdepend on neighborhood queries caneasily get out of hand if thealgorithm needstovisit eachindividualpointfor alarge data set.Also, theamountofdatathatcan be processed in the renderingstep itself, is limitedbyhardware capacities. Very often, however, notthe entire data set is visible at once. Therefore, the answer to both of these issues can be aspatial division of the data.Asthe densitywithin moleculardata setsvariesspatially,wewantour data structure to provide the option to control the maximum amountofdata in eachpage (spatial block). We also want pages to containapproximately the same, or at least a similaramountofdata. Our final choiceofdatastructure is adensitybased octree with pre-calculated levels of detail.
3.1Overviewofthe Components forCPU DataHandling
The main contribution of our work is adata structure that divides largedatasets into manageable blocks, which facilitate efficient calculationsofneighborhood-based algorithms. Our design is basedonacore CPU-baseddata structure,aswell as aset of other components thatmanage dataand rendering.Figure 3.1illustrates themain componentsthatare involved in handling the data and constructing the structure. Theblackarrows illustrate howcomponentsare related. Graycomponents above the dashedline are mainly concernedwith rendering and front-end operations, which are covered in Chapter 4. In this chapter,wefocus on components responsible fordata managementonthe CPU, which are illustratedbelowthe dashed line in Figure3.1.The protein is part of thescene component,whichisinturn part of the viewer component. At anygiven time, there is only oneinstance of each of thesecomponents. The viewer contains renderers. The renderer responsiblefor drawing the datapoints that represent atoms or clusters,iscalledsphere renderer. There can be severaldifferenttypes of renderers.Their displaymethods are calledconsecutively. We useaseparate rendererto render bounding boxes. Data from the .pdb file (Protein Data Bank, Berman et al.[BWF+00]) is read intoour frameworkinthe protein component. As we expect our implementation to be able to handle largedata sets, we divide them spatially.The page componentrepresentsthe
26 3.2. The Octree Data Structure
Viewer SphereRenderer
Scene draw Rendering Data management pdb data Protein
Page Cache
Figure3.1:The main components involved in handling the data structure. Blueindicates where the actual (per point) dataislocated. The blackarrows show which components containeachother. building blocksofthe resulting data structure. We store asingle page, the root of the octree, in theprotein component. As we want to control themaximum number of atoms on asingle page,the depth of theoctree dependsonthe densityofthe data structure. Each page thathas more thanaspecified amountofatomswithin its bounds is subdivided and stores pointers to its eight child nodes. The actual datapoints are stored in the pages that are leaf nodes. This allows us to mixpages of differentspatial extent,but with asimilaramountofdata, which we takeadvantage of in our cacheimplementation. The cache componentmanageswhichdata is uploadedtothe GPU.Itimplements aleast recently used cache whichisresponsible foralistofvisible pages and for replacing the onesthat are no longer needed.
3.2 The Octree Data Structure
Ourmain requirements foradata structure arethat it has to dividethe data in away that makesitpossibletohandledataefficiently,i.e., by reducing bottlenecks, as well as make computationally expensiveneighborhood-based calculations feasible.Wepropose an octree-baseddata structure. It divides thedataset spatially into hierarchically organized units, the pages. Within these pages,wesavethe data at differentresolutions, or levels of detail. The datastructure is built in apre-processing step.Inthis section, we explain the design and implementation at the coreofthe data structure, the pages and the octree
27 3. Data Structure
they form, as well as the construction of the levelsofdetail. Structuring available dataintoblocksthat aremanageable,bothintermsofmemory, and thecomputation of computationally expensiveneighborhood queries, can be achieved in several ways. Foracomprehensiveoverviewofdata structuresfor point-baseddata, we refer to Samet[Sam90]. The mostcommon choicesare regulargrids, and hierarchical tree-based datastructures. Severalvariations of both have been testedand proposed. A griddatastructure is asimple andfast waytodivide space. Regular and perspective gridsolutions are very common in implementations that render theirdatabysampling it into avolume(forexampleQiaoetal. [QEE+05], Navratiletal. [NJB07], Knollet al.[KWN+14], etc.).They are alsousedinsome related implementationsthatrender atoms as spheresdirectly on the GPU (Grottel et al.[GRDE10], Lindowetal. [LBH12], Falk et al. [FKE13],Matthews et al.[MEK+17]).The disadvantage of regular grids is that they allowlittle controloverthe amountofdata in eachblock.Itisofcourse possibleto definethe size of thecells by specifying amaximum number of points in each cell instead of spatial units.The drawback of adaptingthe cell sizetothe densestareasinthe data set is thatitresults in an unnecessarily fine division of space in sparse regions, especially if datapoints are distributed unevenly.Inour framework, we opt for ahierarchical data structure, as it provides greater control over the division of space. Tree-based data structuresare anothercommon choice, especially for implementations thatincludelevel of detail schemes. Several variations of trees have been proposed in the contextofpoint-based rendering.Though octrees are mostcommon,k-d trees (Rusinkiewiczand Levoy [RL00], Wald et al. [WKJ+15]) are also used. The child nodes of an octree node dividethe space into eight smallercubes (four squares in the two- dimensional case).Inregions with sparse data,lowersubdivisions canbeused, providing theability to controlresolution. K-d treesare also basedonhierarchical space partitioning. Whileoctreesare alwayspartitioned cubically,the splitting planes in k-d trees can be placed arbitrarily in space. Space is divided by one axis-aligned split plane perlevel of depth, recursively subdividingspace into abinary tree. Each node is split into two halves, alternatingbetween axes.Inorder to achieveabalancedk-d tree, points in the data set are usedtopartition space. Geometric primitives are usuallystored in leafnodes. In k-d trees, it is notpossibletocontrol thenumberofneighboring cellsthathavetobe examinedwhen using nearest neighbor queries, as splitplanescan be placed anywherein the node. Octrees,onthe other hand, dividespace in aregularmanner. Eachnodeis either aleaf, or is equally divided into eight sub-nodes. Thismakes the divisions more predictable, which makes the datastructure easier to handle. It alsomakes octrees a good choice when amore even division of thedata set in terms of the amount of points perpage is apriority. Most solutions thatuse octree data structures in combination with alevel of detail scheme thatwehavecome acrossinour research, use the nodes throughout the octree to store level of detail data. Often, theoriginaldataisstored in the leaves, and coarser levels of detail in internalnodes.This approachcreates astructurewhichisvery similar to regular gridswith severaldifferent resolutions linked together. Whilethis can be
28 3.2. The Octree Data Structure
pdb input reads gives from Protein to Page
LODs ... creates
Figure3.2: Flow of datawhile creating the data structure. Blueindicates where actual point data is saved. Theprotein component managesthe data structurewhichconsists of nested page components.
very efficientinmanysituations,the disadvantage is that pages or gridcells at different levelshave different spatial extents, which makes mixinglevels of detail more difficult. It alsomakes it harder to achieveasimilar amountofdatapoints pernode. We usethe hierarchical divisionofspace somewhatdifferently.Insteadofstoringcoarserlevels of detail in the internalnodes,westore alllevels of detailinthe leaves. Space is divided depending on atom densityinthe original data. Internal nodessimply contain pointers to their children.
3.2.1 Dividing the Data Set into Pages In apre-processing step, the setofdatapoints is processed, divided,and stored,building the data structurethat is thenusedthroughoutinteractiverendering.Figure 3.2 illustrates the flowofdata through thecomponents.The proteincomponentreads in the original data.Atthis stage, the data foreachpoint consists of aspatial position and aradius. The protein stores asingle page, which servesasthe basis for the octree, and which is filled with data andsub-pages in the pre-processing step. The page componentis responsible forboth subdividingdata, and calculatingclusters to build levels of detail. We readatom positions, and informationabout moleculesinthe Protein Data Bank (PDB)file format. Foreachatom,weget the spatial position, and theelementname from thefile, whichwethen look up in atable in order to get theradius. Thisinformationis stored in afour-componentvector. Whenbeingread fromthe .pdb file, the atoms of such asingle time-step are stored in one vector. This vectoristhen handedovertothe basic page,the root of theoctree, where the data is divided into sub-octrees,according to the specifiedmaximum number of atoms perpage. The maximumnumberofatomspossible in our currentsetup is 32,768 (215). Thisisdue to numerical limits whichare explainedinSection 3.2.3. We did notfind the limit of 215 atoms problematic, as theclusteringalgorithmweuse to build ourlevels of detail is dependentonneighborhoodcomparisonsand becomes very inefficientfor larger pages.
29 3. Data Structure
Algorithm3.1: Spatial datadivision. If the number of points in apage exceeds the maximum number of allowedpoints,itgetseightsub-pages andthe data points are divided according to their spatial position. Thisisdone untilall pages fulfillthe size limit. Input: Maximum number of atoms perpage max,current page p containing vectorofatoms, lowerBound and pageSize 1 if size of atoms >max then 2 Create array of 8 subP ages in p foreach a ∈ atoms do (a.xyz−lowerBound) 3 pos = pageSize 2 insert a into vectorofatomsinpage at position pos in subP ages 4 end 5 foreach page ∈ subP ages do 6 run spatial datadivisionalgorithm 7 end 8 end 9 else 10 return atoms 11 end
The pseudo-code shown in Algorithm3.1 sums up the divisionofspace into pages. Starting with the basic page savedinthe protein component, we checkifthe lengthof the vector of atoms assigned to it exceeds themaximum allowednumberofatomsper page. If it does not, thealgorithm ends.Ifitdoes, we create asub-octree, i.e.,atwo by twobytwo arrayofsub-pages thathave half the page size of theparent-page in each direction. Then, we iterate overall atoms,and sort themintothe sub-pages according to the formula giveninalgorithm 3.1. Foreachsub-page, we recursively repeat the process. Whenthe number of atomsassignedtoapage no longer exceeds thelimit, it is considered aleaf page, and thevectorofatoms is saved, insteadofcreating sub-pages. Once the number of atoms on apage falls underthe allowed maximum, we proceed to the creation of the levels of detail, as describedinsection3.2.2. Figure 3.3 shows asimplified illustration of thesubdivisionofadataset,withalimit of 3atomsper page. The basic pagecontains more than 3atoms, andissubdivided. After thefirst subdivision, twosub-pages stillexceed the limit. Pages are subdivided depth first,sowecheck allchildren of thefirstofthese two sub-pages recursively,before moving on to checkits siblings. Whennopage contains morethan3atoms, we have created theleavesofall branches and the finalstructure is reached. Thestructureofapage can be summed up as follows. Eachpage savesits position, size, lowerand upper bound.Aleafnodeadditionally storesanarray containing the atoms that fallwithin its bounds at differentlevels of detail. Inner nodes have pointers to their child nodes.
30 3.2. The Octree Data Structure
(a) Basicpage (b)Subdivision 1 (c) Subdivision2 (d) Subdivision3 (e) Finalstructure
Figure 3.3: Illustration of page subdivisionwith max. 3atoms perpage
Figure3.4: Octree structure for the molecule 3j3q.The blue lines showthe bounding boxesofpages. In denser areas,more subdivisions are used.
Figure3.4 shows the leaf nodesofthe hierarchicaldatastructure for themolecule 3j3q, whichcontains 2,440,800 atoms, making it the largestindividualmoleculecurrently availableinthe Protein Data Bank. The maximum number of atoms perpage is set to 32,768, the largest number possibleinour current setup. The figure showsthe molecule at theoriginal resolution. Additionally,the bounding boxes of the pages are illustrated in blue. In denserareas, themoleculeisdivided into smallersub-pages while emptyand sparse areas are not subdividedany further.
3.2.2 Calculating LevelsofDetail Levelsofdetail are acommon methodtoincrease flexibility, andimprove performance.For point-baseddata, they are usually calculated bottom-up, using avariation of hierarchical
31 3. Data Structure
clustering. In order to calculatethe clustersthatform our coarserlevels of detail, we use the hierarchicalclustering implementation by Müllner [M+13]. Several researches (Max[Max04], Bajajetal. [BDST04], Vander Zwan et al. [VDZLBI11], Waltemate et al. [WSB14]) propose usingthe naturalhierarchy of molecules,ratherthan purely spatialapproaches.This methodprovides the user with additional structural information, as well as anumberofdifferentlevels of detail. However, the approach is notparticularlyflexible, as it relies on very specificinformation, andcannoteasily provide intermediate levels of resolution. The main goal of our LODimplementation is to optimizeperformance, and enable us to render larger data sets, notnecessarily the integrationofadditional structuralinformation.Thatiswhy we chose themore flexible approachofhierarchicalclustering.Structural levels of detail could be consideredin addition to our existingLOD schemeinafuture developing step. Bothour owntests, and the results achieved by Paruleketal. [PJR+14], showthat density-based clustering does not perform well on thetypeofdataweuse.Atomswithin most moleculesdonot show asignificantvariation in distribution.Therefore,density- based clustering often resultsinonlyasingle clusterfor alarge partofthe molecule. Hierarchical agglomerativeclustering,suchasthe fastcluster algorithm proposed by Müllner [M+13]whichweuse, is more suitable. Guoetal. [GNL+15]argue thatthe algorithm has twolimitations: according to theirexperiments, it is difficult to findthe most suitable parameters,and it requireshierarchical abstraction. Theyuse avolume- baseddistance metric in order to reduce the screen-space error. However, we found the resultssatisfying, and thecontrol over parameters sufficient. Hierarchical agglomerativemethodsclusterinput data basedonadissimilarityindex, starting with eachpointinasingle cluster.Usually, the indexisstored in amatrix, which is by definitionreflexiveand symmetric. Another possibility is the so-calledstored data approach, whereinput points are handed to theclustering algorithm in vectorform, and dissimilarity is specified implicitly.The algorithm by Müllnerprovides two options to define the size of clusters.The user caneitherspecifythe desirednumberofclusters, or acut-offdistance. Algorithm3.2 showsasimplifiedpseudocode of thehierarchical clustering algorithm. We calculate the dissimilaritymatrix based on theEuclideandistancebetween two respectivepoints. Additionally,the algorithmeither needs to know acut-off distance, or thenumberofdesired clusters. In order to specify areasonable number of desired clustersmanually,one would needsome information about thestructureofthe molecule. Specifying acut-off distanceismore flexible,asthe user does notneed anyparticular information beforehand. Therefore, we found it more suitable forour needs and avariety of molecules. In our implementation, we useacut-off distance of c =2l,where l is the level of detail being calculated. Müllner [M+13]implementsfour modesoflinkage forhierarchical clustering: Single- linkage (nearest neighbor), Complete, Average and Median.Figure 3.5 shows the results of the differentdistance calculation formulas for the molecule2btvatlevel 1and 5. The
32 3.2. The Octree Data Structure
Algorithm3.2: Fastcluster by Müllner [M+13]based on anearest neighbor approach. The algorithm needs apair-wise dissimilarity (distance) index, as well as thenumberofpoints to be clustered,and returns alist of labels that dividethe points into clusters. Input: Apair-wise distance index D,the number of points to be clustered C Output: Output list L,numberofpoints percluster P 1 createlist of nearest neighbors nn calculate priorityqueueofindices Q,mindist as keys for j ← 0 to N − 1 do 2 a ← min elementofQ b←nn[a] while dist(a, b) = mindist(a) do 3 recalculate nearest neighbours 4 end 5 add (a, b)toL update C remove a from Q for remaining elements do 6 update distance matrixusingformula3.1 7 end 8 for remaining elementswhere x n d(I,K)+n d(J, K) I J (3.1) nI + nJ Algorithm 3.2 shows apseudocodeofthe hierarchicalclustering method. Foragiven set of nodes, apairofclosest points is determined. Those nodes n1 and n2 are then joined 33 3. Data Structure (a)Averagelevel 1 (b) Median level 1 (c) Single level 1 (d) Complete level 1 (e) Average level 5 (f)Median level 5 (g) Single level 5 (h) Complete level 5 Figure 3.5: Levelsofdetail for the molecule2btv Clustering Methods 7 35000 ts 6 30000 in te po la 5 25000 f cu r o al 4 20000 c be to s 3 15000 num nd 2 10000 g co in lt Se 1 5000 su 0 0 Re AverageMedianSingle Complete Method Level 1 Level 5 Time Figure 3.6: Numberofatomsatlevels 1and 5and buildingtime,showingthe number of resultingclusters for2btv forlevel 1(red) and 5(green) as well ast thetimeittakes to buildthe data structure using thatmethod (blue). 34 3.2. The Octree Data Structure (a) Full resolution (b) Level1 (c) Level2 (d) Level3 (e) Level 4 (f)Level 5 (g)Level 6 (h) One sphere perpage Figure3.7: Levels of detail forthe molecule 2btv. In the original resolution in thetop left,the molecule contains 49,061 atoms, while level7on thelowerrightcontains two data points, one perpage. into anew node, whichreplaces the twooriginal nodes. For n1 and n2,the labelsand distance are added to theoutput. In the next step, thedissimilarity(distance) from the new node to all others in the set is calculated.This is repeated untilall nodes are clustered based on the cut-off distance or desired number of clusters.The result is alist of labels for allinput points. All points thatare labeledwith the same number arepart of thesame cluster,and become asingle data pointinthe new,coarserlevel of detail. Figure 3.7shows the resulting levels of detail for the molecule 2btv. In order to create the new data points fromthe labeled clusterdata, we need to find a position, andaradius for eachnew point. Additionally,wehavetochoose one point in eachcluster that will be the "heir" to the parentonthe coarser level. The"heir" is the pointintowhichall other points in the clustertransitionwhen smoothly blending between levels. Thisinformation is necessary in order to achieveasmoothtransition between differentlevels of detail, as described in more detailinChapter 4. We choose the pointwith the shortestdistance to thecenter, i.e.,the position of the newpoint representing the cluster.Wedetermine the position of the newpoint pc by calculating n p i=1 i + the meanofall points in thecluster pc = n .Both Parulek et al.[PJR 14]and Müllner [M+13]choose aradius that covers allcontributing atoms. We found thatthis methodblows up the atom’s volumeunnecessarily.Individual data points on coarser levels of detailnolong represent anyactualatoms, but rather aclusterofseveralatoms or sub-clusters. The relevant factoristherefore howvisually similar the calculated LODs 35 3. Data Structure (a) When covering thecenters of allpointsin (b)Using the average distancebetween points the previous level, the overall volumeofthe in as abasisfor theradius of the newsphere, molecule increases with each level. thevolume remains closer to theoriginal. Figure3.8: Molecule 1sva. Comparingradius covering allpoints in the cluster vs average distance usingthe originalresolution(orange)vs. level 5(white) are to the original set of atoms. Rather than letting the radiuscover all points in the cluster,wecalculatethe new radius based on theaverage distanceusing the following formula in Equation3.2,where rc is the radiusofthe data pointonthe coarserlevel of detailthatrepresents the cluster, n is the number of points in the cluster, pi is the position of apointinthe clusterwith the radius ri,and pc is the position of thenew data point, whichisthe average of all positions within the cluster.