本文整理汇总了C++中Bezier::Attach方法的典型用法代码示例。如果您正苦于以下问题:C++ Bezier::Attach方法的具体用法?C++ Bezier::Attach怎么用?C++ Bezier::Attach使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bezier
的用法示例。
在下文中一共展示了Bezier::Attach方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReadFrom
bool RoadStrip::ReadFrom(
std::istream & openfile,
bool reverse,
std::ostream & error_output)
{
assert(openfile);
int num = 0;
openfile >> num;
patches.clear();
patches.reserve(num);
// Add all road patches to this strip.
int badcount = 0;
for (int i = 0; i < num; ++i)
{
Bezier * prevbezier = 0;
if (!patches.empty()) prevbezier = &patches.back().GetPatch();
patches.push_back(RoadPatch());
patches.back().GetPatch().ReadFromYZX(openfile);
if (prevbezier) prevbezier->Attach(patches.back().GetPatch());
if (patches.back().GetPatch().CheckForProblems())
{
badcount++;
patches.pop_back();
}
}
if (badcount > 0)
error_output << "Rejected " << badcount << " bezier patch(es) from roadstrip due to errors" << std::endl;
// Reverse patches.
if (reverse)
{
std::reverse(patches.begin(), patches.end());
for (std::vector<RoadPatch>::iterator i = patches.begin(); i != patches.end(); ++i)
{
i->GetPatch().Reverse();
}
}
// Close the roadstrip if it ends near where it starts.
closed = (patches.size() > 2) &&
((patches.back().GetPatch().GetFL() - patches.front().GetPatch().GetBL()).Magnitude() < 0.1) &&
((patches.back().GetPatch().GetFR() - patches.front().GetPatch().GetBR()).Magnitude() < 0.1);
// Connect patches.
for (std::vector<RoadPatch>::iterator i = patches.begin(); i != patches.end() - 1; ++i)
{
std::vector<RoadPatch>::iterator n = i + 1;
i->GetPatch().Attach(n->GetPatch());
}
if (closed)
{
patches.back().GetPatch().Attach(patches.front().GetPatch());
}
GenerateSpacePartitioning();
return true;
}