AggregPacking
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros
heterogeometry.hpp
Go to the documentation of this file.
1 /*
2 *
3 * AggregPacking : Generator of random aggregate packings in concrete
4 *
5 * version 0.1 (2014-08-22)
6 *
7 * Copyright (C) 2014 Jan Stransky
8 *
9 * Czech Technical University, Faculty of Civil Engineering,
10 * Department of Structural Mechanics, 166 29 Prague, Czech Republic
11 *
12 * AggregPacking is free software: you can redistribute it and/or modify it
13 * under the terms of the GNU Lesser General Public License as published by the
14 * Free Software Foundation, either version 3 of the License, or (at your
15 * option) any later version.
16 *
17 * AggregPacking is distributed in the hope that it will be useful, but WITHOUT
18 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
20 * for more details.
21 *
22 * You should have received a copy of the GNU Lesser General Public License
23 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 */
25 
31 #ifndef HETEROGEOMETRY_HPP
32 #define HETEROGEOMETRY_HPP
33 
34 #include "utils.hpp"
35 #include "aggregate.hpp"
36 #include "randomizer.hpp"
37 #include "concmixture.hpp"
38 #include "octree.hpp"
39 using octree::Octree;
40 
41 #include <string>
42 using std::string;
43 
44 #ifdef AGGREGPACKING_SERIALIZATION
45 #include <iostream>
46 #include <fstream>
47 using std::istream;
48 using std::ostream;
49 using std::ifstream;
50 using std::ofstream;
51 #endif
52 
53 namespace aggregpacking {
54 
55 
56 /*********************************************************************
57 * HETERO GEOMETRY
58 *********************************************************************/
60 
64  protected:
65 #ifdef AGGREGPACKING_SERIALIZATION
66  HeteroGeometry() : HeteroGeometry(string()) {};
68 
70 
72  HeteroGeometry(const string& fileName) : fileName(fileName), aggregType(Sphere::className), aggregates(0), placeNumTries(10000) {};
73 #else
74  HeteroGeometry() : aggregType(Sphere::className), aggregates(0), placeNumTries(10000) {};
75 #endif
76 
78  vector<Aggregate*> aggregates;
79 
81  string fileName;
82 
85 
88 
90 
93  Aggregate* CreateParticle(double size);
94 
96 
99  void take(const AggregSizeRandomizer& aggregSizeRandomizer, const ConcreteMixture& concreteMixture);
100 
102 
105  bool place(double minRelAggregDist);
106 
108 
110  bool place() { return place(0.); }
111 
113 
116  virtual bool placeOneParticle(Aggregate& aggreg) = 0;
117 
119 
122  virtual bool containsParticle(const Aggregate& aggreg) = 0;
123 
125  void clearAggregates();
126 
128  string aggregType;
129 
130 #ifdef AGGREGPACKING_SERIALIZATION
131  void saveAggregates(ostream& os) const;
133 
135  void loadAggregates(istream& is);
136 #endif
137  public:
139 
143  void build(const AggregSizeRandomizer& aggregSizeRandomizer, const ConcreteMixture& concreteMixture, double minRelAggregDist);
144 
146 
149  void build(const AggregSizeRandomizer& aggregSizeRandomizer, const ConcreteMixture& concreteMixture) { build(aggregSizeRandomizer,concreteMixture,0.); }
150 
152 
156  void rebuild(const AggregSizeRandomizer& aggregSizeRandomizer, const ConcreteMixture& concreteMixture, double minRelAggregDist);
157 
159 
162  void rebuild(const AggregSizeRandomizer& aggregSizeRandomizer, const ConcreteMixture& concreteMixture) { rebuild(aggregSizeRandomizer,concreteMixture,0.); }
163 
165  virtual double computeVolume() = 0;
166 
168  virtual void initOctree() = 0;
169 
171  const vector<Aggregate*>& getAggregates() const { return aggregates; }
172 
174  vector<Aggregate*>& getAggregates() { return aggregates; }
175 
177  string getAggregType() { return aggregType; }
178 
180  const string& getAggregType() const { return aggregType; }
181 
183  void setAggregType(const string& s);
184 
187 
189  const Octree<Aggregate*>* getOctree() const { return octree; }
190 
192  string getFileName() { return fileName; }
193 
195  int getPlaceNumTries() { return placeNumTries; }
196 
198  void setPlaceNumTries(int v) { placeNumTries = v; }
199 
201 
203  bool check();
204 
205 #ifdef AGGREGPACKING_SERIALIZATION
206  virtual const string& getClassName() = 0;
208 
210  friend ostream& operator<<(ostream& f, const HeteroGeometry& o);
211 
213  friend istream& operator>>(istream& f, HeteroGeometry& o);
214 
216 
218  void save(const string& fName) const { saveObject(*this,fName,fileName); }
219 
221  void save() const { save(string()); }
222 
224 
226  bool load(const string& fName) { return loadObject(*this,fName,fileName); }
227 
229  bool load() { return load(string()); }
230 #endif
231 };
232 
233 
234 
235 
236 
237 
238 /*********************************************************************
239 * CUBE HETERO GEOMETRY
240 *********************************************************************/
242 
246  private:
248  double cubeSize;
249 
250  virtual bool placeOneParticle(Aggregate& aggreg);
251 
252  public:
253 #ifdef AGGREGPACKING_SERIALIZATION
254 
258  CubeHeteroGeometry(double c, const string& m);
259 
261 
263  CubeHeteroGeometry(double c) : CubeHeteroGeometry(c,string()) {}
264 #else
265  CubeHeteroGeometry(double c);
266 #endif
267 
270 
271  virtual void initOctree();
272 
274  virtual double computeVolume() { return pow(cubeSize,3); }
275 
277  double getCubeSize() { return cubeSize; }
278 
279  virtual bool containsParticle(const Aggregate& aggreg);
280 
281 #ifdef AGGREGPACKING_SERIALIZATION
282  const static string className;
284 
285  const string& getClassName() { return CubeHeteroGeometry::className; }
286 
288  friend ostream& operator<<(ostream& f, const CubeHeteroGeometry& o);
289 
291  friend istream& operator>>(istream& f, CubeHeteroGeometry& o);
292 #endif
293 };
294 
295 
296 
297 
298 
299 /*********************************************************************
300 * PYTHON
301 *********************************************************************/
302 #ifdef AGGREGPACKING_BOOST_PYTHON
303 void py_heterogeometry();
306 #endif
307 
308 } // namespace
309 #endif
Representation of spherical aggregate.
Definition: aggregate.hpp:251
Octree< Aggregate * > * getOctree()
Getter for octreee (by non-const pointer)
Definition: heterogeometry.hpp:186
virtual double computeVolume()=0
Compute volume of receiver.
HeteroGeometry()
Default constructor.
Definition: heterogeometry.hpp:67
Abstract class representing heterogeneous geometry.
Definition: heterogeometry.hpp:63
void rebuild(const AggregSizeRandomizer &aggregSizeRandomizer, const ConcreteMixture &concreteMixture, double minRelAggregDist)
Delete already build and re-generate the geometry by take-and-place process. Aggregates has at least ...
Definition: heterogeometry.cpp:65
CubeHeteroGeometry(double c, const string &m)
Constructor from size and file name.
Definition: heterogeometry.cpp:257
void setPlaceNumTries(int v)
Setter for placeNumTries.
Definition: heterogeometry.hpp:198
virtual void initOctree()=0
Initialize new octree (and delete the old one)
friend ostream & operator<<(ostream &f, const CubeHeteroGeometry &o)
CubeHeteroGeometry to ostream shift operator.
Definition: heterogeometry.cpp:301
virtual double computeVolume()
Compute volume of cube.
Definition: heterogeometry.hpp:274
File containing representation of different random number generators.
Representation of concrete mixture.
Definition: concmixture.hpp:42
File containing representation of different aggregate types.
bool load()
Saves receiver from this->fileName.
Definition: heterogeometry.hpp:229
double getCubeSize()
Getter for cube size.
Definition: heterogeometry.hpp:277
const vector< Aggregate * > & getAggregates() const
Getter for aggregates (return by const reference)
Definition: heterogeometry.hpp:171
void build(const AggregSizeRandomizer &aggregSizeRandomizer, const ConcreteMixture &concreteMixture)
Generate the geometry by take-and-place process. Aggregates do not overlap. Do nothing if already bui...
Definition: heterogeometry.hpp:149
string getAggregType()
Getter for aggregate type (by value)
Definition: heterogeometry.hpp:177
File containing several auxiliary functions.
Abstract class representing random size generator for given sieve curve.
Definition: randomizer.hpp:99
virtual bool containsParticle(const Aggregate &aggreg)
Tests if given particle is entirely contained by receiver.
Definition: heterogeometry.cpp:293
bool place()
Places all particles randomly such that they do not overlap and all are entirely contained by the cub...
Definition: heterogeometry.hpp:110
Abstract class representing one aggregate particle.
Definition: aggregate.hpp:63
double cubeSize
Cube size of receiver.
Definition: heterogeometry.hpp:248
Octree< Aggregate * > * octree
Octree (for faster spatial checks)
Definition: heterogeometry.hpp:84
friend istream & operator>>(istream &f, CubeHeteroGeometry &o)
CubeHeteroGeometry from istream shift operator.
Definition: heterogeometry.cpp:308
vector< Aggregate * > & getAggregates()
Getter for aggregates (return by non-const reference)
Definition: heterogeometry.hpp:174
Class representing full octree.
Definition: octree.hpp:128
const string & getClassName()
Returns string representation of Sphere class name.
Definition: heterogeometry.hpp:285
void saveObject(const T &t, const string &fName, const string &memoizeDb)
Auxiliary template function for saving objects to files.
Definition: utils.hpp:142
bool load(const string &fName)
Loads receiver from given file.
Definition: heterogeometry.hpp:226
HeteroGeometry(const string &fileName)
Default constructor from file name.
Definition: heterogeometry.hpp:72
void setAggregType(const string &s)
Setter for aggreg type.
Definition: heterogeometry.cpp:43
friend ostream & operator<<(ostream &f, const HeteroGeometry &o)
HeteroGeometry to ostream shift operator.
Definition: heterogeometry.cpp:209
friend istream & operator>>(istream &f, HeteroGeometry &o)
HeteroGeometry from istream shift operator.
Definition: heterogeometry.cpp:219
virtual bool containsParticle(const Aggregate &aggreg)=0
Tests if given particle is entirely contained by receiver.
File containing representation of concrete mixture.
CubeHeteroGeometry(double c)
Constructor from size.
Definition: heterogeometry.hpp:263
void save() const
Saves receiver to this->fileName.
Definition: heterogeometry.hpp:221
bool check()
Checks that no particles overlap.
Definition: heterogeometry.cpp:191
string fileName
File name for saving files.
Definition: heterogeometry.hpp:81
const Octree< Aggregate * > * getOctree() const
Getter for octreee (by const pointer)
Definition: heterogeometry.hpp:189
int getPlaceNumTries()
Getter for placeNumTries.
Definition: heterogeometry.hpp:195
virtual bool placeOneParticle(Aggregate &aggreg)
Places one particle such that it does not overlap with already placed particles and is entirely conta...
Definition: heterogeometry.cpp:278
string getFileName()
Getter for file name.
Definition: heterogeometry.hpp:192
void rebuild(const AggregSizeRandomizer &aggregSizeRandomizer, const ConcreteMixture &concreteMixture)
Delete already build and re-generate the geometry by take-and-place process. Aggregates do not overla...
Definition: heterogeometry.hpp:162
void take(const AggregSizeRandomizer &aggregSizeRandomizer, const ConcreteMixture &concreteMixture)
Creates a random particle.
Definition: heterogeometry.cpp:94
const string & getAggregType() const
Getter for aggregate type (by const reference)
Definition: heterogeometry.hpp:180
File containing octree representation.
void loadAggregates(istream &is)
Loads receiver from given istream.
Definition: heterogeometry.cpp:236
virtual void initOctree()
Initialize new octree (and delete the old one)
Definition: heterogeometry.cpp:273
bool loadObject(T &t, const string &fName, const string &memoizeDb)
Auxiliary template function for lading objects from files.
Definition: utils.hpp:151
void save(const string &fName) const
Saves receiver to given file.
Definition: heterogeometry.hpp:218
virtual bool placeOneParticle(Aggregate &aggreg)=0
Places one particle such that it does not overlap with already placed particles and is entirely conta...
void saveAggregates(ostream &os) const
Saves receiver to given ostream.
Definition: heterogeometry.cpp:229
int placeNumTries
How many tries of one particle placement is done until error is thrown (default 10000) ...
Definition: heterogeometry.hpp:87
void build(const AggregSizeRandomizer &aggregSizeRandomizer, const ConcreteMixture &concreteMixture, double minRelAggregDist)
Generate the geometry by take-and-place process. Aggregates has at least guaranteed distance between ...
Definition: heterogeometry.cpp:51
Abstract class representing heterogeneous geometry.
Definition: heterogeometry.hpp:245
void clearAggregates()
Delete all aggregates.
Definition: heterogeometry.cpp:73
~CubeHeteroGeometry()
Destructor.
Definition: heterogeometry.cpp:267
string aggregType
Aggregate type to generate. Currently implemented are "Sphere" and "Ellipsoid".
Definition: heterogeometry.hpp:128
Aggregate * CreateParticle(double size)
Creates and return new Aggregate particle according to aggregType and given size. ...
Definition: heterogeometry.cpp:80
virtual const string & getClassName()=0
Returns string representation of Sphere class name.
vector< Aggregate * > aggregates
Aggregates container.
Definition: heterogeometry.hpp:72
static const string className
String representation of CubeHeteroGeometry class name.
Definition: heterogeometry.hpp:283