Mesh Oriented datABase  (version 5.5.1)
An array-based unstructured mesh library
BSPTreePoly.hpp
Go to the documentation of this file.
1 #ifndef MOAB_BSP_TREE_POLY_HPP
2 #define MOAB_BSP_TREE_POLY_HPP
3 
4 #include "moab/Types.hpp"
5 #include <vector>
6 
7 namespace moab
8 {
9 
10 class CartVect;
11 
12 /**\brief Convex polyhedron
13  *
14  * This class is used to represent the convex polyhedron that bounds
15  * a node in a general plane-based BSP-tree.
16  */
18 {
19  public:
20  struct Vertex;
21  struct VertexUse;
22  struct Edge;
23  struct EdgeUse;
24  struct Face;
25 
26  private:
28 
29  void set_vertex_marks( int value );
30 
31  BSPTreePoly( const BSPTreePoly& copy ); // not implemented
32  BSPTreePoly& operator=( const BSPTreePoly& copy ); // not implemented
33 
34  public:
35  /**\brief Initialize as a planar-faced hexahedron
36  *\param hex_corners Corner coordinates for a hexahedron, in Exodus/Patran order
37  */
39  {
40  set( hex_corners );
41  }
42  BSPTreePoly() : faceList( 0 ) {}
44  {
45  clear();
46  }
47 
48  /**\brief Initialize as a planar-faced hexahedron
49  *\param hex_corners Corner coordinates for a hexahedron, in Exodus/Patran order
50  */
51  ErrorCode set( const CartVect hex_corners[8] );
52  void clear();
53 
54  /**\brief Get handles for faces */
55  void get_faces( std::vector< const Face* >& face_list ) const;
56  /**\brief Get corner coordinates for a face */
57  void get_vertices( const Face* face, std::vector< CartVect >& vertices ) const;
58 
59  /** Intersect a plane with a polyhedron, retaining
60  * the portion of the polyhedron below the plane.
61  * This will fail if polyhedron is not convex.
62  */
63  bool cut_polyhedron( const CartVect& plane_normal, double plane_coeff );
64 
65  /** Test if a point is contained in the polyhedron.
66  *
67  *\NOTE algorithm assumes *convex* polyhedron.
68  */
69  bool is_point_contained( const CartVect& point ) const;
70 
71  //! Assumes planar faces
72  double volume() const;
73 
74  // Check that data structure is consistent and represents
75  // a closed polyhedron
76  bool is_valid() const;
77 
78  /** For debugging, does nothing unless debug feature is enabled */
79  static void reset_debug_ids();
80 };
81 
82 } // namespace moab
83 
84 #endif