boxScaling.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | cfMesh: A library for mesh generation
4  \\ / O peration |
5  \\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
6  \\/ M anipulation | Copyright (C) Creative Fields, Ltd.
7 -------------------------------------------------------------------------------
8 License
9  This file is part of cfMesh.
10 
11  cfMesh 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 3 of the License, or (at your
14  option) any later version.
15 
16  cfMesh 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.
20 
21  You should have received a copy of the GNU General Public License
22  along with cfMesh. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  boxScaling
26 
27 Description
28  Checks if a box is contained inside the box object
29 
30 SourceFiles
31  boxScaling.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef boxScaling_H
36 #define boxScaling_H
37 
38 #include "coordinateModification.H"
39 #include "point.H"
40 #include "typeInfo.H"
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
44 namespace Foam
45 {
46 
47 /*---------------------------------------------------------------------------*\
48  Class boxScaling Declaration
49 \*---------------------------------------------------------------------------*/
50 
51 class boxScaling
52 :
54 {
55  // Private data
56  //- centre of the box
57  point centre_;
58 
59  //- length of box sides
61 
62  //- scaling factors in all directions
64 
65  //- min point
66  point pMin_;
67 
68  //- max point
69  point pMax_;
70 
71  // Private member functions
72  //- calculate bounding box points
73  void calculateBndBox();
74 
75 public:
76 
77  //- Runtime type information
78  TypeName("box");
79 
80 
81  // Constructors
82 
83  //- Null construct
84  boxScaling();
85 
86  //- Construct from name, cell size, centre and sizes and scaling factors
88  (
89  const word& name,
90  const point& centre,
91  const scalar lengthX,
92  const scalar lengthY,
93  const scalar lengthZ,
94  const scalar scaleX = 1.0,
95  const scalar scaleY = 1.0,
96  const scalar scaleZ = 1.0
97  );
98 
99  //- Construct from dictionary
100  boxScaling(const word& name, const dictionary& dict);
101 
102  //- Construct and return a clone
104  (
105  const boxScaling& bs
106  ) const
107  {
109  (
110  new boxScaling
111  (
112  bs.name(),
113  bs.centre_,
114  bs.lengthVec_.x(),
115  bs.lengthVec_.y(),
116  bs.lengthVec_.z(),
117  bs.scaleVec_.x(),
118  bs.scaleVec_.y(),
119  bs.scaleVec_.z()
120  )
121  );
122  }
123 
124  // Member Functions
125 
126  //- return the centre of the box
127  virtual point origin() const;
128 
129  //- translate the object to the modified coordinates
130  //- this is needed for backward transformation
131  virtual void translateAndModifyObject(const vector&);
132 
133  //- calculate the displacement vector for box scaling
134  virtual vector displacement(const point&) const;
135 
136  //- calculate the displacement vector for box scaling
137  virtual vector backwardDisplacement(const point&) const;
138 
139  //- can this modification object be combined with other ones
140  virtual bool combiningPossible() const;
141 
142  //- return that "bounding planes" of the scaling region for
143  //- the given object
144  virtual void boundingPlanes(PtrList<plane>&) const;
145 
146  //- Return as dictionary of entries
147  dictionary dict(bool ignoreType = false) const;
148 
149  // Write
150 
151  //- Write
152  void write(Ostream&) const;
153 
154  //- Write dictionary
155  void writeDict(Ostream&, bool subDict = true) const;
156 
157  // Member Operators
158 
159  //- assign from dictionary
160  void operator=(const dictionary&);
161 
162  // IOstream Operators
163 
164  Ostream& operator<<(Ostream&) const;
165  friend Ostream& operator<<(Ostream&, const boxScaling&);
166 };
167 
168 
169 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
170 
171 } // End namespace Foam
172 
173 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
174 
175 #endif
176 
177 // ************************************************************************* //
Foam::boxScaling::writeDict
void writeDict(Ostream &, bool subDict=true) const
Write dictionary.
Definition: boxScaling.C:210
Foam::boxScaling
Definition: boxScaling.H:50
Foam::boxScaling::clone
virtual autoPtr< coordinateModification > clone(const boxScaling &bs) const
Construct and return a clone.
Definition: boxScaling.H:103
Foam::boxScaling::calculateBndBox
void calculateBndBox()
calculate bounding box points
Definition: boxScaling.C:41
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::boxScaling::write
void write(Ostream &) const
Write.
Definition: boxScaling.C:197
typeInfo.H
Foam::boxScaling::origin
virtual point origin() const
return the centre of the box
Definition: boxScaling.C:97
point.H
Foam::boxScaling::operator=
void operator=(const dictionary &)
assign from dictionary
Definition: boxScaling.C:237
Foam::boxScaling::backwardDisplacement
virtual vector backwardDisplacement(const point &) const
calculate the displacement vector for box scaling
Definition: boxScaling.C:129
Foam::boxScaling::lengthVec_
vector lengthVec_
length of box sides
Definition: boxScaling.H:59
Foam::boxScaling::boxScaling
boxScaling()
Null construct.
Definition: boxScaling.C:49
Foam::boxScaling::combiningPossible
virtual bool combiningPossible() const
can this modification object be combined with other ones
Definition: boxScaling.C:147
Foam::PtrList
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: List.H:61
Foam::boxScaling::TypeName
TypeName("box")
Runtime type information.
Foam::Vector::x
const Cmpt & x() const
Definition: VectorI.H:65
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
coordinateModification.H
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::Vector::z
const Cmpt & z() const
Definition: VectorI.H:77
Foam::boxScaling::translateAndModifyObject
virtual void translateAndModifyObject(const vector &)
Definition: boxScaling.C:102
Foam::autoPtr
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117
Foam::Vector< scalar >
Foam::boxScaling::scaleVec_
vector scaleVec_
scaling factors in all directions
Definition: boxScaling.H:62
Foam::coordinateModification::name
const word & name() const
Return name.
Definition: coordinateModification.H:130
Foam::boxScaling::operator<<
Ostream & operator<<(Ostream &) const
Definition: boxScaling.C:338
Foam::boxScaling::pMin_
point pMin_
min point
Definition: boxScaling.H:65
Foam::boxScaling::boundingPlanes
virtual void boundingPlanes(PtrList< plane > &) const
Definition: boxScaling.C:152
Foam::coordinateModification
Definition: coordinateModification.H:55
Foam::boxScaling::dict
dictionary dict(bool ignoreType=false) const
Return as dictionary of entries.
Definition: boxScaling.C:179
Foam::Vector::y
const Cmpt & y() const
Definition: VectorI.H:71
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::boxScaling::pMax_
point pMax_
max point
Definition: boxScaling.H:68
Foam::boxScaling::centre_
point centre_
centre of the box
Definition: boxScaling.H:56
Foam::boxScaling::displacement
virtual vector displacement(const point &) const
calculate the displacement vector for box scaling
Definition: boxScaling.C:112