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

#include <BndSurface.h>

Collaboration diagram for MeshBndSurf:

Public Member Functions

 MeshBndSurf ()
 
 MeshBndSurf (Vec3D *n, Tri *t, unsigned int nv, unsigned int nt)
 
 ~MeshBndSurf ()
 
bool intersection (const Vec3D &p, const Vec3D &d, Vec3D &x)
 
void initialize (double *nodes, int *triangles, unsigned int nv, unsigned int nt, int divisions=50)
 
bool intersection (double *p, double *d, double *x)
 
 MeshBndSurf ()
 
 MeshBndSurf (Vec3D *n, Tri *t, unsigned int nv, unsigned int nt)
 
 ~MeshBndSurf ()
 
bool intersection (const Vec3D &p, const Vec3D &d, Vec3D &x)
 
void initialize (double *nodes, int *triangles, unsigned int nv, unsigned int nt, int divisions=50)
 
bool intersection (double *p, double *d, double *x)
 

Private Member Functions

void compute_bbox (Point3D &bbmin, Point3D &bbmax)
 
void compute_bbox (Point3D &bbmin, Point3D &bbmax)
 

Private Attributes

KNN_Grid< Tri > * gSpace
 
Point3D bbmin
 
Point3D bbmax
 
Vec3Dnode_array
 
Tritri_array
 
unsigned int numv
 
unsigned int numt
 

Detailed Description

Definition at line 85 of file Rocon/include/BndSurface.h.

Constructor & Destructor Documentation

MeshBndSurf ( )
inline

Definition at line 123 of file Rocon/include/BndSurface.h.

123 :gSpace(NULL),node_array(NULL),tri_array(NULL),numv(0),numt(0){}
KNN_Grid< Tri > * gSpace
MeshBndSurf ( Vec3D n,
Tri t,
unsigned int  nv,
unsigned int  nt 
)
inline

Definition at line 125 of file Rocon/include/BndSurface.h.

References i, and q.

126  :node_array(n),tri_array(t),numv(nv),numt(nt)
127  {
129  gSpace = new KNN_Grid< Tri > (bbmin, bbmax, 8);
130  for(unsigned int i=0; i<nt; ++i){
131  Point3D p(n[t[i][0]][0], n[t[i][0]][1], n[t[i][0]][2]);
132  Point3D q(n[t[i][1]][0], n[t[i][1]][1], n[t[i][1]][2]);
133  Point3D r(n[t[i][2]][0], n[t[i][2]][1], n[t[i][2]][2]);
134  gSpace->insertRange(t[i], p,q,r);
135  }
136  }
int insertRange(T &item, Point3D &p, Point3D &q, Point3D &r)
void compute_bbox(Point3D &bbmin, Point3D &bbmax)
blockLoc i
Definition: read.cpp:79
NT q
KNN_Grid< Tri > * gSpace
~MeshBndSurf ( )
inline

Definition at line 138 of file Rocon/include/BndSurface.h.

138  {
139  delete gSpace;
140  delete [] node_array;
141  delete [] tri_array;
142  }
KNN_Grid< Tri > * gSpace
MeshBndSurf ( )
inline

Definition at line 123 of file Rocprop/include/BndSurface.h.

123 :gSpace(NULL),node_array(NULL),tri_array(NULL),numv(0),numt(0){}
KNN_Grid< Tri > * gSpace
MeshBndSurf ( Vec3D n,
Tri t,
unsigned int  nv,
unsigned int  nt 
)
inline

Definition at line 125 of file Rocprop/include/BndSurface.h.

References i, and q.

126  :node_array(n),tri_array(t),numv(nv),numt(nt)
127  {
129 
130  gSpace = new KNN_Grid< Tri > (bbmin, bbmax, 8);
131  for(int i=0; i<nt; ++i){
132  Point3D p(n[t[i][0]][0], n[t[i][0]][1], n[t[i][0]][2]);
133  Point3D q(n[t[i][1]][0], n[t[i][1]][1], n[t[i][1]][2]);
134  Point3D r(n[t[i][2]][0], n[t[i][2]][1], n[t[i][2]][2]);
135  gSpace->insertRange(t[i], p,q,r);
136  }
137  }
int insertRange(T &item, Point3D &p, Point3D &q, Point3D &r)
void compute_bbox(Point3D &bbmin, Point3D &bbmax)
blockLoc i
Definition: read.cpp:79
NT q
KNN_Grid< Tri > * gSpace
~MeshBndSurf ( )
inline

Definition at line 139 of file Rocprop/include/BndSurface.h.

139  {
140  delete gSpace;
141  delete [] node_array;
142  delete [] tri_array;
143  }
KNN_Grid< Tri > * gSpace

Member Function Documentation

void compute_bbox ( Point3D bbmin,
Point3D bbmax 
)
inlineprivate

Definition at line 96 of file Rocon/include/BndSurface.h.

References i, and v.

97  {
98  if (numv == 0)
99  {
100  bbmin = bbmax = 0.0;
101  }
102  else
103  {
104  bbmin = bbmax = node_array[0];
105  }
106 
107  for(unsigned int i=1; i<numv; i++)
108  {
109  Vertex3D & v = node_array[i];
110 
111  if(v[0] < bbmin[0]) bbmin[0]=v[0];
112  if(v[1] < bbmin[1]) bbmin[1]=v[1];
113  if(v[2] < bbmin[2]) bbmin[2]=v[2];
114 
115  if(v[0] > bbmax[0]) bbmax[0]=v[0];
116  if(v[1] > bbmax[1]) bbmax[1]=v[1];
117  if(v[2] > bbmax[2]) bbmax[2]=v[2];
118  }
119  }
*********************************************************************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
blockLoc i
Definition: read.cpp:79
void compute_bbox ( Point3D bbmin,
Point3D bbmax 
)
inlineprivate

Definition at line 96 of file Rocprop/include/BndSurface.h.

References i, and v.

97  {
98  if (numv == 0)
99  {
100  bbmin = bbmax = 0.0;
101  }
102  else
103  {
104  bbmin = bbmax = node_array[0];
105  }
106 
107  for(unsigned int i=1; i<numv; i++)
108  {
109  Vertex3D & v = node_array[i];
110 
111  if(v[0] < bbmin[0]) bbmin[0]=v[0];
112  if(v[1] < bbmin[1]) bbmin[1]=v[1];
113  if(v[2] < bbmin[2]) bbmin[2]=v[2];
114 
115  if(v[0] > bbmax[0]) bbmax[0]=v[0];
116  if(v[1] > bbmax[1]) bbmax[1]=v[1];
117  if(v[2] > bbmax[2]) bbmax[2]=v[2];
118  }
119  }
*********************************************************************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
blockLoc i
Definition: read.cpp:79
void initialize ( double *  nodes,
int *  triangles,
unsigned int  nv,
unsigned int  nt,
int  divisions = 50 
)
inline

Definition at line 193 of file Rocprop/include/BndSurface.h.

References i, j, MAX_GRID_DIV, and q.

194  {
195  numv=nv;
196  numt=nt;
197  //make sure grid divisions are sane
198  if (divisions > MAX_GRID_DIV)
199  {
200  cerr << "Grid divsisions on longest dimension must be less than or equal to " << MAX_GRID_DIV << endl;
201  divisions = MAX_GRID_DIV;
202  }
203 
204  //Copy nodal coordinates
205  if (node_array != NULL)
206  delete [] node_array;
207 
208  node_array = new Vec3D[numv];
209  for(int i=0;i<numv;i++)
210  {
211  for(int j=0;j<3;j++)
212  {
213  (node_array[i])[j]=nodes[i*3+j];
214  }
215  }
216 
217  //Copy triangle connectivity
218  if (tri_array != NULL)
219  delete [] tri_array;
220 
221  tri_array = new Tri[numt];
222  for(int i=0;i<numt;i++)
223  {
224  for(int j=0;j<3;j++)
225  {
226  (tri_array[i])[j]=triangles[i*3+j];
227  }
228  }
229 
231  if (gSpace != NULL)
232  delete gSpace;
233 
234  gSpace = new KNN_Grid< Tri > (bbmin, bbmax, divisions);
235  for(int i=0; i<nt; ++i)
236  {
237  Point3D p(node_array[tri_array[i][0]][0], node_array[tri_array[i][0]][1], node_array[tri_array[i][0]][2]);
238  Point3D q(node_array[tri_array[i][1]][0], node_array[tri_array[i][1]][1], node_array[tri_array[i][1]][2]);
239  Point3D r(node_array[tri_array[i][2]][0], node_array[tri_array[i][2]][1], node_array[tri_array[i][2]][2]);
240  gSpace->insertRange(tri_array[i], p,q,r);
241  }
242  }
int insertRange(T &item, Point3D &p, Point3D &q, Point3D &r)
#define MAX_GRID_DIV
void compute_bbox(Point3D &bbmin, Point3D &bbmax)
blockLoc i
Definition: read.cpp:79
j indices j
Definition: Indexing.h:6
NT q
KNN_Grid< Tri > * gSpace
void initialize ( double *  nodes,
int *  triangles,
unsigned int  nv,
unsigned int  nt,
int  divisions = 50 
)
inline

