SCIRun  5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
VMeshShared.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 #ifndef CORE_DATATYPES_VMESHSHARED_H
31 #define CORE_DATATYPES_VMESHSHARED_H
32 
34 
36 
37 namespace SCIRun {
38 
39 template <class MESH>
40 class SCISHARE VMeshShared : public VMesh {
41 public:
42 
43  // Constructor: this class maintain all the virtual function calls to the
44  // basis class, so we do not need to replicate this for each mesh class
45  // This is only used in the mesh classes
46 
47  VMeshShared(MESH* mesh) :
48  mesh_(mesh)
49  {
50  basis_ = &(mesh_->get_basis());
51 
52  /// Collect general information on mesh type. These are constants and should
53  /// be accessible down the road by inline function calls. The latter
54  /// construction was chosen to improve performance and reduce the need for
55  /// for virtual function calls
56 
57 
58  /// cache the mesh basis order (1=liner, 2=quadratic, 3=cubic)
59  basis_order_ = mesh_->basis_order();
60  /// cache the mesh dimension (0=point,1=curve, 2=surface, or 3=volume)
61  dimension_ = mesh_->dimensionality();
62  /// cache whether we can edit the mesh by adding nodes and elements
63  is_editable_ = mesh_->is_editable();
64  /// cache whether we haev surface normals
65  has_normals_ = mesh_->has_normals();
66  /// cache whether we have node points defined or whether we derive them
67  /// implicitly.
68  is_regular_ = (mesh_->topology_geometry()&Mesh::REGULAR) != 0;
69  /// cache whether we have connectivity defined or whether we assume the data
70  /// to be structured enough so we can derive it implicitly
71  is_structured_ = (mesh_->topology_geometry()&Mesh::STRUCTURED) != 0;
72 
73  /// Store topology information on the mesh:
74  /// This section converts the relevant data out of the underlying older data
75  /// structures.
76 
77  /// Number of nodes in one element
78  num_nodes_per_elem_ = basis_->number_of_mesh_vertices();
79 
80  /// Number of edge nodes for quadratic interpolation model
81  num_enodes_per_elem_ = basis_->number_of_vertices() - basis_->number_of_mesh_vertices();
82 
83  /// Number of edges in one element
84  num_edges_per_elem_ = basis_->number_of_edges();
85 
86  /// Number of faces in one element
87  num_faces_per_elem_ = basis_->faces_of_cell();
88 
89  /// Number of nodes per face (volume and surface meshes only)
90  num_nodes_per_face_ = basis_->vertices_of_face();
91 
92  /// Number of edges per face (volume and surface meshes only)
93  num_edges_per_face_ = 0;
94  if (basis_->vertices_of_face() > 0) num_edges_per_face_ = basis_->vertices_of_face()-1;
95 
96  /// Number of gradients per node for cubic interpolation model
97  num_gradients_per_node_ = basis_->num_hderivs();
98 
99  element_size_ = basis_->domain_size();
100 
101 #ifdef SCIRUN4_CODE_TO_BE_ENABLED_LATER
102  generation_ = mesh_->generation;
103 #endif
104 
105  unit_vertices_.resize(num_nodes_per_elem_);
106  for (size_t k=0; k < num_nodes_per_elem_; k++)
107  {
108  VMesh::coords_type c/*(dimension_)*/;
109  for (int p=0; p<dimension_; p++) c[p] = basis_->unit_vertices[k][p];
110  unit_vertices_[k] = c;
111  }
112 
113  unit_edges_.resize(num_edges_per_elem_);
114  for (size_t k=0; k < num_edges_per_elem_; k++)
115  {
116  unit_edges_[k].resize(2);
117  for (size_t p=0; p<2; p++)
118  {
119  unit_edges_[k][p] = 0;
120  unit_edges_[k][p] = basis_->unit_edges[k][p];
121  }
122  }
123 
124  unit_center_.resize(dimension_);
125  for (int k=0; k < dimension_; k++)
126  {
127  unit_center_[k] = basis_->unit_center[k];
128  }
129 #ifdef SCIRUN4_CODE_TO_BE_ENABLED_LATER
130  pm_ = static_cast<PropertyManager*>(mesh_);
131 #endif
132  }
133 
134  virtual ~VMeshShared() {}
135 
136  virtual bool synchronize(unsigned int sync);
137  virtual bool unsynchronize(unsigned int sync);
138  virtual bool clear_synchronization();
139 
140  virtual Core::Geometry::BBox get_bounding_box() const;
141  virtual void transform(const Core::Geometry::Transform &t);
142 
143  virtual double get_epsilon() const;
144 
145  virtual void get_weights(const VMesh::coords_type& coords,
146  std::vector<double>& weights,
147  int basis_order) const;
148 
149  virtual void get_derivate_weights(const VMesh::coords_type& coords,
150  std::vector<double>& weights,
151  int basis_order) const;
152 
153  virtual void get_gaussian_scheme(std::vector<VMesh::coords_type>& coords,
154  std::vector<double>& weights, int order) const;
155  virtual void get_regular_scheme(std::vector<VMesh::coords_type>& coords,
156  std::vector<double>& weights, int order) const;
157 
158  virtual void get_canonical_transform(Core::Geometry::Transform &t);
159 
160 protected:
161  MESH* mesh_;
162  typename MESH::basis_type* basis_;
163 
164 
165 };
166 
167 template<class MESH>
168 void
170 {
171  mesh_->get_canonical_transform(t);
172 }
173 
174 template<class MESH>
175 void
177  std::vector<double>& weights,
178  int basis_order) const
179 {
180  switch(basis_order)
181  {
182  case 0:
183  weights.resize(1); weights[0] = 1.0;
184  return;
185  case 1:
186  weights.resize(basis_->num_linear_weights());
187  basis_->get_linear_weights(coords,&(weights[0]));
188  return;
189  case 2:
190  weights.resize(basis_->num_quadratic_weights());
191  basis_->get_quadratic_weights(coords,&(weights[0]));
192  return;
193  case 3:
194  weights.resize(basis_->num_cubic_weights());
195  basis_->get_cubic_weights(coords,&(weights[0]));
196  return;
197  }
198  ASSERTFAIL("Weights of unknown order requested");
199 }
200 
201 template<class MESH>
202 void
204  std::vector<double>& weights,
205  int basis_order) const
206 {
207  switch(basis_order)
208  {
209  case 0:
210  weights.resize(1); weights[0] = 1.0;
211  return;
212  case 1:
213  weights.resize(basis_->num_linear_derivate_weights());
214  basis_->get_linear_derivate_weights(coords,&(weights[0]));
215  return;
216  case 2:
217  weights.resize(basis_->num_quadratic_derivate_weights());
218  basis_->get_quadratic_derivate_weights(coords,&(weights[0]));
219  return;
220  case 3:
221  weights.resize(basis_->num_cubic_derivate_weights());
222  basis_->get_cubic_derivate_weights(coords,&(weights[0]));
223  return;
224  }
225  ASSERTFAIL("Derivate weights of unknown order requested");
226 }
227 
228 
229 
230 template <class MESH>
233 {
234  return(mesh_->get_bounding_box());
235 }
236 
237 template <class MESH>
238 double
240 {
241  return(mesh_->get_epsilon());
242 }
243 
244 template<class MESH>
245 void
247 {
248  mesh_->transform(t);
249 }
250 
251 template<class MESH>
252 bool
254 {
255  return(mesh_->synchronize(sync));
256 }
257 
258 template<class MESH>
259 bool
261 {
262  return(mesh_->unsynchronize(sync));
263 }
264 
265 template<class MESH>
266 bool
268 {
269  return(mesh_->clear_synchronization());
270 }
271 
272 template<class MESH>
273 void
274 VMeshShared<MESH>::get_gaussian_scheme(std::vector<coords_type>& coords,
275  std::vector<double>& weights, int order) const
276 {
277  basis_->get_gaussian_scheme(coords,weights,order);
278 }
279 
280 template<class MESH>
281 void
282 VMeshShared<MESH>::get_regular_scheme(std::vector<coords_type>& coords,
283  std::vector<double>& weights, int order) const
284 {
285  basis_->get_regular_scheme(coords,weights,order);
286 }
287 
288 }
289 
290 #endif
MESH::basis_type * basis_
Definition: VMeshShared.h:162
virtual void get_gaussian_scheme(std::vector< VMesh::coords_type > &coords, std::vector< double > &weights, int order) const
Definition: VMeshShared.h:274
FieldHandle mesh()
Definition: BuildTDCSMatrixTests.cc:56
#define SCISHARE
Definition: share.h:39
Definition: BBox.h:46
virtual bool unsynchronize(unsigned int sync)
Definition: VMeshShared.h:260
Definition: Mesh.h:61
virtual ~VMeshShared()
Definition: VMeshShared.h:134
virtual void get_weights(const VMesh::coords_type &coords, std::vector< double > &weights, int basis_order) const
Definition: VMeshShared.h:176
virtual bool clear_synchronization()
Definition: VMeshShared.h:267
Definition: VMeshShared.h:40
virtual bool synchronize(unsigned int sync)
This call is for synchronizing tables of precomputed elements.
Definition: VMeshShared.h:253
MESH * mesh_
Definition: VMeshShared.h:161
virtual void transform(const Core::Geometry::Transform &t)
Definition: VMeshShared.h:246
Definition: Transform.h:53
virtual void get_derivate_weights(const VMesh::coords_type &coords, std::vector< double > &weights, int basis_order) const
Definition: VMeshShared.h:203
#define ASSERTFAIL(string)
Definition: Assert.h:52
virtual void get_regular_scheme(std::vector< VMesh::coords_type > &coords, std::vector< double > &weights, int order) const
Definition: VMeshShared.h:282
virtual Core::Geometry::BBox get_bounding_box() const
Rerouting of some of the virtual mesh function calls.
Definition: VMeshShared.h:232
VMeshShared(MESH *mesh)
Definition: VMeshShared.h:47
void resize(size_t size, const value_type &val=value_type())
Definition: StackVector.h:61
virtual void get_canonical_transform(Core::Geometry::Transform &t)
Definition: VMeshShared.h:169
virtual double get_epsilon() const
Definition: VMeshShared.h:239
Definition: Mesh.h:63
Definition: PropertyManager.h:193
Definition: VMesh.h:53