// ====================================================================== // // Copyright (c) 2005-2017 GeometryFactory (France). All Rights Reserved. // // This file is part of CGAL (www.cgal.org); you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public License as // published by the Free Software Foundation; either version 3 of the License, // or (at your option) any later version. // // 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$ // $Id$ // // // Author(s): Le-Jeng Shiue // // ====================================================================== #ifndef CGAL_POLYHEDRON_SUBDIVISION_H #define CGAL_POLYHEDRON_SUBDIVISION_H #include #include #include #include #include #include #include namespace CGAL { // ====================================================================== namespace Subdivision_method_3 { namespace parameters = Polygon_mesh_processing::parameters; // --------------------------------------------------------------------------- template void PQQ(PolygonMesh& pmesh, Mask mask, int step = 1) { // todo: static assert that PolygonMesh == Mask::PolygonMesh for (int i = 0; i < step; i++) Private::PQQ_1step(pmesh, get(vertex_point,pmesh), mask); } template void PQQ(PolygonMesh& pmesh, Mask mask, const NamedParameters& np) { // todo: static assert that PolygonMesh == Mask::PolygonMesh using boost::choose_param; using boost::get_param; typedef typename GetVertexPointMap::type Vpm; Vpm vpm = choose_param(get_param(np, vertex_point), get_property_map(CGAL::vertex_point, pmesh)); unsigned int step = choose_param(get_param(np, number_of_iterations), 1); for (int i = 0; i < step; i++) Private::PQQ_1step(pmesh, vpm, mask); } template void CatmullClark_subdivision(PolygonMesh& pmesh, int step = 1) { PQQ(pmesh, CatmullClark_mask_3(&pmesh, get(vertex_point,pmesh)), step); } template void CatmullClark_subdivision(PolygonMesh& pmesh, const NamedParameters& np) { using boost::choose_param; using boost::get_param; typedef typename GetVertexPointMap::type Vpm; Vpm vpm = choose_param(get_param(np, vertex_point), get_property_map(CGAL::vertex_point, pmesh)); unsigned int step = choose_param(get_param(np, number_of_iterations), 1); CatmullClark_mask_3 mask(&pmesh, vpm); for(unsigned int i = 0; i < step; i++) Private::PQQ_1step(pmesh, vpm, mask); } // --------------------------------------------------------------------------- template void PTQ(PolygonMesh& pmesh, Mask mask, int step = 1) { for (int i = 0; i < step; i++) Private::PTQ_1step(pmesh, get(vertex_point,pmesh), mask); } template void PTQ(PolygonMesh& pmesh, Mask mask, const NamedParameters& np) { // todo: static assert that PolygonMesh == Mask::PolygonMesh using boost::choose_param; using boost::get_param; typedef typename GetVertexPointMap::type Vpm; Vpm vpm = choose_param(get_param(np, vertex_point), get_property_map(CGAL::vertex_point, pmesh)); unsigned int step = choose_param(get_param(np, number_of_iterations), 1); for (unsigned int i = 0; i < step; i++) Private::PTQ_1step(pmesh, vpm, mask); } template void Loop_subdivision(PolygonMesh& pmesh, int step = 1) { PTQ(pmesh, Loop_mask_3(&pmesh, get(vertex_point,pmesh)) , step); } template void Loop_subdivision(PolygonMesh& pmesh, const NamedParameters& np) { using boost::choose_param; using boost::get_param; typedef typename GetVertexPointMap::type Vpm; Vpm vpm = choose_param(get_param(np, vertex_point), get_property_map(CGAL::vertex_point, pmesh)); unsigned int step = choose_param(get_param(np, number_of_iterations), 1); Loop_mask_3 mask(&pmesh, vpm); for(unsigned int i = 0; i < step; i++) Private::PTQ_1step(pmesh, vpm, mask); } // --------------------------------------------------------------------------- template void DQQ(PolygonMesh& pmesh, Mask mask, int step = 1) { for (int i = 0; i < step; ++i) { Private::DQQ_1step(pmesh, get(vertex_point, pmesh), mask); } } template void DQQ(PolygonMesh& pmesh, Mask mask, const NamedParameters& np) { // todo: static assert that PolygonMesh == Mask::PolygonMesh using boost::choose_param; using boost::get_param; typedef typename GetVertexPointMap::type Vpm; Vpm vpm = choose_param(get_param(np, vertex_point), get_property_map(CGAL::vertex_point, pmesh)); unsigned int step = choose_param(get_param(np, number_of_iterations), 1); for (unsigned int i = 0; i < step; i++) Private::DQQ_1step(pmesh, vpm, mask); } template void DooSabin_subdivision(PolygonMesh& pmesh, int step = 1) { DQQ(pmesh, DooSabin_mask_3(&pmesh, get(vertex_point, pmesh)), step); } template void DooSabin_subdivision(PolygonMesh& pmesh, const NamedParameters& np) { using boost::choose_param; using boost::get_param; typedef typename GetVertexPointMap::type Vpm; Vpm vpm = choose_param(get_param(np, vertex_point), get_property_map(CGAL::vertex_point, pmesh)); unsigned int step = choose_param(get_param(np, number_of_iterations), 1); DooSabin_mask_3 mask(&pmesh, vpm); for(unsigned int i = 0; i < step; i++) Private::DQQ_1step(pmesh, vpm, mask); } // --------------------------------------------------------------------------- template void Sqrt3(PolygonMesh& pmesh, Mask mask, int step = 1) { for (int i = 0; i < step; i++) Private::Sqrt3_1step(pmesh, get(vertex_point,pmesh), mask, (i%2==1)); } template void Sqrt3(PolygonMesh& pmesh, Mask mask, const NamedParameters& np) { // todo: static assert that PolygonMesh == Mask::PolygonMesh using boost::choose_param; using boost::get_param; typedef typename GetVertexPointMap::type Vpm; Vpm vpm = choose_param(get_param(np, vertex_point), get_property_map(CGAL::vertex_point, pmesh)); unsigned int step = choose_param(get_param(np, number_of_iterations), 1); for (unsigned int i = 0; i < step; i++) Private::Sqrt3_1step(pmesh, vpm, mask, (i%2==1)); } template void Sqrt3_subdivision(PolygonMesh& pmesh, int step = 1) { Sqrt3(pmesh, Sqrt3_mask_3(&pmesh, get(vertex_point,pmesh)), step); } template void Sqrt3_subdivision(PolygonMesh& pmesh, const NamedParameters& np) { using boost::choose_param; using boost::get_param; typedef typename GetVertexPointMap::type Vpm; Vpm vpm = choose_param(get_param(np, vertex_point), get_property_map(CGAL::vertex_point, pmesh)); unsigned int step = choose_param(get_param(np, number_of_iterations), 1); Sqrt3_mask_3 mask(&pmesh, vpm); for(unsigned int i = 0; i < step; i++) Private::Sqrt3_1step(pmesh, vpm, mask, (i%2==1)); } // --------------------------------------------------------------------------- } } //namespace CGAL #endif //CGAL_POLYHEDRON_SUBDIVISION_H