20010528j d cunha1 object-oriented visualization joão duarte cunha univ. de lisboa - faculdade de...

64
1 J D Cunha 20010528 Object-oriented Object-oriented Visualization Visualization João Duarte Cunha João Duarte Cunha Univ. de Lisboa - Faculdade Univ. de Lisboa - Faculdade de Ciências de Ciências Socrates Programme Socrates Programme Plzen, May 2001 Plzen, May 2001

Upload: willis-holmes

Post on 03-Jan-2016

222 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 20010528J D Cunha1 Object-oriented Visualization João Duarte Cunha Univ. de Lisboa - Faculdade de Ciências Socrates Programme Plzen, May 2001

1J D Cunha20010528

Object-oriented VisualizationObject-oriented Visualization

João Duarte CunhaJoão Duarte Cunha

Univ. de Lisboa - Faculdade de CiênciasUniv. de Lisboa - Faculdade de Ciências

Socrates ProgrammeSocrates Programme

Plzen, May 2001Plzen, May 2001

Page 2: 20010528J D Cunha1 Object-oriented Visualization João Duarte Cunha Univ. de Lisboa - Faculdade de Ciências Socrates Programme Plzen, May 2001

20010528 J D Cunha 2

VisualizationVisualization

Overcoming spatial, temporal and Overcoming spatial, temporal and physical barriersphysical barriers

Page 3: 20010528J D Cunha1 Object-oriented Visualization João Duarte Cunha Univ. de Lisboa - Faculdade de Ciências Socrates Programme Plzen, May 2001

20010528 J D Cunha 3

Sensorial limitationsSensorial limitations

• Our senses are our “interface”: everything Our senses are our “interface”: everything we got from the outside world comes we got from the outside world comes through themthrough them

• Our senses are quite limitedOur senses are quite limited– in the type of stimuli they can perceivein the type of stimuli they can perceive– in their sensitivityin their sensitivity

Page 4: 20010528J D Cunha1 Object-oriented Visualization João Duarte Cunha Univ. de Lisboa - Faculdade de Ciências Socrates Programme Plzen, May 2001

20010528 J D Cunha 4

Sensorial limitationsSensorial limitations

• Because of those limitations, the world Because of those limitations, the world within our reach is:within our reach is:– limited in spacelimited in space– limited in timelimited in time– limited in the type of objects and phenomena limited in the type of objects and phenomena

that we can perceive!that we can perceive!

Page 5: 20010528J D Cunha1 Object-oriented Visualization João Duarte Cunha Univ. de Lisboa - Faculdade de Ciências Socrates Programme Plzen, May 2001

20010528 J D Cunha 5

Man’s inconformismMan’s inconformism

• Man always struggled against his sensorial Man always struggled against his sensorial limitations!limitations!

• Oral tradition in primitive societies was a Oral tradition in primitive societies was a away of overcoming the time barrier (and, away of overcoming the time barrier (and, combined with travelling, also the space combined with travelling, also the space barrier)barrier)

• Painting and other art forms have a similar Painting and other art forms have a similar role!role!

Page 6: 20010528J D Cunha1 Object-oriented Visualization João Duarte Cunha Univ. de Lisboa - Faculdade de Ciências Socrates Programme Plzen, May 2001

20010528 J D Cunha 6

Man’s inconformismMan’s inconformism

• The introduction of writing was an The introduction of writing was an enormous step forward.enormous step forward.

• And the discovery of the press by And the discovery of the press by Gutemberg in the 15th century amplified its Gutemberg in the 15th century amplified its impact by orders of magnitude.impact by orders of magnitude.

Page 7: 20010528J D Cunha1 Object-oriented Visualization João Duarte Cunha Univ. de Lisboa - Faculdade de Ciências Socrates Programme Plzen, May 2001

20010528 J D Cunha 7

Man’s inconformismMan’s inconformism

• And so we got the 19th century!And so we got the 19th century!

Page 8: 20010528J D Cunha1 Object-oriented Visualization João Duarte Cunha Univ. de Lisboa - Faculdade de Ciências Socrates Programme Plzen, May 2001

20010528 J D Cunha 8

Man’s inconformismMan’s inconformism

• All these ways of overcoming the space and All these ways of overcoming the space and time barriers are human mediatedtime barriers are human mediated– by ONE man in the case of writing and the by ONE man in the case of writing and the

plastic artsplastic arts– by MANY men in the case of oral tradition, by MANY men in the case of oral tradition,

music, dance.music, dance.

Page 9: 20010528J D Cunha1 Object-oriented Visualization João Duarte Cunha Univ. de Lisboa - Faculdade de Ciências Socrates Programme Plzen, May 2001

