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


C++ PlainObjectBase::end方法代码示例

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


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

示例1: abs

void igl::copyleft::cgal::order_facets_around_edge(
    const Eigen::PlainObjectBase<DerivedV>& V,
    const Eigen::PlainObjectBase<DerivedF>& F,
    size_t s,
    size_t d, 
    const std::vector<int>& adj_faces,
    Eigen::PlainObjectBase<DerivedI>& order, bool debug)
{
  // Although we only need exact predicates in the algorithm,
  // exact constructions are needed to avoid degeneracies due to
  // casting to double.
  typedef CGAL::Exact_predicates_exact_constructions_kernel K;
  typedef K::Point_3 Point_3;
  typedef K::Plane_3 Plane_3;

  auto get_face_index = [&](int adj_f)->size_t
  {
    return abs(adj_f) - 1;
  };

  auto get_opposite_vertex = [&](size_t fid)->size_t
  {
    typedef typename DerivedF::Scalar Index;
    if (F(fid, 0) != (Index)s && F(fid, 0) != (Index)d) return F(fid, 0);
    if (F(fid, 1) != (Index)s && F(fid, 1) != (Index)d) return F(fid, 1);
    if (F(fid, 2) != (Index)s && F(fid, 2) != (Index)d) return F(fid, 2);
    assert(false);
    return -1;
  };

  // Handle base cases
  if (adj_faces.size() == 0) 
  {
    order.resize(0, 1);
    return;
  } else if (adj_faces.size() == 1)
  {
    order.resize(1, 1);
    order(0, 0) = 0;
    return;
  } else if (adj_faces.size() == 2)
  {
    const size_t o1 = get_opposite_vertex(get_face_index(adj_faces[0]));
    const size_t o2 = get_opposite_vertex(get_face_index(adj_faces[1]));
    const Point_3 ps(V(s, 0), V(s, 1), V(s, 2));
    const Point_3 pd(V(d, 0), V(d, 1), V(d, 2));
    const Point_3 p1(V(o1, 0), V(o1, 1), V(o1, 2));
    const Point_3 p2(V(o2, 0), V(o2, 1), V(o2, 2));
    order.resize(2, 1);
    switch (CGAL::orientation(ps, pd, p1, p2))
    {
      case CGAL::POSITIVE:
        order(0, 0) = 1;
        order(1, 0) = 0;
        break;
      case CGAL::NEGATIVE:
        order(0, 0) = 0;
        order(1, 0) = 1;
        break;
      case CGAL::COPLANAR:
        {
          switch (CGAL::coplanar_orientation(ps, pd, p1, p2)) {
            case CGAL::POSITIVE:
              // Duplicated face, use index to break tie.
              order(0, 0) = adj_faces[0] < adj_faces[1] ? 0:1;
              order(1, 0) = adj_faces[0] < adj_faces[1] ? 1:0;
              break;
            case CGAL::NEGATIVE:
              // Coplanar faces, one on each side of the edge.
              // It is equally valid to order them (0, 1) or (1, 0).
              // I cannot think of any reason to prefer one to the
              // other.  So just use (0, 1) ordering by default.
              order(0, 0) = 0;
              order(1, 0) = 1;
              break;
            case CGAL::COLLINEAR:
              std::cerr << "Degenerated triangle detected." <<
                std::endl;
              assert(false);
              break;
            default:
              assert(false);
          }
        }
        break;
      default:
        assert(false);
    }
    return;
  }

  const size_t num_adj_faces = adj_faces.size();
  const size_t o = get_opposite_vertex( get_face_index(adj_faces[0]));
  const Point_3 p_s(V(s, 0), V(s, 1), V(s, 2));
  const Point_3 p_d(V(d, 0), V(d, 1), V(d, 2));
  const Point_3 p_o(V(o, 0), V(o, 1), V(o, 2));
  const Plane_3 separator(p_s, p_d, p_o);
  if (separator.is_degenerate()) {
    throw std::runtime_error(
        "Cannot order facets around edge due to degenerated facets");
//.........这里部分代码省略.........
开发者ID:AurelGruber,项目名称:Scalable-Locally-Injective-Mappings,代码行数:101,代码来源:order_facets_around_edge.cpp


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