In file contour/Contour2D.h:

class Contour2D : public Contour, public Data2D, public GeneralFormat

a two-dimensional contour that only includes geometric information

Inheritance:


Public Classes

class EdgeGridIntersection
Class defining the intersection of an edge with a grid
enum IntersectionType
does the intersection corresponds to the intersection between a contour edge with a row or column ?
Vec2 position
the intersection position
IntersectionType type
the type of intersection
VertexContour2D* previousVertex
the previous vertex defining the edge
Vec2 getPosition () const
returns the intersection position
VertexContour2D* getPreviousVertex () const
returns the previous vertex defining the edge
Constructors
EdgeGridIntersection (IntersectionType t, Vec2 &pos, VertexContour2D *v)
Build an edge intersection knowing if it is occurs along a row or column edge, it position along the edge and the corresponding edge of the contour (through v->edge)
Destructor
virtual ~EdgeGridIntersection ()
empty destructor
class EdgeGridPixel : public ListElement<EdgeGridPixel>
Class defining an edge in a grid pixel : the edge corresponds to the intersection of the contour with the rows and columns of a grid
VertexContour2D* vertex
the vertex may be a VertexContour2D when it corresponds to the end of the contour
EdgeGridIntersection* edgeIntersection
the vertex may also be a EdgeGridIntersection
Constructors
GridPixelVertex (VertexContour2D *v)
Build a GridPixelVertex consisting of a single vertex
GridPixelVertex (EdgeGridIntersection *e)
Build a GridPixelVertex consisting of a grid intersection
GridPixelVertex ()
Build a GridPixelVertex without any vertex
GridPixelVertex (GridPixelVertex &iv)
Build a GridPixelVertex given another GridPixelVertex
Destructor
virtual ~GridPixelVertex ()
empty destructor
void setVertex (VertexContour2D *v)
set the vertex as a VertexContour2D
void setEdgeIntersection (EdgeGridIntersection *e)
set the vertex as a EdgeGridIntersection
VertexContour2D* getVertex () const
returns the vertex as a VertexContour2D (may be 0)
EdgeGridIntersection* getEdgeIntersection () const
returns the vertex as a EdgeGridIntersection (may be 0)
Vec2 getPosition () const
returns the position of the vertex
ContourLine* getLine () const
return the line where the pixel vertex belongs
GridPixelVertex vertex [2]
the 2 extremities of the edge
Constructors
EdgeGridPixel (GridPixelVertex &iv1, GridPixelVertex &iv2 )
Create a EdgeGridPixel given its 2 extremities
Destructor
virtual ~EdgeGridPixel ()
empty destructor
bool isValid () const
test if the edge is valid i
Vec2 getPosition (unsigned int i) const
returns the position of the vertex
VertexContour2D* getVertex (unsigned int i) const
returns the VertexContour2D associated with one its extremity (may be 0)
EdgeGridIntersection* getEdgeIntersection (unsigned int i) const
returns the EdgeGridIntersection associated with one its extremity (may be 0)
class GridPixel
Class defining a grid Pixel that encloses a list of edges
ObjectsList <EdgeGridPixel> edgeList
the list of grid edges
const int row
the row index of the pixel
const int col
the column index of the pixel
Constructors
GridPixel (const int r, const int c)
constructor based on the pixel row and column index
Destructor
virtual ~GridPixel ()
empty destructor
int getRowIndex () const
returns the row index of the grid pixel
int getColumnIndex () const
returns the column index of the grid pixel
unsigned int getNbEdges () const
returns the number of edges in the pixel grid
ObjectsList <EdgeGridPixel> ::iterator firstEdge ()
returns an iterator on the first edge
ObjectsList <EdgeGridPixel> ::iterator lastEdge ()
returns an iterator on the last edge

Public Methods

