Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

osg::VerifyGeoGraphOp Class Reference
[Geometry]

#include <OSGVerifyGeoGraphOp.h>

Inheritance diagram for osg::VerifyGeoGraphOp:

osg::SingleTypeGraphOp< Geometry > osg::GraphOp List of all members.

Public Member Functions

SingleTypeGraphOp (const char *name="")
Main methods
const std::string & getName (void)
void setName (const char *name)
Exclusion
*void addToExcludeList (NodePtr &node)
void addToExcludeList (const std::string &name)
void removeFromExcludeList (NodePtr &node)
void removeFromExcludeList (const std::string &name)
void clearExcludeList (void)
bool isInExcludeListNodes (NodePtr &node)
bool isInExcludeListNames (const std::string &name)
bool isInExcludeList (NodePtr &node)
Main methods
const std::string & getName (void)
void setName (const char *name)
Exclusion
*void addToExcludeList (NodePtr &node)
void addToExcludeList (const std::string &name)
void removeFromExcludeList (NodePtr &node)
void removeFromExcludeList (const std::string &name)
void clearExcludeList (void)
bool isInExcludeListNodes (NodePtr &node)
bool isInExcludeListNames (const std::string &name)
bool isInExcludeList (NodePtr &node)
Main methods
*virtual bool traverse (NodePtr &root)
const std::string & getName (void)
void setName (const char *name)
Exclusion
*void addToExcludeList (NodePtr &node)
void addToExcludeList (const std::string &name)
void removeFromExcludeList (NodePtr &node)
void removeFromExcludeList (const std::string &name)
void clearExcludeList (void)
bool isInExcludeListNodes (NodePtr &node)
bool isInExcludeListNames (const std::string &name)
bool isInExcludeList (NodePtr &node)
Constructors
VerifyGeoGraphOp (const char *name="Verify", bool repair=true)
GraphOpcreate ()
Destructors
*virtual ~VerifyGeoGraphOp (void)
Main methods
*void setParams (const std::string params)
void setRepair (bool repair)
std::string usage (void)
Main methods
*virtual bool traverse (NodePtr &root)
const std::string & getName (void)
void setName (const char *name)
Exclusion
*void addToExcludeList (NodePtr &node)
void addToExcludeList (const std::string &name)
void removeFromExcludeList (NodePtr &node)
void removeFromExcludeList (const std::string &name)
void clearExcludeList (void)
bool isInExcludeListNodes (NodePtr &node)
bool isInExcludeListNames (const std::string &name)
bool isInExcludeList (NodePtr &node)

Static Public Member Functions

Class Get
*static const char * getClassname (void)

Protected Member Functions

bool travNodeEnter (NodePtr node)
bool travNodeLeave (NodePtr node)

Protected Attributes

std::list< NodePtr_excludeListNodes
std::list< std::string > _excludeListNames

Private Attributes

bool _repair

Detailed Description

A base class used to traverse geometries.

Definition at line 59 of file OSGVerifyGeoGraphOp.h.


Constructor & Destructor Documentation

VerifyGeoGraphOp::VerifyGeoGraphOp const char *  name = "Verify",
bool  repair = true
 

Definition at line 70 of file OSGVerifyGeoGraphOp.cpp.

Referenced by create().

00070                                                                : 
00071     SingleTypeGraphOpGeo(name), _repair(repair)
00072 {
00073 }

VerifyGeoGraphOp::~VerifyGeoGraphOp void   )  [virtual]
 

Definition at line 75 of file OSGVerifyGeoGraphOp.cpp.

00076 {
00077 }


Member Function Documentation

* static const char* osg::VerifyGeoGraphOp::getClassname void   )  [inline, static]
 

Reimplemented from osg::SingleTypeGraphOp< Geometry >.

Definition at line 68 of file OSGVerifyGeoGraphOp.h.

00068 { return "VerifyGeoGraphOp"; };

GraphOp * VerifyGeoGraphOp::create  )  [virtual]
 

Implements osg::GraphOp.

Definition at line 79 of file OSGVerifyGeoGraphOp.cpp.

References VerifyGeoGraphOp().

00080 {
00081     VerifyGeoGraphOp *inst = new VerifyGeoGraphOp();
00082     return inst;
00083 }

void VerifyGeoGraphOp::setParams const std::string  params  )  [virtual]
 

Implements osg::GraphOp.

Definition at line 85 of file OSGVerifyGeoGraphOp.cpp.

References _repair, and FWARNING.

00086 {
00087     ParamSet ps(params);   
00088     
00089     ps("repair",  _repair);
00090     
00091     std::string out = ps.getUnusedParams();
00092     if(out.length())
00093     {
00094         FWARNING(("VerifyGeoGraphOp doesn't have parameters '%s'.\n",
00095                 out.c_str()));
00096     }
00097 }

void VerifyGeoGraphOp::setRepair bool  repair  ) 
 

Definition at line 109 of file OSGVerifyGeoGraphOp.cpp.

References _repair.

00110 {
00111     _repair = repair;
00112 }

std::string VerifyGeoGraphOp::usage void   )  [virtual]
 

Implements osg::GraphOp.

Definition at line 99 of file OSGVerifyGeoGraphOp.cpp.

00100 {
00101     return 
00102     "Verify: Test validity of Geometries\n"
00103     "  Run some validity tests on Geometries, makes sure indices are\n"
00104     "  in the valid range etc.\n"
00105     "Params: name (type, default)\n"
00106     "  repair (bool, true): try to repair consistency errors\n";
00107 }

bool VerifyGeoGraphOp::travNodeEnter NodePtr  node  )  [protected, virtual]
 

Implements osg::SingleTypeGraphOp< Geometry >.

Definition at line 114 of file OSGVerifyGeoGraphOp.cpp.

References _repair, osg::Action::Continue, osg::AttachmentContainerPtr::dcast(), FDEBUG, FWARNING, osg::GeometryBase::getClassType(), osg::NodePtr::getCore(), osg::NodeCore::getType(), osg::FieldContainerType::isDerivedFrom(), osg::Geometry::MapColor, osg::Geometry::MapNormal, osg::Geometry::MapPosition, osg::Geometry::MapSecondaryColor, osg::Geometry::MapTexCoords, osg::Geometry::MapTexCoords1, osg::Geometry::MapTexCoords2, osg::Geometry::MapTexCoords3, osg::NullFC, osg::osgMin(), and osg::Action::Quit.

