c++ 阅读 ifc文件,使用ifc++ 以及osg引擎功能测试
#include <osgViewer/Viewer>
#include <osgGA/TrackballManipulator>
#include <osgDB/ReadFile>
#include <osg/Geode>
#include <osg/Material>
#include <osg/Texture2D>
#include <osg/ShapeDrawable>
#include <ifcpp/model/IfcModel.h>
#include <ifcpp/reader/ReaderSTEP.h>
int main(int argc, char* argv[])
{
// 读取IFC文件
std::shared_ptr<IfcModel> model = std::make_shared<IfcModel>();
std::string ifc_file_path = "example.ifc";
IfcPP::ReaderSTEP reader;
reader.setModel(model);
reader.read(ifc_file_path);
// 设置渲染器
osg::ref_ptr<osg::Group> scene = new osg::Group();
scene->addChild(root);
osg::ref_ptr<osg::StateSet> stateSet = new osg::StateSet();
osg::ref_ptr<osg::Material> material = new osg::Material();
material->setDiffuse(osg::Material::FRONT, osg::Vec4(1, 1, 1, 1));
stateSet->setAttribute(material.get());
stateSet->setMode(GL_LIGHTING, osg::StateAttribute::ON);
scene->setStateSet(stateSet);
// 创建Viewer
osg::ref_ptr<osgViewer::Viewer> viewer = new osgViewer::Viewer();
viewer->setSceneData(scene.get());
viewer->setCameraManipulator(new osgGA::TrackballManipulator());
viewer->run();
return 0;
}