【问题标题】:Issue with CGAL 3D periodic Delaunay triangulation with info带有信息的 CGAL 3D 周期性 Delaunay 三角剖分问题
【发布时间】:2019-12-31 15:46:44
【问题描述】:

我想使用 CGAL 构造一个带有信息的周期性 3D Delaunay 三角剖分(在本例中为整数)。对于 2D,如果我构造一个成对的向量(点、信息)并将其传递给三角测量函数,则效果很好。但是,非常类似的 3D 代码无法编译。下面是一个示例,将我自己的“粒子”格式的点转换为 CGAL 点格式。

这是 CGAL 的问题还是我遗漏了什么?

#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Periodic_3_Delaunay_triangulation_traits_3.h>
#include <CGAL/Periodic_3_Delaunay_triangulation_3.h>
#include <CGAL/Triangulation_vertex_base_with_info_3.h>
#include <CGAL/periodic_3_triangulation_3_io.h>

#include <iostream>
#include <fstream>
#include <cassert>
#include <list>
#include <vector>

typedef CGAL::Exact_predicates_inexact_constructions_kernel            K;
typedef CGAL::Periodic_3_Delaunay_triangulation_traits_3<K>            Gt;

typedef CGAL::Periodic_3_triangulation_ds_vertex_base_3<>              VbDS;
typedef CGAL::Triangulation_vertex_base_3<Gt, VbDS>                    Vb;
typedef CGAL::Triangulation_vertex_base_with_info_3<unsigned, Gt, Vb>  VbInfo;

typedef CGAL::Periodic_3_triangulation_ds_cell_base_3<>                CbDS;
typedef CGAL::Triangulation_cell_base_3<Gt, CbDS>                      Cb;

typedef CGAL::Triangulation_data_structure_3<VbInfo, Cb>               Tds;

typedef CGAL::Delaunay_triangulation_3<K, Tds>                         DT3;
typedef CGAL::Periodic_3_Delaunay_triangulation_3<Gt, Tds>             P3DT3;

typedef P3DT3::Point               Point;
typedef P3DT3::Iso_cuboid          Iso_cuboid;

void create_PDT_3D(const std::vector<particle>& grid )
{
     // The cube for the periodic domain
     Iso_cuboid domain(0,0,0,1,1,1); 

     // Convert "particle" format to "point with info" format
     std::vector<Point> points_bare;
     std::vector< std::pair<Point,unsigned> > points_info;

     points_bare.reserve(grid.size());
     points_info.reserve(grid.size());

     // the "info" is just given by the index of the point
     for (unsigned i = 0; i < grid.size(); ++i )
     {
          points_bare.emplace_back( Point(grid[i].x, grid[i].y, grid[i].z) );
          points_info.emplace_back( std::make_pair( Point(grid[i].x, grid[i].y, grid[i].z), i ) );
     }

     // Triangulate
     DT3 Ta    ( points_bare.begin(), points_bare.end() );         // working
     DT3 Tb    ( points_info.begin(), points_info.end() );         // working

     // Triangulate (periodic)
     P3DT3 TTa ( points_bare.begin(), points_bare.end(), domain ); // working
     P3DT3 TTb ( points_info.begin(), points_info.end(), domain ); // NOT working
}

其中“粒子”是一个非常简单的类

class particle
{
     public:
          double x, y, z;
          particle(double xr=0, double yr=0, double zr=0) : x(xr), y(yr), z(zr) {};
};

【问题讨论】:

    标签: c++ cgal delaunay


    【解决方案1】:

    CGAL 中的 3D 周期性三角剖分没有必要的代码来插入包含信息的点范围。这并不是因为一个强大的障碍使其无法实施,它只是没有完成。

    然而,将代码从 2D 周期性三角剖分转换为 3D 情况几乎应该是立即的:您可以查看函数 insert_with_info() 以及它在类 Periodic_2_Delaunay_triangulation_2 中的使用方式。 3D 的代码几乎相同。

    如果您需要帮助,请告诉我进展情况。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-12-23
      • 2020-05-06
      • 1970-01-01
      • 1970-01-01
      • 2015-01-07
      • 1970-01-01
      • 1970-01-01
      • 2011-11-12
      相关资源
      最近更新 更多