simulationMaster/myNodeVisitor.h
2021-12-23 17:46:55 +08:00

36 lines
1.2 KiB
C++

#ifndef MYNODEVISITOR_H
#define MYNODEVISITOR_H
#include <osg/NodeVisitor>
#include <osgUtil/Optimizer>
#include <osgDB/ReadFile>
#include <QtCore>
// 深度优先的访问器
class myNodeVisitor : public osg::NodeVisitor
{
public:
myNodeVisitor();
void setPoints(osg::ref_ptr<osg::Vec3Array> _vertexArray) {vertexArray = _vertexArray;}
void setBoundaryList(QList<osg::ref_ptr<osg::Vec3Array>> _boundaryList){ boundaryList = _boundaryList; }
virtual void apply(osg::Geode &node) override;
virtual void apply(osg::Group &node) override;
virtual void apply(osg::PagedLOD &node) override;
bool pointInPolygon(osg::Vec3& point);
int pointsNearVertex(osg::Vec3& point);
private:
osgUtil::Optimizer::TextureVisitor* tv = new osgUtil::Optimizer::TextureVisitor(true, false, false, false, false, false);
osgDB::ReaderWriter::Options* opt = new osgDB::ReaderWriter::Options;
QString workingDir;
QString newFileName;
// 记录点位是否被修改,从而缩减计算量
bool affected = false;
bool childAffected = false;
osg::ref_ptr<osg::Vec3Array> vertexArray;
QList<osg::ref_ptr<osg::Vec3Array>> boundaryList;
};
#endif // MYNODEVISITOR_H