Definition at line 197 of file Rocon/include/BndSurface.h.

References i, j, MAX_GRID_DIV, and q.

Referenced by Rocon::initialize().

198  {
199  numv=nv;
200  numt=nt;
201  //make sure grid divisions are sane
202  if (divisions > MAX_GRID_DIV)
203  {
204  cerr << "Grid divsisions on longest dimension must be less than or equal to "
205  << MAX_GRID_DIV << endl;
206  divisions = MAX_GRID_DIV;
207  }
208 
209  //Copy nodal coordinates
210  if (node_array != NULL)
211  delete [] node_array;
212 
213  node_array = new Vec3D[numv];
214  for(unsigned int i=0;i<numv;i++)
215  {
216  for(int j=0;j<3;j++)
217  {
218  (node_array[i])[j]=nodes[i*3+j];
219  }
220  }
221 
222  //Copy triangle connectivity
223  if (tri_array != NULL)
224  delete [] tri_array;
225 
226  tri_array = new Tri[numt];
227  for(unsigned int i=0;i<numt;i++)
228  {
229  for(int j=0;j<3;j++)
230  {
231  (tri_array[i])[j]=triangles[i*3+j];
232  }
233  }
234 
236  if (gSpace != NULL)
237  delete gSpace;
238 
239  gSpace = new KNN_Grid< Tri > (bbmin, bbmax, divisions);
240  for(unsigned int i=0; i<nt; ++i)
241  {
242  Point3D p(node_array[tri_array[i][0]][0], node_array[tri_array[i][0]][1], node_array[tri_array[i][0]][2]);
243  Point3D q(node_array[tri_array[i][1]][0], node_array[tri_array[i][1]][1], node_array[tri_array[i][1]][2]);
244  Point3D r(node_array[tri_array[i][2]][0], node_array[tri_array[i][2]][1], node_array[tri_array[i][2]][2]);
245  gSpace->insertRange(tri_array[i], p,q,r);
246  }
247  }
int insertRange(T &item, Point3D &p, Point3D &q, Point3D &r)
void compute_bbox(Point3D &bbmin, Point3D &bbmax)
blockLoc i
Definition: read.cpp:79
#define MAX_GRID_DIV
j indices j
Definition: Indexing.h:6
NT q
KNN_Grid< Tri > * gSpace

Here is the caller graph for this function:

bool intersection ( const Vec3D p,
const Vec3D d,
Vec3D x 
)
inline

Definition at line 144 of file Rocon/include/BndSurface.h.

References d, j, and rayIntersectsTriangle().

Referenced by Rocon::find_intersections(), and Rocon::initialize().

