#include <OSGGeoTypeGraphOp.h>

Public Member Functions | |
| GeoTypeGraphOp (const char *name="GeoType") | |
| GraphOp * | create () |
| void | setParams (const std::string params) |
| std::string | usage (void) |
| void | setFilter (const osg::BitVector &filter) |
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 | |
| static const char * | getClassname (void) |
Protected Attributes | |
| std::list< NodePtr > | _excludeListNodes |
| std::list< std::string > | _excludeListNames |
Private Member Functions | |
| bool | travNodeEnter (NodePtr node) |
| bool | travNodeLeave (NodePtr node) |
Private Attributes | |
| osg::BitVector | _filter |
Definition at line 53 of file OSGGeoTypeGraphOp.h.
| GeoTypeGraphOp::GeoTypeGraphOp | ( | const char * | name = "GeoType" |
) |
Definition at line 46 of file OSGGeoTypeGraphOp.cpp.
Referenced by create().
00047 : SingleTypeGraphOp<Geometry>(name), 00048 _filter(TypeTraits<OSG::BitVector>::getMax()) 00049 { 00050 }
| static const char* osg::GeoTypeGraphOp::getClassname | ( | void | ) | [inline, static] |
Reimplemented from osg::SingleTypeGraphOp< Type >.
Definition at line 57 of file OSGGeoTypeGraphOp.h.
| GraphOp * GeoTypeGraphOp::create | ( | ) | [virtual] |
Implements osg::GraphOp.
Definition at line 52 of file OSGGeoTypeGraphOp.cpp.
References GeoTypeGraphOp().
00053 { 00054 return new GeoTypeGraphOp(); 00055 }
| void GeoTypeGraphOp::setParams | ( | const std::string | params | ) | [virtual] |
Implements osg::GraphOp.
Definition at line 184 of file OSGGeoTypeGraphOp.cpp.
References _filter, FWARNING, osg::GraphOp::ParamSet::getUnusedParams(), osg::GeometryBase::IndicesFieldMask, osg::GeometryBase::LengthsFieldMask, and osg::GeometryBase::NormalsFieldMask.
00185 { 00186 ParamSet ps(params); 00187 std::string filter; 00188 00189 if(ps("filter", filter)) 00190 { 00191 _filter = 0; 00192 if(filter.find("Nor") != std::string::npos || 00193 filter.find("nor") != std::string::npos) 00194 { 00195 _filter |= Geometry::NormalsFieldMask; 00196 } 00197 if(filter.find("Ind") != std::string::npos || 00198 filter.find("ind") != std::string::npos) 00199 { 00200 _filter |= Geometry::IndicesFieldMask; 00201 } 00202 if(filter.find("Len") != std::string::npos || 00203 filter.find("len") != std::string::npos) 00204 { 00205 _filter |= Geometry::LengthsFieldMask; 00206 } 00207 } 00208 00209 std::string out = ps.getUnusedParams(); 00210 if(out.length()) 00211 { 00212 FWARNING(("GeoTypeGraphOp doesn't have parameters '%s'.\n", 00213 out.c_str())); 00214 } 00215 }
| std::string GeoTypeGraphOp::usage | ( | void | ) | [virtual] |
Implements osg::GraphOp.
Definition at line 217 of file OSGGeoTypeGraphOp.cpp.
00218 { 00219 return 00220 "GeoType: convert the types of a Geometry's attributes\n" 00221 " Tries to convert the attributes of a Geometry to smaller/faster\n" 00222 " types. By default only the lengths are changed to 16 bit.\n" 00223 "Params: name (type, default)\n" 00224 " filter (string, \"\"): fields to convert, can be a combination of\n" 00225 " Normals, Indices and Lengths, connected by +.\n" 00226 ; 00227 }
| void GeoTypeGraphOp::setFilter | ( | const osg::BitVector & | filter | ) |
Definition at line 229 of file OSGGeoTypeGraphOp.cpp.
References _filter.
00230 { 00231 _filter = filter; 00232 }
| bool GeoTypeGraphOp::travNodeEnter | ( | NodePtr | node | ) | [private, virtual] |
Implements osg::SingleTypeGraphOp< Type >.
Definition at line 58 of file OSGGeoTypeGraphOp.cpp.
References _filter, osg::beginEditCP(), osg::GeoProperty< GeoPropertyDesc >::create(), osg::FCPtr< BasePtrTypeT, FieldContainerTypeT >::dcast(), osg::AttachmentContainerPtr::dcast(), osg::endEditCP(), osg::NodePtr::getCore(), osg::GeometryBase::IndicesFieldMask, osg::VectorInterface< ValueTypeT, StorageInterfaceT >::length(), osg::GeometryBase::LengthsFieldMask, osg::GeometryBase::NormalsFieldMask, osg::NullFC, osg::MField< FieldTypeT, fieldNameSpace >::push_back(), osg::MField< FieldTypeT, fieldNameSpace >::reserve(), and osg::MField< FieldTypeT, fieldNameSpace >::size().
00059 { 00060 GeometryPtr geo = GeometryPtr::dcast(node->getCore()); 00061 00062 if(geo == NullFC) 00063 { 00064 return true; 00065 } 00066 00067 GeoPositionsPtr positions = geo->getPositions(); 00068 00069 #if !defined(__sun) && !defined(OSG_NO_INT8_PNT) 00070 // normals 00071 if(_filter & Geometry::NormalsFieldMask) 00072 { 00073 GeoNormalsPtr normals = geo->getNormals(); 00074 GeoNormals3fPtr normals3f = GeoNormals3fPtr::dcast(normals); 00075 if (normals3f != NullFC) 00076 { 00077 MFVec3f &src = normals3f->getField(); 00078 00079 GeoNormals3bPtr normals3b = GeoNormals3b::create(); 00080 MFVec3b &dst = normals3b->getField(); 00081 dst.reserve(src.size()); 00082 beginEditCP(normals3b); 00083 for (UInt32 i = 0; i < src.size(); ++i) 00084 { 00085 Vec3f vec = src[i]; 00086 vec *= (0.9f / vec.length()); 00087 normals3b->push_back(vec); 00088 } 00089 endEditCP(normals3b); 00090 00091 beginEditCP(geo, Geometry::NormalsFieldMask); 00092 geo->setNormals(normals3b); 00093 endEditCP(geo, Geometry::NormalsFieldMask); 00094 } 00095 } 00096 #endif 00097 00098 GeoColorsPtr colors = geo->getColors(); 00099 GeoColorsPtr scolors = geo->getSecondaryColors(); 00100 00101 if(_filter & Geometry::LengthsFieldMask) 00102 { 00103 // lengths 00104 GeoPLengthsUI32Ptr lengthsUI32 = GeoPLengthsUI32Ptr::dcast(geo->getLengths()); 00105 if(lengthsUI32 != NullFC) 00106 { 00107 MFUInt32 &src = lengthsUI32->getField(); 00108 00109 // now check if maximum length is greater than 65535 00110 UInt32 max_length = UInt32(TypeTraits<UInt16>::getMax()); 00111 bool max_length_ok = true; 00112 for(UInt32 i=0;i<src.size();++i) 00113 { 00114 if(src[i] > max_length) 00115 { 00116 max_length_ok = false; 00117 break; 00118 } 00119 } 00120 00121 if(max_length_ok) 00122 { 00123 GeoPLengthsUI16Ptr lengthsUI16 = GeoPLengthsUI16::create(); 00124 MFUInt16 &dst = lengthsUI16->getField(); 00125 dst.reserve(src.size()); 00126 beginEditCP(lengthsUI16); 00127 for (UInt32 i = 0; i < src.size(); ++i) 00128 dst.push_back(UInt16(src[i])); 00129 endEditCP(lengthsUI16); 00130 00131 beginEditCP(geo, Geometry::LengthsFieldMask); 00132 geo->setLengths(lengthsUI16); 00133 endEditCP(geo, Geometry::LengthsFieldMask); 00134 } 00135 } 00136 } 00137 00138 // indices 00139 if(_filter & Geometry::IndicesFieldMask) 00140 { 00141 GeoIndicesUI32Ptr indicesUI32 = GeoIndicesUI32Ptr::dcast(geo->getIndices()); 00142 if(indicesUI32 != NullFC) 00143 { 00144 MFUInt32 &src = indicesUI32->getField(); 00145 00146 // now check if maximum index is greater than 65535 00147 UInt32 max_index = UInt32(TypeTraits<UInt16>::getMax()); 00148 bool max_index_ok = true; 00149 for(UInt32 i=0;i<src.size();++i) 00150 { 00151 if(src[i] > max_index) 00152 { 00153 max_index_ok = false; 00154 break; 00155 } 00156 } 00157 00158 if(max_index_ok) 00159 { 00160 GeoIndicesUI16Ptr indicesUI16 = GeoIndicesUI16::create(); 00161 MFUInt16 &dst = indicesUI16->getField(); 00162 dst.reserve(src.size()); 00163 beginEditCP(indicesUI16); 00164 for (UInt32 i = 0; i < src.size(); ++i) 00165 dst.push_back(src[i]); 00166 endEditCP(indicesUI16); 00167 00168 beginEditCP(geo, Geometry::IndicesFieldMask); 00169 geo->setIndices(indicesUI16); 00170 endEditCP(geo, Geometry::IndicesFieldMask); 00171 } 00172 } 00173 } 00174 00175 return true; 00176 }
| bool GeoTypeGraphOp::travNodeLeave | ( | NodePtr | node | ) | [private, virtual] |
| 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] |
| 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 }
osg ::BitVector osg::GeoTypeGraphOp::_filter [private] |
Definition at line 74 of file OSGGeoTypeGraphOp.h.
Referenced by setFilter(), setParams(), 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().
1.5.5