Mesh Oriented datABase  (version 5.5.0)
An array-based unstructured mesh library
AxisBox.cpp
Go to the documentation of this file.
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  */
15 
16 /**
17  * \brief Class representing axis-aligned bounding box
18  * \author Jason Kraftcheck ([email protected])
19  * \date August, 2006
20  */
21 
22 #include "AxisBox.hpp"
23 #include "moab/Range.hpp"
24 #include <cassert>
25 
26 namespace moab
27 {
28 
29 const char* const AXIS_BOX_TAG_NAME = "AXIS_BOX";
30 
31 ErrorCode AxisBox::get_tag( Tag& tag_out, Interface* interface, const char* tagname )
32 {
33  assert( sizeof( AxisBox ) == 6 * sizeof( double ) );
34 
35  if( !tagname ) tagname = AXIS_BOX_TAG_NAME;
36 
37  return interface->tag_get_handle( tagname, sizeof( AxisBox ), MB_TYPE_DOUBLE, tag_out,
39 }
40 
42 {
43  Range range;
44  ErrorCode rval = interface->get_entities_by_handle( set, range );
45  if( MB_SUCCESS != rval ) return rval;
46 
47  return calculate( box, range, interface );
48 }
49 
51 {
52  ErrorCode rval;
53  Range vertices;
54  Range elements;
55 
56  elements.merge( entities.upper_bound( MBVERTEX ), entities.lower_bound( MBENTITYSET ) );
57  rval = interface->get_adjacencies( elements, 0, false, vertices );
58  if( MB_SUCCESS != rval ) return rval;
59 
60  vertices.merge( entities.begin(), entities.upper_bound( MBVERTEX ) );
61 
62  std::vector< double > coords( 3 * vertices.size() );
63  rval = interface->get_coords( vertices, &coords[0] );
64  if( MB_SUCCESS != rval ) return rval;
65 
66  box = AxisBox();
67  std::vector< double >::const_iterator i = coords.begin();
68  for( ; i != coords.end(); i += 3 )
69  box |= &*i;
70 
71  return MB_SUCCESS;
72 }
73 
74 } // namespace moab