Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
include/CGAL/SimpleCartesian/PointS3.h
Go to the documentation of this file.
1 /* *******************************************************************
2  * Rocstar Simulation Suite *
3  * Copyright@2015, Illinois Rocstar LLC. All rights reserved. *
4  * *
5  * Illinois Rocstar LLC *
6  * Champaign, IL *
7  * www.illinoisrocstar.com *
8  * sales@illinoisrocstar.com *
9  * *
10  * License: See LICENSE file in top level of distribution package or *
11  * http://opensource.org/licenses/NCSA *
12  *********************************************************************/
13 /* *******************************************************************
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *
15  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *
16  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *
17  * NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR *
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
20  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
21  * USE OR OTHER DEALINGS WITH THE SOFTWARE. *
22  *********************************************************************/
23 // $Id: PointS3.h,v 1.3 2008/12/06 08:43:27 mtcampbe Exp $
24 
25 #ifndef CGAL_OPT_SIMPLE_CARTESIAN_POINT_3_H
26 #define CGAL_OPT_SIMPLE_CARTESIAN_POINT_3_H
27 
29 
30 template < class FT >
31 class PointS3 {
32 public:
33  typedef PointS3<FT> Self;
36 
37  PointS3() {}
38  // PointS3(const Self &v); // use default copy
39  PointS3(const Origin &) : _x(0), _y(0), _z(0) {}
40  PointS3(const FT &hx, const FT &hy, const FT& hz, const FT &hw)
41  : _x(hx/hw), _y(hy/hw), _z(hz/hw) {}
42  PointS3(const FT &x, const FT &y, const FT &z) : _x(x), _y(y), _z(z) {}
43  ~PointS3() {}
44 
45  Self &operator=(const Self &p) {
46  _x=p._x; _y=p._y; _z=p._z;
47  return *this;
48  }
49 
50  bool operator==(const Self &p) const
51  { return x()==p.x() && y()==p.y() && z()==p.z(); }
52  bool operator==(const Origin &) const
53  { return x()==FT(0) && y()==FT(0) && z()==FT(0); }
54  bool operator<(const Self& p) const
55  { return lexicographically_xyz_smaller(*this, p); }
56 
57  int id() const { return (int)this; }
58 
59  FT hx() const { return x(); }
60  FT hy() const { return y(); }
61  FT hz() const { return z(); }
62  FT hw() const { return FT(1); }
63  FT homogeneous(int i) const { return (i == 3) ? FT(1) : cartesian(i); }
64 
65  const FT& x() const { return _x; }
66  const FT& y() const { return _y; }
67  const FT& z() const { return _z; }
68  FT& x() { return _x; }
69  FT& y() { return _y; }
70  FT& z() { return _z; }
71 
72  const FT& cartesian(int i) const {
73  CGAL_kernel_precondition( i >= 0 && i <= 2 );
74  return (i==0) ? x() :
75  (i==1) ? y() : z() ;
76  }
77 
78  FT& cartesian(int i) {
79  CGAL_kernel_precondition( i >= 0 && i <= 2 );
80  return (i==0) ? x() :
81  (i==1) ? y() : z() ;
82  }
83 
84  FT& operator[](int i) { return cartesian(i); }
85  const FT& operator[](int i) const { return cartesian(i); }
86 
87  int dimension() const { return 3; }
88 
89  Self& operator+=(const Vector &v) {
90  _x += v.x(); _y+=v.y(); _z+=v.z();
91  return *this;
92  }
93  Self& operator-=(const Vector &v) {
94  _x -= v.x(); _y-=v.y(); _z-=v.z();
95  return *this;
96  }
97  Bbox_3 bbox() const { return Bbox_3(x(),y(),z(),x(),y(),z()); }
98 
100  { return t.transform(*this); }
101 
102 protected:
103  FT _x,_y,_z;
104 };
105 
107 
108 #include <CGAL/Origin.h>
109 #include <CGAL/SimpleCartesian/VectorS3.h>
111 #include <CGAL/Bbox_3.h>
112 #include <CGAL/number_utils.h>
113 
115 
116 
117 
118 template < class FT >
119 inline
122 { return PointS3<FT>(p.x() + v.x(), p.y() + v.y(), p.z() + v.z()); }
123 
124 template < class FT >
125 inline
128 { return PointS3<FT>(p.x() - v.x(), p.y() - v.y(), p.z() - v.z()); }
129 
130 template < class FT >
131 inline
133 operator+(const Origin& , const VectorS3<FT>& v)
134 { return PointS3<FT>(v); }
135 
136 template < class FT >
137 inline
139 operator-(const Origin& , const VectorS3<FT>& v)
140 { return PointS3<FT>(-v); }
141 
142 template < class FT >
143 inline
146 { return VectorS3<FT>(p.x() - q.x(), p.y() - q.y(), p.z() - q.z()); }
147 
148 
149 template < class FT >
150 inline
152 operator-(const PointS3<FT>& p, const Origin& )
153 { return VectorS3<FT>(p); }
154 
155 
156 template < class FT >
157 inline
159 operator-(const Origin& , const PointS3<FT>& p)
160 { return VectorS3<FT>(-p.x(), -p.y(), -p.z()); }
161 
162 
163 #ifndef CGAL_NO_OSTREAM_INSERT_POINTS3
164 template < class FT >
165 std::ostream& operator<<(std::ostream& os, const PointS3<FT>& p)
166 {
167  switch(os.iword(IO::mode)) {
168  case IO::ASCII :
169  return os << p.x() << ' ' << p.y() << ' ' << p.z();
170  case IO::BINARY :
171  write(os, p.x());
172  write(os, p.y());
173  write(os, p.z());
174  return os;
175  default:
176  os << "PointS3(" << p.x() << ", " << p.y() << ", " << p.z() << ")";
177  return os;
178  }
179 }
180 #endif // CGAL_NO_OSTREAM_INSERT_POINTS3
181 
182 #ifndef CGAL_NO_ISTREAM_EXTRACT_POINTS3
183 template < class FT >
184 std::istream& operator>>(std::istream& is, PointS3<FT>& p)
185 {
186  FT x, y, z;
187  switch(is.iword(IO::mode)) {
188  case IO::ASCII :
189  is >> x >> y >> z;
190  break;
191  case IO::BINARY :
192  read(is, x);
193  read(is, y);
194  read(is, z);
195  break;
196  default:
197  CGAL_kernel_assertion_msg(false,"Stream must be in ascii or binary mode"
198 );
199  // throw ios_base::failure("Stream must be in ascii or binary mode");
200  break;
201  }
202  p = PointS3<FT>(x, y, z);
203  return is;
204 }
205 #endif // CGAL_NO_ISTREAM_EXTRACT_POINTS3
206 
207 
209 
210 #endif // CGAL_OPT_SIMPLE_CARTESIAN_POINT_3_H
211 
212 
213 
214 
215 
216 
bool operator==(const Origin &) const
void int int REAL REAL * y
Definition: read.cpp:74
Aff_transformationS3< FT > Aff_transformation
#define CGAL_kernel_assertion_msg(EX, MSG)
Iterator_from_circulator< C, Ref, Ptr > operator+(Dist n, const Iterator_from_circulator< C, Ref, Ptr > &circ)
Definition: circulator.h:689
bool lexicographically_xyz_smaller(const PointS3< FT > &p, const PointS3< FT > &q)
const FT & operator[](int i) const
Self transform(const Aff_transformation &t) const
PointS3(const FT &hx, const FT &hy, const FT &hz, const FT &hw)
Self & operator-=(const Vector &v)
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
Definition: io.h:64
void int int int REAL REAL REAL * z
Definition: write.cpp:76
void write(std::ostream &os, const T &t, const io_Read_write &)
Definition: io.h:96
bool operator<(const Self &p) const
blockLoc i
Definition: read.cpp:79
void int int REAL * x
Definition: read.cpp:74
Self & operator=(const Self &p)
PointS3< FT > transform(const PointS3< FT > &p) const
static int mode
Definition: io.h:63
Definition: io.h:64
Self & operator+=(const Vector &v)
bool operator==(const Self &p) const
NT q
void read(std::istream &is, T &t, const io_Read_write &)
Definition: io.h:132
#define CGAL_BEGIN_NAMESPACE
Definition: kdtree_d.h:86
std::istream & operator>>(std::istream &is, CGAL::Aff_transformation_2< R > &t)
PointS3(const FT &x, const FT &y, const FT &z)
const FT & cartesian(int i) const
#define CGAL_END_NAMESPACE
Definition: kdtree_d.h:87
#define CGAL_kernel_precondition(EX)
Point_2< R > operator-(const Origin &o, const Vector_2< R > &v)
const FT & cartesian(int i) const