当前位置: 首页>>代码示例>>C++>>正文


C++ Coordinates::size方法代码示例

本文整理汇总了C++中Coordinates::size方法的典型用法代码示例。如果您正苦于以下问题:C++ Coordinates::size方法的具体用法?C++ Coordinates::size怎么用?C++ Coordinates::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Coordinates的用法示例。


在下文中一共展示了Coordinates::size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: copyCoordinates

 void copyCoordinates(Coordinates& dst, const Coordinates& src)
 {
   assert(dst.size() >= src.size());
   for (Coordinates::size_type i = 0; i < src.size(); ++i) {
     dst[i] = src[i];
   }
 }
开发者ID:Goon83,项目名称:scidb,代码行数:7,代码来源:UnfoldArray.cpp

示例2: clipCurve

bool Clipping::clipCurve(Object *obj){
    auto& coords = obj->getNCoords();
    Coordinates newPath;
    bool prevInside = true;
    Coordinate prev;

    for(unsigned int i = 0; i < coords.size(); i++){
        if(clipPoint(coords[i])){
            if(!prevInside){
                clipLine(prev, coords[i]);
                newPath.push_back(prev);
            }
            newPath.push_back(coords[i]);
            prevInside = true;
        }else{
            if(prevInside && newPath.size() != 0){
                clipLine(prev, coords[i]);
                newPath.push_back(coords[i]);
            }
            prevInside = false;
        }
        prev = coords[i];
    }

    if(newPath.size() == 0)
        return false;

    obj->setNCoord(newPath);
    return true;
}
开发者ID:nogenem,项目名称:Computacao-Grafica-2015-2,代码行数:30,代码来源:Clipping.hpp

示例3: clipBottom

void Clipping::clipBottom(Coordinates& input, Coordinates& output){
    if(output.size() > 0)
        output.clear();
    if(input.size() == 0)
        return;

    double clipY = m_w->minY;
    input.push_back(input[0]);
    for(unsigned int i = 0; i < input.size()-1; i++){
        Coordinate c0 = input[i];
        Coordinate c1 = input[i+1];

        //Caso 1: out -> out
        if(c0.y < clipY && c1.y < clipY){}

        //Caso 2: in -> in
        if(c0.y >= clipY && c1.y >= clipY)
            output.push_back(c1);

        double y = clipY;
        double m = (c1.x-c0.x)/(c1.y-c0.y);
        double x = m * (y-c0.y) + c0.x;

        //Caso 3: in -> out
        if(c0.y >= clipY && c1.y < clipY)
            output.emplace_back(x,y);

        //Caso 4: out -> in
        if(c0.y < clipY && c1.y >= clipY){
            output.emplace_back(x,y);
            output.push_back(c1);
        }
    }
}
开发者ID:nogenem,项目名称:Computacao-Grafica-2015-2,代码行数:34,代码来源:Clipping.hpp

示例4: clipRight

void Clipping::clipRight(Coordinates& input, Coordinates& output){
    if(output.size() > 0)
        output.clear();
    if(input.size() == 0)
        return;

    double clipX = m_w->maxX;
    input.push_back(input[0]);
    for(unsigned int i = 0; i < input.size()-1; i++){
        Coordinate c0 = input[i];
        Coordinate c1 = input[i+1];

        //Caso 1: out -> out
        if(c0.x >= clipX && c1.x >= clipX){}

        //Caso 2: in -> in
        if(c0.x < clipX && c1.x < clipX)
            output.push_back(c1);

        double x = clipX;
        double m = (c1.y-c0.y)/(c1.x-c0.x);
        double y = m * (x-c0.x) + c0.y;

        //Caso 3: in -> out
        if(c0.x < clipX && c1.x >= clipX)
            output.emplace_back(x,y);

        //Caso 4: out -> in
        if(c0.x >= clipX && c1.x < clipX){
            output.emplace_back(x,y);
            output.push_back(c1);
        }
    }
}
开发者ID:nogenem,项目名称:Computacao-Grafica-2015-2,代码行数:34,代码来源:Clipping.hpp

示例5: CGException

	BezierCurve::BezierCurve(const Coordinates& coords) {
		if (coords.size() < 4 || (coords.size() - 4) % 3 != 0) {
			throw CGException("A bezier curve must be defined with 4, 7, 10, 13, 16, ... coordinates");
		}

		addCoordinate(coords);
		regeneratePath(0.1);
	}
开发者ID:CarlosBonetti,项目名称:undergrad-archive,代码行数:8,代码来源:objects.cpp

示例6: composeOutCoordinates

    void CrossJoinArray::composeOutCoordinates(Coordinates const &left, Coordinates const& rightLeftover, Coordinates& out) const
    {
        assert(left.size() == nLeftDims);
        assert(rightLeftover.size() == nRightDims - nJoinDims);
        assert(out.size() == desc.getDimensions().size());

        memcpy(&out[0], &left[0], nLeftDims*sizeof(Coordinate));
        memcpy(&out[left.size()], &rightLeftover[0], (nRightDims-nJoinDims)*sizeof(Coordinate));
    }
