SCIRun  5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Mesh.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_LEGACY_MESH_H
31 #define CORE_DATATYPES_LEGACY_MESH_H 1
32 
34 
36 
40 
42 
43 namespace SCIRun {
44 
46 {
47 public:
48  Mesh();
49  Mesh(const Mesh& copy);
50 
51  virtual ~Mesh();
52 
53  virtual Mesh *clone() const = 0;
54 
55  virtual MeshFacadeHandle getFacade() const = 0;
56 
57  /// These will become obsolete at some point
58  enum
59  {
60  UNKNOWN = 0,
61  STRUCTURED = 1 << 1,
62  UNSTRUCTURED = 1 << 2,
63  REGULAR = 1 << 3,
64  IRREGULAR = 1 << 4
65  };
66 
67  /// Synchronize system
68  enum
69  {
70  NONE_E = 0,
71  NODES_E = 1 << 0,
72  EDGES_E = 1 << 1,
73  FACES_E = 1 << 2,
74  CELLS_E = 1 << 3,
75  ELEMS_E = 1 << 4,
76  DELEMS_E = 1 << 5,
77  ENODES_E = 1 << 6,
78  ALL_ELEMENTS_E = NODES_E | EDGES_E | FACES_E | CELLS_E | ENODES_E | ELEMS_E | DELEMS_E,
79  NORMALS_E = 1 << 7,
80  NODE_NEIGHBORS_E = 1 << 8,
81  ELEM_NEIGHBORS_E = 1 << 9,
82  NEIGHBORS_E = NODE_NEIGHBORS_E | ELEM_NEIGHBORS_E,
83  NODE_LOCATE_E = 1 << 10,
84  ELEM_LOCATE_E = 1 << 11,
85  LOCATE_E = NODE_LOCATE_E | ELEM_LOCATE_E,
86  EPSILON_E = 1 << 12,
87  BOUNDING_BOX_E = 1 << 12,
88  FIND_CLOSEST_NODE_E = 1 << 13,
89  FIND_CLOSEST_ELEM_E = 1 << 14,
90  FIND_CLOSEST_E = FIND_CLOSEST_NODE_E | FIND_CLOSEST_ELEM_E
91  };
92 
93  virtual bool synchronize(mask_type) { return false; }
94  virtual bool unsynchronize(mask_type) { return false; }
95 
96  virtual int basis_order();
97 
98  /// Persistent I/O.
99  void io(Piostream &stream);
101  static const std::string type_name(int n = -1);
102  virtual const TypeDescription *get_type_description() const = 0;
103 
104  /// Virtual interface functions:
105  /// Get the virtual mesh interface, this returns the pointer to an internal
106  /// object that has all the virtual functions. This object will be destroyed
107  /// when the mesh is destroyed. The user does not need to destroy the VMesh.
108  virtual VMesh* vmesh();
109 };
110 
112  public:
113  // Constructor
114  MeshTypeID(const std::string& type,
115  MeshHandle (*mesh_maker)());
116  MeshTypeID(const std::string& type,
117  MeshHandle (*mesh_maker)(),
118  MeshHandle (*latvol_maker)(size_type x, size_type y, size_type z, const Core::Geometry::Point& min, const Core::Geometry::Point& max)
119  );
120  MeshTypeID(const std::string& type,
121  MeshHandle (*mesh_maker)(),
122  MeshHandle (*image_maker)(size_type x, size_type y, const Core::Geometry::Point& min, const Core::Geometry::Point& max)
123  );
124  MeshTypeID(const std::string& type,
125  MeshHandle (*mesh_maker)(),
126  MeshHandle (*scanline_maker)(size_type x,const Core::Geometry::Point& min, const Core::Geometry::Point& max)
127  );
128  MeshTypeID(const std::string& type,
129  MeshHandle (*mesh_maker)(),
130  MeshHandle (*structhexvol_maker)(size_type x, size_type y, size_type z)
131  );
132  MeshTypeID(const std::string& type,
133  MeshHandle (*mesh_maker)(),
134  MeshHandle (*structquadsurf_maker)(size_type x, size_type y)
135  );
136  MeshTypeID(const std::string& type,
137  MeshHandle (*mesh_maker)(),
138  MeshHandle (*structcurve_maker)(size_type x)
139  );
140 
141 
142  std::string type;
143  MeshHandle (*mesh_maker)();
144 
145  // Custom Constructors
146  MeshHandle (*latvol_maker)(size_type x, size_type y, size_type z, const Core::Geometry::Point& min, const Core::Geometry::Point& max);
147  MeshHandle (*image_maker)(size_type x, size_type y, const Core::Geometry::Point& min, const Core::Geometry::Point& max);
148  MeshHandle (*scanline_maker)(size_type x, const Core::Geometry::Point& min, const Core::Geometry::Point& max);
149  MeshHandle (*structhexvol_maker)(size_type x, size_type y, size_type z);
150  MeshHandle (*structquadsurf_maker)(size_type x, size_type y);
151  MeshHandle (*structcurve_maker)(size_type x);
152 
153 
154 };
155 
156 
157 SCISHARE MeshHandle CreateMesh(const std::string& type);
158 SCISHARE MeshHandle CreateMesh(const std::string& type, size_type x, size_type y, size_type z, const Core::Geometry::Point& min, const Core::Geometry::Point& max);
159 SCISHARE MeshHandle CreateMesh(const std::string& type, size_type x, size_type y, const Core::Geometry::Point& min, const Core::Geometry::Point& max);
160 SCISHARE MeshHandle CreateMesh(const std::string& type, size_type x, const Core::Geometry::Point& min, const Core::Geometry::Point& max);
161 SCISHARE MeshHandle CreateMesh(const std::string& type, size_type x, size_type y, size_type z);
162 SCISHARE MeshHandle CreateMesh(const std::string& type, size_type x, size_type y);
163 SCISHARE MeshHandle CreateMesh(const std::string& type, size_type x);
164 
172 SCISHARE MeshHandle CreateMesh(FieldInformation &info,const std::vector<size_type>& x);
173 SCISHARE MeshHandle CreateMesh(FieldInformation &info,const std::vector<size_type>& x,const Core::Geometry::Point& min,const Core::Geometry::Point& max);
174 
182 SCISHARE MeshHandle CreateMesh(mesh_info_type mesh, const std::vector<size_type>& x);
183 SCISHARE MeshHandle CreateMesh(mesh_info_type mesh, const std::vector<size_type>& x,const Core::Geometry::Point& min,const Core::Geometry::Point& max);
184 
185 
186 /// General case locate, search each elem.
187 template <class INDEX, class MESH>
188 bool elem_locate(INDEX &elem,
189  MESH &msh, const Core::Geometry::Point &p)
190 {
191  typename MESH::Elem::iterator iter, end;
192  msh.begin(iter);
193  msh.end(end);
194  std::vector<double> coords(msh.dimensionality());
195  while (iter != end) {
196  if (msh.get_coords(coords, p, *iter))
197  {
198  elem = INDEX(*iter);
199  return true;
200  }
201  ++iter;
202  }
203  return false;
204 }
205 
206 
207 } // end namespace SCIRun
208 
209 #endif // Datatypes_Mesh_h
Definition: CreateMeshFromNrrd.cc:38
SCISHARE MeshHandle CreateMesh(const std::string &type)
Definition: Mesh.cc:421
std::string type
Definition: Mesh.h:142
Definition: Persistent.h:89
Definition: Mesh.h:111
Definition: CreateMeshFromNrrd.cc:38
FieldHandle mesh()
Definition: BuildTDCSMatrixTests.cc:56
Definition: Point.h:49
Definition: TypeDescription.h:45
#define SCISHARE
Definition: share.h:39
virtual bool synchronize(mask_type)
Definition: Mesh.h:93
Definition: Mesh.h:45
boost::shared_ptr< Mesh > MeshHandle
Definition: DatatypeFwd.h:67
Definition: Datatype.h:41
SCIRun::mask_type mask_type
Definition: MeshTraits.h:54
Definition: ParallelLinearAlgebraTests.cc:358
mesh_info_type
Definition: Types.h:50
long long size_type
Definition: Types.h:40
static PersistentTypeID type_id
Definition: Mesh.h:100
Definition: MeshTraits.h:51
Definition: CreateMeshFromNrrd.cc:38
Definition: CreateMeshFromNrrd.cc:38
Definition: Persistent.h:64
int n
Definition: eab.py:9
virtual bool unsynchronize(mask_type)
Definition: Mesh.h:94
Definition: CreateMeshFromNrrd.cc:38
boost::shared_ptr< MeshFacade< VMesh > > MeshFacadeHandle
Definition: MeshTraits.h:61
Definition: VMesh.h:53
Definition: FieldInformation.h:150
const TypeDescription * get_type_description(Core::Basis::ConstantBasis< T > *)
Definition: Constant.h:209
Definition: Types.h:84
bool elem_locate(INDEX &elem, MESH &msh, const Core::Geometry::Point &p)
General case locate, search each elem.
Definition: Mesh.h:188