object oriented framework for filtering jonathan wiersma jarett hailes mitacs-pints

42
Object Oriented Framework for Filtering Jonathan Wiersma Jarett Hailes MITACS-PINTS

Post on 18-Dec-2015

223 views

Category:

Documents


2 download

TRANSCRIPT

Object Oriented Framework for Filtering

Jonathan Wiersma

Jarett Hailes

MITACS-PINTS

Presentation Overview

Overview of Programming Concepts– Procedural Programming– Object Oriented Design

Current State of PINTS Projects Proposed Improvements

– Filtering project framework– Common Interfaces– Shared set of utility classes– Refactoring

Implementation and Challenges Conclusion & Future Directions

Procedural Programming - Overview

Different than functions in math:

• May map same input to different outputs

• behavior can depend on state of global variables

• variables are mutable

• Variables

• Data Structures

• Functions

integerfloat

charpointer

combinations of previous

multiple inputs (parameters)single output (return value)

Procedural Programming – Example 1

int global_var;

void main() {int a,b,c;a = 3;b = 4;c = sum(a,b);output(c);

}

int sum(int x, int y) {return x + y;

}

Global variable (accessible to all functions)

functionvariables

Variable assignment

Function call

Object Oriented Design - Basics

Objects Classes Variables/State Methods

Object Oriented Design - Classes

Combines a data structure (set of variables) with operations related to that data structure (methods)

Describes a class of objects (like a set) An object is an instance of a class and has a

state

Object Oriented Programming:Code Structure

Data Structures

Global variables

Procedures/functions

Class 1

Data Structure

methods

Class 2

Data Structure

methods

Procedural Program: Object Oriented Program:

Object Oriented Design - Concepts

Encapsulation Inheritance Polymorphism

State of Code at PINTS

Each project is a completely separate entity Interfaces are different between projects Interfaces are not clearly defined (templates) No code reuse – improvements only effect

one project Large undertaking to create a new project Not easy to read and understand

Improvements being Developed

Create a filtering project framework Shared underlying structure Suite of useful utility classes Abstract output model (M-V-C pattern)

Framework for Filtering Projects

Create a set of generic classes and interfaces (via inheritance)

Have filters use these generic interfaces so they don’t require customized code

Design a framework to ease the development effort of applying a filter to a new application

Shared Filtering Interface

Filter

ObserverObservationDType Signal

POD Signal POD 13 Observation

POD 13 SERP Observer

SERP Filter

CVS – Concurrent Versioning System

Allows several users to work on the same files at the same time

Stores old versions and changes Also useful for text and latex documents

CVS Layout

projects

interfaces math

docs filters

graphics utilities

{projects} misc

Interfaces

Projects

Interfaces

signals observations

Filter

ObserverObservationDType Signal

POD Signal POD 13 Observation

POD 13 SERP Observer

SERP Filter

Interfaces

Projects

Interfaces

signals observations

Signal

• void evolve()

• DType position()

• DType position

BoundedSignal

• AbsDomain domain()

• AbsDomain domain

Interfaces

Projects

Interfaces

signals observations

Observation

• void observe(Signal, double dt)

• ODType position()

• ODType position

Interfaces

Projects

Interfaces

signals observations

Observer

• void observe(Observation, double dt)

• Observation

SERP Observer

• double weightedOffset(Signal, double dt)

CVS Math Package - Algebra

projects

math

algebra coordinates

domain functions

random statistics

Ideally:

Matrix

Row Matrix

Column Matrix

Row Vector

Column Vector

CVS Math Package - Algebra

projects

math

algebra coordinates

domain functions

random statistics

Row Vector

• math operators (+,-,*,+=,-=,*=,etc)

• accessors

• RowVector norm()

• void normalize()

• Scalar values[]

• int dimension

CVS Math Package - Algebra

projects

math

algebra coordinates

domain functions

random statistics

Column Vector

• math operators (+,-,*,+=,-=,*=,etc)

• accessors

• ColumnVector norm()

• void normalize()

• Scalar values[]

• int dimension

CVS Math Package - Algebra

projects

math

algebra coordinates

domain functions

random statistics

Row Matrix

• math operators (+,-,*,+=,-=,*=,etc)

• accessors

• RowMatrix inverse()

