From b00f76be4e4866e06059d77f2a2c0557c2038ce6 Mon Sep 17 00:00:00 2001 From: wolf Date: Fri, 6 Nov 1998 12:11:41 +0000 Subject: [PATCH] Move the point class from deal.II/include/grid to base. git-svn-id: https://svn.dealii.org/trunk@642 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/deal.II/include/grid/point.h | 436 --------------------------- 1 file changed, 436 deletions(-) delete mode 100644 deal.II/deal.II/include/grid/point.h diff --git a/deal.II/deal.II/include/grid/point.h b/deal.II/deal.II/include/grid/point.h deleted file mode 100644 index 28ad47a0e5..0000000000 --- a/deal.II/deal.II/include/grid/point.h +++ /dev/null @@ -1,436 +0,0 @@ -/*---------------------------- point.h ---------------------------*/ -/* $Id$ */ -/* Copyright W. Bangerth, University of Heidelberg, 1998 */ -#ifndef __point_H -#define __point_H -/*---------------------------- point.h ---------------------------*/ - - -#include -#include - - -/** - * The #Point# class provides for a point or vector in a space with arbitrary - * dimension #dim#. - * - * It is the preferred object to be passed to functions which - * operate on points in spaces of a priori unknown dimension: rather than - * using functions like #double f(double x)# and #double f(double x, double y)#, - * you use double #f(Point &p)#. - * - * #Point# also serves as a starting point for the implementation of the - * geometrical primitives like #Polyhedron#, #Triangle#, etc. - * - * #Point#s can also be thought of as vectors, i.e. points in a vector space - * without an obvious meaning. For instance, it may be suitable to let the - * gradient of a function be a #point# vector: - * #Point gradient_of_f (const Point &x)#. #Point#s have all - * functionality for this, e.g. scalar products, addition etc. - * - * @author Wolfgang Bangerth, 1997 - */ -template -class Point { - public: - /** - * Provide a way to get the dimension of - * an object without explicit knowledge - * of it's data type. Implementation is - * this way instead of providing a function - * #dimension()# because now it is possible - * to get the dimension at compile time - * without the expansion and preevaluation - * of an inlined function; the compiler may - * therefore produce more efficient code - * and you may use this value to declare - * other data types. - */ - static const unsigned int dimension = dim; - - /** - * Constructor. Initialize all entries - * to zero. - */ - explicit Point (); - /** - * Constructor for one dimensional points. This - * function is only implemented for #dim==1# - * since the usage is considered unsafe - * for points with #dim!=1#. - */ - explicit Point (const double x); - - /** - * Constructor for two dimensional points. This - * function is only implemented for #dim==2# - * since the usage is considered unsafe - * for points with #dim!=2#. - */ - Point (const double x, const double y); - - /** - * Constructor for three dimensional points. This - * function is only implemented for #dim==3# - * since the usage is considered unsafe - * for points with #dim!=3#. - */ - Point (const double x, const double y, const double z); - - /** - * Copy constructor. - */ - Point (const Point &); - - /** - * Read access to the #index#th coordinate. - */ - double operator () (const unsigned int index) const; - /** - * Read and write access to the #index#th - * coordinate. - */ - double & operator () (const unsigned int index); - - /** - * Assignment operator. - */ - Point & operator = (const Point &); - - /** - * Test for equality of two points. - */ - bool operator ==(const Point &) const; - /** - * Test for inequality of two points. - */ - bool operator !=(const Point &) const; - - /** - * Add two point vectors. If possible, use - * #operator +=# instead since this does not - * need to copy a point at least once. - */ - Point operator + (const Point &) const; - - /** - * Subtract two point vectors. If possible, use - * #operator +=# instead since this does not - * need to copy a point at least once. - */ - Point operator - (const Point &) const; - - /** - * Multiply by a factor. If possible, use - * #operator *=# instead since this does not - * need to copy a point at least once. - * - * There is a commutative complement to this - * function also - */ - Point operator * (const double) const; - - /** - * Divide by a factor. If possible, use - * #operator /=# instead since this does not - * need to copy a point at least once. - */ - Point operator / (const double) const; - - /** - * Add another vector, i.e. move this point by - * the given offset. - */ - Point & operator += (const Point &); - /** - * Subtract another vector. - */ - Point & operator -= (const Point &); - - /** - * Scale the vector by #factor#, i.e. multiply - * all coordinates by #factor#. - */ - Point & operator *= (const double &factor); - - /** - * Scale the vector by #1/factor#. - */ - Point & operator /= (const double &factor); - - /** - * Returns the scalar product of two vectors. - */ - double operator * (const Point &) const; - - /** - * Returns the scalar product of this point - * vector with itself, i.e. the square, or - * the square of the norm. - */ - double square () const; - - - /** - * Exception - */ - DeclException1 (ExcDimTooSmall, - int, - << "Given dimensions must be >= 1, but was " << arg1); - /** - * Exception - */ - DeclException1 (ExcInvalidIndex, - int, - << "Invalid index " << arg1); - protected: - /** - * Stores the coordinate values. - */ - double coordinates[dim]; -}; - - /** - * Prints the coordinates of this point in the - * form #x1 x2 x3 etc#. - */ -template -ostream & operator << (ostream &out, const Point &p); - - - - - - - -/*------------------------------- Inline functions: Point ---------------------------*/ - - -template -inline -Point::Point () { - Assert (dim>0, ExcDimTooSmall(dim)); - - for (unsigned int i=0; i -inline -Point<1>::Point (const double x) { - coordinates[0] = x; -}; - - - -template <> -inline -Point<2>::Point (const double x, const double y) { - coordinates[0] = x; - coordinates[1] = y; -}; - - - -template <> -inline -Point<3>::Point (const double x, const double y, const double z) { - coordinates[0] = x; - coordinates[1] = y; - coordinates[2] = z; -}; - - - -template -inline -Point::Point (const Point &p) { - for (unsigned int i=0; i -inline -double Point::operator () (const unsigned int index) const { - Assert (index -inline -double & Point::operator () (const unsigned int index) { - Assert (index -inline -Point & Point::operator = (const Point &p) { - for (unsigned int i=0; i -inline -bool Point::operator == (const Point &p) const { - for (unsigned int i=0; i -inline -bool Point::operator != (const Point &p) const { - return !((*this) == p); -}; - - - -template -inline -Point Point::operator + (const Point &p) const { - return (Point(*this) += p); -}; - - - -template -inline -Point Point::operator - (const Point &p) const { - return (Point(*this) -= p); -}; - - - -template -inline -Point Point::operator * (const double factor) const { - return (Point(*this) *= factor); -}; - - - -template -inline -Point operator * (const double factor, const Point &p) { - return p*factor; -}; - - - -template -inline -Point Point::operator / (const double factor) const { - return (Point(*this) /= factor); -}; - - - -template -inline -Point & Point::operator += (const Point &p) { - for (unsigned int i=0; i -inline -Point & Point::operator -= (const Point &p) { - for (unsigned int i=0; i -inline -Point & Point::operator *= (const double &s) { - for (unsigned int i=0; i -inline -Point & Point::operator /= (const double &s) { - for (unsigned int i=0; i -inline -double Point::operator * (const Point &p) const { - double q=0; - for (unsigned int i=0; i -inline -double Point::square () const { - double q=0; - for (unsigned int i=0; i -inline -ostream & operator << (ostream &out, const Point &p) { - for (unsigned int i=0; i -inline -ostream & operator << (ostream &out, const Point<1> &p) { - out << p(0); - - if (!out) - throw GlobalExcIO (); - - return out; -}; - - - - - -/*---------------------------- point.h ---------------------------*/ -/* end of #ifndef __point_H */ -#endif -/*---------------------------- point.h ---------------------------*/ -- 2.39.5