void read (TclString filename)
call the read function associated with the General Format Library
void write (TclString filename)
call the write function associated with the General Format Library
VertexContour2DIterator firstVertex () const
returns a VertexIterator of type VertexContour2D pointing on the contour
Line2DIterator firstLine (void) const
returns a line Iterator of type ContourLine2D on first line
Line2DIterator lastLine (void) const
returns a line Iterator of type ContourLine2D on last line
std::map GridPixel *, std::less > & getPixelTable ()
returns the built pixel table for detecting contour intersection
Vec2 computeCenter () const
updates and returns the center of the 2D contour but without updating the contour center private member
void updateCenter (Vec2& center, unsigned int& n)
updates the center position of the 2D contour
double updateRadius (const Vec2& center)
Given a 2D point, returns the smallest sphere radius enclosing the 2D contour @aparam center give the sphere center
virtual void translate (const Vec2& t)
translate a 2D contour
virtual void scale (const double scale)
scale a 2D contour
virtual void rotate (const Rotation2D &rotation)
rotate a 2D contour around its center
virtual void translateLine (const Vec2& t)
translate a 2D contour
virtual void scaleLine (const double scale)
scale a 2D contour
virtual void rotateLine (const Rotation2D &rotation)
rotate a 2D contour around its center
void computeBoundingBox (double &minx, double &maxx, double &miny, double &minz) const
computes the bounding box enclosing the 2D contour
virtual ContourLine* createLine (ContourLine::Topology top)
create a new line : use a virtual function in order to create inherited lines
void buildGridIntersection (double distance)
build the hash table of the contour intersection with a grid of size
void removeGridIntersectionInformation (void)
free all data structure associated with the intersection hash table
void addContour (const Contour2D *contour)
add in the current contour a copy of another contour
void readModule (GFInput &input) throw(ContourLine2D::EmptyLine)
reads the geometric description of the 2D contour
void skipModule (GFInput &input)
skips the geometric description of the 2D contour
void writeModule (GFOutput &output)
writes the geometric description of the 2D contour
void computeTangent ()
Computes the tangent vector for each vertex
void saveAsMapleFile (const char *name)
save the contour geometry as a list of list of pair of points
TclObject* getTclInterface () const
returns the Tcl interface (usually a TclContour2D) associated with a 2D contour
VertexContour2D* getSelectedVertex () const
returns the selected vertex
ContourLine2D* getSelectedLine () const
returns the selected vertex
void updateBoundingBox ()
recompute the bounding box geometry
virtual void redraw (Camera2D *cam)
redraw a 2D contour in a camera
void drawLine (Camera2D *c, TclCamera2D *cam, ContourLine2D *l)
draw a line of a contour in a given a camera
double computeClosestDistance (DataTypes::MouseClick& mc) const
returns the distance between a mouse position and a given contour
virtual void selectLine (const Vec2& pixel, Camera2D *cam)
select the contour line closest from a given position and set the selectedLine variable
virtual void moveVertex (const Vec2& pixel, Camera2D *cam)
move the selected vertex at a given position select
virtual void addVertex (const Vec2& pixel, Camera2D *cam)
create a new vertex at the pizel position and insert it at the end of the selected line
virtual void insertVertex (const Vec2& pixel, Camera2D *cam)
create a new vertex at the pixel position and insert it near the closest vertex of the selected line
void setSelectedLine (ContourLine2D *l)
set the selected contour line
void setSelectedVertex (VertexContour2D *v)
set the selected vertex
virtual void selectVertex (const Vec2& pixel, Camera2D *cam)
select the contour vertex closest from a given position and set the selectedVertex variable
virtual void selectObject (const Vec2 pixel, Camera2D *cam)
a function that allows to perform a task on a data object from a mouse click

Public

Constructors
Contour2D (const TclString filename, Scene2D *scene=NULL)
create a 2D contour from a file
Contour2D (Scene2D *scene=NULL)
create an empty 2D contour from a file
Contour2D (const Contour2D *_contour)
copy constructor : create a copy of a given 2D contour
Contour2D (const unsigned int nbLines, const unsigned int *nbVertices, Vec2 **array, const ContourLine::Topology *top, Scene2D *scene=NULL)
create a 2D contour given an array of vertex arrays
Destructor
virtual ~Contour2D ()
destructor of a 2D contour

Protected Fields

std::list <EdgeGridIntersection *> edgeIntersectionList
the list of grid intersections
std::map GridPixel *, std::less > pixelTable
the hash table where the key is the index of the pixel (ie col + ncols*row) and the item is a pointer to a GridPixel object
VertexContour2D* selectedVertex
the selected vertex
ContourLine2D* selectedLine
the selected line

Protected Methods

virtual void initGeometry ()
function for updating geometric parameters when the geometry has been updated

Private Methods

void initFormat ()
the function creating the module for General Format I/O

Inherited from Contour:

Public Classes

template class VertexIterator
const Contour* contour
the contour where are the vertices
ObjectsList <ContourLine> :: iterator currentLine
the current Line pointed by the iterator
ObjectsList <VertexContour> :: iterator currentVertex
the current vertex pointed by the iterator
constructor
VertexIterator(const Contour *c)
Build a VertexIterator given a Contour
T* operator++(int) throw(ObjectsList<ContourLine>::iterator::AccessBeyondList)
Operator ++ that pre-increment the iterator
T* operator++(void) throw(ObjectsList<ContourLine>::iterator::AccessBeyondList)
Operator ++ that post-increment the iterator
T* operator *(void) const throw(ObjectsList<ContourLine>::iterator::AccessBeyondList)
Operator () that returns the pointed element
void first(void)
set the iterator to point on the first vertex
bool isAtEnd(void)
returns true if list end was reached and there is no current element anymore
enum DisplayMode
enum VertexDisplayMode
enum SelectionMode

Public Methods

template L* getFirstLine(void) const
ObjectsList <ContourLine> ::iterator firstLineContour() const
ObjectsList <ContourLine> ::iterator lastLineContour() const
void addLine(ContourLine *l)
unsigned int getNbLines() const
unsigned int getNbVertices() const
virtual void mergeEdges(EdgeContour *e1, EdgeContour *e2)
template void applyLine(void (T::*fn)(const unsigned int ), const unsigned int v)
template void applyVertex(void (T::*fn)(void))
template void applyVertex(void (T::*fn)(const double), const double v)
template void applyVertex(void (T::*fn)(const unsigned int ), const unsigned int v)
void initColor()
void getLineColor(float &r, float &g, float &b) const
void getSelectedLineColor(float &r, float &g, float &b) const
void getVertexColor(float &r, float &g, float &b) const
void getSelectedVertexColor(float &r, float &g, float &b) const
float getLineWidth() const
float getVertexSize() const
DisplayMode getDisplayMode() const
SelectionMode getSelectionMode() const
VertexDisplayMode getVertexDisplayMode() const
void setLineColor(const float r, const float g, const float b)
void setSelectedLineColor(const float r, const float g, const float b)
void setVertexColor(const float r, const float g, const float b)
void setSelectedVertexColor(const float r, const float g, const float b)
void setLineWidth(const float w)
void setVertexSize(const float s)
void setDisplayMode(const DisplayMode mode)
void setVertexDisplayMode(const VertexDisplayMode mode)
void setSelectionMode(const SelectionMode mode)

Public

constructor

Contour()
Build a contour

destructor

virtual ~Contour()
empty

Protected Fields

ObjectsList <ContourLine> lineList
float lineColor[3]
static const float defaultLineColor[3]
float selectedLineColor[3]
static const float defaultSelectedLineColor[3]
float selectedVertexColor[3]
static const float defaultSelectedVertexColor[3]
float vertexColor[3]
static const float defaultVertexColor[3]
float lineWidth
static const float defaultLineWidth
float vertexSize
static const float defaultVertexSize
DisplayMode displayMode
VertexDisplayMode vertexDisplayMode
SelectionMode selectionMode

Documentation

a two-dimensional contour that only includes geometric information. Topological operators can be applied on this type of contours.
class EdgeGridIntersection
Class defining the intersection of an edge with a grid