• void invert()

• RowVector values[]

• int nrows, ncols

CVS Math Package - Coordinates

projects

math

algebra coordinates

domain functions

random statistics

Coordinate

Euclidean Coordinate

Polar Coordinate

CVS Math Package - Coordinates

projects

math

algebra coordinates

domain functions

random statistics

Coordinate

• math operators (+,-,*,+=,-=,*=,etc)

• accessors

• CType value

CVS Math Package - Coordinates

projects

math

algebra coordinates

domain functions

random statistics

Polar Coordinate

• math operators (+,-,*,+=,-=,*=,etc)

• accessors

• CType max, min

CVS Math Package - Domain

projects

math

algebra coordinates

domain functions

random statistics

Abstract Domain

Abstract Bounded Domain

Vector Box Domain

CVS Math Package - Domain

projects

math

algebra coordinates

domain functions

random statistics

Abstract Domain

• bool contains(DType)

Abstract Bounded Domain

• DType min()

• DType max()

• DType min, max

CVS Math Package - Domain

projects

math

algebra coordinates

domain functions

random statistics

Abstract Function

Continuous Function

Discrete Function

Range Type

Domain Type

CVS Math Package - Domain

projects

math

algebra coordinates

domain functions

random statistics

Range Type Domain Type

• int dimension

Abstract Function

• Range operator()(Domain val)

• int dimension()

CVS Math Package - Domain

projects

math

algebra coordinates

domain functions

random statistics

Range Type

Domain Type

• int dimension

Abstract Function

• Range operator()(Domain val)

• int dimension()

Continuous Function

• Range operator()(Domain val)

• DiscreteFunction discretize()

• DiscreteFunction fft(VBoxDom<DType>, int)

CVS Math Package - Domain

projects

math

algebra coordinates

domain functions

random statistics

Discrete Function

• RType index(int idx[])

• DiscreteFunction fft(int type)

• accessors

Range Type

Domain Type

• int dimension

Abstract Function

• Range operator()(Domain val)

• int dimension()

• VectorBoxDomain<DType> domain

• MultiDArray<RType> data

• int numDivisions

• DType delta[]

Graphics - Legacy

projects

graphics

animation image

povray vtk

output util

• Packages of raster graphics procedures

• Outdated

• Custom code

• Not supported

• Very low level

Graphics - povray

projects

graphics

animation image

povray vtk

output util

• 3D Ray Tracing program

• Beautiful output

• Slow Rendering

• Separate Application

• Requires specific input format

Graphics - VTK

projects

graphics

animation image

povray vtk

output util

• Object Oriented 3D Visualization Toolkit

• Uses standard visualization network

• Fairly fast

• Easy to incorporate into real-time display

• Support for several languages

Graphics – Output Classes

projects

graphics

animation image

povray vtk

output util

Output

Text Output

PovRay Output

VTK Output

POD 13 PovRay Output

POD 13 VTK

Output

Utilities - Simulations

projects

utilities

simulations structures

parser misc

• Abstract Simulation Classes

• Rapid Simulation Development

• Code reuse

• Standard Code Layout

• Signal Simulation

• Observation Simulation

• Filter Simulation

Utilities - Simulations

Simulation

Simulation View Simulation Model

POD 13 Filter View 1

Output

Text Output

VTK Output

Filter Simulation Model

Filter

Signal ObservationSERP Filter

POD Signal

POD 13 Observation

Controller

View Model

Utilities - Structures

projects

utilities

simulations structures

parser misc

• Hash Table / Hash Bin

• List

• Multi Dimensional Array

• Dictionary

Data Structures

Refactoring

Splitting large classes into smaller ones– Better encapsulation– Fewer variables to remember– Fewer methods to remember– More abstraction

Splitting large methods into smaller ones– Less code to read through to understand method– Easier to reuse code

Moving methods (feature envy)– Easier to understand– Easier to locate

Implementation

Signal – evolve() Observation - observe(Signal) Observer – depends on filter(s) used Output – output()

Challenges

Multiple Inheritance– Observer Interfaces

Return by value– multiple copies– inheritance

Graphics MVC Model– templates

Future Directions

Single Filtering Application for all Projects Scripting Language Language Change (java?) Talk on using CVS for latex papers Suggestions