SCIRun  5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
BaseMC.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  * BaseMC.h
32  *
33  * Allen R. Sanderson
34  * SCI Institute
35  * University of Utah
36  * Feb 2008
37  *
38  */
39 
40 
41 #ifndef CORE_ALGORITHMS_VISUALIZATION_BASEMC_H
42 #define CORE_ALGORITHMS_VISUALIZATION_BASEMC_H 1
43 
44 #include <sci_defs/hashmap_defs.h>
45 
47 #include <Core/Datatypes/Field.h>
48 #include <Core/Geom/GeomObj.h>
49 
50 #include <Core/Util/TypeDescription.h>
51 
52 
53 namespace SCIRun {
54 
55 class BaseMC
56 {
57  public:
58 
59  BaseMC() : build_field_(false), build_geom_(false), basis_order_(-1),
60  nnodes_(0), ncells_(0), geomHandle_(0) {}
61 
62  virtual ~BaseMC() {}
63 
64  virtual void reset( int,
65  bool build_field,
66  bool build_geom,
67  bool transparency ) = 0;
68 
69  virtual FieldHandle get_field(double val) = 0;
70 
71  GeomHandle get_geom() { return geomHandle_; }
74 
75  protected:
76 
77  struct edgepair_t
78  {
81  double dfirst;
82  };
83 
84  struct edgepairless
85  {
86  bool operator()(const edgepair_t &a, const edgepair_t &b) const
87  {
88  return less(a,b);
89  }
90  static bool less(const edgepair_t &a, const edgepair_t &b)
91  {
92  return a.first < b.first || (a.first == b.first && a.second < b.second);
93  }
94  };
95 
96  #ifdef HAVE_HASH_MAP
97 
98  struct edgepairequal
99  {
100  bool operator()(const edgepair_t &a, const edgepair_t &b) const
101  {
102  return a.first == b.first && a.second == b.second;
103  }
104  };
105 
106  struct edgepairhash
107  {
108  unsigned int operator()(const edgepair_t &a) const
109  {
110  #if defined(__ECC) || defined(_MSC_VER)
111  hash_compare<unsigned int> h;
112  #else
113  hash<unsigned int> h;
114  #endif
115  return h(a.first ^ a.second);
116  }
117  # if defined(__ECC) || defined(_MSC_VER)
118 
119  // These are particularly needed by ICC's hash stuff
120  static const size_t bucket_size = 4;
121  static const size_t min_buckets = 8;
122 
123  // This is a less than function.
124  bool operator()(const edgepair_t & a, const edgepair_t & b) const {
125  return edgepairless::less(a,b);
126  }
127  # endif // endif ifdef __ICC
128  };
129 
130  # if defined(__ECC) || defined(_MSC_VER)
131  typedef hash_map<edgepair_t, SCIRun::index_type, edgepairhash> edge_hash_type;
132  #else
133  typedef hash_map<edgepair_t,
135  edgepairhash,
136  edgepairequal> edge_hash_type;
137  #endif // !defined(__ECC) && !defined(_MSC_VER)
138 
139  #else
140  typedef std::map<edgepair_t,SCIRun::index_type,edgepairless> edge_hash_type;
141  #endif
142 
143  edge_hash_type edge_map_; // Unique edge cuts when surfacing node data
144  std::vector<SCIRun::index_type> cell_map_; // Unique cells when surfacing node data.
145  std::vector<SCIRun::index_type> node_map_; // Unique nodes when surfacing cell data.
146 
150 
153 
154  GeomHandle geomHandle_;
155 };
156 
157 } // End namespace SCIRun
158 
159 #endif
LockingHandle< Matrix< double > > MatrixHandle
Definition: MatrixFwd.h:55
Definition: BaseMC.h:77
bool operator()(const edgepair_t &a, const edgepair_t &b) const
Definition: BaseMC.h:86
SCIRun::size_type ncells_
Definition: BaseMC.h:152
MatrixHandle get_interpolant()
Definition: BaseMC.cc:34
virtual FieldHandle get_field(double val)=0
std::vector< SCIRun::index_type > cell_map_
Definition: BaseMC.h:144
static bool less(const edgepair_t &a, const edgepair_t &b)
Definition: BaseMC.h:90
double dfirst
Definition: BaseMC.h:81
std::map< edgepair_t, SCIRun::index_type, edgepairless > edge_hash_type
Definition: BaseMC.h:140
GeomHandle geomHandle_
Definition: BaseMC.h:154
Definition: BaseMC.h:55
SCIRun::index_type first
Definition: BaseMC.h:79
long long size_type
Definition: Types.h:40
virtual ~BaseMC()
Definition: BaseMC.h:62
virtual void reset(int, bool build_field, bool build_geom, bool transparency)=0
bool build_geom_
Definition: BaseMC.h:148
SCIRun::size_type nnodes_
Definition: BaseMC.h:151
long long index_type
Definition: Types.h:39
Definition: BaseMC.h:84
MatrixHandle get_parent_cells()
Definition: BaseMC.cc:88
boost::shared_ptr< Field > FieldHandle
Definition: DatatypeFwd.h:65
SCIRun::index_type second
Definition: BaseMC.h:80
int basis_order_
Definition: BaseMC.h:149
GeomHandle get_geom()
Definition: BaseMC.h:71
std::vector< SCIRun::index_type > node_map_
Definition: BaseMC.h:145
bool build_field_
Definition: BaseMC.h:147
BaseMC()
Definition: BaseMC.h:59
edge_hash_type edge_map_
Definition: BaseMC.h:143