本文整理汇总了C++中Poly::append方法的典型用法代码示例。如果您正苦于以下问题:C++ Poly::append方法的具体用法?C++ Poly::append怎么用?C++ Poly::append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Poly
的用法示例。
在下文中一共展示了Poly::append方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rowToPolynomial
void SparseMatrix::rowToPolynomial(
const RowIndex row,
const std::vector<PolyRing::Monoid::ConstMonoPtr>& colMonomials,
Poly& poly
) {
poly.setToZero();
poly.reserve(entryCountInRow(row));
const auto end = rowEnd(row);
for (auto it = rowBegin(row); it != end; ++it) {
MATHICGB_ASSERT(it.index() < colMonomials.size());
if (it.scalar() != 0)
poly.append(it.scalar(), *colMonomials[it.index()]);
}
MATHICGB_ASSERT(poly.termsAreInDescendingOrder());
}
示例2: if
void
LineCombiner::add( QPointF p1, QPointF p2 )
{
bool ok;
qDebug() << "add" << p1 << p2;
// find closest points within the threshold distance of p1 and p2
IndexPt * ip1 = _findClosestPt( p1 );
IndexPt * ip2 = _findClosestPt( p2 );
// normalize the cases
if ( ! ip1 ) {
std::swap( ip1, ip2 );
std::swap( p1, p2 );
}
if ( ip1 ) {
CARTA_ASSERT( ip1-> poly );
}
if ( ip2 ) {
CARTA_ASSERT( ip2-> poly );
}
// case1: this line segment is not near anything else
if ( ip1 == nullptr && ip2 == nullptr ) {
qDebug() << "case null null";
// we insert a new polyline and update spacial index
// make a new polyline from p1 and p2
Poly * poly = new Poly;
poly->append( p1 );
poly->append( p2 );
// insert beginning of this polyline into grid
findCell( p1 )-> pts.append( IndexPt( poly, false ) );
// insert end of this polyine into grid
findCell( p2 )-> pts.append( IndexPt( poly, true ) );
IndexPt ipt1( poly, true );
CARTA_ASSERT( findCell( ipt1.pt() )->pts.contains( ipt1 ) );
return;
}
// catch a super-special case.... both points point to the same polyline, same end...
// we'll treat this as if only one of the points pointed to a polyline)
if( ip2 && ip1->poly == ip2->poly && ip1->flipped == ip2->flipped) {
qDebug() << "super special";
ip2 = nullptr;
}
// only one point has a match (ip1, ip2 is null)
if ( ip1 != nullptr && ip2 == nullptr ) {
qDebug() << "case poly null";
// make a copy of what ip1 points to, because it'll be destroyed
IndexPt ip1copy = * ip1;
// remove ip1 from it's corresponding cell (after this ip1 will point to
// a destroyed memory!)
ok = findCell( ip1-> pt() )-> pts.removeOne( * ip1 );
CARTA_ASSERT( ok );
// re-point ip1 to the copy
ip1 = & ip1copy;
// we extend the polyline that ip1 points to with p2
if ( ip1-> flipped ) {
ip1-> poly-> append( p2 );
}
else {
ip1-> poly-> prepend( p2 );
}
// and add a new index point (for p2) to the respective cell
findCell( p2 )-> pts.append( * ip1 );
return;
}
// both points have a match, and it's the same polyline, but different ends...
if ( ip1-> poly == ip2-> poly ) {
qDebug() << "case poly poly same";
CARTA_ASSERT( ip1->flipped == ! ip2->flipped );
// we need to remove both points from their cells
Poly * poly = ip1->poly;
ok = findCell( ip1->pt() )->pts.removeOne( * ip1 );
CARTA_ASSERT( ok );
ok = findCell( ip2->pt() )->pts.removeOne( * ip2 );
CARTA_ASSERT( ok );
// make it a closed polyline
poly->append( poly->first() );
QPolygonF polygon = poly2polygon( poly );
m_polygons.push_back( polygon );
//.........这里部分代码省略.........