本文整理汇总了C++中Intersections::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ Intersections::begin方法的具体用法?C++ Intersections::begin怎么用?C++ Intersections::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Intersections
的用法示例。
在下文中一共展示了Intersections::begin方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pickAtXY
// This method performs intersection testing at the given XY coords, and returns true if
// any intersections were found. It will break after processing the first pickable Window
// it finds.
bool WindowManager::pickAtXY(float x, float y, WidgetList& wl)
{
Intersections intr;
osg::Camera* camera = _view->getCamera();
osgViewer::GraphicsWindow* gw = dynamic_cast<osgViewer::GraphicsWindow*>(camera->getGraphicsContext());
if (gw)
{
_view->computeIntersections(camera, osgUtil::Intersector::WINDOW, x, y, intr, _nodeMask);
}
if (!intr.empty())
{
// Get the first Window at the XY coordinates; if you want a Window to be
// non-pickable, set the NodeMask to something else.
Window* activeWin = 0;
// Iterate over every picked result and create a list of Widgets that belong
// to that Window.
for(Intersections::iterator i = intr.begin(); i != intr.end(); i++) {
Window* win = dynamic_cast<Window*>(i->nodePath.back()->getParent(0));
// Make sure that our window is valid, and that our pick is within the
// "visible area" of the Window.
if(
!win ||
(win->getVisibilityMode() == Window::VM_PARTIAL && !win->isPointerXYWithinVisible(x, y))
) {
continue;
}
// Set our activeWin, so that we know when we've got all the Widgets
// that belong to it.
if(!activeWin) activeWin = win;
// If we've found a new Widnow, break out!
else if(activeWin != win) break;
Widget* widget = dynamic_cast<Widget*>(i->drawable.get());
if(!widget) continue;
// We need to return a list of every Widget that was picked, so
// that the handler can operate on it accordingly.
else wl.push_back(widget);
}
if(wl.size()) {
// Potentially VERY expensive; only to be used for debugging. :)
if(_flags & WM_PICK_DEBUG) _updatePickWindow(&wl, x, y);
return true;
}
}
if(_flags & WM_PICK_DEBUG) _updatePickWindow(0, x, y);
return false;
}
示例2: cut_segment_plane
void Scene::cut_segment_plane()
{
// Build tree (if build fail, exit)
build_facet_tree();
if ( m_facet_tree.empty() ) {
return;
}
Plane plane = frame_plane();
// Compute intersections
typedef std::vector<Facet_tree::Object_and_primitive_id> Intersections;
Intersections intersections;
m_facet_tree.all_intersections(plane, std::back_inserter(intersections));
// Fill data structure
m_cut_segments.clear();
for ( Intersections::iterator it = intersections.begin(),
end = intersections.end() ; it != end ; ++it )
{
const Segment* inter_seg = CGAL::object_cast<Segment>(&(it->first));
if ( NULL != inter_seg )
{
m_cut_segments.push_back(*inter_seg);
}
}
m_cut_plane = CUT_SEGMENTS;
}
示例3: processIntersections
void QTessellatorPrivate::processIntersections()
{
QDEBUG() << "PROCESS INTERSECTIONS";
// process intersections
while (!intersections.isEmpty()) {
Intersections::iterator it = intersections.begin();
if (it.key().y != y)
break;
// swap edges
QDEBUG() << " swapping intersecting edges ";
int min = scanline.size;
int max = 0;
Q27Dot5 xmin = INT_MAX;
Q27Dot5 xmax = INT_MIN;
int num = 0;
while (1) {
const Intersection &i = it.key();
int next = it->next;
int edgePos = scanline.findEdge(i.edge);
if (edgePos >= 0) {
++num;
min = qMin(edgePos, min);
max = qMax(edgePos, max);
Edge *edge = scanline.edges[edgePos];
xmin = qMin(xmin, edge->positionAt(y));
xmax = qMax(xmax, edge->positionAt(y));
}
Intersection key;
key.y = y;
key.edge = next;
it = intersections.find(key);
intersections.remove(i);
if (it == intersections.end())
break;
}
if (num < 2)
continue;
Q_ASSERT(min != max);
QDEBUG() << "sorting between" << min << "and" << max << "xpos=" << xmin << xmax;
while (min > 0 && scanline.edges[min - 1]->positionAt(y) >= xmin) {
QDEBUG() << " adding edge on left";
--min;
}
while (max + 1 < scanline.size && scanline.edges[max + 1]->positionAt(y) <= xmax) {
QDEBUG() << " adding edge on right";
++max;
}
qSort(scanline.edges + min, scanline.edges + max + 1, EdgeSorter(y));
#ifdef DEBUG
for (int i = min; i <= max; ++i)
QDEBUG() << " " << scanline.edges[i]->edge << "at pos" << i;
#endif
for (int i = min; i <= max; ++i) {
Edge *edge = scanline.edges[i];
edge->intersect_left = true;
edge->intersect_right = true;
edge->mark = true;
}
}
}