Commit 3b99cd77 authored by Tobias Neeb's avatar Tobias Neeb
Browse files

[ADD #736] extend implementation for triangular widgets so only points inside...

[ADD #736] extend implementation for triangular widgets so only points inside the triangle are considered
* add isPointInTriangle-Method
* add PolyPoint-Struct
* add getPoints-Method to make available the PolyPoint-List of the triangle in other classes
parent 5cb464cc
......@@ -68,11 +68,17 @@ void WTransferFunction2D::sample2DTransferFunction( unsigned char*array, int wid
int xMax = static_cast<int>( ( w.isoX + w.width ) * width );
int yMin = static_cast<int>( w.isoY * height );
int yMax = static_cast<int>( ( w.isoY + w.height ) * height );
wlog::debug( "TransferFunction2D" ) << "isoX: " << w.isoX;
wlog::debug( "TransferFunction2D" ) << "isoY: " << w.isoY;
wlog::debug( "TransferFunction2D" ) << "triangle width: " << w.width;
wlog::debug( "TransferFunction2D" ) << "triangle height: " << w.height;
wlog::debug( "TransferFunction2D" ) << "Left: " << w.points[0].x << ", " << w.points[0].y;
wlog::debug( "TransferFunction2D" ) << "Mid: " << w.points[1].x << ", " << w.points[1].y;
wlog::debug( "TransferFunction2D" ) << "Left: " << w.points[2].x << " , " << w.points[2].y;
for( int x = xMin; x < xMax; ++x )
{
for( int y = yMin; y < yMax; ++y )
{
wlog::debug( "WTransferFunction2D" ) << "Triangle:" << w.points;
if( isPointInTriangle( w.points, PolyPoint( x, y ) ) )
{
for( int j = 0; j < 3; ++j )
......@@ -86,7 +92,7 @@ void WTransferFunction2D::sample2DTransferFunction( unsigned char*array, int wid
}
}
}
//TODO(T. Neeb): Check what happens when moving the triangle inside tis function
bool WTransferFunction2D::isPointInTriangle( const PolyPoint trianglePoints[], PolyPoint point ) const
{
float m1, m2, m3;
......@@ -106,7 +112,6 @@ bool WTransferFunction2D::isPointInTriangle( const PolyPoint trianglePoints[], P
if( m1 > 0 && m2 > 0 && m3 > 0 )
{
wlog::debug( "WTransferFunction2D" ) << "Point in triangle: (" << p.x << "," << p.y << ")";
return true;
}
else
......@@ -195,8 +200,4 @@ std::ostream& operator << ( std::ostream& out, const WTransferFunction2D& tf )
}
//TODO(T. Neeb): Check updates between Polygon, ResizePoints and TF
//TODO(T. Neeb): Thread onSleep Save the triangle
......@@ -114,6 +114,31 @@ public:
m_opacityScale = factor;
}
/**
* (WIP) Point of a polygon shape
*
*/
struct PolyPoint
{
/**
* Default constructor for a PolyPoint
*
* @param xc x-coordinate
* @param yc y-coordinate
*/
PolyPoint( float xc = 0, float yc = 0 )
{
x = xc;
y = yc;
}
/** x-coordiante of the point */
float x;
/** y-coordinate of the point */
float y;
};
/**
* Get the histogram going along with the transfer function
*
......@@ -211,6 +236,22 @@ public:
return m_widget.at( i ).height;
}
/**
* @brief Return the points of the 2DTF-triangle as a vector of PolyPoint-Objects
*
* @param i
* @return std::vector<PolyPoint>
*/
std::vector<PolyPoint> getPoints( size_t i )
{
std::vector<PolyPoint> pointsVec;
pointsVec.push_back( m_triangle_widgets.at( i ).points[0] );
pointsVec.push_back( m_triangle_widgets.at( i ).points[1] );
pointsVec.push_back( m_triangle_widgets.at( i ).points[2] );
return pointsVec;
}
/**
* The color of the i-th boxwidget in the list.
*
......@@ -234,30 +275,7 @@ public:
void addBoxWidget( double isoX, double isoY, double width, double height, const WColor& color );
/**
* (WIP) Point of a polygon shape
*
*/
struct PolyPoint
{
/**
* Default constructor for a PolyPoint
*
* @param xc x-coordinate
* @param yc y-coordinate
*/
PolyPoint( double xc = 0, double yc = 0 )
{
x = xc;
y = yc;
}
/** x-coordiante of the point */
double x;
/** y-coordinate of the point */
double y;
};
/**
* Insert a new triangle widget
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment