1 /** 2 * UGENE - Integrated Bioinformatics Tools. 3 * Copyright (C) 2008-2021 UniPro <ugene@unipro.ru> 4 * http://ugene.net 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License 8 * as published by the Free Software Foundation; either version 2 9 * of the License, or (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 19 * MA 02110-1301, USA. 20 */ 21 22 #ifndef _U2_GEOM_UTILS_H_ 23 #define _U2_GEOM_UTILS_H_ 24 25 #include <QScopedPointer> 26 #include <QVector> 27 28 #include <U2Core/Vector3D.h> 29 30 namespace U2 { 31 32 const float PI = 3.14159265f; 33 const float Rad2Deg = 57.2957795f; 34 const float Deg2Rad = 0.017453293f; 35 36 struct U2ALGORITHM_EXPORT Face { FaceFace37 Face() { 38 } 39 Vector3D v[3]; 40 Vector3D n[3]; 41 }; 42 43 //! Builds sphere 44 class U2ALGORITHM_EXPORT GeodesicSphere { 45 QVector<Vector3D> vertices; 46 QVector<Face> faces; 47 static QScopedPointer<QVector<Vector3D>> elementarySphere; 48 static int currentDetailLevel; 49 static void interpolate(const Vector3D &v1, const Vector3D &v2, const Vector3D &v3, QVector<Vector3D> *v, int detailLevel); 50 51 public: 52 GeodesicSphere(const Vector3D ¢er, float radius, int detaillevel); 53 static QVector<Vector3D> *createGeodesicSphere(int detailLevel); getVertices()54 QVector<Vector3D> getVertices() { 55 return vertices; 56 } getFaces()57 QVector<Face> getFaces() { 58 return faces; 59 } 60 }; 61 62 } // namespace U2 63 64 #endif // _U2_GEOM_UTILS_H_ 65