Tulip 6.1.0
Large graphs analysis and drawing
Loading...
Searching...
No Matches
tlp::GlComplexPolygon Class Reference

#include <GlComplexPolygon.h>

Inheritance diagram for tlp::GlComplexPolygon:
Collaboration diagram for tlp::GlComplexPolygon:

Public Member Functions

 GlComplexPolygon ()
 GlComplexPolygon (const std::vector< Coord > &coords, Color fcolor, Color ocolor, int polygonEdgesType=0, const std::string &textureName="", bool textured=true)
 GlComplexPolygon (const std::vector< Coord > &coords, Color fcolor, int polygonEdgesType=0, const std::string &textureName="", bool textured=true)
 GlComplexPolygon (const std::vector< std::vector< Coord > > &coords, Color fcolor, Color ocolor, int polygonEdgesType=0, const std::string &textureName="", bool textured=true)
 GlComplexPolygon (const std::vector< std::vector< Coord > > &coords, Color fcolor, int polygonEdgesType=0, const std::string &textureName="", bool textured=true)
void activateQuadBorder (const float borderWidth, const Color &color, const std::string &texture="", const int position=1, const float texCoordFactor=1.f, const int polygonId=0)
void deactivateQuadBorder (const int polygonId=0)
void draw (float lod, Camera *camera) override
Color getFillColor () const
Color getOutlineColor () const
const std::vector< std::vector< Coord > > & getPolygonSides () const
std::string getTextureName ()
float getTextureZoom ()
void getXML (std::string &outString) override
virtual void getXMLOnlyData (std::string &outString)
void setFillColor (const Color &color)
void setOutlineColor (const Color &color)
void setOutlineMode (const bool)
void setOutlineSize (double size)
void setOutlineStippled (bool stippled)
void setTextureActivation (bool)
void setTextureName (const std::string &name)
void setTextureZoom (float zoom)
void setWithXML (const std::string &inString, unsigned int &currentPosition) override
bool textureActivation ()
void translate (const Coord &mouvement) override
Public Member Functions inherited from tlp::GlSimpleEntity
 GlSimpleEntity ()
 ~GlSimpleEntity () override
virtual BoundingBox getBoundingBox ()
int getStencil ()
bool isVisible () const
virtual void setStencil (int stencil)
virtual void setVisible (bool visible)

Protected Member Functions

virtual void addPoint (const Coord &point)
virtual void beginNewHole ()
void createPolygon (const std::vector< Coord > &coords, int polygonEdgesType)
void runTesselation ()

Protected Attributes

int currentVector
Color fillColor
Color outlineColor
bool outlined
double outlineSize
bool outlineStippled
std::vector< std::vector< Coord > > points
std::vector< std::vector< float > > pointsIdx
std::vector< bool > quadBorderActivated
std::vector< Color > quadBorderColor
std::vector< int > quadBorderPosition
std::vector< float > quadBorderTexFactor
std::vector< std::string > quadBorderTexture
std::vector< float > quadBorderWidth
bool textured
std::string textureName
float textureZoom
std::vector< float > verticesData
std::vector< unsigned int > verticesIndices
Protected Attributes inherited from tlp::GlSimpleEntity
BoundingBox boundingBox
std::vector< GlComposite * > parents
int stencil
bool visible

Detailed Description

Class to create a complex polygon (concave polygon or polygon with hole) If you want to create a complex polygon you have 4 constructors : Constructors with vector of coords : to create a complex polygon without hole.

  • In this case you have two constructor : with and without outline color
  • You can create a polygon like this :
    vector <Coord> coords;
    coords.push_back(Coord(0,0,0));
    coords.push_back(Coord(10,0,0));
    coords.push_back(Coord(10,10,0));
    coords.push_back(Coord(0,10,0));
    GlComplexPolygon *complexPolygon=new GlComplexPolygon(coords,Color(255,0,0,255));
    layer->addGlEntity(complexPolygon,"complexPolygon");
    GlComplexPolygon()
    Default constructor.

Constructors with vector of vector of Coords : to create a complex polygon with hole

  • In this case you have two constructor : with and without outline color
  • The first vector of coords is the polygon and others vector are holes
  • You can create a polygon with hole like this :
    vector <vector <Coord> > coords;
    vector <Coord> polygon;
    vector <Coord> hole;
    polygon.push_back(Coord(0,0,0));
    polygon.push_back(Coord(10,0,0));
    polygon.push_back(Coord(10,10,0));
    polygon.push_back(Coord(0,10,0));
    hole.push_back(Coord(4,4,0));
    hole.push_back(Coord(6,4,0));
    hole.push_back(Coord(6,6,0));
    hole.push_back(Coord(4,6,0));
    coords.push_back(polygon);
    coords.push_back(hole);
    GlComplexPolygon *complexPolygon=new GlComplexPolygon(coords,Color(255,0,0,255));
    layer->addGlEntity(complexPolygon,"complexPolygon");

In constructors you can specify the polygon border style : polygonEdgesType parameter (0 -> straight lines, 1 -> catmull rom curves, 2 -> bezier curves) You can also specify the texture name if you want to create a textured complex polygon

In complex polygon you can add a smooth border : see activateQuadBorder(..) function And you can specify the texture zoom : see setTextureZoom(...) function

Definition at line 79 of file GlComplexPolygon.h.

Constructor & Destructor Documentation

◆ GlComplexPolygon() [1/5]

tlp::GlComplexPolygon::GlComplexPolygon ( )
inline

Default constructor.

Warning
don't use this constructor if you want to create a complex polygon, see others constructors

Definition at line 87 of file GlComplexPolygon.h.

Here is the caller graph for this function:

◆ GlComplexPolygon() [2/5]

tlp::GlComplexPolygon::GlComplexPolygon ( const std::vector< Coord > & coords,
Color fcolor,
int polygonEdgesType = 0,
const std::string & textureName = "",
bool textured = true )

Constructor with a vector of coords, a fill color, a polygon edges type(0 -> straight lines, 1 -> catmull rom curves, 2 -> bezier curves) and a textureName if you want.

◆ GlComplexPolygon() [3/5]

tlp::GlComplexPolygon::GlComplexPolygon ( const std::vector< Coord > & coords,
Color fcolor,
Color ocolor,
int polygonEdgesType = 0,
const std::string & textureName = "",
bool textured = true )

Constructor with a vector of coords, a fill color, an outline color, a polygon edges type(0 -> straight lines, 1 -> catmull rom curves, 2 -> bezier curves) and a textureName if you want.

◆ GlComplexPolygon() [4/5]

tlp::GlComplexPolygon::GlComplexPolygon ( const std::vector< std::vector< Coord > > & coords,
Color fcolor,
int polygonEdgesType = 0,
const std::string & textureName = "",
bool textured = true )

Constructor with a vector of vector of coords (the first vector of coord is the polygon and others vectors are holes in polygon), a fill color, a polygon edges type(0 -> straight lines, 1 -> catmull rom curves, 2 -> bezier curves) and a textureName if you want.

◆ GlComplexPolygon() [5/5]

tlp::GlComplexPolygon::GlComplexPolygon ( const std::vector< std::vector< Coord > > & coords,
Color fcolor,
Color ocolor,
int polygonEdgesType = 0,
const std::string & textureName = "",
bool textured = true )

Constructor with a vector of vector of coords (the first vector of coord is the polygon and others vectors are holes in polygon), a fill color, an outline color a polygon edges type(0 -> straight lines, 1 -> catmull rom curves, 2 -> bezier curves) and a textureName if you want.

Here is the call graph for this function:

◆ ~GlComplexPolygon()

tlp::GlComplexPolygon::~GlComplexPolygon ( )
inlineoverride

Definition at line 119 of file GlComplexPolygon.h.

