本文整理汇总了C++中Shape::AddPoint方法的典型用法代码示例。如果您正苦于以下问题:C++ Shape::AddPoint方法的具体用法?C++ Shape::AddPoint怎么用?C++ Shape::AddPoint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Shape
的用法示例。
在下文中一共展示了Shape::AddPoint方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BuildFromSegmentSoup
void MultiShape::BuildFromSegmentSoup(const LineSegmentContainer& Segments)
{
typedef std::multimap<Vector2,Vector2,Vector2LengthCompare> Vec2MultiMap;
typedef std::pair<Vector2,Vector2> Vec2Pair;
Vec2MultiMap SegMap;
for( ConstLineSegmentIterator SegIt = Segments.begin() ; SegIt != Segments.end() ; ++SegIt )
{
SegMap.insert( Vec2Pair(SegIt->PointA,SegIt->PointB) );
SegMap.insert( Vec2Pair(SegIt->PointB,SegIt->PointA) );
}
while( !SegMap.empty() )
{
Vector2 headFirst = SegMap.begin()->first;
Vector2 headSecond = SegMap.begin()->second;
Shape s;
s.AddPoint(headFirst).AddPoint(headSecond);
Vec2MultiMap::iterator firstSeg = SegMap.begin();
std::pair<Vec2MultiMap::iterator,Vec2MultiMap::iterator> correspondants2 = SegMap.equal_range(headSecond);
for( Vec2MultiMap::iterator Vec2It = correspondants2.first ; Vec2It != correspondants2.second ; )
{
Vec2MultiMap::iterator RemoveIt = ++Vec2It;
if( ( RemoveIt->second - firstSeg->first ).SquaredLength() < 1e-8 )
SegMap.erase(RemoveIt);
}
SegMap.erase(firstSeg);
Boole FoundSomething = true;
while( !SegMap.empty() && FoundSomething )
{
FoundSomething = false;
Vec2MultiMap::iterator next = SegMap.find(headSecond);
if( next != SegMap.end() ) {
FoundSomething = true;
headSecond = next->second;
s.AddPoint(headSecond);
std::pair<Vec2MultiMap::iterator, Vec2MultiMap::iterator> correspondants = SegMap.equal_range(headSecond);
for( Vec2MultiMap::iterator it = correspondants.first ; it != correspondants.second ; )
{
Vec2MultiMap::iterator RemoveIt = ++it;
if( ( RemoveIt->second - next->first ).SquaredLength() < 1e-8)
SegMap.erase(RemoveIt);
}
SegMap.erase(next);
}
Vec2MultiMap::iterator previous = SegMap.find(headFirst);
if( previous != SegMap.end() ) {
FoundSomething = true;
s.InsertPoint(0, previous->second);
headFirst = previous->second;
std::pair<Vec2MultiMap::iterator,Vec2MultiMap::iterator> correspondants = SegMap.equal_range(headFirst);
for( Vec2MultiMap::iterator it = correspondants.first ; it != correspondants.second ; )
{
Vec2MultiMap::iterator RemoveIt = ++it;
if( ( RemoveIt->second - previous->first ).SquaredLength() < 1e-8 )
SegMap.erase(RemoveIt);
}
SegMap.erase(previous);
}
}
if( s.GetPoint(0).SquaredDistance( s.GetPoint( s.GetSegCount() + 1 ) ) < 1e-6 ) {
s.GetPointsReference().pop_back();
s.Close();
}
this->AddShape(s);
}
}