首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >CGAL insert_constraint

CGAL insert_constraint
EN

Stack Overflow用户
提问于 2020-12-31 19:22:39
回答 1查看 95关注 0票数 0

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

代码语言:javascript
复制
ct.insert_constraint(P.vertices_begin(), P.vertices_end(), closed);

闭合是一个布尔值,当约束为闭合(多边形)时,该布尔值为true。

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

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

CGAL文件是Polyline_constraint_hierarchy_2.h。

例外数据为:

代码语言:javascript
复制
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上的代码是:

代码语言:javascript
复制
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

谢谢。

EN

回答 1

Stack Overflow用户

发布于 2021-01-06 21:42:11

按照我创建的测试文件来显示错误。

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

代码语言:javascript
复制
#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;
}

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65520212

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档