| 1 |
///////////////////////////////////////////////////////////// |
| 2 |
// // |
| 3 |
// Copyright (c) 2007-2017 by The University of Queensland // |
| 4 |
// Centre for Geoscience Computing // |
| 5 |
// http://earth.uq.edu.au/centre-geoscience-computing // |
| 6 |
// // |
| 7 |
// Primary Business: Brisbane, Queensland, Australia // |
| 8 |
// Licensed under the Open Software License version 3.0 // |
| 9 |
// http://www.apache.org/licenses/LICENSE-2.0 // |
| 10 |
// // |
| 11 |
///////////////////////////////////////////////////////////// |
| 12 |
|
| 13 |
#include "ShapeList.h" |
| 14 |
#include "HexAggregateShape.h" |
| 15 |
|
| 16 |
void ShapeList::addHexShape(int bias, int random) { |
| 17 |
HexAggregateShape shape; |
| 18 |
shape.setBias(bias); |
| 19 |
shape.makeOrientationRandom(random); |
| 20 |
shapeList.push_back(&shape); |
| 21 |
} |
| 22 |
|
| 23 |
void ShapeList::insertShape(Vector3 pos, double radius, MNTable3D* ntable, int tag, int id) { |
| 24 |
std::vector<int> biasList; |
| 25 |
unsigned int i; |
| 26 |
int biasTotal=0; |
| 27 |
// at all bias values. |
| 28 |
for(i=0; i < shapeList.size() ; i++) { |
| 29 |
int currBias = shapeList[i]->bias(); |
| 30 |
biasTotal = biasTotal + currBias; |
| 31 |
biasList.push_back ( currBias ); |
| 32 |
} |
| 33 |
|
| 34 |
if ( biasTotal == 0 ) { |
| 35 |
return; |
| 36 |
} |
| 37 |
|
| 38 |
// at a random value to select a shape |
| 39 |
int randomValue = rand() % biasTotal; |
| 40 |
i=0; |
| 41 |
// Find appropriate shape in list. |
| 42 |
while ( randomValue > shapeList[i]->bias() ) { |
| 43 |
randomValue = randomValue - shapeList[i]->bias(); |
| 44 |
i++; |
| 45 |
if (i == shapeList.size() ) { |
| 46 |
std::cout << "Error in ShapeList::insertShape :> randomValue too high\n"; |
| 47 |
return; |
| 48 |
} |
| 49 |
} |
| 50 |
shapeList[i]->insert(pos, radius, ntable, tag,id); |
| 51 |
} |
| 52 |
|
| 53 |
|
| 54 |
void ShapeList::addGenericShape(string db, string name, int bias, int random, |
| 55 |
int particleTag, int bondTag) { |
| 56 |
shapeList.push_back(new GenericShape(db,name)); |
| 57 |
Shape *shape = shapeList[shapeList.size()-1]; |
| 58 |
shape->setBias(bias); |
| 59 |
shape->makeOrientationRandom(random); |
| 60 |
shape->setParticleTag(particleTag); |
| 61 |
shape->setBondTag(bondTag); |
| 62 |
} |
| 63 |
|