File: Level_interval.h

package info (click to toggle)
cgal 3.2.1-2
  • links: PTS
  • area: non-free
  • in suites: etch, etch-m68k
  • size: 47,752 kB
  • ctags: 72,510
  • sloc: cpp: 397,707; ansic: 10,393; sh: 4,232; makefile: 3,713; perl: 394; sed: 9
file content (127 lines) | stat: -rw-r--r-- 3,191 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
// Copyright (c) 2003, 2005 GeometryFactory
// 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.2-branch/Interval_skip_list/include/CGAL/Level_interval.h $
// $Id: Level_interval.h 28567 2006-02-16 14:30:13Z lsaboret $
// 
//
// Author(s)     : Andreas Fabri

#ifndef CGAL_LEVEL_INTERVAL_H
#define CGAL_LEVEL_INTERVAL_H

#include <CGAL/Kernel_traits.h>
#include <iostream>


namespace CGAL {

  template <class FaceHandle>
  class Level_interval
  {
  public:
    typedef typename FaceHandle::value_type Face;
    typedef typename Face::Vertex_handle::value_type Vertex;
    typedef typename Vertex::Point Point;
    typedef typename Kernel_traits<Point>::Kernel K;
    typedef typename K::FT Value;


  private:
    FaceHandle fh_; 
    Value inf_;
    Value sup_;  // left and right boundary values
  public:

    Level_interval(){}
    Level_interval(FaceHandle fh);
    const Value& inf() const {return inf_;}
    const Value& sup() const {return sup_;}
    FaceHandle face_handle() const { return fh_;}
    bool contains(const Value& V) const;

    // true iff this contains (l,r)
    bool contains_interval(const Value& l, const Value& r) const;  

    bool operator==(const Level_interval& I) const 
    {
      // there is no need to compare inf and sup, as these are derived from the face
      return face_handle() == I.face_handle();
    }

    bool operator!=(const Level_interval& I) const 
    {
      return face_handle() != I.face_handle();
    }
  };



  template <class V>
  std::ostream& operator<<(std::ostream& os, 
			   const Level_interval<V>& i)
  {
    os << i.face_handle()->vertex(0)->point() << ", " << 
      i.face_handle()->vertex(1)->point() << ", " << 
      i.face_handle()->vertex(2)->point() << std::endl; 
    return os;
  }


  template <class FaceHandle>
  Level_interval<FaceHandle>::Level_interval(FaceHandle fh)
    : fh_(fh), inf_(fh->vertex(0)->point().z()), sup_(inf_)
  {
    double z = fh->vertex(1)->point().z();
    sup_= (z>sup_)? z : sup_;
    inf_ = (z<inf_) ? z : inf_;
    z = fh->vertex(2)->point().z();
    sup_ = (z>sup_)? z : sup_;
    inf_ = (z<inf_) ? z : inf_;
  }


  template <class FaceHandle>
  bool
  Level_interval<FaceHandle>::contains_interval(const Value& i, 
					       const Value& s) const
    // true iff this contains (l,r)
  {
    return( (inf() <= i) && (sup() >= s) );
  }


  template <class FaceHandle>
  bool
  Level_interval<FaceHandle>::contains(const Value& v) const
  {
    // return true if this contains V, false otherwise
    if((v >= inf()) && (v <= sup()))
      return true;
    else
      return false;
  }




} // namespace CGAL

#endif // CGAL_LEVEL_INTERVAL_H