SCIRun  5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PointCloudMesh.h
Go to the documentation of this file.
1 /*
2  For more information, please see: http://software.sci.utah.edu
3 
4  The MIT License
5 
6  Copyright (c) 2009 Scientific Computing and Imaging Institute,
7  University of Utah.
8 
9 
10  Permission is hereby granted, free of charge, to any person obtaining a
11  copy of this software and associated documentation files (the "Software"),
12  to deal in the Software without restriction, including without limitation
13  the rights to use, copy, modify, merge, publish, distribute, sublicense,
14  and/or sell copies of the Software, and to permit persons to whom the
15  Software is furnished to do so, subject to the following conditions:
16 
17  The above copyright notice and this permission notice shall be included
18  in all copies or substantial portions of the Software.
19 
20  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26  DEALINGS IN THE SOFTWARE.
27 */
28 
29 #ifndef CORE_DATATYPES_POINTCLOUDMESH_H
30 #define CORE_DATATYPES_POINTCLOUDMESH_H 1
31 
32 /// Include what kind of support we want to have
33 /// Need to fix this and couple it sci-defs
35 
39 
43 
44 #include <Core/Thread/Mutex.h>
45 #include <Core/Basis/Locate.h>
46 #include <Core/Basis/Constant.h>
47 
53 
55 
56 namespace SCIRun {
57 
58 /////////////////////////////////////////////////////
59 // Declarations for virtual interface
60 
61 /// Functions for creating the virtual interface
62 /// Declare the functions that instantiate the virtual interface
63 template <class Basis> class PointCloudMesh;
64 
65 /// make sure any other mesh other than the preinstantiate ones
66 /// returns no virtual interface. Altering this behavior will allow
67 /// for dynamically compiling the interface if needed.
68 
69 template<class MESH>
70 VMesh* CreateVPointCloudMesh(MESH*) { return (0); }
71 
72 /// Declare that these can be found in a library that is already
73 /// precompiled. So dynamic compilation will not instantiate them again.
74 #if (SCIRUN_POINTCLOUD_SUPPORT > 0)
75 SCISHARE VMesh* CreateVPointCloudMesh(PointCloudMesh<Core::Basis::ConstantBasis<Core::Geometry::Point> >* mesh);
76 
77 #endif
78 /////////////////////////////////////////////////////
79 
80 
81 /////////////////////////////////////////////////////
82 // Declarations for PointCloudMesh class
83 
84 template <class Basis>
85 class PointCloudMesh : public Mesh
86 {
87 
88 /// Make sure the virtual interface has access
89 template<class MESH> friend class VPointCloudMesh;
90 template<class MESH> friend class VMeshShared;
91 
92 public:
93  // Types that change depending on 32 or 64bits
98 
99  typedef boost::shared_ptr<PointCloudMesh<Basis> > handle_type;
100  typedef Basis basis_type;
101 
102  /// Index and Iterator types required for Mesh Concept.
103  struct Node {
108  };
109 
110  struct Edge {
114  typedef std::vector<index_type> array_type;
115  };
116 
117  struct Face {
121  typedef std::vector<index_type> array_type;
122  };
123 
124  struct Cell {
128  typedef std::vector<index_type> array_type;
129  };
130 
131  /// Elem refers to the most complex topological object
132  /// DElem refers to object just below Elem in the topological hierarchy
133 
134  typedef Node Elem;
135  typedef Node DElem;
136 
137  /// Somehow the information of how to interpolate inside an element
138  /// ended up in a separate class, as they need to share information
139  /// this construction was created to transfer data.
140  /// Hopefully in the future this class will disappear again.
141  friend class ElemData;
142  class ElemData
143  {
144  public:
146 
147  ElemData(const PointCloudMesh<Basis>& msh, const index_type ind) :
148  mesh_(msh),
149  index_(ind)
150  {}
151 
152  // the following designed to coordinate with ::get_nodes
153  inline index_type node0_index() const
154  {
155  return index_;
156  }
157 
158  inline
159  const Core::Geometry::Point &node0() const
160  {
161  return mesh_.points_[index_];
162  }
163 
164  private:
165  const PointCloudMesh<Basis> &mesh_;
166  const index_type index_;
167  };
168 
169 
170  //////////////////////////////////////////////////////////////////
171 
172  /// Construct a new mesh
173  PointCloudMesh();
174 
175  /// Copy a mesh, needed for detaching the mesh from a field
176  PointCloudMesh(const PointCloudMesh &copy);
177 
178  /// Clone function for detaching the mesh and automatically generating
179  /// a new version if needed.
180  virtual PointCloudMesh *clone() const { return new PointCloudMesh(*this); }
181 
182  /// Destructor
183  virtual ~PointCloudMesh();
184 
185  /// Access point to virtual interface
186  virtual VMesh* vmesh() { return (vmesh_.get()); }
187 
188  virtual MeshFacadeHandle getFacade() const
189  {
190  return boost::make_shared<Core::Datatypes::VirtualMeshFacade<VMesh>>(vmesh_);
191  }
192 
193  /// This one should go at some point, should be reroute throught the
194  /// virtual interface
195  virtual int basis_order()
196  {
197  return (basis_.polynomial_order());
198  }
199 
200  /// Topological dimension
201  virtual int dimensionality() const { return 0; }
202 
203  /// What kind of mesh is this
204  /// structured = no connectivity data
205  /// regular = no node location data
206  virtual int topology_geometry() const
207  { return (Mesh::UNSTRUCTURED | Mesh::IRREGULAR); }
208 
209  /// Get the bounding box of the field
210  virtual Core::Geometry::BBox get_bounding_box() const;
211 
212  /// Return the transformation that takes a 0-1 space bounding box
213  /// to the current bounding box of this mesh.
214  virtual void get_canonical_transform(Core::Geometry::Transform &t) const;
215 
216  /// Core::Geometry::Transform a field (transform all nodes using this transformation matrix)
217  virtual void transform(const Core::Geometry::Transform &t);
218 
219  /// Check whether mesh can be altered by adding nodes or elements
220  virtual bool is_editable() const { return true; }
221 
222  /// Has this mesh normals.
223  virtual bool has_normals() const { return (false); }
224 
225  /// Compute tables for doing topology, these need to be synchronized
226  /// before doing a lot of operations.
227  virtual bool synchronize(mask_type sync);
228  virtual bool unsynchronize(mask_type sync);
229  bool clear_synchronization();
230 
231  /// Get the basis class
232  Basis& get_basis() { return basis_; }
233 
234  /// begin/end iterators
235  void begin(typename Node::iterator &) const;
236  void begin(typename Edge::iterator &) const;
237  void begin(typename Face::iterator &) const;
238  void begin(typename Cell::iterator &) const;
239 
240  void end(typename Node::iterator &) const;
241  void end(typename Edge::iterator &) const;
242  void end(typename Face::iterator &) const;
243  void end(typename Cell::iterator &) const;
244 
245  /// Get the iteration sizes
246  void size(typename Node::size_type &) const;
247  void size(typename Edge::size_type &) const;
248  void size(typename Face::size_type &) const;
249  void size(typename Cell::size_type &) const;
250 
251  /// These are here to convert indices to unsigned int
252  /// counters. Some how the decision was made to use multi
253  /// dimensional indices in some fields, these functions
254  /// should deal with different pointer types.
255  /// Use the virtual interface to avoid all this non sense.
256  inline void to_index(typename Node::index_type &index, index_type i) const
257  { index = i; }
258  inline void to_index(typename Edge::index_type &index, index_type i) const
259  { index = i; }
260  inline void to_index(typename Face::index_type &index, index_type i) const
261  { index = i; }
262  inline void to_index(typename Cell::index_type &index, index_type i) const
263  { index = i; }
264 
265 
266  // This is actually get_nodes(typename Node::array_type &, Elem::index_type)
267  // for compilation purposes. IE It is redundant unless we are
268  // templated by Elem type and we don't know that Elem is Node.
269  // This is needed in ClipField, for example.
270  void get_nodes(typename Node::array_type &a,
271  typename Node::index_type i) const
272  { a.resize(1); a[0] = i; }
273  void get_nodes(typename Node::array_type &,
274  typename Edge::index_type) const
275  { ASSERTFAIL("PointCloudMesh: get_nodes has not been implemented for edges"); }
276  void get_nodes(typename Node::array_type &,
277  typename Face::index_type) const
278  { ASSERTFAIL("PointCloudMesh: get_nodes has not been implemented for faces"); }
279  void get_nodes(typename Node::array_type &,
280  typename Cell::index_type) const
281  { ASSERTFAIL("PointCloudMesh: get_nodes has not been implemented for cells"); }
282 
283 
284  void get_edges(typename Edge::array_type&,
285  typename Node::index_type) const
286  { ASSERTFAIL("PointCloudMesh: get_edges has not been implemented for nodes"); }
287  void get_edges(typename Edge::array_type&,
288  typename Edge::index_type) const
289  { ASSERTFAIL("PointCloudMesh: get_edgees has not been implemented for edges"); }
290  void get_edges(typename Edge::array_type&,
291  typename Face::index_type) const
292  { ASSERTFAIL("PointCloudMesh: get_edgees has not been implemented for faces"); }
293  void get_edges(typename Edge::array_type&,
294  typename Cell::index_type) const
295  { ASSERTFAIL("PointCloudMesh: get_edges has not been implemented for cells"); }
296 
297  void get_faces(typename Face::array_type&,
298  typename Node::index_type) const
299  { ASSERTFAIL("PointCloudMesh: get_faces has not been implemented"); }
300  void get_faces(typename Face::array_type&,
301  typename Edge::index_type) const
302  { ASSERTFAIL("PointCloudMesh: get_faces has not been implemented"); }
303  void get_faces(typename Face::array_type&,
304  typename Face::index_type) const
305  { ASSERTFAIL("PointCloudMesh: get_faces has not been implemented"); }
306  void get_faces(typename Face::array_type&,
307  typename Cell::index_type) const
308  { ASSERTFAIL("PointCloudMesh: get_faces has not been implemented"); }
309 
310  void get_cells(typename Cell::array_type&,
311  typename Node::index_type) const
312  { ASSERTFAIL("PointCloudMesh: get_cells has not been implemented"); }
313  void get_cells(typename Cell::array_type&,
314  typename Edge::index_type) const
315  { ASSERTFAIL("PointCloudMesh: get_cells has not been implemented"); }
316  void get_cells(typename Cell::array_type&,
317  typename Face::index_type) const
318  { ASSERTFAIL("PointCloudMesh: get_cells has not been implemented"); }
319  void get_cells(typename Cell::array_type&,
320  typename Cell::index_type) const
321  { ASSERTFAIL("PointCloudMesh: get_cells has not been implemented"); }
322 
323 
324  /// get the parent element(s) of the given index
325  void get_elems(typename Elem::array_type &result,
326  typename Node::index_type idx) const
327  {
328  // result.clear();
329  // result.push_back(idx);
330  result[0] = idx;
331  }
332  void get_elems(typename Elem::array_type&,
333  typename Edge::index_type) const
334  { ASSERTFAIL("PointCloudMesh: get_elems has not been implemented for edges"); }
335  void get_elems(typename Elem::array_type&,
336  typename Face::index_type) const
337  { ASSERTFAIL("PointCloudMesh: get_elems has not been implemented for faces"); }
338  void get_elems(typename Elem::array_type&,
339  typename Cell::index_type) const
340  { ASSERTFAIL("PointCloudMesh: get_elems has not been implemented for cells"); }
341 
342  void get_delems(typename DElem::array_type&,
343  typename Node::index_type) const
344  { ASSERTFAIL("PointCloudMesh: get_delems has not been implemented for nodes"); }
345  void get_delems(typename DElem::array_type&,
346  typename Edge::index_type) const
347  { ASSERTFAIL("PointCloudMesh: get_delems has not been implemented for edges"); }
348  void get_delems(typename DElem::array_type&,
349  typename Face::index_type) const
350  { ASSERTFAIL("PointCloudMesh: get_delems has not been implemented for faces"); }
351  void get_delems(typename DElem::array_type&,
352  typename Cell::index_type) const
353  { ASSERTFAIL("PointCloudMesh: get_delems has not been implemented for cells"); }
354 
355  /// Generate the list of points that make up a sufficiently accurate
356  /// piecewise linear approximation of an edge.
357  template<class VECTOR>
358  void pwl_approx_edge(VECTOR &,
359  typename Elem::index_type,
360  unsigned int,
361  unsigned int) const
362  {
363  ASSERTFAIL("PointCloudMesh: cannot approximiate edges");
364  }
365 
366  template<class VECTOR>
367  void pwl_approx_face(VECTOR &,
368  typename Elem::index_type,
369  unsigned int,
370  unsigned int) const
371  {
372  ASSERTFAIL("PointCloudMesh: cannot approximiate faces");
373  }
374 
375 
376  /// get the center point (in object space) of an element
378  { p = points_[i]; }
380  { ASSERTFAIL("PointCloudMesh: get_center has not been implemented for edges"); }
382  { ASSERTFAIL("PointCloudMesh: get_center has not been implemented for faces"); }
384  { ASSERTFAIL("PointCloudMesh: get_center has not been implemented for cells"); }
385 
386  /// Get the size of an elemnt (length, area, volume)
387  double get_size(typename Node::index_type) const { return 0.0; }
388  double get_size(typename Edge::index_type) const { return 0.0; }
389  double get_size(typename Face::index_type) const { return 0.0; }
390  double get_size(typename Cell::index_type) const { return 0.0; }
391  double get_length(typename Edge::index_type) const { return 0.0; }
392  double get_area(typename Face::index_type) const { return 0.0; }
393  double get_volume(typename Cell::index_type) const { return 0.0; }
394 
395  double get_size(typename Node::array_type&) const { return 0.0; }
396 
397  /// Get neighbors of an element or a node
398  /// THIS ONE IS FLAWED AS IN 3D SPACE A NODE CAN BE CONNECTED TO
399  /// MANY ELEMENTS
400  bool get_neighbor(typename Elem::index_type& /*neighbor*/,
401  typename Elem::index_type /*elem*/,
402  typename DElem::index_type /*delem*/) const
403  { return (false); }
404  void get_neighbors(std::vector<typename Node::index_type> &array,
405  typename Node::index_type /*node*/) const
406  { array.resize(0); }
407  bool get_neighbors(std::vector<typename Elem::index_type> &array,
408  typename Elem::index_type /*elem*/,
409  typename DElem::index_type /*delem*/) const
410  { array.resize(0); return (false); }
411 
412  /// Locate a point in a mesh, find which is the closest node
413  bool locate(typename Node::index_type &n, const Core::Geometry::Point &p) const
414  { return (locate_node(n,p)); }
415  bool locate(typename Edge::index_type &, const Core::Geometry::Point &) const
416  { return (false); }
417  bool locate(typename Face::index_type &, const Core::Geometry::Point &) const
418  { return (false); }
419  bool locate(typename Cell::index_type &, const Core::Geometry::Point &) const
420  { return (false); }
421 
422  template<class ARRAY>
423  bool locate(typename Node::index_type &n, ARRAY& coords, const Core::Geometry::Point &p) const
424  { coords.resize(0); return (locate_node(n,p)); }
425 
426  /// These should become obsolete soon, they do not follow the concept
427  /// of the basis functions....
428  int get_weights(const Core::Geometry::Point &p, typename Node::array_type &l, double *w);
429  int get_weights(const Core::Geometry::Point&, typename Edge::array_type&, double*)
430  { ASSERTFAIL("PointCloudField: get_weights for edges isn't supported"); }
431  int get_weights(const Core::Geometry::Point&, typename Face::array_type&, double*)
432  { ASSERTFAIL("PointCloudField: get_weights for faces isn't supported"); }
433  int get_weights(const Core::Geometry::Point&, typename Cell::array_type&, double*)
434  { ASSERTFAIL("PointCloudField: get_weights for cells isn't supported"); }
435 
436 
438  { get_center(p,i); }
440  { points_[i] = p; }
442  FieldRNG& /*rng*/) const
443  { get_center(p, i); }
444 
446  { ASSERTFAIL("PointCloudMesh: this mesh type does not have node normals."); }
447  template<class VECTOR>
448  void get_normal(Core::Geometry::Vector&, VECTOR &, typename Elem::index_type, unsigned int) const
449  { ASSERTFAIL("PointCloudMesh: this mesh type does not have element normals."); }
450 
451  /// use these to build up a new PointCloudField mesh
452  typename Node::index_type add_node(const Core::Geometry::Point &p) { return add_point(p); }
454 
455  template <class ARRAY>
456  typename Elem::index_type add_elem(ARRAY a)
457  {
458  return (static_cast<typename Elem::index_type>(a[0]));
459  }
460 
461  void node_reserve(size_t s) { points_.reserve(s); }
462  void elem_reserve(size_t s) { points_.reserve(s); }
463  void resize_nodes(size_t s) { points_.resize(s); }
464  void resize_elems(size_t s) { points_.resize(s); }
465 
466 
467  /// THESE FUNCTIONS ARE DEFINED INSIDE THE CLASS AS THESE ARE TEMPLATED
468  /// FUNCTIONS INSIDE A TEMPLATED CLASS. THIS WAY OF DEFINING THE FUNCTIONS
469  /// IS SUPPORTED BY MOST COMPILERS
470 
471  /// Get the local coordinates for a certain point within an element
472  /// This function uses a couple of newton iterations to find the local
473  /// coordinate of a point
474  template<class VECTOR, class INDEX>
475  bool get_coords(VECTOR &coords, const Core::Geometry::Point& /*p*/, INDEX /*idx*/) const
476  {
477  coords.resize(1);
478  coords[0] = 0.0;
479  return true;
480  }
481 
482  /// Find the location in the global coordinate system for a local coordinate
483  /// This function is the opposite of get_coords.
484  template<class VECTOR, class INDEX>
485  void interpolate(Core::Geometry::Point &pt, const VECTOR& /*coords*/, INDEX idx) const
486  {
487  get_center(pt, typename Node::index_type(idx));
488  }
489 
490  /// Interpolate the derivate of the function, This infact will return the
491  /// jacobian of the local to global coordinate transformation. This function
492  /// is mainly intended for the non linear elements
493  template<class VECTOR1, class INDEX, class VECTOR2>
494  void derivate(const VECTOR1& /*coords*/, INDEX /*idx*/, VECTOR2 &J) const
495  {
496  J.resize(1);
497  J[0].x(0.0);
498  J[0].y(0.0);
499  J[0].z(0.0);
500  }
501 
502 
503  /// Get the determinant of the jacobian, which is the local volume of an element
504  /// and is intended to help with the integration of functions over an element.
505  template<class VECTOR, class INDEX>
506  double det_jacobian(const VECTOR& coords, INDEX idx) const
507  {
508  return (1.0);
509  }
510 
511  /// Get the jacobian of the transformation. In case one wants the non inverted
512  /// version of this matrix. This is currentl here for completeness of the
513  /// interface
514  template<class VECTOR, class INDEX>
515  void jacobian(const VECTOR& coords, INDEX idx, double* J) const
516  {
517  J[0] = 1.0;
518  J[1] = 0.0;
519  J[2] = 0.0;
520  J[3] = 0.0;
521  J[4] = 1.0;
522  J[5] = 0.0;
523  J[6] = 0.0;
524  J[7] = 0.0;
525  J[8] = 1.0;
526  }
527 
528  /// Get the inverse jacobian of the transformation. This one is needed to
529  /// translate local gradients into global gradients. Hence it is crucial for
530  /// calculating gradients of fields, or constructing finite elements.
531  template<class VECTOR, class INDEX>
532  double inverse_jacobian(const VECTOR& /*coords*/, INDEX /*idx*/, double* Ji) const
533  {
534  Ji[0] = 1.0;
535  Ji[1] = 0.0;
536  Ji[2] = 0.0;
537  Ji[3] = 0.0;
538  Ji[4] = 1.0;
539  Ji[5] = 0.0;
540  Ji[6] = 0.0;
541  Ji[7] = 0.0;
542  Ji[8] = 1.0;
543 
544  return (1.0);
545  }
546 
547 
548  template<class INDEX>
549  double scaled_jacobian_metric(INDEX idx) const
550  {
551  return (0.0);
552  }
553 
554  template<class INDEX>
555  double jacobian_metric(INDEX idx) const
556  {
557  return (0.0);
558  }
559 
560  template<class INDEX>
562  {
563  return (0.0);
564  }
565 
566  /// Find closest node
567  /// Loop over all nodes to see which is the closest
568  template <class INDEX>
569  bool locate_node(INDEX &node, const Core::Geometry::Point &p) const
570  {
571  /// If there are no nodes, we cannot find a closest one
572  typename Node::size_type sz; size(sz);
573  if (sz == 0) return (false);
574 
575  /// Check accuracity of first guess if we have any
576  if (node >= 0 && node < sz)
577  {
578  /// Estimate is close enough and thence continue as we found the
579  /// closest point within an epsilon uncertainty
580  if ((p-points_[node]).length2() < epsilon2_) return (true);
581  }
582 
584  "PointCloudMesh::locate_node requires synchronize(NODE_LOCATE_E).")
585 
586  // get grid sizes
587  const size_type ni = grid_->get_ni()-1;
588  const size_type nj = grid_->get_nj()-1;
589  const size_type nk = grid_->get_nk()-1;
590 
591  // Convert to grid coordinates.
592  index_type bi, bj, bk, ei, ej, ek;
593  grid_->unsafe_locate(bi, bj, bk, p);
594 
595  // Clamp to closest point on the grid.
596  if (bi > ni) bi =ni; if (bi < 0) bi = 0;
597  if (bj > nj) bj =nj; if (bj < 0) bj = 0;
598  if (bk > nk) bk =nk; if (bk < 0) bk = 0;
599 
600  ei = bi;
601  ej = bj;
602  ek = bk;
603 
604  double dmin = DBL_MAX;
605  bool found = true;
606  do
607  {
608  found = true;
609  /// We need to do a full shell without any elements that are closer
610  /// to make sure there no closer elements in neighboring searchgrid cells
611 
612  for (index_type i = bi; i <= ei; i++)
613  {
614  if (i < 0 || i > ni) continue;
615  for (index_type j = bj; j <= ej; j++)
616  {
617  if (j < 0 || j > nj) continue;
618  for (index_type k = bk; k <= ek; k++)
619  {
620  if (k < 0 || k > nk) continue;
621  if (i == bi || i == ei || j == bj || j == ej || k == bk || k == ek)
622  {
623  if (grid_->min_distance_squared(p, i, j, k) < dmin)
624  {
625  found = false;
627  grid_->lookup_ijk(it, eit, i, j, k);
628 
629  while (it != eit)
630  {
631  const Core::Geometry::Point point = points_[*it];
632  const double dist = (p-point).length2();
633 
634  if (dist < dmin)
635  {
636  node = INDEX(*it);
637  dmin = dist;
638 
639  if (dist < epsilon2_) return (true);
640  }
641  ++it;
642  }
643  }
644  }
645  }
646  }
647  }
648  bi--;ei++;
649  bj--;ej++;
650  bk--;ek++;
651  }
652  while ((!found)||(dmin == DBL_MAX)) ;
653 
654  return (true);
655  }
656 
657  /// Find whether we are inside the element
658  /// If we find an element we return true
659  template <class INDEX>
660  bool locate_elem(INDEX &idx, const Core::Geometry::Point &p) const
661  {
662  typename Elem::size_type sz; size(sz);
663 
664  /// Check whether the estimate given in idx is the point we are looking for
665  if (idx >= 0 && idx < sz)
666  {
667  if ((p - points_[idx]).length2() < epsilon2_) return (true);
668  }
669 
671  "PointCloudMesh::locate requires synchronize(ELEM_LOCATE_E).")
672 
673  typename SearchGridT<index_type>::iterator it, eit;
674  if (grid_->lookup(it, eit, p))
675  {
676  while (it != eit)
677  {
678  if ((points_[*it]-p).length2() < epsilon2_)
679  {
680  idx = static_cast<INDEX>(*it);
681  return (true);
682  }
683  ++it;
684  }
685  }
686 
687  return (false);
688  }
689 
690  template <class ARRAY>
691  inline bool locate_elems(ARRAY &array, const Core::Geometry::BBox &b) const
692  {
693 
695  "PointCloudMesh::locate_elems requires synchronize(ELEM_LOCATE_E).")
696 
697  array.clear();
698  index_type is,js,ks;
699  index_type ie,je,ke;
700  grid_->locate_clamp(is,js,ks,b.min());
701  grid_->locate_clamp(ie,je,ke,b.max());
702  for (index_type i=is; i<=ie;i++)
703  for (index_type j=js; j<je;j++)
704  for (index_type k=ks; k<ke; k++)
705  {
706  typename SearchGridT<index_type>::iterator it, eit;
707  grid_->lookup_ijk(it, eit, i, j, k);
708  while (it != eit)
709  {
710  size_t p=0;
711  for (;p<array.size();p++) if (array[p] == typename ARRAY::value_type(*it)) break;
712  if (p == array.size()) array.push_back(typename ARRAY::value_type(*it));
713  ++it;
714  }
715  }
716 
717  return (array.size() > 0);
718  }
719 
720 
721 
722  template <class INDEX>
723  bool find_closest_node(double& pdist, Core::Geometry::Point& result,
724  INDEX &node, const Core::Geometry::Point &p) const
725  {
726  return(find_closest_node(pdist,result,node,p,-1.0));
727  }
728 
729 
730  /// Closest node and the location
731  template <class INDEX>
732  bool find_closest_node(double& pdist, Core::Geometry::Point& result,
733  INDEX &node, const Core::Geometry::Point &p, double maxdist) const
734  {
735  if (maxdist < 0.0) maxdist = DBL_MAX; else maxdist = maxdist*maxdist;
736  typename Node::size_type sz; size(sz);
737 
738  /// If there are no nodes we cannot find the closest one
739  if(sz == 0) return (false);
740 
741  if (node >= 0 && node < sz)
742  {
743  double dist = (p-points_[node]).length2();
744  if (dist < epsilon2_)
745  {
746  result = p;
747  pdist = sqrt(dist);
748  return (true);
749  }
750  }
751 
753  "PointCloudMesh::find_closest_node requires synchronize(NODE_LOCATE_E).")
754 
755  // get grid sizes
756  const size_type ni = grid_->get_ni()-1;
757  const size_type nj = grid_->get_nj()-1;
758  const size_type nk = grid_->get_nk()-1;
759 
760  // Convert to grid coordinates.
761  index_type bi, bj, bk, ei, ej, ek;
762  grid_->unsafe_locate(bi, bj, bk, p);
763 
764  // Clamp to closest point on the grid.
765  if (bi > ni) bi = ni; if (bi < 0) bi = 0;
766  if (bj > nj) bj = nj; if (bj < 0) bj = 0;
767  if (bk > nk) bk = nk; if (bk < 0) bk = 0;
768 
769  ei = bi; ej = bj; ek = bk;
770 
771  double dmin = maxdist;
772  bool found = true;
773  bool found_one = false;
774  do
775  {
776  found = true;
777  /// This looks incorrect - but it is correct
778  /// We need to do a full shell without any elements that are closer
779  /// to make sure there no closer elements in neighboring searchgrid cells
780 
781  for (index_type i = bi; i <= ei; i++)
782  {
783  if (i < 0 || i > ni) continue;
784  for (index_type j = bj; j <= ej; j++)
785  {
786  if (j < 0 || j > nj) continue;
787  for (index_type k = bk; k <= ek; k++)
788  {
789  if (k < 0 || k > nk) continue;
790  if (i == bi || i == ei || j == bj || j == ej || k == bk || k == ek)
791  {
792  if (grid_->min_distance_squared(p, i, j, k) < dmin)
793  {
794  found = false;
795  typename SearchGridT<index_type>::iterator it, eit;
796  grid_->lookup_ijk(it, eit, i, j, k);
797 
798  while (it != eit)
799  {
800  const Core::Geometry::Point point = points_[*it];
801  const double dist = (p-point).length2();
802 
803  if (dist < dmin)
804  {
805  found_one = true;
806  result = point;
807  node = INDEX(*it);
808  dmin = dist;
809 
810  /// If we are closer than eps^2 we found a node close enough
811  if (dmin < epsilon2_)
812  {
813  pdist = sqrt(dmin);
814  return (true);
815  }
816  }
817 
818  ++it;
819  }
820  }
821  }
822  }
823  }
824  }
825  bi--;ei++;
826  bj--;ej++;
827  bk--;ek++;
828  }
829  while (!found) ;
830 
831  if (!found_one) return (false);
832  pdist = sqrt(dmin);
833  return (true);
834  }
835 
836 
837  template <class ARRAY>
838  bool find_closest_nodes(ARRAY &nodes, const Core::Geometry::Point &p, double maxdist) const
839  {
840  nodes.clear();
841 
843  "PointCloudMesh::find_closest_node requires synchronize(NODE_LOCATE_E).")
844 
845  // get grid sizes
846  const size_type ni = grid_->get_ni()-1;
847  const size_type nj = grid_->get_nj()-1;
848  const size_type nk = grid_->get_nk()-1;
849 
850  // Convert to grid coordinates.
851  index_type bi, bj, bk, ei, ej, ek;
852 
853  Core::Geometry::Point max = p+Core::Geometry::Vector(maxdist,maxdist,maxdist);
854  Core::Geometry::Point min = p+Core::Geometry::Vector(-maxdist,-maxdist,-maxdist);
855 
856  grid_->unsafe_locate(bi, bj, bk, min);
857  grid_->unsafe_locate(ei, ej, ek, max);
858 
859  // Clamp to closest point on the grid.
860  if (bi > ni) bi = ni; if (bi < 0) bi = 0;
861  if (bj > nj) bj = nj; if (bj < 0) bj = 0;
862  if (bk > nk) bk = nk; if (bk < 0) bk = 0;
863 
864  if (ei > ni) ei = ni; if (ei < 0) ei = 0;
865  if (ej > nj) ej = nj; if (ej < 0) ej = 0;
866  if (ek > nk) ek = nk; if (ek < 0) ek = 0;
867 
868  double maxdist2 = maxdist*maxdist;
869 
870  for (index_type i = bi; i <= ei; i++)
871  {
872  for (index_type j = bj; j <= ej; j++)
873  {
874  for (index_type k = bk; k <= ek; k++)
875  {
876  if (grid_->min_distance_squared(p, i, j, k) < maxdist2)
877  {
878  typename SearchGridT<index_type>::iterator it, eit;
879  grid_->lookup_ijk(it, eit, i, j, k);
880 
881  while (it != eit)
882  {
883  const Core::Geometry::Point point = points_[*it];
884  const double dist = (p-point).length2();
885 
886  if (dist < maxdist2)
887  {
888  nodes.push_back(*it);
889  }
890  ++it;
891  }
892  }
893  }
894  }
895  }
896 
897  return(nodes.size() > 0);
898  }
899 
900 
901  template <class ARRAY1, class ARRAY2>
902  bool find_closest_nodes(ARRAY1 &distances, ARRAY2 &nodes, const Core::Geometry::Point &p, double maxdist) const
903  {
904  nodes.clear();
905  distances.clear();
906 
908  "PointCloudMesh::find_closest_node requires synchronize(NODE_LOCATE_E).")
909 
910  // get grid sizes
911  const size_type ni = grid_->get_ni()-1;
912  const size_type nj = grid_->get_nj()-1;
913  const size_type nk = grid_->get_nk()-1;
914 
915  // Convert to grid coordinates.
916  index_type bi, bj, bk, ei, ej, ek;
917 
918  Core::Geometry::Point max = p+Core::Geometry::Vector(maxdist,maxdist,maxdist);
919  Core::Geometry::Point min = p+Core::Geometry::Vector(-maxdist,-maxdist,-maxdist);
920 
921  grid_->unsafe_locate(bi, bj, bk, min);
922  grid_->unsafe_locate(ei, ej, ek, max);
923 
924  // Clamp to closest point on the grid.
925  if (bi > ni) bi = ni; if (bi < 0) bi = 0;
926  if (bj > nj) bj = nj; if (bj < 0) bj = 0;
927  if (bk > nk) bk = nk; if (bk < 0) bk = 0;
928 
929  if (ei > ni) ei = ni; if (ei < 0) ei = 0;
930  if (ej > nj) ej = nj; if (ej < 0) ej = 0;
931  if (ek > nk) ek = nk; if (ek < 0) ek = 0;
932 
933  double maxdist2 = maxdist*maxdist;
934 
935  for (index_type i = bi; i <= ei; i++)
936  {
937  for (index_type j = bj; j <= ej; j++)
938  {
939  for (index_type k = bk; k <= ek; k++)
940  {
941  if (grid_->min_distance_squared(p, i, j, k) < maxdist2)
942  {
943  typename SearchGridT<index_type>::iterator it, eit;
944  grid_->lookup_ijk(it, eit, i, j, k);
945 
946  while (it != eit)
947  {
948  const Core::Geometry::Point point = points_[*it];
949  const double dist = (p-point).length2();
950 
951  if (dist < maxdist2)
952  {
953  nodes.push_back(*it);
954  distances.push_back(dist);
955  }
956  ++it;
957  }
958  }
959  }
960  }
961  }
962 
963  return(nodes.size() > 0);
964  }
965 
966 
967  template <class INDEX, class ARRAY>
968  bool find_closest_elem(double& pdist,
969  Core::Geometry::Point& result,
970  ARRAY& coords,
971  INDEX &elem,
972  const Core::Geometry::Point &p) const
973  {
974  return (find_closest_elem(pdist,result,coords,elem,p,-1.0));
975  }
976 
977 
978  template <class INDEX, class ARRAY>
979  bool find_closest_elem(double& pdist,
980  Core::Geometry::Point& result,
981  ARRAY& coords,
982  INDEX &elem,
983  const Core::Geometry::Point &p,
984  double maxdist) const
985  {
986  if (maxdist < 0.0) maxdist = DBL_MAX; else maxdist = maxdist*maxdist;
987 
988  coords.resize(0);
989  typename Elem::size_type sz; size(sz);
990 
991  /// If there are no nodes we cannot find the closest one
992  if(sz == 0) return (false);
993 
994  if (elem >= 0 && elem < sz)
995  {
996  double dist = (p-points_[elem]).length2();
997  if (dist < epsilon2_)
998  {
999  result = p;
1000  pdist = sqrt(dist);
1001  return (true);
1002  }
1003  }
1004 
1006  "PointCloudMesh::find_closest_elem requires synchronize(ELEM_LOCATE_E).")
1007 
1008  // get grid sizes
1009  const size_type ni = grid_->get_ni()-1;
1010  const size_type nj = grid_->get_nj()-1;
1011  const size_type nk = grid_->get_nk()-1;
1012 
1013  // Convert to grid coordinates.
1014  index_type bi, ei, bj, ej, bk, ek;
1015  grid_->unsafe_locate(bi, bj, bk, p);
1016 
1017  // Clamp to closest point on the grid.
1018  if (bi > ni) bi = ni; if (bi < 0) bi = 0;
1019  if (bj > nj) bj = nj; if (bj < 0) bj = 0;
1020  if (bk > nk) bk = nk; if (bk < 0) bk = 0;
1021 
1022  ei = bi; ej = bj; ek = bk;
1023 
1024  double dmin = maxdist;
1025  bool found = true;
1026  bool found_one = false;
1027 
1028  do
1029  {
1030  found = true;
1031  /// We need to do a full shell without any elements that are closer
1032  /// to make sure there no closer elements in neighboring searchgrid cells
1033  for (index_type i = bi; i <= ei; i++)
1034  {
1035  if (i < 0 || i > ni) continue;
1036  for (index_type j = bj; j <= ej; j++)
1037  {
1038  if (j < 0 || j > nj) continue;
1039  for (index_type k = bk; k <= ek; k++)
1040  {
1041  if (k < 0 || k > nk) continue;
1042  if (i == bi || i == ei || j == bj || j == ej || k == bk || k == ek)
1043  {
1044  if (grid_->min_distance_squared(p, i, j, k) < dmin)
1045  {
1046  found = false;
1047  typename SearchGridT<index_type>::iterator it, eit;
1048  grid_->lookup_ijk(it,eit, i, j, k);
1049 
1050  while (it != eit)
1051  {
1052  const Core::Geometry::Point point = points_[*it];
1053  const double dist = (p-point).length2();
1054 
1055  if (dist < dmin)
1056  {
1057  found_one = true;
1058  result = point;
1059  elem = INDEX(*it);
1060  dmin = dist;
1061 
1062  /// If we are closer than eps^2 we found a node close enough
1063  if (dmin < epsilon2_)
1064  {
1065  pdist = sqrt(dmin);
1066  return( true );
1067  }
1068  }
1069 
1070  ++it;
1071  }
1072  }
1073  }
1074  }
1075  }
1076  }
1077  bi--;ei++;
1078  bj--;ej++;
1079  bk--;ek++;
1080  }
1081  while (!found) ;
1082 
1083  if (!found_one) return (false);
1084 
1085  pdist = sqrt(dmin);
1086  return (true);
1087  }
1088 
1089  template <class INDEX>
1090  bool find_closest_elem(double& pdist,
1091  Core::Geometry::Point &result,
1092  INDEX &elem,
1093  const Core::Geometry::Point &p) const
1094  {
1095  StackVector<double,1> coords;
1096  return(find_closest_elem(pdist,result,coords,elem,p,-1.0));
1097  }
1098 
1099  template <class ARRAY>
1100  bool find_closest_elems(double& pdist, Core::Geometry::Point& result,
1101  ARRAY &elems, const Core::Geometry::Point &p) const
1102  {
1103  typename Elem::size_type sz; size(sz);
1104  if (sz == 0) return (false);
1105 
1106  elems.clear();
1107 
1108  // Walking the grid like this works really well if we're near the
1109  // surface. It's degenerately bad if for example the point is
1110  // placed in the center of a sphere (because then we still have to
1111  // test all the faces, but with the grid overhead and triangle
1112  // duplication as well).
1114  "PointCloudMesh::find_closest_elems requires synchronize(ELEM_LOCATE_E).")
1115 
1116  // get grid sizes
1117  const size_type ni = grid_->get_ni()-1;
1118  const size_type nj = grid_->get_nj()-1;
1119  const size_type nk = grid_->get_nk()-1;
1120 
1121  // Convert to grid coordinates.
1122  index_type bi, ei, bj, ej, bk, ek;
1123  grid_->unsafe_locate(bi, bj, bk, p);
1124 
1125  // Clamp to closest point on the grid.
1126  if (bi > ni) bi = ni; if (bi < 0) bi = 0;
1127  if (bj > nj) bj = nj; if (bj < 0) bj = 0;
1128  if (bk > nk) bk = nk; if (bk < 0) bk = 0;
1129 
1130  ei = bi; ej = bj; ek = bk;
1131 
1132  double dmin = DBL_MAX;
1133 
1134  bool found;
1135  do
1136  {
1137  found = true;
1138  /// This looks incorrect - but it is correct
1139  /// We need to do a full shell without any elements that are closer
1140  /// to make sure there no closer elements
1141  for (index_type i = bi; i <= ei; i++)
1142  {
1143  if (i < 0 || i > ni) continue;
1144  for (index_type j = bj; j <= ej; j++)
1145  {
1146  if (j < 0 || j > nj) continue;
1147  for (index_type k = bk; k <= ek; k++)
1148  {
1149  if (k < 0 || k > nk) continue;
1150  if (i == bi || i == ei || j == bj || j == ej || k == bk || k == ek)
1151  {
1152  if (grid_->min_distance_squared(p, i, j, k) < dmin)
1153  {
1154  found = false;
1155  typename SearchGridT<index_type>::iterator it, eit;
1156  grid_->lookup_ijk(it,eit, i, j, k);
1157 
1158  while (it != eit)
1159  {
1160  Core::Geometry::Point point = points_[*it];
1161  const double dist = (p - point).length2();
1162 
1163  if (dist < dmin - epsilon2_)
1164  {
1165  elems.clear();
1166  result = point;
1167  elems.push_back(typename ARRAY::value_type(*it));
1168  found = false;
1169  dmin = dist;
1170  }
1171  else if (dist < dmin + epsilon2_)
1172  {
1173  elems.push_back(typename ARRAY::value_type(*it));
1174  }
1175  ++it;
1176  }
1177  }
1178  }
1179  }
1180  }
1181  }
1182  bi--;ei++;
1183  bj--;ej++;
1184  bk--;ek++;
1185  }
1186  while ((!found)||(dmin == DBL_MAX)) ;
1187 
1188  pdist = sqrt(dmin);
1189  return (true);
1190  }
1191 
1192 
1193  double get_epsilon() const
1194  { return (epsilon_); }
1195 
1196  /// Export this class using the old Pio system
1197  virtual void io(Piostream&);
1198 
1199  ///////////////////////////////////////////////////
1200  // STATIC VARIABLES AND FUNCTIONS
1201 
1202  /// These IDs are created as soon as this class will be instantiated
1204  /// Core functionality for getting the name of a templated mesh class
1205  static const std::string type_name(int n = -1);
1206  virtual std::string dynamic_type_name() const { return pointcloud_typeid.type; }
1207 
1208  /// Type description, used for finding names of the mesh class for
1209  /// dynamic compilation purposes. Some of this should be obsolete
1210  virtual const TypeDescription *get_type_description() const;
1211  static const TypeDescription* node_type_description();
1212  static const TypeDescription* edge_type_description();
1213  static const TypeDescription* face_type_description();
1214  static const TypeDescription* cell_type_description();
1216  { return node_type_description(); }
1217 
1218  /// This function returns a maker for Pio.
1219  static Persistent *maker() { return new PointCloudMesh(); }
1220  /// This function returns a handle for the virtual interface.
1221  static MeshHandle mesh_maker() { return boost::make_shared<PointCloudMesh>(); }
1222 
1223 protected:
1224  template <class ARRAY, class INDEX>
1225  void get_nodes_from_elem(ARRAY nodes,INDEX idx)
1226  {
1227  nodes.resize(1); nodes[0] = idx;
1228  }
1229 
1230  template <class ARRAY, class INDEX>
1231  void get_edges_from_elem(ARRAY edges,INDEX idx)
1232  {
1233  edges.resize(0);
1234  }
1235 
1236  template <class ARRAY, class INDEX>
1237  inline void set_nodes_by_elem(ARRAY &array, INDEX idx)
1238  {
1239  }
1240 
1241 protected:
1244 
1245  void insert_elem_into_grid(typename Elem::index_type ci);
1246  void remove_elem_from_grid(typename Elem::index_type ci);
1247 
1248 
1249  /// the nodes
1250  std::vector<Core::Geometry::Point> points_;
1251 
1252  /// basis fns
1253  Basis basis_;
1254 
1255  boost::shared_ptr<SearchGridT<index_type> > grid_;
1256 
1257  /// Record which parts of the mesh are synchronized
1259  /// Lock to synchronize between threads
1261 
1262  double epsilon_;
1263  double epsilon2_;
1264 
1265  /// Virtual interface
1266  boost::shared_ptr<VMesh> vmesh_;
1267 
1268 }; // end class PointCloudMesh
1269 
1270 
1271 template<class Basis>
1273  synchronized_(ALL_ELEMENTS_E),
1274  synchronize_lock_("PointCloudMesh Lock"),
1275  epsilon_(0.0),
1276  epsilon2_(0.0)
1277 {
1278  DEBUG_CONSTRUCTOR("PointCloudMesh")
1279  /// Initialize the virtual interface when the mesh is created
1280  vmesh_.reset(CreateVPointCloudMesh(this));
1281 }
1282 
1283 template<class Basis>
1285  Mesh(copy),
1286  points_(copy.points_),
1287  basis_(copy.basis_),
1288  synchronized_(copy.synchronized_),
1289  synchronize_lock_("PointCloudMesh Lock")
1290 {
1291  DEBUG_CONSTRUCTOR("PointCloudMesh")
1292 
1293  PointCloudMesh &lcopy = (PointCloudMesh &)copy;
1294 
1295  /// We need to lock before we can copy these as these
1296  /// structures are generate dynamically when they are
1297  /// needed.
1298  lcopy.synchronize_lock_.lock();
1299 
1300  // Copy element grid
1302  if (copy.grid_)
1303  {
1304  grid_.reset(new SearchGridT<index_type>(*copy.grid_));
1305  }
1306 
1307  synchronized_ |= copy.synchronized_ & Mesh::LOCATE_E;
1308  synchronized_ |= copy.synchronized_ & Mesh::EPSILON_E;
1309 
1310  // Make sure we got the synchronized version
1311  epsilon_ = copy.epsilon_;
1312  epsilon2_ = copy.epsilon2_;
1313 
1314  lcopy.synchronize_lock_.unlock();
1315 
1316  /// Create a new virtual interface for this copy
1317  /// all pointers have changed hence create a new
1318  /// virtual interface class
1319  vmesh_.reset(CreateVPointCloudMesh(this));
1320 }
1321 
1322 template<class Basis>
1324 {
1325  DEBUG_DESTRUCTOR("PointCloudMesh")
1326 }
1327 
1328 
1329 
1330 
1331 template <class Basis>
1333 PointCloudMesh<Basis>::pointcloud_typeid(type_name(-1), "Mesh",
1335 
1336 
1337 template <class Basis>
1340 {
1341  Core::Geometry::BBox result;
1342 
1343  typename Node::iterator i, ie;
1344  begin(i);
1345  end(ie);
1346 
1347  while (i != ie)
1348  {
1349  result.extend(points_[*i]);
1350  ++i;
1351  }
1352 
1353  // Make sure we have a bounding box
1354  if (points_.size() == 1)
1355  {
1356  result.extend(points_[0]);
1357  result.extend(1e-5);
1358  }
1359 
1360  return result;
1361 }
1362 
1363 template <class Basis>
1364 void
1366 {
1367  t.load_identity();
1368  Core::Geometry::BBox bbox = get_bounding_box();
1369  t.pre_scale(bbox.diagonal());
1371 }
1372 
1373 template <class Basis>
1374 void
1376 {
1377  synchronize_lock_.lock();
1378 
1379  std::vector<Core::Geometry::Point>::iterator itr = points_.begin();
1380  std::vector<Core::Geometry::Point>::iterator eitr = points_.end();
1381  while (itr != eitr)
1382  {
1383  *itr = t.project(*itr);
1384  ++itr;
1385  }
1386 
1387  if (grid_) { grid_->transform(t); }
1388 
1389  synchronize_lock_.unlock();
1390 }
1391 
1392 
1393 template <class Basis>
1394 int
1396  typename Node::array_type &l,
1397  double *w)
1398 {
1399  typename Node::index_type idx;
1400  if (locate(idx, p))
1401  {
1402  l.resize(1);
1403  l[0] = idx;
1404  w[0] = 1.0;
1405  return 1;
1406  }
1407  return 0;
1408 }
1409 
1410 
1411 template <class Basis>
1414 {
1415  points_.push_back(p);
1416  return points_.size() - 1;
1417 }
1418 
1419 
1420 #define PointCloudFieldMESH_VERSION 2
1421 
1422 template <class Basis>
1423 void
1425 {
1426  int version = stream.begin_class(type_name(-1), PointCloudFieldMESH_VERSION);
1427 
1428  Mesh::io(stream);
1429 
1430  // IO data members, in order
1431  Pio(stream, points_);
1432 
1433  if (version >= 2) {
1434  basis_.io(stream);
1435  }
1436 
1437  stream.end_class();
1438 
1439  if (stream.reading())
1440  vmesh_.reset(CreateVPointCloudMesh(this));
1441 }
1442 
1443 
1444 template <class Basis>
1445 const std::string
1447 {
1448  ASSERT((n >= -1) && n <= 1);
1449  if (n == -1)
1450  {
1451  static const std::string name = TypeNameGenerator::make_template_id(type_name(0), type_name(1));
1452  return name;
1453  }
1454  else if (n == 0)
1455  {
1456  static const std::string nm("PointCloudMesh");
1457  return nm;
1458  }
1459  else
1460  {
1461  return find_type_name((Basis *)0);
1462  }
1463 }
1464 
1465 
1466 template <class Basis>
1467 void
1469 {
1470  itr = 0;
1471 }
1472 
1473 
1474 template <class Basis>
1475 void
1477 {
1478  itr = static_cast<index_type>(points_.size());
1479 }
1480 
1481 
1482 template <class Basis>
1483 void
1485 {
1486  s = static_cast<index_type>(points_.size());
1487 }
1488 
1489 
1490 template <class Basis>
1491 void
1493 {
1494  ASSERTFAIL("This mesh type does not have edges use \"elem\".");
1495 }
1496 
1497 
1498 template <class Basis>
1499 void
1501 {
1502  ASSERTFAIL("This mesh type does not have edges use \"elem\".");
1503 }
1504 
1505 
1506 template <class Basis>
1507 void
1509 {
1510  ASSERTFAIL("This mesh type does not have edges use \"elem\".");
1511 }
1512 
1513 
1514 template <class Basis>
1515 void
1517 {
1518  ASSERTFAIL("This mesh type does not have faces use \"elem\".");
1519 }
1520 
1521 
1522 template <class Basis>
1523 void
1525 {
1526  ASSERTFAIL("This mesh type does not have faces use \"elem\".");
1527 }
1528 
1529 
1530 template <class Basis>
1531 void
1533 {
1534  ASSERTFAIL("This mesh type does not have faces use \"elem\".");
1535 }
1536 
1537 
1538 template <class Basis>
1539 void
1541 {
1542  ASSERTFAIL("This mesh type does not have cells use \"elem\".");
1543 }
1544 
1545 
1546 template <class Basis>
1547 void
1549 {
1550  ASSERTFAIL("This mesh type does not have cells use \"elem\".");
1551 }
1552 
1553 
1554 template <class Basis>
1555 void
1557 {
1558  ASSERTFAIL("This mesh type does not have cells use \"elem\".");
1559 }
1560 
1561 
1562 template<class Basis>
1563 bool
1565 {
1566  synchronize_lock_.lock();
1568  ( !(synchronized_ & Mesh::LOCATE_E) ||
1569  !(synchronized_ & Mesh::EPSILON_E) ))
1570  {
1571  /// These computations share the evalution of the bounding box
1572  Core::Geometry::BBox bb = get_bounding_box();
1573 
1574  /// Compute the epsilon for geometrical closeness comparisons
1575  /// Mainly used by the grid lookup tables
1576  if (sync & (Mesh::EPSILON_E|Mesh::LOCATE_E|Mesh::FIND_CLOSEST_E) &&
1577  !(synchronized_ & Mesh::EPSILON_E))
1578  {
1579  compute_epsilon(bb);
1580  }
1581 
1582  /// Table for finding nodes in space
1583  if (sync & (Mesh::LOCATE_E|Mesh::FIND_CLOSEST_E) &&
1584  !(synchronized_ & Mesh::LOCATE_E))
1585  {
1586  compute_grid(bb);
1587  }
1588  }
1589 
1590  synchronize_lock_.unlock();
1591 
1592  return(true);
1593 }
1594 
1595 template<class Basis>
1596 bool
1598 {
1599  synchronize_lock_.lock();
1600  if (sync & Mesh::EPSILON_E) synchronized_ &= ~(Mesh::EPSILON_E);
1601  // No object to synchronize, hence always will succeed
1602  synchronize_lock_.unlock();
1603  return(true);
1604 }
1605 
1606 
1607 template <class Basis>
1608 bool
1610 {
1611  synchronize_lock_.lock();
1612  // Undo marking the synchronization
1613  synchronized_ = Mesh::NODES_E | Mesh::ELEMS_E;
1614 
1615  // Free memory where possible
1616  grid_.reset();
1617 
1618  synchronize_lock_.unlock();
1619  return (true);
1620 }
1621 
1622 template <class Basis>
1623 void
1625 {
1626  /// @todo: This can crash if you insert a new cell outside of the grid.
1627  // Need to recompute grid at that point.
1628  grid_->insert(ni,points_[ni]);
1629 }
1630 
1631 
1632 template <class Basis>
1633 void
1635 {
1636  grid_->remove(ni,points_[ni]);
1637 }
1638 
1639 template <class Basis>
1640 void
1642 {
1643  if (bb.valid())
1644  {
1645  // Cubed root of number of cells to get a subdivision ballpark.
1646 
1647  typename Elem::size_type esz; size(esz);
1648 
1649  const size_type s =
1650  3*static_cast<size_type>((ceil(pow(static_cast<double>(esz) , (1.0/3.0))))/2.0 + 1.0);
1651 
1652  Core::Geometry::Vector diag = bb.diagonal();
1653  double trace = (diag.x()+diag.y()+diag.z());
1654  size_type sx = static_cast<size_type>(ceil(0.5+diag.x()/trace*s));
1655  size_type sy = static_cast<size_type>(ceil(0.5+diag.y()/trace*s));
1656  size_type sz = static_cast<size_type>(ceil(0.5+diag.z()/trace*s));
1657 
1658  Core::Geometry::BBox b = bb; b.extend(10*epsilon_);
1659  grid_.reset(new SearchGridT<index_type>(sx, sy, sz, b.min(), b.max()));
1660 
1661  typename Elem::iterator ci, cie;
1662  begin(ci); end(cie);
1663  while(ci != cie)
1664  {
1665  insert_elem_into_grid(*ci);
1666  ++ci;
1667  }
1668  }
1669  else
1670  {
1671  grid_.reset(new SearchGridT<index_type>(1,1,1,Core::Geometry::Point(0,0,0.0,0.0),Core::Geometry::Point(1.0,1.0,1.0)));
1672  }
1673 
1674  synchronized_ |= Mesh::LOCATE_E;
1675 }
1676 
1677 
1678 template<class Basis>
1679 void
1681 {
1682  bb = get_bounding_box();
1683  epsilon_ = bb.diagonal().length()*1e-8;
1684  epsilon2_ = epsilon_*epsilon_;
1685 }
1686 
1687 
1688 template <class Basis>
1689 const TypeDescription*
1691 {
1692  static TypeDescription *td = 0;
1693  if (!td)
1694  {
1695  const TypeDescription *sub = get_type_description((Basis*)0);
1697  (*subs)[0] = sub;
1698  td = new TypeDescription("PointCloudMesh", subs,
1699  std::string(__FILE__),
1700  "SCIRun",
1702  }
1703  return td;
1704 }
1705 
1706 
1707 template <class Basis>
1708 const TypeDescription*
1710 {
1712 }
1713 
1714 
1715 template <class Basis>
1716 const TypeDescription*
1718 {
1719  static TypeDescription *td = 0;
1720  if (!td)
1721  {
1722  const TypeDescription *me =
1724  td = new TypeDescription(me->get_name() + "::Node",
1725  std::string(__FILE__),
1726  "SCIRun",
1728  }
1729  return td;
1730 }
1731 
1732 
1733 template <class Basis>
1734 const TypeDescription*
1736 {
1737  static TypeDescription *td = 0;
1738  if (!td)
1739  {
1740  const TypeDescription *me =
1742  td = new TypeDescription(me->get_name() + "::Edge",
1743  std::string(__FILE__),
1744  "SCIRun",
1746  }
1747  return td;
1748 }
1749 
1750 
1751 template <class Basis>
1752 const TypeDescription*
1754 {
1755  static TypeDescription *td = 0;
1756  if (!td)
1757  {
1758  const TypeDescription *me =
1760  td = new TypeDescription(me->get_name() + "::Face",
1761  std::string(__FILE__),
1762  "SCIRun",
1764  }
1765  return td;
1766 }
1767 
1768 
1769 template <class Basis>
1770 const TypeDescription*
1772 {
1773  static TypeDescription *td = 0;
1774  if (!td)
1775  {
1776  const TypeDescription *me =
1778  td = new TypeDescription(me->get_name() + "::Cell",
1779  std::string(__FILE__),
1780  "SCIRun",
1782  }
1783  return td;
1784 }
1785 
1786 } // namespace SCIRun
1787 
1788 #endif
int get_weights(const Core::Geometry::Point &, typename Edge::array_type &, double *)
Definition: PointCloudMesh.h:429
double get_volume(typename Cell::index_type) const
Definition: PointCloudMesh.h:393
bool locate(typename Face::index_type &, const Core::Geometry::Point &) const
Definition: PointCloudMesh.h:417
Interface to statically allocated std::vector class.
index_type node0_index() const
Definition: PointCloudMesh.h:153
Definition: PointCloudMesh.h:124
void insert_elem_into_grid(typename Elem::index_type ci)
Definition: PointCloudMesh.h:1624
double det_jacobian(const VECTOR &coords, INDEX idx) const
Definition: PointCloudMesh.h:506
void get_elems(typename Elem::array_type &, typename Face::index_type) const
Definition: PointCloudMesh.h:335
bool find_closest_elem(double &pdist, Core::Geometry::Point &result, ARRAY &coords, INDEX &elem, const Core::Geometry::Point &p) const
Definition: PointCloudMesh.h:968
bool reading() const
Definition: Persistent.h:164
Distinct type for node FieldIterator.
Definition: FieldIterator.h:89
void get_edges_from_elem(ARRAY edges, INDEX idx)
Definition: PointCloudMesh.h:1231
virtual std::string dynamic_type_name() const
Definition: PointCloudMesh.h:1206
void get_edges(typename Edge::array_type &, typename Cell::index_type) const
Definition: PointCloudMesh.h:293
std::vector< index_type > array_type
Definition: PointCloudMesh.h:128
Definition: FieldRNG.h:37
virtual VMesh * vmesh()
Access point to virtual interface.
Definition: PointCloudMesh.h:186
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
void get_normal(Core::Geometry::Vector &, VECTOR &, typename Elem::index_type, unsigned int) const
Definition: PointCloudMesh.h:448
void get_edges(typename Edge::array_type &, typename Edge::index_type) const
Definition: PointCloudMesh.h:287
PointCloudMesh< Basis >::index_type index_type
Definition: PointCloudMesh.h:145
Definition: Mesh.h:85
Vector project(const Vector &p) const
Definition: Transform.cc:425
EdgeIterator< under_type > iterator
Definition: PointCloudMesh.h:112
Definition: Mesh.h:64
Point max() const
Definition: BBox.h:195
double epsilon_
Definition: PointCloudMesh.h:1262
virtual bool has_normals() const
Has this mesh normals.
Definition: PointCloudMesh.h:223
#define ASSERTMSG(condition, message)
Definition: Exception.h:113
void pwl_approx_edge(VECTOR &, typename Elem::index_type, unsigned int, unsigned int) const
Definition: PointCloudMesh.h:358
Node::index_type add_node(const Core::Geometry::Point &p)
use these to build up a new PointCloudField mesh
Definition: PointCloudMesh.h:452
bool find_closest_nodes(ARRAY &nodes, const Core::Geometry::Point &p, double maxdist) const
Definition: PointCloudMesh.h:838
NodeIndex< under_type > index_type
Definition: PointCloudMesh.h:104
double get_length(typename Edge::index_type) const
Definition: PointCloudMesh.h:391
Definition: Mesh.h:90
double get_size(typename Face::index_type) const
Definition: PointCloudMesh.h:389
Definition: Persistent.h:89
void pre_scale(const Vector &)
Definition: Transform.cc:193
std::vector< index_type > array_type
Definition: PointCloudMesh.h:114
void get_delems(typename DElem::array_type &, typename Face::index_type) const
Definition: PointCloudMesh.h:348
SCIRun::index_type index_type
Definition: PointCloudMesh.h:95
virtual void get_canonical_transform(Core::Geometry::Transform &t) const
Definition: PointCloudMesh.h:1365
FaceIndex< under_type > size_type
Definition: PointCloudMesh.h:120
void jacobian(const VECTOR &coords, INDEX idx, double *J) const
Definition: PointCloudMesh.h:515
Definition: Persistent.h:187
void get_center(Core::Geometry::Point &, typename Edge::index_type) const
Definition: PointCloudMesh.h:379
BBox & extend(const Point &p)
Expand the bounding box to include point p.
Definition: BBox.h:98
void set_point(const Core::Geometry::Point &p, typename Node::index_type i)
Definition: PointCloudMesh.h:439
Definition: TypeDescription.h:50
virtual bool is_editable() const
Check whether mesh can be altered by adding nodes or elements.
Definition: PointCloudMesh.h:220
Definition: PointCloudMesh.h:63
Index and Iterator types required for Mesh Concept.
Definition: PointCloudMesh.h:103
FieldHandle mesh()
Definition: BuildTDCSMatrixTests.cc:56
Definition: Mesh.h:84
void resize_elems(size_t s)
Definition: PointCloudMesh.h:464
Definition: Point.h:49
Definition: TypeDescription.h:45
#define SCISHARE
Definition: share.h:39
std::vector< const TypeDescription * > td_vec
Definition: TypeDescription.h:56
Basis basis_type
Definition: PointCloudMesh.h:100
bool find_closest_node(double &pdist, Core::Geometry::Point &result, INDEX &node, const Core::Geometry::Point &p, double maxdist) const
Closest node and the location.
Definition: PointCloudMesh.h:732
void size(typename Node::size_type &) const
Get the iteration sizes.
Definition: PointCloudMesh.h:1484
Definition: Mesh.h:45
Basis basis_
basis fns
Definition: PointCloudMesh.h:1253
Definition: BBox.h:46
boost::shared_ptr< Mesh > MeshHandle
Definition: DatatypeFwd.h:67
Definition: Mutex.h:43
void get_nodes_from_elem(ARRAY nodes, INDEX idx)
Definition: PointCloudMesh.h:1225
Distinct type for cell Iterator.
Definition: FieldIterator.h:134
bool locate(typename Node::index_type &n, ARRAY &coords, const Core::Geometry::Point &p) const
Definition: PointCloudMesh.h:423
unsigned int mask_type
Definition: Types.h:45
void get_faces(typename Face::array_type &, typename Cell::index_type) const
Definition: PointCloudMesh.h:306
double inverse_jacobian(const VECTOR &, INDEX, double *Ji) const
Definition: PointCloudMesh.h:532
#define ASSERT(condition)
Definition: Assert.h:110
bool clear_synchronization()
Definition: PointCloudMesh.h:1609
StackVector< index_type, 1 > array_type
Definition: PointCloudMesh.h:107
virtual const TypeDescription * get_type_description() const
Definition: PointCloudMesh.h:1709
const Core::Geometry::Point & node0() const
Definition: PointCloudMesh.h:159
void get_edges(typename Edge::array_type &, typename Face::index_type) const
Definition: PointCloudMesh.h:290
void get_delems(typename DElem::array_type &, typename Edge::index_type) const
Definition: PointCloudMesh.h:345
virtual int begin_class(const std::string &name, int current_version)
Definition: Persistent.cc:143
FaceIterator< under_type > iterator
Definition: PointCloudMesh.h:119
void elem_reserve(size_t s)
Definition: PointCloudMesh.h:462
Definition: Vector.h:63
Core::Thread::Mutex synchronize_lock_
Lock to synchronize between threads.
Definition: PointCloudMesh.h:1260
void get_center(Core::Geometry::Point &, typename Face::index_type) const
Definition: PointCloudMesh.h:381
void get_center(Core::Geometry::Point &, typename Cell::index_type) const
Definition: PointCloudMesh.h:383
const string find_type_name(float *)
Definition: TypeName.cc:63
std::vector< index_type > array_type
Definition: PointCloudMesh.h:121
ElemData(const PointCloudMesh< Basis > &msh, const index_type ind)
Definition: PointCloudMesh.h:147
void get_elems(typename Elem::array_type &result, typename Node::index_type idx) const
get the parent element(s) of the given index
Definition: PointCloudMesh.h:325
void node_reserve(size_t s)
Definition: PointCloudMesh.h:461
bool valid() const
Definition: BBox.h:93
double scaled_jacobian_metric(INDEX idx) const
Definition: PointCloudMesh.h:549
std::vector< Core::Geometry::Point > points_
the nodes
Definition: PointCloudMesh.h:1250
bool get_coords(VECTOR &coords, const Core::Geometry::Point &, INDEX) const
Definition: PointCloudMesh.h:475
bool get_neighbor(typename Elem::index_type &, typename Elem::index_type, typename DElem::index_type) const
Definition: PointCloudMesh.h:400
Definition: Mesh.h:86
bool locate_elem(INDEX &idx, const Core::Geometry::Point &p) const
Definition: PointCloudMesh.h:660
virtual void io(Piostream &)
Export this class using the old Pio system.
Definition: PointCloudMesh.h:1424
double jacobian_metric(INDEX idx) const
Definition: PointCloudMesh.h:555
void begin(typename Node::iterator &) const
begin/end iterators
Definition: PointCloudMesh.h:1468
void pwl_approx_face(VECTOR &, typename Elem::index_type, unsigned int, unsigned int) const
Definition: PointCloudMesh.h:367
Definition: VMeshShared.h:40
Definition: ParallelLinearAlgebraTests.cc:358
friend class VPointCloudMesh
Make sure the virtual interface has access.
Definition: PointCloudMesh.h:89
Node Elem
Definition: PointCloudMesh.h:134
virtual int dimensionality() const
Topological dimension.
Definition: PointCloudMesh.h:201
void end(typename Node::iterator &) const
Definition: PointCloudMesh.h:1476
Definition: SearchGridT.h:47
const char * name[]
Definition: BoostGraphExampleTests.cc:87
void get_delems(typename DElem::array_type &, typename Node::index_type) const
Definition: PointCloudMesh.h:342
Basis & get_basis()
Get the basis class.
Definition: PointCloudMesh.h:232
long long size_type
Definition: Types.h:40
double get_size(typename Node::array_type &) const
Definition: PointCloudMesh.h:395
bool find_closest_nodes(ARRAY1 &distances, ARRAY2 &nodes, const Core::Geometry::Point &p, double maxdist) const
Definition: PointCloudMesh.h:902
Definition: StackVector.h:50
Node::index_type add_point(const Core::Geometry::Point &p)
Definition: PointCloudMesh.h:1413
bool find_closest_node(double &pdist, Core::Geometry::Point &result, INDEX &node, const Core::Geometry::Point &p) const
Definition: PointCloudMesh.h:723
virtual bool unsynchronize(mask_type sync)
Definition: PointCloudMesh.h:1597
Definition: Mesh.h:71
virtual int basis_order()
Definition: PointCloudMesh.h:195
void get_cells(typename Cell::array_type &, typename Node::index_type) const
Definition: PointCloudMesh.h:310
double get_area(typename Face::index_type) const
Definition: PointCloudMesh.h:392
Vector diagonal() const
Definition: BBox.h:198
void get_elems(typename Elem::array_type &, typename Cell::index_type) const
Definition: PointCloudMesh.h:338
void compute_epsilon(Core::Geometry::BBox &bb)
Definition: PointCloudMesh.h:1680
Persistent i/o for STL containers.
std::vector< INDEX >::iterator iterator
Definition: SearchGridT.h:53
std::string type
Definition: Persistent.h:72
VMesh * CreateVPointCloudMesh(MESH *)
Definition: PointCloudMesh.h:70
bool find_closest_elem(double &pdist, Core::Geometry::Point &result, ARRAY &coords, INDEX &elem, const Core::Geometry::Point &p, double maxdist) const
Definition: PointCloudMesh.h:979
static PersistentTypeID pointcloud_typeid
These IDs are created as soon as this class will be instantiated.
Definition: PointCloudMesh.h:1203
virtual ~PointCloudMesh()
Destructor.
Definition: PointCloudMesh.h:1323
Point min() const
Definition: BBox.h:192
Distinct type for face index.
Definition: FieldIndex.h:90
Definition: Mesh.h:62
void compute_grid(Core::Geometry::BBox &bb)
Definition: PointCloudMesh.h:1641
Definition: Transform.h:53
void get_cells(typename Cell::array_type &, typename Edge::index_type) const
Definition: PointCloudMesh.h:313
void remove_elem_from_grid(typename Elem::index_type ci)
Definition: PointCloudMesh.h:1634
virtual Core::Geometry::BBox get_bounding_box() const
Get the bounding box of the field.
Definition: PointCloudMesh.h:1339
void set_nodes_by_elem(ARRAY &array, INDEX idx)
Definition: PointCloudMesh.h:1237
void x(double)
Definition: Vector.h:175
CellIndex< under_type > index_type
Definition: PointCloudMesh.h:125
void get_normal(Core::Geometry::Vector &, typename Node::index_type) const
Definition: PointCloudMesh.h:445
void get_center(Core::Geometry::Point &p, typename Node::index_type i) const
get the center point (in object space) of an element
Definition: PointCloudMesh.h:377
void to_index(typename Face::index_type &index, index_type i) const
Definition: PointCloudMesh.h:260
void get_edges(typename Edge::array_type &, typename Node::index_type) const
Definition: PointCloudMesh.h:284
void get_faces(typename Face::array_type &, typename Edge::index_type) const
Definition: PointCloudMesh.h:300
virtual bool synchronize(mask_type sync)
Definition: PointCloudMesh.h:1564
int get_weights(const Core::Geometry::Point &, typename Face::array_type &, double *)
Definition: PointCloudMesh.h:431
static const TypeDescription * face_type_description()
Definition: PointCloudMesh.h:1753
static const std::string make_template_id(const std::string &templateName, const std::string &templateParam)
Definition: TypeName.h:62
bool locate(typename Node::index_type &n, const Core::Geometry::Point &p) const
Locate a point in a mesh, find which is the closest node.
Definition: PointCloudMesh.h:413
bool locate(typename Edge::index_type &, const Core::Geometry::Point &) const
Definition: PointCloudMesh.h:415
void pre_translate(const Vector &)
Definition: Transform.cc:278
SCIRun::index_type under_type
Definition: PointCloudMesh.h:94
double epsilon2_
Definition: PointCloudMesh.h:1263
int get_weights(const Core::Geometry::Point &, typename Cell::array_type &, double *)
Definition: PointCloudMesh.h:433
PointCloudMesh()
Construct a new mesh.
Definition: PointCloudMesh.h:1272
void y(double)
Definition: Vector.h:185
void get_faces(typename Face::array_type &, typename Face::index_type) const
Definition: PointCloudMesh.h:303
static const TypeDescription * cell_type_description()
Definition: PointCloudMesh.h:1771
Distinct type for edge Iterator.
Definition: FieldIterator.h:105
Definition: Mesh.h:75
#define ASSERTFAIL(string)
Definition: Assert.h:52
SCIRun::size_type size_type
Definition: PointCloudMesh.h:96
void Pio(Piostream &stream, Array1< T > &array)
Definition: Array1.h:65
FaceIndex< under_type > index_type
Definition: PointCloudMesh.h:118
Some convenient simple iterators for fields.
bool locate_node(INDEX &node, const Core::Geometry::Point &p) const
Definition: PointCloudMesh.h:569
SCIRun::mask_type mask_type
Definition: PointCloudMesh.h:97
void get_neighbors(std::vector< typename Node::index_type > &array, typename Node::index_type) const
Definition: PointCloudMesh.h:404
void get_nodes(typename Node::array_type &, typename Face::index_type) const
Definition: PointCloudMesh.h:276
double length() const
Definition: Vector.h:365
virtual void end_class()
Definition: Persistent.cc:178
CellIndex< under_type > size_type
Definition: PointCloudMesh.h:127
double get_size(typename Edge::index_type) const
Definition: PointCloudMesh.h:388
virtual PointCloudMesh * clone() const
Definition: PointCloudMesh.h:180
bool get_neighbors(std::vector< typename Elem::index_type > &array, typename Elem::index_type, typename DElem::index_type) const
Definition: PointCloudMesh.h:407
double get_epsilon() const
Definition: PointCloudMesh.h:1193
#define PointCloudFieldMESH_VERSION
Definition: PointCloudMesh.h:1420
long long index_type
Definition: Types.h:39
Definition: Mesh.h:83
NodeIterator< under_type > iterator
Definition: PointCloudMesh.h:105
void resize_nodes(size_t s)
Definition: PointCloudMesh.h:463
void resize(size_t size, const value_type &val=value_type())
Definition: StackVector.h:61
Definition: PointCloudMesh.h:142
void interpolate(Core::Geometry::Point &pt, const VECTOR &, INDEX idx) const
Definition: PointCloudMesh.h:485
Definition: PointCloudMesh.h:117
NodeIndex< under_type > size_type
Definition: PointCloudMesh.h:106
void get_nodes(typename Node::array_type &a, typename Node::index_type i) const
Definition: PointCloudMesh.h:270
static const TypeDescription * edge_type_description()
Definition: PointCloudMesh.h:1735
void reset()
Definition: BBox.h:95
Definition: Persistent.h:64
Node DElem
Definition: PointCloudMesh.h:135
void get_cells(typename Cell::array_type &, typename Cell::index_type) const
Definition: PointCloudMesh.h:319
Distinct type for edge index.
Definition: FieldIndex.h:81
void to_index(typename Edge::index_type &index, index_type i) const
Definition: PointCloudMesh.h:258
int n
Definition: eab.py:9
bool find_closest_elems(double &pdist, Core::Geometry::Point &result, ARRAY &elems, const Core::Geometry::Point &p) const
Definition: PointCloudMesh.h:1100
void get_nodes(typename Node::array_type &, typename Cell::index_type) const
Definition: PointCloudMesh.h:279
virtual void transform(const Core::Geometry::Transform &t)
Core::Geometry::Transform a field (transform all nodes using this transformation matrix) ...
Definition: PointCloudMesh.h:1375
static const std::string type_name(int n=-1)
Core functionality for getting the name of a templated mesh class.
Definition: PointCloudMesh.h:1446
EdgeIndex< under_type > size_type
Definition: PointCloudMesh.h:113
void get_nodes(typename Node::array_type &, typename Edge::index_type) const
Definition: PointCloudMesh.h:273
double get_size(typename Node::index_type) const
Get the size of an elemnt (length, area, volume)
Definition: PointCloudMesh.h:387
double get_size(typename Cell::index_type) const
Definition: PointCloudMesh.h:390
double inscribed_circumscribed_radius_metric(INDEX idx) const
Definition: PointCloudMesh.h:561
#define DEBUG_CONSTRUCTOR(type)
Definition: Debug.h:64
void derivate(const VECTOR1 &, INDEX, VECTOR2 &J) const
Definition: PointCloudMesh.h:494
void io(Piostream &stream)
Persistent I/O.
Definition: Mesh.cc:387
EdgeIndex< under_type > index_type
Definition: PointCloudMesh.h:111
mask_type synchronized_
Record which parts of the mesh are synchronized.
Definition: PointCloudMesh.h:1258
bool locate_elems(ARRAY &array, const Core::Geometry::BBox &b) const
Definition: PointCloudMesh.h:691
static const TypeDescription * node_type_description()
Definition: PointCloudMesh.h:1717
boost::shared_ptr< VMesh > vmesh_
Virtual interface.
Definition: PointCloudMesh.h:1266
Definition: PointCloudMesh.h:110
virtual int topology_geometry() const
Definition: PointCloudMesh.h:206
bool locate(typename Cell::index_type &, const Core::Geometry::Point &) const
Definition: PointCloudMesh.h:419
void to_index(typename Node::index_type &index, index_type i) const
Definition: PointCloudMesh.h:256
void z(double)
Definition: Vector.h:195
void get_point(Core::Geometry::Point &p, typename Node::index_type i) const
Definition: PointCloudMesh.h:437
void get_random_point(Core::Geometry::Point &p, const typename Elem::index_type i, FieldRNG &) const
Definition: PointCloudMesh.h:441
boost::shared_ptr< MeshFacade< VMesh > > MeshFacadeHandle
Definition: MeshTraits.h:61
int get_weights(const Core::Geometry::Point &p, typename Node::array_type &l, double *w)
Definition: PointCloudMesh.h:1395
CellIterator< under_type > iterator
Definition: PointCloudMesh.h:126
Definition: VMesh.h:53
static MeshHandle mesh_maker()
This function returns a handle for the virtual interface.
Definition: PointCloudMesh.h:1221
void get_cells(typename Cell::array_type &, typename Face::index_type) const
Definition: PointCloudMesh.h:316
Elem::index_type add_elem(ARRAY a)
Definition: PointCloudMesh.h:456
boost::shared_ptr< PointCloudMesh< Basis > > handle_type
Definition: PointCloudMesh.h:99
void to_index(typename Cell::index_type &index, index_type i) const
Definition: PointCloudMesh.h:262
static Persistent * maker()
This function returns a maker for Pio.
Definition: PointCloudMesh.h:1219
void get_elems(typename Elem::array_type &, typename Edge::index_type) const
Definition: PointCloudMesh.h:332
virtual MeshFacadeHandle getFacade() const
Definition: PointCloudMesh.h:188
boost::shared_ptr< SearchGridT< index_type > > grid_
Definition: PointCloudMesh.h:1255
static const TypeDescription * elem_type_description()
Definition: PointCloudMesh.h:1215
int size
Definition: eabLatVolData.py:2
bool find_closest_elem(double &pdist, Core::Geometry::Point &result, INDEX &elem, const Core::Geometry::Point &p) const
Definition: PointCloudMesh.h:1090
void get_faces(typename Face::array_type &, typename Node::index_type) const
Definition: PointCloudMesh.h:297
#define DEBUG_DESTRUCTOR(type)
Definition: Debug.h:65
void get_delems(typename DElem::array_type &, typename Cell::index_type) const
Definition: PointCloudMesh.h:351
const TypeDescription * get_type_description(Core::Basis::ConstantBasis< T > *)
Definition: Constant.h:209