#include <OSGGraphOpSeq.h>
Public Member Functions | |
| void | setGraphOps (const std::string params) |
| void | addGraphOp (GraphOp *op) |
| void | removeGraphOp (GraphOp *op) |
| void | clearGraphOps (void) |
| UInt16 | getSize (void) |
| GraphOp * | getGraphOp (UInt16 index) |
| bool | setGraphOp (UInt16 index, GraphOp *op) |
| bool | removeGraphOp (UInt16 index) |
Constructors | |
| GraphOpSeq (void) | |
| GraphOpSeq (const std::string params) | |
Destructors | |
| ~GraphOpSeq (void) | |
Main methods | |
| bool | run (NodePtr &root) |
Static Public Member Functions | |
Class Get | |
| static const char * | getClassname (void) |
Private Member Functions | |
| UInt16 | extractStr (const std::string param, UInt16 spos, char *delim, std::string &result) |
Private Attributes | |
| std::vector< GraphOp * > | _GraphOperators |
| std::list< std::string > | _excludeNames |
A base class used to traverse geometries.
Definition at line 58 of file OSGGraphOpSeq.h.
| GraphOpSeq::GraphOpSeq | ( | void | ) |
Definition at line 72 of file OSGGraphOpSeq.cpp.
00072 : _GraphOperators(), _excludeNames() 00073 { 00074 }
| GraphOpSeq::GraphOpSeq | ( | const std::string | params | ) |
Definition at line 76 of file OSGGraphOpSeq.cpp.
References setGraphOps().
00076 : 00077 _GraphOperators(), _excludeNames() 00078 { 00079 setGraphOps(params); 00080 }
| GraphOpSeq::~GraphOpSeq | ( | void | ) |
| static const char* osg::GraphOpSeq::getClassname | ( | void | ) | [inline, static] |
| bool GraphOpSeq::run | ( | NodePtr & | root | ) |
Definition at line 86 of file OSGGraphOpSeq.cpp.
References _GraphOperators, and FWARNING.
Referenced by osg::SceneFileHandler::read(), and osg::SceneFileHandler::readTopNodes().
00087 { 00088 bool res=true; 00089 std::vector<GraphOp *>::iterator it=_GraphOperators.begin(); 00090 std::vector<GraphOp *>::iterator en=_GraphOperators.end(); 00091 00092 for ( ; it != en; ++it ) 00093 { 00094 bool b = (*it)->traverse(root); 00095 res = res & b; 00096 if (!b) 00097 FWARNING(("GraphOpSeq: GraphOp %s could not traverse the scene correctly\n",(*it)->getName().c_str())); 00098 } 00099 00100 return res; 00101 }
| void GraphOpSeq::setGraphOps | ( | const std::string | params | ) |
Creates the GraphOps automatically using a string. Every GraphOp has a special unique name. This name is how the GraphOp is recognized.
Format of the string: <GraphOpName1>(<param1>,<param2>,...,<paramN>) <GraphOpName2>() ... Basically you give a GraphOp name, then in brackets all parameters that should be passed to its setParams(...).
There are two special cases: Exclude and AddExclude The first one sets and the second one adds a new list of names.
P.S. There is no error handling to keep things simple. Pass as parameters only strings which can be processed correctly. Examples:
Exclude(Me,You) Verify(true) AddExclude(Us,Them) Merge() Exclude(All) Split(max_polygons=1500) Verify(repair=true) Exclude(Node1,Node2) Merge() Stripe(stitch=true force=true)
Definition at line 125 of file OSGGraphOpSeq.cpp.
References _excludeNames, _GraphOperators, osg::GraphOp::addToExcludeList(), osg::GraphOpFactory::create(), extractStr(), FDEBUG, FWARNING, osg::GraphOp::setParams(), and osg::GraphOpFactory::the().
Referenced by GraphOpSeq(), and osg::SceneFileHandler::SceneFileHandler().
00126 { 00127 UInt16 counter = 0; 00128 while (counter < params.length()) 00129 { 00130 //eat all intervals 00131 while (params[counter]==' ') 00132 counter++; 00133 00134 std::string command; 00135 counter = extractStr(params, counter, ")", command) + 1; 00136 FDEBUG(("command: %s\n", command.c_str())); 00137 00138 //extract the command from the substring 00139 std::string goname; 00140 UInt16 pos = extractStr(command, 0, "(", goname); 00141 FDEBUG(("GraphOpSeq::setGraphOps: goname: %s\n",goname.c_str())); 00142 00143 GraphOp * go = GraphOpFactory::the().create(goname.c_str()); 00144 if (go == NULL) 00145 { 00146 if (goname=="Exclude" || goname=="AddExclude") 00147 { 00148 if (goname=="Exclude") 00149 _excludeNames.clear(); 00150 00151 std::string cparams; 00152 extractStr(command, pos, ")", cparams); 00153 FDEBUG(("GraphOpSeq::setGraphOps: cparams: %s\n", cparams.c_str())); 00154 UInt16 i = 0; 00155 while(i < cparams.length()) 00156 { 00157 std::string ename; 00158 i = extractStr(cparams, i, ",", ename); 00159 _excludeNames.push_back(ename); 00160 FDEBUG(("GraphOpSeq::setGraphOps: ename: %s\n",ename.c_str())); 00161 } 00162 00163 } 00164 else 00165 FWARNING(("GraphOpSeq::setGraphOps: Invalid GraphOp name given: %s\n",goname.c_str())); 00166 } 00167 else 00168 { 00169 std::string goparams; 00170 extractStr(command, pos, ")", goparams); 00171 FDEBUG(("GraphOpSeq::setGraphOps: goparams: %s\n", goparams.c_str())); 00172 go->setParams(goparams); 00173 std::list<std::string>::iterator it=_excludeNames.begin(); 00174 for (; it!=_excludeNames.end(); ++it) 00175 { 00176 go->addToExcludeList(*it); 00177 FDEBUG(("GraphOpSeq::setGraphOps: Added to op: %s\n",(*it).c_str())); 00178 } 00179 _GraphOperators.push_back(go); 00180 } 00181 } 00182 }
| void GraphOpSeq::addGraphOp | ( | GraphOp * | op | ) |
Definition at line 184 of file OSGGraphOpSeq.cpp.
References _GraphOperators.
00185 { 00186 _GraphOperators.push_back(op); 00187 }
| void GraphOpSeq::removeGraphOp | ( | GraphOp * | op | ) |
Definition at line 189 of file OSGGraphOpSeq.cpp.
References _GraphOperators.
00190 { 00191 std::vector<GraphOp *>::iterator it=_GraphOperators.begin(); 00192 for (; it!=_GraphOperators.end(); ++it) 00193 if (*it==op) 00194 { 00195 _GraphOperators.erase(it); 00196 break; 00197 } 00198 }
| void GraphOpSeq::clearGraphOps | ( | void | ) |
Definition at line 200 of file OSGGraphOpSeq.cpp.
References _GraphOperators.
00201 { 00202 _GraphOperators.clear(); 00203 }
| UInt16 GraphOpSeq::getSize | ( | void | ) |
Definition at line 205 of file OSGGraphOpSeq.cpp.
References _GraphOperators.
Referenced by getGraphOp(), removeGraphOp(), and setGraphOp().
00206 { 00207 return _GraphOperators.size(); 00208 }
Definition at line 210 of file OSGGraphOpSeq.cpp.
References _GraphOperators, and getSize().
00211 { 00212 if (index<getSize()) 00213 return _GraphOperators[index]; 00214 else 00215 return NULL; 00216 }
Definition at line 218 of file OSGGraphOpSeq.cpp.
References _GraphOperators, and getSize().
00219 { 00220 if (index<getSize()) 00221 { 00222 _GraphOperators[index]=op; 00223 return true; 00224 } 00225 else 00226 return false; 00227 }
| bool GraphOpSeq::removeGraphOp | ( | UInt16 | index | ) |
Definition at line 229 of file OSGGraphOpSeq.cpp.
References _GraphOperators, and getSize().
00230 { 00231 if (index<getSize()) 00232 { 00233 _GraphOperators.erase(_GraphOperators.begin()+index); 00234 return true; 00235 } 00236 else 00237 return false; 00238 }
| UInt16 GraphOpSeq::extractStr | ( | const std::string | param, | |
| UInt16 | spos, | |||
| char * | delim, | |||
| std::string & | result | |||
| ) | [private] |
Definition at line 248 of file OSGGraphOpSeq.cpp.
Referenced by setGraphOps().
00250 { 00251 std::string::size_type pos = param.find(delim,spos); 00252 if (pos == std::string::npos) 00253 pos = param.length(); 00254 00255 result=param.substr(spos,pos-spos); 00256 return pos+1; 00257 }
std::vector<GraphOp *> osg::GraphOpSeq::_GraphOperators [private] |
Definition at line 109 of file OSGGraphOpSeq.h.
Referenced by addGraphOp(), clearGraphOps(), getGraphOp(), getSize(), removeGraphOp(), run(), setGraphOp(), and setGraphOps().
std::list<std::string> osg::GraphOpSeq::_excludeNames [private] |
1.5.5