bool hasHollowPoint(std::vector<osg::Vec3d> allPoints)
{
std::vector<osg::Vec3d> pHollowPoints;
auto num = allPoints.size();
osg::Vec3d pHollowNor = (allPoints[num - 1] - allPoints[0]) ^ (allPoints[1] - allPoints[0]);
osg::Vec3d Nor;
for (int i = 0; i < num; i++)
{
if (i == 0) //第一个点
{
Nor = (allPoints[0] - allPoints[num - 1]) ^ (allPoints[1] - allPoints[0]);
if ((Nor * pHollowNor) > 0.0) //如果点乘大于0
{
pHollowPoints.push_back(allPoints[i]);
}
}
else if (i == num - 1) //最后一个点
{
Nor = (allPoints[i] - allPoints[i - 1]) ^ (allPoints[0] - allPoints[i]);
if (((Nor * pHollowNor) > 0.0)) //如果点乘大于0
{
pHollowPoints.push_back(allPoints[i]);
}
}
else //中间点
{
Nor = (allPoints[i] - allPoints[i - 1]) ^ (allPoints[i + 1] - allPoints[i]);
if (((Nor * pHollowNor) > 0.0))
{
pHollowPoints.push_back(allPoints[i]);
}
}
}
if (pHollowPoints.size() == 0)
{
return false;
}
else
{
return true;
}
}