enum IntersectionType
does the intersection corresponds to the intersection between a contour edge with a row or column ?

Vec2 position
the intersection position

IntersectionType type
the type of intersection

VertexContour2D* previousVertex
the previous vertex defining the edge. More precisely, the edge is [previousVertex, previousVertex->following()]

Vec2 getPosition() const
returns the intersection position

VertexContour2D* getPreviousVertex() const
returns the previous vertex defining the edge

Constructors

EdgeGridIntersection(IntersectionType t, Vec2 &pos, VertexContour2D *v)
Build an edge intersection knowing if it is occurs along a row or column edge, it position along the edge and the corresponding edge of the contour (through v->edge)
Parameters:
t - if the intersection occurs along a Row or column edge
pos - the position of the intersection
v - defines the edge of the Contour2D that created the intersection

Destructor

virtual ~EdgeGridIntersection()
empty destructor

class EdgeGridPixel: public ListElement<EdgeGridPixel>
Class defining an edge in a grid pixel : the edge corresponds to the intersection of the contour with the rows and columns of a grid

VertexContour2D* vertex
the vertex may be a VertexContour2D when it corresponds to the end of the contour

EdgeGridIntersection* edgeIntersection
the vertex may also be a EdgeGridIntersection

Constructors

GridPixelVertex(VertexContour2D *v)
Build a GridPixelVertex consisting of a single vertex
Parameters:
v - a vertex of a 2D contour

GridPixelVertex(EdgeGridIntersection *e)
Build a GridPixelVertex consisting of a grid intersection
Parameters:
e - a grid intersection edge

GridPixelVertex()
Build a GridPixelVertex without any vertex

GridPixelVertex(GridPixelVertex &iv)
Build a GridPixelVertex given another GridPixelVertex
Parameters:
iv - another GridPixelVertex

Destructor

virtual ~GridPixelVertex()
empty destructor

void setVertex(VertexContour2D *v)
set the vertex as a VertexContour2D

void setEdgeIntersection(EdgeGridIntersection *e)
set the vertex as a EdgeGridIntersection

VertexContour2D* getVertex() const
returns the vertex as a VertexContour2D (may be 0)

EdgeGridIntersection* getEdgeIntersection() const
returns the vertex as a EdgeGridIntersection (may be 0)

Vec2 getPosition() const
returns the position of the vertex

ContourLine* getLine() const
return the line where the pixel vertex belongs

GridPixelVertex vertex[2]
the 2 extremities of the edge

Constructors

EdgeGridPixel(GridPixelVertex &iv1, GridPixelVertex &iv2 )
Create a EdgeGridPixel given its 2 extremities
Parameters:
iv1 - first extremity
iv2 - second extremity

Destructor

virtual ~EdgeGridPixel()
empty destructor

bool isValid() const
test if the edge is valid i.e. its two extremities belong to the same line

Vec2 getPosition(unsigned int i) const
returns the position of the vertex
Parameters:
i - the index of the vertex (either 0 or 1)

VertexContour2D* getVertex(unsigned int i) const
returns the VertexContour2D associated with one its extremity (may be 0)
Parameters:
i - the index of the vertex (either 0 or 1)

EdgeGridIntersection* getEdgeIntersection(unsigned int i) const
returns the EdgeGridIntersection associated with one its extremity (may be 0)
Parameters:
i - the index of the vertex (either 0 or 1)

class GridPixel
Class defining a grid Pixel that encloses a list of edges. Each edge correspond to the intersection of the contour with the rows and columns of a grid

ObjectsList <EdgeGridPixel> edgeList
the list of grid edges

const int row
the row index of the pixel

const int col
the column index of the pixel

Constructors

GridPixel(const int r, const int c)
constructor based on the pixel row and column index
Parameters:
r - the row index of the pixel
c - the column index of the pixel

Destructor

virtual ~GridPixel()
empty destructor

int getRowIndex() const
returns the row index of the grid pixel

int getColumnIndex() const
returns the column index of the grid pixel

unsigned int getNbEdges() const
returns the number of edges in the pixel grid

ObjectsList <EdgeGridPixel> ::iterator firstEdge()
returns an iterator on the first edge

ObjectsList <EdgeGridPixel> ::iterator lastEdge()
returns an iterator on the last edge

virtual void initGeometry()
function for updating geometric parameters when the geometry has been updated

std::list <EdgeGridIntersection *> edgeIntersectionList
the list of grid intersections

std::map GridPixel *, std::less > pixelTable
the hash table where the key is the index of the pixel (ie col + ncols*row) and the item is a pointer to a GridPixel object

void initFormat()
the function creating the module for General Format I/O

void read(TclString filename)
call the read function associated with the General Format Library

void write(TclString filename)
call the write function associated with the General Format Library

Constructors

Contour2D(const TclString filename, Scene2D *scene=NULL)
create a 2D contour from a file
Parameters:
filename - file name describing a contour2D
scene - the 2D scene where the contour should be inserted. If the scene is NULL then the first exisiting scene is chosen

Contour2D(Scene2D *scene=NULL)
create an empty 2D contour from a file
Parameters:
scene - the 2D scene where the contour should be inserted. If the scene is NULL then the first exisiting scene is chosen

Contour2D(const Contour2D *_contour)
copy constructor : create a copy of a given 2D contour
Parameters:
_contour - another contour 2D

Contour2D(const unsigned int nbLines, const unsigned int *nbVertices, Vec2 **array, const ContourLine::Topology *top, Scene2D *scene=NULL)
create a 2D contour given an array of vertex arrays
Parameters:
nbLines - the number of lines in the contour
nbVertices - an array describing the number of vertices for each line
array - a 2D array describing the vertex position for each line : array[i][j] gives the position of the jth vertex of the ith line
top - a 2D array describing the topology (closed or open) for each line
scene - the 2D scene where the contour should be inserted. If the scene is NULL then the first exisiting scene is chosen

Destructor

virtual ~Contour2D()
destructor of a 2D contour

VertexContour2DIterator firstVertex() const
returns a VertexIterator of type VertexContour2D pointing on the contour
Returns:
s the VertexIterator pointing on the first contour vertex

Line2DIterator firstLine(void) const
returns a line Iterator of type ContourLine2D on first line
Returns:
a CastIterator of type ContourLine2D on the lines of a Contour

Line2DIterator lastLine(void) const
returns a line Iterator of type ContourLine2D on last line
Returns:
a CastIterator of type ContourLine2D on the lines of a Contour

std::map GridPixel *, std::less > & getPixelTable()
returns the built pixel table for detecting contour intersection

Vec2 computeCenter() const
updates and returns the center of the 2D contour but without updating the contour center private member

void updateCenter(Vec2& center, unsigned int& n)
updates the center position of the 2D contour
Parameters:
center - a vector that is set to the contour center : must be initialized as (0.0,0.0)
n - a integer that is set to the total number of contour vertices : it does not need to be initialized

double updateRadius(const Vec2& center)
Given a 2D point, returns the smallest sphere radius enclosing the 2D contour @aparam center give the sphere center

virtual void translate(const Vec2& t)
translate a 2D contour
Parameters:
t - the 2D translation vector

virtual void scale(const double scale)
scale a 2D contour
Parameters:
s - the scale factor (should be greater than 0)

virtual void rotate(const Rotation2D &rotation)
rotate a 2D contour around its center
Parameters:
rotation - the 2D rotation

virtual void translateLine(const Vec2& t)
translate a 2D contour
Parameters:
t - the 2D translation vector

virtual void scaleLine(const double scale)
scale a 2D contour
Parameters:
s - the scale factor (should be greater than 0)

virtual void rotateLine(const Rotation2D &rotation)
rotate a 2D contour around its center
Parameters:
rotation - the 2D rotation

