Toast++  1.0.2 (r.539)
Forward and inverse modelling in optical tomography
raster.h
1 // -*-C++-*-
2 
3 #ifndef __RASTER_H
4 #define __RASTER_H
5 
10 #include "mathlib.h"
11 #include "felib.h"
12 
13 // =========================================================================
20 class STOASTLIB Raster {
21 public:
35  Raster (const IVector &_bdim, const IVector &_gdim, Mesh *mesh,
36  RDenseMatrix *bb = 0);
37 
41  virtual ~Raster();
42 
48  const int Dim() const {return dim; }
49 
55  const IVector &BDim() const { return bdim; }
56 
61  const IVector &GDim() const { return gdim; }
62 
70  const RVector &GSize() const { return bbsize; }
71 
75  inline int GLen() const { return glen; }
76 
80  inline int BLen() const { return blen; }
81 
85  inline int SLen() const { return slen; }
86 
90  inline const Mesh &mesh() const { return *meshptr; }
91 
100  inline int *Elref() const { return gelref; }
101 
110  inline int *BElref() const { return belref; }
111 
116  void BasisVoxelPositions (RDenseMatrix &pos) const;
117 
122  void SolutionVoxelPositions (RDenseMatrix &pos) const;
123 
124  virtual void Sample (const RVector &bvec, const IVector &grd, RVector &img)
125  const;
126 
132  virtual double Value (const Point &p, int i) const;
133 
139  virtual double Value_nomask (const Point &p, int i, bool is_solidx=true)
140  const = 0;
141 
147  virtual void Map_MeshToGrid (const RVector &mvec, RVector &gvec) const;
148 
154  virtual void Map_MeshToGrid (const CVector &mvec, CVector &gvec) const;
155 
162  virtual void Map_MeshToGrid (const Solution &msol, Solution &gsol,
163  bool mapall = false) const;
164 
170  virtual void Map_GridToMesh (const RVector &gvec, RVector &mvec) const;
171 
177  virtual void Map_GridToMesh (const CVector &gvec, CVector &mvec) const;
178 
185  virtual void Map_GridToMesh (const Solution &gsol, Solution &msol,
186  bool mapall = false) const;
187 
193  virtual void Map_GridToBasis (const RVector &gvec, RVector &bvec) const =0;
194 
200  virtual void Map_GridToBasis (const CVector &gvec, CVector &bvec) const =0;
201 
208  virtual void Map_GridToBasis (const Solution &gsol, Solution &bsol,
209  bool mapall = false) const;
210 
216  virtual void Map_BasisToGrid (const RVector &bvec, RVector &gvec) const =0;
217 
223  virtual void Map_BasisToGrid (const CVector &bvec, CVector &gvec) const =0;
224 
231  virtual void Map_BasisToGrid (const Solution &bsol, Solution &gsol,
232  bool mapall = false) const;
233 
241  virtual void Map_MeshToBasis (const RVector &mvec, RVector &bvec) const;
242 
250  virtual void Map_MeshToBasis (const CVector &mvec, CVector &bvec) const;
251 
259  virtual void Map_BasisToMesh (const RVector &bvec, RVector &mvec) const;
260 
268  virtual void Map_BasisToMesh (const CVector &bvec, CVector &mvec) const;
269 
281  virtual void Map_BasisToSol (const RVector &bvec, RVector &svec) const;
282 
294  virtual void Map_BasisToSol (const CVector &bvec, CVector &svec) const;
295 
307  virtual void Map_SolToBasis (const RVector &svec, RVector &bvec) const;
308 
320  virtual void Map_SolToBasis (const CVector &svec, CVector &bvec) const;
321 
322  virtual void Map_SolToBasis (const Solution &ssol, Solution &bsol,
323  bool mapall = false) const;
324 
333  virtual void Map_SolToGrid (const RVector &svec, RVector &gvec) const;
334 
343  virtual void Map_SolToGrid (const CVector &svec, CVector &gvec) const;
344 
353  virtual void Map_GridToSol (const RVector &gvec, RVector &svec) const;
354 
363  virtual void Map_GridToSol (const CVector &gvec, CVector &svec) const;
364 
373  virtual void Map_SolToMesh (const RVector &svec, RVector &mvec) const;
374 
383  virtual void Map_SolToMesh (const CVector &svec, CVector &mvec) const;
384 
385  virtual void Map_SolToMesh (const Solution &ssol, Solution &msol,
386  bool mapall = false ) const;
387 
388  // Mapping from active parameter vector to solution
389  virtual void Map_ActiveSolToMesh (const RVector &asol, Solution &msol) const;
390 
399  virtual void Map_MeshToSol (const RVector &mvec, RVector &svec) const;
400 
409  virtual void Map_MeshToSol (const CVector &mvec, CVector &svec) const;
410 
420  virtual void Map_MeshToSol (const Solution &msol, Solution &ssol,
421  bool mapall = false) const;
422 
426  inline const RGenericSparseMatrix &Mesh2GridMatrix() const
427  { return *B; }
428 
435  virtual const RGenericSparseMatrix &Mesh2BasisMatrix() const
436  { ERROR_UNDEF;
437  static RCompRowMatrix dummy;
438  return dummy; }
439 
446  virtual const RGenericSparseMatrix &Basis2MeshMatrix() const
447  { ERROR_UNDEF;
448  static RCompRowMatrix dummy;
449  return dummy; }
450 
460  virtual int GetSolIdx (int basisidx) const;
461 
469  virtual int GetSolIdx (const IVector &crd) const;
470 
479  virtual int GetBasisIdx (int solidx) const;
480 
487  virtual void GetBasisIndices (int basisidx, IVector &crd) const;
488 
496  //virtual IVector &GetBasisIndices (int basisidx) const;
497 
504  virtual IVector &GetGridIndices (int grididx) const;
505 
513  inline int Basis2Sol (int i) const { return basis2sol[i]; }
514 
521  inline int Sol2Basis (int j) const { return sol2basis[j]; }
522 
523  void NeighbourGraph (idxtype *&rowptr, idxtype *&colidx, int &nzero) const;
524  void NeighbourGraph (ICompRowMatrix &NG) const;
525  IVector NeighbourShift (const ICompRowMatrix &NG, int i, int j) const;
526  RVector RNeighbourShift (const ICompRowMatrix &NG, int i, int j) const;
527 
528  RVector SmoothImage (const RVector &x, double sd) const;
529 
530  RVector * ImageJet(const RVector &x, double sd, bool *iflags) const;
531 
532  RVector ImageGradient(const RVector &x, double sd) const;
533 
534 protected:
535  int dim;
538  int blen;
539  int glen;
540  int slen;
543  Point bbmin, bbmax;
544  int *belref;
545  int *gelref;
546 
548  int padlen;
549 
556 
568 
581 
584 };
585 
586 #endif // !__RASTER_H
int Basis2Sol(int i) const
Returns the corresponding solution vector index for a given basis vector index.
Definition: raster.h:513
const IVector & GDim() const
Return high-res grid dimensions.
Definition: raster.h:61
Virtual base class for sparse matrix types.
Definition: gsmatrix.h:47
Mesh * meshptr
mesh pointer
Definition: raster.h:542
const RVector & GSize() const
Return size of the grid bounding box.
Definition: raster.h:70
const RGenericSparseMatrix & Mesh2GridMatrix() const
Return the mesh->grid transformation matrix.
Definition: raster.h:426
int BLen() const
Return the length of the basis vector representation.
Definition: raster.h:80
IVector paddim
dimensions padded to a power of 2
Definition: raster.h:547
int slen
length of solution vector (excluding mask)
Definition: raster.h:540
Finite-element mesh management.
Definition: mesh.h:145
virtual const RGenericSparseMatrix & Mesh2BasisMatrix() const
Return the mesh->basis transformation matrix.
Definition: raster.h:435
Base class for mapping between mesh and an independent basis representation.
Definition: raster.h:20
int SLen() const
Return the length of the solution vector representation.
Definition: raster.h:85
Definition: point.h:18
RGenericSparseMatrix * B
transformation matrix mesh->grid
Definition: raster.h:582
int padlen
vector length of padded grid
Definition: raster.h:548
int blen
length of basis vector (full bb)
Definition: raster.h:538
const int Dim() const
Return problem dimension.
Definition: raster.h:48
IVector bdim
native basis dimensions
Definition: raster.h:536
RGenericSparseMatrix * BI
transformation matrix grid->mesh
Definition: raster.h:583
const IVector & BDim() const
Return native basis dimensions.
Definition: raster.h:55
const Mesh & mesh() const
Return the mesh associated with the basis.
Definition: raster.h:90
virtual const RGenericSparseMatrix & Basis2MeshMatrix() const
Return the basis->mesh transformation matrix.
Definition: raster.h:446
IVector sol2basis
Solution mask vector.
Definition: raster.h:580
IVector basis2sol
basis->solution permutation vector.
Definition: raster.h:567
int GLen() const
Return the length of the grid vector representation.
Definition: raster.h:75
int * belref
basis->element reference list (length blen)
Definition: raster.h:544
RVector bbsize
physical extents of grid bounding box
Definition: raster.h:541
int glen
length of grid vector (full bb)
Definition: raster.h:539
int * gelref
grid->element reference list (length glen)
Definition: raster.h:545
RVector bsupport
Definition: raster.h:555
int Sol2Basis(int j) const
Returns the corresponding basis vector index for a given solution vector index.
Definition: raster.h:521
int * Elref() const
Returns a pointer to the element reference array for all grid points.
Definition: raster.h:100
Definition: solution.h:39
IVector gdim
high-res grid dimension
Definition: raster.h:537
int * BElref() const
Returns a pointer to the element reference array for all basis points.
Definition: raster.h:110
Point bbmax
grid bounding box
Definition: raster.h:543
int dim
problem dimension (2 or 3)
Definition: raster.h:535