segment_voronoi_diagram_predicates_ftc2.h
来自「CGAL is a collaborative effort of severa」· C头文件 代码 · 共 1,247 行 · 第 1/3 页
H
1,247 行
// Copyright (c) 2003,2004 INRIA Sophia-Antipolis (France) and// Notre Dame University (U.S.A.). 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.//// $Source: /CVSROOT/CGAL/Packages/Segment_Voronoi_diagram_2/include/CGAL/predicates/Segment_Voronoi_diagram_predicates_ftC2.h,v $// $Revision: 1.34 $ $Date: 2004/10/04 17:39:40 $// $Name: $//// Author(s) : Menelaos Karavelas <mkaravel@cse.nd.edu>#ifndef CGAL_SEGMENT_VORONOI_DIAGRAM_PREDICATES_FTC2_H#define CGAL_SEGMENT_VORONOI_DIAGRAM_PREDICATES_FTC2_H#include <CGAL/determinant.h>#include <CGAL/predicates/Segment_Voronoi_diagram_predicates_C2.h>#include <CGAL/predicates/check_filter.h>#include <CGAL/Segment_Voronoi_diagram_kernel_wrapper_2.h>CGAL_BEGIN_NAMESPACE//--------------------------------------------------------------------------//--------------------------------------------------------------------------//--------------------------------------------------------------------------template<class K>void svd_predicate_push_back_C2(const typename K::Site_2& t, typename K::FT v[], unsigned int& k, char site_types[], unsigned int& j, const Tag_true&){ unsigned int step(0); if ( t.is_point() ) { site_types[j] = 'p'; if ( t.is_input() ) { site_types[j+1] = 'e'; v[k] = t.point().x(); v[k+1] = t.point().y(); step = 2; } else { site_types[j+1] = 'i'; v[k] = t.source_of_supporting_site(0).x(); v[k+1] = t.source_of_supporting_site(0).y(); v[k+2] = t.target_of_supporting_site(0).x(); v[k+3] = t.target_of_supporting_site(0).y(); v[k+4] = t.source_of_supporting_site(1).x(); v[k+5] = t.source_of_supporting_site(1).y(); v[k+6] = t.target_of_supporting_site(1).x(); v[k+7] = t.target_of_supporting_site(1).y(); step = 8; } } else { site_types[j] = 's'; if ( t.is_input() ) { site_types[j+1] = 'e'; v[k] = t.source_of_supporting_site().x(); v[k+1] = t.source_of_supporting_site().y(); v[k+2] = t.target_of_supporting_site().x(); v[k+3] = t.target_of_supporting_site().y(); step = 4; } else { v[k] = t.source_of_supporting_site().x(); v[k+1] = t.source_of_supporting_site().y(); v[k+2] = t.target_of_supporting_site().x(); v[k+3] = t.target_of_supporting_site().y(); typedef typename K::Point_2 Point_2; if ( t.is_input(0) ) { const Point_2& cs_p1 = t.source_of_crossing_site(1); const Point_2& cs_p2 = t.target_of_crossing_site(1); site_types[j+1] = '0'; v[k+4] = cs_p1.x(); v[k+5] = cs_p1.y(); v[k+6] = cs_p2.x(); v[k+7] = cs_p2.y(); step = 8; } else if ( t.is_input(1) ) { const Point_2& cs_p1 = t.source_of_crossing_site(0); const Point_2& cs_p2 = t.target_of_crossing_site(0); site_types[j+1] = '1'; v[k+4] = cs_p1.x(); v[k+5] = cs_p1.y(); v[k+6] = cs_p2.x(); v[k+7] = cs_p2.y(); step = 8; } else { const Point_2& cs_p1 = t.source_of_crossing_site(0); const Point_2& cs_p2 = t.target_of_crossing_site(0); const Point_2& cs2_p1 = t.source_of_crossing_site(1); const Point_2& cs2_p2 = t.target_of_crossing_site(1); site_types[j+1] = 'i'; v[k+4] = cs_p1.x(); v[k+5] = cs_p1.y(); v[k+6] = cs_p2.x(); v[k+7] = cs_p2.y(); v[k+8] = cs2_p1.x(); v[k+9] = cs2_p1.y(); v[k+10] = cs2_p2.x(); v[k+11] = cs2_p2.y(); step = 12; } } } j += 2; k += step;}template<class K>void svd_predicate_push_back_C2(const typename K::Site_2& t, typename K::FT v[], unsigned int& k, char site_types[], unsigned int& j, const Tag_false&){ unsigned int step(0); if ( t.is_point() ) { site_types[j] = 'p'; site_types[j+1] = 'e'; v[k] = t.point().x(); v[k+1] = t.point().y(); step = 2; } else { site_types[j] = 's'; site_types[j+1] = 'e'; v[k] = t.source().x(); v[k+1] = t.source().y(); v[k+2] = t.target().x(); v[k+3] = t.target().y(); step = 4; } j += 2; k += step;}//--------------------------------------------------------------------------template<class K, class ITag> class Svd_get_site_C2;template<class K>class Svd_get_site_C2<K,Tag_true>{private: typedef typename K::Point_2 Point_2; typedef typename K::Segment_2 Segment_2; typedef typename K::Site_2 Site_2; typedef typename K::FT FT;public: Site_2 operator()(const FT v[], unsigned int& k, const char site_types[], unsigned int& j) { Site_2 t; unsigned int step(0); if ( site_types[j] == 'p' ) { if ( site_types[j+1] == 'e' ) { Point_2 p(v[k], v[k+1]); t = Site_2::construct_site_2(p); step = 2; } else { Point_2 p1(v[k], v[k+1]), p2(v[k+2], v[k+3]); Point_2 p3(v[k+4], v[k+5]), p4(v[k+6], v[k+7]); t = Site_2::construct_site_2(p1, p2, p3, p4); step = 8; } } else { if ( site_types[j+1] == 'e' ) { Point_2 p1(v[k], v[k+1]), p2(v[k+2], v[k+3]); t = Site_2::construct_site_2(p1, p2); step = 4; } else { if ( site_types[j+1] != 'i' ) { Point_2 p1(v[k], v[k+1]), p2(v[k+2], v[k+3]); Point_2 p3(v[k+4], v[k+5]), p4(v[k+6], v[k+7]); t = Site_2::construct_site_2(p1, p2, p3, p4, (site_types[j+1] == '0')); step = 8; } else { Point_2 p1(v[k], v[k+1]), p2(v[k+2], v[k+3]); Point_2 p3(v[k+4], v[k+5]), p4(v[k+6], v[k+7]); Point_2 p5(v[k+8], v[k+9]), p6(v[k+10], v[k+11]); t = Site_2::construct_site_2(p1, p2, p3, p4, p5, p6); step = 12; } } } j += 2; k += step; return t; }};template<class K>class Svd_get_site_C2<K,Tag_false>{private: typedef typename K::Point_2 Point_2; typedef typename K::Segment_2 Segment_2; typedef typename K::Site_2 Site_2; typedef typename K::FT FT;public: Site_2 operator()(const FT v[], unsigned int& k, const char site_types[], unsigned int& j) { Site_2 t; unsigned int step(0); if ( site_types[j] == 'p' ) { Point_2 p(v[k], v[k+1]); t = Site_2::construct_site_2(p); step = 2; } else { Point_2 p1(v[k], v[k+1]), p2(v[k+2], v[k+3]); t = Site_2::construct_site_2(p1, p2); step = 4; } j += 2; k += step; return t; }};template<class K>typename K::Site_2svd_get_site_C2(const typename K::FT v[], unsigned int& k, const char site_types[], unsigned int& j, const Tag_true&){ typedef typename K::Point_2 Point_2; typedef typename K::Segment_2 Segment_2; typedef typename K::Site_2 Site_2; Site_2 t; unsigned int step(0); if ( site_types[j] == 'p' ) { if ( site_types[j+1] == 'e' ) { Point_2 p(v[k], v[k+1]); t = Site_2::construct_site_2(p); step = 2; } else { Point_2 p1(v[k], v[k+1]), p2(v[k+2], v[k+3]); Point_2 p3(v[k+4], v[k+5]), p4(v[k+6], v[k+7]); t = Site_2::construct_site_2(p1, p2, p3, p4); step = 8; } } else { if ( site_types[j+1] == 'e' ) { Point_2 p1(v[k], v[k+1]), p2(v[k+2], v[k+3]); t = Site_2::construct_site_2(p1, p2); step = 4; } else { if ( site_types[j+1] != 'i' ) { Point_2 p1(v[k], v[k+1]), p2(v[k+2], v[k+3]); Point_2 p3(v[k+4], v[k+5]), p4(v[k+6], v[k+7]); t = Site_2::construct_site_2(p1, p2, p3, p4, (site_types[j+1] == '0')); step = 8; } else { Point_2 p1(v[k], v[k+1]), p2(v[k+2], v[k+3]); Point_2 p3(v[k+4], v[k+5]), p4(v[k+6], v[k+7]); Point_2 p5(v[k+8], v[k+9]), p6(v[k+10], v[k+11]); t = Site_2::construct_site_2(p1, p2, p3, p4, p5, p6); step = 12; } } } j += 2; k += step; return t;}template<class K>typename K::Site_2svd_get_site_C2(const typename K::FT v[], unsigned int& k, const char site_types[], unsigned int& j, const Tag_false&){ typedef typename K::Point_2 Point_2; typedef typename K::Segment_2 Segment_2; typedef typename K::Site_2 Site_2; Site_2 t; unsigned int step(0); if ( site_types[j] == 'p' ) { Point_2 p(v[k], v[k+1]); t = Site_2::construct_site_2(p); step = 2; } else { Point_2 p1(v[k], v[k+1]), p2(v[k+2], v[k+3]); t = Site_2::construct_site_2(p1, p2); step = 4; } j += 2; k += step; return t;}//--------------------------------------------------------------------------template<typename Result_t, class Predicate, unsigned int Arity>struct Svd_predicate_caller;template<typename Result_t, class Predicate>struct Svd_predicate_caller<Result_t, Predicate, 2>{ template<class S> Result_t operator()(const S t[]) const { return Predicate()(t[0], t[1]); }};template<typename Result_t, class Predicate>struct Svd_predicate_caller<Result_t, Predicate, 3>{ template<class S> Result_t operator()(const S t[]) const { return Predicate()(t[0], t[1], t[2]); } template<class S, typename Data> Result_t operator()(const S t[], Data data) const { return Predicate()(t[0], t[1], t[2], data); }};template<typename Result_t, class Predicate>struct Svd_predicate_caller<Result_t, Predicate, 4>{ template<class S> Result_t operator()(const S t[]) const { return Predicate()(t[0], t[1], t[2], t[3]); } template<class S, typename Data> Result_t operator()(const S t[], Data data) const { return Predicate()(t[0], t[1], t[2], t[3], data); }};template<typename Result_t, class Predicate>struct Svd_predicate_caller<Result_t, Predicate, 5>{ template<class S> Result_t operator()(const S t[]) const { return Predicate()(t[0], t[1], t[2], t[3], t[4]); } template<class S, typename Data> Result_t operator()(const S t[], Data data) const { return Predicate()(t[0], t[1], t[2], t[3], t[4], data); }};//--------------------------------------------------------------------------#if 0template<template<class Kernel> class Predicate_t, typename Return_t, class FT, class ITag, unsigned int Num_sites>Return_tsvd_predicate_ftC2(const FT v[], const char site_types[]){ typedef Simple_cartesian<FT> Rep; typedef CGAL::Segment_Voronoi_diagram_kernel_wrapper_2<Rep,ITag> Kernel; typedef typename Kernel::Site_2 Site_2; typedef Predicate_t<Kernel> Predicate; typedef Svd_predicate_caller<Return_t, Predicate, Num_sites> Caller; must_be_filtered(FT()); Site_2 t[Num_sites]; for (unsigned int i = 0, k = 0, j = 0; i < Num_sites; i++) { t[i] = svd_get_site_C2<Kernel>(v, k, site_types, j, ITag()); }
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?