20010528 J D Cunha 9

Man’s inconformismMan’s inconformism

• The senses involved are always vision and The senses involved are always vision and hearing!hearing!

Page 10: 20010528J D Cunha1 Object-oriented Visualization João Duarte Cunha Univ. de Lisboa - Faculdade de Ciências Socrates Programme Plzen, May 2001

20010528 J D Cunha 10

Man’s inconformismMan’s inconformism

• Galileo’s telescope and other optical Galileo’s telescope and other optical instruments pushed away the space barrier.instruments pushed away the space barrier.

And we know well howAnd we know well how

important this was forimportant this was for

our understanding of our understanding of

the universe!the universe!

Page 11: 20010528J D Cunha1 Object-oriented Visualization João Duarte Cunha Univ. de Lisboa - Faculdade de Ciências Socrates Programme Plzen, May 2001

20010528 J D Cunha 11

Man’s inconformismMan’s inconformism

• With the development of measuring With the development of measuring instruments the struggle against the physical instruments the struggle against the physical barrier proceeded step by step.barrier proceeded step by step.

• But slowly!But slowly!

Page 12: 20010528J D Cunha1 Object-oriented Visualization João Duarte Cunha Univ. de Lisboa - Faculdade de Ciências Socrates Programme Plzen, May 2001

20010528 J D Cunha 12

Man’s inconformismMan’s inconformism

• In the 19th century a new era begun!In the 19th century a new era begun!– Telegraphy (1856) introduced the “instanta-Telegraphy (1856) introduced the “instanta-

neous” transmission of the written word.neous” transmission of the written word.

We can say, at Earth scale at least,We can say, at Earth scale at least,

that with telegraphythat with telegraphy

space became independent of time!space became independent of time!

Page 13: 20010528J D Cunha1 Object-oriented Visualization João Duarte Cunha Univ. de Lisboa - Faculdade de Ciências Socrates Programme Plzen, May 2001

20010528 J D Cunha 13

Man’s inconformismMan’s inconformism

• The telephone (1876) and radio or wireless The telephone (1876) and radio or wireless telephony (already in the 20th century) are telephony (already in the 20th century) are new advances allowing for a limited form new advances allowing for a limited form of direct (not human mediated) perception.of direct (not human mediated) perception.

• Photography (1839), sound recording Photography (1839), sound recording (1877) and the cinema (1895) are other (1877) and the cinema (1895) are other important landmarks.important landmarks.

Page 14: 20010528J D Cunha1 Object-oriented Visualization João Duarte Cunha Univ. de Lisboa - Faculdade de Ciências Socrates Programme Plzen, May 2001

20010528 J D Cunha 14

Man’s inconformismMan’s inconformism

• But it was undoubtedly the television But it was undoubtedly the television (1926) the most significant step in man’s (1926) the most significant step in man’s struggle against the space barrier!struggle against the space barrier!

Page 15: 20010528J D Cunha1 Object-oriented Visualization João Duarte Cunha Univ. de Lisboa - Faculdade de Ciências Socrates Programme Plzen, May 2001

20010528 J D Cunha 15

"Sensing" information "Sensing" information

• From Visualization to "Perception" !From Visualization to "Perception" !

Page 16: 20010528J D Cunha1 Object-oriented Visualization João Duarte Cunha Univ. de Lisboa - Faculdade de Ciências Socrates Programme Plzen, May 2001

20010528 J D Cunha 16

SEEING informationSEEING information• Knowledge is based on information and action Knowledge is based on information and action

is determined by knowledge.is determined by knowledge.

• Computers are essential to generate new Computers are essential to generate new information (simulation and data acquisition).information (simulation and data acquisition).

• But they are, more than anything else, the But they are, more than anything else, the ideal instrument to store, search, retrieve and ideal instrument to store, search, retrieve and process information.process information.

Page 17: 20010528J D Cunha1 Object-oriented Visualization João Duarte Cunha Univ. de Lisboa - Faculdade de Ciências Socrates Programme Plzen, May 2001

20010528 J D Cunha 17

SEEING informationSEEING information

• In their book "Readings in Information In their book "Readings in Information Visualization - Using vision to think", Visualization - Using vision to think", Card, Mackinlay e Shneiderman define Card, Mackinlay e Shneiderman define visualization asvisualization as

The use of computer-supported,The use of computer-supported,

interactive, visual representationsinteractive, visual representations

of data to amplify cognitionof data to amplify cognition

