2010-01-14 22 views
14

में चेहरे पर फिर से कैसे सक्रिय करूं मैं कुछ डेलाउने त्रिकोण करने के लिए सीजीएएल का उपयोग करने की कोशिश कर रहा हूं। मैंने त्रिकोण के गणना के लिए सीजीएएल नमूने में से एक का उपयोग किया जिसमें ऊंचाई क्षेत्र विशेषता शामिल है।मैं CGAL

मेरी समस्या यह है कि मुझे नहीं पता कि परिणामस्वरूप त्रिभुज कैसे प्राप्त करें। मुझे पता चला कि face_iterator कैसे प्राप्त करें, लेकिन मुझे नहीं पता कि वहां से क्या करना है। मैं जो उम्मीद कर रहा हूं वह प्रत्येक त्रिकोण पर 3 अंकों में से प्रत्येक के लिए बिंदु सरणी में एक सूचकांक है।

मैं मुसीबत नेस्टेड टेम्पलेट्स के सभी से जूझने आ रही हैं:

#include <CGAL/Exact_predicates_inexact_constructions_kernel.h> 
#include <CGAL/Triangulation_euclidean_traits_xy_3.h> 
#include <CGAL/Delaunay_triangulation_2.h> 

typedef CGAL::Exact_predicates_inexact_constructions_kernel K; 
typedef CGAL::Triangulation_euclidean_traits_xy_3<K> Gt; 
typedef CGAL::Delaunay_triangulation_2<Gt> Delaunay; 
typedef K::Point_3 Point; 

int main() 
{ 
    //initialize the points with some trivial data 
    std::vector<Point> pts; 
    pts.push_back(Point(1., 2., 3.)); 
    pts.push_back(Point(2., 2., 3.)); 
    pts.push_back(Point(1., 3., 3.)); 
    pts.push_back(Point(4., 2., 3.));  

    //create a delaunay triangulation 
    Delaunay dt; 
    dt.insert(pts.begin(), pts.end()); 

    //iterate through the faces 
    Delaunay::Finite_faces_iterator it; 
    for (it = dt.finite_faces_begin(); it != dt.finite_faces_end(); it++) 
    { 
     //What do I do here?? 
    } 

    return 0; 
} 
+0

it.something ... सब पर कोड पूर्णता मदद करता है? –

+1