145  {
146  double orig[3];
147  double dir[3];
148  double v1[3];
149  double v2[3];
150  double v3[3];
151  double t;
152 
153  Point3D a,b;
154  a = p;
155  b = p+d;
156  vector<Tri> * hitTri = gSpace->get_cell_range(a,b);
157 
158  t = 0;
159 
160  for(int j=0;j<3;j++)
161  {
162  orig[j] = p[j];
163  dir[j] = d[j];
164  }
165 
166  for(vector<Tri>::iterator it = hitTri->begin(); it !=hitTri->end(); it++)
167  {
168  Tri & cur = *it;
169  for(int j=0;j<3;j++)
170  {
171  v1[j]=(node_array[cur[0]])[j];
172  v2[j]=(node_array[cur[1]])[j];
173  v3[j]=(node_array[cur[2]])[j];
174  }
175  if (rayIntersectsTriangle(orig, dir,v1,v2,v3,x))
176  {
177  //Debugging info
178  std::cerr << "XXXX Ray " << p << " to " << d
179  << " Tri " << std::endl;
180  std::cerr << node_array[cur[0]] << std::endl;
181  std::cerr << node_array[cur[1]] << std::endl;
182  std::cerr << node_array[cur[2]] << std::endl << std::endl;
183  return true;
184  }
185  else
186  {
187  std::cerr << "0000 Ray "<< p << " to" << d
188  << " Tri " << std::endl;
189  std::cerr << node_array[cur[0]] << std::endl;
190  std::cerr << node_array[cur[1]] << std::endl;
191  std::cerr << node_array[cur[2]] << std::endl << std::endl;
192  }
193  }
194  return false;
195  }
const NT & d
vector< T > * get_cell_range(Point3D &p, Point3D &q)
bool rayIntersectsTriangle(double *p, double *d, double *v0, double *v1, double *v2, Vec3D &I)
j indices j
Definition: Indexing.h:6
KNN_Grid< Tri > * gSpace

Here is the call graph for this function:

Here is the caller graph for this function:

bool intersection ( const Vec3D p,
const Vec3D d,
Vec3D x 
)
inline

Definition at line 145 of file Rocprop/include/BndSurface.h.

References d, j, and rayIntersectsTriangle().

146  {
147  double orig[3];
148  double dir[3];
149  double v1[3];
150  double v2[3];
151  double v3[3];
152  double t;
153 
154  Point3D a,b;
155  a = p;
156  b = p+d;
157  vector<Tri> * hitTri = gSpace->get_cell_range(a,b);
158 
159  t = 0;
160 
161  for(int j=0;j<3;j++)
162  {
163  orig[j] = p[j];
164  dir[j] = d[j];
165  }
166 
167  for(vector<Tri>::iterator it = hitTri->begin(); it !=hitTri->end(); it++)
168  {
169  Tri & cur = *it;
170  for(int j=0;j<3;j++)
171  {
172  v1[j]=(node_array[cur[0]])[j];
173  v2[j]=(node_array[cur[1]])[j];
174  v3[j]=(node_array[cur[2]])[j];
175  }
176  if (rayIntersectsTriangle(orig, dir,v1,v2,v3,x))
177  {
178  //Debugging info
179  //cerr << "XXXX Ray " << p << " to " << d << " Tri " << endl;
180  //cerr << node_array[cur[0]] << endl;
181  //cerr << node_array[cur[1]] << endl;
182  //cerr << node_array[cur[2]] << endl << endl;
183  return true;
184  }
185  //else
186  //{
187  //cerr<<"0000 Ray "<< p << " to" << d << " Tri " << endl;
188  //}
189  }
190  return false;
191  }
const NT & d
vector< T > * get_cell_range(Point3D &p, Point3D &q)
bool rayIntersectsTriangle(double *p, double *d, double *v0, double *v1, double *v2, Vec3D &I)
j indices j
Definition: Indexing.h:6
KNN_Grid< Tri > * gSpace

Here is the call graph for this function:

bool intersection ( double *  p,
double *  d,
double *  x 
)
inline

Definition at line 244 of file Rocprop/include/BndSurface.h.

References i, j, and rayIntersectsTriangle().

