Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CBox Class Reference

#include <GeoPrimitives.H>

Collaboration diagram for CBox:

Public Member Functions

 CBox ()
 
 CBox (const std::vector< CPoint > &pv)
 
 CBox (const double *points, unsigned int n)
 
 CBox (const CPoint &ip1, const CPoint &ip2)
 
 CBox (const CBox &box)
 
const CPointP1 () const
 
const CPointP2 () const
 
bool empty () const
 
CPointP1 ()
 
CPointP2 ()
 
void init (const double *points, unsigned int n)
 
CBoxoperator= (const CBox &b)
 
CBox around (const CPoint &p) const
 
bool operator== (const CBox &b) const
 
CPointmin ()
 
const CPointmin () const
 
CPointmax ()
 
const CPointmax () const
 
bool contains (const CPoint &p) const
 
bool contains (const double *p) const
 
double size () const
 
bool operator< (const CBox &b) const
 
bool operator> (const CBox &b) const
 
void AddPoint (const CPoint &p)
 
void merge (const CBox &b)
 
bool collide (const CBox &b) const
 
CBox intersect (const CBox &b) const
 

Protected Attributes

CPoint p1
 
CPoint p2
 

Private Attributes

bool initd
 

Friends

std::ostream & operator<< (std::ostream &, const CBox &)
 

Detailed Description

Definition at line 1126 of file GeoPrimitives.H.

Constructor & Destructor Documentation

CBox ( )
inline

Definition at line 1134 of file GeoPrimitives.H.

References CBox::initd, CBox::p1, CBox::p2, and CPoint::reset().

1135  {
1136  p1.reset();
1137  p2.reset();
1138  initd=false;
1139  };
CPoint & reset()

Here is the call graph for this function:

CBox ( const std::vector< CPoint > &  pv)
inline

Definition at line 1140 of file GeoPrimitives.H.

References CBox::initd, CBox::p1, CBox::p2, CPoint::x(), CPoint::y(), and CPoint::z().

1141  {
1142  std::vector<CPoint>::const_iterator pvi = pv.begin();
1143  p1.x(pvi->x());
1144  p2.x(p1.x());
1145  p1.y(pvi->y());
1146  p2.y(p1.y());
1147  p1.z(pvi->z());
1148  p2.z(p1.z());
1149  pvi++;
1150  while(pvi != pv.end()){
1151  if(pvi->x() < p1.x()) p1.x(pvi->x());
1152  if(pvi->x() > p2.x()) p2.x(pvi->x());
1153  if(pvi->y() < p1.y()) p1.y(pvi->y());
1154  if(pvi->y() > p2.y()) p2.y(pvi->y());
1155  if(pvi->z() < p1.z()) p1.z(pvi->z());
1156  if(pvi->z() > p2.z()) p2.z(pvi->z());
1157  pvi++;
1158  }
1159  initd = true;
1160  }

Here is the call graph for this function:

CBox ( const double *  points,
unsigned int  n 
)
inline

Definition at line 1161 of file GeoPrimitives.H.

References i, CBox::initd, n, CBox::p1, CBox::p2, CPoint::x(), CPoint::y(), and CPoint::z().

1162  {
1163  p1.x(points[0]);
1164  p1.y(points[1]);
1165  p1.z(points[2]);
1166  p2 = p1;
1167  for(unsigned int i = 1;i<n;i++){
1168  if(points[i*3] < p1.x()) p1.x(points[i*3]);
1169  if(points[i*3] > p2.x()) p2.x(points[i*3]);
1170  if(points[(i*3)+1] < p1.y()) p1.y(points[(i*3)+1]);
1171  if(points[(i*3)+1] > p2.y()) p2.y(points[(i*3)+1]);
1172  if(points[(i*3)+2] < p1.z()) p1.z(points[(i*3)+2]);
1173  if(points[(i*3)+2] > p2.z()) p2.z(points[(i*3)+2]);
1174  }
1175  initd = true;
1176  };
Definition: points.h:30
blockLoc i
Definition: read.cpp:79
const NT & n

Here is the call graph for this function:

CBox ( const CPoint ip1,
const CPoint ip2 
)
inline

Definition at line 1177 of file GeoPrimitives.H.

References CBox::initd.

1178  : p1(ip1),p2(ip2)
1179  {initd = true;};
CBox ( const CBox box)
inline

Definition at line 1180 of file GeoPrimitives.H.

References CBox::initd.

1181  : p1(box.p1),p2(box.p2)
1182  {initd = true;};
KD_tree::Box box
Definition: Overlay_0d.C:47

Member Function Documentation

void AddPoint ( const CPoint p)
inline

Definition at line 1275 of file GeoPrimitives.H.

References CBox::initd, CBox::p1, CBox::p2, CPoint::x(), CPoint::y(), and CPoint::z().

1276  {
1277  if(!initd){
1278  p1 = p;
1279  p2 = p;
1280  initd = true;
1281  }
1282  else{
1283  if(p.x() < p1.x()) p1.x() = p.x();
1284  if(p.x() > p2.x()) p2.x() = p.x();
1285  if(p.y() < p1.y()) p1.y() = p.y();
1286  if(p.y() > p2.y()) p2.y() = p.y();
1287  if(p.z() < p1.z()) p1.z() = p.z();
1288  if(p.z() > p2.z()) p2.z() = p.z();
1289  }
1290  };

Here is the call graph for this function:

CBox around ( const CPoint p) const
inline

Definition at line 1213 of file GeoPrimitives.H.

References CBox::p1, CBox::p2, v, CPoint::x(), CVector::x(), CPoint::y(), CVector::y(), CPoint::z(), and CVector::z().

1214  {
1215  CVector v(p1,p2);
1216  CPoint minp(p.x()-fabs(v.x()/2.0),
1217  p.y()-fabs(v.y()/2.0),
1218  p.z()-fabs(v.z()/2.0));
1219  CPoint maxp(p.x()+fabs(v.x()/2.0),
1220  p.y()+fabs(v.y()/2.0),
1221  p.z()+fabs(v.z()/2.0));
1222  CBox box(minp,maxp);
1223  return(box);
1224  };
KD_tree::Box box
Definition: Overlay_0d.C:47
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20

Here is the call graph for this function:

bool collide ( const CBox b) const
inline

Definition at line 1309 of file GeoPrimitives.H.

References CBox::empty(), CBox::p1, CBox::p2, CPoint::x(), CPoint::y(), and CPoint::z().

Referenced by CBox::intersect().

1310  {
1311  if(this->empty() || b.empty())
1312  return(false);
1313  return(!(b.p2.x() < p1.x() || b.p1.x() > p2.x()) &&
1314  !(b.p2.y() < p1.y() || b.p1.y() > p2.y()) &&
1315  !(b.p2.z() < p1.z() || b.p1.z() > p2.z()));
1316  };
bool empty() const

Here is the call graph for this function:

Here is the caller graph for this function:

bool contains ( const CPoint p) const
inline

Definition at line 1249 of file GeoPrimitives.H.

References CBox::p1, CBox::p2, CPoint::x(), CPoint::y(), and CPoint::z().

1250  {
1251  return( p.x() <= p2.x() && p.x() >= p1.x() &&
1252  p.y() <= p2.y() && p.y() >= p1.y() &&
1253  p.z() <= p2.z() && p.z() >= p1.z() );
1254  };

Here is the call graph for this function:

bool contains ( const double *  p) const
inline

Definition at line 1255 of file GeoPrimitives.H.

References CBox::p1, CBox::p2, CPoint::x(), CPoint::y(), and CPoint::z().

1256  {
1257  return( p[0] <= p2.x() && p[0] >= p1.x() &&
1258  p[1] <= p2.y() && p[1] >= p1.y() &&
1259  p[2] <= p2.z() && p[2] >= p1.z() );
1260  };

Here is the call graph for this function:

bool empty ( void  ) const
inline

Definition at line 1185 of file GeoPrimitives.H.

References CBox::p1, CBox::p2, GeoPrim::TOL, CPoint::x(), CPoint::y(), and CPoint::z().

Referenced by CBox::collide(), and main().

1185  {return ((std::fabs(p2.x()-p1.x()) < TOL) ||
1186  (std::fabs(p2.y()-p1.y()) < TOL) ||
1187  (std::fabs(p2.z()-p1.z()) < TOL));};
const double TOL
Definition: GeoPrimitives.H:17

Here is the call graph for this function:

Here is the caller graph for this function:

void init ( const double *  points,
unsigned int  n 
)
inline

Definition at line 1190 of file GeoPrimitives.H.

References i, CBox::initd, n, CBox::p1, CBox::p2, CPoint::x(), CPoint::y(), and CPoint::z().

1191  {
1192  initd = true;
1193  p1.x(points[0]);
1194  p1.y(points[1]);
1195  p1.z(points[2]);
1196  p2 = p1;
1197  for(unsigned int i = 1;i<n;i++){
1198  if(points[i*3] < p1.x()) p1.x(points[i*3]);
1199  if(points[i*3] > p2.x()) p2.x(points[i*3]);
1200  if(points[(i*3)+1] < p1.y()) p1.y(points[(i*3)+1]);
1201  if(points[(i*3)+1] > p2.y()) p2.y(points[(i*3)+1]);
1202  if(points[(i*3)+2] < p1.z()) p1.z(points[(i*3)+2]);
1203  if(points[(i*3)+2] > p2.z()) p2.z(points[(i*3)+2]);
1204  }
1205  };
Definition: points.h:30
blockLoc i
Definition: read.cpp:79
const NT & n

Here is the call graph for this function:

CBox intersect ( const CBox b) const
inline

Definition at line 1317 of file GeoPrimitives.H.

References CBox::collide(), CBox::p1, CBox::p2, CPoint::x(), CPoint::y(), and CPoint::z().

1318  {
1319  CBox retval;
1320  if(collide(b)){
1321  retval.p1.x(b.p1.x() > p1.x() ? b.p1.x() : p1.x());
1322  retval.p1.y(b.p1.y() > p1.y() ? b.p1.y() : p1.y());
1323  retval.p1.z(b.p1.z() > p1.z() ? b.p1.z() : p1.z());
1324  retval.p2.x(b.p2.x() < p2.x() ? b.p2.x() : p2.x());
1325  retval.p2.y(b.p2.y() < p2.y() ? b.p2.y() : p2.y());
1326  retval.p2.z(b.p2.z() < p2.z() ? b.p2.z() : p2.z());
1327  }
1328  return(retval);
1329  };
bool collide(const CBox &b) const

Here is the call graph for this function:

CPoint& max ( void  )
inline

Definition at line 1241 of file GeoPrimitives.H.

References CBox::p2.

1242  {
1243  return(p2);
1244  };
const CPoint& max ( void  ) const
inline

Definition at line 1245 of file GeoPrimitives.H.

References CBox::p2.

1246  {
1247  return(p2);
1248  };
void merge ( const CBox b)
inline

Definition at line 1291 of file GeoPrimitives.H.

References CBox::initd, CBox::p1, CBox::p2, CPoint::x(), CPoint::y(), and CPoint::z().

Referenced by main().

1292  {
1293  if(initd){
1294  CPoint p(p1);
1295  p1.x((b.p1.x() > p1.x() ? p.x() : b.p1.x()));
1296  p1.y((b.p1.y() > p1.y() ? p.y() : b.p1.y()));
1297  p1.z((b.p1.z() > p1.z() ? p.z() : b.p1.z()));
1298  p = p2;
1299  p2.x(b.p2.x() < p2.x() ? p.x() : b.p2.x());
1300  p2.y(b.p2.y() < p2.y() ? p.y() : b.p2.y());
1301  p2.z(b.p2.z() < p2.z() ? p.z() : b.p2.z());
1302  }
1303  else {
1304  p1 = b.p1;
1305  p2 = b.p2;
1306  initd = true;
1307  }
1308  };

Here is the call graph for this function:

Here is the caller graph for this function:

CPoint& min ( )
inline

Definition at line 1233 of file GeoPrimitives.H.

References CBox::p1.

1234  {
1235  return(p1);
1236  };
const CPoint& min ( ) const
inline

Definition at line 1237 of file GeoPrimitives.H.

References CBox::p1.

1238  {
1239  return(p1);
1240  };
bool operator< ( const CBox b) const
inline

Definition at line 1267 of file GeoPrimitives.H.

References CBox::size().

1268  {
1269  return(this->size() < b.size());
1270  };
double size() const

Here is the call graph for this function:

CBox& operator= ( const CBox b)
inline

Definition at line 1206 of file GeoPrimitives.H.

References CBox::initd, CBox::p1, and CBox::p2.

1207  {
1208  p1 = b.p1;
1209  p2 = b.p2;
1210  initd = true;
1211  return(*this);
1212  };
bool operator== ( const CBox b) const
inline

Definition at line 1225 of file GeoPrimitives.H.

References CBox::p1, and CBox::p2.

1226  {
1227  return(p1 == b.p1 && p2 == b.p2);
1228  };
bool operator> ( const CBox b) const
inline

Definition at line 1271 of file GeoPrimitives.H.

References CBox::size().

1272  {
1273  return(this->size() > b.size());
1274  };
double size() const

Here is the call graph for this function:

const CPoint& P1 ( ) const
inline

Definition at line 1183 of file GeoPrimitives.H.

References CBox::p1.

Referenced by main(), and GeoPrim::operator<<().

1183 {return p1;};

Here is the caller graph for this function:

CPoint& P1 ( )
inline

Definition at line 1188 of file GeoPrimitives.H.

References CBox::p1.

1188 {return p1;};
const CPoint& P2 ( ) const
inline

Definition at line 1184 of file GeoPrimitives.H.

References CBox::p2.

Referenced by main(), and GeoPrim::operator<<().

1184 {return p2;};

Here is the caller graph for this function:

CPoint& P2 ( )
inline

Definition at line 1189 of file GeoPrimitives.H.

References CBox::p2.

1189 {return p2;};
double size ( ) const
inline

Definition at line 1262 of file GeoPrimitives.H.

References CBox::p1, CBox::p2, v, CVector::x(), CVector::y(), and CVector::z().

Referenced by CBox::operator<(), and CBox::operator>().

1263  {
1264  CVector v(p1,p2);
1265  return(fabs(v.x()*v.y()*v.z()));
1266  };
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20

Here is the call graph for this function:

Here is the caller graph for this function:

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  oS,
const CBox b 
)
friend

Definition at line 55 of file GeoPrimitives.C.

56  {
57  oS << b.P1() << " " << b.P2();
58  return(oS);
59  }

Member Data Documentation

bool initd
private

The documentation for this class was generated from the following file: