【问题标题】:CGAL insert_constraintCGAL insert_constraint
【发布时间】:2021-01-06 22:57:46
【问题描述】:

我正在构建一个可以拦截自身的带有约束的地形,因此我将 CDT 的第三个参数更改为 CGAL::Exact_intersections_tag。我认为在插入约束中出现错误的唯一原因是,在没有正确标记的情况下交叉约束但仍然在 CDT::insert_constrain 上发生错误。异常文本为空,所以我被卡住了,无法验证原因并修复代码。插入代码是:

ct.insert_constraint(P.vertices_begin(), P.vertices_end(), closed);

closed 是一个布尔值,当约束关闭(多边形)时为真。

是一个有 500.000 个点的大曲面。在我的代码中,错误发生在:

ct.insert_constraint(P.vertices_begin(), P.vertices_end(),closed);

CGAL 文件是 Polyline_constraint_hierarchy_2.h。

异常数据是:

expr -> false
file -> file = 0x00007ffbeb81d6b0 "C:\\dev\\CGAL- 
5.0\\include\\CGAL\\Triangulation_2\\internal\\Polyline_constraint_hierarchy_2.h"
line -> 1016
msg -> ""

文件Polyline_constraint_hierarchy_2.h上的代码是:

template <class T, class Compare, class Data>
void 
Polyline_constraint_hierarchy_2<T,Compare,Data>::
add_Steiner(T va, T vb, T vc){
Context_list* hcl=nullptr;
if(!get_contexts(va,vb,hcl)) CGAL_triangulation_assertion(false);  <<--- here

Context_list* hcl2 = new  Context_list;

Vertex_it      pos;
...

确定问题出在get_contexts

谢谢。

【问题讨论】:

  • 您能否提供一个我们可以编译和运行的最小示例来显示问题?
  • 好的 Sloriot,我会做一个例子并发布它。我会花一两天时间来做,因为现在我没有时间。谢谢。
  • 注意这里可以直接提交github.com/CGAL/cgal/issues
  • 好的,我会的。谢谢。

标签: c++ eclipse-cdt cgal


【解决方案1】:

按照我制作的测试文件来显示错误。

它不是 exe 文件,而是我在我的 dll 中包含的用于 CGAL 函数的函数。插入多边形编号 1790 时出现的错误。

#include <iostream>
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Projection_traits_xy_3.h>
#include <CGAL/Polygon_2.h>
#include <CGAL/Constrained_Delaunay_triangulation_2.h>
#include <CGAL/Constrained_triangulation_plus_2.h>
#include <CGAL/Polyline_simplification_2/simplify.h>
#include <CGAL/Polyline_simplification_2/Squared_distance_cost.h>
#include <CGAL/Polyline_simplification_2/Scaled_squared_distance_cost.h>
#include <CGAL/Constrained_triangulation_2.h>

namespace PS = CGAL::Polyline_simplification_2;

typedef CGAL::Exact_predicates_inexact_constructions_kernel Epic;
typedef CGAL::Projection_traits_xy_3<Epic>  K;
typedef CGAL::Polygon_2<K> Polygon_2;
typedef PS::Vertex_base_2<K> Vb;
typedef CGAL::Constrained_triangulation_face_base_2<K> Fb;
typedef CGAL::Triangulation_data_structure_2<Vb, Fb> TDS;
typedef CGAL::Constrained_Delaunay_triangulation_2<K, TDS, CGAL::Exact_predicates_tag> 
CDT;
typedef CGAL::Constrained_triangulation_plus_2<CDT> CT;
typedef CT::Point Point;
typedef CT::Constraint_iterator Constraint_iterator;
typedef CT::Vertices_in_constraint_iterator Vertices_in_constraint_iterator;
typedef CT::Points_in_constraint_iterator Points_in_constraint_iterator;
typedef PS::Stop_below_count_ratio_threshold Stop;
typedef PS::Squared_distance_cost CostSquare;
typedef PS::Hybrid_squared_distance_cost<double> CostHybrid;
typedef CGAL::Polygon_2<K> Polygon_2_2;

#define _AFXDLL 
#include "..\stdafx.h"
#include <set>
#include "afxtempl.h"

int TesteCGAL()
{
  std::ifstream ArqTrian("C:\\Users\\carlo\\Documents\\CampoGolf.pon", 
  std::fstream::in);

  if (!ArqTrian.good())
  {
    AfxMessageBox("Error reading file");

    exit(0);
  }

  int C(0);
  size_t QtdPoints(0);
  char Separator;
  int i(0), Closed(0);

  CT ct;

  while (ArqTrian.good())
  {
    ArqTrian >> i >> Separator >> Closed >> Separator;

    Polygon_2_2 P;
    double x, y, z;

    for (ArqTrian >> QtdPoints; QtdPoints; --QtdPoints)
    {
      ArqTrian >> x >> Separator >> y >> Separator >> z;

      P.push_back(Point(x, y, z));
    }

    ct.insert_constraint(P.vertices_begin(), P.vertices_end(), (bool)Closed);
  }

  return 0;
}

如何发布带有积分的文件?

【讨论】:

    猜你喜欢
    • 2023-03-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-06
    • 1970-01-01
    • 1970-01-01
    • 2013-01-24
    • 1970-01-01
    相关资源
    最近更新 更多