本文整理汇总了C++中Cylinder::Distance方法的典型用法代码示例。如果您正苦于以下问题:C++ Cylinder::Distance方法的具体用法?C++ Cylinder::Distance怎么用?C++ Cylinder::Distance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cylinder
的用法示例。
在下文中一共展示了Cylinder::Distance方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SuggestSimplifications
void ConePrimitiveShape::SuggestSimplifications(const PointCloud &pc,
MiscLib::Vector< size_t >::const_iterator begin,
MiscLib::Vector< size_t >::const_iterator end, float distThresh,
MiscLib::Vector< MiscLib::RefCountPtr< PrimitiveShape > > *suggestions) const
{
// sample the bounding box in parameter space at 25 locations
// these points are used to estimate the other shapes
// if the shapes succeed the suggestion is returned
MiscLib::Vector< Vec3f > samples(2 * 25);
float uStep = (m_extBbox.Max()[0] - m_extBbox.Min()[0]) / 4;
float vStep = (m_extBbox.Max()[1] - m_extBbox.Min()[1]) / 4;
float u = m_extBbox.Min()[0];
for(unsigned int i = 0; i < 5; ++i, u += uStep)
{
float v = m_extBbox.Min()[1];
for(unsigned int j = 0; j < 5; ++j, v += vStep)
{
float bmpu, bmpv;
if(m_cone.Angle() >= M_PI / 4)
{
bmpu = std::sin(v) * u;
bmpv = std::cos(v) * u;
}
else
{
bmpu = u;
float r = m_cone.RadiusAtLength(u);
bmpv = (v - float(M_PI)) * r;
}
InSpace(bmpu, bmpv, &samples[i * 5 + j],
&samples[i * 5 + j + 25]);
}
}
size_t c = samples.size() / 2;
// now check all the shape types
Cylinder cylinder;
if(cylinder.InitAverage(samples))
{
cylinder.LeastSquaresFit(samples.begin(), samples.begin() + c);
bool failed = false;
for(size_t i = 0; i < c; ++i)
if(cylinder.Distance(samples[i]) > distThresh)
{
failed = true;
break;
}
if(!failed)
{
suggestions->push_back(new CylinderPrimitiveShape(cylinder));
suggestions->back()->Release();
}
}
Sphere sphere;
if(sphere.Init(samples))
{
sphere.LeastSquaresFit(samples.begin(), samples.begin() + c);
bool failed = false;
for(size_t i = 0; i < c; ++i)
if(sphere.Distance(samples[i]) > distThresh)
{
failed = true;
break;
}
if(!failed)
{
suggestions->push_back(new SpherePrimitiveShape(sphere));
suggestions->back()->Release();
}
}
Plane plane;
if(plane.LeastSquaresFit(samples.begin(), samples.begin() + c))
{
bool failed = false;
for(size_t i = 0; i < c; ++i)
if(plane.Distance(samples[i]) > distThresh)
{
failed = true;
break;
}
if(!failed)
{
suggestions->push_back(new PlanePrimitiveShape(plane));
suggestions->back()->Release();
}
}
/*// simpler shapes are suggested if the maximal curvature of the cone
// is small compared to the extend in relation to the distThresh
float meanRadius, length, meanLength, radialExtent;
// the cone is parameterized as length and angle
// in this case the cone is parametrized as length and arclength
meanRadius = (m_cone.RadiusAtLength(m_extBbox.Min()[0])
+ m_cone.RadiusAtLength(m_extBbox.Max()[0])) / 2;
length = m_extBbox.Max()[0] - m_extBbox.Min()[0];
meanLength = (m_extBbox.Max()[0] + m_extBbox.Min()[0]) / 2;
// the radial extent
radialExtent = m_extBbox.Max()[1] - m_extBbox.Min()[1];
// We suggest a cylinder if the opening angle of the cone is so small
// that over the whole height the difference is less than distThresh
//.........这里部分代码省略.........