00115 {
00116     if (!node->getCore()->getType().isDerivedFrom(Geometry::getClassType()))
00117     {
00118         FWARNING(("VerifyGeoOp: travNodeEnter got a non-Geometry Node\n"));
00119         return false;
00120     }
00121 
00122     bool _verified = true;
00123 
00124     GeometryPtr geo=GeometryPtr::dcast(node->getCore());
00125 
00126     if(geo->getTypes() != NullFC && geo->getTypes()->size() == 0)
00127     {
00128         if (_repair)
00129         {
00130             //geo->setTypes(NullFC);
00131         }
00132         else
00133         {
00134             //_verified = false;
00135         }
00136     }        
00137 
00138     if(geo->getLengths() != NullFC && geo->getLengths()->size() == 0)
00139     {
00140         if (_repair)
00141         {
00142             //geo->setLengths(NullFC);
00143         }
00144         else
00145         {
00146             //_verified = false;
00147         }
00148     }
00149 
00150     if(geo->getPositions() != NullFC && geo->getPositions()->size() == 0)
00151     {
00152         if (_repair)
00153             geo->setPositions(NullFC);
00154         else
00155         {
00156             _verified = false;
00157         }
00158     }
00159 
00160     if(geo->getNormals() != NullFC && geo->getNormals()->size() == 0)
00161     {
00162         if (_repair)
00163             geo->setNormals(NullFC);
00164         else
00165         {
00166             _verified = false;
00167         }
00168     }
00169 
00170     if(geo->getColors() != NullFC && geo->getColors()->size() == 0)
00171     {
00172         if (_repair)
00173             geo->setColors(NullFC);
00174         else
00175         {
00176             _verified = false;
00177         }
00178     }
00179 
00180     if(geo->getSecondaryColors() != NullFC && geo->getSecondaryColors()->size() == 0)
00181     {
00182         if (_repair)
00183             geo->setSecondaryColors(NullFC);
00184         else
00185         {
00186             _verified = false;
00187         }
00188     }
00189 
00190     if(geo->getTexCoords() != NullFC && geo->getTexCoords()->size() == 0)
00191     {
00192         if (_repair)
00193             geo->setTexCoords(NullFC);
00194         else
00195         {
00196             _verified = false;
00197         }
00198     }
00199 
00200     if(geo->getTexCoords1() != NullFC && geo->getTexCoords1()->size() == 0)
00201     {
00202         if (_repair)
00203             geo->setTexCoords1(NullFC);
00204         else
00205         {
00206             _verified = false;
00207         }
00208     }
00209 
00210     if(geo->getTexCoords2() != NullFC && geo->getTexCoords2()->size() == 0)
00211     {
00212         if (_repair)
00213             geo->setTexCoords2(NullFC);
00214         else
00215         {
00216             _verified = false;
00217         }
00218     }
00219 
00220     if(geo->getTexCoords3() != NullFC && geo->getTexCoords3()->size() == 0)
00221     {
00222         if (_repair)
00223             geo->setTexCoords3(NullFC);
00224         else
00225         {
00226             _verified = false;
00227         }
00228     }
00229 
00230     bool consistent=true;
00231     int i, mind;
00232 
00233     GeoIndicesPtr ind = geo->getIndices();
00234     UInt16 nmap = geo->getIndexMapping().size();
00235 
00236     if (nmap==0) return Action::Continue;
00237 
00238     UInt32* sizes = new UInt32[nmap];
00239     for (i=0; i<nmap; i++) sizes[i]=UInt32(-1);
00240 
00241     if ( ( mind = geo->calcMappingIndex( Geometry::MapPosition ) ) >= 0 )
00242     {
00243         if (geo->getPositions()!=NullFC)
00244             sizes[ mind ] = osgMin ( sizes[ mind ], geo->getPositions()->size() );
00245         else
00246         {
00247             if (_repair)
00248             {
00249                 UInt16 &im = geo->getIndexMapping(mind);
00250                 im &=~( Geometry::MapPosition );                
00251             }
00252             else
00253             {
00254                 _verified = false;
00255                 FDEBUG(("calcMappingIndex>=0, getPositions = NullFC\n"));
00256             }
00257         }
00258     }
00259 
00260     if ( ( mind = geo->calcMappingIndex( Geometry::MapNormal ) ) >= 0 )
00261     {
00262         if (geo->getNormals()!=NullFC)
00263             sizes[ mind ] = osgMin ( sizes[ mind ], geo->getNormals()->size() );
00264         else
00265         {
00266             if (_repair)
00267             {
00268                 UInt16 &im = geo->getIndexMapping(mind);
00269                 im &=~( Geometry::MapNormal );                
00270             }
00271             else
00272             {
00273                 _verified = false;
00274                 FDEBUG(("calcMappingIndex>=0, getNormals = NullFC\n"));
00275             }                
00276         }
00277     }
00278 
00279     if ( ( mind = geo->calcMappingIndex( Geometry::MapColor ) ) >= 0 )
00280     {
00281         if (geo->getColors()!=NullFC)
00282             sizes[ mind ] = osgMin ( sizes[ mind ], geo->getColors()->size() );
00283         else
00284         {
00285             if (_repair)
00286             {
00287                 UInt16 &im = geo->getIndexMapping(mind);
00288                 im &=~( Geometry::MapColor );                
00289             }
00290             else
00291             {
00292                 _verified = false;
00293                 FDEBUG(("calcMappingIndex>=0, getColors = NullFC\n"));
00294             }                
00295         }                
00296     }
00297 
00298     if ( ( mind = geo->calcMappingIndex( Geometry::MapSecondaryColor ) ) >= 0 )
00299     {
00300         if (geo->getSecondaryColors()!=NullFC)
00301             sizes[ mind ] = osgMin ( sizes[ mind ], geo->getSecondaryColors()->size() );
00302         else
00303         {
00304             if (_repair)
00305             {
00306                 UInt16 &im = geo->getIndexMapping(mind);
00307                 im &=~( Geometry::MapSecondaryColor );                
00308             }
00309             else
00310             {
00311                 _verified = false;
00312                 FDEBUG(("calcMappingIndex>=0, getSecondaryColors = NullFC\n"));
00313             }                
00314         }
00315     }
00316 
00317     if ( ( mind = geo->calcMappingIndex( Geometry::MapTexCoords ) ) >= 0 )
00318     {
00319         if (geo->getTexCoords()!=NullFC)
00320             sizes[ mind ] = osgMin ( sizes[ mind ], geo->getTexCoords()->size() );
00321         else
00322         {
00323             if (_repair)
00324             {
00325                 UInt16 &im = geo->getIndexMapping(mind);
00326                 im &=~( Geometry::MapTexCoords );                
00327             }
00328             else
00329             {
00330                 _verified = false;
00331                 FDEBUG(("calcMappingIndex>=0, getTexCoords = NullFC\n"));
00332             }                
00333         }
00334     }
00335 
00336     if ( ( mind = geo->calcMappingIndex( Geometry::MapTexCoords1 ) ) >= 0 )
00337     {
00338         if (geo->getTexCoords1()!=NullFC)
00339             sizes[ mind ] = osgMin ( sizes[ mind ], geo->getTexCoords1()->size() );
00340         else
00341         {
00342             if (_repair)
00343             {
00344                 UInt16 &im = geo->getIndexMapping(mind);
00345                 im &=~( Geometry::MapTexCoords1 );                
00346             }
00347             else
00348             {
00349                 _verified = false;
00350                 FDEBUG(("calcMappingIndex>=0, getTexCoords1 = NullFC\n"));
00351             }                
00352         }
00353                 
00354     }
00355 
00356     if ( ( mind = geo->calcMappingIndex( Geometry::MapTexCoords2 ) ) >= 0 )
00357     {
00358         if (geo->getTexCoords2()!=NullFC)
00359             sizes[ mind ] = osgMin ( sizes[ mind ], geo->getTexCoords2()->size() );
00360         else
00361         {
00362             if (_repair)
00363             {
00364                 UInt16 &im = geo->getIndexMapping(mind);
00365                 im &=~( Geometry::MapTexCoords2 );                
00366             }
00367             else
00368             {
00369                 _verified = false;
00370                 FDEBUG(("calcMappingIndex>=0, getTexCoords2 = NullFC\n"));
00371             }                
00372         }
00373                 
00374     }
00375 
00376     if ( ( mind = geo->calcMappingIndex( Geometry::MapTexCoords3 ) ) >= 0 )
00377     {
00378         if (geo->getTexCoords3()!=NullFC)
00379             sizes[ mind ] = osgMin ( sizes[ mind ], geo->getTexCoords3()->size() );
00380         else
00381         {
00382             if (_repair)
00383             {
00384                 UInt16 &im = geo->getIndexMapping(mind);
00385                 im &=~( Geometry::MapTexCoords3 );                
00386             }
00387             else
00388             {
00389                 _verified = false;
00390                 FDEBUG(("calcMappingIndex>=0, getTexCoords3 = NullFC\n"));
00391             }                
00392         }                
00393     }
00394 
00395     for (UInt32 j=0; j<ind->size(); j++)
00396         if (ind->getValue(j)>=sizes[j % nmap])
00397         {
00398             if (_repair)
00399             {
00400                 ind->setValue(0,j);
00401             }
00402             else
00403             {
00404                 consistent = false; break;
00405             }
00406         }
00407 
00408     _verified = (_verified && (_repair | consistent) );
00409 
00410     if (_verified)
00411         return Action::Continue;
00412     else
00413         return Action::Quit;
00414 }

