[MOAB-dev] r2819 - MOAB/trunk
pppebay at sandia.gov
pppebay at sandia.gov
Tue Apr 14 19:57:28 CDT 2009
Author: pebay
Date: 2009-04-14 19:57:28 -0500 (Tue, 14 Apr 2009)
New Revision: 2819
Added:
MOAB/trunk/SweptElementData.cpp
MOAB/trunk/SweptElementData.hpp
MOAB/trunk/SweptVertexData.cpp
MOAB/trunk/SweptVertexData.hpp
Modified:
MOAB/trunk/ScdElementData.hpp
MOAB/trunk/SweptElementSeq.cpp
Log:
ENH: swept element data and sequence classes
Modified: MOAB/trunk/ScdElementData.hpp
===================================================================
--- MOAB/trunk/ScdElementData.hpp 2009-04-14 21:13:40 UTC (rev 2818)
+++ MOAB/trunk/ScdElementData.hpp 2009-04-15 00:57:28 UTC (rev 2819)
@@ -17,7 +17,7 @@
#define SCD_ELEMENT_DATA_HPP
//
-// Class: ScdElementSeq
+// Class: ScdElementData
//
// Purpose: represent a rectangular element of mesh
//
Added: MOAB/trunk/SweptElementData.cpp
===================================================================
--- MOAB/trunk/SweptElementData.cpp (rev 0)
+++ MOAB/trunk/SweptElementData.cpp 2009-04-15 00:57:28 UTC (rev 2819)
@@ -0,0 +1,151 @@
+/**
+ * MOAB, a Mesh-Oriented datABase, is a software component for creating,
+ * storing and accessing finite element mesh data.
+ *
+ * Copyright 2004 Sandia Corporation. Under the terms of Contract
+ * DE-AC04-94AL85000 with Sandia Coroporation, the U.S. Government
+ * retains certain rights in this software.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ */
+
+#include "SweptElementData.hpp"
+#include "SweptVertexData.hpp"
+#include "MBInterface.hpp"
+#include "MBReadUtilIface.hpp"
+#include "MBCN.hpp"
+#include "MBInternals.hpp"
+#include <assert.h>
+
+MBEntityID SweptElementData::calc_num_entities(MBEntityHandle start_handle,
+ int irange, int jrange, int krange)
+{
+ size_t result = 1;
+ switch (MBCN::Dimension(TYPE_FROM_HANDLE(start_handle))) {
+ default: result = 0; assert( false );
+ case 3: result *= krange;
+ case 2: result *= jrange;
+ case 1: result *= irange;
+ }
+ return result;
+}
+
+SweptElementData::SweptElementData(
+ MBEntityHandle start_handle,
+ const int imin, const int jmin, const int kmin,
+ const int imax, const int jmax, const int kmax,
+ const int* Cq )
+)
+ : SequenceData(0, start_handle,
+ start_handle +
+ calc_num_entities( start_handle, imax-imin, jmax-jmin, kmax-kmin )
+ - 1)
+{
+ // need to have meaningful parameters
+ assert(imax >= imin && jmax >= jmin && kmax >= kmin);
+
+ elementParams[0] = HomCoord(imin, jmin, kmin);
+ elementParams[1] = HomCoord(imax, jmax, kmax);
+ elementParams[2] = HomCoord(1, 1, 1);
+
+ // assign and compute parameter stuff
+ dIJK[0] = elementParams[1][0] - elementParams[0][0] + 1;
+ dIJK[1] = elementParams[1][1] - elementParams[0][1] + 1;
+ dIJK[2] = elementParams[1][2] - elementParams[0][2] + 1;
+ dIJKm1[0] = dIJK[0] - 1;
+ dIJKm1[1] = dIJK[1] - 1;
+ dIJKm1[2] = dIJK[2] - 1;
+}
+
+SweptElementData::~SweptElementData()
+{
+}
+
+bool SweptElementData::boundary_complete() const
+{
+ // test the bounding vertex sequences to see if they fully define the
+ // vertex parameter space for this rectangular block of elements
+
+ int p;
+ std::vector<VertexDataRef> minlist, maxlist;
+
+ // pseudo code:
+ // for each vertex sequence v:
+ for (std::vector<VertexDataRef>::const_iterator vseq = vertexSeqRefs.begin();
+ vseq != vertexSeqRefs.end(); vseq++)
+ {
+ // test min corner mincorner:
+ bool mincorner = true;
+ // for each p = (i-1,j,k), (i,j-1,k), (i,j,k-1):
+ for (p = 0; p < 3; p++) {
+
+ // for each vsequence v' != v:
+ for (std::vector<VertexDataRef>::const_iterator othervseq = vertexSeqRefs.begin();
+ othervseq != vertexSeqRefs.end(); othervseq++)
+ {
+ if (othervseq == vseq) continue;
+ // if v.min-p contained in v'
+ if ((*othervseq).contains((*vseq).minmax[0]-HomCoord::unitv[p])) {
+ // mincorner = false
+ mincorner = false;
+ break;
+ }
+ }
+ if (!mincorner) break;
+ }
+
+ bool maxcorner = true;
+ // for each p = (i-1,j,k), (i,j-1,k), (i,j,k-1):
+ for (p = 0; p < 3; p++) {
+
+ // for each vsequence v' != v:
+ for (std::vector<VertexDataRef>::const_iterator othervseq = vertexSeqRefs.begin();
+ othervseq != vertexSeqRefs.end(); othervseq++)
+ {
+ if (othervseq == vseq) continue;
+ // if v.max+p contained in v'
+ if ((*othervseq).contains((*vseq).minmax[1]+HomCoord::unitv[p])) {
+ // maxcorner = false
+ maxcorner = false;
+ break;
+ }
+ }
+ if (!maxcorner) break;
+ }
+
+ // if mincorner add to min corner list minlist
+ if (mincorner) minlist.push_back(*vseq);
+ // if maxcorner add to max corner list maxlist
+ if (maxcorner) maxlist.push_back(*vseq);
+ }
+
+ //
+ // if minlist.size = 1 & maxlist.size = 1 & minlist[0] = esequence.min &
+ // maxlist[0] = esequence.max+(1,1,1)
+ if (minlist.size() == 1 && maxlist.size() == 1 &&
+ minlist[0].minmax[0] == elementParams[0] &&
+ maxlist[0].minmax[1] == elementParams[1])
+ // complete
+ return true;
+ // else
+
+ return false;
+}
+
+
+SequenceData* SweptElementData::subset( MBEntityHandle /*start*/,
+ MBEntityHandle /*end*/,
+ const int* /*sequence_data_sizes*/,
+ const int* /*tag_data_sizes*/ ) const
+{
+ return 0;
+}
+
+unsigned long SweptElementData::get_memory_use() const
+{
+ return sizeof(*this) + vertexSeqRefs.capacity() * sizeof(VertexDataRef);
+}
Property changes on: MOAB/trunk/SweptElementData.cpp
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: MOAB/trunk/SweptElementData.hpp
===================================================================
--- MOAB/trunk/SweptElementData.hpp (rev 0)
+++ MOAB/trunk/SweptElementData.hpp 2009-04-15 00:57:28 UTC (rev 2819)
@@ -0,0 +1,307 @@
+/**
+ * MOAB, a Mesh-Oriented datABase, is a software component for creating,
+ * storing and accessing finite element mesh data.
+ *
+ * Copyright 2004 Sandia Corporation. Under the terms of Contract
+ * DE-AC04-94AL85000 with Sandia Coroporation, the U.S. Government
+ * retains certain rights in this software.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ */
+
+#ifndef SWEPT_ELEMENT_DATA_HPP
+#define SWEPT_ELEMENT_DATA_HPP
+
+//
+// Class: SweptElementData
+//
+// Purpose: represent a rectangular element of mesh
+//
+// A SweptElement represents a rectangular element of mesh, including both vertices and
+// elements, and the parametric space used to address that element. Vertex data,
+// i.e. coordinates, may not be stored directly in the element, but the element returns
+// information about the vertex handles of vertices in the element. Vertex and element
+// handles associated with the element are each contiguous.
+
+#include "SequenceData.hpp"
+#include "HomXform.hpp"
+#include "MBCN.hpp"
+#include "SweptVertexData.hpp"
+#include "MBInternals.hpp"
+#include "MBRange.hpp"
+
+#include <vector>
+#include <algorithm>
+
+ //! structure to hold references to bounding vertex blocks
+class VertexDataRef
+{
+private:
+ HomCoord minmax[2];
+ HomXform xform, invXform;
+ SweptVertexData *srcSeq;
+public:
+ friend class SweptElementData;
+
+ VertexDataRef(const HomCoord &min, const HomCoord &max,
+ const HomXform &tmp_xform, SweptVertexData *this_seq);
+
+ bool contains(const HomCoord &coords) const;
+};
+
+class SweptElementData : public SequenceData
+{
+
+private:
+
+ //! parameter min/max/stride, in homogeneous coords ijkh
+ HomCoord elementParams[3];
+
+ //! difference between max and min params plus one (i.e. # VERTICES in
+ //! each parametric direction)
+ int dIJK[3];
+
+ //! difference between max and min params (i.e. # ELEMENTS in
+ //! each parametric direction)
+ int dIJKm1[3];
+
+ //! bare constructor, so compiler doesn't create one for me
+ SweptElementData();
+
+ //! list of bounding vertex blocks
+ std::vector<VertexDataRef> vertexSeqRefs;
+
+public:
+
+ //! constructor
+ SweptElementData( MBEntityHandle start_handle,
+ const int imin, const int jmin, const int kmin,
+ const int imax, const int jmax, const int kmax
+ const int* Cq );
+
+ virtual ~SweptElementData();
+
+ //! get handle of vertex at homogeneous coords
+ inline MBEntityHandle get_vertex(const HomCoord &coords) const;
+ inline MBEntityHandle get_vertex(int i, int j, int k) const
+ { return get_vertex(HomCoord(i,j,k)); }
+
+ //! get handle of element at i, j, k
+ MBEntityHandle get_element(const int i, const int j, const int k) const;
+
+ //! get min params for this element
+ const HomCoord &min_params() const;
+
+ //! get max params for this element
+ const HomCoord &max_params() const;
+
+ //! get the number of vertices in each direction, inclusive
+ void param_extents(int &di, int &dj, int &dk) const;
+
+ //! given a handle, get the corresponding parameters
+ MBErrorCode get_params(const MBEntityHandle ehandle,
+ int &i, int &j, int &k) const;
+
+ //! convenience functions for parameter extents
+ int i_min() const {return (elementParams[0].hom_coord())[0];}
+ int j_min() const {return (elementParams[0].hom_coord())[1];}
+ int k_min() const {return (elementParams[0].hom_coord())[2];}
+ int i_max() const {return (elementParams[1].hom_coord())[0];}
+ int j_max() const {return (elementParams[1].hom_coord())[1];}
+ int k_max() const {return (elementParams[1].hom_coord())[2];}
+
+ //! test the bounding vertex sequences and determine whether they fully
+ //! define the vertices covering this element block's parameter space
+ bool boundary_complete() const;
+
+ //! test whether this sequence contains these parameters
+ inline bool contains(const HomCoord &coords) const;
+
+ //! get connectivity of an entity given entity's parameters
+ inline MBErrorCode get_params_connectivity(const int i, const int j, const int k,
+ std::vector<MBEntityHandle>& connectivity) const;
+
+ //! add a vertex seq ref to this element sequence;
+ //! if bb_input is true, bounding box (in eseq-local coords) of vseq being added
+ //! is input in bb_min and bb_max (allows partial sharing of vseq rather than the whole
+ //! vseq); if it's false, the whole vseq is referenced and the eseq-local coordinates
+ //! is computed from the transformed bounding box of the vseq
+ MBErrorCode add_vsequence(SweptVertexData *vseq,
+ const HomCoord &p1, const HomCoord &q1,
+ const HomCoord &p2, const HomCoord &q2,
+ const HomCoord &p3, const HomCoord &q3,
+ bool bb_input = false,
+ const HomCoord &bb_min = HomCoord::unitv[0],
+ const HomCoord &bb_max = HomCoord::unitv[0]);
+
+
+ SequenceData* subset( MBEntityHandle start,
+ MBEntityHandle end,
+ const int* sequence_data_sizes,
+ const int* tag_data_sizes ) const;
+
+ static MBEntityID calc_num_entities( MBEntityHandle start_handle,
+ int irange,
+ int jrange,
+ int krange );
+
+ unsigned long get_memory_use() const;
+};
+
+inline MBEntityHandle SweptElementData::get_element(const int i, const int j, const int k) const
+{
+ return start_handle() + (i-i_min()) + (j-j_min())*dIJKm1[0] + (k-k_min())*dIJKm1[0]*dIJKm1[1];
+}
+
+inline const HomCoord &SweptElementData::min_params() const
+{
+ return elementParams[0];
+}
+
+inline const HomCoord &SweptElementData::max_params() const
+{
+ return elementParams[1];
+}
+
+ //! get the number of vertices in each direction, inclusive
+inline void SweptElementData::param_extents(int &di, int &dj, int &dk) const
+{
+ di = dIJK[0];
+ dj = dIJK[1];
+ dk = dIJK[2];
+}
+
+inline MBErrorCode SweptElementData::get_params(const MBEntityHandle ehandle,
+ int &i, int &j, int &k) const
+{
+ if (TYPE_FROM_HANDLE(ehandle) != TYPE_FROM_HANDLE(start_handle())) return MB_FAILURE;
+
+ int hdiff = ehandle - start_handle();
+
+ // use double ?: test below because on some platforms, both sides of the : are
+ // evaluated, and if dIJKm1[1] is zero, that'll generate a divide-by-zero
+ k = (dIJKm1[1] > 0 ? hdiff / (dIJKm1[1] > 0 ? dIJKm1[0]*dIJKm1[1] : 1) : 0);
+ j = (hdiff - (k*dIJKm1[0]*dIJKm1[1])) / dIJKm1[0];
+ i = hdiff % dIJKm1[0];
+
+ k += elementParams[0].k();
+ j += elementParams[0].j();
+ i += elementParams[0].i();
+
+ return (ehandle >= start_handle() &&
+ ehandle < start_handle()+size() &&
+ i >= i_min() && i <= i_max() &&
+ j >= j_min() && j <= j_max() &&
+ k >= k_min() && k <= k_max()) ? MB_SUCCESS : MB_FAILURE;
+}
+
+inline bool SweptElementData::contains(const HomCoord &temp) const
+{
+ // upper bound is < instead of <= because element params max is one less
+ // than vertex params max
+ return (temp >= elementParams[0] && temp < elementParams[1]);
+}
+
+inline bool VertexDataRef::contains(const HomCoord &coords) const
+{
+ return (minmax[0] <= coords && minmax[1] >= coords);
+}
+
+inline VertexDataRef::VertexDataRef(const HomCoord &this_min, const HomCoord &this_max,
+ const HomXform &tmp_xform, SweptVertexData *this_seq)
+ : xform(tmp_xform), invXform(tmp_xform.inverse()), srcSeq(this_seq)
+{
+ minmax[0] = HomCoord(this_min);
+ minmax[1] = HomCoord(this_max);
+}
+
+inline MBEntityHandle SweptElementData::get_vertex(const HomCoord &coords) const
+{
+ assert(boundary_complete());
+ for (std::vector<VertexDataRef>::const_iterator it = vertexSeqRefs.begin();
+ it != vertexSeqRefs.end(); it++) {
+ if ((*it).minmax[0] <= coords && (*it).minmax[1] >= coords) {
+ // first get the vertex block-local parameters
+ HomCoord local_coords = coords / (*it).xform;
+
+ // now get the vertex handle for those coords
+ return (*it).srcSeq->get_vertex(local_coords);
+ }
+ }
+
+ // got here, it's an error
+ return 0;
+}
+
+inline MBErrorCode SweptElementData::add_vsequence(SweptVertexData *vseq,
+ const HomCoord &p1, const HomCoord &q1,
+ const HomCoord &p2, const HomCoord &q2,
+ const HomCoord &p3, const HomCoord &q3,
+ bool bb_input,
+ const HomCoord &bb_min,
+ const HomCoord &bb_max)
+{
+ // compute the transform given the vseq-local parameters and the mapping to
+ // this element sequence's parameters passed in minmax
+ HomXform M;
+ M.three_pt_xform(p1, q1, p2, q2, p3, q3);
+
+ // min and max in element seq's parameter system may not be same as those in
+ // vseq's system, so need to take min/max
+
+ HomCoord minmax[2];
+ if (bb_input) {
+ minmax[0] = bb_min;
+ minmax[1] = bb_max;
+ }
+ else {
+ minmax[0] = vseq->min_params() * M;
+ minmax[1] = vseq->max_params() * M;
+ }
+
+ // check against other vseq's to make sure they don't overlap
+ for (std::vector<VertexDataRef>::const_iterator vsit = vertexSeqRefs.begin();
+ vsit != vertexSeqRefs.end(); vsit++)
+ if ((*vsit).contains(minmax[0]) || (*vsit).contains(minmax[1]))
+ return MB_FAILURE;
+
+ HomCoord tmp_min(std::min(minmax[0].i(), minmax[1].i()),
+ std::min(minmax[0].j(), minmax[1].j()),
+ std::min(minmax[0].k(), minmax[1].k()));
+ HomCoord tmp_max(std::max(minmax[0].i(), minmax[1].i()),
+ std::max(minmax[0].j(), minmax[1].j()),
+ std::max(minmax[0].k(), minmax[1].k()));
+
+
+ // set up a new vertex sequence reference
+ VertexDataRef tmp_seq_ref(tmp_min, tmp_max, M, vseq);
+
+ // add to the list
+ vertexSeqRefs.push_back(tmp_seq_ref);
+
+ return MB_SUCCESS;
+}
+
+inline MBErrorCode SweptElementData::get_params_connectivity(const int i, const int j, const int k,
+ std::vector<MBEntityHandle>& connectivity) const
+{
+ if (contains(HomCoord(i, j, k)) == false) return MB_FAILURE;
+
+ connectivity.push_back(get_vertex(i, j, k));
+ connectivity.push_back(get_vertex(i+1, j, k));
+ if (MBCN::Dimension(TYPE_FROM_HANDLE(start_handle())) < 2) return MB_SUCCESS;
+ connectivity.push_back(get_vertex(i+1, j+1, k));
+ connectivity.push_back(get_vertex(i, j+1, k));
+ if (MBCN::Dimension(TYPE_FROM_HANDLE(start_handle())) < 3) return MB_SUCCESS;
+ connectivity.push_back(get_vertex(i, j, k+1));
+ connectivity.push_back(get_vertex(i+1, j, k+1));
+ connectivity.push_back(get_vertex(i+1, j+1, k+1));
+ connectivity.push_back(get_vertex(i, j+1, k+1));
+ return MB_SUCCESS;
+}
+
+#endif
Modified: MOAB/trunk/SweptElementSeq.cpp
===================================================================
--- MOAB/trunk/SweptElementSeq.cpp 2009-04-14 21:13:40 UTC (rev 2818)
+++ MOAB/trunk/SweptElementSeq.cpp 2009-04-15 00:57:28 UTC (rev 2819)
@@ -14,8 +14,8 @@
*/
#include "SweptElementSeq.hpp"
-#include "ScdVertexData.hpp"
-#include "ScdElementData.hpp"
+#include "SweptVertexData.hpp"
+#include "SweptElementData.hpp"
#include "MBInterface.hpp"
#include "MBReadUtilIface.hpp"
#include "MBCN.hpp"
@@ -31,9 +31,10 @@
jmax-jmin,
kmax-kmin ),
MBCN::VerticesPerEntity(TYPE_FROM_HANDLE(start_handle)),
- new ScdElementData( start_handle,
- imin, jmin, kmin,
- imax, jmax, kmax ) )
+ new SweptElementData( start_handle,
+ imin, jmin, kmin,
+ imax, jmax, kmax,
+ Cq ) )
{
}
Added: MOAB/trunk/SweptVertexData.cpp
===================================================================
--- MOAB/trunk/SweptVertexData.cpp (rev 0)
+++ MOAB/trunk/SweptVertexData.cpp 2009-04-15 00:57:28 UTC (rev 2819)
@@ -0,0 +1,49 @@
+/**
+ * MOAB, a Mesh-Oriented datABase, is a software component for creating,
+ * storing and accessing finite element mesh data.
+ *
+ * Copyright 2004 Sandia Corporation. Under the terms of Contract
+ * DE-AC04-94AL85000 with Sandia Coroporation, the U.S. Government
+ * retains certain rights in this software.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ */
+
+#include "SweptVertexData.hpp"
+#include <assert.h>
+
+ //! constructor
+SweptVertexData::SweptVertexData(const MBEntityHandle start_vertex,
+ const int imin, const int jmin, const int kmin,
+ const int imax, const int jmax, const int kmax)
+ : SequenceData( 3, start_vertex,
+ start_vertex + (imax-imin+1)*(jmax-jmin+1)*(kmax-kmin+1) - 1 )
+{
+ // need to have meaningful parameters
+ assert(imax >= imin && jmax >= jmin && kmax >= kmin);
+
+ vertexParams[0] = HomCoord(imin, jmin, kmin);
+ vertexParams[1] = HomCoord(imax, jmax, kmax);
+ vertexParams[2] = HomCoord(1,1,1);
+
+ dIJK[0] = imax-imin+1; dIJK[1] = jmax-jmin+1; dIJK[2] = kmax-kmin+1;
+ dIJKm1[0] = dIJK[0]-1;
+ dIJKm1[1] = dIJK[1]-1;
+ dIJKm1[2] = dIJK[2]-1;
+
+ create_sequence_data( 0, sizeof(double) );
+ create_sequence_data( 1, sizeof(double) );
+ create_sequence_data( 2, sizeof(double) );
+}
+
+SequenceData* SweptVertexData::subset( MBEntityHandle /*start*/,
+ MBEntityHandle /*end*/,
+ const int* /*sequence_data_sizes*/,
+ const int* /*tag_data_sizes*/ ) const
+{
+ return 0;
+}
Property changes on: MOAB/trunk/SweptVertexData.cpp
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: MOAB/trunk/SweptVertexData.hpp
===================================================================
--- MOAB/trunk/SweptVertexData.hpp (rev 0)
+++ MOAB/trunk/SweptVertexData.hpp 2009-04-15 00:57:28 UTC (rev 2819)
@@ -0,0 +1,176 @@
+/**
+ * MOAB, a Mesh-Oriented datABase, is a software component for creating,
+ * storing and accessing finite element mesh data.
+ *
+ * Copyright 2004 Sandia Corporation. Under the terms of Contract
+ * DE-AC04-94AL85000 with Sandia Coroporation, the U.S. Government
+ * retains certain rights in this software.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ */
+
+#ifndef SWEPT_VERTEX_DATA_HPP
+#define SWEPT_VERTEX_DATA_HPP
+
+//
+// Class: SweptVertexData
+//
+// Purpose: represent a rectangular vertex block of mesh
+//
+// A SweptVertex represents a rectangular vertex block of mesh, including both vertices and
+// the parametric space used to address those vertices.
+
+#include "SequenceData.hpp"
+#include "HomXform.hpp"
+
+class SweptVertexData : public SequenceData
+{
+
+private:
+
+ //! parameter min/max, in homogeneous coords ijkh (extra row for stride eventually)
+ HomCoord vertexParams[3];
+
+ //! difference between max and min params plus one (i.e. # VERTICES in
+ //! each parametric direction)
+ int dIJK[3];
+
+ //! difference between max and min params (i.e. # VERTEXS in
+ //! each parametric direction)
+ int dIJKm1[3];
+
+public:
+
+ //! constructor
+ SweptVertexData(const MBEntityHandle start_vertex,
+ const int imin, const int jmin, const int kmin,
+ const int imax, const int jmax, const int kmax) ;
+
+ virtual ~SweptVertexData() {};
+
+ //! get handle of vertex at i, j, k
+ MBEntityHandle get_vertex(const int i, const int j, const int k) const;
+
+ //! get handle of vertex at homogeneous coordinates
+ MBEntityHandle get_vertex(const HomCoord &coords) const;
+
+ //! get the parameters of a given handle; return MB_FAILURE if vhandle not in this
+ //! sequence
+ MBErrorCode get_params(const MBEntityHandle vhandle,
+ int &i, int &j, int &k) const;
+
+ //! get min params for this vertex
+ void min_params(int &i, int &j, int &k) const;
+
+ //! get max params for this vertex
+ void max_params(int &i, int &j, int &k) const;
+
+ //! get the min params
+ const HomCoord &min_params() const;
+
+ //! get the max params
+ const HomCoord &max_params() const;
+
+ //! get the number of vertices in each direction, inclusive
+ void param_extents(int &di, int &dj, int &dk) const;
+
+ //! convenience functions for parameter extents
+ int i_min() const {return vertexParams[0].hom_coord()[0];}
+ int j_min() const {return vertexParams[0].hom_coord()[1];}
+ int k_min() const {return vertexParams[0].hom_coord()[2];}
+ int i_max() const {return vertexParams[1].hom_coord()[0];}
+ int j_max() const {return vertexParams[1].hom_coord()[1];}
+ int k_max() const {return vertexParams[1].hom_coord()[2];}
+
+ //! return whether this vseq's parameter space contains these parameters
+ bool contains(const HomCoord &coords) const;
+ bool contains(const int i, const int j, const int k) const;
+
+ SequenceData* subset( MBEntityHandle start,
+ MBEntityHandle end,
+ const int* sequence_data_sizes,
+ const int* tag_data_sizes ) const;
+};
+
+inline MBEntityHandle SweptVertexData::get_vertex(const int i, const int j,
+ const int k) const
+{
+ return start_handle() + (i-i_min()) + (j-j_min())*dIJK[0] +
+ (k-k_min())*dIJK[0]*dIJK[1];
+}
+
+inline MBEntityHandle SweptVertexData::get_vertex(const HomCoord &coords) const
+{
+ return get_vertex(coords.hom_coord()[0], coords.hom_coord()[1], coords.hom_coord()[2]);
+}
+
+inline MBErrorCode SweptVertexData::get_params(const MBEntityHandle vhandle,
+ int &i, int &j, int &k) const
+{
+ if (TYPE_FROM_HANDLE(vhandle) != MBVERTEX) return MB_FAILURE;
+
+ int hdiff = vhandle - start_handle();
+
+ k = hdiff / (dIJK[0]*dIJK[1]);
+ j = (hdiff - (k*dIJK[0]*dIJK[1])) / dIJK[0];
+ i = hdiff % dIJK[0];
+
+ k += vertexParams[0].k();
+ j += vertexParams[0].j();
+ i += vertexParams[0].i();
+
+ return (vhandle >= start_handle() &&
+ i >= i_min() && i <= i_max() &&
+ j >= j_min() && j <= j_max() &&
+ k >= k_min() && k <= k_max()) ? MB_SUCCESS : MB_FAILURE;
+}
+
+ //! get min params for this vertex
+inline void SweptVertexData::min_params(int &i, int &j, int &k) const
+{
+ i = i_min();
+ j = j_min();
+ k = k_min();
+}
+
+//! get max params for this vertex
+inline void SweptVertexData::max_params(int &i, int &j, int &k) const
+{
+ i = i_max();
+ j = j_max();
+ k = k_max();
+}
+
+inline const HomCoord &SweptVertexData::min_params() const
+{
+ return vertexParams[0];
+}
+
+inline const HomCoord &SweptVertexData::max_params() const
+{
+ return vertexParams[1];
+}
+
+ //! get the number of vertices in each direction, inclusive
+inline void SweptVertexData::param_extents(int &di, int &dj, int &dk) const
+{
+ di = dIJK[0];
+ dj = dIJK[1];
+ dk = dIJK[2];
+}
+
+inline bool SweptVertexData::contains(const HomCoord &coords) const
+{
+ return (coords >= vertexParams[0] && coords <= vertexParams[1]) ? true : false;
+}
+
+inline bool SweptVertexData::contains(const int i, const int j, const int k) const
+{
+ return contains(HomCoord(i, j, k));
+}
+
+#endif
More information about the moab-dev
mailing list