$treeview $search $mathjax
Palabos  Version 1.1
$projectbrief
$projectbrief
$searchbox

voxelizer.h

Go to the documentation of this file.
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: Orestis Malaspinas */
00026 
00027 #ifndef VOXELIZER_H
00028 #define VOXELIZER_H
00029 
00030 #include "core/globalDefs.h"
00031 #include "atomicBlock/dataProcessingFunctional3D.h"
00032 #include "offLattice/triangleHash.h"
00033 
00034 namespace plb {
00035 
00036 namespace voxelFlag {
00037 
00040     static const int undetermined = 0;
00041     static const int outside      = 1;
00044     static const int outerBorder  = 2;
00045     static const int inside       = 3;
00048     static const int innerBorder  = 4;
00049 
00050     int invert(int arg);
00051     int bulkFlag(int arg);
00052     int borderFlag(int arg);
00053     bool insideFlag(int arg);
00054     bool outsideFlag(int arg);
00055 
00056 }
00057 
00058 template<typename T>
00059 std::auto_ptr<MultiScalarField3D<int> > voxelize (
00060         TriangularSurfaceMesh<T> const& mesh,
00061         plint symmetricLayer, plint borderWidth );
00062 
00063 template<typename T>
00064 std::auto_ptr<MultiScalarField3D<int> > voxelize (
00065         TriangularSurfaceMesh<T> const& mesh,
00066         Box3D const& domain, plint borderWidth );
00067 
00068 template<typename T>
00069 std::auto_ptr<MultiScalarField3D<int> > revoxelize (
00070         TriangularSurfaceMesh<T> const& mesh,
00071         MultiScalarField3D<int>& oldVoxelMatrix,
00072         MultiContainerBlock3D& hashContainer, plint borderWidth );
00073 
00074 template<typename T>
00075 class VoxelizeMeshFunctional3D : public BoxProcessingFunctional3D {
00076 public:
00077     VoxelizeMeshFunctional3D (
00078             TriangularSurfaceMesh<T> const& mesh_ );
00079     virtual void processGenericBlocks (
00080         Box3D domain, std::vector<AtomicBlock3D*> blocks );
00081     virtual VoxelizeMeshFunctional3D<T>* clone() const;
00082     virtual void getTypeOfModification(std::vector<modif::ModifT>& modified) const;
00083     virtual BlockDomain::DomainT appliesTo() const;
00084 private:
00085     bool checkIfFacetsCrossed (
00086             AtomicContainerBlock3D& hashContainer,
00087             Array<T,3> const& point1, Array<T,3> const& point2,
00088             T& distance, plint& whichTriangle );
00089     bool distanceToSurface (
00090             AtomicContainerBlock3D& hashContainer,
00091             Array<T,3> const& point, T& distance, bool& isBehind ) const;
00092     bool createVoxelizationRange (
00093             Box3D const& domain, ScalarField3D<int>& voxels,
00094             Array<plint,2>& xRange, Array<plint,2>& yRange, Array<plint,2>& zRange );
00095     bool voxelizeFromNeighbor (
00096         ScalarField3D<int> const& voxels, AtomicContainerBlock3D& hashContainer,
00097         Dot3D pos, Dot3D neighbor, int& voxelType );
00098     void printOffender (
00099             ScalarField3D<int> const& voxels,
00100             AtomicContainerBlock3D& hashContainer, Dot3D pos );
00101 private:
00102     TriangularSurfaceMesh<T> const& mesh;
00103 };
00104 
00107 template<typename T>
00108 void detectBorderLine( MultiScalarField3D<T>& voxelMatrix,
00109                        Box3D const& domain, plint borderWidth );
00110 
00111 template<typename T>
00112 class DetectBorderLineFunctional3D : public BoxProcessingFunctional3D_S<T> {
00113 public:
00114     DetectBorderLineFunctional3D(plint borderWidth_);
00115     virtual void process(Box3D domain, ScalarField3D<T>& voxels);
00116     virtual DetectBorderLineFunctional3D<T>* clone() const;
00117     virtual void getTypeOfModification(std::vector<modif::ModifT>& modified) const;
00118     virtual BlockDomain::DomainT appliesTo() const;
00119 private:
00120     plint borderWidth;
00121 };
00122 
00123 } // namespace plb
00124 
00125 #endif  // VOXELIZER_H