1/**
2 * MOAB, a Mesh-Oriented datABase, is a software component for creating,
3 * storing and accessing finite element mesh data.
4 *
5 * Copyright 2004 Sandia Corporation. Under the terms of Contract
6 * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government
7 * retains certain rights in this software.
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13 *
14 */1516#ifndef SWEPT_VERTEX_DATA_HPP17#define SWEPT_VERTEX_DATA_HPP1819//20// Class: SweptVertexData21//22// Purpose: represent a rectangular vertex block of mesh23//24// A SweptVertex represents a rectangular vertex block of mesh, including both vertices and25// the parametric space used to address those vertices.2627#include"SequenceData.hpp"28#include"moab/HomXform.hpp"2930namespace moab
31 {
3233classSweptVertexData : public SequenceData
34 {
3536private:
37//! parameter min/max, in homogeneous coords ijkh (extra row for stride eventually)38 HomCoord vertexParams[3];
3940//! difference between max and min params plus one (i.e. # VERTICES in41//! each parametric direction)42int dIJK[3];
4344//! difference between max and min params (i.e. # VERTEXS in45//! each parametric direction)46int dIJKm1[3];
4748public:
49//! constructor50SweptVertexData( const EntityHandle start_vertex,
51constint imin,
52constint jmin,
53constint kmin,
54constint imax,
55constint jmax,
56constint kmax );
5758virtual ~SweptVertexData() {}
5960//! get handle of vertex at i, j, k61EntityHandle get_vertex( constint i, constint j, constint k )const;
6263//! get handle of vertex at homogeneous coordinates64EntityHandle get_vertex( const HomCoord& coords )const;
6566//! get the parameters of a given handle; return MB_FAILURE if vhandle not in this67//! sequence68ErrorCode get_params( const EntityHandle vhandle, int& i, int& j, int& k )const;
6970//! get min params for this vertex71voidmin_params( int& i, int& j, int& k )const;
7273//! get max params for this vertex74voidmax_params( int& i, int& j, int& k )const;
7576//! get the min params77const HomCoord& min_params()const;
7879//! get the max params80const HomCoord& max_params()const;
8182//! get the number of vertices in each direction, inclusive83voidparam_extents( int& di, int& dj, int& dk )const;
8485//! convenience functions for parameter extents86inti_min()const
87 {
88return vertexParams[0].hom_coord()[0];
89 }
90intj_min()const
91 {
92return vertexParams[0].hom_coord()[1];
93 }
94intk_min()const
95 {
96return vertexParams[0].hom_coord()[2];
97 }
98inti_max()const
99 {
100return vertexParams[1].hom_coord()[0];
101 }
102intj_max()const
103 {
104return vertexParams[1].hom_coord()[1];
105 }
106intk_max()const
107 {
108return vertexParams[1].hom_coord()[2];
109 }
110111//! return whether this vseq's parameter space contains these parameters112boolcontains( const HomCoord& coords )const;
113boolcontains( constint i, constint j, constint k )const;
114115SequenceData* subset( EntityHandle start,
116 EntityHandle end,
117constint* sequence_data_sizes,
118constint* tag_data_sizes )const;
119 };
120121inline EntityHandle SweptVertexData::get_vertex( constint i, constint j, constint k )const
122 {
123returnstart_handle() + ( i - i_min() ) + ( j - j_min() ) * dIJK[0] + ( k - k_min() ) * dIJK[0] * dIJK[1];
124 }
125126inline EntityHandle SweptVertexData::get_vertex( const HomCoord& coords )const
127 {
128returnget_vertex( coords.hom_coord()[0], coords.hom_coord()[1], coords.hom_coord()[2] );
129 }
130131inline ErrorCode SweptVertexData::get_params( const EntityHandle vhandle, int& i, int& j, int& k )const
132 {
133if( TYPE_FROM_HANDLE( vhandle ) != MBVERTEX ) return MB_FAILURE;
134135int hdiff = vhandle - start_handle();
136137 k = hdiff / ( dIJK[0] * dIJK[1] );
138 j = ( hdiff - ( k * dIJK[0] * dIJK[1] ) ) / dIJK[0];
139 i = hdiff % dIJK[0];
140141 k += vertexParams[0].k();
142 j += vertexParams[0].j();
143 i += vertexParams[0].i();
144145return ( vhandle >= start_handle() && i >= i_min() && i <= i_max() && j >= j_min() && j <= j_max() &&
146 k >= k_min() && k <= k_max() )
147 ? MB_SUCCESS
148 : MB_FAILURE;
149 }
150151//! get min params for this vertex152inlinevoidSweptVertexData::min_params( int& i, int& j, int& k )const
153 {
154 i = i_min();
155 j = j_min();
156 k = k_min();
157 }
158159//! get max params for this vertex160inlinevoidSweptVertexData::max_params( int& i, int& j, int& k )const
161 {
162 i = i_max();
163 j = j_max();
164 k = k_max();
165 }
166167inlineconst HomCoord& SweptVertexData::min_params()const
168 {
169return vertexParams[0];
170 }
171172inlineconst HomCoord& SweptVertexData::max_params()const
173 {
174return vertexParams[1];
175 }
176177//! get the number of vertices in each direction, inclusive178inlinevoidSweptVertexData::param_extents( int& di, int& dj, int& dk )const
179 {
180 di = dIJK[0];
181 dj = dIJK[1];
182 dk = dIJK[2];
183 }
184185inlineboolSweptVertexData::contains( const HomCoord& coords )const
186 {
187return ( coords >= vertexParams[0] && coords <= vertexParams[1] ) ? true : false;
188 }
189190inlineboolSweptVertexData::contains( constint i, constint j, constint k )const
191 {
192returncontains( HomCoord( i, j, k ) );
193 }
194195 } // namespace moab196197#endif