bool VerifyGeoGraphOp::travNodeLeave NodePtr  node  )  [protected, virtual]
 

Implements osg::SingleTypeGraphOp< Geometry >.

Definition at line 416 of file OSGVerifyGeoGraphOp.cpp.

00417 {
00418     return true;
00419 }

* osg::SingleTypeGraphOp< Geometry >::SingleTypeGraphOp const char *  name = ""  )  [inherited]
 

bool GraphOp::traverse NodePtr root  )  [virtual, inherited]
 

Reimplemented in osg::MakeTransparentGraphOp, osg::MaterialMergeGraphOp, osg::MergeGraphOp, osg::SharePtrGraphOp, osg::SplitGraphOp, and osg::VerifyGraphOp.

Definition at line 94 of file OSGGraphOp.cpp.

References osg::Action::Continue, osg::osgTypedMethodFunctor1ObjPtrCPtrRef(), osg::osgTypedMethodFunctor2ObjPtrCPtrRef(), osg::GraphOp::traverseEnter(), and osg::GraphOp::traverseLeave().

Referenced by osg::VerifyGraphOp::traverse(), osg::MaterialMergeGraphOp::traverse(), and osg::MakeTransparentGraphOp::traverse().

00095 {
00096     Action::ResultE res;
00097     res = ::traverse(node,
00098           osgTypedMethodFunctor1ObjPtrCPtrRef<Action::ResultE,
00099           GraphOp,
00100           NodePtr>(this,&GraphOp::traverseEnter),
00101           osgTypedMethodFunctor2ObjPtrCPtrRef<Action::ResultE,
00102           GraphOp,
00103           NodePtr,
00104           Action::ResultE>(this,&GraphOp::traverseLeave));
00105 
00106     if (res == Action::Continue) 
00107         return true;
00108     else 
00109         return false;
00110 }

const std::string & GraphOp::getName void   )  [inherited]
 

Definition at line 112 of file OSGGraphOp.cpp.

References osg::GraphOp::_name.

Referenced by osg::GraphOpFactory::registerOp(), and osg::GraphOpFactory::unRegisterOp().

00113 {
00114     return _name;
00115 };

void GraphOp::setName const char *  name  )  [inherited]
 

Definition at line 117 of file OSGGraphOp.cpp.

References osg::GraphOp::_name.

00118 {
00119     _name = name;
00120 };

void GraphOp::addToExcludeList NodePtr node  )  [inherited]
 

Definition at line 124 of file OSGGraphOp.cpp.

References osg::GraphOp::_excludeListNodes, and osg::GraphOp::isInExcludeListNodes().

Referenced by osg::MergeGraphOp::excludeListLeave(), and osg::GraphOpSeq::setGraphOps().

00125 {
00126     if (!isInExcludeListNodes(node))
00127         _excludeListNodes.push_back(node);
00128 }

void GraphOp::addToExcludeList const std::string &  name  )  [inherited]
 

Definition at line 130 of file OSGGraphOp.cpp.

References osg::GraphOp::_excludeListNames, and osg::GraphOp::isInExcludeListNames().

00131 {
00132     if (!isInExcludeListNames(name))
00133         _excludeListNames.push_back(name);
00134 }

void GraphOp::removeFromExcludeList NodePtr node  )  [inherited]
 

Definition at line 136 of file OSGGraphOp.cpp.

References osg::GraphOp::_excludeListNodes.

00137 {
00138     _excludeListNodes.remove(node);
00139 }

void GraphOp::removeFromExcludeList const std::string &  name  )  [inherited]
 

Definition at line 141 of file OSGGraphOp.cpp.

References osg::GraphOp::_excludeListNames.

00142 {
00143     _excludeListNames.remove(name);
00144 }

void GraphOp::clearExcludeList void   )  [inherited]
 

Definition at line 146 of file OSGGraphOp.cpp.

References osg::GraphOp::_excludeListNames, and osg::GraphOp::_excludeListNodes.

00147 {
00148     _excludeListNames.clear();
00149     _excludeListNodes.clear();
00150 }

bool GraphOp::isInExcludeListNodes NodePtr node  )  [inherited]
 

Definition at line 152 of file OSGGraphOp.cpp.

References osg::GraphOp::_excludeListNodes.

Referenced by osg::GraphOp::addToExcludeList(), and osg::GraphOp::isInExcludeList().

00153 {
00154     std::list<NodePtr>::iterator list_iter;
00155     list_iter = std::find(_excludeListNodes.begin(),_excludeListNodes.end(),node);
00156 
00157     if (list_iter==_excludeListNodes.end()) 
00158         return false;
00159     else 
00160         return true;
00161 }

bool GraphOp::isInExcludeListNames const std::string &  name  )  [inherited]
 

Definition at line 163 of file OSGGraphOp.cpp.

References osg::GraphOp::_excludeListNames.

Referenced by osg::GraphOp::addToExcludeList(), and osg::GraphOp::isInExcludeList().

00164 {
00165     std::list<std::string>::iterator namelist_iter;
00166     namelist_iter = std::find(_excludeListNames.begin(),_excludeListNames.end(),name);
00167 
00168     if (namelist_iter==_excludeListNames.end()) 
00169         return false;
00170     else 
00171         return true;
00172 }

bool GraphOp::isInExcludeList NodePtr node  )  [inherited]
 

Definition at line 174 of file OSGGraphOp.cpp.

References osg::getName(), osg::GraphOp::isInExcludeListNames(), and osg::GraphOp::isInExcludeListNodes().

Referenced by osg::MergeGraphOp::processGeometries(), osg::MergeGraphOp::processGroups(), osg::MergeGraphOp::processTransformations(), osg::SplitGraphOp::splitNode(), and osg::SplitGraphOp::traverseLeave().

00175 {
00176     if (isInExcludeListNodes(node) || (OSG::getName(node)!=NULL && isInExcludeListNames(OSG::getName(node))))
00177         return true;
00178     else
00179         return false;
00180 }


Member Data Documentation

bool osg::VerifyGeoGraphOp::_repair [private]
 

Definition at line 107 of file OSGVerifyGeoGraphOp.h.

Referenced by setParams(), setRepair(), and travNodeEnter().

std::list<NodePtr> osg::GraphOp::_excludeListNodes [protected, inherited]
 

Definition at line 161 of file OSGGraphOp.h.

Referenced by osg::GraphOp::addToExcludeList(), osg::GraphOp::clearExcludeList(), osg::GraphOp::isInExcludeListNodes(), osg::MergeGraphOp::mergeOnce(), and osg::GraphOp::removeFromExcludeList().

std::list<std::string> osg::GraphOp::_excludeListNames [protected, inherited]
 

Definition at line 162 of file OSGGraphOp.h.

Referenced by osg::GraphOp::addToExcludeList(), osg::GraphOp::clearExcludeList(), osg::GraphOp::isInExcludeListNames(), and osg::GraphOp::removeFromExcludeList().


The documentation for this class was generated from the following files:
Generated on Thu Aug 25 04:14:12 2005 for OpenSG by  doxygen 1.4.3