245  {
246  double orig[3];
247  double dir[3];
248  double v1[3];
249  double v2[3];
250  double v3[3];
251  double t;
252  Vec3D xint;
253  Point3D a,b;
254  for(int j=0;j<3;j++)
255  {
256  a[j] = p[j];
257  b[j] = p[j]+d[j];
258  }
259  vector<Tri> * hitTri = gSpace->get_cell_range(a,b);
260 
261  t = 0;
262 
263  for(int j=0;j<3;j++)
264  {
265  orig[j] = p[j];
266  dir[j] = d[j];
267  }
268 
269  for(vector<Tri>::iterator it = hitTri->begin(); it !=hitTri->end(); it++)
270  {
271  Tri & cur = *it;
272  for(int j=0;j<3;j++)
273  {
274  v1[j]=(node_array[cur[0]])[j];
275  v2[j]=(node_array[cur[1]])[j];
276  v3[j]=(node_array[cur[2]])[j];
277  }
278  if (rayIntersectsTriangle(orig, dir,v1,v2,v3,xint))
279  {
280  for(int i=0;i<3;i++)
281  x[i]=xint[i];
282  return true;
283  }
284  }
285  return false;
286  }
const NT & d
vector< T > * get_cell_range(Point3D &p, Point3D &q)
blockLoc i
Definition: read.cpp:79
void int int REAL * x
Definition: read.cpp:74
bool rayIntersectsTriangle(double *p, double *d, double *v0, double *v1, double *v2, Vec3D &I)
j indices j
Definition: Indexing.h:6
KNN_Grid< Tri > * gSpace

Here is the call graph for this function:

bool intersection ( double *  p,
double *  d,
double *  x 
)
inline

Definition at line 249 of file Rocon/include/BndSurface.h.

References i, j, and rayIntersectsTriangle().

250  {
251  double orig[3];
252  double dir[3];
253  double v1[3];
254  double v2[3];
255  double v3[3];
256  double t;
257  Vec3D xint;
258  Point3D a,b;
259  for(int j=0;j<3;j++)
260  {
261  a[j] = p[j];
262  b[j] = p[j]+d[j];
263  }
264  vector<Tri> * hitTri = gSpace->get_cell_range(a,b);
265  if(hitTri->size() == 0){
266  // std::cout << "Rocon> WARNING: No constraint boundary found for p("
267  // << a[0] << "," << a[1] << "," << a[2] << "), d(" << d[0]
268  // << "," << d[1] << "," << d[2] << std::endl;
269  }
270  // else
271  // std::cout << "Rocon> Checking " << hitTri->size() << " triangles for intersection for < "
272  // << a[0] << "," << a[1] << "," << a[2] << " >" << std::endl;
273  t = 0;
274 
275  for(int j=0;j<3;j++)
276  {
277  orig[j] = p[j];
278  dir[j] = d[j];
279  }
280 
281  for(vector<Tri>::iterator it = hitTri->begin(); it !=hitTri->end(); it++)
282  {
283  Tri & cur = *it;
284  for(int j=0;j<3;j++)
285  {
286  v1[j]=(node_array[cur[0]])[j];
287  v2[j]=(node_array[cur[1]])[j];
288  v3[j]=(node_array[cur[2]])[j];
289  }
290  if (rayIntersectsTriangle(orig, dir,v1,v2,v3,xint))
291  {
292  for(int i=0;i<3;i++)
293  x[i]=xint[i];
294  hitTri->resize(0);
295  delete hitTri;
296  return true;
297  }
298  // else
299  // {
300  // std::cout << "Rocon> " " Tri< " << node_array[cur[0]]
301  // << ","<< node_array[cur[1]] << ","
302  // << node_array[cur[2]] << " >" << std::endl;
303  // }
304  }
305  if(hitTri){
306  hitTri->resize(0);
307  delete hitTri;
308  }
309  return false;
310  }
const NT & d
vector< T > * get_cell_range(Point3D &p, Point3D &q)
blockLoc i
Definition: read.cpp:79
void int int REAL * x
Definition: read.cpp:74
bool rayIntersectsTriangle(double *p, double *d, double *v0, double *v1, double *v2, Vec3D &I)
j indices j
Definition: Indexing.h:6
KNN_Grid< Tri > * gSpace

Here is the call graph for this function:

Member Data Documentation

Point3D bbmax
private

Definition at line 90 of file Rocon/include/BndSurface.h.

Point3D bbmin
private

Definition at line 90 of file Rocon/include/BndSurface.h.

KNN_Grid< Tri > * gSpace
private

Definition at line 89 of file Rocon/include/BndSurface.h.

Vec3D * node_array
private

Definition at line 91 of file Rocon/include/BndSurface.h.

unsigned int numt
private

Definition at line 94 of file Rocon/include/BndSurface.h.

unsigned int numv
private

Definition at line 93 of file Rocon/include/BndSurface.h.

Tri * tri_array
private

Definition at line 92 of file Rocon/include/BndSurface.h.


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