本文整理汇总了C++中IntervalTree::getIntervals方法的典型用法代码示例。如果您正苦于以下问题:C++ IntervalTree::getIntervals方法的具体用法?C++ IntervalTree::getIntervals怎么用?C++ IntervalTree::getIntervals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IntervalTree
的用法示例。
在下文中一共展示了IntervalTree::getIntervals方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: algorithm2
void algorithm2(vector<Square> & squares){
priority_queue<Event, vector<Event>, CompareEvent> events;
//vector<SQINTERVAL> intervals; // vector containg all vertical intervals and their rectangles
IntervalTree<Square, float> activeTree; // tree containing the vertical intervals
vector<SQINTERVAL> results; // contains the intersecting vertical intervals and their rectangles
ofstream output;
output.open("uitvoerrechthoeken.txt");
// start timer
auto start = std::chrono::steady_clock::now();
for (int i = 0; i < squares.size(); i++){
Event e1 = Event(true, squares[i], squares[i].getLB().getX());
Event e2 = Event(false, squares[i], squares[i].getRA().getX());
events.push( e1 ); //left side event of rectangle
events.push( e2 ); //right side event of rectangle
}
while (!events.empty()) {
Event current = events.top();
if (current.isLeftEdge()){
if (activeTree.getIntervals().size() > 0){
activeTree.findOverlapping(current.getSquare().getLB().getY(), current.getSquare().getRA().getY(), results);
vector<Coordinate> pos;
for (int i = 0; i < results.size(); i++){
results[i].value.getIntersection(current.getSquare(), pos);
for (int w = 0; w < pos.size(); w++){
output << pos[w].getX() << " " << pos[w].getY() << "\n";
}
pos.clear();
}
}
activeTree.addInterval(SQINTERVAL(current.getSquare().getInterval()));
activeTree.sort();
results.clear();
}
else {
for (vector<SQINTERVAL>::iterator i = activeTree.getIntervals().begin(); i != activeTree.getIntervals().end(); ++i){
if (current.getSquare().getId() == i->value.getId()){
activeTree.getIntervals().erase(i);
break;
}
}
results.clear();
}
events.pop();
}
// stop timer
auto end = std::chrono::steady_clock::now();
auto elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end - start);
output << elapsed.count() << "\n";
output.close();
cout << "Ready. \n";
cout << elapsed.count();
}