62 #include "DrawModes.hh" 63 #include "BaseNode.hh" 85 DrawMode FACES = ModeFlagSet(1) << 7;
106 DrawMode CELLS = ModeFlagSet(1) << 28;
138 void name(
const std::string& _name) {
143 const std::string&
name()
const {
151 bool propertyBased()
const {
168 typedef std::vector< DrawModeInternal > VecDrawModes;
172 static VecDrawModes registeredDrawModes_;
184 envMapped_(_envMapping),
185 primitive_(_primitive),
186 lightStage_(_lightStage),
187 colorSource_(_colorSource),
188 texcoordSource_(_texcoordSource),
189 normalSource_(_normalSource)
194 DrawMode::DrawMode(
size_t _index)
197 if ( _index >= modeFlags_.size() ) {
198 std::cerr <<
"Illegal drawMode specification from unsigned int. This should not be a bitset!!!" << std::endl;
200 modeFlags_.set(_index);
206 DrawMode::DrawMode() {
211 DrawMode::DrawMode(ModeFlagSet _flags) :
218 DrawMode DrawMode::getFromDescription(std::string _description)
222 std::istringstream f(_description);
224 while (std::getline(f, s,
'+')) {
225 VecDrawModes::const_iterator modeIter, modeEnd( registeredDrawModes_.end() );
226 for( modeIter = registeredDrawModes_.begin(); modeIter != modeEnd; ++modeIter ) {
227 if(modeIter->name() == s) {
228 val |= modeIter->id();
238 DrawMode::operator bool()
const {
239 return( modeFlags_ != NONE.modeFlags_ );
274 bool DrawMode::operator==(
const DrawMode& _mode)
const {
275 return modeFlags_ == _mode.modeFlags_;
280 modeFlags_ = _mode.modeFlags_;
287 bool DrawMode::operator!=(
const DrawMode& _mode2 )
const {
288 return (modeFlags_ != _mode2.modeFlags_);
292 if ( modeFlags_.count() != 1 ) {
293 std::cerr <<
"Operator ++ for drawMode which is not atomic!!" << std::endl;
302 DrawMode andMode = (modeFlags_ & _mode.modeFlags_);
310 for (
int i = (
int)andMode.
getNumLayers() - 1; i >= 0; --i)
322 modeFlags_ |= _mode2.modeFlags_;
324 for (
unsigned int i = 0; i < _mode2.
getNumLayers(); ++i)
333 modeFlags_ &= _mode2.modeFlags_;
350 DrawMode combined = ( modeFlags_ | _mode2.modeFlags_ );
357 for (
unsigned int i = 0; i < _mode2.
getNumLayers(); ++i)
365 DrawMode xorMode = ( modeFlags_ ^ _mode2.modeFlags_ );
373 std::vector<const DrawModeProperties*> tmpLayers;
382 tmpLayers.push_back(curProps);
387 for (
unsigned int i = 0; i < _mode2.
getNumLayers(); ++i)
391 if (!curProps)
continue;
398 for (
unsigned int k = 0; addToVec && k < tmpLayers.size(); ++k)
403 tmpLayers.erase(tmpLayers.begin() + k);
409 tmpLayers.push_back(curProps);
415 if (tmpLayers.empty())
425 for (
unsigned int i = 1; i < tmpLayers.size(); ++i)
434 DrawMode DrawMode::operator~( )
const {
435 return( ~modeFlags_ );
441 if ( modeFlags_.count() == 1 ) {
442 for (
size_t i = 0 ; i < modeFlags_.size() ; ++i )
452 std::string text(
"");
454 VecDrawModes::const_iterator modeIter, modeEnd( registeredDrawModes_.end() );
455 for( modeIter = registeredDrawModes_.begin(); modeIter != modeEnd; ++modeIter )
457 if( (*
this) & modeIter->id() )
459 if (!text.empty()) text +=
"+";
460 text += modeIter->name();
471 modeFlags_ = (modeFlags_ | _filter.modeFlags_) ^ _filter.modeFlags_;
473 for (
unsigned int i = 0; i < _filter.
getNumLayers(); ++i)
488 modeFlags_ = (modeFlags_ ^ _mode.modeFlags_);
500 std::vector< DrawMode >
503 std::vector< DrawMode > draw_mode_ids;
505 VecDrawModes::const_iterator modeIter, modeEnd( registeredDrawModes_.end() );
506 for( modeIter = registeredDrawModes_.begin();
509 if( (*
this) & modeIter->id() )
510 draw_mode_ids.push_back( modeIter->id() );
512 return draw_mode_ids;
519 return(modeFlags_.count() == 1 );
528 return (*
this) & _atomicDrawMode;
534 return (modeFlags_.size() );
583 for (
unsigned int i = 0; i <
layers_.size(); ++i)
585 for (
unsigned int k = i+1; k <
layers_.size(); ++k)
603 for (
unsigned int k = 0; k <
layers_.size(); ++k)
605 if (
layers_[k].primitive() == PRIMITIVE_POINT)
619 if (!_prop)
return -1;
621 for (
unsigned int i = 0; i <
layers_.size(); ++i)
634 for (
unsigned int i = 0; i <
layers_.size(); ++i)
636 if (
layers_[i].primitive() == _type )
647 static bool initialized_ =
false;
652 registeredDrawModes_.clear();
710 registeredDrawModes_.push_back( DrawModeInternal(
"<invalid>", NONE ) );
711 registeredDrawModes_.push_back( DrawModeInternal(
"Default", DEFAULT ) );
713 registeredDrawModes_.push_back( DrawModeInternal(
"Points", POINTS ) );
714 registeredDrawModes_.push_back( DrawModeInternal(
"Points (colored)", POINTS_COLORED ) );
715 registeredDrawModes_.push_back( DrawModeInternal(
"Points (shaded)", POINTS_SHADED ) );
717 registeredDrawModes_.push_back( DrawModeInternal(
"Edges", EDGES ) );
718 registeredDrawModes_.push_back( DrawModeInternal(
"Edges Colored", EDGES_COLORED ) );
720 registeredDrawModes_.push_back( DrawModeInternal(
"Wireframe", WIREFRAME ) );
722 registeredDrawModes_.push_back( DrawModeInternal(
"Faces", FACES ) );
724 registeredDrawModes_.push_back( DrawModeInternal(
"Hiddenline", HIDDENLINE ) );
726 registeredDrawModes_.push_back( DrawModeInternal(
"Solid (flat shaded)", SOLID_FLAT_SHADED ) );
727 registeredDrawModes_.push_back( DrawModeInternal(
"Solid (smooth shaded)", SOLID_SMOOTH_SHADED ) );
728 registeredDrawModes_.push_back( DrawModeInternal(
"Solid (Phong shaded)", SOLID_PHONG_SHADED ) );
730 registeredDrawModes_.push_back( DrawModeInternal(
"Solid (colored per-face)", SOLID_FACES_COLORED ) );
731 registeredDrawModes_.push_back( DrawModeInternal(
"Solid (colored per-vertex)", SOLID_POINTS_COLORED ) );
732 registeredDrawModes_.push_back( DrawModeInternal(
"Solid (colored per-vertex, shaded)", SOLID_POINTS_COLORED_SHADED ) );
734 registeredDrawModes_.push_back( DrawModeInternal(
"Solid (environment mapped)", SOLID_ENV_MAPPED ) );
736 registeredDrawModes_.push_back( DrawModeInternal(
"Solid (textured)", SOLID_TEXTURED ) );
737 registeredDrawModes_.push_back( DrawModeInternal(
"Solid (textured, shaded)", SOLID_TEXTURED_SHADED ) );
739 registeredDrawModes_.push_back( DrawModeInternal(
"Solid (scalar field)", SOLID_1DTEXTURED ) );
740 registeredDrawModes_.push_back( DrawModeInternal(
"Solid (scalar field, shaded)", SOLID_1DTEXTURED_SHADED ) );
742 registeredDrawModes_.push_back( DrawModeInternal(
"Solid (3D textured)", SOLID_3DTEXTURED ) );
743 registeredDrawModes_.push_back( DrawModeInternal(
"Solid (3D textured, shaded)", SOLID_3DTEXTURED_SHADED ) );
745 registeredDrawModes_.push_back( DrawModeInternal(
"Solid (colored per-face, flat shaded)", SOLID_FACES_COLORED_FLAT_SHADED ) );
746 registeredDrawModes_.push_back( DrawModeInternal(
"Solid (colored per-face, smooth shaded)", SOLID_FACES_COLORED_SMOOTH_SHADED ) );
748 registeredDrawModes_.push_back(DrawModeInternal(
"Solid (colored per-face, face textured, smooth shaded)", SOLID_FACES_COLORED_2DTEXTURED_FACE_SMOOTH_SHADED));
751 registeredDrawModes_.push_back( DrawModeInternal(
"Solid (face textured)", SOLID_2DTEXTURED_FACE ) );
752 registeredDrawModes_.push_back( DrawModeInternal(
"Solid (face textured, shaded)", SOLID_2DTEXTURED_FACE_SHADED ) );
753 registeredDrawModes_.push_back( DrawModeInternal(
"Shader controlled", SOLID_SHADER ) );
755 registeredDrawModes_.push_back( DrawModeInternal(
"Solid (smooth shaded, features)", SOLID_SMOOTH_SHADED_FEATURES ) );
757 registeredDrawModes_.push_back( DrawModeInternal(
"Cells", CELLS ) );
758 registeredDrawModes_.push_back( DrawModeInternal(
"Cells Colored", CELLS_COLORED ) );
760 registeredDrawModes_.push_back( DrawModeInternal(
"Halfedges", HALFEDGES ) );
761 registeredDrawModes_.push_back( DrawModeInternal(
"Halfedges Colored", HALFEDGES_COLORED ) );
774 VecDrawModes::iterator modeIter, modeEnd( registeredDrawModes_.end() );
776 for( modeIter = registeredDrawModes_.begin(); modeIter != modeEnd; ++modeIter ) {
777 if( _name == modeIter->name() ) {
778 return modeIter->id();
784 registeredDrawModes_.push_back( DrawModeInternal( _name, firstFreeID_ , _propertyBased) );
787 return registeredDrawModes_[ registeredDrawModes_.size() - 1 ].id();
798 VecDrawModes::iterator modeIter, modeEnd( registeredDrawModes_.end() );
800 for( modeIter = registeredDrawModes_.begin(); modeIter != modeEnd; ++modeIter ) {
801 if( _name == modeIter->name() ) {
802 modeIter->properties() = _properties;
816 VecDrawModes::const_iterator modeIter, modeEnd( registeredDrawModes_.end() );
818 for( modeIter = registeredDrawModes_.begin(); modeIter != modeEnd; ++modeIter )
820 if( _name == modeIter->name() )
822 return modeIter->id();
833 VecDrawModes::const_iterator modeIter, modeEnd( registeredDrawModes_.end() );
835 for( modeIter = registeredDrawModes_.begin(); modeIter != modeEnd; ++modeIter )
837 if( _name == modeIter->name() )
ACGDLLEXPORT DrawMode NONE
not a valid draw mode
DrawMode POINTS_COLORED
draw colored, but not lighted points (requires point colors)
DrawModeNormalSource
Source of Normals.
const std::string & name() const
Get the name of the DrawMode.
bool removeLayer(unsigned int _i)
remove layer at index i
DrawMode SOLID_SMOOTH_SHADED
draw smooth shaded (Gouraud shaded) faces (requires halfedge normals)
DrawMode SOLID_POINTS_COLORED_SHADED
draw faces, but use Gouraud shading to interpolate vertex colors
DrawMode HIDDENLINE
draw hidden line (2 rendering passes needed)
DrawMode SOLID_FLAT_SHADED
draw flat shaded faces (requires face normals)
DrawModeProperties stores a set of properties that defines, how to render an object.
const DrawModeProperties * getDrawModeProperties() const
returns the base properties of this draw mode
DrawMode SOLID_1DTEXTURED_SHADED
draw smooth shaded textured faces
std::vector< DrawModeProperties > layers_
DrawMode DEFAULT
use the default (global) draw mode and not the node's own.
DrawMode WIREFRAME
draw wireframe
DrawMode HALFEDGES
draw halfedges
bool checkConsistency() const
checks consistency of property layers
size_t getIndex() const
get an index of the current drawMode
DrawMode SOLID_FACES_COLORED_SMOOTH_SHADED
draw smooth shaded and colored faces (requires vertex normals and face colors)
DrawMode HALFEDGES_COLORED
draw halfedges with colors (without shading)
ACGDLLEXPORT DrawMode POINTS
draw unlighted points using the default base color
DrawMode id_
The id of the DrawMode.
DrawMode CELLS_COLORED
draw cells with colors (without shading)
size_t getNumLayers() const
returns the layer count
DrawMode SOLID_3DTEXTURED
draw textured faces
DrawMode SOLID_2DTEXTURED_FACE
draw per halfedge textured faces
int getLayerIndex(const DrawModeProperties *_prop) const
returns layer index of a property, -1 if not in list
std::string name_
Human Readable Name.
DrawModeColorSource
Source of Primitive Colors.
ACGDLLEXPORT const DrawMode & getDrawMode(const std::string &_name)
Get a custom DrawMode.
ACGDLLEXPORT void initializeDefaultDrawModes(void)
DrawMode SOLID_FACES_COLORED_FLAT_SHADED
draw flat shaded and colored faces (requires face normals and colors)
DrawMode SOLID_2DTEXTURED_FACE_SHADED
draw per halfedge textured faces
void combine(DrawMode _mode)
combine with another drawmode
ACGDLLEXPORT DrawMode UNUSED
marks the last used ID
DrawMode POINTS
draw unlighted points using the default base color
ACGDLLEXPORT const DrawMode & addDrawMode(const std::string &_name, bool _propertyBased=false)
Add a custom DrawMode.
DrawModeTexCoordSource
Source of Texture Coordinates.
DrawMode SOLID_FACES_COLORED_2DTEXTURED_FACE_SMOOTH_SHADED
draw per halfedge texture faces modulated with face colors with smooth shading
Definition of a draw mode.
std::vector< DrawMode > getAtomicDrawModes() const
Separates this drawMode into a list of all separate atomic draw modes.
DrawMode SOLID_TEXTURED
draw textured faces
DrawMode SOLID_FACES_COLORED
draw colored, but not lighted faces using face colors
void filter(DrawMode _filter)
filter out one drawmode
bool isAtomic() const
Check if this is an atomic draw Mode.
DrawMode SOLID_PHONG_SHADED
draw phong shaded faces
DrawModeLightStage
Lighting stage of a mesh: unlit, smooth, phong.
DrawMode EDGES_COLORED
draw edges with colors (without shading)
DrawMode POINTS_SHADED
draw shaded points (requires point normals)
DrawModePrimitive
Primitive mode of a mesh.
ACGDLLEXPORT DrawMode POINTS_SHADED
draw shaded points (requires point normals)
Namespace providing different geometric functions concerning angles.
DrawMode SOLID_SMOOTH_SHADED_FEATURES
draw smooth shaded (Gouraud shaded) faces (requires halfedge normals)
DrawModePrimitive
Primitive mode of a mesh.
bool propertyBased_
Flag if the DrawMode is property based.
DrawMode NONE
not a valid draw mode
DrawMode SOLID_ENV_MAPPED
draw environment mapped
DrawMode UNUSED
marks the last used ID
void addLayer(const DrawModeProperties *_props)
add another layer on top of this drawmode
DrawMode SOLID_1DTEXTURED
draw textured faces
size_t maxModes() const
Get the number of maximum Modes which could be handled by the current implementation.
DrawMode SOLID_POINTS_COLORED
draw colored, but not lighted faces using interpolated vertex colors
void setDrawModeProperties(const DrawModeProperties *_props)
set the base properties of this draw mode
DrawMode SOLID_3DTEXTURED_SHADED
draw smooth shaded textured faces
ACGDLLEXPORT DrawMode DEFAULT
use the default (global) draw mode and not the node's own.
std::string description() const
ACGDLLEXPORT DrawMode POINTS_COLORED
draw colored, but not lighted points (requires point colors)
bool containsAtomicDrawMode(DrawMode _atomicDrawMode) const
Check whether an Atomic DrawMode is active in this draw Mode.
DrawMode SOLID_TEXTURED_SHADED
draw smooth shaded textured faces
ACGDLLEXPORT bool drawModeExists(const std::string &_name)
Check if the given draw mode exists.
DrawModeProperties stores a set of properties that defines, how to render an object.
DrawModeProperties properties_
The properties associated with this DrawMode.
int getLayerIndexByPrimitive(DrawModePrimitive _type) const
search for layer with specified primitive
ACGDLLEXPORT DrawMode getDrawModeFromIndex(unsigned int _index)
given an index of an atomic draw mode, return the drawmode
void name(const std::string &_name)
Set the name of the DrawMode.
DrawModeInternal(const std::string &_name, const DrawMode &_id, const bool _propertyBased=false)
const DrawModeProperties * getLayer(unsigned int _i) const
returns the property set at layer i