Loading [MathJax]/extensions/tex2jax.js
Plugins
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
new_tools.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2013-2017: 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_PROMESH__new_tools__
34#define __H__UG_PROMESH__new_tools__
35
36#include "../mesh.h"
39
40namespace ug{
41namespace promesh{
42
45class Box{
46 public:
47 void set_min(const vector3& val) {min = val;}
48 void set_max(const vector3& val) {max = val;}
49 const vector3& get_min() const {return min;}
50 const vector3& get_max() const {return max;}
51
52 void global_to_local (const vector3& glob, vector3& locOut)
53 {
54 for(size_t i = 0; i < 3; ++i){
55 number d = max[i] - min[i];
56 if(d != 0)
57 locOut[i] = (glob[i] - min[i]) / d;
58 else
59 locOut[i] = 0;
60 }
61 }
62
63 void local_to_global (const vector3& loc, vector3& globOut)
64 {
65 for(size_t i = 0; i < 3; ++i){
66 number d = max[i] - min[i];
67 globOut[i] = loc[i] * d + min[i];
68 }
69 }
70
73};
74
75
77// INFO
79{
80 SmartPtr<Box> box = make_sp(new Box);
81 CalculateBoundingBox(box->min, box->max, obj->grid().vertices_begin(),
82 obj->grid().vertices_end(), obj->position_accessor());
83 return box;
84}
85
87
88}}// end of namespace
89
90#endif
VertexIterator vertices_begin()
VertexIterator vertices_end()
Definition new_tools.h:45
const vector3 & get_min() const
Definition new_tools.h:49
vector3 max
Definition new_tools.h:72
vector3 min
Definition new_tools.h:71
const vector3 & get_max() const
Definition new_tools.h:50
void set_max(const vector3 &val)
Definition new_tools.h:48
void set_min(const vector3 &val)
Definition new_tools.h:47
void local_to_global(const vector3 &loc, vector3 &globOut)
Definition new_tools.h:63
void global_to_local(const vector3 &glob, vector3 &locOut)
Definition new_tools.h:52
Definition mesh.h:73
position_accessor_t & position_accessor()
returns accessor to vertex positions
Definition mesh.h:113
Grid & grid()
Definition mesh.h:99
void CalculateBoundingBox(size_t npoints, const MathVector< dim > points[], MathVector< dim > &vMinBB, MathVector< dim > &vMaxBB)
SmartPtr< Box > GetBoundingBox(Mesh *obj)
Definition new_tools.h:78
double number
SmartPtr< T, FreePolicy > make_sp(T *inst)