⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 parameterization_polyhedron_adaptor_ex.h

📁 很多二维 三维几何计算算法 C++ 类库
💻 H
📖 第 1 页 / 共 3 页
字号:
// Copyright (c) 2005  INRIA (France).// All rights reserved.//// This file is part of CGAL (www.cgal.org); you may redistribute it under// the terms of the Q Public License version 1.0.// See the file LICENSE.QPL distributed with CGAL.//// Licensees holding a valid commercial license may use this file in// accordance with the commercial license agreement provided with the software.//// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.//// $URL: svn+ssh://scm.gforge.inria.fr/svn/cgal/branches/CGAL-3.3-branch/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/include/Parameterization_polyhedron_adaptor_ex.h $// $Id: Parameterization_polyhedron_adaptor_ex.h 38428 2007-04-24 13:34:11Z lsaboret $////// Author(s)     : Laurent Saboret, Pierre Alliez, Bruno Levy#ifndef PARAMETERIZATION_POLYHEDRON_ADAPTOREX_H#define PARAMETERIZATION_POLYHEDRON_ADAPTOREX_H#include <CGAL/iterator.h>#include <CGAL/circulator.h>#include <CGAL/Convertible_iterator_project.h>#include <CGAL/Convertible_circulator_project.h>#include "Polyhedron_ex.h"#include <list>#include <cassert>// Class Parameterization_polyhedron_adaptor_ex// Model of ParameterizationPatchableMesh_3 concept, whose purpose is to allow// the Surface_mesh_parameterization package to access meshes in a uniform manner.//// Parameterization_polyhedron_adaptor_ex is an adaptor class to access to a Polyhedron_ex// 3D mesh using ParameterizationPatchableMesh_3 interface.//// The input mesh can be of any genus.// It can have have any number of borders. Its "main border"// will be the mesh's longest border (if there is at least one border).//// Design Pattern:// Parameterization_polyhedron_adaptor_ex is an Adaptor [GHJV95]: it changes the// Polyhedron_ex interface to match the ParameterizationPatchableMesh_3 conceptclass Parameterization_polyhedron_adaptor_ex{// Forward referencesprivate:    struct                                  Project_halfedge_vertex;    struct                                  Project_vertex_handle_vertex;    struct                                  Project_opposite_halfedge_vertex;// Private typesprivate:    // Halfedge    typedef Polyhedron_ex::Halfedge         Halfedge;    typedef Polyhedron_ex::Halfedge_handle  Halfedge_handle;    typedef Polyhedron_ex::Halfedge_const_handle                                            Halfedge_const_handle;    typedef Polyhedron_ex::Halfedge_iterator Halfedge_iterator;    typedef Polyhedron_ex::Halfedge_const_iterator                                            Halfedge_const_iterator;    typedef Polyhedron_ex::Halfedge_around_vertex_circulator                                            Halfedge_around_vertex_circulator;    typedef Polyhedron_ex::Halfedge_around_vertex_const_circulator                                            Halfedge_around_vertex_const_circulator;    typedef Polyhedron_ex::Halfedge_around_facet_circulator                                            Halfedge_around_facet_circulator;    typedef Polyhedron_ex::Halfedge_around_facet_const_circulator                                            Halfedge_around_facet_const_circulator;// Public typespublic:    //******************************************************************    // LEVEL 1 INTERFACE:    // for "normal" classes that do not deal with virtual seams    // Example: all parameterization methods    //******************************************************************    // Number type    typedef Polyhedron_ex::Traits::FT       NT;    // Points and vectors    typedef Polyhedron_ex::Traits::Point_2  Point_2;    typedef Polyhedron_ex::Traits::Point_3  Point_3;    typedef Polyhedron_ex::Traits::Vector_2 Vector_2;    typedef Polyhedron_ex::Traits::Vector_3 Vector_3;    // Facet    typedef Polyhedron_ex::Facet            Facet;    typedef Polyhedron_ex::Facet_handle     Facet_handle;    typedef Polyhedron_ex::Facet_const_handle Facet_const_handle;    // Iterator over all mesh facets    typedef Polyhedron_ex::Facet_iterator   Facet_iterator;    typedef Polyhedron_ex::Facet_const_iterator                                            Facet_const_iterator;    // Vertex    typedef Polyhedron_ex::Vertex           Vertex;    typedef Polyhedron_ex::Vertex_handle    Vertex_handle;    typedef Polyhedron_ex::Vertex_const_handle Vertex_const_handle;    // Iterator over all mesh vertices    typedef Polyhedron_ex::Vertex_iterator  Vertex_iterator;    typedef Polyhedron_ex::Vertex_const_iterator                                            Vertex_const_iterator;    // Iterator over mesh border vertices    typedef CGAL::Convertible_iterator_project<std::list<Vertex_handle>::iterator,                                               Project_vertex_handle_vertex,                                               Vertex_const_handle,                                               Vertex_handle>                                            Border_vertex_iterator;    typedef CGAL::Convertible_iterator_project<std::list<Vertex_handle>::const_iterator,                                               Project_vertex_handle_vertex,                                               Vertex_const_handle>                                            Border_vertex_const_iterator;    // Counter-clockwise circulator over a facet's vertices    typedef CGAL::Convertible_circulator_project<Halfedge_around_facet_circulator,                                                 Project_halfedge_vertex,                                                 Vertex&,                                                 Vertex*,                                                 Vertex_const_handle,                                                 Vertex_handle>                                            Vertex_around_facet_circulator;    typedef CGAL::Convertible_circulator_project<Halfedge_around_facet_const_circulator,                                                 Project_halfedge_vertex,                                                 const Vertex&,                                                 const Vertex*,                                                 Vertex_const_handle>                                            Vertex_around_facet_const_circulator;    // Clockwise circulator over the vertices incident to a vertex    typedef CGAL::Convertible_circulator_project<Halfedge_around_vertex_circulator,                                                 Project_opposite_halfedge_vertex,                                                 Vertex&,                                                 Vertex*,                                                 Vertex_const_handle,                                                 Vertex_handle>                                            Vertex_around_vertex_circulator;    typedef CGAL::Convertible_circulator_project<Halfedge_around_vertex_const_circulator,                                                 Project_opposite_halfedge_vertex,                                                 const Vertex&,                                                 const Vertex*,                                                 Vertex_const_handle>                                            Vertex_around_vertex_const_circulator;// Public operationspublic:    //******************************************************************    // INTERFACE SPECIFIC TO Polyhedron_ex    //******************************************************************    // Create an adaptator for an existing Polyhedron_ex mesh.    // The input mesh can be of any genus.    // It can have have any number of borders. Its "main border"    // will be the mesh's longest border (if there is at least one border).    Parameterization_polyhedron_adaptor_ex(Polyhedron_ex& mesh)        // Store reference to adapted mesh      : m_polyhedron(mesh)    {        // Extract mesh's longest border        m_main_border = extract_longest_border();#ifndef NDEBUG        // Index vertices right away to ease debugging        index_mesh_vertices();#endif    }    // Default destructor, copy constructor and operator =() are fine    // Get the adapted mesh    Polyhedron_ex&       get_adapted_mesh()       { return m_polyhedron; }    const Polyhedron_ex& get_adapted_mesh() const { return m_polyhedron; }    // Get halfedge from source and target vertices    // Will assert if such an halfedge doesn't exist    Halfedge_const_handle get_halfedge(        Vertex_const_handle source, Vertex_const_handle target) const    {        assert(source != NULL);        assert(target != NULL);        Halfedge_around_vertex_const_circulator cir     = target->vertex_begin(),                                                cir_end = cir;        CGAL_For_all(cir, cir_end)            if (cir->opposite()->vertex() == source)                return cir;        assert(false);              // error if we reach this point        return NULL;    }    Halfedge_handle get_halfedge(Vertex_handle source, Vertex_handle target)    {        Halfedge_const_handle halfedge = get_halfedge((Vertex_const_handle)source,                                                      (Vertex_const_handle)target);        return const_cast<Halfedge*>(&*halfedge);    }    //******************************************************************    // LEVEL 1 INTERFACE:    // for "normal" classes that do not deal with virtual seams    // Example: all parameterization methods    //******************************************************************    // MESH INTERFACE    /// Indicate if the mesh matches the ParameterizationMesh_3 concept.    bool is_valid() const {        return m_polyhedron.is_valid();    }    // Get iterator over first vertex of mesh    Vertex_iterator  mesh_vertices_begin() {        return m_polyhedron.vertices_begin();    }    Vertex_const_iterator  mesh_vertices_begin() const {        return m_polyhedron.vertices_begin();    }    // Get iterator over past-the-end vertex of mesh    Vertex_iterator  mesh_vertices_end() {        return m_polyhedron.vertices_end();    }    Vertex_const_iterator  mesh_vertices_end() const {        return m_polyhedron.vertices_end();    }    // Count the number of vertices of the mesh    int  count_mesh_vertices() const {        int index = 0;        for (Vertex_const_iterator it=mesh_vertices_begin(); it!=mesh_vertices_end(); it++)            index++;        return index;    }    // Index vertices of the mesh from 0 to count_mesh_vertices()-1    void  index_mesh_vertices ()    {#ifdef DEBUG_TRACE        fprintf(stderr,"  index Parameterization_polyhedron_adaptor vertices:\n");#endif        int index = 0;        for (Vertex_iterator it=mesh_vertices_begin(); it!=mesh_vertices_end(); it++)        {            Point_3 position = get_vertex_position(it);/*#ifdef DEBUG_TRACE            fprintf(stderr, "    %d=(%f,%f,%f)\n",                            index,                            (float)position.x(),                            (float)position.y(),                            (float)position.z());#endif*/            set_vertex_index(it, index++);        }#ifdef DEBUG_TRACE        fprintf(stderr,"    ok\n");#endif    }    // Get iterator over first vertex of mesh's main border    Border_vertex_iterator  mesh_main_border_vertices_begin() {        return Border_vertex_iterator(m_main_border.begin());    }    Border_vertex_const_iterator  mesh_main_border_vertices_begin() const {        return Border_vertex_const_iterator(m_main_border.begin());    }    // Get iterator over past-the-end vertex of mesh's main border    Border_vertex_iterator  mesh_main_border_vertices_end() {        return Border_vertex_iterator(m_main_border.end());    }    Border_vertex_const_iterator  mesh_main_border_vertices_end() const {        return Border_vertex_const_iterator(m_main_border.end());    }    // Return the border containing seed_vertex    // Return an empty list if not found    std::list<Vertex_handle> get_border(Vertex_handle seed_vertex)    {        std::list<Vertex_handle> border;    // returned list        Halfedge_around_vertex_circulator pHalfedge = seed_vertex->vertex_begin();        Halfedge_around_vertex_circulator end       = pHalfedge;        // if isolated vertex        if (pHalfedge == NULL) {            border.push_back(seed_vertex);            return border;        }        // Get seed_vertex' border halfedge        Halfedge_handle  seed_halfedge = NULL;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -