Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
tools
frackit
Commits
1dc3fe3e
Commit
1dc3fe3e
authored
Jan 22, 2020
by
Dennis Gläser
Browse files
[sampling] add free function to create point samplers
parent
11bfd57c
Changes
2
Hide whitespace changes
Inline
Side-by-side
frackit/sampling/CMakeLists.txt
View file @
1dc3fe3e
...
@@ -4,6 +4,7 @@ cylinderpointsampler.hh
...
@@ -4,6 +4,7 @@ cylinderpointsampler.hh
disksampler.hh
disksampler.hh
geometrysampler.hh
geometrysampler.hh
geometrypointsampler.hh
geometrypointsampler.hh
makepointsampler.hh
pointsampler.hh
pointsampler.hh
uniformpointsamplertraits.hh
uniformpointsamplertraits.hh
DESTINATION
${
CMAKE_INSTALL_INCLUDEDIR
}
/frackit/sampling
)
DESTINATION
${
CMAKE_INSTALL_INCLUDEDIR
}
/frackit/sampling
)
frackit/sampling/makepointsampler.hh
0 → 100644
View file @
1dc3fe3e
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*****************************************************************************
* See the file COPYING for full copying permissions. *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program 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 General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*****************************************************************************/
/*!
* \file
* \brief Free functions to create point samplers from geometries.
*/
#ifndef FRACKIT_MAKE_POINT_SAMPLER_HH
#define FRACKIT_MAKE_POINT_SAMPLER_HH
#include "cylinderpointsampler.hh"
#include "boxpointsampler.hh"
namespace
Frackit
{
/*!
* \brief Overload of the free function to create point
* samplers for cylinders.
* \note Sampling along the radius coordinate occurs in the interval [0, r^2]
* and the square root is taken after sampling. Thus, the provided distribution
* must be for the squared radius rather than the radius itself.
*/
template
<
class
Traits
,
class
ctype
>
CylinderPointSampler
<
ctype
,
Traits
>
makePointSampler
(
const
Cylinder
<
ctype
>&
cylinder
)
{
using
Sampler
=
CylinderPointSampler
<
ctype
,
Traits
>
;
return
Sampler
(
cylinder
,
typename
Traits
::
DistributionBase1
(
0.0
,
cylinder
.
radius
()
*
cylinder
.
radius
()),
typename
Traits
::
DistributionBase2
(
0.0
,
2
*
M_PI
),
typename
Traits
::
DistributionBase3
(
0.0
,
cylinder
.
height
())
);
}
/*!
* \brief Overload of the free function to create point
* samplers for boxes.
*/
template
<
class
Traits
,
class
ctype
>
BoxPointSampler
<
ctype
,
Traits
>
makePointSampler
(
const
Box
<
ctype
>&
box
)
{
using
Sampler
=
BoxPointSampler
<
ctype
,
Traits
>
;
return
Sampler
(
typename
Traits
::
DistributionBase1
(
box
.
xMin
(),
box
.
xMax
()),
typename
Traits
::
DistributionBase2
(
box
.
yMin
(),
box
.
yMax
()),
typename
Traits
::
DistributionBase3
(
box
.
zMin
(),
box
.
zMax
())
);
}
}
// end namespace Frackit
#endif // FRACKIT_MAKE_POINT_SAMPLER_HH
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment