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


C++ Simplex::get_ngb方法代码示例

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


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

示例1: construct

void VorTess::construct() {
    LOGS("Starting VorTess construction");
    _delaunay->set_relations();
    vector<VorGen*> points = _delaunay->get_points();
    for(unsigned int i = 0; i < _delaunay->get_size(); i++) {
        if(!points[i]) {
            continue;
        }
        _cells.push_back(new VorCell(points[i]));
        points[i]->set_cell(_cells.back());
        list<Simplex*> tetrahedra = points[i]->get_tetrahedra();
        // walk around the triangles in counterclockwise order
        Simplex* current = *(tetrahedra.begin());
        // iindex is the index of the central point in the current triangle
        int iindex = current->get_index(i);
        unsigned int* cvorgens = current->get_vorgens();
        VorGen* cpoints[3] = {points[cvorgens[0]], points[cvorgens[1]],
                              points[cvorgens[2]]};
        // start is the first point in counterclockwise order after the central
        // point
        VorGen* start = cpoints[(iindex + 1) % 3];
        // next is the second point in counterclockwise order after the central
        // point
        // it will be the first point after the central point in the next
        // triangle
        VorGen* next = cpoints[(iindex + 2) % 3];
        unsigned int vnext = cvorgens[(iindex + 2) % 3];
        // prevsp is the midpoint of the circumsphere of the current triangle
        VorGen* prevsp = current->get_special_point(points);
        // firstsp is the first midpoint, to be used in the end to connect the
        // final edge
        VorGen* firstsp = prevsp;
        // cursp is the midpoint of the circumsphere of the next triangle, which
        // becomes the current triangle at the start of every iteration
        VorGen* cursp = NULL;
        // iterate until next == start, at this point, we have completed a full
        // walk-around
        while(next != start) {
            // use the information stored in the current triangle to retrieve
            // absolute index information for the next triangle without
            // searching for points
            int nindex = current->get_ngbindex((iindex + 1) % 3);
            // go to the next triangle
            current =
                    _delaunay->get_simplex(current->get_ngb((iindex + 1) % 3));
            cursp = current->get_special_point(points);
            //      double distance = fabs(cursp->distance(*prevsp));
            VorFace* face;
            // every face is only constructed once
            // if the point on the other side does not have a cell
            // associated with it, then it is either a ghost point
            // or it is not yet processed
            // either way, this point (and cell) becomes the owner
            // of the face
            if(next->get_cell() == NULL) {
                _faces.push_back(new VorFace(i, points));
                face = _faces.back();
                _cells.back()->add_face(face);
                face->add_vertex(prevsp);
                face->add_vertex(cursp);
                face->add_ngb(next);
                face->add_ngb_id(next->get_particle_id());
                face->calculate_area();
                // try to solve problems with accuracy
                if(prevsp->distance(*cursp) < 1.e-13) {
                    face->set_area(0.);
                }
                face->calculate_midpoint();
            } else {
                face = next->get_cell()->get_face(points[i]);
                _cells.back()->add_face(face);
            }
            // store the neighbour relations
            _cells.back()->add_ngb(next);
            _cells.back()->add_ngb_id(vnext);
            cvorgens = current->get_vorgens();
            cpoints[0] = points[cvorgens[0]];
            cpoints[1] = points[cvorgens[1]];
            cpoints[2] = points[cvorgens[2]];
            // update loop variables
            next = cpoints[nindex];
            vnext = cvorgens[nindex];
            iindex = (nindex + 1) % 3;
            prevsp = cursp;
        }
        VorFace* face;
        // construct the final face
        if(next->get_cell() == NULL) {
            _faces.push_back(new VorFace(i, points));
            face = _faces.back();
            _cells.back()->add_face(face);
            face->add_vertex(prevsp);
            face->add_vertex(firstsp);
            face->add_ngb(next);
            face->add_ngb_id(next->get_particle_id());
            face->calculate_area();
            // try to solve problems with accuracy
            if(prevsp->distance(*firstsp) < 1.e-13) {
                face->set_area(0.);
            }
//.........这里部分代码省略.........
开发者ID:JackieXie168,项目名称:shadowfax,代码行数:101,代码来源:VorTess.cpp


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