Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SegmentS3.h
Go to the documentation of this file.
1 // ======================================================================
2 //
3 // Copyright (c) 1999 The CGAL Consortium
4 
5 // This software and related documentation is part of the Computational
6 // Geometry Algorithms Library (CGAL).
7 // This software and documentation is provided "as-is" and without warranty
8 // of any kind. In no event shall the CGAL Consortium be liable for any
9 // damage of any kind.
10 //
11 // Every use of CGAL requires a license.
12 //
13 // Academic research and teaching license
14 // - For academic research and teaching purposes, permission to use and copy
15 // the software and its documentation is hereby granted free of charge,
16 // provided that it is not a component of a commercial product, and this
17 // notice appears in all copies of the software and related documentation.
18 //
19 // Commercial licenses
20 // - A commercial license is available through Algorithmic Solutions, who also
21 // markets LEDA (http://www.algorithmic-solutions.de).
22 // - Commercial users may apply for an evaluation license by writing to
23 // Algorithmic Solutions (contact@algorithmic-solutions.com).
24 //
25 // The CGAL Consortium consists of Utrecht University (The Netherlands),
26 // ETH Zurich (Switzerland), Free University of Berlin (Germany),
27 // INRIA Sophia-Antipolis (France), Martin-Luther-University Halle-Wittenberg
28 // (Germany), Max-Planck-Institute Saarbrucken (Germany), RISC Linz (Austria),
29 // and Tel-Aviv University (Israel).
30 //
31 // ----------------------------------------------------------------------
32 // release : CGAL-2.2
33 // release_date : 2000, September 30
34 //
35 // source : webS3/S3.lw
36 // file : include/CGAL/SimpleCartesian/SegmentS3.h
37 // package : S3 (1.6)
38 // revision : 1.6
39 // revision_date : 28 Jun 2000
40 // author(s) : Stefan Schirra
41 // based on code by
42 // Andreas Fabri and
43 // Herve Brönnimann
44 //
45 // coordinator : MPI, Saarbrücken
46 // email : contact@cgal.org
47 // www : http://www.cgal.org
48 //
49 // ======================================================================
50 
51 #ifndef CGAL_SEGMENTS3_H
52 #define CGAL_SEGMENTS3_H
53 
57 
59 
60 template < class FT >
61 class SegmentS3{
62 public:
63  SegmentS3() {}
64  SegmentS3(const PointS3<FT>& sp, const PointS3<FT>& ep)
65  : e0(sp), e1(ep) {}
66 
67  bool has_on(const PointS3<FT>& p) const;
68  bool collinear_has_on(const PointS3<FT>& p) const;
69 
70  bool operator==(const SegmentS3<FT>& s) const;
71  bool operator!=(const SegmentS3<FT>& s) const;
72 
73  PointS3<FT> start() const;
74  PointS3<FT> end() const;
75 
76  PointS3<FT> source() const;
77  PointS3<FT> target() const;
78 
79  PointS3<FT> min() const;
80  PointS3<FT> max() const;
81  PointS3<FT> vertex(int i) const;
82  PointS3<FT> point(int i) const;
83  PointS3<FT> operator[](int i) const;
84 
85  FT squared_length() const;
86 
87  DirectionS3<FT> direction() const;
89  SegmentS3 opposite() const;
91 
92  bool is_degenerate() const;
93  Bbox_3 bbox() const;
94 
95 // private:
98 };
99 
100 template < class FT >
101 inline
102 bool
104 { return (source() == s.source()) && (target() == s.target()); }
105 
106 
107 template < class FT >
108 inline
109 bool
111 { return !(*this == s); }
112 
113 
114 template < class FT >
116 { return e0; }
117 
118 
119 template < class FT >
121 { return e1; }
122 
123 
124 template < class FT >
126 { return e0; }
127 
128 
129 template < class FT >
131 { return e1; }
132 
133 
134 template < class FT >
135 inline
138 {
139  return (lexicographically_xyz_smaller(source(),target())) ? source()
140  : target();
141 }
142 
143 
144 template < class FT >
145 inline
148 {
149  return (lexicographically_xyz_smaller(source(),target())) ? target()
150  : source();
151 }
152 
153 
154 template < class FT >
155 inline
158 { return (i%2 == 0) ? source() : target(); }
159 
160 
161 template < class FT >
162 inline
165 { return (i%2 == 0) ? source() : target(); }
166 
167 
168 template < class FT >
169 inline
172 { return vertex(i); }
173 
174 template < class FT >
175 inline
176 FT
178 { return squared_distance(target(), source()); }
179 
180 
181 template < class FT >
182 inline
185 { return DirectionS3<FT>( target() - source() ); }
186 
187 
188 template < class FT >
189 inline
192 { return LineS3<FT>(*this); }
193 
194 
195 template < class FT >
196 inline
199 { return SegmentS3<FT>(target(), source()); }
200 
201 
202 template < class FT >
203 inline
206 { return SegmentS3<FT>(t.transform(source()), t.transform(target())); }
207 
208 
209 template < class FT >
210 inline
211 bool
213 { return source() == target(); }
214 
215 
216 template < class FT >
217 inline
218 Bbox_3
220 { return source().bbox() + target().bbox(); }
221 
222 
223 #ifndef CGAL_NO_OSTREAM_INSERT_SEGMENTS3
224 template < class FT >
225 std::ostream& operator<<(std::ostream& os, const SegmentS3<FT>& s)
226 {
227  switch(os.iword(IO::mode)) {
228  case IO::ASCII :
229  return os << s.source() << ' ' << s.target();
230  case IO::BINARY :
231  return os << s.source() << s.target();
232  default:
233  return os << "SegmentS3(" << s.source() << ", " << s.target() << ")";
234  }
235 }
236 #endif // CGAL_NO_OSTREAM_INSERT_SEGMENTS3
237 
238 #ifndef CGAL_NO_ISTREAM_EXTRACT_SEGMENTS3
239 template < class FT >
240 std::istream& operator>>(std::istream& is, SegmentS3<FT>& s)
241 {
242  PointS3<FT> p, q;
243 
244  is >> p >> q;
245 
246  s = SegmentS3<FT>(p, q);
247  return is;
248 }
249 #endif // CGAL_NO_ISTREAM_EXTRACT_SEGMENTS3
250 
251 template < class FT >
252 bool SegmentS3<FT>::has_on(const PointS3<FT>& p) const
253 { return are_ordered_along_line(source(), p, target()); }
254 
255 template < class FT >
256 inline
257 bool
259 { return collinear_are_ordered_along_line(source(), p, target()); }
260 
261 
263 
264 #endif
PointS3< FT > e0
Definition: SegmentS3.h:96
FT squared_length() const
Definition: SegmentS3.h:177
double s
Definition: blastest.C:80
Bbox_3 bbox() const
Definition: SegmentS3.h:219
PointS3< FT > target() const
Definition: SegmentS3.h:130
PointS3< FT > start() const
Definition: SegmentS3.h:115
bool lexicographically_xyz_smaller(const PointS3< FT > &p, const PointS3< FT > &q)
bool collinear_has_on(const PointS3< FT > &p) const
Definition: SegmentS3.h:258
PointS3< FT > min() const
Definition: SegmentS3.h:137
Definition: io.h:64
PointS3< FT > max() const
Definition: SegmentS3.h:147
PointS3< FT > e1
Definition: SegmentS3.h:97
PointS3< FT > source() const
Definition: SegmentS3.h:125
FT squared_distance(const PointS3< FT > &p, const PointS3< FT > &q)
SegmentS3()
Definition: SegmentS3.h:63
bool are_ordered_along_line(const Point_2< R > &p, const Point_2< R > &q, const Point_2< R > &r)
PointS3< FT > end() const
Definition: SegmentS3.h:120
PointS3< FT > operator[](int i) const
Definition: SegmentS3.h:171
blockLoc i
Definition: read.cpp:79
bool collinear_are_ordered_along_line(const Point_2< R > &p, const Point_2< R > &q, const Point_2< R > &r)
bool has_on(const PointS3< FT > &p) const
Definition: SegmentS3.h:252
PointS3< FT > transform(const PointS3< FT > &p) const
LineS3< FT > supporting_line() const
Definition: SegmentS3.h:191
SegmentS3 transform(const Aff_transformationS3< FT > &t) const
Definition: SegmentS3.h:205
PointS3< FT > point(int i) const
Definition: SegmentS3.h:164
static int mode
Definition: io.h:63
Definition: io.h:64
bool operator!=(const SegmentS3< FT > &s) const
Definition: SegmentS3.h:110
bool operator==(const SegmentS3< FT > &s) const
Definition: SegmentS3.h:103
NT q
DirectionS3< FT > direction() const
Definition: SegmentS3.h:184
#define CGAL_BEGIN_NAMESPACE
Definition: kdtree_d.h:86
bool is_degenerate() const
Definition: SegmentS3.h:212
std::istream & operator>>(std::istream &is, CGAL::Aff_transformation_2< R > &t)
SegmentS3 opposite() const
Definition: SegmentS3.h:198
#define CGAL_END_NAMESPACE
Definition: kdtree_d.h:87
Definition: LineS3.h:59
SegmentS3(const PointS3< FT > &sp, const PointS3< FT > &ep)
Definition: SegmentS3.h:64
PointS3< FT > vertex(int i) const
Definition: SegmentS3.h:157