Line data Source code
1 : /*
2 : * Copyright (c) 2011-2015: G-CSC, Goethe University Frankfurt
3 : * Author: Sebastian Reiter
4 : *
5 : * This file is part of UG4.
6 : *
7 : * UG4 is free software: you can redistribute it and/or modify it under the
8 : * terms of the GNU Lesser General Public License version 3 (as published by the
9 : * Free Software Foundation) with the following additional attribution
10 : * requirements (according to LGPL/GPL v3 §7):
11 : *
12 : * (1) The following notice must be displayed in the Appropriate Legal Notices
13 : * of covered and combined works: "Based on UG4 (www.ug4.org/license)".
14 : *
15 : * (2) The following notice must be displayed at a prominent place in the
16 : * terminal output of covered works: "Based on UG4 (www.ug4.org/license)".
17 : *
18 : * (3) The following bibliography is recommended for citation and must be
19 : * preserved in all covered files:
20 : * "Reiter, S., Vogel, A., Heppner, I., Rupp, M., and Wittum, G. A massively
21 : * parallel geometric multigrid solver on hierarchically distributed grids.
22 : * Computing and visualization in science 16, 4 (2013), 151-164"
23 : * "Vogel, A., Reiter, S., Rupp, M., Nägel, A., and Wittum, G. UG4 -- a novel
24 : * flexible software system for simulating pde based models on high performance
25 : * computers. Computing and visualization in science 16, 4 (2013), 165-179"
26 : *
27 : * This program is distributed in the hope that it will be useful,
28 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
29 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 : * GNU Lesser General Public License for more details.
31 : */
32 :
33 : #ifndef __H__UG__grid_objects_3d__
34 : #define __H__UG__grid_objects_3d__
35 :
36 : #include "../grid/grid.h"
37 : #include "common/math/ugmath.h"
38 : #include "common/assert.h"
39 : #include "grid_objects_0d.h"
40 : #include "grid_objects_1d.h"
41 : #include "grid_objects_2d.h"
42 :
43 : namespace ug
44 : {
45 :
46 : ////////////////////////////////////////////////////////////////////////
47 : /// These numbers define where in the volume-section-container a volume will be stored.
48 : /** The order of the constants must not be changed! Algorithms may exist that rely on it.*/
49 : enum VolumeContainerSections
50 : {
51 : CSVOL_NONE = -1,
52 : CSVOL_TETRAHEDRON = 0,
53 : CSVOL_HEXAHEDRON = 1,
54 : CSVOL_PRISM = 2,
55 : CSVOL_PYRAMID = 3,
56 : CSVOL_OCTAHEDRON = 4
57 : };
58 :
59 : ////////////////////////////////////////////////////////////////////////
60 : // TetrahedronDescriptor
61 : /// only used to initialize a tetrahedron. for all other tasks you should use VolumeDescripor.
62 : /**
63 : * please be sure to pass the vertices in the correct order:
64 : * v1, v2, v3: bottom-vertices in counterclockwise order (if viewed from the top).
65 : * v4: top
66 : */
67 : class UG_API TetrahedronDescriptor
68 : {
69 : public:
70 : TetrahedronDescriptor() {}
71 : TetrahedronDescriptor(const TetrahedronDescriptor& td);
72 : TetrahedronDescriptor(const VolumeVertices& vv);
73 : TetrahedronDescriptor(Vertex* v1, Vertex* v2, Vertex* v3, Vertex* v4);
74 :
75 : inline uint num_vertices() const {return 4;}
76 0 : inline Vertex* vertex(size_t index) const {return m_vertex[index];}
77 :
78 : protected:
79 : Vertex* m_vertex[4];
80 : };
81 :
82 : ////////////////////////////////////////////////////////////////////////
83 : // Tetrahedron
84 : /// the most simple volume-element.
85 : /**
86 : * order of vertices should be the same as described in \sa TetrahedronDescriptor
87 : *
88 : * \ingroup lib_grid_grid_objects
89 : */
90 : class UG_API Tetrahedron : public Volume
91 : {
92 : public:
93 : typedef Volume BaseClass;
94 :
95 : static const size_t NUM_VERTICES = 4;
96 :
97 : public:
98 : inline static bool type_match(GridObject* pObj) {return dynamic_cast<Tetrahedron*>(pObj) != NULL;}
99 :
100 0 : Tetrahedron() {}
101 : Tetrahedron(const TetrahedronDescriptor& td);
102 : Tetrahedron(Vertex* v1, Vertex* v2, Vertex* v3, Vertex* v4);
103 :
104 0 : virtual GridObject* create_empty_instance() const {return new Tetrahedron;}
105 :
106 0 : virtual Vertex* vertex(size_t index) const {return m_vertices[index];}
107 0 : virtual ConstVertexArray vertices() const {return m_vertices;}
108 0 : virtual size_t num_vertices() const {return 4;}
109 :
110 : virtual EdgeDescriptor edge_desc(int index) const;
111 : virtual void edge_desc(int index, EdgeDescriptor& edOut) const;
112 : virtual uint num_edges() const;
113 :
114 : virtual FaceDescriptor face_desc(int index) const;
115 : virtual void face_desc(int index, FaceDescriptor& fdOut) const;
116 : virtual uint num_faces() const;
117 :
118 : virtual Edge* create_edge(int index); ///< create the edge with index i and return it.
119 : virtual Face* create_face(int index); ///< create the face with index i and return it.
120 :
121 : virtual void get_vertex_indices_of_edge(size_t& ind1Out,
122 : size_t& ind2Out,
123 : size_t edgeInd) const;
124 :
125 : virtual void get_vertex_indices_of_face(std::vector<size_t>& indsOut,
126 : size_t side) const;
127 :
128 : virtual int get_edge_index_from_vertices( const size_t vi0,
129 : const size_t vi1) const;
130 :
131 : virtual int get_face_edge_index ( const size_t faceInd,
132 : const size_t faceEdgeInd) const;
133 :
134 : virtual std::pair<GridBaseObjectId, int> get_opposing_object(Vertex* vrt) const;
135 :
136 : /// Creates new volume elements through refinement.
137 : /** Make sure that newEdgeVertices contains 6 vertex pointers.
138 : * newFaceVertices is ignored for Tetrahedrons.*/
139 : virtual bool refine(std::vector<Volume*>& vNewVolumesOut,
140 : Vertex** ppNewVertexOut,
141 : Vertex** newEdgeVertices,
142 : Vertex** newFaceVertices,
143 : Vertex* newVolumeVertex,
144 : const Vertex& prototypeVertex,
145 : Vertex** pSubstituteVertices = NULL,
146 : vector3* corners = NULL,
147 : bool* isSnapPoint = NULL);
148 :
149 : virtual bool is_regular_ref_rule(int edgeMarks) const;
150 :
151 : virtual bool collapse_edge(std::vector<Volume*>& vNewVolumesOut,
152 : int edgeIndex, Vertex* newVertex,
153 : std::vector<Vertex*>* pvSubstituteVertices = NULL);
154 :
155 : virtual void get_flipped_orientation(VolumeDescriptor& vdOut) const;
156 :
157 0 : virtual int container_section() const
158 0 : {return CSVOL_TETRAHEDRON;}
159 :
160 0 : virtual ReferenceObjectID reference_object_id() const
161 0 : {return ROID_TETRAHEDRON;}
162 :
163 : protected:
164 0 : virtual void set_vertex(uint index, Vertex* pVrt) {m_vertices[index] = pVrt;}
165 :
166 : protected:
167 : Vertex* m_vertices[4];
168 : };
169 :
170 : template <>
171 : class geometry_traits<Tetrahedron>
172 : {
173 : public:
174 : typedef GenericGridObjectIterator<Tetrahedron*, VolumeIterator> iterator;
175 : typedef ConstGenericGridObjectIterator<Tetrahedron*, VolumeIterator,
176 : ConstVolumeIterator> const_iterator;
177 :
178 : typedef TetrahedronDescriptor Descriptor;
179 : typedef Volume grid_base_object;
180 :
181 : enum
182 : {
183 : CONTAINER_SECTION = CSVOL_TETRAHEDRON,
184 : BASE_OBJECT_ID = VOLUME
185 : };
186 : static const ReferenceObjectID REFERENCE_OBJECT_ID = ROID_TETRAHEDRON;
187 : };
188 :
189 : typedef geometry_traits<Tetrahedron>::iterator TetrahedronIterator;
190 : typedef geometry_traits<Tetrahedron>::const_iterator ConstTetrahedronIterator;
191 :
192 :
193 :
194 : ////////////////////////////////////////////////////////////////////////
195 : // HexahedronDescriptor
196 : /// only used to initialize a hexahedron. for all other tasks you should use VolumeDescriptor.
197 : /**
198 : * please be sure to pass the vertices in the correct order:
199 : * v1, v2, v3, v4: bottom-vertices in counterclockwise order (if viewed from the top).
200 : * v5, v6, v7, v8: top-vertices in counterclockwise order (if viewed from the top).
201 : */
202 : class UG_API HexahedronDescriptor
203 : {
204 : public:
205 : HexahedronDescriptor() {}
206 : HexahedronDescriptor(const HexahedronDescriptor& td);
207 : HexahedronDescriptor(const VolumeVertices& vv);
208 : HexahedronDescriptor(Vertex* v1, Vertex* v2, Vertex* v3, Vertex* v4,
209 : Vertex* v5, Vertex* v6, Vertex* v7, Vertex* v8);
210 :
211 : inline uint num_vertices() const {return 8;}
212 0 : inline Vertex* vertex(size_t index) const {return m_vertex[index];}
213 :
214 : protected:
215 : Vertex* m_vertex[8];
216 : };
217 :
218 : ////////////////////////////////////////////////////////////////////////
219 : // Hexahedron
220 : /// A volume element with 6 quadrilateral sides.
221 : /**
222 : * Order of vertices should be the same as described in \sa HexahedronDescriptor
223 : *
224 : * \ingroup lib_grid_grid_objects
225 : */
226 0 : class UG_API Hexahedron : public Volume
227 : {
228 : public:
229 : typedef Volume BaseClass;
230 :
231 : static const size_t NUM_VERTICES = 8;
232 :
233 : public:
234 : inline static bool type_match(GridObject* pObj) {return dynamic_cast<Hexahedron*>(pObj) != NULL;}
235 :
236 0 : Hexahedron() {}
237 : Hexahedron(const HexahedronDescriptor& td);
238 : Hexahedron(Vertex* v1, Vertex* v2, Vertex* v3, Vertex* v4,
239 : Vertex* v5, Vertex* v6, Vertex* v7, Vertex* v8);
240 :
241 0 : virtual GridObject* create_empty_instance() const {return new Hexahedron;}
242 :
243 0 : virtual Vertex* vertex(size_t index) const {return m_vertices[index];}
244 0 : virtual ConstVertexArray vertices() const {return m_vertices;}
245 0 : virtual size_t num_vertices() const {return 8;}
246 :
247 : virtual EdgeDescriptor edge_desc(int index) const;
248 : virtual void edge_desc(int index, EdgeDescriptor& edOut) const;
249 : virtual uint num_edges() const;
250 :
251 : virtual FaceDescriptor face_desc(int index) const;
252 : virtual void face_desc(int index, FaceDescriptor& fdOut) const;
253 : virtual uint num_faces() const;
254 :
255 : virtual Edge* create_edge(int index); ///< create the edge with index i and return it.
256 : virtual Face* create_face(int index); ///< create the face with index i and return it.
257 :
258 : virtual void get_vertex_indices_of_edge(size_t& ind1Out,
259 : size_t& ind2Out,
260 : size_t edgeInd) const;
261 :
262 : virtual void get_vertex_indices_of_face(std::vector<size_t>& indsOut,
263 : size_t side) const;
264 :
265 : virtual int get_edge_index_from_vertices( const size_t vi0,
266 : const size_t vi1) const;
267 :
268 : virtual int get_face_edge_index ( const size_t faceInd,
269 : const size_t faceEdgeInd) const;
270 :
271 : virtual bool get_opposing_side(FaceVertices* f, FaceDescriptor& fdOut) const;
272 :
273 : virtual std::pair<GridBaseObjectId, int> get_opposing_object(Vertex* vrt) const;
274 :
275 : /// see Volume::refine for a detailed description.
276 : virtual bool refine(std::vector<Volume*>& vNewVolumesOut,
277 : Vertex** ppNewVertexOut,
278 : Vertex** newEdgeVertices,
279 : Vertex** newFaceVertices,
280 : Vertex* newVolumeVertex,
281 : const Vertex& prototypeVertex,
282 : Vertex** pSubstituteVertices = NULL,
283 : vector3* corners = NULL,
284 : bool* isSnapPoint = NULL);
285 :
286 : virtual bool is_regular_ref_rule(int edgeMarks) const;
287 :
288 : virtual bool collapse_edge(std::vector<Volume*>& vNewVolumesOut,
289 : int edgeIndex, Vertex* newVertex,
290 : std::vector<Vertex*>* pvSubstituteVertices = NULL);
291 :
292 : virtual void get_flipped_orientation(VolumeDescriptor& vdOut) const;
293 :
294 0 : virtual int container_section() const {return CSVOL_HEXAHEDRON;}
295 0 : virtual ReferenceObjectID reference_object_id() const {return ROID_HEXAHEDRON;}
296 :
297 : protected:
298 0 : virtual void set_vertex(uint index, Vertex* pVrt) {m_vertices[index] = pVrt;}
299 :
300 : protected:
301 : Vertex* m_vertices[8];
302 : };
303 :
304 : template <>
305 : class geometry_traits<Hexahedron>
306 : {
307 : public:
308 : typedef GenericGridObjectIterator<Hexahedron*, VolumeIterator> iterator;
309 : typedef ConstGenericGridObjectIterator<Hexahedron*, VolumeIterator,
310 : ConstVolumeIterator> const_iterator;
311 :
312 : typedef HexahedronDescriptor Descriptor;
313 : typedef Volume grid_base_object;
314 :
315 : enum
316 : {
317 : CONTAINER_SECTION = CSVOL_HEXAHEDRON,
318 : BASE_OBJECT_ID = VOLUME
319 : };
320 : static const ReferenceObjectID REFERENCE_OBJECT_ID = ROID_HEXAHEDRON;
321 : };
322 :
323 : typedef geometry_traits<Hexahedron>::iterator HexahedronIterator;
324 : typedef geometry_traits<Hexahedron>::const_iterator ConstHexahedronIterator;
325 :
326 :
327 : ////////////////////////////////////////////////////////////////////////
328 : // PrismDescriptor
329 : /// only used to initialize a prism. for all other tasks you should use VolumeDescripor.
330 : /**
331 : * please be sure to pass the vertices in the correct order:
332 : * v1, v2, v3: bottom-vertices in counterclockwise order (if viewed from the top).
333 : * v4, v5, v6: top-vertices in counterclockwise order (if viewed from the top).
334 : */
335 : class UG_API PrismDescriptor
336 : {
337 : public:
338 : PrismDescriptor() {}
339 : PrismDescriptor(const PrismDescriptor& td);
340 : PrismDescriptor(const VolumeVertices& vv);
341 : PrismDescriptor(Vertex* v1, Vertex* v2, Vertex* v3,
342 : Vertex* v4, Vertex* v5, Vertex* v6);
343 :
344 : inline uint num_vertices() const {return 6;}
345 0 : inline Vertex* vertex(size_t index) const {return m_vertex[index];}
346 :
347 : protected:
348 : Vertex* m_vertex[6];
349 : };
350 :
351 : ////////////////////////////////////////////////////////////////////////
352 : // Prism
353 : /// A volume element with 2 triangle and 3 quadrilateral sides.
354 : /**
355 : * order of vertices should be the same as described in \sa PrismDescriptor
356 : *
357 : * \ingroup lib_grid_grid_objects
358 : */
359 0 : class UG_API Prism : public Volume
360 : {
361 : public:
362 : typedef Volume BaseClass;
363 :
364 : static const size_t NUM_VERTICES = 6;
365 :
366 : public:
367 : inline static bool type_match(GridObject* pObj) {return dynamic_cast<Prism*>(pObj) != NULL;}
368 :
369 0 : Prism() {}
370 : Prism(const PrismDescriptor& td);
371 : Prism(Vertex* v1, Vertex* v2, Vertex* v3,
372 : Vertex* v4, Vertex* v5, Vertex* v6);
373 :
374 0 : virtual GridObject* create_empty_instance() const {return new Prism;}
375 :
376 0 : virtual Vertex* vertex(size_t index) const {return m_vertices[index];}
377 0 : virtual ConstVertexArray vertices() const {return m_vertices;}
378 0 : virtual size_t num_vertices() const {return 6;}
379 :
380 : virtual EdgeDescriptor edge_desc(int index) const;
381 : virtual void edge_desc(int index, EdgeDescriptor& edOut) const;
382 : virtual uint num_edges() const;
383 :
384 : virtual FaceDescriptor face_desc(int index) const;
385 : virtual void face_desc(int index, FaceDescriptor& fdOut) const;
386 : virtual uint num_faces() const;
387 :
388 : virtual Edge* create_edge(int index); ///< create the edge with index i and return it.
389 : virtual Face* create_face(int index); ///< create the face with index i and return it.
390 :
391 : virtual void get_vertex_indices_of_edge(size_t& ind1Out,
392 : size_t& ind2Out,
393 : size_t edgeInd) const;
394 :
395 : virtual void get_vertex_indices_of_face(std::vector<size_t>& indsOut,
396 : size_t side) const;
397 :
398 : virtual int get_edge_index_from_vertices( const size_t vi0,
399 : const size_t vi1) const;
400 :
401 : virtual int get_face_edge_index ( const size_t faceInd,
402 : const size_t faceEdgeInd) const;
403 :
404 : virtual bool get_opposing_side(FaceVertices* f, FaceDescriptor& fdOut) const;
405 :
406 : virtual std::pair<GridBaseObjectId, int> get_opposing_object(Vertex* vrt) const;
407 :
408 : /// see Volume::refine for a detailed description.
409 : virtual bool refine(std::vector<Volume*>& vNewVolumesOut,
410 : Vertex** ppNewVertexOut,
411 : Vertex** newEdgeVertices,
412 : Vertex** newFaceVertices,
413 : Vertex* newVolumeVertex,
414 : const Vertex& prototypeVertex,
415 : Vertex** pSubstituteVertices = NULL,
416 : vector3* corners = NULL,
417 : bool* isSnapPoint = NULL);
418 :
419 : virtual bool is_regular_ref_rule(int edgeMarks) const;
420 :
421 : virtual bool collapse_edge(std::vector<Volume*>& vNewVolumesOut,
422 : int edgeIndex, Vertex* newVertex,
423 : std::vector<Vertex*>* pvSubstituteVertices = NULL);
424 :
425 : virtual void get_flipped_orientation(VolumeDescriptor& vdOut) const;
426 :
427 0 : virtual int container_section() const {return CSVOL_PRISM;}
428 0 : virtual ReferenceObjectID reference_object_id() const {return ROID_PRISM;}
429 :
430 : protected:
431 0 : virtual void set_vertex(uint index, Vertex* pVrt) {m_vertices[index] = pVrt;}
432 :
433 : protected:
434 : Vertex* m_vertices[6];
435 : };
436 :
437 : template <>
438 : class geometry_traits<Prism>
439 : {
440 : public:
441 : typedef GenericGridObjectIterator<Prism*, VolumeIterator> iterator;
442 : typedef ConstGenericGridObjectIterator<Prism*, VolumeIterator,
443 : ConstVolumeIterator> const_iterator;
444 :
445 : typedef PrismDescriptor Descriptor;
446 : typedef Volume grid_base_object;
447 :
448 : enum
449 : {
450 : CONTAINER_SECTION = CSVOL_PRISM,
451 : BASE_OBJECT_ID = VOLUME
452 : };
453 : static const ReferenceObjectID REFERENCE_OBJECT_ID = ROID_PRISM;
454 : };
455 :
456 : typedef geometry_traits<Prism>::iterator PrismIterator;
457 : typedef geometry_traits<Prism>::const_iterator ConstPrismIterator;
458 :
459 :
460 : ////////////////////////////////////////////////////////////////////////
461 : // PyramidDescriptor
462 : /// only used to initialize a pyramids. for all other tasks you should use VolumeDescripor.
463 : /**
464 : * please be sure to pass the vertices in the correct order:
465 : * v1, v2, v3, v4: bottom-vertices in counterclockwise order (if viewed from the top).
466 : * v5: top-vertex.
467 : */
468 : class UG_API PyramidDescriptor
469 : {
470 : public:
471 : PyramidDescriptor() {}
472 : PyramidDescriptor(const PyramidDescriptor& td);
473 : PyramidDescriptor(const VolumeVertices& vv);
474 : PyramidDescriptor(Vertex* v1, Vertex* v2, Vertex* v3,
475 : Vertex* v4, Vertex* v5);
476 :
477 : inline uint num_vertices() const {return 5;}
478 0 : inline Vertex* vertex(size_t index) const {return m_vertex[index];}
479 :
480 : protected:
481 : Vertex* m_vertex[5];
482 : };
483 :
484 : ////////////////////////////////////////////////////////////////////////
485 : // Pyramid
486 : /// A volume element with 4 triangle and 1 quadrilateral sides.
487 : /**
488 : * order of vertices should be the same as described in \sa PyramidDescriptor
489 : *
490 : * \ingroup lib_grid_grid_objects
491 : */
492 : class UG_API Pyramid : public Volume
493 : {
494 : public:
495 : typedef Volume BaseClass;
496 :
497 : static const size_t NUM_VERTICES = 5;
498 :
499 : public:
500 : inline static bool type_match(GridObject* pObj) {return dynamic_cast<Pyramid*>(pObj) != NULL;}
501 :
502 0 : Pyramid() {}
503 : Pyramid(const PyramidDescriptor& td);
504 : Pyramid(Vertex* v1, Vertex* v2, Vertex* v3,
505 : Vertex* v4, Vertex* v5);
506 :
507 0 : virtual GridObject* create_empty_instance() const {return new Pyramid;}
508 :
509 0 : virtual Vertex* vertex(size_t index) const {return m_vertices[index];}
510 0 : virtual ConstVertexArray vertices() const {return m_vertices;}
511 0 : virtual size_t num_vertices() const {return 5;}
512 :
513 : virtual EdgeDescriptor edge_desc(int index) const;
514 : virtual void edge_desc(int index, EdgeDescriptor& edOut) const;
515 : virtual uint num_edges() const;
516 :
517 : virtual FaceDescriptor face_desc(int index) const;
518 : virtual void face_desc(int index, FaceDescriptor& fdOut) const;
519 : virtual uint num_faces() const;
520 :
521 : virtual Edge* create_edge(int index); ///< create the edge with index i and return it.
522 : virtual Face* create_face(int index); ///< create the face with index i and return it.
523 :
524 : virtual void get_vertex_indices_of_edge(size_t& ind1Out,
525 : size_t& ind2Out,
526 : size_t edgeInd) const;
527 :
528 : virtual void get_vertex_indices_of_face(std::vector<size_t>& indsOut,
529 : size_t side) const;
530 :
531 : virtual int get_edge_index_from_vertices( const size_t vi0,
532 : const size_t vi1) const;
533 :
534 : virtual int get_face_edge_index ( const size_t faceInd,
535 : const size_t faceEdgeInd) const;
536 :
537 : virtual std::pair<GridBaseObjectId, int> get_opposing_object(Vertex* vrt) const;
538 :
539 : /// see Volume::refine for a detailed description.
540 : virtual bool refine(std::vector<Volume*>& vNewVolumesOut,
541 : Vertex** ppNewVertexOut,
542 : Vertex** newEdgeVertices,
543 : Vertex** newFaceVertices,
544 : Vertex* newVolumeVertex,
545 : const Vertex& prototypeVertex,
546 : Vertex** pSubstituteVertices = NULL,
547 : vector3* corners = NULL,
548 : bool* isSnapPoint = NULL);
549 :
550 : virtual bool is_regular_ref_rule(int edgeMarks) const;
551 :
552 : virtual bool collapse_edge(std::vector<Volume*>& vNewVolumesOut,
553 : int edgeIndex, Vertex* newVertex,
554 : std::vector<Vertex*>* pvSubstituteVertices = NULL);
555 :
556 : virtual void get_flipped_orientation(VolumeDescriptor& vdOut) const;
557 :
558 0 : virtual int container_section() const {return CSVOL_PYRAMID;}
559 0 : virtual ReferenceObjectID reference_object_id() const {return ROID_PYRAMID;}
560 :
561 : protected:
562 0 : virtual void set_vertex(uint index, Vertex* pVrt) {m_vertices[index] = pVrt;}
563 :
564 : protected:
565 : Vertex* m_vertices[5];
566 : };
567 :
568 : template <>
569 : class geometry_traits<Pyramid>
570 : {
571 : public:
572 : typedef GenericGridObjectIterator<Pyramid*, VolumeIterator> iterator;
573 : typedef ConstGenericGridObjectIterator<Pyramid*, VolumeIterator,
574 : ConstVolumeIterator> const_iterator;
575 :
576 : typedef PyramidDescriptor Descriptor;
577 : typedef Volume grid_base_object;
578 :
579 : enum
580 : {
581 : CONTAINER_SECTION = CSVOL_PYRAMID,
582 : BASE_OBJECT_ID = VOLUME
583 : };
584 : static const ReferenceObjectID REFERENCE_OBJECT_ID = ROID_PYRAMID;
585 : };
586 :
587 : typedef geometry_traits<Pyramid>::iterator PyramidIterator;
588 : typedef geometry_traits<Pyramid>::const_iterator ConstPyramidIterator;
589 :
590 :
591 :
592 : ////////////////////////////////////////////////////////////////////////
593 : // OctahedronDescriptor
594 : /// only used to initialize a octahedron. for all other tasks you should use VolumeDescripor.
595 : /**
596 : * please be sure to pass the vertices in the correct order:
597 : * v1: bottom-vertex
598 : * v2, v3, v4, v5: middle-section-vertices in counterclockwise order (if viewed from the top).
599 : * v6: top-vertex
600 : */
601 : class UG_API OctahedronDescriptor
602 : {
603 : public:
604 : OctahedronDescriptor() {}
605 : OctahedronDescriptor(const OctahedronDescriptor& td);
606 : OctahedronDescriptor(const VolumeVertices& vv);
607 : OctahedronDescriptor(Vertex* v1, Vertex* v2, Vertex* v3, Vertex* v4, Vertex* v5, Vertex* v6);
608 :
609 : inline uint num_vertices() const {return 6;}
610 0 : inline Vertex* vertex(size_t index) const {return m_vertex[index];}
611 :
612 : protected:
613 : Vertex* m_vertex[6];
614 : };
615 :
616 :
617 : ////////////////////////////////////////////////////////////////////////
618 : // Octahedron
619 : /// platonic solid with eight faces.
620 : /**
621 : * order of vertices should be the same as described in \sa OctahedronDescriptor
622 : *
623 : * \ingroup lib_grid_grid_objects
624 : */
625 : class UG_API Octahedron : public Volume
626 : {
627 : public:
628 : typedef Volume BaseClass;
629 :
630 : static const size_t NUM_VERTICES = 6;
631 :
632 : public:
633 : inline static bool type_match(GridObject* pObj) {return dynamic_cast<Octahedron*>(pObj) != NULL;}
634 :
635 0 : Octahedron() {}
636 : Octahedron(const OctahedronDescriptor& td);
637 : Octahedron(Vertex* v1, Vertex* v2, Vertex* v3, Vertex* v4, Vertex* v5, Vertex* v6);
638 :
639 0 : virtual GridObject* create_empty_instance() const {return new Octahedron;}
640 :
641 0 : virtual Vertex* vertex(size_t index) const {return m_vertices[index];}
642 0 : virtual ConstVertexArray vertices() const {return m_vertices;}
643 0 : virtual size_t num_vertices() const {return 6;}
644 :
645 : virtual EdgeDescriptor edge_desc(int index) const;
646 : virtual void edge_desc(int index, EdgeDescriptor& edOut) const;
647 : virtual uint num_edges() const;
648 :
649 : virtual FaceDescriptor face_desc(int index) const;
650 : virtual void face_desc(int index, FaceDescriptor& fdOut) const;
651 : virtual uint num_faces() const;
652 :
653 : virtual Edge* create_edge(int index); ///< create the edge with index i and return it.
654 : virtual Face* create_face(int index); ///< create the face with index i and return it.
655 :
656 : virtual void get_vertex_indices_of_edge(size_t& ind1Out,
657 : size_t& ind2Out,
658 : size_t edgeInd) const;
659 :
660 : virtual void get_vertex_indices_of_face(std::vector<size_t>& indsOut,
661 : size_t side) const;
662 :
663 : virtual int get_edge_index_from_vertices( const size_t vi0,
664 : const size_t vi1) const;
665 :
666 : virtual int get_face_edge_index ( const size_t faceInd,
667 : const size_t faceEdgeInd) const;
668 :
669 : virtual std::pair<GridBaseObjectId, int> get_opposing_object(Vertex* vrt) const;
670 :
671 : /// Creates new volume elements through refinement.
672 : /** Make sure that newEdgeVertices contains 6 vertex pointers.
673 : * newFaceVertices is ignored for Octahedrons.*/
674 : virtual bool refine(std::vector<Volume*>& vNewVolumesOut,
675 : Vertex** ppNewVertexOut,
676 : Vertex** newEdgeVertices,
677 : Vertex** newFaceVertices,
678 : Vertex* newVolumeVertex,
679 : const Vertex& prototypeVertex,
680 : Vertex** pSubstituteVertices = NULL,
681 : vector3* corners = NULL,
682 : bool* isSnapPoint = NULL);
683 :
684 : virtual bool is_regular_ref_rule(int edgeMarks) const;
685 :
686 : virtual bool collapse_edge(std::vector<Volume*>& vNewVolumesOut,
687 : int edgeIndex, Vertex* newVertex,
688 : std::vector<Vertex*>* pvSubstituteVertices = NULL);
689 :
690 : virtual void get_flipped_orientation(VolumeDescriptor& vdOut) const;
691 :
692 0 : virtual int container_section() const {return CSVOL_OCTAHEDRON;}
693 0 : virtual ReferenceObjectID reference_object_id() const {return ROID_OCTAHEDRON;}
694 :
695 : protected:
696 0 : virtual void set_vertex(uint index, Vertex* pVrt) {m_vertices[index] = pVrt;}
697 :
698 : protected:
699 : Vertex* m_vertices[6];
700 : };
701 :
702 : template <>
703 : class geometry_traits<Octahedron>
704 : {
705 : public:
706 : typedef GenericGridObjectIterator<Octahedron*, VolumeIterator> iterator;
707 : typedef ConstGenericGridObjectIterator<Octahedron*, VolumeIterator,
708 : ConstVolumeIterator> const_iterator;
709 :
710 : typedef OctahedronDescriptor Descriptor;
711 : typedef Volume grid_base_object;
712 :
713 : enum
714 : {
715 : CONTAINER_SECTION = CSVOL_OCTAHEDRON,
716 : BASE_OBJECT_ID = VOLUME
717 : };
718 : static const ReferenceObjectID REFERENCE_OBJECT_ID = ROID_OCTAHEDRON;
719 : };
720 :
721 : typedef geometry_traits<Octahedron>::iterator OctahedronIterator;
722 : typedef geometry_traits<Octahedron>::const_iterator ConstOctahedronIterator;
723 :
724 : }// end of namespace
725 :
726 : #endif
|