Page 18: 20010528J D Cunha1 Object-oriented Visualization João Duarte Cunha Univ. de Lisboa - Faculdade de Ciências Socrates Programme Plzen, May 2001

20010528 J D Cunha 18

SEEING informationSEEING information

Look at the following table:

0,000 0,087 0,174 0,259 0,342 0,423 0,500 0,574

0,643 0,707 0,766 0,819 0,866 0,906 0,940 0,966

0,985 0,996 1,000 0,996 0,985 0,966 0,940 0,906

0,866 0,819 0,766 0,707 0,643 0,574 0,500 0,4230,342 0,259 0,174 0,087 0,000

and at the graph in the following slide:and at the graph in the following slide:

Page 19: 20010528J D Cunha1 Object-oriented Visualization João Duarte Cunha Univ. de Lisboa - Faculdade de Ciências Socrates Programme Plzen, May 2001

20010528 J D Cunha 19

SEEING informationSEEING information

0,000

0,200

0,400

0,600

0,800

1,000

1,200

0 50 100 150 200

Series1

Page 20: 20010528J D Cunha1 Object-oriented Visualization João Duarte Cunha Univ. de Lisboa - Faculdade de Ciências Socrates Programme Plzen, May 2001

20010528 J D Cunha 20

SEEING informationSEEING information

• These two slides just point out what we These two slides just point out what we already knew very well: our ability to get already knew very well: our ability to get information is highly dependent on its form.information is highly dependent on its form.– In general, a graph or image allow a much In general, a graph or image allow a much

faster understanding than a list of numbers or a faster understanding than a list of numbers or a textual description.textual description.

Page 21: 20010528J D Cunha1 Object-oriented Visualization João Duarte Cunha Univ. de Lisboa - Faculdade de Ciências Socrates Programme Plzen, May 2001

20010528 J D Cunha 21

SEEING informationSEEING information

• Visualization was used long before, but the Visualization was used long before, but the Scientific Visualization and Information Scientific Visualization and Information Visualization areas were born in the late Visualization areas were born in the late 80’s.80’s.

• The confluence of “push” and “pull” factors The confluence of “push” and “pull” factors was determinant for that.was determinant for that.

Page 22: 20010528J D Cunha1 Object-oriented Visualization João Duarte Cunha Univ. de Lisboa - Faculdade de Ciências Socrates Programme Plzen, May 2001

20010528 J D Cunha 22

SEEING informationSEEING information

• ““Push” factorsPush” factors– 30 years of experience in Computer Graphics30 years of experience in Computer Graphics

– Availability of powerful graphical hardwareAvailability of powerful graphical hardware

– Developments in human-machine interfacesDevelopments in human-machine interfaces

Page 23: 20010528J D Cunha1 Object-oriented Visualization João Duarte Cunha Univ. de Lisboa - Faculdade de Ciências Socrates Programme Plzen, May 2001

20010528 J D Cunha 23

SEEING informationSEEING information

• ““Pull” factorsPull” factors– Ever greater amounts of data to store and Ever greater amounts of data to store and

analyze coming from:analyze coming from:

• Sophisticated simulations made possible by the Sophisticated simulations made possible by the available computing poweravailable computing power

• Very large and complex data basesVery large and complex data bases

Page 24: 20010528J D Cunha1 Object-oriented Visualization João Duarte Cunha Univ. de Lisboa - Faculdade de Ciências Socrates Programme Plzen, May 2001

20010528 J D Cunha 24

SEEING informationSEEING information

• Simplified reference model for visualizationSimplified reference model for visualization

DataData MappingMapping RenderingRendering

Page 25: 20010528J D Cunha1 Object-oriented Visualization João Duarte Cunha Univ. de Lisboa - Faculdade de Ciências Socrates Programme Plzen, May 2001

20010528 J D Cunha 25

SEEING informationSEEING information

Mapping

Information is converted into Information is converted into geometry and/or graphical attributes.geometry and/or graphical attributes.

Page 26: 20010528J D Cunha1 Object-oriented Visualization João Duarte Cunha Univ. de Lisboa - Faculdade de Ciências Socrates Programme Plzen, May 2001

20010528 J D Cunha 26

Scientific VisualizationScientific Visualization

• Scientific Visualization or Visualization of Scientific Visualization or Visualization of Scientific Data is usually defined as concer-Scientific Data is usually defined as concer-ned with visualization of data associated ned with visualization of data associated with a spatial grid, as opposed to Informa-with a spatial grid, as opposed to Informa-tion Visualization which concentrates on tion Visualization which concentrates on more abstract kinds of data.more abstract kinds of data.