Member Function Documentation

◆ activateQuadBorder()

void tlp::GlComplexPolygon::activateQuadBorder ( const float borderWidth,
const Color & color,
const std::string & texture = "",
const int position = 1,
const float texCoordFactor = 1.f,
const int polygonId = 0 )

Draw a thick (textured) border around the polygon.

The graphic card must support geometry shader to make this feature to work. The position parameter determines the way the border is drawn (depending on the polygon points ordering):

  • 0 : the border is drawn outside (or inside) the polygon
  • 1 : the border is centered on the polygon outline
  • 2 : the border is drawn inside (or outside) the polygon

The texCoordFactor parameter determines the way the texture is applied : if < 1, the texture will be expanded and > 1, the texture will be compressed The polygonId parameter determines on which contour of the polygon, the border will be applied

◆ addPoint()

virtual void tlp::GlComplexPolygon::addPoint ( const Coord & point)
protectedvirtual

Add a new point in polygon.

◆ beginNewHole()

virtual void tlp::GlComplexPolygon::beginNewHole ( )
protectedvirtual

Begin a new hole in the polygon.

◆ deactivateQuadBorder()

void tlp::GlComplexPolygon::deactivateQuadBorder ( const int polygonId = 0)

Deactivate the textured quad border.

◆ draw()

void tlp::GlComplexPolygon::draw ( float lod,
Camera * camera )
overridevirtual

Draw the complex polygon.

Implements tlp::GlSimpleEntity.

◆ getFillColor()

Color tlp::GlComplexPolygon::getFillColor ( ) const
inline

Get fill color of GlComplexPolygon.

Definition at line 144 of file GlComplexPolygon.h.

◆ getOutlineColor()

Color tlp::GlComplexPolygon::getOutlineColor ( ) const
inline

Get outline color of GlComplexPolygon.

Definition at line 158 of file GlComplexPolygon.h.

◆ getPolygonSides()

const std::vector< std::vector< Coord > > & tlp::GlComplexPolygon::getPolygonSides ( ) const
inline

Definition at line 254 of file GlComplexPolygon.h.

◆ getTextureName()

std::string tlp::GlComplexPolygon::getTextureName ( )

Get the textureName.

◆ getTextureZoom()

float tlp::GlComplexPolygon::getTextureZoom ( )
inline

Get the texture zoom factor.

Definition at line 172 of file GlComplexPolygon.h.

◆ getXML()

void tlp::GlComplexPolygon::getXML ( std::string & outString)
overridevirtual

Function to export data and type outString (in XML format).

Implements tlp::GlSimpleEntity.

◆ getXMLOnlyData()

virtual void tlp::GlComplexPolygon::getXMLOnlyData ( std::string & outString)
virtual

Function to export data in outString (in XML format).

◆ setFillColor()

void tlp::GlComplexPolygon::setFillColor ( const Color & color)
inline

Set fill color of GlComplexPolygon.

Definition at line 151 of file GlComplexPolygon.h.

◆ setOutlineColor()

void tlp::GlComplexPolygon::setOutlineColor ( const Color & color)
inline

Set outline color of GlComplexPolygon.

Definition at line 165 of file GlComplexPolygon.h.

◆ setOutlineMode()

void tlp::GlComplexPolygon::setOutlineMode ( const bool )

Set if the polygon is outlined or not.

◆ setOutlineSize()

void tlp::GlComplexPolygon::setOutlineSize ( double size)

Set size of outline.

◆ setOutlineStippled()

void tlp::GlComplexPolygon::setOutlineStippled ( bool stippled)

Set if the outline is stippled or not.

◆ setTextureActivation()

void tlp::GlComplexPolygon::setTextureActivation ( bool )

set if texture must be applied

◆ setTextureName()

void tlp::GlComplexPolygon::setTextureName ( const std::string & name)

Set the textureName.

◆ setTextureZoom()

void tlp::GlComplexPolygon::setTextureZoom ( float zoom)
inline

