Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F102275273
cube.cc
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, Feb 19, 00:20
Size
4 KB
Mime Type
text/x-c
Expires
Fri, Feb 21, 00:20 (2 d)
Engine
blob
Format
Raw Data
Handle
24321019
Attached To
rLIBMULTISCALE LibMultiScale
cube.cc
View Options
/**
* @file cube.cc
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author Till Junge <till.junge@epfl.ch>
*
* @date Mon Nov 25 17:17:19 2013
*
* @brief Cubic geometry
*
* @section LICENSE
*
* Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* LibMultiScale is free software: you can redistribute it and/or modify it
* under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* LibMultiScale is distributed in the hope that it will be useful, but
* WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with LibMultiScale. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "cube.hh"
#include "geometry_manager.hh"
#include "lm_common.hh"
/* -------------------------------------------------------------------------- */
__BEGIN_LIBMULTISCALE__
/* -------------------------------------------------------------------------- */
Cube Geometry::getBoundingBox() {
LMID bboxID = this->getID() + ":bbox";
Cube bbox(dim, bboxID);
return bbox;
}
/* -------------------------------------------------------------------------- */
Cube::Cube(UInt dim, LMID id) : LMObject(id), Geometry(dim, CUBE) {
xmin.setZero();
xmax.setZero();
hole.setZero();
ranges.setZero();
// for (UInt i = 0; i < 3; ++i) {
// xmin[i] = 0;
// xmax[i] = 0;
// hole[i] = 0;
// }
empty = true;
}
/* -------------------------------------------------------------------------- */
void Cube::setXmin(UInt i, Real r) {
this->xmin[i] = r;
this->ranges[2 * i + 0] = r;
this->init();
}
/* -------------------------------------------------------------------------- */
void Cube::setXmax(UInt i, Real r) {
this->xmax[i] = r;
this->ranges[2 * i + 1] = r;
this->init();
}
/* -------------------------------------------------------------------------- */
const Real &Cube::Hole(UInt i) const { return hole[i]; }
/* -------------------------------------------------------------------------- */
void Cube::setHole(Real *X) {
for (UInt i = 0; i < 3; ++i) {
hole[i] = X[i];
}
}
/* -------------------------------------------------------------------------- */
void Cube::resetDimensions() {
for (UInt i = 0; i < 3; ++i) {
setXmax(i, 0.0);
setXmin(i, 0.0);
}
init();
}
/* -------------------------------------------------------------------------- */
Real *Cube::getSize() { return size; }
/* -------------------------------------------------------------------------- */
Real Cube::getSize(UInt i) { return size[i]; }
/* -------------------------------------------------------------------------- */
Real *Cube::getSizeHalf() { return size_half; }
/* -------------------------------------------------------------------------- */
Real *Cube::getInvSizeHalf() { return inv_size_half; }
/* -------------------------------------------------------------------------- */
Cube Cube::getBoundingBox() { return *this; }
/* -------------------------------------------------------------------------- */
void Cube::init() {
for (UInt i = 0; i < 3; ++i) {
xmin[i] = this->ranges[2 * i + 0];
xmax[i] = this->ranges[2 * i + 1];
this->center[i] = getXmin()[i] + (getXmax()[i] - getXmin()[i]) / 2;
this->size[i] = getXmax()[i] - getXmin()[i];
this->size_half[i] = this->size[i] / 2.;
this->inv_size_half[i] = 1. / this->size_half[i];
}
}
/* -------------------------------------------------------------------------- */
/* LMDESC CUBE
This geometry is the generalized description of a bounding box.
There is also a mechanism to generate holes
(as described by the HOLE keyword) inside of a plain bounding box.
*/
/* LMEXAMPLE
GEOMETRY segment CUBE BBOX -10 10 \\
GEOMETRY rectangle CUBE BBOX -10 10 -20 20 \\
GEOMETRY cube CUBE BBOX -10 10 -10 10 -10 10 \\
*/
void Cube::declareParams() {
/* LMKEYWORD BBOX
Give the bounding box coordinates. For example:\\
GEOMETRY full CUBE BBOX -L0/2 L0/2 -L1/2 L1/2 \\
\includegraphics[scale=.2]{images/geom-cube} \\
*/
this->parseVectorKeyword("BBOX", dim * 2, ranges);
/* LMKEYWORD HOLE
In the bounding box description this provides the hole values
Below are provided a few self explanatory examples.
GEOMETRY 1d-hole CUBE BBOX -L0/2 L0/2 -L1/2 L1/2 HOLE L0/10 0 \\
\includegraphics[scale=.2]{images/geom-cube-hole1d} \\
GEOMETRY 2d-hole CUBE BBOX -L0/2 L0/2 -L1/2 L1/2 HOLE L0/10 L1/5 \\
\includegraphics[scale=.2]{images/geom-cube-hole2d} \\
*/
this->parseVectorKeyword("HOLE", dim, hole, VEC_DEFAULTS(0., 0., 0.));
}
/* -------------------------------------------------------------------------- */
__END_LIBMULTISCALE__
Event Timeline
Log In to Comment