KJB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gr_parapiped.h
Go to the documentation of this file.
1 
34 /* =========================================================================== *
35 |
36 | Copyright (c) 1994-2008 by Kobus Barnard (author).
37 |
38 | Personal and educational use of this code is granted, provided that this
39 | header is kept intact, and that the authorship is not misrepresented, that
40 | its use is acknowledged in publications, and relevant papers are cited.
41 |
42 | For other use contact the author (kobus AT cs DOT arizona DOT edu).
43 |
44 | Please note that the code in this file has not necessarily been adequately
45 | tested. Naturally, there is no guarantee of performance, support, or fitness
46 | for any particular task. Nonetheless, I am interested in hearing about
47 | problems that you encounter.
48 |
49 | Authors:
50 | Joseph Schlecht, Luca Del Pero
51 |
52 * =========================================================================== */
53 
63 #ifndef KJB_PARAPIPED_H
64 #define KJB_PARAPIPED_H
65 
66 #include <iosfwd>
67 #include <vector>
68 
69 #include <inttypes.h>
70 
71 #include <gr_cpp/gr_polymesh.h>
73 #include <l_cpp/l_int_matrix.h>
74 
75 namespace kjb {
76 
77 
83 class Parapiped : public kjb::Polymesh
84 {
85  public:
86 
88  Parapiped
89  (
90  double x1, double y1, double z1,
91  double x2, double y2, double z2,
92  double x3, double y3, double z3,
93  double x4, double y4, double z4
94  );
95 
96 
98  Parapiped
99  (
100  const kjb::Vector & p1,
101  const kjb::Vector & p2,
102  const kjb::Vector & p3,
103  const kjb::Vector & p4
104  )
105  throw (kjb::Illegal_argument);
106 
107 
109  Parapiped(const Parapiped& p);
110 
111 
113  Parapiped(const char* fname) throw (kjb::Illegal_argument,
114  kjb::IO_error);
115 
116 
118  Parapiped(std::istream& in) throw (kjb::Illegal_argument,
119  kjb::IO_error);
120 
121 
123  virtual ~Parapiped() { };
124 
125 
127  virtual Parapiped& operator= (const Parapiped& p);
128 
129 
131  virtual Parapiped* clone() const;
132 
134  virtual void transform(const kjb::Matrix & M)
135  throw (kjb::Illegal_argument);
136 
137 
139  const kjb::Vector & get_point(size_t i) const
140  throw (kjb::Illegal_argument);
141 
142 
144  const kjb::Vector & get_center() const;
145 
150  virtual void add_face(const Polygon & face) throw (kjb::Illegal_argument);
151 
152 
154  virtual void read(std::istream& in) throw (kjb::IO_error,
156 
157 
159  virtual void write(std::ostream& out) const
160  throw (kjb::IO_error);
161 
163  void set_points
164  (
165  double x1, double y1, double z1,
166  double x2, double y2, double z2,
167  double x3, double y3, double z3,
168  double x4, double y4, double z4
169  );
170 
175  virtual unsigned int adjacent_face(unsigned int f, unsigned int e) const
177 
178  void draw_orientation_map() const;
179 
180  void draw_left_right_orientation_map() const;
181 
182  void draw_CMU_orientation_map() const;
183 
184  void draw_geometric_context_map() const;
185 
186  static int get_num_edges()
187  {
188  return 24;
189  }
190 
191  static void get_edge_indexes
192  (
193  std::vector<int> & base_edge_indexes,
194  std::vector<int> & vertical_edge_indexes,
195  std::vector<int> & top_edge_indexes
196  )
197  {
198  base_edge_indexes.push_back(2);
199  base_edge_indexes.push_back(4);
200  base_edge_indexes.push_back(12);
201  base_edge_indexes.push_back(13);
202  base_edge_indexes.push_back(14);
203  base_edge_indexes.push_back(15);
204  base_edge_indexes.push_back(18);
205  base_edge_indexes.push_back(23);
206 
207  //TODO Double check this
208  vertical_edge_indexes.push_back(1);
209  vertical_edge_indexes.push_back(3);
210  vertical_edge_indexes.push_back(5);
211  vertical_edge_indexes.push_back(7);
212  vertical_edge_indexes.push_back(17);
213  vertical_edge_indexes.push_back(19);
214  vertical_edge_indexes.push_back(20);
215  vertical_edge_indexes.push_back(22);
216 
217  top_edge_indexes.push_back(0);
218  top_edge_indexes.push_back(6);
219  top_edge_indexes.push_back(8);
220  top_edge_indexes.push_back(9);
221  top_edge_indexes.push_back(10);
222  top_edge_indexes.push_back(11);
223  top_edge_indexes.push_back(16);
224  top_edge_indexes.push_back(21);
225  }
226 
227  protected:
228 
230  std::vector<kjb::Vector > points;
231 
238 
239  private:
240 
245  Int_matrix _adjacency;
246 
250  void create_adjacency_matrix();
251 
252 };
253 
254 
255 }
256 
257 
258 #endif
void set_points(double x1, double y1, double z1, double x2, double y2, double z2, double x3, double y3, double z3, double x4, double y4, double z4)
reset the points of this parapiped
Definition: gr_parapiped.cpp:615
static void get_edge_indexes(std::vector< int > &base_edge_indexes, std::vector< int > &vertical_edge_indexes, std::vector< int > &top_edge_indexes)
Definition: gr_parapiped.h:192
Definition for the Int_matrix class, a thin wrapper on the KJB Int_matrix struct and its related func...
void draw_orientation_map() const
Definition: gr_parapiped.cpp:758
void draw_CMU_orientation_map() const
Definition: gr_parapiped.cpp:768
y2
Definition: APPgetLargeConnectedEdges.m:125
Object thrown when an index argument exceeds the size of a container.
Definition: l_exception.h:399
static int get_num_edges()
Definition: gr_parapiped.h:186
This class implements matrices, in the linear-algebra sense, restricted to integer-valued elements...
Definition: l_int_matrix.h:71
std::vector< kjb::Vector > points
Points defining this parapiped.
Definition: gr_parapiped.h:230
void draw_geometric_context_map() const
Definition: gr_parapiped.cpp:773
virtual void write(std::ostream &out) const
Writes this parallelepiped to an output stream.
Definition: gr_parapiped.cpp:519
This class implements vectors, in the linear-algebra sense, with real-valued elements.
Definition: m_vector.h:87
Parallelepiped: a hexahedron of which each face is a parallelegram.
Definition: gr_parapiped.h:83
virtual Parapiped & operator=(const Parapiped &p)
Copies a parallelepiped into this one.
Definition: gr_parapiped.cpp:396
const kjb::Vector & get_center() const
Returns the center vector for this parallelepiped.
Definition: gr_parapiped.cpp:436
Abstract class of connected polygons (faces) forming a mesh.
x1
Definition: APPgetLargeConnectedEdges.m:122
virtual void transform(const kjb::Matrix &M)
Transforms this parallelepiped.
Definition: gr_parapiped.cpp:583
virtual void read(std::istream &in)
Reads this parallelepiped from an input stream.
Definition: gr_parapiped.cpp:448
Definition: gr_polygon.h:36
Abstract class of connected polygons (faces) forming a mesh. We assume that each edge is shared betwe...
Definition: gr_polymesh.h:89
virtual ~Parapiped()
Deletes this parallelepiped.
Definition: gr_parapiped.h:123
kjb::Vector center
Center of this parallelepiped.
Definition: gr_parapiped.h:237
y1
Definition: APPgetLargeConnectedEdges.m:124
void draw_left_right_orientation_map() const
Definition: gr_parapiped.cpp:763
x2
Definition: APPgetLargeConnectedEdges.m:123
Exception often thrown when wrapped C functions return error codes.
Definition: l_exception.h:262
virtual unsigned int adjacent_face(unsigned int f, unsigned int e) const
returns the index of the face adjacent to face f along edge e This is an efficient implementation to ...
Definition: gr_parapiped.cpp:703
Object thrown when an argument to a function is not acceptable.
Definition: l_exception.h:377
get the indices of edges in each direction for i
Definition: APPgetLargeConnectedEdges.m:48
virtual void add_face(const Polygon &face)
Adds a face to this parapiped -> Not implemented here, it will throw an exception, because the use of this method will violate the constraints defining this parapiped.
Definition: gr_parapiped.cpp:753
Object thrown when input or output fails.
Definition: l_exception.h:496
This class implements matrices, in the linear-algebra sense, with real-valued elements.
Definition: m_matrix.h:94
const kjb::Vector & get_point(size_t i) const
Returns an indexed point defining this parapiped.
Definition: gr_parapiped.cpp:420
Parapiped(double x1, double y1, double z1, double x2, double y2, double z2, double x3, double y3, double z3, double x4, double y4, double z4)
Constructs a parallelepiped.
Definition: gr_parapiped.cpp:128
virtual Parapiped * clone() const
Clones this parallelepiped.
Definition: gr_parapiped.cpp:409