MCPcopy Create free account
hub / github.com/PDAL/PDAL / CollectTriangles

Class CollectTriangles

plugins/openscenegraph/io/OSGReader.cpp:47–179  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45{
46
47struct CollectTriangles
48{
49 CollectTriangles()
50 {
51 verts = new osg::Vec3Array();
52 }
53#ifdef OSG_VERSION_GREATER_THAN
54#if OSG_VERSION_GREATER_THAN(3,4,0)
55 inline void operator () (const osg::Vec3& v1, const osg::Vec3& v2, const osg::Vec3& v3)
56#elif OSG_VERSION_GREATER_THAN(3, 2, 0)
57 inline void operator () (const osg::Vec3& v1, const osg::Vec3& v2, const osg::Vec3& v3, bool treatVertexDataAsTemporary)
58#else
59 inline void operator () (const osg::Vec3& v1, const osg::Vec3& v2, const osg::Vec3& v3)
60#endif
61#else
62 inline void operator () (const osg::Vec3& v1, const osg::Vec3& v2, const osg::Vec3& v3)
63#endif
64 {
65 verts->push_back(v1);
66 verts->push_back(v2);
67 verts->push_back(v3);
68 }
69
70 osg::ref_ptr< osg::Vec3Array > verts;
71};
72
73struct CollectTrianglesVisitor : public osg::NodeVisitor
74{
75 CollectTrianglesVisitor() :
76 osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN)
77 {
78 }
79
80 void apply(osg::Transform& transform)
81 {
82 osg::Matrix matrix;
83 if (!_matrixStack.empty()) matrix = _matrixStack.back();
84
85 transform.computeLocalToWorldMatrix(matrix, this);
86
87 pushMatrix(matrix);
88
89 traverse(transform);
90
91 popMatrix();
92 }
93
94 void apply(osg::Geode& geode)
95 {
96 for (unsigned int i = 0; i<geode.getNumDrawables(); ++i)
97 {
98 osg::TriangleFunctor<CollectTriangles> triangleCollector;
99 geode.getDrawable(i)->accept(triangleCollector);
100 for (unsigned int j = 0; j < triangleCollector.verts->size(); j++)
101 {
102 osg::Matrix matrix;
103 if (!_matrixStack.empty())
104 {

Callers

nothing calls this directly

Calls 12

addDimensionsFunction · 0.85
readFunction · 0.85
registerDimMethod · 0.80
getNameFunction · 0.50
readyFunction · 0.50
doneFunction · 0.50
sizeMethod · 0.45
setFieldMethod · 0.45
xMethod · 0.45
yMethod · 0.45
zMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected