initial commit for version 1.5.x patch release
[OpenFOAM-1.5.x.git] / src / dynamicMesh / polyTopoChange / polyTopoChange / addObject / polyAddPoint.H
blob4358be6c4bb740b771149ce20d92d996f256f415
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2008 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
11     OpenFOAM is free software; you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
16     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
19     for more details.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 Class
26     Foam::polyAddPoint
28 Description
29     Class containing data for point addition.
31 \*---------------------------------------------------------------------------*/
33 #ifndef polyAddPoint_H
34 #define polyAddPoint_H
36 #include "label.H"
37 #include "point.H"
38 #include "topoAction.H"
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 namespace Foam
45 /*---------------------------------------------------------------------------*\
46                            Class polyAddPoint Declaration
47 \*---------------------------------------------------------------------------*/
49 class polyAddPoint
51     public topoAction
53     // Private data
55         //- Point to add
56         point p_;
58         //- Master point
59         label masterPointID_;
61         //- Point zone ID
62         label zoneID_;
64         //- Does the point support a cell
65         bool inCell_;
68 public:
70     // Static data members
72         //- Runtime type information
73         TypeName("addPoint");
76     // Constructors
78         //- Construct null.  Used only for list construction
79         polyAddPoint()
80         :
81             p_(vector::zero),
82             masterPointID_(-1),
83             zoneID_(-1),
84             inCell_(false)
85         {}
87         //- Construct from components
88         polyAddPoint
89         (
90             const point& p,
91             const label masterPointID,
92             const label zoneID,
93             const bool inCell
94         )
95         :
96             p_(p),
97             masterPointID_(masterPointID),
98             zoneID_(zoneID),
99             inCell_(inCell)
100         {
101             if (zoneID_ < 0 && !inCell)
102             {
103                 FatalErrorIn
104                 (
105                     "polyAddPoint\n"
106                     "(\n"
107                     "    const point& p,\n"
108                     "    const label masterPointID,\n"
109                     "    const label zoneID,\n"
110                     "    const bool inCell\n"
111                     ")"
112                 )   << "Point is not in a cell and not in a zone.  "
113                     << "This is not allowed.\n"
114                     << "point: " << p
115                     << " master: " << masterPointID_
116                     << " zone: " << zoneID_
117                     << abort(FatalError);
118             }
120         }
122         //- Construct and return a clone
123         virtual autoPtr<topoAction> clone() const
124         {
125             return autoPtr<topoAction>(new polyAddPoint(*this));
126         }
129     // Default Destructor
132     // Member Functions
134         //- Point location
135         const point& newPoint() const
136         {
137             return p_;
138         }
140         //- Master point label
141         label masterPointID() const
142         {
143             return masterPointID_;
144         }
146         //- Is the point appended with no master
147         bool appended() const
148         {
149             return masterPointID_ < 0;
150         }
152         //- Does the point belong to a zone?
153         bool isInZone() const
154         {
155             return zoneID_ >= 0;
156         }
158         //- Point zone ID
159         label zoneID() const
160         {
161             return zoneID_;
162         }
164         //- Does the point support a cell
165         bool inCell() const
166         {
167             return inCell_;
168         }
172 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
174 } // End namespace Foam
176 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
178 #endif
180 // ************************************************************************* //