void computeBoundingBox(double &minx, double &maxx, double &miny, double &minz) const
computes the bounding box enclosing the 2D contour
Parameters:
minx - the minimum x coordinates (its initial value is irrelevant)
maxx - the maximum x coordinates (its initial value is irrelevant)
miny - the minimum y coordinates (its initial value is irrelevant)
maxy - the maximum y coordinates (its initial value is irrelevant)

virtual ContourLine* createLine(ContourLine::Topology top)
create a new line : use a virtual function in order to create inherited lines

void buildGridIntersection(double distance)
build the hash table of the contour intersection with a grid of size
Parameters:
distance - the edge size of the regular grid

void removeGridIntersectionInformation(void)
free all data structure associated with the intersection hash table

void addContour(const Contour2D *contour)
add in the current contour a copy of another contour
Parameters:
contour - the contour whose vertices are to be copied and inserted in the current contour

void readModule(GFInput &input) throw(ContourLine2D::EmptyLine)
reads the geometric description of the 2D contour

void skipModule(GFInput &input)
skips the geometric description of the 2D contour

void writeModule(GFOutput &output)
writes the geometric description of the 2D contour

void computeTangent()
Computes the tangent vector for each vertex

void saveAsMapleFile(const char *name)
save the contour geometry as a list of list of pair of points
Parameters:
name - the name of the output file

TclObject* getTclInterface() const
returns the Tcl interface (usually a TclContour2D) associated with a 2D contour

VertexContour2D* selectedVertex
the selected vertex

ContourLine2D* selectedLine
the selected line

VertexContour2D* getSelectedVertex() const
returns the selected vertex

ContourLine2D* getSelectedLine() const
returns the selected vertex

void updateBoundingBox()
recompute the bounding box geometry

virtual void redraw(Camera2D *cam)
redraw a 2D contour in a camera
Parameters:
cam - the 2D camera where to draw the contour

void drawLine(Camera2D *c, TclCamera2D *cam, ContourLine2D *l)
draw a line of a contour in a given a camera

double computeClosestDistance(DataTypes::MouseClick& mc) const
returns the distance between a mouse position and a given contour
Parameters:
mc - the structure containing the mouse position

virtual void selectLine(const Vec2& pixel, Camera2D *cam)
select the contour line closest from a given position and set the selectedLine variable
Parameters:
pixel - a pixel position given in camera coordinates (must be transformed with cam->mapToWorld())
cam - a 2D camera

virtual void moveVertex(const Vec2& pixel, Camera2D *cam)
move the selected vertex at a given position select
Parameters:
pixel - a pixel position given in camera coordinates (must be transformed with cam->mapToWorld())
cam - a 2D camera

virtual void addVertex(const Vec2& pixel, Camera2D *cam)
create a new vertex at the pizel position and insert it at the end of the selected line
Parameters:
pixel - a pixel position given in camera coordinates (must be transformed with cam->mapToWorld())
cam - a 2D camera

virtual void insertVertex(const Vec2& pixel, Camera2D *cam)
create a new vertex at the pixel position and insert it near the closest vertex of the selected line
Parameters:
pixel - a pixel position given in camera coordinates (must be transformed with cam->mapToWorld())
cam - a 2D camera

void setSelectedLine(ContourLine2D *l)
set the selected contour line
Parameters:
l - a contour line

void setSelectedVertex(VertexContour2D *v)
set the selected vertex
Parameters:
v - a contour vertex

virtual void selectVertex(const Vec2& pixel, Camera2D *cam)
select the contour vertex closest from a given position and set the selectedVertex variable
Parameters:
pixel - a pixel position given in camera coordinates (must be transformed with cam->mapToWorld())
cam - a 2D camera

virtual void selectObject(const Vec2 pixel, Camera2D *cam)
a function that allows to perform a task on a data object from a mouse click
Parameters:
pixel - a pixel position given in camera coordinates (must be transformed with cam->mapToWorld())
cam - the camera *from which the object is selected


Direct child classes:
ActiveContour2D

alphabetic index hierarchy of classes


this page has been generated automatically by doc++

(c)opyright by Malte Zöckler, Roland Wunderling
contact: doc++@zib.de