SCIRun  5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ScanlineMesh.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 
30 ///
31 ///@file ScanlineMesh.h
32 ///@brief Templated Mesh defined on a 3D Regular Grid
33 ///
34 ///@author
35 /// Michael Callahan
36 /// Department of Computer Science
37 /// University of Utah
38 ///@date January 2001
39 ///
40 
41 
42 
43 #ifndef CORE_DATATYPES_SCANLINEMESH_H
44 #define CORE_DATATYPES_SCANLINEMESH_H 1
45 
46 /// Include what kind of support we want to have
47 /// Need to fix this and couple it sci-defs
49 
51 
52 #include <Core/Basis/Locate.h>
54 
58 
64 
66 
67 namespace SCIRun {
68 
69 /////////////////////////////////////////////////////
70 // Declarations for virtual interface
71 
72 
73 /// Functions for creating the virtual interface
74 /// Declare the functions that instantiate the virtual interface
75 template <class Basis>
77 
78 /// make sure any other mesh other than the preinstantiate ones
79 /// returns no virtual interface. Altering this behavior will allow
80 /// for dynamically compiling the interface if needed.
81 template<class MESH>
82 VMesh* CreateVScanlineMesh(MESH* mesh) { return (0); }
83 
84 /// These declarations are needed for a combined dynamic compilation as
85 /// as well as virtual functions solution.
86 /// Declare that these can be found in a library that is already
87 /// precompiled. So dynamic compilation will not instantiate them again.
88 
89 #if (SCIRUN_SCANLINE_SUPPORT > 0)
90 
91 SCISHARE VMesh* CreateVScanlineMesh(ScanlineMesh<Core::Basis::CrvLinearLgn<Core::Geometry::Point> >* mesh);
92 
93 #endif
94 /////////////////////////////////////////////////////
95 
96 
97 template <class Basis>
98 class ScanlineMesh : public Mesh
99 {
100 
101 /// Make sure the virtual interface has access
102 template <class MESH> friend class VScanlineMesh;
103 
104 public:
105 
106  // Types that change depending on 32 or 64bits
111 
112  typedef boost::shared_ptr<ScanlineMesh<Basis> > handle_type;
113  typedef Basis basis_type;
114 
115  /// Index and Iterator types required for Mesh Concept.
116  struct Node {
121  };
122 
123  struct Edge {
127  typedef std::vector<index_type> array_type;
128  };
129 
130  struct Face {
134  typedef std::vector<index_type> array_type;
135  };
136 
137  struct Cell {
141  typedef std::vector<index_type> array_type;
142  };
143 
144  typedef Edge Elem;
145  typedef Node DElem;
146 
147  friend class ElemData;
148 
149  class ElemData
150  {
151  public:
153 
155  const typename Elem::index_type ind) :
156  mesh_(msh),
157  index_(ind)
158  {}
159 
160  // the following designed to coordinate with ::get_nodes
161  inline
163  {
164  return (index_);
165  }
166  inline
168  {
169  return (index_ + 1);
170  }
171 
172 
173  // the following designed to coordinate with ::get_edges
174  inline
176  {
177  return index_;
178  }
179 
180  inline
182  {
183  Core::Geometry::Point p(index_, 0.0, 0.0);
184  return mesh_.transform_.project(p);
185  }
186  inline
188  {
189  Core::Geometry::Point p(index_ + 1, 0.0, 0.0);
190  return mesh_.transform_.project(p);
191  }
192 
193  private:
194  const ScanlineMesh<Basis> &mesh_;
195  const index_type index_;
196  };
197 
198  ScanlineMesh() : min_i_(0), ni_(0)
199  {
200  DEBUG_CONSTRUCTOR("ScanlineMesh")
201 
202  vmesh_.reset(CreateVScanlineMesh(this));
203  compute_jacobian();
204  }
205 
208  : min_i_(offset), ni_(nx), transform_(mh->transform_)
209  {
210  DEBUG_CONSTRUCTOR("ScanlineMesh")
211 
212  /// Create a new virtual interface for this copy
213  /// all pointers have changed hence create a new
214  /// virtual interface class
215  vmesh_.reset(CreateVScanlineMesh(this));
216 
217  compute_jacobian();
218  }
220  : Mesh(copy),
221  min_i_(copy.get_min_i()), ni_(copy.get_ni()),
222  transform_(copy.transform_)
223  {
224  DEBUG_CONSTRUCTOR("ScanlineMesh")
225 
226  /// Create a new virtual interface for this copy
227  /// all pointers have changed hence create a new
228  /// virtual interface class
229  vmesh_.reset(CreateVScanlineMesh(this));
230 
231  compute_jacobian();
232  }
233  virtual ScanlineMesh *clone() const { return new ScanlineMesh(*this); }
234  virtual ~ScanlineMesh()
235  {
236  DEBUG_DESTRUCTOR("ScanlineMesh")
237  }
238 
239  /// Access point to virtual interface
240  virtual VMesh* vmesh() { return (vmesh_.get()); }
241 
242  virtual MeshFacadeHandle getFacade() const
243  {
244  return boost::make_shared<Core::Datatypes::VirtualMeshFacade<VMesh>>(vmesh_);
245  }
246 
247  virtual int basis_order() { return basis_.polynomial_order(); }
248 
249  virtual bool has_normals() const { return false; }
250  virtual bool has_face_normals() const { return false; }
251  virtual bool is_editable() const { return false; }
252 
253  /// get the mesh statistics
254  index_type get_min_i() const { return min_i_; }
255  bool get_min(std::vector<index_type>&) const;
256  size_type get_ni() const { return ni_; }
257  virtual bool get_dim(std::vector<size_type>&) const;
259  virtual Core::Geometry::BBox get_bounding_box() const;
260  virtual void transform(const Core::Geometry::Transform &t);
262 
263  /// set the mesh statistics
264  void set_min_i(index_type i) {min_i_ = i; }
265  void set_min(std::vector<index_type> mins);
267  {
268  ni_ = i;
269 
270  /// Create a new virtual interface for this copy
271  /// all pointers have changed hence create a new
272  /// virtual interface class
273  vmesh_.reset(CreateVScanlineMesh(this));
274  }
275  virtual void set_dim(std::vector<size_type> dims);
276 
277  void begin(typename Node::iterator &) const;
278  void begin(typename Edge::iterator &) const;
279  void begin(typename Face::iterator &) const;
280  void begin(typename Cell::iterator &) const;
281 
282  void end(typename Node::iterator &) const;
283  void end(typename Edge::iterator &) const;
284  void end(typename Face::iterator &) const;
285  void end(typename Cell::iterator &) const;
286 
287  void size(typename Node::size_type &) const;
288  void size(typename Edge::size_type &) const;
289  void size(typename Face::size_type &) const;
290  void size(typename Cell::size_type &) const;
291 
292  void to_index(typename Node::index_type &index, index_type i) const
293  { index = i; }
294  void to_index(typename Edge::index_type &index, index_type i) const
295  { index = i; }
296  void to_index(typename Face::index_type &, index_type) const
297  { ASSERTFAIL("This mesh type does not have faces use \"elem\"."); }
298  void to_index(typename Cell::index_type &, index_type) const
299  { ASSERTFAIL("This mesh type does not have cells use \"elem\"."); }
300 
301  /// get the child elements of the given index
302  void get_nodes(typename Node::array_type &, typename Edge::index_type) const;
303  void get_nodes(typename Node::array_type &, typename Face::index_type) const
304  { ASSERTFAIL("This mesh type does not have faces use \"elem\"."); }
305  void get_nodes(typename Node::array_type &, typename Cell::index_type) const
306  { ASSERTFAIL("This mesh type does not have cells use \"elem\"."); }
307  void get_edges(typename Edge::array_type &, typename Edge::index_type) const
308  {}
309  void get_edges(typename Edge::array_type &, typename Face::index_type) const
310  { ASSERTFAIL("This mesh type does not have faces use \"elem\"."); }
311  void get_edges(typename Edge::array_type &, typename Cell::index_type) const
312  { ASSERTFAIL("This mesh type does not have cells use \"elem\"."); }
313 
314  //Stub, used by ShowField.
315  void get_faces(typename Face::array_type &, typename Elem::index_type) const
316  {}
317 
318  /// get the parent element(s) of the given index
319  void get_elems(typename Elem::array_type &result,
320  typename Node::index_type idx) const;
321  void get_elems(typename Elem::array_type&,
322  typename Edge::index_type) const {}
323  void get_elems(typename Elem::array_type&,
324  typename Face::index_type) const {}
325 
326  /// Wrapper to get the derivative elements from this element.
327  void get_delems(typename DElem::array_type &result,
328  typename Elem::index_type idx) const
329  {
330  get_nodes(result, idx);
331  }
332 
333  /// Get the size of an elemnt (length, area, volume)
334  double get_size(typename Node::index_type) const { return 0.0; }
335  double get_size(typename Edge::index_type idx) const
336  {
337  typename Node::array_type ra;
338  get_nodes(ra,idx);
339  Core::Geometry::Point p0,p1;
340  get_point(p0,ra[0]);
341  get_point(p1,ra[1]);
342  return (p0-p1).length();
343  }
344  double get_size(typename Face::index_type) const
345  { ASSERTFAIL("This mesh type does not have faces use \"elem\"."); }
346  double get_size(typename Cell::index_type) const
347  { ASSERTFAIL("This mesh type does not have cells use \"elem\"."); }
348  double get_length(typename Edge::index_type idx) const
349  { return get_size(idx); }
350  double get_area(typename Face::index_type idx) const
351  { return get_size(idx); }
352  double get_volume(typename Cell::index_type) const
353  { ASSERTFAIL("This mesh type does not have cells use \"elem\"."); }
354 
355  int get_valence(typename Node::index_type idx) const
356  { return (idx == 0 || idx == ni_ - 1) ? 1 : 2; }
357  int get_valence(typename Edge::index_type) const { return 0; }
358  int get_valence(typename Face::index_type) const
359  { ASSERTFAIL("This mesh type does not have faces use \"elem\"."); }
360  int get_valence(typename Cell::index_type) const
361  { ASSERTFAIL("This mesh type does not have cells use \"elem\"."); }
362 
363  /// get the center point (in object space) of an element
364  void get_center(Core::Geometry::Point &, typename Node::index_type) const;
365  void get_center(Core::Geometry::Point &, typename Edge::index_type) const;
367  { ASSERTFAIL("This mesh type does not have faces use \"elem\"."); }
369  { ASSERTFAIL("This mesh type does not have cells use \"elem\"."); }
370 
371  bool locate(typename Node::index_type &, const Core::Geometry::Point &) const;
372  bool locate(typename Edge::index_type &, const Core::Geometry::Point &) const;
373  bool locate(typename Face::index_type &, const Core::Geometry::Point &) const
374  { ASSERTFAIL("This mesh type does not have faces use \"elem\"."); }
375  bool locate(typename Cell::index_type &, const Core::Geometry::Point &) const
376  { ASSERTFAIL("This mesh type does not have cells use \"elem\"."); }
377 
378  bool locate(typename Elem::index_type&, std::vector<double>& coords,
379  const Core::Geometry::Point &) const;
380 
381  int get_weights(const Core::Geometry::Point &p, typename Node::array_type &l, double *w);
382  int get_weights(const Core::Geometry::Point &p, typename Edge::array_type &l, double *w);
383  int get_weights(const Core::Geometry::Point & , typename Face::array_type & , double * )
384  { ASSERTFAIL("This mesh type does not have faces use \"elem\"."); }
385  int get_weights(const Core::Geometry::Point & , typename Cell::array_type & , double * )
386  { ASSERTFAIL("This mesh type does not have cells use \"elem\"."); }
387 
388  void get_random_point(Core::Geometry::Point &p, typename Elem::index_type i, FieldRNG &rng) const;
389 
390  void get_point(Core::Geometry::Point &p, typename Node::index_type i) const { get_center(p, i); }
392  { ASSERTFAIL("This mesh type does not have node normals."); }
393  void get_normal(Core::Geometry::Vector &, std::vector<double> &, typename Elem::index_type,
394  unsigned int)
395  { ASSERTFAIL("This mesh type does not have element normals."); }
396 
397 
398 
399  // Unsafe due to non-constness of unproject.
402  { transform_ = trans; compute_jacobian(); return transform_; }
403 
404  virtual int dimensionality() const { return 1; }
405  virtual int topology_geometry() const { return (Mesh::STRUCTURED | Mesh::REGULAR); }
406  Basis& get_basis() { return basis_; }
407 
408  /// Generate the list of points that make up a sufficiently accurate
409  /// piecewise linear approximation of an edge.
410  void pwl_approx_edge(std::vector<std::vector<double> > &coords,
411  typename Elem::index_type /*ci*/,
412  unsigned int,
413  unsigned int div_per_unit) const
414  {
415  // Needs to match unit_edges in Basis/QuadBilinearLgn.cc
416  // compare get_nodes order to the basis order
417  basis_.approx_edge(0, div_per_unit, coords);
418  }
419 
420  /// Generate the list of points that make up a sufficiently accurate
421  /// piecewise linear approximation of an face.
422  void pwl_approx_face(std::vector<std::vector<std::vector<double> > >& /*coords*/,
423  typename Elem::index_type /*ci*/,
424  typename Face::index_type /*fi*/,
425  unsigned int /*div_per_unit*/) const
426  {
427  ASSERTFAIL("ScanlineMesh has no faces");
428  }
429 
430  /// Synchronize functions, as there is nothing to synchronize, these
431  /// functions always succeed
432 
433  virtual bool synchronize(mask_type /*sync*/) { return (true); }
434  virtual bool unsynchronize(mask_type /*sync*/) { return (true); }
435  bool clear_synchronization() { return (true); }
436 
437  /// Get the local coordinates for a certain point within an element
438  /// This function uses a couple of newton iterations to find the local
439  /// coordinate of a point
440  template<class VECTOR>
441  bool get_coords(VECTOR &coords, const Core::Geometry::Point &p, typename Elem::index_type idx) const
442  {
443  // If polynomial order is larger, use the complicated HO basis implementation
444  // Since this is a latvol and most probably linear, this function is to expensive
445  if (basis_.polynomial_order() > 1)
446  {
447  ElemData ed(*this, idx);
448  return (basis_.get_coords(coords, p, ed));
449  }
450 
451  // Cheap implementation that assumes it is a regular grid
452  // This implementation should be faster then the interpolate of the linear
453  // basis which needs to work as well for the unstructured hexvol :(
455 
456  coords.resize(1);
457  coords[0] = static_cast<typename VECTOR::value_type>(r.x()-static_cast<double>(idx));
458 
459  if (static_cast<double>(coords[0]) < 0.0) if (static_cast<double>(coords[0]) > -(1e-8))
460  coords[0] = static_cast<typename VECTOR::value_type>(0.0); else return (false);
461  if (static_cast<double>(coords[0]) > 1.0) if (static_cast<double>(coords[0]) < 1.0+(1e-8))
462  coords[0] = static_cast<typename VECTOR::value_type>(1.0); else return (false);
463 
464  return (true);
465  }
466 
467  /// Find the location in the global coordinate system for a local coordinate
468  /// This function is the opposite of get_coords.
469  template<class VECTOR>
470  void interpolate(Core::Geometry::Point &pt, const VECTOR &coords, typename Elem::index_type idx) const
471  {
472  // only makes sense for higher order
473  if (basis_.polynomial_order() > 1)
474  {
475  ElemData ed(*this, idx);
476  pt = basis_.interpolate(coords, ed);
477  return;
478  }
479 
480  Core::Geometry::Point p(static_cast<double>(idx)+static_cast<double>(coords[0]),0.0,0.0);
481  pt = transform_.project(p);
482  }
483 
484  /// Interpolate the derivate of the function, This infact will return the
485  /// jacobian of the local to global coordinate transformation. This function
486  /// is mainly intended for the non linear elements
487  template<class VECTOR1, class VECTOR2>
488  void derivate(const VECTOR1 &coords, typename Elem::index_type idx, VECTOR2 &J) const
489  {
490  // only makes sense for higher order
491  if (basis_.polynomial_order() > 1)
492  {
493  ElemData ed(*this, idx);
494  basis_.derivate(coords, ed, J);
495  return;
496  }
497 
498  // Cheaper implementation
499  J.resize(1);
500  J[0] = transform_.project(Core::Geometry::Point(1.0,0.0,0.0));
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>
506  double det_jacobian(const VECTOR& coords,
507  typename Elem::index_type idx) const
508  {
509  if (basis_.polynomial_order() > 1)
510  {
511  double J[9];
512  jacobian(coords,idx,J);
513  return (DetMatrix3x3(J));
514  }
515 
516  return (det_jacobian_);
517  }
518 
519  /// Get the jacobian of the transformation. In case one wants the non inverted
520  /// version of this matrix. This is currentl here for completeness of the
521  /// interface
522  template<class VECTOR>
523  void jacobian(const VECTOR& coords, typename Elem::index_type idx, double* J) const
524  {
525  if (basis_.polynomial_order() > 1)
526  {
528  ElemData ed(*this,idx);
529  basis_.derivate(coords,ed,Jv);
530  Core::Geometry::Vector Jv1, Jv2;
531  Core::Geometry::Vector(Jv[0]).find_orthogonal(Jv1,Jv2);
532  J[0] = Jv[0].x();
533  J[1] = Jv[0].y();
534  J[2] = Jv[0].z();
535  J[3] = Jv1.x();
536  J[4] = Jv1.y();
537  J[5] = Jv1.z();
538  J[6] = Jv2.x();
539  J[7] = Jv2.y();
540  J[8] = Jv2.z();
541 
542  return;
543  }
544 
545  J[0] = jacobian_[0];
546  J[1] = jacobian_[1];
547  J[2] = jacobian_[2];
548  J[3] = jacobian_[3];
549  J[4] = jacobian_[4];
550  J[5] = jacobian_[5];
551  J[6] = jacobian_[6];
552  J[7] = jacobian_[7];
553  J[8] = jacobian_[8];
554  }
555 
556  /// Get the inverse jacobian of the transformation. This one is needed to
557  /// translate local gradients into global gradients. Hence it is crucial for
558  /// calculating gradients of fields, or constructing finite elements.
559  template<class VECTOR>
560  double inverse_jacobian(const VECTOR& coords, typename Elem::index_type idx, double* Ji) const
561  {
562  if (basis_.polynomial_order() > 1)
563  {
565  ElemData ed(*this,idx);
566  basis_.derivate(coords,ed,Jv);
567  double J[9];
568  Core::Geometry::Vector Jv1, Jv2;
569  Core::Geometry::Vector(Jv[0]).find_orthogonal(Jv1,Jv2);
570  J[0] = Jv[0].x();
571  J[1] = Jv[0].y();
572  J[2] = Jv[0].z();
573  J[3] = Jv1.x();
574  J[4] = Jv1.y();
575  J[5] = Jv1.z();
576  J[6] = Jv2.x();
577  J[7] = Jv2.y();
578  J[8] = Jv2.z();
579 
580  return (InverseMatrix3x3(J,Ji));
581  }
582 
583  Ji[0] = inverse_jacobian_[0];
584  Ji[1] = inverse_jacobian_[1];
585  Ji[2] = inverse_jacobian_[2];
586  Ji[3] = inverse_jacobian_[3];
587  Ji[4] = inverse_jacobian_[4];
588  Ji[5] = inverse_jacobian_[5];
589  Ji[6] = inverse_jacobian_[6];
590  Ji[7] = inverse_jacobian_[7];
591  Ji[8] = inverse_jacobian_[8];
592 
593  return (det_inverse_jacobian_);
594  }
595 
596  double scaled_jacobian_metric(typename Elem::index_type /*idx*/) const
597  { return (scaled_jacobian_); }
598 
599  double jacobian_metric(typename Elem::index_type /*idx*/) const
600  { return (det_jacobian_); }
601 
602 
603  double get_epsilon() const;
604 
605  /// Export this class using the old Pio system
606  virtual void io(Piostream&);
607  /// These IDs are created as soon as this class will be instantiated
608  /// The first one is for Pio and the second for the virtual interface
609  /// These are currently different as they serve different needs.
611  /// Core functionality for getting the name of a templated mesh class
612  static const std::string type_name(int n = -1);
613  virtual std::string dynamic_type_name() const { return scanline_typeid.type; }
614 
615  /// Type description, used for finding names of the mesh class for
616  /// dynamic compilation purposes. Some of this should be obsolete
617  virtual const TypeDescription *get_type_description() const;
618  static const TypeDescription* node_type_description();
619  static const TypeDescription* edge_type_description();
620  static const TypeDescription* face_type_description();
621  static const TypeDescription* cell_type_description();
623  { return edge_type_description(); }
624 
625  /// This function returns a maker for Pio.
626  static Persistent *maker() { return new ScanlineMesh(); }
627  /// This function returns a handle for the virtual interface.
628  static MeshHandle mesh_maker() { return boost::make_shared<ScanlineMesh>(); }
629  /// This function returns a handle for the virtual interface.
631  {
632  return boost::make_shared<ScanlineMesh>(x,min,max);
633  }
634 
635  /// This function will find the closest element and the location on that
636  /// element that is the closest
637  template <class INDEX>
638  bool
639  find_closest_node(double& pdist, Core::Geometry::Point &result,
640  INDEX &node, const Core::Geometry::Point &p, double maxdist) const
641  {
642  bool ret = find_closest_node(pdist,result,node,p);
643  if (!ret) return (false);
644  if (maxdist < 0.0 || pdist < maxdist) return (true);
645  return (false);
646  }
647 
648  /// This function will find the closest element and the location on that
649  /// element that is the closest
650  template <class INDEX>
651  bool
652  find_closest_node(double& pdist, Core::Geometry::Point &result,
653  INDEX &node, const Core::Geometry::Point &p) const
654  {
655  /// If there are no elements, we cannot find the closest
656  if (ni_ == 0) return (false);
657 
659 
660  double rx = floor(r.x() + 0.5);
661  const double nii = static_cast<double>(ni_-1);
662 
663  if (rx < 0.0) rx = 0.0; if (rx > nii) rx = nii;
664 
665  result = transform_.project(Core::Geometry::Point(rx,0.0,0.0));
666  index_type irx =static_cast<index_type>(rx);
667  node = INDEX(irx);
668  pdist = (p-result).length();
669 
670  return (true);
671  }
672 
673 
674  template <class INDEX, class ARRAY>
675  bool
676  find_closest_elem(double& pdist,
677  Core::Geometry::Point& result,
678  ARRAY &coords,
679  INDEX &elem,
680  const Core::Geometry::Point &p) const
681  {
682  /// If there are no elements, we cannot find the closest
683  if (ni_ == 0) return (false);
684 
686 
687  double ii = r.x();
688  const double nii = static_cast<double>(ni_-2);
689 
690  if (ii < 0.0) ii = 0.0; if (ii > nii) ii = nii;
691 
692  const double fi = floor(ii);
693 
694  elem = INDEX(static_cast<index_type>(fi));
695  result = transform_.project(Core::Geometry::Point(ii,0,0));
696  pdist = (p-result).length();
697 
698  coords.resize(1);
699  coords[0] = ii-fi;
700 
701  return (true);
702  }
703 
704  template <class INDEX, class ARRAY>
705  bool
706  find_closest_elem(double& pdist, Core::Geometry::Point& result,
707  ARRAY& coords, INDEX &elem,
708  const Core::Geometry::Point &p, double maxdist) const
709  {
710  bool ret = find_closest_elem(pdist,result,coords,elem,p);
711  if (!ret) return (false);
712  if (maxdist < 0.0 || pdist < maxdist) return (true);
713  return (false);
714  }
715 
716  /// This function will find the closest element and the location on that
717  /// element that is the closest
718  template <class INDEX>
719  bool
720  find_closest_elem(double& pdist,
721  Core::Geometry::Point &result,
722  INDEX &elem,
723  const Core::Geometry::Point &p) const
724  {
725  /// If there are no elements, we cannot find the closest
726  if (ni_ == 0) return (false);
727 
729 
730  double ii = r.x();
731  const double nii = static_cast<double>(ni_-2);
732 
733  if (ii < 0.0) ii = 0.0; if (ii > nii) ii = nii;
734 
735  elem = INDEX(static_cast<index_type>(floor(ii)));
736  result = transform_.project(Core::Geometry::Point(ii,0,0));
737  pdist = (p-result).length();
738 
739  return (true);
740  }
741 
742 
743  /// This function will return multiple elements if the closest point is
744  /// located on a node or edge. All bordering elements are returned in that
745  /// case.
746  template <class ARRAY>
747  bool
749  ARRAY &elems, const Core::Geometry::Point &p) const
750  {
751  /// If there are no elements, we cannot find the closest
752  if (ni_ == 0) return (false);
753 
754  const double epsilon_ = 1e-8;
755 
757 
758  double ii = r.x();
759  const double nii = static_cast<double>(ni_-2);
760 
761  if (ii < 0.0) ii = 0.0; if (ii > nii) ii = nii;
762 
763  const double fii = floor(ii);
764  index_type i = static_cast<index_type>(fii);
765  elems.push_back(static_cast<typename ARRAY::value_type>(i));
766 
767  if ((fabs(fii-ii) < epsilon_) && ((i-1)>0))
768  {
769  elems.push_back(static_cast<typename ARRAY::value_type>(i-1));
770  }
771 
772  if ((fabs(fii-(ii+1.0)) < epsilon_) && (i<(ni_-1)))
773  {
774  elems.push_back(static_cast<typename ARRAY::value_type>(i+1));
775  }
776 
777  result = transform_.project(Core::Geometry::Point(ii,0,0));
778  pdist = (p-result).length();
779 
780  return (true);
781  }
782 
783 
784 
785 
786 
787 
788 
789 protected:
790 
791  void compute_jacobian();
792 
793  /// the min typename Node::index_type ( incase this is a subLattice )
795 
796  /// the typename Node::index_type space extents of a ScanlineMesh
797  /// (min=min_typename Node::index_type, max=min+extents-1)
799 
800  /// the object space extents of a ScanlineMesh
802 
803  /// the basis fn
804  Basis basis_;
805 
806  boost::shared_ptr<VMesh> vmesh_;
807 
808  // The jacobian is the same for every element
809  // hence store them as soon as we know the transfrom_
810  // This should speed up FE computations on these regular grids.
811  double jacobian_[9];
812  double inverse_jacobian_[9];
816 
817 };
818 
819 
820 template <class Basis>
822 ScanlineMesh<Basis>::scanline_typeid(type_name(-1), "Mesh",
824 
825 
826 template <class Basis>
829  : min_i_(0), ni_(ni)
830 {
831  DEBUG_CONSTRUCTOR("ScanlineMesh")
832 
833  Core::Geometry::Vector v0 = max - min;
834  Core::Geometry::Vector v1, v2;
835  v0.find_orthogonal(v1,v2);
836 
837  // The two points define a line, this sets up the transfrom so it projects
838  // to the x-axis
839 
840  transform_.load_basis(min,v0,v1,v2);
841  transform_.post_scale(Core::Geometry::Vector(1.0 / (ni_ - 1.0), 1.0, 1.0));
842 
845 
846  /// Create a new virtual interface for this copy
847  /// all pointers have changed hence create a new
848  /// virtual interface class
849  vmesh_.reset(CreateVScanlineMesh(this));
850 }
851 
852 
853 template <class Basis>
856 {
857  Core::Geometry::Point p0(0.0, 0.0, 0.0);
858  Core::Geometry::Point p1(ni_ - 1, 0.0, 0.0);
859 
860  Core::Geometry::BBox result;
861  result.extend(transform_.project(p0));
862  result.extend(transform_.project(p1));
863  return result;
864 }
865 
866 
867 template <class Basis>
870 {
871  return get_bounding_box().diagonal();
872 }
873 
874 
875 template <class Basis>
876 void
878 {
879  transform_.pre_trans(t);
880  compute_jacobian();
881 }
882 
883 
884 template <class Basis>
885 void
887 {
888  t = transform_;
889  t.post_scale(Core::Geometry::Vector(ni_ - 1.0, 1.0, 1.0));
890 }
891 
892 
893 template <class Basis>
894 bool
895 ScanlineMesh<Basis>::get_min(std::vector<index_type> &array ) const
896 {
897  array.resize(1);
898  array.clear();
899 
900  array.push_back(min_i_);
901 
902  return true;
903 }
904 
905 
906 template <class Basis>
907 bool
908 ScanlineMesh<Basis>::get_dim(std::vector<size_type> &array) const
909 {
910  array.resize(1);
911  array.clear();
912 
913  array.push_back(ni_);
914 
915  return true;
916 }
917 
918 
919 template <class Basis>
920 void
921 ScanlineMesh<Basis>::set_min(std::vector<index_type> min)
922 {
923  min_i_ = min[0];
924 }
925 
926 
927 template <class Basis>
928 void
929 ScanlineMesh<Basis>::set_dim(std::vector<size_type> dim)
930 {
931  ni_ = dim[0];
932 
933  /// Create a new virtual interface for this copy
934  /// all pointers have changed hence create a new
935  /// virtual interface class
936  vmesh_.reset(CreateVScanlineMesh(this));
937 }
938 
939 
940 template <class Basis>
941 void
943  typename Edge::index_type idx) const
944 {
945  array.resize(2);
946  array[0] = typename Node::index_type(idx);
947  array[1] = typename Node::index_type(idx + 1);
948 }
949 
950 
951 template <class Basis>
952 void
954  typename Node::index_type index) const
955 {
956  result.reserve(2);
957  result.clear();
958  if (index > 0)
959  {
960  result.push_back(typename Edge::index_type(index-1));
961  }
962  if (index < ni_-1)
963  {
964  result.push_back(typename Edge::index_type(index));
965  }
966 }
967 
968 
969 template <class Basis>
970 void
972  typename Node::index_type idx) const
973 {
974  Core::Geometry::Point p(idx, 0.0, 0.0);
975  result = transform_.project(p);
976 }
977 
978 
979 template <class Basis>
980 void
982  typename Edge::index_type idx) const
983 {
984  Core::Geometry::Point p(idx + 0.5, 0.0, 0.0);
985  result = transform_.project(p);
986 }
987 
988 
989 template <class Basis>
990 int
992  double *w)
993 {
994  typename Edge::index_type idx;
995  if (locate(idx, p))
996  {
997  get_nodes(l,idx);
998  std::vector<double> coords(1);
999  if (get_coords(coords, p, idx))
1000  {
1001  basis_.get_weights(coords, w);
1002  return basis_.dofs();
1003  }
1004  }
1005  return 0;
1006 }
1007 
1008 
1009 template <class Basis>
1010 int
1012  double *w)
1013 {
1014  typename Edge::index_type idx;
1015  if (locate(idx, p))
1016  {
1017  l.resize(1);
1018  l[0] = idx;
1019  w[0] = 1.0;
1020  return 1;
1021  }
1022  return 0;
1023 }
1024 
1025 
1026 template <class Basis>
1027 void
1029  typename Elem::index_type ei,
1030  FieldRNG &rng) const
1031 {
1032  Core::Geometry::Point p0, p1;
1033  get_center(p0, typename Node::index_type(ei));
1034  get_center(p1, typename Node::index_type(under_type(ei)+1));
1035 
1036  p = p0 + (p1 - p0) * rng();
1037 }
1038 
1039 
1040 #define SCANLINEMESH_VERSION 4
1041 
1042 template <class Basis>
1043 void
1045 {
1046  int version = stream.begin_class(type_name(-1), SCANLINEMESH_VERSION);
1047 
1048  Mesh::io(stream);
1049 
1050  // IO data members, in order
1051  Pio(stream, ni_);
1052 
1053  if (version < 4)
1054  {
1055  unsigned int ni = static_cast<unsigned int>(ni_);
1056  Pio(stream, ni);
1057  ni_ = static_cast<size_type>(ni);
1058  }
1059  else
1060  {
1061  Pio_size(stream, ni_);
1062  }
1063 
1064  if (version < 2 && stream.reading() )
1065  {
1066  Pio_old(stream, transform_);
1067  }
1068  else
1069  {
1070  Pio(stream, transform_);
1071  }
1072  if (version >= 3)
1073  {
1074  basis_.io(stream);
1075  }
1076  stream.end_class();
1077 
1078  if (stream.reading())
1079  {
1080  compute_jacobian();
1081  vmesh_.reset(CreateVScanlineMesh(this));
1082  }
1083 }
1084 
1085 
1086 template <class Basis>
1087 const std::string
1089 {
1090  ASSERT((n >= -1) && n <= 1);
1091  if (n == -1)
1092  {
1093  static const std::string name = TypeNameGenerator::make_template_id(type_name(0), type_name(1));
1094  return name;
1095  }
1096  else if (n == 0)
1097  {
1098  static const std::string nm("ScanlineMesh");
1099  return nm;
1100  }
1101  else
1102  {
1103  return find_type_name((Basis *)0);
1104  }
1105 }
1106 
1107 
1108 template <class Basis>
1109 void
1111 {
1112  itr = typename Node::iterator(min_i_);
1113 }
1114 
1115 
1116 template <class Basis>
1117 void
1119 {
1120  itr = typename Node::iterator(min_i_ + ni_);
1121 }
1122 
1123 
1124 template <class Basis>
1125 void
1127 {
1128  s = typename Node::size_type(ni_);
1129 }
1130 
1131 
1132 template <class Basis>
1133 void
1135 {
1136  itr = typename Edge::iterator(min_i_);
1137 }
1138 
1139 
1140 template <class Basis>
1141 void
1143 {
1144  itr = typename Edge::iterator(min_i_+ni_-1);
1145 }
1146 
1147 
1148 template <class Basis>
1149 void
1151 {
1152  s = typename Edge::size_type(ni_ - 1);
1153 }
1154 
1155 
1156 template <class Basis>
1157 void
1159 {
1160  ASSERTFAIL("This mesh type does not have faces use \"elem\".");
1161 }
1162 
1163 
1164 template <class Basis>
1165 void
1167 {
1168  ASSERTFAIL("This mesh type does not have faces use \"elem\".");
1169 }
1170 
1171 
1172 template <class Basis>
1173 void
1175 {
1176  ASSERTFAIL("This mesh type does not have faces use \"elem\".");
1177 }
1178 
1179 
1180 template <class Basis>
1181 void
1183 {
1184  ASSERTFAIL("This mesh type does not have cells use \"elem\".");
1185 }
1186 
1187 
1188 template <class Basis>
1189 void
1191 {
1192  ASSERTFAIL("This mesh type does not have cells use \"elem\".");
1193 }
1194 
1195 
1196 template <class Basis>
1197 void
1199 {
1200  ASSERTFAIL("This mesh type does not have cells use \"elem\".");
1201 }
1202 
1203 
1204 template <class Basis>
1205 double
1207 {
1208  Core::Geometry::Point p0(static_cast<double>(ni_-1),0.0,0.0);
1209  Core::Geometry::Point p1(0.0,0.0,0.0);
1210  Core::Geometry::Point q0 = transform_.project(p0);
1211  Core::Geometry::Point q1 = transform_.project(p1);
1212  return ((q0-q1).length()*1e-8);
1213 }
1214 
1215 template <class Basis>
1216 const TypeDescription*
1218 {
1219  static TypeDescription *td = 0;
1220  if (!td)
1221  {
1222  const TypeDescription *sub = get_type_description((Basis*)0);
1224  (*subs)[0] = sub;
1225  td = new TypeDescription("ScanlineMesh", subs,
1226  std::string(__FILE__),
1227  "SCIRun",
1229  }
1230  return td;
1231 }
1232 
1233 
1234 template <class Basis>
1235 const TypeDescription*
1237 {
1239 }
1240 
1241 
1242 template <class Basis>
1243 const TypeDescription*
1245 {
1246  static TypeDescription *td = 0;
1247  if (!td)
1248  {
1249  const TypeDescription *me =
1251  td = new TypeDescription(me->get_name() + "::Node",
1252  std::string(__FILE__),
1253  "SCIRun",
1255  }
1256  return td;
1257 }
1258 
1259 
1260 template <class Basis>
1261 const TypeDescription*
1263 {
1264  static TypeDescription *td = 0;
1265  if (!td)
1266  {
1267  const TypeDescription *me =
1269  td = new TypeDescription(me->get_name() + "::Edge",
1270  std::string(__FILE__),
1271  "SCIRun",
1273  }
1274  return td;
1275 }
1276 
1277 
1278 template <class Basis>
1279 const TypeDescription*
1281 {
1282  static TypeDescription *td = 0;
1283  if (!td)
1284  {
1285  const TypeDescription *me =
1287  td = new TypeDescription(me->get_name() + "::Face",
1288  std::string(__FILE__),
1289  "SCIRun",
1291  }
1292  return td;
1293 }
1294 
1295 
1296 template <class Basis>
1297 const TypeDescription*
1299 {
1300  static TypeDescription *td = 0;
1301  if (!td)
1302  {
1303  const TypeDescription *me =
1305  td = new TypeDescription(me->get_name() + "::Cell",
1306  std::string(__FILE__),
1307  "SCIRun",
1309  }
1310  return td;
1311 }
1312 
1313 
1314 template <class Basis>
1315 void
1317 {
1318  if (basis_.polynomial_order() < 2)
1319  {
1320  Core::Geometry::Vector J1 = transform_.project(Core::Geometry::Vector(1.0,0.0,0.0));
1321  Core::Geometry::Vector J2, J3;
1322  J1.find_orthogonal(J2,J3);
1323  J2.normalize();
1324  J3.normalize();
1325 
1326  jacobian_[0] = J1.x();
1327  jacobian_[1] = J1.y();
1328  jacobian_[2] = J1.z();
1329  jacobian_[3] = J2.x();
1330  jacobian_[4] = J2.y();
1331  jacobian_[5] = J2.z();
1332  jacobian_[6] = J3.x();
1333  jacobian_[7] = J3.y();
1334  jacobian_[8] = J3.z();
1335 
1336  det_jacobian_ = DetMatrix3x3(jacobian_);
1337  scaled_jacobian_ = ScaledDetMatrix3x3(jacobian_);
1338  det_inverse_jacobian_ = InverseMatrix3x3(jacobian_,inverse_jacobian_);
1339  }
1340 }
1341 
1342 template <class Basis>
1343 bool
1345 {
1346  /// If there are no nodes, return false, otherwise there will always be
1347  /// a node that is closest
1348  if (ni_ == 0) return (false);
1349 
1350  const Core::Geometry::Point r = transform_.unproject(p);
1351 
1352  double rx = floor(r.x() + 0.5);
1353  const double nii = static_cast<double>(ni_-1);
1354 
1355  if (rx < 0.0) rx = 0.0; if (rx > nii) rx = nii;
1356 
1357  node = static_cast<index_type>(rx);
1358 
1359  return (true);
1360 }
1361 
1362 template <class Basis>
1363 bool
1365 {
1366  if (basis_.polynomial_order() > 1) return elem_locate(elem, *this, p);
1367 
1368  /// If there are no elements, we are definitely not inside an element
1369  if (ni_ < 2) return (false);
1370 
1371  const double epsilon_ = 1e-7;
1372 
1373  const Core::Geometry::Point r = transform_.unproject(p);
1374 
1375  double ii = r.x();
1376  const double nii = static_cast<double>(ni_-1);
1377 
1378  if (ii>=nii && (ii-epsilon_)<nii) ii=nii-epsilon_;
1379 
1380  if (ii<0 && ii>(-epsilon_)) ii=0.0;
1381 
1382  const index_type i = static_cast<index_type>(floor(ii));
1383 
1384  if (i < (ni_-1) && i >= 0 && ii >= 0.0)
1385  {
1386  elem = i;
1387  return (true);
1388  }
1389 
1390  /// Not inside any elements
1391  return (false);
1392 }
1393 
1394 template <class Basis>
1395 bool
1397  std::vector<double>& coords,
1398  const Core::Geometry::Point &p) const
1399 {
1400  if (basis_.polynomial_order() > 1) return elem_locate(elem, *this, p);
1401 
1402  /// If there are no elements, we are definitely not inside an element
1403  if (ni_ < 2) return (false);
1404 
1405  coords.resize(1);
1406  const double epsilon_ = 1e-8;
1407 
1408  const Core::Geometry::Point r = transform_.unproject(p);
1409 
1410  double ii = r.x();
1411  const double nii = static_cast<double>(ni_-1);
1412 
1413  if (ii>nii && (ii-epsilon_)<nii) ii=nii-epsilon_;
1414 
1415  if (ii<0 && ii>(-epsilon_)) ii=0.0;
1416 
1417  const double fi = floor(ii);
1418  const index_type i = static_cast<index_type>(fi);
1419 
1420  if (i < (ni_-1) && i >= 0 && ii >= 0.0)
1421  {
1422  elem = i;
1423  return (true);
1424  }
1425 
1426  coords[0] = ii - fi;
1427 
1428  /// Not inside any elements
1429  return (false);
1430 }
1431 
1432 } // namespace SCIRun
1433 
1434 #endif
index_type min_i_
the min typename Node::index_type ( incase this is a subLattice )
Definition: ScanlineMesh.h:794
bool find_closest_elem(double &pdist, Core::Geometry::Point &result, INDEX &elem, const Core::Geometry::Point &p) const
Definition: ScanlineMesh.h:720
static const TypeDescription * face_type_description()
Definition: ScanlineMesh.h:1280
Definition: ScanlineMesh.h:149
Node DElem
Definition: ScanlineMesh.h:145
bool find_closest_elems(double &pdist, Core::Geometry::Point &result, ARRAY &elems, const Core::Geometry::Point &p) const
Definition: ScanlineMesh.h:748
Interface to statically allocated std::vector class.
Index and Iterator types required for Mesh Concept.
Definition: ScanlineMesh.h:116
bool get_min(std::vector< index_type > &) const
Definition: ScanlineMesh.h:895
bool reading() const
Definition: Persistent.h:164
void get_elems(typename Elem::array_type &, typename Face::index_type) const
Definition: ScanlineMesh.h:323
Distinct type for node FieldIterator.
Definition: FieldIterator.h:89
static Persistent * maker()
This function returns a maker for Pio.
Definition: ScanlineMesh.h:626
static const TypeDescription * cell_type_description()
Definition: ScanlineMesh.h:1298
bool find_closest_elem(double &pdist, Core::Geometry::Point &result, ARRAY &coords, INDEX &elem, const Core::Geometry::Point &p, double maxdist) const
Definition: ScanlineMesh.h:706
void get_edges(typename Edge::array_type &, typename Face::index_type) const
Definition: ScanlineMesh.h:309
ElemData(const ScanlineMesh< Basis > &msh, const typename Elem::index_type ind)
Definition: ScanlineMesh.h:154
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
ScanlineMesh()
Definition: ScanlineMesh.h:198
double det_jacobian(const VECTOR &coords, typename Elem::index_type idx) const
Definition: ScanlineMesh.h:506
Vector project(const Vector &p) const
Definition: Transform.cc:425
size_type ni_
Definition: ScanlineMesh.h:798
static const TypeDescription * node_type_description()
Definition: ScanlineMesh.h:1244
void end(typename Node::iterator &) const
Definition: ScanlineMesh.h:1118
void get_edges(typename Edge::array_type &, typename Edge::index_type) const
Definition: ScanlineMesh.h:307
const Core::Geometry::Point node1() const
Definition: ScanlineMesh.h:187
ScanlineMesh(const ScanlineMesh &copy)
Definition: ScanlineMesh.h:219
void set_min_i(index_type i)
set the mesh statistics
Definition: ScanlineMesh.h:264
Definition: Persistent.h:89
void get_random_point(Core::Geometry::Point &p, typename Elem::index_type i, FieldRNG &rng) const
Definition: ScanlineMesh.h:1028
EdgeIndex< under_type > index_type
Definition: ScanlineMesh.h:124
void get_delems(typename DElem::array_type &result, typename Elem::index_type idx) const
Wrapper to get the derivative elements from this element.
Definition: ScanlineMesh.h:327
Point unproject(const Point &p) const
Definition: Transform.cc:483
const Core::Geometry::Point node0() const
Definition: ScanlineMesh.h:181
boost::shared_ptr< VMesh > vmesh_
Definition: ScanlineMesh.h:806
virtual const TypeDescription * get_type_description() const
Definition: ScanlineMesh.h:1236
void get_center(Core::Geometry::Point &, typename Face::index_type) const
Definition: ScanlineMesh.h:366
virtual VMesh * vmesh()
Access point to virtual interface.
Definition: ScanlineMesh.h:240
virtual int topology_geometry() const
Definition: ScanlineMesh.h:405
int get_valence(typename Node::index_type idx) const
Definition: ScanlineMesh.h:355
Definition: Persistent.h:187
virtual bool get_dim(std::vector< size_type > &) const
Definition: ScanlineMesh.h:908
BBox & extend(const Point &p)
Expand the bounding box to include point p.
Definition: BBox.h:98
double get_length(typename Edge::index_type idx) const
Definition: ScanlineMesh.h:348
Definition: ScanlineMesh.h:137
CellIndex< under_type > index_type
Definition: ScanlineMesh.h:138
int get_valence(typename Face::index_type) const
Definition: ScanlineMesh.h:358
SCIRun::size_type size_type
Definition: ScanlineMesh.h:109
Definition: TypeDescription.h:50
FieldHandle mesh()
Definition: BuildTDCSMatrixTests.cc:56
Definition: Point.h:49
Definition: TypeDescription.h:45
#define SCISHARE
Definition: share.h:39
std::vector< const TypeDescription * > td_vec
Definition: TypeDescription.h:56
NodeIterator< under_type > iterator
Definition: ScanlineMesh.h:118
std::vector< index_type > array_type
Definition: ScanlineMesh.h:141
Definition: ScanlineMesh.h:76
NodeIndex< under_type > index_type
Definition: ScanlineMesh.h:117
Definition: Mesh.h:45
virtual bool synchronize(mask_type)
Definition: ScanlineMesh.h:433
ScanlineMesh< Basis >::index_type index_type
Definition: ScanlineMesh.h:152
Definition: BBox.h:46
SCIRun::index_type index_type
Definition: ScanlineMesh.h:108
boost::shared_ptr< Mesh > MeshHandle
Definition: DatatypeFwd.h:67
bool locate(typename Face::index_type &, const Core::Geometry::Point &) const
Definition: ScanlineMesh.h:373
Distinct type for cell Iterator.
Definition: FieldIterator.h:134
void compute_imat() const
Definition: Transform.cc:687
int get_weights(const Core::Geometry::Point &, typename Face::array_type &, double *)
Definition: ScanlineMesh.h:383
Definition: Mesh.h:61
double get_size(typename Cell::index_type) const
Definition: ScanlineMesh.h:346
unsigned int mask_type
Definition: Types.h:45
void get_elems(typename Elem::array_type &result, typename Node::index_type idx) const
get the parent element(s) of the given index
Definition: ScanlineMesh.h:953
FaceIndex< under_type > size_type
Definition: ScanlineMesh.h:133
double det_inverse_jacobian_
Definition: ScanlineMesh.h:815
#define ASSERT(condition)
Definition: Assert.h:110
static MeshHandle mesh_maker()
This function returns a handle for the virtual interface.
Definition: ScanlineMesh.h:628
void set_min(std::vector< index_type > mins)
Definition: ScanlineMesh.h:921
virtual int basis_order()
Definition: ScanlineMesh.h:247
virtual int begin_class(const std::string &name, int current_version)
Definition: Persistent.cc:143
Definition: ScanlineMesh.h:130
virtual void set_dim(std::vector< size_type > dims)
Definition: ScanlineMesh.h:929
Definition: ScanlineMesh.h:123
double get_size(typename Edge::index_type idx) const
Definition: ScanlineMesh.h:335
bool get_coords(VECTOR &coords, const Core::Geometry::Point &p, typename Elem::index_type idx) const
Definition: ScanlineMesh.h:441
Definition: Vector.h:63
virtual bool unsynchronize(mask_type)
Definition: ScanlineMesh.h:434
Core::Geometry::Vector diagonal() const
Definition: ScanlineMesh.h:869
double get_size(typename Node::index_type) const
Get the size of an elemnt (length, area, volume)
Definition: ScanlineMesh.h:334
double get_epsilon() const
Definition: ScanlineMesh.h:1206
const string find_type_name(float *)
Definition: TypeName.cc:63
void get_normal(Core::Geometry::Vector &, std::vector< double > &, typename Elem::index_type, unsigned int)
Definition: ScanlineMesh.h:393
StackVector< index_type, 8 > array_type
Definition: ScanlineMesh.h:120
void get_nodes(typename Node::array_type &, typename Face::index_type) const
Definition: ScanlineMesh.h:303
void get_center(Core::Geometry::Point &, typename Node::index_type) const
get the center point (in object space) of an element
Definition: ScanlineMesh.h:971
T DetMatrix3x3(const T *p)
Definition: Locate.h:95
bool find_closest_node(double &pdist, Core::Geometry::Point &result, INDEX &node, const Core::Geometry::Point &p, double maxdist) const
Definition: ScanlineMesh.h:639
index_type node0_index() const
Definition: ScanlineMesh.h:162
void to_index(typename Node::index_type &index, index_type i) const
Definition: ScanlineMesh.h:292
virtual ScanlineMesh * clone() const
Definition: ScanlineMesh.h:233
void load_basis(const Point &, const Vector &, const Vector &, const Vector &)
Definition: Transform.cc:86
Definition: ParallelLinearAlgebraTests.cc:358
void get_point(Core::Geometry::Point &p, typename Node::index_type i) const
Definition: ScanlineMesh.h:390
bool find_closest_elem(double &pdist, Core::Geometry::Point &result, ARRAY &coords, INDEX &elem, const Core::Geometry::Point &p) const
Definition: ScanlineMesh.h:676
void to_index(typename Face::index_type &, index_type) const
Definition: ScanlineMesh.h:296
Basis & get_basis()
Definition: ScanlineMesh.h:406
const char * name[]
Definition: BoostGraphExampleTests.cc:87
void x(const double)
Definition: Point.h:125
int get_valence(typename Edge::index_type) const
Definition: ScanlineMesh.h:357
long long size_type
Definition: Types.h:40
virtual Core::Geometry::BBox get_bounding_box() const
Definition: ScanlineMesh.h:855
FaceIndex< under_type > index_type
Definition: ScanlineMesh.h:131
EdgeIndex< under_type > size_type
Definition: ScanlineMesh.h:126
SCISHARE void find_orthogonal(Vector &, Vector &) const
Definition: Vector.cc:59
virtual int dimensionality() const
Definition: ScanlineMesh.h:404
int get_weights(const Core::Geometry::Point &, typename Cell::array_type &, double *)
Definition: ScanlineMesh.h:385
static const std::string type_name(int n=-1)
Core functionality for getting the name of a templated mesh class.
Definition: ScanlineMesh.h:1088
virtual void get_canonical_transform(Core::Geometry::Transform &t)
Definition: ScanlineMesh.h:886
int get_weights(const Core::Geometry::Point &p, typename Node::array_type &l, double *w)
Definition: ScanlineMesh.h:991
void interpolate(Core::Geometry::Point &pt, const VECTOR &coords, typename Elem::index_type idx) const
Definition: ScanlineMesh.h:470
std::string type
Definition: Persistent.h:72
void jacobian(const VECTOR &coords, typename Elem::index_type idx, double *J) const
Definition: ScanlineMesh.h:523
Distinct type for face index.
Definition: FieldIndex.h:90
CellIterator< under_type > iterator
Definition: ScanlineMesh.h:139
static PersistentTypeID scanline_typeid
Definition: ScanlineMesh.h:610
void get_edges(typename Edge::array_type &, typename Cell::index_type) const
Definition: ScanlineMesh.h:311
VMesh * CreateVScanlineMesh(MESH *mesh)
Definition: ScanlineMesh.h:82
double inverse_jacobian(const VECTOR &coords, typename Elem::index_type idx, double *Ji) const
Definition: ScanlineMesh.h:560
#define SCANLINEMESH_VERSION
Definition: ScanlineMesh.h:1040
Definition: Transform.h:53
void get_nodes(typename Node::array_type &, typename Cell::index_type) const
Definition: ScanlineMesh.h:305
void x(double)
Definition: Vector.h:175
Basis basis_
the basis fn
Definition: ScanlineMesh.h:804
FaceIterator< under_type > iterator
Definition: ScanlineMesh.h:132
virtual bool has_face_normals() const
Definition: ScanlineMesh.h:250
double scaled_jacobian_metric(typename Elem::index_type) const
Definition: ScanlineMesh.h:596
bool find_closest_node(double &pdist, Core::Geometry::Point &result, INDEX &node, const Core::Geometry::Point &p) const
Definition: ScanlineMesh.h:652
void get_faces(typename Face::array_type &, typename Elem::index_type) const
Definition: ScanlineMesh.h:315
bool locate(typename Cell::index_type &, const Core::Geometry::Point &) const
Definition: ScanlineMesh.h:375
static const std::string make_template_id(const std::string &templateName, const std::string &templateParam)
Definition: TypeName.h:62
void pwl_approx_face(std::vector< std::vector< std::vector< double > > > &, typename Elem::index_type, typename Face::index_type, unsigned int) const
Definition: ScanlineMesh.h:422
virtual ~ScanlineMesh()
Definition: ScanlineMesh.h:234
double jacobian_[9]
Definition: ScanlineMesh.h:811
double normalize()
Definition: Vector.h:437
SCIRun::index_type under_type
Definition: ScanlineMesh.h:107
int get_valence(typename Cell::index_type) const
Definition: ScanlineMesh.h:360
Basis basis_type
Definition: ScanlineMesh.h:113
void y(double)
Definition: Vector.h:185
void begin(typename Node::iterator &) const
Definition: ScanlineMesh.h:1110
virtual void io(Piostream &)
Export this class using the old Pio system.
Definition: ScanlineMesh.h:1044
Distinct type for edge Iterator.
Definition: FieldIterator.h:105
#define ASSERTFAIL(string)
Definition: Assert.h:52
virtual MeshFacadeHandle getFacade() const
Definition: ScanlineMesh.h:242
std::vector< index_type > array_type
Definition: ScanlineMesh.h:134
index_type get_min_i() const
get the mesh statistics
Definition: ScanlineMesh.h:254
void Pio(Piostream &stream, Array1< T > &array)
Definition: Array1.h:65
Some convenient simple iterators for fields.
void get_normal(Core::Geometry::Vector &, typename Node::index_type) const
Definition: ScanlineMesh.h:391
EdgeIterator< under_type > iterator
Definition: ScanlineMesh.h:125
virtual void transform(const Core::Geometry::Transform &t)
Definition: ScanlineMesh.h:877
virtual void end_class()
Definition: Persistent.cc:178
double inverse_jacobian_[9]
Definition: ScanlineMesh.h:812
std::vector< index_type > array_type
Definition: ScanlineMesh.h:127
static MeshHandle scanline_maker(size_type x, const Core::Geometry::Point &min, const Core::Geometry::Point &max)
This function returns a handle for the virtual interface.
Definition: ScanlineMesh.h:630
T ScaledDetMatrix3x3(const T *p)
Definition: Locate.h:106
CellIndex< under_type > size_type
Definition: ScanlineMesh.h:140
NodeIndex< under_type > size_type
Definition: ScanlineMesh.h:119
void to_index(typename Edge::index_type &index, index_type i) const
Definition: ScanlineMesh.h:294
long long index_type
Definition: Types.h:39
Core::Geometry::Transform & get_transform()
Definition: ScanlineMesh.h:400
void resize(size_t size, const value_type &val=value_type())
Definition: StackVector.h:61
virtual bool has_normals() const
Definition: ScanlineMesh.h:249
SCISHARE void Pio_old(Piostream &, Transform &)
Definition: Transform.cc:940
void pwl_approx_edge(std::vector< std::vector< double > > &coords, typename Elem::index_type, unsigned int, unsigned int div_per_unit) const
piecewise linear approximation of an edge.
Definition: ScanlineMesh.h:410
static const TypeDescription * elem_type_description()
Definition: ScanlineMesh.h:622
void size(typename Node::size_type &) const
Definition: ScanlineMesh.h:1126
Edge Elem
Definition: ScanlineMesh.h:144
Core::Geometry::Transform & set_transform(const Core::Geometry::Transform &trans)
Definition: ScanlineMesh.h:401
Definition: Persistent.h:64
virtual bool is_editable() const
Definition: ScanlineMesh.h:251
double jacobian_metric(typename Elem::index_type) const
Definition: ScanlineMesh.h:599
double det_jacobian_
Definition: ScanlineMesh.h:813
double get_size(typename Face::index_type) const
Definition: ScanlineMesh.h:344
double scaled_jacobian_
Definition: ScanlineMesh.h:814
Distinct type for edge index.
Definition: FieldIndex.h:81
int n
Definition: eab.py:9
void get_nodes(typename Node::array_type &, typename Edge::index_type) const
get the child elements of the given index
Definition: ScanlineMesh.h:942
T InverseMatrix3x3(const T *p, T *q)
Definition: Locate.h:47
boost::shared_ptr< ScanlineMesh< Basis > > handle_type
Definition: ScanlineMesh.h:112
Core::Geometry::Transform transform_
the object space extents of a ScanlineMesh
Definition: ScanlineMesh.h:801
void post_scale(const Vector &)
Definition: Transform.cc:202
static const TypeDescription * edge_type_description()
Definition: ScanlineMesh.h:1262
#define DEBUG_CONSTRUCTOR(type)
Definition: Debug.h:64
void to_index(typename Cell::index_type &, index_type) const
Definition: ScanlineMesh.h:298
void io(Piostream &stream)
Persistent I/O.
Definition: Mesh.cc:387
double get_area(typename Face::index_type idx) const
Definition: ScanlineMesh.h:350
ScanlineMesh(ScanlineMesh *mh, index_type offset, index_type nx)
Definition: ScanlineMesh.h:207
double get_volume(typename Cell::index_type) const
Definition: ScanlineMesh.h:352
Definition: Mesh.h:63
size_type get_ni() const
Definition: ScanlineMesh.h:256
void Pio_size(Piostream &stream, Size &size)
Definition: Persistent.h:273
void z(double)
Definition: Vector.h:195
boost::shared_ptr< MeshFacade< VMesh > > MeshFacadeHandle
Definition: MeshTraits.h:61
Definition: VMesh.h:53
void get_center(Core::Geometry::Point &, typename Cell::index_type) const
Definition: ScanlineMesh.h:368
SCIRun::mask_type mask_type
Definition: ScanlineMesh.h:110
bool locate(typename Node::index_type &, const Core::Geometry::Point &) const
Definition: ScanlineMesh.h:1344
index_type edge0_index() const
Definition: ScanlineMesh.h:175
friend class VScanlineMesh
Make sure the virtual interface has access.
Definition: ScanlineMesh.h:102
virtual std::string dynamic_type_name() const
Definition: ScanlineMesh.h:613
void compute_jacobian()
Definition: ScanlineMesh.h:1316
index_type node1_index() const
Definition: ScanlineMesh.h:167
void get_elems(typename Elem::array_type &, typename Edge::index_type) const
Definition: ScanlineMesh.h:321
void set_ni(size_type i)
Definition: ScanlineMesh.h:266
#define DEBUG_DESTRUCTOR(type)
Definition: Debug.h:65
const TypeDescription * get_type_description(Core::Basis::ConstantBasis< T > *)
Definition: Constant.h:209
bool clear_synchronization()
Definition: ScanlineMesh.h:435
void derivate(const VECTOR1 &coords, typename Elem::index_type idx, VECTOR2 &J) const
Definition: ScanlineMesh.h:488
bool elem_locate(INDEX &elem, MESH &msh, const Core::Geometry::Point &p)
General case locate, search each elem.
Definition: Mesh.h:188