File: intersection_line_2_circle_2_map.h

package info (click to toggle)
cgal 6.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 144,912 kB
  • sloc: cpp: 810,858; ansic: 208,477; sh: 493; python: 411; makefile: 286; javascript: 174
file content (75 lines) | stat: -rw-r--r-- 2,254 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// Copyright (c) 2003-2008  INRIA Sophia-Antipolis (France).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
//
// $URL: https://github.com/CGAL/cgal/blob/v6.1/Circular_kernel_2/include/CGAL/Circular_kernel_2/intersection_line_2_circle_2_map.h $
// $Id: include/CGAL/Circular_kernel_2/intersection_line_2_circle_2_map.h b26b07a1242 $
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
//
// Author(s)     : Monique Teillaud, Sylvain Pion, Pedro Machado

// Partially supported by the IST Programme of the EU as a Shared-cost
// RTD (FET Open) Project under Contract No  IST-2000-26473
// (ECG - Effective Computational Geometry for Curves and Surfaces)
// and a STREP (FET Open) Project under Contract No  IST-006413
// (ACS -- Algorithms for Complex Shapes)

#ifndef CGAL_INTERSECTION_LINE_2_CIRCLE_2_MAP_H
#define CGAL_INTERSECTION_LINE_2_CIRCLE_2_MAP_H

#include <CGAL/license/Circular_kernel_2.h>


#include <map>
#include <vector>

namespace CGAL {
namespace internal {

class Intersection_line_2_circle_2_map {

typedef struct inter_map_pair {
  int x, y;
  inter_map_pair(int xx=0, int yy=0) : x(xx), y(yy) {}
  inter_map_pair(const inter_map_pair &i) : x(i.x), y(i.y) {}
  bool operator<(const inter_map_pair &i) const {
    if(x < i.x) return true;
    if(x > i.x) return false;
    if(y < i.y) return true;
    return false;
  }
} inter_map_pair;
typedef std::map< inter_map_pair , CGAL::Object > Table;

private:
  Table intersection_map;
  unsigned int id_gen;

public:
  Intersection_line_2_circle_2_map() : id_gen(0) { intersection_map.clear(); }
  ~Intersection_line_2_circle_2_map() { intersection_map.clear(); }

  unsigned int get_new_id() {
    return ++id_gen;
  }

  template < class T >
  bool find(int id1, int id2, T& res) const {
    Table::const_iterator p = intersection_map.find(
      inter_map_pair(id1,id2));
    if(p == intersection_map.end()) return false;
    assign(res, p->second);
    return true;
  }

  template < class T >
  void put(const int id1, const int id2, const T& res) {
    intersection_map[inter_map_pair(id1,id2)] = CGAL::make_object(res);
  }
};

} // endof internal cgal namespace
} //endof cgal namespace

#endif // CGAL_INTERSECTION_LINE_2_CIRCLE_2_MAP_H