Commit ef240480 authored by Hans-Christian Ebke's avatar Hans-Christian Ebke
Browse files

Merge remote-tracking branch 'remotes/origin/master'

parents 8fc676a5 35ec798f
......@@ -17,3 +17,31 @@ cppcheck:
artifacts:
paths:
- cppcheck.log
VS2015-Qt-5.6.0-x64:
script: "CI\\VS2015-Qt-5.6.0-x64.bat"
tags:
- VS2015
- Qt56
artifacts:
paths:
- rel/*.exe
VS2015-Qt-5.6.0-x32:
script: "CI\\VS2015-Qt-5.6.0-x32.bat"
tags:
- VS2015
- Qt56
artifacts:
paths:
- rel/*.exe
VS2013-Qt-5.5.1-x64:
script: "CI\\VS2013-Qt-5.5.1-x64.bat"
tags:
- VS2013
- Qt551
artifacts:
paths:
- rel/*.exe
......@@ -8,21 +8,10 @@ if ( ${PROJECT_NAME} MATCHES "OpenFlipper")
endif()
if (NOT FORCE_QT4)
# try to use QT5 if possible otherwise stick to QT4
acg_qt5 ()
else()
set (QT_MAX_VERSION 4.9.9)
set (QT5_FOUND false)
endif()
acg_qt5 ()
if (NOT QT5_FOUND)
message(STATUS "Using QT4 for ACG")
acg_qt4 (REQUIRED 4.5)
else ()
message(STATUS "Using QT5 for ACG")
message(FATAL ERROR "Qt5 not found")
endif ()
acg_openmp ()
......@@ -66,7 +55,7 @@ if (QJSON_FOUND)
endif ()
# use Qwt6 for QT5
if (NOT FORCE_QT4 AND QT5_FOUND)
if (QT5_FOUND)
find_package(Qwt6)
if (QWT6_FOUND)
......@@ -74,14 +63,7 @@ if (NOT FORCE_QT4 AND QT5_FOUND)
set(ADDITIONAL_LINK_LIBRARIES ${ADDITIONAL_LINK_LIBRARIES} ${QWT6_LIBRARIES})
set(ADDITIONAL_BUILD_DIRS "QwtWidgets" )
endif()
else()
find_package(Qwt5)
if(Qwt5_Qt4_FOUND)
set(INCLUDE_DIRS ${INCLUDE_DIRS} ${Qwt5_INCLUDE_DIR} )
set(ADDITIONAL_LINK_LIBRARIES ${ADDITIONAL_LINK_LIBRARIES} ${Qwt5_Qt4_LIBRARY})
set(ADDITIONAL_BUILD_DIRS "QwtWidgets" )
endif()
endif()
include_directories (
......@@ -135,18 +117,13 @@ if (QT5_FOUND)
acg_qt5_autouic (uic_targets ${ui})
acg_qt5_automoc (moc_targets ${headers})
acg_qt5_autoqrc (qrc_targets ${qrc})
elseif (QT4_FOUND)
acg_qt4_autouic (uic_targets ${ui})
acg_qt4_automoc (moc_targets ${headers})
acg_qt4_autoqrc (qrc_targets ${qrc})
endif()
if (QT5_FOUND)
acg_add_library (ACG SHARED ${uic_targets} ${sources} ${headers} ${moc_targets} ${qrc_targets})
elseif (QT4_FOUND)
acg_add_library (ACG SHARED ${uic_targets} ${sources} ${headers} ${moc_targets} ${qrc_targets})
endif()
if ( NOT WIN32 )
set_target_properties (ACG PROPERTIES VERSION ${ACG_VERSION_MAJOR}.${ACG_VERSION_MINOR}
SOVERSION ${ACG_VERSION_MAJOR}.${ACG_VERSION_MINOR})
......
......@@ -103,7 +103,7 @@ void ColorStack::initialize ()
//----------------------------------------------------------------------------
bool ColorStack::setMaximumIndex (unsigned int _idx)
bool ColorStack::setMaximumIndex (size_t _idx)
{
if (initialized_)
{
......@@ -117,7 +117,7 @@ bool ColorStack::setMaximumIndex (unsigned int _idx)
//----------------------------------------------------------------------------
void ColorStack::setIndex (unsigned int _idx)
void ColorStack::setIndex (size_t _idx)
{
if (initialized_)
{
......@@ -128,7 +128,7 @@ void ColorStack::setIndex (unsigned int _idx)
//----------------------------------------------------------------------------
Vec4uc ColorStack::getIndexColor (unsigned int _idx)
Vec4uc ColorStack::getIndexColor (size_t _idx)
{
if (initialized_)
{
......@@ -144,7 +144,7 @@ Vec4uc ColorStack::getIndexColor (unsigned int _idx)
//----------------------------------------------------------------------------
void ColorStack::pushIndex (unsigned int _idx)
void ColorStack::pushIndex (size_t _idx)
{
if (initialized_)
currentNode_ = currentNode_->pushIndex (_idx);
......@@ -160,12 +160,12 @@ void ColorStack::popIndex ()
//----------------------------------------------------------------------------
std::vector<unsigned int> ColorStack::colorToStack (Vec4uc _rgba) const
std::vector<size_t> ColorStack::colorToStack (Vec4uc _rgba) const
{
std::vector<unsigned int> rv(0);
std::vector<size_t> rv(0);
if (initialized_ && !error_)
{
unsigned int idx = translator_.color2index (_rgba);
const size_t idx = translator_.color2index (_rgba);
if (idx >= root_->startIndex () && idx < root_->endIndex ())
root_->colorToStack (rv, idx);
}
......@@ -174,7 +174,7 @@ std::vector<unsigned int> ColorStack::colorToStack (Vec4uc _rgba) const
//----------------------------------------------------------------------------
unsigned int ColorStack::freeIndicies() const
size_t ColorStack::freeIndicies() const
{
if (initialized_)
{
......@@ -186,7 +186,7 @@ unsigned int ColorStack::freeIndicies() const
//----------------------------------------------------------------------------
unsigned int ColorStack::currentIndex () const
size_t ColorStack::currentIndex () const
{
if (initialized_)
{
......@@ -198,7 +198,7 @@ unsigned int ColorStack::currentIndex () const
//----------------------------------------------------------------------------
ColorStack::Node::Node (unsigned int _idx, Node *_parent, ColorTranslator *_ct) :
ColorStack::Node::Node (size_t _idx, Node *_parent, ColorTranslator *_ct) :
parent_(_parent),
index_(_idx),
translator_(_ct),
......@@ -221,7 +221,7 @@ ColorStack::Node::~Node ()
//----------------------------------------------------------------------------
bool ColorStack::Node::setMaximumIndex (unsigned int _idx)
bool ColorStack::Node::setMaximumIndex (size_t _idx)
{
if (_idx == 0)
_idx = 1;
......@@ -237,7 +237,7 @@ bool ColorStack::Node::setMaximumIndex (unsigned int _idx)
//----------------------------------------------------------------------------
bool ColorStack::Node::setIndex (unsigned int _idx) const
bool ColorStack::Node::setIndex (size_t _idx) const
{
if (colorStartIdx_ && colorStartIdx_ + _idx < colorEndIdx_)
{
......@@ -249,7 +249,7 @@ bool ColorStack::Node::setIndex (unsigned int _idx) const
//----------------------------------------------------------------------------
bool ColorStack::Node::getIndexColor (unsigned int _idx, Vec4uc &_rgba) const
bool ColorStack::Node::getIndexColor (size_t _idx, Vec4uc &_rgba) const
{
if (colorStartIdx_ && colorStartIdx_ + _idx < colorEndIdx_)
{
......@@ -261,7 +261,7 @@ bool ColorStack::Node::getIndexColor (unsigned int _idx, Vec4uc &_rgba) const
//----------------------------------------------------------------------------
ColorStack::Node * ColorStack::Node::pushIndex (unsigned int _idx)
ColorStack::Node * ColorStack::Node::pushIndex (size_t _idx)
{
ColorStack::Node *n = new ColorStack::Node (_idx, this, translator_);
nodes_.push_back (n);
......@@ -278,7 +278,7 @@ ColorStack::Node * ColorStack::Node::popIndex ()
//----------------------------------------------------------------------------
void ColorStack::Node::colorToStack (std::vector<unsigned int> &_stack, unsigned int _index)
void ColorStack::Node::colorToStack (std::vector<size_t> &_stack, size_t _index)
{
if (_index >= colorStartIdx_ && _index < colorEndIdx_)
{
......
......@@ -95,31 +95,31 @@ public:
bool initialized() const { return initialized_; }
/// sets the maximum index number used in current node
bool setMaximumIndex (unsigned int _idx);
bool setMaximumIndex (size_t _idx);
/// sets the current color the given index (like glLoadName)
void setIndex (unsigned int _idx);
void setIndex (size_t _idx);
/// gets the color instead of setting it directly
Vec4uc getIndexColor (unsigned int _idx);
Vec4uc getIndexColor (size_t _idx);
/// creates a new node the stack (like glPushName)
void pushIndex (unsigned int _idx);
void pushIndex (size_t _idx);
/// pops the current node from the stack (like glPopName)
void popIndex ();
/// converts the given color to index values on the stack
std::vector<unsigned int> colorToStack (Vec4uc _rgba) const;
std::vector<size_t> colorToStack (Vec4uc _rgba) const;
/// returns maximal available index count
unsigned int freeIndicies () const;
size_t freeIndicies () const;
/// Did an error occur during picking
bool error () const { return error_ && initialized_; };
/// returns the current color index
unsigned int currentIndex () const;
size_t currentIndex () const;
private:
......@@ -127,40 +127,40 @@ private:
class Node {
public:
Node (unsigned int _idx, Node *_parent, ColorTranslator *_ct);
Node (size_t _idx, Node *_parent, ColorTranslator *_ct);
~Node ();
/// sets the maximum index number used in current node
bool setMaximumIndex (unsigned int _idx);
bool setMaximumIndex (size_t _idx);
/// sets the current color the given index (like glLoadName)
bool setIndex (unsigned int _idx) const;
bool setIndex (size_t _idx) const;
/// gets the color instead of setting it directly
bool getIndexColor (unsigned int _idx, Vec4uc &_rgba) const;
bool getIndexColor (size_t _idx, Vec4uc &_rgba) const;
/// creates a new node the stack (like glPushName)
Node * pushIndex (unsigned int _idx);
Node * pushIndex (size_t _idx);
/// pops the current node from the stack (like glPopName)
Node * popIndex ();
void colorToStack (std::vector<unsigned int> &_stack, unsigned int _index);
void colorToStack (std::vector<size_t> &_stack, size_t size_t);
unsigned int startIndex () { return startIdx_; };
unsigned int endIndex () { return endIdx_; };
unsigned int colorIndex () { return colorStartIdx_; };
size_t startIndex () const { return startIdx_; };
size_t endIndex () const { return endIdx_; };
size_t colorIndex () const { return colorStartIdx_; };
private:
Node *parent_;
unsigned int index_;
size_t index_;
ColorTranslator *translator_;
std::vector<Node *> nodes_;
unsigned int startIdx_;
unsigned int endIdx_;
unsigned int colorStartIdx_;
unsigned int colorEndIdx_;
size_t startIdx_;
size_t endIdx_;
size_t colorStartIdx_;
size_t colorEndIdx_;
};
......
......@@ -61,6 +61,7 @@
#include "ColorTranslator.hh"
#include <iostream>
#include <limits>
//== NAMESPACES ===============================================================
......@@ -81,21 +82,25 @@ initialize()
glGetIntegerv( GL_BLUE_BITS, &blue_bits_ );
glGetIntegerv( GL_ALPHA_BITS, &alpha_bits_ );
// We currently only support up to 8 bits per channel (
if (red_bits_ > 8) red_bits_ = 8;
if (green_bits_ > 8) green_bits_ = 8;
if (blue_bits_ > 8) blue_bits_ = 8;
if (alpha_bits_ > 8) alpha_bits_ = 8;
// Compute the mask to extract the component
red_mask_ = ((1 << red_bits_) - 1);
green_mask_ = ((1 << green_bits_) - 1);
blue_mask_ = ((1 << blue_bits_) - 1);
alpha_mask_ = ((1 << alpha_bits_) - 1);
// Shift required to move the component to the lowest bits
red_shift_ = 8 - red_bits_;
green_shift_ = 8 - green_bits_;
blue_shift_ = 8 - blue_bits_;
alpha_shift_ = 8 - alpha_bits_;
red_round_ = 1 << (red_shift_ - 1);
green_round_ = 1 << (green_shift_ - 1);
blue_round_ = 1 << (blue_shift_ - 1);
......@@ -110,12 +115,19 @@ initialize()
Vec4uc
ColorTranslator::
index2color(unsigned int _idx) const
index2color(const size_t _idx) const
{
assert(initialized());
unsigned char r, g, b, a;
unsigned int idx(_idx+1);
// Make sure that the number fits
if ( _idx > std::numeric_limits<unsigned int>::max() ) {
std::cerr << "Can't convert index " << _idx << " to RGBA. Number too large for unsigned int \n";
return Vec4uc(0, 0, 0, 0);
}
unsigned int idx = ( static_cast<unsigned int>(_idx) + 1);
b = ((idx & blue_mask_) << blue_shift_) | blue_round_;
idx >>= blue_bits_;
g = ((idx & green_mask_) << green_shift_) | green_round_;
......@@ -139,13 +151,18 @@ index2color(unsigned int _idx) const
//-----------------------------------------------------------------------------
int
size_t
ColorTranslator::
color2index(Vec4uc _rgba) const
color2index(const Vec4uc _rgba) const
{
assert(initialized());
// Work internally with#include <iostream> unsigned int for now
unsigned int result;
// Combine the single unsigned chars according to masks
result = _rgba[3] >> alpha_shift_;
result <<= red_bits_;
result = _rgba[0] >> red_shift_;
......@@ -154,14 +171,15 @@ color2index(Vec4uc _rgba) const
result <<= blue_bits_;
result |= _rgba[2] >> blue_shift_;
return (result-1);
// Return size_t Here
return ( static_cast<size_t>(result-1) );
}
//-----------------------------------------------------------------------------
unsigned int
size_t
ColorTranslator::max_index() const
{
assert(initialized());
......
......@@ -95,20 +95,23 @@ public:
~ColorTranslator() {};
/// init (takes current GL context)
/// init (takes current GL context to get the component sizes)
/// Can't use constructor as we might not have a context at this point.
void initialize();
/// has it been initialized?
bool initialized() const { return initialized_; }
/// index -> color (one buffer)
Vec4uc index2color(unsigned int _idx) const;
Vec4uc index2color(const size_t _idx) const;
/// color -> index (one buffer)
int color2index(Vec4uc _rgba) const;
size_t color2index(const Vec4uc _rgba) const;
/// returns maximal convertable index
unsigned int max_index() const;
/// returns maximal convertible index
size_t max_index() const;
private:
......
......@@ -105,8 +105,8 @@ class ACGDLLEXPORT DrawMeshBase {
void fillInvVertexMap(size_t n_vertices, void *data);
public:
unsigned int getNumTris() const { return numTris_; }
unsigned int getNumVerts() const { return numVerts_; }
size_t getNumTris() const { return numTris_; }
size_t getNumVerts() const { return numVerts_; }
/** \brief get mesh compiler used to create the draw mesh
*/
......@@ -385,22 +385,22 @@ private:
* @param _hh corresponding halfedge handle of this vertex
* @param _fh corresponding face handle of this vertex
*/
void readVertex(unsigned int _vertex,
const typename Mesh::VertexHandle _vh,
const typename Mesh::HalfedgeHandle _hh,
const typename Mesh::FaceHandle _fh);
void readVertex(size_t _vertex,
const typename Mesh::VertexHandle& _vh,
const typename Mesh::HalfedgeHandle& _hh,
const typename Mesh::FaceHandle& _fh);
/** \brief return a vertex color from mesh
*
* @param _vh mesh vertex handle
*/
unsigned int getVertexColor(const typename Mesh::VertexHandle _vh);
unsigned int getVertexColor(const typename Mesh::VertexHandle& _vh);
/** \brief return a face color from mesh
*
* @param _fh mesh face handle
*/
unsigned int getFaceColor(const typename Mesh::FaceHandle _fh);
unsigned int getFaceColor(const typename Mesh::FaceHandle& _fh);
/** \brief eventually update vertex and index buffers
*
......@@ -474,7 +474,7 @@ public:
* @param _mvp model view projection transformation
* @param _pickOffset base picking id of the first vertex
*/
void drawPickingVertices_opt(const GLMatrixf& _mvp, int _pickOffset);
void drawPickingVertices_opt(const GLMatrixf& _mvp, size_t _pickOffset);
/** \brief Check if optimized vertex picking is supported
......@@ -559,7 +559,7 @@ public:
* @param _mvp model view projection transformation
* @param _pickOffset base picking id of the first edge
*/
void drawPickingEdges_opt(const GLMatrixf& _mvp, int _pickOffset);
void drawPickingEdges_opt(const GLMatrixf& _mvp, size_t _pickOffset);
/** \brief Check if optimized face picking is supported
......@@ -628,7 +628,7 @@ public:
* @param _mvp model view projection transformation
* @param _pickOffset base picking id of the first face
*/
void drawPickingFaces_opt(const GLMatrixf& _mvp, int _pickOffset);
void drawPickingFaces_opt(const GLMatrixf& _mvp, size_t _pickOffset);
/** \brief Check if optimized face picking is supported
......@@ -734,7 +734,7 @@ public:
* @param _mvp model view projection transformation
* @param _pickOffset base picking id of the first element
*/
void drawPickingAny_opt(const GLMatrixf& _mvp, int _pickOffset);
void drawPickingAny_opt(const GLMatrixf& _mvp, size_t _pickOffset);
/** \brief Check if optimized any picking is supported
*
......@@ -929,19 +929,19 @@ private:
//========================================================================
// write functions for flexible vertex format
void writeVertexElement(void* _dstBuf, unsigned int _vertex, unsigned int _stride, unsigned int _elementOffset, unsigned int _elementSize, const void* _elementData);
void writeVertexElement(void* _dstBuf, size_t _vertex, size_t _stride, size_t _elementOffset, size_t _elementSize, const void* _elementData);
void writePosition(unsigned int _vertex, const ACG::Vec3d& _p);
void writePosition(size_t _vertex, const ACG::Vec3d& _p);
void writeNormal(unsigned int _vertex, const ACG::Vec3d& _n);
void writeNormal(size_t _vertex, const ACG::Vec3d& _n);
void writeTexcoord(unsigned int _vertex, const ACG::Vec2f& _uv);
void writeTexcoord(size_t _vertex, const ACG::Vec2f& _uv);
void writeColor(unsigned int _vertex, unsigned int _color);
void writeColor(size_t _vertex, unsigned int _color);
void writeVertexProperty(unsigned int _vertex, const VertexElement* _elementDesc, const ACG::Vec4f& _propf);
void writeVertexProperty(size_t _vertex, const VertexElement* _elementDesc, const ACG::Vec4f& _propf);
void writeVertexProperty(unsigned int _vertex, const VertexElement* _elementDesc, const ACG::Vec4d& _propd);
void writeVertexProperty(size_t _vertex, const VertexElement* _elementDesc, const ACG::Vec4d& _propd);
/** \brief Read one vertex from the rendering vbo.
......@@ -1103,7 +1103,7 @@ private:
return normal;
}
typename Mesh::HalfedgeHandle mapToHalfedgeHandle(int _vertexId);
typename Mesh::HalfedgeHandle mapToHalfedgeHandle(size_t _vertexId);
};
......
......@@ -454,7 +454,7 @@ DrawMeshT<Mesh>::rebuild()
// read all vertices
for (size_t i = 0; i < numVerts_; ++i)
readVertex(i,
mesh_.vertex_handle(i),
mesh_.vertex_handle(static_cast<unsigned int>(i)),
(typename Mesh::HalfedgeHandle)(-1),
(typename Mesh::FaceHandle)(-1));
......@@ -513,7 +513,7 @@ DrawMeshT<Mesh>::rebuild()
#pragma omp parallel for
#endif
#endif
for (unsigned int i = 0; i < numVerts_; ++i)
for (size_t i = 0; i < numVerts_; ++i)
{
// just pick one face, srews up face colors here so color updates need a full rebuild
const typename Mesh::HalfedgeHandle hh = mapToHalfedgeHandle(i);
......@@ -626,7 +626,7 @@ DrawMeshT<Mesh>::rebuild()
if (baseProp)
{
int numAttribs = baseProp->n_elements();
size_t numAttribs = baseProp->n_elements();
const void* attribData = propDesc->propDataPtr_;
meshComp_->setAttribVec( propDesc->declElementID_, numAttribs, attribData );
......@@ -752,10 +752,10 @@ DrawMeshT<Mesh>::rebuild()
template <class Mesh>
void
DrawMeshT<Mesh>::readVertex(unsigned int _vertex,
const typename Mesh::VertexHandle _vh,
const typename Mesh::HalfedgeHandle _hh,
const typename Mesh::FaceHandle _fh)
DrawMeshT<Mesh>::readVertex(size_t _vertex,
const typename Mesh::VertexHandle& _vh,
const typename Mesh::HalfedgeHandle& _hh,
const typename Mesh::FaceHandle& _fh)
{
static const typename Mesh::HalfedgeHandle invalidHEH(-1);
static const typename Mesh::FaceHandle invalidFH(-1);
......@@ -831,7 +831,7 @@ DrawMeshT<Mesh>::readVertex(unsigned int _vertex,
template <class Mesh>
unsigned int
DrawMeshT<Mesh>::getVertexColor(const typename Mesh::VertexHandle _vh)
DrawMeshT<Mesh>::getVertexColor(const typename Mesh::VertexHandle& _vh)
{
static const typename Mesh::VertexHandle invalidVH(-1);
......@@ -853,7 +853,7 @@ DrawMeshT<Mesh>::getVertexColor(const typename Mesh::VertexHandle _vh)
template <class Mesh>
unsigned int
DrawMeshT<Mesh>::getFaceColor(const typename Mesh::FaceHandle _fh)
DrawMeshT<Mesh>::getFaceColor(const typename Mesh::FaceHandle& _fh)
{
static const typename Mesh::FaceHandle invalidFH(-1);
......@@ -1389,18 +1389,18 @@ void DrawMeshT<Mesh>::draw(std::map< int, GLuint>* _textureMap, bool _nonindexed
ACG::GLState::bindTexture(GL_TEXTURE_2D, (*_textureMap)[sub->id]);
if (!_nonindexed)
glDrawElements(GL_TRIANGLES, sub->numTris * 3, indexType_,
glDrawElements(GL_TRIANGLES, static_cast<GLsizei>(sub->numTris * 3), indexType_,
(GLvoid*)( (size_t)sub->startIndex * (indexType_ == GL_UNSIGNED_INT ? 4 : 2))); // offset in bytes
else
glDrawArrays(GL_TRIANGLES, sub->startIndex, sub->numTris * 3);
glDrawArrays(GL_TRIANGLES, sub->startIndex, static_cast<GLsizei>(sub->numTris * 3));
}
}
else
{
if (!_nonindexed)
glDrawElements(GL_TRIANGLES, numTris_ * 3, indexType_, 0);
glDrawElements(GL_TRIANGLES, static_cast<GLsizei>(numTris_ * 3), indexType_, 0);
else