2014-01-17 14 views
2

삼각형 객체에 정보를 추가하기 전에 (int와 같은) 정보를 점에 첨부하는 것이 가능합니다. 필자는 텍스쳐 좌표를 정의하기 위해 lateron을 사용하는 int-flag와 인덱싱 된 VBO를 생성 할 수 있도록 내가 사용하는 인덱스를 필요로하므로이 작업을 수행합니다. http://doc.cgal.org/latest/Triangulation_2/Triangulation_2_2info_insert_with_pair_iterator_2_8cpp-example.htmlCGAL : 2D 구속 Delaunay 삼각 측량 - 구속 조건에 정보 추가

그러나 대신에 포인트 제한 조건을 삽입하고 싶습니다. 두 점을 모두 삽입하면 점에 두 번 (점으로 한 번, 구속 된 모서리의 점으로 한 번) 급지 되었기 때문에 이상한 결과를 반환합니다. http://doc.cgal.org/latest/Triangulation_2/Triangulation_2_2constrained_8cpp-example.html

는 점 정보와 같은 방법으로 연결할 수 있습니다 나는 결과 얼굴을 반복하기 전에 나는 단지이 기능 ​​cdt.insert_constraint(Point(j,0), Point(j,6));을 사용할 수 있도록 "제한"에?

Lateron 내가 삼각형을 반복 할 때 나는 내가 정의한 int-flag에 접근 할 방법이 필요하다. acutal 포인트하지만 제약 조건에 의해 정의 된 세그먼트의 "끝"에서이 아니라 같이 가장자리 : Constrained (Delaunay) Triangulation :

for(CDT::Finite_faces_iterator fit = m_cdt.finite_faces_begin(); fit != m_cdt.finite_faces_end(); ++fit, ++k) { 

    int j = k*3; 
    for(int i=0; i < 3; i++) { 

     indices[j+i] = fit->vertex(i)->info().first; 
    } 
} 

이 질문은 내가 여기에 게시 또 다른 질문의 일부입니다. 그것은 자체의 질문이기 때문에 두 번째로 독립적으로 게시했습니다.

+0

이 보이는 마침내 그것을 해결처럼! 이 지침을 따름 : http://doc.cgal.org/latest/Kernel_23/index.html#sectionextensiblekernel – HesselKRaymond

+0

해결책에 대한 설명과 함께 자기 대답을 게시 할 수 있습니까? 나는 Anders와 당신이 당신의 코멘트에 묘사 한 것을 확신하지 못합니다. – lrineau

답변

0

질문의 저자는 해결책을 찾았지만 답변을 게시하지 않았습니다. 그래서 나는 그것을 할 것입니다.


공식 웹 사이트에 그 examplesexplanation에있는 대답.

Point에 맞춤 클래스 만 필요한 경우를 설명합니다.

MyPointC2의 출처를 가져 와서 필요한 부분을 수정/추가하십시오.

#ifndef MYKERNEL_H 
#define MYKERNEL_H 
#include <CGAL/Cartesian.h> 
#include "Point_i2.h" 

// K_ is the new kernel, and K_Base is the old kernel 
template < typename K_, typename K_Base > 
class MyCartesian_base 
    : public K_Base::template Base<K_>::Type 
{ 
    typedef typename K_Base::template Base<K_>::Type OldK; 
public: 
    typedef K_        Kernel; 
    typedef Point_i2       Point_2; 

    template < typename Kernel2 > 
    struct Base { typedef MyCartesian_base<Kernel2, K_Base> Type; }; 
}; 
template < typename FT_ > 
struct MyKernel 
    : public CGAL::Type_equality_wrapper< 
       MyCartesian_base<MyKernel<FT_>, CGAL::Cartesian<FT_> >, 
       MyKernel<FT_> > 
{}; 

을 그리고 지금 우리는 기본적 대신에 우리의 새로운 커널을 사용할 수 있습니다 :

#ifndef MY_POINTC2_H 
#define MY_POINTC2_H 
#include <CGAL/Origin.h> 

class Point_i2 { 
private: 
    double vec[2]; 
    int ind; 
public: 
    Point_i2() : ind(0) 
    { 
    *vec = 0; 
    *(vec+1) = 0; 
    } 
    Point_i2(const double x, const double y, int i = 0) : ind(i) 
    { 
    *vec = x; 
    *(vec+1) = y; 
    } 
    const double& x() const { return *vec; } 
    const double& y() const { return *(vec+1); } 
    double & x() { return *vec; } 
    double& y() { return *(vec+1); } 
    int index() const { return ind; } 
    int& index() { return ind; } 
    bool operator==(const Point_i2 &p) const 
    { 
    return (*vec == *(p.vec)) && (*(vec+1) == *(p.vec + 1) && (ind == p.ind)); 
    } 
    bool operator!=(const Point_i2 &p) const 
    { 
     return !(*this == p); 
    } 
}; 
#endif // MY_POINTC2_H 

그런 다음 새로운 커널을

typedef MyKernel<double>     MK; 
typedef CGAL::Filtered_kernel_adaptor<MK> K;