OpenFOAM logo
Open Source CFD Toolkit

line.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2005 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Class
00026     line
00027 
00028 Description
00029     A line primitive.
00030 
00031 SourceFiles
00032     lineI.H
00033 
00034 \*---------------------------------------------------------------------------*/
00035 
00036 #ifndef line_H
00037 #define line_H
00038 
00039 #include "vector.H"
00040 #include "pointHit.H"
00041 
00042 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00043 
00044 namespace Foam
00045 {
00046 
00047 // * * * * * * Forward declaration of template friend fuctions * * * * * * * //
00048 
00049 template<class Point, class PointRef> class line;
00050 
00051 class pointHit;
00052 class Istream;
00053 class Ostream;
00054 
00055 template<class Point, class PointRef>
00056 inline Istream& operator>>
00057 (
00058     Istream&,
00059     line<Point, PointRef>&
00060 );
00061 
00062 template<class Point, class PointRef>
00063 inline Ostream& operator<<
00064 (
00065     Ostream&,
00066     const line<Point, PointRef>&
00067 );
00068 
00069 /*---------------------------------------------------------------------------*\
00070                            Class line Declaration
00071 \*---------------------------------------------------------------------------*/
00072 
00073 template<class Point, class PointRef>
00074 class line
00075 {
00076     // Private data
00077 
00078         PointRef a_, b_;
00079 
00080 
00081 public:
00082 
00083     // Constructors
00084 
00085         //- Construct from two points
00086         inline line(const Point& start, const Point& end);
00087 
00088         //- Construct from Istream
00089         inline line(Istream&);
00090 
00091 
00092     // Member functions
00093 
00094         // Access
00095 
00096             //- Return first vertex
00097             inline PointRef start() const;
00098 
00099             //- Return second vertex
00100             inline PointRef end() const;
00101 
00102 
00103         // Properties
00104 
00105             //- Return centre (centroid)
00106             inline Point centre() const;
00107 
00108             //- Return scalar magnitude
00109             inline scalar mag() const;
00110 
00111             //- Return start-end vector
00112             inline vector vec() const;
00113 
00114             //- Return nearest distance to line from a given point
00115             //  If the nearest point is on the line, return a hit
00116             pointHit nearestDist(const point& p) const;
00117 
00118             //- Return nearest distance from line to line. Returns distance
00119             //  and sets both points (one on *this, one on the provided
00120             //  linePointRef
00121             scalar nearestDist
00122             (
00123                 const line<point, const point&>& edge,
00124                 point& thisPoint,
00125                 point& edgePoint
00126             ) const;
00127 
00128 
00129     // Ostream operator
00130 
00131         friend Istream& operator>> <Point, PointRef>
00132         (
00133             Istream&,
00134             line&
00135         );
00136 
00137         friend Ostream& operator<< <Point, PointRef>
00138         (
00139             Ostream&,
00140             const line&
00141         );
00142 };
00143 
00144 
00145 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00146 
00147 } // End namespace Foam
00148 
00149 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00150 
00151 #include "lineI.H"
00152 
00153 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00154 
00155 #endif
00156 
00157 // ************************************************************************* //
For further information go to www.openfoam.org