56 #include "DrawModes.hh" 57 #include "BaseNode.hh" 132 void name(
const std::string& _name) {
137 const std::string&
name()
const {
145 bool propertyBased()
const {
162 typedef std::vector< DrawModeInternal > VecDrawModes;
166 static VecDrawModes registeredDrawModes_;
178 envMapped_(_envMapping),
179 primitive_(_primitive),
180 lightStage_(_lightStage),
181 colorSource_(_colorSource),
182 texcoordSource_(_texcoordSource),
183 normalSource_(_normalSource)
188 DrawMode::DrawMode(
size_t _index)
191 if ( _index >= modeFlags_.size() ) {
192 std::cerr <<
"Illegal drawMode specification from unsigned int. This should not be a bitset!!!" << std::endl;
194 modeFlags_.set(_index);
200 DrawMode::DrawMode() {
205 DrawMode::DrawMode(
const ModeFlagSet& _flags) :
212 DrawMode DrawMode::getFromDescription(std::string _description)
216 std::istringstream f(_description);
218 while (std::getline(f, s,
'+')) {
219 VecDrawModes::const_iterator modeIter, modeEnd( registeredDrawModes_.end() );
220 for( modeIter = registeredDrawModes_.begin(); modeIter != modeEnd; ++modeIter ) {
221 if(modeIter->name() == s) {
222 val |= modeIter->id();
232 DrawMode::operator bool()
const {
233 return( modeFlags_ != NONE.modeFlags_ );
268 bool DrawMode::operator==(
const DrawMode& _mode)
const {
269 return modeFlags_ == _mode.modeFlags_;
273 bool DrawMode::operator!=(
const DrawMode& _mode2 )
const {
274 return (modeFlags_ != _mode2.modeFlags_);
278 if ( modeFlags_.count() != 1 ) {
279 std::cerr <<
"Operator ++ for drawMode which is not atomic!!" << std::endl;
296 for (
int i = (
int)andMode.
getNumLayers() - 1; i >= 0; --i)
308 modeFlags_ |= _mode2.modeFlags_;
310 for (
unsigned int i = 0; i < _mode2.
getNumLayers(); ++i)
319 modeFlags_ &= _mode2.modeFlags_;
343 for (
unsigned int i = 0; i < _mode2.
getNumLayers(); ++i)
359 std::vector<const DrawModeProperties*> tmpLayers;
368 tmpLayers.push_back(curProps);
373 for (
unsigned int i = 0; i < _mode2.
getNumLayers(); ++i)
377 if (!curProps)
continue;
384 for (
unsigned int k = 0; addToVec && k < tmpLayers.size(); ++k)
389 tmpLayers.erase(tmpLayers.begin() + k);
395 tmpLayers.push_back(curProps);
401 if (tmpLayers.empty())
411 for (
unsigned int i = 1; i < tmpLayers.size(); ++i)
420 DrawMode DrawMode::operator~( )
const {
427 if ( modeFlags_.count() == 1 ) {
428 for (
size_t i = 0 ; i < modeFlags_.size() ; ++i )
438 std::string text(
"");
440 VecDrawModes::const_iterator modeIter, modeEnd( registeredDrawModes_.end() );
441 for( modeIter = registeredDrawModes_.begin(); modeIter != modeEnd; ++modeIter )
443 if( (*
this) & modeIter->id() )
445 if (!text.empty()) text +=
"+";
446 text += modeIter->name();
457 modeFlags_ = (modeFlags_ | _filter.modeFlags_) ^ _filter.modeFlags_;
459 for (
unsigned int i = 0; i < _filter.
getNumLayers(); ++i)
474 modeFlags_ = (modeFlags_ ^ _mode.modeFlags_);
486 std::vector< DrawMode >
489 std::vector< DrawMode > draw_mode_ids;
491 VecDrawModes::const_iterator modeIter, modeEnd( registeredDrawModes_.end() );
492 for( modeIter = registeredDrawModes_.begin();
495 if( (*
this) & modeIter->id() )
496 draw_mode_ids.push_back( modeIter->id() );
498 return draw_mode_ids;
505 return(modeFlags_.count() == 1 );
514 return (*
this) & _atomicDrawMode;
520 return (modeFlags_.size() );
569 for (
unsigned int i = 0; i <
layers_.size(); ++i)
571 for (
unsigned int k = i+1; k <
layers_.size(); ++k)
589 for (
unsigned int k = 0; k <
layers_.size(); ++k)
591 if (
layers_[k].primitive() == PRIMITIVE_POINT)
605 if (!_prop)
return -1;
607 for (
unsigned int i = 0; i <
layers_.size(); ++i)
620 for (
unsigned int i = 0; i <
layers_.size(); ++i)
622 if (
layers_[i].primitive() == _type )
633 static bool initialized_ =
false;
638 registeredDrawModes_.clear();
700 registeredDrawModes_.push_back(
DrawModeInternal(
"Points (colored)", POINTS_COLORED ) );
701 registeredDrawModes_.push_back(
DrawModeInternal(
"Points (shaded)", POINTS_SHADED ) );
704 registeredDrawModes_.push_back(
DrawModeInternal(
"Edges Colored", EDGES_COLORED ) );
706 registeredDrawModes_.push_back(
DrawModeInternal(
"Wireframe", WIREFRAME ) );
710 registeredDrawModes_.push_back(
DrawModeInternal(
"Hiddenline", HIDDENLINE ) );
712 registeredDrawModes_.push_back(
DrawModeInternal(
"Solid (flat shaded)", SOLID_FLAT_SHADED ) );
713 registeredDrawModes_.push_back(
DrawModeInternal(
"Solid (smooth shaded)", SOLID_SMOOTH_SHADED ) );
714 registeredDrawModes_.push_back(
DrawModeInternal(
"Solid (Phong shaded)", SOLID_PHONG_SHADED ) );
716 registeredDrawModes_.push_back(
DrawModeInternal(
"Solid (colored per-face)", SOLID_FACES_COLORED ) );
717 registeredDrawModes_.push_back(
DrawModeInternal(
"Solid (colored per-vertex)", SOLID_POINTS_COLORED ) );
718 registeredDrawModes_.push_back(
DrawModeInternal(
"Solid (colored per-vertex, shaded)", SOLID_POINTS_COLORED_SHADED ) );
720 registeredDrawModes_.push_back(
DrawModeInternal(
"Solid (environment mapped)", SOLID_ENV_MAPPED ) );
722 registeredDrawModes_.push_back(
DrawModeInternal(
"Solid (textured)", SOLID_TEXTURED ) );
723 registeredDrawModes_.push_back(
DrawModeInternal(
"Solid (textured, shaded)", SOLID_TEXTURED_SHADED ) );
725 registeredDrawModes_.push_back(
DrawModeInternal(
"Solid (scalar field)", SOLID_1DTEXTURED ) );
726 registeredDrawModes_.push_back(
DrawModeInternal(
"Solid (scalar field, shaded)", SOLID_1DTEXTURED_SHADED ) );
728 registeredDrawModes_.push_back(
DrawModeInternal(
"Solid (3D textured)", SOLID_3DTEXTURED ) );
729 registeredDrawModes_.push_back(
DrawModeInternal(
"Solid (3D textured, shaded)", SOLID_3DTEXTURED_SHADED ) );
731 registeredDrawModes_.push_back(
DrawModeInternal(
"Solid (colored per-face, flat shaded)", SOLID_FACES_COLORED_FLAT_SHADED ) );
732 registeredDrawModes_.push_back(
DrawModeInternal(
"Solid (colored per-face, smooth shaded)", SOLID_FACES_COLORED_SMOOTH_SHADED ) );
734 registeredDrawModes_.push_back(
DrawModeInternal(
"Solid (colored per-face, face textured, smooth shaded)", SOLID_FACES_COLORED_2DTEXTURED_FACE_SMOOTH_SHADED));
737 registeredDrawModes_.push_back(
DrawModeInternal(
"Solid (face textured)", SOLID_2DTEXTURED_FACE ) );
738 registeredDrawModes_.push_back(
DrawModeInternal(
"Solid (face textured, shaded)", SOLID_2DTEXTURED_FACE_SHADED ) );
739 registeredDrawModes_.push_back(
DrawModeInternal(
"Shader controlled", SOLID_SHADER ) );
741 registeredDrawModes_.push_back(
DrawModeInternal(
"Solid (smooth shaded, features)", SOLID_SMOOTH_SHADED_FEATURES ) );
744 registeredDrawModes_.push_back(
DrawModeInternal(
"Cells Colored", CELLS_COLORED ) );
746 registeredDrawModes_.push_back(
DrawModeInternal(
"Halfedges", HALFEDGES ) );
747 registeredDrawModes_.push_back(
DrawModeInternal(
"Halfedges Colored", HALFEDGES_COLORED ) );
760 VecDrawModes::iterator modeIter, modeEnd( registeredDrawModes_.end() );
762 for( modeIter = registeredDrawModes_.begin(); modeIter != modeEnd; ++modeIter ) {
763 if( _name == modeIter->name() ) {
764 return modeIter->id();
770 registeredDrawModes_.push_back(
DrawModeInternal( _name, firstFreeID_ , _propertyBased) );
773 return registeredDrawModes_[ registeredDrawModes_.size() - 1 ].id();
784 VecDrawModes::iterator modeIter, modeEnd( registeredDrawModes_.end() );
786 for( modeIter = registeredDrawModes_.begin(); modeIter != modeEnd; ++modeIter ) {
787 if( _name == modeIter->name() ) {
788 modeIter->properties() = _properties;
802 VecDrawModes::const_iterator modeIter, modeEnd( registeredDrawModes_.end() );
804 for( modeIter = registeredDrawModes_.begin(); modeIter != modeEnd; ++modeIter )
806 if( _name == modeIter->name() )
808 return modeIter->id();
819 VecDrawModes::const_iterator modeIter, modeEnd( registeredDrawModes_.end() );
821 for( modeIter = registeredDrawModes_.begin(); modeIter != modeEnd; ++modeIter )
823 if( _name == modeIter->name() )
DrawMode SOLID_2DTEXTURED_FACE
draw per halfedge textured faces
std::vector< DrawModeProperties > layers_
int getLayerIndexByPrimitive(DrawModePrimitive _type) const
search for layer with specified primitive
bool removeLayer(unsigned int _i)
remove layer at index i
DrawModePrimitive
Primitive mode of a mesh.
DrawModeInternal(const std::string &_name, const DrawMode &_id, const bool _propertyBased=false)
DrawMode SOLID_3DTEXTURED_SHADED
draw smooth shaded textured faces
std::string name_
Human Readable Name.
bool isAtomic() const
Check if this is an atomic draw Mode.
DrawMode SOLID_ENV_MAPPED
draw environment mapped
Namespace providing different geometric functions concerning angles.
DrawModeNormalSource
Source of Normals.
bool containsAtomicDrawMode(const DrawMode &_atomicDrawMode) const
Check whether an Atomic DrawMode is active in this draw Mode.
DrawModeLightStage
Lighting stage of a mesh: unlit, smooth, phong.
const DrawModeProperties * getDrawModeProperties() const
returns the base properties of this draw mode
int getLayerIndex(const DrawModeProperties *_prop) const
returns layer index of a property, -1 if not in list
DrawMode SOLID_SMOOTH_SHADED_FEATURES
draw smooth shaded (Gouraud shaded) faces (requires halfedge normals)
DrawMode SOLID_FACES_COLORED_2DTEXTURED_FACE_SMOOTH_SHADED
draw per halfedge texture faces modulated with face colors with smooth shading
DrawMode SOLID_2DTEXTURED_FACE_SHADED
draw per halfedge textured faces
DrawMode HIDDENLINE
draw hidden line (2 rendering passes needed)
DrawMode UNUSED
marks the last used ID
DrawMode SOLID_SMOOTH_SHADED
draw smooth shaded (Gouraud shaded) faces (requires halfedge normals)
const std::string & name() const
Get the name of the DrawMode.
void addLayer(const DrawModeProperties *_props)
add another layer on top of this drawmode
DrawMode SOLID_3DTEXTURED
draw textured faces
bool drawModeExists(const std::string &_name)
Check if the given draw mode exists.
bool propertyBased_
Flag if the DrawMode is property based.
DrawMode SOLID_POINTS_COLORED_SHADED
draw faces, but use Gouraud shading to interpolate vertex colors
DrawMode HALFEDGES
draw halfedges
void name(const std::string &_name)
Set the name of the DrawMode.
DrawMode SOLID_PHONG_SHADED
draw phong shaded faces
DrawMode HALFEDGES_COLORED
draw halfedges with colors (without shading)
DrawMode DEFAULT
use the default (global) draw mode and not the node's own.
DrawMode SOLID_1DTEXTURED
draw textured faces
DrawMode SOLID_POINTS_COLORED
draw colored, but not lighted faces using interpolated vertex colors
void combine(DrawMode _mode)
combine with another drawmode
std::string description() const
const DrawMode & getDrawMode(const std::string &_name)
Get a custom DrawMode.
DrawModeTexCoordSource
Source of Texture Coordinates.
DrawMode SOLID_TEXTURED
draw textured faces
DrawMode SOLID_FACES_COLORED_FLAT_SHADED
draw flat shaded and colored faces (requires face normals and colors)
bool checkConsistency() const
checks consistency of property layers
DrawModeColorSource
Source of Primitive Colors.
DrawMode CELLS_COLORED
draw cells with colors (without shading)
const DrawMode & addDrawMode(const std::string &_name, bool _propertyBased)
Add a custom DrawMode.
std::vector< DrawMode > getAtomicDrawModes() const
Separates this drawMode into a list of all separate atomic draw modes.
DrawMode NONE
not a valid draw mode
DrawMode POINTS
draw unlighted points using the default base color
void filter(DrawMode _filter)
filter out one drawmode
DrawModeProperties stores a set of properties that defines, how to render an object.
void setDrawModeProperties(const DrawModeProperties *_props)
set the base properties of this draw mode
size_t getIndex() const
get an index of the current drawMode
DrawModeProperties properties_
The properties associated with this DrawMode.
DrawMode SOLID_FLAT_SHADED
draw flat shaded faces (requires face normals)
DrawMode SOLID_1DTEXTURED_SHADED
draw smooth shaded textured faces
DrawMode getDrawModeFromIndex(unsigned int _index)
given an index of an atomic draw mode, return the drawmode
DrawMode WIREFRAME
draw wireframe
DrawMode SOLID_FACES_COLORED
draw colored, but not lighted faces using face colors
DrawMode POINTS_COLORED
draw colored, but not lighted points (requires point colors)
Definition of a draw mode.
DrawMode EDGES_COLORED
draw edges with colors (without shading)
DrawMode id_
The id of the DrawMode.
DrawMode SOLID_TEXTURED_SHADED
draw smooth shaded textured faces
void initializeDefaultDrawModes(void)
const DrawModeProperties * getLayer(unsigned int _i) const
returns the property set at layer i
DrawMode SOLID_FACES_COLORED_SMOOTH_SHADED
draw smooth shaded and colored faces (requires vertex normals and face colors)
DrawMode POINTS_SHADED
draw shaded points (requires point normals)
size_t getNumLayers() const
returns the layer count
size_t maxModes() const
Get the number of maximum Modes which could be handled by the current implementation.