#include <OSGPruneGraphOp.h>
Public Types | |
| enum | Method { VOLUME, SUM_OF_DIMENSIONS } |
Public Member Functions | |
| PruneGraphOp (float size=1.0f, Method method=SUM_OF_DIMENSIONS, const char *name="Prune") | |
| GraphOp * | create () |
| void | setParams (const std::string params) |
| std::string | usage (void) |
Main methods | |
| virtual bool | traverse (NodePtr &root) |
| const std::string & | getName (void) |
| void | setName (const char *name) |
Exclusion | |
| void | addToExcludeList (const NodePtr &node) |
| void | addToExcludeList (const std::string &name) |
| void | removeFromExcludeList (NodePtr &node) |
| void | removeFromExcludeList (const std::string &name) |
| void | clearExcludeList (void) |
| bool | isInExcludeListNodes (const NodePtr &node) |
| bool | isInExcludeListNames (const std::string &name) |
| bool | isInExcludeList (NodePtr &node) |
Static Public Member Functions | |
| static const char * | getClassname (void) |
Protected Attributes | |
| std::list< NodePtr > | _excludeListNodes |
| std::list< std::string > | _excludeListNames |
Private Member Functions | |
| Action::ResultE | traverseEnter (NodePtr &node) |
| Action::ResultE | traverseLeave (NodePtr &node, Action::ResultE res) |
| bool | isTooSmall (const NodePtr &node) |
| float | getSize (const NodePtr &node) |
Private Attributes | |
| float | _size |
| Method | _method |
Removes nodes of size smaller than a given threshold from the scene.
Definition at line 54 of file OSGPruneGraphOp.h.
Definition at line 57 of file OSGPruneGraphOp.h.
00057 { 00058 VOLUME, 00059 SUM_OF_DIMENSIONS, 00060 };
| PruneGraphOp::PruneGraphOp | ( | float | size = 1.0f, |
|
| Method | method = SUM_OF_DIMENSIONS, |
|||
| const char * | name = "Prune" | |||
| ) |
| static const char* osg::PruneGraphOp::getClassname | ( | void | ) | [inline, static] |
Reimplemented from osg::GraphOp.
Definition at line 62 of file OSGPruneGraphOp.h.
| GraphOp * PruneGraphOp::create | ( | ) | [virtual] |
Implements osg::GraphOp.
Definition at line 65 of file OSGPruneGraphOp.cpp.
References _method, _size, and PruneGraphOp().
00066 { 00067 return new PruneGraphOp(_size, _method); 00068 }
| void PruneGraphOp::setParams | ( | const std::string | params | ) | [virtual] |
Implements osg::GraphOp.
Definition at line 70 of file OSGPruneGraphOp.cpp.
References _method, _size, FWARNING, osg::GraphOp::ParamSet::getUnusedParams(), SUM_OF_DIMENSIONS, and VOLUME.
00071 { 00072 ParamSet ps(params); 00073 00074 ps("size", _size); 00075 00076 std::string m; 00077 ps("method", m); 00078 00079 if(m.length()) 00080 { 00081 if(m.find("volume") || m.find("VOLUME")) 00082 { 00083 _method = VOLUME; 00084 } 00085 else if(m.find("sum_of_dimensions") || m.find("SUM_OF_DIMENSIONS") || 00086 m.find("sum")) 00087 { 00088 _method = SUM_OF_DIMENSIONS; 00089 } 00090 else 00091 { 00092 FWARNING(("GeoTypeGraphOp: method '%s' unknown.\n", m.c_str())); 00093 } 00094 } 00095 00096 std::string out = ps.getUnusedParams(); 00097 if(out.length()) 00098 { 00099 FWARNING(("PruneGraphOp doesn't have parameters '%s'.\n", 00100 out.c_str())); 00101 } 00102 }
| std::string PruneGraphOp::usage | ( | void | ) | [virtual] |
Implements osg::GraphOp.
Definition at line 104 of file OSGPruneGraphOp.cpp.
00105 { 00106 return 00107 "Prune: Remove small objects\n" 00108 " Removes nodes of size smaller than a given threshold from the scene\n" 00109 "Params: name (type, default)\n" 00110 " method (string, SUM_OF_DIMENSIONS): \n" 00111 " VOLUME: measure volume of Node\n" 00112 " SUM_OF_DIMENSIONS: add upp the individual dims\n" 00113 " size (Real32, 1.0f): \n" 00114 " threshold value. Nodes smaller than this will be\n" 00115 " removed\n"; 00116 }
| Action::ResultE PruneGraphOp::traverseEnter | ( | NodePtr & | node | ) | [private, virtual] |
Implements osg::GraphOp.
Definition at line 118 of file OSGPruneGraphOp.cpp.
References osg::Action::Continue, isTooSmall(), and osg::Action::Skip.
00119 { 00120 return isTooSmall(node) ? Action::Skip : Action::Continue; 00121 }
| Action::ResultE PruneGraphOp::traverseLeave | ( | NodePtr & | node, | |
| Action::ResultE | res | |||
| ) | [private, virtual] |
Implements osg::GraphOp.
Definition at line 123 of file OSGPruneGraphOp.cpp.
References osg::beginEditCP(), osg::endEditCP(), and isTooSmall().
00124 { 00125 beginEditCP(node); 00126 for (UInt32 i = 0; i < node->getNChildren(); ++i) { 00127 if (isTooSmall(node->getChild(i))) { 00128 node->subChild(i); 00129 --i; 00130 } 00131 } 00132 endEditCP(node); 00133 00134 return res; 00135 }
| bool PruneGraphOp::isTooSmall | ( | const NodePtr & | node | ) | [private] |
Definition at line 137 of file OSGPruneGraphOp.cpp.
References _size, and getSize().
Referenced by traverseEnter(), and traverseLeave().
| float PruneGraphOp::getSize | ( | const NodePtr & | node | ) | [private] |
Definition at line 142 of file OSGPruneGraphOp.cpp.
References _method, osg::BoxVolume::getBounds(), osg::BoxVolume::getScalarVolume(), SUM_OF_DIMENSIONS, SWARNING, and VOLUME.
Referenced by isTooSmall().
00143 { 00144 #ifndef OSG_2_PREP 00145 const DynamicVolume &vol = node->editVolume(true); 00146 #else 00147 const BoxVolume &vol = node->editVolume(true); 00148 #endif 00149 if (_method == VOLUME) 00150 { 00151 return vol.getScalarVolume(); 00152 } 00153 else if (_method == SUM_OF_DIMENSIONS) 00154 { 00155 Pnt3f min, max; 00156 vol.getBounds(min, max); 00157 Vec3f diff = max - min; 00158 return diff[0] + diff[1] + diff[2]; 00159 } 00160 else 00161 { 00162 SWARNING << "Unknown size calculation method" << std::endl; 00163 return 0; 00164 } 00165 }
| 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(), osg::VerifyGraphOp::repairGeometry(), 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.
Referenced by osg::VerifyGraphOp::repairGeometry(), and osg::VerifyGraphOp::traverseEnter().
| void GraphOp::addToExcludeList | ( | const 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 | ( | const 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(), osg::MakeTransparentGraphOp::traverseEnter(), 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 }
float osg::PruneGraphOp::_size [private] |
Definition at line 82 of file OSGPruneGraphOp.h.
Referenced by create(), isTooSmall(), and setParams().
Method osg::PruneGraphOp::_method [private] |
Definition at line 83 of file OSGPruneGraphOp.h.
Referenced by create(), getSize(), and setParams().
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().
1.6.1