Debian Codegraph @

src/BoxWithLines2DSubVol.cc

raw
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 "BoxWithLines2DSubVol.h"
14
15 // --- system includes ---
16 #include <cmath>
17
18 using std::ceil;
19
20 BoxWithLines2DSubVol::BoxWithLines2DSubVol()
21 {}
22
23 /*!
24 construct box
25
26 \param pmin minimum point of bounding box
27 \param pmax maximum point of bounding box
28 \param svdim_x
29 \param svdim_y
30 */
31 BoxWithLines2DSubVol::BoxWithLines2DSubVol(const Vector3& pmin,const Vector3& pmax,double svdim_x,double svdim_y):BoxWithLines2D(pmin,pmax)
32 {
33 m_nsv_x=int(ceil((pmax-pmin).X())/svdim_x);
34 m_nsv_y=int(ceil((pmax-pmin).Y())/svdim_y);
35 m_svdim_x=(pmax-pmin).X()/double(m_nsv_x);
36 m_svdim_y=(pmax-pmin).X()/double(m_nsv_x);
37 }
38
39 /*!
40 get a point within a given subvolume
41
42 \param id index of the subvolume
43 */
44 Vector3 BoxWithLines2DSubVol::BoxWithLines2DSubVol::getAPoint(int id) const
45 {
46 int idx=id%m_nsv_x;
47 int idy=id/m_nsv_x;
48
49 double minx=double(idx)*m_svdim_x;
50 double maxx=double(idx+1)*m_svdim_x;
51 double miny=double(idy)*m_svdim_y;
52 double maxy=double(idy+1)*m_svdim_y;
53
54
55
56 double px=m_random(minx,maxx);
57 double py=m_random(miny,maxy);
58
59 //std::cout << "id, x, y, p " << id << " [ " << minx << " - " << maxx << " ] [ " << miny << " - " << maxy << " ] [ " << px << " - " << py << " ] " << std::endl;
60 return Vector3(px,py,0.0);
61 }
62
63 int BoxWithLines2DSubVol::BoxWithLines2DSubVol::getNumberSubVolumes() const
64 {
65 return m_nsv_x*m_nsv_y;
66 }