/* This file is part of the OpenLB library
*
* Copyright (C) 2010-2015 Thomas Henn, Mathias J. Krause
* E-mail contact: info@openlb.net
* The most recent release of OpenLB can be downloaded at
* <http://www.openlb.net/>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
/** \file
* Input in STL format -- header file. - nope
*/
#ifndef STL_READER_HH
#define STL_READER_HH
#include <iostream>
#include <sstream>
#include <fstream>
#include <stdexcept>
#include "core/singleton.h"
#include "communication/mpiManager.h"
#include "octree.hh"
#include "stlReader.h"
using namespace olb::util;
/// All OpenLB code is contained in this namespace.
namespace olb {
template<typename T>
void STLtriangle<T>::init()
{
Vector<T,3> A = point[0].r;
Vector<T,3> B = point[1].r;
Vector<T,3> C = point[2].r;
Vector<T,3> b, c;
T bb = 0., bc = 0., cc = 0.;
for (int i = 0; i < 3; i++) {
b[i] = B[i] - A[i];
c[i] = C[i] - A[i];
bb += b[i] * b[i];
bc += b[i] * c[i];
cc += c[i] * c[i];
}
normal[0] = b[1] * c[2] - b[2] * c[1];
normal[1] = b[2] * c[0] - b[0] * c[2];
normal[2] = b[0] * c[1] - b[1] * c[0];
T norm = sqrt(
std::pow(normal[0], 2) + std::pow(normal[1], 2) + std::pow(normal[2], 2));
normal[0] /= norm;
normal[1] /= norm;
normal[2] /= norm;
T D = 1.0 / (cc * bb - bc * bc);
T bbD = bb *