开发者ID:hansmire,项目名称:scidb-osx-12.10-mountain-lion,代码行数:9,代码来源:CrossJoinArray.cpp

示例7: fillVertices

 /// Converts geometry.
 void fillVertices(const Coordinates &coordinates) {
   vertices_.reserve(coordinates.size() * 3);
   for (std::size_t i = 0; i < coordinates.size(); ++i) {
     const utymap::GeoCoordinate coordinate = coordinates[i];
     vertices_.push_back(coordinate.longitude);
     vertices_.push_back(coordinate.latitude);
     vertices_.push_back(eleProvider_ == nullptr ? 0 : eleProvider_->getElevation(quadKey_, coordinate));
   }
 }
开发者ID:reinterpretcat,项目名称:utymap,代码行数:10,代码来源:Search.hpp

示例8: main

int main(int argc, char *argv[])
{
  int rows = SIZE;
  int cols = SIZE;
  bool fullyrand = true;

  BenchTimer timer;
  Coordinates coords;
  Values values;
  if(fullyrand)
  {
    Coordinates pool;
    pool.reserve(cols*NBPERROW);
    std::cerr << "fill pool" << "\n";
    for (int i=0; i<cols*NBPERROW; )
    {
//       DynamicSparseMatrix<int> stencil(SIZE,SIZE);
      Vector2i ij(ei_random<int>(0,rows-1),ei_random<int>(0,cols-1));
//       if(stencil.coeffRef(ij.x(), ij.y())==0)
      {
//         stencil.coeffRef(ij.x(), ij.y()) = 1;
        pool.push_back(ij);

      }
      ++i;
    }
    std::cerr << "pool ok" << "\n";
    int n = cols*NBPERROW*KK;
    coords.reserve(n);
    values.reserve(n);
    for (int i=0; i<n; ++i)
    {
      int i = ei_random<int>(0,pool.size());
      coords.push_back(pool[i]);
      values.push_back(ei_random<Scalar>());
    }
  }
  else
  {
    for (int j=0; j<cols; ++j)
    for (int i=0; i<NBPERROW; ++i)
    {
      coords.push_back(Vector2i(ei_random<int>(0,rows-1),j));
      values.push_back(ei_random<Scalar>());
    }
  }
  std::cout << "nnz = " << coords.size()  << "\n";
  CHECK_MEM

    // dense matrices
    #ifdef DENSEMATRIX
    {
      BENCH(setrand_eigen_dense(coords,values);)
      std::cout << "Eigen Dense\t" << timer.value() << "\n";
    }
开发者ID:B-Rich,项目名称:sim3d,代码行数:55,代码来源:sparse_setter.cpp

示例9: QCOMPARE

void Coordinates_test::
t_readonly()
{
    Coordinates c;
    QCOMPARE(c.size(), 0u);
    QCOMPARE(c.count(), 0);
    QVERIFY(c.isEmpty());
    c << 1.0 << -2.0;
    QCOMPARE(c.size(), 2u);
    QCOMPARE(c.count(), 2);
    QVERIFY(!c.isEmpty());
}//t_readonly
开发者ID:JunjieZhang,项目名称:qhull,代码行数:12,代码来源:Coordinates_test.cpp

示例10: decomposeLeftCoordinates

    void CrossJoinArray::decomposeLeftCoordinates(Coordinates const& left, Coordinates& hashKey) const
    {
        assert(left.size() == nLeftDims);
        assert(hashKey.size() == nJoinDims);

        for (size_t i =0; i<nLeftDims; i++)
        {
            if(leftJoinDims[i]!=-1)
            {
                hashKey[leftJoinDims[i]] = left[i];
            }
        }
    }
开发者ID:hansmire,项目名称:scidb-osx-12.10-mountain-lion,代码行数:13,代码来源:CrossJoinArray.cpp

示例11: MustBeTrue

int
CubicSpline<DT>::calculate(const Coordinates &xs, const Coordinates &ys,
                           DT yp1, DT ypn)
{
    MustBeTrue(xs.size() == ys.size());
    MustBeTrue((npoints_= xs.size()) > 0);
    xs_ = xs;
    ys_ = ys;
    yp1_ = yp1;
    ypn_ = ypn;
    ypps_.resize(npoints_+1);
    calculate();
    return(0);
}
开发者ID:ombt,项目名称:ombt,代码行数:14,代码来源:CubicSpline.cpp

示例12: drawPolygon

void Viewport::drawPolygon(Object* obj){
    auto coords = obj->getNCoords();
    Coordinates nCoords;
    if(coords.size() == 1){// Usuario quer um ponto?
        drawPoint(obj);
        return;
    }else if(coords.size() == 2){// Usuario quer uma linha?
        drawLine(obj);
        return;
    }

    transformCoordinates(coords, nCoords);
    prepareContext(obj);

    cairo_move_to(m_cairo, nCoords[0].x, nCoords[0].y);
    for(unsigned int i = 0; i<nCoords.size(); i++)
        cairo_line_to(m_cairo, nCoords[i].x, nCoords[i].y);

    cairo_close_path(m_cairo);

    Polygon* p = (Polygon*) obj;
    if(p->filled()){
        cairo_stroke_preserve(m_cairo);
        cairo_fill(m_cairo);
    }else
        cairo_stroke(m_cairo);
}
开发者ID:nogenem,项目名称:Computacao-Grafica-2015-2,代码行数:27,代码来源:Viewport.hpp

示例13: DelegateArray

 SplitArray::SplitArray(ArrayDesc const& desc,
                        const boost::shared_array<char>& src,
                        Coordinates const& from,
                        Coordinates const& till,
                        shared_ptr<Query>const& query)
 : DelegateArray(desc, shared_ptr<Array>(), true),
   _startingChunk(from),
   _from(from),
   _till(till),
   _size(from.size()),
   _src(src),
   _empty(false)
 {
     assert(query);
     _query = query;
     desc.getChunkPositionFor(_startingChunk);
     Dimensions const& dims = desc.getDimensions();
     for (size_t i = 0, n = dims.size(); i < n; i++) { 
         _size[i] = _till[i] - _from[i] + 1;
         if (_size[i] == 0) { 
             _empty = true;
         }
         if (_till[i] > dims[i].getEndMax()) { 
             _till[i] = dims[i].getEndMax();
         }
     }
 }
开发者ID:Goon83,项目名称:scidb,代码行数:27,代码来源:DelegateArray.cpp

示例14: QCOMPARE

void Coordinates_test::
t_convert()
{
    Coordinates c;
    c << 1.0 << 3.0;
    QCOMPARE(c.data()[1], 3.0);
    coordT *c2= c.data();
    const coordT *c3= c.data();
    QCOMPARE(c2, c3);
    std::vector<coordT> vc= c.toStdVector();
    QCOMPARE(vc.size(), c.size());
    for(size_t k= vc.size(); k--; ){
        QCOMPARE(vc[k], c[k]);
    }
    QList<coordT> qc= c.toQList();
    QCOMPARE(qc.count(), c.count());
    for(int k= qc.count(); k--; ){
        QCOMPARE(qc[k], c[k]);
    }
    Coordinates c4;
    c4= std::vector<double>(2, 0.0);
    QCOMPARE(c4.back(), 0.0);
    Coordinates c5(std::vector<double>(2, 0.0));
    QCOMPARE(c4.size(), c5.size());
    QVERIFY(c4==c5);
}//t_convert
开发者ID:jonaswitt,项目名称:nestk,代码行数:26,代码来源:Coordinates_test.cpp

示例15: coords

Fleissner::Fleissner(const Coordinates &key, const uint32_t grid_dim, const bool clockwise)
{
    Coordinates coords(key);
    setGridDimension(grid_dim);
    const uint32_t key_size = key.size();
    const uint32_t mask_size_approuved = key_size * 4;

    if (mask_size_approuved != (grid_dim * grid_dim))
    {
        throw BadKeyLength("Your key have to be square following the dimension you provided.", mask_size_approuved);
    }

    // If the rotation coordinates exist, then the mask is not valid. 
    // Mask rotations 270, 180, 90 degrees to check.
    coords.reserve(mask_size_approuved);
    std::set<Cell> rotation;

    if (clockwise)
    {
        for (const auto &xy : key)
        {
            rotationExists(rotation, xy.second, grid_dim - 1 - xy.first);
        }
    }
    else
    {
        for (const auto &xy : key)
        {
            rotationExists(rotation, grid_dim - 1 - xy.second, xy.first);
        }
    }
    coords.insert(coords.end(), rotation.begin(), rotation.end());
    rotation.clear();

    for (const auto &xy : key)
    {
        rotationExists(rotation, grid_dim - 1 - xy.first, grid_dim - 1 - xy.second);
    }
    coords.insert(coords.end(), rotation.begin(), rotation.end());
    rotation.clear();

    if (clockwise)
    {
        for (const auto &xy : key)
        {
            rotationExists(rotation, grid_dim - 1 - xy.second, xy.first);
        }
    }
    else
    {
        for (const auto &xy : key)
        {
            rotationExists(rotation, xy.second, grid_dim - 1 - xy.first);
        }
    }
    coords.insert(coords.end(), rotation.begin(), rotation.end());

    this->key = coords;
}
开发者ID:glapointe7,项目名称:CryptoGL,代码行数:59,代码来源:Fleissner.cpp


注:本文中的Coordinates::size方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。