$treeview $search $mathjax
|
Palabos
Version 1.1
$projectbrief
|
$projectbrief
|
$searchbox |
00001 /* This file is part of the Palabos library. 00002 * 00003 * Copyright (C) 2011 FlowKit Sarl 00004 * Avenue de Chailly 23 00005 * 1012 Lausanne, Switzerland 00006 * E-mail contact: contact@flowkit.com 00007 * 00008 * The most recent release of Palabos can be downloaded at 00009 * <http://www.palabos.org/> 00010 * 00011 * The library Palabos is free software: you can redistribute it and/or 00012 * modify it under the terms of the GNU Affero General Public License as 00013 * published by the Free Software Foundation, either version 3 of the 00014 * License, or (at your option) any later version. 00015 * 00016 * The library is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU Affero General Public License for more details. 00020 * 00021 * You should have received a copy of the GNU Affero General Public License 00022 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00023 */ 00024 00025 /* Main author: Dimitrios Kontaxakis */ 00026 00027 #ifndef TRIANGLE_SET_H 00028 #define TRIANGLE_SET_H 00029 00030 #include "core/globalDefs.h" 00031 #include "core/geometry3D.h" 00032 #include "core/array.h" 00033 #include <string> 00034 #include <vector> 00035 #include <cstdio> 00036 00037 namespace plb { 00038 00039 template<typename T> 00040 class TriangleSet { 00041 public: 00042 typedef Array<Array<T,3>,3> Triangle; 00043 public: 00044 TriangleSet(Precision precision_ = FLT); 00045 TriangleSet(std::vector<Triangle> const& triangles_, Precision precision_ = FLT); 00046 TriangleSet(std::string fname, Precision precision_ = FLT, SurfaceGeometryFileFormat fformat = STL); 00047 std::vector<Triangle> const& getTriangles() const; 00048 Precision getPrecision() const { return precision; } 00049 void setPrecision(Precision precision_); 00050 00052 void translate(Array<T,3> const& vector); 00054 void scale(T alpha); 00063 void rotate(T phi, T theta, T psi); 00064 void rotateAtOrigin(Array<T,3> const& normedAxis, T theta); 00065 00074 void merge(std::vector<TriangleSet<T> > meshes); 00075 00077 void reverseOrientation(); 00078 00080 void writeAsciiSTL(std::string fname) const; 00082 void writeBinarySTL(std::string fname) const; 00083 00092 int cutWithPlane(Plane<T> const& plane, TriangleSet<T>& newTriangleSet) const; 00093 00108 int cutWithPlane(Plane<T> const& plane, Cuboid<T> const& cuboid, 00109 TriangleSet<T>& newTriangleSet) const; 00110 00111 T getMinEdgeLength() const { return minEdgeLength; } 00112 T getMaxEdgeLength() const { return maxEdgeLength; } 00113 00114 Cuboid<T> getBoundingCuboid() const { return boundingCuboid; } 00115 00116 private: 00117 void readSTL(std::string fname); 00118 void readAsciiSTL(FILE* fp); 00119 void readBinarySTL(FILE* fp); 00120 void check(Triangle& triangle, Array<T,3> const& n); 00121 void computeMinMaxEdge(pluint iTriangle, T& minEdge, T& maxEdge) const; 00122 void computeMinMaxEdges(); 00123 void computeBoundingCuboid(); 00131 int cutTriangleWithPlane(Plane<T> const& plane, Triangle const& triangle, 00132 TriangleSet<T>& newTriangleSet) const; 00133 00134 private: 00135 std::vector<Triangle> triangles; 00136 T minEdgeLength, maxEdgeLength; 00137 Cuboid<T> boundingCuboid; 00142 Precision precision; 00143 }; 00144 00145 } // namespace plb 00146 00147 #endif // TRIANGLE_SET_H
1.6.3
1.6.3