विजुअल स्टूडियो 2008 इस कोड पर कोड पूरा करने में असमर्थ है :( –

+0

Delaunay :: Finite_faces_iterator को हाइलाइट करें और परिभाषा पर जाएं। .h फ़ाइल का पता लगाएं और देखें कि कौन से फ़ंक्शन उपलब्ध हैं। यह होगा।

उत्तर

1

यहाँ गूगल से एक उदाहरण है। Finite_faces_iterator टाइप किया गया था।

Interval_skip_list isl; 
    for(Finite_faces_iterator fh = dt.finite_faces_begin(); 
     fh != dt.finite_faces_end(); 
     ++fh){ 
    isl.insert(Interval(fh)); 
    } 
    std::list<Interval> level; 
    isl.find_intervals(50, std::back_inserter(level)); 
    for(std::list<Interval>::iterator it = level.begin(); 
     it != level.end(); 
     ++it){ 
    std::cout << dt.triangle(it->face_handle()) << std::endl; 
    } 

यह आप क्या चाहते हैं नहीं करता है, लेकिन आप क्या पुनरावर्तक साथ किया जा सकता का एक उदाहरण देता है।

+1

इटेटर स्वयं स्वयं एसएलएल इटरेटर्स हैं। मुद्दा यह है कि मैं यह नहीं समझ सकता कि इटेटरेटर क्या इंगित कर रहा है (संभवतः एक चेहरा या पहलू या कुछ) –

0

आप कैसे वास्तव में आप क्या चाहते हैं करने के लिए की एक बहुत विस्तृत उदाहरण चाहते हैं, यहाँ से एक्स-विमान दृश्यों उपकरणों के लिए स्रोत पर एक नज़र डालें: http://scenery.x-plane.com/code.php

विस्तारित उदाहरण से, मैं के एक जोड़े मतलब सौ हजार लाइनें, लेकिन लगभग सभी चीजों का उपयोग CGAL Delaunay त्रिकोण और विस्तारित विशेषताओं के साथ कर सकता है।

10

आप फेस (इटरेटर) से संबंधित त्रिभुज में कनवर्ट करने के लिए Delaunay::triangle का उपयोग कर सकते हैं। यह CGAL 3.8 के तहत परीक्षण किया जाता है

// points.cin contains point pairs, e.g., 
// 3 5 
// 0 0 
// 1 9 
// ... 
#include <CGAL/Exact_predicates_exact_constructions_kernel.h> 
#include <CGAL/Delaunay_triangulation_2.h> 
#include <fstream> 

typedef CGAL::Exact_predicates_exact_constructions_kernel K; 
typedef CGAL::Delaunay_triangulation_2<K> Delaunay; 
typedef K::Point_2 Point; 

int main() 
{ 
    std::ifstream in("points.cin"); 
    std::istream_iterator<Point> begin(in); 
    std::istream_iterator<Point> end; 

    Delaunay dt; 
    dt.insert(begin, end); 

    Delaunay::Finite_faces_iterator it; 
    for (it = dt.finite_faces_begin(); it != dt.finite_faces_end(); it++) 
    { 
    std::cout << dt.triangle(it) << std::endl; 
    } 

    return 0; 
} 
4

एक त्रिकोण के एक शीर्ष dt.triangle का उपयोग कर (यह) [IDX], जहां यह एक चेहरे इटरेटर और IDX है पहुँचा जा सकता है शिखर संख्या (0 ,1 या 2)। नीचे दिए गए उदाहरण में, एक कशेरुक एक पॉइंट_2 ऑब्जेक्ट है, इसके कार्टेशियन निर्देशांक को x() और y() विधियों का उपयोग करके एक्सेस किया जा सकता है।

#include <CGAL/Exact_predicates_inexact_constructions_kernel.h> 
#include <CGAL/Triangulation_euclidean_traits_2.h> 
#include <CGAL/Delaunay_triangulation_2.h> 

typedef CGAL::Exact_predicates_inexact_constructions_kernel K; 
typedef CGAL::Triangulation_euclidean_traits_2<K> Gt; 
typedef CGAL::Delaunay_triangulation_2<Gt> Delaunay; 

typedef K::Point_2 Point_2; 
typedef std::vector<Point_2> Points; 

int main() 
{ 
    Points points; 
    points.push_back(Point_2(0,0)); 
    points.push_back(Point_2(0,7)); 
    points.push_back(Point_2(7,0)); 
    points.push_back(Point_2(7,7)); 

    Delaunay dt(points.begin(), points.end()); 

    // Print Cartesian coordinates of vertices of triangles in 2D Delaunay triangulation 
    for (Delaunay::Finite_faces_iterator it = dt.finite_faces_begin(); it != dt.finite_faces_end(); it++) 
    { 
     std::cout << " " << dt.triangle(it)[0].x() << " " << dt.triangle(it)[0].y() << " "; 
     std::cout << " " << dt.triangle(it)[1].x() << " " << dt.triangle(it)[1].y() << " "; 
     std::cout << " " << dt.triangle(it)[2].x() << " " << dt.triangle(it)[2].y() << " "; 
     std::cout << std::endl << "-------------------" << std::endl; 
    } 
    return 0; 
} 
0

खैर मैं सिर्फ एक समान समस्या है जहाँ मैं अनुसंधान के एक बहुत कुछ किया (मुख्य रूप से, क्योंकि मैं सी ++ के किसी भी ज्ञान नहीं था) था। मैं इसके वर्टेक्स पूर्णांक प्रतिनिधित्व द्वारा त्रिभुज मुद्रित करने में सक्षम होना चाहता था। यहाँ यह है कि यह कैसे दिखता है:

#include <CGAL/Surface_mesh_default_triangulation_3.h> 
#include <CGAL/Complex_2_in_triangulation_3.h> 
#include <CGAL/make_surface_mesh.h> 
#include <CGAL/Implicit_surface_3.h> 

// This is the file where you can look for an example of iterating, geting basic vertex positions, outputing triangles 
// #include <CGAL/IO/Complex_2_in_triangulation_3_file_writer.h> 

// default triangulation for Surface_mesher 
typedef CGAL::Surface_mesh_default_triangulation_3 Tr; 

// c2t3 
typedef CGAL::Complex_2_in_triangulation_3<Tr> C2t3; 

typedef Tr::Geom_traits GT; 
typedef GT::Sphere_3 Sphere_3; 
typedef GT::Point_3 Point_3; 
typedef GT::FT FT; 

typedef FT (*Function)(Point_3); 

typedef CGAL::Implicit_surface_3<GT, Function> Surface_3; 

// This already have been defined 
//typedef typename C2t3::Triangulation Tr; 
typedef typename Tr::Vertex_handle Vertex_handle; 
typedef typename Tr::Finite_vertices_iterator Finite_vertices_iterator; 
typedef typename Tr::Finite_facets_iterator Finite_facets_iterator; 

typedef typename Tr::Point Point; 


FT sphere_function (Point_3 p) { 
    const FT x = p.x(); 
    const FT y = p.y(); 
    const FT z = p.z(); 

    //const FT x2=p.x()*p.x(), y2=p.y()*p.y(), z2=p.z()*p.z(); 
    const FT a = 2; 
    const FT b = 1; 
    const FT c = 1.5; 
    return x*x/a/a + y*y/b/b + z*z/c/c -1; 
} 

int main() { 
    Tr tr;   // 3D-Delaunay triangulation 
    C2t3 c2t3 (tr); // 2D-complex in 3D-Delaunay triangulation 

    // defining the surface 
    Surface_3 surface(sphere_function,    // pointer to function 
        Sphere_3(CGAL::ORIGIN, 2.)); // bounding sphere 
    // Note that "2." above is the *squared* radius of the bounding sphere! 

    // defining meshing criteria 
    CGAL::Surface_mesh_default_criteria_3<Tr> criteria(30., // angular bound 
                0.1, // radius bound 
                0.1); // distance bound 
    // meshing surface 
    CGAL::make_surface_mesh(c2t3, surface, criteria, CGAL::Non_manifold_tag()); 

    std::cout << "Final number of points: " << tr.number_of_vertices() << "\n"; 

    // Here should be the main code 

    Tr& tr2 = c2t3.triangulation(); 

    std::map<Vertex_handle, int> V; 
    int inum = 0; 
    Finite_vertices_iterator vit = tr2.finite_vertices_begin(); 
    while(vit != tr2.finite_vertices_end()) { 

    // making an integer representation of vertex pointers 
    V[vit] = inum++; 

    // obtaining vertex positions from vertex pointer vit 
    Point p = static_cast<Point>(vit->point()); 
    std::cout << p.x() << " " << p.y() << " " << p.z() << std::endl; 

    ++vit; 
    } 

    Finite_facets_iterator fit = tr2.finite_facets_begin(); 

    while (fit != tr2.finite_facets_end()) { 

    typename Tr::Cell_handle cell = fit->first; 
    const int& index = fit->second; 

    int index1 = V[cell->vertex(tr.vertex_triple_index(index, 0))]; 
    int index2 = V[cell->vertex(tr.vertex_triple_index(index, 1))]; 
    int index3 = V[cell->vertex(tr.vertex_triple_index(index, 2))]; 

    std::cout << index1 << " " << index2 << " " << index3 << std::endl; 
    ++fit; 
    } 

} 

साथ यह संकलन (यदि mesh_implicit_function स्रोत, वस्तु फ़ाइल, और निष्पादन योग्य है):

c++ -DCGAL_USE_GMP -DCGAL_USE_MPFR -DCGAL_USE_ZLIB -frounding-math -o mesh_an_implicit_function.cpp.o -c mesh_an_implicit_function.cpp 
c++ mesh_an_implicit_function.cpp.o -o mesh_an_implicit_function -lmpfr -lgmp -lCGAL -lboost_thread