Set the texture zoom factor.

By default if you have a polygon with a size bigger than (1,1,0) the texture will be repeated If you want to don't have this texture repeat you have to modify texture zoom For example if you have a polygon with coords ((0,0,0),(5,0,0),(5,5,0),(0,5,0)) you can set texture zoom to 5. to don't have texture repeat

Definition at line 184 of file GlComplexPolygon.h.

◆ setWithXML()

void tlp::GlComplexPolygon::setWithXML ( const std::string & inString,
unsigned int & currentPosition )
overridevirtual

Function to set data with inString (in XML format).

Implements tlp::GlSimpleEntity.

◆ textureActivation()

bool tlp::GlComplexPolygon::textureActivation ( )
inline

indicates if texture must be applied

Definition at line 202 of file GlComplexPolygon.h.

◆ translate()

void tlp::GlComplexPolygon::translate ( const Coord & mouvement)
override

Translate entity.

Member Data Documentation

◆ currentVector

int tlp::GlComplexPolygon::currentVector
protected

Definition at line 275 of file GlComplexPolygon.h.

◆ fillColor

Color tlp::GlComplexPolygon::fillColor
protected

Definition at line 277 of file GlComplexPolygon.h.

◆ outlineColor

Color tlp::GlComplexPolygon::outlineColor
protected

Definition at line 278 of file GlComplexPolygon.h.

◆ outlined

bool tlp::GlComplexPolygon::outlined
protected

Definition at line 276 of file GlComplexPolygon.h.

◆ outlineSize

double tlp::GlComplexPolygon::outlineSize
protected

Definition at line 279 of file GlComplexPolygon.h.

◆ outlineStippled

bool tlp::GlComplexPolygon::outlineStippled
protected

Definition at line 276 of file GlComplexPolygon.h.

◆ points

std::vector<std::vector<Coord> > tlp::GlComplexPolygon::points
protected

Definition at line 271 of file GlComplexPolygon.h.

◆ pointsIdx

std::vector<std::vector<float> > tlp::GlComplexPolygon::pointsIdx
protected

Definition at line 272 of file GlComplexPolygon.h.

◆ quadBorderActivated

std::vector<bool> tlp::GlComplexPolygon::quadBorderActivated
protected

Definition at line 282 of file GlComplexPolygon.h.

◆ quadBorderColor

std::vector<Color> tlp::GlComplexPolygon::quadBorderColor
protected

Definition at line 284 of file GlComplexPolygon.h.

◆ quadBorderPosition

std::vector<int> tlp::GlComplexPolygon::quadBorderPosition
protected

Definition at line 286 of file GlComplexPolygon.h.

◆ quadBorderTexFactor

std::vector<float> tlp::GlComplexPolygon::quadBorderTexFactor
protected

Definition at line 287 of file GlComplexPolygon.h.

◆ quadBorderTexture

std::vector<std::string> tlp::GlComplexPolygon::quadBorderTexture
protected

Definition at line 285 of file GlComplexPolygon.h.

◆ quadBorderWidth

std::vector<float> tlp::GlComplexPolygon::quadBorderWidth
protected

Definition at line 283 of file GlComplexPolygon.h.

◆ textured

bool tlp::GlComplexPolygon::textured
protected

Definition at line 276 of file GlComplexPolygon.h.

◆ textureName

std::string tlp::GlComplexPolygon::textureName
protected

Definition at line 280 of file GlComplexPolygon.h.

◆ textureZoom

float tlp::GlComplexPolygon::textureZoom
protected

Definition at line 281 of file GlComplexPolygon.h.

◆ verticesData

std::vector<float> tlp::GlComplexPolygon::verticesData
protected

Definition at line 273 of file GlComplexPolygon.h.

◆ verticesIndices

std::vector<unsigned int> tlp::GlComplexPolygon::verticesIndices
protected

Definition at line 274 of file GlComplexPolygon.h.