MOAB: Mesh Oriented datABase
(version 5.3.1)
|
00001 /** 00002 * MOAB, a Mesh-Oriented datABase, is a software component for creating, 00003 * storing and accessing finite element mesh data. 00004 * 00005 * Copyright 2004 Sandia Corporation. Under the terms of Contract 00006 * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government 00007 * retains certain rights in this software. 00008 * 00009 * This library is free software; you can redistribute it and/or 00010 * modify it under the terms of the GNU Lesser General Public 00011 * License as published by the Free Software Foundation; either 00012 * version 2.1 of the License, or (at your option) any later version. 00013 * 00014 */ 00015 00016 #ifndef SCD_VERTEX_DATA_HPP 00017 #define SCD_VERTEX_DATA_HPP 00018 00019 // 00020 // Class: ScdVertexData 00021 // 00022 // Purpose: represent a rectangular vertex block of mesh 00023 // 00024 // A ScdVertex represents a rectangular vertex block of mesh, including both vertices and 00025 // the parametric space used to address those vertices. 00026 00027 #include "SequenceData.hpp" 00028 #include "moab/HomXform.hpp" 00029 00030 namespace moab 00031 { 00032 00033 class ScdVertexData : public SequenceData 00034 { 00035 00036 private: 00037 //! parameter min/max, in homogeneous coords ijkh (extra row for stride eventually) 00038 HomCoord vertexParams[3]; 00039 00040 //! difference between max and min params plus one (i.e. # VERTICES in 00041 //! each parametric direction) 00042 int dIJK[3]; 00043 00044 //! difference between max and min params (i.e. # VERTEXS in 00045 //! each parametric direction) 00046 int dIJKm1[3]; 00047 00048 public: 00049 //! constructor 00050 ScdVertexData( const EntityHandle start_vertex, const int imin, const int jmin, const int kmin, const int imax, 00051 const int jmax, const int kmax ); 00052 00053 virtual ~ScdVertexData() {} 00054 00055 //! get handle of vertex at i, j, k 00056 EntityHandle get_vertex( const int i, const int j, const int k ) const; 00057 00058 //! get handle of vertex at homogeneous coordinates 00059 EntityHandle get_vertex( const HomCoord& coords ) const; 00060 00061 //! get the parameters of a given handle; return MB_FAILURE if vhandle not in this 00062 //! sequence 00063 ErrorCode get_params( const EntityHandle vhandle, int& i, int& j, int& k ) const; 00064 00065 //! get min params for this vertex 00066 void min_params( int& i, int& j, int& k ) const; 00067 00068 //! get max params for this vertex 00069 void max_params( int& i, int& j, int& k ) const; 00070 00071 //! get the min params 00072 const HomCoord& min_params() const; 00073 00074 //! get the max params 00075 const HomCoord& max_params() const; 00076 00077 //! get the number of vertices in each direction, inclusive 00078 void param_extents( int& di, int& dj, int& dk ) const; 00079 00080 //! convenience functions for parameter extents 00081 int i_min() const 00082 { 00083 return vertexParams[0].hom_coord()[0]; 00084 } 00085 int j_min() const 00086 { 00087 return vertexParams[0].hom_coord()[1]; 00088 } 00089 int k_min() const 00090 { 00091 return vertexParams[0].hom_coord()[2]; 00092 } 00093 int i_max() const 00094 { 00095 return vertexParams[1].hom_coord()[0]; 00096 } 00097 int j_max() const 00098 { 00099 return vertexParams[1].hom_coord()[1]; 00100 } 00101 int k_max() const 00102 { 00103 return vertexParams[1].hom_coord()[2]; 00104 } 00105 00106 //! return whether this vseq's parameter space contains these parameters 00107 bool contains( const HomCoord& coords ) const; 00108 bool contains( const int i, const int j, const int k ) const; 00109 00110 SequenceData* subset( EntityHandle start, EntityHandle end, const int* sequence_data_sizes, 00111 const int* tag_data_sizes ) const; 00112 }; 00113 00114 inline EntityHandle ScdVertexData::get_vertex( const int i, const int j, const int k ) const 00115 { 00116 return start_handle() + ( i - i_min() ) + ( j - j_min() ) * dIJK[0] + ( k - k_min() ) * dIJK[0] * dIJK[1]; 00117 } 00118 00119 inline EntityHandle ScdVertexData::get_vertex( const HomCoord& coords ) const 00120 { 00121 return get_vertex( coords.hom_coord()[0], coords.hom_coord()[1], coords.hom_coord()[2] ); 00122 } 00123 00124 inline ErrorCode ScdVertexData::get_params( const EntityHandle vhandle, int& i, int& j, int& k ) const 00125 { 00126 if( TYPE_FROM_HANDLE( vhandle ) != MBVERTEX ) return MB_FAILURE; 00127 00128 int hdiff = vhandle - start_handle(); 00129 00130 k = hdiff / ( dIJK[0] * dIJK[1] ); 00131 j = ( hdiff - ( k * dIJK[0] * dIJK[1] ) ) / dIJK[0]; 00132 i = hdiff % dIJK[0]; 00133 00134 k += vertexParams[0].k(); 00135 j += vertexParams[0].j(); 00136 i += vertexParams[0].i(); 00137 00138 return ( vhandle >= start_handle() && i >= i_min() && i <= i_max() && j >= j_min() && j <= j_max() && 00139 k >= k_min() && k <= k_max() ) 00140 ? MB_SUCCESS 00141 : MB_FAILURE; 00142 } 00143 00144 //! get min params for this vertex 00145 inline void ScdVertexData::min_params( int& i, int& j, int& k ) const 00146 { 00147 i = i_min(); 00148 j = j_min(); 00149 k = k_min(); 00150 } 00151 00152 //! get max params for this vertex 00153 inline void ScdVertexData::max_params( int& i, int& j, int& k ) const 00154 { 00155 i = i_max(); 00156 j = j_max(); 00157 k = k_max(); 00158 } 00159 00160 inline const HomCoord& ScdVertexData::min_params() const 00161 { 00162 return vertexParams[0]; 00163 } 00164 00165 inline const HomCoord& ScdVertexData::max_params() const 00166 { 00167 return vertexParams[1]; 00168 } 00169 00170 //! get the number of vertices in each direction, inclusive 00171 inline void ScdVertexData::param_extents( int& di, int& dj, int& dk ) const 00172 { 00173 di = dIJK[0]; 00174 dj = dIJK[1]; 00175 dk = dIJK[2]; 00176 } 00177 00178 inline bool ScdVertexData::contains( const HomCoord& coords ) const 00179 { 00180 return ( coords >= vertexParams[0] && coords <= vertexParams[1] ) ? true : false; 00181 } 00182 00183 inline bool ScdVertexData::contains( const int i, const int j, const int k ) const 00184 { 00185 return contains( HomCoord( i, j, k ) ); 00186 } 00187 00188 } // namespace moab 00189 00190 #endif