Page 27: 20010528J D Cunha1 Object-oriented Visualization João Duarte Cunha Univ. de Lisboa - Faculdade de Ciências Socrates Programme Plzen, May 2001

20010528 J D Cunha 27

The Visualization Toolkit - vtkThe Visualization Toolkit - vtk

• VTKVTK is an object-oriented toolkit for 3D is an object-oriented toolkit for 3D graphics(http://www.kitware.com/vtk.html)graphics(http://www.kitware.com/vtk.html)

• Although tailored for the scientific visuali-Although tailored for the scientific visuali-zation field it can also be sucessfully used zation field it can also be sucessfully used to illustrate the basics of 3D graphics and to illustrate the basics of 3D graphics and rendering.rendering.

Page 28: 20010528J D Cunha1 Object-oriented Visualization João Duarte Cunha Univ. de Lisboa - Faculdade de Ciências Socrates Programme Plzen, May 2001

20010528 J D Cunha 28

The Visualization Toolkit - vtkThe Visualization Toolkit - vtk

• The toolkit consists of a set of C++ classes The toolkit consists of a set of C++ classes providing the functionality to build 3D providing the functionality to build 3D graphics applications, namely visualization graphics applications, namely visualization applications, without the need for any low applications, without the need for any low level programming.level programming.

• Vtk is compatible with several graphical Vtk is compatible with several graphical systems, namely OpenGL and X-Windows.systems, namely OpenGL and X-Windows.

Page 29: 20010528J D Cunha1 Object-oriented Visualization João Duarte Cunha Univ. de Lisboa - Faculdade de Ciências Socrates Programme Plzen, May 2001

20010528 J D Cunha 29

The Visualization Toolkit - vtkThe Visualization Toolkit - vtk

• Vtk may be used from C++, Java or Tcl/Tk Vtk may be used from C++, Java or Tcl/Tk programmes.programmes.

• In this talk Tcl/Tk will be used.In this talk Tcl/Tk will be used.

Page 30: 20010528J D Cunha1 Object-oriented Visualization João Duarte Cunha Univ. de Lisboa - Faculdade de Ciências Socrates Programme Plzen, May 2001

20010528 J D Cunha 30

The Visualization Toolkit - vtkThe Visualization Toolkit - vtk

• Vtk being object-oriented, we need only to Vtk being object-oriented, we need only to create objects of the appropriate types and create objects of the appropriate types and call the available methods.call the available methods.

Page 31: 20010528J D Cunha1 Object-oriented Visualization João Duarte Cunha Univ. de Lisboa - Faculdade de Ciências Socrates Programme Plzen, May 2001

20010528 J D Cunha 31

The Visualization Toolkit - vtkThe Visualization Toolkit - vtk

• Vtk object types can be grouped according Vtk object types can be grouped according to their functionality.to their functionality.

• The most important object groups are: The most important object groups are: Sources, Mappers, Graphics and Filters.Sources, Mappers, Graphics and Filters.

• We will now look in some detail at each We will now look in some detail at each group.group.

Page 32: 20010528J D Cunha1 Object-oriented Visualization João Duarte Cunha Univ. de Lisboa - Faculdade de Ciências Socrates Programme Plzen, May 2001

20010528 J D Cunha 32

The Visualization Toolkit - vtkThe Visualization Toolkit - vtk

• SourcesSources are information provider objects.are information provider objects.

• Some sources are readers, that is, they get Some sources are readers, that is, they get the information from files in appropriate the information from files in appropriate formats. Examples:formats. Examples:– vtkPLOT3DReadervtkPLOT3DReader– vtkBYUReadervtkBYUReader– vtkPolyDataReader (one of vtk own formats)vtkPolyDataReader (one of vtk own formats)

Page 33: 20010528J D Cunha1 Object-oriented Visualization João Duarte Cunha Univ. de Lisboa - Faculdade de Ciências Socrates Programme Plzen, May 2001

20010528 J D Cunha 33

The Visualization Toolkit - vtkThe Visualization Toolkit - vtk

• Others generate data algorithmically. The Others generate data algorithmically. The typical example are the sources that create typical example are the sources that create basic geometric shapes likebasic geometric shapes like– vtkSphereSourcevtkSphereSource– vtkCylinderSourcevtkCylinderSource– vtkConeSourcevtkConeSource

Page 34: 20010528J D Cunha1 Object-oriented Visualization João Duarte Cunha Univ. de Lisboa - Faculdade de Ciências Socrates Programme Plzen, May 2001

20010528 J D Cunha 34

The Visualization Toolkit - vtkThe Visualization Toolkit - vtk

• MappersMappers, as suggested by the name itself, , as suggested by the name itself, get the information provided by source get the information provided by source objects, directly or through appropriate objects, directly or through appropriate filters, and generate graphic primitives.filters, and generate graphic primitives.

• There are two types of mappers:There are two types of mappers:– vtkDataSetMappervtkDataSetMapper– vtkPolyDataMappervtkPolyDataMapper

Page 35: 20010528J D Cunha1 Object-oriented Visualization João Duarte Cunha Univ. de Lisboa - Faculdade de Ciências Socrates Programme Plzen, May 2001

20010528 J D Cunha 35

The Visualization Toolkit - vtkThe Visualization Toolkit - vtk

• A special type of mappers are the writers, A special type of mappers are the writers, which write out information in files with which write out information in files with differente formats. Examples:differente formats. Examples:– vtkBYUWritervtkBYUWriter– vtkTIFFWritervtkTIFFWriter– vtkPolyDataWritervtkPolyDataWriter

Page 36: 20010528J D Cunha1 Object-oriented Visualization João Duarte Cunha Univ. de Lisboa - Faculdade de Ciências Socrates Programme Plzen, May 2001

20010528 J D Cunha 36

The Visualization Toolkit - vtkThe Visualization Toolkit - vtk

• Objects in the Objects in the graphicsgraphics group are respon- group are respon-sible for the rendering portion of the visua-sible for the rendering portion of the visua-lization pipeline.lization pipeline.

Page 37: 20010528J D Cunha1 Object-oriented Visualization João Duarte Cunha Univ. de Lisboa - Faculdade de Ciências Socrates Programme Plzen, May 2001

20010528 J D Cunha 37

The Visualization Toolkit - vtkThe Visualization Toolkit - vtk

• Objects in this group include:Objects in this group include:– vtkRenderervtkRenderer– vtkRenderWindowvtkRenderWindow– vtkActorvtkActor– vtkPropertyvtkProperty– vtkTransformvtkTransform– vtkCameravtkCamera– vtkLightvtkLight

Page 38: 20010528J D Cunha1 Object-oriented Visualization João Duarte Cunha Univ. de Lisboa - Faculdade de Ciências Socrates Programme Plzen, May 2001

20010528 J D Cunha 38

The Visualization Toolkit - vtkThe Visualization Toolkit - vtk

• vtkRenderer is a virtual class.vtkRenderer is a virtual class.

• But vtkOpenGLRenderer, which inherits But vtkOpenGLRenderer, which inherits from vtkRenderer, is a concrete class from vtkRenderer, is a concrete class instan-tiated when the graphics systems is instan-tiated when the graphics systems is OpenGL.OpenGL.

Page 39: 20010528J D Cunha1 Object-oriented Visualization João Duarte Cunha Univ. de Lisboa - Faculdade de Ciências Socrates Programme Plzen, May 2001

20010528 J D Cunha 39

The Visualization Toolkit - vtkThe Visualization Toolkit - vtk

• Objects of type vtkRenderWindow repre-Objects of type vtkRenderWindow repre-sent the application window.sent the application window.

• The window will be a Windows window or The window will be a Windows window or an X window, according to the graphics an X window, according to the graphics system being used.system being used.

Page 40: 20010528J D Cunha1 Object-oriented Visualization João Duarte Cunha Univ. de Lisboa - Faculdade de Ciências Socrates Programme Plzen, May 2001

20010528 J D Cunha 40

The Visualization Toolkit - vtkThe Visualization Toolkit - vtk

• Each instance of vtkActor represents a Each instance of vtkActor represents a scene “object”, combining the geometry scene “object”, combining the geometry (provided by the mapper) with the optical (provided by the mapper) with the optical properties (colour, texture, etc) and con-properties (colour, texture, etc) and con-crete values for the location, orientation and crete values for the location, orientation and size.size.

Page 41: 20010528J D Cunha1 Object-oriented Visualization João Duarte Cunha Univ. de Lisboa - Faculdade de Ciências Socrates Programme Plzen, May 2001

20010528 J D Cunha 41

The Visualization Toolkit - vtkThe Visualization Toolkit - vtk

• Instances of vtkProperty are associated with Instances of vtkProperty are associated with actors to control its appearance.actors to control its appearance.

• Similarly, instances of vtkTransform are Similarly, instances of vtkTransform are associated with actors to determine their associated with actors to determine their location, orientation and size.location, orientation and size.

Page 42: 20010528J D Cunha1 Object-oriented Visualization João Duarte Cunha Univ. de Lisboa - Faculdade de Ciências Socrates Programme Plzen, May 2001

20010528 J D Cunha 42

The Visualization Toolkit - vtkThe Visualization Toolkit - vtk

• Instances of vtkCamera and vtkLight are Instances of vtkCamera and vtkLight are associated with Renderer objects to specify associated with Renderer objects to specify how the scene is seen and illuminated.how the scene is seen and illuminated.

• If the user does not explicitely create If the user does not explicitely create objects of these two types, default ones are objects of these two types, default ones are provided.provided.

Page 43: 20010528J D Cunha1 Object-oriented Visualization João Duarte Cunha Univ. de Lisboa - Faculdade de Ciências Socrates Programme Plzen, May 2001

20010528 J D Cunha 43

The Visualization Toolkit - vtkThe Visualization Toolkit - vtk

• FiltersFilters are “transformation” objects and are “transformation” objects and there are many types of filters available.there are many types of filters available.

• For example, the marching cubes and mar-For example, the marching cubes and mar-ching squares algorithms are implemented ching squares algorithms are implemented as filters. The same is true for decimation, as filters. The same is true for decimation, sampling, geometry extraction, threshol-sampling, geometry extraction, threshol-ding, particle and many other algorithms.ding, particle and many other algorithms.

Page 44: 20010528J D Cunha1 Object-oriented Visualization João Duarte Cunha Univ. de Lisboa - Faculdade de Ciências Socrates Programme Plzen, May 2001

20010528 J D Cunha 44

The visualization pipeline in vtkThe visualization pipeline in vtk

• The simplest pipeline includes a source, a The simplest pipeline includes a source, a mapper and an actor.mapper and an actor.

• To be seen, actors must be associated with a To be seen, actors must be associated with a renderer and the renderer associated to a renderer and the renderer associated to a window.window.

Page 45: 20010528J D Cunha1 Object-oriented Visualization João Duarte Cunha Univ. de Lisboa - Faculdade de Ciências Socrates Programme Plzen, May 2001

20010528 J D Cunha 45

The visualization pipeline in vtkThe visualization pipeline in vtk

Cubo_S Cubo_M Cubo_A

rw r

vtkProperty

vtkTransform

vtkCamera

vtkLight

Page 46: 20010528J D Cunha1 Object-oriented Visualization João Duarte Cunha Univ. de Lisboa - Faculdade de Ciências Socrates Programme Plzen, May 2001

20010528 J D Cunha 46

Case studyCase study

• We will now see and briefly discuss the We will now see and briefly discuss the application of vtk to meteorological data.application of vtk to meteorological data.

• The data was provided by the Lisbon The data was provided by the Lisbon Meteorological Institute (IM) for use in a Meteorological Institute (IM) for use in a course of Computer Graphics for physics course of Computer Graphics for physics students.students.

Page 47: 20010528J D Cunha1 Object-oriented Visualization João Duarte Cunha Univ. de Lisboa - Faculdade de Ciências Socrates Programme Plzen, May 2001

20010528 J D Cunha 47

Case studyCase study

• The data were collected with intervals of six The data were collected with intervals of six hours between April 5 at 12h and April 6 at hours between April 5 at 12h and April 6 at 12h.12h.

• Physical quantities measured are Tempera-Physical quantities measured are Tempera-ture, Humidity, Altitude and Wind velocity ture, Humidity, Altitude and Wind velocity along the parallel and along the meridian. along the parallel and along the meridian.

Page 48: 20010528J D Cunha1 Object-oriented Visualization João Duarte Cunha Univ. de Lisboa - Faculdade de Ciências Socrates Programme Plzen, May 2001

20010528 J D Cunha 48

Case studyCase study

• The grid is topologically and geometrically The grid is topologically and geometrically regular (cartesian grid), covering a region regular (cartesian grid), covering a region from -45º W to 45º E and from 80º N to 20º from -45º W to 45º E and from 80º N to 20º N, at 0.5º intervals.N, at 0.5º intervals.

• This means a total of 108000 data points for This means a total of 108000 data points for each physical quantity.each physical quantity.

Page 49: 20010528J D Cunha1 Object-oriented Visualization João Duarte Cunha Univ. de Lisboa - Faculdade de Ciências Socrates Programme Plzen, May 2001

20010528 J D Cunha 49

Case studyCase study

• The data were measured at the so called The data were measured at the so called “mid-atmosphere”, defined as the 500 hPa “mid-atmosphere”, defined as the 500 hPa isobaric.isobaric.

• We will start by having a look at the data We will start by having a look at the data using WebWinds, a visualization program using WebWinds, a visualization program developped by the Jet Propulsion Lab developped by the Jet Propulsion Lab (http://www.jpl.nasa.gov/directory)(http://www.jpl.nasa.gov/directory)

Page 50: 20010528J D Cunha1 Object-oriented Visualization João Duarte Cunha Univ. de Lisboa - Faculdade de Ciências Socrates Programme Plzen, May 2001

20010528 J D Cunha 50

Case studyCase study

• WebWinds is also object-oriented, but the WebWinds is also object-oriented, but the objects are provided with a complete inter-objects are provided with a complete inter-face and a visual programming approach face and a visual programming approach was adopted.was adopted.

Page 51: 20010528J D Cunha1 Object-oriented Visualization João Duarte Cunha Univ. de Lisboa - Faculdade de Ciências Socrates Programme Plzen, May 2001

20010528 J D Cunha 51

Case studyCase study

• Now the vtk application.Now the vtk application.

• First the essential parts of the Tcl code.First the essential parts of the Tcl code.

Page 52: 20010528J D Cunha1 Object-oriented Visualization João Duarte Cunha Univ. de Lisboa - Faculdade de Ciências Socrates Programme Plzen, May 2001

20010528 J D Cunha 52

Case studyCase study

• # Create RenderWindow and Renderer# Create RenderWindow and Renderer• vtkRenderer ren1vtkRenderer ren1• vtkRenderWindow renWinvtkRenderWindow renWin• renWin AddRenderer ren1renWin AddRenderer ren1

Page 53: 20010528J D Cunha1 Object-oriented Visualization João Duarte Cunha Univ. de Lisboa - Faculdade de Ciências Socrates Programme Plzen, May 2001

20010528 J D Cunha 53

Case studyCase study

• # Get the Temperature data# Get the Temperature data• vtkStructuredPointsReader readervtkStructuredPointsReader reader• reader SetFileName reader SetFileName "dados_meteo_T_vtk.vtk""dados_meteo_T_vtk.vtk"

• reader Updatereader Update

Page 54: 20010528J D Cunha1 Object-oriented Visualization João Duarte Cunha Univ. de Lisboa - Faculdade de Ciências Socrates Programme Plzen, May 2001

20010528 J D Cunha 54

Case studyCase study

• # Extract planes for each time slice# Extract planes for each time slice• # Plane 0# Plane 0• vtkStructuredPointsGeometryFilter vtkStructuredPointsGeometryFilter compPlanecompPlane

• compPlane SetInput [reader GetOutput]compPlane SetInput [reader GetOutput]• compPlane SetExtent 0 200 0 200 0 0compPlane SetExtent 0 200 0 200 0 0• vtkPolyDataMapper planeMappervtkPolyDataMapper planeMapper• planeMapper SetInput [compPlane planeMapper SetInput [compPlane GetOutput]GetOutput]

Page 55: 20010528J D Cunha1 Object-oriented Visualization João Duarte Cunha Univ. de Lisboa - Faculdade de Ciências Socrates Programme Plzen, May 2001

20010528 J D Cunha 55

Case studyCase study

• planeMapper ScalarVisibilityOnplaneMapper ScalarVisibilityOn• eval planeMapper SetScalarRange eval planeMapper SetScalarRange [[[[reader GetOutput] GetPointData] [[[[reader GetOutput] GetPointData] GetScalars] GetRange]GetScalars] GetRange]

• vtkActor planeActorvtkActor planeActor• planeActor SetMapper planeMapperplaneActor SetMapper planeMapper• planeMapper SetColorModeToLuminanceplaneMapper SetColorModeToLuminance• [planeActor GetProperty] [planeActor GetProperty] SetRepresentationToSurfaceSetRepresentationToSurface

Page 56: 20010528J D Cunha1 Object-oriented Visualization João Duarte Cunha Univ. de Lisboa - Faculdade de Ciências Socrates Programme Plzen, May 2001

20010528 J D Cunha 56

Case studyCase study

• # Plane 1# Plane 1• ..........• # Plane 2# Plane 2• ..........• # Plane 3# Plane 3• ..........• # Plane 4# Plane 4• ..........

Page 57: 20010528J D Cunha1 Object-oriented Visualization João Duarte Cunha Univ. de Lisboa - Faculdade de Ciências Socrates Programme Plzen, May 2001

20010528 J D Cunha 57

Case studyCase study

• # Cut data using a plane# Cut data using a plane• vtkPlane planevtkPlane plane• # Plane contains the volume center# Plane contains the volume center• eval plane SetOrigin [[reader eval plane SetOrigin [[reader GetOutput] GetCenter]GetOutput] GetCenter]

• # and is parallel to the latitude and # and is parallel to the latitude and time axistime axis

• plane SetNormal 1 0 0plane SetNormal 1 0 0• vtkCutter planeCutvtkCutter planeCut

Page 58: 20010528J D Cunha1 Object-oriented Visualization João Duarte Cunha Univ. de Lisboa - Faculdade de Ciências Socrates Programme Plzen, May 2001

20010528 J D Cunha 58

Case studyCase study

• planeCut SetInput [reader GetOutput]planeCut SetInput [reader GetOutput]• planeCut SetCutFunction planeplaneCut SetCutFunction plane• vtkDataSetMapper cutMappervtkDataSetMapper cutMapper• cutMapper SetInput [planeCut GetOutput]cutMapper SetInput [planeCut GetOutput]• cutMapper SetColorModeToLuminancecutMapper SetColorModeToLuminance• eval cutMapper SetScalarRange [[[[reader eval cutMapper SetScalarRange [[[[reader GetOutput] GetPointData] GetScalars] GetOutput] GetPointData] GetScalars] GetRange]GetRange]

• vtkActor cutActorvtkActor cutActor• cutActor SetMapper cutMappercutActor SetMapper cutMapper

Page 59: 20010528J D Cunha1 Object-oriented Visualization João Duarte Cunha Univ. de Lisboa - Faculdade de Ciências Socrates Programme Plzen, May 2001

20010528 J D Cunha 59

Case studyCase study

• # Draw the outline# Draw the outline• vtkOutlineFilter outlinevtkOutlineFilter outline• outline SetInput [reader GetOutput]outline SetInput [reader GetOutput]• vtkPolyDataMapper outlineMappervtkPolyDataMapper outlineMapper• outlineMapper SetInput [outline outlineMapper SetInput [outline GetOutput]GetOutput]

• vtkActor outlineActorvtkActor outlineActor• outlineActor SetMapper outlineMapperoutlineActor SetMapper outlineMapper• eval [outlineActor GetProperty] SetColor eval [outlineActor GetProperty] SetColor 0 0 00 0 0

Page 60: 20010528J D Cunha1 Object-oriented Visualization João Duarte Cunha Univ. de Lisboa - Faculdade de Ciências Socrates Programme Plzen, May 2001

20010528 J D Cunha 60

Case studyCase study

• # Add actors to the renderer# Add actors to the renderer• ren1 AddActor outlineActorren1 AddActor outlineActor• ren1 AddActor planeActorren1 AddActor planeActor• ren1 AddActor planeActor1ren1 AddActor planeActor1• ren1 AddActor planeActor2ren1 AddActor planeActor2• ren1 AddActor planeActor3ren1 AddActor planeActor3• ren1 AddActor planeActor4ren1 AddActor planeActor4• ren1 AddActor cutActorren1 AddActor cutActor

Page 61: 20010528J D Cunha1 Object-oriented Visualization João Duarte Cunha Univ. de Lisboa - Faculdade de Ciências Socrates Programme Plzen, May 2001

20010528 J D Cunha 61

Case studyCase study

• # Adjust camera# Adjust camera• set cam1 [ren1 GetActiveCamera]set cam1 [ren1 GetActiveCamera]• $cam1 SetClippingRange 3.95297 50$cam1 SetClippingRange 3.95297 50• $cam1 SetFocalPoint 0 50 3$cam1 SetFocalPoint 0 50 3• $cam1 SetPosition 0 28 -200$cam1 SetPosition 0 28 -200• $cam1 ComputeViewPlaneNormal$cam1 ComputeViewPlaneNormal• $cam1 SetViewUp 0 -0.99 0.06$cam1 SetViewUp 0 -0.99 0.06

Page 62: 20010528J D Cunha1 Object-oriented Visualization João Duarte Cunha Univ. de Lisboa - Faculdade de Ciências Socrates Programme Plzen, May 2001

20010528 J D Cunha 62

Case studyCase study

• #Get the rendering done!#Get the rendering done!

• renWin RenderrenWin Render

Page 63: 20010528J D Cunha1 Object-oriented Visualization João Duarte Cunha Univ. de Lisboa - Faculdade de Ciências Socrates Programme Plzen, May 2001

20010528 J D Cunha 63

Case studyCase study

• Now we are ready to play with the Now we are ready to play with the application itselfapplication itself

Page 64: 20010528J D Cunha1 Object-oriented Visualization João Duarte Cunha Univ. de Lisboa - Faculdade de Ciências Socrates Programme Plzen, May 2001

20010528 J D Cunha 64

Case StudyCase Study

Thank you for your attention!Thank you for your attention!