/******************************************************************** ** Image Component Library (ICL) ** ** ** ** Copyright (C) 2006-2010 CITEC, University of Bielefeld ** ** Neuroinformatics Group ** ** Website: www.iclcv.org and ** ** http://opensource.cit-ec.de/projects/icl ** ** ** ** File : ICLGeom/src/SceneObject.cpp ** ** Module : ICLGeom ** ** Authors: Christof Elbrechter ** ** ** ** ** ** Commercial License ** ** ICL can be used commercially, please refer to our website ** ** www.iclcv.org for more details. ** ** ** ** GNU General Public License Usage ** ** Alternatively, this file may be used under the terms of the ** ** GNU General Public License version 3.0 as published by the ** ** Free Software Foundation and appearing in the file LICENSE.GPL ** ** included in the packaging of this file. Please review the ** ** following information to ensure the GNU General Public License ** ** version 3.0 requirements will be met: ** ** http://www.gnu.org/copyleft/gpl.html. ** ** ** ** The development of this software was supported by the ** ** Excellence Cluster EXC 277 Cognitive Interaction Technology. ** ** The Excellence Cluster EXC 277 is a grant of the Deutsche ** ** Forschungsgemeinschaft (DFG) in the context of the German ** ** Excellence Initiative. ** ** ** *********************************************************************/ #include namespace icl{ const std::vector &SceneObject::getVertices() const { return m_vertices; } std::vector &SceneObject::getVertices() { return m_vertices; } const std::vector &SceneObject::getPrimitives() const { return m_primitives; } std::vector &SceneObject::getPrimitives() { return m_primitives; } void SceneObject::setVisible(Primitive::Type t, bool visible) { m_visible[t] = visible; } bool SceneObject::isVisible(Primitive::Type t) const { return m_visible[t]; } SceneObject::SceneObject(): m_lineColorsFromVertices(false), m_triangleColorsFromVertices(false), m_quadColorsFromVertices(false), m_pointSize(1), m_lineWidth(1) { std::fill(m_visible,m_visible+Primitive::PRIMITIVE_TYPE_COUNT,true); } void SceneObject::addVertex(const Vec &p, const GeomColor &color){ m_vertices.push_back(p); m_vertexColors.push_back(color); } void SceneObject::addLine(int a, int b, const GeomColor &color){ m_primitives.push_back(Primitive(a,b,color)); } void SceneObject::addTriangle(int a, int b, int c, const GeomColor &color){ m_primitives.push_back(Primitive(a,b,c,color)); } void SceneObject::addQuad(int a, int b, int c, int d, const GeomColor &color){ m_primitives.push_back(Primitive(a,b,c,d,color)); } void SceneObject::addTexture(int a, int b, int c, int d, const Img8u &texture,bool deepCopy){ m_primitives.push_back(Primitive(a,b,c,d,texture,deepCopy)); } SceneObject *SceneObject::copy() const{ return new SceneObject(*this); } void SceneObject::updateZFromPrimitives(){ m_z = 0; if(m_primitives.size()){ for(unsigned int i=0;i0 && j>0){ addLine(idx,idx-1); addLine(idx,idx-slices); } } } }else{ ERROR_LOG("unknown type:" << type); } } void SceneObject::setColorsFromVertices(Primitive::Type t, bool on){ switch(t){ case Primitive::line: m_lineColorsFromVertices = on; break; case Primitive::triangle: m_triangleColorsFromVertices = on; break; case Primitive::quad: m_quadColorsFromVertices = on; break; default: ERROR_LOG("this operations is only supported for line, triangle and quad primitive types"); break; } } }