std::vector<std::string> Split(const string& src, const char& delim)
{
std::istringstream stream(src);
std::string field;
std::vector<std::string> result;
while (std::getline(stream, field, delim))
{
result.push_back(field);
}
return result;
}
osg::Geometry* createLine(const std::vector<osg::Vec3d>& allPTs, osg::Vec4 color, osg::PrimitiveSet::Mode model, float nWidth)
{
int nCount = allPTs.size();
osg::ref_ptr<osg::Geometry> pGeometry = new osg::Geometry();
osg::ref_ptr<osg::Vec3Array> pyramidVertices = new osg::Vec3Array;
pGeometry->setVertexArray(pyramidVertices.get());
for (int i = 0; i < allPTs.size(); i++)
{
pyramidVertices->push_back(allPTs[i]);
}
osg::ref_ptr<osg::Vec4Array> colors = new osg::Vec4Array;
colors->push_back(color);
pGeometry->setColorArray(colors.get());
pGeometry->setColorBinding(osg::Geometry::BIND_OVERALL);
osg::ref_ptr<osg::DrawArrays> pyramidBase = NULL;
pyramidBase = new osg::DrawArrays(model, 0, allPTs.size());
pGeometry->addPrimitiveSet(pyramidBase.get());
pGeometry->setUseVertexBufferObjects(false);
{
osg::StateSet* stateset = pGeometry->getOrCreateStateSet();
stateset->setAttributeAndModes(new osg::LineWidth(nWidth), osg::StateAttribute::ON);
stateset->setMode(GL_LIGHTING, osg::StateAttribute::OFF | osg::StateAttribute::PROTECTED);
}
return pGeometry.release();
}