29 #ifndef CORE_DATATYPES_QUADSURFMESH_H
30 #define CORE_DATATYPES_QUADSURFMESH_H 1
58 #include <boost/thread.hpp>
79 #if (SCIRUN_QUADSURF_SUPPORT > 0)
85 #if (SCIRUN_QUADRATIC_SUPPORT > 0)
88 #if (SCIRUN_CUBIC_SUPPORT > 0)
100 template <
class Basis>
101 class QuadSurfMesh :
public Mesh
169 if (basis_type::polynomial_order() > 1)
171 mesh_.get_edges_from_face(edges_, index_);
179 return mesh_.faces_[index_ * 4];
184 return mesh_.faces_[index_ * 4 + 1];
189 return mesh_.faces_[index_ * 4 + 2];
194 return mesh_.faces_[index_ * 4 + 3];
256 mesh_(mesh), sync_(sync)
267 mesh_->synchronize_lock_.lock();
269 sync_ &= ~(mesh_->synchronized_);
271 sync_ &= ~(mesh_->synchronizing_);
274 mesh_->synchronizing_ |= sync_;
276 mesh_->synchronize_lock_.unlock();
291 while(!(mesh_->synchronized_ & Mesh::BOUNDING_BOX_E))
293 mesh_->synchronize_cond_.wait(lock);
298 mesh_->compute_node_grid();
302 mesh_->compute_elem_grid();
306 mesh_->synchronize_lock_.lock();
308 mesh_->synchronized_ |= sync_;
310 mesh_->synchronizing_ &= ~(sync_);
311 mesh_->synchronize_lock_.unlock();
313 mesh_->synchronize_cond_.conditionBroadcast();
339 return boost::make_shared<Core::Datatypes::VirtualMeshFacade<VMesh>>(
vmesh_);
414 {
ASSERTFAIL(
"This mesh type does not have cells use \"elem\"."); }
419 { array.
resize(1); array[0]= idx; }
428 {
ASSERTFAIL(
"This mesh type does not have cells use \"elem\"."); }
435 { array.resize(1); array[0]= idx; }
441 {
ASSERTFAIL(
"This mesh type does not have cells use \"elem\"."); }
451 { array.resize(1); array[0]= idx; }
454 {
ASSERTFAIL(
"This mesh type does not have cells use \"elem\"."); }
458 {
ASSERTFAIL(
"This mesh type does not have cells use \"elem\"."); }
461 {
ASSERTFAIL(
"This mesh type does not have cells use \"elem\"."); }
464 {
ASSERTFAIL(
"This mesh type does not have cells use \"elem\"."); }
467 {
ASSERTFAIL(
"This mesh type does not have cells use \"elem\"."); }
477 { array.resize(1); array[0]= idx; }
480 {
ASSERTFAIL(
"This mesh type does not have cells use \"elem\"."); }
487 { array.resize(1); array[0]= idx; }
493 {
ASSERTFAIL(
"This mesh type does not have cells use \"elem\"."); }
497 template<
class VECTOR,
class INDEX>
500 unsigned int which_edge,
501 unsigned int div_per_unit)
const
503 basis_.approx_edge(which_edge, div_per_unit, coords);
508 template<
class VECTOR,
class INDEX>
511 unsigned int which_face,
512 unsigned int div_per_unit)
const
514 basis_.approx_face(which_face, div_per_unit, coords);
525 {
ASSERTFAIL(
"This mesh type does not have cells use \"elem\"."); }
534 return (
point(arr[0]) -
point(arr[1])).length();
544 return ((
Cross(p0-p1,p2-p1)).length()+(
Cross(p2-p3,p0-p3)).length()+
545 (
Cross(p3-p0,p1-p0)).length()+(
Cross(p1-p2,p3-p2)).length())*0.25;
548 {
ASSERTFAIL(
"This mesh type does not have cells use \"elem\"."); }
556 {
ASSERTFAIL(
"This mesh type does not have cells use \"elem\"."); }
590 {
ASSERTFAIL(
"This mesh type does not have cells use \"elem\"."); }
593 std::vector<double>& coords,
602 {
ASSERTFAIL(
"QuadSurfMesh: get_weights(edges) is not supported."); }
605 {
ASSERTFAIL(
"This mesh type does not have cells use \"elem\"."); }
619 "Must call synchronize NORMALS_E on QuadSurfMesh first");
624 template<
class VECTOR,
class INDEX1,
class INDEX2>
666 std::vector<Core::Geometry::Point> Jv;
667 basis_.derivate(coords, ed, Jv);
678 template <
class ARRAY>
681 ASSERTMSG(a.size() == 4,
"Tried to add non-quad element.");
684 faces_.push_back(static_cast<typename Node::index_type>(a[0]));
685 faces_.push_back(static_cast<typename Node::index_type>(a[1]));
686 faces_.push_back(static_cast<typename Node::index_type>(a[2]));
687 faces_.push_back(static_cast<typename Node::index_type>(a[3]));
700 template<
class VECTOR,
class INDEX>
704 return basis_.get_coords(coords, p, ed);
709 template<
class VECTOR,
class INDEX>
713 pt =
basis_.interpolate(coords, ed);
719 template<
class VECTOR1,
class INDEX,
class VECTOR2>
720 void derivate(
const VECTOR1 &coords, INDEX idx, VECTOR2 &J)
const
723 basis_.derivate(coords, ed, J);
728 template<
class VECTOR,
class INDEX>
739 template<
class VECTOR,
class INDEX>
740 void jacobian(
const VECTOR& coords, INDEX idx,
double* J)
const
744 basis_.derivate(coords,ed,Jv);
761 template<
class VECTOR,
class INDEX>
766 basis_.derivate(coords,ed,Jv);
784 template<
class INDEX>
799 size_t num_vertices =
basis_.number_of_vertices();
800 for (
size_t j=0;j < num_vertices;j++)
807 if(temp < min_jacobian) min_jacobian = temp;
810 return (min_jacobian);
814 template<
class INDEX>
828 size_t num_vertices =
basis_.number_of_vertices();
829 for (
size_t j=0;j < num_vertices;j++)
836 if(temp < min_jacobian) min_jacobian = temp;
839 return (min_jacobian);
842 template<
class INDEX>
848 template <
class INDEX>
855 template <
class INDEX>
859 if (maxdist < 0.0) maxdist = DBL_MAX;
else maxdist = maxdist*maxdist;
863 if (sz == 0)
return (
false);
865 if (node >= 0 && node < sz)
868 double dist = (point-p).length2();
879 "QuadSurfMesh::find_closest_node requires synchronize(NODE_LOCATE_E).")
891 if (bi > ni) bi = ni;
if (bi < 0) bi = 0;
892 if (bj > nj) bj = nj;
if (bj < 0) bj = 0;
893 if (bk > nk) bk = nk;
if (bk < 0) bk = 0;
895 ei = bi; ej = bj; ek = bk;
897 double dmin = maxdist;
899 bool found_one =
false;
910 if (i < 0 || i > ni)
continue;
913 if (j < 0 || j > nj)
continue;
916 if (k < 0 || k > nk)
continue;
917 if (i == bi || i == ei || j == bj || j == ej || k == bk || k == ek)
919 if (
node_grid_->min_distance_squared(p, i, j, k) < dmin)
928 const double dist = (p-
point).length2();
957 if (!found_one)
return (
false);
963 template <
class ARRAY>
969 "QuadSurfMesh::find_closest_node requires synchronize(NODE_LOCATE_E).")
986 if (bi > ni) bi = ni;
if (bi < 0) bi = 0;
987 if (bj > nj) bj = nj;
if (bj < 0) bj = 0;
988 if (bk > nk) bk = nk;
if (bk < 0) bk = 0;
990 if (ei > ni) ei = ni;
if (ei < 0) ei = 0;
991 if (ej > nj) ej = nj;
if (ej < 0) ej = 0;
992 if (ek > nk) ek = nk;
if (ek < 0) ek = 0;
994 double maxdist2 = maxdist*maxdist;
1002 if (
node_grid_->min_distance_squared(p, i, j, k) < maxdist2)
1010 const double dist = (p-
point).length2();
1012 if (dist < maxdist2)
1014 nodes.push_back(*it);
1023 return(nodes.size() > 0);
1026 template <
class ARRAY1,
class ARRAY2>
1033 "QuadSurfMesh::find_closest_node requires synchronize(NODE_LOCATE_E).")
1050 if (bi > ni) bi = ni;
if (bi < 0) bi = 0;
1051 if (bj > nj) bj = nj;
if (bj < 0) bj = 0;
1052 if (bk > nk) bk = nk;
if (bk < 0) bk = 0;
1054 if (ei > ni) ei = ni;
if (ei < 0) ei = 0;
1055 if (ej > nj) ej = nj;
if (ej < 0) ej = 0;
1056 if (ek > nk) ek = nk;
if (ek < 0) ek = 0;
1058 double maxdist2 = maxdist*maxdist;
1066 if (
node_grid_->min_distance_squared(p, i, j, k) < maxdist2)
1074 const double dist = (p-
point).length2();
1076 if (dist < maxdist2)
1078 nodes.push_back(*it);
1079 distances.push_back(dist);
1088 return(nodes.size() > 0);
1097 template <
class INDEX,
class ARRAY>
1107 template <
class INDEX,
class ARRAY>
1113 double maxdist)
const
1115 if (maxdist < 0.0) maxdist = DBL_MAX;
else maxdist = maxdist*maxdist;
1120 if (sz == 0)
return (
false);
1123 if (elem >= 0 && elem < sz)
1132 double dist = (p-result).length2();
1142 basis_.get_coords(coords,result,ed);
1144 result =
basis_.interpolate(coords,ed);
1145 double dmin = (result-p).length2();
1152 "QuadSurfMesh::find_closest_elem requires synchronize(ELEM_LOCATE_E).")
1163 if (bi > ni) bi = ni;
if (bi < 0) bi = 0;
1164 if (bj > nj) bj = nj;
if (bj < 0) bj = 0;
1165 if (bk > nk) bk = nk;
if (bk < 0) bk = 0;
1167 ei = bi; ej = bj; ek = bk;
1169 double dmin = maxdist;
1171 bool found_one =
false;
1182 if (i < 0 || i > ni)
continue;
1185 if (j < 0 || j > nj)
continue;
1188 if (k < 0 || k > nk)
continue;
1189 if (i == bi || i == ei || j == bj || j == ej || k == bk || k == ek)
1191 if (
elem_grid_->min_distance_squared(p, i, j, k) < dmin)
1206 const double dist = (p - r).length2();
1222 basis_.get_coords(coords,result,ed);
1224 result =
basis_.interpolate(coords,ed);
1225 dmin = (result-p).length2();
1244 if (!found_one)
return (
false);
1253 basis_.get_coords(coords,result,ed);
1255 result =
basis_.interpolate(coords,ed);
1256 dmin = (result-p).length2();
1268 template <
class INDEX,
class ARRAY>
1275 double mindistfromrepel,
1277 double mindotfromrepel,
1278 double maxdist)
const
1280 if (maxdist < 0.0) maxdist = DBL_MAX;
else maxdist = maxdist*maxdist;
1284 if (sz == 0)
return (
false);
1287 "QuadSurfMesh::find_closest_elem requires synchronize(ELEM_LOCATE_E).")
1299 if (bi > ni) bi = ni;
if (bi < 0) bi = 0;
1300 if (bj > nj) bj = nj;
if (bj < 0) bj = 0;
1301 if (bk > nk) bk = nk;
if (bk < 0) bk = 0;
1303 ei = bi; ej = bj; ek = bk;
1305 double dmin = maxdist;
1307 bool found_one =
false;
1308 double mindistfromrepelsquared = mindistfromrepel * mindistfromrepel;
1316 if (i < 0 || i > ni)
continue;
1319 if (j < 0 || j > nj)
continue;
1322 if (k < 0 || k > nk)
continue;
1323 if (i == bi || i == ei || j == bj || j == ej || k == bk || k == ek)
1325 if (
elem_grid_->min_distance_squared(p, i, j, k) < dmin)
1342 double dot=
Dot(n,repelnormal);
1343 if (dot > mindotfromrepel &&
1344 (((p1-repelpos).length2() < mindistfromrepelsquared) ||
1345 ((p2-repelpos).length2() < mindistfromrepelsquared) ||
1346 ((p3-repelpos).length2() < mindistfromrepelsquared) ||
1347 ((p4-repelpos).length2() < mindistfromrepelsquared)))
1351 const double dtmp = (p - r).length2();
1368 basis_.get_coords(coords,result,ed);
1370 result =
basis_.interpolate(coords,ed);
1371 dmin = (result-p).length2();
1391 if (!found_one)
return (
false);
1400 basis_.get_coords(coords,result,ed);
1402 result =
basis_.interpolate(coords,ed);
1403 dmin = (result-p).length2();
1410 template <
class INDEX>
1420 template <
class ARRAY>
1429 if (sz == 0)
return (
false);
1437 "QuadSurfMesh::find_closest_elems requires synchronize(ELEM_LOCATE_E).")
1449 if (bi > ni) bi = ni;
if (bi < 0) bi = 0;
1450 if (bj > nj) bj = nj;
if (bj < 0) bj = 0;
1451 if (bk > nk) bk = nk;
if (bk < 0) bk = 0;
1453 ei = bi; ej = bj; ek = bk;
1455 double dmin = DBL_MAX;
1466 if (i < 0 || i > ni)
continue;
1469 if (j < 0 || j > nj)
continue;
1472 if (k < 0 || k > nk)
continue;
1473 if (i == bi || i == ei || j == bj || j == ej || k == bk || k == ek)
1475 if (
elem_grid_->min_distance_squared(p, i, j, k) < dmin)
1490 const double dtmp = (p - rtmp).length2();
1496 elems.push_back(*it);
1501 elems.push_back(
typename ARRAY::value_type(*it));
1514 while ((!found)||(dmin == DBL_MAX)) ;
1523 if (elems.size() == 1)
1527 std::vector<double> coords;
1529 basis_.get_coords(coords,result,ed);
1530 result =
basis_.interpolate(coords,ed);
1531 dmin = (result-p).length2();
1552 static const std::string
type_name(
int n = -1);
1574 template <
class INDEX>
1592 if(
basis_.get_coords(coords, p, ed))
return (
true);
1600 double err = 1.0e-3);
1623 template<
class ARRAY,
class INDEX>
1627 "QuadSurfMesh: Must call synchronize EDGES_E on QuadSurfMesh first");
1629 static int table[4][2] = { {0, 1}, {1, 2}, {2, 3}, {3, 0} };
1635 array[0] =
static_cast<typename ARRAY::value_type
>(
faces_[node + table[off][0]]);
1636 array[1] =
static_cast<typename ARRAY::value_type
>(
faces_[node + table[off][1]]);
1640 template<
class ARRAY,
class INDEX>
1644 array[0] =
static_cast<typename ARRAY::value_type
>(
faces_[idx * 4 + 0]);
1645 array[1] =
static_cast<typename ARRAY::value_type
>(
faces_[idx * 4 + 1]);
1646 array[2] =
static_cast<typename ARRAY::value_type
>(
faces_[idx * 4 + 2]);
1647 array[3] =
static_cast<typename ARRAY::value_type
>(
faces_[idx * 4 + 3]);
1651 template<
class ARRAY,
class INDEX>
1657 template<
class ARRAY,
class INDEX>
1661 "QuadSurfMesh: Must call synchronize EDGES_E on QuadSurfMesh first");
1668 if (he >=0) array[i++] = he;
1670 if (he >=0) array[i++] = he;
1672 if (he >=0) array[i++] = he;
1674 if (he >=0) array[i++] = he;
1678 template<
class ARRAY,
class INDEX>
1685 template <
class ARRAY,
class INDEX>
1689 "QuadSurfMesh: Must call synchronize NODE_NEIGHBORS_E on QuadSurfMesh first");
1693 array[i] = static_cast<typename ARRAY::value_type>(
node_neighbors_[idx][i]);
1697 template <
class ARRAY,
class INDEX>
1701 "Must call synchronize EDGES_E on QuadSurfMesh first");
1703 const std::vector<index_type>& faces =
edges_[idx];
1708 array.reserve(faces.size());
1713 array.push_back((faces[i]>>2));
1718 template<
class ARRAY,
class INDEX>
1722 "Must call synchronize NODE_NEIGHBORS_E on QuadSurfMesh first");
1725 "Must call synchronize EDGES_E on QuadSurfMesh first");
1729 const std::vector<typename Face::index_type>& faces =
node_neighbors_[idx];
1732 typename ARRAY::value_type edge;
1733 for (
index_type i=0; i<static_cast<size_type>(faces.size()); i++)
1739 for (; k<array.size(); k++)
1740 if (array[k] == edge)
break;
1741 if (k == array.size()) array.push_back(edge);
1746 template <
class ARRAY,
class INDEX>
1750 faces_[idx * 4 +
n] = static_cast<index_type>(array[
n]);
1755 template <
class INDEX1,
class INDEX2>
1759 "Must call synchronize EDGES_E on QuadSurfMesh first");
1761 const std::vector<index_type>& faces =
edges_[delem];
1776 template <
class ARRAY,
class INDEX1,
class INDEX2>
1780 "Must call synchronize EDGES_E on QuadSurfMesh first");
1783 const std::vector<index_type>& faces =
edges_[delem];
1794 array.push_back(face);
1797 return (array.size() > 0);
1800 template <
class ARRAY,
class INDEX>
1804 "Must call synchronize EDGES_E on QuadSurfMesh first");
1810 array.reserve(edges.size());
1812 for (
index_type i=0; i<static_cast<index_type>(edges.size()); i++)
1814 typename ARRAY::value_type nbor;
1817 array.push_back(nbor);
1823 template <
class ARRAY,
class INDEX>
1827 "Must call synchronize NODE_NEIGHBORS_E on QuadSurfMesh first");
1833 const std::vector<typename Face::index_type>& faces =
node_neighbors_[idx];
1835 array.reserve(2*faces.size());
1837 for (
index_type i=0;i<static_cast<index_type>(faces.size());i++)
1842 if (
faces_[base+j] == idx)
continue;
1844 for (;k<array.size();k++)
1845 if (static_cast<typename ARRAY::value_type>(
faces_[base+j]) == array[k])
break;
1846 if (k==array.size())
1847 array.push_back(static_cast<typename ARRAY::value_type>(
faces_[base+j]));
1854 template <
class INDEX>
1860 if (sz == 0)
return (
false);
1863 if (node >= 0 && node < sz)
1869 "QuadSurfMesh::locate_node requires synchronize(NODE_LOCATE_E).")
1881 if (bi > ni) bi =ni;
if (bi < 0) bi = 0;
1882 if (bj > nj) bj =nj;
if (bj < 0) bj = 0;
1883 if (bk > nk) bk =nk;
if (bk < 0) bk = 0;
1889 double dmin = DBL_MAX;
1900 if (i < 0 || i > ni)
continue;
1903 if (j < 0 || j > nj)
continue;
1906 if (k < 0 || k > nk)
continue;
1907 if (i == bi || i == ei || j == bj || j == ej || k == bk || k == ek)
1909 if (
node_grid_->min_distance_squared(p, i, j, k) < dmin)
1918 const double dist = (p-
point).length2();
1938 while ((!found)||(dmin == DBL_MAX)) ;
1944 template <
class INDEX>
1948 "QuadSurfMesh::locate_edge requires synchronize(EDGES_E).")
1957 double mindist = 0.0;
1963 if (!found || dist < mindist)
1965 loc =
static_cast<INDEX
>(*bi);
1975 template <
class INDEX>
1983 if (sz == 0)
return (
false);
1986 if ((elem > 0)&&(elem < sz))
1988 if (
inside(elem,p))
return (
true);
1992 "QuadSurfMesh::locate_node requires synchronize(ELEM_LOCATE_E).")
2001 elem =
static_cast<INDEX
>(*it);
2010 template <
class ARRAY>
2015 "QuadSurfMesh::locate_elems requires synchronize(ELEM_LOCATE_E).")
2031 for (;p<array.size();p++)
if (array[p] ==
typename ARRAY::value_type(*it))
break;
2032 if (p == array.size()) array.push_back(
typename ARRAY::value_type(*it));
2037 return (array.size() > 0);
2041 template <
class INDEX,
class ARRAY>
2049 if (sz == 0)
return (
false);
2052 if ((elem > 0)&&(elem < sz))
2057 basis_.get_coords(coords, p, ed);
2063 "QuadSurfMesh::locate_node requires synchronize(ELEM_LOCATE_E).")
2072 elem =
static_cast<INDEX
>(*it);
2074 basis_.get_coords(coords, p, ed);
2084 template <
class INDEX>
2090 template <
class INDEX>
2101 template <
class INDEX>
2107 ASSERT(nodes.size() == 4);
2108 typename Node::array_type::iterator nai = nodes.begin();
2111 while (nai != nodes.end())
2139 template <
class NODE>
2144 if ((n1 == n3)||(n2==n4))
return (
false);
2151 if (n3==n4)
return (
false);
2154 t = n1; n1 = n2; n2 = n3; n3 = n4; n4 = t;
2159 if (n1==n4)
return (
false);
2162 t = n1; n1 = n3; n3 = t; t = n2; n2 = n4; n4 = t;
2169 t = n4; n4 = n3; n3 = n2; n2 = n1; n1 = t;
2179 if ((n1 < n2)&&(n1 < n3)&&(n1 < n4))
2184 else if ((n2 < n3)&&(n2 < n4))
2188 t = n1; n1 = n2; n2 = n3; n3 = n4; n4 = t;
2195 t = n1; n1 = n3; n3 = t; t = n2; n2 = n4; n4 = t;
2202 t = n4; n4 = n3; n3 = n2; n2 = n1; n1 = t;
2220 std::vector<std::vector<index_type> >
edges_;
2250 #ifdef HAVE_HASH_MAP
2253 size_t operator()(
const std::pair<index_type, index_type> &a)
const
2255 #if defined(__ECC) || defined(_MSC_VER)
2256 hash_compare<int> hasher;
2260 return hasher(static_cast<int>(hasher(a.first) + a.second));
2262 #if defined(__ECC) || defined(_MSC_VER)
2264 static const size_t bucket_size = 4;
2265 static const size_t min_buckets = 8;
2267 bool operator()(
const std::pair<index_type, index_type> &a,
const std::pair<index_type, index_type> &b)
const
2269 return a.first < b.first || a.first == b.first && a.second < b.second;
2276 bool operator()(
const std::pair<index_type, index_type> &a,
const std::pair<index_type, index_type> &b)
const
2278 return a.first == b.first && a.second == b.second;
2282 #else // HAVE_HASH_MAP
2286 bool operator()(
const std::pair<index_type, index_type> &a,
const std::pair<index_type, index_type> &b)
const
2288 return a.first < b.first || a.first == b.first && a.second < b.second;
2291 #endif // HAVE_HASH_MAP
2296 template <
class Basis>
2299 QuadSurfMesh<Basis>::maker);
2301 template <
class Basis>
2305 ASSERT((n >= -1) && n <= 1);
2313 static const std::string nm(
"QuadSurfMesh");
2323 template <
class Basis>
2329 synchronize_lock_(
"QuadSurfMesh lock"),
2330 synchronize_cond_(
"QuadSurfMesh condition variable"),
2331 synchronized_(
Mesh::NODES_E |
Mesh::FACES_E |
Mesh::CELLS_E),
2343 template <
class Basis>
2350 synchronize_lock_(
"QuadSurfMesh lock"),
2351 synchronize_cond_(
"QuadSurfMesh condition variable"),
2352 synchronized_(
Mesh::NODES_E |
Mesh::FACES_E |
Mesh::CELLS_E),
2374 template <
class Basis>
2381 template <
class Basis>
2393 result.
extend(points_[*ni]);
2401 template <
class Basis>
2411 template <
class Basis>
2415 synchronize_lock_.lock();
2416 std::vector<Core::Geometry::Point>::iterator itr = points_.begin();
2417 std::vector<Core::Geometry::Point>::iterator eitr = points_.end();
2436 bbox_.extend(point(*ni));
2441 epsilon_ = bbox_.diagonal().length()*1e-8;
2442 epsilon2_ = epsilon_*epsilon_;
2446 if (node_grid_) { node_grid_->transform(t); }
2447 if (elem_grid_) { elem_grid_->transform(t); }
2448 synchronize_lock_.unlock();
2452 template <
class Basis>
2457 "Must call synchronize NODES_E on QuadSurfMesh first");
2462 template <
class Basis>
2467 "Must call synchronize NODES_E on QuadSurfMesh first");
2468 itr =
static_cast<size_type>(points_.size());
2472 template <
class Basis>
2477 "Must call synchronize EDGES_E on QuadSurfMesh first");
2482 template <
class Basis>
2487 "Must call synchronize EDGES_E on QuadSurfMesh first");
2488 itr =
static_cast<size_type>(edges_.size());
2492 template <
class Basis>
2497 "Must call synchronize FACES_E on QuadSurfMesh first");
2502 template <
class Basis>
2507 "Must call synchronize FACES_E on QuadSurfMesh first");
2508 itr =
static_cast<size_type>(faces_.size() / 4);
2512 template <
class Basis>
2517 "Must call synchronize CELLS_E on QuadSurfMesh first");
2522 template <
class Basis>
2527 "Must call synchronize CELLS_E on QuadSurfMesh first");
2532 template <
class Basis>
2549 template <
class Basis>
2558 std::vector<double> coords(2);
2559 if (get_coords(coords, p, idx))
2561 basis_.get_weights(coords, w);
2562 return basis_.dofs();
2569 template <
class Basis>
2583 const double aarea =
Cross(a1 - a0, a2 - a0).
length();
2584 const double barea =
Cross(b1 - b0, b2 - b0).
length();
2586 if (rng() * (aarea + barea) < aarea)
2591 if (u + v > 1.0) { u = 1.0 - u; v = 1.0 -
v; }
2594 p = a0+((a1-a0)*u)+((a2-a0)*v);
2601 if (u + v > 1.0) { u = 1.0 - u; v = 1.0 -
v; }
2604 p = b0+((b1-b0)*u)+((b2-b0)*v);
2608 template <
class Basis>
2637 sync &= (~synchronized_);
2648 synchronize_lock_.unlock();
2650 synchronize_lock_.lock();
2656 boost::thread syncthread(syncclass);
2662 synchronize_lock_.unlock();
2664 synchronize_lock_.lock();
2670 boost::thread syncthread(syncclass);
2673 if (sync == Mesh::NODE_NEIGHBORS_E)
2676 synchronize_lock_.unlock();
2678 synchronize_lock_.lock();
2680 else if (sync & Mesh::NODE_NEIGHBORS_E)
2684 boost::thread syncthread(syncclass);
2690 synchronize_lock_.unlock();
2692 synchronize_lock_.lock();
2698 boost::thread syncthread(syncclass);
2704 synchronize_lock_.unlock();
2706 synchronize_lock_.lock();
2712 boost::thread syncthread(syncclass);
2718 synchronize_lock_.unlock();
2720 synchronize_lock_.lock();
2726 boost::thread syncthread(syncclass);
2730 while ((synchronized_ & sync) != sync)
2732 synchronize_cond_.wait(lock);
2740 template <
class Basis>
2748 template <
class Basis>
2752 synchronize_lock_.lock();
2757 ASSERTFAIL(
"clear_synchronization is in parallel to a synchronization call from another thread.");
2762 halfedge_to_edge_.clear();
2763 node_neighbors_.clear();
2768 synchronize_lock_.unlock();
2772 template <
class Basis>
2776 normals_.resize(points_.size());
2779 std::vector<std::vector<typename Face::index_type> > node_in_faces(points_.size());
2781 std::vector<Core::Geometry::Vector> face_normals(faces_.size());
2787 while (iter != iter_end)
2789 get_nodes(nodes, *iter);
2792 get_point(p0, nodes[0]);
2793 get_point(p1, nodes[1]);
2794 get_point(p2, nodes[2]);
2795 get_point(p3, nodes[3]);
2798 node_in_faces[nodes[0]].push_back(*iter);
2799 node_in_faces[nodes[1]].push_back(*iter);
2800 node_in_faces[nodes[2]].push_back(*iter);
2801 node_in_faces[nodes[3]].push_back(*iter);
2806 face_normals[*iter] =
n;
2811 typename std::vector<std::vector<typename Face::index_type> >::iterator nif_iter =
2812 node_in_faces.begin();
2814 while (nif_iter != node_in_faces.end())
2816 const std::vector<typename Face::index_type> &
v = *nif_iter;
2817 typename std::vector<typename Face::index_type>::const_iterator fiter =
2820 while(fiter != v.end())
2822 ave += face_normals[*fiter];
2826 normals_[i] = ave; ++i;
2830 synchronize_lock_.lock();
2832 synchronize_lock_.unlock();
2836 template <
class Basis>
2841 if (locate(i, p) && (points_[i] - p).length2() < err)
2847 points_.push_back(p);
2849 (
static_cast<size_type>(points_.size()) - 1);
2854 template <
class Basis>
2861 ASSERTMSG(order_face_nodes(a,b,c,d),
"add_quad: element that is being added is invalid");
2862 faces_.push_back(a);
2863 faces_.push_back(b);
2864 faces_.push_back(c);
2865 faces_.push_back(d);
2866 synchronize_lock_.lock();
2867 synchronized_ &= ~
Mesh::ELEM_NEIGHBORS_E;
2868 synchronized_ &= ~
Mesh::NODE_NEIGHBORS_E;
2869 synchronized_ &= ~
Mesh::NORMALS_E;
2870 synchronize_lock_.unlock();
2875 #ifdef HAVE_HASH_MAP
2879 size_t operator()(
const std::pair<index_type, index_type> &a)
const
2881 #if defined(__ECC) || defined(_MSC_VER)
2882 hash_compare<int> hasher;
2886 return hasher(static_cast<index_type>(hasher(a.first)) + a.second);
2888 #if defined(__ECC) || defined(_MSC_VER)
2890 static const size_t bucket_size = 4;
2891 static const size_t min_buckets = 8;
2893 bool operator()(
const std::pair<index_type, index_type> &a,
const std::pair<index_type, index_type> &b)
const
2895 return a.first < b.first || a.first == b.first && a.second < b.second;
2902 bool operator()(
const std::pair<index_type, index_type> &a,
const std::pair<index_type, index_type> &b)
const
2904 return a.first == b.first && a.second == b.second;
2912 bool operator()(
const std::pair<index_type, index_type> &a,
const std::pair<index_type, index_type> &b)
const
2914 return a.first < b.first || a.first == b.first && a.second < b.second;
2920 #ifdef HAVE_HASH_MAP
2922 #if defined(__ECC) || defined(_MSC_VER)
2934 #ifdef HAVE_HASH_MAP
2936 #if defined(__ECC) || defined(_MSC_VER)
2937 typedef hash_map<std::pair<index_type, index_type>, std::vector<index_type>, edgehash>
EdgeMapType2;
2939 typedef hash_map<std::pair<index_type, index_type>, std::vector<index_type>, edgehash,
edgecompare>
EdgeMapType2;
2948 template <
class Basis>
2963 if (n0 > n1) edge_map[std::pair<index_type, index_type>(n1,n0)].push_back(i<<2);
2964 else if (n1 > n0) edge_map[std::pair<index_type, index_type>(n0,n1)].push_back(i<<2);
2966 if (n1 > n2) edge_map[std::pair<index_type, index_type>(n2,n1)].push_back((i<<2)+1);
2967 else if (n2 > n1) edge_map[std::pair<index_type, index_type>(n1,n2)].push_back((i<<2)+1);
2969 if (n2 > n3) edge_map[std::pair<index_type, index_type>(n3,n2)].push_back((i<<2)+2);
2970 else if (n3 > n2) edge_map[std::pair<index_type, index_type>(n2,n3)].push_back((i<<2)+2);
2972 if (n3 > n0) edge_map[std::pair<index_type, index_type>(n0,n3)].push_back((i<<2)+3);
2973 else if (n0 > n3) edge_map[std::pair<index_type, index_type>(n3,n0)].push_back((i<<2)+3);
2976 typename EdgeMapType2::iterator itr;
2978 edges_.resize(edge_map.size());
2979 halfedge_to_edge_.resize(faces_.size(),-1);
2982 for (itr = edge_map.begin(); itr != edge_map.end(); ++itr)
2984 const std::vector<index_type >& hedges = (*itr).second;
2985 for (
size_t j=0; j<hedges.size(); j++)
2988 edges_[k].push_back(h);
2989 halfedge_to_edge_[h] = k;
2994 synchronize_lock_.lock();
2996 synchronize_lock_.unlock();
3000 template <
class Basis>
3004 node_neighbors_.clear();
3005 node_neighbors_.resize(points_.size());
3007 for (i = 0; i < num_elems; i++)
3009 node_neighbors_[faces_[i]].push_back(i/4);
3012 synchronize_lock_.lock();
3014 synchronize_lock_.unlock();
3019 template <
class Basis>
3027 box.
extend(points_[faces_[idx]]);
3028 box.
extend(points_[faces_[idx+1]]);
3029 box.
extend(points_[faces_[idx+2]]);
3030 box.
extend(points_[faces_[idx+3]]);
3032 elem_grid_->insert(ci, box);
3036 template <
class Basis>
3042 box.
extend(points_[faces_[idx]]);
3043 box.
extend(points_[faces_[idx+1]]);
3044 box.
extend(points_[faces_[idx+2]]);
3045 box.
extend(points_[faces_[idx+3]]);
3047 elem_grid_->remove(ci, box);
3051 template <
class Basis>
3057 node_grid_->insert(ni,points_[ni]);
3061 template <
class Basis>
3065 node_grid_->remove(ni,points_[ni]);
3069 template <
class Basis>
3080 ((ceil(pow(static_cast<double>(esz) , (1.0/3.0))))/2.0 + 1.0);
3083 double trace = (diag.
x()+diag.
y()+diag.
z());
3093 begin(ni); end(nie);
3096 insert_node_into_grid(*ni);
3101 synchronize_lock_.lock();
3103 synchronize_lock_.unlock();
3106 template <
class Basis>
3117 ((ceil(pow(static_cast<double>(esz) , (1.0/3.0))))/2.0 + 1.0);
3120 double trace = (diag.
x()+diag.
y()+diag.
z());
3130 begin(ci); end(cie);
3133 insert_elem_into_grid(*ci);
3138 synchronize_lock_.lock();
3140 synchronize_lock_.unlock();
3144 template <
class Basis>
3156 bbox_.extend(points_[*ni]);
3161 epsilon_ = bbox_.diagonal().length()*1e-8;
3162 epsilon2_ = epsilon_*epsilon_;
3164 synchronize_lock_.lock();
3166 synchronize_lock_.unlock();
3169 template <
class Basis>
3173 points_.push_back(p);
3178 template <
class Basis>
3183 return add_quad(add_find_point(p0), add_find_point(p1),
3184 add_find_point(p2), add_find_point(p3));
3188 #define QUADSURFMESH_VERSION 4
3189 template <
class Basis>
3197 Pio(stream, points_);
3207 for (
size_t i=0; i < faces_.size(); i += 4)
3208 if(!( order_face_nodes(faces_[i],faces_[i+1],faces_[i+2],faces_[i+3])))
3209 std::cerr <<
"Detected an invalid quadrilateral face\n";
3219 std::vector<under_type> dummy;
3240 template <
class Basis>
3249 template <
class Basis>
3254 "Must call synchronize EDGES_E on QuadSurfMesh first");
3259 template <
class Basis>
3268 template <
class Basis>
3277 template <
class Basis>
3288 std::string(__FILE__),
3296 template <
class Basis>
3297 const TypeDescription*
3304 template <
class Basis>
3314 std::string(__FILE__),
3322 template <
class Basis>
3332 std::string(__FILE__),
3340 template <
class Basis>
3350 std::string(__FILE__),
3358 template <
class Basis>
3368 std::string(__FILE__),
void get_faces(typename Face::array_type &array, typename Face::index_type idx) const
Definition: QuadSurfMesh.h:449
void get_delems(typename DElem::array_type &array, typename Face::index_type idx) const
Definition: QuadSurfMesh.h:488
virtual int topology_geometry() const
Definition: QuadSurfMesh.h:355
void get_elems(typename Elem::array_type &array, typename Node::index_type idx) const
Definition: QuadSurfMesh.h:469
Interface to statically allocated std::vector class.
Definition: VUnstructuredMesh.h:41
int get_weights(const Core::Geometry::Point &, typename Edge::array_type &, double *)
Definition: QuadSurfMesh.h:601
double epsilon_
Definition: QuadSurfMesh.h:2244
virtual int basis_order()
Definition: QuadSurfMesh.h:347
virtual VMesh * vmesh()
Access point to virtual interface.
Definition: QuadSurfMesh.h:343
bool reading() const
Definition: Persistent.h:164
std::vector< index_type > array_type
Definition: QuadSurfMesh.h:131
index_type edge1_index() const
Definition: QuadSurfMesh.h:204
double get_size(typename Edge::index_type idx) const
Definition: QuadSurfMesh.h:530
Distinct type for node FieldIterator.
Definition: FieldIterator.h:89
void get_center(Core::Geometry::Point &result, typename Node::index_type idx) const
get the center point (in object space) of an element
Definition: QuadSurfMesh.h:518
MeshFacadeHandle getFacade() const
Definition: QuadSurfMesh.h:337
void begin(typename Node::iterator &) const
begin/end iterators
Definition: QuadSurfMesh.h:2454
Definition: FieldRNG.h:37
std::string get_name(const std::string &type_sep_start="<", const std::string &type_sep_end="> ") const
Definition: TypeDescription.cc:135
Distinct type for face Iterator.
Definition: FieldIterator.h:121
mask_type synchronized_
Definition: QuadSurfMesh.h:2237
const Core::Geometry::Point & node2() const
Definition: QuadSurfMesh.h:230
NodeIterator< under_type > iterator
Definition: QuadSurfMesh.h:122
Definition: ConditionVariable.h:45
void remove_node_from_grid(typename Node::index_type ci)
Definition: QuadSurfMesh.h:3063
index_type next(index_type i)
Definition: QuadSurfMesh.h:2209
std::vector< Core::Geometry::Point > points_
array with all the points
Definition: QuadSurfMesh.h:2213
Synchronize(QuadSurfMesh< Basis > *mesh, mask_type sync)
Definition: QuadSurfMesh.h:255
void get_neighbors(typename Elem::array_type &array, typename Elem::index_type elem) const
Definition: QuadSurfMesh.h:577
EdgeIndex< under_type > index_type
Definition: QuadSurfMesh.h:128
Point max() const
Definition: BBox.h:195
std::vector< std::vector< index_type > > edges_
Definition: QuadSurfMesh.h:2220
bool find_closest_nodes(ARRAY1 &distances, ARRAY2 &nodes, const Core::Geometry::Point &p, double maxdist) const
Definition: QuadSurfMesh.h:1027
void get_edge_center(Core::Geometry::Point &result, INDEX idx) const
Definition: QuadSurfMesh.h:2091
#define ASSERTMSG(condition, message)
Definition: Exception.h:113
void get_center(Core::Geometry::Point &result, typename Face::index_type idx) const
Definition: QuadSurfMesh.h:522
virtual ~QuadSurfMesh()
Destructor.
Definition: QuadSurfMesh.h:2375
virtual bool synchronize(mask_type mask)
Definition: QuadSurfMesh.h:2610
void get_edges_from_node(ARRAY &array, INDEX idx) const
Definition: QuadSurfMesh.h:1719
index_type prev(index_type i)
Definition: QuadSurfMesh.h:2210
void get_normal(Core::Geometry::Vector &result, VECTOR &coords, INDEX1 eidx, INDEX2)
Get the normals at the outside of the element.
Definition: QuadSurfMesh.h:625
bool get_elem_neighbor(INDEX1 &neighbor, INDEX1 elem, INDEX2 delem) const
Definition: QuadSurfMesh.h:1756
void compute_node_grid()
Definition: QuadSurfMesh.h:3071
SCIRun::size_type size_type
Definition: QuadSurfMesh.h:113
Definition: QuadSurfMesh.h:141
void get_neighbors(std::vector< typename Node::index_type > &array, typename Node::index_type node)
These are more general implementations.
Definition: QuadSurfMesh.h:570
SCIRun::index_type index_type
Definition: QuadSurfMesh.h:112
void operator()()
Definition: QuadSurfMesh.h:260
Definition: Persistent.h:89
#define QUADSURFMESH_VERSION
Definition: QuadSurfMesh.h:3188
VMesh * CreateVQuadSurfMesh(MESH *mesh)
Definition: QuadSurfMesh.h:77
bool locate(typename Edge::index_type &edge, const Core::Geometry::Point &p) const
Definition: QuadSurfMesh.h:585
Core::Thread::ConditionVariable synchronize_cond_
Definition: QuadSurfMesh.h:2234
static const TypeDescription * elem_type_description()
Definition: QuadSurfMesh.h:1562
void get_nodes(typename Node::array_type &array, typename Face::index_type idx) const
Definition: QuadSurfMesh.h:423
void get_node_center(Core::Geometry::Point &p, INDEX idx) const
Definition: QuadSurfMesh.h:2085
bool find_closest_node(double &pdist, Core::Geometry::Point &result, INDEX &node, const Core::Geometry::Point &p) const
Definition: QuadSurfMesh.h:849
void get_faces(typename Face::array_type &array, typename Node::index_type idx) const
Definition: QuadSurfMesh.h:443
double get_volume(typename Cell::index_type) const
Definition: QuadSurfMesh.h:555
static const std::string type_name(int n=-1)
Core functionality for getting the name of a templated mesh class.
Definition: QuadSurfMesh.h:2303
static MeshHandle mesh_maker()
This function returns a handle for the virtual interface.
Definition: QuadSurfMesh.h:1568
boost::shared_ptr< QuadSurfMesh< Basis > > handle_type
Definition: QuadSurfMesh.h:116
void get_faces(typename Face::array_type &array, typename Edge::index_type idx) const
Definition: QuadSurfMesh.h:446
std::vector< index_type > faces_
array with the four nodes that make up a face
Definition: QuadSurfMesh.h:2215
Elem::index_type add_quad(typename Node::index_type a, typename Node::index_type b, typename Node::index_type c, typename Node::index_type d)
Definition: QuadSurfMesh.h:2856
bool get_neighbor(typename Elem::index_type &neighbor, typename Elem::index_type elem, typename DElem::index_type delem) const
Get neighbors of an element or a node.
Definition: QuadSurfMesh.h:564
Definition: Persistent.h:187
void derivate(const VECTOR1 &coords, INDEX idx, VECTOR2 &J) const
Definition: QuadSurfMesh.h:720
double scaled_jacobian_metric(INDEX idx) const
Definition: QuadSurfMesh.h:785
boost::shared_ptr< SearchGridT< index_type > > elem_grid_
Lookup grid for nodes.
Definition: QuadSurfMesh.h:2230
NodeIndex< under_type > index_type
Definition: QuadSurfMesh.h:121
BBox & extend(const Point &p)
Expand the bounding box to include point p.
Definition: BBox.h:98
void get_elems(typename Elem::array_type &array, typename Face::index_type idx) const
Definition: QuadSurfMesh.h:475
Node::index_type add_node(const Core::Geometry::Point &p)
Definition: QuadSurfMesh.h:674
double jacobian_metric(INDEX idx) const
Definition: QuadSurfMesh.h:815
Edge DElem
Definition: QuadSurfMesh.h:151
static const TypeDescription * edge_type_description()
Definition: QuadSurfMesh.h:3324
Definition: TypeDescription.h:50
T Dot(const ColumnMatrixGeneric< T > &a, const ColumnMatrixGeneric< T > &b)
Definition: ColumnMatrixFunctions.h:155
double det_jacobian(const VECTOR &coords, INDEX idx) const
Definition: QuadSurfMesh.h:729
index_type node1_index() const
Definition: QuadSurfMesh.h:182
std::vector< index_type > array_type
Definition: QuadSurfMesh.h:145
boost::mutex & get()
Definition: Mutex.h:49
Definition: TypeDescription.h:45
#define SCISHARE
Definition: share.h:39
std::vector< const TypeDescription * > td_vec
Definition: TypeDescription.h:56
Virtual function table.
Definition: QuadSurfMesh.h:2284
std::map< std::pair< index_type, index_type >, index_type, edgecompare > EdgeMapType
Definition: QuadSurfMesh.h:2930
void interpolate(Core::Geometry::Point &pt, const VECTOR &coords, INDEX idx) const
Definition: QuadSurfMesh.h:710
index_type node0_index() const
Definition: QuadSurfMesh.h:177
boost::shared_ptr< Mesh > MeshHandle
Definition: DatatypeFwd.h:67
virtual Core::Geometry::BBox get_bounding_box() const
Get the bounding box of the field.
Definition: QuadSurfMesh.h:2383
double get_length(typename Edge::index_type idx) const
More specific names for get_size.
Definition: QuadSurfMesh.h:551
double get_size(typename Face::index_type idx) const
Definition: QuadSurfMesh.h:536
virtual int dimensionality() const
Topological dimension.
Definition: QuadSurfMesh.h:350
Distinct type for cell Iterator.
Definition: FieldIterator.h:134
void compute_normals()
Definition: QuadSurfMesh.h:2774
unsigned int mask_type
Definition: Types.h:45
EdgeIterator< under_type > iterator
Definition: QuadSurfMesh.h:129
std::map< std::pair< index_type, index_type >, std::vector< index_type >, edgecompare > EdgeMapType2
Definition: QuadSurfMesh.h:2944
Basis & get_basis()
Get the basis class.
Definition: QuadSurfMesh.h:384
Point & asPoint() const
Definition: Vector.h:457
bool find_closest_nodes(ARRAY &nodes, const Core::Geometry::Point &p, double maxdist) const
Definition: QuadSurfMesh.h:964
virtual bool has_normals() const
Has this mesh normals.
Definition: QuadSurfMesh.h:375
#define ASSERT(condition)
Definition: Assert.h:110
std::vector< index_type > array_type
Definition: QuadSurfMesh.h:138
double inscribed_circumscribed_radius_metric(INDEX idx) const
Definition: QuadSurfMesh.h:843
Face Elem
Definition: QuadSurfMesh.h:150
index_type node2_index() const
Definition: QuadSurfMesh.h:187
void get_normal(Core::Geometry::Vector &n, typename Node::index_type i) const
Normals for visualizations.
Definition: QuadSurfMesh.h:616
Definition: QuadSurfMesh.h:159
void get_delems(typename DElem::array_type &array, typename Node::index_type idx) const
Definition: QuadSurfMesh.h:482
virtual int begin_class(const std::string &name, int current_version)
Definition: Persistent.cc:143
double get_size(typename Cell::index_type) const
Definition: QuadSurfMesh.h:547
std::vector< index_type > halfedge_to_edge_
Definition: QuadSurfMesh.h:2223
static const TypeDescription * face_type_description()
Definition: QuadSurfMesh.h:3342
virtual void io(Piostream &)
Export this class using the old Pio system.
Definition: QuadSurfMesh.h:3191
Core::Thread::Mutex synchronize_lock_
Lookup grid for elements.
Definition: QuadSurfMesh.h:2233
boost::unique_lock< boost::mutex > UniqueLock
Definition: ConditionVariable.h:43
double DetMatrix3P(const VectorOfPoints &p)
Inline templated determinant of matrix.
Definition: Locate.h:120
const string find_type_name(float *)
Definition: TypeName.cc:63
static const TypeDescription * node_type_description()
Definition: QuadSurfMesh.h:3306
bool locate_node(INDEX &node, const Core::Geometry::Point &p) const
Definition: QuadSurfMesh.h:1855
Core::Geometry::BBox bbox_
Basis for interpolation.
Definition: QuadSurfMesh.h:2243
void to_index(typename Face::index_type &index, index_type i) const
Definition: QuadSurfMesh.h:411
boost::shared_ptr< SearchGridT< index_type > > node_grid_
normalized per node
Definition: QuadSurfMesh.h:2229
void get_edges(typename Edge::array_type &, typename Cell::index_type) const
Definition: QuadSurfMesh.h:439
T DetMatrix3x3(const T *p)
Definition: Locate.h:95
mask_type synchronizing_
Definition: QuadSurfMesh.h:2239
EdgeIndex< under_type > size_type
Definition: QuadSurfMesh.h:130
bool find_closest_elem(double &pdist, Core::Geometry::Point &result, INDEX &elem, const Core::Geometry::Point &p) const
Definition: QuadSurfMesh.h:1411
virtual std::string dynamic_type_name() const
Definition: QuadSurfMesh.h:1553
void get_elems(typename Elem::array_type &array, typename Edge::index_type idx) const
Definition: QuadSurfMesh.h:472
void get_faces(typename Face::array_type &, typename Cell::index_type) const
Definition: QuadSurfMesh.h:452
Definition: VMeshShared.h:40
void get_nodes(typename Node::array_type &array, typename Node::index_type idx) const
Get the child elements of the given index.
Definition: QuadSurfMesh.h:417
Definition: ParallelLinearAlgebraTests.cc:358
double get_epsilon() const
Definition: QuadSurfMesh.h:1539
Definition: QuadSurfMesh.h:127
void compute_edges()
Definition: QuadSurfMesh.h:2950
void get_center(Core::Geometry::Point &result, typename Edge::index_type idx) const
Definition: QuadSurfMesh.h:520
Definition: SearchGridT.h:47
bool locate(typename Node::index_type &node, const Core::Geometry::Point &p) const
Locate a point in a mesh, find which is the closest node.
Definition: QuadSurfMesh.h:583
const char * name[]
Definition: BoostGraphExampleTests.cc:87
bool find_closest_node(double &pdist, Core::Geometry::Point &result, INDEX &node, const Core::Geometry::Point &p, double maxdist) const
Definition: QuadSurfMesh.h:856
index_type edge0_index() const
changed the indexing as we now use unique indices
Definition: QuadSurfMesh.h:199
void est_closest_point_on_quad(Point &result, const Point &orig, const Point &p0, const Point &p1, const Point &p2, const Point &p3, const double epsilon)
Definition: CompGeom.cc:226
void get_nodes(typename Node::array_type &array, typename Edge::index_type idx) const
Definition: QuadSurfMesh.h:420
void Pio_index(Piostream &stream, index_type *data, size_type size)
Definition: Persistent.cc:606
index_type edge3_index() const
Definition: QuadSurfMesh.h:214
long long size_type
Definition: Types.h:40
void insert_node_into_grid(typename Node::index_type ci)
Definition: QuadSurfMesh.h:3053
Definition: StackVector.h:50
void get_cells(typename Cell::array_type &, typename Cell::index_type) const
Definition: QuadSurfMesh.h:465
int get_weights(const Core::Geometry::Point &p, typename Node::array_type &l, double *w)
Definition: QuadSurfMesh.h:2551
bool find_closest_elem(double &pdist, Core::Geometry::Point &result, ARRAY &coords, INDEX &elem, const Core::Geometry::Point &p) const
Definition: QuadSurfMesh.h:1098
Vector Cross(const Vector &v1, const Vector &v2)
Definition: Vector.h:378
std::vector< std::vector< typename Elem::index_type > > NodeNeighborMap
Definition: QuadSurfMesh.h:2225
double ScaledDetMatrix3P(const VectorOfPoints &p)
Inline templated determinant of matrix.
Definition: Locate.h:132
double inverse_jacobian(const VECTOR &coords, INDEX idx, double *Ji) const
Definition: QuadSurfMesh.h:762
void pwl_approx_edge(std::vector< VECTOR > &coords, INDEX ci, unsigned int which_edge, unsigned int div_per_unit) const
Definition: QuadSurfMesh.h:498
void compute_elem_grid()
Definition: QuadSurfMesh.h:3108
void get_nodes(typename Node::array_type &, typename Cell::index_type) const
Definition: QuadSurfMesh.h:426
Vector diagonal() const
Definition: BBox.h:198
void get_cells(typename Cell::array_type &, typename Edge::index_type) const
Definition: QuadSurfMesh.h:459
void to_index(typename Node::index_type &index, index_type i) const
Definition: QuadSurfMesh.h:407
bool locate_elem(INDEX &elem, const Core::Geometry::Point &p) const
Definition: QuadSurfMesh.h:1976
ElemData(const QuadSurfMesh< Basis > &msh, const index_type ind)
Definition: QuadSurfMesh.h:164
void get_elem_neighbors(ARRAY &array, INDEX idx) const
Definition: QuadSurfMesh.h:1801
void get_delems(typename DElem::array_type &array, typename Edge::index_type idx) const
Definition: QuadSurfMesh.h:485
void pwl_approx_face(std::vector< std::vector< VECTOR > > &coords, INDEX ci, unsigned int which_face, unsigned int div_per_unit) const
Definition: QuadSurfMesh.h:509
Persistent i/o for STL containers.
std::vector< INDEX >::iterator iterator
Definition: SearchGridT.h:53
virtual bool is_editable() const
Check whether mesh can be altered by adding nodes or elements.
Definition: QuadSurfMesh.h:369
std::string type
Definition: Persistent.h:72
void get_faces_from_node(ARRAY &array, INDEX idx) const
Definition: QuadSurfMesh.h:1686
void get_nodes_from_face(ARRAY &array, INDEX idx) const
Definition: QuadSurfMesh.h:1641
void get_edges_from_face(ARRAY &array, INDEX idx) const
Definition: QuadSurfMesh.h:1658
Point min() const
Definition: BBox.h:192
Distinct type for face index.
Definition: FieldIndex.h:90
Definition: QuadSurfMesh.h:2910
int get_weights(const Core::Geometry::Point &, typename Cell::array_type &, double *)
Definition: QuadSurfMesh.h:604
void get_node_neighbors(ARRAY &array, INDEX idx) const
Definition: QuadSurfMesh.h:1824
void to_index(typename Edge::index_type &index, index_type i) const
Definition: QuadSurfMesh.h:409
FaceIndex< under_type > index_type
Definition: QuadSurfMesh.h:135
FaceIterator< under_type > iterator
Definition: QuadSurfMesh.h:136
void x(double)
Definition: Vector.h:175
bool find_closest_elems(double &pdist, Core::Geometry::Point &result, ARRAY &elems, const Core::Geometry::Point &p) const
Definition: QuadSurfMesh.h:1421
void to_index(typename Cell::index_type &, index_type) const
Definition: QuadSurfMesh.h:413
bool clear_synchronization()
Definition: QuadSurfMesh.h:2750
Definition: QuadSurfMesh.h:134
void node_reserve(size_type s)
Definition: QuadSurfMesh.h:691
FaceIndex< under_type > size_type
Definition: QuadSurfMesh.h:137
void resize_nodes(size_type s)
Definition: QuadSurfMesh.h:693
static Persistent * maker()
This function returns a maker for Pio.
Definition: QuadSurfMesh.h:1566
SCIRun::mask_type mask_type
Definition: QuadSurfMesh.h:114
static const std::string make_template_id(const std::string &templateName, const std::string &templateParam)
Definition: TypeName.h:62
bool get_elem_neighbors(ARRAY &array, INDEX1 elem, INDEX2 delem) const
Definition: QuadSurfMesh.h:1777
bool inside(const Point &p) const
Definition: BBox.h:205
void get_edges(typename Edge::array_type &array, typename Face::index_type idx) const
Definition: QuadSurfMesh.h:436
v
Definition: readAllFields.py:42
index_type edge2_index() const
Definition: QuadSurfMesh.h:209
void get_center(Core::Geometry::Point &, typename Cell::index_type) const
Definition: QuadSurfMesh.h:524
CellIndex< under_type > size_type
Definition: QuadSurfMesh.h:144
double normalize()
Definition: Vector.h:437
void get_cells(typename Cell::array_type &, typename Face::index_type) const
Definition: QuadSurfMesh.h:462
void compute_node_neighbors()
Definition: QuadSurfMesh.h:3002
void get_elems(typename Face::array_type &, typename Cell::index_type) const
Definition: QuadSurfMesh.h:478
void y(double)
Definition: Vector.h:185
bool locate(typename Elem::index_type &elem, std::vector< double > &coords, const Core::Geometry::Point &p) const
Definition: QuadSurfMesh.h:592
CellIterator< under_type > iterator
Definition: QuadSurfMesh.h:143
double safe_normalize()
Definition: Vector.h:236
bool order_face_nodes(NODE &n1, NODE &n2, NODE &n3, NODE &n4) const
Definition: QuadSurfMesh.h:2140
NodeIndex< under_type > size_type
Definition: QuadSurfMesh.h:123
double distance_to_line2(const Point &p, const Point &a, const Point &b, const double epsilon)
Definition: CompGeom.cc:53
Distinct type for edge Iterator.
Definition: FieldIterator.h:105
Node::index_type add_find_point(const Core::Geometry::Point &p, double err=1.0e-3)
Definition: QuadSurfMesh.h:2838
void get_faces_from_edge(ARRAY &array, INDEX idx) const
Definition: QuadSurfMesh.h:1698
#define ASSERTFAIL(string)
Definition: Assert.h:52
void size(typename Node::size_type &) const
Definition: QuadSurfMesh.h:3242
Definition: QuadSurfMesh.h:71
void Pio(Piostream &stream, Array1< T > &array)
Definition: Array1.h:65
Some convenient simple iterators for fields.
const Core::Geometry::Point & node1() const
Definition: QuadSurfMesh.h:225
Basis basis_type
Definition: QuadSurfMesh.h:117
const Core::Geometry::Point & node0() const
Definition: QuadSurfMesh.h:220
NodeNeighborMap node_neighbors_
Definition: QuadSurfMesh.h:2226
double get_area(typename Face::index_type idx) const
Definition: QuadSurfMesh.h:553
bool get_coords(VECTOR &coords, const Core::Geometry::Point &p, INDEX idx) const
Definition: QuadSurfMesh.h:701
double length() const
Definition: Vector.h:365
virtual void end_class()
Definition: Persistent.cc:178
void get_face_center(Core::Geometry::Point &p, INDEX idx) const
Definition: QuadSurfMesh.h:2102
long long index_type
Definition: Types.h:39
void insert_elem_into_grid(typename Elem::index_type ci)
Used to recompute data for individual cells.
Definition: QuadSurfMesh.h:3021
std::vector< Core::Geometry::Vector > normals_
Definition: QuadSurfMesh.h:2228
double epsilon2_
epsilon for calculations 1e-8*diagonal bounding box
Definition: QuadSurfMesh.h:2245
void get_edges(typename Edge::array_type &array, typename Node::index_type idx)
Definition: QuadSurfMesh.h:430
void resize(size_t size, const value_type &val=value_type())
Definition: StackVector.h:61
Elem::index_type add_elem(ARRAY a)
Add a new element to the mesh.
Definition: QuadSurfMesh.h:679
bool find_closest_elem(double &pdist, Core::Geometry::Point &result, ARRAY &coords, INDEX &elem, const Core::Geometry::Point &p, double maxdist) const
Definition: QuadSurfMesh.h:1108
QuadSurfMesh< Basis >::index_type index_type
Definition: QuadSurfMesh.h:162
Definition: QuadSurfMesh.h:252
QuadSurfMesh()
Construct a new mesh.
Definition: QuadSurfMesh.h:2324
void reset()
Definition: BBox.h:95
const Core::Geometry::Point & node3() const
Definition: QuadSurfMesh.h:235
bool operator()(const std::pair< index_type, index_type > &a, const std::pair< index_type, index_type > &b) const
Definition: QuadSurfMesh.h:2286
void get_cells(typename Cell::array_type &, typename Node::index_type) const
Definition: QuadSurfMesh.h:456
Definition: Persistent.h:64
void elem_reserve(size_type s)
Definition: QuadSurfMesh.h:692
void get_random_point(Core::Geometry::Point &, typename Elem::index_type, FieldRNG &rng) const
Definition: QuadSurfMesh.h:2571
void get_point(Core::Geometry::Point &p, typename Node::index_type i) const
Access the nodes of the mesh.
Definition: QuadSurfMesh.h:608
boost::shared_ptr< VMesh > vmesh_
square of epsilon for squared distance comparisons
Definition: QuadSurfMesh.h:2248
virtual const TypeDescription * get_type_description() const
Definition: QuadSurfMesh.h:3298
void set_nodes_by_elem(ARRAY &array, INDEX idx)
Definition: QuadSurfMesh.h:1747
SCIRun::index_type under_type
Definition: QuadSurfMesh.h:111
bool find_closest_elem_far_from(double &pdist, Core::Geometry::Point &result, ARRAY &coords, INDEX &face, const Core::Geometry::Point &p, const Core::Geometry::Point &repelpos, double mindistfromrepel, const Core::Geometry::Vector &repelnormal, double mindotfromrepel, double maxdist) const
Definition: QuadSurfMesh.h:1269
static PersistentTypeID quadsurfmesh_typeid
This ID is created as soon as this class will be instantiated.
Definition: QuadSurfMesh.h:1549
void resize_elems(size_type s)
Definition: QuadSurfMesh.h:694
Distinct type for edge index.
Definition: FieldIndex.h:81
static const TypeDescription * cell_type_description()
Definition: QuadSurfMesh.h:3360
friend class VQuadSurfMesh
Make sure the virtual interface has access.
Definition: QuadSurfMesh.h:105
int n
Definition: eab.py:9
double get_size(typename Node::index_type) const
Get the size of an element (length, area, volume)
Definition: QuadSurfMesh.h:528
boost::lock_guard< boost::mutex > Guard
Definition: Mutex.h:55
CellIndex< under_type > index_type
Definition: QuadSurfMesh.h:142
T InverseMatrix3x3(const T *p, T *q)
Definition: Locate.h:47
Index and Iterator types required for Mesh Concept.
Definition: QuadSurfMesh.h:120
StackVector< index_type, 4 > array_type
Definition: QuadSurfMesh.h:124
void run()
Definition: QuadSurfMesh.h:265
#define DEBUG_CONSTRUCTOR(type)
Definition: Debug.h:64
void io(Piostream &stream)
Persistent I/O.
Definition: Mesh.cc:387
bool locate_elems(ARRAY &array, const Core::Geometry::BBox &b) const
Definition: QuadSurfMesh.h:2011
void get_edges_from_elem(ARRAY &array, INDEX idx) const
Definition: QuadSurfMesh.h:1679
void jacobian(const VECTOR &coords, INDEX idx, double *J) const
Definition: QuadSurfMesh.h:740
void remove_elem_from_grid(typename Elem::index_type ci)
Definition: QuadSurfMesh.h:3038
bool get_neighbors(std::vector< typename Elem::index_type > &array, typename Elem::index_type elem, typename DElem::index_type delem) const
Definition: QuadSurfMesh.h:573
bool locate_elem(INDEX &elem, ARRAY &coords, const Core::Geometry::Point &p) const
Definition: QuadSurfMesh.h:2042
virtual void transform(const Core::Geometry::Transform &t)
Core::Geometry::Transform a field (transform all nodes using this transformation matrix) ...
Definition: QuadSurfMesh.h:2413
void z(double)
Definition: Vector.h:195
Node::index_type add_point(const Core::Geometry::Point &p)
Add a new node to the mesh.
Definition: QuadSurfMesh.h:3171
boost::shared_ptr< MeshFacade< VMesh > > MeshFacadeHandle
Definition: MeshTraits.h:61
bool inside(INDEX idx, const Core::Geometry::Point &p) const
Definition: QuadSurfMesh.h:1575
index_type node3_index() const
Definition: QuadSurfMesh.h:192
bool locate_edge(INDEX &loc, const Core::Geometry::Point &p) const
This is currently implemented as an exhaustive search.
Definition: QuadSurfMesh.h:1945
void get_delems(typename DElem::array_type &, typename Cell::index_type) const
Definition: QuadSurfMesh.h:491
bool operator()(const std::pair< index_type, index_type > &a, const std::pair< index_type, index_type > &b) const
Definition: QuadSurfMesh.h:2912
virtual bool unsynchronize(mask_type mask)
Definition: QuadSurfMesh.h:2742
Basis basis_
Definition: QuadSurfMesh.h:2241
virtual QuadSurfMesh * clone() const
Definition: QuadSurfMesh.h:332
void get_nodes_from_elem(ARRAY &array, INDEX idx) const
Definition: QuadSurfMesh.h:1652
const Core::Geometry::Point & point(typename Node::index_type i) const
Definition: QuadSurfMesh.h:2121
virtual void get_canonical_transform(Core::Geometry::Transform &t) const
Definition: QuadSurfMesh.h:2403
bool locate(typename Face::index_type &face, const Core::Geometry::Point &p) const
Definition: QuadSurfMesh.h:587
bool locate(typename Cell::index_type &, const Core::Geometry::Point &) const
Definition: QuadSurfMesh.h:589
void set_point(const Core::Geometry::Point &p, typename Node::index_type i)
Definition: QuadSurfMesh.h:610
void get_edges(typename Edge::array_type &array, typename Edge::index_type idx) const
Definition: QuadSurfMesh.h:433
void get_nodes_from_edge(ARRAY &array, INDEX i) const
Definition: QuadSurfMesh.h:1624
int size
Definition: eabLatVolData.py:2
void end(typename Node::iterator &) const
Definition: QuadSurfMesh.h:2464
#define DEBUG_DESTRUCTOR(type)
Definition: Debug.h:65
const TypeDescription * get_type_description(Core::Basis::ConstantBasis< T > *)
Definition: Constant.h:209
void compute_bounding_box()
Definition: QuadSurfMesh.h:3146
bool elem_locate(INDEX &elem, MESH &msh, const Core::Geometry::Point &p)
General case locate, search each elem.
Definition: Mesh.h:188