diff --git a/applications/solvers/compressible/rhoSimpleFoam/Allwclean b/applications/solvers/compressible/rhoSimpleFoam/Allwclean new file mode 100755 index 0000000000000000000000000000000000000000..49e4b694825e9af88024f4e4857c6ca246477bde --- /dev/null +++ b/applications/solvers/compressible/rhoSimpleFoam/Allwclean @@ -0,0 +1,9 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # run from this directory +set -x + +wclean +wclean rhoPorousMRFSimpleFoam +wclean rhoSimplecFoam + +# ----------------------------------------------------------------- end-of-file diff --git a/applications/solvers/compressible/rhoSimpleFoam/Allwmake b/applications/solvers/compressible/rhoSimpleFoam/Allwmake index 33916c7b39c519b09755699c6d36314c30a5859d..e0b621c2530e21c1221271c0afa24a67fa3e2dac 100755 --- a/applications/solvers/compressible/rhoSimpleFoam/Allwmake +++ b/applications/solvers/compressible/rhoSimpleFoam/Allwmake @@ -4,5 +4,6 @@ set -x wmake wmake rhoPorousMRFSimpleFoam +wmake rhoSimplecFoam # ----------------------------------------------------------------- end-of-file diff --git a/applications/solvers/compressible/rhoSimpleFoam/UEqn.H b/applications/solvers/compressible/rhoSimpleFoam/UEqn.H index 21ec2646be5bb5702e0b2210335592e1fe124ec0..f1bed4d071e985d92c9057c777ca9e216b174c54 100644 --- a/applications/solvers/compressible/rhoSimpleFoam/UEqn.H +++ b/applications/solvers/compressible/rhoSimpleFoam/UEqn.H @@ -3,6 +3,7 @@ tmp<fvVectorMatrix> UEqn ( fvm::div(phi, U) + - fvm::Sp(fvc::div(phi), U) + turbulence->divDevRhoReff(U) ); diff --git a/applications/solvers/compressible/rhoSimpleFoam/hEqn.H b/applications/solvers/compressible/rhoSimpleFoam/hEqn.H index 8ff402a2b1aa414ad9583bd6925138f0b298a01a..879578cf49d9d34b0e30b56e426a59dcd969cc09 100644 --- a/applications/solvers/compressible/rhoSimpleFoam/hEqn.H +++ b/applications/solvers/compressible/rhoSimpleFoam/hEqn.H @@ -1,11 +1,13 @@ { + volScalarField K("K", 0.5*magSqr(U)); + fvScalarMatrix hEqn ( fvm::div(phi, h) - fvm::Sp(fvc::div(phi), h) - fvm::laplacian(turbulence->alphaEff(), h) == - - fvc::div(phi, 0.5*magSqr(U), "div(phi,K)") + fvc::div(phi)*K - fvc::div(phi, K) ); hEqn.relax(); diff --git a/applications/solvers/compressible/rhoSimpleFoam/pEqn.H b/applications/solvers/compressible/rhoSimpleFoam/pEqn.H index 56c444cdaba17c58857dd45f385380a274d907fa..cefee48969acf984baf1c8a8b54211290576ab45 100644 --- a/applications/solvers/compressible/rhoSimpleFoam/pEqn.H +++ b/applications/solvers/compressible/rhoSimpleFoam/pEqn.H @@ -28,7 +28,7 @@ if (simple.transonic()) ); // Relax the pressure equation to ensure diagonal-dominance - pEqn.relax(mesh.equationRelaxationFactor("pEqn")); + pEqn.relax(); pEqn.setReference(pRefCell, pRefValue); diff --git a/applications/solvers/compressible/rhoSimplecFoam/Make/files b/applications/solvers/compressible/rhoSimpleFoam/rhoSimplecFoam/Make/files similarity index 100% rename from applications/solvers/compressible/rhoSimplecFoam/Make/files rename to applications/solvers/compressible/rhoSimpleFoam/rhoSimplecFoam/Make/files diff --git a/applications/solvers/compressible/rhoSimplecFoam/Make/options b/applications/solvers/compressible/rhoSimpleFoam/rhoSimplecFoam/Make/options similarity index 93% rename from applications/solvers/compressible/rhoSimplecFoam/Make/options rename to applications/solvers/compressible/rhoSimpleFoam/rhoSimplecFoam/Make/options index 9d578f011a760625377ef026f10d7f84ef72b5c8..30c1e55d3102e2ff68a095ea497bc3481bc79735 100644 --- a/applications/solvers/compressible/rhoSimplecFoam/Make/options +++ b/applications/solvers/compressible/rhoSimpleFoam/rhoSimplecFoam/Make/options @@ -1,5 +1,5 @@ EXE_INC = \ - -I../rhoSimpleFoam \ + -I.. \ -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ -I$(LIB_SRC)/turbulenceModels \ -I$(LIB_SRC)/turbulenceModels/compressible/RAS/RASModel \ diff --git a/applications/solvers/compressible/rhoSimplecFoam/createFields.H b/applications/solvers/compressible/rhoSimpleFoam/rhoSimplecFoam/createFields.H similarity index 100% rename from applications/solvers/compressible/rhoSimplecFoam/createFields.H rename to applications/solvers/compressible/rhoSimpleFoam/rhoSimplecFoam/createFields.H diff --git a/applications/solvers/compressible/rhoSimplecFoam/pEqn.H b/applications/solvers/compressible/rhoSimpleFoam/rhoSimplecFoam/pEqn.H similarity index 88% rename from applications/solvers/compressible/rhoSimplecFoam/pEqn.H rename to applications/solvers/compressible/rhoSimpleFoam/rhoSimplecFoam/pEqn.H index a4d9325522752657d2bf77b2bf2f37c9737d1f9e..379e720c042eb8d08cdae81ed4064549a84aa7f1 100644 --- a/applications/solvers/compressible/rhoSimplecFoam/pEqn.H +++ b/applications/solvers/compressible/rhoSimpleFoam/rhoSimplecFoam/pEqn.H @@ -29,21 +29,17 @@ if (simple.transonic()) ( "phic", fvc::interpolate(rho/AtU - rho/AU)*fvc::snGrad(p)*mesh.magSf() - + phid*(fvc::interpolate(p) - fvc::interpolate(p, "UD")) ); - //refCast<mixedFvPatchScalarField>(p.boundaryField()[1]).refValue() - // = p.boundaryField()[1]; - fvScalarMatrix pEqn ( fvm::div(phid, p) + fvc::div(phic) - - fvm::Sp(fvc::div(phid), p) - + fvc::div(phid)*p - fvm::laplacian(rho/AtU, p) ); - //pEqn.relax(); + + // Relax the pressure equation to ensure diagonal-dominance + pEqn.relax(); pEqn.setReference(pRefCell, pRefValue); @@ -71,7 +67,6 @@ else fvScalarMatrix pEqn ( fvc::div(phiHbyA) - //- fvm::laplacian(rho/AU, p) - fvm::laplacian(rho/AtU, p) ); diff --git a/applications/solvers/compressible/rhoSimplecFoam/rhoSimplecFoam.C b/applications/solvers/compressible/rhoSimpleFoam/rhoSimplecFoam/rhoSimplecFoam.C similarity index 97% rename from applications/solvers/compressible/rhoSimplecFoam/rhoSimplecFoam.C rename to applications/solvers/compressible/rhoSimpleFoam/rhoSimplecFoam/rhoSimplecFoam.C index 937358e0f5a83619655efca3ded9aece15e90838..37334e7955417deae9f48ba7a8c0901f2c129012 100644 --- a/applications/solvers/compressible/rhoSimplecFoam/rhoSimplecFoam.C +++ b/applications/solvers/compressible/rhoSimpleFoam/rhoSimplecFoam/rhoSimplecFoam.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/applications/solvers/multiphase/compressibleTwoPhaseEulerFoam/createFields.H b/applications/solvers/multiphase/compressibleTwoPhaseEulerFoam/createFields.H index 93c35ee1e1b3dba3983cf66d67843f3791103764..c773650be287ff98c19d6754a11702b6066742ec 100644 --- a/applications/solvers/multiphase/compressibleTwoPhaseEulerFoam/createFields.H +++ b/applications/solvers/multiphase/compressibleTwoPhaseEulerFoam/createFields.H @@ -310,14 +310,21 @@ Info << "dispersedPhase is " << dispersedPhase << endl; - scalar minInterfaceAlpha + scalar residualPhaseFraction ( readScalar ( - interfacialProperties.lookup("minInterfaceAlpha") + interfacialProperties.lookup("residualPhaseFraction") ) ); + dimensionedScalar residualSlip + ( + "residualSlip", + dimVelocity, + interfacialProperties.lookup("residualSlip") + ); + kineticTheoryModel kineticTheory ( phase1, diff --git a/applications/solvers/multiphase/compressibleTwoPhaseEulerFoam/interfacialCoeffs.H b/applications/solvers/multiphase/compressibleTwoPhaseEulerFoam/interfacialCoeffs.H index 3b4d2be679d8fc11be453eff2ec45108d6428caa..d6ccf90289ad6891248e665609408a68d4e7c766 100644 --- a/applications/solvers/multiphase/compressibleTwoPhaseEulerFoam/interfacialCoeffs.H +++ b/applications/solvers/multiphase/compressibleTwoPhaseEulerFoam/interfacialCoeffs.H @@ -36,7 +36,7 @@ volScalarField heatTransferCoeff { volVectorField Ur(U1 - U2); - volScalarField magUr(mag(Ur)); + volScalarField magUr(mag(Ur) + residualSlip); if (dispersedPhase == "1") { @@ -69,12 +69,9 @@ volScalarField heatTransferCoeff << exit(FatalError); } - volScalarField alpha1Coeff - ( - (alpha1 + minInterfaceAlpha)*(alpha2 + minInterfaceAlpha) - ); - dragCoeff *= alpha1Coeff; - heatTransferCoeff *= alpha1Coeff; + volScalarField alphaCoeff(max(alpha1*alpha2, residualPhaseFraction)); + dragCoeff *= alphaCoeff; + heatTransferCoeff *= alphaCoeff; liftForce = Cl*(alpha1*rho1 + alpha2*rho2)*(Ur ^ fvc::curl(U)); diff --git a/applications/solvers/multiphase/multiphaseEulerFoam/correctPhi.H b/applications/solvers/multiphase/multiphaseEulerFoam/correctPhi.H index 78f93384b0a103389aafcb0ca22e44a571c17788..57a79b6091cbf34f3b01156f1a61a311a08aad76 100644 --- a/applications/solvers/multiphase/multiphaseEulerFoam/correctPhi.H +++ b/applications/solvers/multiphase/multiphaseEulerFoam/correctPhi.H @@ -32,7 +32,7 @@ dimensionedScalar rAUf("(1|A(U))", dimTime/rho.dimensions(), 1.0); - adjustPhi(phi, U, pcorr); + //adjustPhi(phi, U, pcorr); while (pimple.correctNonOrthogonal()) { diff --git a/applications/test/tetTetOverlap/Make/files b/applications/test/tetTetOverlap/Make/files new file mode 100644 index 0000000000000000000000000000000000000000..0092ff87718ad032b7bf3ffbf003f8213197a323 --- /dev/null +++ b/applications/test/tetTetOverlap/Make/files @@ -0,0 +1,3 @@ +Test-tetTetOverlap.C + +EXE = $(FOAM_USER_APPBIN)/Test-tetTetOverlap diff --git a/applications/test/tetTetOverlap/Make/options b/applications/test/tetTetOverlap/Make/options new file mode 100644 index 0000000000000000000000000000000000000000..54c035b8f55d183c1ad02bc372398feceaf31718 --- /dev/null +++ b/applications/test/tetTetOverlap/Make/options @@ -0,0 +1,5 @@ +EXE_INC = \ + -I$(LIB_SRC)/meshTools/lnInclude + +EXE_LIBS = \ + -lmeshTools diff --git a/applications/test/tetTetOverlap/Test-tetTetOverlap.C b/applications/test/tetTetOverlap/Test-tetTetOverlap.C new file mode 100644 index 0000000000000000000000000000000000000000..df6f2b8f83c16591bcb3a532252ebc4d0236b357 --- /dev/null +++ b/applications/test/tetTetOverlap/Test-tetTetOverlap.C @@ -0,0 +1,164 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM 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 3 of the License, or + (at your option) any later version. + + OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +Application + Test-tetTetOverlap + +Description + Overlap volume of two tets + +\*---------------------------------------------------------------------------*/ + +#include "tetrahedron.H" +#include "OFstream.H" +#include "meshTools.H" + +using namespace Foam; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +void writeOBJ +( + Ostream& os, + label& vertI, + const tetPoints& tet +) +{ + forAll(tet, fp) + { + meshTools::writeOBJ(os, tet[fp]); + } + os << "l " << vertI+1 << ' ' << vertI+2 << nl + << "l " << vertI+1 << ' ' << vertI+3 << nl + << "l " << vertI+1 << ' ' << vertI+4 << nl + << "l " << vertI+2 << ' ' << vertI+3 << nl + << "l " << vertI+2 << ' ' << vertI+4 << nl + << "l " << vertI+3 << ' ' << vertI+4 << nl; + vertI += 4; +} + + +int main(int argc, char *argv[]) +{ + tetPoints A + ( + point(0, 0, 0), + point(1, 0, 0), + point(1, 1, 0), + point(1, 1, 1) + ); + const tetPointRef tetA = A.tet(); + + tetPoints B + ( + point(0.1, 0.1, 0.1), + point(1.1, 0.1, 0.1), + point(1.1, 1.1, 0.1), + point(1.1, 1.1, 1.1) + ); + const tetPointRef tetB = B.tet(); + + + tetPointRef::tetIntersectionList insideTets; + label nInside = 0; + tetPointRef::tetIntersectionList outsideTets; + label nOutside = 0; + + tetA.tetOverlap + ( + tetB, + insideTets, + nInside, + outsideTets, + nOutside + ); + + + // Dump to file + // ~~~~~~~~~~~~ + + { + OFstream str("tetA.obj"); + Info<< "Writing A to " << str.name() << endl; + label vertI = 0; + writeOBJ(str, vertI, A); + } + { + OFstream str("tetB.obj"); + Info<< "Writing B to " << str.name() << endl; + label vertI = 0; + writeOBJ(str, vertI, B); + } + { + OFstream str("inside.obj"); + Info<< "Writing parts of A inside B to " << str.name() << endl; + label vertI = 0; + for (label i = 0; i < nInside; ++i) + { + writeOBJ(str, vertI, insideTets[i]); + } + } + { + OFstream str("outside.obj"); + Info<< "Writing parts of A outside B to " << str.name() << endl; + label vertI = 0; + for (label i = 0; i < nOutside; ++i) + { + writeOBJ(str, vertI, outsideTets[i]); + } + } + + + // Check + // ~~~~~ + + Info<< "Vol A:" << tetA.mag() << endl; + + scalar volInside = 0; + for (label i = 0; i < nInside; ++i) + { + volInside += insideTets[i].tet().mag(); + } + Info<< "Vol A inside B:" << volInside << endl; + + scalar volOutside = 0; + for (label i = 0; i < nOutside; ++i) + { + volOutside += outsideTets[i].tet().mag(); + } + Info<< "Vol A outside B:" << volOutside << endl; + + Info<< "Sum inside and outside:" << volInside+volOutside << endl; + + if (mag(volInside+volOutside-tetA.mag()) > SMALL) + { + FatalErrorIn("Test-tetetOverlap") + << "Tet volumes do not sum up to input tet." + << exit(FatalError); + } + + return 0; +} + + +// ************************************************************************* // diff --git a/applications/utilities/mesh/generation/cvMesh/Allwclean b/applications/utilities/mesh/generation/cvMesh/Allwclean index 6dd3690c256b786353f55a4a9aad5f01cfbf135c..3eff84006aa70bbe0d2c8b60b9408274c47bad7d 100755 --- a/applications/utilities/mesh/generation/cvMesh/Allwclean +++ b/applications/utilities/mesh/generation/cvMesh/Allwclean @@ -4,5 +4,7 @@ set -x wclean libso conformalVoronoiMesh wclean +wclean cvMeshSurfaceSimplify +wclean cvMeshBackgroundMesh # ----------------------------------------------------------------- end-of-file diff --git a/applications/utilities/mesh/generation/cvMesh/Allwmake b/applications/utilities/mesh/generation/cvMesh/Allwmake index f059754bab6f69f793ddfd156f50e914d3cf3d55..eb453138ce529dfcf03af180f64350cd034726af 100755 --- a/applications/utilities/mesh/generation/cvMesh/Allwmake +++ b/applications/utilities/mesh/generation/cvMesh/Allwmake @@ -4,6 +4,7 @@ set -x wmake libso conformalVoronoiMesh wmake -wmake cvMeshSurfaceSimplify +wmake cvMeshBackgroundMesh +(cd cvMeshSurfaceSimplify && ./Allwmake) # ----------------------------------------------------------------- end-of-file diff --git a/applications/utilities/mesh/generation/cvMesh/Make/options b/applications/utilities/mesh/generation/cvMesh/Make/options index 5efdb125725138a1df13a4eae74625e3a0fc8cc0..e7a3c9e0e3a8226cc31acc9b6be4c16ff24a6329 100644 --- a/applications/utilities/mesh/generation/cvMesh/Make/options +++ b/applications/utilities/mesh/generation/cvMesh/Make/options @@ -2,11 +2,15 @@ EXE_DEBUG = -DFULLDEBUG -g -O0 EXE_FROUNDING_MATH = -frounding-math EXE_NDEBUG = -DNDEBUG +CGAL_EXACT = +CGAL_INEXACT = -DCGAL_INEXACT + include $(GENERAL_RULES)/CGAL EXE_INC = \ ${EXE_FROUNDING_MATH} \ ${EXE_NDEBUG} \ + ${CGAL_INEXACT} \ ${CGAL_INC} \ -IconformalVoronoiMesh/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \ diff --git a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/Make/options b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/Make/options index 2d2d1a1178abede674023f52331496cd82e291a6..97e045f30502c9dc417b7d110e9492f03d29b289 100644 --- a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/Make/options +++ b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/Make/options @@ -2,12 +2,16 @@ EXE_DEBUG = -DFULLDEBUG -g -O0 EXE_FROUNDING_MATH = -frounding-math EXE_NDEBUG = -DNDEBUG +CGAL_EXACT = +CGAL_INEXACT = -DCGAL_INEXACT + include $(GENERAL_RULES)/CGAL FFLAGS = -DCGAL_FILES='"${CGAL_ARCH_PATH}/share/files"' EXE_INC = \ ${EXE_FROUNDING_MATH} \ ${EXE_NDEBUG} \ + ${CGAL_INEXACT} \ ${CGAL_INC} \ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \ diff --git a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.C b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.C index 395b6c78b2d60d78e7bf30c61213fc537bceea2a..cf7a1eb9021fd476ba2c4589b51ac07963cbc4e6 100644 --- a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.C +++ b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -142,7 +142,7 @@ void Foam::backgroundMeshDecomposition::initialRefinement() zeroGradientFvPatchScalarField::typeName ); - const conformationSurfaces& geometry = cvMesh_.geometryToConformTo(); + const conformationSurfaces& geometry = geometryToConformTo_; decompositionMethod& decomposer = decomposerPtr_(); @@ -512,7 +512,7 @@ bool Foam::backgroundMeshDecomposition::refineCell // Sample the box to find an estimate of the min size, and a volume // estimate when overlapping == true. - const conformationSurfaces& geometry = cvMesh_.geometryToConformTo(); + const conformationSurfaces& geometry = geometryToConformTo_; treeBoundBox cellBb ( @@ -578,7 +578,7 @@ bool Foam::backgroundMeshDecomposition::refineCell forAll(samplePoints, i) { - scalar s = cvMesh_.cellSizeControl().cellSize + scalar s = cellSizeControl_.cellSize ( hitInfo[i].hitPoint() ); @@ -693,7 +693,7 @@ void Foam::backgroundMeshDecomposition::buildPatchAndTree() // Overall bb treeBoundBox overallBb(boundaryFacesPtr_().localPoints()); - Random& rnd = cvMesh_.rndGen(); + Random& rnd = rndGen_; bFTreePtr_.reset ( @@ -726,11 +726,11 @@ void Foam::backgroundMeshDecomposition::buildPatchAndTree() octreeNearestDistances_ = bFTreePtr_().calcNearestDistance(); - if (cvMesh_.cvMeshControls().objOutput()) + if (cvMeshControls_.objOutput()) { OFstream fStr ( - cvMesh_.time().path() + mesh_.time().path() /"backgroundMeshDecomposition_proc_" + name(Pstream::myProcNo()) + "_boundaryFaces.obj" @@ -777,15 +777,18 @@ Foam::backgroundMeshDecomposition::backgroundMeshDecomposition const conformalVoronoiMesh& cvMesh ) : - coeffsDict_(coeffsDict), - cvMesh_(cvMesh), + runTime_(cvMesh.time()), + geometryToConformTo_(cvMesh.geometryToConformTo()), + cellSizeControl_(cvMesh.cellSizeControl()), + rndGen_(cvMesh.rndGen()), + cvMeshControls_(cvMesh.cvMeshControls()), mesh_ ( IOobject ( fvMesh::defaultRegion, - cvMesh_.time().timeName(), - cvMesh_.time(), + runTime_.timeName(), + runTime_, IOobject::MUST_READ ) ), @@ -805,22 +808,22 @@ Foam::backgroundMeshDecomposition::backgroundMeshDecomposition IOobject ( "decomposeParDict", - cvMesh_.time().system(), - cvMesh_.time(), + runTime_.system(), + runTime_, IOobject::MUST_READ_IF_MODIFIED, IOobject::NO_WRITE ) ), decomposerPtr_(decompositionMethod::New(decomposeDict_)), mergeDist_(1e-6*mesh_.bounds().mag()), - spanScale_(readScalar(coeffsDict_.lookup("spanScale"))), + spanScale_(readScalar(coeffsDict.lookup("spanScale"))), minCellSizeLimit_ ( - coeffsDict_.lookupOrDefault<scalar>("minCellSizeLimit", 0.0) + coeffsDict.lookupOrDefault<scalar>("minCellSizeLimit", 0.0) ), - minLevels_(readLabel(coeffsDict_.lookup("minLevels"))), - volRes_(readLabel(coeffsDict_.lookup("sampleResolution"))), - maxCellWeightCoeff_(readScalar(coeffsDict_.lookup("maxCellWeightCoeff"))) + minLevels_(readLabel(coeffsDict.lookup("minLevels"))), + volRes_(readLabel(coeffsDict.lookup("sampleResolution"))), + maxCellWeightCoeff_(readScalar(coeffsDict.lookup("maxCellWeightCoeff"))) { if (!Pstream::parRun()) { @@ -854,6 +857,74 @@ Foam::backgroundMeshDecomposition::backgroundMeshDecomposition } +Foam::backgroundMeshDecomposition::backgroundMeshDecomposition +( + const scalar spanScale, + const scalar minCellSizeLimit, + const label minLevels, + const label volRes, + const scalar maxCellWeightCoeff, + + const Time& runTime, + const conformationSurfaces& geometryToConformTo, + const cellSizeControlSurfaces& cellSizeControl, + Random& rndGen, + const cvControls& cvMeshControls +) +: + runTime_(runTime), + geometryToConformTo_(geometryToConformTo), + cellSizeControl_(cellSizeControl), + rndGen_(rndGen), + cvMeshControls_(cvMeshControls), + mesh_ + ( + IOobject + ( + fvMesh::defaultRegion, + runTime_.timeName(), + runTime_, + IOobject::MUST_READ + ) + ), + meshCutter_ + ( + mesh_, + labelList(mesh_.nCells(), 0), + labelList(mesh_.nPoints(), 0) + ), + boundaryFacesPtr_(), + bFTreePtr_(), + octreeNearestDistances_(), + allBackgroundMeshBounds_(Pstream::nProcs()), + globalBackgroundBounds_(), + decomposeDict_ + ( + IOobject + ( + "decomposeParDict", + runTime_.system(), + runTime_, + IOobject::MUST_READ_IF_MODIFIED, + IOobject::NO_WRITE + ) + ), + decomposerPtr_(decompositionMethod::New(decomposeDict_)), + mergeDist_(1e-6*mesh_.bounds().mag()), + spanScale_(spanScale), + minCellSizeLimit_(minCellSizeLimit), + minLevels_(minLevels), + volRes_(volRes), + maxCellWeightCoeff_(maxCellWeightCoeff) +{ + // Stand-alone operation + + Info<< nl << "Building initial background mesh decomposition" << endl; + + initialRefinement(); +} + + // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // Foam::backgroundMeshDecomposition::~backgroundMeshDecomposition() diff --git a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.H b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.H index 01572a48f9a20b93b617ce0ada3e773dbf84860e..910732fa7ac2415857d2274c102f52f3356257dc 100644 --- a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.H +++ b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -92,10 +92,22 @@ class backgroundMeshDecomposition // Private data //- Method details dictionary - dictionary coeffsDict_; + //dictionary coeffsDict_; - //- Reference to the conformalVoronoiMesh holding this object - const conformalVoronoiMesh& cvMesh_; + //- Reference to runtime + const Time& runTime_; + + //- Reference to surface + const conformationSurfaces& geometryToConformTo_; + + //- The cell size control object + const cellSizeControlSurfaces& cellSizeControl_; + + //- Random number generator + Random& rndGen_; + + //- Controls + const cvControls& cvMeshControls_; //- Mesh stored on for this processor, specifiying the domain that it // is responsible for. @@ -191,13 +203,29 @@ public: // Constructors - //- Construct from components + //- Construct from components in cvMesh operation backgroundMeshDecomposition ( const dictionary& coeffsDict, const conformalVoronoiMesh& cvMesh ); + //- Construct from components for standalone operation + backgroundMeshDecomposition + ( + const scalar spanScale, + const scalar minCellSizeLimit, + const label minLevels, + const label volRes, + const scalar maxCellWeightCoeff, + + const Time& runTime, + const conformationSurfaces& geometryToConformTo, + const cellSizeControlSurfaces& cellSizeControl, + Random& rndGen, + const cvControls& cvMeshControls + ); + //- Destructor ~backgroundMeshDecomposition(); @@ -299,6 +327,15 @@ public: //- Return the boundBox of this processor inline const treeBoundBox& procBounds() const; + + //- Return the cell level of the underlying mesh + inline const labelList& cellLevel() const; + + //- Return the point level of the underlying mesh + inline const labelList& pointLevel() const; + + //- Return the current decomposition method + inline const decompositionMethod& decomposer() const; }; diff --git a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecompositionI.H b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecompositionI.H index 94a05c4134a0b80e2c18d45fa11edfaf0dd7139f..44a007193d8e85fae30c2b8a024385a2c90fedab 100644 --- a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecompositionI.H +++ b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecompositionI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -43,9 +43,30 @@ Foam::backgroundMeshDecomposition::octreeNearestDistances() const } -const Foam::treeBoundBox& Foam::backgroundMeshDecomposition::procBounds() const +const Foam::treeBoundBox& +Foam::backgroundMeshDecomposition::procBounds() const { return allBackgroundMeshBounds_[Pstream::myProcNo()]; } + +const Foam::labelList& Foam::backgroundMeshDecomposition::cellLevel() const +{ + return meshCutter_.cellLevel(); +} + + +const Foam::labelList& Foam::backgroundMeshDecomposition::pointLevel() const +{ + return meshCutter_.pointLevel(); +} + + +const Foam::decompositionMethod& +Foam::backgroundMeshDecomposition::decomposer() const +{ + return decomposerPtr_(); +} + + // ************************************************************************* // diff --git a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.C b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.C index e012b1fa44b61f305e88aaa53bb55f6ca31eb9ba..c9ae92f4984ae7575ca16fa6cab1669e17b2bf57 100644 --- a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.C +++ b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.C @@ -249,6 +249,7 @@ Foam::conformationSurfaces::conformationSurfaces Info<< endl << "Testing for locationInMesh " << locationInMesh_ << endl; + forAll(surfaces_, s) { const searchableSurface& surface(allGeometry_[surfaces_[s]]); @@ -267,7 +268,6 @@ Foam::conformationSurfaces::conformationSurfaces referenceVolumeTypes_[s] = vTypes[0]; - Info<< " is " << searchableSurface::volumeTypeNames[referenceVolumeTypes_[s]] << " surface " << surface.name() diff --git a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.H b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.H index 9387f2e0f3d2df8841bb7c16c16e2f8192c34e34..c1bdac76ba2ef772c19fc9dce17e3eadbd3f10fa 100644 --- a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.H +++ b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.H @@ -303,6 +303,9 @@ public: //- Find which patch is closest to the point label findPatch(const point& pt) const; + //- Is the surface a baffle + inline bool isBaffle(const label index) const; + // Write diff --git a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfacesI.H b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfacesI.H index c773d21b46bc7af7f1e057e6d2bdb40bce268f36..a4a6595d315f0ea4fbe2dcd1f1d739f50dd6b943 100644 --- a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfacesI.H +++ b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfacesI.H @@ -62,4 +62,10 @@ const Foam::treeBoundBox& Foam::conformationSurfaces::globalBounds() const } +bool Foam::conformationSurfaces::isBaffle(const label index) const +{ + return baffleSurfaces_[index]; +} + + // ************************************************************************* // diff --git a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cvControls/cvControls.C b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cvControls/cvControls.C index 996aa71abfcf13e62ba123e3519090121d5ff095..15c82e64c5c9a9fdbb47ec73dc2affedc48bf7be 100644 --- a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cvControls/cvControls.C +++ b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/cvControls/cvControls.C @@ -61,7 +61,7 @@ Foam::cvControls::cvControls specialiseFeaturePoints_ = Switch ( - surfDict.lookupOrDefault<Switch>("specialiseFeaturePoints", false) + surfDict.lookup("specialiseFeaturePoints") ); surfaceSearchDistanceCoeff_ = readScalar diff --git a/applications/utilities/mesh/generation/cvMesh/cvMeshBackgroundMesh/Make/files b/applications/utilities/mesh/generation/cvMesh/cvMeshBackgroundMesh/Make/files new file mode 100644 index 0000000000000000000000000000000000000000..58406b931afc7b1b1b72a8c3eb68587d2c2d210d --- /dev/null +++ b/applications/utilities/mesh/generation/cvMesh/cvMeshBackgroundMesh/Make/files @@ -0,0 +1,3 @@ +cvMeshBackgroundMesh.C + +EXE = $(FOAM_APPBIN)/cvMeshBackgroundMesh diff --git a/applications/utilities/mesh/generation/cvMesh/cvMeshBackgroundMesh/Make/options b/applications/utilities/mesh/generation/cvMesh/cvMeshBackgroundMesh/Make/options new file mode 100644 index 0000000000000000000000000000000000000000..3c9ef8cd4b89e81c1eadf2202ec6416fdd93ddf1 --- /dev/null +++ b/applications/utilities/mesh/generation/cvMesh/cvMeshBackgroundMesh/Make/options @@ -0,0 +1,29 @@ +EXE_DEBUG = -DFULLDEBUG -g -O0 +EXE_FROUNDING_MATH = -frounding-math +EXE_NDEBUG = -DNDEBUG + +include $(GENERAL_RULES)/CGAL + +EXE_INC = \ + ${EXE_FROUNDING_MATH} \ + ${EXE_NDEBUG} \ + ${CGAL_INC} \ + -I../conformalVoronoiMesh/lnInclude \ + -I$(LIB_SRC)/parallel/decompose/decompositionMethods/lnInclude \ + -I$(LIB_SRC)/edgeMesh/lnInclude \ + -I$(LIB_SRC)/sampling/lnInclude \ + -I$(LIB_SRC)/triSurface/lnInclude \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude \ + -I$(LIB_SRC)/dynamicMesh/lnInclude + +EXE_LIBS = \ + $(CGAL_LIBS) \ + -lconformalVoronoiMesh \ + -ldecompositionMethods /* -L$(FOAM_LIBBIN)/dummy -lscotchDecomp */ \ + -ledgeMesh \ + -lsampling \ + -ltriSurface \ + -lmeshTools \ + -ldynamicMesh \ + -lfiniteVolume diff --git a/applications/utilities/mesh/generation/cvMesh/cvMeshBackgroundMesh/cvMeshBackgroundMesh.C b/applications/utilities/mesh/generation/cvMesh/cvMeshBackgroundMesh/cvMeshBackgroundMesh.C new file mode 100644 index 0000000000000000000000000000000000000000..72d05293b9c6c866bf66071c95ab6904a717b070 --- /dev/null +++ b/applications/utilities/mesh/generation/cvMesh/cvMeshBackgroundMesh/cvMeshBackgroundMesh.C @@ -0,0 +1,770 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM 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 3 of the License, or + (at your option) any later version. + + OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +Application + cvMeshBackGroundMesh + +Description + Writes out background mesh as constructed by cvMesh and constructs + distanceSurface. + +\*---------------------------------------------------------------------------*/ + +#include "PatchTools.H" +#include "argList.H" +#include "Time.H" +#include "triSurface.H" +#include "searchableSurfaces.H" +#include "conformationSurfaces.H" +#include "cellSizeControlSurfaces.H" +#include "backgroundMeshDecomposition.H" +#include "cellShape.H" +#include "cellModeller.H" +#include "DynamicField.H" +#include "isoSurfaceCell.H" +#include "vtkSurfaceWriter.H" +#include "syncTools.H" + +using namespace Foam; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +// Tolerance (as fraction of the bounding box). Needs to be fairly lax since +// usually meshes get written with limited precision (6 digits) +static const scalar defaultMergeTol = 1E-6; + +// Get merging distance when matching face centres +scalar getMergeDistance +( + const argList& args, + const Time& runTime, + const boundBox& bb +) +{ + scalar mergeTol = defaultMergeTol; + args.optionReadIfPresent("mergeTol", mergeTol); + + scalar writeTol = + Foam::pow(scalar(10.0), -scalar(IOstream::defaultPrecision())); + + Info<< "Merge tolerance : " << mergeTol << nl + << "Write tolerance : " << writeTol << endl; + + if (runTime.writeFormat() == IOstream::ASCII && mergeTol < writeTol) + { + FatalErrorIn("getMergeDistance") + << "Your current settings specify ASCII writing with " + << IOstream::defaultPrecision() << " digits precision." << endl + << "Your merging tolerance (" << mergeTol << ") is finer than this." + << endl + << "Please change your writeFormat to binary" + << " or increase the writePrecision" << endl + << "or adjust the merge tolerance (-mergeTol)." + << exit(FatalError); + } + + scalar mergeDist = mergeTol * bb.mag(); + + Info<< "Overall meshes bounding box : " << bb << nl + << "Relative tolerance : " << mergeTol << nl + << "Absolute matching distance : " << mergeDist << nl + << endl; + + return mergeDist; +} + + +void printMeshData(const polyMesh& mesh) +{ + // Collect all data on master + + globalIndex globalCells(mesh.nCells()); + labelListList patchNeiProcNo(Pstream::nProcs()); + labelListList patchSize(Pstream::nProcs()); + const labelList& pPatches = mesh.globalData().processorPatches(); + patchNeiProcNo[Pstream::myProcNo()].setSize(pPatches.size()); + patchSize[Pstream::myProcNo()].setSize(pPatches.size()); + forAll(pPatches, i) + { + const processorPolyPatch& ppp = refCast<const processorPolyPatch> + ( + mesh.boundaryMesh()[pPatches[i]] + ); + patchNeiProcNo[Pstream::myProcNo()][i] = ppp.neighbProcNo(); + patchSize[Pstream::myProcNo()][i] = ppp.size(); + } + Pstream::gatherList(patchNeiProcNo); + Pstream::gatherList(patchSize); + + + // Print stats + + globalIndex globalBoundaryFaces(mesh.nFaces()-mesh.nInternalFaces()); + + label maxProcCells = 0; + label totProcFaces = 0; + label maxProcPatches = 0; + label totProcPatches = 0; + label maxProcFaces = 0; + + for (label procI = 0; procI < Pstream::nProcs(); procI++) + { + Info<< endl + << "Processor " << procI << nl + << " Number of cells = " << globalCells.localSize(procI) + << endl; + + label nProcFaces = 0; + + const labelList& nei = patchNeiProcNo[procI]; + + forAll(patchNeiProcNo[procI], i) + { + Info<< " Number of faces shared with processor " + << patchNeiProcNo[procI][i] << " = " << patchSize[procI][i] + << endl; + + nProcFaces += patchSize[procI][i]; + } + + Info<< " Number of processor patches = " << nei.size() << nl + << " Number of processor faces = " << nProcFaces << nl + << " Number of boundary faces = " + << globalBoundaryFaces.localSize(procI) << endl; + + maxProcCells = max(maxProcCells, globalCells.localSize(procI)); + totProcFaces += nProcFaces; + totProcPatches += nei.size(); + maxProcPatches = max(maxProcPatches, nei.size()); + maxProcFaces = max(maxProcFaces, nProcFaces); + } + + // Stats + + scalar avgProcCells = scalar(globalCells.size())/Pstream::nProcs(); + scalar avgProcPatches = scalar(totProcPatches)/Pstream::nProcs(); + scalar avgProcFaces = scalar(totProcFaces)/Pstream::nProcs(); + + // In case of all faces on one processor. Just to avoid division by 0. + if (totProcPatches == 0) + { + avgProcPatches = 1; + } + if (totProcFaces == 0) + { + avgProcFaces = 1; + } + + Info<< nl + << "Number of processor faces = " << totProcFaces/2 << nl + << "Max number of cells = " << maxProcCells + << " (" << 100.0*(maxProcCells-avgProcCells)/avgProcCells + << "% above average " << avgProcCells << ")" << nl + << "Max number of processor patches = " << maxProcPatches + << " (" << 100.0*(maxProcPatches-avgProcPatches)/avgProcPatches + << "% above average " << avgProcPatches << ")" << nl + << "Max number of faces between processors = " << maxProcFaces + << " (" << 100.0*(maxProcFaces-avgProcFaces)/avgProcFaces + << "% above average " << avgProcFaces << ")" << nl + << endl; +} + + +// Return cellID +label cellLabel +( + const Vector<label>& nCells, + const label i, + const label j, + const label k +) +{ + return i*nCells[1]*nCells[2]+j*nCells[2]+k; +} + +label vtxLabel +( + const Vector<label>& nCells, + const label i, + const label j, + const label k +) +{ + Vector<label> nPoints + ( + nCells[0]+1, + nCells[1]+1, + nCells[2]+1 + ); + return i*nPoints[1]*nPoints[2]+j*nPoints[2]+k; +} + + +autoPtr<polyMesh> generateHexMesh +( + const IOobject& io, + const point& origin, + const vector& cellSize, + const Vector<label>& nCells +) +{ + pointField points; + if (nCells[0]+nCells[1]+nCells[2] > 0) + { + points.setSize((nCells[0]+1)*(nCells[1]+1)*(nCells[2]+1)); + + // Generate points + for (label i = 0; i <= nCells[0]; i++) + { + for (label j = 0; j <= nCells[1]; j++) + { + for (label k = 0; k <= nCells[2]; k++) + { + point pt = origin; + pt.x() += i*cellSize[0]; + pt.y() += j*cellSize[1]; + pt.z() += k*cellSize[2]; + points[vtxLabel(nCells, i, j, k)] = pt; + } + } + } + } + + + const cellModel& hex = *(cellModeller::lookup("hex")); + cellShapeList cellShapes(nCells[0]*nCells[1]*nCells[2]); + + labelList hexPoints(8); + label cellI = 0; + for (label i = 0; i < nCells[0]; i++) + { + for (label j = 0; j < nCells[1]; j++) + { + for (label k = 0; k < nCells[2]; k++) + { + hexPoints[0] = vtxLabel(nCells, i, j, k); + hexPoints[1] = vtxLabel(nCells, i+1, j, k); + hexPoints[2] = vtxLabel(nCells, i+1, j+1, k); + hexPoints[3] = vtxLabel(nCells, i, j+1, k); + hexPoints[4] = vtxLabel(nCells, i, j, k+1); + hexPoints[5] = vtxLabel(nCells, i+1, j, k+1); + hexPoints[6] = vtxLabel(nCells, i+1, j+1, k+1); + hexPoints[7] = vtxLabel(nCells, i, j+1, k+1); + cellShapes[cellI++] = cellShape(hex, hexPoints); + } + } + } + + faceListList boundary(0); + wordList patchNames(0); + wordList patchTypes(0); + word defaultFacesName = "defaultFaces"; + word defaultFacesType = polyPatch::typeName; + wordList patchPhysicalTypes(0); + + return autoPtr<polyMesh> + ( + new polyMesh + ( + io, + xferMoveTo<pointField>(points), + cellShapes, + boundary, + patchNames, + patchTypes, + defaultFacesName, + defaultFacesType, + patchPhysicalTypes + ) + ); +} + + +// Determine for every point a signed distance to the nearest surface +// (outside is positive) +tmp<scalarField> signedDistance +( + const scalarField& distSqr, + const pointField& points, + const searchableSurfaces& geometry, + const labelList& surfaces +) +{ + tmp<scalarField> tfld(new scalarField(points.size(), Foam::sqr(GREAT))); + scalarField& fld = tfld(); + + // Find nearest + List<pointIndexHit> nearest; + labelList nearestSurfaces; + searchableSurfacesQueries::findNearest + ( + geometry, + surfaces, + points, + scalarField(points.size(), Foam::sqr(GREAT)),//distSqr + nearestSurfaces, + nearest + ); + + // Determine sign of nearest. Sort by surface to do this. + DynamicField<point> surfPoints(points.size()); + DynamicList<label> surfIndices(points.size()); + + forAll(surfaces, surfI) + { + // Extract points on this surface + surfPoints.clear(); + surfIndices.clear(); + forAll(nearestSurfaces, i) + { + if (nearestSurfaces[i] == surfI) + { + surfPoints.append(points[i]); + surfIndices.append(i); + } + } + + // Calculate sideness of these surface points + label geomI = surfaces[surfI]; + List<searchableSurface::volumeType> volType; + geometry[geomI].getVolumeType(surfPoints, volType); + + // Push back to original + forAll(volType, i) + { + label pointI = surfIndices[i]; + scalar dist = mag(points[pointI] - nearest[pointI].hitPoint()); + + searchableSurface::volumeType vT = volType[i]; + + if (vT == searchableSurface::OUTSIDE) + { + fld[pointI] = dist; + } + else if (vT == searchableSurface::INSIDE) + { + fld[i] = -dist; + } + else + { + FatalErrorIn("signedDistance()") + << "getVolumeType failure, neither INSIDE or OUTSIDE" + << exit(FatalError); + } + } + } + + return tfld; +} + + + +// Main program: + +int main(int argc, char *argv[]) +{ + argList::addNote + ( + "Generate cvMesh-consistent representation of surfaces" + ); + argList::addBoolOption + ( + "writeMesh", + "write the resulting mesh and distance fields" + ); + argList::addOption + ( + "mergeTol", + "scalar", + "specify the merge distance relative to the bounding box size " + "(default 1E-6)" + ); + + #include "setRootCase.H" + #include "createTime.H" + runTime.functionObjects().off(); + + const bool writeMesh = args.optionFound("writeMesh"); + + if (writeMesh) + { + Info<< "Writing resulting mesh and cellDistance, pointDistance fields." + << nl << endl; + } + + + IOdictionary cvMeshDict + ( + IOobject + ( + "cvMeshDict", + runTime.system(), + runTime, + IOobject::MUST_READ_IF_MODIFIED, + IOobject::NO_WRITE + ) + ); + + // Define/load all geometry + searchableSurfaces allGeometry + ( + IOobject + ( + "cvSearchableSurfaces", + runTime.constant(), + "triSurface", + runTime, + IOobject::MUST_READ, + IOobject::NO_WRITE + ), + cvMeshDict.subDict("geometry") + ); + + Random rndGen(64293*Pstream::myProcNo()); + + conformationSurfaces geometryToConformTo + ( + runTime, + rndGen, + allGeometry, + cvMeshDict.subDict("surfaceConformation") + ); + + cellSizeControlSurfaces cellSizeControl + ( + allGeometry, + cvMeshDict.subDict("motionControl") + ); + + + // Generate starting block mesh + vector cellSize; + { + const treeBoundBox& bb = geometryToConformTo.globalBounds(); + + // Determine the number of cells in each direction. + const vector span = bb.span(); + vector nScalarCells = span/cellSizeControl.defaultCellSize(); + + // Calculate initial cell size to be a little bit smaller than the + // defaultCellSize to avoid initial refinement triggering. + Vector<label> nCells = Vector<label> + ( + label(nScalarCells.x())+2, + label(nScalarCells.y())+2, + label(nScalarCells.z())+2 + ); + cellSize = vector + ( + span[0]/nCells[0], + span[1]/nCells[1], + span[2]/nCells[2] + ); + + Info<< "Generating initial hex mesh with" << nl + << " bounding box : " << bb << nl + << " nCells : " << nCells << nl + << " cellSize : " << cellSize << nl + << endl; + + autoPtr<polyMesh> meshPtr + ( + generateHexMesh + ( + IOobject + ( + polyMesh::defaultRegion, + runTime.constant(), + runTime + ), + bb.min(), + cellSize, + ( + Pstream::master() + ? nCells + : Vector<label>(0, 0, 0) + ) + ) + ); + Info<< "Writing initial hex mesh to " << meshPtr().instance() << nl + << endl; + meshPtr().write(); + } + + // Distribute the initial mesh + if (Pstream::parRun()) + { +# include "createMesh.H" + Info<< "Loaded mesh:" << endl; + printMeshData(mesh); + + // Allocate a decomposer + IOdictionary decompositionDict + ( + IOobject + ( + "decomposeParDict", + runTime.system(), + mesh, + IOobject::MUST_READ_IF_MODIFIED, + IOobject::NO_WRITE + ) + ); + + autoPtr<decompositionMethod> decomposer + ( + decompositionMethod::New + ( + decompositionDict + ) + ); + + labelList decomp = decomposer().decompose(mesh, mesh.cellCentres()); + + // Global matching tolerance + const scalar tolDim = getMergeDistance + ( + args, + runTime, + mesh.bounds() + ); + + // Mesh distribution engine + fvMeshDistribute distributor(mesh, tolDim); + + Info<< "Wanted distribution:" + << distributor.countCells(decomp) << nl << endl; + + // Do actual sending/receiving of mesh + autoPtr<mapDistributePolyMesh> map = distributor.distribute(decomp); + + // Print some statistics + //Info<< "After distribution:" << endl; + //printMeshData(mesh); + + mesh.setInstance(runTime.constant()); + Info<< "Writing redistributed mesh" << nl << endl; + mesh.write(); + } + + + Info<< "Refining backgroud mesh according to cell size specification" << nl + << endl; + + backgroundMeshDecomposition backgroundMesh + ( + 1.0, //spanScale,ratio of poly cell size v.s. hex cell size + 0.0, //minCellSizeLimit + 0, //minLevels + 4, //volRes, check multiple points per cell + 20.0, //maxCellWeightCoeff + runTime, + geometryToConformTo, + cellSizeControl, + rndGen, + cvMeshDict + ); + + if (writeMesh) + { + runTime++; + Info<< "Writing mesh to " << runTime.timeName() << endl; + backgroundMesh.mesh().write(); + } + + const scalar tolDim = getMergeDistance + ( + args, + runTime, + backgroundMesh.mesh().bounds() + ); + + + faceList isoFaces; + pointField isoPoints; + + { + // Apply a distanceSurface to it. + const fvMesh& fvm = backgroundMesh.mesh(); + + volScalarField cellDistance + ( + IOobject + ( + "cellDistance", + fvm.time().timeName(), + fvm.time(), + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ), + fvm, + dimensionedScalar("zero", dimLength, 0) + ); + + const searchableSurfaces& geometry = geometryToConformTo.geometry(); + const labelList& surfaces = geometryToConformTo.surfaces(); + + + // Get maximum search size per cell + scalarField distSqr(cellDistance.size()); + + const labelList& cellLevel = backgroundMesh.cellLevel(); + forAll(cellLevel, cellI) + { + // The largest edge of the cell will always be less than the + // span of the bounding box of the cell. + distSqr[cellI] = magSqr(cellSize)/pow(2, cellLevel[cellI]); + } + + { + // Internal field + cellDistance.internalField() = signedDistance + ( + distSqr, + fvm.C(), + geometry, + surfaces + ); + // Patch fields + forAll(fvm.C().boundaryField(), patchI) + { + const pointField& cc = fvm.C().boundaryField()[patchI]; + fvPatchScalarField& fld = cellDistance.boundaryField()[patchI]; + scalarField patchDistSqr + ( + fld.patch().patchInternalField(distSqr) + ); + fld = signedDistance(patchDistSqr, cc, geometry, surfaces); + } + + // On processor patches the fvm.C() will already be the cell centre + // on the opposite side so no need to swap cellDistance. + + if (writeMesh) + { + cellDistance.write(); + } + } + + + // Distance to points + pointScalarField pointDistance + ( + IOobject + ( + "pointDistance", + fvm.time().timeName(), + fvm.time(), + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ), + pointMesh::New(fvm), + dimensionedScalar("zero", dimLength, 0) + ); + { + scalarField pointDistSqr(fvm.nPoints(), -sqr(GREAT)); + for (label faceI = 0; faceI < fvm.nInternalFaces(); faceI++) + { + label own = fvm.faceOwner()[faceI]; + label ownDistSqr = distSqr[own]; + + const face& f = fvm.faces()[faceI]; + forAll(f, fp) + { + pointDistSqr[f[fp]] = max(pointDistSqr[f[fp]], ownDistSqr); + } + } + syncTools::syncPointList + ( + fvm, + pointDistSqr, + maxEqOp<scalar>(), + -sqr(GREAT) // null value + ); + + pointDistance.internalField() = signedDistance + ( + pointDistSqr, + fvm.points(), + geometry, + surfaces + ); + + if (writeMesh) + { + pointDistance.write(); + } + } + + isoSurfaceCell iso + ( + fvm, + cellDistance, + pointDistance, + 0, //distance, + false //regularise + ); + + isoFaces.setSize(iso.size()); + forAll(isoFaces, i) + { + isoFaces[i] = iso[i].triFaceFace(); + } + isoPoints = iso.points(); + } + + + pointField mergedPoints; + faceList mergedFaces; + labelList pointMergeMap; + PatchTools::gatherAndMerge + ( + tolDim, + primitivePatch + ( + SubList<face>(isoFaces, isoFaces.size()), + isoPoints + ), + mergedPoints, + mergedFaces, + pointMergeMap + ); + + vtkSurfaceWriter writer; + writer.write + ( + runTime.path(), + "iso", + mergedPoints, + mergedFaces + ); + + Info<< "End\n" << endl; + + return 0; +} + + +// ************************************************************************* // diff --git a/applications/utilities/mesh/generation/cvMesh/cvMeshSurfaceSimplify/Allwmake b/applications/utilities/mesh/generation/cvMesh/cvMeshSurfaceSimplify/Allwmake new file mode 100755 index 0000000000000000000000000000000000000000..98dec66c76bfc035c39136cff18ad685c707128c --- /dev/null +++ b/applications/utilities/mesh/generation/cvMesh/cvMeshSurfaceSimplify/Allwmake @@ -0,0 +1,10 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # run from this directory +set -x + +if [ -d "${FASTDUALOCTREE_SRC_PATH}" ] +then + wmake +fi + +# ----------------------------------------------------------------- end-of-file diff --git a/applications/utilities/mesh/generation/cvMesh/cvMeshSurfaceSimplify/Make/files b/applications/utilities/mesh/generation/cvMesh/cvMeshSurfaceSimplify/Make/files index a0fcd8f0bf85d8c5624f026c6cae568cd63f7251..fbe4cfeda6cc8bd7e41dd0bc3e34eb92108cfce8 100644 --- a/applications/utilities/mesh/generation/cvMesh/cvMeshSurfaceSimplify/Make/files +++ b/applications/utilities/mesh/generation/cvMesh/cvMeshSurfaceSimplify/Make/files @@ -1,6 +1,22 @@ -cvMeshSurfaceSimplify.C - +/* +cvMeshSurfaceSimplify_non_octree.C MarchingCubes/MarchingCubes.cpp MarchingCubes/ply.c +*/ + +/* +MarchingCubes = fastdualoctree_sgp + +$(MarchingCubes)/data_access.cpp +$(MarchingCubes)/fparser.cpp +$(MarchingCubes)/fpoptimizer.cpp +$(MarchingCubes)/MarchingCubes.cpp +$(MarchingCubes)/mc_draw.cpp +$(MarchingCubes)/morton.cpp +$(MarchingCubes)/opt_octree.cpp +$(MarchingCubes)/hash_octree.cpp +*/ + +cvMeshSurfaceSimplify.C EXE = $(FOAM_APPBIN)/cvMeshSurfaceSimplify diff --git a/applications/utilities/mesh/generation/cvMesh/cvMeshSurfaceSimplify/Make/options b/applications/utilities/mesh/generation/cvMesh/cvMeshSurfaceSimplify/Make/options index 1711b9ba615e3d9a77ea1e005fc6dc392a93a06e..3b9b222ba8343d500079b8137861acc19aaae6b4 100644 --- a/applications/utilities/mesh/generation/cvMesh/cvMeshSurfaceSimplify/Make/options +++ b/applications/utilities/mesh/generation/cvMesh/cvMeshSurfaceSimplify/Make/options @@ -1,7 +1,12 @@ +MarchingCubes = fastdualoctree_sgp + include $(GENERAL_RULES)/CGAL EXE_INC = \ - -IMarchingCubes \ + -DUNIX \ + -Wno-old-style-cast \ + /* -IMarchingCubes */ \ + -I$(FASTDUALOCTREE_SRC_PATH) \ -I../conformalVoronoiMesh/lnInclude \ -I$(LIB_SRC)/edgeMesh/lnInclude \ -I$(LIB_SRC)/triSurface/lnInclude \ @@ -9,6 +14,8 @@ EXE_INC = \ EXE_LIBS = \ $(CGAL_LIBS) \ + -L$(FASTDUALOCTREE_SRC_PATH) -lperf_main \ + -lGL \ -lconformalVoronoiMesh \ -ldecompositionMethods -L$(FOAM_LIBBIN)/dummy -lscotchDecomp \ -ledgeMesh \ diff --git a/applications/utilities/mesh/generation/cvMesh/cvMeshSurfaceSimplify/MarchingCubes/LookUpTable.h b/applications/utilities/mesh/generation/cvMesh/cvMeshSurfaceSimplify/MarchingCubes/LookUpTable.h deleted file mode 100755 index 5529346954a3fb59076c85d2edaf980978f4a245..0000000000000000000000000000000000000000 --- a/applications/utilities/mesh/generation/cvMesh/cvMeshSurfaceSimplify/MarchingCubes/LookUpTable.h +++ /dev/null @@ -1,2322 +0,0 @@ -/** - * @file LookUpTable.h - * @author Thomas Lewiner <thomas.lewiner@polytechnique.org> - * @author Math Dept, PUC-Rio - * @version 0.2 - * @date 12/08/2002 - * - * @brief LookUpTable for the MarchingCubes 33 Algorithm - */ -//________________________________________________ - - - -#ifndef _LOOKUPTABLE_H_ -#define _LOOKUPTABLE_H_ - - - - - -//_____________________________________________________________________________ -/** - * \brief case mapping - * For each of the possible vertex states listed in this table there is a - * specific triangulation of the edge intersection points. The table lists - * all of them in the form of 0-5 edge triples with the list terminated by - * the invalid value -1. For example: case[3] list the 2 triangles - * formed when cube[0] and cube[1] are inside of the surface, but the rest of - * the cube is not. - * - * Cube description: - * 7 ________ 6 _____6__ ________ - * /| /| 7/| /| /| /| - * / | / | / | /5 | / 6 / | - * 4 /_______ / | /__4____ / 10 /_______3/ | - * | | |5 | | 11 | | | | | 2 | - * | 3|__|_____|2 | |__|__2__| | 4 |__|_____| - * | / | / 8 3/ 9 / | / | / - * | / | / | / | /1 | / 5 / - * |/_______|/ |/___0___|/ |/_1_____|/ - * 0 1 0 1 - */ -//----------------------------------------------------------------------------- -static const char cases[256][2] = { -/* 0: */ { 0, -1 }, -/* 1: 0, */ { 1, 0 }, -/* 2: 1, */ { 1, 1 }, -/* 3: 0, 1, */ { 2, 0 }, -/* 4: 2, */ { 1, 2 }, -/* 5: 0, 2, */ { 3, 0 }, -/* 6: 1, 2, */ { 2, 3 }, -/* 7: 0, 1, 2, */ { 5, 0 }, -/* 8: 3, */ { 1, 3 }, -/* 9: 0, 3, */ { 2, 1 }, -/* 10: 1, 3, */ { 3, 3 }, -/* 11: 0, 1, 3, */ { 5, 1 }, -/* 12: 2, 3, */ { 2, 5 }, -/* 13: 0, 2, 3, */ { 5, 4 }, -/* 14: 1, 2, 3, */ { 5, 9 }, -/* 15: 0, 1, 2, 3, */ { 8, 0 }, -/* 16: 4, */ { 1, 4 }, -/* 17: 0, 4, */ { 2, 2 }, -/* 18: 1, 4, */ { 3, 4 }, -/* 19: 0, 1, 4, */ { 5, 2 }, -/* 20: 2, 4, */ { 4, 2 }, -/* 21: 0, 2, 4, */ { 6, 2 }, -/* 22: 1, 2, 4, */ { 6, 9 }, -/* 23: 0, 1, 2, 4, */ { 11, 0 }, -/* 24: 3, 4, */ { 3, 8 }, -/* 25: 0, 3, 4, */ { 5, 5 }, -/* 26: 1, 3, 4, */ { 7, 3 }, -/* 27: 0, 1, 3, 4, */ { 9, 1 }, -/* 28: 2, 3, 4, */ { 6, 16 }, -/* 29: 0, 2, 3, 4, */ { 14, 3 }, -/* 30: 1, 2, 3, 4, */ { 12, 12 }, -/* 31: 0, 1, 2, 3, 4, */ { 5, 24 }, -/* 32: 5, */ { 1, 5 }, -/* 33: 0, 5, */ { 3, 1 }, -/* 34: 1, 5, */ { 2, 4 }, -/* 35: 0, 1, 5, */ { 5, 3 }, -/* 36: 2, 5, */ { 3, 6 }, -/* 37: 0, 2, 5, */ { 7, 0 }, -/* 38: 1, 2, 5, */ { 5, 10 }, -/* 39: 0, 1, 2, 5, */ { 9, 0 }, -/* 40: 3, 5, */ { 4, 3 }, -/* 41: 0, 3, 5, */ { 6, 4 }, -/* 42: 1, 3, 5, */ { 6, 11 }, -/* 43: 0, 1, 3, 5, */ { 14, 1 }, -/* 44: 2, 3, 5, */ { 6, 17 }, -/* 45: 0, 2, 3, 5, */ { 12, 4 }, -/* 46: 1, 2, 3, 5, */ { 11, 6 }, -/* 47: 0, 1, 2, 3, 5, */ { 5, 25 }, -/* 48: 4, 5, */ { 2, 8 }, -/* 49: 0, 4, 5, */ { 5, 7 }, -/* 50: 1, 4, 5, */ { 5, 12 }, -/* 51: 0, 1, 4, 5, */ { 8, 1 }, -/* 52: 2, 4, 5, */ { 6, 18 }, -/* 53: 0, 2, 4, 5, */ { 12, 5 }, -/* 54: 1, 2, 4, 5, */ { 14, 7 }, -/* 55: 0, 1, 2, 4, 5, */ { 5, 28 }, -/* 56: 3, 4, 5, */ { 6, 21 }, -/* 57: 0, 3, 4, 5, */ { 11, 4 }, -/* 58: 1, 3, 4, 5, */ { 12, 15 }, -/* 59: 0, 1, 3, 4, 5, */ { 5, 30 }, -/* 60: 2, 3, 4, 5, */ { 10, 5 }, -/* 61: 0, 2, 3, 4, 5, */ { 6, 32 }, -/* 62: 1, 2, 3, 4, 5, */ { 6, 39 }, -/* 63: 0, 1, 2, 3, 4, 5, */ { 2, 12 }, -/* 64: 6, */ { 1, 6 }, -/* 65: 0, 6, */ { 4, 0 }, -/* 66: 1, 6, */ { 3, 5 }, -/* 67: 0, 1, 6, */ { 6, 0 }, -/* 68: 2, 6, */ { 2, 6 }, -/* 69: 0, 2, 6, */ { 6, 3 }, -/* 70: 1, 2, 6, */ { 5, 11 }, -/* 71: 0, 1, 2, 6, */ { 14, 0 }, -/* 72: 3, 6, */ { 3, 9 }, -/* 73: 0, 3, 6, */ { 6, 5 }, -/* 74: 1, 3, 6, */ { 7, 4 }, -/* 75: 0, 1, 3, 6, */ { 12, 1 }, -/* 76: 2, 3, 6, */ { 5, 14 }, -/* 77: 0, 2, 3, 6, */ { 11, 3 }, -/* 78: 1, 2, 3, 6, */ { 9, 4 }, -/* 79: 0, 1, 2, 3, 6, */ { 5, 26 }, -/* 80: 4, 6, */ { 3, 10 }, -/* 81: 0, 4, 6, */ { 6, 6 }, -/* 82: 1, 4, 6, */ { 7, 5 }, -/* 83: 0, 1, 4, 6, */ { 12, 2 }, -/* 84: 2, 4, 6, */ { 6, 19 }, -/* 85: 0, 2, 4, 6, */ { 10, 1 }, -/* 86: 1, 2, 4, 6, */ { 12, 13 }, -/* 87: 0, 1, 2, 4, 6, */ { 6, 24 }, -/* 88: 3, 4, 6, */ { 7, 7 }, -/* 89: 0, 3, 4, 6, */ { 12, 9 }, -/* 90: 1, 3, 4, 6, */ { 13, 1 }, -/* 91: 0, 1, 3, 4, 6, */ { 7, 9 }, -/* 92: 2, 3, 4, 6, */ { 12, 20 }, -/* 93: 0, 2, 3, 4, 6, */ { 6, 33 }, -/* 94: 1, 2, 3, 4, 6, */ { 7, 13 }, -/* 95: 0, 1, 2, 3, 4, 6, */ { 3, 12 }, -/* 96: 5, 6, */ { 2, 10 }, -/* 97: 0, 5, 6, */ { 6, 7 }, -/* 98: 1, 5, 6, */ { 5, 13 }, -/* 99: 0, 1, 5, 6, */ { 11, 2 }, -/* 100: 2, 5, 6, */ { 5, 16 }, -/* 101: 0, 2, 5, 6, */ { 12, 7 }, -/* 102: 1, 2, 5, 6, */ { 8, 3 }, -/* 103: 0, 1, 2, 5, 6, */ { 5, 29 }, -/* 104: 3, 5, 6, */ { 6, 22 }, -/* 105: 0, 3, 5, 6, */ { 10, 2 }, -/* 106: 1, 3, 5, 6, */ { 12, 17 }, -/* 107: 0, 1, 3, 5, 6, */ { 6, 27 }, -/* 108: 2, 3, 5, 6, */ { 14, 9 }, -/* 109: 0, 2, 3, 5, 6, */ { 6, 34 }, -/* 110: 1, 2, 3, 5, 6, */ { 5, 39 }, -/* 111: 0, 1, 2, 3, 5, 6, */ { 2, 14 }, -/* 112: 4, 5, 6, */ { 5, 20 }, -/* 113: 0, 4, 5, 6, */ { 14, 5 }, -/* 114: 1, 4, 5, 6, */ { 9, 5 }, -/* 115: 0, 1, 4, 5, 6, */ { 5, 32 }, -/* 116: 2, 4, 5, 6, */ { 11, 10 }, -/* 117: 0, 2, 4, 5, 6, */ { 6, 35 }, -/* 118: 1, 2, 4, 5, 6, */ { 5, 41 }, -/* 119: 0, 1, 2, 4, 5, 6, */ { 2, 16 }, -/* 120: 3, 4, 5, 6, */ { 12, 23 }, -/* 121: 0, 3, 4, 5, 6, */ { 6, 37 }, -/* 122: 1, 3, 4, 5, 6, */ { 7, 14 }, -/* 123: 0, 1, 3, 4, 5, 6, */ { 3, 16 }, -/* 124: 2, 3, 4, 5, 6, */ { 6, 46 }, -/* 125: 0, 2, 3, 4, 5, 6, */ { 4, 6 }, -/* 126: 1, 2, 3, 4, 5, 6, */ { 3, 21 }, -/* 127: 0, 1, 2, 3, 4, 5, 6, */ { 1, 8 }, -/* 128: 7, */ { 1, 7 }, -/* 129: 0, 7, */ { 3, 2 }, -/* 130: 1, 7, */ { 4, 1 }, -/* 131: 0, 1, 7, */ { 6, 1 }, -/* 132: 2, 7, */ { 3, 7 }, -/* 133: 0, 2, 7, */ { 7, 1 }, -/* 134: 1, 2, 7, */ { 6, 10 }, -/* 135: 0, 1, 2, 7, */ { 12, 0 }, -/* 136: 3, 7, */ { 2, 7 }, -/* 137: 0, 3, 7, */ { 5, 6 }, -/* 138: 1, 3, 7, */ { 6, 12 }, -/* 139: 0, 1, 3, 7, */ { 11, 1 }, -/* 140: 2, 3, 7, */ { 5, 15 }, -/* 141: 0, 2, 3, 7, */ { 9, 2 }, -/* 142: 1, 2, 3, 7, */ { 14, 6 }, -/* 143: 0, 1, 2, 3, 7, */ { 5, 27 }, -/* 144: 4, 7, */ { 2, 9 }, -/* 145: 0, 4, 7, */ { 5, 8 }, -/* 146: 1, 4, 7, */ { 6, 13 }, -/* 147: 0, 1, 4, 7, */ { 14, 2 }, -/* 148: 2, 4, 7, */ { 6, 20 }, -/* 149: 0, 2, 4, 7, */ { 12, 6 }, -/* 150: 1, 2, 4, 7, */ { 10, 3 }, -/* 151: 0, 1, 2, 4, 7, */ { 6, 25 }, -/* 152: 3, 4, 7, */ { 5, 18 }, -/* 153: 0, 3, 4, 7, */ { 8, 2 }, -/* 154: 1, 3, 4, 7, */ { 12, 16 }, -/* 155: 0, 1, 3, 4, 7, */ { 5, 31 }, -/* 156: 2, 3, 4, 7, */ { 11, 9 }, -/* 157: 0, 2, 3, 4, 7, */ { 5, 34 }, -/* 158: 1, 2, 3, 4, 7, */ { 6, 40 }, -/* 159: 0, 1, 2, 3, 4, 7, */ { 2, 13 }, -/* 160: 5, 7, */ { 3, 11 }, -/* 161: 0, 5, 7, */ { 7, 2 }, -/* 162: 1, 5, 7, */ { 6, 14 }, -/* 163: 0, 1, 5, 7, */ { 12, 3 }, -/* 164: 2, 5, 7, */ { 7, 6 }, -/* 165: 0, 2, 5, 7, */ { 13, 0 }, -/* 166: 1, 2, 5, 7, */ { 12, 14 }, -/* 167: 0, 1, 2, 5, 7, */ { 7, 8 }, -/* 168: 3, 5, 7, */ { 6, 23 }, -/* 169: 0, 3, 5, 7, */ { 12, 10 }, -/* 170: 1, 3, 5, 7, */ { 10, 4 }, -/* 171: 0, 1, 3, 5, 7, */ { 6, 28 }, -/* 172: 2, 3, 5, 7, */ { 12, 21 }, -/* 173: 0, 2, 3, 5, 7, */ { 7, 10 }, -/* 174: 1, 2, 3, 5, 7, */ { 6, 41 }, -/* 175: 0, 1, 2, 3, 5, 7, */ { 3, 13 }, -/* 176: 4, 5, 7, */ { 5, 21 }, -/* 177: 0, 4, 5, 7, */ { 9, 3 }, -/* 178: 1, 4, 5, 7, */ { 11, 8 }, -/* 179: 0, 1, 4, 5, 7, */ { 5, 33 }, -/* 180: 2, 4, 5, 7, */ { 12, 22 }, -/* 181: 0, 2, 4, 5, 7, */ { 7, 11 }, -/* 182: 1, 2, 4, 5, 7, */ { 6, 42 }, -/* 183: 0, 1, 2, 4, 5, 7, */ { 3, 14 }, -/* 184: 3, 4, 5, 7, */ { 14, 11 }, -/* 185: 0, 3, 4, 5, 7, */ { 5, 36 }, -/* 186: 1, 3, 4, 5, 7, */ { 6, 44 }, -/* 187: 0, 1, 3, 4, 5, 7, */ { 2, 17 }, -/* 188: 2, 3, 4, 5, 7, */ { 6, 47 }, -/* 189: 0, 2, 3, 4, 5, 7, */ { 3, 18 }, -/* 190: 1, 2, 3, 4, 5, 7, */ { 4, 7 }, -/* 191: 0, 1, 2, 3, 4, 5, 7, */ { 1, 9 }, -/* 192: 6, 7, */ { 2, 11 }, -/* 193: 0, 6, 7, */ { 6, 8 }, -/* 194: 1, 6, 7, */ { 6, 15 }, -/* 195: 0, 1, 6, 7, */ { 10, 0 }, -/* 196: 2, 6, 7, */ { 5, 17 }, -/* 197: 0, 2, 6, 7, */ { 12, 8 }, -/* 198: 1, 2, 6, 7, */ { 11, 7 }, -/* 199: 0, 1, 2, 6, 7, */ { 6, 26 }, -/* 200: 3, 6, 7, */ { 5, 19 }, -/* 201: 0, 3, 6, 7, */ { 14, 4 }, -/* 202: 1, 3, 6, 7, */ { 12, 18 }, -/* 203: 0, 1, 3, 6, 7, */ { 6, 29 }, -/* 204: 2, 3, 6, 7, */ { 8, 4 }, -/* 205: 0, 2, 3, 6, 7, */ { 5, 35 }, -/* 206: 1, 2, 3, 6, 7, */ { 5, 40 }, -/* 207: 0, 1, 2, 3, 6, 7, */ { 2, 15 }, -/* 208: 4, 6, 7, */ { 5, 22 }, -/* 209: 0, 4, 6, 7, */ { 11, 5 }, -/* 210: 1, 4, 6, 7, */ { 12, 19 }, -/* 211: 0, 1, 4, 6, 7, */ { 6, 30 }, -/* 212: 2, 4, 6, 7, */ { 14, 10 }, -/* 213: 0, 2, 4, 6, 7, */ { 6, 36 }, -/* 214: 1, 2, 4, 6, 7, */ { 6, 43 }, -/* 215: 0, 1, 2, 4, 6, 7, */ { 4, 4 }, -/* 216: 3, 4, 6, 7, */ { 9, 7 }, -/* 217: 0, 3, 4, 6, 7, */ { 5, 37 }, -/* 218: 1, 3, 4, 6, 7, */ { 7, 15 }, -/* 219: 0, 1, 3, 4, 6, 7, */ { 3, 17 }, -/* 220: 2, 3, 4, 6, 7, */ { 5, 44 }, -/* 221: 0, 2, 3, 4, 6, 7, */ { 2, 19 }, -/* 222: 1, 2, 3, 4, 6, 7, */ { 3, 22 }, -/* 223: 0, 1, 2, 3, 4, 6, 7, */ { 1, 10 }, -/* 224: 5, 6, 7, */ { 5, 23 }, -/* 225: 0, 5, 6, 7, */ { 12, 11 }, -/* 226: 1, 5, 6, 7, */ { 14, 8 }, -/* 227: 0, 1, 5, 6, 7, */ { 6, 31 }, -/* 228: 2, 5, 6, 7, */ { 9, 6 }, -/* 229: 0, 2, 5, 6, 7, */ { 7, 12 }, -/* 230: 1, 2, 5, 6, 7, */ { 5, 42 }, -/* 231: 0, 1, 2, 5, 6, 7, */ { 3, 15 }, -/* 232: 3, 5, 6, 7, */ { 11, 11 }, -/* 233: 0, 3, 5, 6, 7, */ { 6, 38 }, -/* 234: 1, 3, 5, 6, 7, */ { 6, 45 }, -/* 235: 0, 1, 3, 5, 6, 7, */ { 4, 5 }, -/* 236: 2, 3, 5, 6, 7, */ { 5, 45 }, -/* 237: 0, 2, 3, 5, 6, 7, */ { 3, 19 }, -/* 238: 1, 2, 3, 5, 6, 7, */ { 2, 21 }, -/* 239: 0, 1, 2, 3, 5, 6, 7, */ { 1, 11 }, -/* 240: 4, 5, 6, 7, */ { 8, 5 }, -/* 241: 0, 4, 5, 6, 7, */ { 5, 38 }, -/* 242: 1, 4, 5, 6, 7, */ { 5, 43 }, -/* 243: 0, 1, 4, 5, 6, 7, */ { 2, 18 }, -/* 244: 2, 4, 5, 6, 7, */ { 5, 46 }, -/* 245: 0, 2, 4, 5, 6, 7, */ { 3, 20 }, -/* 246: 1, 2, 4, 5, 6, 7, */ { 2, 22 }, -/* 247: 0, 1, 2, 4, 5, 6, 7, */ { 1, 12 }, -/* 248: 3, 4, 5, 6, 7, */ { 5, 47 }, -/* 249: 0, 3, 4, 5, 6, 7, */ { 2, 20 }, -/* 250: 1, 3, 4, 5, 6, 7, */ { 3, 23 }, -/* 251: 0, 1, 3, 4, 5, 6, 7, */ { 1, 13 }, -/* 252: 2, 3, 4, 5, 6, 7, */ { 2, 23 }, -/* 253: 0, 2, 3, 4, 5, 6, 7, */ { 1, 14 }, -/* 254: 1, 2, 3, 4, 5, 6, 7, */ { 1, 15 }, -/* 255: 0, 1, 2, 3, 4, 5, 6, 7, */ { 0, -1 } -}; -//_____________________________________________________________________________ - - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 1 - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char tiling1[16][3] = { -/* 1: 0, */ { 0, 8, 3 }, -/* 2: 1, */ { 0, 1, 9 }, -/* 4: 2, */ { 1, 2, 10 }, -/* 8: 3, */ { 3, 11, 2 }, -/* 16: 4, */ { 4, 7, 8 }, -/* 32: 5, */ { 9, 5, 4 }, -/* 64: 6, */ { 10, 6, 5 }, -/* 128: 7, */ { 7, 6, 11 }, -/* 127: 0, 1, 2, 3, 4, 5, 6, */ { 7, 11, 6 }, -/* 191: 0, 1, 2, 3, 4, 5, 7, */ { 10, 5, 6 }, -/* 223: 0, 1, 2, 3, 4, 6, 7, */ { 9, 4, 5 }, -/* 239: 0, 1, 2, 3, 5, 6, 7, */ { 4, 8, 7 }, -/* 247: 0, 1, 2, 4, 5, 6, 7, */ { 3, 2, 11 }, -/* 251: 0, 1, 3, 4, 5, 6, 7, */ { 1, 10, 2 }, -/* 253: 0, 2, 3, 4, 5, 6, 7, */ { 0, 9, 1 }, -/* 254: 1, 2, 3, 4, 5, 6, 7, */ { 0, 3, 8 } -}; -//_____________________________________________________________________________ - - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 2 - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char tiling2[24][6] = { -/* 3: 0, 1, */ { 1, 8, 3, 9, 8, 1 }, -/* 9: 0, 3, */ { 0, 11, 2, 8, 11, 0 }, -/* 17: 0, 4, */ { 4, 3, 0, 7, 3, 4 }, -/* 6: 1, 2, */ { 9, 2, 10, 0, 2, 9 }, -/* 34: 1, 5, */ { 0, 5, 4, 1, 5, 0 }, -/* 12: 2, 3, */ { 3, 10, 1, 11, 10, 3 }, -/* 68: 2, 6, */ { 1, 6, 5, 2, 6, 1 }, -/* 136: 3, 7, */ { 7, 2, 3, 6, 2, 7 }, -/* 48: 4, 5, */ { 9, 7, 8, 5, 7, 9 }, -/* 144: 4, 7, */ { 6, 8, 4, 11, 8, 6 }, -/* 96: 5, 6, */ { 10, 4, 9, 6, 4, 10 }, -/* 192: 6, 7, */ { 11, 5, 10, 7, 5, 11 }, -/* 63: 0, 1, 2, 3, 4, 5, */ { 11, 10, 5, 7, 11, 5 }, -/* 159: 0, 1, 2, 3, 4, 7, */ { 10, 9, 4, 6, 10, 4 }, -/* 111: 0, 1, 2, 3, 5, 6, */ { 6, 4, 8, 11, 6, 8 }, -/* 207: 0, 1, 2, 3, 6, 7, */ { 9, 8, 7, 5, 9, 7 }, -/* 119: 0, 1, 2, 4, 5, 6, */ { 7, 3, 2, 6, 7, 2 }, -/* 187: 0, 1, 3, 4, 5, 7, */ { 1, 5, 6, 2, 1, 6 }, -/* 243: 0, 1, 4, 5, 6, 7, */ { 3, 1, 10, 11, 3, 10 }, -/* 221: 0, 2, 3, 4, 6, 7, */ { 0, 4, 5, 1, 0, 5 }, -/* 249: 0, 3, 4, 5, 6, 7, */ { 9, 10, 2, 0, 9, 2 }, -/* 238: 1, 2, 3, 5, 6, 7, */ { 4, 0, 3, 7, 4, 3 }, -/* 246: 1, 2, 4, 5, 6, 7, */ { 0, 2, 11, 8, 0, 11 }, -/* 252: 2, 3, 4, 5, 6, 7, */ { 1, 3, 8, 9, 1, 8 } -}; -//_____________________________________________________________________________ - -//_____________________________________________________________________________ -/** - * \brief test table for case 3 - * One face to test - * When the test on the specified face is positive : 4 first triangles - * When the test on the specified face is negative : 2 last triangles - * - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char test3[24] = { -/* 5: 0, 2, */ 5, -/* 33: 0, 5, */ 1, -/* 129: 0, 7, */ 4, -/* 10: 1, 3, */ 5, -/* 18: 1, 4, */ 1, -/* 66: 1, 6, */ 2, -/* 36: 2, 5, */ 2, -/* 132: 2, 7, */ 3, -/* 24: 3, 4, */ 4, -/* 72: 3, 6, */ 3, -/* 80: 4, 6, */ 6, -/* 160: 5, 7, */ 6, -/* 95: 0, 1, 2, 3, 4, 6, */ -6, -/* 175: 0, 1, 2, 3, 5, 7, */ -6, -/* 183: 0, 1, 2, 4, 5, 7, */ -3, -/* 231: 0, 1, 2, 5, 6, 7, */ -4, -/* 123: 0, 1, 3, 4, 5, 6, */ -3, -/* 219: 0, 1, 3, 4, 6, 7, */ -2, -/* 189: 0, 2, 3, 4, 5, 7, */ -2, -/* 237: 0, 2, 3, 5, 6, 7, */ -1, -/* 245: 0, 2, 4, 5, 6, 7, */ -5, -/* 126: 1, 2, 3, 4, 5, 6, */ -4, -/* 222: 1, 2, 3, 4, 6, 7, */ -1, -/* 250: 1, 3, 4, 5, 6, 7, */ -5 -}; - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 3.1 - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char tiling3_1[24][6] = { -/* 5: 0, 2, */ { 0, 8, 3, 1, 2, 10 }, -/* 33: 0, 5, */ { 9, 5, 4, 0, 8, 3 }, -/* 129: 0, 7, */ { 3, 0, 8, 11, 7, 6 }, -/* 10: 1, 3, */ { 1, 9, 0, 2, 3, 11 }, -/* 18: 1, 4, */ { 0, 1, 9, 8, 4, 7 }, -/* 66: 1, 6, */ { 9, 0, 1, 5, 10, 6 }, -/* 36: 2, 5, */ { 1, 2, 10, 9, 5, 4 }, -/* 132: 2, 7, */ { 10, 1, 2, 6, 11, 7 }, -/* 24: 3, 4, */ { 8, 4, 7, 3, 11, 2 }, -/* 72: 3, 6, */ { 2, 3, 11, 10, 6, 5 }, -/* 80: 4, 6, */ { 5, 10, 6, 4, 7, 8 }, -/* 160: 5, 7, */ { 4, 9, 5, 7, 6, 11 }, -/* 95: 0, 1, 2, 3, 4, 6, */ { 5, 9, 4, 11, 6, 7 }, -/* 175: 0, 1, 2, 3, 5, 7, */ { 6, 10, 5, 8, 7, 4 }, -/* 183: 0, 1, 2, 4, 5, 7, */ { 11, 3, 2, 5, 6, 10 }, -/* 231: 0, 1, 2, 5, 6, 7, */ { 7, 4, 8, 2, 11, 3 }, -/* 123: 0, 1, 3, 4, 5, 6, */ { 2, 1, 10, 7, 11, 6 }, -/* 219: 0, 1, 3, 4, 6, 7, */ { 10, 2, 1, 4, 5, 9 }, -/* 189: 0, 2, 3, 4, 5, 7, */ { 1, 0, 9, 6, 10, 5 }, -/* 237: 0, 2, 3, 5, 6, 7, */ { 9, 1, 0, 7, 4, 8 }, -/* 245: 0, 2, 4, 5, 6, 7, */ { 0, 9, 1, 11, 3, 2 }, -/* 126: 1, 2, 3, 4, 5, 6, */ { 8, 0, 3, 6, 7, 11 }, -/* 222: 1, 2, 3, 4, 6, 7, */ { 4, 5, 9, 3, 8, 0 }, -/* 250: 1, 3, 4, 5, 6, 7, */ { 3, 8, 0, 10, 2, 1 } -}; - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 3.2 - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char tiling3_2[24][12] = { -/* 5: 0, 2, */ { 10, 3, 2, 10, 8, 3, 10, 1, 0, 8, 10, 0 }, -/* 33: 0, 5, */ { 3, 4, 8, 3, 5, 4, 3, 0, 9, 5, 3, 9 }, -/* 129: 0, 7, */ { 6, 8, 7, 6, 0, 8, 6, 11, 3, 0, 6, 3 }, -/* 10: 1, 3, */ { 11, 0, 3, 11, 9, 0, 11, 2, 1, 9, 11, 1 }, -/* 18: 1, 4, */ { 7, 9, 4, 7, 1, 9, 7, 8, 0, 1, 7, 0 }, -/* 66: 1, 6, */ { 6, 1, 10, 6, 0, 1, 9, 0, 6, 9, 6, 5 }, -/* 36: 2, 5, */ { 4, 10, 5, 4, 2, 10, 4, 9, 1, 2, 4, 1 }, -/* 132: 2, 7, */ { 7, 2, 11, 7, 1, 2, 7, 6, 10, 1, 7, 10 }, -/* 24: 3, 4, */ { 2, 7, 11, 2, 4, 7, 2, 3, 8, 4, 2, 8 }, -/* 72: 3, 6, */ { 5, 11, 6, 5, 3, 11, 5, 10, 2, 3, 5, 2 }, -/* 80: 4, 6, */ { 8, 6, 7, 8, 10, 6, 8, 4, 5, 10, 8, 5 }, -/* 160: 5, 7, */ { 11, 5, 6, 11, 9, 5, 11, 7, 4, 9, 11, 4 }, -/* 95: 0, 1, 2, 3, 4, 6, */ { 6, 5, 11, 5, 9, 11, 4, 7, 11, 4, 11, 9 }, -/* 175: 0, 1, 2, 3, 5, 7, */ { 7, 6, 8, 6, 10, 8, 5, 4, 8, 5, 8, 10 }, -/* 183: 0, 1, 2, 4, 5, 7, */ { 6, 11, 5, 11, 3, 5, 2, 10, 5, 2, 5, 3 }, -/* 231: 0, 1, 2, 5, 6, 7, */ { 11, 7, 2, 7, 4, 2, 8, 3, 2, 8, 2, 4 }, -/* 123: 0, 1, 3, 4, 5, 6, */ { 11, 2, 7, 2, 1, 7, 10, 6, 7, 10, 7, 1 }, -/* 219: 0, 1, 3, 4, 6, 7, */ { 5, 10, 4, 10, 2, 4, 1, 9, 4, 1, 4, 2 }, -/* 189: 0, 2, 3, 4, 5, 7, */ { 10, 1, 6, 1, 0, 6, 6, 0, 9, 5, 6, 9 }, -/* 237: 0, 2, 3, 5, 6, 7, */ { 4, 9, 7, 9, 1, 7, 0, 8, 7, 0, 7, 1 }, -/* 245: 0, 2, 4, 5, 6, 7, */ { 3, 0, 11, 0, 9, 11, 1, 2, 11, 1, 11, 9 }, -/* 126: 1, 2, 3, 4, 5, 6, */ { 7, 8, 6, 8, 0, 6, 3, 11, 6, 3, 6, 0 }, -/* 222: 1, 2, 3, 4, 6, 7, */ { 8, 4, 3, 4, 5, 3, 9, 0, 3, 9, 3, 5 }, -/* 250: 1, 3, 4, 5, 6, 7, */ { 2, 3, 10, 3, 8, 10, 0, 1, 10, 0, 10, 8 } -}; -//_____________________________________________________________________________ - - - -//_____________________________________________________________________________ -/** - * \brief test table for case 4 - * Interior to test - * When the test on the interior is negative : 2 first triangles - * When the test on the interior is positive : 6 last triangles - * - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char test4[8] = { -/* 65: 0, 6, */ 7, -/* 130: 1, 7, */ 7, -/* 20: 2, 4, */ 7, -/* 40: 3, 5, */ 7, -/* 215: 0, 1, 2, 4, 6, 7, */ -7, -/* 235: 0, 1, 3, 5, 6, 7, */ -7, -/* 125: 0, 2, 3, 4, 5, 6, */ -7, -/* 190: 1, 2, 3, 4, 5, 7, */ -7 -}; - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 4.1 - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char tiling4_1[8][6] = { -/* 65: 0, 6, */ { 0, 8, 3, 5, 10, 6 }, -/* 130: 1, 7, */ { 0, 1, 9, 11, 7, 6 }, -/* 20: 2, 4, */ { 1, 2, 10, 8, 4, 7 }, -/* 40: 3, 5, */ { 9, 5, 4, 2, 3, 11 }, -/* 215: 0, 1, 2, 4, 6, 7, */ { 4, 5, 9, 11, 3, 2 }, -/* 235: 0, 1, 3, 5, 6, 7, */ { 10, 2, 1, 7, 4, 8 }, -/* 125: 0, 2, 3, 4, 5, 6, */ { 9, 1, 0, 6, 7, 11 }, -/* 190: 1, 2, 3, 4, 5, 7, */ { 3, 8, 0, 6, 10, 5 } -}; - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 4.2 - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char tiling4_2[8][18] = { -/* 65: 0, 6, */ { 8, 5, 0, 5, 8, 6, 3, 6, 8, 6, 3, 10, 0, 10, 3, 10, 0, 5 }, -/* 130: 1, 7, */ { 9, 6, 1, 6, 9, 7, 0, 7, 9, 7, 0, 11, 1, 11, 0, 11, 1, 6 }, -/* 20: 2, 4, */ { 10, 7, 2, 7, 10, 4, 1, 4, 10, 4, 1, 8, 2, 8, 1, 8, 2, 7 }, -/* 40: 3, 5, */ { 11, 4, 3, 4, 11, 5, 2, 5, 11, 5, 2, 9, 3, 9, 2, 9, 3, 4 }, -/* 215: 0, 1, 2, 4, 6, 7, */ { 3, 4, 11, 5, 11, 4, 11, 5, 2, 9, 2, 5, 2, 9, 3, 4, 3, 9 }, -/* 235: 0, 1, 3, 5, 6, 7, */ { 2, 7, 10, 4, 10, 7, 10, 4, 1, 8, 1, 4, 1, 8, 2, 7, 2, 8 }, -/* 125: 0, 2, 3, 4, 5, 6, */ { 1, 6, 9, 7, 9, 6, 9, 7, 0, 11, 0, 7, 0, 11, 1, 6, 1, 11 }, -/* 190: 1, 2, 3, 4, 5, 7, */ { 0, 5, 8, 6, 8, 5, 8, 6, 3, 10, 3, 6, 3, 10, 0, 5, 0, 10 } -}; -//_____________________________________________________________________________ - - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 5 - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char tiling5[48][9] = { -/* 7: 0, 1, 2, */ { 2, 8, 3, 2, 10, 8, 10, 9, 8 }, -/* 11: 0, 1, 3, */ { 1, 11, 2, 1, 9, 11, 9, 8, 11 }, -/* 19: 0, 1, 4, */ { 4, 1, 9, 4, 7, 1, 7, 3, 1 }, -/* 35: 0, 1, 5, */ { 8, 5, 4, 8, 3, 5, 3, 1, 5 }, -/* 13: 0, 2, 3, */ { 0, 10, 1, 0, 8, 10, 8, 11, 10 }, -/* 25: 0, 3, 4, */ { 11, 4, 7, 11, 2, 4, 2, 0, 4 }, -/* 137: 0, 3, 7, */ { 7, 0, 8, 7, 6, 0, 6, 2, 0 }, -/* 49: 0, 4, 5, */ { 9, 3, 0, 9, 5, 3, 5, 7, 3 }, -/* 145: 0, 4, 7, */ { 3, 6, 11, 3, 0, 6, 0, 4, 6 }, -/* 14: 1, 2, 3, */ { 3, 9, 0, 3, 11, 9, 11, 10, 9 }, -/* 38: 1, 2, 5, */ { 5, 2, 10, 5, 4, 2, 4, 0, 2 }, -/* 70: 1, 2, 6, */ { 9, 6, 5, 9, 0, 6, 0, 2, 6 }, -/* 50: 1, 4, 5, */ { 0, 7, 8, 0, 1, 7, 1, 5, 7 }, -/* 98: 1, 5, 6, */ { 10, 0, 1, 10, 6, 0, 6, 4, 0 }, -/* 76: 2, 3, 6, */ { 6, 3, 11, 6, 5, 3, 5, 1, 3 }, -/* 140: 2, 3, 7, */ { 10, 7, 6, 10, 1, 7, 1, 3, 7 }, -/* 100: 2, 5, 6, */ { 1, 4, 9, 1, 2, 4, 2, 6, 4 }, -/* 196: 2, 6, 7, */ { 11, 1, 2, 11, 7, 1, 7, 5, 1 }, -/* 152: 3, 4, 7, */ { 8, 2, 3, 8, 4, 2, 4, 6, 2 }, -/* 200: 3, 6, 7, */ { 2, 5, 10, 2, 3, 5, 3, 7, 5 }, -/* 112: 4, 5, 6, */ { 7, 10, 6, 7, 8, 10, 8, 9, 10 }, -/* 176: 4, 5, 7, */ { 6, 9, 5, 6, 11, 9, 11, 8, 9 }, -/* 208: 4, 6, 7, */ { 5, 8, 4, 5, 10, 8, 10, 11, 8 }, -/* 224: 5, 6, 7, */ { 4, 11, 7, 4, 9, 11, 9, 10, 11 }, -/* 31: 0, 1, 2, 3, 4, */ { 4, 7, 11, 4, 11, 9, 9, 11, 10 }, -/* 47: 0, 1, 2, 3, 5, */ { 5, 4, 8, 5, 8, 10, 10, 8, 11 }, -/* 79: 0, 1, 2, 3, 6, */ { 6, 5, 9, 6, 9, 11, 11, 9, 8 }, -/* 143: 0, 1, 2, 3, 7, */ { 7, 6, 10, 7, 10, 8, 8, 10, 9 }, -/* 55: 0, 1, 2, 4, 5, */ { 2, 10, 5, 2, 5, 3, 3, 5, 7 }, -/* 103: 0, 1, 2, 5, 6, */ { 8, 3, 2, 8, 2, 4, 4, 2, 6 }, -/* 59: 0, 1, 3, 4, 5, */ { 11, 2, 1, 11, 1, 7, 7, 1, 5 }, -/* 155: 0, 1, 3, 4, 7, */ { 1, 9, 4, 1, 4, 2, 2, 4, 6 }, -/* 115: 0, 1, 4, 5, 6, */ { 10, 6, 7, 10, 7, 1, 1, 7, 3 }, -/* 179: 0, 1, 4, 5, 7, */ { 6, 11, 3, 6, 3, 5, 5, 3, 1 }, -/* 157: 0, 2, 3, 4, 7, */ { 10, 1, 0, 10, 0, 6, 6, 0, 4 }, -/* 205: 0, 2, 3, 6, 7, */ { 0, 8, 7, 0, 7, 1, 1, 7, 5 }, -/* 185: 0, 3, 4, 5, 7, */ { 9, 5, 6, 9, 6, 0, 0, 6, 2 }, -/* 217: 0, 3, 4, 6, 7, */ { 5, 10, 2, 5, 2, 4, 4, 2, 0 }, -/* 241: 0, 4, 5, 6, 7, */ { 3, 0, 9, 3, 9, 11, 11, 9, 10 }, -/* 110: 1, 2, 3, 5, 6, */ { 3, 11, 6, 3, 6, 0, 0, 6, 4 }, -/* 206: 1, 2, 3, 6, 7, */ { 9, 0, 3, 9, 3, 5, 5, 3, 7 }, -/* 118: 1, 2, 4, 5, 6, */ { 7, 8, 0, 7, 0, 6, 6, 0, 2 }, -/* 230: 1, 2, 5, 6, 7, */ { 11, 7, 4, 11, 4, 2, 2, 4, 0 }, -/* 242: 1, 4, 5, 6, 7, */ { 0, 1, 10, 0, 10, 8, 8, 10, 11 }, -/* 220: 2, 3, 4, 6, 7, */ { 8, 4, 5, 8, 5, 3, 3, 5, 1 }, -/* 236: 2, 3, 5, 6, 7, */ { 4, 9, 1, 4, 1, 7, 7, 1, 3 }, -/* 244: 2, 4, 5, 6, 7, */ { 1, 2, 11, 1, 11, 9, 9, 11, 8 }, -/* 248: 3, 4, 5, 6, 7, */ { 2, 3, 8, 2, 8, 10, 10, 8, 9 } -}; -//_____________________________________________________________________________ - - -//_____________________________________________________________________________ -/** - * \brief test table for case 6 - * 1 face to test + eventually the interior - * When the test on the specified face is positive : 5 first triangles - * When the test on the specified face is negative : - * - if the test on the interior is negative : 3 middle triangles - * - if the test on the interior is positive : 8 last triangles - * The support edge for the interior test is marked as the 3rd column. - * - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char test6[48][3] = { -/* 67: 0, 1, 6, */ { 2, 7, 10 }, -/* 131: 0, 1, 7, */ { 4, 7, 11 }, -/* 21: 0, 2, 4, */ { 5, 7, 1 }, -/* 69: 0, 2, 6, */ { 5, 7, 3 }, -/* 41: 0, 3, 5, */ { 1, 7, 9 }, -/* 73: 0, 3, 6, */ { 3, 7, 10 }, -/* 81: 0, 4, 6, */ { 6, 7, 5 }, -/* 97: 0, 5, 6, */ { 1, 7, 8 }, -/* 193: 0, 6, 7, */ { 4, 7, 8 }, -/* 22: 1, 2, 4, */ { 1, 7, 8 }, -/* 134: 1, 2, 7, */ { 3, 7, 11 }, -/* 42: 1, 3, 5, */ { 5, 7, 2 }, -/* 138: 1, 3, 7, */ { 5, 7, 0 }, -/* 146: 1, 4, 7, */ { 1, 7, 9 }, -/* 162: 1, 5, 7, */ { 6, 7, 6 }, -/* 194: 1, 6, 7, */ { 2, 7, 9 }, -/* 28: 2, 3, 4, */ { 4, 7, 8 }, -/* 44: 2, 3, 5, */ { 2, 7, 9 }, -/* 52: 2, 4, 5, */ { 2, 7, 10 }, -/* 84: 2, 4, 6, */ { 6, 7, 7 }, -/* 148: 2, 4, 7, */ { 3, 7, 10 }, -/* 56: 3, 4, 5, */ { 4, 7, 11 }, -/* 104: 3, 5, 6, */ { 3, 7, 11 }, -/* 168: 3, 5, 7, */ { 6, 7, 4 }, -/* 87: 0, 1, 2, 4, 6, */ { -6, -7, 4 }, -/* 151: 0, 1, 2, 4, 7, */ { -3, -7, 11 }, -/* 199: 0, 1, 2, 6, 7, */ { -4, -7, 11 }, -/* 107: 0, 1, 3, 5, 6, */ { -3, -7, 10 }, -/* 171: 0, 1, 3, 5, 7, */ { -6, -7, 7 }, -/* 203: 0, 1, 3, 6, 7, */ { -2, -7, 10 }, -/* 211: 0, 1, 4, 6, 7, */ { -2, -7, 9 }, -/* 227: 0, 1, 5, 6, 7, */ { -4, -7, 8 }, -/* 61: 0, 2, 3, 4, 5, */ { -2, -7, 9 }, -/* 93: 0, 2, 3, 4, 6, */ { -6, -7, 6 }, -/* 109: 0, 2, 3, 5, 6, */ { -1, -7, 9 }, -/* 117: 0, 2, 4, 5, 6, */ { -5, -7, 0 }, -/* 213: 0, 2, 4, 6, 7, */ { -5, -7, 2 }, -/* 121: 0, 3, 4, 5, 6, */ { -3, -7, 11 }, -/* 233: 0, 3, 5, 6, 7, */ { -1, -7, 8 }, -/* 62: 1, 2, 3, 4, 5, */ { -4, -7, 8 }, -/* 158: 1, 2, 3, 4, 7, */ { -1, -7, 8 }, -/* 174: 1, 2, 3, 5, 7, */ { -6, -7, 5 }, -/* 182: 1, 2, 4, 5, 7, */ { -3, -7, 10 }, -/* 214: 1, 2, 4, 6, 7, */ { -1, -7, 9 }, -/* 186: 1, 3, 4, 5, 7, */ { -5, -7, 3 }, -/* 234: 1, 3, 5, 6, 7, */ { -5, -7, 1 }, -/* 124: 2, 3, 4, 5, 6, */ { -4, -7, 11 }, -/* 188: 2, 3, 4, 5, 7, */ { -2, -7, 10 } -}; - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 6.1.1 - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char tiling6_1_1[48][9] = { -/* 67: 0, 1, 6, */ { 6, 5, 10, 3, 1, 8, 9, 8, 1 }, -/* 131: 0, 1, 7, */ { 11, 7, 6, 9, 3, 1, 3, 9, 8 }, -/* 21: 0, 2, 4, */ { 1, 2, 10, 7, 0, 4, 0, 7, 3 }, -/* 69: 0, 2, 6, */ { 3, 0, 8, 5, 2, 6, 2, 5, 1 }, -/* 41: 0, 3, 5, */ { 5, 4, 9, 2, 0, 11, 8, 11, 0 }, -/* 73: 0, 3, 6, */ { 10, 6, 5, 8, 2, 0, 2, 8, 11 }, -/* 81: 0, 4, 6, */ { 10, 6, 5, 0, 4, 3, 7, 3, 4 }, -/* 97: 0, 5, 6, */ { 3, 0, 8, 6, 4, 10, 9, 10, 4 }, -/* 193: 0, 6, 7, */ { 8, 3, 0, 10, 7, 5, 7, 10, 11 }, -/* 22: 1, 2, 4, */ { 8, 4, 7, 10, 0, 2, 0, 10, 9 }, -/* 134: 1, 2, 7, */ { 7, 6, 11, 0, 2, 9, 10, 9, 2 }, -/* 42: 1, 3, 5, */ { 2, 3, 11, 4, 1, 5, 1, 4, 0 }, -/* 138: 1, 3, 7, */ { 0, 1, 9, 6, 3, 7, 3, 6, 2 }, -/* 146: 1, 4, 7, */ { 9, 0, 1, 11, 4, 6, 4, 11, 8 }, -/* 162: 1, 5, 7, */ { 11, 7, 6, 1, 5, 0, 4, 0, 5 }, -/* 194: 1, 6, 7, */ { 0, 1, 9, 7, 5, 11, 10, 11, 5 }, -/* 28: 2, 3, 4, */ { 4, 7, 8, 1, 3, 10, 11, 10, 3 }, -/* 44: 2, 3, 5, */ { 9, 5, 4, 11, 1, 3, 1, 11, 10 }, -/* 52: 2, 4, 5, */ { 10, 1, 2, 8, 5, 7, 5, 8, 9 }, -/* 84: 2, 4, 6, */ { 8, 4, 7, 2, 6, 1, 5, 1, 6 }, -/* 148: 2, 4, 7, */ { 1, 2, 10, 4, 6, 8, 11, 8, 6 }, -/* 56: 3, 4, 5, */ { 2, 3, 11, 5, 7, 9, 8, 9, 7 }, -/* 104: 3, 5, 6, */ { 11, 2, 3, 9, 6, 4, 6, 9, 10 }, -/* 168: 3, 5, 7, */ { 9, 5, 4, 3, 7, 2, 6, 2, 7 }, -/* 87: 0, 1, 2, 4, 6, */ { 4, 5, 9, 2, 7, 3, 7, 2, 6 }, -/* 151: 0, 1, 2, 4, 7, */ { 3, 2, 11, 4, 6, 9, 10, 9, 6 }, -/* 199: 0, 1, 2, 6, 7, */ { 11, 3, 2, 9, 7, 5, 7, 9, 8 }, -/* 107: 0, 1, 3, 5, 6, */ { 10, 2, 1, 8, 6, 4, 6, 8, 11 }, -/* 171: 0, 1, 3, 5, 7, */ { 7, 4, 8, 1, 6, 2, 6, 1, 5 }, -/* 203: 0, 1, 3, 6, 7, */ { 2, 1, 10, 7, 5, 8, 9, 8, 5 }, -/* 211: 0, 1, 4, 6, 7, */ { 4, 5, 9, 3, 1, 11, 10, 11, 1 }, -/* 227: 0, 1, 5, 6, 7, */ { 8, 7, 4, 10, 3, 1, 3, 10, 11 }, -/* 61: 0, 2, 3, 4, 5, */ { 9, 1, 0, 11, 5, 7, 5, 11, 10 }, -/* 93: 0, 2, 3, 4, 6, */ { 6, 7, 11, 0, 5, 1, 5, 0, 4 }, -/* 109: 0, 2, 3, 5, 6, */ { 1, 0, 9, 6, 4, 11, 8, 11, 4 }, -/* 117: 0, 2, 4, 5, 6, */ { 9, 1, 0, 7, 3, 6, 2, 6, 3 }, -/* 213: 0, 2, 4, 6, 7, */ { 11, 3, 2, 5, 1, 4, 0, 4, 1 }, -/* 121: 0, 3, 4, 5, 6, */ { 11, 6, 7, 9, 2, 0, 2, 9, 10 }, -/* 233: 0, 3, 5, 6, 7, */ { 7, 4, 8, 2, 0, 10, 9, 10, 0 }, -/* 62: 1, 2, 3, 4, 5, */ { 0, 3, 8, 5, 7, 10, 11, 10, 7 }, -/* 158: 1, 2, 3, 4, 7, */ { 8, 0, 3, 10, 4, 6, 4, 10, 9 }, -/* 174: 1, 2, 3, 5, 7, */ { 5, 6, 10, 3, 4, 0, 4, 3, 7 }, -/* 182: 1, 2, 4, 5, 7, */ { 5, 6, 10, 0, 2, 8, 11, 8, 2 }, -/* 214: 1, 2, 4, 6, 7, */ { 9, 4, 5, 11, 0, 2, 0, 11, 8 }, -/* 186: 1, 3, 4, 5, 7, */ { 8, 0, 3, 6, 2, 5, 1, 5, 2 }, -/* 234: 1, 3, 5, 6, 7, */ { 10, 2, 1, 4, 0, 7, 3, 7, 0 }, -/* 124: 2, 3, 4, 5, 6, */ { 6, 7, 11, 1, 3, 9, 8, 9, 3 }, -/* 188: 2, 3, 4, 5, 7, */ { 10, 5, 6, 8, 1, 3, 1, 8, 9 } -}; - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 6.1.2 - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char tiling6_1_2[48][27] = { - /* 67: 0, 1, 6, */ { 1, 12, 3, 12, 10, 3, 6, 3, 10, 3, 6, 8, 5, 8, 6, 8, 5, 12, 12, 9, 8, 1, 9, 12, 12, 5, 10 }, - /* 131: 0, 1, 7, */ { 1, 12, 3, 1, 11, 12, 11, 1, 6, 9, 6, 1, 6, 9, 7, 12, 7, 9, 9, 8, 12, 12, 8, 3, 11, 7, 12 }, - /* 21: 0, 2, 4, */ { 4, 12, 0, 4, 1, 12, 1, 4, 10, 7, 10, 4, 10, 7, 2, 12, 2, 7, 7, 3, 12, 12, 3, 0, 1, 2, 12 }, - /* 69: 0, 2, 6, */ { 6, 12, 2, 6, 3, 12, 3, 6, 8, 5, 8, 6, 8, 5, 0, 12, 0, 5, 5, 1, 12, 12, 1, 2, 3, 0, 12 }, - /* 41: 0, 3, 5, */ { 0, 12, 2, 12, 9, 2, 5, 2, 9, 2, 5, 11, 4, 11, 5, 11, 4, 12, 12, 8, 11, 0, 8, 12, 12, 4, 9 }, - /* 73: 0, 3, 6, */ { 0, 12, 2, 0, 10, 12, 10, 0, 5, 8, 5, 0, 5, 8, 6, 12, 6, 8, 8, 11, 12, 12, 11, 2, 10, 6, 12 }, - /* 81: 0, 4, 6, */ { 4, 12, 0, 12, 5, 0, 10, 0, 5, 0, 10, 3, 6, 3, 10, 3, 6, 12, 12, 7, 3, 4, 7, 12, 12, 6, 5 }, - /* 97: 0, 5, 6, */ { 4, 12, 6, 12, 8, 6, 3, 6, 8, 6, 3, 10, 0, 10, 3, 10, 0, 12, 12, 9, 10, 4, 9, 12, 12, 0, 8 }, - /* 193: 0, 6, 7, */ { 5, 12, 7, 5, 8, 12, 8, 5, 0, 10, 0, 5, 0, 10, 3, 12, 3, 10, 10, 11, 12, 12, 11, 7, 8, 3, 12 }, - /* 22: 1, 2, 4, */ { 2, 12, 0, 2, 8, 12, 8, 2, 7, 10, 7, 2, 7, 10, 4, 12, 4, 10, 10, 9, 12, 12, 9, 0, 8, 4, 12 }, - /* 134: 1, 2, 7, */ { 2, 12, 0, 12, 11, 0, 7, 0, 11, 0, 7, 9, 6, 9, 7, 9, 6, 12, 12, 10, 9, 2, 10, 12, 12, 6, 11 }, - /* 42: 1, 3, 5, */ { 5, 12, 1, 5, 2, 12, 2, 5, 11, 4, 11, 5, 11, 4, 3, 12, 3, 4, 4, 0, 12, 12, 0, 1, 2, 3, 12 }, - /* 138: 1, 3, 7, */ { 7, 12, 3, 7, 0, 12, 0, 7, 9, 6, 9, 7, 9, 6, 1, 12, 1, 6, 6, 2, 12, 12, 2, 3, 0, 1, 12 }, - /* 146: 1, 4, 7, */ { 6, 12, 4, 6, 9, 12, 9, 6, 1, 11, 1, 6, 1, 11, 0, 12, 0, 11, 11, 8, 12, 12, 8, 4, 9, 0, 12 }, - /* 162: 1, 5, 7, */ { 5, 12, 1, 12, 6, 1, 11, 1, 6, 1, 11, 0, 7, 0, 11, 0, 7, 12, 12, 4, 0, 5, 4, 12, 12, 7, 6 }, - /* 194: 1, 6, 7, */ { 5, 12, 7, 12, 9, 7, 0, 7, 9, 7, 0, 11, 1, 11, 0, 11, 1, 12, 12, 10, 11, 5, 10, 12, 12, 1, 9 }, - /* 28: 2, 3, 4, */ { 3, 12, 1, 12, 8, 1, 4, 1, 8, 1, 4, 10, 7, 10, 4, 10, 7, 12, 12, 11, 10, 3, 11, 12, 12, 7, 8 }, - /* 44: 2, 3, 5, */ { 3, 12, 1, 3, 9, 12, 9, 3, 4, 11, 4, 3, 4, 11, 5, 12, 5, 11, 11, 10, 12, 12, 10, 1, 9, 5, 12 }, - /* 52: 2, 4, 5, */ { 7, 12, 5, 7, 10, 12, 10, 7, 2, 8, 2, 7, 2, 8, 1, 12, 1, 8, 8, 9, 12, 12, 9, 5, 10, 1, 12 }, - /* 84: 2, 4, 6, */ { 6, 12, 2, 12, 7, 2, 8, 2, 7, 2, 8, 1, 4, 1, 8, 1, 4, 12, 12, 5, 1, 6, 5, 12, 12, 4, 7 }, - /* 148: 2, 4, 7, */ { 6, 12, 4, 12, 10, 4, 1, 4, 10, 4, 1, 8, 2, 8, 1, 8, 2, 12, 12, 11, 8, 6, 11, 12, 12, 2, 10 }, - /* 56: 3, 4, 5, */ { 7, 12, 5, 12, 11, 5, 2, 5, 11, 5, 2, 9, 3, 9, 2, 9, 3, 12, 12, 8, 9, 7, 8, 12, 12, 3, 11 }, - /* 104: 3, 5, 6, */ { 4, 12, 6, 4, 11, 12, 11, 4, 3, 9, 3, 4, 3, 9, 2, 12, 2, 9, 9, 10, 12, 12, 10, 6, 11, 2, 12 }, - /* 168: 3, 5, 7, */ { 7, 12, 3, 12, 4, 3, 9, 3, 4, 3, 9, 2, 5, 2, 9, 2, 5, 12, 12, 6, 2, 7, 6, 12, 12, 5, 4 }, - /* 87: 0, 1, 2, 4, 6, */ { 3, 12, 7, 3, 4, 12, 4, 3, 9, 2, 9, 3, 9, 2, 5, 12, 5, 2, 2, 6, 12, 12, 6, 7, 4, 5, 12 }, - /* 151: 0, 1, 2, 4, 7, */ { 6, 12, 4, 12, 11, 4, 3, 4, 11, 4, 3, 9, 2, 9, 3, 9, 2, 12, 12, 10, 9, 6, 10, 12, 12, 2, 11 }, - /* 199: 0, 1, 2, 6, 7, */ { 5, 12, 7, 5, 11, 12, 11, 5, 2, 9, 2, 5, 2, 9, 3, 12, 3, 9, 9, 8, 12, 12, 8, 7, 11, 3, 12 }, - /* 107: 0, 1, 3, 5, 6, */ { 4, 12, 6, 4, 10, 12, 10, 4, 1, 8, 1, 4, 1, 8, 2, 12, 2, 8, 8, 11, 12, 12, 11, 6, 10, 2, 12 }, - /* 171: 0, 1, 3, 5, 7, */ { 2, 12, 6, 2, 7, 12, 7, 2, 8, 1, 8, 2, 8, 1, 4, 12, 4, 1, 1, 5, 12, 12, 5, 6, 7, 4, 12 }, - /* 203: 0, 1, 3, 6, 7, */ { 5, 12, 7, 12, 10, 7, 2, 7, 10, 7, 2, 8, 1, 8, 2, 8, 1, 12, 12, 9, 8, 5, 9, 12, 12, 1, 10 }, - /* 211: 0, 1, 4, 6, 7, */ { 1, 12, 3, 12, 9, 3, 4, 3, 9, 3, 4, 11, 5, 11, 4, 11, 5, 12, 12, 10, 11, 1, 10, 12, 12, 5, 9 }, - /* 227: 0, 1, 5, 6, 7, */ { 1, 12, 3, 1, 8, 12, 8, 1, 4, 10, 4, 1, 4, 10, 7, 12, 7, 10, 10, 11, 12, 12, 11, 3, 8, 7, 12 }, - /* 61: 0, 2, 3, 4, 5, */ { 7, 12, 5, 7, 9, 12, 9, 7, 0, 11, 0, 7, 0, 11, 1, 12, 1, 11, 11, 10, 12, 12, 10, 5, 9, 1, 12 }, - /* 93: 0, 2, 3, 4, 6, */ { 1, 12, 5, 1, 6, 12, 6, 1, 11, 0, 11, 1, 11, 0, 7, 12, 7, 0, 0, 4, 12, 12, 4, 5, 6, 7, 12 }, - /* 109: 0, 2, 3, 5, 6, */ { 4, 12, 6, 12, 9, 6, 1, 6, 9, 6, 1, 11, 0, 11, 1, 11, 0, 12, 12, 8, 11, 4, 8, 12, 12, 0, 9 }, - /* 117: 0, 2, 4, 5, 6, */ { 3, 12, 7, 12, 0, 7, 9, 7, 0, 7, 9, 6, 1, 6, 9, 6, 1, 12, 12, 2, 6, 3, 2, 12, 12, 1, 0 }, - /* 213: 0, 2, 4, 6, 7, */ { 1, 12, 5, 12, 2, 5, 11, 5, 2, 5, 11, 4, 3, 4, 11, 4, 3, 12, 12, 0, 4, 1, 0, 12, 12, 3, 2 }, - /* 121: 0, 3, 4, 5, 6, */ { 0, 12, 2, 0, 11, 12, 11, 0, 7, 9, 7, 0, 7, 9, 6, 12, 6, 9, 9, 10, 12, 12, 10, 2, 11, 6, 12 }, - /* 233: 0, 3, 5, 6, 7, */ { 0, 12, 2, 12, 8, 2, 7, 2, 8, 2, 7, 10, 4, 10, 7, 10, 4, 12, 12, 9, 10, 0, 9, 12, 12, 4, 8 }, - /* 62: 1, 2, 3, 4, 5, */ { 7, 12, 5, 12, 8, 5, 0, 5, 8, 5, 0, 10, 3, 10, 0, 10, 3, 12, 12, 11, 10, 7, 11, 12, 12, 3, 8 }, - /* 158: 1, 2, 3, 4, 7, */ { 6, 12, 4, 6, 8, 12, 8, 6, 3, 10, 3, 6, 3, 10, 0, 12, 0, 10, 10, 9, 12, 12, 9, 4, 8, 0, 12 }, - /* 174: 1, 2, 3, 5, 7, */ { 0, 12, 4, 0, 5, 12, 5, 0, 10, 3, 10, 0, 10, 3, 6, 12, 6, 3, 3, 7, 12, 12, 7, 4, 5, 6, 12 }, - /* 182: 1, 2, 4, 5, 7, */ { 2, 12, 0, 12, 10, 0, 5, 0, 10, 0, 5, 8, 6, 8, 5, 8, 6, 12, 12, 11, 8, 2, 11, 12, 12, 6, 10 }, - /* 214: 1, 2, 4, 6, 7, */ { 2, 12, 0, 2, 9, 12, 9, 2, 5, 11, 5, 2, 5, 11, 4, 12, 4, 11, 11, 8, 12, 12, 8, 0, 9, 4, 12 }, - /* 186: 1, 3, 4, 5, 7, */ { 2, 12, 6, 12, 3, 6, 8, 6, 3, 6, 8, 5, 0, 5, 8, 5, 0, 12, 12, 1, 5, 2, 1, 12, 12, 0, 3 }, - /* 234: 1, 3, 5, 6, 7, */ { 0, 12, 4, 12, 1, 4, 10, 4, 1, 4, 10, 7, 2, 7, 10, 7, 2, 12, 12, 3, 7, 0, 3, 12, 12, 2, 1 }, - /* 124: 2, 3, 4, 5, 6, */ { 3, 12, 1, 12, 11, 1, 6, 1, 11, 1, 6, 9, 7, 9, 6, 9, 7, 12, 12, 8, 9, 3, 8, 12, 12, 7, 11 }, - /* 188: 2, 3, 4, 5, 7, */ { 3, 12, 1, 3, 10, 12, 10, 3, 6, 8, 6, 3, 6, 8, 5, 12, 5, 8, 8, 9, 12, 12, 9, 1, 10, 5, 12 }, -}; - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 6.2 - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char tiling6_2[48][15] = { -/* 67: 0, 1, 6, */ { 1, 10, 3, 6, 3, 10, 3, 6, 8, 5, 8, 6, 8, 5, 9 }, -/* 131: 0, 1, 7, */ { 1, 11, 3, 11, 1, 6, 9, 6, 1, 6, 9, 7, 8, 7, 9 }, -/* 21: 0, 2, 4, */ { 4, 1, 0, 1, 4, 10, 7, 10, 4, 10, 7, 2, 3, 2, 7 }, -/* 69: 0, 2, 6, */ { 6, 3, 2, 3, 6, 8, 5, 8, 6, 8, 5, 0, 1, 0, 5 }, -/* 41: 0, 3, 5, */ { 0, 9, 2, 5, 2, 9, 2, 5, 11, 4, 11, 5, 11, 4, 8 }, -/* 73: 0, 3, 6, */ { 0, 10, 2, 10, 0, 5, 8, 5, 0, 5, 8, 6, 11, 6, 8 }, -/* 81: 0, 4, 6, */ { 4, 5, 0, 10, 0, 5, 0, 10, 3, 6, 3, 10, 3, 6, 7 }, -/* 97: 0, 5, 6, */ { 4, 8, 6, 3, 6, 8, 6, 3, 10, 0, 10, 3, 10, 0, 9 }, -/* 193: 0, 6, 7, */ { 5, 8, 7, 8, 5, 0, 10, 0, 5, 0, 10, 3, 11, 3, 10 }, -/* 22: 1, 2, 4, */ { 2, 8, 0, 8, 2, 7, 10, 7, 2, 7, 10, 4, 9, 4, 10 }, -/* 134: 1, 2, 7, */ { 2, 11, 0, 7, 0, 11, 0, 7, 9, 6, 9, 7, 9, 6, 10 }, -/* 42: 1, 3, 5, */ { 5, 2, 1, 2, 5, 11, 4, 11, 5, 11, 4, 3, 0, 3, 4 }, -/* 138: 1, 3, 7, */ { 7, 0, 3, 0, 7, 9, 6, 9, 7, 9, 6, 1, 2, 1, 6 }, -/* 146: 1, 4, 7, */ { 6, 9, 4, 9, 6, 1, 11, 1, 6, 1, 11, 0, 8, 0, 11 }, -/* 162: 1, 5, 7, */ { 5, 6, 1, 11, 1, 6, 1, 11, 0, 7, 0, 11, 0, 7, 4 }, -/* 194: 1, 6, 7, */ { 5, 9, 7, 0, 7, 9, 7, 0, 11, 1, 11, 0, 11, 1, 10 }, -/* 28: 2, 3, 4, */ { 3, 8, 1, 4, 1, 8, 1, 4, 10, 7, 10, 4, 10, 7, 11 }, -/* 44: 2, 3, 5, */ { 3, 9, 1, 9, 3, 4, 11, 4, 3, 4, 11, 5, 10, 5, 11 }, -/* 52: 2, 4, 5, */ { 7, 10, 5, 10, 7, 2, 8, 2, 7, 2, 8, 1, 9, 1, 8 }, -/* 84: 2, 4, 6, */ { 6, 7, 2, 8, 2, 7, 2, 8, 1, 4, 1, 8, 1, 4, 5 }, -/* 148: 2, 4, 7, */ { 6, 10, 4, 1, 4, 10, 4, 1, 8, 2, 8, 1, 8, 2, 11 }, -/* 56: 3, 4, 5, */ { 7, 11, 5, 2, 5, 11, 5, 2, 9, 3, 9, 2, 9, 3, 8 }, -/* 104: 3, 5, 6, */ { 4, 11, 6, 11, 4, 3, 9, 3, 4, 3, 9, 2, 10, 2, 9 }, -/* 168: 3, 5, 7, */ { 7, 4, 3, 9, 3, 4, 3, 9, 2, 5, 2, 9, 2, 5, 6 }, -/* 87: 0, 1, 2, 4, 6, */ { 3, 4, 7, 4, 3, 9, 2, 9, 3, 9, 2, 5, 6, 5, 2 }, -/* 151: 0, 1, 2, 4, 7, */ { 6, 11, 4, 3, 4, 11, 4, 3, 9, 2, 9, 3, 9, 2, 10 }, -/* 199: 0, 1, 2, 6, 7, */ { 5, 11, 7, 11, 5, 2, 9, 2, 5, 2, 9, 3, 8, 3, 9 }, -/* 107: 0, 1, 3, 5, 6, */ { 4, 10, 6, 10, 4, 1, 8, 1, 4, 1, 8, 2, 11, 2, 8 }, -/* 171: 0, 1, 3, 5, 7, */ { 2, 7, 6, 7, 2, 8, 1, 8, 2, 8, 1, 4, 5, 4, 1 }, -/* 203: 0, 1, 3, 6, 7, */ { 5, 10, 7, 2, 7, 10, 7, 2, 8, 1, 8, 2, 8, 1, 9 }, -/* 211: 0, 1, 4, 6, 7, */ { 1, 9, 3, 4, 3, 9, 3, 4, 11, 5, 11, 4, 11, 5, 10 }, -/* 227: 0, 1, 5, 6, 7, */ { 1, 8, 3, 8, 1, 4, 10, 4, 1, 4, 10, 7, 11, 7, 10 }, -/* 61: 0, 2, 3, 4, 5, */ { 7, 9, 5, 9, 7, 0, 11, 0, 7, 0, 11, 1, 10, 1, 11 }, -/* 93: 0, 2, 3, 4, 6, */ { 1, 6, 5, 6, 1, 11, 0, 11, 1, 11, 0, 7, 4, 7, 0 }, -/* 109: 0, 2, 3, 5, 6, */ { 4, 9, 6, 1, 6, 9, 6, 1, 11, 0, 11, 1, 11, 0, 8 }, -/* 117: 0, 2, 4, 5, 6, */ { 3, 0, 7, 9, 7, 0, 7, 9, 6, 1, 6, 9, 6, 1, 2 }, -/* 213: 0, 2, 4, 6, 7, */ { 1, 2, 5, 11, 5, 2, 5, 11, 4, 3, 4, 11, 4, 3, 0 }, -/* 121: 0, 3, 4, 5, 6, */ { 0, 11, 2, 11, 0, 7, 9, 7, 0, 7, 9, 6, 10, 6, 9 }, -/* 233: 0, 3, 5, 6, 7, */ { 0, 8, 2, 7, 2, 8, 2, 7, 10, 4, 10, 7, 10, 4, 9 }, -/* 62: 1, 2, 3, 4, 5, */ { 7, 8, 5, 0, 5, 8, 5, 0, 10, 3, 10, 0, 10, 3, 11 }, -/* 158: 1, 2, 3, 4, 7, */ { 6, 8, 4, 8, 6, 3, 10, 3, 6, 3, 10, 0, 9, 0, 10 }, -/* 174: 1, 2, 3, 5, 7, */ { 0, 5, 4, 5, 0, 10, 3, 10, 0, 10, 3, 6, 7, 6, 3 }, -/* 182: 1, 2, 4, 5, 7, */ { 2, 10, 0, 5, 0, 10, 0, 5, 8, 6, 8, 5, 8, 6, 11 }, -/* 214: 1, 2, 4, 6, 7, */ { 2, 9, 0, 9, 2, 5, 11, 5, 2, 5, 11, 4, 8, 4, 11 }, -/* 186: 1, 3, 4, 5, 7, */ { 2, 3, 6, 8, 6, 3, 6, 8, 5, 0, 5, 8, 5, 0, 1 }, -/* 234: 1, 3, 5, 6, 7, */ { 0, 1, 4, 10, 4, 1, 4, 10, 7, 2, 7, 10, 7, 2, 3 }, -/* 124: 2, 3, 4, 5, 6, */ { 3, 11, 1, 6, 1, 11, 1, 6, 9, 7, 9, 6, 9, 7, 8 }, -/* 188: 2, 3, 4, 5, 7, */ { 3, 10, 1, 10, 3, 6, 8, 6, 3, 6, 8, 5, 9, 5, 8 } -}; -//_____________________________________________________________________________ - - - -//_____________________________________________________________________________ -/** - * \brief test table for case 7 - * 3 faces to test + eventually the interior - * When the tests on the 3 specified faces are positive : - * - if the test on the interior is positive : 5 first triangles - * - if the test on the interior is negative : 9 next triangles - * When the tests on the first and the second specified faces are positive : 9 next triangles - * When the tests on the first and the third specified faces are positive : 9 next triangles - * When the tests on the second and the third specified faces are positive : 9 next triangles - * When the test on the first specified face is positive : 5 next triangles - * When the test on the second specified face is positive : 5 next triangles - * When the test on the third specified face is positive : 5 next triangles - * When the tests on the 3 specified faces are negative : 3 last triangles - * The support edge for the interior test is marked as the 5th column. - * - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char test7[16][5] = { -/* 37: 0, 2, 5, */ { 1, 2, 5, 7, 1 }, -/* 133: 0, 2, 7, */ { 3, 4, 5, 7, 3 }, -/* 161: 0, 5, 7, */ { 4, 1, 6, 7, 4 }, -/* 26: 1, 3, 4, */ { 4, 1, 5, 7, 0 }, -/* 74: 1, 3, 6, */ { 2, 3, 5, 7, 2 }, -/* 82: 1, 4, 6, */ { 1, 2, 6, 7, 5 }, -/* 164: 2, 5, 7, */ { 2, 3, 6, 7, 6 }, -/* 88: 3, 4, 6, */ { 3, 4, 6, 7, 7 }, -/* 167: 0, 1, 2, 5, 7, */ { -3, -4, -6, -7, 7 }, -/* 91: 0, 1, 3, 4, 6, */ { -2, -3, -6, -7, 6 }, -/* 173: 0, 2, 3, 5, 7, */ { -1, -2, -6, -7, 5 }, -/* 181: 0, 2, 4, 5, 7, */ { -2, -3, -5, -7, 2 }, -/* 229: 0, 2, 5, 6, 7, */ { -4, -1, -5, -7, 0 }, -/* 94: 1, 2, 3, 4, 6, */ { -4, -1, -6, -7, 4 }, -/* 122: 1, 3, 4, 5, 6, */ { -3, -4, -5, -7, 3 }, -/* 218: 1, 3, 4, 6, 7, */ { -1, -2, -5, -7, 1 } -}; - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 7.1 - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char tiling7_1[16][9] = { -/* 37: 0, 2, 5, */ { 9, 5, 4, 10, 1, 2, 8, 3, 0 }, -/* 133: 0, 2, 7, */ { 11, 7, 6, 8, 3, 0, 10, 1, 2 }, -/* 161: 0, 5, 7, */ { 3, 0, 8, 5, 4, 9, 7, 6, 11 }, -/* 26: 1, 3, 4, */ { 8, 4, 7, 9, 0, 1, 11, 2, 3 }, -/* 74: 1, 3, 6, */ { 10, 6, 5, 11, 2, 3, 9, 0, 1 }, -/* 82: 1, 4, 6, */ { 0, 1, 9, 6, 5, 10, 4, 7, 8 }, -/* 164: 2, 5, 7, */ { 1, 2, 10, 7, 6, 11, 5, 4, 9 }, -/* 88: 3, 4, 6, */ { 2, 3, 11, 4, 7, 8, 6, 5, 10 }, -/* 167: 0, 1, 2, 5, 7, */ { 11, 3, 2, 8, 7, 4, 10, 5, 6 }, -/* 91: 0, 1, 3, 4, 6, */ { 10, 2, 1, 11, 6, 7, 9, 4, 5 }, -/* 173: 0, 2, 3, 5, 7, */ { 9, 1, 0, 10, 5, 6, 8, 7, 4 }, -/* 181: 0, 2, 4, 5, 7, */ { 5, 6, 10, 3, 2, 11, 1, 0, 9 }, -/* 229: 0, 2, 5, 6, 7, */ { 7, 4, 8, 1, 0, 9, 3, 2, 11 }, -/* 94: 1, 2, 3, 4, 6, */ { 8, 0, 3, 9, 4, 5, 11, 6, 7 }, -/* 122: 1, 3, 4, 5, 6, */ { 6, 7, 11, 0, 3, 8, 2, 1, 10 }, -/* 218: 1, 3, 4, 6, 7, */ { 4, 5, 9, 2, 1, 10, 0, 3, 8 } -}; - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 7.2 - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char tiling7_2[16][3][15] = { -/* 37: 0, 2, 5, */ { - /* 1,0 */ { 1, 2, 10, 3, 4, 8, 4, 3, 5, 0, 5, 3, 5, 0, 9 }, - /* 0,1 */ { 3, 0, 8, 9, 1, 4, 2, 4, 1, 4, 2, 5, 10, 5, 2 }, - /* 1,1 */ { 9, 5, 4, 0, 10, 1, 10, 0, 8, 10, 8, 2, 3, 2, 8 } -}, -/* 133: 0, 2, 7, */ { - /* 1,0 */ { 3, 0, 8, 1, 6, 10, 6, 1, 7, 2, 7, 1, 7, 2, 11 }, - /* 0,1 */ { 1, 2, 10, 11, 3, 6, 0, 6, 3, 6, 0, 7, 8, 7, 0 }, - /* 1,1 */ { 11, 7, 6, 2, 8, 3, 8, 2, 10, 8, 10, 0, 1, 0, 10 } -}, -/* 161: 0, 5, 7, */ { - /* 1,0 */ { 9, 5, 4, 11, 3, 6, 0, 6, 3, 6, 0, 7, 8, 7, 0 }, - /* 0,1 */ { 11, 7, 6, 3, 4, 8, 4, 3, 5, 0, 5, 3, 5, 0, 9 }, - /* 1,1 */ { 3, 0, 8, 4, 9, 7, 11, 7, 9, 5, 11, 9, 11, 5, 6 } -}, -/* 26: 1, 3, 4, */ { - /* 1,0 */ { 0, 1, 9, 2, 7, 11, 7, 2, 4, 3, 4, 2, 4, 3, 8 }, - /* 0,1 */ { 2, 3, 11, 8, 0, 7, 1, 7, 0, 7, 1, 4, 9, 4, 1 }, - /* 1,1 */ { 8, 4, 7, 3, 9, 0, 9, 3, 11, 9, 11, 1, 2, 1, 11 } -}, -/* 74: 1, 3, 6, */ { - /* 1,0 */ { 2, 3, 11, 0, 5, 9, 5, 0, 6, 1, 6, 0, 6, 1, 10 }, - /* 0,1 */ { 0, 1, 9, 10, 2, 5, 3, 5, 2, 5, 3, 6, 11, 6, 3 }, - /* 1,1 */ { 6, 5, 10, 1, 11, 2, 11, 1, 9, 11, 9, 3, 0, 3, 9 } -}, -/* 82: 1, 4, 6, */ { - /* 1,0 */ { 6, 5, 10, 8, 0, 7, 1, 7, 0, 7, 1, 4, 9, 4, 1 }, - /* 0,1 */ { 8, 4, 7, 0, 5, 9, 5, 0, 6, 1, 6, 0, 6, 1, 10 }, - /* 1,1 */ { 0, 1, 9, 5, 10, 4, 8, 4, 10, 6, 8, 10, 8, 6, 7 } -}, -/* 164: 2, 5, 7, */ { - /* 1,0 */ { 11, 7, 6, 9, 1, 4, 2, 4, 1, 4, 2, 5, 10, 5, 2 }, - /* 0,1 */ { 9, 5, 4, 1, 6, 10, 6, 1, 7, 2, 7, 1, 7, 2, 11 }, - /* 1,1 */ { 1, 2, 10, 6, 11, 5, 9, 5, 11, 7, 9, 11, 9, 7, 4 } -}, -/* 88: 3, 4, 6, */ { - /* 1,0 */ { 8, 4, 7, 10, 2, 5, 3, 5, 2, 5, 3, 6, 11, 6, 3 }, - /* 0,1 */ { 6, 5, 10, 2, 7, 11, 7, 2, 4, 3, 4, 2, 4, 3, 8 }, - /* 1,1 */ { 2, 3, 11, 7, 8, 6, 10, 6, 8, 4, 10, 8, 10, 4, 5 } -}, -/* 167: 0, 1, 2, 5, 7, */ { - /* 1,0 */ { 7, 4, 8, 5, 2, 10, 2, 5, 3, 6, 3, 5, 3, 6, 11 }, - /* 0,1 */ { 10, 5, 6, 11, 7, 2, 4, 2, 7, 2, 4, 3, 8, 3, 4 }, - /* 1,1 */ { 11, 3, 2, 6, 8, 7, 8, 6, 10, 8, 10, 4, 5, 4, 10 } -}, -/* 91: 0, 1, 3, 4, 6, */ { - /* 1,0 */ { 6, 7, 11, 4, 1, 9, 1, 4, 2, 5, 2, 4, 2, 5, 10 }, - /* 0,1 */ { 4, 5, 9, 10, 6, 1, 7, 1, 6, 1, 7, 2, 11, 2, 7 }, - /* 1,1 */ { 10, 2, 1, 5, 11, 6, 11, 5, 9, 11, 9, 7, 4, 7, 9 } -}, -/* 173: 0, 2, 3, 5, 7, */ { - /* 1,0 */ { 10, 5, 6, 7, 0, 8, 0, 7, 1, 4, 1, 7, 1, 4, 9 }, - /* 0,1 */ { 7, 4, 8, 9, 5, 0, 6, 0, 5, 0, 6, 1, 10, 1, 6 }, - /* 1,1 */ { 9, 1, 0, 4, 10, 5, 10, 4, 8, 10, 8, 6, 7, 6, 8 } -}, -/* 181: 0, 2, 4, 5, 7, */ { - /* 1,0 */ { 11, 3, 2, 9, 5, 0, 6, 0, 5, 0, 6, 1, 10, 1, 6 }, - /* 0,1 */ { 9, 1, 0, 5, 2, 10, 2, 5, 3, 6, 3, 5, 3, 6, 11 }, - /* 1,1 */ { 10, 5, 6, 2, 11, 1, 9, 1, 11, 3, 9, 11, 9, 3, 0 } -}, -/* 229: 0, 2, 5, 6, 7, */ { - /* 1,0 */ { 9, 1, 0, 11, 7, 2, 4, 2, 7, 2, 4, 3, 8, 3, 4 }, - /* 0,1 */ { 11, 3, 2, 7, 0, 8, 0, 7, 1, 4, 1, 7, 1, 4, 9 }, - /* 1,1 */ { 7, 4, 8, 0, 9, 3, 11, 3, 9, 1, 11, 9, 11, 1, 2 } -}, -/* 94: 1, 2, 3, 4, 6, */ { - /* 1,0 */ { 4, 5, 9, 6, 3, 11, 3, 6, 0, 7, 0, 6, 0, 7, 8 }, - /* 0,1 */ { 6, 7, 11, 8, 4, 3, 5, 3, 4, 3, 5, 0, 9, 0, 5 }, - /* 1,1 */ { 8, 0, 3, 7, 9, 4, 9, 7, 11, 9, 11, 5, 6, 5, 11 } -}, -/* 122: 1, 3, 4, 5, 6, */ { - /* 1,0 */ { 8, 0, 3, 10, 6, 1, 7, 1, 6, 1, 7, 2, 11, 2, 7 }, - /* 0,1 */ { 10, 2, 1, 6, 3, 11, 3, 6, 0, 7, 0, 6, 0, 7, 8 }, - /* 1,1 */ { 6, 7, 11, 3, 8, 2, 10, 2, 8, 0, 10, 8, 10, 0, 1 } -}, -/* 218: 1, 3, 4, 6, 7, */ { - /* 1,0 */ { 10, 2, 1, 8, 4, 3, 5, 3, 4, 3, 5, 0, 9, 0, 5 }, - /* 0,1 */ { 8, 0, 3, 4, 1, 9, 1, 4, 2, 5, 2, 4, 2, 5, 10 }, - /* 1,1 */ { 4, 5, 9, 1, 10, 0, 8, 0, 10, 2, 8, 10, 8, 2, 3 } } -}; - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 7.3 - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char tiling7_3[16][3][27] = { -/* 37: 0, 2, 5, */ { - /* 1,0 */ { 12, 2, 10, 12, 10, 5, 12, 5, 4, 12, 4, 8, 12, 8, 3, 12, 3, 0, 12, 0, 9, 12, 9, 1, 12, 1, 2 }, - /* 0,1 */ { 12, 5, 4, 12, 4, 8, 12, 8, 3, 12, 3, 2, 12, 2, 10, 12, 10, 1, 12, 1, 0, 12, 0, 9, 12, 9, 5 }, - /* 1,1 */ { 5, 4, 12, 10, 5, 12, 2, 10, 12, 3, 2, 12, 8, 3, 12, 0, 8, 12, 1, 0, 12, 9, 1, 12, 4, 9, 12 } -}, -/* 133: 0, 2, 7, */ { - /* 1,0 */ { 12, 0, 8, 12, 8, 7, 12, 7, 6, 12, 6, 10, 12, 10, 1, 12, 1, 2, 12, 2, 11, 12, 11, 3, 12, 3, 0 }, - /* 0,1 */ { 12, 7, 6, 12, 6, 10, 12, 10, 1, 12, 1, 0, 12, 0, 8, 12, 8, 3, 12, 3, 2, 12, 2, 11, 12, 11, 7 }, - /* 1,1 */ { 7, 6, 12, 8, 7, 12, 0, 8, 12, 1, 0, 12, 10, 1, 12, 2, 10, 12, 3, 2, 12, 11, 3, 12, 6, 11, 12 } -}, -/* 161: 0, 5, 7, */ { - /* 1,0 */ { 9, 5, 12, 0, 9, 12, 3, 0, 12, 11, 3, 12, 6, 11, 12, 7, 6, 12, 8, 7, 12, 4, 8, 12, 5, 4, 12 }, - /* 0,1 */ { 3, 0, 12, 11, 3, 12, 6, 11, 12, 5, 6, 12, 9, 5, 12, 4, 9, 12, 7, 4, 12, 8, 7, 12, 0, 8, 12 }, - /* 1,1 */ { 12, 3, 0, 12, 0, 9, 12, 9, 5, 12, 5, 6, 12, 6, 11, 12, 11, 7, 12, 7, 4, 12, 4, 8, 12, 8, 3 } -}, -/* 26: 1, 3, 4, */ { - /* 1,0 */ { 12, 1, 9, 12, 9, 4, 12, 4, 7, 12, 7, 11, 12, 11, 2, 12, 2, 3, 12, 3, 8, 12, 8, 0, 12, 0, 1 }, - /* 0,1 */ { 12, 4, 7, 12, 7, 11, 12, 11, 2, 12, 2, 1, 12, 1, 9, 12, 9, 0, 12, 0, 3, 12, 3, 8, 12, 8, 4 }, - /* 1,1 */ { 4, 7, 12, 9, 4, 12, 1, 9, 12, 2, 1, 12, 11, 2, 12, 3, 11, 12, 0, 3, 12, 8, 0, 12, 7, 8, 12 } -}, -/* 74: 1, 3, 6, */ { - /* 1,0 */ { 12, 3, 11, 12, 11, 6, 12, 6, 5, 12, 5, 9, 12, 9, 0, 12, 0, 1, 12, 1, 10, 12, 10, 2, 12, 2, 3 }, - /* 0,1 */ { 12, 6, 5, 12, 5, 9, 12, 9, 0, 12, 0, 3, 12, 3, 11, 12, 11, 2, 12, 2, 1, 12, 1, 10, 12, 10, 6 }, - /* 1,1 */ { 6, 5, 12, 11, 6, 12, 3, 11, 12, 0, 3, 12, 9, 0, 12, 1, 9, 12, 2, 1, 12, 10, 2, 12, 5, 10, 12 } -}, -/* 82: 1, 4, 6, */ { - /* 1,0 */ { 10, 6, 12, 1, 10, 12, 0, 1, 12, 8, 0, 12, 7, 8, 12, 4, 7, 12, 9, 4, 12, 5, 9, 12, 6, 5, 12 }, - /* 0,1 */ { 0, 1, 12, 8, 0, 12, 7, 8, 12, 6, 7, 12, 10, 6, 12, 5, 10, 12, 4, 5, 12, 9, 4, 12, 1, 9, 12 }, - /* 1,1 */ { 12, 0, 1, 12, 1, 10, 12, 10, 6, 12, 6, 7, 12, 7, 8, 12, 8, 4, 12, 4, 5, 12, 5, 9, 12, 9, 0 } -}, -/* 164: 2, 5, 7, */ { - /* 1,0 */ { 11, 7, 12, 2, 11, 12, 1, 2, 12, 9, 1, 12, 4, 9, 12, 5, 4, 12, 10, 5, 12, 6, 10, 12, 7, 6, 12 }, - /* 0,1 */ { 1, 2, 12, 9, 1, 12, 4, 9, 12, 7, 4, 12, 11, 7, 12, 6, 11, 12, 5, 6, 12, 10, 5, 12, 2, 10, 12 }, - /* 1,1 */ { 12, 1, 2, 12, 2, 11, 12, 11, 7, 12, 7, 4, 12, 4, 9, 12, 9, 5, 12, 5, 6, 12, 6, 10, 12, 10, 1 } -}, -/* 88: 3, 4, 6, */ { - /* 1,0 */ { 8, 4, 12, 3, 8, 12, 2, 3, 12, 10, 2, 12, 5, 10, 12, 6, 5, 12, 11, 6, 12, 7, 11, 12, 4, 7, 12 }, - /* 0,1 */ { 2, 3, 12, 10, 2, 12, 5, 10, 12, 4, 5, 12, 8, 4, 12, 7, 8, 12, 6, 7, 12, 11, 6, 12, 3, 11, 12 }, - /* 1,1 */ { 12, 2, 3, 12, 3, 8, 12, 8, 4, 12, 4, 5, 12, 5, 10, 12, 10, 6, 12, 6, 7, 12, 7, 11, 12, 11, 2 } -}, -/* 167: 0, 1, 2, 5, 7, */ { - /* 1,0 */ { 12, 4, 8, 12, 8, 3, 12, 3, 2, 12, 2, 10, 12, 10, 5, 12, 5, 6, 12, 6, 11, 12, 11, 7, 12, 7, 4 }, - /* 0,1 */ { 12, 3, 2, 12, 2, 10, 12, 10, 5, 12, 5, 4, 12, 4, 8, 12, 8, 7, 12, 7, 6, 12, 6, 11, 12, 11, 3 }, - /* 1,1 */ { 3, 2, 12, 8, 3, 12, 4, 8, 12, 5, 4, 12, 10, 5, 12, 6, 10, 12, 7, 6, 12, 11, 7, 12, 2, 11, 12 } -}, -/* 91: 0, 1, 3, 4, 6, */ { - /* 1,0 */ { 12, 7, 11, 12, 11, 2, 12, 2, 1, 12, 1, 9, 12, 9, 4, 12, 4, 5, 12, 5, 10, 12, 10, 6, 12, 6, 7 }, - /* 0,1 */ { 12, 2, 1, 12, 1, 9, 12, 9, 4, 12, 4, 7, 12, 7, 11, 12, 11, 6, 12, 6, 5, 12, 5, 10, 12, 10, 2 }, - /* 1,1 */ { 2, 1, 12, 11, 2, 12, 7, 11, 12, 4, 7, 12, 9, 4, 12, 5, 9, 12, 6, 5, 12, 10, 6, 12, 1, 10, 12 } -}, -/* 173: 0, 2, 3, 5, 7, */ { - /* 1,0 */ { 12, 6, 10, 12, 10, 1, 12, 1, 0, 12, 0, 8, 12, 8, 7, 12, 7, 4, 12, 4, 9, 12, 9, 5, 12, 5, 6 }, - /* 0,1 */ { 12, 1, 0, 12, 0, 8, 12, 8, 7, 12, 7, 6, 12, 6, 10, 12, 10, 5, 12, 5, 4, 12, 4, 9, 12, 9, 1 }, - /* 1,1 */ { 1, 0, 12, 10, 1, 12, 6, 10, 12, 7, 6, 12, 8, 7, 12, 4, 8, 12, 5, 4, 12, 9, 5, 12, 0, 9, 12 } -}, -/* 181: 0, 2, 4, 5, 7, */ { - /* 1,0 */ { 11, 3, 12, 6, 11, 12, 5, 6, 12, 9, 5, 12, 0, 9, 12, 1, 0, 12, 10, 1, 12, 2, 10, 12, 3, 2, 12 }, - /* 0,1 */ { 5, 6, 12, 9, 5, 12, 0, 9, 12, 3, 0, 12, 11, 3, 12, 2, 11, 12, 1, 2, 12, 10, 1, 12, 6, 10, 12 }, - /* 1,1 */ { 12, 5, 6, 12, 6, 11, 12, 11, 3, 12, 3, 0, 12, 0, 9, 12, 9, 1, 12, 1, 2, 12, 2, 10, 12, 10, 5 } -}, -/* 229: 0, 2, 5, 6, 7, */ { - /* 1,0 */ { 9, 1, 12, 4, 9, 12, 7, 4, 12, 11, 7, 12, 2, 11, 12, 3, 2, 12, 8, 3, 12, 0, 8, 12, 1, 0, 12 }, - /* 0,1 */ { 7, 4, 12, 11, 7, 12, 2, 11, 12, 1, 2, 12, 9, 1, 12, 0, 9, 12, 3, 0, 12, 8, 3, 12, 4, 8, 12 }, - /* 1,1 */ { 12, 7, 4, 12, 4, 9, 12, 9, 1, 12, 1, 2, 12, 2, 11, 12, 11, 3, 12, 3, 0, 12, 0, 8, 12, 8, 7 } -}, -/* 94: 1, 2, 3, 4, 6, */ { - /* 1,0 */ { 12, 5, 9, 12, 9, 0, 12, 0, 3, 12, 3, 11, 12, 11, 6, 12, 6, 7, 12, 7, 8, 12, 8, 4, 12, 4, 5 }, - /* 0,1 */ { 12, 0, 3, 12, 3, 11, 12, 11, 6, 12, 6, 5, 12, 5, 9, 12, 9, 4, 12, 4, 7, 12, 7, 8, 12, 8, 0 }, - /* 1,1 */ { 0, 3, 12, 9, 0, 12, 5, 9, 12, 6, 5, 12, 11, 6, 12, 7, 11, 12, 4, 7, 12, 8, 4, 12, 3, 8, 12 } -}, -/* 122: 1, 3, 4, 5, 6, */ { - /* 1,0 */ { 8, 0, 12, 7, 8, 12, 6, 7, 12, 10, 6, 12, 1, 10, 12, 2, 1, 12, 11, 2, 12, 3, 11, 12, 0, 3, 12 }, - /* 0,1 */ { 6, 7, 12, 10, 6, 12, 1, 10, 12, 0, 1, 12, 8, 0, 12, 3, 8, 12, 2, 3, 12, 11, 2, 12, 7, 11, 12 }, - /* 1,1 */ { 12, 6, 7, 12, 7, 8, 12, 8, 0, 12, 0, 1, 12, 1, 10, 12, 10, 2, 12, 2, 3, 12, 3, 11, 12, 11, 6 } -}, -/* 218: 1, 3, 4, 6, 7, */ { - /* 1,0 */ { 10, 2, 12, 5, 10, 12, 4, 5, 12, 8, 4, 12, 3, 8, 12, 0, 3, 12, 9, 0, 12, 1, 9, 12, 2, 1, 12 }, - /* 0,1 */ { 4, 5, 12, 8, 4, 12, 3, 8, 12, 2, 3, 12, 10, 2, 12, 1, 10, 12, 0, 1, 12, 9, 0, 12, 5, 9, 12 }, - /* 1,1 */ { 12, 4, 5, 12, 5, 10, 12, 10, 2, 12, 2, 3, 12, 3, 8, 12, 8, 0, 12, 0, 1, 12, 1, 9, 12, 9, 4 } } -}; - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 7.4.1 - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char tiling7_4_1[16][15] = { -/* 37: 0, 2, 5, */ { 3, 4, 8, 4, 3, 10, 2, 10, 3, 4, 10, 5, 9, 1, 0 }, -/* 133: 0, 2, 7, */ { 1, 6, 10, 6, 1, 8, 0, 8, 1, 6, 8, 7, 11, 3, 2 }, -/* 161: 0, 5, 7, */ { 11, 3, 6, 9, 6, 3, 6, 9, 5, 0, 9, 3, 7, 4, 8 }, -/* 26: 1, 3, 4, */ { 2, 7, 11, 7, 2, 9, 1, 9, 2, 7, 9, 4, 8, 0, 3 }, -/* 74: 1, 3, 6, */ { 0, 5, 9, 5, 0, 11, 3, 11, 0, 5, 11, 6, 10, 2, 1 }, -/* 82: 1, 4, 6, */ { 8, 0, 7, 10, 7, 0, 7, 10, 6, 1, 10, 0, 4, 5, 9 }, -/* 164: 2, 5, 7, */ { 9, 1, 4, 11, 4, 1, 4, 11, 7, 2, 11, 1, 5, 6, 10 }, -/* 88: 3, 4, 6, */ { 10, 2, 5, 8, 5, 2, 5, 8, 4, 3, 8, 2, 6, 7, 11 }, -/* 167: 0, 1, 2, 5, 7, */ { 5, 2, 10, 2, 5, 8, 4, 8, 5, 2, 8, 3, 11, 7, 6 }, -/* 91: 0, 1, 3, 4, 6, */ { 4, 1, 9, 1, 4, 11, 7, 11, 4, 1, 11, 2, 10, 6, 5 }, -/* 173: 0, 2, 3, 5, 7, */ { 7, 0, 8, 0, 7, 10, 6, 10, 7, 0, 10, 1, 9, 5, 4 }, -/* 181: 0, 2, 4, 5, 7, */ { 9, 5, 0, 11, 0, 5, 0, 11, 3, 6, 11, 5, 1, 2, 10 }, -/* 229: 0, 2, 5, 6, 7, */ { 11, 7, 2, 9, 2, 7, 2, 9, 1, 4, 9, 7, 3, 0, 8 }, -/* 94: 1, 2, 3, 4, 6, */ { 6, 3, 11, 3, 6, 9, 5, 9, 6, 3, 9, 0, 8, 4, 7 }, -/* 122: 1, 3, 4, 5, 6, */ { 10, 6, 1, 8, 1, 6, 1, 8, 0, 7, 8, 6, 2, 3, 11 }, -/* 218: 1, 3, 4, 6, 7, */ { 8, 4, 3, 10, 3, 4, 3, 10, 2, 5, 10, 4, 0, 1, 9 } -}; - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 7.4.2 - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char tiling7_4_2[16][27] = { -/* 37: 0, 2, 5, */ { 9, 4, 8, 4, 9, 5, 10, 5, 9, 1, 10, 9, 10, 1, 2, 0, 2, 1, 2, 0, 3, 8, 3, 0, 9, 8, 0 }, -/* 133: 0, 2, 7, */ { 11, 6, 10, 6, 11, 7, 8, 7, 11, 3, 8, 11, 8, 3, 0, 2, 0, 3, 0, 2, 1, 10, 1, 2, 11, 10, 2 }, -/* 161: 0, 5, 7, */ { 11, 3, 8, 0, 8, 3, 8, 0, 9, 8, 9, 4, 5, 4, 9, 4, 5, 7, 6, 7, 5, 7, 6, 11, 7, 11, 8 }, -/* 26: 1, 3, 4, */ { 8, 7, 11, 7, 8, 4, 9, 4, 8, 0, 9, 8, 9, 0, 1, 3, 1, 0, 1, 3, 2, 11, 2, 3, 8, 11, 3 }, -/* 74: 1, 3, 6, */ { 10, 5, 9, 5, 10, 6, 11, 6, 10, 2, 11, 10, 11, 2, 3, 1, 3, 2, 3, 1, 0, 9, 0, 1, 10, 9, 1 }, -/* 82: 1, 4, 6, */ { 8, 0, 9, 1, 9, 0, 9, 1, 10, 9, 10, 5, 6, 5, 10, 5, 6, 4, 7, 4, 6, 4, 7, 8, 4, 8, 9 }, -/* 164: 2, 5, 7, */ { 9, 1, 10, 2, 10, 1, 10, 2, 11, 10, 11, 6, 7, 6, 11, 6, 7, 5, 4, 5, 7, 5, 4, 9, 5, 9, 10 }, -/* 88: 3, 4, 6, */ { 10, 2, 11, 3, 11, 2, 11, 3, 8, 11, 8, 7, 4, 7, 8, 7, 4, 6, 5, 6, 4, 6, 5, 10, 6, 10, 11 }, -/* 167: 0, 1, 2, 5, 7, */ { 11, 2, 10, 2, 11, 3, 8, 3, 11, 7, 8, 11, 8, 7, 4, 6, 4, 7, 4, 6, 5, 10, 5, 6, 11, 10, 6 }, -/* 91: 0, 1, 3, 4, 6, */ { 10, 1, 9, 1, 10, 2, 11, 2, 10, 6, 11, 10, 11, 6, 7, 5, 7, 6, 7, 5, 4, 9, 4, 5, 10, 9, 5 }, -/* 173: 0, 2, 3, 5, 7, */ { 9, 0, 8, 0, 9, 1, 10, 1, 9, 5, 10, 9, 10, 5, 6, 4, 6, 5, 6, 4, 7, 8, 7, 4, 9, 8, 4 }, -/* 181: 0, 2, 4, 5, 7, */ { 9, 5, 10, 6, 10, 5, 10, 6, 11, 10, 11, 2, 3, 2, 11, 2, 3, 1, 0, 1, 3, 1, 0, 9, 1, 9, 10 }, -/* 229: 0, 2, 5, 6, 7, */ { 11, 7, 8, 4, 8, 7, 8, 4, 9, 8, 9, 0, 1, 0, 9, 0, 1, 3, 2, 3, 1, 3, 2, 11, 3, 11, 8 }, -/* 94: 1, 2, 3, 4, 6, */ { 8, 3, 11, 3, 8, 0, 9, 0, 8, 4, 9, 8, 9, 4, 5, 7, 5, 4, 5, 7, 6, 11, 6, 7, 8, 11, 7 }, -/* 122: 1, 3, 4, 5, 6, */ { 10, 6, 11, 7, 11, 6, 11, 7, 8, 11, 8, 3, 0, 3, 8, 3, 0, 2, 1, 2, 0, 2, 1, 10, 2, 10, 11 }, -/* 218: 1, 3, 4, 6, 7, */ { 8, 4, 9, 5, 9, 4, 9, 5, 10, 9, 10, 1, 2, 1, 10, 1, 2, 0, 3, 0, 2, 0, 3, 8, 0, 8, 9 } -}; -//_____________________________________________________________________________ - - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 8 - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char tiling8[6][6] = { -/* 15: 0, 1, 2, 3, */ { 9, 8, 10, 10, 8, 11 }, -/* 51: 0, 1, 4, 5, */ { 1, 5, 3, 3, 5, 7 }, -/* 153: 0, 3, 4, 7, */ { 0, 4, 2, 4, 6, 2 }, -/* 102: 1, 2, 5, 6, */ { 0, 2, 4, 4, 2, 6 }, -/* 204: 2, 3, 6, 7, */ { 1, 3, 5, 3, 7, 5 }, -/* 240: 4, 5, 6, 7, */ { 9, 10, 8, 10, 11, 8 } -}; -//_____________________________________________________________________________ - - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 9 - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char tiling9[8][12] = { -/* 39: 0, 1, 2, 5, */ { 2, 10, 5, 3, 2, 5, 3, 5, 4, 3, 4, 8 }, -/* 27: 0, 1, 3, 4, */ { 4, 7, 11, 9, 4, 11, 9, 11, 2, 9, 2, 1 }, -/* 141: 0, 2, 3, 7, */ { 10, 7, 6, 1, 7, 10, 1, 8, 7, 1, 0, 8 }, -/* 177: 0, 4, 5, 7, */ { 3, 6, 11, 0, 6, 3, 0, 5, 6, 0, 9, 5 }, -/* 78: 1, 2, 3, 6, */ { 3, 11, 6, 0, 3, 6, 0, 6, 5, 0, 5, 9 }, -/* 114: 1, 4, 5, 6, */ { 10, 6, 7, 1, 10, 7, 1, 7, 8, 1, 8, 0 }, -/* 228: 2, 5, 6, 7, */ { 4, 11, 7, 9, 11, 4, 9, 2, 11, 9, 1, 2 }, -/* 216: 3, 4, 6, 7, */ { 2, 5, 10, 3, 5, 2, 3, 4, 5, 3, 8, 4 } -}; -//_____________________________________________________________________________ - - - -//_____________________________________________________________________________ -/** - * \brief test table for case 10 - * 2 faces to test + eventually the interior - * When the tests on both specified faces are positive : 4 middle triangles (1) - * When the test on the first specified face is positive : 8 first triangles - * When the test on the second specified face is positive : 8 next triangles - * When the tests on both specified faces are negative : - * - if the test on the interior is negative : 4 middle triangles - * - if the test on the interior is positive : 8 last triangles - * - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char test10[6][3] = { -/* 195: 0, 1, 6, 7, */ { 2, 4, 7 }, -/* 85: 0, 2, 4, 6, */ { 5, 6, 7 }, -/* 105: 0, 3, 5, 6, */ { 1, 3, 7 }, -/* 150: 1, 2, 4, 7, */ { 1, 3, 7 }, -/* 170: 1, 3, 5, 7, */ { 5, 6, 7 }, -/* 60: 2, 3, 4, 5, */ { 2, 4, 7 } -}; - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 10.1.1 - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char tiling10_1_1[6][12] = { -/* 195: 0, 1, 6, 7, */ { 5, 10, 7, 11, 7, 10, 8, 1, 9, 1, 8, 3 }, -/* 85: 0, 2, 4, 6, */ { 1, 2, 5, 6, 5, 2, 4, 3, 0, 3, 4, 7 }, -/* 105: 0, 3, 5, 6, */ { 11, 0, 8, 0, 11, 2, 4, 9, 6, 10, 6, 9 }, -/* 150: 1, 2, 4, 7, */ { 9, 0, 10, 2, 10, 0, 6, 8, 4, 8, 6, 11 }, -/* 170: 1, 3, 5, 7, */ { 7, 2, 3, 2, 7, 6, 0, 1, 4, 5, 4, 1 }, -/* 60: 2, 3, 4, 5, */ { 7, 9, 5, 9, 7, 8, 10, 1, 11, 3, 11, 1 } -}; - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 10.1.1 inverted - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char tiling10_1_1_[6][12] = { -/* 195: 0, 1, 6, 7, */ { 5, 9, 7, 8, 7, 9, 11, 1, 10, 1, 11, 3 }, -/* 85: 0, 2, 4, 6, */ { 3, 2, 7, 6, 7, 2, 4, 1, 0, 1, 4, 5 }, -/* 105: 0, 3, 5, 6, */ { 10, 0, 9, 0, 10, 2, 4, 8, 6, 11, 6, 8 }, -/* 150: 1, 2, 4, 7, */ { 8, 0, 11, 2, 11, 0, 6, 9, 4, 9, 6, 10 }, -/* 170: 1, 3, 5, 7, */ { 5, 2, 1, 2, 5, 6, 0, 3, 4, 7, 4, 3 }, -/* 60: 2, 3, 4, 5, */ { 7, 10, 5, 10, 7, 11, 9, 1, 8, 3, 8, 1 } -}; - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 10.1.2 - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char tiling10_1_2[6][24] = { -/* 195: 0, 1, 6, 7, */ { 3, 11, 7, 3, 7, 8, 9, 8, 7, 5, 9, 7, 9, 5, 10, 9, 10, 1, 3, 1, 10, 11, 3, 10 }, -/* 85: 0, 2, 4, 6, */ { 7, 6, 5, 7, 5, 4, 0, 4, 5, 1, 0, 5, 0, 1, 2, 0, 2, 3, 7, 3, 2, 6, 7, 2 }, -/* 105: 0, 3, 5, 6, */ { 11, 2, 10, 6, 11, 10, 11, 6, 4, 11, 4, 8, 0, 8, 4, 9, 0, 4, 0, 9, 10, 0, 10, 2 }, -/* 150: 1, 2, 4, 7, */ { 11, 2, 10, 11, 10, 6, 4, 6, 10, 9, 4, 10, 4, 9, 0, 4, 0, 8, 11, 8, 0, 2, 11, 0 }, -/* 170: 1, 3, 5, 7, */ { 7, 6, 5, 4, 7, 5, 7, 4, 0, 7, 0, 3, 2, 3, 0, 1, 2, 0, 2, 1, 5, 2, 5, 6 }, -/* 60: 2, 3, 4, 5, */ { 7, 8, 3, 11, 7, 3, 7, 11, 10, 7, 10, 5, 9, 5, 10, 1, 9, 10, 9, 1, 3, 9, 3, 8 } -}; - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 10.2 - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char tiling10_2[6][24] = { -/* 195: 0, 1, 6, 7, */ { 12, 5, 9, 12, 9, 8, 12, 8, 3, 12, 3, 1, 12, 1, 10, 12, 10, 11, 12, 11, 7, 12, 7, 5 }, -/* 85: 0, 2, 4, 6, */ { 12, 1, 0, 12, 0, 4, 12, 4, 7, 12, 7, 3, 12, 3, 2, 12, 2, 6, 12, 6, 5, 12, 5, 1 }, -/* 105: 0, 3, 5, 6, */ { 4, 8, 12, 6, 4, 12, 10, 6, 12, 9, 10, 12, 0, 9, 12, 2, 0, 12, 11, 2, 12, 8, 11, 12 }, -/* 150: 1, 2, 4, 7, */ { 12, 9, 4, 12, 4, 6, 12, 6, 11, 12, 11, 8, 12, 8, 0, 12, 0, 2, 12, 2, 10, 12, 10, 9 }, -/* 170: 1, 3, 5, 7, */ { 0, 3, 12, 4, 0, 12, 5, 4, 12, 1, 5, 12, 2, 1, 12, 6, 2, 12, 7, 6, 12, 3, 7, 12 }, -/* 60: 2, 3, 4, 5, */ { 10, 5, 12, 11, 10, 12, 3, 11, 12, 1, 3, 12, 9, 1, 12, 8, 9, 12, 7, 8, 12, 5, 7, 12 } -}; - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 10.2 inverted - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char tiling10_2_[6][24] = { -/* 195: 0, 1, 6, 7, */ { 8, 7, 12, 9, 8, 12, 1, 9, 12, 3, 1, 12, 11, 3, 12, 10, 11, 12, 5, 10, 12, 7, 5, 12 }, -/* 85: 0, 2, 4, 6, */ { 4, 5, 12, 0, 4, 12, 3, 0, 12, 7, 3, 12, 6, 7, 12, 2, 6, 12, 1, 2, 12, 5, 1, 12 }, -/* 105: 0, 3, 5, 6, */ { 12, 11, 6, 12, 6, 4, 12, 4, 9, 12, 9, 10, 12, 10, 2, 12, 2, 0, 12, 0, 8, 12, 8, 11 }, -/* 150: 1, 2, 4, 7, */ { 6, 10, 12, 4, 6, 12, 8, 4, 12, 11, 8, 12, 2, 11, 12, 0, 2, 12, 9, 0, 12, 10, 9, 12 }, -/* 170: 1, 3, 5, 7, */ { 12, 7, 4, 12, 4, 0, 12, 0, 1, 12, 1, 5, 12, 5, 6, 12, 6, 2, 12, 2, 3, 12, 3, 7 }, -/* 60: 2, 3, 4, 5, */ { 12, 7, 11, 12, 11, 10, 12, 10, 1, 12, 1, 3, 12, 3, 8, 12, 8, 9, 12, 9, 5, 12, 5, 7 } -}; -//_____________________________________________________________________________ - - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 11 - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char tiling11[12][12] = { -/* 23: 0, 1, 2, 4, */ { 2, 10, 9, 2, 9, 7, 2, 7, 3, 7, 9, 4 }, -/* 139: 0, 1, 3, 7, */ { 1, 6, 2, 1, 8, 6, 1, 9, 8, 8, 7, 6 }, -/* 99: 0, 1, 5, 6, */ { 8, 3, 1, 8, 1, 6, 8, 6, 4, 6, 1, 10 }, -/* 77: 0, 2, 3, 6, */ { 0, 8, 11, 0, 11, 5, 0, 5, 1, 5, 11, 6 }, -/* 57: 0, 3, 4, 5, */ { 9, 5, 7, 9, 7, 2, 9, 2, 0, 2, 7, 11 }, -/* 209: 0, 4, 6, 7, */ { 5, 0, 4, 5, 11, 0, 5, 10, 11, 11, 3, 0 }, -/* 46: 1, 2, 3, 5, */ { 5, 4, 0, 5, 0, 11, 5, 11, 10, 11, 0, 3 }, -/* 198: 1, 2, 6, 7, */ { 9, 7, 5, 9, 2, 7, 9, 0, 2, 2, 11, 7 }, -/* 178: 1, 4, 5, 7, */ { 0, 11, 8, 0, 5, 11, 0, 1, 5, 5, 6, 11 }, -/* 156: 2, 3, 4, 7, */ { 8, 1, 3, 8, 6, 1, 8, 4, 6, 6, 10, 1 }, -/* 116: 2, 4, 5, 6, */ { 1, 2, 6, 1, 6, 8, 1, 8, 9, 8, 6, 7 }, -/* 232: 3, 5, 6, 7, */ { 2, 9, 10, 2, 7, 9, 2, 3, 7, 7, 4, 9 } -}; -//_____________________________________________________________________________ - - -//_____________________________________________________________________________ -/** - * \brief test table for case 12 - * 2 faces to test + eventually the interior - * When the tests on both specified faces are positive : 4 middle triangles (1) - * When the test on the first specified face is positive : 8 first triangles - * When the test on the second specified face is positive : 8 next triangles - * When the tests on both specified faces are negative : - * - if the test on the interior is negative : 4 middle triangles - * - if the test on the interior is positive : 8 last triangles - * The support edge for the interior test is marked as the 4th column. - * - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char test12[24][4] = { -/* 135: 0, 1, 2, 7, */ { 4, 3, 7, 11 }, -/* 75: 0, 1, 3, 6, */ { 3, 2, 7, 10 }, -/* 83: 0, 1, 4, 6, */ { 2, 6, 7, 5 }, -/* 163: 0, 1, 5, 7, */ { 6, 4, 7, 7 }, -/* 45: 0, 2, 3, 5, */ { 2, 1, 7, 9 }, -/* 53: 0, 2, 4, 5, */ { 5, 2, 7, 1 }, -/* 149: 0, 2, 4, 7, */ { 5, 3, 7, 2 }, -/* 101: 0, 2, 5, 6, */ { 5, 1, 7, 0 }, -/* 197: 0, 2, 6, 7, */ { 5, 4, 7, 3 }, -/* 89: 0, 3, 4, 6, */ { 6, 3, 7, 6 }, -/* 169: 0, 3, 5, 7, */ { 1, 6, 7, 4 }, -/* 225: 0, 5, 6, 7, */ { 1, 4, 7, 8 }, -/* 30: 1, 2, 3, 4, */ { 4, 1, 7, 8 }, -/* 86: 1, 2, 4, 6, */ { 6, 1, 7, 4 }, -/* 166: 1, 2, 5, 7, */ { 3, 6, 7, 6 }, -/* 58: 1, 3, 4, 5, */ { 4, 5, 7, 3 }, -/* 154: 1, 3, 4, 7, */ { 1, 5, 7, 0 }, -/* 106: 1, 3, 5, 6, */ { 3, 5, 7, 2 }, -/* 202: 1, 3, 6, 7, */ { 2, 5, 7, 1 }, -/* 210: 1, 4, 6, 7, */ { 1, 2, 7, 9 }, -/* 92: 2, 3, 4, 6, */ { 4, 6, 7, 7 }, -/* 172: 2, 3, 5, 7, */ { 6, 2, 7, 5 }, -/* 180: 2, 4, 5, 7, */ { 2, 3, 7, 10 }, -/* 120: 3, 4, 5, 6, */ { 3, 4, 7, 11 } -}; - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 12.1.1 - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char tiling12_1_1[24][12] = { -/* 135: 0, 1, 2, 7, */ { 7, 6, 11, 10, 3, 2, 3, 10, 8, 9, 8, 10 }, -/* 75: 0, 1, 3, 6, */ { 6, 5, 10, 9, 2, 1, 2, 9, 11, 8, 11, 9 }, -/* 83: 0, 1, 4, 6, */ { 10, 6, 5, 7, 9, 4, 9, 7, 1, 3, 1, 7 }, -/* 163: 0, 1, 5, 7, */ { 7, 6, 11, 4, 8, 5, 3, 5, 8, 5, 3, 1 }, -/* 45: 0, 2, 3, 5, */ { 5, 4, 9, 8, 1, 0, 1, 8, 10, 11, 10, 8 }, -/* 53: 0, 2, 4, 5, */ { 1, 2, 10, 0, 9, 3, 5, 3, 9, 3, 5, 7 }, -/* 149: 0, 2, 4, 7, */ { 10, 1, 2, 0, 11, 3, 11, 0, 6, 4, 6, 0 }, -/* 101: 0, 2, 5, 6, */ { 8, 3, 0, 2, 9, 1, 9, 2, 4, 6, 4, 2 }, -/* 197: 0, 2, 6, 7, */ { 3, 0, 8, 2, 11, 1, 7, 1, 11, 1, 7, 5 }, -/* 89: 0, 3, 4, 6, */ { 6, 5, 10, 7, 11, 4, 2, 4, 11, 4, 2, 0 }, -/* 169: 0, 3, 5, 7, */ { 9, 5, 4, 6, 8, 7, 8, 6, 0, 2, 0, 6 }, -/* 225: 0, 5, 6, 7, */ { 8, 3, 0, 7, 4, 11, 9, 11, 4, 11, 9, 10 }, -/* 30: 1, 2, 3, 4, */ { 4, 7, 8, 11, 0, 3, 0, 11, 9, 10, 9, 11 }, -/* 86: 1, 2, 4, 6, */ { 4, 7, 8, 5, 9, 6, 0, 6, 9, 6, 0, 2 }, -/* 166: 1, 2, 5, 7, */ { 11, 7, 6, 4, 10, 5, 10, 4, 2, 0, 2, 4 }, -/* 58: 1, 3, 4, 5, */ { 11, 2, 3, 1, 8, 0, 8, 1, 7, 5, 7, 1 }, -/* 154: 1, 3, 4, 7, */ { 0, 1, 9, 3, 8, 2, 4, 2, 8, 2, 4, 6 }, -/* 106: 1, 3, 5, 6, */ { 2, 3, 11, 1, 10, 0, 6, 0, 10, 0, 6, 4 }, -/* 202: 1, 3, 6, 7, */ { 9, 0, 1, 3, 10, 2, 10, 3, 5, 7, 5, 3 }, -/* 210: 1, 4, 6, 7, */ { 9, 0, 1, 4, 5, 8, 10, 8, 5, 8, 10, 11 }, -/* 92: 2, 3, 4, 6, */ { 8, 4, 7, 5, 11, 6, 11, 5, 3, 1, 3, 5 }, -/* 172: 2, 3, 5, 7, */ { 5, 4, 9, 6, 10, 7, 1, 7, 10, 7, 1, 3 }, -/* 180: 2, 4, 5, 7, */ { 10, 1, 2, 5, 6, 9, 11, 9, 6, 9, 11, 8 }, -/* 120: 3, 4, 5, 6, */ { 11, 2, 3, 6, 7, 10, 8, 10, 7, 10, 8, 9 } -}; - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 12.1.1 inverted - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char tiling12_1_1_[24][12] = { -/* 135: 0, 1, 2, 7, */ { 3, 2, 11, 10, 7, 6, 7, 10, 8, 9, 8, 10 }, -/* 75: 0, 1, 3, 6, */ { 2, 1, 10, 9, 6, 5, 6, 9, 11, 8, 11, 9 }, -/* 83: 0, 1, 4, 6, */ { 9, 4, 5, 7, 10, 6, 10, 7, 1, 3, 1, 7 }, -/* 163: 0, 1, 5, 7, */ { 7, 4, 8, 6, 11, 5, 3, 5, 11, 5, 3, 1 }, -/* 45: 0, 2, 3, 5, */ { 1, 0, 9, 8, 5, 4, 5, 8, 10, 11, 10, 8 }, -/* 53: 0, 2, 4, 5, */ { 1, 0, 9, 2, 10, 3, 5, 3, 10, 3, 5, 7 }, -/* 149: 0, 2, 4, 7, */ { 11, 3, 2, 0, 10, 1, 10, 0, 6, 4, 6, 0 }, -/* 101: 0, 2, 5, 6, */ { 9, 1, 0, 2, 8, 3, 8, 2, 4, 6, 4, 2 }, -/* 197: 0, 2, 6, 7, */ { 3, 2, 11, 0, 8, 1, 7, 1, 8, 1, 7, 5 }, -/* 89: 0, 3, 4, 6, */ { 6, 7, 11, 5, 10, 4, 2, 4, 10, 4, 2, 0 }, -/* 169: 0, 3, 5, 7, */ { 8, 7, 4, 6, 9, 5, 9, 6, 0, 2, 0, 6 }, -/* 225: 0, 5, 6, 7, */ { 8, 7, 4, 3, 0, 11, 9, 11, 0, 11, 9, 10 }, -/* 30: 1, 2, 3, 4, */ { 0, 3, 8, 11, 4, 7, 4, 11, 9, 10, 9, 11 }, -/* 86: 1, 2, 4, 6, */ { 4, 5, 9, 7, 8, 6, 0, 6, 8, 6, 0, 2 }, -/* 166: 1, 2, 5, 7, */ { 10, 5, 6, 4, 11, 7, 11, 4, 2, 0, 2, 4 }, -/* 58: 1, 3, 4, 5, */ { 8, 0, 3, 1, 11, 2, 11, 1, 7, 5, 7, 1 }, -/* 154: 1, 3, 4, 7, */ { 0, 3, 8, 1, 9, 2, 4, 2, 9, 2, 4, 6 }, -/* 106: 1, 3, 5, 6, */ { 2, 1, 10, 3, 11, 0, 6, 0, 11, 0, 6, 4 }, -/* 202: 1, 3, 6, 7, */ { 10, 2, 1, 3, 9, 0, 9, 3, 5, 7, 5, 3 }, -/* 210: 1, 4, 6, 7, */ { 9, 4, 5, 0, 1, 8, 10, 8, 1, 8, 10, 11 }, -/* 92: 2, 3, 4, 6, */ { 11, 6, 7, 5, 8, 4, 8, 5, 3, 1, 3, 5 }, -/* 172: 2, 3, 5, 7, */ { 5, 6, 10, 4, 9, 7, 1, 7, 9, 7, 1, 3 }, -/* 180: 2, 4, 5, 7, */ { 10, 5, 6, 1, 2, 9, 11, 9, 2, 9, 11, 8 }, -/* 120: 3, 4, 5, 6, */ { 11, 6, 7, 2, 3, 10, 8, 10, 3, 10, 8, 9 } -}; - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 12.1.2 - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char tiling12_1_2[24][24] = { -/* 135: 0, 1, 2, 7, */ { 7, 3, 11, 3, 7, 8, 9, 8, 7, 6, 9, 7, 9, 6, 10, 2, 10, 6, 11, 2, 6, 2, 11, 3 }, -/* 75: 0, 1, 3, 6, */ { 6, 2, 10, 2, 6, 11, 8, 11, 6, 5, 8, 6, 8, 5, 9, 1, 9, 5, 10, 1, 5, 1, 10, 2 }, -/* 83: 0, 1, 4, 6, */ { 10, 9, 5, 9, 10, 1, 3, 1, 10, 6, 3, 10, 3, 6, 7, 4, 7, 6, 5, 4, 6, 4, 5, 9 }, -/* 163: 0, 1, 5, 7, */ { 7, 8, 11, 3, 11, 8, 11, 3, 1, 11, 1, 6, 5, 6, 1, 6, 5, 4, 6, 4, 7, 8, 7, 4 }, -/* 45: 0, 2, 3, 5, */ { 5, 1, 9, 1, 5, 10, 11, 10, 5, 4, 11, 5, 11, 4, 8, 0, 8, 4, 9, 0, 4, 0, 9, 1 }, -/* 53: 0, 2, 4, 5, */ { 1, 9, 10, 5, 10, 9, 10, 5, 7, 10, 7, 2, 3, 2, 7, 2, 3, 0, 2, 0, 1, 9, 1, 0 }, -/* 149: 0, 2, 4, 7, */ { 10, 11, 2, 11, 10, 6, 4, 6, 10, 1, 4, 10, 4, 1, 0, 3, 0, 1, 2, 3, 1, 3, 2, 11 }, -/* 101: 0, 2, 5, 6, */ { 8, 9, 0, 9, 8, 4, 6, 4, 8, 3, 6, 8, 6, 3, 2, 1, 2, 3, 0, 1, 3, 1, 0, 9 }, -/* 197: 0, 2, 6, 7, */ { 3, 11, 8, 7, 8, 11, 8, 7, 5, 8, 5, 0, 1, 0, 5, 0, 1, 2, 0, 2, 3, 11, 3, 2 }, -/* 89: 0, 3, 4, 6, */ { 6, 11, 10, 2, 10, 11, 10, 2, 0, 10, 0, 5, 4, 5, 0, 5, 4, 7, 5, 7, 6, 11, 6, 7 }, -/* 169: 0, 3, 5, 7, */ { 9, 8, 4, 8, 9, 0, 2, 0, 9, 5, 2, 9, 2, 5, 6, 7, 6, 5, 4, 7, 5, 7, 4, 8 }, -/* 225: 0, 5, 6, 7, */ { 8, 4, 0, 9, 0, 4, 0, 9, 10, 0, 10, 3, 11, 3, 10, 3, 11, 7, 3, 7, 8, 4, 8, 7 }, -/* 30: 1, 2, 3, 4, */ { 4, 0, 8, 0, 4, 9, 10, 9, 4, 7, 10, 4, 10, 7, 11, 3, 11, 7, 8, 3, 7, 3, 8, 0 }, -/* 86: 1, 2, 4, 6, */ { 4, 9, 8, 0, 8, 9, 8, 0, 2, 8, 2, 7, 6, 7, 2, 7, 6, 5, 7, 5, 4, 9, 4, 5 }, -/* 166: 1, 2, 5, 7, */ { 11, 10, 6, 10, 11, 2, 0, 2, 11, 7, 0, 11, 0, 7, 4, 5, 4, 7, 6, 5, 7, 5, 6, 10 }, -/* 58: 1, 3, 4, 5, */ { 11, 8, 3, 8, 11, 7, 5, 7, 11, 2, 5, 11, 5, 2, 1, 0, 1, 2, 3, 0, 2, 0, 3, 8 }, -/* 154: 1, 3, 4, 7, */ { 0, 8, 9, 4, 9, 8, 9, 4, 6, 9, 6, 1, 2, 1, 6, 1, 2, 3, 1, 3, 0, 8, 0, 3 }, -/* 106: 1, 3, 5, 6, */ { 2, 10, 11, 6, 11, 10, 11, 6, 4, 11, 4, 3, 0, 3, 4, 3, 0, 1, 3, 1, 2, 10, 2, 1 }, -/* 202: 1, 3, 6, 7, */ { 9, 10, 1, 10, 9, 5, 7, 5, 9, 0, 7, 9, 7, 0, 3, 2, 3, 0, 1, 2, 0, 2, 1, 10 }, -/* 210: 1, 4, 6, 7, */ { 9, 5, 1, 10, 1, 5, 1, 10, 11, 1, 11, 0, 8, 0, 11, 0, 8, 4, 0, 4, 9, 5, 9, 4 }, -/* 92: 2, 3, 4, 6, */ { 8, 11, 7, 11, 8, 3, 1, 3, 8, 4, 1, 8, 1, 4, 5, 6, 5, 4, 7, 6, 4, 6, 7, 11 }, -/* 172: 2, 3, 5, 7, */ { 5, 10, 9, 1, 9, 10, 9, 1, 3, 9, 3, 4, 7, 4, 3, 4, 7, 6, 4, 6, 5, 10, 5, 6 }, -/* 180: 2, 4, 5, 7, */ { 10, 6, 2, 11, 2, 6, 2, 11, 8, 2, 8, 1, 9, 1, 8, 1, 9, 5, 1, 5, 10, 6, 10, 5 }, -/* 120: 3, 4, 5, 6, */ { 11, 7, 3, 8, 3, 7, 3, 8, 9, 3, 9, 2, 10, 2, 9, 2, 10, 6, 2, 6, 11, 7, 11, 6 } -}; - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 12.2 - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char tiling12_2[24][24] = { -/* 135: 0, 1, 2, 7, */ { 9, 8, 12, 10, 9, 12, 2, 10, 12, 3, 2, 12, 11, 3, 12, 6, 11, 12, 7, 6, 12, 8, 7, 12 }, -/* 75: 0, 1, 3, 6, */ { 8, 11, 12, 9, 8, 12, 1, 9, 12, 2, 1, 12, 10, 2, 12, 5, 10, 12, 6, 5, 12, 11, 6, 12 }, -/* 83: 0, 1, 4, 6, */ { 3, 1, 12, 7, 3, 12, 4, 7, 12, 9, 4, 12, 5, 9, 12, 6, 5, 12, 10, 6, 12, 1, 10, 12 }, -/* 163: 0, 1, 5, 7, */ { 12, 3, 1, 12, 1, 5, 12, 5, 6, 12, 6, 11, 12, 11, 7, 12, 7, 4, 12, 4, 8, 12, 8, 3 }, -/* 45: 0, 2, 3, 5, */ { 11, 10, 12, 8, 11, 12, 0, 8, 12, 1, 0, 12, 9, 1, 12, 4, 9, 12, 5, 4, 12, 10, 5, 12 }, -/* 53: 0, 2, 4, 5, */ { 12, 5, 7, 12, 7, 3, 12, 3, 2, 12, 2, 10, 12, 10, 1, 12, 1, 0, 12, 0, 9, 12, 9, 5 }, -/* 149: 0, 2, 4, 7, */ { 4, 6, 12, 0, 4, 12, 1, 0, 12, 10, 1, 12, 2, 10, 12, 3, 2, 12, 11, 3, 12, 6, 11, 12 }, -/* 101: 0, 2, 5, 6, */ { 6, 4, 12, 2, 6, 12, 3, 2, 12, 8, 3, 12, 0, 8, 12, 1, 0, 12, 9, 1, 12, 4, 9, 12 }, -/* 197: 0, 2, 6, 7, */ { 12, 7, 5, 12, 5, 1, 12, 1, 0, 12, 0, 8, 12, 8, 3, 12, 3, 2, 12, 2, 11, 12, 11, 7 }, -/* 89: 0, 3, 4, 6, */ { 12, 2, 0, 12, 0, 4, 12, 4, 5, 12, 5, 10, 12, 10, 6, 12, 6, 7, 12, 7, 11, 12, 11, 2 }, -/* 169: 0, 3, 5, 7, */ { 2, 0, 12, 6, 2, 12, 7, 6, 12, 8, 7, 12, 4, 8, 12, 5, 4, 12, 9, 5, 12, 0, 9, 12 }, -/* 225: 0, 5, 6, 7, */ { 12, 9, 10, 12, 10, 11, 12, 11, 7, 12, 7, 4, 12, 4, 8, 12, 8, 3, 12, 3, 0, 12, 0, 9 }, -/* 30: 1, 2, 3, 4, */ { 10, 9, 12, 11, 10, 12, 7, 11, 12, 4, 7, 12, 8, 4, 12, 3, 8, 12, 0, 3, 12, 9, 0, 12 }, -/* 86: 1, 2, 4, 6, */ { 12, 0, 2, 12, 2, 6, 12, 6, 7, 12, 7, 8, 12, 8, 4, 12, 4, 5, 12, 5, 9, 12, 9, 0 }, -/* 166: 1, 2, 5, 7, */ { 0, 2, 12, 4, 0, 12, 5, 4, 12, 10, 5, 12, 6, 10, 12, 7, 6, 12, 11, 7, 12, 2, 11, 12 }, -/* 58: 1, 3, 4, 5, */ { 5, 7, 12, 1, 5, 12, 0, 1, 12, 8, 0, 12, 3, 8, 12, 2, 3, 12, 11, 2, 12, 7, 11, 12 }, -/* 154: 1, 3, 4, 7, */ { 12, 4, 6, 12, 6, 2, 12, 2, 3, 12, 3, 8, 12, 8, 0, 12, 0, 1, 12, 1, 9, 12, 9, 4 }, -/* 106: 1, 3, 5, 6, */ { 12, 6, 4, 12, 4, 0, 12, 0, 1, 12, 1, 10, 12, 10, 2, 12, 2, 3, 12, 3, 11, 12, 11, 6 }, -/* 202: 1, 3, 6, 7, */ { 7, 5, 12, 3, 7, 12, 2, 3, 12, 10, 2, 12, 1, 10, 12, 0, 1, 12, 9, 0, 12, 5, 9, 12 }, -/* 210: 1, 4, 6, 7, */ { 12, 10, 11, 12, 11, 8, 12, 8, 0, 12, 0, 1, 12, 1, 9, 12, 9, 4, 12, 4, 5, 12, 5, 10 }, -/* 92: 2, 3, 4, 6, */ { 1, 3, 12, 5, 1, 12, 6, 5, 12, 11, 6, 12, 7, 11, 12, 4, 7, 12, 8, 4, 12, 3, 8, 12 }, -/* 172: 2, 3, 5, 7, */ { 12, 1, 3, 12, 3, 7, 12, 7, 4, 12, 4, 9, 12, 9, 5, 12, 5, 6, 12, 6, 10, 12, 10, 1 }, -/* 180: 2, 4, 5, 7, */ { 12, 11, 8, 12, 8, 9, 12, 9, 1, 12, 1, 2, 12, 2, 10, 12, 10, 5, 12, 5, 6, 12, 6, 11 }, -/* 120: 3, 4, 5, 6, */ { 12, 8, 9, 12, 9, 10, 12, 10, 2, 12, 2, 3, 12, 3, 11, 12, 11, 6, 12, 6, 7, 12, 7, 8 } -}; - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 12.2 inverted - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char tiling12_2_[24][24] = { -/* 135: 0, 1, 2, 7, */ { 12, 2, 11, 12, 11, 7, 12, 7, 6, 12, 6, 10, 12, 10, 9, 12, 9, 8, 12, 8, 3, 12, 3, 2 }, -/* 75: 0, 1, 3, 6, */ { 12, 1, 10, 12, 10, 6, 12, 6, 5, 12, 5, 9, 12, 9, 8, 12, 8, 11, 12, 11, 2, 12, 2, 1 }, -/* 83: 0, 1, 4, 6, */ { 12, 4, 5, 12, 5, 10, 12, 10, 6, 12, 6, 7, 12, 7, 3, 12, 3, 1, 12, 1, 9, 12, 9, 4 }, -/* 163: 0, 1, 5, 7, */ { 7, 6, 12, 8, 7, 12, 4, 8, 12, 5, 4, 12, 1, 5, 12, 3, 1, 12, 11, 3, 12, 6, 11, 12 }, -/* 45: 0, 2, 3, 5, */ { 12, 0, 9, 12, 9, 5, 12, 5, 4, 12, 4, 8, 12, 8, 11, 12, 11, 10, 12, 10, 1, 12, 1, 0 }, -/* 53: 0, 2, 4, 5, */ { 1, 2, 12, 9, 1, 12, 0, 9, 12, 3, 0, 12, 7, 3, 12, 5, 7, 12, 10, 5, 12, 2, 10, 12 }, -/* 149: 0, 2, 4, 7, */ { 12, 1, 2, 12, 2, 11, 12, 11, 3, 12, 3, 0, 12, 0, 4, 12, 4, 6, 12, 6, 10, 12, 10, 1 }, -/* 101: 0, 2, 5, 6, */ { 12, 3, 0, 12, 0, 9, 12, 9, 1, 12, 1, 2, 12, 2, 6, 12, 6, 4, 12, 4, 8, 12, 8, 3 }, -/* 197: 0, 2, 6, 7, */ { 3, 0, 12, 11, 3, 12, 2, 11, 12, 1, 2, 12, 5, 1, 12, 7, 5, 12, 8, 7, 12, 0, 8, 12 }, -/* 89: 0, 3, 4, 6, */ { 6, 5, 12, 11, 6, 12, 7, 11, 12, 4, 7, 12, 0, 4, 12, 2, 0, 12, 10, 2, 12, 5, 10, 12 }, -/* 169: 0, 3, 5, 7, */ { 12, 7, 4, 12, 4, 9, 12, 9, 5, 12, 5, 6, 12, 6, 2, 12, 2, 0, 12, 0, 8, 12, 8, 7 }, -/* 225: 0, 5, 6, 7, */ { 8, 7, 12, 0, 8, 12, 3, 0, 12, 11, 3, 12, 10, 11, 12, 9, 10, 12, 4, 9, 12, 7, 4, 12 }, -/* 30: 1, 2, 3, 4, */ { 12, 7, 8, 12, 8, 0, 12, 0, 3, 12, 3, 11, 12, 11, 10, 12, 10, 9, 12, 9, 4, 12, 4, 7 }, -/* 86: 1, 2, 4, 6, */ { 4, 7, 12, 9, 4, 12, 5, 9, 12, 6, 5, 12, 2, 6, 12, 0, 2, 12, 8, 0, 12, 7, 8, 12 }, -/* 166: 1, 2, 5, 7, */ { 12, 5, 6, 12, 6, 11, 12, 11, 7, 12, 7, 4, 12, 4, 0, 12, 0, 2, 12, 2, 10, 12, 10, 5 }, -/* 58: 1, 3, 4, 5, */ { 12, 0, 3, 12, 3, 11, 12, 11, 2, 12, 2, 1, 12, 1, 5, 12, 5, 7, 12, 7, 8, 12, 8, 0 }, -/* 154: 1, 3, 4, 7, */ { 0, 3, 12, 9, 0, 12, 1, 9, 12, 2, 1, 12, 6, 2, 12, 4, 6, 12, 8, 4, 12, 3, 8, 12 }, -/* 106: 1, 3, 5, 6, */ { 2, 1, 12, 11, 2, 12, 3, 11, 12, 0, 3, 12, 4, 0, 12, 6, 4, 12, 10, 6, 12, 1, 10, 12 }, -/* 202: 1, 3, 6, 7, */ { 12, 2, 1, 12, 1, 9, 12, 9, 0, 12, 0, 3, 12, 3, 7, 12, 7, 5, 12, 5, 10, 12, 10, 2 }, -/* 210: 1, 4, 6, 7, */ { 9, 0, 12, 5, 9, 12, 4, 5, 12, 8, 4, 12, 11, 8, 12, 10, 11, 12, 1, 10, 12, 0, 1, 12 }, -/* 92: 2, 3, 4, 6, */ { 12, 6, 7, 12, 7, 8, 12, 8, 4, 12, 4, 5, 12, 5, 1, 12, 1, 3, 12, 3, 11, 12, 11, 6 }, -/* 172: 2, 3, 5, 7, */ { 5, 4, 12, 10, 5, 12, 6, 10, 12, 7, 6, 12, 3, 7, 12, 1, 3, 12, 9, 1, 12, 4, 9, 12 }, -/* 180: 2, 4, 5, 7, */ { 10, 1, 12, 6, 10, 12, 5, 6, 12, 9, 5, 12, 8, 9, 12, 11, 8, 12, 2, 11, 12, 1, 2, 12 }, -/* 120: 3, 4, 5, 6, */ { 11, 2, 12, 7, 11, 12, 6, 7, 12, 10, 6, 12, 9, 10, 12, 8, 9, 12, 3, 8, 12, 2, 3, 12 } -}; -//_____________________________________________________________________________ - - - -//_____________________________________________________________________________ -/** - * \brief test table for case 13 - * All faces are to be tested - * - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -/* 13: face test */ -static const char test13[2][7] = { -/* 165: 0, 2, 5, 7, */ { 1,2,3,4,5,6,7 }, -/* 90: 1, 3, 4, 6, */ { 2,3,4,1,5,6,7 }, -}; - - - -//_____________________________________________________________________________ -/** - * \brief subconfiguration table for case 13 - * Hard-coded tests for the subconfiguration determination - * - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -/* 13: sub configs */ -static const char subconfig13[64] = { -/* 0: 0,0,0,0,0,0 */ 0, -/* 1: 1,0,0,0,0,0 */ 1, -/* 2: 0,1,0,0,0,0 */ 2, -/* 3: 1,1,0,0,0,0 */ 7, -/* 4: 0,0,1,0,0,0 */ 3, -/* 5: 1,0,1,0,0,0 */ -1, -/* 6: 0,1,1,0,0,0 */ 11, -/* 7: 1,1,1,0,0,0 */ -1, -/* 8: 0,0,0,1,0,0 */ 4, -/* 9: 1,0,0,1,0,0 */ 8, -/* 10: 0,1,0,1,0,0 */ -1, -/* 11: 1,1,0,1,0,0 */ -1, -/* 12: 0,0,1,1,0,0 */ 14, -/* 13: 1,0,1,1,0,0 */ -1, -/* 14: 0,1,1,1,0,0 */ -1, -/* 15: 1,1,1,1,0,0 */ -1, -/* 16: 0,0,0,0,1,0 */ 5, -/* 17: 1,0,0,0,1,0 */ 9, -/* 18: 0,1,0,0,1,0 */ 12, -/* 19: 1,1,0,0,1,0 */ 23, -/* 20: 0,0,1,0,1,0 */ 15, -/* 21: 1,0,1,0,1,0 */ -1, -/* 22: 0,1,1,0,1,0 */ 21, -/* 23: 1,1,1,0,1,0 */ 38, -/* 24: 0,0,0,1,1,0 */ 17, -/* 25: 1,0,0,1,1,0 */ 20, -/* 26: 0,1,0,1,1,0 */ -1, -/* 27: 1,1,0,1,1,0 */ 36, -/* 28: 0,0,1,1,1,0 */ 26, -/* 29: 1,0,1,1,1,0 */ 33, -/* 30: 0,1,1,1,1,0 */ 30, -/* 31: 1,1,1,1,1,0 */ 44, -/* 32: 0,0,0,0,0,1 */ 6, -/* 33: 1,0,0,0,0,1 */ 10, -/* 34: 0,1,0,0,0,1 */ 13, -/* 35: 1,1,0,0,0,1 */ 19, -/* 36: 0,0,1,0,0,1 */ 16, -/* 37: 1,0,1,0,0,1 */ -1, -/* 38: 0,1,1,0,0,1 */ 25, -/* 39: 1,1,1,0,0,1 */ 37, -/* 40: 0,0,0,1,0,1 */ 18, -/* 41: 1,0,0,1,0,1 */ 24, -/* 42: 0,1,0,1,0,1 */ -1, -/* 43: 1,1,0,1,0,1 */ 35, -/* 44: 0,0,1,1,0,1 */ 22, -/* 45: 1,0,1,1,0,1 */ 32, -/* 46: 0,1,1,1,0,1 */ 29, -/* 47: 1,1,1,1,0,1 */ 43, -/* 48: 0,0,0,0,1,1 */ -1, -/* 49: 1,0,0,0,1,1 */ -1, -/* 50: 0,1,0,0,1,1 */ -1, -/* 51: 1,1,0,0,1,1 */ 34, -/* 52: 0,0,1,0,1,1 */ -1, -/* 53: 1,0,1,0,1,1 */ -1, -/* 54: 0,1,1,0,1,1 */ 28, -/* 55: 1,1,1,0,1,1 */ 42, -/* 56: 0,0,0,1,1,1 */ -1, -/* 57: 1,0,0,1,1,1 */ 31, -/* 58: 0,1,0,1,1,1 */ -1, -/* 59: 1,1,0,1,1,1 */ 41, -/* 60: 0,0,1,1,1,1 */ 27, -/* 61: 1,0,1,1,1,1 */ 40, -/* 62: 0,1,1,1,1,1 */ 39, -/* 63: 1,1,1,1,1,1 */ 45, -}; - - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 13.1 - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -/* 13.1 */ -static const char tiling13_1[2][12] = { -/* 165: 0, 2, 5, 7, */ { 11, 7, 6, 1, 2, 10, 8, 3, 0, 9, 5, 4 }, -/* 90: 1, 3, 4, 6, */ { 8, 4, 7, 2, 3, 11, 9, 0, 1, 10, 6, 5 } -}; - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 13.1 inverted - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -/* 13.1 */ -static const char tiling13_1_[2][12] = { -/* 165: 0, 2, 5, 7, */ { 7, 4, 8, 11, 3, 2, 1, 0, 9, 5, 6, 10 }, -/* 90: 1, 3, 4, 6, */ { 6, 7, 11, 10, 2, 1, 0, 3, 8, 4, 5, 9 } -}; - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 13.2 - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -/* 13.2 */ -static const char tiling13_2[2][6][18] = { -/* 165: 0, 2, 5, 7, */ { - /* 1 */ { 1, 2, 10, 11, 7, 6, 3, 4, 8, 4, 3, 5, 0, 5, 3, 5, 0, 9 }, - /* 2 */ { 8, 3, 0, 11, 7, 6, 9, 1, 4, 2, 4, 1, 4, 2, 5, 10, 5, 2 }, - /* 3 */ { 9, 5, 4, 8, 3, 0, 1, 6, 10, 6, 1, 7, 2, 7, 1, 7, 2, 11 }, - /* 4 */ { 9, 5, 4, 1, 2, 10, 11, 3, 6, 0, 6, 3, 6, 0, 7, 8, 7, 0 }, - /* 5 */ { 9, 5, 4, 11, 7, 6, 0, 10, 1, 10, 0, 8, 10, 8, 2, 3, 2, 8 }, - /* 6 */ { 1, 2, 10, 3, 0, 8, 4, 9, 7, 11, 7, 9, 5, 11, 9, 11, 5, 6 } -}, -/* 90: 1, 3, 4, 6, */ { - /* 1 */ { 2, 3, 11, 8, 4, 7, 0, 5, 9, 5, 0, 6, 1, 6, 0, 6, 1, 10 }, - /* 2 */ { 9, 0, 1, 8, 4, 7, 10, 2, 5, 3, 5, 2, 5, 3, 6, 11, 6, 3 }, - /* 3 */ { 6, 5, 10, 9, 0, 1, 2, 7, 11, 7, 2, 4, 3, 4, 2, 4, 3, 8 }, - /* 4 */ { 6, 5, 10, 2, 3, 11, 8, 0, 7, 1, 7, 0, 7, 1, 4, 9, 4, 1 }, - /* 5 */ { 6, 5, 10, 8, 4, 7, 1, 11, 2, 11, 1, 9, 11, 9, 3, 0, 3, 9 }, - /* 6 */ { 2, 3, 11, 0, 1, 9, 5, 10, 4, 8, 4, 10, 6, 8, 10, 8, 6, 7 } -} }; - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 13.2 inverted - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -/* 13.2 */ -static const char tiling13_2_[2][6][18] = { -/* 165: 0, 2, 5, 7, */ { - /* 1 */ { 10, 5, 6, 11, 3, 2, 7, 0, 8, 0, 7, 1, 4, 1, 7, 1, 4, 9 }, - /* 2 */ { 11, 3, 2, 7, 4, 8, 9, 5, 0, 6, 0, 5, 0, 6, 1, 10, 1, 6 }, - /* 3 */ { 1, 0, 9, 7, 4, 8, 5, 2, 10, 2, 5, 3, 6, 3, 5, 3, 6, 11 }, - /* 4 */ { 10, 5, 6, 1, 0, 9, 11, 7, 2, 4, 2, 7, 2, 4, 3, 8, 3, 4 }, - /* 5 */ { 10, 5, 6, 7, 4, 8, 2, 11, 1, 9, 1, 11, 3, 9, 11, 9, 3, 0 }, - /* 6 */ { 11, 3, 2, 9, 1, 0, 4, 10, 5, 10, 4, 8, 10, 8, 6, 7, 6, 8 } -}, -/* 90: 1, 3, 4, 6, */ { - /* 1 */ { 6, 7, 11, 8, 0, 3, 4, 1, 9, 1, 4, 2, 5, 2, 4, 2, 5, 10 }, - /* 2 */ { 8, 0, 3, 4, 5, 9, 10, 6, 1, 7, 1, 6, 1, 7, 2, 11, 2, 7 }, - /* 3 */ { 2, 1, 10, 4, 5, 9, 6, 3, 11, 3, 6, 0, 7, 0, 6, 0, 7, 8 }, - /* 4 */ { 6, 7, 11, 2, 1, 10, 8, 4, 3, 5, 3, 4, 3, 5, 0, 9, 0, 5 }, - /* 5 */ { 6, 7, 11, 4, 5, 9, 3, 8, 2, 10, 2, 8, 0, 10, 8, 10, 0, 1 }, - /* 6 */ { 8, 0, 3, 10, 2, 1, 5, 11, 6, 11, 5, 9, 11, 9, 7, 4, 7, 9 } -} }; - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 13.3 - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -/* 13.3 */ -static const char tiling13_3[2][12][30] = { -/* 165: 0, 2, 5, 7, */ { - /* 1,2 */ { 11, 7, 6, 12, 2, 10, 12, 10, 5, 12, 5, 4, 12, 4, 8, 12, 8, 3, 12, 3, 0, 12, 0, 9, 12, 9, 1, 12, 1, 2 }, - /* 1,4 */ { 1, 2, 10, 9, 5, 12, 0, 9, 12, 3, 0, 12, 11, 3, 12, 6, 11, 12, 7, 6, 12, 8, 7, 12, 4, 8, 12, 5, 4, 12 }, - /* 1,5 */ { 11, 7, 6, 12, 5, 4, 12, 4, 8, 12, 8, 3, 12, 3, 2, 12, 2, 10, 12, 10, 1, 12, 1, 0, 12, 0, 9, 12, 9, 5 }, - /* 1,6 */ { 1, 2, 10, 12, 3, 0, 12, 0, 9, 12, 9, 5, 12, 5, 6, 12, 6, 11, 12, 11, 7, 12, 7, 4, 12, 4, 8, 12, 8, 3 }, - /* 2,3 */ { 8, 3, 0, 11, 7, 12, 2, 11, 12, 1, 2, 12, 9, 1, 12, 4, 9, 12, 5, 4, 12, 10, 5, 12, 6, 10, 12, 7, 6, 12 }, - /* 2,5 */ { 11, 7, 6, 5, 4, 12, 10, 5, 12, 2, 10, 12, 3, 2, 12, 8, 3, 12, 0, 8, 12, 1, 0, 12, 9, 1, 12, 4, 9, 12 }, - /* 2,6 */ { 8, 3, 0, 1, 2, 12, 9, 1, 12, 4, 9, 12, 7, 4, 12, 11, 7, 12, 6, 11, 12, 5, 6, 12, 10, 5, 12, 2, 10, 12 }, - /* 3,4 */ { 9, 5, 4, 12, 0, 8, 12, 8, 7, 12, 7, 6, 12, 6, 10, 12, 10, 1, 12, 1, 2, 12, 2, 11, 12, 11, 3, 12, 3, 0 }, - /* 3,5 */ { 9, 5, 4, 12, 7, 6, 12, 6, 10, 12, 10, 1, 12, 1, 0, 12, 0, 8, 12, 8, 3, 12, 3, 2, 12, 2, 11, 12, 11, 7 }, - /* 3,6 */ { 8, 3, 0, 12, 1, 2, 12, 2, 11, 12, 11, 7, 12, 7, 4, 12, 4, 9, 12, 9, 5, 12, 5, 6, 12, 6, 10, 12, 10, 1 }, - /* 4,5 */ { 9, 5, 4, 7, 6, 12, 8, 7, 12, 0, 8, 12, 1, 0, 12, 10, 1, 12, 2, 10, 12, 3, 2, 12, 11, 3, 12, 6, 11, 12 }, - /* 4,6 */ { 1, 2, 10, 3, 0, 12, 11, 3, 12, 6, 11, 12, 5, 6, 12, 9, 5, 12, 4, 9, 12, 7, 4, 12, 8, 7, 12, 0, 8, 12 } -}, -/* 90: 1, 3, 4, 6, */ { - /* 1,2 */ { 8, 4, 7, 12, 3, 11, 12, 11, 6, 12, 6, 5, 12, 5, 9, 12, 9, 0, 12, 0, 1, 12, 1, 10, 12, 10, 2, 12, 2, 3 }, - /* 1,4 */ { 2, 3, 11, 10, 6, 12, 1, 10, 12, 0, 1, 12, 8, 0, 12, 7, 8, 12, 4, 7, 12, 9, 4, 12, 5, 9, 12, 6, 5, 12 }, - /* 1,5 */ { 8, 4, 7, 12, 6, 5, 12, 5, 9, 12, 9, 0, 12, 0, 3, 12, 3, 11, 12, 11, 2, 12, 2, 1, 12, 1, 10, 12, 10, 6 }, - /* 1,6 */ { 2, 3, 11, 12, 0, 1, 12, 1, 10, 12, 10, 6, 12, 6, 7, 12, 7, 8, 12, 8, 4, 12, 4, 5, 12, 5, 9, 12, 9, 0 }, - /* 2,3 */ { 0, 1, 9, 8, 4, 12, 3, 8, 12, 2, 3, 12, 10, 2, 12, 5, 10, 12, 6, 5, 12, 11, 6, 12, 7, 11, 12, 4, 7, 12 }, - /* 2,5 */ { 8, 4, 7, 6, 5, 12, 11, 6, 12, 3, 11, 12, 0, 3, 12, 9, 0, 12, 1, 9, 12, 2, 1, 12, 10, 2, 12, 5, 10, 12 }, - /* 2,6 */ { 9, 0, 1, 2, 3, 12, 10, 2, 12, 5, 10, 12, 4, 5, 12, 8, 4, 12, 7, 8, 12, 6, 7, 12, 11, 6, 12, 3, 11, 12 }, - /* 3,4 */ { 6, 5, 10, 12, 1, 9, 12, 9, 4, 12, 4, 7, 12, 7, 11, 12, 11, 2, 12, 2, 3, 12, 3, 8, 12, 8, 0, 12, 0, 1 }, - /* 3,5 */ { 6, 5, 10, 12, 4, 7, 12, 7, 11, 12, 11, 2, 12, 2, 1, 12, 1, 9, 12, 9, 0, 12, 0, 3, 12, 3, 8, 12, 8, 4 }, - /* 3,6 */ { 9, 0, 1, 12, 2, 3, 12, 3, 8, 12, 8, 4, 12, 4, 5, 12, 5, 10, 12, 10, 6, 12, 6, 7, 12, 7, 11, 12, 11, 2 }, - /* 4,5 */ { 6, 5, 10, 4, 7, 12, 9, 4, 12, 1, 9, 12, 2, 1, 12, 11, 2, 12, 3, 11, 12, 0, 3, 12, 8, 0, 12, 7, 8, 12 }, - /* 4,6 */ { 2, 3, 11, 0, 1, 12, 8, 0, 12, 7, 8, 12, 6, 7, 12, 10, 6, 12, 5, 10, 12, 4, 5, 12, 9, 4, 12, 1, 9, 12 } -} }; - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 13.3, inverted - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -/* 13.3 */ -static const char tiling13_3_[2][12][30] = { -/* 165: 0, 2, 5, 7, */ { - /* 1,2 */ { 3, 2, 11, 8, 7, 12, 0, 8, 12, 1, 0, 12, 10, 1, 12, 6, 10, 12, 5, 6, 12, 9, 5, 12, 4, 9, 12, 7, 4, 12 }, - /* 1,4 */ { 5, 6, 10, 12, 2, 11, 12, 11, 7, 12, 7, 4, 12, 4, 9, 12, 9, 1, 12, 1, 0, 12, 0, 8, 12, 8, 3, 12, 3, 2 }, - /* 1,5 */ { 10, 5, 6, 12, 7, 4, 12, 4, 9, 12, 9, 1, 12, 1, 2, 12, 2, 11, 12, 11, 3, 12, 3, 0, 12, 0, 8, 12, 8, 7 }, - /* 1,6 */ { 11, 3, 2, 12, 1, 0, 12, 0, 8, 12, 8, 7, 12, 7, 6, 12, 6, 10, 12, 10, 5, 12, 5, 4, 12, 4, 9, 12, 9, 1 }, - /* 2,3 */ { 7, 4, 8, 11, 3, 12, 6, 11, 12, 5, 6, 12, 9, 5, 12, 0, 9, 12, 1, 0, 12, 10, 1, 12, 2, 10, 12, 3, 2, 12 }, - /* 2,5 */ { 7, 4, 8, 5, 6, 12, 9, 5, 12, 0, 9, 12, 3, 0, 12, 11, 3, 12, 2, 11, 12, 1, 2, 12, 10, 1, 12, 6, 10, 12 }, - /* 2,6 */ { 11, 3, 2, 1, 0, 12, 10, 1, 12, 6, 10, 12, 7, 6, 12, 8, 7, 12, 4, 8, 12, 5, 4, 12, 9, 5, 12, 0, 9, 12 }, - /* 3,4 */ { 1, 0, 9, 12, 4, 8, 12, 8, 3, 12, 3, 2, 12, 2, 10, 12, 10, 5, 12, 5, 6, 12, 6, 11, 12, 11, 7, 12, 7, 4 }, - /* 3,5 */ { 7, 4, 8, 12, 5, 6, 12, 6, 11, 12, 11, 3, 12, 3, 0, 12, 0, 9, 12, 9, 1, 12, 1, 2, 12, 2, 10, 12, 10, 5 }, - /* 3,6 */ { 1, 0, 9, 12, 3, 2, 12, 2, 10, 12, 10, 5, 12, 5, 4, 12, 4, 8, 12, 8, 7, 12, 7, 6, 12, 6, 11, 12, 11, 3 }, - /* 4,5 */ { 10, 5, 6, 7, 4, 12, 11, 7, 12, 2, 11, 12, 1, 2, 12, 9, 1, 12, 0, 9, 12, 3, 0, 12, 8, 3, 12, 4, 8, 12 }, - /* 4,6 */ { 9, 1, 0, 3, 2, 12, 8, 3, 12, 4, 8, 12, 5, 4, 12, 10, 5, 12, 6, 10, 12, 7, 6, 12, 11, 7, 12, 2, 11, 12 } -}, -/* 90: 1, 3, 4, 6, */ { - /* 1,2 */ { 0, 3, 8, 9, 4, 12, 1, 9, 12, 2, 1, 12, 11, 2, 12, 7, 11, 12, 6, 7, 12, 10, 6, 12, 5, 10, 12, 4, 5, 12 }, - /* 1,4 */ { 11, 6, 7, 12, 3, 8, 12, 8, 4, 12, 4, 5, 12, 5, 10, 12, 10, 2, 12, 2, 1, 12, 1, 9, 12, 9, 0, 12, 0, 3 }, - /* 1,5 */ { 6, 7, 11, 12, 4, 5, 12, 5, 10, 12, 10, 2, 12, 2, 3, 12, 3, 8, 12, 8, 0, 12, 0, 1, 12, 1, 9, 12, 9, 4 }, - /* 1,6 */ { 8, 0, 3, 12, 2, 1, 12, 1, 9, 12, 9, 4, 12, 4, 7, 12, 7, 11, 12, 11, 6, 12, 6, 5, 12, 5, 10, 12, 10, 2 }, - /* 2,3 */ { 4, 5, 9, 8, 0, 12, 7, 8, 12, 6, 7, 12, 10, 6, 12, 1, 10, 12, 2, 1, 12, 11, 2, 12, 3, 11, 12, 0, 3, 12 }, - /* 2,5 */ { 4, 5, 9, 6, 7, 12, 10, 6, 12, 1, 10, 12, 0, 1, 12, 8, 0, 12, 3, 8, 12, 2, 3, 12, 11, 2, 12, 7, 11, 12 }, - /* 2,6 */ { 8, 0, 3, 2, 1, 12, 11, 2, 12, 7, 11, 12, 4, 7, 12, 9, 4, 12, 5, 9, 12, 6, 5, 12, 10, 6, 12, 1, 10, 12 }, - /* 3,4 */ { 2, 1, 10, 12, 5, 9, 12, 9, 0, 12, 0, 3, 12, 3, 11, 12, 11, 6, 12, 6, 7, 12, 7, 8, 12, 8, 4, 12, 4, 5 }, - /* 3,5 */ { 4, 5, 9, 12, 6, 7, 12, 7, 8, 12, 8, 0, 12, 0, 1, 12, 1, 10, 12, 10, 2, 12, 2, 3, 12, 3, 11, 12, 11, 6 }, - /* 3,6 */ { 2, 1, 10, 12, 0, 3, 12, 3, 11, 12, 11, 6, 12, 6, 5, 12, 5, 9, 12, 9, 4, 12, 4, 7, 12, 7, 8, 12, 8, 0 }, - /* 4,5 */ { 6, 7, 11, 4, 5, 12, 8, 4, 12, 3, 8, 12, 2, 3, 12, 10, 2, 12, 1, 10, 12, 0, 1, 12, 9, 0, 12, 5, 9, 12 }, - /* 4,6 */ { 10, 2, 1, 0, 3, 12, 9, 0, 12, 5, 9, 12, 6, 5, 12, 11, 6, 12, 7, 11, 12, 4, 7, 12, 8, 4, 12, 3, 8, 12 } -} }; - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 13.4 - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -/* 13.4 */ -static const char tiling13_4[2][4][36] = { -/* 165: 0, 2, 5, 7, */ { -/* 1,2,6 */ { 12, 2, 10, 12, 10, 5, 12, 5, 6, 12, 6, 11, 12, 11, 7, 12, 7, 4, 12, 4, 8, 12, 8, 3, 12, 3, 0, 12, 0, 9, 12, 9, 1, 12, 1, 2 }, -/* 1,4,5 */ { 11, 3, 12, 6, 11, 12, 7, 6, 12, 8, 7, 12, 4, 8, 12, 5, 4, 12, 9, 5, 12, 0, 9, 12, 1, 0, 12, 10, 1, 12, 2, 10, 12, 3, 2, 12 }, -/* 2,3,5 */ { 9, 1, 12, 4, 9, 12, 5, 4, 12, 10, 5, 12, 6, 10, 12, 7, 6, 12, 11, 7, 12, 2, 11, 12, 3, 2, 12, 8, 3, 12, 0, 8, 12, 1, 0, 12 }, -/* 3,4,6 */ { 12, 0, 8, 12, 8, 7, 12, 7, 4, 12, 4, 9, 12, 9, 5, 12, 5, 6, 12, 6, 10, 12, 10, 1, 12, 1, 2, 12, 2, 11, 12, 11, 3, 12, 3, 0 } -}, -/* 90: 1, 3, 4, 6, */ { -/* 1,2,6 */ { 12, 3, 11, 12, 11, 6, 12, 6, 7, 12, 7, 8, 12, 8, 4, 12, 4, 5, 12, 5, 9, 12, 9, 0, 12, 0, 1, 12, 1, 10, 12, 10, 2, 12, 2, 3 }, -/* 1,4,5 */ { 8, 0, 12, 7, 8, 12, 4, 7, 12, 9, 4, 12, 5, 9, 12, 6, 5, 12, 10, 6, 12, 1, 10, 12, 2, 1, 12, 11, 2, 12, 3, 11, 12, 0, 3, 12 }, -/* 2,3,5 */ { 10, 2, 12, 5, 10, 12, 6, 5, 12, 11, 6, 12, 7, 11, 12, 4, 7, 12, 8, 4, 12, 3, 8, 12, 0, 3, 12, 9, 0, 12, 1, 9, 12, 2, 1, 12 }, -/* 3,4,6 */ { 12, 1, 9, 12, 9, 4, 12, 4, 5, 12, 5, 10, 12, 10, 6, 12, 6, 7, 12, 7, 11, 12, 11, 2, 12, 2, 3, 12, 3, 8, 12, 8, 0, 12, 0, 1 } -} }; - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 13.5.1 - * The support edge for the interior test is marked as the 1st column. - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -/* 13.5.1 */ -static const char tiling13_5_1[2][4][18] = { -/* 165: 0, 2, 5, 7, */ { -/* 1,2,5 */ { 7, 6, 11, 1, 0, 9, 10, 3, 2, 3, 10, 5, 3, 5, 8, 4, 8, 5 }, -/* 1,4,6 */ { 1, 2, 10, 7, 4, 8, 3, 0, 11, 6, 11, 0, 9, 6, 0, 6, 9, 5 }, -/* 2,3,6 */ { 3, 0, 8, 5, 6, 10, 1, 2, 9, 4, 9, 2, 11, 4, 2, 4, 11, 7 }, -/* 3,4,5 */ { 5, 4, 9, 3, 2, 11, 8, 1, 0, 1, 8, 7, 1, 7, 10, 6, 10, 7 } -}, -/* 90: 1, 3, 4, 6, */ { -/* 1,2,5 */ { 4, 7, 8, 2, 1, 10, 11, 0, 3, 0, 11, 6, 0, 6, 9, 5, 9, 6 }, -/* 1,4,6 */ { 2, 3, 11, 4, 5, 9, 0, 1, 8, 7, 8, 1, 10, 7, 1, 7, 10, 6 }, -/* 2,3,6 */ { 0, 1, 9, 6, 7, 11, 2, 3, 10, 5, 10, 3, 8, 5, 3, 5, 8, 4 }, -/* 3,4,5 */ { 6, 5, 10, 0, 3, 8, 9, 2, 1, 2, 9, 4, 2, 4, 11, 7, 11, 4 } -} }; - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 13.5.2 - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -/* 13.5.2 */ -static const char tiling13_5_2[2][4][30] = { -/* 165: 0, 2, 5, 7, */ { -/* 1,2,5 */ { 1, 0, 9, 7, 4, 8, 7, 8, 3, 7, 3, 11, 2, 11, 3, 11, 2, 10, 11, 10, 6, 5, 6, 10, 6, 5, 7, 4, 7, 5 }, -/* 1,4,6 */ { 7, 4, 8, 11, 3, 2, 6, 11, 2, 10, 6, 2, 6, 10, 5, 9, 5, 10, 1, 9, 10, 9, 1, 0, 2, 0, 1, 0, 2, 3 }, -/* 2,3,6 */ { 5, 6, 10, 9, 1, 0, 4, 9, 0, 8, 4, 0, 4, 8, 7, 11, 7, 8, 3, 11, 8, 11, 3, 2, 0, 2, 3, 2, 0, 1 }, -/* 3,4,5 */ { 3, 2, 11, 5, 6, 10, 5, 10, 1, 5, 1, 9, 0, 9, 1, 9, 0, 8, 9, 8, 4, 4, 8, 7, 4, 7, 5, 6, 5, 7 } -}, -/* 90: 1, 3, 4, 6, */ { -/* 1,2,5 */ { 2, 1, 10, 4, 5, 9, 4, 9, 0, 4, 0, 8, 3, 8, 0, 8, 3, 11, 8, 11, 7, 6, 7, 11, 7, 6, 4, 5, 4, 6 }, -/* 1,4,6 */ { 4, 5, 9, 8, 0, 3, 7, 8, 3, 11, 7, 3, 7, 11, 6, 10, 6, 11, 2, 10, 11, 10, 2, 1, 3, 1, 2, 1, 3, 0 }, -/* 2,3,6 */ { 6, 7, 11, 10, 2, 1, 5, 10, 1, 9, 5, 1, 5, 9, 4, 8, 4, 9, 0, 8, 9, 8, 0, 3, 1, 3, 0, 3, 1, 2 }, -/* 3,4,5 */ { 0, 3, 8, 6, 7, 11, 6, 11, 2, 6, 2, 10, 1, 10, 2, 10, 1, 9, 10, 9, 5, 5, 9, 4, 5, 4, 6, 7, 6, 4 } -} }; -//_____________________________________________________________________________ - - - -//_____________________________________________________________________________ -/** - * \brief tiling table for case 14 - * For each of the case above, the specific triangulation of the edge - * intersection points is given. - * When a case is ambiguous, there is an auxiliary table that contains - * the face number to test and the tiling table contains the specific - * triangulations depending on the results - * A minus sign means to invert the result of the test. - */ -//----------------------------------------------------------------------------- -static const char tiling14[12][12] = { -/* 71: 0, 1, 2, 6, */ { 5, 9, 8, 5, 8, 2, 5, 2, 6, 3, 2, 8 }, -/* 43: 0, 1, 3, 5, */ { 2, 1, 5, 2, 5, 8, 2, 8, 11, 4, 8, 5 }, -/* 147: 0, 1, 4, 7, */ { 9, 4, 6, 9, 6, 3, 9, 3, 1, 11, 3, 6 }, -/* 29: 0, 2, 3, 4, */ { 1, 11, 10, 1, 4, 11, 1, 0, 4, 7, 11, 4 }, -/* 201: 0, 3, 6, 7, */ { 8, 2, 0, 8, 5, 2, 8, 7, 5, 10, 2, 5 }, -/* 113: 0, 4, 5, 6, */ { 0, 7, 3, 0, 10, 7, 0, 9, 10, 6, 7, 10 }, -/* 142: 1, 2, 3, 7, */ { 0, 3, 7, 0, 7, 10, 0, 10, 9, 6, 10, 7 }, -/* 54: 1, 2, 4, 5, */ { 8, 0, 2, 8, 2, 5, 8, 5, 7, 10, 5, 2 }, -/* 226: 1, 5, 6, 7, */ { 1, 10, 11, 1, 11, 4, 1, 4, 0, 7, 4, 11 }, -/* 108: 2, 3, 5, 6, */ { 9, 6, 4, 9, 3, 6, 9, 1, 3, 11, 6, 3 }, -/* 212: 2, 4, 6, 7, */ { 2, 5, 1, 2, 8, 5, 2, 11, 8, 4, 5, 8 }, -/* 184: 3, 4, 5, 7, */ { 5, 8, 9, 5, 2, 8, 5, 6, 2, 3, 8, 2 } -}; -//_____________________________________________________________________________ - - - -//_____________________________________________________________________________ -/** - * \brief original Marching Cubes implementation - * For each of the possible vertex states listed in this table there is a - * specific triangulation of the edge intersection points. The table lists - * all of them in the form of 0-5 edge triples with the list terminated by - * the invalid value -1. For example: casesClassic[3] list the 2 triangles - * formed when cube[0] and cube[1] are inside of the surface, but the rest of - * the cube is not. - */ -//----------------------------------------------------------------------------- -static const char casesClassic[256][16] = { -/* 0: */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 1: 0, */ { 0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 2: 1, */ { 0, 1, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 3: 0, 1, */ { 1, 8, 3, 9, 8, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 4: 2, */ { 1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 5: 0, 2, */ { 0, 8, 3, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 6: 1, 2, */ { 9, 2, 10, 0, 2, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 7: 0, 1, 2, */ { 2, 8, 3, 2, 10, 8, 10, 9, 8, -1, -1, -1, -1, -1, -1, -1 }, -/* 8: 3, */ { 3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 9: 0, 3, */ { 0, 11, 2, 8, 11, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 10: 1, 3, */ { 1, 9, 0, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 11: 0, 1, 3, */ { 1, 11, 2, 1, 9, 11, 9, 8, 11, -1, -1, -1, -1, -1, -1, -1 }, -/* 12: 2, 3, */ { 3, 10, 1, 11, 10, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 13: 0, 2, 3, */ { 0, 10, 1, 0, 8, 10, 8, 11, 10, -1, -1, -1, -1, -1, -1, -1 }, -/* 14: 1, 2, 3, */ { 3, 9, 0, 3, 11, 9, 11, 10, 9, -1, -1, -1, -1, -1, -1, -1 }, -/* 15: 0, 1, 2, 3, */ { 9, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 16: 4, */ { 4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 17: 0, 4, */ { 4, 3, 0, 7, 3, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 18: 1, 4, */ { 0, 1, 9, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 19: 0, 1, 4, */ { 4, 1, 9, 4, 7, 1, 7, 3, 1, -1, -1, -1, -1, -1, -1, -1 }, -/* 20: 2, 4, */ { 1, 2, 10, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 21: 0, 2, 4, */ { 3, 4, 7, 3, 0, 4, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1 }, -/* 22: 1, 2, 4, */ { 9, 2, 10, 9, 0, 2, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1 }, -/* 23: 0, 1, 2, 4, */ { 2, 10, 9, 2, 9, 7, 2, 7, 3, 7, 9, 4, -1, -1, -1, -1 }, -/* 24: 3, 4, */ { 8, 4, 7, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 25: 0, 3, 4, */ { 11, 4, 7, 11, 2, 4, 2, 0, 4, -1, -1, -1, -1, -1, -1, -1 }, -/* 26: 1, 3, 4, */ { 9, 0, 1, 8, 4, 7, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1 }, -/* 27: 0, 1, 3, 4, */ { 4, 7, 11, 9, 4, 11, 9, 11, 2, 9, 2, 1, -1, -1, -1, -1 }, -/* 28: 2, 3, 4, */ { 3, 10, 1, 3, 11, 10, 7, 8, 4, -1, -1, -1, -1, -1, -1, -1 }, -/* 29: 0, 2, 3, 4, */ { 1, 11, 10, 1, 4, 11, 1, 0, 4, 7, 11, 4, -1, -1, -1, -1 }, -/* 30: 1, 2, 3, 4, */ { 4, 7, 8, 9, 0, 11, 9, 11, 10, 11, 0, 3, -1, -1, -1, -1 }, -/* 31: 0, 1, 2, 3, 4, */ { 4, 7, 11, 4, 11, 9, 9, 11, 10, -1, -1, -1, -1, -1, -1, -1 }, -/* 32: 5, */ { 9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 33: 0, 5, */ { 9, 5, 4, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 34: 1, 5, */ { 0, 5, 4, 1, 5, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 35: 0, 1, 5, */ { 8, 5, 4, 8, 3, 5, 3, 1, 5, -1, -1, -1, -1, -1, -1, -1 }, -/* 36: 2, 5, */ { 1, 2, 10, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 37: 0, 2, 5, */ { 3, 0, 8, 1, 2, 10, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1 }, -/* 38: 1, 2, 5, */ { 5, 2, 10, 5, 4, 2, 4, 0, 2, -1, -1, -1, -1, -1, -1, -1 }, -/* 39: 0, 1, 2, 5, */ { 2, 10, 5, 3, 2, 5, 3, 5, 4, 3, 4, 8, -1, -1, -1, -1 }, -/* 40: 3, 5, */ { 9, 5, 4, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 41: 0, 3, 5, */ { 0, 11, 2, 0, 8, 11, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1 }, -/* 42: 1, 3, 5, */ { 0, 5, 4, 0, 1, 5, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1 }, -/* 43: 0, 1, 3, 5, */ { 2, 1, 5, 2, 5, 8, 2, 8, 11, 4, 8, 5, -1, -1, -1, -1 }, -/* 44: 2, 3, 5, */ { 10, 3, 11, 10, 1, 3, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1 }, -/* 45: 0, 2, 3, 5, */ { 4, 9, 5, 0, 8, 1, 8, 10, 1, 8, 11, 10, -1, -1, -1, -1 }, -/* 46: 1, 2, 3, 5, */ { 5, 4, 0, 5, 0, 11, 5, 11, 10, 11, 0, 3, -1, -1, -1, -1 }, -/* 47: 0, 1, 2, 3, 5, */ { 5, 4, 8, 5, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1 }, -/* 48: 4, 5, */ { 9, 7, 8, 5, 7, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 49: 0, 4, 5, */ { 9, 3, 0, 9, 5, 3, 5, 7, 3, -1, -1, -1, -1, -1, -1, -1 }, -/* 50: 1, 4, 5, */ { 0, 7, 8, 0, 1, 7, 1, 5, 7, -1, -1, -1, -1, -1, -1, -1 }, -/* 51: 0, 1, 4, 5, */ { 1, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 52: 2, 4, 5, */ { 9, 7, 8, 9, 5, 7, 10, 1, 2, -1, -1, -1, -1, -1, -1, -1 }, -/* 53: 0, 2, 4, 5, */ { 10, 1, 2, 9, 5, 0, 5, 3, 0, 5, 7, 3, -1, -1, -1, -1 }, -/* 54: 1, 2, 4, 5, */ { 8, 0, 2, 8, 2, 5, 8, 5, 7, 10, 5, 2, -1, -1, -1, -1 }, -/* 55: 0, 1, 2, 4, 5, */ { 2, 10, 5, 2, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1 }, -/* 56: 3, 4, 5, */ { 7, 9, 5, 7, 8, 9, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1 }, -/* 57: 0, 3, 4, 5, */ { 9, 5, 7, 9, 7, 2, 9, 2, 0, 2, 7, 11, -1, -1, -1, -1 }, -/* 58: 1, 3, 4, 5, */ { 2, 3, 11, 0, 1, 8, 1, 7, 8, 1, 5, 7, -1, -1, -1, -1 }, -/* 59: 0, 1, 3, 4, 5, */ { 11, 2, 1, 11, 1, 7, 7, 1, 5, -1, -1, -1, -1, -1, -1, -1 }, -/* 60: 2, 3, 4, 5, */ { 9, 5, 8, 8, 5, 7, 10, 1, 3, 10, 3, 11, -1, -1, -1, -1 }, -/* 61: 0, 2, 3, 4, 5, */ { 5, 7, 0, 5, 0, 9, 7, 11, 0, 1, 0, 10, 11, 10, 0, -1 }, -/* 62: 1, 2, 3, 4, 5, */ { 11, 10, 0, 11, 0, 3, 10, 5, 0, 8, 0, 7, 5, 7, 0, -1 }, -/* 63: 0, 1, 2, 3, 4, 5, */ { 11, 10, 5, 7, 11, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 64: 6, */ { 10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 65: 0, 6, */ { 0, 8, 3, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 66: 1, 6, */ { 9, 0, 1, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 67: 0, 1, 6, */ { 1, 8, 3, 1, 9, 8, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1 }, -/* 68: 2, 6, */ { 1, 6, 5, 2, 6, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 69: 0, 2, 6, */ { 1, 6, 5, 1, 2, 6, 3, 0, 8, -1, -1, -1, -1, -1, -1, -1 }, -/* 70: 1, 2, 6, */ { 9, 6, 5, 9, 0, 6, 0, 2, 6, -1, -1, -1, -1, -1, -1, -1 }, -/* 71: 0, 1, 2, 6, */ { 5, 9, 8, 5, 8, 2, 5, 2, 6, 3, 2, 8, -1, -1, -1, -1 }, -/* 72: 3, 6, */ { 2, 3, 11, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 73: 0, 3, 6, */ { 11, 0, 8, 11, 2, 0, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1 }, -/* 74: 1, 3, 6, */ { 0, 1, 9, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1 }, -/* 75: 0, 1, 3, 6, */ { 5, 10, 6, 1, 9, 2, 9, 11, 2, 9, 8, 11, -1, -1, -1, -1 }, -/* 76: 2, 3, 6, */ { 6, 3, 11, 6, 5, 3, 5, 1, 3, -1, -1, -1, -1, -1, -1, -1 }, -/* 77: 0, 2, 3, 6, */ { 0, 8, 11, 0, 11, 5, 0, 5, 1, 5, 11, 6, -1, -1, -1, -1 }, -/* 78: 1, 2, 3, 6, */ { 3, 11, 6, 0, 3, 6, 0, 6, 5, 0, 5, 9, -1, -1, -1, -1 }, -/* 79: 0, 1, 2, 3, 6, */ { 6, 5, 9, 6, 9, 11, 11, 9, 8, -1, -1, -1, -1, -1, -1, -1 }, -/* 80: 4, 6, */ { 5, 10, 6, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 81: 0, 4, 6, */ { 4, 3, 0, 4, 7, 3, 6, 5, 10, -1, -1, -1, -1, -1, -1, -1 }, -/* 82: 1, 4, 6, */ { 1, 9, 0, 5, 10, 6, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1 }, -/* 83: 0, 1, 4, 6, */ { 10, 6, 5, 1, 9, 7, 1, 7, 3, 7, 9, 4, -1, -1, -1, -1 }, -/* 84: 2, 4, 6, */ { 6, 1, 2, 6, 5, 1, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1 }, -/* 85: 0, 2, 4, 6, */ { 1, 2, 5, 5, 2, 6, 3, 0, 4, 3, 4, 7, -1, -1, -1, -1 }, -/* 86: 1, 2, 4, 6, */ { 8, 4, 7, 9, 0, 5, 0, 6, 5, 0, 2, 6, -1, -1, -1, -1 }, -/* 87: 0, 1, 2, 4, 6, */ { 7, 3, 9, 7, 9, 4, 3, 2, 9, 5, 9, 6, 2, 6, 9, -1 }, -/* 88: 3, 4, 6, */ { 3, 11, 2, 7, 8, 4, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1 }, -/* 89: 0, 3, 4, 6, */ { 5, 10, 6, 4, 7, 2, 4, 2, 0, 2, 7, 11, -1, -1, -1, -1 }, -/* 90: 1, 3, 4, 6, */ { 0, 1, 9, 4, 7, 8, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1 }, -/* 91: 0, 1, 3, 4, 6, */ { 9, 2, 1, 9, 11, 2, 9, 4, 11, 7, 11, 4, 5, 10, 6, -1 }, -/* 92: 2, 3, 4, 6, */ { 8, 4, 7, 3, 11, 5, 3, 5, 1, 5, 11, 6, -1, -1, -1, -1 }, -/* 93: 0, 2, 3, 4, 6, */ { 5, 1, 11, 5, 11, 6, 1, 0, 11, 7, 11, 4, 0, 4, 11, -1 }, -/* 94: 1, 2, 3, 4, 6, */ { 0, 5, 9, 0, 6, 5, 0, 3, 6, 11, 6, 3, 8, 4, 7, -1 }, -/* 95: 0, 1, 2, 3, 4, 6, */ { 6, 5, 9, 6, 9, 11, 4, 7, 9, 7, 11, 9, -1, -1, -1, -1 }, -/* 96: 5, 6, */ { 10, 4, 9, 6, 4, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 97: 0, 5, 6, */ { 4, 10, 6, 4, 9, 10, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1 }, -/* 98: 1, 5, 6, */ { 10, 0, 1, 10, 6, 0, 6, 4, 0, -1, -1, -1, -1, -1, -1, -1 }, -/* 99: 0, 1, 5, 6, */ { 8, 3, 1, 8, 1, 6, 8, 6, 4, 6, 1, 10, -1, -1, -1, -1 }, -/* 100: 2, 5, 6, */ { 1, 4, 9, 1, 2, 4, 2, 6, 4, -1, -1, -1, -1, -1, -1, -1 }, -/* 101: 0, 2, 5, 6, */ { 3, 0, 8, 1, 2, 9, 2, 4, 9, 2, 6, 4, -1, -1, -1, -1 }, -/* 102: 1, 2, 5, 6, */ { 0, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 103: 0, 1, 2, 5, 6, */ { 8, 3, 2, 8, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1 }, -/* 104: 3, 5, 6, */ { 10, 4, 9, 10, 6, 4, 11, 2, 3, -1, -1, -1, -1, -1, -1, -1 }, -/* 105: 0, 3, 5, 6, */ { 0, 8, 2, 2, 8, 11, 4, 9, 10, 4, 10, 6, -1, -1, -1, -1 }, -/* 106: 1, 3, 5, 6, */ { 3, 11, 2, 0, 1, 6, 0, 6, 4, 6, 1, 10, -1, -1, -1, -1 }, -/* 107: 0, 1, 3, 5, 6, */ { 6, 4, 1, 6, 1, 10, 4, 8, 1, 2, 1, 11, 8, 11, 1, -1 }, -/* 108: 2, 3, 5, 6, */ { 9, 6, 4, 9, 3, 6, 9, 1, 3, 11, 6, 3, -1, -1, -1, -1 }, -/* 109: 0, 2, 3, 5, 6, */ { 8, 11, 1, 8, 1, 0, 11, 6, 1, 9, 1, 4, 6, 4, 1, -1 }, -/* 110: 1, 2, 3, 5, 6, */ { 3, 11, 6, 3, 6, 0, 0, 6, 4, -1, -1, -1, -1, -1, -1, -1 }, -/* 111: 0, 1, 2, 3, 5, 6, */ { 6, 4, 8, 11, 6, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 112: 4, 5, 6, */ { 7, 10, 6, 7, 8, 10, 8, 9, 10, -1, -1, -1, -1, -1, -1, -1 }, -/* 113: 0, 4, 5, 6, */ { 0, 7, 3, 0, 10, 7, 0, 9, 10, 6, 7, 10, -1, -1, -1, -1 }, -/* 114: 1, 4, 5, 6, */ { 10, 6, 7, 1, 10, 7, 1, 7, 8, 1, 8, 0, -1, -1, -1, -1 }, -/* 115: 0, 1, 4, 5, 6, */ { 10, 6, 7, 10, 7, 1, 1, 7, 3, -1, -1, -1, -1, -1, -1, -1 }, -/* 116: 2, 4, 5, 6, */ { 1, 2, 6, 1, 6, 8, 1, 8, 9, 8, 6, 7, -1, -1, -1, -1 }, -/* 117: 0, 2, 4, 5, 6, */ { 2, 6, 9, 2, 9, 1, 6, 7, 9, 0, 9, 3, 7, 3, 9, -1 }, -/* 118: 1, 2, 4, 5, 6, */ { 7, 8, 0, 7, 0, 6, 6, 0, 2, -1, -1, -1, -1, -1, -1, -1 }, -/* 119: 0, 1, 2, 4, 5, 6, */ { 7, 3, 2, 6, 7, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 120: 3, 4, 5, 6, */ { 2, 3, 11, 10, 6, 8, 10, 8, 9, 8, 6, 7, -1, -1, -1, -1 }, -/* 121: 0, 3, 4, 5, 6, */ { 2, 0, 7, 2, 7, 11, 0, 9, 7, 6, 7, 10, 9, 10, 7, -1 }, -/* 122: 1, 3, 4, 5, 6, */ { 1, 8, 0, 1, 7, 8, 1, 10, 7, 6, 7, 10, 2, 3, 11, -1 }, -/* 123: 0, 1, 3, 4, 5, 6, */ { 11, 2, 1, 11, 1, 7, 10, 6, 1, 6, 7, 1, -1, -1, -1, -1 }, -/* 124: 2, 3, 4, 5, 6, */ { 8, 9, 6, 8, 6, 7, 9, 1, 6, 11, 6, 3, 1, 3, 6, -1 }, -/* 125: 0, 2, 3, 4, 5, 6, */ { 0, 9, 1, 11, 6, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 126: 1, 2, 3, 4, 5, 6, */ { 7, 8, 0, 7, 0, 6, 3, 11, 0, 11, 6, 0, -1, -1, -1, -1 }, -/* 127: 0, 1, 2, 3, 4, 5, 6, */ { 7, 11, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 128: 7, */ { 7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 129: 0, 7, */ { 3, 0, 8, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 130: 1, 7, */ { 0, 1, 9, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 131: 0, 1, 7, */ { 8, 1, 9, 8, 3, 1, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1 }, -/* 132: 2, 7, */ { 10, 1, 2, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 133: 0, 2, 7, */ { 1, 2, 10, 3, 0, 8, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1 }, -/* 134: 1, 2, 7, */ { 2, 9, 0, 2, 10, 9, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1 }, -/* 135: 0, 1, 2, 7, */ { 6, 11, 7, 2, 10, 3, 10, 8, 3, 10, 9, 8, -1, -1, -1, -1 }, -/* 136: 3, 7, */ { 7, 2, 3, 6, 2, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 137: 0, 3, 7, */ { 7, 0, 8, 7, 6, 0, 6, 2, 0, -1, -1, -1, -1, -1, -1, -1 }, -/* 138: 1, 3, 7, */ { 2, 7, 6, 2, 3, 7, 0, 1, 9, -1, -1, -1, -1, -1, -1, -1 }, -/* 139: 0, 1, 3, 7, */ { 1, 6, 2, 1, 8, 6, 1, 9, 8, 8, 7, 6, -1, -1, -1, -1 }, -/* 140: 2, 3, 7, */ { 10, 7, 6, 10, 1, 7, 1, 3, 7, -1, -1, -1, -1, -1, -1, -1 }, -/* 141: 0, 2, 3, 7, */ { 10, 7, 6, 1, 7, 10, 1, 8, 7, 1, 0, 8, -1, -1, -1, -1 }, -/* 142: 1, 2, 3, 7, */ { 0, 3, 7, 0, 7, 10, 0, 10, 9, 6, 10, 7, -1, -1, -1, -1 }, -/* 143: 0, 1, 2, 3, 7, */ { 7, 6, 10, 7, 10, 8, 8, 10, 9, -1, -1, -1, -1, -1, -1, -1 }, -/* 144: 4, 7, */ { 6, 8, 4, 11, 8, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 145: 0, 4, 7, */ { 3, 6, 11, 3, 0, 6, 0, 4, 6, -1, -1, -1, -1, -1, -1, -1 }, -/* 146: 1, 4, 7, */ { 8, 6, 11, 8, 4, 6, 9, 0, 1, -1, -1, -1, -1, -1, -1, -1 }, -/* 147: 0, 1, 4, 7, */ { 9, 4, 6, 9, 6, 3, 9, 3, 1, 11, 3, 6, -1, -1, -1, -1 }, -/* 148: 2, 4, 7, */ { 6, 8, 4, 6, 11, 8, 2, 10, 1, -1, -1, -1, -1, -1, -1, -1 }, -/* 149: 0, 2, 4, 7, */ { 1, 2, 10, 3, 0, 11, 0, 6, 11, 0, 4, 6, -1, -1, -1, -1 }, -/* 150: 1, 2, 4, 7, */ { 4, 11, 8, 4, 6, 11, 0, 2, 9, 2, 10, 9, -1, -1, -1, -1 }, -/* 151: 0, 1, 2, 4, 7, */ { 10, 9, 3, 10, 3, 2, 9, 4, 3, 11, 3, 6, 4, 6, 3, -1 }, -/* 152: 3, 4, 7, */ { 8, 2, 3, 8, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1 }, -/* 153: 0, 3, 4, 7, */ { 0, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 154: 1, 3, 4, 7, */ { 1, 9, 0, 2, 3, 4, 2, 4, 6, 4, 3, 8, -1, -1, -1, -1 }, -/* 155: 0, 1, 3, 4, 7, */ { 1, 9, 4, 1, 4, 2, 2, 4, 6, -1, -1, -1, -1, -1, -1, -1 }, -/* 156: 2, 3, 4, 7, */ { 8, 1, 3, 8, 6, 1, 8, 4, 6, 6, 10, 1, -1, -1, -1, -1 }, -/* 157: 0, 2, 3, 4, 7, */ { 10, 1, 0, 10, 0, 6, 6, 0, 4, -1, -1, -1, -1, -1, -1, -1 }, -/* 158: 1, 2, 3, 4, 7, */ { 4, 6, 3, 4, 3, 8, 6, 10, 3, 0, 3, 9, 10, 9, 3, -1 }, -/* 159: 0, 1, 2, 3, 4, 7, */ { 10, 9, 4, 6, 10, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 160: 5, 7, */ { 4, 9, 5, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 161: 0, 5, 7, */ { 0, 8, 3, 4, 9, 5, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1 }, -/* 162: 1, 5, 7, */ { 5, 0, 1, 5, 4, 0, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1 }, -/* 163: 0, 1, 5, 7, */ { 11, 7, 6, 8, 3, 4, 3, 5, 4, 3, 1, 5, -1, -1, -1, -1 }, -/* 164: 2, 5, 7, */ { 9, 5, 4, 10, 1, 2, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1 }, -/* 165: 0, 2, 5, 7, */ { 6, 11, 7, 1, 2, 10, 0, 8, 3, 4, 9, 5, -1, -1, -1, -1 }, -/* 166: 1, 2, 5, 7, */ { 7, 6, 11, 5, 4, 10, 4, 2, 10, 4, 0, 2, -1, -1, -1, -1 }, -/* 167: 0, 1, 2, 5, 7, */ { 3, 4, 8, 3, 5, 4, 3, 2, 5, 10, 5, 2, 11, 7, 6, -1 }, -/* 168: 3, 5, 7, */ { 7, 2, 3, 7, 6, 2, 5, 4, 9, -1, -1, -1, -1, -1, -1, -1 }, -/* 169: 0, 3, 5, 7, */ { 9, 5, 4, 0, 8, 6, 0, 6, 2, 6, 8, 7, -1, -1, -1, -1 }, -/* 170: 1, 3, 5, 7, */ { 3, 6, 2, 3, 7, 6, 1, 5, 0, 5, 4, 0, -1, -1, -1, -1 }, -/* 171: 0, 1, 3, 5, 7, */ { 6, 2, 8, 6, 8, 7, 2, 1, 8, 4, 8, 5, 1, 5, 8, -1 }, -/* 172: 2, 3, 5, 7, */ { 9, 5, 4, 10, 1, 6, 1, 7, 6, 1, 3, 7, -1, -1, -1, -1 }, -/* 173: 0, 2, 3, 5, 7, */ { 1, 6, 10, 1, 7, 6, 1, 0, 7, 8, 7, 0, 9, 5, 4, -1 }, -/* 174: 1, 2, 3, 5, 7, */ { 4, 0, 10, 4, 10, 5, 0, 3, 10, 6, 10, 7, 3, 7, 10, -1 }, -/* 175: 0, 1, 2, 3, 5, 7, */ { 7, 6, 10, 7, 10, 8, 5, 4, 10, 4, 8, 10, -1, -1, -1, -1 }, -/* 176: 4, 5, 7, */ { 6, 9, 5, 6, 11, 9, 11, 8, 9, -1, -1, -1, -1, -1, -1, -1 }, -/* 177: 0, 4, 5, 7, */ { 3, 6, 11, 0, 6, 3, 0, 5, 6, 0, 9, 5, -1, -1, -1, -1 }, -/* 178: 1, 4, 5, 7, */ { 0, 11, 8, 0, 5, 11, 0, 1, 5, 5, 6, 11, -1, -1, -1, -1 }, -/* 179: 0, 1, 4, 5, 7, */ { 6, 11, 3, 6, 3, 5, 5, 3, 1, -1, -1, -1, -1, -1, -1, -1 }, -/* 180: 2, 4, 5, 7, */ { 1, 2, 10, 9, 5, 11, 9, 11, 8, 11, 5, 6, -1, -1, -1, -1 }, -/* 181: 0, 2, 4, 5, 7, */ { 0, 11, 3, 0, 6, 11, 0, 9, 6, 5, 6, 9, 1, 2, 10, -1 }, -/* 182: 1, 2, 4, 5, 7, */ { 11, 8, 5, 11, 5, 6, 8, 0, 5, 10, 5, 2, 0, 2, 5, -1 }, -/* 183: 0, 1, 2, 4, 5, 7, */ { 6, 11, 3, 6, 3, 5, 2, 10, 3, 10, 5, 3, -1, -1, -1, -1 }, -/* 184: 3, 4, 5, 7, */ { 5, 8, 9, 5, 2, 8, 5, 6, 2, 3, 8, 2, -1, -1, -1, -1 }, -/* 185: 0, 3, 4, 5, 7, */ { 9, 5, 6, 9, 6, 0, 0, 6, 2, -1, -1, -1, -1, -1, -1, -1 }, -/* 186: 1, 3, 4, 5, 7, */ { 1, 5, 8, 1, 8, 0, 5, 6, 8, 3, 8, 2, 6, 2, 8, -1 }, -/* 187: 0, 1, 3, 4, 5, 7, */ { 1, 5, 6, 2, 1, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 188: 2, 3, 4, 5, 7, */ { 1, 3, 6, 1, 6, 10, 3, 8, 6, 5, 6, 9, 8, 9, 6, -1 }, -/* 189: 0, 2, 3, 4, 5, 7, */ { 10, 1, 0, 10, 0, 6, 9, 5, 0, 5, 6, 0, -1, -1, -1, -1 }, -/* 190: 1, 2, 3, 4, 5, 7, */ { 0, 3, 8, 5, 6, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 191: 0, 1, 2, 3, 4, 5, 7, */ { 10, 5, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 192: 6, 7, */ { 11, 5, 10, 7, 5, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 193: 0, 6, 7, */ { 11, 5, 10, 11, 7, 5, 8, 3, 0, -1, -1, -1, -1, -1, -1, -1 }, -/* 194: 1, 6, 7, */ { 5, 11, 7, 5, 10, 11, 1, 9, 0, -1, -1, -1, -1, -1, -1, -1 }, -/* 195: 0, 1, 6, 7, */ { 10, 7, 5, 10, 11, 7, 9, 8, 1, 8, 3, 1, -1, -1, -1, -1 }, -/* 196: 2, 6, 7, */ { 11, 1, 2, 11, 7, 1, 7, 5, 1, -1, -1, -1, -1, -1, -1, -1 }, -/* 197: 0, 2, 6, 7, */ { 0, 8, 3, 1, 2, 7, 1, 7, 5, 7, 2, 11, -1, -1, -1, -1 }, -/* 198: 1, 2, 6, 7, */ { 9, 7, 5, 9, 2, 7, 9, 0, 2, 2, 11, 7, -1, -1, -1, -1 }, -/* 199: 0, 1, 2, 6, 7, */ { 7, 5, 2, 7, 2, 11, 5, 9, 2, 3, 2, 8, 9, 8, 2, -1 }, -/* 200: 3, 6, 7, */ { 2, 5, 10, 2, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1 }, -/* 201: 0, 3, 6, 7, */ { 8, 2, 0, 8, 5, 2, 8, 7, 5, 10, 2, 5, -1, -1, -1, -1 }, -/* 202: 1, 3, 6, 7, */ { 9, 0, 1, 5, 10, 3, 5, 3, 7, 3, 10, 2, -1, -1, -1, -1 }, -/* 203: 0, 1, 3, 6, 7, */ { 9, 8, 2, 9, 2, 1, 8, 7, 2, 10, 2, 5, 7, 5, 2, -1 }, -/* 204: 2, 3, 6, 7, */ { 1, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 205: 0, 2, 3, 6, 7, */ { 0, 8, 7, 0, 7, 1, 1, 7, 5, -1, -1, -1, -1, -1, -1, -1 }, -/* 206: 1, 2, 3, 6, 7, */ { 9, 0, 3, 9, 3, 5, 5, 3, 7, -1, -1, -1, -1, -1, -1, -1 }, -/* 207: 0, 1, 2, 3, 6, 7, */ { 9, 8, 7, 5, 9, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 208: 4, 6, 7, */ { 5, 8, 4, 5, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1 }, -/* 209: 0, 4, 6, 7, */ { 5, 0, 4, 5, 11, 0, 5, 10, 11, 11, 3, 0, -1, -1, -1, -1 }, -/* 210: 1, 4, 6, 7, */ { 0, 1, 9, 8, 4, 10, 8, 10, 11, 10, 4, 5, -1, -1, -1, -1 }, -/* 211: 0, 1, 4, 6, 7, */ { 10, 11, 4, 10, 4, 5, 11, 3, 4, 9, 4, 1, 3, 1, 4, -1 }, -/* 212: 2, 4, 6, 7, */ { 2, 5, 1, 2, 8, 5, 2, 11, 8, 4, 5, 8, -1, -1, -1, -1 }, -/* 213: 0, 2, 4, 6, 7, */ { 0, 4, 11, 0, 11, 3, 4, 5, 11, 2, 11, 1, 5, 1, 11, -1 }, -/* 214: 1, 2, 4, 6, 7, */ { 0, 2, 5, 0, 5, 9, 2, 11, 5, 4, 5, 8, 11, 8, 5, -1 }, -/* 215: 0, 1, 2, 4, 6, 7, */ { 9, 4, 5, 2, 11, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 216: 3, 4, 6, 7, */ { 2, 5, 10, 3, 5, 2, 3, 4, 5, 3, 8, 4, -1, -1, -1, -1 }, -/* 217: 0, 3, 4, 6, 7, */ { 5, 10, 2, 5, 2, 4, 4, 2, 0, -1, -1, -1, -1, -1, -1, -1 }, -/* 218: 1, 3, 4, 6, 7, */ { 3, 10, 2, 3, 5, 10, 3, 8, 5, 4, 5, 8, 0, 1, 9, -1 }, -/* 219: 0, 1, 3, 4, 6, 7, */ { 5, 10, 2, 5, 2, 4, 1, 9, 2, 9, 4, 2, -1, -1, -1, -1 }, -/* 220: 2, 3, 4, 6, 7, */ { 8, 4, 5, 8, 5, 3, 3, 5, 1, -1, -1, -1, -1, -1, -1, -1 }, -/* 221: 0, 2, 3, 4, 6, 7, */ { 0, 4, 5, 1, 0, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 222: 1, 2, 3, 4, 6, 7, */ { 8, 4, 5, 8, 5, 3, 9, 0, 5, 0, 3, 5, -1, -1, -1, -1 }, -/* 223: 0, 1, 2, 3, 4, 6, 7, */ { 9, 4, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 224: 5, 6, 7, */ { 4, 11, 7, 4, 9, 11, 9, 10, 11, -1, -1, -1, -1, -1, -1, -1 }, -/* 225: 0, 5, 6, 7, */ { 0, 8, 3, 4, 9, 7, 9, 11, 7, 9, 10, 11, -1, -1, -1, -1 }, -/* 226: 1, 5, 6, 7, */ { 1, 10, 11, 1, 11, 4, 1, 4, 0, 7, 4, 11, -1, -1, -1, -1 }, -/* 227: 0, 1, 5, 6, 7, */ { 3, 1, 4, 3, 4, 8, 1, 10, 4, 7, 4, 11, 10, 11, 4, -1 }, -/* 228: 2, 5, 6, 7, */ { 4, 11, 7, 9, 11, 4, 9, 2, 11, 9, 1, 2, -1, -1, -1, -1 }, -/* 229: 0, 2, 5, 6, 7, */ { 9, 7, 4, 9, 11, 7, 9, 1, 11, 2, 11, 1, 0, 8, 3, -1 }, -/* 230: 1, 2, 5, 6, 7, */ { 11, 7, 4, 11, 4, 2, 2, 4, 0, -1, -1, -1, -1, -1, -1, -1 }, -/* 231: 0, 1, 2, 5, 6, 7, */ { 11, 7, 4, 11, 4, 2, 8, 3, 4, 3, 2, 4, -1, -1, -1, -1 }, -/* 232: 3, 5, 6, 7, */ { 2, 9, 10, 2, 7, 9, 2, 3, 7, 7, 4, 9, -1, -1, -1, -1 }, -/* 233: 0, 3, 5, 6, 7, */ { 9, 10, 7, 9, 7, 4, 10, 2, 7, 8, 7, 0, 2, 0, 7, -1 }, -/* 234: 1, 3, 5, 6, 7, */ { 3, 7, 10, 3, 10, 2, 7, 4, 10, 1, 10, 0, 4, 0, 10, -1 }, -/* 235: 0, 1, 3, 5, 6, 7, */ { 1, 10, 2, 8, 7, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 236: 2, 3, 5, 6, 7, */ { 4, 9, 1, 4, 1, 7, 7, 1, 3, -1, -1, -1, -1, -1, -1, -1 }, -/* 237: 0, 2, 3, 5, 6, 7, */ { 4, 9, 1, 4, 1, 7, 0, 8, 1, 8, 7, 1, -1, -1, -1, -1 }, -/* 238: 1, 2, 3, 5, 6, 7, */ { 4, 0, 3, 7, 4, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 239: 0, 1, 2, 3, 5, 6, 7, */ { 4, 8, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 240: 4, 5, 6, 7, */ { 9, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 241: 0, 4, 5, 6, 7, */ { 3, 0, 9, 3, 9, 11, 11, 9, 10, -1, -1, -1, -1, -1, -1, -1 }, -/* 242: 1, 4, 5, 6, 7, */ { 0, 1, 10, 0, 10, 8, 8, 10, 11, -1, -1, -1, -1, -1, -1, -1 }, -/* 243: 0, 1, 4, 5, 6, 7, */ { 3, 1, 10, 11, 3, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 244: 2, 4, 5, 6, 7, */ { 1, 2, 11, 1, 11, 9, 9, 11, 8, -1, -1, -1, -1, -1, -1, -1 }, -/* 245: 0, 2, 4, 5, 6, 7, */ { 3, 0, 9, 3, 9, 11, 1, 2, 9, 2, 11, 9, -1, -1, -1, -1 }, -/* 246: 1, 2, 4, 5, 6, 7, */ { 0, 2, 11, 8, 0, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 247: 0, 1, 2, 4, 5, 6, 7, */ { 3, 2, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 248: 3, 4, 5, 6, 7, */ { 2, 3, 8, 2, 8, 10, 10, 8, 9, -1, -1, -1, -1, -1, -1, -1 }, -/* 249: 0, 3, 4, 5, 6, 7, */ { 9, 10, 2, 0, 9, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 250: 1, 3, 4, 5, 6, 7, */ { 2, 3, 8, 2, 8, 10, 0, 1, 8, 1, 10, 8, -1, -1, -1, -1 }, -/* 251: 0, 1, 3, 4, 5, 6, 7, */ { 1, 10, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 252: 2, 3, 4, 5, 6, 7, */ { 1, 3, 8, 9, 1, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 253: 0, 2, 3, 4, 5, 6, 7, */ { 0, 9, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 254: 1, 2, 3, 4, 5, 6, 7, */ { 0, 3, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -/* 255: 0, 1, 2, 3, 4, 5, 6, 7, */ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } -}; -//_____________________________________________________________________________ - - - -#endif // _LOOKUPTABLE_H_ diff --git a/applications/utilities/mesh/generation/cvMesh/cvMeshSurfaceSimplify/MarchingCubes/MarchingCubes.cpp b/applications/utilities/mesh/generation/cvMesh/cvMeshSurfaceSimplify/MarchingCubes/MarchingCubes.cpp deleted file mode 100755 index d9012f0405a2ea63c696e432250891477d75074e..0000000000000000000000000000000000000000 --- a/applications/utilities/mesh/generation/cvMesh/cvMeshSurfaceSimplify/MarchingCubes/MarchingCubes.cpp +++ /dev/null @@ -1,1302 +0,0 @@ -/** - * @file MarchingCubes.cpp - * @author Thomas Lewiner <thomas.lewiner@polytechnique.org> - * @author Math Dept, PUC-Rio - * @version 0.2 - * @date 12/08/2002 - * - * @brief MarchingCubes Algorithm - */ -//________________________________________________ - - -#if !defined(WIN32) || defined(__CYGWIN__) -#pragma implementation -#endif // WIN32 - -#include <math.h> -#include <time.h> -#include <memory.h> -#include <stdlib.h> -#include <float.h> -#include "MarchingCubes.h" -#include "ply.h" -#include "LookUpTable.h" - -// step size of the arrays of vertices and triangles -#define ALLOC_SIZE 65536 - -//_____________________________________________________________________________ -// print cube for debug -void MarchingCubes::print_cube() { printf( "\t%f %f %f %f %f %f %f %f\n", _cube[0], _cube[1], _cube[2], _cube[3], _cube[4], _cube[5], _cube[6], _cube[7]) ; } -//_____________________________________________________________________________ - - - -//_____________________________________________________________________________ -// Constructor -MarchingCubes::MarchingCubes( const int size_x /*= -1*/, const int size_y /*= -1*/, const int size_z /*= -1*/ ) : -//----------------------------------------------------------------------------- - _originalMC(false), - _ext_data (false), - _size_x (size_x), - _size_y (size_y), - _size_z (size_z), - _data ((real *)NULL), - _x_verts (( int *)NULL), - _y_verts (( int *)NULL), - _z_verts (( int *)NULL), - _nverts (0), - _ntrigs (0), - _Nverts (0), - _Ntrigs (0), - _vertices (( Vertex *)NULL), - _triangles ((Triangle*)NULL) -{} -//_____________________________________________________________________________ - - - -//_____________________________________________________________________________ -// Destructor -MarchingCubes::~MarchingCubes() -//----------------------------------------------------------------------------- -{ - clean_all() ; -} -//_____________________________________________________________________________ - - - -//_____________________________________________________________________________ -// main algorithm -void MarchingCubes::run( real iso ) -//----------------------------------------------------------------------------- -{ - clock_t time = clock() ; - - compute_intersection_points( iso ) ; - - for( _k = 0 ; _k < _size_z-1 ; _k++ ) - for( _j = 0 ; _j < _size_y-1 ; _j++ ) - for( _i = 0 ; _i < _size_x-1 ; _i++ ) - { - _lut_entry = 0 ; - for( int p = 0 ; p < 8 ; ++p ) - { - _cube[p] = get_data( _i+((p^(p>>1))&1), _j+((p>>1)&1), _k+((p>>2)&1) ) - iso ; - if( fabs( _cube[p] ) < FLT_EPSILON ) _cube[p] = FLT_EPSILON ; - if( _cube[p] > 0 ) _lut_entry += 1 << p ; - } -/* - if( ( _cube[0] = get_data( _i , _j , _k ) ) > 0 ) _lut_entry += 1 ; - if( ( _cube[1] = get_data(_i+1, _j , _k ) ) > 0 ) _lut_entry += 2 ; - if( ( _cube[2] = get_data(_i+1,_j+1, _k ) ) > 0 ) _lut_entry += 4 ; - if( ( _cube[3] = get_data( _i ,_j+1, _k ) ) > 0 ) _lut_entry += 8 ; - if( ( _cube[4] = get_data( _i , _j ,_k+1) ) > 0 ) _lut_entry += 16 ; - if( ( _cube[5] = get_data(_i+1, _j ,_k+1) ) > 0 ) _lut_entry += 32 ; - if( ( _cube[6] = get_data(_i+1,_j+1,_k+1) ) > 0 ) _lut_entry += 64 ; - if( ( _cube[7] = get_data( _i ,_j+1,_k+1) ) > 0 ) _lut_entry += 128 ; -*/ - process_cube( ) ; - } - - printf("Marching Cubes ran in %lf secs.\n", (double)(clock() - time)/CLOCKS_PER_SEC) ; -} -//_____________________________________________________________________________ - - - -//_____________________________________________________________________________ -// init temporary structures (must set sizes before call) -void MarchingCubes::init_temps() -//----------------------------------------------------------------------------- -{ - if( !_ext_data ) - _data = new real [_size_x * _size_y * _size_z] ; - _x_verts = new int [_size_x * _size_y * _size_z] ; - _y_verts = new int [_size_x * _size_y * _size_z] ; - _z_verts = new int [_size_x * _size_y * _size_z] ; - - memset( _x_verts, -1, _size_x * _size_y * _size_z * sizeof( int ) ) ; - memset( _y_verts, -1, _size_x * _size_y * _size_z * sizeof( int ) ) ; - memset( _z_verts, -1, _size_x * _size_y * _size_z * sizeof( int ) ) ; -} -//_____________________________________________________________________________ - - - -//_____________________________________________________________________________ -// init all structures (must set sizes before call) -void MarchingCubes::init_all () -//----------------------------------------------------------------------------- -{ - init_temps() ; - - _nverts = _ntrigs = 0 ; - _Nverts = _Ntrigs = ALLOC_SIZE ; - _vertices = new Vertex [_Nverts] ; - _triangles = new Triangle[_Ntrigs] ; -} -//_____________________________________________________________________________ - - - -//_____________________________________________________________________________ -// clean temporary structures -void MarchingCubes::clean_temps() -//----------------------------------------------------------------------------- -{ - if( !_ext_data ) - delete [] _data; - delete [] _x_verts; - delete [] _y_verts; - delete [] _z_verts; - - if( !_ext_data ) - _data = (real*)NULL ; - _x_verts = (int*)NULL ; - _y_verts = (int*)NULL ; - _z_verts = (int*)NULL ; -} -//_____________________________________________________________________________ - - - -//_____________________________________________________________________________ -// clean all structures -void MarchingCubes::clean_all() -//----------------------------------------------------------------------------- -{ - clean_temps() ; - delete [] _vertices ; - delete [] _triangles ; - _vertices = (Vertex *)NULL ; - _triangles = (Triangle *)NULL ; - _nverts = _ntrigs = 0 ; - _Nverts = _Ntrigs = 0 ; - - _size_x = _size_y = _size_z = -1 ; -} -//_____________________________________________________________________________ - - - -//_____________________________________________________________________________ -//_____________________________________________________________________________ - - -//_____________________________________________________________________________ -// Compute the intersection points -void MarchingCubes::compute_intersection_points( real iso ) -//----------------------------------------------------------------------------- -{ - for( _k = 0 ; _k < _size_z ; _k++ ) - for( _j = 0 ; _j < _size_y ; _j++ ) - for( _i = 0 ; _i < _size_x ; _i++ ) - { - _cube[0] = get_data( _i, _j, _k ) - iso ; - if( _i < _size_x - 1 ) _cube[1] = get_data(_i+1, _j , _k ) - iso ; - else _cube[1] = _cube[0] ; - - if( _j < _size_y - 1 ) _cube[3] = get_data( _i ,_j+1, _k ) - iso ; - else _cube[3] = _cube[0] ; - - if( _k < _size_z - 1 ) _cube[4] = get_data( _i , _j ,_k+1) - iso ; - else _cube[4] = _cube[0] ; - - if( fabs( _cube[0] ) < FLT_EPSILON ) _cube[0] = FLT_EPSILON ; - if( fabs( _cube[1] ) < FLT_EPSILON ) _cube[1] = FLT_EPSILON ; - if( fabs( _cube[3] ) < FLT_EPSILON ) _cube[3] = FLT_EPSILON ; - if( fabs( _cube[4] ) < FLT_EPSILON ) _cube[4] = FLT_EPSILON ; - - if( _cube[0] < 0 ) - { - if( _cube[1] > 0 ) set_x_vert( add_x_vertex( ), _i,_j,_k ) ; - if( _cube[3] > 0 ) set_y_vert( add_y_vertex( ), _i,_j,_k ) ; - if( _cube[4] > 0 ) set_z_vert( add_z_vertex( ), _i,_j,_k ) ; - } - else - { - if( _cube[1] < 0 ) set_x_vert( add_x_vertex( ), _i,_j,_k ) ; - if( _cube[3] < 0 ) set_y_vert( add_y_vertex( ), _i,_j,_k ) ; - if( _cube[4] < 0 ) set_z_vert( add_z_vertex( ), _i,_j,_k ) ; - } - } -} -//_____________________________________________________________________________ - - - - - -//_____________________________________________________________________________ -// Test a face -// if face>0 return true if the face contains a part of the surface -bool MarchingCubes::test_face( schar face ) -//----------------------------------------------------------------------------- -{ - real A,B,C,D ; - - switch( face ) - { - case -1 : case 1 : A = _cube[0] ; B = _cube[4] ; C = _cube[5] ; D = _cube[1] ; break ; - case -2 : case 2 : A = _cube[1] ; B = _cube[5] ; C = _cube[6] ; D = _cube[2] ; break ; - case -3 : case 3 : A = _cube[2] ; B = _cube[6] ; C = _cube[7] ; D = _cube[3] ; break ; - case -4 : case 4 : A = _cube[3] ; B = _cube[7] ; C = _cube[4] ; D = _cube[0] ; break ; - case -5 : case 5 : A = _cube[0] ; B = _cube[3] ; C = _cube[2] ; D = _cube[1] ; break ; - case -6 : case 6 : A = _cube[4] ; B = _cube[7] ; C = _cube[6] ; D = _cube[5] ; break ; - default : printf( "Invalid face code %d\n", face ) ; print_cube() ; A = B = C = D = 0 ; - }; - - if( fabs( A*C - B*D ) < FLT_EPSILON ) - return face >= 0 ; - return face * A * ( A*C - B*D ) >= 0 ; // face and A invert signs -} -//_____________________________________________________________________________ - - - - - -//_____________________________________________________________________________ -// Test the interior of a cube -// if s == 7, return true if the interior is empty -// if s ==-7, return false if the interior is empty -bool MarchingCubes::test_interior( schar s ) -//----------------------------------------------------------------------------- -{ - real t, At=0, Bt=0, Ct=0, Dt=0, a, b ; - char test = 0 ; - char edge = -1 ; // reference edge of the triangulation - - switch( _case ) - { - case 4 : - case 10 : - a = ( _cube[4] - _cube[0] ) * ( _cube[6] - _cube[2] ) - ( _cube[7] - _cube[3] ) * ( _cube[5] - _cube[1] ) ; - b = _cube[2] * ( _cube[4] - _cube[0] ) + _cube[0] * ( _cube[6] - _cube[2] ) - - _cube[1] * ( _cube[7] - _cube[3] ) - _cube[3] * ( _cube[5] - _cube[1] ) ; - t = - b / (2*a) ; - if( t<0 || t>1 ) return s>0 ; - - At = _cube[0] + ( _cube[4] - _cube[0] ) * t ; - Bt = _cube[3] + ( _cube[7] - _cube[3] ) * t ; - Ct = _cube[2] + ( _cube[6] - _cube[2] ) * t ; - Dt = _cube[1] + ( _cube[5] - _cube[1] ) * t ; - break ; - - case 6 : - case 7 : - case 12 : - case 13 : - switch( _case ) - { - case 6 : edge = test6 [_config][2] ; break ; - case 7 : edge = test7 [_config][4] ; break ; - case 12 : edge = test12[_config][3] ; break ; - case 13 : edge = tiling13_5_1[_config][_subconfig][0] ; break ; - } - switch( edge ) - { - case 0 : - t = _cube[0] / ( _cube[0] - _cube[1] ) ; - At = 0 ; - Bt = _cube[3] + ( _cube[2] - _cube[3] ) * t ; - Ct = _cube[7] + ( _cube[6] - _cube[7] ) * t ; - Dt = _cube[4] + ( _cube[5] - _cube[4] ) * t ; - break ; - case 1 : - t = _cube[1] / ( _cube[1] - _cube[2] ) ; - At = 0 ; - Bt = _cube[0] + ( _cube[3] - _cube[0] ) * t ; - Ct = _cube[4] + ( _cube[7] - _cube[4] ) * t ; - Dt = _cube[5] + ( _cube[6] - _cube[5] ) * t ; - break ; - case 2 : - t = _cube[2] / ( _cube[2] - _cube[3] ) ; - At = 0 ; - Bt = _cube[1] + ( _cube[0] - _cube[1] ) * t ; - Ct = _cube[5] + ( _cube[4] - _cube[5] ) * t ; - Dt = _cube[6] + ( _cube[7] - _cube[6] ) * t ; - break ; - case 3 : - t = _cube[3] / ( _cube[3] - _cube[0] ) ; - At = 0 ; - Bt = _cube[2] + ( _cube[1] - _cube[2] ) * t ; - Ct = _cube[6] + ( _cube[5] - _cube[6] ) * t ; - Dt = _cube[7] + ( _cube[4] - _cube[7] ) * t ; - break ; - case 4 : - t = _cube[4] / ( _cube[4] - _cube[5] ) ; - At = 0 ; - Bt = _cube[7] + ( _cube[6] - _cube[7] ) * t ; - Ct = _cube[3] + ( _cube[2] - _cube[3] ) * t ; - Dt = _cube[0] + ( _cube[1] - _cube[0] ) * t ; - break ; - case 5 : - t = _cube[5] / ( _cube[5] - _cube[6] ) ; - At = 0 ; - Bt = _cube[4] + ( _cube[7] - _cube[4] ) * t ; - Ct = _cube[0] + ( _cube[3] - _cube[0] ) * t ; - Dt = _cube[1] + ( _cube[2] - _cube[1] ) * t ; - break ; - case 6 : - t = _cube[6] / ( _cube[6] - _cube[7] ) ; - At = 0 ; - Bt = _cube[5] + ( _cube[4] - _cube[5] ) * t ; - Ct = _cube[1] + ( _cube[0] - _cube[1] ) * t ; - Dt = _cube[2] + ( _cube[3] - _cube[2] ) * t ; - break ; - case 7 : - t = _cube[7] / ( _cube[7] - _cube[4] ) ; - At = 0 ; - Bt = _cube[6] + ( _cube[5] - _cube[6] ) * t ; - Ct = _cube[2] + ( _cube[1] - _cube[2] ) * t ; - Dt = _cube[3] + ( _cube[0] - _cube[3] ) * t ; - break ; - case 8 : - t = _cube[0] / ( _cube[0] - _cube[4] ) ; - At = 0 ; - Bt = _cube[3] + ( _cube[7] - _cube[3] ) * t ; - Ct = _cube[2] + ( _cube[6] - _cube[2] ) * t ; - Dt = _cube[1] + ( _cube[5] - _cube[1] ) * t ; - break ; - case 9 : - t = _cube[1] / ( _cube[1] - _cube[5] ) ; - At = 0 ; - Bt = _cube[0] + ( _cube[4] - _cube[0] ) * t ; - Ct = _cube[3] + ( _cube[7] - _cube[3] ) * t ; - Dt = _cube[2] + ( _cube[6] - _cube[2] ) * t ; - break ; - case 10 : - t = _cube[2] / ( _cube[2] - _cube[6] ) ; - At = 0 ; - Bt = _cube[1] + ( _cube[5] - _cube[1] ) * t ; - Ct = _cube[0] + ( _cube[4] - _cube[0] ) * t ; - Dt = _cube[3] + ( _cube[7] - _cube[3] ) * t ; - break ; - case 11 : - t = _cube[3] / ( _cube[3] - _cube[7] ) ; - At = 0 ; - Bt = _cube[2] + ( _cube[6] - _cube[2] ) * t ; - Ct = _cube[1] + ( _cube[5] - _cube[1] ) * t ; - Dt = _cube[0] + ( _cube[4] - _cube[0] ) * t ; - break ; - default : printf( "Invalid edge %d\n", edge ) ; print_cube() ; break ; - } - break ; - - default : printf( "Invalid ambiguous case %d\n", _case ) ; print_cube() ; break ; - } - - if( At >= 0 ) test ++ ; - if( Bt >= 0 ) test += 2 ; - if( Ct >= 0 ) test += 4 ; - if( Dt >= 0 ) test += 8 ; - switch( test ) - { - case 0 : return s>0 ; - case 1 : return s>0 ; - case 2 : return s>0 ; - case 3 : return s>0 ; - case 4 : return s>0 ; - case 5 : if( At * Ct - Bt * Dt < FLT_EPSILON ) return s>0 ; break ; - case 6 : return s>0 ; - case 7 : return s<0 ; - case 8 : return s>0 ; - case 9 : return s>0 ; - case 10 : if( At * Ct - Bt * Dt >= FLT_EPSILON ) return s>0 ; break ; - case 11 : return s<0 ; - case 12 : return s>0 ; - case 13 : return s<0 ; - case 14 : return s<0 ; - case 15 : return s<0 ; - } - - return s<0 ; -} -//_____________________________________________________________________________ - - - - -//_____________________________________________________________________________ -// Process a unit cube -void MarchingCubes::process_cube( ) -//----------------------------------------------------------------------------- -{ - if( _originalMC ) - { - char nt = 0 ; - while( casesClassic[_lut_entry][3*nt] != -1 ) nt++ ; - add_triangle( casesClassic[_lut_entry], nt ) ; - return ; - } - - int v12 = -1 ; - _case = cases[_lut_entry][0] ; - _config = cases[_lut_entry][1] ; - _subconfig = 0 ; - - switch( _case ) - { - case 0 : - break ; - - case 1 : - add_triangle( tiling1[_config], 1 ) ; - break ; - - case 2 : - add_triangle( tiling2[_config], 2 ) ; - break ; - - case 3 : - if( test_face( test3[_config]) ) - add_triangle( tiling3_2[_config], 4 ) ; // 3.2 - else - add_triangle( tiling3_1[_config], 2 ) ; // 3.1 - break ; - - case 4 : - if( test_interior( test4[_config]) ) - add_triangle( tiling4_1[_config], 2 ) ; // 4.1.1 - else - add_triangle( tiling4_2[_config], 6 ) ; // 4.1.2 - break ; - - case 5 : - add_triangle( tiling5[_config], 3 ) ; - break ; - - case 6 : - if( test_face( test6[_config][0]) ) - add_triangle( tiling6_2[_config], 5 ) ; // 6.2 - else - { - if( test_interior( test6[_config][1]) ) - add_triangle( tiling6_1_1[_config], 3 ) ; // 6.1.1 - else - { - v12 = add_c_vertex() ; - add_triangle( tiling6_1_2[_config], 9 , v12) ; // 6.1.2 - } - } - break ; - - case 7 : - if( test_face( test7[_config][0] ) ) _subconfig += 1 ; - if( test_face( test7[_config][1] ) ) _subconfig += 2 ; - if( test_face( test7[_config][2] ) ) _subconfig += 4 ; - switch( _subconfig ) - { - case 0 : - add_triangle( tiling7_1[_config], 3 ) ; break ; - case 1 : - add_triangle( tiling7_2[_config][0], 5 ) ; break ; - case 2 : - add_triangle( tiling7_2[_config][1], 5 ) ; break ; - case 3 : - v12 = add_c_vertex() ; - add_triangle( tiling7_3[_config][0], 9, v12 ) ; break ; - case 4 : - add_triangle( tiling7_2[_config][2], 5 ) ; break ; - case 5 : - v12 = add_c_vertex() ; - add_triangle( tiling7_3[_config][1], 9, v12 ) ; break ; - case 6 : - v12 = add_c_vertex() ; - add_triangle( tiling7_3[_config][2], 9, v12 ) ; break ; - case 7 : - if( test_interior( test7[_config][3]) ) - add_triangle( tiling7_4_2[_config], 9 ) ; - else - add_triangle( tiling7_4_1[_config], 5 ) ; - break ; - }; - break ; - - case 8 : - add_triangle( tiling8[_config], 2 ) ; - break ; - - case 9 : - add_triangle( tiling9[_config], 4 ) ; - break ; - - case 10 : - if( test_face( test10[_config][0]) ) - { - if( test_face( test10[_config][1]) ) - add_triangle( tiling10_1_1_[_config], 4 ) ; // 10.1.1 - else - { - v12 = add_c_vertex() ; - add_triangle( tiling10_2[_config], 8, v12 ) ; // 10.2 - } - } - else - { - if( test_face( test10[_config][1]) ) - { - v12 = add_c_vertex() ; - add_triangle( tiling10_2_[_config], 8, v12 ) ; // 10.2 - } - else - { - if( test_interior( test10[_config][2]) ) - add_triangle( tiling10_1_1[_config], 4 ) ; // 10.1.1 - else - add_triangle( tiling10_1_2[_config], 8 ) ; // 10.1.2 - } - } - break ; - - case 11 : - add_triangle( tiling11[_config], 4 ) ; - break ; - - case 12 : - if( test_face( test12[_config][0]) ) - { - if( test_face( test12[_config][1]) ) - add_triangle( tiling12_1_1_[_config], 4 ) ; // 12.1.1 - else - { - v12 = add_c_vertex() ; - add_triangle( tiling12_2[_config], 8, v12 ) ; // 12.2 - } - } - else - { - if( test_face( test12[_config][1]) ) - { - v12 = add_c_vertex() ; - add_triangle( tiling12_2_[_config], 8, v12 ) ; // 12.2 - } - else - { - if( test_interior( test12[_config][2]) ) - add_triangle( tiling12_1_1[_config], 4 ) ; // 12.1.1 - else - add_triangle( tiling12_1_2[_config], 8 ) ; // 12.1.2 - } - } - break ; - - case 13 : - if( test_face( test13[_config][0] ) ) _subconfig += 1 ; - if( test_face( test13[_config][1] ) ) _subconfig += 2 ; - if( test_face( test13[_config][2] ) ) _subconfig += 4 ; - if( test_face( test13[_config][3] ) ) _subconfig += 8 ; - if( test_face( test13[_config][4] ) ) _subconfig += 16 ; - if( test_face( test13[_config][5] ) ) _subconfig += 32 ; - switch( subconfig13[_subconfig] ) - { - case 0 :/* 13.1 */ - add_triangle( tiling13_1[_config], 4 ) ; break ; - - case 1 :/* 13.2 */ - add_triangle( tiling13_2[_config][0], 6 ) ; break ; - case 2 :/* 13.2 */ - add_triangle( tiling13_2[_config][1], 6 ) ; break ; - case 3 :/* 13.2 */ - add_triangle( tiling13_2[_config][2], 6 ) ; break ; - case 4 :/* 13.2 */ - add_triangle( tiling13_2[_config][3], 6 ) ; break ; - case 5 :/* 13.2 */ - add_triangle( tiling13_2[_config][4], 6 ) ; break ; - case 6 :/* 13.2 */ - add_triangle( tiling13_2[_config][5], 6 ) ; break ; - - case 7 :/* 13.3 */ - v12 = add_c_vertex() ; - add_triangle( tiling13_3[_config][0], 10, v12 ) ; break ; - case 8 :/* 13.3 */ - v12 = add_c_vertex() ; - add_triangle( tiling13_3[_config][1], 10, v12 ) ; break ; - case 9 :/* 13.3 */ - v12 = add_c_vertex() ; - add_triangle( tiling13_3[_config][2], 10, v12 ) ; break ; - case 10 :/* 13.3 */ - v12 = add_c_vertex() ; - add_triangle( tiling13_3[_config][3], 10, v12 ) ; break ; - case 11 :/* 13.3 */ - v12 = add_c_vertex() ; - add_triangle( tiling13_3[_config][4], 10, v12 ) ; break ; - case 12 :/* 13.3 */ - v12 = add_c_vertex() ; - add_triangle( tiling13_3[_config][5], 10, v12 ) ; break ; - case 13 :/* 13.3 */ - v12 = add_c_vertex() ; - add_triangle( tiling13_3[_config][6], 10, v12 ) ; break ; - case 14 :/* 13.3 */ - v12 = add_c_vertex() ; - add_triangle( tiling13_3[_config][7], 10, v12 ) ; break ; - case 15 :/* 13.3 */ - v12 = add_c_vertex() ; - add_triangle( tiling13_3[_config][8], 10, v12 ) ; break ; - case 16 :/* 13.3 */ - v12 = add_c_vertex() ; - add_triangle( tiling13_3[_config][9], 10, v12 ) ; break ; - case 17 :/* 13.3 */ - v12 = add_c_vertex() ; - add_triangle( tiling13_3[_config][10], 10, v12 ) ; break ; - case 18 :/* 13.3 */ - v12 = add_c_vertex() ; - add_triangle( tiling13_3[_config][11], 10, v12 ) ; break ; - - case 19 :/* 13.4 */ - v12 = add_c_vertex() ; - add_triangle( tiling13_4[_config][0], 12, v12 ) ; break ; - case 20 :/* 13.4 */ - v12 = add_c_vertex() ; - add_triangle( tiling13_4[_config][1], 12, v12 ) ; break ; - case 21 :/* 13.4 */ - v12 = add_c_vertex() ; - add_triangle( tiling13_4[_config][2], 12, v12 ) ; break ; - case 22 :/* 13.4 */ - v12 = add_c_vertex() ; - add_triangle( tiling13_4[_config][3], 12, v12 ) ; break ; - - case 23 :/* 13.5 */ - _subconfig = 0 ; - if( test_interior( test13[_config][6] ) ) - add_triangle( tiling13_5_1[_config][0], 6 ) ; - else - add_triangle( tiling13_5_2[_config][0], 10 ) ; - break ; - case 24 :/* 13.5 */ - _subconfig = 1 ; - if( test_interior( test13[_config][6] ) ) - add_triangle( tiling13_5_1[_config][1], 6 ) ; - else - add_triangle( tiling13_5_2[_config][1], 10 ) ; - break ; - case 25 :/* 13.5 */ - _subconfig = 2 ; - if( test_interior( test13[_config][6] ) ) - add_triangle( tiling13_5_1[_config][2], 6 ) ; - else - add_triangle( tiling13_5_2[_config][2], 10 ) ; - break ; - case 26 :/* 13.5 */ - _subconfig = 3 ; - if( test_interior( test13[_config][6] ) ) - add_triangle( tiling13_5_1[_config][3], 6 ) ; - else - add_triangle( tiling13_5_2[_config][3], 10 ) ; - break ; - - case 27 :/* 13.3 */ - v12 = add_c_vertex() ; - add_triangle( tiling13_3_[_config][0], 10, v12 ) ; break ; - case 28 :/* 13.3 */ - v12 = add_c_vertex() ; - add_triangle( tiling13_3_[_config][1], 10, v12 ) ; break ; - case 29 :/* 13.3 */ - v12 = add_c_vertex() ; - add_triangle( tiling13_3_[_config][2], 10, v12 ) ; break ; - case 30 :/* 13.3 */ - v12 = add_c_vertex() ; - add_triangle( tiling13_3_[_config][3], 10, v12 ) ; break ; - case 31 :/* 13.3 */ - v12 = add_c_vertex() ; - add_triangle( tiling13_3_[_config][4], 10, v12 ) ; break ; - case 32 :/* 13.3 */ - v12 = add_c_vertex() ; - add_triangle( tiling13_3_[_config][5], 10, v12 ) ; break ; - case 33 :/* 13.3 */ - v12 = add_c_vertex() ; - add_triangle( tiling13_3_[_config][6], 10, v12 ) ; break ; - case 34 :/* 13.3 */ - v12 = add_c_vertex() ; - add_triangle( tiling13_3_[_config][7], 10, v12 ) ; break ; - case 35 :/* 13.3 */ - v12 = add_c_vertex() ; - add_triangle( tiling13_3_[_config][8], 10, v12 ) ; break ; - case 36 :/* 13.3 */ - v12 = add_c_vertex() ; - add_triangle( tiling13_3_[_config][9], 10, v12 ) ; break ; - case 37 :/* 13.3 */ - v12 = add_c_vertex() ; - add_triangle( tiling13_3_[_config][10], 10, v12 ) ; break ; - case 38 :/* 13.3 */ - v12 = add_c_vertex() ; - add_triangle( tiling13_3_[_config][11], 10, v12 ) ; break ; - - case 39 :/* 13.2 */ - add_triangle( tiling13_2_[_config][0], 6 ) ; break ; - case 40 :/* 13.2 */ - add_triangle( tiling13_2_[_config][1], 6 ) ; break ; - case 41 :/* 13.2 */ - add_triangle( tiling13_2_[_config][2], 6 ) ; break ; - case 42 :/* 13.2 */ - add_triangle( tiling13_2_[_config][3], 6 ) ; break ; - case 43 :/* 13.2 */ - add_triangle( tiling13_2_[_config][4], 6 ) ; break ; - case 44 :/* 13.2 */ - add_triangle( tiling13_2_[_config][5], 6 ) ; break ; - - case 45 :/* 13.1 */ - add_triangle( tiling13_1_[_config], 4 ) ; break ; - - default : - printf("Marching Cubes: Impossible case 13?\n" ) ; print_cube() ; - } - break ; - - case 14 : - add_triangle( tiling14[_config], 4 ) ; - break ; - }; -} -//_____________________________________________________________________________ - - - -//_____________________________________________________________________________ -// Adding triangles -void MarchingCubes::add_triangle( const char* trig, char n, int v12 ) -//----------------------------------------------------------------------------- -{ - int tv[3] ; - - for( int t = 0 ; t < 3*n ; t++ ) - { - switch( trig[t] ) - { - case 0 : tv[ t % 3 ] = get_x_vert( _i , _j , _k ) ; break ; - case 1 : tv[ t % 3 ] = get_y_vert(_i+1, _j , _k ) ; break ; - case 2 : tv[ t % 3 ] = get_x_vert( _i ,_j+1, _k ) ; break ; - case 3 : tv[ t % 3 ] = get_y_vert( _i , _j , _k ) ; break ; - case 4 : tv[ t % 3 ] = get_x_vert( _i , _j ,_k+1) ; break ; - case 5 : tv[ t % 3 ] = get_y_vert(_i+1, _j ,_k+1) ; break ; - case 6 : tv[ t % 3 ] = get_x_vert( _i ,_j+1,_k+1) ; break ; - case 7 : tv[ t % 3 ] = get_y_vert( _i , _j ,_k+1) ; break ; - case 8 : tv[ t % 3 ] = get_z_vert( _i , _j , _k ) ; break ; - case 9 : tv[ t % 3 ] = get_z_vert(_i+1, _j , _k ) ; break ; - case 10 : tv[ t % 3 ] = get_z_vert(_i+1,_j+1, _k ) ; break ; - case 11 : tv[ t % 3 ] = get_z_vert( _i ,_j+1, _k ) ; break ; - case 12 : tv[ t % 3 ] = v12 ; break ; - default : break ; - } - - if( tv[t%3] == -1 ) - { - printf("Marching Cubes: invalid triangle %d\n", _ntrigs+1) ; - print_cube() ; - } - - if( t%3 == 2 ) - { - if( _ntrigs >= _Ntrigs ) - { - Triangle *temp = _triangles ; - _triangles = new Triangle[ 2*_Ntrigs ] ; - memcpy( _triangles, temp, _Ntrigs*sizeof(Triangle) ) ; - delete[] temp ; - printf("%d allocated triangles\n", _Ntrigs) ; - _Ntrigs *= 2 ; - } - - Triangle *T = _triangles + _ntrigs++ ; - T->v1 = tv[0] ; - T->v2 = tv[1] ; - T->v3 = tv[2] ; - } - } -} -//_____________________________________________________________________________ - - - -//_____________________________________________________________________________ -// Calculating gradient - -real MarchingCubes::get_x_grad( const int i, const int j, const int k ) const -//----------------------------------------------------------------------------- -{ - if( i > 0 ) - { - if ( i < _size_x - 1 ) - return ( get_data( i+1, j, k ) - get_data( i-1, j, k ) ) / 2 ; - else - return get_data( i, j, k ) - get_data( i-1, j, k ) ; - } - else - return get_data( i+1, j, k ) - get_data( i, j, k ) ; -} -//----------------------------------------------------------------------------- - -real MarchingCubes::get_y_grad( const int i, const int j, const int k ) const -//----------------------------------------------------------------------------- -{ - if( j > 0 ) - { - if ( j < _size_y - 1 ) - return ( get_data( i, j+1, k ) - get_data( i, j-1, k ) ) / 2 ; - else - return get_data( i, j, k ) - get_data( i, j-1, k ) ; - } - else - return get_data( i, j+1, k ) - get_data( i, j, k ) ; -} -//----------------------------------------------------------------------------- - -real MarchingCubes::get_z_grad( const int i, const int j, const int k ) const -//----------------------------------------------------------------------------- -{ - if( k > 0 ) - { - if ( k < _size_z - 1 ) - return ( get_data( i, j, k+1 ) - get_data( i, j, k-1 ) ) / 2 ; - else - return get_data( i, j, k ) - get_data( i, j, k-1 ) ; - } - else - return get_data( i, j, k+1 ) - get_data( i, j, k ) ; -} -//_____________________________________________________________________________ - - -//_____________________________________________________________________________ -// Adding vertices - -void MarchingCubes::test_vertex_addition() -{ - if( _nverts >= _Nverts ) - { - Vertex *temp = _vertices ; - _vertices = new Vertex[ _Nverts*2 ] ; - memcpy( _vertices, temp, _Nverts*sizeof(Vertex) ) ; - delete[] temp ; - printf("%d allocated vertices\n", _Nverts) ; - _Nverts *= 2 ; - } -} - - -int MarchingCubes::add_x_vertex( ) -//----------------------------------------------------------------------------- -{ - test_vertex_addition() ; - Vertex *vert = _vertices + _nverts++ ; - - real u = ( _cube[0] ) / ( _cube[0] - _cube[1] ) ; - - vert->x = (real)_i+u; - vert->y = (real) _j ; - vert->z = (real) _k ; - - vert->nx = (1-u)*get_x_grad(_i,_j,_k) + u*get_x_grad(_i+1,_j,_k) ; - vert->ny = (1-u)*get_y_grad(_i,_j,_k) + u*get_y_grad(_i+1,_j,_k) ; - vert->nz = (1-u)*get_z_grad(_i,_j,_k) + u*get_z_grad(_i+1,_j,_k) ; - - u = (real) sqrt( vert->nx * vert->nx + vert->ny * vert->ny +vert->nz * vert->nz ) ; - if( u > 0 ) - { - vert->nx /= u ; - vert->ny /= u ; - vert->nz /= u ; - } - - - return _nverts-1 ; -} -//----------------------------------------------------------------------------- - -int MarchingCubes::add_y_vertex( ) -//----------------------------------------------------------------------------- -{ - test_vertex_addition() ; - Vertex *vert = _vertices + _nverts++ ; - - real u = ( _cube[0] ) / ( _cube[0] - _cube[3] ) ; - - vert->x = (real) _i ; - vert->y = (real)_j+u; - vert->z = (real) _k ; - - vert->nx = (1-u)*get_x_grad(_i,_j,_k) + u*get_x_grad(_i,_j+1,_k) ; - vert->ny = (1-u)*get_y_grad(_i,_j,_k) + u*get_y_grad(_i,_j+1,_k) ; - vert->nz = (1-u)*get_z_grad(_i,_j,_k) + u*get_z_grad(_i,_j+1,_k) ; - - u = (real) sqrt( vert->nx * vert->nx + vert->ny * vert->ny +vert->nz * vert->nz ) ; - if( u > 0 ) - { - vert->nx /= u ; - vert->ny /= u ; - vert->nz /= u ; - } - - return _nverts-1 ; -} -//----------------------------------------------------------------------------- - -int MarchingCubes::add_z_vertex( ) -//----------------------------------------------------------------------------- -{ - test_vertex_addition() ; - Vertex *vert = _vertices + _nverts++ ; - - real u = ( _cube[0] ) / ( _cube[0] - _cube[4] ) ; - - vert->x = (real) _i ; - vert->y = (real) _j ; - vert->z = (real)_k+u; - - vert->nx = (1-u)*get_x_grad(_i,_j,_k) + u*get_x_grad(_i,_j,_k+1) ; - vert->ny = (1-u)*get_y_grad(_i,_j,_k) + u*get_y_grad(_i,_j,_k+1) ; - vert->nz = (1-u)*get_z_grad(_i,_j,_k) + u*get_z_grad(_i,_j,_k+1) ; - - u = (real) sqrt( vert->nx * vert->nx + vert->ny * vert->ny +vert->nz * vert->nz ) ; - if( u > 0 ) - { - vert->nx /= u ; - vert->ny /= u ; - vert->nz /= u ; - } - - return _nverts-1 ; -} - - -int MarchingCubes::add_c_vertex( ) -//----------------------------------------------------------------------------- -{ - test_vertex_addition() ; - Vertex *vert = _vertices + _nverts++ ; - - real u = 0 ; - int vid ; - - vert->x = vert->y = vert->z = vert->nx = vert->ny = vert->nz = 0 ; - - // Computes the average of the intersection points of the cube - vid = get_x_vert( _i , _j , _k ) ; - if( vid != -1 ) { ++u ; const Vertex &v = _vertices[vid] ; vert->x += v.x ; vert->y += v.y ; vert->z += v.z ; vert->nx += v.nx ; vert->ny += v.ny ; vert->nz += v.nz ; } - vid = get_y_vert(_i+1, _j , _k ) ; - if( vid != -1 ) { ++u ; const Vertex &v = _vertices[vid] ; vert->x += v.x ; vert->y += v.y ; vert->z += v.z ; vert->nx += v.nx ; vert->ny += v.ny ; vert->nz += v.nz ; } - vid = get_x_vert( _i ,_j+1, _k ) ; - if( vid != -1 ) { ++u ; const Vertex &v = _vertices[vid] ; vert->x += v.x ; vert->y += v.y ; vert->z += v.z ; vert->nx += v.nx ; vert->ny += v.ny ; vert->nz += v.nz ; } - vid = get_y_vert( _i , _j , _k ) ; - if( vid != -1 ) { ++u ; const Vertex &v = _vertices[vid] ; vert->x += v.x ; vert->y += v.y ; vert->z += v.z ; vert->nx += v.nx ; vert->ny += v.ny ; vert->nz += v.nz ; } - vid = get_x_vert( _i , _j ,_k+1) ; - if( vid != -1 ) { ++u ; const Vertex &v = _vertices[vid] ; vert->x += v.x ; vert->y += v.y ; vert->z += v.z ; vert->nx += v.nx ; vert->ny += v.ny ; vert->nz += v.nz ; } - vid = get_y_vert(_i+1, _j ,_k+1) ; - if( vid != -1 ) { ++u ; const Vertex &v = _vertices[vid] ; vert->x += v.x ; vert->y += v.y ; vert->z += v.z ; vert->nx += v.nx ; vert->ny += v.ny ; vert->nz += v.nz ; } - vid = get_x_vert( _i ,_j+1,_k+1) ; - if( vid != -1 ) { ++u ; const Vertex &v = _vertices[vid] ; vert->x += v.x ; vert->y += v.y ; vert->z += v.z ; vert->nx += v.nx ; vert->ny += v.ny ; vert->nz += v.nz ; } - vid = get_y_vert( _i , _j ,_k+1) ; - if( vid != -1 ) { ++u ; const Vertex &v = _vertices[vid] ; vert->x += v.x ; vert->y += v.y ; vert->z += v.z ; vert->nx += v.nx ; vert->ny += v.ny ; vert->nz += v.nz ; } - vid = get_z_vert( _i , _j , _k ) ; - if( vid != -1 ) { ++u ; const Vertex &v = _vertices[vid] ; vert->x += v.x ; vert->y += v.y ; vert->z += v.z ; vert->nx += v.nx ; vert->ny += v.ny ; vert->nz += v.nz ; } - vid = get_z_vert(_i+1, _j , _k ) ; - if( vid != -1 ) { ++u ; const Vertex &v = _vertices[vid] ; vert->x += v.x ; vert->y += v.y ; vert->z += v.z ; vert->nx += v.nx ; vert->ny += v.ny ; vert->nz += v.nz ; } - vid = get_z_vert(_i+1,_j+1, _k ) ; - if( vid != -1 ) { ++u ; const Vertex &v = _vertices[vid] ; vert->x += v.x ; vert->y += v.y ; vert->z += v.z ; vert->nx += v.nx ; vert->ny += v.ny ; vert->nz += v.nz ; } - vid = get_z_vert( _i ,_j+1, _k ) ; - if( vid != -1 ) { ++u ; const Vertex &v = _vertices[vid] ; vert->x += v.x ; vert->y += v.y ; vert->z += v.z ; vert->nx += v.nx ; vert->ny += v.ny ; vert->nz += v.nz ; } - - vert->x /= u ; - vert->y /= u ; - vert->z /= u ; - - u = (real) sqrt( vert->nx * vert->nx + vert->ny * vert->ny +vert->nz * vert->nz ) ; - if( u > 0 ) - { - vert->nx /= u ; - vert->ny /= u ; - vert->nz /= u ; - } - - return _nverts-1 ; -} -//_____________________________________________________________________________ - - - -//_____________________________________________________________________________ -//_____________________________________________________________________________ - - - - -//_____________________________________________________________________________ -// Grid exportation -void MarchingCubes::writeISO(const char *fn ) -//----------------------------------------------------------------------------- -{ - unsigned char buf[sizeof(float)] ; - - FILE *fp = fopen( fn, "wb" ) ; - - // header - * (int*) buf = _size_x ; - fwrite(buf, sizeof(float), 1, fp); - * (int*) buf = _size_y ; - fwrite(buf, sizeof(float), 1, fp); - * (int*) buf = _size_z ; - fwrite(buf, sizeof(float), 1, fp); - - * (float*) buf = -1.0f ; - fwrite(buf, sizeof(float), 1, fp); - * (float*) buf = 1.0f ; - fwrite(buf, sizeof(float), 1, fp); - * (float*) buf = -1.0f ; - fwrite(buf, sizeof(float), 1, fp); - * (float*) buf = 1.0f ; - fwrite(buf, sizeof(float), 1, fp); - * (float*) buf = -1.0f ; - fwrite(buf, sizeof(float), 1, fp); - * (float*) buf = 1.0f ; - fwrite(buf, sizeof(float), 1, fp); - - for( int i = 0 ; i < _size_x ; i++ ) - { - for( int j = 0 ; j < _size_y ; j++ ) - { - for( int k = 0 ; k < _size_z ; k++ ) - { - * (float*) buf = (float)get_data( i,j,k ) ; - fwrite(buf, sizeof(float), 1, fp); - } - } - } - - fclose(fp) ; -} -//_____________________________________________________________________________ - - - - - -//_____________________________________________________________________________ -// PLY exportation -void MarchingCubes::writePLY(const char *fn, bool bin ) -//----------------------------------------------------------------------------- -{ - - typedef struct PlyFace { - unsigned char nverts; /* number of Vertex indices in list */ - int *verts; /* Vertex index list */ - } PlyFace; - - - PlyProperty vert_props[] = { /* list of property information for a PlyVertex */ - {"x", Float32, Float32, offsetof( Vertex,x ), 0, 0, 0, 0}, - {"y", Float32, Float32, offsetof( Vertex,y ), 0, 0, 0, 0}, - {"z", Float32, Float32, offsetof( Vertex,z ), 0, 0, 0, 0}, - {"nx", Float32, Float32, offsetof( Vertex,nx ), 0, 0, 0, 0}, - {"ny", Float32, Float32, offsetof( Vertex,ny ), 0, 0, 0, 0}, - {"nz", Float32, Float32, offsetof( Vertex,nz ), 0, 0, 0, 0} - }; - - PlyProperty face_props[] = { /* list of property information for a PlyFace */ - {"vertex_indices", Int32, Int32, offsetof( PlyFace,verts ), - 1, Uint8, Uint8, offsetof( PlyFace,nverts )}, - }; - - - PlyFile *ply; - FILE *fp = fopen( fn, "w" ); - - int i ; - PlyFace face ; - int verts[3] ; - char *elem_names[] = { "vertex", "face" }; - printf("Marching Cubes::writePLY(%s)...", fn ) ; - ply = write_ply ( fp, 2, elem_names, bin? PLY_BINARY_LE : PLY_ASCII ); - - /* describe what properties go into the PlyVertex elements */ - describe_element_ply ( ply, "vertex", _nverts ); - describe_property_ply ( ply, &vert_props[0] ); - describe_property_ply ( ply, &vert_props[1] ); - describe_property_ply ( ply, &vert_props[2] ); - describe_property_ply ( ply, &vert_props[3] ); - describe_property_ply ( ply, &vert_props[4] ); - describe_property_ply ( ply, &vert_props[5] ); - - /* describe PlyFace properties (just list of PlyVertex indices) */ - describe_element_ply ( ply, "face", _ntrigs ); - describe_property_ply ( ply, &face_props[0] ); - - header_complete_ply ( ply ); - - /* set up and write the PlyVertex elements */ - put_element_setup_ply ( ply, "vertex" ); - for ( i = 0; i < _nverts; i++ ) - put_element_ply ( ply, ( void * ) &(_vertices[i]) ); - printf(" %d vertices written\n", _nverts ) ; - - /* set up and write the PlyFace elements */ - put_element_setup_ply ( ply, "face" ); - face.nverts = 3 ; - face.verts = verts ; - for ( i = 0; i < _ntrigs; i++ ) - { - face.verts[0] = _triangles[i].v1 ; - face.verts[1] = _triangles[i].v2 ; - face.verts[2] = _triangles[i].v3 ; - put_element_ply ( ply, ( void * ) &face ); - } - printf(" %d triangles written\n", _ntrigs ) ; - - close_ply ( ply ); - free_ply ( ply ); - fclose( fp ) ; -} -//_____________________________________________________________________________ - - - -//_____________________________________________________________________________ -// PLY importation -void MarchingCubes::readPLY(const char *fn ) -//----------------------------------------------------------------------------- -{ - typedef struct PlyFace { - unsigned char nverts; /* number of Vertex indices in list */ - int *verts; /* Vertex index list */ - } PlyFace; - - - PlyProperty vert_props[] = { /* list of property information for a PlyVertex */ - {"x", Float32, Float32, offsetof( Vertex,x ), 0, 0, 0, 0}, - {"y", Float32, Float32, offsetof( Vertex,y ), 0, 0, 0, 0}, - {"z", Float32, Float32, offsetof( Vertex,z ), 0, 0, 0, 0}, - {"nx", Float32, Float32, offsetof( Vertex,nx ), 0, 0, 0, 0}, - {"ny", Float32, Float32, offsetof( Vertex,ny ), 0, 0, 0, 0}, - {"nz", Float32, Float32, offsetof( Vertex,nz ), 0, 0, 0, 0} - }; - - PlyProperty face_props[] = { /* list of property information for a PlyFace */ - {"vertex_indices", Int32, Int32, offsetof( PlyFace,verts ), - 1, Uint8, Uint8, offsetof( PlyFace,nverts )}, - }; - - - FILE *fp = fopen( fn, "r" ); - if( !fp ) return ; - PlyFile *ply = read_ply ( fp ); - printf("Marching Cubes::readPLY(%s)...", fn ) ; - - //----------------------------------------------------------------------------- - - // gets the number of faces and vertices - for ( int i = 0; i < ply->num_elem_types; ++i ) - { - int elem_count ; - char *elem_name = setup_element_read_ply ( ply, i, &elem_count ); - if ( equal_strings ( "vertex", elem_name ) ) - _Nverts = _nverts = elem_count; - if ( equal_strings ( "face", elem_name ) ) - _Ntrigs = _ntrigs = elem_count; - } - delete [] _vertices ; - _vertices = new Vertex [_Nverts] ; - delete [] _triangles ; - _triangles = new Triangle[_Ntrigs] ; - - //----------------------------------------------------------------------------- - - /* examine each element type that is in the file (PlyVertex, PlyFace) */ - - for ( int i = 0; i < ply->num_elem_types; ++i ) - { - /* prepare to read the i'th list of elements */ - int elem_count ; - char *elem_name = setup_element_read_ply ( ply, i, &elem_count ); - - //----------------------------------------------------------------------------- - if ( equal_strings ( "vertex", elem_name ) ) - { - /* set up for getting PlyVertex elements */ - setup_property_ply ( ply, &vert_props[0] ); - setup_property_ply ( ply, &vert_props[1] ); - setup_property_ply ( ply, &vert_props[2] ); - setup_property_ply ( ply, &vert_props[3] ); - setup_property_ply ( ply, &vert_props[4] ); - setup_property_ply ( ply, &vert_props[5] ); - - for ( int j = 0; j < _nverts; ++j ) - { - get_element_ply ( ply, ( void * ) (_vertices + j) ); - } - printf(" %d vertices read\n", _nverts ) ; - } - - //----------------------------------------------------------------------------- - else if ( equal_strings ( "face", elem_name ) ) - { - /* set up for getting PlyFace elements */ - /* (all we need are PlyVertex indices) */ - - setup_property_ply ( ply, &face_props[0] ) ; - PlyFace face ; - for ( int j = 0; j < _ntrigs; ++j ) - { - get_element_ply ( ply, ( void * ) &face ); - if( face.nverts != 3 ) - { - printf( "not a triangulated surface: polygon %d has %d sides\n", j, face.nverts ) ; - return ; - } - - _triangles[j].v1 = face.verts[0] ; - _triangles[j].v2 = face.verts[1] ; - _triangles[j].v3 = face.verts[2] ; - - free( face.verts ) ; - } - printf(" %d triangles read\n", _ntrigs ) ; - } - //----------------------------------------------------------------------------- - - //----------------------------------------------------------------------------- - else /* all non-PlyVertex and non-PlyFace elements are grabbed here */ - get_other_element_ply ( ply ); - //----------------------------------------------------------------------------- - } - - close_ply ( ply ); - free_ply ( ply ); - -// fit_to_bbox() ; - fclose( fp ) ; -} -//_____________________________________________________________________________ - - - -//_____________________________________________________________________________ -// Open Inventor / VRML 1.0 ascii exportation -void MarchingCubes::writeIV(const char *fn ) -//----------------------------------------------------------------------------- -{ - FILE *fp = fopen( fn, "w" ) ; - int i ; - - printf("Marching Cubes::exportIV(%s)...", fn) ; - - fprintf( fp, "#Inventor V2.1 ascii \n\nSeparator { \n ShapeHints {\n vertexOrdering COUNTERCLOCKWISE\n shapeType UNKNOWN_SHAPE_TYPE\n creaseAngle 0.0\n }\n Coordinate3 { \n point [ \n" ) ; - for ( i = 0; i < _nverts; i++ ) - fprintf( fp, " %f %f %f,\n", _vertices[i].x, _vertices[i].y, _vertices[i].z ) ; - printf(" %d vertices written\n", _nverts ) ; - - fprintf( fp, "\n ] \n} \nNormal { \nvector [ \n" ) ; - for ( i = 0; i < _nverts; i++ ) - fprintf( fp, " %f %f %f,\n", _vertices[i].nx, _vertices[i].ny, _vertices[i].nz ) ; - - fprintf( fp, "\n ] \n} \nIndexedFaceSet { \ncoordIndex [ \n" ) ; - for ( i = 0; i < _ntrigs; i++ ) - fprintf( fp, "%d, %d, %d, -1,\n", _triangles[i].v1, _triangles[i].v2, _triangles[i].v3 ) ; - - fprintf( fp, " ] \n } \n } \n" ) ; - fclose( fp ) ; - printf(" %d triangles written\n", _ntrigs ) ; -} -//_____________________________________________________________________________ diff --git a/applications/utilities/mesh/generation/cvMesh/cvMeshSurfaceSimplify/MarchingCubes/MarchingCubes.h b/applications/utilities/mesh/generation/cvMesh/cvMeshSurfaceSimplify/MarchingCubes/MarchingCubes.h deleted file mode 100755 index c589bffb7f52d6574763fcdc8947f5539e0871a7..0000000000000000000000000000000000000000 --- a/applications/utilities/mesh/generation/cvMesh/cvMeshSurfaceSimplify/MarchingCubes/MarchingCubes.h +++ /dev/null @@ -1,343 +0,0 @@ -/** - * @file MarchingCubes.h - * @author Thomas Lewiner <thomas.lewiner@polytechnique.org> - * @author Math Dept, PUC-Rio - * @version 0.2 - * @date 12/08/2002 - * - * @brief MarchingCubes Algorithm - */ -//________________________________________________ - - -#ifndef _MARCHINGCUBES_H_ -#define _MARCHINGCUBES_H_ - -#if !defined(WIN32) || defined(__CYGWIN__) -#pragma interface -#endif // WIN32 - - -//_____________________________________________________________________________ -// types -/** unsigned char alias */ -typedef unsigned char uchar ; -/** signed char alias */ -typedef signed char schar ; -/** isovalue alias */ -typedef float real ; - -//----------------------------------------------------------------------------- -// Vertex structure -/** \struct Vertex "MarchingCubes.h" MarchingCubes - * Position and normal of a vertex - * \brief vertex structure - * \param x X coordinate - * \param y Y coordinate - * \param z Z coordinate - * \param nx X component of the normal - * \param ny Y component of the normal - * \param nz Z component of the normal - */ -typedef struct -{ - real x, y, z ; /**< Vertex coordinates */ - real nx, ny, nz ; /**< Vertex normal */ -} Vertex ; - -//----------------------------------------------------------------------------- -// Triangle structure -/** \struct Triangle "MarchingCubes.h" MarchingCubes - * Indices of the oriented triange vertices - * \brief triangle structure - * \param v1 First vertex index - * \param v2 Second vertex index - * \param v3 Third vertex index - */ -typedef struct -{ - int v1,v2,v3 ; /**< Triangle vertices */ -} Triangle ; -//_____________________________________________________________________________ - - - -//_____________________________________________________________________________ -/** Marching Cubes algorithm wrapper */ -/** \class MarchingCubes - * \brief Marching Cubes algorithm. - */ -class MarchingCubes -//----------------------------------------------------------------------------- -{ -// Constructors -public : - /** - * Main and default constructor - * \brief constructor - * \param size_x width of the grid - * \param size_y depth of the grid - * \param size_z height of the grid - */ - MarchingCubes ( const int size_x = -1, const int size_y = -1, const int size_z = -1 ) ; - /** Destructor */ - ~MarchingCubes() ; - -//----------------------------------------------------------------------------- -// Accessors -public : - /** accesses the number of vertices of the generated mesh */ - inline const int nverts() const { return _nverts ; } - /** accesses the number of triangles of the generated mesh */ - inline const int ntrigs() const { return _ntrigs ; } - /** accesses a specific vertex of the generated mesh */ - inline Vertex * vert( const int i ) const { if( i < 0 || i >= _nverts ) return ( Vertex *)NULL ; return _vertices + i ; } - /** accesses a specific triangle of the generated mesh */ - inline Triangle * trig( const int i ) const { if( i < 0 || i >= _ntrigs ) return (Triangle*)NULL ; return _triangles + i ; } - - /** accesses the vertex buffer of the generated mesh */ - inline Vertex *vertices () { return _vertices ; } - /** accesses the triangle buffer of the generated mesh */ - inline Triangle *triangles() { return _triangles ; } - - /** accesses the width of the grid */ - inline const int size_x() const { return _size_x ; } - /** accesses the depth of the grid */ - inline const int size_y() const { return _size_y ; } - /** accesses the height of the grid */ - inline const int size_z() const { return _size_z ; } - - /** - * changes the size of the grid - * \param size_x width of the grid - * \param size_y depth of the grid - * \param size_z height of the grid - */ - inline void set_resolution( const int size_x, const int size_y, const int size_z ) { _size_x = size_x ; _size_y = size_y ; _size_z = size_z ; } - /** - * selects wether the algorithm will use the enhanced topologically controlled lookup table or the original MarchingCubes - * \param originalMC true for the original Marching Cubes - */ - inline void set_method ( const bool originalMC = false ) { _originalMC = originalMC ; } - /** - * selects to use data from another class - * \param data is the pointer to the external data, allocated as a size_x*size_y*size_z vector running in x first - */ - inline void set_ext_data ( real *data ) - { if( !_ext_data ) delete [] _data ; _ext_data = data != NULL ; if( _ext_data ) _data = data ; } - /** - * selects to allocate data - */ - inline void set_int_data () { _ext_data = false ; _data = NULL ; } - - // Data access - /** - * accesses a specific cube of the grid - * \param i abscisse of the cube - * \param j ordinate of the cube - * \param k height of the cube - */ - inline const real get_data ( const int i, const int j, const int k ) const { return _data[ i + j*_size_x + k*_size_x*_size_y] ; } - /** - * sets a specific cube of the grid - * \param val new value for the cube - * \param i abscisse of the cube - * \param j ordinate of the cube - * \param k height of the cube - */ - inline void set_data ( const real val, const int i, const int j, const int k ) { _data[ i + j*_size_x + k*_size_x*_size_y] = val ; } - - // Data initialization - /** inits temporary structures (must set sizes before call) : the grid and the vertex index per cube */ - void init_temps () ; - /** inits all structures (must set sizes before call) : the temporary structures and the mesh buffers */ - void init_all () ; - /** clears temporary structures : the grid and the main */ - void clean_temps() ; - /** clears all structures : the temporary structures and the mesh buffers */ - void clean_all () ; - - -//----------------------------------------------------------------------------- -// Exportation -public : - /** - * PLY exportation of the generated mesh - * \param fn name of the PLY file to create - * \param bin if true, the PLY will be written in binary mode - */ - void writePLY( const char *fn, bool bin = false ) ; - - /** - * PLY importation of a mesh - * \param fn name of the PLY file to read from - */ - void readPLY( const char *fn ) ; - - /** - * VRML / Open Inventor exportation of the generated mesh - * \param fn name of the IV file to create - */ - void writeIV ( const char *fn ) ; - - /** - * ISO exportation of the input grid - * \param fn name of the ISO file to create - */ - void writeISO( const char *fn ) ; - - -//----------------------------------------------------------------------------- -// Algorithm -public : - /** - * Main algorithm : must be called after init_all - * \param iso isovalue - */ - void run( real iso = (real)0.0 ) ; - -protected : - /** tesselates one cube */ - void process_cube () ; - /** tests if the components of the tesselation of the cube should be connected by the interior of an ambiguous face */ - bool test_face ( schar face ) ; - /** tests if the components of the tesselation of the cube should be connected through the interior of the cube */ - bool test_interior( schar s ) ; - - -//----------------------------------------------------------------------------- -// Operations -protected : - /** - * computes almost all the vertices of the mesh by interpolation along the cubes edges - * \param iso isovalue - */ - void compute_intersection_points( real iso ) ; - - /** - * routine to add a triangle to the mesh - * \param trig the code for the triangle as a sequence of edges index - * \param n the number of triangles to produce - * \param v12 the index of the interior vertex to use, if necessary - */ - void add_triangle ( const char* trig, char n, int v12 = -1 ) ; - - /** tests and eventually doubles the vertex buffer capacity for a new vertex insertion */ - void test_vertex_addition() ; - /** adds a vertex on the current horizontal edge */ - int add_x_vertex() ; - /** adds a vertex on the current longitudinal edge */ - int add_y_vertex() ; - /** adds a vertex on the current vertical edge */ - int add_z_vertex() ; - /** adds a vertex inside the current cube */ - int add_c_vertex() ; - - /** - * interpolates the horizontal gradient of the implicit function at the lower vertex of the specified cube - * \param i abscisse of the cube - * \param j ordinate of the cube - * \param k height of the cube - */ - real get_x_grad( const int i, const int j, const int k ) const ; - /** - * interpolates the longitudinal gradient of the implicit function at the lower vertex of the specified cube - * \param i abscisse of the cube - * \param j ordinate of the cube - * \param k height of the cube - */ - real get_y_grad( const int i, const int j, const int k ) const ; - /** - * interpolates the vertical gradient of the implicit function at the lower vertex of the specified cube - * \param i abscisse of the cube - * \param j ordinate of the cube - * \param k height of the cube - */ - real get_z_grad( const int i, const int j, const int k ) const ; - - /** - * accesses the pre-computed vertex index on the lower horizontal edge of a specific cube - * \param i abscisse of the cube - * \param j ordinate of the cube - * \param k height of the cube - */ - inline int get_x_vert( const int i, const int j, const int k ) const { return _x_verts[ i + j*_size_x + k*_size_x*_size_y] ; } - /** - * accesses the pre-computed vertex index on the lower longitudinal edge of a specific cube - * \param i abscisse of the cube - * \param j ordinate of the cube - * \param k height of the cube - */ - inline int get_y_vert( const int i, const int j, const int k ) const { return _y_verts[ i + j*_size_x + k*_size_x*_size_y] ; } - /** - * accesses the pre-computed vertex index on the lower vertical edge of a specific cube - * \param i abscisse of the cube - * \param j ordinate of the cube - * \param k height of the cube - */ - inline int get_z_vert( const int i, const int j, const int k ) const { return _z_verts[ i + j*_size_x + k*_size_x*_size_y] ; } - - /** - * sets the pre-computed vertex index on the lower horizontal edge of a specific cube - * \param val the index of the new vertex - * \param i abscisse of the cube - * \param j ordinate of the cube - * \param k height of the cube - */ - inline void set_x_vert( const int val, const int i, const int j, const int k ) { _x_verts[ i + j*_size_x + k*_size_x*_size_y] = val ; } - /** - * sets the pre-computed vertex index on the lower longitudinal edge of a specific cube - * \param val the index of the new vertex - * \param i abscisse of the cube - * \param j ordinate of the cube - * \param k height of the cube - */ - inline void set_y_vert( const int val, const int i, const int j, const int k ) { _y_verts[ i + j*_size_x + k*_size_x*_size_y] = val ; } - /** - * sets the pre-computed vertex index on the lower vertical edge of a specific cube - * \param val the index of the new vertex - * \param i abscisse of the cube - * \param j ordinate of the cube - * \param k height of the cube - */ - inline void set_z_vert( const int val, const int i, const int j, const int k ) { _z_verts[ i + j*_size_x + k*_size_x*_size_y] = val ; } - - /** prints cube for debug */ - void print_cube() ; - -//----------------------------------------------------------------------------- -// Elements -protected : - bool _originalMC ; /**< selects wether the algorithm will use the enhanced topologically controlled lookup table or the original MarchingCubes */ - bool _ext_data ; /**< selects wether to allocate data or use data from another class */ - - int _size_x ; /**< width of the grid */ - int _size_y ; /**< depth of the grid */ - int _size_z ; /**< height of the grid */ - real *_data ; /**< implicit function values sampled on the grid */ - - int *_x_verts ; /**< pre-computed vertex indices on the lower horizontal edge of each cube */ - int *_y_verts ; /**< pre-computed vertex indices on the lower longitudinal edge of each cube */ - int *_z_verts ; /**< pre-computed vertex indices on the lower vertical edge of each cube */ - - int _nverts ; /**< number of allocated vertices in the vertex buffer */ - int _ntrigs ; /**< number of allocated triangles in the triangle buffer */ - int _Nverts ; /**< size of the vertex buffer */ - int _Ntrigs ; /**< size of the triangle buffer */ - Vertex *_vertices ; /**< vertex buffer */ - Triangle *_triangles ; /**< triangle buffer */ - - int _i ; /**< abscisse of the active cube */ - int _j ; /**< height of the active cube */ - int _k ; /**< ordinate of the active cube */ - - real _cube[8] ; /**< values of the implicit function on the active cube */ - uchar _lut_entry ; /**< cube sign representation in [0..255] */ - uchar _case ; /**< case of the active cube in [0..15] */ - uchar _config ; /**< configuration of the active cube */ - uchar _subconfig ; /**< subconfiguration of the active cube */ -}; -//_____________________________________________________________________________ - - -#endif // _MARCHINGCUBES_H_ diff --git a/applications/utilities/mesh/generation/cvMesh/cvMeshSurfaceSimplify/MarchingCubes/ply.c b/applications/utilities/mesh/generation/cvMesh/cvMeshSurfaceSimplify/MarchingCubes/ply.c deleted file mode 100755 index 06c60f4dbb863fa79c88ac5336c3498adfecb99b..0000000000000000000000000000000000000000 --- a/applications/utilities/mesh/generation/cvMesh/cvMeshSurfaceSimplify/MarchingCubes/ply.c +++ /dev/null @@ -1,3325 +0,0 @@ -/* - -The interface routines for reading and writing PLY polygon files. - -Greg Turk - ---------------------------------------------------------------- - -A PLY file contains a single polygonal _object_. - -An object is composed of lists of _elements_. Typical elements are -vertices, faces, edges and materials. - -Each type of element for a given object has one or more _properties_ -associated with the element type. For instance, a vertex element may -have as properties the floating-point values x,y,z and the three unsigned -chars representing red, green and blue. - ------------------------------------------------------------------------ - -Copyright (c) 1998 Georgia Institute of Technology. All rights reserved. - -Permission to use, copy, modify and distribute this software and its -documentation for any purpose is hereby granted without fee, provided -that the above copyright notice and this permission notice appear in -all copies of this software and that you do not sell the software. - -THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTY OF ANY KIND, -EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY -WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - -*/ - -#include <stdio.h> -#include <stdlib.h> -#include <math.h> -#include <string.h> -#include "ply.h" - -char *type_names[] = { /* names of scalar types */ -"invalid", -"int8", "int16", "int32", "uint8", "uint16", "uint32", "float32", "float64", -}; - -char *old_type_names[] = { /* old names of types for backward compatability */ -"invalid", -"char", "short", "int", "uchar", "ushort", "uint", "float", "double", -}; - -int ply_type_size[] = { -0, 1, 2, 4, 1, 2, 4, 4, 8 -}; - -#define NO_OTHER_PROPS -1 - -#define DONT_STORE_PROP 0 -#define STORE_PROP 1 - -#define OTHER_PROP 0 -#define NAMED_PROP 1 - -/* returns 1 if strings are equal, 0 if not */ -int equal_strings( char * , char * ); - -/* find an element in a plyfile's list */ -PlyElement *find_element( PlyFile * , char * ); - -/* find a property in an element's list */ -PlyProperty *find_property( PlyElement * , char * , int * ); - -/* write to a file the word describing a PLY file data type */ -void write_scalar_type( FILE * , int ); - -/* read a line from a file and break it up into separate words */ -char* *get_words( FILE * , int * , char ** ); - -/* write an item to a file */ -void write_binary_item( FILE * , int, unsigned int, double, int ); -void write_ascii_item( FILE * , int, unsigned int, double, int ); - -/* add information to a PLY file descriptor */ -void add_element( PlyFile * , char ** , int ); -void add_property( PlyFile * , char ** , int ); -void add_comment( PlyFile * , char * ); -void add_obj_info( PlyFile * , char * ); - -/* copy a property */ -void copy_property( PlyProperty * , PlyProperty * ); - -/* store a value into where a pointer and a type specify */ -void store_item( char * , int, int, unsigned int, double ); - -/* return the value of a stored item */ -void get_stored_item( void * , int, int * , unsigned int * , double * ); - -/* return the value stored in an item, given ptr to it and its type */ -double get_item_value( char * , int ); - -/* get binary or ascii item and store it according to ptr and type */ -void get_ascii_item( char * , int, int * , unsigned int * , double * ); -void get_binary_item( FILE * , int, int * , unsigned int * , double * ); - -/* get a bunch of elements from a file */ -void ascii_get_element( PlyFile * , char * ); -void binary_get_element( PlyFile * , char * ); - -/* memory allocation */ -static char *my_alloc( int, int, char * ); - - -/*************/ -/* Writing */ -/*************/ - - -/****************************************************************************** -Given a file pointer, get ready to write PLY data to the file. - -Entry: -fp - the given file pointer -nelems - number of elements in object -elem_names - list of element names -file_type - file type, either ascii or binary - -Exit: -returns a pointer to a PlyFile, used to refer to this file, or NULL if error -******************************************************************************/ - -PlyFile *ply_write( FILE *fp, int nelems, char **elem_names, int file_type ) -{ - int i; - PlyFile *plyfile; - PlyElement *elem; - - /* check for NULL file pointer */ - if ( fp == NULL ) - return ( NULL ); - - /* create a record for this object */ - - plyfile = ( PlyFile * ) myalloc ( sizeof ( PlyFile ) ); - plyfile->file_type = file_type; - plyfile->num_comments = 0; - plyfile->num_obj_info = 0; - plyfile->num_elem_types = nelems; - plyfile->version = 1.0; - plyfile->fp = fp; - plyfile->other_elems = NULL; - - /* tuck aside the names of the elements */ - - plyfile->elems = ( PlyElement * * ) myalloc ( sizeof ( PlyElement * ) * nelems ); - for ( i = 0; i < nelems; i++ ) - { - elem = ( PlyElement * ) myalloc ( sizeof ( PlyElement ) ); - plyfile->elems[i] = elem; - elem->name = strdup ( elem_names[i] ); - elem->num = 0; - elem->nprops = 0; - } - - /* return pointer to the file descriptor */ - return ( plyfile ); -} - - -/****************************************************************************** -Open a polygon file for writing. - -Entry: -filename - name of file to read from -nelems - number of elements in object -elem_names - list of element names -file_type - file type, either ascii or binary - -Exit: -returns a file identifier, used to refer to this file, or NULL if error -******************************************************************************/ - -PlyFile *open_for_writing_ply( char *filename, int nelems, char **elem_names, int file_type ) -{ - PlyFile *plyfile; - char *name; - FILE *fp; - - /* tack on the extension .ply, if necessary */ - - name = ( char * ) myalloc ( sizeof ( char ) * ( strlen ( filename ) + 5 ) ); - strcpy ( name, filename ); - if ( strlen ( name ) < 4 || strcmp ( name + strlen ( name ) - 4, ".ply" ) != 0 ) - strcat ( name, ".ply" ); - - /* open the file for writing */ - - fp = fopen ( name, "w" ); - if ( fp == NULL ) - { - return ( NULL ); - } - - /* create the actual PlyFile structure */ - - plyfile = ply_write ( fp, nelems, elem_names, file_type ); - if ( plyfile == NULL ) - return ( NULL ); - - /* return pointer to the file descriptor */ - return ( plyfile ); -} - - -/****************************************************************************** -Describe an element, including its properties and how many will be written -to the file. - -Entry: -plyfile - file identifier -elem_name - name of element that information is being specified about -nelems - number of elements of this type to be written -nprops - number of properties contained in the element -prop_list - list of properties -******************************************************************************/ - -void element_layout_ply( PlyFile *plyfile, char *elem_name, int nelems, int nprops, PlyProperty *prop_list ) -{ - int i; - PlyElement *elem; - PlyProperty *prop; - - /* look for appropriate element */ - elem = find_element ( plyfile, elem_name ); - if ( elem == NULL ) - { - fprintf( stderr,"element_layout_ply: can't find element '%s'\n",elem_name ); - exit ( -1 ); - } - - elem->num = nelems; - - /* copy the list of properties */ - - elem->nprops = nprops; - elem->props = ( PlyProperty * * ) myalloc ( sizeof ( PlyProperty * ) * nprops ); - elem->store_prop = ( char * ) myalloc ( sizeof ( char ) * nprops ); - - for ( i = 0; i < nprops; i++ ) - { - prop = ( PlyProperty * ) myalloc ( sizeof ( PlyProperty ) ); - elem->props[i] = prop; - elem->store_prop[i] = NAMED_PROP; - copy_property ( prop, &prop_list[i] ); - } -} - - -/****************************************************************************** -Describe a property of an element. - -Entry: -plyfile - file identifier -elem_name - name of element that information is being specified about -prop - the new property -******************************************************************************/ - -void ply_describe_property( PlyFile *plyfile, char *elem_name, PlyProperty *prop ) -{ - PlyElement *elem; - PlyProperty *elem_prop; - - /* look for appropriate element */ - elem = find_element ( plyfile, elem_name ); - if ( elem == NULL ) - { - fprintf( stderr, "ply_describe_property: can't find element '%s'\n", - elem_name ); - return; - } - - /* create room for new property */ - - if ( elem->nprops == 0 ) - { - elem->props = ( PlyProperty * * ) myalloc ( sizeof ( PlyProperty * ) ); - elem->store_prop = ( char * ) myalloc ( sizeof ( char ) ); - elem->nprops = 1; - } - else - { - elem->nprops++; - elem->props = ( PlyProperty * * ) - realloc ( elem->props, sizeof ( PlyProperty * ) * elem->nprops ); - elem->store_prop = ( char * ) - realloc ( elem->store_prop, sizeof ( char ) * elem->nprops ); - } - - /* copy the new property */ - - elem_prop = ( PlyProperty * ) myalloc ( sizeof ( PlyProperty ) ); - elem->props[elem->nprops - 1] = elem_prop; - elem->store_prop[elem->nprops - 1] = NAMED_PROP; - copy_property ( elem_prop, prop ); -} - - -/****************************************************************************** -State how many of a given element will be written. - -Entry: -plyfile - file identifier -elem_name - name of element that information is being specified about -nelems - number of elements of this type to be written -******************************************************************************/ - -void element_count_ply( PlyFile *plyfile, char *elem_name, int nelems ) -{ - PlyElement *elem; - - /* look for appropriate element */ - elem = find_element ( plyfile, elem_name ); - if ( elem == NULL ) - { - fprintf( stderr,"element_count_ply: can't find element '%s'\n",elem_name ); - exit ( -1 ); - } - - elem->num = nelems; -} - - -/****************************************************************************** -Signal that we've described everything a PLY file's header and that the -header should be written to the file. - -Entry: -plyfile - file identifier -******************************************************************************/ - -void header_complete_ply( PlyFile *plyfile ) -{ - int i,j; - FILE *fp = plyfile->fp; - PlyElement *elem; - PlyProperty *prop; - - fprintf ( fp, "ply\n" ); - - switch ( plyfile->file_type ) - { - case PLY_ASCII: - fprintf ( fp, "format ascii 1.0\n" ); - break; - case PLY_BINARY_BE: - fprintf ( fp, "format binary_big_endian 1.0\n" ); - break; - case PLY_BINARY_LE: - fprintf ( fp, "format binary_little_endian 1.0\n" ); - break; - default: - fprintf ( stderr, "ply_header_complete: bad file type = %d\n", - plyfile->file_type ); - exit ( -1 ); - } - - /* write out the comments */ - - for ( i = 0; i < plyfile->num_comments; i++ ) - fprintf ( fp, "comment %s\n", plyfile->comments[i] ); - - /* write out object information */ - - for ( i = 0; i < plyfile->num_obj_info; i++ ) - fprintf ( fp, "obj_info %s\n", plyfile->obj_info[i] ); - - /* write out information about each element */ - - for ( i = 0; i < plyfile->num_elem_types; i++ ) - { - elem = plyfile->elems[i]; - fprintf ( fp, "element %s %d\n", elem->name, elem->num ); - - /* write out each property */ - for ( j = 0; j < elem->nprops; j++ ) - { - prop = elem->props[j]; - if ( prop->is_list == PLY_LIST ) - { - fprintf ( fp, "property list " ); - write_scalar_type ( fp, prop->count_external ); - fprintf ( fp, " " ); - write_scalar_type ( fp, prop->external_type ); - fprintf ( fp, " %s\n", prop->name ); - } - else if ( prop->is_list == PLY_STRING ) - { - fprintf ( fp, "property string" ); - fprintf ( fp, " %s\n", prop->name ); - } - else - { - fprintf ( fp, "property " ); - write_scalar_type ( fp, prop->external_type ); - fprintf ( fp, " %s\n", prop->name ); - } - } - } - - fprintf ( fp, "end_header\n" ); -} - - -/****************************************************************************** -Specify which elements are going to be written. This should be called -before a call to the routine ply_put_element(). - -Entry: -plyfile - file identifier -elem_name - name of element we're talking about -******************************************************************************/ - -void put_element_setup_ply( PlyFile *plyfile, char *elem_name ) -{ - PlyElement *elem; - - elem = find_element ( plyfile, elem_name ); - if ( elem == NULL ) - { - fprintf( stderr, "put_element_setup_ply: can't find element '%s'\n", elem_name ); - exit ( -1 ); - } - - plyfile->which_elem = elem; -} - - -/****************************************************************************** -Write an element to the file. This routine assumes that we're -writing the type of element specified in the last call to the routine -put_element_setup_ply(). - -Entry: -plyfile - file identifier -elem_ptr - pointer to the element -******************************************************************************/ - -void put_element_ply( PlyFile *plyfile, void *elem_ptr ) -{ - int j,k; - FILE *fp = plyfile->fp; - PlyElement *elem; - PlyProperty *prop; - char *item; - char *elem_data; - char* *item_ptr; - int list_count; - int item_size; - int int_val; - unsigned int uint_val; - double double_val; - char* *other_ptr; - - elem = plyfile->which_elem; - elem_data = ( char * ) elem_ptr; - other_ptr = ( char * * ) ( ( ( char * ) elem_ptr ) + elem->other_offset ); - - /* write out either to an ascii or binary file */ - - if ( plyfile->file_type == PLY_ASCII ) - { - /* write an ascii file */ - - /* write out each property of the element */ - for ( j = 0; j < elem->nprops; j++ ) - { - prop = elem->props[j]; - - if ( elem->store_prop[j] == OTHER_PROP ) - elem_data = *other_ptr; - else - elem_data = ( char * ) elem_ptr; - - if ( prop->is_list == PLY_LIST ) - { - /* list */ - item = elem_data + prop->count_offset; - get_stored_item ( ( void * ) item, prop->count_internal, - &int_val, &uint_val, &double_val ); - write_ascii_item ( fp, int_val, uint_val, double_val, - prop->count_external ); - list_count = uint_val; - item_ptr = ( char * * ) ( elem_data + prop->offset ); - item = item_ptr[0]; - item_size = ply_type_size[prop->internal_type]; - for ( k = 0; k < list_count; k++ ) - { - get_stored_item ( ( void * ) item, prop->internal_type, - &int_val, &uint_val, &double_val ); - write_ascii_item ( fp, int_val, uint_val, double_val, - prop->external_type ); - item += item_size; - } - } - else if ( prop->is_list == PLY_STRING ) - { - /* string */ - char* *str; - item = elem_data + prop->offset; - str = ( char * * ) item; - fprintf ( fp, "\"%s\"", *str ); - } - else - { - /* scalar */ - item = elem_data + prop->offset; - get_stored_item ( ( void * ) item, prop->internal_type, - &int_val, &uint_val, &double_val ); - write_ascii_item ( fp, int_val, uint_val, double_val, - prop->external_type ); - } - } - - fprintf ( fp, "\n" ); - } - else - { - /* write a binary file */ - - /* write out each property of the element */ - for ( j = 0; j < elem->nprops; j++ ) - { - prop = elem->props[j]; - if ( elem->store_prop[j] == OTHER_PROP ) - elem_data = *other_ptr; - else - elem_data = ( char * ) elem_ptr; - if ( prop->is_list == PLY_LIST ) - { - /* list */ - item = elem_data + prop->count_offset; - item_size = ply_type_size[prop->count_internal]; - get_stored_item ( ( void * ) item, prop->count_internal, - &int_val, &uint_val, &double_val ); - write_binary_item ( fp, int_val, uint_val, double_val, - prop->count_external ); - list_count = uint_val; - item_ptr = ( char * * ) ( elem_data + prop->offset ); - item = item_ptr[0]; - item_size = ply_type_size[prop->internal_type]; - for ( k = 0; k < list_count; k++ ) - { - get_stored_item ( ( void * ) item, prop->internal_type, - &int_val, &uint_val, &double_val ); - write_binary_item ( fp, int_val, uint_val, double_val, - prop->external_type ); - item += item_size; - } - } - else if ( prop->is_list == PLY_STRING ) - { - /* string */ - int len; - char* *str; - item = elem_data + prop->offset; - str = ( char * * ) item; - - /* write the length */ - len = strlen( *str ) + 1; - fwrite ( &len, sizeof( int ), 1, fp ); - - /* write the string, including the null character */ - fwrite ( *str, len, 1, fp ); - } - else - { - /* scalar */ - item = elem_data + prop->offset; - item_size = ply_type_size[prop->internal_type]; - get_stored_item ( ( void * ) item, prop->internal_type, - &int_val, &uint_val, &double_val ); - write_binary_item ( fp, int_val, uint_val, double_val, - prop->external_type ); - } - } - } -} - - - - - - -/*************/ -/* Reading */ -/*************/ - - - -/****************************************************************************** -Given a file pointer, get ready to read PLY data from the file. - -Entry: -fp - the given file pointer - -Exit: -nelems - number of elements in object -elem_names - list of element names -returns a pointer to a PlyFile, used to refer to this file, or NULL if error -******************************************************************************/ - -PlyFile *ply_read( FILE *fp, int *nelems, char ***elem_names ) -{ - int i,j; - PlyFile *plyfile; - int nwords; - char* *words; - int found_format = 0; - char* *elist; - PlyElement *elem; - char *orig_line; - - /* check for NULL file pointer */ - if ( fp == NULL ) - return ( NULL ); - - /* create record for this object */ - - plyfile = ( PlyFile * ) myalloc ( sizeof ( PlyFile ) ); - plyfile->num_elem_types = 0; - plyfile->comments = NULL; - plyfile->num_comments = 0; - plyfile->obj_info = NULL; - plyfile->num_obj_info = 0; - plyfile->fp = fp; - plyfile->other_elems = NULL; - plyfile->rule_list = NULL; - - /* read and parse the file's header */ - - words = get_words ( plyfile->fp, &nwords, &orig_line ); - if ( !words || !equal_strings ( words[0], "ply" ) ) - return ( NULL ); - - while ( words ) - { - /* parse words */ - - if ( equal_strings ( words[0], "format" ) ) - { - if ( nwords != 3 ) - return ( NULL ); - if ( equal_strings ( words[1], "ascii" ) ) - plyfile->file_type = PLY_ASCII; - else if ( equal_strings ( words[1], "binary_big_endian" ) ) - plyfile->file_type = PLY_BINARY_BE; - else if ( equal_strings ( words[1], "binary_little_endian" ) ) - plyfile->file_type = PLY_BINARY_LE; - else - return ( NULL ); - plyfile->version = ( float ) atof ( words[2] ); - found_format = 1; - } - else if ( equal_strings ( words[0], "element" ) ) - add_element ( plyfile, words, nwords ); - else if ( equal_strings ( words[0], "property" ) ) - add_property ( plyfile, words, nwords ); - else if ( equal_strings ( words[0], "comment" ) ) - add_comment ( plyfile, orig_line ); - else if ( equal_strings ( words[0], "obj_info" ) ) - add_obj_info ( plyfile, orig_line ); - else if ( equal_strings ( words[0], "end_header" ) ) - break; - - /* free up words space */ - free ( words ); - - words = get_words ( plyfile->fp, &nwords, &orig_line ); - } - - /* create tags for each property of each element, to be used */ - /* later to say whether or not to store each property for the user */ - - for ( i = 0; i < plyfile->num_elem_types; i++ ) - { - elem = plyfile->elems[i]; - elem->store_prop = ( char * ) myalloc ( sizeof ( char ) * elem->nprops ); - for ( j = 0; j < elem->nprops; j++ ) - elem->store_prop[j] = DONT_STORE_PROP; - elem->other_offset = NO_OTHER_PROPS; /* no "other" props by default */ - } - - /* set return values about the elements */ - - elist = ( char * * ) myalloc ( sizeof ( char * ) * plyfile->num_elem_types ); - for ( i = 0; i < plyfile->num_elem_types; i++ ) - elist[i] = strdup ( plyfile->elems[i]->name ); - - *elem_names = elist; - *nelems = plyfile->num_elem_types; - - /* return a pointer to the file's information */ - - return ( plyfile ); -} - - -/****************************************************************************** -Open a polygon file for reading. - -Entry: -filename - name of file to read from - -Exit: -nelems - number of elements in object -elem_names - list of element names -file_type - file type, either ascii or binary -version - version number of PLY file -returns a file identifier, used to refer to this file, or NULL if error -******************************************************************************/ - -PlyFile *ply_open_for_reading( char *filename, int *nelems, char ***elem_names, int *file_type, float *version ) -{ - FILE *fp; - PlyFile *plyfile; - char *name; - - /* tack on the extension .ply, if necessary */ - - name = ( char * ) myalloc ( sizeof ( char ) * ( strlen ( filename ) + 5 ) ); - strcpy ( name, filename ); - if ( strlen ( name ) < 4 || strcmp ( name + strlen ( name ) - 4, ".ply" ) != 0 ) - strcat ( name, ".ply" ); - - /* open the file for reading */ - - fp = fopen ( name, "r" ); - if ( fp == NULL ) - return ( NULL ); - - /* create the PlyFile data structure */ - - plyfile = ply_read ( fp, nelems, elem_names ); - - /* determine the file type and version */ - - *file_type = plyfile->file_type; - *version = plyfile->version; - - /* return a pointer to the file's information */ - - return ( plyfile ); -} - - -/****************************************************************************** -Get information about a particular element. - -Entry: -plyfile - file identifier -elem_name - name of element to get information about - -Exit: -nelems - number of elements of this type in the file -nprops - number of properties -returns a list of properties, or NULL if the file doesn't contain that elem -******************************************************************************/ - -PlyProperty **get_element_description_ply( PlyFile *plyfile, char *elem_name, int *nelems, int *nprops ) -{ - int i; - PlyElement *elem; - PlyProperty *prop; - PlyProperty* *prop_list; - - /* find information about the element */ - elem = find_element ( plyfile, elem_name ); - if ( elem == NULL ) - return ( NULL ); - - *nelems = elem->num; - *nprops = elem->nprops; - - /* make a copy of the element's property list */ - prop_list = ( PlyProperty * * ) myalloc ( sizeof ( PlyProperty * ) * elem->nprops ); - for ( i = 0; i < elem->nprops; i++ ) - { - prop = ( PlyProperty * ) myalloc ( sizeof ( PlyProperty ) ); - copy_property ( prop, elem->props[i] ); - prop_list[i] = prop; - } - - /* return this duplicate property list */ - return ( prop_list ); -} - - -/****************************************************************************** -Specify which properties of an element are to be returned. This should be -called before a call to the routine get_element_ply(). - -Entry: -plyfile - file identifier -elem_name - which element we're talking about -nprops - number of properties -prop_list - list of properties -******************************************************************************/ - -void get_element_setup_ply( PlyFile *plyfile, char *elem_name, int nprops, PlyProperty *prop_list ) -{ - int i; - PlyElement *elem; - PlyProperty *prop; - int index; - - /* find information about the element */ - elem = find_element ( plyfile, elem_name ); - plyfile->which_elem = elem; - - /* deposit the property information into the element's description */ - for ( i = 0; i < nprops; i++ ) - { - /* look for actual property */ - prop = find_property ( elem, prop_list[i].name, &index ); - if ( prop == NULL ) - { - fprintf ( stderr, "Warning: Can't find property '%s' in element '%s'\n", - prop_list[i].name, elem_name ); - continue; - } - - /* store its description */ - prop->internal_type = prop_list[i].internal_type; - prop->offset = prop_list[i].offset; - prop->count_internal = prop_list[i].count_internal; - prop->count_offset = prop_list[i].count_offset; - - /* specify that the user wants this property */ - elem->store_prop[index] = STORE_PROP; - } -} - - -/****************************************************************************** -Specify a property of an element that is to be returned. This should be -called (usually multiple times) before a call to the routine ply_get_element(). -This routine should be used in preference to the less flexible old routine -called ply_get_element_setup(). - -Entry: -plyfile - file identifier -elem_name - which element we're talking about -prop - property to add to those that will be returned -******************************************************************************/ - -void ply_get_property( PlyFile *plyfile, char *elem_name, PlyProperty *prop ) -{ - PlyElement *elem; - PlyProperty *prop_ptr; - int index; - - /* find information about the element */ - elem = find_element ( plyfile, elem_name ); - plyfile->which_elem = elem; - - /* deposit the property information into the element's description */ - - prop_ptr = find_property ( elem, prop->name, &index ); - if ( prop_ptr == NULL ) - { - fprintf ( stderr, "Warning: Can't find property '%s' in element '%s'\n", - prop->name, elem_name ); - return; - } - prop_ptr->internal_type = prop->internal_type; - prop_ptr->offset = prop->offset; - prop_ptr->count_internal = prop->count_internal; - prop_ptr->count_offset = prop->count_offset; - - /* specify that the user wants this property */ - elem->store_prop[index] = STORE_PROP; -} - - -/****************************************************************************** -Read one element from the file. This routine assumes that we're reading -the type of element specified in the last call to the routine -ply_get_element_setup(). - -Entry: -plyfile - file identifier -elem_ptr - pointer to location where the element information should be put -******************************************************************************/ - -void ply_get_element( PlyFile *plyfile, void *elem_ptr ) -{ - if ( plyfile->file_type == PLY_ASCII ) - ascii_get_element ( plyfile, ( char * ) elem_ptr ); - else - binary_get_element ( plyfile, ( char * ) elem_ptr ); -} - - -/****************************************************************************** -Extract the comments from the header information of a PLY file. - -Entry: -plyfile - file identifier - -Exit: -num_comments - number of comments returned -returns a pointer to a list of comments -******************************************************************************/ - -char **get_comments_ply( PlyFile *plyfile, int *num_comments ) -{ - *num_comments = plyfile->num_comments; - return ( plyfile->comments ); -} - - -/****************************************************************************** -Extract the object information (arbitrary text) from the header information -of a PLY file. - -Entry: -plyfile - file identifier - -Exit: -num_obj_info - number of lines of text information returned -returns a pointer to a list of object info lines -******************************************************************************/ - -char **get_obj_info_ply( PlyFile *plyfile, int *num_obj_info ) -{ - *num_obj_info = plyfile->num_obj_info; - return ( plyfile->obj_info ); -} - - -/****************************************************************************** -ake ready for "other" properties of an element-- those properties that -the user has not explicitly asked for, but that are to be stashed away -in a special structure to be carried along with the element's other -information. - -Entry: -plyfile - file identifier -elem - element for which we want to save away other properties -******************************************************************************/ - -void setup_other_props( PlyFile *plyfile, PlyElement *elem ) -{ - int i; - PlyProperty *prop; - int size = 0; - int type_size; - - /* Examine each property in decreasing order of size. */ - /* We do this so that all data types will be aligned by */ - /* word, half-word, or whatever within the structure. */ - - for ( type_size = 8; type_size > 0; type_size /= 2 ) - { - /* add up the space taken by each property, and save this information */ - /* away in the property descriptor */ - - for ( i = 0; i < elem->nprops; i++ ) - { - /* don't bother with properties we've been asked to store explicitly */ - if ( elem->store_prop[i] ) - continue; - - prop = elem->props[i]; - - /* internal types will be same as external */ - prop->internal_type = prop->external_type; - prop->count_internal = prop->count_external; - - /* list case */ - if ( prop->is_list == PLY_LIST ) - { - /* pointer to list */ - if ( type_size == sizeof ( void * ) ) - { - prop->offset = size; - size += sizeof ( void * ); /* always use size of a pointer here */ - } - - /* count of number of list elements */ - if ( type_size == ply_type_size[prop->count_external] ) - { - prop->count_offset = size; - size += ply_type_size[prop->count_external]; - } - } - /* string */ - else if ( prop->is_list == PLY_STRING ) - { - /* pointer to string */ - if ( type_size == sizeof ( char * ) ) - { - prop->offset = size; - size += sizeof ( char * ); - } - } - /* scalar */ - else if ( type_size == ply_type_size[prop->external_type] ) - { - prop->offset = size; - size += ply_type_size[prop->external_type]; - } - } - } - - /* save the size for the other_props structure */ - elem->other_size = size; -} - - -/****************************************************************************** -Specify that we want the "other" properties of an element to be tucked -away within the user's structure. - -Entry: -plyfile - file identifier -elem - the element that we want to store other_props in -offset - offset to where other_props will be stored inside user's structure - -Exit: -returns pointer to structure containing description of other_props -******************************************************************************/ - -static PlyOtherProp *get_other_properties( PlyFile *plyfile, PlyElement *elem, int offset ) -{ - int i; - PlyOtherProp *other; - PlyProperty *prop; - int nprops; - - /* remember that this is the "current" element */ - plyfile->which_elem = elem; - - /* save the offset to where to store the other_props */ - elem->other_offset = offset; - - /* place the appropriate pointers, etc. in the element's property list */ - setup_other_props ( plyfile, elem ); - - /* create structure for describing other_props */ - other = ( PlyOtherProp * ) myalloc ( sizeof ( PlyOtherProp ) ); - other->name = strdup ( elem->name ); -#if 0 -if (elem->other_offset == NO_OTHER_PROPS) { -other->size = 0; -other->props = NULL; -other->nprops = 0; -return (other); -} -#endif - other->size = elem->other_size; - other->props = ( PlyProperty * * ) myalloc ( sizeof( PlyProperty ) * elem->nprops ); - - /* save descriptions of each "other" property */ - nprops = 0; - for ( i = 0; i < elem->nprops; i++ ) - { - if ( elem->store_prop[i] ) - continue; - prop = ( PlyProperty * ) myalloc ( sizeof ( PlyProperty ) ); - copy_property ( prop, elem->props[i] ); - other->props[nprops] = prop; - nprops++; - } - other->nprops = nprops; - - /* set other_offset pointer appropriately if there are NO other properties */ - if ( other->nprops == 0 ) - { - elem->other_offset = NO_OTHER_PROPS; - } - - /* return structure */ - return ( other ); -} - - -/****************************************************************************** -Specify that we want the "other" properties of an element to be tucked -away within the user's structure. The user needn't be concerned for how -these properties are stored. - -Entry: -plyfile - file identifier -elem_name - name of element that we want to store other_props in -offset - offset to where other_props will be stored inside user's structure - -Exit: -returns pointer to structure containing description of other_props -******************************************************************************/ - -PlyOtherProp *ply_get_other_properties( PlyFile *plyfile, char *elem_name, int offset ) -{ - PlyElement *elem; - PlyOtherProp *other; - - /* find information about the element */ - elem = find_element ( plyfile, elem_name ); - if ( elem == NULL ) - { - fprintf ( stderr, "ply_get_other_properties: Can't find element '%s'\n", - elem_name ); - return ( NULL ); - } - - other = get_other_properties ( plyfile, elem, offset ); - return ( other ); -} - - - - -/*************************/ -/* Other Element Stuff */ -/*************************/ - - - - - -/****************************************************************************** -Grab all the data for the current element that a user does not want to -explicitly read in. Stores this in the PLY object's data structure. - -Entry: -plyfile - pointer to file - -Exit: -returns pointer to ALL the "other" element data for this PLY file -******************************************************************************/ - -PlyOtherElems *get_other_element_ply( PlyFile *plyfile ) -{ - int i; - PlyElement *elem; - char *elem_name; - int elem_count; - PlyOtherElems *other_elems; - OtherElem *other; - - elem = plyfile->which_elem; - elem_name = elem->name; - elem_count = elem->num; - - /* create room for the new "other" element, initializing the */ - /* other data structure if necessary */ - - if ( plyfile->other_elems == NULL ) - { - plyfile->other_elems = ( PlyOtherElems * ) myalloc ( sizeof ( PlyOtherElems ) ); - other_elems = plyfile->other_elems; - other_elems->other_list = ( OtherElem * ) myalloc ( sizeof ( OtherElem ) ); - other = &( other_elems->other_list[0] ); - other_elems->num_elems = 1; - } - else - { - other_elems = plyfile->other_elems; - other_elems->other_list = ( OtherElem * ) realloc ( other_elems->other_list, - sizeof ( OtherElem ) * other_elems->num_elems + 1 ); - other = &( other_elems->other_list[other_elems->num_elems] ); - other_elems->num_elems++; - } - - /* count of element instances in file */ - other->elem_count = elem_count; - - /* save name of element */ - other->elem_name = strdup ( elem_name ); - - /* create a list to hold all the current elements */ - other->other_data = ( OtherData * * ) - malloc ( sizeof ( OtherData * ) * other->elem_count ); - - /* set up for getting elements */ - other->other_props = ply_get_other_properties ( plyfile, elem_name, - offsetof( OtherData,other_props ) ); - - /* grab all these elements */ - for ( i = 0; i < other->elem_count; i++ ) - { - /* grab and element from the file */ - other->other_data[i] = ( OtherData * ) malloc ( sizeof ( OtherData ) ); - ply_get_element ( plyfile, ( void * ) other->other_data[i] ); - } - - /* return pointer to the other elements data */ - return ( other_elems ); -} - - -/****************************************************************************** -Write out the "other" elements specified for this PLY file. - -Entry: -plyfile - pointer to PLY file to write out other elements for -******************************************************************************/ - -void put_other_elements_ply( PlyFile *plyfile ) -{ - int i,j; - OtherElem *other; - - /* make sure we have other elements to write */ - if ( plyfile->other_elems == NULL ) - return; - - /* write out the data for each "other" element */ - - for ( i = 0; i < plyfile->other_elems->num_elems; i++ ) - { - other = &( plyfile->other_elems->other_list[i] ); - put_element_setup_ply ( plyfile, other->elem_name ); - - /* write out each instance of the current element */ - for ( j = 0; j < other->elem_count; j++ ) - put_element_ply ( plyfile, ( void * ) other->other_data[j] ); - } -} - - -/****************************************************************************** -Free up storage used by an "other" elements data structure. - -Entry: -other_elems - data structure to free up -******************************************************************************/ - -void free_other_elements_ply( PlyOtherElems *other_elems ) -{ -} - - - -/*******************/ -/* Miscellaneous */ -/*******************/ - - - -/****************************************************************************** -Close a PLY file. - -Entry: -plyfile - identifier of file to close -******************************************************************************/ - -void ply_close( PlyFile *plyfile ) -{ - fclose ( plyfile->fp ); - - /* free up memory associated with the PLY file */ - free ( plyfile ); -} - - -/****************************************************************************** -Get version number and file type of a PlyFile. - -Entry: -ply - pointer to PLY file - -Exit: -version - version of the file -file_type - PLY_ASCII, PLY_BINARY_BE, or PLY_BINARY_LE -******************************************************************************/ - -void get_info_ply( PlyFile *ply, float *version, int *file_type ) -{ - if ( ply == NULL ) - return; - - *version = ply->version; - *file_type = ply->file_type; -} - - -/****************************************************************************** -Compare two strings. Returns 1 if they are the same, 0 if not. -******************************************************************************/ - -int equal_strings( char *s1, char *s2 ) -{ - while ( *s1 && *s2 ) - if ( *s1++ != *s2++ ) - return ( 0 ); - - if ( *s1 != *s2 ) - return ( 0 ); - else - return ( 1 ); -} - - -/****************************************************************************** -Re-create the command line that was used to invoke this program. - -Entry: -argc - number of words in argv -argv - array of words in command line -******************************************************************************/ - -char *recreate_command_line( int argc, char *argv[] ) -{ - int i; - char *line; - int len = 0; - - /* count total number of characters needed, including separating spaces */ - for ( i = 0; i < argc; i++ ) - len += strlen( argv[i] ) + 1; - - /* create empty line */ - line = ( char * ) malloc ( sizeof( char ) * len ); - line[0] = '\0'; - - /* repeatedly append argv */ - for ( i = 0; i < argc; i++ ) - { - strcat ( line, argv[i] ); - if ( i != argc - 1 ) - strcat ( line, " " ); - } - - return ( line ); -} - - -/****************************************************************************** -Find an element from the element list of a given PLY object. - -Entry: -plyfile - file id for PLY file -element - name of element we're looking for - -Exit: -returns the element, or NULL if not found -******************************************************************************/ - -PlyElement *find_element( PlyFile *plyfile, char *element ) -{ - int i; - - for ( i = 0; i < plyfile->num_elem_types; i++ ) - if ( equal_strings ( element, plyfile->elems[i]->name ) ) - return ( plyfile->elems[i] ); - - return ( NULL ); -} - - -/****************************************************************************** -Find a property in the list of properties of a given element. - -Entry: -elem - pointer to element in which we want to find the property -prop_name - name of property to find - -Exit: -index - index to position in list -returns a pointer to the property, or NULL if not found -******************************************************************************/ - -PlyProperty *find_property( PlyElement *elem, char *prop_name, int *index ) -{ - int i; - - for ( i = 0; i < elem->nprops; i++ ) - if ( equal_strings ( prop_name, elem->props[i]->name ) ) - { - *index = i; - return ( elem->props[i] ); - } - - *index = -1; - return ( NULL ); -} - - -/****************************************************************************** -Read an element from an ascii file. - -Entry: -plyfile - file identifier -elem_ptr - pointer to element -******************************************************************************/ - -void ascii_get_element( PlyFile *plyfile, char *elem_ptr ) -{ - int j,k; - PlyElement *elem; - PlyProperty *prop; - char* *words; - int nwords; - int which_word; - char *elem_data,*item; - char *item_ptr; - int item_size; - int int_val; - unsigned int uint_val; - double double_val; - int list_count; - int store_it; - char* *store_array; - char *orig_line; - char *other_data; - int other_flag; - - item = (char*) NULL ; - other_data = (char*) NULL ; - - /* the kind of element we're reading currently */ - elem = plyfile->which_elem; - - /* do we need to setup for other_props? */ - - if ( elem->other_offset != NO_OTHER_PROPS ) - { - char* *ptr; - other_flag = 1; - /* make room for other_props */ - other_data = ( char * ) myalloc ( elem->other_size ); - /* store pointer in user's structure to the other_props */ - ptr = ( char * * ) ( elem_ptr + elem->other_offset ); - *ptr = other_data; - } - else - other_flag = 0; - - /* read in the element */ - - words = get_words ( plyfile->fp, &nwords, &orig_line ); - if ( words == NULL ) - { - fprintf ( stderr, "ply_get_element: unexpected end of file\n" ); - exit ( -1 ); - } - - which_word = 0; - - for ( j = 0; j < elem->nprops; j++ ) - { - prop = elem->props[j]; - store_it = ( elem->store_prop[j] | other_flag ); - - /* store either in the user's structure or in other_props */ - if ( elem->store_prop[j] ) - elem_data = elem_ptr; - else - elem_data = other_data; - - if ( prop->is_list == PLY_LIST ) - { - /* a list */ - - /* get and store the number of items in the list */ - get_ascii_item ( words[which_word++], prop->count_external, - &int_val, &uint_val, &double_val ); - if ( store_it ) - { - item = elem_data + prop->count_offset; - store_item( item, prop->count_internal, int_val, uint_val, double_val ); - } - - /* allocate space for an array of items and store a ptr to the array */ - list_count = int_val; - item_size = ply_type_size[prop->internal_type]; - store_array = ( char * * ) ( elem_data + prop->offset ); - - if ( list_count == 0 ) - { - if ( store_it ) - *store_array = NULL; - } - else - { - if ( store_it ) - { - item_ptr = ( char * ) myalloc ( sizeof ( char ) * item_size * list_count ); - item = item_ptr; - *store_array = item_ptr; - } - - /* read items and store them into the array */ - for ( k = 0; k < list_count; k++ ) - { - get_ascii_item ( words[which_word++], prop->external_type, - &int_val, &uint_val, &double_val ); - if ( store_it ) - { - store_item ( item, prop->internal_type, - int_val, uint_val, double_val ); - item += item_size; - } - } - } - } - else if ( prop->is_list == PLY_STRING ) - { - /* a string */ - if ( store_it ) - { - char *str; - char* *str_ptr; - str = strdup ( words[which_word++] ); - item = elem_data + prop->offset; - str_ptr = ( char * * ) item; - *str_ptr = str; - } - else - { - which_word++; - } - } - else - { - /* a scalar */ - get_ascii_item ( words[which_word++], prop->external_type, - &int_val, &uint_val, &double_val ); - if ( store_it ) - { - item = elem_data + prop->offset; - store_item ( item, prop->internal_type, int_val, uint_val, double_val ); - } - } - } - - free ( words ); -} - - -/****************************************************************************** -Read an element from a binary file. - -Entry: -plyfile - file identifier -elem_ptr - pointer to an element -******************************************************************************/ - -void binary_get_element( PlyFile *plyfile, char *elem_ptr ) -{ - int j,k; - PlyElement *elem; - PlyProperty *prop; - FILE *fp = plyfile->fp; - char *elem_data; - char *item; - char *item_ptr; - int item_size; - int int_val; - unsigned int uint_val; - double double_val; - int list_count; - int store_it; - char* *store_array; - char *other_data; - int other_flag; - - item = (char*) NULL ; - other_data = (char*) NULL ; - - /* the kind of element we're reading currently */ - elem = plyfile->which_elem; - - /* do we need to setup for other_props? */ - - if ( elem->other_offset != NO_OTHER_PROPS ) - { - char* *ptr; - other_flag = 1; - /* make room for other_props */ - other_data = ( char * ) myalloc ( elem->other_size ); - /* store pointer in user's structure to the other_props */ - ptr = ( char * * ) ( elem_ptr + elem->other_offset ); - *ptr = other_data; - } - else - other_flag = 0; - - /* read in a number of elements */ - - for ( j = 0; j < elem->nprops; j++ ) - { - prop = elem->props[j]; - store_it = ( elem->store_prop[j] | other_flag ); - - /* store either in the user's structure or in other_props */ - if ( elem->store_prop[j] ) - elem_data = elem_ptr; - else - elem_data = other_data; - - if ( prop->is_list == PLY_LIST ) - { - /* list */ - - /* get and store the number of items in the list */ - get_binary_item ( fp, prop->count_external, - &int_val, &uint_val, &double_val ); - if ( store_it ) - { - item = elem_data + prop->count_offset; - store_item( item, prop->count_internal, int_val, uint_val, double_val ); - } - - /* allocate space for an array of items and store a ptr to the array */ - list_count = int_val; - item_size = ply_type_size[prop->internal_type]; - store_array = ( char * * ) ( elem_data + prop->offset ); - if ( list_count == 0 ) - { - if ( store_it ) - *store_array = NULL; - } - else - { - if ( store_it ) - { - item_ptr = ( char * ) myalloc ( sizeof ( char ) * item_size * list_count ); - item = item_ptr; - *store_array = item_ptr; - } - - /* read items and store them into the array */ - for ( k = 0; k < list_count; k++ ) - { - get_binary_item ( fp, prop->external_type, - &int_val, &uint_val, &double_val ); - if ( store_it ) - { - store_item ( item, prop->internal_type, - int_val, uint_val, double_val ); - item += item_size; - } - } - } - } - else if ( prop->is_list == PLY_STRING ) - { - /* string */ - int len; - char *str; - fread ( &len, sizeof( int ), 1, fp ); - str = ( char * ) myalloc ( len ); - fread ( str, len, 1, fp ); - if ( store_it ) - { - char* *str_ptr; - item = elem_data + prop->offset; - str_ptr = ( char * * ) item; - *str_ptr = str; - } - } - else - { - /* scalar */ - get_binary_item ( fp, prop->external_type, - &int_val, &uint_val, &double_val ); - if ( store_it ) - { - item = elem_data + prop->offset; - store_item ( item, prop->internal_type, int_val, uint_val, double_val ); - } - } - } -} - - -/****************************************************************************** -Write to a file the word that represents a PLY data type. - -Entry: -fp - file pointer -code - code for type -******************************************************************************/ - -void write_scalar_type( FILE *fp, int code ) -{ - /* make sure this is a valid code */ - - if ( code <= StartType || code >= EndType ) - { - fprintf ( stderr, "write_scalar_type: bad data code = %d\n", code ); - exit ( -1 ); - } - - /* write the code to a file */ - - fprintf ( fp, "%s", type_names[code] ); -} - - -/****************************************************************************** -Get a text line from a file and break it up into words. - -IMPORTANT: The calling routine should call "free" on the returned pointer once -finished with it. - -Entry: -fp - file to read from - -Exit: -nwords - number of words returned -orig_line - the original line of characters -returns a list of words from the line, or NULL if end-of-file -******************************************************************************/ - -char **get_words( FILE *fp, int *nwords, char **orig_line ) -{ -#define BIG_STRING 4096 - static char str[BIG_STRING]; - static char str_copy[BIG_STRING]; - char* *words; - int max_words = 10; - int num_words = 0; - char *ptr,*ptr2; - char *result; - - words = ( char * * ) myalloc ( sizeof ( char * ) * max_words ); - - /* read in a line */ - result = fgets ( str, BIG_STRING, fp ); - if ( result == NULL ) - { - *nwords = 0; - *orig_line = NULL; - return ( NULL ); - } - - /* convert line-feed and tabs into spaces */ - /* (this guarentees that there will be a space before the */ - /* null character at the end of the string) */ - - str[BIG_STRING - 2] = ' '; - str[BIG_STRING - 1] = '\0'; - - for ( ptr = str, ptr2 = str_copy; *ptr != '\0'; ptr++, ptr2++ ) - { - *ptr2 = *ptr; - if ( *ptr == '\t' ) - { - *ptr = ' '; - *ptr2 = ' '; - } - else if ( *ptr == '\n' ) - { - *ptr = ' '; - *ptr2 = ' '; - break; - } - else if ( *ptr == '\r' ) - { - *ptr = ' '; - *ptr2 = '\0'; - } - } - - /* find the words in the line */ - - ptr = str; - while ( *ptr != '\0' ) - { - /* jump over leading spaces */ - while ( *ptr == ' ' ) - ptr++; - - /* break if we reach the end */ - if ( *ptr == '\0' ) - break; - - /* allocate more room for words if necessary */ - if ( num_words >= max_words ) - { - max_words += 10; - words = ( char * * ) realloc ( words, sizeof ( char * ) * max_words ); - } - - if ( *ptr == '\"' ) - { - /* a quote indidicates that we have a string */ - - /* skip over leading quote */ - ptr++; - - /* save pointer to beginning of word */ - words[num_words++] = ptr; - - /* find trailing quote or end of line */ - while ( *ptr != '\"' && *ptr != '\0' ) - ptr++; - - /* replace quote with a null character to mark the end of the word */ - /* if we are not already at the end of the line */ - if ( *ptr != '\0' ) - *ptr++ = '\0'; - } - else - { - /* non-string */ - - /* save pointer to beginning of word */ - words[num_words++] = ptr; - - /* jump over non-spaces */ - while ( *ptr != ' ' ) - ptr++; - - /* place a null character here to mark the end of the word */ - *ptr++ = '\0'; - } - } - - /* return the list of words */ - *nwords = num_words; - *orig_line = str_copy; - return ( words ); -} - - -/****************************************************************************** -Return the value of an item, given a pointer to it and its type. - -Entry: -item - pointer to item -type - data type that "item" points to - -Exit: -returns a double-precision float that contains the value of the item -******************************************************************************/ - -double get_item_value( char *item, int type ) -{ - unsigned char *puchar; - char *pchar; - short int *pshort; - unsigned short int *pushort; - int *pint; - unsigned int *puint; - float *pfloat; - double *pdouble; - int int_value; - unsigned int uint_value; - double double_value; - - switch ( type ) - { - case Int8: - pchar = ( char * ) item; - int_value = *pchar; - return ( ( double ) int_value ); - case Uint8: - puchar = ( unsigned char * ) item; - int_value = *puchar; - return ( ( double ) int_value ); - case Int16: - pshort = ( short int * ) item; - int_value = *pshort; - return ( ( double ) int_value ); - case Uint16: - pushort = ( unsigned short int * ) item; - int_value = *pushort; - return ( ( double ) int_value ); - case Int32: - pint = ( int * ) item; - int_value = *pint; - return ( ( double ) int_value ); - case Uint32: - puint = ( unsigned int * ) item; - uint_value = *puint; - return ( ( double ) uint_value ); - case Float32: - pfloat = ( float * ) item; - double_value = *pfloat; - return ( double_value ); - case Float64: - pdouble = ( double * ) item; - double_value = *pdouble; - return ( double_value ); - default: - fprintf ( stderr, "get_item_value: bad type = %d\n", type ); - exit ( -1 ); - } - - return ( 0.0 ); /* never actually gets here */ -} - - -/****************************************************************************** -Write out an item to a file as raw binary bytes. - -Entry: -fp - file to write to -int_val - integer version of item -uint_val - unsigned integer version of item -double_val - double-precision float version of item -type - data type to write out -******************************************************************************/ - -void write_binary_item( FILE *fp, int int_val, unsigned int uint_val, double double_val, int type ) -{ - unsigned char uchar_val; - char char_val; - unsigned short ushort_val; - short short_val; - float float_val; - - switch ( type ) - { - case Int8: - char_val = int_val; - fwrite ( &char_val, 1, 1, fp ); - break; - case Int16: - short_val = int_val; - fwrite ( &short_val, 2, 1, fp ); - break; - case Int32: - fwrite ( &int_val, 4, 1, fp ); - break; - case Uint8: - uchar_val = uint_val; - fwrite ( &uchar_val, 1, 1, fp ); - break; - case Uint16: - ushort_val = uint_val; - fwrite ( &ushort_val, 2, 1, fp ); - break; - case Uint32: - fwrite ( &uint_val, 4, 1, fp ); - break; - case Float32: - float_val = ( float ) double_val; - fwrite ( &float_val, 4, 1, fp ); - break; - case Float64: - fwrite ( &double_val, 8, 1, fp ); - break; - default: - fprintf ( stderr, "write_binary_item: bad type = %d\n", type ); - exit ( -1 ); - } -} - - -/****************************************************************************** -Write out an item to a file as ascii characters. - -Entry: -fp - file to write to -int_val - integer version of item -uint_val - unsigned integer version of item -double_val - double-precision float version of item -type - data type to write out -******************************************************************************/ - -void write_ascii_item( FILE *fp, int int_val, unsigned int uint_val, double double_val, int type ) -{ - switch ( type ) - { - case Int8: - case Int16: - case Int32: - fprintf ( fp, "%d ", int_val ); - break; - case Uint8: - case Uint16: - case Uint32: - fprintf ( fp, "%u ", uint_val ); - break; - case Float32: - case Float64: - fprintf ( fp, "%12f ", double_val ); - break; - default: - fprintf ( stderr, "write_ascii_item: bad type = %d\n", type ); - exit ( -1 ); - } -} - - -/****************************************************************************** -Get the value of an item that is in memory, and place the result -into an integer, an unsigned integer and a double. - -Entry: -ptr - pointer to the item -type - data type supposedly in the item - -Exit: -int_val - integer value -uint_val - unsigned integer value -double_val - double-precision floating point value -******************************************************************************/ - -void get_stored_item( void *ptr, int type, int *int_val, unsigned int *uint_val, double *double_val ) -{ - switch ( type ) - { - case Int8: - *int_val = *( ( char * ) ptr ); - *uint_val = *int_val; - *double_val = *int_val; - break; - case Uint8: - *uint_val = *( ( unsigned char * ) ptr ); - *int_val = *uint_val; - *double_val = *uint_val; - break; - case Int16: - *int_val = *( ( short int * ) ptr ); - *uint_val = *int_val; - *double_val = *int_val; - break; - case Uint16: - *uint_val = *( ( unsigned short int * ) ptr ); - *int_val = *uint_val; - *double_val = *uint_val; - break; - case Int32: - *int_val = *( ( int * ) ptr ); - *uint_val = *int_val; - *double_val = *int_val; - break; - case Uint32: - *uint_val = *( ( unsigned int * ) ptr ); - *int_val = *uint_val; - *double_val = *uint_val; - break; - case Float32: - *double_val = *( ( float * ) ptr ); - *int_val = ( int ) *double_val; - *uint_val = ( unsigned int ) *double_val; - break; - case Float64: - *double_val = *( ( double * ) ptr ); - *int_val = ( int ) *double_val; - *uint_val = ( unsigned int ) *double_val; - break; - default: - fprintf ( stderr, "get_stored_item: bad type = %d\n", type ); - exit ( -1 ); - } -} - - -/****************************************************************************** -Get the value of an item from a binary file, and place the result -into an integer, an unsigned integer and a double. - -Entry: -fp - file to get item from -type - data type supposedly in the word - -Exit: -int_val - integer value -uint_val - unsigned integer value -double_val - double-precision floating point value -******************************************************************************/ - -void get_binary_item( FILE *fp, int type, int *int_val, unsigned int *uint_val, double *double_val ) -{ - char c[8]; - void *ptr; - - ptr = ( void * ) c; - - switch ( type ) - { - case Int8: - fread ( ptr, 1, 1, fp ); - *int_val = *( ( char * ) ptr ); - *uint_val = *int_val; - *double_val = *int_val; - break; - case Uint8: - fread ( ptr, 1, 1, fp ); - *uint_val = *( ( unsigned char * ) ptr ); - *int_val = *uint_val; - *double_val = *uint_val; - break; - case Int16: - fread ( ptr, 2, 1, fp ); - *int_val = *( ( short int * ) ptr ); - *uint_val = *int_val; - *double_val = *int_val; - break; - case Uint16: - fread ( ptr, 2, 1, fp ); - *uint_val = *( ( unsigned short int * ) ptr ); - *int_val = *uint_val; - *double_val = *uint_val; - break; - case Int32: - fread ( ptr, 4, 1, fp ); - *int_val = *( ( int * ) ptr ); - *uint_val = *int_val; - *double_val = *int_val; - break; - case Uint32: - fread ( ptr, 4, 1, fp ); - *uint_val = *( ( unsigned int * ) ptr ); - *int_val = *uint_val; - *double_val = *uint_val; - break; - case Float32: - fread ( ptr, 4, 1, fp ); - *double_val = *( ( float * ) ptr ); - *int_val = ( int ) *double_val; - *uint_val = ( unsigned int ) *double_val; - break; - case Float64: - fread ( ptr, 8, 1, fp ); - *double_val = *( ( double * ) ptr ); - *int_val = ( int ) *double_val; - *uint_val = ( unsigned int ) *double_val; - break; - default: - fprintf ( stderr, "get_binary_item: bad type = %d\n", type ); - exit ( -1 ); - } -} - - -/****************************************************************************** -Extract the value of an item from an ascii word, and place the result -into an integer, an unsigned integer and a double. - -Entry: -word - word to extract value from -type - data type supposedly in the word - -Exit: -int_val - integer value -uint_val - unsigned integer value -double_val - double-precision floating point value -******************************************************************************/ - -void get_ascii_item( char *word, int type, int *int_val, unsigned int *uint_val, double *double_val ) -{ - switch ( type ) - { - case Int8: - case Uint8: - case Int16: - case Uint16: - case Int32: - *int_val = atoi ( word ); - *uint_val = *int_val; - *double_val = *int_val; - break; - - case Uint32: - *uint_val = strtoul ( word, ( char * * ) NULL, 10 ); - *int_val = *uint_val; - *double_val = *uint_val; - break; - - case Float32: - case Float64: - *double_val = atof ( word ); - *int_val = ( int ) *double_val; - *uint_val = ( unsigned int ) *double_val; - break; - - default: - fprintf ( stderr, "get_ascii_item: bad type = %d\n", type ); - exit ( -1 ); - } -} - - -/****************************************************************************** -Store a value into a place being pointed to, guided by a data type. - -Entry: -item - place to store value -type - data type -int_val - integer version of value -uint_val - unsigned integer version of value -double_val - double version of value - -Exit: -item - pointer to stored value -******************************************************************************/ - -void store_item( char *item, int type, int int_val, unsigned int uint_val, double double_val ) -{ - unsigned char *puchar; - short int *pshort; - unsigned short int *pushort; - int *pint; - unsigned int *puint; - float *pfloat; - double *pdouble; - - switch ( type ) - { - case Int8: - *item = int_val; - break; - case Uint8: - puchar = ( unsigned char * ) item; - *puchar = uint_val; - break; - case Int16: - pshort = ( short * ) item; - *pshort = int_val; - break; - case Uint16: - pushort = ( unsigned short * ) item; - *pushort = uint_val; - break; - case Int32: - pint = ( int * ) item; - *pint = int_val; - break; - case Uint32: - puint = ( unsigned int * ) item; - *puint = uint_val; - break; - case Float32: - pfloat = ( float * ) item; - *pfloat = ( float ) double_val; - break; - case Float64: - pdouble = ( double * ) item; - *pdouble = double_val; - break; - default: - fprintf ( stderr, "store_item: bad type = %d\n", type ); - exit ( -1 ); - } -} - - -/****************************************************************************** -Add an element to a PLY file descriptor. - -Entry: -plyfile - PLY file descriptor -words - list of words describing the element -nwords - number of words in the list -******************************************************************************/ - -void add_element( PlyFile *plyfile, char **words, int nwords ) -{ - PlyElement *elem; - - /* create the new element */ - elem = ( PlyElement * ) myalloc ( sizeof ( PlyElement ) ); - elem->name = strdup ( words[1] ); - elem->num = atoi ( words[2] ); - elem->nprops = 0; - - /* make room for new element in the object's list of elements */ - if ( plyfile->num_elem_types == 0 ) - plyfile->elems = ( PlyElement * * ) myalloc ( sizeof ( PlyElement * ) ); - else - plyfile->elems = ( PlyElement * * ) realloc ( plyfile->elems, - sizeof ( PlyElement * ) * ( plyfile->num_elem_types + 1 ) ); - - /* add the new element to the object's list */ - plyfile->elems[plyfile->num_elem_types] = elem; - plyfile->num_elem_types++; -} - - -/****************************************************************************** -Return the type of a property, given the name of the property. - -Entry: -name - name of property type - -Exit: -returns integer code for property, or 0 if not found -******************************************************************************/ - -int get_prop_type( char *type_name ) -{ - int i; - - /* try to match the type name */ - for ( i = StartType + 1; i < EndType; i++ ) - if ( equal_strings ( type_name, type_names[i] ) ) - return ( i ); - - /* see if we can match an old type name */ - for ( i = StartType + 1; i < EndType; i++ ) - if ( equal_strings ( type_name, old_type_names[i] ) ) - return ( i ); - - /* if we get here, we didn't find the type */ - return ( 0 ); -} - - -/****************************************************************************** -Add a property to a PLY file descriptor. - -Entry: -plyfile - PLY file descriptor -words - list of words describing the property -nwords - number of words in the list -******************************************************************************/ - -void add_property( PlyFile *plyfile, char **words, int nwords ) -{ - PlyProperty *prop; - PlyElement *elem; - - /* create the new property */ - - prop = ( PlyProperty * ) myalloc ( sizeof ( PlyProperty ) ); - - if ( equal_strings ( words[1], "list" ) ) - { - /* list */ - prop->count_external = get_prop_type ( words[2] ); - prop->external_type = get_prop_type ( words[3] ); - prop->name = strdup ( words[4] ); - prop->is_list = PLY_LIST; - } - else if ( equal_strings ( words[1], "string" ) ) - { - /* string */ - prop->count_external = Int8; - prop->external_type = Int8; - prop->name = strdup ( words[2] ); - prop->is_list = PLY_STRING; - } - else - { - /* scalar */ - prop->external_type = get_prop_type ( words[1] ); - prop->name = strdup ( words[2] ); - prop->is_list = PLY_SCALAR; - } - - /* add this property to the list of properties of the current element */ - - elem = plyfile->elems[plyfile->num_elem_types - 1]; - - if ( elem->nprops == 0 ) - elem->props = ( PlyProperty * * ) myalloc ( sizeof ( PlyProperty * ) ); - else - elem->props = ( PlyProperty * * ) realloc ( elem->props, - sizeof ( PlyProperty * ) * ( elem->nprops + 1 ) ); - - elem->props[elem->nprops] = prop; - elem->nprops++; -} - - -/****************************************************************************** -Add a comment to a PLY file descriptor. - -Entry: -plyfile - PLY file descriptor -line - line containing comment -******************************************************************************/ - -void add_comment( PlyFile *plyfile, char *line ) -{ - int i; - - /* skip over "comment" and leading spaces and tabs */ - i = 7; - while ( line[i] == ' ' || line[i] == '\t' ) - i++; - - append_comment_ply ( plyfile, &line[i] ); -} - - -/****************************************************************************** -Add a some object information to a PLY file descriptor. - -Entry: -plyfile - PLY file descriptor -line - line containing text info -******************************************************************************/ - -void add_obj_info( PlyFile *plyfile, char *line ) -{ - int i; - - /* skip over "obj_info" and leading spaces and tabs */ - i = 8; - while ( line[i] == ' ' || line[i] == '\t' ) - i++; - - append_obj_info_ply ( plyfile, &line[i] ); -} - - -/****************************************************************************** -Copy a property. -******************************************************************************/ - -void copy_property( PlyProperty *dest, PlyProperty *src ) -{ - dest->name = strdup ( src->name ); - dest->external_type = src->external_type; - dest->internal_type = src->internal_type; - dest->offset = src->offset; - - dest->is_list = src->is_list; - dest->count_external = src->count_external; - dest->count_internal = src->count_internal; - dest->count_offset = src->count_offset; -} - - -/****************************************************************************** -Allocate some memory. - -Entry: -size - amount of memory requested (in bytes) -lnum - line number from which memory was requested -fname - file name from which memory was requested -******************************************************************************/ - -static char *my_alloc( int size, int lnum, char *fname ) -{ - char *ptr; - - ptr = ( char * ) malloc ( size ); - - if ( ptr == 0 ) - { - fprintf( stderr, "Memory allocation bombed on line %d in %s\n", lnum, fname ); - } - - return ( ptr ); -} - - -/**** NEW STUFF ****/ -/**** NEW STUFF ****/ -/**** NEW STUFF ****/ -/**** NEW STUFF ****/ - - - -/****************************************************************************** -Given a file pointer, get ready to read PLY data from the file. - -Entry: -fp - the given file pointer - -Exit: -nelems - number of elements in object -elem_names - list of element names -returns a pointer to a PlyFile, used to refer to this file, or NULL if error -******************************************************************************/ - -PlyFile *read_ply( FILE *fp ) -{ - PlyFile *ply; - int num_elems; - char* *elem_names; - - ply = ply_read ( fp, &num_elems, &elem_names ); - - return ( ply ); -} - - -/****************************************************************************** -Given a file pointer, get ready to write PLY data to the file. - -Entry: -fp - the given file pointer -nelems - number of elements in object -elem_names - list of element names -file_type - file type, either ascii or binary - -Exit: -returns a pointer to a PlyFile, used to refer to this file, or NULL if error -******************************************************************************/ - -PlyFile *write_ply( FILE *fp, int nelems, char **elem_names, int file_type ) -{ - PlyFile *ply; - - ply = ply_write ( fp, nelems, elem_names, file_type ); - - return ( ply ); -} - - -/****************************************************************************** -Return a list of the names of the elements in a particular PLY file. - -Entry: -ply - PLY file whose element name list we want - -Exit: -num_elems - the number of element names in the list -returns the list of names -******************************************************************************/ - -char **get_element_list_ply( PlyFile *ply, int *num_elems ) -{ - int i; - char* *elist; - - /* create the list of element names */ - - elist = ( char * * ) myalloc ( sizeof ( char * ) * ply->num_elem_types ); - for ( i = 0; i < ply->num_elem_types; i++ ) - elist[i] = strdup ( ply->elems[i]->name ); - - /* return the number of elements and the list of element names */ - *num_elems = ply->num_elem_types; - return ( elist ); -} - - -/****************************************************************************** -Append a comment to a PLY file. - -Entry: -ply - file to append comment to -comment - the comment to append -******************************************************************************/ - -void append_comment_ply( PlyFile *ply, char *comment ) -{ - /* (re)allocate space for new comment */ - if ( ply->num_comments == 0 ) - ply->comments = ( char * * ) myalloc ( sizeof ( char * ) ); - else - ply->comments = ( char * * ) realloc ( ply->comments, - sizeof ( char * ) * ( ply->num_comments + 1 ) ); - - /* add comment to list */ - ply->comments[ply->num_comments] = strdup ( comment ); - ply->num_comments++; -} - - -/****************************************************************************** -Copy the comments from one PLY file to another. - -Entry: -out_ply - destination file to copy comments to -in_ply - the source of the comments -******************************************************************************/ - -void copy_comments_ply( PlyFile *out_ply, PlyFile *in_ply ) -{ - int i; - - for ( i = 0; i < in_ply->num_comments; i++ ) - append_comment_ply ( out_ply, in_ply->comments[i] ); -} - - -/****************************************************************************** -Append object information (arbitrary text) to a PLY file. - -Entry: -ply - file to append object info to -obj_info - the object info to append -******************************************************************************/ - -void append_obj_info_ply( PlyFile *ply, char *obj_info ) -{ - /* (re)allocate space for new info */ - if ( ply->num_obj_info == 0 ) - ply->obj_info = ( char * * ) myalloc ( sizeof ( char * ) ); - else - ply->obj_info = ( char * * ) realloc ( ply->obj_info, - sizeof ( char * ) * ( ply->num_obj_info + 1 ) ); - - /* add info to list */ - ply->obj_info[ply->num_obj_info] = strdup ( obj_info ); - ply->num_obj_info++; -} - - -/****************************************************************************** -Copy the object information from one PLY file to another. - -Entry: -out_ply - destination file to copy object information to -in_ply - the source of the object information -******************************************************************************/ - -void copy_obj_info_ply( PlyFile *out_ply, PlyFile *in_ply ) -{ - int i; - - for ( i = 0; i < in_ply->num_obj_info; i++ ) - append_obj_info_ply ( out_ply, in_ply->obj_info[i] ); -} - - -/****************************************************************************** -Close a PLY file. - -Entry: -plyfile - identifier of file to close -******************************************************************************/ - -void close_ply( PlyFile *plyfile ) -{ - fclose ( plyfile->fp ); -} - - -/****************************************************************************** -Free the memory used by a PLY file. - -Entry: -plyfile - identifier of file -******************************************************************************/ - -void free_ply( PlyFile *plyfile ) -{ - /* free up memory associated with the PLY file */ - free ( plyfile ); -} - - -/****************************************************************************** -Specify the index of the next element to be read in from a PLY file. - -Entry: -ply - file to read from -index - index of the element to be read - -Exit: -elem_count - the number of elements in the file -returns pointer to the name of this next element -******************************************************************************/ - -char *setup_element_read_ply( PlyFile *ply, int index, int *elem_count ) -{ - PlyElement *elem; - - if ( index < 0 || index > ply->num_elem_types ) - { - fprintf ( stderr, "Warning: No element with index %d\n", index ); - return ( 0 ); - } - - elem = ply->elems[index]; - - /* set this to be the current element */ - ply->which_elem = elem; - - /* return the number of such elements in the file and the element's name */ - *elem_count = elem->num; - return ( elem->name ); -} - - -/****************************************************************************** -Read one element from the file. This routine assumes that we're reading -the type of element specified in the last call to the routine -setup_element_read_ply(). - -Entry: -plyfile - file identifier -elem_ptr - pointer to location where the element information should be put -******************************************************************************/ - -void get_element_ply( PlyFile *plyfile, void *elem_ptr ) -{ - if ( plyfile->file_type == PLY_ASCII ) - ascii_get_element ( plyfile, ( char * ) elem_ptr ); - else - binary_get_element ( plyfile, ( char * ) elem_ptr ); -} - - -/****************************************************************************** -Specify one of several properties of the current element that is to be -read from a file. This should be called (usually multiple times) before a -call to the routine get_element_ply(). - -Entry: -plyfile - file identifier -prop - property to add to those that will be returned - -Exit: -0 if the property has not been found -1 if the property has been found -******************************************************************************/ - -int setup_property_ply( PlyFile *plyfile, PlyProperty *prop ) -{ - PlyElement *elem; - PlyProperty *prop_ptr; - int index; - - elem = plyfile->which_elem; - - /* deposit the property information into the element's description */ - - prop_ptr = find_property ( elem, prop->name, &index ); - if ( prop_ptr == NULL ) - { - fprintf ( stderr, "Warning: Can't find property '%s' in element '%s'\n", - prop->name, elem->name ); - return 0; - } - prop_ptr->internal_type = prop->internal_type; - prop_ptr->offset = prop->offset; - prop_ptr->count_internal = prop->count_internal; - prop_ptr->count_offset = prop->count_offset; - - /* specify that the user wants this property */ - elem->store_prop[index] = STORE_PROP; - return 1 ; -} - - -/****************************************************************************** -Specify that we want the "other" properties of the current element to be tucked -away within the user's structure. - -Entry: -plyfile - file identifier -offset - offset to where other_props will be stored inside user's structure - -Exit: -returns pointer to structure containing description of other_props -******************************************************************************/ - -PlyOtherProp *get_other_properties_ply( PlyFile *plyfile, int offset ) -{ - PlyOtherProp *other; - - other = get_other_properties ( plyfile, plyfile->which_elem, offset ); - return ( other ); -} - - -/****************************************************************************** -Describe which element is to be written next and state how many of them will -be written. - -Entry: -plyfile - file identifier -elem_name - name of element that information is being described -nelems - number of elements of this type to be written -******************************************************************************/ - -void describe_element_ply( PlyFile *plyfile, char *elem_name, int nelems ) -{ - PlyElement *elem; - - /* look for appropriate element */ - elem = find_element ( plyfile, elem_name ); - if ( elem == NULL ) - { - fprintf( stderr,"describe_element_ply: can't find element '%s'\n",elem_name ); - exit ( -1 ); - } - - elem->num = nelems; - - /* now this element is the current element */ - plyfile->which_elem = elem; -} - - -/****************************************************************************** -Describe a property of an element. - -Entry: -plyfile - file identifier -prop - the new property -******************************************************************************/ - -void describe_property_ply( PlyFile *plyfile, PlyProperty *prop ) -{ - PlyElement *elem; - PlyProperty *elem_prop; - - elem = plyfile->which_elem; - - /* create room for new property */ - - if ( elem->nprops == 0 ) - { - elem->props = ( PlyProperty * * ) myalloc ( sizeof ( PlyProperty * ) ); - elem->store_prop = ( char * ) myalloc ( sizeof ( char ) ); - elem->nprops = 1; - } - else - { - elem->nprops++; - elem->props = ( PlyProperty * * ) - realloc ( elem->props, sizeof ( PlyProperty * ) * elem->nprops ); - elem->store_prop = ( char * ) - realloc ( elem->store_prop, sizeof ( char ) * elem->nprops ); - } - - /* copy the new property */ - - elem_prop = ( PlyProperty * ) myalloc ( sizeof ( PlyProperty ) ); - elem->props[elem->nprops - 1] = elem_prop; - elem->store_prop[elem->nprops - 1] = NAMED_PROP; - copy_property ( elem_prop, prop ); -} - - -/****************************************************************************** -Describe what the "other" properties are that are to be stored, and where -they are in an element. -******************************************************************************/ - -void describe_other_properties_ply( PlyFile *plyfile, PlyOtherProp *other, int offset ) -{ - int i; - PlyElement *elem; - PlyProperty *prop; - - /* look for appropriate element */ - elem = find_element ( plyfile, other->name ); - if ( elem == NULL ) - { - fprintf( stderr, "describe_other_properties_ply: can't find element '%s'\n", - other->name ); - return; - } - - /* create room for other properties */ - - if ( elem->nprops == 0 ) - { - elem->props = ( PlyProperty * * ) - myalloc ( sizeof ( PlyProperty * ) * other->nprops ); - elem->store_prop = ( char * ) myalloc ( sizeof ( char ) * other->nprops ); - elem->nprops = 0; - } - else - { - int newsize; - newsize = elem->nprops + other->nprops; - elem->props = ( PlyProperty * * ) - realloc ( elem->props, sizeof ( PlyProperty * ) * newsize ); - elem->store_prop = ( char * ) - realloc ( elem->store_prop, sizeof ( char ) * newsize ); - } - - /* copy the other properties */ - - for ( i = 0; i < other->nprops; i++ ) - { - prop = ( PlyProperty * ) myalloc ( sizeof ( PlyProperty ) ); - copy_property ( prop, other->props[i] ); - elem->props[elem->nprops] = prop; - elem->store_prop[elem->nprops] = OTHER_PROP; - elem->nprops++; - } - - /* save other info about other properties */ - elem->other_size = other->size; - elem->other_offset = offset; -} - - -/****************************************************************************** -Pass along a pointer to "other" elements that we want to save in a given -PLY file. These other elements were presumably read from another PLY file. - -Entry: -plyfile - file pointer in which to store this other element info -other_elems - info about other elements that we want to store -******************************************************************************/ - -void describe_other_elements_ply( PlyFile *plyfile, PlyOtherElems *other_elems ) -{ - int i; - OtherElem *other; - - /* ignore this call if there is no other element */ - if ( other_elems == NULL ) - return; - - /* save pointer to this information */ - plyfile->other_elems = other_elems; - - /* describe the other properties of this element */ - - for ( i = 0; i < other_elems->num_elems; i++ ) - { - other = &( other_elems->other_list[i] ); - element_count_ply ( plyfile, other->elem_name, other->elem_count ); - describe_other_properties_ply ( plyfile, other->other_props, - offsetof( OtherData,other_props ) ); - } -} - - - -/**** Property Propagation Rules ****/ - - -typedef struct RuleName { -int code; -char *name; -} RuleName; - -RuleName rule_name_list[] = { -{AVERAGE_RULE, "avg"}, -{RANDOM_RULE, "rnd"}, -{MINIMUM_RULE, "max"}, -{MAXIMUM_RULE, "min"}, -{MAJORITY_RULE, "major"}, -{SAME_RULE, "same"}, -{-1, "end_marker"}, -}; - - - -/****************************************************************************** -Initialize the property propagation rules for an element. Default is to -use averaging (AVERAGE_RULE) for creating all new properties. - -Entry: -ply - PLY object that this is for -elem_name - name of the element that we're making the rules for - -Exit: -returns pointer to the default rules -******************************************************************************/ - -PlyPropRules *init_rule_ply( PlyFile *ply, char *elem_name ) -{ - int i,j; - PlyElement *elem; - PlyPropRules *rules; - PlyRuleList *list; - int found_prop; - - elem = find_element ( ply, elem_name ); - if ( elem == NULL ) - { - fprintf ( stderr, "init_rule_ply: Can't find element '%s'\n", elem_name ); - exit ( -1 ); - } - - rules = ( PlyPropRules * ) myalloc ( sizeof ( PlyPropRules ) ); - rules->elem = elem; - rules->rule_list = ( int * ) myalloc ( sizeof( int ) * elem->nprops ); - rules->max_props = 0; - rules->nprops = 0; - - /* default is to use averaging rule */ - for ( i = 0; i < elem->nprops; i++ ) - rules->rule_list[i] = AVERAGE_RULE; - - /* see if there are other rules we should use */ - - if ( ply->rule_list == NULL ) - return ( rules ); - - /* try to match the element, property and rule name */ - - for ( list = ply->rule_list; list != NULL; list = list->next ) - { - if ( !equal_strings ( list->element, elem->name ) ) - continue; - - found_prop = 0; - - for ( i = 0; i < elem->nprops; i++ ) - if ( equal_strings ( list->property, elem->props[i]->name ) ) - { - found_prop = 1; - - /* look for matching rule name */ - for ( j = 0; rule_name_list[j].code != -1; j++ ) - if ( equal_strings ( list->name, rule_name_list[j].name ) ) - { - rules->rule_list[i] = rule_name_list[j].code; - break; - } - } - - if ( !found_prop ) - { - fprintf ( stderr, "Can't find property '%s' for rule '%s'\n", - list->property, list->name ); - continue; - } - } - - return ( rules ); -} - - -/****************************************************************************** -odify a property propagation rule. - -Entry: -rules - rules for the element -prop_name - name of the property whose rule we're modifying -rule_type - type of rule (MAXIMUM_RULE, MINIMUM_RULE, MAJORITY_RULE, etc.) -******************************************************************************/ - -void modify_rule_ply( PlyPropRules *rules, char *prop_name, int rule_type ) -{ - int i; - PlyElement *elem = rules->elem; - - /* find the property and modify its rule type */ - - for ( i = 0; i < elem->nprops; i++ ) - if ( equal_strings ( elem->props[i]->name, prop_name ) ) - { - rules->rule_list[i] = rule_type; - return; - } - - /* we didn't find the property if we get here */ - fprintf ( stderr, "modify_rule_ply: Can't find property '%s'\n", prop_name ); - exit ( -1 ); -} - - -/****************************************************************************** -Begin to create a set of properties from a set of propagation rules. - -Entry: -ply - PLY object whose rules we're preparing to use -rules - rules for the element -******************************************************************************/ - -void start_props_ply( PlyFile *ply, PlyPropRules *rules ) -{ - /* PlyElement *elem = rules->elem; */ - - /* save pointer to the rules in the PLY object */ - ply->current_rules = rules; - - /* get ready for new sets of properties to combine */ - rules->nprops = 0; -} - - -/****************************************************************************** -Remember a set of properties and their weights for creating a new set of -properties. - -Entry: -weight - weights for this set of properties -other_props - the properties to use -******************************************************************************/ - -void weight_props_ply( PlyFile *ply, float weight, void *other_props ) -{ - PlyPropRules *rules = ply->current_rules; - - /* allocate space for properties and weights, if necessary */ - if ( rules->max_props == 0 ) - { - rules->max_props = 6; - rules->props = ( void * * ) myalloc ( sizeof ( void * ) * rules->max_props ); - rules->weights = ( float * ) myalloc ( sizeof ( float ) * rules->max_props ); - } - if ( rules->nprops == rules->max_props ) - { - rules->max_props *= 2; - rules->props = ( void * * ) realloc ( rules->props, - sizeof ( void * ) * rules->max_props ); - rules->weights = ( float * ) realloc ( rules->weights, - sizeof ( float ) * rules->max_props ); - } - - /* remember these new properties and their weights */ - - rules->props[rules->nprops] = other_props; - rules->weights[rules->nprops] = weight; - rules->nprops++; -} - - -/****************************************************************************** -Return a pointer to a new set of properties that have been created using -a specified set of property combination rules and a given collection of -"other" properties. - -Exit: -returns a pointer to the new properties -******************************************************************************/ - -void *get_new_props_ply( PlyFile *ply ) -{ - int i,j; - static double *vals; - static int max_vals = 0; - PlyPropRules *rules = ply->current_rules; - PlyElement *elem = rules->elem; - PlyProperty *prop; - char *data; - char *new_data; - void *ptr; - int offset; - int type; - double double_val; - int int_val; - unsigned int uint_val; - int random_pick; - - /* return NULL if we've got no "other" properties */ - if ( elem->other_size == 0 ) - { - return ( NULL ); - } - - /* create room for combined other properties */ - new_data = ( char * ) myalloc ( sizeof ( char ) * elem->other_size ); - - /* make sure there is enough room to store values we're to combine */ - - if ( max_vals == 0 ) - { - max_vals = rules->nprops; - vals = ( double * ) myalloc ( sizeof ( double ) * rules->nprops ); - } - if ( rules->nprops >= max_vals ) - { - max_vals = rules->nprops; - vals = ( double * ) realloc ( vals, sizeof ( double ) * rules->nprops ); - } - - /* in case we need a random choice */ - random_pick = ( int ) floor ( rules->nprops ); //* drand48()); - - /* calculate the combination for each "other" property of the element */ - - for ( i = 0; i < elem->nprops; i++ ) - { - /* don't bother with properties we've been asked to store explicitly */ - if ( elem->store_prop[i] ) - continue; - - prop = elem->props[i]; - offset = prop->offset; - type = prop->external_type; - - /* collect together all the values we're to combine */ - - for ( j = 0; j < rules->nprops; j++ ) - { - data = ( char * ) rules->props[j]; - ptr = ( void * ) ( data + offset ); - get_stored_item ( ( void * ) ptr, type, &int_val, &uint_val, &double_val ); - vals[j] = double_val; - } - - /* calculate the combined value */ - - switch ( rules->rule_list[i] ) - { - case AVERAGE_RULE: - { - double sum = 0; - double weight_sum = 0; - for ( j = 0; j < rules->nprops; j++ ) - { - sum += vals[j] * rules->weights[j]; - weight_sum += rules->weights[j]; - } - double_val = sum / weight_sum; - break; - } - case MINIMUM_RULE: - { - double_val = vals[0]; - for ( j = 1; j < rules->nprops; j++ ) - if ( double_val > vals[j] ) - double_val = vals[j]; - break; - } - case MAXIMUM_RULE: - { - double_val = vals[0]; - for ( j = 1; j < rules->nprops; j++ ) - if ( double_val < vals[j] ) - double_val = vals[j]; - break; - } - case RANDOM_RULE: - { - double_val = vals[random_pick]; - break; - } - case SAME_RULE: - { - double_val = vals[0]; - for ( j = 1; j < rules->nprops; j++ ) - if ( double_val != vals[j] ) - { - fprintf ( stderr, - "get_new_props_ply: Error combining properties that should be the same.\n" ); - exit ( -1 ); - } - break; - } - default: - fprintf ( stderr, "get_new_props_ply: Bad rule = %d\n", - rules->rule_list[i] ); - exit ( -1 ); - } - - /* store the combined value */ - - int_val = ( int ) double_val; - uint_val = ( unsigned int ) double_val; - ptr = ( void * ) ( new_data + offset ); - store_item ( ( char * ) ptr, type, int_val, uint_val, double_val ); - } - - return ( ( void * ) new_data ); -} - - -/****************************************************************************** -Set the list of user-specified property combination rules. -******************************************************************************/ - -void set_prop_rules_ply( PlyFile *ply, PlyRuleList *prop_rules ) -{ - ply->rule_list = prop_rules; -} - - -/****************************************************************************** -Append a property rule to a growing list of user-specified rules. - -Entry: -rule_list - current rule list -name - name of property combination rule -property - "element.property" says which property the rule affects - -Exit: -returns pointer to the new rule list -******************************************************************************/ - -PlyRuleList *append_prop_rule( PlyRuleList *rule_list, char *name, char *property ) -{ - PlyRuleList *rule; - PlyRuleList *rule_ptr; - char *str,*str2; - char *ptr; - - /* find . */ - str = strdup ( property ); - for ( ptr = str; *ptr != '\0' && *ptr != '.'; ptr++ ) - ; - - /* split string at . */ - if ( *ptr == '.' ) - { - *ptr = '\0'; - str2 = ptr + 1; - } - else - { - fprintf ( stderr, "Can't find property '%s' for rule '%s'\n", - property, name ); - return ( rule_list ); - } - - rule = ( PlyRuleList * ) malloc ( sizeof ( PlyRuleList ) ); - rule->name = name; - rule->element = str; - rule->property = str2; - rule->next = NULL; - - /* either start rule list or append to it */ - - if ( rule_list == NULL ) - rule_list = rule; - else - { - /* append new rule to current list */ - rule_ptr = rule_list; - while ( rule_ptr->next != NULL ) - rule_ptr = rule_ptr->next; - rule_ptr->next = rule; - } - - /* return pointer to list */ - - return ( rule_list ); -} - - -/****************************************************************************** -See if a name matches the name of any property combination rules. - -Entry: -name - name of rule we're trying to match - -Exit: -returns 1 if we find a match, 0 if not -******************************************************************************/ - -int matches_rule_name( char *name ) -{ - int i; - - for ( i = 0; rule_name_list[i].code != -1; i++ ) - if ( equal_strings ( rule_name_list[i].name, name ) ) - return ( 1 ); - - return ( 0 ); -} - diff --git a/applications/utilities/mesh/generation/cvMesh/cvMeshSurfaceSimplify/MarchingCubes/ply.h b/applications/utilities/mesh/generation/cvMesh/cvMeshSurfaceSimplify/MarchingCubes/ply.h deleted file mode 100755 index 1925d5e584371f4713a93860f6cdfd93601d1ec4..0000000000000000000000000000000000000000 --- a/applications/utilities/mesh/generation/cvMesh/cvMeshSurfaceSimplify/MarchingCubes/ply.h +++ /dev/null @@ -1,233 +0,0 @@ -/* - -Header for PLY polygon files. - -- Greg Turk - -A PLY file contains a single polygonal _object_. - -An object is composed of lists of _elements_. Typical elements are -vertices, faces, edges and materials. - -Each type of element for a given object has one or more _properties_ -associated with the element type. For instance, a vertex element may -have as properties three floating-point values x,y,z and three unsigned -chars for red, green and blue. - ------------------------------------------------------------------------ - -Copyright (c) 1998 Georgia Institute of Technology. All rights reserved. - -Permission to use, copy, modify and distribute this software and its -documentation for any purpose is hereby granted without fee, provided -that the above copyright notice and this permission notice appear in -all copies of this software and that you do not sell the software. - -THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTY OF ANY KIND, -EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY -WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - -*/ - -#ifndef __PLY_H__ -#define __PLY_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <stdio.h> -#include <stddef.h> - -#define PLY_ASCII 1 /* ascii PLY file */ -#define PLY_BINARY_BE 2 /* binary PLY file, big endian */ -#define PLY_BINARY_LE 3 /* binary PLY file, little endian */ - -#define PLY_OKAY 0 /* ply routine worked okay */ -#define PLY_ERROR -1 /* error in ply routine */ - -/* scalar data types supported by PLY format */ - -#define StartType 0 -#define Int8 1 -#define Int16 2 -#define Int32 3 -#define Uint8 4 -#define Uint16 5 -#define Uint32 6 -#define Float32 7 -#define Float64 8 -#define EndType 9 - -#define PLY_SCALAR 0 -#define PLY_LIST 1 -#define PLY_STRING 2 - - -typedef struct PlyProperty { /* description of a property */ - -char *name; /* property name */ -int external_type; /* file's data type */ -int internal_type; /* program's data type */ -int offset; /* offset bytes of prop in a struct */ - -int is_list; /* 0 = scalar, 1 = list, 2 = char string */ -int count_external; /* file's count type */ -int count_internal; /* program's count type */ -int count_offset; /* offset byte for list count */ - -} PlyProperty; - -typedef struct PlyElement { /* description of an element */ -char *name; /* element name */ -int num; /* number of elements in this object */ -int size; /* size of element (bytes) or -1 if variable */ -int nprops; /* number of properties for this element */ -PlyProperty **props; /* list of properties in the file */ -char *store_prop; /* flags: property wanted by user? */ -int other_offset; /* offset to un-asked-for props, or -1 if none*/ -int other_size; /* size of other_props structure */ -} PlyElement; - -typedef struct PlyOtherProp { /* describes other properties in an element */ -char *name; /* element name */ -int size; /* size of other_props */ -int nprops; /* number of properties in other_props */ -PlyProperty **props; /* list of properties in other_props */ -} PlyOtherProp; - -typedef struct OtherData { /* for storing other_props for an other element */ -void *other_props; -} OtherData; - -typedef struct OtherElem { /* data for one "other" element */ -char *elem_name; /* names of other elements */ -int elem_count; /* count of instances of each element */ -OtherData **other_data; /* actual property data for the elements */ -PlyOtherProp *other_props; /* description of the property data */ -} OtherElem; - -typedef struct PlyOtherElems { /* "other" elements, not interpreted by user */ -int num_elems; /* number of other elements */ -OtherElem *other_list; /* list of data for other elements */ -} PlyOtherElems; - -#define AVERAGE_RULE 1 -#define MAJORITY_RULE 2 -#define MINIMUM_RULE 3 -#define MAXIMUM_RULE 4 -#define SAME_RULE 5 -#define RANDOM_RULE 6 - -typedef struct PlyPropRules { /* rules for combining "other" properties */ -PlyElement *elem; /* element whose rules we are making */ -int *rule_list; /* types of rules (AVERAGE_PLY, MAJORITY_PLY, etc.) */ -int nprops; /* number of properties we're combining so far */ -int max_props; /* maximum number of properties we have room for now */ -void **props; /* list of properties we're combining */ -float *weights; /* list of weights of the properties */ -} PlyPropRules; - -typedef struct PlyRuleList { -char *name; /* name of the rule */ -char *element; /* name of element that rule applies to */ -char *property; /* name of property that rule applies to */ -struct PlyRuleList *next; /* pointer for linked list of rules */ -} PlyRuleList; - -typedef struct PlyFile { /* description of PLY file */ -FILE *fp; /* file pointer */ -int file_type; /* ascii or binary */ -float version; /* version number of file */ -int num_elem_types; /* number of element types of object */ -PlyElement **elems; /* list of elements */ -int num_comments; /* number of comments */ -char **comments; /* list of comments */ -int num_obj_info; /* number of items of object information */ -char **obj_info; /* list of object info items */ -PlyElement *which_elem; /* element we're currently reading or writing */ -PlyOtherElems *other_elems; /* "other" elements from a PLY file */ -PlyPropRules *current_rules; /* current propagation rules */ -PlyRuleList *rule_list; /* rule list from user */ -} PlyFile; - -/* memory allocation */ -/* -extern char *my_alloc(); -*/ -#define myalloc(mem_size) my_alloc((mem_size), __LINE__, __FILE__) - - -/* old routines */ - -#if 0 -extern PlyFile *ply_write(FILE *, int, char **, int); -extern PlyFile *ply_read(FILE *, int *, char ***); -extern PlyFile *ply_open_for_reading( char *, int *, char ***, int *, float *); -extern void ply_close(PlyFile *); -extern PlyOtherProp *ply_get_other_properties(PlyFile *, char *, int); -#endif - -extern void ply_describe_property( PlyFile * , char * , PlyProperty * ); -extern void ply_get_property( PlyFile * , char * , PlyProperty * ); -extern void ply_get_element( PlyFile * , void * ); - - -/*** delcaration of routines ***/ - -PlyOtherElems *get_other_element_ply( PlyFile * ); - -PlyFile *read_ply( FILE * ); -PlyFile *write_ply( FILE * , int, char ** , int ); -extern PlyFile *open_for_writing_ply( char * , int, char ** , int ); -void close_ply( PlyFile * ); -void free_ply( PlyFile * ); - -void get_info_ply( PlyFile * , float * , int * ); -void free_other_elements_ply( PlyOtherElems * ); - -void append_comment_ply( PlyFile * , char * ); -void append_obj_info_ply( PlyFile * , char * ); -void copy_comments_ply( PlyFile * , PlyFile * ); -void copy_obj_info_ply( PlyFile * , PlyFile * ); -char* *get_comments_ply( PlyFile * , int * ); -char* *get_obj_info_ply( PlyFile * , int * ); - -char* *get_element_list_ply( PlyFile * , int * ); -int setup_property_ply( PlyFile * , PlyProperty * ); -void get_element_ply( PlyFile * , void * ); -char *setup_element_read_ply( PlyFile * , int, int * ); -PlyOtherProp *get_other_properties_ply( PlyFile * , int ); - -void element_count_ply( PlyFile * , char * , int ); -void describe_element_ply( PlyFile * , char * , int ); -void describe_property_ply( PlyFile * , PlyProperty * ); -void describe_other_properties_ply( PlyFile * , PlyOtherProp * , int ); -void describe_other_elements_ply( PlyFile * , PlyOtherElems * ); -void get_element_setup_ply( PlyFile * , char * , int, PlyProperty * ); -PlyProperty* *get_element_description_ply( PlyFile * , char * , int * , int * ); -void element_layout_ply( PlyFile * , char * , int, int, PlyProperty * ); - -void header_complete_ply( PlyFile * ); -void put_element_setup_ply( PlyFile * , char * ); -void put_element_ply( PlyFile * , void * ); -void put_other_elements_ply( PlyFile * ); - -PlyPropRules *init_rule_ply( PlyFile * , char * ); -void modify_rule_ply( PlyPropRules * , char * , int ); -void start_props_ply( PlyFile * , PlyPropRules * ); -void weight_props_ply( PlyFile * , float, void * ); -void *get_new_props_ply( PlyFile * ); -void set_prop_rules_ply( PlyFile * , PlyRuleList * ); -PlyRuleList *append_prop_rule( PlyRuleList * , char * , char * ); -int matches_rule_name( char * ); - -int equal_strings( char * , char * ); -char *recreate_command_line( int, char *argv[] ); - - -#ifdef __cplusplus -} -#endif -#endif /* !__PLY_H__ */ - diff --git a/applications/utilities/mesh/generation/cvMesh/cvMeshSurfaceSimplify/cvMeshSurfaceSimplify.C b/applications/utilities/mesh/generation/cvMesh/cvMeshSurfaceSimplify/cvMeshSurfaceSimplify.C index adc46f762378c75dafefa76bac50f125a5793b12..ae4f8812f7d7faaeac4abf525aa5262083993d80 100644 --- a/applications/utilities/mesh/generation/cvMesh/cvMeshSurfaceSimplify/cvMeshSurfaceSimplify.C +++ b/applications/utilities/mesh/generation/cvMesh/cvMeshSurfaceSimplify/cvMeshSurfaceSimplify.C @@ -28,6 +28,7 @@ Description Simplifies surfaces by resampling. Uses Thomas Lewiner's topology preserving MarchingCubes. + (http://zeus.mat.puc-rio.br/tomlew/tomlew_uk.php) \*---------------------------------------------------------------------------*/ @@ -37,13 +38,328 @@ Description #include "conformationSurfaces.H" #include "triSurfaceMesh.H" -#include "MarchingCubes.h" - +#include "opt_octree.h" +#include "cube.h" using namespace Foam; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +class pointConversion +{ + const vector scale_; + + const vector offset_; + +public: + + //- Construct from components + pointConversion + ( + const vector scale, + const vector offset + ) + : + scale_(scale), + offset_(offset) + {} + + inline Point toLocal(const Foam::point& pt) const + { + Foam::point p = cmptMultiply(scale_, (pt + offset_)); + return Point(p.x(), p.y(), p.z()); + } + + inline Foam::point toGlobal(const Point& pt) const + { + point p(pt.x(), pt.y(), pt.z()); + return cmptDivide(p, scale_) - offset_; + } +}; + + + + +// For use in Fast-Dual Octree from Thomas Lewiner +class distanceCalc +: + public ::data_access +{ + + const Level min_level_; + + const conformationSurfaces& geometryToConformTo_; + + const pointConversion& converter_; + + + // Private Member Functions + + scalar signedDistance(const Foam::point& pt) const + { + const searchableSurfaces& geometry = geometryToConformTo_.geometry(); + const labelList& surfaces = geometryToConformTo_.surfaces(); + + static labelList nearestSurfaces; + static scalarField distance; + + static pointField samples(1); + samples[0] = pt; + + searchableSurfacesQueries::signedDistance + ( + geometry, + surfaces, + samples, + scalarField(1, GREAT), + searchableSurface::OUTSIDE, + nearestSurfaces, + distance + ); + + return distance[0]; + } + + +public: + + // Constructors + + //- Construct from components + distanceCalc + ( + Level max_level_, + real iso_val_, + Level min_level, + const conformationSurfaces& geometryToConformTo, + const pointConversion& converter + ) + : + data_access(max_level_,iso_val_), + min_level_(min_level), + geometryToConformTo_(geometryToConformTo), + converter_(converter) + {} + + + //- Destructor + virtual ~distanceCalc() + {} + + + // Member Functions + + //- test function + virtual bool need_refine( const Cube &c ) + { + int l = c.lv() ; + + if( l >= _max_level ) return false; + if( l < min_level_ ) return true; + + treeBoundBox bb + ( + converter_.toGlobal + ( + Point + ( + c.xmin(), + c.ymin(), + c.zmin() + ) + ), + converter_.toGlobal + ( + Point + ( + c.xmax(), + c.ymax(), + c.zmax() + ) + ) + ); + + const searchableSurfaces& geometry = + geometryToConformTo_.geometry(); + const labelList& surfaces = + geometryToConformTo_.surfaces(); + + + //- Uniform refinement around surface + { + forAll(surfaces, i) + { + if (geometry[surfaces[i]].overlaps(bb)) + { + return true; + } + } + return false; + } + + + ////- Surface intersects bb (but not using intersection test) + //scalar ccDist = signedDistance(bb.midpoint()); + //scalar ccVal = ccDist - _iso_val; + //if (mag(ccVal) < SMALL) + //{ + // return true; + //} + //const pointField points(bb.points()); + //forAll(points, pointI) + //{ + // scalar pointVal = signedDistance(points[pointI]) - _iso_val; + // if (ccVal*pointVal < 0) + // { + // return true; + // } + //} + //return false; + + + ////- Refinement based on intersection with multiple planes. + //// Does not work well - too high a ratio between + //// neighbouring cubes. + //const pointField points(bb.points()); + //const edgeList& edges = treeBoundBox::edges; + //pointField start(edges.size()); + //pointField end(edges.size()); + //forAll(edges, i) + //{ + // start[i] = points[edges[i][0]]; + // end[i] = points[edges[i][1]]; + //} + //Foam::List<Foam::List<pointIndexHit> > hitInfo; + //labelListList hitSurfaces; + //searchableSurfacesQueries::findAllIntersections + //( + // geometry, + // surfaces, + // start, + // end, + // hitSurfaces, + // hitInfo + //); + // + //// Count number of intersections + //label nInt = 0; + //forAll(hitSurfaces, edgeI) + //{ + // nInt += hitSurfaces[edgeI].size(); + //} + // + //if (nInt == 0) + //{ + // // No surface intersected. See if there is one inside + // forAll(surfaces, i) + // { + // if (geometry[surfaces[i]].overlaps(bb)) + // { + // return true; + // } + // } + // return false; + //} + // + //// Check multiple surfaces + //label baseSurfI = -1; + //forAll(hitSurfaces, edgeI) + //{ + // const labelList& hSurfs = hitSurfaces[edgeI]; + // forAll(hSurfs, i) + // { + // if (baseSurfI == -1) + // { + // baseSurfI = hSurfs[i]; + // } + // else if (baseSurfI != hSurfs[i]) + // { + // // Multiple surfaces + // return true; + // } + // } + //} + // + //// Get normals + //DynamicList<pointIndexHit> baseInfo(nInt); + //forAll(hitInfo, edgeI) + //{ + // const Foam::List<pointIndexHit>& hits = hitInfo[edgeI]; + // forAll(hits, i) + // { + // (void)hits[i].hitPoint(); + // baseInfo.append(hits[i]); + // } + //} + //vectorField normals; + //geometry[surfaces[baseSurfI]].getNormal(baseInfo, normals); + //for (label i = 1; i < normals.size(); ++i) + //{ + // if ((normals[0] & normals[i]) < 0.9) + // { + // return true; + // } + //} + //labelList regions; + //geometry[surfaces[baseSurfI]].getRegion(baseInfo, regions); + //for (label i = 1; i < regions.size(); ++i) + //{ + // if (regions[0] != regions[i]) + // { + // return true; + // } + //} + //return false; + + + + //samples[0] = point(c.xmin(), c.ymin(), c.zmin()); + //samples[1] = point(c.xmax(), c.ymin(), c.zmin()); + //samples[2] = point(c.xmax(), c.ymax(), c.zmin()); + //samples[3] = point(c.xmin(), c.ymax(), c.zmin()); + // + //samples[4] = point(c.xmin(), c.ymin(), c.zmax()); + //samples[5] = point(c.xmax(), c.ymin(), c.zmax()); + //samples[6] = point(c.xmax(), c.ymax(), c.zmax()); + //samples[7] = point(c.xmin(), c.ymax(), c.zmax()); + + //scalarField nearestDistSqr(8, GREAT); + // + //Foam::List<pointIndexHit> nearestInfo; + //surf_.findNearest(samples, nearestDistSqr, nearestInfo); + //vectorField normals; + //surf_.getNormal(nearestInfo, normals); + // + //for (label i = 1; i < normals.size(); ++i) + //{ + // if ((normals[0] & normals[i]) < 0.5) + // { + // return true; + // } + //} + //return false; + + //// Check if surface octree same level + //const labelList elems(surf_.tree().findBox(bb)); + // + //if (elems.size() > 1) + //{ + // return true; + //} + //else + //{ + // return false; + //} + } + + //- data function + virtual real value_at( const Cube &c ) + { + return signedDistance(converter_.toGlobal(c)) - _iso_val; + } +}; + + // Main program: int main(int argc, char *argv[]) @@ -52,19 +368,16 @@ int main(int argc, char *argv[]) ( "Re-sample surfaces used in cvMesh operation" ); - //argList::validArgs.append("inputFile"); - argList::validArgs.append("(nx ny nz)"); argList::validArgs.append("outputName"); #include "setRootCase.H" #include "createTime.H" runTime.functionObjects().off(); - const Vector<label> n(IStringStream(args.args()[1])()); - const fileName exportName = args.args()[2]; + const fileName exportName = args.args()[1]; Info<< "Reading surfaces as specified in the cvMeshDict and" - << " writing re-sampled " << n << " to " << exportName + << " writing a re-sampled surface to " << exportName << nl << endl; cpuTime timer; @@ -114,124 +427,100 @@ int main(int argc, char *argv[]) << timer.cpuTimeIncrement() << " s." << nl << endl; + const searchableSurfaces& geometry = geometryToConformTo.geometry(); + const labelList& surfaces = geometryToConformTo.surfaces(); - // Extend - treeBoundBox bb = geometryToConformTo.globalBounds(); - { - const vector smallVec = 0.1*bb.span(); - bb.min() -= smallVec; - bb.max() += smallVec; - } - Info<< "Meshing to bounding box " << bb << nl << endl; + const label minLevel = 2; - const vector span(bb.span()); - const vector d - ( - span.x()/(n.x()-1), - span.y()/(n.y()-1), - span.z()/(n.z()-1) - ); + // The max cube size follows from the minLevel and the default cube size + // (1) + const scalar maxSize = 1.0 / (1 << minLevel); + const scalar halfMaxSize = 0.5*maxSize; - MarchingCubes mc(span.x(), span.y(), span.z() ) ; - mc.set_resolution(n.x(), n.y(), n.z()); - mc.init_all() ; + // Scale the geometry to fit within + // halfMaxSize .. 1-halfMaxSize - // Generate points - pointField points(mc.size_x()*mc.size_y()*mc.size_z()); - label pointI = 0; + scalar wantedRange = 1.0-maxSize; - point pt; - for( int k = 0 ; k < mc.size_z() ; k++ ) - { - pt.z() = bb.min().z() + k*d.z(); - for( int j = 0 ; j < mc.size_y() ; j++ ) - { - pt.y() = bb.min().y() + j*d.y(); - for( int i = 0 ; i < mc.size_x() ; i++ ) - { - pt.x() = bb.min().x() + i*d.x(); - points[pointI++] = pt; - } - } - } + const treeBoundBox bb = geometryToConformTo.globalBounds(); - Info<< "Generated " << points.size() << " sampling points in = " - << timer.cpuTimeIncrement() << " s." << nl << endl; + const vector scale = cmptDivide + ( + point(wantedRange, wantedRange, wantedRange), + bb.span() + ); + const vector offset = + cmptDivide + ( + point(halfMaxSize, halfMaxSize, halfMaxSize), + scale + ) + -bb.min(); - // Compute data - const searchableSurfaces& geometry = geometryToConformTo.geometry(); - const labelList& surfaces = geometryToConformTo.surfaces(); + const pointConversion converter(scale, offset); - scalarField signedDist; - labelList nearestSurfaces; - searchableSurfacesQueries::signedDistance - ( - geometry, - surfaces, - points, - scalarField(points.size(), sqr(GREAT)), - nearestSurfaces, - signedDist - ); - // Fill elements - pointI = 0; - for( int k = 0 ; k < mc.size_z() ; k++ ) - { - for( int j = 0 ; j < mc.size_y() ; j++ ) - { - for( int i = 0 ; i < mc.size_x() ; i++ ) - { - mc.set_data(float(signedDist[pointI++]), i, j, k); - } - } - } + // Marching cubes - Info<< "Determined signed distance in = " - << timer.cpuTimeIncrement() << " s." << nl << endl; + OptOctree octree; + distanceCalc ref + ( + 8, //maxLevel + 0.0, //distance + minLevel, //minLevel + geometryToConformTo, + converter + ); - mc.run() ; + octree.refine(&ref); + octree.set_impl(&ref); - Info<< "Constructed iso surface in = " + Info<< "Calculated octree in = " << timer.cpuTimeIncrement() << " s." << nl << endl; + MarchingCubes& mc = octree.mc(); - mc.clean_temps() ; - + mc.clean_all() ; + octree.build_isosurface(&ref) ; + Info<< "Constructed iso surface of distance in = " + << timer.cpuTimeIncrement() << " s." << nl << endl; // Write output file if (mc.ntrigs() > 0) { Triangle* triangles = mc.triangles(); - List<labelledTri> tris(mc.ntrigs()); - forAll(tris, triI) + label nTris = mc.ntrigs(); + Foam::DynamicList<labelledTri> tris(mc.ntrigs()); + for (label triI = 0; triI < nTris; ++triI) { - tris[triI] = labelledTri - ( - triangles[triI].v1, - triangles[triI].v2, - triangles[triI].v3, - 0 // region - ); + const Triangle& t = triangles[triI]; + if (t.v1 != t.v2 && t.v1 != t.v3 && t.v2 != t.v3) + { + tris.append + ( + labelledTri + ( + triangles[triI].v1, + triangles[triI].v2, + triangles[triI].v3, + 0 // region + ) + ); + } } - Vertex* vertices = mc.vertices(); + Point* vertices = mc.vertices(); pointField points(mc.nverts()); forAll(points, pointI) { - Vertex& v = vertices[pointI]; - points[pointI] = point - ( - bb.min().x() + v.x*span.x()/mc.size_x(), - bb.min().y() + v.y*span.y()/mc.size_y(), - bb.min().z() + v.z*span.z()/mc.size_z() - ); + const Point& v = vertices[pointI]; + points[pointI] = converter.toGlobal(v); } @@ -265,6 +554,7 @@ int main(int argc, char *argv[]) } triSurface s(tris, patches, points, true); + tris.clearStorage(); Info<< "Extracted triSurface in = " << timer.cpuTimeIncrement() << " s." << nl << endl; @@ -272,7 +562,7 @@ int main(int argc, char *argv[]) // Find out region on local surface of nearest point { - List<pointIndexHit> hitInfo; + Foam::List<pointIndexHit> hitInfo; labelList hitSurfaces; geometryToConformTo.findSurfaceNearest ( @@ -340,7 +630,6 @@ int main(int argc, char *argv[]) mc.clean_all() ; - Info<< "End\n" << endl; return 0; diff --git a/applications/utilities/mesh/generation/cvMesh/cvMeshSurfaceSimplify/cvMeshSurfaceSimplify_non_octree.C b/applications/utilities/mesh/generation/cvMesh/cvMeshSurfaceSimplify/cvMeshSurfaceSimplify_non_octree.C new file mode 100644 index 0000000000000000000000000000000000000000..c3518ef1a0365e5359f9d402068a6914053049b9 --- /dev/null +++ b/applications/utilities/mesh/generation/cvMesh/cvMeshSurfaceSimplify/cvMeshSurfaceSimplify_non_octree.C @@ -0,0 +1,352 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM 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 3 of the License, or + (at your option) any later version. + + OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +Application + cvMeshSurfaceSimplify + +Description + Simplifies surfaces by resampling. + + Uses Thomas Lewiner's topology preserving MarchingCubes. + +\*---------------------------------------------------------------------------*/ + +#include "argList.H" +#include "Time.H" +#include "searchableSurfaces.H" +#include "conformationSurfaces.H" +#include "triSurfaceMesh.H" + +#include "MarchingCubes.h" + + +using namespace Foam; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +// Main program: + +int main(int argc, char *argv[]) +{ + argList::addNote + ( + "Re-sample surfaces used in cvMesh operation" + ); + //argList::validArgs.append("inputFile"); + argList::validArgs.append("(nx ny nz)"); + argList::validArgs.append("outputName"); + + #include "setRootCase.H" + #include "createTime.H" + runTime.functionObjects().off(); + + const Vector<label> n(IStringStream(args.args()[1])()); + const fileName exportName = args.args()[2]; + + Info<< "Reading surfaces as specified in the cvMeshDict and" + << " writing re-sampled " << n << " to " << exportName + << nl << endl; + + cpuTime timer; + + IOdictionary cvMeshDict + ( + IOobject + ( + "cvMeshDict", + runTime.system(), + runTime, + IOobject::MUST_READ_IF_MODIFIED, + IOobject::NO_WRITE + ) + ); + + // Define/load all geometry + searchableSurfaces allGeometry + ( + IOobject + ( + "cvSearchableSurfaces", + runTime.constant(), + "triSurface", + runTime, + IOobject::MUST_READ, + IOobject::NO_WRITE + ), + cvMeshDict.subDict("geometry") + ); + + Info<< "Geometry read in = " + << timer.cpuTimeIncrement() << " s." << nl << endl; + + + Random rndGen(64293*Pstream::myProcNo()); + + conformationSurfaces geometryToConformTo + ( + runTime, + rndGen, + allGeometry, + cvMeshDict.subDict("surfaceConformation") + ); + + Info<< "Set up geometry in = " + << timer.cpuTimeIncrement() << " s." << nl << endl; + + + + // Extend + treeBoundBox bb = geometryToConformTo.globalBounds(); + { + const vector smallVec = 0.1*bb.span(); + bb.min() -= smallVec; + bb.max() += smallVec; + } + + Info<< "Meshing to bounding box " << bb << nl << endl; + + const vector span(bb.span()); + const vector d + ( + span.x()/(n.x()-1), + span.y()/(n.y()-1), + span.z()/(n.z()-1) + ); + + MarchingCubes mc(span.x(), span.y(), span.z() ) ; + mc.set_resolution(n.x(), n.y(), n.z()); + mc.init_all() ; + + + // Generate points + pointField points(mc.size_x()*mc.size_y()*mc.size_z()); + label pointI = 0; + + point pt; + for( int k = 0 ; k < mc.size_z() ; k++ ) + { + pt.z() = bb.min().z() + k*d.z(); + for( int j = 0 ; j < mc.size_y() ; j++ ) + { + pt.y() = bb.min().y() + j*d.y(); + for( int i = 0 ; i < mc.size_x() ; i++ ) + { + pt.x() = bb.min().x() + i*d.x(); + points[pointI++] = pt; + } + } + } + + Info<< "Generated " << points.size() << " sampling points in = " + << timer.cpuTimeIncrement() << " s." << nl << endl; + + + // Compute data + const searchableSurfaces& geometry = geometryToConformTo.geometry(); + const labelList& surfaces = geometryToConformTo.surfaces(); + + scalarField signedDist; + labelList nearestSurfaces; + searchableSurfacesQueries::signedDistance + ( + geometry, + surfaces, + points, + scalarField(points.size(), sqr(GREAT)), + searchableSurface::OUTSIDE, // for non-closed surfaces treat as + // outside + nearestSurfaces, + signedDist + ); + + // Fill elements + pointI = 0; + for( int k = 0 ; k < mc.size_z() ; k++ ) + { + for( int j = 0 ; j < mc.size_y() ; j++ ) + { + for( int i = 0 ; i < mc.size_x() ; i++ ) + { + mc.set_data(float(signedDist[pointI++]), i, j, k); + } + } + } + + Info<< "Determined signed distance in = " + << timer.cpuTimeIncrement() << " s." << nl << endl; + + + mc.run() ; + + Info<< "Constructed iso surface in = " + << timer.cpuTimeIncrement() << " s." << nl << endl; + + + mc.clean_temps() ; + + + + // Write output file + if (mc.ntrigs() > 0) + { + Triangle* triangles = mc.triangles(); + List<labelledTri> tris(mc.ntrigs()); + forAll(tris, triI) + { + tris[triI] = labelledTri + ( + triangles[triI].v1, + triangles[triI].v2, + triangles[triI].v3, + 0 // region + ); + } + + + Vertex* vertices = mc.vertices(); + pointField points(mc.nverts()); + forAll(points, pointI) + { + Vertex& v = vertices[pointI]; + points[pointI] = point + ( + bb.min().x() + v.x*span.x()/mc.size_x(), + bb.min().y() + v.y*span.y()/mc.size_y(), + bb.min().z() + v.z*span.z()/mc.size_z() + ); + } + + + // Find correspondence to original surfaces + labelList regionOffsets(surfaces.size()); + label nRegions = 0; + forAll(surfaces, i) + { + const wordList& regions = geometry[surfaces[i]].regions(); + regionOffsets[i] = nRegions; + nRegions += regions.size(); + } + + + geometricSurfacePatchList patches(nRegions); + nRegions = 0; + forAll(surfaces, i) + { + const wordList& regions = geometry[surfaces[i]].regions(); + + forAll(regions, regionI) + { + patches[nRegions] = geometricSurfacePatch + ( + "patch", + geometry[surfaces[i]].name() + "_" + regions[regionI], + nRegions + ); + nRegions++; + } + } + + triSurface s(tris, patches, points, true); + + Info<< "Extracted triSurface in = " + << timer.cpuTimeIncrement() << " s." << nl << endl; + + + // Find out region on local surface of nearest point + { + List<pointIndexHit> hitInfo; + labelList hitSurfaces; + geometryToConformTo.findSurfaceNearest + ( + s.faceCentres(), + scalarField(s.size(), sqr(GREAT)), + hitInfo, + hitSurfaces + ); + + // Get region + DynamicList<pointIndexHit> surfInfo(hitSurfaces.size()); + DynamicList<label> surfIndices(hitSurfaces.size()); + + forAll(surfaces, surfI) + { + // Extract info on this surface + surfInfo.clear(); + surfIndices.clear(); + forAll(hitSurfaces, triI) + { + if (hitSurfaces[triI] == surfI) + { + surfInfo.append(hitInfo[triI]); + surfIndices.append(triI); + } + } + + // Calculate sideness of these surface points + labelList region; + geometry[surfaces[surfI]].getRegion(surfInfo, region); + + forAll(region, i) + { + label triI = surfIndices[i]; + s[triI].region() = regionOffsets[surfI]+region[i]; + } + } + } + + Info<< "Re-patched surface in = " + << timer.cpuTimeIncrement() << " s." << nl << endl; + + triSurfaceMesh smesh + ( + IOobject + ( + exportName, + runTime.constant(), // instance + "triSurface", + runTime, // registry + IOobject::NO_READ, + IOobject::AUTO_WRITE, + false + ), + s + ); + + Info<< "writing surfMesh:\n " + << smesh.searchableSurface::objectPath() << nl << endl; + smesh.searchableSurface::write(); + + Info<< "Written surface in = " + << timer.cpuTimeIncrement() << " s." << nl << endl; + } + + mc.clean_all() ; + + + Info<< "End\n" << endl; + + return 0; +} + + +// ************************************************************************* // diff --git a/applications/utilities/mesh/generation/cvMesh/cvMeshSurfaceSimplify/marching_cubes_jgt.zip b/applications/utilities/mesh/generation/cvMesh/cvMeshSurfaceSimplify/marching_cubes_jgt.zip deleted file mode 100644 index bb15279b270eb84738e70467383317685d53e425..0000000000000000000000000000000000000000 Binary files a/applications/utilities/mesh/generation/cvMesh/cvMeshSurfaceSimplify/marching_cubes_jgt.zip and /dev/null differ diff --git a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict index d3aefb6445c3754e107db549ab4e97a395a8d3c9..0e760387ebad0b9b6410a15f21d8ef8c8bbb1592 100644 --- a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict +++ b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict @@ -154,6 +154,13 @@ castellatedMeshControls //faceZone sphere; //cellZone sphere; //cellZoneInside inside; //outside/insidePoint + //- Optional specification of what to do with faceZone faces: + // internal : keep them as internal faces (default) + // baffle : create baffles from them. This gives more + // freedom in mesh motion + // boundary : create free-standing boundary faces (baffles + // but without the shared points) + //faceType internal; } } diff --git a/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C b/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C index 8910645b5c196cf190e32bd2dc11e66d40c7f8ac..5f724095ca4a36b58dc5e1ca7314b54962c71e10 100644 --- a/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C +++ b/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C @@ -641,9 +641,12 @@ int main(int argc, char *argv[]) Info<< "Mesh size: " << mesh.globalData().nTotalCells() << nl << "Before renumbering :" << nl << " band : " << band << nl - << " profile : " << profile << nl - << " rms frontwidth : " << rmsFrontwidth << nl - << endl; + << " profile : " << profile << nl; + if (doFrontWidth) + { + Info<< " rms frontwidth : " << rmsFrontwidth << nl; + } + Info<< endl; bool sortCoupledFaceCells = false; bool writeMaps = false; diff --git a/applications/utilities/parallelProcessing/redistributePar/Make/files b/applications/utilities/parallelProcessing/redistributePar/Make/files index ce0b6760d450aa3779b1ddb3cdd766d53048e14f..8bf23d0895bd62d08b893465256cf9d4ed8ab2d4 100644 --- a/applications/utilities/parallelProcessing/redistributePar/Make/files +++ b/applications/utilities/parallelProcessing/redistributePar/Make/files @@ -1,3 +1,4 @@ +loadOrCreateMesh.C redistributePar.C EXE = $(FOAM_APPBIN)/redistributePar diff --git a/applications/utilities/parallelProcessing/redistributePar/loadOrCreateMesh.C b/applications/utilities/parallelProcessing/redistributePar/loadOrCreateMesh.C new file mode 100644 index 0000000000000000000000000000000000000000..9e68e1f726e9883f5b0a2ae9fbb6f2cbde127d34 --- /dev/null +++ b/applications/utilities/parallelProcessing/redistributePar/loadOrCreateMesh.C @@ -0,0 +1,323 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM 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 3 of the License, or + (at your option) any later version. + + OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "loadOrCreateMesh.H" +#include "processorPolyPatch.H" +#include "Time.H" + +// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * // + +// Read mesh if available. Otherwise create empty mesh with same non-proc +// patches as proc0 mesh. Requires all processors to have all patches +// (and in same order). +Foam::autoPtr<Foam::fvMesh> Foam::loadOrCreateMesh +( + const IOobject& io +) +{ + fileName meshSubDir; + + if (io.name() == polyMesh::defaultRegion) + { + meshSubDir = polyMesh::meshSubDir; + } + else + { + meshSubDir = io.name()/polyMesh::meshSubDir; + } + + // Check who has a mesh + const bool haveMesh = isDir(io.time().path()/io.instance()/meshSubDir); + +Pout<< "meshpath:" << io.time().path()/io.instance()/meshSubDir << endl; +Pout<< "haveMesh:" << haveMesh << endl; + + if (!haveMesh) + { + // Create dummy mesh. Only used on procs that don't have mesh. + IOobject noReadIO(io); + noReadIO.readOpt() = IOobject::NO_READ; + fvMesh dummyMesh + ( + noReadIO, + xferCopy(pointField()), + xferCopy(faceList()), + xferCopy(labelList()), + xferCopy(labelList()), + false + ); + // Add some dummy zones so upon reading it does not read them + // from the undecomposed case. Should be done as extra argument to + // regIOobject::readStream? + List<pointZone*> pz + ( + 1, + new pointZone + ( + "dummyPointZone", + labelList(0), + 0, + dummyMesh.pointZones() + ) + ); + List<faceZone*> fz + ( + 1, + new faceZone + ( + "dummyFaceZone", + labelList(0), + boolList(0), + 0, + dummyMesh.faceZones() + ) + ); + List<cellZone*> cz + ( + 1, + new cellZone + ( + "dummyCellZone", + labelList(0), + 0, + dummyMesh.cellZones() + ) + ); + dummyMesh.addZones(pz, fz, cz); + //Pout<< "Writing dummy mesh to " << dummyMesh.polyMesh::objectPath() + // << endl; + dummyMesh.write(); + } + + //Pout<< "Reading mesh from " << io.objectPath() << endl; + autoPtr<fvMesh> meshPtr(new fvMesh(io)); + fvMesh& mesh = meshPtr(); + + + // Sync patches + // ~~~~~~~~~~~~ + + if (Pstream::master()) + { + // Send patches + for + ( + int slave=Pstream::firstSlave(); + slave<=Pstream::lastSlave(); + slave++ + ) + { + OPstream toSlave(Pstream::scheduled, slave); + toSlave << mesh.boundaryMesh(); + } + } + else + { + // Receive patches + IPstream fromMaster(Pstream::scheduled, Pstream::masterNo()); + PtrList<entry> patchEntries(fromMaster); + + if (haveMesh) + { + // Check master names against mine + + const polyBoundaryMesh& patches = mesh.boundaryMesh(); + + forAll(patchEntries, patchI) + { + const entry& e = patchEntries[patchI]; + const word type(e.dict().lookup("type")); + const word& name = e.keyword(); + + if (type == processorPolyPatch::typeName) + { + break; + } + + if (patchI >= patches.size()) + { + FatalErrorIn + ( + "createMesh(const Time&, const fileName&, const bool)" + ) << "Non-processor patches not synchronised." + << endl + << "Processor " << Pstream::myProcNo() + << " has only " << patches.size() + << " patches, master has " + << patchI + << exit(FatalError); + } + + if + ( + type != patches[patchI].type() + || name != patches[patchI].name() + ) + { + FatalErrorIn + ( + "createMesh(const Time&, const fileName&, const bool)" + ) << "Non-processor patches not synchronised." + << endl + << "Master patch " << patchI + << " name:" << type + << " type:" << type << endl + << "Processor " << Pstream::myProcNo() + << " patch " << patchI + << " has name:" << patches[patchI].name() + << " type:" << patches[patchI].type() + << exit(FatalError); + } + } + } + else + { + // Add patch + List<polyPatch*> patches(patchEntries.size()); + label nPatches = 0; + + forAll(patchEntries, patchI) + { + const entry& e = patchEntries[patchI]; + const word type(e.dict().lookup("type")); + const word& name = e.keyword(); + + if (type == processorPolyPatch::typeName) + { + break; + } + + //Pout<< "Adding patch:" << nPatches + // << " name:" << name << " type:" << type << endl; + + dictionary patchDict(e.dict()); + patchDict.remove("nFaces"); + patchDict.add("nFaces", 0); + patchDict.remove("startFace"); + patchDict.add("startFace", 0); + + patches[patchI] = polyPatch::New + ( + name, + patchDict, + nPatches++, + mesh.boundaryMesh() + ).ptr(); + } + patches.setSize(nPatches); + mesh.addFvPatches(patches, false); // no parallel comms + + //// Write empty mesh now we have correct patches + //meshPtr().write(); + } + } + + + // Determine zones + // ~~~~~~~~~~~~~~~ + + wordList pointZoneNames(mesh.pointZones().names()); + Pstream::scatter(pointZoneNames); + wordList faceZoneNames(mesh.faceZones().names()); + Pstream::scatter(faceZoneNames); + wordList cellZoneNames(mesh.cellZones().names()); + Pstream::scatter(cellZoneNames); + + if (!haveMesh) + { + // Add the zones. Make sure to remove the old dummy ones first + mesh.pointZones().clear(); + mesh.faceZones().clear(); + mesh.cellZones().clear(); + + List<pointZone*> pz(pointZoneNames.size()); + forAll(pointZoneNames, i) + { + pz[i] = new pointZone + ( + pointZoneNames[i], + labelList(0), + i, + mesh.pointZones() + ); + } + List<faceZone*> fz(faceZoneNames.size()); + forAll(faceZoneNames, i) + { + fz[i] = new faceZone + ( + faceZoneNames[i], + labelList(0), + boolList(0), + i, + mesh.faceZones() + ); + } + List<cellZone*> cz(cellZoneNames.size()); + forAll(cellZoneNames, i) + { + cz[i] = new cellZone + ( + cellZoneNames[i], + labelList(0), + i, + mesh.cellZones() + ); + } + mesh.addZones(pz, fz, cz); + } + + + if (!haveMesh) + { + // We created a dummy mesh file above. Delete it. + //Pout<< "Removing dummy mesh " << io.objectPath() << endl; + rmDir(io.objectPath()); + } + + // Force recreation of globalMeshData. + mesh.clearOut(); + mesh.globalData(); + + + // Do some checks. + + // Check if the boundary definition is unique + mesh.boundaryMesh().checkDefinition(true); + // Check if the boundary processor patches are correct + mesh.boundaryMesh().checkParallelSync(true); + // Check names of zones are equal + mesh.cellZones().checkDefinition(true); + mesh.cellZones().checkParallelSync(true); + mesh.faceZones().checkDefinition(true); + mesh.faceZones().checkParallelSync(true); + mesh.pointZones().checkDefinition(true); + mesh.pointZones().checkParallelSync(true); + + return meshPtr; +} + + +// ************************************************************************* // diff --git a/src/finiteVolume/finiteVolume/snGradSchemes/quadraticFitSnGrad/quadraticFitSnGrads.C b/applications/utilities/parallelProcessing/redistributePar/loadOrCreateMesh.H similarity index 67% rename from src/finiteVolume/finiteVolume/snGradSchemes/quadraticFitSnGrad/quadraticFitSnGrads.C rename to applications/utilities/parallelProcessing/redistributePar/loadOrCreateMesh.H index 00185cd16cd60f2aaae5529d5f63d0672e49bb82..73d6dfd1c77da43399e69cdc561ca5331c4304d0 100644 --- a/src/finiteVolume/finiteVolume/snGradSchemes/quadraticFitSnGrad/quadraticFitSnGrads.C +++ b/applications/utilities/parallelProcessing/redistributePar/loadOrCreateMesh.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -21,23 +21,38 @@ License You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. +InNamespace + Foam + Description - Simple central-difference snGrad scheme with quadratic fit correction from - a larger stencil. + Load or create (0 size) a mesh. Used in distributing meshes to a + larger number of processors + +SourceFiles + loadOrCreateMesh.C \*---------------------------------------------------------------------------*/ -#include "quadraticFitSnGrad.H" +#ifndef loadOrCreateMesh_H +#define loadOrCreateMesh_H + #include "fvMesh.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { -namespace fv -{ - makeSnGradScheme(quadraticFitSnGrad) -} + +//- Load (if it exists) or create zero cell mesh given an IOobject: +// name : regionName +// instance : exact directory where to find mesh (i.e. does not +// do a findInstance +autoPtr<fvMesh> loadOrCreateMesh(const IOobject& io); + } +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + // ************************************************************************* // diff --git a/applications/utilities/parallelProcessing/redistributePar/redistributePar.C b/applications/utilities/parallelProcessing/redistributePar/redistributePar.C index cde7f5b12d1f299441c9077a5eadb82842347f3b..4d02655955fa3a5c10f12ed2be1d9688fe60406e 100644 --- a/applications/utilities/parallelProcessing/redistributePar/redistributePar.C +++ b/applications/utilities/parallelProcessing/redistributePar/redistributePar.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -54,6 +54,7 @@ Description #include "mapDistributePolyMesh.H" #include "IOobjectList.H" #include "globalIndex.H" +#include "loadOrCreateMesh.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -62,292 +63,292 @@ Description static const scalar defaultMergeTol = 1E-6; -// Read mesh if available. Otherwise create empty mesh with same non-proc -// patches as proc0 mesh. Requires all processors to have all patches -// (and in same order). -autoPtr<fvMesh> createMesh -( - const Time& runTime, - const word& regionName, - const fileName& instDir, - const bool haveMesh -) -{ - //Pout<< "Create mesh for time = " - // << runTime.timeName() << nl << endl; - - IOobject io - ( - regionName, - instDir, - runTime, - IOobject::MUST_READ - ); - - if (!haveMesh) - { - // Create dummy mesh. Only used on procs that don't have mesh. - IOobject noReadIO(io); - noReadIO.readOpt() = IOobject::NO_READ; - fvMesh dummyMesh - ( - noReadIO, - xferCopy(pointField()), - xferCopy(faceList()), - xferCopy(labelList()), - xferCopy(labelList()), - false - ); - // Add some dummy zones so upon reading it does not read them - // from the undecomposed case. Should be done as extra argument to - // regIOobject::readStream? - List<pointZone*> pz - ( - 1, - new pointZone - ( - "dummyPointZone", - labelList(0), - 0, - dummyMesh.pointZones() - ) - ); - List<faceZone*> fz - ( - 1, - new faceZone - ( - "dummyFaceZone", - labelList(0), - boolList(0), - 0, - dummyMesh.faceZones() - ) - ); - List<cellZone*> cz - ( - 1, - new cellZone - ( - "dummyCellZone", - labelList(0), - 0, - dummyMesh.cellZones() - ) - ); - dummyMesh.addZones(pz, fz, cz); - //Pout<< "Writing dummy mesh to " << dummyMesh.polyMesh::objectPath() - // << endl; - dummyMesh.write(); - } - - //Pout<< "Reading mesh from " << io.objectPath() << endl; - autoPtr<fvMesh> meshPtr(new fvMesh(io)); - fvMesh& mesh = meshPtr(); - - - // Sync patches - // ~~~~~~~~~~~~ - - if (Pstream::master()) - { - // Send patches - for - ( - int slave=Pstream::firstSlave(); - slave<=Pstream::lastSlave(); - slave++ - ) - { - OPstream toSlave(Pstream::scheduled, slave); - toSlave << mesh.boundaryMesh(); - } - } - else - { - // Receive patches - IPstream fromMaster(Pstream::scheduled, Pstream::masterNo()); - PtrList<entry> patchEntries(fromMaster); - - if (haveMesh) - { - // Check master names against mine - - const polyBoundaryMesh& patches = mesh.boundaryMesh(); - - forAll(patchEntries, patchI) - { - const entry& e = patchEntries[patchI]; - const word type(e.dict().lookup("type")); - const word& name = e.keyword(); - - if (type == processorPolyPatch::typeName) - { - break; - } - - if (patchI >= patches.size()) - { - FatalErrorIn - ( - "createMesh(const Time&, const fileName&, const bool)" - ) << "Non-processor patches not synchronised." - << endl - << "Processor " << Pstream::myProcNo() - << " has only " << patches.size() - << " patches, master has " - << patchI - << exit(FatalError); - } - - if - ( - type != patches[patchI].type() - || name != patches[patchI].name() - ) - { - FatalErrorIn - ( - "createMesh(const Time&, const fileName&, const bool)" - ) << "Non-processor patches not synchronised." - << endl - << "Master patch " << patchI - << " name:" << type - << " type:" << type << endl - << "Processor " << Pstream::myProcNo() - << " patch " << patchI - << " has name:" << patches[patchI].name() - << " type:" << patches[patchI].type() - << exit(FatalError); - } - } - } - else - { - // Add patch - List<polyPatch*> patches(patchEntries.size()); - label nPatches = 0; - - forAll(patchEntries, patchI) - { - const entry& e = patchEntries[patchI]; - const word type(e.dict().lookup("type")); - const word& name = e.keyword(); - - if (type == processorPolyPatch::typeName) - { - break; - } - - //Pout<< "Adding patch:" << nPatches - // << " name:" << name << " type:" << type << endl; - - dictionary patchDict(e.dict()); - patchDict.remove("nFaces"); - patchDict.add("nFaces", 0); - patchDict.remove("startFace"); - patchDict.add("startFace", 0); - - patches[patchI] = polyPatch::New - ( - name, - patchDict, - nPatches++, - mesh.boundaryMesh() - ).ptr(); - } - patches.setSize(nPatches); - mesh.addFvPatches(patches, false); // no parallel comms - - //// Write empty mesh now we have correct patches - //meshPtr().write(); - } - } - - - // Determine zones - // ~~~~~~~~~~~~~~~ - - wordList pointZoneNames(mesh.pointZones().names()); - Pstream::scatter(pointZoneNames); - wordList faceZoneNames(mesh.faceZones().names()); - Pstream::scatter(faceZoneNames); - wordList cellZoneNames(mesh.cellZones().names()); - Pstream::scatter(cellZoneNames); - - if (!haveMesh) - { - // Add the zones. Make sure to remove the old dummy ones first - mesh.pointZones().clear(); - mesh.faceZones().clear(); - mesh.cellZones().clear(); - - List<pointZone*> pz(pointZoneNames.size()); - forAll(pointZoneNames, i) - { - pz[i] = new pointZone - ( - pointZoneNames[i], - labelList(0), - i, - mesh.pointZones() - ); - } - List<faceZone*> fz(faceZoneNames.size()); - forAll(faceZoneNames, i) - { - fz[i] = new faceZone - ( - faceZoneNames[i], - labelList(0), - boolList(0), - i, - mesh.faceZones() - ); - } - List<cellZone*> cz(cellZoneNames.size()); - forAll(cellZoneNames, i) - { - cz[i] = new cellZone - ( - cellZoneNames[i], - labelList(0), - i, - mesh.cellZones() - ); - } - mesh.addZones(pz, fz, cz); - } - - - if (!haveMesh) - { - // We created a dummy mesh file above. Delete it. - //Pout<< "Removing dummy mesh " << io.objectPath() << endl; - rmDir(io.objectPath()); - } - - // Force recreation of globalMeshData. - mesh.clearOut(); - mesh.globalData(); - - - // Do some checks. - - // Check if the boundary definition is unique - mesh.boundaryMesh().checkDefinition(true); - // Check if the boundary processor patches are correct - mesh.boundaryMesh().checkParallelSync(true); - // Check names of zones are equal - mesh.cellZones().checkDefinition(true); - mesh.cellZones().checkParallelSync(true); - mesh.faceZones().checkDefinition(true); - mesh.faceZones().checkParallelSync(true); - mesh.pointZones().checkDefinition(true); - mesh.pointZones().checkParallelSync(true); - - return meshPtr; -} +//// Read mesh if available. Otherwise create empty mesh with same non-proc +//// patches as proc0 mesh. Requires all processors to have all patches +//// (and in same order). +//autoPtr<fvMesh> createMesh +//( +// const Time& runTime, +// const word& regionName, +// const fileName& instDir, +// const bool haveMesh +//) +//{ +// //Pout<< "Create mesh for time = " +// // << runTime.timeName() << nl << endl; +// +// IOobject io +// ( +// regionName, +// instDir, +// runTime, +// IOobject::MUST_READ +// ); +// +// if (!haveMesh) +// { +// // Create dummy mesh. Only used on procs that don't have mesh. +// IOobject noReadIO(io); +// noReadIO.readOpt() = IOobject::NO_READ; +// fvMesh dummyMesh +// ( +// noReadIO, +// xferCopy(pointField()), +// xferCopy(faceList()), +// xferCopy(labelList()), +// xferCopy(labelList()), +// false +// ); +// // Add some dummy zones so upon reading it does not read them +// // from the undecomposed case. Should be done as extra argument to +// // regIOobject::readStream? +// List<pointZone*> pz +// ( +// 1, +// new pointZone +// ( +// "dummyPointZone", +// labelList(0), +// 0, +// dummyMesh.pointZones() +// ) +// ); +// List<faceZone*> fz +// ( +// 1, +// new faceZone +// ( +// "dummyFaceZone", +// labelList(0), +// boolList(0), +// 0, +// dummyMesh.faceZones() +// ) +// ); +// List<cellZone*> cz +// ( +// 1, +// new cellZone +// ( +// "dummyCellZone", +// labelList(0), +// 0, +// dummyMesh.cellZones() +// ) +// ); +// dummyMesh.addZones(pz, fz, cz); +// //Pout<< "Writing dummy mesh to " << dummyMesh.polyMesh::objectPath() +// // << endl; +// dummyMesh.write(); +// } +// +// //Pout<< "Reading mesh from " << io.objectPath() << endl; +// autoPtr<fvMesh> meshPtr(new fvMesh(io)); +// fvMesh& mesh = meshPtr(); +// +// +// // Sync patches +// // ~~~~~~~~~~~~ +// +// if (Pstream::master()) +// { +// // Send patches +// for +// ( +// int slave=Pstream::firstSlave(); +// slave<=Pstream::lastSlave(); +// slave++ +// ) +// { +// OPstream toSlave(Pstream::scheduled, slave); +// toSlave << mesh.boundaryMesh(); +// } +// } +// else +// { +// // Receive patches +// IPstream fromMaster(Pstream::scheduled, Pstream::masterNo()); +// PtrList<entry> patchEntries(fromMaster); +// +// if (haveMesh) +// { +// // Check master names against mine +// +// const polyBoundaryMesh& patches = mesh.boundaryMesh(); +// +// forAll(patchEntries, patchI) +// { +// const entry& e = patchEntries[patchI]; +// const word type(e.dict().lookup("type")); +// const word& name = e.keyword(); +// +// if (type == processorPolyPatch::typeName) +// { +// break; +// } +// +// if (patchI >= patches.size()) +// { +// FatalErrorIn +// ( +// "createMesh(const Time&, const fileName&, const bool)" +// ) << "Non-processor patches not synchronised." +// << endl +// << "Processor " << Pstream::myProcNo() +// << " has only " << patches.size() +// << " patches, master has " +// << patchI +// << exit(FatalError); +// } +// +// if +// ( +// type != patches[patchI].type() +// || name != patches[patchI].name() +// ) +// { +// FatalErrorIn +// ( +// "createMesh(const Time&, const fileName&, const bool)" +// ) << "Non-processor patches not synchronised." +// << endl +// << "Master patch " << patchI +// << " name:" << type +// << " type:" << type << endl +// << "Processor " << Pstream::myProcNo() +// << " patch " << patchI +// << " has name:" << patches[patchI].name() +// << " type:" << patches[patchI].type() +// << exit(FatalError); +// } +// } +// } +// else +// { +// // Add patch +// List<polyPatch*> patches(patchEntries.size()); +// label nPatches = 0; +// +// forAll(patchEntries, patchI) +// { +// const entry& e = patchEntries[patchI]; +// const word type(e.dict().lookup("type")); +// const word& name = e.keyword(); +// +// if (type == processorPolyPatch::typeName) +// { +// break; +// } +// +// //Pout<< "Adding patch:" << nPatches +// // << " name:" << name << " type:" << type << endl; +// +// dictionary patchDict(e.dict()); +// patchDict.remove("nFaces"); +// patchDict.add("nFaces", 0); +// patchDict.remove("startFace"); +// patchDict.add("startFace", 0); +// +// patches[patchI] = polyPatch::New +// ( +// name, +// patchDict, +// nPatches++, +// mesh.boundaryMesh() +// ).ptr(); +// } +// patches.setSize(nPatches); +// mesh.addFvPatches(patches, false); // no parallel comms +// +// //// Write empty mesh now we have correct patches +// //meshPtr().write(); +// } +// } +// +// +// // Determine zones +// // ~~~~~~~~~~~~~~~ +// +// wordList pointZoneNames(mesh.pointZones().names()); +// Pstream::scatter(pointZoneNames); +// wordList faceZoneNames(mesh.faceZones().names()); +// Pstream::scatter(faceZoneNames); +// wordList cellZoneNames(mesh.cellZones().names()); +// Pstream::scatter(cellZoneNames); +// +// if (!haveMesh) +// { +// // Add the zones. Make sure to remove the old dummy ones first +// mesh.pointZones().clear(); +// mesh.faceZones().clear(); +// mesh.cellZones().clear(); +// +// List<pointZone*> pz(pointZoneNames.size()); +// forAll(pointZoneNames, i) +// { +// pz[i] = new pointZone +// ( +// pointZoneNames[i], +// labelList(0), +// i, +// mesh.pointZones() +// ); +// } +// List<faceZone*> fz(faceZoneNames.size()); +// forAll(faceZoneNames, i) +// { +// fz[i] = new faceZone +// ( +// faceZoneNames[i], +// labelList(0), +// boolList(0), +// i, +// mesh.faceZones() +// ); +// } +// List<cellZone*> cz(cellZoneNames.size()); +// forAll(cellZoneNames, i) +// { +// cz[i] = new cellZone +// ( +// cellZoneNames[i], +// labelList(0), +// i, +// mesh.cellZones() +// ); +// } +// mesh.addZones(pz, fz, cz); +// } +// +// +// if (!haveMesh) +// { +// // We created a dummy mesh file above. Delete it. +// //Pout<< "Removing dummy mesh " << io.objectPath() << endl; +// rmDir(io.objectPath()); +// } +// +// // Force recreation of globalMeshData. +// mesh.clearOut(); +// mesh.globalData(); +// +// +// // Do some checks. +// +// // Check if the boundary definition is unique +// mesh.boundaryMesh().checkDefinition(true); +// // Check if the boundary processor patches are correct +// mesh.boundaryMesh().checkParallelSync(true); +// // Check names of zones are equal +// mesh.cellZones().checkDefinition(true); +// mesh.cellZones().checkParallelSync(true); +// mesh.faceZones().checkDefinition(true); +// mesh.faceZones().checkParallelSync(true); +// mesh.pointZones().checkDefinition(true); +// mesh.pointZones().checkParallelSync(true); +// +// return meshPtr; +//} // Get merging distance when matching face centres @@ -786,13 +787,24 @@ int main(int argc, char *argv[]) const bool allHaveMesh = (findIndex(haveMesh, false) == -1); // Create mesh - autoPtr<fvMesh> meshPtr = createMesh + //autoPtr<fvMesh> meshPtr = createMesh + //( + // runTime, + // regionName, + // masterInstDir, + // haveMesh[Pstream::myProcNo()] + //); + autoPtr<fvMesh> meshPtr = loadOrCreateMesh ( - runTime, - regionName, - masterInstDir, - haveMesh[Pstream::myProcNo()] + IOobject + ( + regionName, + masterInstDir, + runTime, + Foam::IOobject::MUST_READ + ) ); + fvMesh& mesh = meshPtr(); // Print some statistics diff --git a/applications/utilities/surface/surfaceBooleanFeatures/surfaceBooleanFeatures.C b/applications/utilities/surface/surfaceBooleanFeatures/surfaceBooleanFeatures.C index 419b8568e0b8388613a30a9a976e693aef0c89c6..d1a9b8f0288287e5f55d5e1fe6bbfed9d5d8c2ac 100644 --- a/applications/utilities/surface/surfaceBooleanFeatures/surfaceBooleanFeatures.C +++ b/applications/utilities/surface/surfaceBooleanFeatures/surfaceBooleanFeatures.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -216,7 +216,6 @@ bool intersectSurfaces int main(int argc, char *argv[]) { - argList::validArgs.clear(); argList::noParallel(); argList::validArgs.append("action"); argList::validArgs.append("surface file"); diff --git a/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C b/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C index 5b2e78ca967f882ce3b91aabc93e95e07008cdbe..5aae0ede0ebf81adb979a655c6211425b9c95875 100644 --- a/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C +++ b/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C @@ -525,12 +525,6 @@ int main(int argc, char *argv[]) surfaceDict.lookupOrAddDefault<Switch>("writeVTK", "off"); const Switch writeObj = surfaceDict.lookupOrAddDefault<Switch>("writeObj", "off"); - const Switch writeFeatureEdgeMesh = - surfaceDict.lookupOrAddDefault<Switch> - ( - "writeFeatureEdgeMesh", - "off" - ); const Switch curvature = surfaceDict.lookupOrAddDefault<Switch>("curvature", "off"); @@ -592,7 +586,7 @@ int main(int argc, char *argv[]) if (extractionMethod == "extractFromFile") { const fileName featureEdgeFile = - surfaceDict.subDict("extractFromFile").lookup + surfaceDict.subDict("extractFromFileCoeffs").lookup ( "featureEdgeFile" ); @@ -612,7 +606,7 @@ int main(int argc, char *argv[]) const scalar includedAngle = readScalar ( - surfaceDict.subDict("extractFromSurface").lookup + surfaceDict.subDict("extractFromSurfaceCoeffs").lookup ( "includedAngle" ) @@ -747,10 +741,10 @@ int main(int argc, char *argv[]) surfaceFeatures newSet(surf); newSet.setFromStatus(edgeStat); - if (writeObj) - { - newSet.writeObj("final"); - } + //if (writeObj) + //{ + // newSet.writeObj("final"); + //} Info<< nl << "Final feature set after trimming and subsetting:" << nl @@ -773,37 +767,36 @@ int main(int argc, char *argv[]) Info<< nl << "Writing extendedFeatureEdgeMesh to " << feMesh.objectPath() << endl; + mkDir(feMesh.path()); + if (writeObj) { - feMesh.writeObj(surfFileName.lessExt().name()); + feMesh.writeObj(feMesh.path()/surfFileName.lessExt().name()); } feMesh.write(); // Write a featureEdgeMesh for backwards compatibility - if (writeFeatureEdgeMesh) - { - featureEdgeMesh bfeMesh + featureEdgeMesh bfeMesh + ( + IOobject ( - IOobject - ( - surfFileName.lessExt().name() + ".eMesh", // name - runTime.constant(), // instance - "triSurface", - runTime, // registry - IOobject::NO_READ, - IOobject::AUTO_WRITE, - false - ), - feMesh.points(), - feMesh.edges() - ); + surfFileName.lessExt().name() + ".eMesh", // name + runTime.constant(), // instance + "triSurface", + runTime, // registry + IOobject::NO_READ, + IOobject::AUTO_WRITE, + false + ), + feMesh.points(), + feMesh.edges() + ); - Info<< nl << "Writing featureEdgeMesh to " - << bfeMesh.objectPath() << endl; + Info<< nl << "Writing featureEdgeMesh to " + << bfeMesh.objectPath() << endl; - bfeMesh.regIOobject::write(); - } + bfeMesh.regIOobject::write(); triSurfaceMesh searchSurf ( diff --git a/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtractDict b/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtractDict index ef97d13889bc54c5634a5885f3d16de271fc355e..b5084ec10390041c0d3dbc197f28180fa4db2ab6 100644 --- a/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtractDict +++ b/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtractDict @@ -16,10 +16,34 @@ FoamFile surface1.stl { - // extractFromFile || extractFromSurface + // How to obtain raw features (extractFromFile || extractFromSurface) + extractionMethod extractFromSurface; + + extractFromSurfaceCoeffs + { + // Mark edges whose adjacent surface normals are at an angle less + // than includedAngle as features + // - 0 : selects no edges + // - 180: selects all edges + includedAngle 120; + } + + // Write options + + // Write .eMesh file (for snappyHexMesh) + writeFeatureEdgeMesh yes; + + // Write features to obj format for postprocessing + writeObj yes; +} + + +surface2.nas +{ + // How to obtain raw features (extractFromFile || extractFromSurface) extractionMethod extractFromFile; - extractFromFile + extractFromFileCoeffs { // Load from an existing feature edge file featureEdgeFile "constant/triSurface/featureEdges.nas"; @@ -62,24 +86,13 @@ surface1.stl closeness no; // Write options - writeVTK no; - writeObj yes; - writeFeatureEdgeMesh no; -} + // Write features to obj format for postprocessing + writeObj yes; -surface2.nas -{ - extractionMethod extractFromSurface; - - extractFromSurface - { - // Mark edges whose adjacent surface normals are at an angle less - // than includedAngle as features - // - 0 : selects no edges - // - 180: selects all edges - includedAngle 120; - } + // Write surface proximity and curvature fields to vtk format + // for postprocessing + writeVTK no; } diff --git a/applications/utilities/surface/surfaceMeshTriangulate/surfaceMeshTriangulate.C b/applications/utilities/surface/surfaceMeshTriangulate/surfaceMeshTriangulate.C index 55f01f1e2cc94b4ae6c27cd5a5508b487a334eb8..a3cc3221cd9ed971d023b245a7a7aaeaf9ff544f 100644 --- a/applications/utilities/surface/surfaceMeshTriangulate/surfaceMeshTriangulate.C +++ b/applications/utilities/surface/surfaceMeshTriangulate/surfaceMeshTriangulate.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -312,7 +312,7 @@ int main(int argc, char *argv[]) triSurface allSurf(allFaces, allPatches, allPoints); - // Cleanup (which does point merge as well + // Cleanup (which does point merge as well) allSurf.cleanup(false); // Write surface mesh diff --git a/bin/tools/CleanFunctions b/bin/tools/CleanFunctions index 9973503e52780e651124e6b42313885094a9eb81..be1c3723b42eb30522c7b65a5e0e134d9bc6efc5 100644 --- a/bin/tools/CleanFunctions +++ b/bin/tools/CleanFunctions @@ -2,7 +2,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation +# \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation # \\/ M anipulation | #------------------------------------------------------------------------------ # License @@ -88,7 +88,7 @@ cleanCase() rm -rf \ allOwner* cell* face* meshModifiers* \ owner* neighbour* point* edge* \ - cellLevel* pointLevel* refinementHistory* surfaceIndex* sets \ + cellLevel* pointLevel* refinementHistory* level0Edge surfaceIndex* sets \ > /dev/null 2>&1 \ ) fi diff --git a/bin/tools/pre-commit-hook b/bin/tools/pre-commit-hook index 1a8ae0181ad7b0ceaff823c5ae3b25b2e9d7262a..551af76c6ce41eeabc4868351e17ffe205237a2f 100755 --- a/bin/tools/pre-commit-hook +++ b/bin/tools/pre-commit-hook @@ -275,6 +275,7 @@ checkCopyright() year=$(date +%Y) echo "$hookName: check copyright ..." 1>&2 + badFiles=$( for f in $fileList do startYear=`grep "Copyright.*OpenFOAM" $f | sed 's/[^0-9]*\([0-9]*\).*/\1/g'` @@ -287,19 +288,24 @@ checkCopyright() # Date is of type 2011-2012 OpenFOAM Foundation if [ "$year" != "$endYear" ] then - echo "Updated copyright for: $f" + echo "Updated copyright for: $f" 1>&2 + echo "$f" sed -i "s/$startYear-$endYear OpenFOAM/$startYear-$year OpenFOAM/g" $f fi else # Date is of type 2011 OpenFOAM Foundation if [ "$year" != "$startYear" ] then - echo "Updated copyright for: $f" + echo "$f" + echo "Updated copyright for: $f" 1>&2 sed -i "s/$startYear OpenFOAM/$startYear-$year OpenFOAM/g" $f fi fi fi done + ) + + dieOnBadFiles "Some copyright dates were automatically updated; Please check these before pushing" } diff --git a/etc/codeTemplates/dynamicCode/functionObjectTemplate.C b/etc/codeTemplates/dynamicCode/functionObjectTemplate.C index a747b528b6f8dcc3c4247bd917bf9fba1ed3ecc8..b44bdfb8dc108aef8117866a63186a02b9dd642f 100644 --- a/etc/codeTemplates/dynamicCode/functionObjectTemplate.C +++ b/etc/codeTemplates/dynamicCode/functionObjectTemplate.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -28,10 +28,6 @@ License #include "fvCFD.H" #include "unitConversion.H" -//{{{ begin codeInclude -${codeInclude} -//}}} end codeInclude - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam diff --git a/etc/codeTemplates/dynamicCode/functionObjectTemplate.H b/etc/codeTemplates/dynamicCode/functionObjectTemplate.H index bac835412403f522db56e7206d444c497b680ab4..bd07fff034128e5d89fe86043091e416a5355dc1 100644 --- a/etc/codeTemplates/dynamicCode/functionObjectTemplate.H +++ b/etc/codeTemplates/dynamicCode/functionObjectTemplate.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -36,6 +36,10 @@ SourceFiles #include "stringList.H" #include "pointField.H" +//{{{ begin codeInclude +${codeInclude} +//}}} end codeInclude + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam diff --git a/src/OpenFOAM/containers/Lists/ListListOps/ListListOps.C b/src/OpenFOAM/containers/Lists/ListListOps/ListListOps.C index 443e188ed1d93139b2b2554c7f80272abf2b7d7f..d83b4a9f3af4bb1f244f16d74b3f684392cc7fee 100644 --- a/src/OpenFOAM/containers/Lists/ListListOps/ListListOps.C +++ b/src/OpenFOAM/containers/Lists/ListListOps/ListListOps.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -106,6 +106,7 @@ AccessType ListListOps::combineOffset return result; } + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/OpenFOAM/containers/Lists/ListListOps/ListListOps.H b/src/OpenFOAM/containers/Lists/ListListOps/ListListOps.H index c35fc714c6132f50111fd7fbab059b0c30f66edd..05cef4a723bad9d8c03d0871d2cd9b9a2a30a05a 100644 --- a/src/OpenFOAM/containers/Lists/ListListOps/ListListOps.H +++ b/src/OpenFOAM/containers/Lists/ListListOps/ListListOps.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -92,10 +92,8 @@ SourceFiles namespace Foam { -// -//template <class T> class accessOp; -//template <class T> class offsetOp; -// Dummy access operator for combine() + +// Dummy access operator for ListListOps::combine() template <class T> class accessOp { @@ -108,7 +106,7 @@ public: }; -// Offset operator for combineOffset() +// Offset operator for ListListOps::combineOffset() template <class T> class offsetOp { diff --git a/src/OpenFOAM/dimensionedTypes/dimensionedType/dimensionedType.C b/src/OpenFOAM/dimensionedTypes/dimensionedType/dimensionedType.C index 1d65b22fd6680251f87acb27ae70ddedc9658fb8..83f76cf8a3d2333d1e1182ddf7df26d3dbb880d5 100644 --- a/src/OpenFOAM/dimensionedTypes/dimensionedType/dimensionedType.C +++ b/src/OpenFOAM/dimensionedTypes/dimensionedType/dimensionedType.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -126,8 +126,30 @@ dimensioned<Type>::dimensioned : name_(name), dimensions_(dimSet), - value_(pTraits<Type>(is)) -{} + value_(pTraits<Type>::zero) +{ + token nextToken(is); + is.putBack(nextToken); + + if (nextToken == token::BEGIN_SQR) + { + dimensionSet dims(is); + + if (dims != dimensions_) + { + FatalErrorIn + ( + "dimensioned<Type>::dimensioned" + "(const word&, const dimensionSet&, Istream&)" + ) << "The dimensions " << dims + << " provided do not match the required dimensions " + << dimensions_ + << abort(FatalError); + } + } + + is >> value_; +} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/meshes/meshShapes/face/face.H b/src/OpenFOAM/meshes/meshShapes/face/face.H index 3b2ffcc757a961435746c72843260f66b882343b..c9cd3724dcae999961d39a7d64200ca0152c2d1d 100644 --- a/src/OpenFOAM/meshes/meshShapes/face/face.H +++ b/src/OpenFOAM/meshes/meshShapes/face/face.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -50,6 +50,7 @@ SourceFiles #include "faceListFwd.H" #include "intersection.H" #include "pointHit.H" +#include "ListListOps.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -386,6 +387,30 @@ public: }; +//- Hash specialization to offset faces in ListListOps::combineOffset +template<> +class offsetOp<face> +{ + +public: + + inline face operator() + ( + const face& x, + const label offset + ) const + { + face result(x.size()); + + forAll(x, xI) + { + result[xI] = x[xI] + offset; + } + return result; + } +}; + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/OpenFOAM/meshes/meshShapes/triFace/triFace.H b/src/OpenFOAM/meshes/meshShapes/triFace/triFace.H index 8e5103ac2cb7c014654e3032f6a9efe844b08d09..24ad5d3d1ccf920dd401a01b81edbe5354635d06 100644 --- a/src/OpenFOAM/meshes/meshShapes/triFace/triFace.H +++ b/src/OpenFOAM/meshes/meshShapes/triFace/triFace.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -46,6 +46,7 @@ SourceFiles #include "intersection.H" #include "pointField.H" #include "triPointRef.H" +#include "ListListOps.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -249,6 +250,30 @@ template<> inline bool contiguous<triFace>() {return true;} +//- Hash specialization to offset faces in ListListOps::combineOffset +template<> +class offsetOp<triFace> +{ + +public: + + inline triFace operator() + ( + const triFace& x, + const label offset + ) const + { + triFace result(x); + + forAll(x, xI) + { + result[xI] = x[xI] + offset; + } + return result; + } +}; + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.H b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.H index a3530dc86c39700c7edc7da10dfc54e9f4ef0d36..3a3c234821556864222c212cb55c8eab8beacc9d 100644 --- a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.H +++ b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -544,7 +544,7 @@ public: const labelListList& globalEdgeSlaves() const; const labelListList& globalEdgeTransformedSlaves() const; const mapDistribute& globalEdgeSlavesMap() const; - //- Is my edge same orientation master edge + //- Is my edge same orientation as master edge const PackedBoolList& globalEdgeOrientation() const; // Coupled point to boundary faces. These are uncoupled boundary diff --git a/src/OpenFOAM/meshes/polyMesh/polyMesh.C b/src/OpenFOAM/meshes/polyMesh/polyMesh.C index 960e35ddd4ca620744ee5733e4843b9f539c139b..8877cdafcfc38b98f6851040fb9159c5b87ace3f 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyMesh.C +++ b/src/OpenFOAM/meshes/polyMesh/polyMesh.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -1092,7 +1092,8 @@ const Foam::pointField& Foam::polyMesh::oldPoints() const Foam::tmp<Foam::scalarField> Foam::polyMesh::movePoints ( - const pointField& newPoints + const pointField& newPoints, + const bool deleteDemandDrivenData ) { if (debug) @@ -1146,6 +1147,14 @@ Foam::tmp<Foam::scalarField> Foam::polyMesh::movePoints // Force recalculation of all geometric data with new points + if (deleteDemandDrivenData) + { + // Remove the stored tet base points + tetBasePtIsPtr_.clear(); + // Remove the cell tree + cellTreePtr_.clear(); + } + bounds_ = boundBox(points_); boundary_.movePoints(points_); diff --git a/src/OpenFOAM/meshes/polyMesh/polyMesh.H b/src/OpenFOAM/meshes/polyMesh/polyMesh.H index d67896744f9b0b3bb9b67b538442c53e2ca438ca..6c013339745a3add02a726040160f3b61994db50 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyMesh.H +++ b/src/OpenFOAM/meshes/polyMesh/polyMesh.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -442,7 +442,11 @@ public: } //- Move points, returns volumes swept by faces in motion - virtual tmp<scalarField> movePoints(const pointField&); + virtual tmp<scalarField> movePoints + ( + const pointField&, + const bool deleteDemandDrivenData = false + ); //- Reset motion void resetMotion() const; diff --git a/src/OpenFOAM/meshes/polyMesh/polyMeshFromShapeMesh.C b/src/OpenFOAM/meshes/polyMesh/polyMeshFromShapeMesh.C index bf8c028ccc8280fb51b316121c5c55be39dae1e6..18a725bbec00b4e9c781731768c1de7f580e6330 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyMeshFromShapeMesh.C +++ b/src/OpenFOAM/meshes/polyMesh/polyMeshFromShapeMesh.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -614,10 +614,17 @@ Foam::polyMesh::polyMesh label nAllPatches = boundaryFaces.size(); - if (nFaces > defaultPatchStart) + + label nDefaultFaces = nFaces - defaultPatchStart; + if (syncPar) + { + reduce(nDefaultFaces, sumOp<label>()); + } + + if (nDefaultFaces > 0) { WarningIn("polyMesh::polyMesh(... construct from shapes...)") - << "Found " << nFaces - defaultPatchStart + << "Found " << nDefaultFaces << " undefined faces in mesh; adding to default patch." << endl; // Check if there already exists a defaultFaces patch as last patch @@ -883,10 +890,16 @@ Foam::polyMesh::polyMesh label nAllPatches = boundaryFaces.size(); - if (nFaces > defaultPatchStart) + label nDefaultFaces = nFaces - defaultPatchStart; + if (syncPar) + { + reduce(nDefaultFaces, sumOp<label>()); + } + + if (nDefaultFaces > 0) { WarningIn("polyMesh::polyMesh(... construct from shapes...)") - << "Found " << nFaces - defaultPatchStart + << "Found " << nDefaultFaces << " undefined faces in mesh; adding to default patch." << endl; // Check if there already exists a defaultFaces patch as last patch diff --git a/src/OpenFOAM/meshes/polyMesh/polyMeshIO.C b/src/OpenFOAM/meshes/polyMesh/polyMeshIO.C index ea3b05f0ca02bf1dcea2fe94761eb8ddedef00c4..a296fd336ad82647be52f360b0bcac8e0ad16aa8 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyMeshIO.C +++ b/src/OpenFOAM/meshes/polyMesh/polyMeshIO.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -407,9 +407,12 @@ Foam::polyMesh::readUpdateState Foam::polyMesh::readUpdate() clearGeom(); - points_.instance() = pointsInst; - points_ = pointIOField + label nOldPoints = points_.size(); + + points_.clear(); + + pointIOField newPoints ( IOobject ( @@ -423,6 +426,19 @@ Foam::polyMesh::readUpdateState Foam::polyMesh::readUpdate() ) ); + if (nOldPoints != 0 && nOldPoints != newPoints.size()) + { + FatalErrorIn("polyMesh::readUpdate()") + << "Point motion detected but number of points " + << newPoints.size() << " in " + << newPoints.objectPath() << " does not correspond to " + << " current " << nOldPoints + << exit(FatalError); + } + + points_.transfer(newPoints); + points_.instance() = pointsInst; + // Derived info bounds_ = boundBox(points_); diff --git a/src/OpenFOAM/meshes/polyMesh/polyMeshTetDecomposition/polyMeshTetDecomposition.C b/src/OpenFOAM/meshes/polyMesh/polyMeshTetDecomposition/polyMeshTetDecomposition.C index 8a9136b68a55c5eb00db3a8600aebb3244bdaaf8..ef697325b6834980e1ba30a010ac48845c672b3a 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyMeshTetDecomposition/polyMeshTetDecomposition.C +++ b/src/OpenFOAM/meshes/polyMesh/polyMeshTetDecomposition/polyMeshTetDecomposition.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -197,7 +197,7 @@ Foam::label Foam::polyMeshTetDecomposition::findBasePoint } // If a base point hasn't triggered a return by now, then there is - // non that can produce a good decomposition + // none that can produce a good decomposition return -1; } diff --git a/src/OpenFOAM/meshes/primitiveMesh/PatchTools/PatchTools.C b/src/OpenFOAM/meshes/primitiveMesh/PatchTools/PatchTools.C index 793411c162ab2efa6450b4c9c0a739d175e394a5..9335ba0f8f2637405b294f97c43d6a1dd6734faa 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/PatchTools/PatchTools.C +++ b/src/OpenFOAM/meshes/primitiveMesh/PatchTools/PatchTools.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -27,6 +27,7 @@ License #include "PatchToolsCheck.C" #include "PatchToolsEdgeOwner.C" +#include "PatchToolsGatherAndMerge.C" #include "PatchToolsSearch.C" #include "PatchToolsSortEdges.C" #include "PatchToolsNormals.C" diff --git a/src/OpenFOAM/meshes/primitiveMesh/PatchTools/PatchTools.H b/src/OpenFOAM/meshes/primitiveMesh/PatchTools/PatchTools.H index e4ade383ef366829d8b701579a8da83bc32fd4c2..968b0b52441cf3898afbd93a340ddf25559d3071 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/PatchTools/PatchTools.H +++ b/src/OpenFOAM/meshes/primitiveMesh/PatchTools/PatchTools.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -33,6 +33,7 @@ SourceFiles PatchTools.C PatchToolsCheck.C PatchToolsEdgeOwner.C + PatchToolsGatherAndMerge.C PatchToolsSearch.C PatchToolsSortEdges.C PatchToolsNormals.C @@ -236,6 +237,25 @@ public: const labelList& meshFaces ); + + //- Gather points and faces onto master and merge (geometrically) into + // single patch. + template + < + class Face, + template<class> class FaceList, + class PointField, + class PointType + > + static void gatherAndMerge + ( + const scalar mergeDist, + const PrimitivePatch<Face, FaceList, PointField, PointType>& p, + Field<PointType>& mergedPoints, + List<Face>& mergedFaces, + labelList& pointMergeMap + ); + }; diff --git a/src/OpenFOAM/meshes/primitiveMesh/PatchTools/PatchToolsGatherAndMerge.C b/src/OpenFOAM/meshes/primitiveMesh/PatchTools/PatchToolsGatherAndMerge.C new file mode 100644 index 0000000000000000000000000000000000000000..89ffdec2ae21668e99e4e90bdb6db9e0774e9700 --- /dev/null +++ b/src/OpenFOAM/meshes/primitiveMesh/PatchTools/PatchToolsGatherAndMerge.C @@ -0,0 +1,130 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM 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 3 of the License, or + (at your option) any later version. + + OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "PatchTools.H" +#include "ListListOps.H" +#include "mergePoints.H" +#include "face.H" +#include "triFace.H" +#include "ListListOps.H" + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +< + class Face, + template<class> class FaceList, + class PointField, + class PointType +> +void Foam::PatchTools::gatherAndMerge +( + const scalar mergeDist, + const PrimitivePatch<Face, FaceList, PointField, PointType>& p, + Field<PointType>& mergedPoints, + List<Face>& mergedFaces, + labelList& pointMergeMap +) +{ + // Collect points from all processors + labelList pointSizes; + { + List<Field<PointType> > gatheredPoints(Pstream::nProcs()); + gatheredPoints[Pstream::myProcNo()] = p.localPoints(); + Pstream::gatherList(gatheredPoints); + + if (Pstream::master()) + { + pointSizes = ListListOps::subSizes + ( + gatheredPoints, + accessOp<Field<PointType> >() + ); + + mergedPoints = ListListOps::combine<Field<PointType> > + ( + gatheredPoints, + accessOp<Field<PointType> >() + ); + } + } + + // Collect faces from all processors and renumber using sizes of + // gathered points + { + List<List<Face> > gatheredFaces(Pstream::nProcs()); + gatheredFaces[Pstream::myProcNo()] = p.localFaces(); + Pstream::gatherList(gatheredFaces); + + if (Pstream::master()) + { + mergedFaces = static_cast<const List<Face>&> + ( + ListListOps::combineOffset<List<Face> > + ( + gatheredFaces, + pointSizes, + accessOp<List<Face> >(), + offsetOp<Face>() + ) + ); + } + } + + if (Pstream::master()) + { + Field<PointType> newPoints; + labelList oldToNew; + + bool hasMerged = mergePoints + ( + mergedPoints, + mergeDist, + false, // verbosity + oldToNew, + newPoints + ); + + if (hasMerged) + { + // Store point mapping + pointMergeMap.transfer(oldToNew); + + // Copy points + mergedPoints.transfer(newPoints); + + // Relabel faces + List<Face>& faces = mergedFaces; + + forAll(faces, faceI) + { + inplaceRenumber(pointMergeMap, faces[faceI]); + } + } + } +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/meshes/primitiveShapes/tetrahedron/tetrahedron.C b/src/OpenFOAM/meshes/primitiveShapes/tetrahedron/tetrahedron.C index 6a16d0df73a88d3cc19bcded052bb852575a87f5..9180eb098602523eae4a3aaf3e04a1f626c1a115 100644 --- a/src/OpenFOAM/meshes/primitiveShapes/tetrahedron/tetrahedron.C +++ b/src/OpenFOAM/meshes/primitiveShapes/tetrahedron/tetrahedron.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -21,9 +21,6 @@ License You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. -Description - Calculation of shape function product for a tetrahedron - \*---------------------------------------------------------------------------*/ #include "tetrahedron.H" @@ -32,6 +29,96 @@ Description // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +template<class Point, class PointRef> +void Foam::tetrahedron<Point, PointRef>::tetOverlap +( + const tetrahedron<Point, PointRef>& tetB, + tetIntersectionList& insideTets, + label& nInside, + tetIntersectionList& outsideTets, + label& nOutside +) const +{ + // Work storage + tetIntersectionList cutInsideTets; + label nCutInside = 0; + + nInside = 0; + storeOp inside(insideTets, nInside); + storeOp cutInside(cutInsideTets, nCutInside); + + nOutside = 0; + storeOp outside(outsideTets, nOutside); + + + // Cut tetA with all inwards pointing faces of tetB. Any tets remaining + // in aboveTets are inside tetB. + + { + // face0 + plane pl0(tetB.b_, tetB.d_, tetB.c_); + + // Cut and insert subtets into cutInsideTets (either by getting + // an index from freeSlots or by appending to insideTets) or + // insert into outsideTets + sliceWithPlane(pl0, cutInside, outside); + } + + if (nCutInside == 0) + { + nInside = nCutInside; + return; + } + + { + // face1 + plane pl1(tetB.a_, tetB.c_, tetB.d_); + + nInside = 0; + + for (label i = 0; i < nCutInside; i++) + { + cutInsideTets[i].tet().sliceWithPlane(pl1, inside, outside); + } + + if (nInside == 0) + { + return; + } + } + + { + // face2 + plane pl2(tetB.a_, tetB.d_, tetB.b_); + + nCutInside = 0; + + for (label i = 0; i < nInside; i++) + { + insideTets[i].tet().sliceWithPlane(pl2, cutInside, outside); + } + + if (nCutInside == 0) + { + nInside = nCutInside; + return; + } + } + + { + // face3 + plane pl3(tetB.a_, tetB.b_, tetB.c_); + + nInside = 0; + + for (label i = 0; i < nCutInside; i++) + { + cutInsideTets[i].tet().sliceWithPlane(pl3, inside, outside); + } + } +} + + // (Probably very inefficient) minimum containment sphere calculation. // From http://www.imr.sandia.gov/papers/imr11/shewchuk2.pdf: // Sphere ctr is smallest one of diff --git a/src/OpenFOAM/meshes/primitiveShapes/tetrahedron/tetrahedron.H b/src/OpenFOAM/meshes/primitiveShapes/tetrahedron/tetrahedron.H index 5ff25795b216a8aa4c766f0a37de9cb9a8ee5140..1900aee38728abaebbf70ea16e6596969a47ebcc 100644 --- a/src/OpenFOAM/meshes/primitiveShapes/tetrahedron/tetrahedron.H +++ b/src/OpenFOAM/meshes/primitiveShapes/tetrahedron/tetrahedron.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -87,6 +87,13 @@ class tetrahedron { public: + // Public typedefs + + //- Storage type for tets originating from intersecting tets. + // (can possibly be smaller than 200) + typedef FixedList<tetPoints, 200> tetIntersectionList; + + // Classes for use in sliceWithPlane. What to do with decomposition // of tet. @@ -111,11 +118,11 @@ public: //- Store resulting tets class storeOp { - FixedList<tetPoints, 200>& tets_; + tetIntersectionList& tets_; label& nTets_; public: - inline storeOp(FixedList<tetPoints, 200>&, label&); + inline storeOp(tetIntersectionList&, label&); inline void operator()(const tetPoints&); }; @@ -261,6 +268,16 @@ public: BelowTetOp& belowOp ) const; + //- Decompose tet into tets inside and outside other tet + inline void tetOverlap + ( + const tetrahedron<Point, PointRef>& tetB, + tetIntersectionList& insideTets, + label& nInside, + tetIntersectionList& outsideTets, + label& nOutside + ) const; + //- Return (min)containment sphere, i.e. the smallest sphere with // all points inside. Returns pointHit with: diff --git a/src/OpenFOAM/meshes/primitiveShapes/tetrahedron/tetrahedronI.H b/src/OpenFOAM/meshes/primitiveShapes/tetrahedron/tetrahedronI.H index 5a6787be8390b813894fdd12dce48f652cd1a339..7831e2614befd181ba6331ace1beddaf7b7752ee 100644 --- a/src/OpenFOAM/meshes/primitiveShapes/tetrahedron/tetrahedronI.H +++ b/src/OpenFOAM/meshes/primitiveShapes/tetrahedron/tetrahedronI.H @@ -556,7 +556,7 @@ inline void Foam::tetrahedron<Point, PointRef>::sumVolOp::operator() template<class Point, class PointRef> inline Foam::tetrahedron<Point, PointRef>::storeOp::storeOp ( - FixedList<tetPoints, 200>& tets, + tetIntersectionList& tets, label& nTets ) : diff --git a/src/Pstream/mpi/UPstream.C b/src/Pstream/mpi/UPstream.C index e5b2808ca615b970686aec5af010a0bec3c03ca3..3123aa47879d1f89bc740ff278f6aa11547a8e5d 100644 --- a/src/Pstream/mpi/UPstream.C +++ b/src/Pstream/mpi/UPstream.C @@ -41,40 +41,6 @@ License # define MPI_SCALAR MPI_DOUBLE #endif -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - typedef struct - { - scalar value; - label count; - } CountAndValue; - - void reduceSum - ( - void *in, - void *inOut, - int *len, - MPI_Datatype *dptr - ) - { - CountAndValue* inPtr = - reinterpret_cast<CountAndValue*>(in); - CountAndValue* inOutPtr = - reinterpret_cast<CountAndValue*>(inOut); - - for (int i=0; i< *len; ++i) - { - inOutPtr->value += inPtr->value; - inOutPtr->count += inPtr->count; - inPtr++; - inOutPtr++; - } - } -} - - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // NOTE: @@ -493,101 +459,11 @@ void Foam::sumReduce const int tag ) { - static bool hasDataType_ = false; - static MPI_Datatype mesg_mpi_strct_; - static MPI_Op myOp_; - - if (Pstream::debug) - { - Pout<< "Foam::sumReduce : value:" << Value - << " count:" << Count << endl; - } - - if (!UPstream::parRun()) - { - return; - } - - if (UPstream::nProcs() <= UPstream::nProcsSimpleSum) - { - reduce(Value, sumOp<scalar>(), tag); - reduce(Count, sumOp<label>(), tag); - } - else - { - CountAndValue in,out; + vector2D twoScalars(Value, scalar(Count)); + reduce(twoScalars, sumOp<vector2D>()); - if (!hasDataType_) - { - int lengths[2]; - lengths[0] = 1; - lengths[1] = 1; - MPI_Datatype types[2]; - types[0] = MPI_DOUBLE; - types[1] = MPI_INT; - MPI_Aint addresses[2]; - MPI_Address(&in.value, &addresses[0]); - MPI_Address(&in.count, &addresses[1]); - MPI_Aint offsets[2]; - offsets[0] = 0; - offsets[1] = addresses[1]-addresses[0]; - - if - ( - MPI_Type_create_struct - ( - 2, - lengths, - offsets, - types, - &mesg_mpi_strct_ - ) - ) - { - FatalErrorIn("Foam::sumReduce()") - << "MPI_Type_create_struct" << abort(FatalError); - } - if (MPI_Type_commit(&mesg_mpi_strct_)) - { - FatalErrorIn("Foam::sumReduce()") - << "MPI_Type_commit" << abort(FatalError); - } - if (MPI_Op_create(reduceSum, true, &myOp_)) - { - FatalErrorIn("Foam::sumReduce()") - << "MPI_Op_create" << abort(FatalError); - } - - hasDataType_ = true; - } - - in.value = Value; - in.count = Count; - if - ( - MPI_Allreduce - ( - &in, - &out, - 1, - mesg_mpi_strct_, - myOp_, - MPI_COMM_WORLD - ) - ) - { - FatalErrorIn("Foam::sumReduce(..)") - << "Problem." << abort(FatalError); - } - Value = out.value; - Count = out.count; - } - - if (Pstream::debug) - { - Pout<< "Foam::reduce : reduced value:" << Value - << " reduced count:" << Count << endl; - } + Value = twoScalars.x(); + Count = twoScalars.y(); } diff --git a/src/dynamicMesh/motionSmoother/motionSmoother.C b/src/dynamicMesh/motionSmoother/motionSmoother.C index cace37690b88521f6927944fbb27617ca74f5d30..6542432aea4e224f371ef0db1d78fb145a98435d 100644 --- a/src/dynamicMesh/motionSmoother/motionSmoother.C +++ b/src/dynamicMesh/motionSmoother/motionSmoother.C @@ -903,7 +903,9 @@ Foam::tmp<Foam::scalarField> Foam::motionSmoother::movePoints testSyncPositions(newPoints, 1E-6*mesh_.bounds().mag()); } - tmp<scalarField> tsweptVol = mesh_.movePoints(newPoints); + // Move actual mesh points. Make sure to delete tetBasePtIs so it + // gets rebuilt. + tmp<scalarField> tsweptVol = mesh_.movePoints(newPoints, true); pp_.movePoints(mesh_.points()); diff --git a/src/fileFormats/vtk/vtkUnstructuredReader.C b/src/fileFormats/vtk/vtkUnstructuredReader.C index 049f68f89bad0cbfa00c9e1ce727884904d52007..5bb8b8d8f9ff1d39cea312fc38f231824f4397ca 100644 --- a/src/fileFormats/vtk/vtkUnstructuredReader.C +++ b/src/fileFormats/vtk/vtkUnstructuredReader.C @@ -36,14 +36,18 @@ defineTypeNameAndDebug(Foam::vtkUnstructuredReader, 0); template<> const char* -Foam::NamedEnum<Foam::vtkUnstructuredReader::vtkDataType, 4>::names[] = +Foam::NamedEnum<Foam::vtkUnstructuredReader::vtkDataType, 8>::names[] = { "int", + "unsigned_int", + "long", + "unsigned_long", "float", + "double", "string", "vtkIdType" }; -const Foam::NamedEnum<Foam::vtkUnstructuredReader::vtkDataType, 4> +const Foam::NamedEnum<Foam::vtkUnstructuredReader::vtkDataType, 8> Foam::vtkUnstructuredReader::vtkDataTypeNames; @@ -385,6 +389,9 @@ void Foam::vtkUnstructuredReader::readField switch (vtkDataTypeNames[dataType]) { case VTK_INT: + case VTK_UINT: + case VTK_LONG: + case VTK_ULONG: case VTK_ID: { autoPtr<labelIOField> fieldVals @@ -406,6 +413,7 @@ void Foam::vtkUnstructuredReader::readField break; case VTK_FLOAT: + case VTK_DOUBLE: { autoPtr<scalarIOField> fieldVals ( @@ -627,7 +635,7 @@ void Foam::vtkUnstructuredReader::read(ISstream& inFile) } word primitiveTag(inFile); - if (primitiveTag != "float") + if (primitiveTag != "float" && primitiveTag != "double") { FatalIOErrorIn("vtkUnstructuredReader::read(..)", inFile) << "Expected 'float' entry but found " @@ -809,7 +817,11 @@ void Foam::vtkUnstructuredReader::read(ISstream& inFile) 3*wantedSize ); - if (vtkDataTypeNames[dataType] == VTK_FLOAT) + if + ( + vtkDataTypeNames[dataType] == VTK_FLOAT + || vtkDataTypeNames[dataType] == VTK_DOUBLE + ) { objectRegistry::iterator iter = reg.find(dataName); scalarField s(*dynamic_cast<const scalarField*>(iter())); diff --git a/src/fileFormats/vtk/vtkUnstructuredReader.H b/src/fileFormats/vtk/vtkUnstructuredReader.H index 201012eaec1b2ad4a81c923c80d336b56f98af85..e31bfb0d419d418d73c45e55db97f2abaa2d7380 100644 --- a/src/fileFormats/vtk/vtkUnstructuredReader.H +++ b/src/fileFormats/vtk/vtkUnstructuredReader.H @@ -28,6 +28,8 @@ Description Reader for vtk unstructured_grid legacy files. Supports single CELLS, POINTS etc. entry only. + - all integer types (int, unsigned_int, long etc.) become Foam::label + - all real types (float, double) become Foam::scalar - POINTS becomes OpenFOAM points - CELLS gets split into OpenFOAM - cells @@ -69,12 +71,16 @@ public: enum vtkDataType { VTK_INT, + VTK_UINT, + VTK_LONG, + VTK_ULONG, VTK_FLOAT, + VTK_DOUBLE, VTK_STRING, VTK_ID }; - static const NamedEnum<vtkDataType, 4> vtkDataTypeNames; + static const NamedEnum<vtkDataType, 8> vtkDataTypeNames; //- Enumeration defining the vtk dataset types diff --git a/src/finiteVolume/Make/files b/src/finiteVolume/Make/files index 0e2de76c07e9afe4c38740a43dfcbf49a9079ec8..c7e7453b1f5ad23fb696f3bf8dc1d2deaf3ff7df 100644 --- a/src/finiteVolume/Make/files +++ b/src/finiteVolume/Make/files @@ -173,6 +173,8 @@ $(derivedFvPatchFields)/cylindricalInletVelocity/cylindricalInletVelocityFvPatch $(derivedFvPatchFields)/outletMappedUniformInlet/outletMappedUniformInletFvPatchFields.C $(derivedFvPatchFields)/waveSurfacePressure/waveSurfacePressureFvPatchScalarField.C $(derivedFvPatchFields)/phaseHydrostaticPressure/phaseHydrostaticPressureFvPatchScalarField.C +$(derivedFvPatchFields)/variableHeightFlowRate/variableHeightFlowRateFvPatchField.C +$(derivedFvPatchFields)/variableHeightFlowRateInletVelocity/variableHeightFlowRateInletVelocityFvPatchVectorField.C fvsPatchFields = fields/fvsPatchFields $(fvsPatchFields)/fvsPatchField/fvsPatchFields.C @@ -338,10 +340,6 @@ $(snGradSchemes)/correctedSnGrad/correctedSnGrads.C $(snGradSchemes)/limitedSnGrad/limitedSnGrads.C $(snGradSchemes)/uncorrectedSnGrad/uncorrectedSnGrads.C $(snGradSchemes)/orthogonalSnGrad/orthogonalSnGrads.C -/* -$(snGradSchemes)/quadraticFitSnGrad/quadraticFitSnGradData.C -$(snGradSchemes)/quadraticFitSnGrad/quadraticFitSnGrads.C -*/ convectionSchemes = finiteVolume/convectionSchemes $(convectionSchemes)/convectionScheme/convectionSchemes.C diff --git a/src/finiteVolume/cfdTools/general/MRF/MRFZone.C b/src/finiteVolume/cfdTools/general/MRF/MRFZone.C index d2f8caeb23be383488c97145f9173ca75f5fcd73..ab1837b1f6fcdb1ac5c376bc3892a72d663c18fa 100644 --- a/src/finiteVolume/cfdTools/general/MRF/MRFZone.C +++ b/src/finiteVolume/cfdTools/general/MRF/MRFZone.C @@ -32,6 +32,7 @@ License #include "faceSet.H" #include "geometricOneField.H" + // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // defineTypeNameAndDebug(Foam::MRFZone, 0); @@ -273,8 +274,8 @@ Foam::MRFZone::MRFZone(const fvMesh& mesh, Istream& is) } } - bool cellZoneFound = (cellZoneID_ != -1); + reduce(cellZoneFound, orOp<bool>()); if (!cellZoneFound) @@ -307,6 +308,7 @@ void Foam::MRFZone::addCoriolis const scalarField& V = mesh_.V(); vectorField& ddtUc = ddtU.internalField(); const vectorField& Uc = U.internalField(); + const vector& Omega = Omega_.value(); forAll(cells, i) @@ -328,6 +330,7 @@ void Foam::MRFZone::addCoriolis(fvVectorMatrix& UEqn) const const scalarField& V = mesh_.V(); vectorField& Usource = UEqn.source(); const vectorField& U = UEqn.psi(); + const vector& Omega = Omega_.value(); forAll(cells, i) @@ -353,6 +356,7 @@ void Foam::MRFZone::addCoriolis const scalarField& V = mesh_.V(); vectorField& Usource = UEqn.source(); const vectorField& U = UEqn.psi(); + const vector& Omega = Omega_.value(); forAll(cells, i) @@ -368,6 +372,7 @@ void Foam::MRFZone::relativeVelocity(volVectorField& U) const const volVectorField& C = mesh_.C(); const vector& origin = origin_.value(); + const vector& Omega = Omega_.value(); const labelList& cells = mesh_.cellZones()[cellZoneID_]; @@ -395,7 +400,8 @@ void Foam::MRFZone::relativeVelocity(volVectorField& U) const { label patchFacei = excludedFaces_[patchi][i]; U.boundaryField()[patchi][patchFacei] -= - (Omega ^ (C.boundaryField()[patchi][patchFacei] - origin)); + (Omega + ^ (C.boundaryField()[patchi][patchFacei] - origin)); } } } @@ -406,6 +412,7 @@ void Foam::MRFZone::absoluteVelocity(volVectorField& U) const const volVectorField& C = mesh_.C(); const vector& origin = origin_.value(); + const vector& Omega = Omega_.value(); const labelList& cells = mesh_.cellZones()[cellZoneID_]; @@ -475,6 +482,7 @@ void Foam::MRFZone::absoluteFlux void Foam::MRFZone::correctBoundaryVelocity(volVectorField& U) const { const vector& origin = origin_.value(); + const vector& Omega = Omega_.value(); // Included patches @@ -496,4 +504,24 @@ void Foam::MRFZone::correctBoundaryVelocity(volVectorField& U) const } +Foam::Ostream& Foam::operator<<(Ostream& os, const MRFZone& MRF) +{ + os << indent << nl; + os.write(MRF.name_) << nl; + os << token::BEGIN_BLOCK << incrIndent << nl; + os.writeKeyword("origin") << MRF.origin_ << token::END_STATEMENT << nl; + os.writeKeyword("axis") << MRF.axis_ << token::END_STATEMENT << nl; + os.writeKeyword("omega") << MRF.omega_ << token::END_STATEMENT << nl; + + if (MRF.excludedPatchNames_.size()) + { + os.writeKeyword("nonRotatingPatches") << MRF.excludedPatchNames_ + << token::END_STATEMENT << nl; + } + + os << decrIndent << token::END_BLOCK << nl; + + return os; +} + // ************************************************************************* // diff --git a/src/finiteVolume/cfdTools/general/MRF/MRFZone.H b/src/finiteVolume/cfdTools/general/MRF/MRFZone.H index 0a4f21bf6501677db1c7e3ab9cd0522e002a9a2c..5c5cd245c033e2e54ed49973d725d582fbc817e4 100644 --- a/src/finiteVolume/cfdTools/general/MRF/MRFZone.H +++ b/src/finiteVolume/cfdTools/general/MRF/MRFZone.H @@ -48,6 +48,7 @@ SourceFiles #include "surfaceFieldsFwd.H" #include "fvMatricesFwd.H" #include "fvMatrices.H" +#include "DataEntry.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -87,7 +88,7 @@ class MRFZone const dimensionedVector origin_; dimensionedVector axis_; - const dimensionedScalar omega_; + dimensionedScalar omega_; dimensionedVector Omega_; @@ -205,13 +206,11 @@ public: void correctBoundaryVelocity(volVectorField& U) const; - // Ostream Operator + // IOstream operator + + friend Ostream& operator<<(Ostream& os, const MRFZone& MRF); + - friend Ostream& operator<<(Ostream& os, const MRFZone&) - { - notImplemented("Ostream& operator<<(Ostream& os, const MRFZone&)"); - return os; - } }; diff --git a/src/finiteVolume/cfdTools/general/MRF/MRFZones.C b/src/finiteVolume/cfdTools/general/MRF/MRFZones.C index d1c961afec7edd3698ffaf35a896c7f4e2ca9701..fa35898f0e611b20448ba25ab1655f62e6c5c0c7 100644 --- a/src/finiteVolume/cfdTools/general/MRF/MRFZones.C +++ b/src/finiteVolume/cfdTools/general/MRF/MRFZones.C @@ -49,8 +49,28 @@ Foam::MRFZones::MRFZones(const fvMesh& mesh) IOobject::NO_WRITE ), MRFZone::iNew(mesh) + ), + mesh_(mesh) +{ + if + ( + Pstream::parRun() + && + ( + regIOobject::fileModificationChecking == timeStampMaster + || regIOobject::fileModificationChecking == inotifyMaster + ) ) -{} + { + WarningIn("MRFZones(const fvMesh&)") + << "The MRFZones are not run time modifiable\n" + << " using 'timeStampMaster' or 'inotifyMaster'\n" + << " for the entry fileModificationChecking\n" + << " in the etc/controlDict.\n" + << " Use 'timeStamp' instead." + << endl; + } +} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // @@ -161,4 +181,11 @@ void Foam::MRFZones::correctBoundaryVelocity(volVectorField& U) const } +bool Foam::MRFZones::readData(Istream& is) +{ + PtrList<MRFZone>::read(is, MRFZone::iNew(mesh_)); + return is.good(); +} + + // ************************************************************************* // diff --git a/src/finiteVolume/cfdTools/general/MRF/MRFZones.H b/src/finiteVolume/cfdTools/general/MRF/MRFZones.H index 8df9d428beeeef06ba030e3cfff3cf6a94775e9b..f5b43bce290df8d1703d86698a5196325607b6c8 100644 --- a/src/finiteVolume/cfdTools/general/MRF/MRFZones.H +++ b/src/finiteVolume/cfdTools/general/MRF/MRFZones.H @@ -52,6 +52,11 @@ class MRFZones : public IOPtrList<MRFZone> { + // Private data + + //- Reference to mesh + const fvMesh& mesh_; + // Private Member Functions @@ -109,6 +114,13 @@ public: //- Correct the boundary velocity for the roation of the MRF region void correctBoundaryVelocity(volVectorField& U) const; + + + // I-O + + //- Read from Istream + virtual bool readData(Istream&); + }; diff --git a/src/finiteVolume/fields/fvPatchFields/derived/phaseHydrostaticPressure/phaseHydrostaticPressureFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/phaseHydrostaticPressure/phaseHydrostaticPressureFvPatchScalarField.C index 6b9a22da0fb48fb67df5eaf87b91098a236a341d..09da151f9850b35a2950b4107c6496839ac5cec0 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/phaseHydrostaticPressure/phaseHydrostaticPressureFvPatchScalarField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/phaseHydrostaticPressure/phaseHydrostaticPressureFvPatchScalarField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -148,7 +148,7 @@ void Foam::phaseHydrostaticPressureFvPatchScalarField::updateCoeffs() // scalar rhor = 1000; // scalarField alphap1 = max(min(alphap, 1.0), 0.0); // valueFraction() = alphap1/(alphap1 + rhor*(1.0 - alphap1)); - valueFraction() = max(min(alphap, 1.0), 0.0); + valueFraction() = max(min(alphap, scalar(1.0)), scalar(0.0)); refValue() = pRefValue_ diff --git a/src/finiteVolume/fields/fvPatchFields/derived/variableHeightFlowRate/variableHeightFlowRateFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/variableHeightFlowRate/variableHeightFlowRateFvPatchField.C new file mode 100644 index 0000000000000000000000000000000000000000..8c293d4a993d35a387a899d796a19911acaa8587 --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/derived/variableHeightFlowRate/variableHeightFlowRateFvPatchField.C @@ -0,0 +1,196 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM 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 3 of the License, or + (at your option) any later version. + + OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "variableHeightFlowRateFvPatchField.H" +#include "fvPatchFieldMapper.H" +#include "addToRunTimeSelectionTable.H" +#include "volFields.H" +#include "surfaceFields.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::variableHeightFlowRateFvPatchScalarField +::variableHeightFlowRateFvPatchScalarField +( + const fvPatch& p, + const DimensionedField<scalar, volMesh>& iF +) +: + mixedFvPatchField<scalar>(p, iF), + phiName_("phi"), + lowerBound_(0.0), + upperBound_(1.0) +{ + this->refValue() = 0.0; + this->refGrad() = 0.0; + this->valueFraction() = 0.0; +} + + +Foam::variableHeightFlowRateFvPatchScalarField +::variableHeightFlowRateFvPatchScalarField +( + const variableHeightFlowRateFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField<scalar, volMesh>& iF, + const fvPatchFieldMapper& mapper +) +: + mixedFvPatchScalarField(ptf, p, iF, mapper), + phiName_(ptf.phiName_), + lowerBound_(ptf.lowerBound_), + upperBound_(ptf.upperBound_) +{} + + +Foam::variableHeightFlowRateFvPatchScalarField +::variableHeightFlowRateFvPatchScalarField +( + const fvPatch& p, + const DimensionedField<scalar, volMesh>& iF, + const dictionary& dict +) +: + mixedFvPatchScalarField(p, iF), + phiName_(dict.lookupOrDefault<word>("phi", "phi")), + lowerBound_(readScalar(dict.lookup("lowerBound"))), + upperBound_(readScalar(dict.lookup("upperBound"))) +{ + this->refValue() = 0.0; + + if (dict.found("value")) + { + fvPatchScalarField::operator= + ( + scalarField("value", dict, p.size()) + ); + } + else + { + fvPatchScalarField::operator=(this->patchInternalField()); + } + + this->refGrad() = 0.0; + this->valueFraction() = 0.0; +} + + +Foam::variableHeightFlowRateFvPatchScalarField + ::variableHeightFlowRateFvPatchScalarField +( + const variableHeightFlowRateFvPatchScalarField& ptf +) +: + mixedFvPatchScalarField(ptf), + phiName_(ptf.phiName_), + lowerBound_(ptf.lowerBound_), + upperBound_(ptf.upperBound_) +{} + + +Foam::variableHeightFlowRateFvPatchScalarField + ::variableHeightFlowRateFvPatchScalarField +( + const variableHeightFlowRateFvPatchScalarField& ptf, + const DimensionedField<scalar, volMesh>& iF +) +: + mixedFvPatchScalarField(ptf, iF), + phiName_(ptf.phiName_), + lowerBound_(ptf.lowerBound_), + upperBound_(ptf.upperBound_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::variableHeightFlowRateFvPatchScalarField::updateCoeffs() +{ + if (this->updated()) + { + return; + } + + const fvsPatchField<scalar>& phip = + patch().lookupPatchField<surfaceScalarField, scalar>(phiName_); + + scalarField alphap = this->patchInternalField(); + + + forAll(phip, i) + { + if (phip[i] < -SMALL) + { + if (alphap[i] < lowerBound_) + { + this->refValue()[i] = 0.0; + } + else if (alphap[i] > upperBound_) + { + this->refValue()[i] = 1.0; + } + else + { + this->refValue()[i] = alphap[i]; + } + + this->valueFraction()[i] = 1.0; + } + else + { + this->refValue()[i] = 0.0; + this->valueFraction()[i] = 0.0; + } + } + + mixedFvPatchScalarField::updateCoeffs(); +} + + +void Foam::variableHeightFlowRateFvPatchScalarField::write(Ostream& os) const +{ + fvPatchScalarField::write(os); + if (phiName_ != "phi") + { + os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl; + } + os.writeKeyword("lowerBound") << lowerBound_ << token::END_STATEMENT << nl; + os.writeKeyword("upperBound") << upperBound_ << token::END_STATEMENT << nl; + this->writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + makePatchTypeField + ( + fvPatchScalarField, + variableHeightFlowRateFvPatchScalarField + ); +} + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/variableHeightFlowRate/variableHeightFlowRateFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/derived/variableHeightFlowRate/variableHeightFlowRateFvPatchField.H new file mode 100644 index 0000000000000000000000000000000000000000..51e8c878990995df0b653b7ef27e012fc4983bc3 --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/derived/variableHeightFlowRate/variableHeightFlowRateFvPatchField.H @@ -0,0 +1,174 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM 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 3 of the License, or + (at your option) any later version. + + OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +Class + Foam::variableHeightFlowRateFvPatchScalarField + +Description + This boundary condition uses zeroGradient within a specified range of + values for phase fraction alpha. The range is defined within the + boundary condition by the lowerBound and upperBound. + + alpha > upperBound: fixedValue with uniform value of upperBound + lowerBound <= alpha <= upperBound: zeroGradient + alpha < lowerBound: fixedValue with uniform value of lowerBound + + Example: + \verbatim + inlet + { + type clippedZeroGradient; + lowerBound 0.0; + upperBound 0.9; + value uniform 0; + } + \verbatim + +SourceFiles + variableHeightFlowRateFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef variableHeightFlowRateFvPatchScalarField_H +#define variableHeightFlowRateFvPatchScalarField_H + +#include "mixedFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class variableHeightFlowRateFvPatchScalar Declaration +\*---------------------------------------------------------------------------*/ + +class variableHeightFlowRateFvPatchScalarField +: + public mixedFvPatchScalarField +{ + +protected: + + // Protected data + + //- Name of flux field + word phiName_; + + //- Lower bound for alpha1 + scalar lowerBound_; + + //- Upper bound for alpha1 + scalar upperBound_; + +public: + + //- Runtime scalar information + TypeName("variableHeightFlowRate"); + + + // Constructors + + //- Construct from patch and internal field + variableHeightFlowRateFvPatchScalarField + ( + const fvPatch&, + const DimensionedField<scalar, volMesh>& + ); + + //- Construct from patch, internal field and dictionary + variableHeightFlowRateFvPatchScalarField + ( + const fvPatch&, + const DimensionedField<scalar, volMesh>&, + const dictionary& + ); + + //- Construct by mapping given + // variableHeightFlowRateFvPatchScalarField onto a new patch + variableHeightFlowRateFvPatchScalarField + ( + const variableHeightFlowRateFvPatchScalarField&, + const fvPatch&, + const DimensionedField<scalar, volMesh>&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + variableHeightFlowRateFvPatchScalarField + ( + const variableHeightFlowRateFvPatchScalarField& + ); + + //- Construct and return a clone + virtual tmp<fvPatchField<scalar> > clone() const + { + return tmp<fvPatchField<scalar> > + ( + new variableHeightFlowRateFvPatchScalarField(*this) + ); + } + + //- Construct as copy setting internal field reference + variableHeightFlowRateFvPatchScalarField + ( + const variableHeightFlowRateFvPatchScalarField&, + const DimensionedField<scalar, volMesh>& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp<fvPatchField<scalar> > clone + ( + const DimensionedField<scalar, volMesh>& iF + ) const + { + return tmp<fvPatchField<scalar> > + ( + new variableHeightFlowRateFvPatchScalarField(*this, iF) + ); + } + + + // Member functions + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + //- Write + virtual void write(Ostream&) const; + + + // Member operators + +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/variableHeightFlowRateInletVelocity/variableHeightFlowRateInletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/variableHeightFlowRateInletVelocity/variableHeightFlowRateInletVelocityFvPatchVectorField.C new file mode 100644 index 0000000000000000000000000000000000000000..98d98f07bab1b46831c5e9ec2b3e6832bacb2c8f --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/derived/variableHeightFlowRateInletVelocity/variableHeightFlowRateInletVelocityFvPatchVectorField.C @@ -0,0 +1,147 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM 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. + + OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "variableHeightFlowRateInletVelocityFvPatchVectorField.H" +#include "volFields.H" +#include "addToRunTimeSelectionTable.H" +#include "fvPatchFieldMapper.H" +#include "surfaceFields.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::variableHeightFlowRateInletVelocityFvPatchVectorField +::variableHeightFlowRateInletVelocityFvPatchVectorField +( + const fvPatch& p, + const DimensionedField<vector, volMesh>& iF +) +: + fixedValueFvPatchField<vector>(p, iF), + flowRate_(0) +{} + + +Foam::variableHeightFlowRateInletVelocityFvPatchVectorField +::variableHeightFlowRateInletVelocityFvPatchVectorField +( + const variableHeightFlowRateInletVelocityFvPatchVectorField& ptf, + const fvPatch& p, + const DimensionedField<vector, volMesh>& iF, + const fvPatchFieldMapper& mapper +) +: + fixedValueFvPatchField<vector>(ptf, p, iF, mapper), + flowRate_(ptf.flowRate_) +{} + + +Foam::variableHeightFlowRateInletVelocityFvPatchVectorField +::variableHeightFlowRateInletVelocityFvPatchVectorField +( + const fvPatch& p, + const DimensionedField<vector, volMesh>& iF, + const dictionary& dict +) +: + fixedValueFvPatchField<vector>(p, iF, dict), + flowRate_(readScalar(dict.lookup("flowRate"))) +{} + + +Foam::variableHeightFlowRateInletVelocityFvPatchVectorField +::variableHeightFlowRateInletVelocityFvPatchVectorField +( + const variableHeightFlowRateInletVelocityFvPatchVectorField& ptf +) +: + fixedValueFvPatchField<vector>(ptf), + flowRate_(ptf.flowRate_) +{} + + +Foam::variableHeightFlowRateInletVelocityFvPatchVectorField +::variableHeightFlowRateInletVelocityFvPatchVectorField +( + const variableHeightFlowRateInletVelocityFvPatchVectorField& ptf, + const DimensionedField<vector, volMesh>& iF +) +: + fixedValueFvPatchField<vector>(ptf, iF), + flowRate_(ptf.flowRate_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::variableHeightFlowRateInletVelocityFvPatchVectorField +::updateCoeffs() +{ + if (updated()) + { + return; + } + + scalarField alphap = + patch().lookupPatchField<volScalarField, scalar>("alpha1"); + + alphap = max(alphap, 0.0); + alphap = min(alphap, 1.0); + + // a simpler way of doing this would be nice + scalar avgU = -flowRate_/gSum(patch().magSf()*alphap); + + vectorField n = patch().nf(); + + operator==(n*avgU*alphap); + + fixedValueFvPatchField<vector>::updateCoeffs(); +} + + +void Foam::variableHeightFlowRateInletVelocityFvPatchVectorField +::write(Ostream& os) const +{ + fvPatchField<vector>::write(os); + + os.writeKeyword("flowRate") << flowRate_ + << token::END_STATEMENT << nl; + writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + makePatchTypeField + ( + fvPatchVectorField, + variableHeightFlowRateInletVelocityFvPatchVectorField + ); +} + + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/variableHeightFlowRateInletVelocity/variableHeightFlowRateInletVelocityFvPatchVectorField.H b/src/finiteVolume/fields/fvPatchFields/derived/variableHeightFlowRateInletVelocity/variableHeightFlowRateInletVelocityFvPatchVectorField.H new file mode 100644 index 0000000000000000000000000000000000000000..d1bc1ac62f74b43f7fd245d6d5cc38b7483ef651 --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/derived/variableHeightFlowRateInletVelocity/variableHeightFlowRateInletVelocityFvPatchVectorField.H @@ -0,0 +1,189 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM 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. + + OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::variableHeightFlowRateInletVelocityFvPatchVectorField + +Description + Describes a volumetric/mass flow normal vector boundary condition by its + magnitude as an integral over its area. + + The basis of the patch (volumetric or mass) is determined by the + dimensions of the flux, phi. + The current density is used to correct the velocity when applying the + mass basis. + + The flow rate is made proportional to the phase fraction alpha at each face + of the patch and alpha is ensured to be bound between 0 and 1. + + Example of the boundary condition specification: + \verbatim + inlet + { + type variableHeightFlowRateInletVelocity; + flowRate 0.2; // Volumetric/mass flow rate [m3/s or kg/s] + value uniform (0 0 0); // placeholder + } + \endverbatim + +Note + - The value is positive inwards + - May not work correctly for transonic inlets + - Strange behaviour with potentialFoam since the U equation is not solved + +SourceFiles + variableHeightFlowRateInletVelocityFvPatchVectorField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef variableHeightFlowRateInletVelocityFvPatchVectorField_H +#define variableHeightFlowRateInletVelocityFvPatchVectorField_H + +#include "fixedValueFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +/*---------------------------------------------------------------------------*\ + Class variableHeightFlowRateInletVelocityFvPatch Declaration +\*---------------------------------------------------------------------------*/ + +class variableHeightFlowRateInletVelocityFvPatchVectorField +: + public fixedValueFvPatchVectorField +{ + // Private data + + //- Inlet integral flow rate + scalar flowRate_; + +public: + + //- Runtime type information + TypeName("variableHeightFlowRateInletVelocity"); + + + // Constructors + + //- Construct from patch and internal field + variableHeightFlowRateInletVelocityFvPatchVectorField + ( + const fvPatch&, + const DimensionedField<vector, volMesh>& + ); + + //- Construct from patch, internal field and dictionary + variableHeightFlowRateInletVelocityFvPatchVectorField + ( + const fvPatch&, + const DimensionedField<vector, volMesh>&, + const dictionary& + ); + + //- Construct by mapping given + // variableHeightFlowRateInletVelocityFvPatchVectorField + // onto a new patch + variableHeightFlowRateInletVelocityFvPatchVectorField + ( + const variableHeightFlowRateInletVelocityFvPatchVectorField&, + const fvPatch&, + const DimensionedField<vector, volMesh>&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + variableHeightFlowRateInletVelocityFvPatchVectorField + ( + const variableHeightFlowRateInletVelocityFvPatchVectorField& + ); + + //- Construct and return a clone + virtual tmp<fvPatchVectorField> clone() const + { + return tmp<fvPatchVectorField> + ( + new variableHeightFlowRateInletVelocityFvPatchVectorField(*this) + ); + } + + //- Construct as copy setting internal field reference + variableHeightFlowRateInletVelocityFvPatchVectorField + ( + const variableHeightFlowRateInletVelocityFvPatchVectorField&, + const DimensionedField<vector, volMesh>& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp<fvPatchVectorField> clone + ( + const DimensionedField<vector, volMesh>& iF + ) const + { + return tmp<fvPatchVectorField> + ( + new variableHeightFlowRateInletVelocityFvPatchVectorField + ( + *this, + iF + ) + ); + } + + + // Member functions + + // Access + + //- Return the flux + scalar flowRate() const + { + return flowRate_; + } + + //- Return reference to the flux to allow adjustment + scalar& flowRate() + { + return flowRate_; + } + + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + //- Write + virtual void write(Ostream&) const; + +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteVolume/finiteVolume/ddtSchemes/EulerDdtScheme/EulerDdtScheme.C b/src/finiteVolume/finiteVolume/ddtSchemes/EulerDdtScheme/EulerDdtScheme.C index 81559df141edf32e9acf4d3ed6573aefd3cd6757..d48a63449117cc972f7283b05f4c1e14ca315c18 100644 --- a/src/finiteVolume/finiteVolume/ddtSchemes/EulerDdtScheme/EulerDdtScheme.C +++ b/src/finiteVolume/finiteVolume/ddtSchemes/EulerDdtScheme/EulerDdtScheme.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -389,6 +389,8 @@ EulerDdtScheme<Type>::fvcDdtPhiCorr tmp<fluxFieldType> phiCorr = phiAbs.oldTime() - (fvc::interpolate(U.oldTime()) & mesh().Sf()); + phiCorr().boundaryField() = pTraits<typename flux<Type>::type>::zero; + return tmp<fluxFieldType> ( new fluxFieldType @@ -430,7 +432,7 @@ EulerDdtScheme<Type>::fvcDdtPhiCorr && phiAbs.dimensions() == dimVelocity*dimArea ) { - return tmp<fluxFieldType> + tmp<fluxFieldType> ddtPhiCorr ( new fluxFieldType ( @@ -446,6 +448,10 @@ EulerDdtScheme<Type>::fvcDdtPhiCorr ) ) ); + + ddtPhiCorr().boundaryField() = pTraits<typename flux<Type>::type>::zero; + + return ddtPhiCorr; } else if ( @@ -453,7 +459,7 @@ EulerDdtScheme<Type>::fvcDdtPhiCorr && phiAbs.dimensions() == rho.dimensions()*dimVelocity*dimArea ) { - return tmp<fluxFieldType> + tmp<fluxFieldType> ddtPhiCorr ( new fluxFieldType ( @@ -476,6 +482,10 @@ EulerDdtScheme<Type>::fvcDdtPhiCorr ) ) ); + + ddtPhiCorr().boundaryField() = pTraits<typename flux<Type>::type>::zero; + + return ddtPhiCorr; } else if ( @@ -483,7 +493,7 @@ EulerDdtScheme<Type>::fvcDdtPhiCorr && phiAbs.dimensions() == rho.dimensions()*dimVelocity*dimArea ) { - return tmp<fluxFieldType> + tmp<fluxFieldType> ddtPhiCorr ( new fluxFieldType ( @@ -497,6 +507,10 @@ EulerDdtScheme<Type>::fvcDdtPhiCorr ) ) ); + + ddtPhiCorr().boundaryField() = pTraits<typename flux<Type>::type>::zero; + + return ddtPhiCorr; } else { diff --git a/src/finiteVolume/finiteVolume/snGradSchemes/quadraticFitSnGrad/quadraticFitSnGrad.H b/src/finiteVolume/finiteVolume/snGradSchemes/quadraticFitSnGrad/quadraticFitSnGrad.H deleted file mode 100644 index b4892095771727fdaaf39ea14e718501a9b4f932..0000000000000000000000000000000000000000 --- a/src/finiteVolume/finiteVolume/snGradSchemes/quadraticFitSnGrad/quadraticFitSnGrad.H +++ /dev/null @@ -1,159 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM 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 3 of the License, or - (at your option) any later version. - - OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>. - -Class - quadraticFitSnGrad - -Description - Simple central-difference snGrad scheme with quadratic fit correction from - a larger stencil. - -SourceFiles - quadraticFitSnGrad.C - -\*---------------------------------------------------------------------------*/ - -#ifndef quadraticFitSnGrad_H -#define quadraticFitSnGrad_H - -#include "snGradScheme.H" -#include "quadraticFitSnGradData.H" -#include "extendedCellToFaceStencil.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace fv -{ - -/*---------------------------------------------------------------------------*\ - Class quadraticFitSnGrad Declaration -\*---------------------------------------------------------------------------*/ - -template<class Type> -class quadraticFitSnGrad -: - public snGradScheme<Type> -{ - // Private Data - //- weights for central stencil - const scalar centralWeight_; - - // Private Member Functions - - //- Disallow default bitwise assignment - void operator=(const quadraticFitSnGrad&); - - -public: - - //- Runtime type information - TypeName("quadraticFit"); - - - // Constructors - - //- Construct from mesh and scheme data - quadraticFitSnGrad - ( - const fvMesh& mesh, - const scalar centralWeight - ) - : - snGradScheme<Type>(mesh), - centralWeight_(centralWeight) - {} - - - //- Construct from mesh and data stream - quadraticFitSnGrad(const fvMesh& mesh, Istream& is) - : - snGradScheme<Type>(mesh), - centralWeight_(readScalar(is)) - {} - - - //- Destructor - virtual ~quadraticFitSnGrad() {} - - - // Member Functions - - //- Return the interpolation weighting factors for the given field - virtual tmp<surfaceScalarField> deltaCoeffs - ( - const GeometricField<Type, fvPatchField, volMesh>& - ) const - { - return this->mesh().nonOrthDeltaCoeffs(); - } - - //- Return true if this scheme uses an explicit correction - virtual bool corrected() const - { - return true; - } - - //- Return the explicit correction to the quadraticFitSnGrad - // for the given field - virtual tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > - correction(const GeometricField<Type, fvPatchField, volMesh>& vf) const - { - const fvMesh& mesh = this->mesh(); - - const quadraticFitSnGradData& qfd = quadraticFitSnGradData::New - ( - mesh, - centralWeight_ - ); - - const extendedCellToFaceStencil& stencil = qfd.stencil(); - const List<scalarList>& f = qfd.fit(); - - tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > sft - = stencil.weightedSum(vf, f); - - sft().dimensions() /= dimLength; - - return sft; - } -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace fv - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/finiteVolume/finiteVolume/snGradSchemes/quadraticFitSnGrad/quadraticFitSnGradData.C b/src/finiteVolume/finiteVolume/snGradSchemes/quadraticFitSnGrad/quadraticFitSnGradData.C deleted file mode 100644 index fe0858e1c6a6e9d4557e2b5ffdc85ad3336615d9..0000000000000000000000000000000000000000 --- a/src/finiteVolume/finiteVolume/snGradSchemes/quadraticFitSnGrad/quadraticFitSnGradData.C +++ /dev/null @@ -1,321 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM 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 3 of the License, or - (at your option) any later version. - - OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "quadraticFitSnGradData.H" -#include "surfaceFields.H" -#include "volFields.H" -#include "SVD.H" -#include "syncTools.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -defineTypeNameAndDebug(Foam::quadraticFitSnGradData, 0); - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::quadraticFitSnGradData::quadraticFitSnGradData -( - const fvMesh& mesh, - const scalar cWeight -) -: - MeshObject<fvMesh, quadraticFitSnGradData>(mesh), - centralWeight_(cWeight), - #ifdef SPHERICAL_GEOMETRY - dim_(2), - #else - dim_(mesh.nGeometricD()), - #endif - minSize_ - ( - dim_ == 1 ? 3 : - dim_ == 2 ? 6 : - dim_ == 3 ? 9 : 0 - ), - stencil_(mesh), - fit_(mesh.nInternalFaces()) -{ - if (debug) - { - Info<< "Contructing quadraticFitSnGradData" << endl; - } - - // check input - if (centralWeight_ < 1 - SMALL) - { - FatalErrorIn("quadraticFitSnGradData::quadraticFitSnGradData") - << "centralWeight requested = " << centralWeight_ - << " should not be less than one" - << exit(FatalError); - } - - if (minSize_ == 0) - { - FatalErrorIn("quadraticFitSnGradData") - << " dimension must be 1,2 or 3, not" << dim_ << exit(FatalError); - } - - // store the polynomial size for each face to write out - surfaceScalarField snGradPolySize - ( - IOobject - ( - "quadraticFitSnGradPolySize", - "constant", - mesh, - IOobject::NO_READ, - IOobject::NO_WRITE - ), - mesh, - dimensionedScalar("quadraticFitSnGradPolySize", dimless, scalar(0)) - ); - - // Get the cell/face centres in stencil order. - // Centred face stencils no good for triangles of tets. Need bigger stencils - List<List<point> > stencilPoints(stencil_.stencil().size()); - stencil_.collectData - ( - mesh.C(), - stencilPoints - ); - - // find the fit coefficients for every face in the mesh - - for (label faci = 0; faci < mesh.nInternalFaces(); faci++) - { - snGradPolySize[faci] = calcFit(stencilPoints[faci], faci); - } - - if (debug) - { - snGradPolySize.write(); - Info<< "quadraticFitSnGradData::quadraticFitSnGradData() :" - << "Finished constructing polynomialFit data" - << endl; - } -} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -void Foam::quadraticFitSnGradData::findFaceDirs -( - vector& idir, // value changed in return - vector& jdir, // value changed in return - vector& kdir, // value changed in return - const fvMesh& mesh, - const label faci -) -{ - idir = mesh.Sf()[faci]; - idir /= mag(idir); - - #ifndef SPHERICAL_GEOMETRY - if (mesh.nGeometricD() <= 2) // find the normal direcion - { - if (mesh.geometricD()[0] == -1) - { - kdir = vector(1, 0, 0); - } - else if (mesh.geometricD()[1] == -1) - { - kdir = vector(0, 1, 0); - } - else - { - kdir = vector(0, 0, 1); - } - } - else // 3D so find a direction in the plane of the face - { - const face& f = mesh.faces()[faci]; - kdir = mesh.points()[f[0]] - mesh.points()[f[1]]; - } - #else - // Spherical geometry so kdir is the radial direction - kdir = mesh.Cf()[faci]; - #endif - - if (mesh.nGeometricD() == 3) - { - // Remove the idir component from kdir and normalise - kdir -= (idir & kdir)*idir; - - scalar magk = mag(kdir); - - if (magk < SMALL) - { - FatalErrorIn("findFaceDirs") << " calculated kdir = zero" - << exit(FatalError); - } - else - { - kdir /= magk; - } - } - - jdir = kdir ^ idir; -} - - -Foam::label Foam::quadraticFitSnGradData::calcFit -( - const List<point>& C, - const label faci -) -{ - vector idir(1,0,0); - vector jdir(0,1,0); - vector kdir(0,0,1); - findFaceDirs(idir, jdir, kdir, mesh(), faci); - - scalarList wts(C.size(), scalar(1)); - wts[0] = centralWeight_; - wts[1] = centralWeight_; - - point p0 = mesh().faceCentres()[faci]; - scalar scale = 0; - - // calculate the matrix of the polynomial components - scalarRectangularMatrix B(C.size(), minSize_, scalar(0)); - - forAll(C, ip) - { - const point& p = C[ip]; - - scalar px = (p - p0)&idir; - scalar py = (p - p0)&jdir; - #ifdef SPHERICAL_GEOMETRY - scalar pz = mag(p) - mag(p0); - #else - scalar pz = (p - p0)&kdir; - #endif - - if (ip == 0) scale = max(max(mag(px), mag(py)), mag(pz)); - - px /= scale; - py /= scale; - pz /= scale; - - label is = 0; - - B[ip][is++] = wts[0]*wts[ip]; - B[ip][is++] = wts[0]*wts[ip]*px; - B[ip][is++] = wts[ip]*sqr(px); - - if (dim_ >= 2) - { - B[ip][is++] = wts[ip]*py; - B[ip][is++] = wts[ip]*px*py; - B[ip][is++] = wts[ip]*sqr(py); - } - if (dim_ == 3) - { - B[ip][is++] = wts[ip]*pz; - B[ip][is++] = wts[ip]*px*pz; - //B[ip][is++] = wts[ip]*py*pz; - B[ip][is++] = wts[ip]*sqr(pz); - } - } - - // Set the fit - label stencilSize = C.size(); - fit_[faci].setSize(stencilSize); - scalarList singVals(minSize_); - label nSVDzeros = 0; - - const scalar deltaCoeff = deltaCoeffs()[faci]; - - bool goodFit = false; - for (int iIt = 0; iIt < 10 && !goodFit; iIt++) - { - SVD svd(B, SMALL); - - scalar fit0 = wts[0]*wts[0]*svd.VSinvUt()[1][0]/scale; - scalar fit1 = wts[0]*wts[1]*svd.VSinvUt()[1][1]/scale; - - goodFit = - fit0 < 0 && fit1 > 0 - && mag(fit0 + deltaCoeff) < 0.5*deltaCoeff - && mag(fit1 - deltaCoeff) < 0.5*deltaCoeff; - - if (goodFit) - { - fit_[faci][0] = fit0; - fit_[faci][1] = fit1; - for (label i = 2; i < stencilSize; i++) - { - fit_[faci][i] = wts[0]*wts[i]*svd.VSinvUt()[1][i]/scale; - } - singVals = svd.S(); - nSVDzeros = svd.nZeros(); - } - else // (not good fit so increase weight in the centre and for linear) - { - wts[0] *= 10; - wts[1] *= 10; - - for (label i = 0; i < B.n(); i++) - { - B[i][0] *= 10; - B[i][1] *= 10; - } - - for (label j = 0; j < B.m(); j++) - { - B[0][j] *= 10; - B[1][j] *= 10; - } - } - } - - if (goodFit) - { - // remove the uncorrected snGradScheme coefficients - fit_[faci][0] += deltaCoeff; - fit_[faci][1] -= deltaCoeff; - } - else - { - Pout<< "quadratifFitSnGradData could not fit face " << faci - << " fit_[faci][0] = " << fit_[faci][0] - << " fit_[faci][1] = " << fit_[faci][1] - << " deltaCoeff = " << deltaCoeff << endl; - fit_[faci] = 0; - } - - return minSize_ - nSVDzeros; -} - -bool Foam::quadraticFitSnGradData::movePoints() -{ - notImplemented("quadraticFitSnGradData::movePoints()"); - - return true; -} - - -// ************************************************************************* // diff --git a/src/finiteVolume/finiteVolume/snGradSchemes/quadraticFitSnGrad/quadraticFitSnGradData.H b/src/finiteVolume/finiteVolume/snGradSchemes/quadraticFitSnGrad/quadraticFitSnGradData.H deleted file mode 100644 index 40f24c7c7074cddd2cc971e8b76effdedd8c2714..0000000000000000000000000000000000000000 --- a/src/finiteVolume/finiteVolume/snGradSchemes/quadraticFitSnGrad/quadraticFitSnGradData.H +++ /dev/null @@ -1,129 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM 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 3 of the License, or - (at your option) any later version. - - OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>. - -Class - quadraticFitSnGradData - -Description - Data for the quadratic fit correction snGrad scheme - -SourceFiles - quadraticFitSnGradData.C - -\*---------------------------------------------------------------------------*/ - -#ifndef quadraticFitSnGradData_H -#define quadraticFitSnGradData_H - -#include "MeshObject.H" -#include "fvMesh.H" -#include "extendedCellToFaceStencil.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -/*---------------------------------------------------------------------------*\ - Class quadraticFitSnGradData Declaration -\*---------------------------------------------------------------------------*/ - -class quadraticFitSnGradData -: - public MeshObject<fvMesh, quadraticFitSnGradData> -{ - // Private data - - const scalar centralWeight_; - const label dim_; - - //- minimum stencil size - const label minSize_; - - //- Extended stencil addressing - extendedCellToFaceStencil stencil_; - - //- For each cell in the mesh store the values which multiply the - // values of the stencil to obtain the gradient for each direction - List<scalarList> fit_; - - - // Private Member Functions - - //- Find the normal direction and i, j and k directions for face faci - static void findFaceDirs - ( - vector& idir, // value changed in return - vector& jdir, // value changed in return - vector& kdir, // value changed in return - const fvMesh& mesh, - const label faci - ); - - label calcFit(const List<point>&, const label faci); - - -public: - - TypeName("quadraticFitSnGradData"); - - - // Constructors - - explicit quadraticFitSnGradData - ( - const fvMesh& mesh, - const scalar cWeight - ); - - - //- Destructor - virtual ~quadraticFitSnGradData() - {}; - - - // Member functions - - //- Return reference to the stencil - const extendedCellToFaceStencil& stencil() const - { - return stencil_; - } - - //- Return reference to fit coefficients - const List<scalarList>& fit() const { return fit_; } - - //- Delete the data when the mesh moves not implemented - virtual bool movePoints(); -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C index f9937b532cdf4a84561e1e63e687fe387c3fe503..a69f7f5add6d6ee9c1d3a6c2ffd52f3da59873ad 100644 --- a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C +++ b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C @@ -576,12 +576,18 @@ void Foam::fvMatrix<Type>::relax(const scalar alpha) // Also add the source contribution from the relaxation forAll(pa, face) { - Type iCoeff0 = iCoeffs[face]; - iCoeffs[face] = cmptMag(iCoeffs[face]); - sumOff[pa[face]] -= cmptMin(iCoeffs[face]); - iCoeffs[face] /= alpha; - S[pa[face]] += - cmptMultiply(iCoeffs[face] - iCoeff0, psi_[pa[face]]); + // Type iCoeff0 = iCoeffs[face]; + // iCoeffs[face] = cmptMag(iCoeffs[face]); + // sumOff[pa[face]] -= cmptMin(iCoeffs[face]); + // iCoeffs[face] /= alpha; + D[pa[face]] += + cmptMag(cmptMin(iCoeffs[face])) + - cmptMin(iCoeffs[face]); + sumOff[pa[face]] += + cmptMag(cmptMin(iCoeffs[face])) + - cmptMin(iCoeffs[face]); + // S[pa[face]] += + // cmptMultiply(iCoeffs[face] - iCoeff0, psi_[pa[face]]); } } } diff --git a/src/finiteVolume/fvMatrices/solvers/MULES/MULESTemplates.C b/src/finiteVolume/fvMatrices/solvers/MULES/MULESTemplates.C index 98ed53686089aab9add585aabec71ef18273370e..c16288ea357cba049519162dc11b7e8267ff6ff9 100644 --- a/src/finiteVolume/fvMatrices/solvers/MULES/MULESTemplates.C +++ b/src/finiteVolume/fvMatrices/solvers/MULES/MULESTemplates.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -32,6 +32,7 @@ License #include "surfaceInterpolate.H" #include "fvcSurfaceIntegrate.H" #include "slicedSurfaceFields.H" +#include "wedgeFvPatch.H" #include "syncTools.H" #include "fvm.H" @@ -567,19 +568,29 @@ void Foam::MULES::limiter fvsPatchScalarField& lambdaPf = lambdaBf[patchi]; const scalarField& phiCorrfPf = phiCorrBf[patchi]; - const labelList& pFaceCells = mesh.boundary()[patchi].faceCells(); - - forAll(lambdaPf, pFacei) + if (isA<wedgeFvPatch>(mesh.boundary()[patchi])) { - label pfCelli = pFaceCells[pFacei]; + lambdaPf = 0; + } + else + { + const labelList& pFaceCells = + mesh.boundary()[patchi].faceCells(); - if (phiCorrfPf[pFacei] > 0.0) - { - lambdaPf[pFacei] = min(lambdaPf[pFacei], lambdap[pfCelli]); - } - else + forAll(lambdaPf, pFacei) { - lambdaPf[pFacei] = min(lambdaPf[pFacei], lambdam[pfCelli]); + label pfCelli = pFaceCells[pFacei]; + + if (phiCorrfPf[pFacei] > 0.0) + { + lambdaPf[pFacei] = + min(lambdaPf[pFacei], lambdap[pfCelli]); + } + else + { + lambdaPf[pFacei] = + min(lambdaPf[pFacei], lambdam[pfCelli]); + } } } } diff --git a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriver.C b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriver.C index ea29efbb8454bcc368960ac1887ec7648eb9937b..41769eb9354c80712e0d67d4d23ca74a93523e2b 100644 --- a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriver.C +++ b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriver.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -40,6 +40,7 @@ Description #include "snapParameters.H" #include "refinementSurfaces.H" #include "unitConversion.H" +#include "localPointRegion.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -1267,6 +1268,121 @@ void Foam::autoSnapDriver::doSnap meshRefiner_.createZoneBaffles(globalToPatch_, baffles); + // Selectively 'forget' about the baffles, i.e. not check across them + // or merge across them. + { + const faceZoneMesh& fZones = mesh.faceZones(); + const refinementSurfaces& surfaces = meshRefiner_.surfaces(); + const wordList& faceZoneNames = surfaces.faceZoneNames(); + const List<refinementSurfaces::faceZoneType>& faceType = + surfaces.faceType(); + + // Determine which + // - faces to remove from list of baffles (so not merge) + // - points to duplicate + labelList filterFace(mesh.nFaces(), -1); + label nFilterFaces = 0; + PackedBoolList duplicatePoint(mesh.nPoints()); + label nDuplicatePoints = 0; + forAll(faceZoneNames, surfI) + { + if + ( + faceType[surfI] == refinementSurfaces::BAFFLE + || faceType[surfI] == refinementSurfaces::BOUNDARY + ) + { + if (faceZoneNames[surfI].size()) + { + // Filter out all faces for this zone. + label zoneI = fZones.findZoneID(faceZoneNames[surfI]); + const faceZone& fZone = fZones[zoneI]; + forAll(fZone, i) + { + label faceI = fZone[i]; + filterFace[faceI] = zoneI; + nFilterFaces++; + } + + if (faceType[surfI] == refinementSurfaces::BOUNDARY) + { + forAll(fZone, i) + { + label faceI = fZone[i]; + const face& f = mesh.faces()[faceI]; + forAll(f, fp) + { + if (!duplicatePoint[f[fp]]) + { + duplicatePoint[f[fp]] = 1; + nDuplicatePoints++; + } + } + } + } + + Info<< "Surface : " << surfaces.names()[surfI] << nl + << " faces to become baffle : " + << returnReduce(nFilterFaces, sumOp<label>()) << nl + << " points to duplicate : " + << returnReduce(nDuplicatePoints, sumOp<label>()) + << endl; + } + } + } + + + // Duplicate points + if (returnReduce(nDuplicatePoints, sumOp<label>()) > 0) + { + // Collect all points + labelList candidatePoints(nDuplicatePoints); + nDuplicatePoints = 0; + forAll(duplicatePoint, pointI) + { + if (duplicatePoint[pointI]) + { + candidatePoints[nDuplicatePoints++] = pointI; + } + } + + + localPointRegion regionSide(mesh, candidatePoints); + autoPtr<mapPolyMesh> mapPtr = meshRefiner_.dupNonManifoldPoints + ( + regionSide + ); + meshRefinement::updateList(mapPtr().faceMap(), -1, filterFace); + } + + + // Forget about baffles in a BAFFLE/BOUNDARY type zone + DynamicList<labelPair> newBaffles(baffles.size()); + forAll(baffles, i) + { + const labelPair& baffle = baffles[i]; + if + ( + filterFace[baffle.first()] == -1 + && filterFace[baffles[i].second()] == -1 + ) + { + newBaffles.append(baffle); + } + } + + if (newBaffles.size() < baffles.size()) + { + //Info<< "Splitting baffles into" << nl + // << " internal : " << newBaffles.size() << nl + // << " baffle : " << baffles.size()-newBaffles.size() + // << nl << endl; + baffles.transfer(newBaffles); + } + Info<< endl; + } + + bool doFeatures = false; label nFeatIter = 1; if (snapParams.nFeatureSnap() > 0) diff --git a/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinement.C b/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinement.C index c2565fc67061a2013377919f5e98af7e742860cc..e12394624b1e8200444b7c12704af81cf663241c 100644 --- a/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinement.C +++ b/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinement.C @@ -2216,28 +2216,6 @@ void Foam::meshRefinement::dumpRefinementLevel() const pointRefLevel.write(); } - - // Dump cell centres - { - for (direction i=0; i<vector::nComponents; i++) - { - volScalarField cci - ( - IOobject - ( - "cc" + word(vector::componentNames[i]), - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - false - ), - mesh_.C().component(i) - ); - - cci.write(); - } - } } diff --git a/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinement.H b/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinement.H index be9994523a6e7fb0e57559c675b6d4c7188cf946..4deb6f3eed5fd1fae95464e7b0ea494d9264f838 100644 --- a/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinement.H +++ b/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinement.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -70,6 +70,7 @@ class searchableSurface; class regionSplit; class globalIndex; class removePoints; +class localPointRegion; /*---------------------------------------------------------------------------*\ Class meshRefinement Declaration @@ -141,15 +142,6 @@ private: // Private Member Functions - //- Reorder list according to map. - template<class T> - static void updateList - ( - const labelList& newToOld, - const T& nullValue, - List<T>& elems - ); - //- Add patchfield of given type to all fields on mesh template<class GeoField> static void addPatchFields(fvMesh&, const word& patchFieldType); @@ -707,6 +699,10 @@ public: const point& keepPoint ); + //- Find boundary points that connect to more than one cell + // region and split them. + autoPtr<mapPolyMesh> dupNonManifoldPoints(const localPointRegion&); + //- Find boundary points that connect to more than one cell // region and split them. autoPtr<mapPolyMesh> dupNonManifoldPoints(); @@ -780,6 +776,15 @@ public: const labelList& changedFaces ); + //- Helper: reorder list according to map. + template<class T> + static void updateList + ( + const labelList& newToOld, + const T& nullValue, + List<T>& elems + ); + // Restoring : is where other processes delete and reinsert data. diff --git a/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementBaffles.C b/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementBaffles.C index 5ec90659554d4c6df96f14f1ec36888cbb79d142..076fd11e2fd4963e890f01df0188d31f9715858c 100644 --- a/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementBaffles.C +++ b/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementBaffles.C @@ -2206,15 +2206,14 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::splitMesh // Find boundary points that connect to more than one cell region and // split them. -Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::dupNonManifoldPoints() +Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::dupNonManifoldPoints +( + const localPointRegion& regionSide +) { // Topochange container polyTopoChange meshMod(mesh_); - - // Analyse which points need to be duplicated - localPointRegion regionSide(mesh_); - label nNonManifPoints = returnReduce ( regionSide.meshPointMap().size(), @@ -2260,6 +2259,17 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::dupNonManifoldPoints() } +// Find boundary points that connect to more than one cell region and +// split them. +Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::dupNonManifoldPoints() +{ + // Analyse which points need to be duplicated + localPointRegion regionSide(mesh_); + + return dupNonManifoldPoints(regionSide); +} + + // Zoning Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::zonify ( diff --git a/src/mesh/autoMesh/autoHexMesh/refinementSurfaces/refinementSurfaces.C b/src/mesh/autoMesh/autoHexMesh/refinementSurfaces/refinementSurfaces.C index a1cb5efdf7a476d6949328e89d350c39f181dfce..52b2cd1b5b07e58459c4f7aec2af9d6beebfcc76 100644 --- a/src/mesh/autoMesh/autoHexMesh/refinementSurfaces/refinementSurfaces.C +++ b/src/mesh/autoMesh/autoHexMesh/refinementSurfaces/refinementSurfaces.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -49,12 +49,28 @@ namespace Foam "none" }; } - - const Foam::NamedEnum<Foam::refinementSurfaces::areaSelectionAlgo, 4> Foam::refinementSurfaces::areaSelectionAlgoNames; +namespace Foam +{ + template<> + const char* Foam::NamedEnum + < + Foam::refinementSurfaces::faceZoneType, + 3 + >::names[] = + { + "internal", + "baffle", + "boundary" + }; +} +const Foam::NamedEnum<Foam::refinementSurfaces::faceZoneType, 3> + Foam::refinementSurfaces::faceZoneTypeNames; + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::refinementSurfaces::refinementSurfaces @@ -70,6 +86,7 @@ Foam::refinementSurfaces::refinementSurfaces cellZoneNames_(surfacesDict.size()), zoneInside_(surfacesDict.size(), NONE), zoneInsidePoints_(surfacesDict.size()), + faceType_(surfacesDict.size(), INTERNAL), regionOffset_(surfacesDict.size()) { // Wilcard specification : loop over all surface, all regions @@ -93,6 +110,7 @@ Foam::refinementSurfaces::refinementSurfaces faceZoneNames_.setSize(surfI); cellZoneNames_.setSize(surfI); zoneInside_.setSize(surfI, NONE); + faceType_.setSize(surfI, INTERNAL), regionOffset_.setSize(surfI); labelList globalMinLevel(surfI, 0); @@ -183,8 +201,17 @@ Foam::refinementSurfaces::refinementSurfaces << " since no cellZone specified." << endl; } + + // How to handle faces on faceZone + word faceTypeMethod; + if (dict.readIfPresent("faceType", faceTypeMethod)) + { + faceType_[surfI] = faceZoneTypeNames[faceTypeMethod]; + } } + + // Global perpendicular angle if (dict.found("patchInfo")) { diff --git a/src/mesh/autoMesh/autoHexMesh/refinementSurfaces/refinementSurfaces.H b/src/mesh/autoMesh/autoHexMesh/refinementSurfaces/refinementSurfaces.H index c0bb6facc9f98b405ec3273548def998f3f9790f..b0edaec614aec610f0801cb2ea58983ca413a282 100644 --- a/src/mesh/autoMesh/autoHexMesh/refinementSurfaces/refinementSurfaces.H +++ b/src/mesh/autoMesh/autoHexMesh/refinementSurfaces/refinementSurfaces.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -70,6 +70,16 @@ public: static const NamedEnum<areaSelectionAlgo, 4> areaSelectionAlgoNames; + //- What to do with faceZone faces + enum faceZoneType + { + INTERNAL, + BAFFLE, + BOUNDARY + }; + + static const NamedEnum<faceZoneType, 3> faceZoneTypeNames; + private: // Private data @@ -97,6 +107,10 @@ private: //- If zoneInside=location gives the corresponding inside point pointField zoneInsidePoints_; + //- Per 'interface' surface : + // Waht to do with outside + List<faceZoneType> faceType_; + //- From local region number to global region number labelList regionOffset_; @@ -187,6 +201,12 @@ public: return zoneInsidePoints_; } + //- How to handle face of surfaces with a faceZone + const List<faceZoneType>& faceType() const + { + return faceType_; + } + //- From local region number to global region number const labelList& regionOffset() const { diff --git a/src/meshTools/searchableSurface/searchableSurfacesQueries.C b/src/meshTools/searchableSurface/searchableSurfacesQueries.C index 4db8f9acf37f58a13c9e874c657ab6aa9b7202a9..26f0a4532438786515bd73d60cb312907b79ed98 100644 --- a/src/meshTools/searchableSurface/searchableSurfacesQueries.C +++ b/src/meshTools/searchableSurface/searchableSurfacesQueries.C @@ -693,6 +693,7 @@ void Foam::searchableSurfacesQueries::signedDistance const labelList& surfacesToTest, const pointField& samples, const scalarField& nearestDistSqr, + const searchableSurface::volumeType illegalHandling, labelList& nearestSurfaces, scalarField& distance ) @@ -753,9 +754,32 @@ void Foam::searchableSurfacesQueries::signedDistance } else { - FatalErrorIn("signedDistance()") - << "getVolumeType failure, neither INSIDE or OUTSIDE" - << exit(FatalError); + switch (illegalHandling) + { + case searchableSurface::OUTSIDE: + { + distance[pointI] = dist; + break; + } + case searchableSurface::INSIDE: + { + distance[pointI] = -dist; + break; + } + default: + { + FatalErrorIn("signedDistance()") + << "getVolumeType failure," + << " neither INSIDE or OUTSIDE." + << " point:" << surfPoints[i] + << " surface:" + << allSurfaces[surfacesToTest[testI]].name() + << " volType:" + << searchableSurface::volumeTypeNames[vT] + << exit(FatalError); + break; + } + } } } } diff --git a/src/meshTools/searchableSurface/searchableSurfacesQueries.H b/src/meshTools/searchableSurface/searchableSurfacesQueries.H index a2dba23cb5d295a7b80338275a57d697ed670454..9f2ebfbadb6c575aaf0c5fb9a431acf6079df455 100644 --- a/src/meshTools/searchableSurface/searchableSurfacesQueries.H +++ b/src/meshTools/searchableSurface/searchableSurfacesQueries.H @@ -184,13 +184,18 @@ public: List<pointIndexHit>& ); - //- Find signed distance to nearest surface + //- Find signed distance to nearest surface. Outside is positive. + // illegalHandling: how to handle non-inside or outside + // OUTSIDE : treat as outside + // INSIDE : treat as inside + // UNKNOWN : throw fatal error static void signedDistance ( const PtrList<searchableSurface>& allSurfaces, const labelList& surfacesToTest, const pointField& samples, const scalarField& nearestDistSqr, + const searchableSurface::volumeType illegalHandling, labelList& nearestSurfaces, scalarField& distance ); diff --git a/src/sampling/meshToMeshInterpolation/meshToMesh/calculateMeshToMeshWeights.C b/src/sampling/meshToMeshInterpolation/meshToMesh/calculateMeshToMeshWeights.C index c3db6586ad5646185539c122687d60128c829cd7..5ffd6de0e149c5bf0aa742d52ec9669198e310cc 100644 --- a/src/sampling/meshToMeshInterpolation/meshToMesh/calculateMeshToMeshWeights.C +++ b/src/sampling/meshToMeshInterpolation/meshToMesh/calculateMeshToMeshWeights.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -118,7 +118,7 @@ void Foam::meshToMesh::calculateInverseVolumeWeights() const inverseVolumeWeightsPtr_ = new scalarListList(toMesh_.nCells()); scalarListList& invVolCoeffs = *inverseVolumeWeightsPtr_; - labelListList& cellToCell = *cellToCellAddressingPtr_; + const labelListList& cellToCell = cellToCellAddressing(); tetOverlapVolume overlapEngine; @@ -129,8 +129,8 @@ void Foam::meshToMesh::calculateInverseVolumeWeights() const if (overlapCells.size() > 0) { invVolCoeffs[celli].setSize(overlapCells.size()); - scalar v(0); - forAll (overlapCells, j) + + forAll(overlapCells, j) { label cellFrom = overlapCells[j]; treeBoundBox bbFromMesh @@ -142,7 +142,7 @@ void Foam::meshToMesh::calculateInverseVolumeWeights() const ) ); - v = overlapEngine.cellCellOverlapVolumeMinDecomp + scalar v = overlapEngine.cellCellOverlapVolumeMinDecomp ( toMesh_, celli, @@ -151,19 +151,14 @@ void Foam::meshToMesh::calculateInverseVolumeWeights() const cellFrom, bbFromMesh ); - invVolCoeffs[celli][j] = v/toMesh_.V()[celli]; - } - if (celli == 2) - { - Info << "cellToCell :" << cellToCell[celli] << endl; - Info << "invVolCoeffs :" << invVolCoeffs[celli] << endl; + invVolCoeffs[celli][j] = v/toMesh_.V()[celli]; } } } } -void Foam::meshToMesh::calculateCellToCellAddressing() const +void Foam::meshToMesh::calculateCellToCellAddressing() const { if (debug) { diff --git a/src/sampling/meshToMeshInterpolation/tetOverlapVolume/tetOverlapVolume.C b/src/sampling/meshToMeshInterpolation/tetOverlapVolume/tetOverlapVolume.C index 16d311815ce6cced07b6339cd29a1c7940df0271..43061586dedbe83f43f6c2945b011862a4a313e7 100644 --- a/src/sampling/meshToMeshInterpolation/tetOverlapVolume/tetOverlapVolume.C +++ b/src/sampling/meshToMeshInterpolation/tetOverlapVolume/tetOverlapVolume.C @@ -45,102 +45,15 @@ Foam::tetOverlapVolume::tetOverlapVolume() // * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * * // -void Foam::tetOverlapVolume::tetTetOverlap -( - const tetPoints& tetA, - const tetPoints& tetB, - FixedList<tetPoints, 200>& insideTets, - label& nInside, - FixedList<tetPoints, 200>& outsideTets, - label& nOutside -) const -{ - // Work storage - FixedList<tetPoints, 200> cutInsideTets; - label nCutInside = 0; - - tetPointRef::storeOp inside(insideTets, nInside); - tetPointRef::storeOp cutInside(cutInsideTets, nCutInside); - tetPointRef::dummyOp outside; - - - // Cut tetA with all inwards pointing faces of tetB. Any tets remaining - // in aboveTets are inside tetB. - - { - // face0 - plane pl0(tetB[1], tetB[3], tetB[2]); - - // Cut and insert subtets into cutInsideTets (either by getting - // an index from freeSlots or by appending to insideTets) or - // insert into outsideTets - tetA.tet().sliceWithPlane(pl0, cutInside, outside); - } - - if (nCutInside == 0) - { - nInside = nCutInside; - return; - } - - { - // face1 - plane pl1(tetB[0], tetB[2], tetB[3]); - - nInside = 0; - - for (label i = 0; i < nCutInside; i++) - { - cutInsideTets[i].tet().sliceWithPlane(pl1, inside, outside); - } - - if (nInside == 0) - { - return; - } - } - - { - // face2 - plane pl2(tetB[0], tetB[3], tetB[1]); - - nCutInside = 0; - - for (label i = 0; i < nInside; i++) - { - insideTets[i].tet().sliceWithPlane(pl2, cutInside, outside); - } - - if (nCutInside == 0) - { - nInside = nCutInside; - return; - } - } - - { - // face3 - plane pl3(tetB[0], tetB[1], tetB[2]); - - nInside = 0; - - for (label i = 0; i < nCutInside; i++) - { - cutInsideTets[i].tet().sliceWithPlane(pl3, inside, outside); - } - } -} - - Foam::scalar Foam::tetOverlapVolume::tetTetOverlapVol ( const tetPoints& tetA, const tetPoints& tetB ) const { - FixedList<tetPoints, 200> insideTets; + tetPointRef::tetIntersectionList insideTets; label nInside = 0; - FixedList<tetPoints, 200> cutInsideTets; + tetPointRef::tetIntersectionList cutInsideTets; label nCutInside = 0; tetPointRef::storeOp inside(insideTets, nInside); @@ -222,7 +135,7 @@ Foam::scalar Foam::tetOverlapVolume::cellCellOverlapVolumeMinDecomp const primitiveMesh& meshB, const label cellBI, const treeBoundBox& cellBbB -) +) const { const cell& cFacesA = meshA.cells()[cellAI]; const point& ccA = meshA.cellCentres()[cellAI]; diff --git a/src/sampling/meshToMeshInterpolation/tetOverlapVolume/tetOverlapVolume.H b/src/sampling/meshToMeshInterpolation/tetOverlapVolume/tetOverlapVolume.H index 388f645f3fa5eff60455562d21d498690f6782cc..e8890a3ee97df7894a7659227d9f7b063985f3cc 100644 --- a/src/sampling/meshToMeshInterpolation/tetOverlapVolume/tetOverlapVolume.H +++ b/src/sampling/meshToMeshInterpolation/tetOverlapVolume/tetOverlapVolume.H @@ -55,17 +55,6 @@ class tetOverlapVolume { // Private member functions - //- Tet overlap - void tetTetOverlap - ( - const tetPoints& tetA, - const tetPoints& tetB, - FixedList<tetPoints, 200>& insideTets, - label& nInside, - FixedList<tetPoints, 200>& outsideTets, - label& nOutside - ) const; - //- Tet Overlap Vol scalar tetTetOverlapVol ( @@ -115,7 +104,7 @@ public: const primitiveMesh& meshB, const label cellBI, const treeBoundBox& cellBbB - ); + ) const; }; diff --git a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C index 332e933417bf83059446c45adadf18aeccd0b25c..a8dfaebdfcf67f3fe59e09c44d98c9733b5ca657 100644 --- a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C +++ b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -28,9 +28,8 @@ License #include "dictionary.H" #include "Time.H" #include "IOmanip.H" -#include "ListListOps.H" -#include "mergePoints.H" #include "volPointInterpolation.H" +#include "PatchTools.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -38,34 +37,6 @@ defineTypeNameAndDebug(Foam::sampledSurfaces, 0); bool Foam::sampledSurfaces::verbose_ = false; Foam::scalar Foam::sampledSurfaces::mergeTol_ = 1e-10; -namespace Foam -{ - //- Used to offset faces in Pstream::combineOffset - template <> - class offsetOp<face> - { - - public: - - face operator() - ( - const face& x, - const label offset - ) const - { - face result(x.size()); - - forAll(x, xI) - { - result[xI] = x[xI] + offset; - } - return result; - } - }; - -} - - // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // void Foam::sampledSurfaces::writeGeometry() const @@ -379,80 +350,18 @@ bool Foam::sampledSurfaces::update() continue; } - - // Collect points from all processors - List<pointField> gatheredPoints(Pstream::nProcs()); - gatheredPoints[Pstream::myProcNo()] = s.points(); - Pstream::gatherList(gatheredPoints); - - if (Pstream::master()) - { - mergeList_[surfI].points = ListListOps::combine<pointField> - ( - gatheredPoints, - accessOp<pointField>() - ); - } - - // Collect faces from all processors and renumber using sizes of - // gathered points - List<faceList> gatheredFaces(Pstream::nProcs()); - gatheredFaces[Pstream::myProcNo()] = s.faces(); - Pstream::gatherList(gatheredFaces); - - if (Pstream::master()) - { - mergeList_[surfI].faces = static_cast<const faceList&> - ( - ListListOps::combineOffset<faceList> - ( - gatheredFaces, - ListListOps::subSizes - ( - gatheredPoints, - accessOp<pointField>() - ), - accessOp<faceList>(), - offsetOp<face>() - ) - ); - } - - pointField newPoints; - labelList oldToNew; - - bool hasMerged = mergePoints + PatchTools::gatherAndMerge ( - mergeList_[surfI].points, mergeDim, - false, // verbosity - oldToNew, - newPoints + primitivePatch + ( + SubList<face>(s.faces(), s.faces().size()), + s.points() + ), + mergeList_[surfI].points, + mergeList_[surfI].faces, + mergeList_[surfI].pointsMap ); - - if (hasMerged) - { - // Store point mapping - mergeList_[surfI].pointsMap.transfer(oldToNew); - - // Copy points - mergeList_[surfI].points.transfer(newPoints); - - // Relabel faces - faceList& faces = mergeList_[surfI].faces; - - forAll(faces, faceI) - { - inplaceRenumber(mergeList_[surfI].pointsMap, faces[faceI]); - } - - if (Pstream::master() && debug) - { - Pout<< "For surface " << surfI << " merged from " - << mergeList_[surfI].pointsMap.size() << " points down to " - << mergeList_[surfI].points.size() << " points" << endl; - } - } } return updated; diff --git a/src/triSurface/tools/labelledTri/labelledTri.H b/src/triSurface/tools/labelledTri/labelledTri.H index d36934dceb1f5866507e4c1dfc6f875369ef6590..6f0c13065d50bb53ecd6d38e42824b72875b1b60 100644 --- a/src/triSurface/tools/labelledTri/labelledTri.H +++ b/src/triSurface/tools/labelledTri/labelledTri.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -36,6 +36,7 @@ SourceFiles #define labelledTri_H #include "triFace.H" +#include "ListListOps.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -115,6 +116,30 @@ template<> inline bool contiguous<labelledTri>() {return true;} +//- Hash specialization to offset faces in ListListOps::combineOffset +template<> +class offsetOp<labelledTri> +{ + +public: + + inline labelledTri operator() + ( + const labelledTri& x, + const label offset + ) const + { + labelledTri result(x); + + forAll(x, xI) + { + result[xI] = x[xI] + offset; + } + return result; + } +}; + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/turbulenceModels/compressible/RAS/LRR/LRR.C b/src/turbulenceModels/compressible/RAS/LRR/LRR.C index e0958e376e2a7cc8af50ff806a1c0f79178b7fab..be15b76474057a28df10d241e05774a33cf253e4 100644 --- a/src/turbulenceModels/compressible/RAS/LRR/LRR.C +++ b/src/turbulenceModels/compressible/RAS/LRR/LRR.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -351,6 +351,7 @@ void LRR::correct() ( fvm::ddt(rho_, epsilon_) + fvm::div(phi_, epsilon_) + - fvm::Sp(fvc::ddt(rho_) + fvc::div(phi_), epsilon_) //- fvm::laplacian(Ceps*rho_*(k_/epsilon_)*R_, epsilon_) - fvm::laplacian(DepsilonEff(), epsilon_) == @@ -393,6 +394,7 @@ void LRR::correct() ( fvm::ddt(rho_, R_) + fvm::div(phi_, R_) + - fvm::Sp(fvc::ddt(rho_) + fvc::div(phi_), R_) //- fvm::laplacian(Cs*rho_*(k_/epsilon_)*R_, R_) - fvm::laplacian(DREff(), R_) + fvm::Sp(Clrr1_*rho_*epsilon_/k_, R_) diff --git a/src/turbulenceModels/compressible/RAS/LaunderGibsonRSTM/LaunderGibsonRSTM.C b/src/turbulenceModels/compressible/RAS/LaunderGibsonRSTM/LaunderGibsonRSTM.C index 6aef97660a326ea8720c3d1897604c48d906ca46..fb9bee6570acf4836bc5af7b63afdedb6de55b6e 100644 --- a/src/turbulenceModels/compressible/RAS/LaunderGibsonRSTM/LaunderGibsonRSTM.C +++ b/src/turbulenceModels/compressible/RAS/LaunderGibsonRSTM/LaunderGibsonRSTM.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -389,6 +389,7 @@ void LaunderGibsonRSTM::correct() ( fvm::ddt(rho_, epsilon_) + fvm::div(phi_, epsilon_) + - fvm::Sp(fvc::ddt(rho_) + fvc::div(phi_), epsilon_) //- fvm::laplacian(Ceps*rho_*(k_/epsilon_)*R_, epsilon_) - fvm::laplacian(DepsilonEff(), epsilon_) == @@ -432,6 +433,7 @@ void LaunderGibsonRSTM::correct() ( fvm::ddt(rho_, R_) + fvm::div(phi_, R_) + - fvm::Sp(fvc::ddt(rho_) + fvc::div(phi_), R_) //- fvm::laplacian(Cs*rho_*(k_/epsilon_)*R_, R_) - fvm::laplacian(DREff(), R_) + fvm::Sp(Clg1_*rho_*epsilon_/k_, R_) diff --git a/src/turbulenceModels/compressible/RAS/LaunderSharmaKE/LaunderSharmaKE.C b/src/turbulenceModels/compressible/RAS/LaunderSharmaKE/LaunderSharmaKE.C index 996f0e5d2cb4f43ae0e01ed3bed26fe985a55302..d03f6b5de9dab139670e85500e2d7a77da628bbb 100644 --- a/src/turbulenceModels/compressible/RAS/LaunderSharmaKE/LaunderSharmaKE.C +++ b/src/turbulenceModels/compressible/RAS/LaunderSharmaKE/LaunderSharmaKE.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -314,6 +314,7 @@ void LaunderSharmaKE::correct() ( fvm::ddt(rho_, epsilon_) + fvm::div(phi_, epsilon_) + - fvm::Sp(fvc::ddt(rho_) + fvc::div(phi_), epsilon_) - fvm::laplacian(DepsilonEff(), epsilon_) == C1_*G*epsilon_/k_ + fvm::SuSp((C3_ - 2.0/3.0*C1_)*rho_*divU, epsilon_) @@ -333,6 +334,7 @@ void LaunderSharmaKE::correct() ( fvm::ddt(rho_, k_) + fvm::div(phi_, k_) + - fvm::Sp(fvc::ddt(rho_) + fvc::div(phi_), k_) - fvm::laplacian(DkEff(), k_) == G - fvm::SuSp(2.0/3.0*rho_*divU, k_) diff --git a/src/turbulenceModels/compressible/RAS/RNGkEpsilon/RNGkEpsilon.C b/src/turbulenceModels/compressible/RAS/RNGkEpsilon/RNGkEpsilon.C index d1d751e54da457412dbe80ece4ced800a037290d..96155d40a43be6bec13e6fd6d03a2bda814bcb52 100644 --- a/src/turbulenceModels/compressible/RAS/RNGkEpsilon/RNGkEpsilon.C +++ b/src/turbulenceModels/compressible/RAS/RNGkEpsilon/RNGkEpsilon.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -321,6 +321,7 @@ void RNGkEpsilon::correct() ( fvm::ddt(rho_, epsilon_) + fvm::div(phi_, epsilon_) + - fvm::Sp(fvc::ddt(rho_) + fvc::div(phi_), epsilon_) - fvm::laplacian(DepsilonEff(), epsilon_) == (C1_ - R)*G*epsilon_/k_ @@ -342,6 +343,7 @@ void RNGkEpsilon::correct() ( fvm::ddt(rho_, k_) + fvm::div(phi_, k_) + - fvm::Sp(fvc::ddt(rho_) + fvc::div(phi_), k_) - fvm::laplacian(DkEff(), k_) == G - fvm::SuSp(2.0/3.0*rho_*divU, k_) diff --git a/src/turbulenceModels/compressible/RAS/SpalartAllmaras/SpalartAllmaras.C b/src/turbulenceModels/compressible/RAS/SpalartAllmaras/SpalartAllmaras.C index 358e6810ece572ab39c2e5e55fdf161d016bac4d..b76872cfa1fa4e8fca8504ff1baf5bf3eee84bd9 100644 --- a/src/turbulenceModels/compressible/RAS/SpalartAllmaras/SpalartAllmaras.C +++ b/src/turbulenceModels/compressible/RAS/SpalartAllmaras/SpalartAllmaras.C @@ -416,6 +416,7 @@ void SpalartAllmaras::correct() ( fvm::ddt(rho_, nuTilda_) + fvm::div(phi_, nuTilda_) + - fvm::Sp(fvc::ddt(rho_) + fvc::div(phi_), nuTilda_) - fvm::laplacian(DnuTildaEff(), nuTilda_) - Cb2_/sigmaNut_*rho_*magSqr(fvc::grad(nuTilda_)) == diff --git a/src/turbulenceModels/compressible/RAS/kEpsilon/kEpsilon.C b/src/turbulenceModels/compressible/RAS/kEpsilon/kEpsilon.C index 2db4878a4cd7f2226a1b7a172a69c872b1479a18..aa63cf9f239b94c5e49c03fff93d849f103ec376 100644 --- a/src/turbulenceModels/compressible/RAS/kEpsilon/kEpsilon.C +++ b/src/turbulenceModels/compressible/RAS/kEpsilon/kEpsilon.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -292,6 +292,7 @@ void kEpsilon::correct() ( fvm::ddt(rho_, epsilon_) + fvm::div(phi_, epsilon_) + - fvm::Sp(fvc::ddt(rho_) + fvc::div(phi_), epsilon_) - fvm::laplacian(DepsilonEff(), epsilon_) == C1_*G*epsilon_/k_ @@ -313,6 +314,7 @@ void kEpsilon::correct() ( fvm::ddt(rho_, k_) + fvm::div(phi_, k_) + - fvm::Sp(fvc::ddt(rho_) + fvc::div(phi_), k_) - fvm::laplacian(DkEff(), k_) == G diff --git a/src/turbulenceModels/compressible/RAS/kOmegaSST/kOmegaSST.C b/src/turbulenceModels/compressible/RAS/kOmegaSST/kOmegaSST.C index e4032d854c6ad8587c2e05537189076186ea29b2..e1ffc23d8de99001a85a26025dcbbd982a7d5c17 100644 --- a/src/turbulenceModels/compressible/RAS/kOmegaSST/kOmegaSST.C +++ b/src/turbulenceModels/compressible/RAS/kOmegaSST/kOmegaSST.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -411,6 +411,7 @@ void kOmegaSST::correct() ( fvm::ddt(rho_, omega_) + fvm::div(phi_, omega_) + - fvm::Sp(fvc::ddt(rho_) + fvc::div(phi_), omega_) - fvm::laplacian(DomegaEff(F1), omega_) == rhoGammaF1*GbyMu @@ -435,6 +436,7 @@ void kOmegaSST::correct() ( fvm::ddt(rho_, k_) + fvm::div(phi_, k_) + - fvm::Sp(fvc::ddt(rho_) + fvc::div(phi_), k_) - fvm::laplacian(DkEff(F1), k_) == min(G, (c1_*betaStar_)*rho_*k_*omega_) diff --git a/src/turbulenceModels/compressible/RAS/realizableKE/realizableKE.C b/src/turbulenceModels/compressible/RAS/realizableKE/realizableKE.C index c169831c51617446aac074607c8ba7d760182c4b..bb0f3041fad76fc7f01289a8a540a7c45e5a5b34 100644 --- a/src/turbulenceModels/compressible/RAS/realizableKE/realizableKE.C +++ b/src/turbulenceModels/compressible/RAS/realizableKE/realizableKE.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -331,6 +331,7 @@ void realizableKE::correct() ( fvm::ddt(rho_, epsilon_) + fvm::div(phi_, epsilon_) + - fvm::Sp(fvc::ddt(rho_) + fvc::div(phi_), epsilon_) - fvm::laplacian(DepsilonEff(), epsilon_) == C1*rho_*magS*epsilon_ @@ -355,6 +356,7 @@ void realizableKE::correct() ( fvm::ddt(rho_, k_) + fvm::div(phi_, k_) + - fvm::Sp(fvc::ddt(rho_) + fvc::div(phi_), k_) - fvm::laplacian(DkEff(), k_) == G - fvm::SuSp(2.0/3.0*rho_*divU, k_) diff --git a/tutorials/compressible/rhoSimplecFoam/squareBend/0/p b/tutorials/compressible/rhoSimplecFoam/squareBend/0/p index 5e1d1effb2bc264f671d610eba7cadd1d4e17235..79a1eeb02809c6506699abf42c3d057ea349c1d9 100644 --- a/tutorials/compressible/rhoSimplecFoam/squareBend/0/p +++ b/tutorials/compressible/rhoSimplecFoam/squareBend/0/p @@ -26,8 +26,8 @@ boundaryField } inlet { - //type zeroGradient; - type mixed; + type zeroGradient; + //type mixed; refValue uniform 110000; refGradient uniform 0; valueFraction uniform 0.3; diff --git a/tutorials/compressible/rhoSimplecFoam/squareBend/system/fvSolution b/tutorials/compressible/rhoSimplecFoam/squareBend/system/fvSolution index df2018d930bd1479894f25acee3e227938bcebfc..09afca5761b1515ad887abe4ff8a8c39a9273876 100644 --- a/tutorials/compressible/rhoSimplecFoam/squareBend/system/fvSolution +++ b/tutorials/compressible/rhoSimplecFoam/squareBend/system/fvSolution @@ -65,8 +65,9 @@ relaxationFactors } equations { + p 1; U 0.9; - h 0.8; + h 0.9; k 0.9; epsilon 0.9; } diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/snappyMultiRegionHeater/Allrun b/tutorials/heatTransfer/chtMultiRegionFoam/snappyMultiRegionHeater/Allrun index e6b1c579ee9927e64f22c5d3c33d66997b84fb4b..7fa0f0dc7802710477c3f11c28bb974503cd17f4 100755 --- a/tutorials/heatTransfer/chtMultiRegionFoam/snappyMultiRegionHeater/Allrun +++ b/tutorials/heatTransfer/chtMultiRegionFoam/snappyMultiRegionHeater/Allrun @@ -8,16 +8,7 @@ cd ${0%/*} || exit 1 # run from this directory rm -rf constant/polyMesh/sets runApplication blockMesh -runApplication surfaceFeatureExtract -includedAngle 150 constant/triSurface/bottomAir.stl bottomAir -mv log.surfaceFeatureExtract log.surfaceFeatureExtract.bottom -runApplication surfaceFeatureExtract -includedAngle 150 constant/triSurface/heater.stl heater -mv log.surfaceFeatureExtract log.surfaceFeatureExtract.heater -runApplication surfaceFeatureExtract -includedAngle 150 constant/triSurface/leftSolid.stl leftSolid -mv log.surfaceFeatureExtract log.surfaceFeatureExtract.leftSolid -runApplication surfaceFeatureExtract -includedAngle 150 constant/triSurface/rightSolid.stl rightSolid -mv log.surfaceFeatureExtract log.surfaceFeatureExtract.rightSolid -runApplication surfaceFeatureExtract -includedAngle 150 constant/triSurface/topAir.stl topAir -mv log.surfaceFeatureExtract log.surfaceFeatureExtract.topAir +runApplication surfaceFeatureExtract runApplication snappyHexMesh -overwrite runApplication splitMeshRegions -cellZones -overwrite diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/snappyMultiRegionHeater/system/surfaceFeatureExtractDict b/tutorials/heatTransfer/chtMultiRegionFoam/snappyMultiRegionHeater/system/surfaceFeatureExtractDict new file mode 100644 index 0000000000000000000000000000000000000000..f33e0162527707716211cf47aa6f1eccbeff7d5d --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionFoam/snappyMultiRegionHeater/system/surfaceFeatureExtractDict @@ -0,0 +1,99 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object surfaceFeatureExtractDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +bottomAir.stl +{ + extractionMethod extractFromSurface; + + extractFromSurfaceCoeffs + { + // Mark edges whose adjacent surface normals are at an angle less + // than includedAngle as features + // - 0 : selects no edges + // - 180: selects all edges + includedAngle 150; + } + + // Write options + writeFeatureEdgeMesh yes; +} +heater.stl +{ + extractionMethod extractFromSurface; + + extractFromSurfaceCoeffs + { + // Mark edges whose adjacent surface normals are at an angle less + // than includedAngle as features + // - 0 : selects no edges + // - 180: selects all edges + includedAngle 150; + } + + // Write options + writeFeatureEdgeMesh yes; +} +leftSolid.stl +{ + extractionMethod extractFromSurface; + + extractFromSurfaceCoeffs + { + // Mark edges whose adjacent surface normals are at an angle less + // than includedAngle as features + // - 0 : selects no edges + // - 180: selects all edges + includedAngle 150; + } + + // Write options + writeFeatureEdgeMesh yes; +} +rightSolid.stl +{ + extractionMethod extractFromSurface; + + extractFromSurfaceCoeffs + { + // Mark edges whose adjacent surface normals are at an angle less + // than includedAngle as features + // - 0 : selects no edges + // - 180: selects all edges + includedAngle 150; + } + + // Write options + writeFeatureEdgeMesh yes; +} +topAir.stl +{ + extractionMethod extractFromSurface; + + extractFromSurfaceCoeffs + { + // Mark edges whose adjacent surface normals are at an angle less + // than includedAngle as features + // - 0 : selects no edges + // - 180: selects all edges + includedAngle 150; + } + + // Write options + writeFeatureEdgeMesh yes; +} + + +// ************************************************************************* // diff --git a/tutorials/mesh/cvMesh/flange/Allrun b/tutorials/mesh/cvMesh/flange/Allrun index f35e96c706dc86f9c3c02f057341ee0652411e7b..d4e853bb3f471c82fed754dc1518b996dee79423 100755 --- a/tutorials/mesh/cvMesh/flange/Allrun +++ b/tutorials/mesh/cvMesh/flange/Allrun @@ -28,6 +28,7 @@ do done runParallel cvMesh $nProc +#runParallel snappyHexMesh $nProc runApplication reconstructParMesh -constant -mergeTol 1e-6 diff --git a/tutorials/mesh/cvMesh/flange/system/controlDict b/tutorials/mesh/cvMesh/flange/system/controlDict index ff948a6e05c61a70bff01bd382afff19ef1cbd06..66a4bab34e67f6193ac3dcbad0d2e0c424851a5f 100644 --- a/tutorials/mesh/cvMesh/flange/system/controlDict +++ b/tutorials/mesh/cvMesh/flange/system/controlDict @@ -22,13 +22,13 @@ FoamFile // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -startFrom latestTime; +startFrom startTime; startTime 0; stopAt endTime; -endTime 80; +endTime 0; deltaT 1; diff --git a/tutorials/mesh/cvMesh/flange/system/cvMeshDict b/tutorials/mesh/cvMesh/flange/system/cvMeshDict index 91a1c4ad0d525d1610c1d2b3fa149b82fdacde7a..cbd86c379d4f08a8008b6e76ad3b062b93305dd8 100644 --- a/tutorials/mesh/cvMesh/flange/system/cvMeshDict +++ b/tutorials/mesh/cvMesh/flange/system/cvMeshDict @@ -113,7 +113,7 @@ initialPoints minimumSurfaceDistanceCoeff 0.55; initialPointsMethod autoDensity; - // initialPointsMethod pointFile; + //initialPointsMethod pointFile; autoDensityCoeffs { @@ -143,10 +143,15 @@ motionControl { priority 1; mode inside; + surfaceCellSizeFunction uniformValue; + uniformValueCoeffs + { + surfaceCellSize 0.0005; + } + cellSizeFunction linearDistance; linearDistanceCoeffs { - surfaceCellSize 0.0005; distanceCellSize $defaultCellSize; distance 0.004; } @@ -205,27 +210,14 @@ polyMeshFiltering filterCountSkipThreshold 4; maxCollapseIterations 25; maxConsecutiveEqualFaceSets 5; - surfaceStepFaceAngle 80; - edgeCollapseGuardFraction 0.3; + surfaceStepFaceAngle 90; + edgeCollapseGuardFraction 0.0; //0.3; maxCollapseFaceToPointSideLengthCoeff 0.35; + edgeMergeAngle 30; } -meshQualityControls -{ - maxNonOrtho 65; - maxBoundarySkewness 50; - maxInternalSkewness 10; - maxConcave 80; - minTetQuality 1e-30; - minVol 0; - minArea -1; - minTwist 0.001; - minDeterminant 0.001; - minFaceWeight 0.02; - minVolRatio 0.01; - minTriangleTwist -1; -} +#include "meshQualityControls" // ************************************************************************* // diff --git a/tutorials/mesh/cvMesh/flange/system/meshQualityControls b/tutorials/mesh/cvMesh/flange/system/meshQualityControls new file mode 100644 index 0000000000000000000000000000000000000000..09ebbb2458e42e23f5b07ed411ce74493f1d7d2b --- /dev/null +++ b/tutorials/mesh/cvMesh/flange/system/meshQualityControls @@ -0,0 +1,76 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ + +FoamFile +{ + version 2.0; + format ascii; + + root ""; + case ""; + instance ""; + local ""; + + class dictionary; + object meshQualityControls; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +meshQualityControls +{ + //- Maximum non-orthogonality allowed. Set to 180 to disable. + maxNonOrtho 65; + + //- Max skewness allowed. Set to <0 to disable. + maxBoundarySkewness 50; + maxInternalSkewness 10; + + //- Max concaveness allowed. Is angle (in degrees) below which concavity + // is allowed. 0 is straight face, <0 would be convex face. + // Set to 180 to disable. + maxConcave 80; + + //- Minimum quality of the tet formed by the face-centre + // and variable base point minimum decomposition triangles and + // the cell centre. This has to be a positive number for tracking + // to work. Set to very negative number (e.g. -1E30) to + // disable. + // <0 = inside out tet, + // 0 = flat tet + // 1 = regular tet + minTetQuality 1e-30; + + //- Minimum pyramid volume. Is absolute volume of cell pyramid. + // Set to a sensible fraction of the smallest cell volume expected. + // Set to very negative number (e.g. -1E30) to disable. + minVol 0; + + //- Minimum face area. Set to <0 to disable. + minArea -1; + + //- Minimum face twist. Set to <-1 to disable. dot product of face normal + //- and face centre triangles normal + minTwist 0.001; + + //- minimum normalised cell determinant + //- 1 = hex, <= 0 = folded or flattened illegal cell + minDeterminant 0.001; + + //- minFaceWeight (0 -> 0.5) + minFaceWeight 0.02; + + //- minVolRatio (0 -> 1) + minVolRatio 0.01; + + //must be >0 for Fluent compatibility + minTriangleTwist -1; +} + + +// ************************************************************************* // diff --git a/tutorials/mesh/cvMesh/flange/system/snappyHexMeshDict b/tutorials/mesh/cvMesh/flange/system/snappyHexMeshDict new file mode 100644 index 0000000000000000000000000000000000000000..034e3c0e749d95c36508975773bcddabbd49a150 --- /dev/null +++ b/tutorials/mesh/cvMesh/flange/system/snappyHexMeshDict @@ -0,0 +1,309 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object snappyHexMeshDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +// Which of the steps to run +castellatedMesh false; +snap false; +addLayers true; + + +// Geometry. Definition of all surfaces. All surfaces are of class +// searchableSurface. +// Surfaces are used +// - to specify refinement for any mesh cell intersecting it +// - to specify refinement for any mesh cell inside/outside/near +// - to 'snap' the mesh boundary to the surface +geometry +{ +// motorBike.obj +// { +// type triSurfaceMesh; +// name motorBike; +// } +// +// refinementBox +// { +// type searchableBox; +// min (-1.0 -0.7 0.0); +// max ( 8.0 0.7 2.5); +// } +}; + + + +// Settings for the castellatedMesh generation. +castellatedMeshControls +{ + + // Refinement parameters + // ~~~~~~~~~~~~~~~~~~~~~ + + // If local number of cells is >= maxLocalCells on any processor + // switches from from refinement followed by balancing + // (current method) to (weighted) balancing before refinement. + maxLocalCells 100000; + + // Overall cell limit (approximately). Refinement will stop immediately + // upon reaching this number so a refinement level might not complete. + // Note that this is the number of cells before removing the part which + // is not 'visible' from the keepPoint. The final number of cells might + // actually be a lot less. + maxGlobalCells 2000000; + + // The surface refinement loop might spend lots of iterations refining just a + // few cells. This setting will cause refinement to stop if <= minimumRefine + // are selected for refinement. Note: it will at least do one iteration + // (unless the number of cells to refine is 0) + minRefinementCells 10; + + // Allow a certain level of imbalance during refining + // (since balancing is quite expensive) + // Expressed as fraction of perfect balance (= overall number of cells / + // nProcs). 0=balance always. + maxLoadUnbalance 0.10; + + + // Number of buffer layers between different levels. + // 1 means normal 2:1 refinement restriction, larger means slower + // refinement. + nCellsBetweenLevels 3; + + + + // Explicit feature edge refinement + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + // Specifies a level for any cell intersected by its edges. + // This is a featureEdgeMesh, read from constant/triSurface for now. + features + ( + //{ + // file "someLine.eMesh"; + // level 2; + //} + ); + + + + // Surface based refinement + // ~~~~~~~~~~~~~~~~~~~~~~~~ + + // Specifies two levels for every surface. The first is the minimum level, + // every cell intersecting a surface gets refined up to the minimum level. + // The second level is the maximum level. Cells that 'see' multiple + // intersections where the intersections make an + // angle > resolveFeatureAngle get refined up to the maximum level. + + refinementSurfaces + { +// motorBike +// { +// // Surface-wise min and max refinement level +// level (5 6); +// +// // Optional specification of patch type (default is wall). No +// // constraint types (cyclic, symmetry) etc. are allowed. +// patchInfo +// { +// type wall; +// inGroups (motorBike); +// } +// } + } + + // Resolve sharp angles + resolveFeatureAngle 30; + + + // Region-wise refinement + // ~~~~~~~~~~~~~~~~~~~~~~ + + // Specifies refinement level for cells in relation to a surface. One of + // three modes + // - distance. 'levels' specifies per distance to the surface the + // wanted refinement level. The distances need to be specified in + // descending order. + // - inside. 'levels' is only one entry and only the level is used. All + // cells inside the surface get refined up to the level. The surface + // needs to be closed for this to be possible. + // - outside. Same but cells outside. + + refinementRegions + { +// refinementBox +// { +// mode inside; +// levels ((1E15 4)); +// } + } + + + // Mesh selection + // ~~~~~~~~~~~~~~ + + // After refinement patches get added for all refinementSurfaces and + // all cells intersecting the surfaces get put into these patches. The + // section reachable from the locationInMesh is kept. + // NOTE: This point should never be on a face, always inside a cell, even + // after refinement. + locationInMesh (-1 0 0); + + + // Whether any faceZones (as specified in the refinementSurfaces) + // are only on the boundary of corresponding cellZones or also allow + // free-standing zone faces. Not used if there are no faceZones. + allowFreeStandingZoneFaces true; +} + + + +// Settings for the snapping. +snapControls +{ + //- Number of patch smoothing iterations before finding correspondence + // to surface + nSmoothPatch 3; + + //- Relative distance for points to be attracted by surface feature point + // or edge. True distance is this factor times local + // maximum edge length. + tolerance 4.0; + + //- Number of mesh displacement relaxation iterations. + nSolveIter 0; + + //- Maximum number of snapping relaxation iterations. Should stop + // before upon reaching a correct mesh. + nRelaxIter 5; + + //- Highly experimental and wip: number of feature edge snapping + // iterations. Leave out altogether to disable. + // Do not use here since mesh resolution too low and baffles present + //nFeatureSnapIter 10; +} + + + +// Settings for the layer addition. +addLayersControls +{ + // Are the thickness parameters below relative to the undistorted + // size of the refined cell outside layer (true) or absolute sizes (false). + relativeSizes false; + + // Per final patch (so not geometry!) the layer information + layers + { + "flange.obj.*" + { + nSurfaceLayers 1; + } + } + + // Expansion factor for layer mesh + expansionRatio 1.5; + + //- Wanted thickness of final added cell layer. If multiple layers + // is the + // thickness of the layer furthest away from the wall. + // Relative to undistorted size of cell outside layer. + // is the thickness of the layer furthest away from the wall. + // See relativeSizes parameter. + finalLayerThickness 0.0003; + + //- Minimum thickness of cell layer. If for any reason layer + // cannot be above minThickness do not add layer. + // Relative to undistorted size of cell outside layer. + minThickness 0.0001; + + //- If points get not extruded do nGrow layers of connected faces that are + // also not grown. This helps convergence of the layer addition process + // close to features. + // Note: changed(corrected) w.r.t 17x! (didn't do anything in 17x) + nGrow 0; + + // Advanced settings + + //- When not to extrude surface. 0 is flat surface, 90 is when two faces + // make straight angle. + featureAngle 90; + + //- Maximum number of snapping relaxation iterations. Should stop + // before upon reaching a correct mesh. + nRelaxIter 3; + + // Number of smoothing iterations of surface normals + nSmoothSurfaceNormals 1; + + // Number of smoothing iterations of interior mesh movement direction + nSmoothNormals 3; + + // Smooth layer thickness over surface patches + nSmoothThickness 10; + + // Stop layer growth on highly warped cells + maxFaceThicknessRatio 1000; + + // Reduce layer growth where ratio thickness to medial + // distance is large + maxThicknessToMedialRatio 0.3; + + // Angle used to pick up medial axis points + // Note: changed(corrected) w.r.t 17x! 90 degrees corresponds to 130 in 17x. + minMedianAxisAngle 90; + + + // Create buffer region for new layer terminations + nBufferCellsNoExtrude 0; + + + // Overall max number of layer addition iterations. The mesher will exit + // if it reaches this number of iterations; possibly with an illegal + // mesh. + nLayerIter 50; +} + + + +// Generic mesh quality settings. At any undoable phase these determine +// where to undo. +#include "meshQualityControls" + +meshQualityControls +{ + //- Number of error distribution iterations + nSmoothScale 4; + //- amount to scale back displacement at error points + errorReduction 0.75; +} + + +// Advanced + +// Flags for optional output +// 0 : only write final meshes +// 1 : write intermediate meshes +// 2 : write volScalarField with cellLevel for postprocessing +// 4 : write current intersections as .obj files +debug 0; + + +// Merge tolerance. Is fraction of overall bounding box of initial mesh. +// Note: the write tolerance needs to be higher than this. +mergeTolerance 1e-6; + + +// ************************************************************************* // diff --git a/tutorials/mesh/cvMesh/flange/system/surfaceFeatureExtractDict b/tutorials/mesh/cvMesh/flange/system/surfaceFeatureExtractDict new file mode 100644 index 0000000000000000000000000000000000000000..a4c24aa610ba75314acd08a4d37251e509b6e7e9 --- /dev/null +++ b/tutorials/mesh/cvMesh/flange/system/surfaceFeatureExtractDict @@ -0,0 +1,41 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object surfaceFeatureExtractDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +flange.obj +{ + extractionMethod extractFromSurface; + + extractFromSurfaceCoeffs + { + // Mark edges whose adjacent surface normals are at an angle less + // than includedAngle as features + // - 0 : selects no edges + // - 180: selects all edges + includedAngle 155; + } + + + // Write options + + // Write .eMesh file (for snappyHexMesh) + writeFeatureEdgeMesh no; + + // Write features to obj format for postprocessing + writeObj yes; +} + + +// ************************************************************************* // diff --git a/tutorials/multiphase/compressibleTwoPhaseEulerFoam/bubbleColumn/constant/interfacialProperties b/tutorials/multiphase/compressibleTwoPhaseEulerFoam/bubbleColumn/constant/interfacialProperties index c48ea4b91f94c5803c6e4b7fb30721d74d2ec121..03a3a667a3d8c1ee3e013766f338b7928053cabc 100644 --- a/tutorials/multiphase/compressibleTwoPhaseEulerFoam/bubbleColumn/constant/interfacialProperties +++ b/tutorials/multiphase/compressibleTwoPhaseEulerFoam/bubbleColumn/constant/interfacialProperties @@ -23,6 +23,7 @@ heatTransferModel2 RanzMarshall; dispersedPhase both; -minInterfaceAlpha 1e-2; +residualPhaseFraction 1e-3; +residualSlip 1e-2; // ************************************************************************* // diff --git a/tutorials/multiphase/compressibleTwoPhaseEulerFoam/fluidisedBed/constant/interfacialProperties b/tutorials/multiphase/compressibleTwoPhaseEulerFoam/fluidisedBed/constant/interfacialProperties index a8f0a288a0aa14f3c7be5e4f13ef608ffa382610..63efa66a33df1344b571e8b25a15fc48880dd097 100644 --- a/tutorials/multiphase/compressibleTwoPhaseEulerFoam/fluidisedBed/constant/interfacialProperties +++ b/tutorials/multiphase/compressibleTwoPhaseEulerFoam/fluidisedBed/constant/interfacialProperties @@ -23,6 +23,7 @@ heatTransferModel2 RanzMarshall; dispersedPhase "1"; -minInterfaceAlpha 1e-2; +residualPhaseFraction 1e-3; +residualSlip 1e-2; // ************************************************************************* // diff --git a/tutorials/multiphase/compressibleTwoPhaseEulerFoam/mixerVessel2D/constant/interfacialProperties b/tutorials/multiphase/compressibleTwoPhaseEulerFoam/mixerVessel2D/constant/interfacialProperties index 41159fe9def1d68030d4d4c65aacca7947e0610b..06b13a7b3c68ae7a87a4c2f40e232fef99502c7d 100644 --- a/tutorials/multiphase/compressibleTwoPhaseEulerFoam/mixerVessel2D/constant/interfacialProperties +++ b/tutorials/multiphase/compressibleTwoPhaseEulerFoam/mixerVessel2D/constant/interfacialProperties @@ -24,7 +24,7 @@ heatTransferModel2 RanzMarshall; dispersedPhase both; dragPhase blended; -residualSlip 1e-2; -minInterfaceAlpha 1e-3; +residualPhaseFraction 1e-3; +residualSlip 1e-2; // ************************************************************************* // diff --git a/tutorials/multiphase/compressibleTwoPhaseEulerFoam/mixerVessel2D/system/topoSetDict b/tutorials/multiphase/compressibleTwoPhaseEulerFoam/mixerVessel2D/system/topoSetDict new file mode 100644 index 0000000000000000000000000000000000000000..bf749449bfe3a53cee9b2d709eb66a9b2aff4bfe --- /dev/null +++ b/tutorials/multiphase/compressibleTwoPhaseEulerFoam/mixerVessel2D/system/topoSetDict @@ -0,0 +1,32 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object topoSetDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +actions +( + { + name rotor; + type cellSet; + action new; + source zoneToCell; + sourceInfo + { + name rotor; + } + } +); + +// ************************************************************************* // diff --git a/tutorials/multiphase/interFoam/ras/Allclean b/tutorials/multiphase/interFoam/ras/Allclean index fdd2e7c83e0cb0d50c29713e65f2d8b1ac3948ea..bd5bed38568db41b9be00630aa8024cadc663f68 100755 --- a/tutorials/multiphase/interFoam/ras/Allclean +++ b/tutorials/multiphase/interFoam/ras/Allclean @@ -4,7 +4,7 @@ cd ${0%/*} || exit 1 # run from this directory # Source tutorial clean functions . $WM_PROJECT_DIR/bin/tools/CleanFunctions -keepCases="damBreak damBreakPorousBaffle" +keepCases="damBreak damBreakPorousBaffle weirOverflow" loseCases="damBreakFine" for case in $keepCases diff --git a/tutorials/multiphase/interFoam/ras/Allrun b/tutorials/multiphase/interFoam/ras/Allrun index c34b3608349e8852298bc5a08f729fdcfde11177..85cfa0fbfb1355189d2c6c23ae7fec241045daa2 100755 --- a/tutorials/multiphase/interFoam/ras/Allrun +++ b/tutorials/multiphase/interFoam/ras/Allrun @@ -49,4 +49,7 @@ cloneCase damBreak damBreakFine # Do damBreakPorousBaffle (cd damBreakPorousBaffle && foamRunTutorials) +# Do weirOverflow +(cd weirOverflow && foamRunTutorials) + # ----------------------------------------------------------------- end-of-file diff --git a/tutorials/multiphase/interFoam/ras/weirOverflow/0.org/U b/tutorials/multiphase/interFoam/ras/weirOverflow/0.org/U new file mode 100644 index 0000000000000000000000000000000000000000..92b06fe0a614ad67e3ec0bc5eb8bf48b52d524b9 --- /dev/null +++ b/tutorials/multiphase/interFoam/ras/weirOverflow/0.org/U @@ -0,0 +1,56 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volVectorField; + object U; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "include/initialConditions" + +dimensions [0 1 -1 0 0 0 0]; + +internalField uniform (0 0 0); + +boundaryField +{ + inlet + { + type variableHeightFlowRateInletVelocity; + flowRate $inletFlowRate; + value uniform (0 0 0); + } + + outlet + { + type zeroGradient; + } + + lowerWall + { + type fixedValue; + value uniform (0 0 0); + } + + atmosphere + { + type pressureInletOutletVelocity; + phi phi; + value uniform (0 0 0); + } + + defaultFaces + { + type empty; + } +} + +// ************************************************************************* // diff --git a/tutorials/multiphase/interFoam/ras/weirOverflow/0.org/alpha1.org b/tutorials/multiphase/interFoam/ras/weirOverflow/0.org/alpha1.org new file mode 100644 index 0000000000000000000000000000000000000000..deeaf2f3dff70ccc44bee629d9085e3546cb7713 --- /dev/null +++ b/tutorials/multiphase/interFoam/ras/weirOverflow/0.org/alpha1.org @@ -0,0 +1,56 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object alpha1; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "include/initialConditions" + +dimensions [0 0 0 0 0 0 0]; + +internalField uniform 0; + +boundaryField +{ + inlet + { + type variableHeightFlowRate; + lowerBound 0.0; + upperBound 0.9; + value uniform 0; + } + + outlet + { + type zeroGradient; + } + + lowerWall + { + type zeroGradient; + } + + atmosphere + { + type inletOutlet; + inletValue uniform 0; + value uniform 0; + } + + defaultFaces + { + type empty; + } +} + +// ************************************************************************* // diff --git a/tutorials/multiphase/interFoam/ras/weirOverflow/0.org/epsilon b/tutorials/multiphase/interFoam/ras/weirOverflow/0.org/epsilon new file mode 100644 index 0000000000000000000000000000000000000000..7d98d9ac02b9e8a5b09c4a5a5b4dbec2bd41d1d2 --- /dev/null +++ b/tutorials/multiphase/interFoam/ras/weirOverflow/0.org/epsilon @@ -0,0 +1,59 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + location "0"; + object epsilon; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "include/initialConditions" + +dimensions [0 2 -3 0 0 0 0]; + +internalField uniform $turbulentEpsilon; + +boundaryField +{ + inlet + { + type fixedValue; + value $internalField; + } + + outlet + { + type inletOutlet; + inletValue $internalField; + value $internalField; + } + + lowerWall + { + type epsilonWallFunction; + value $internalField; + } + + atmosphere + { + type inletOutlet; + inletValue $internalField; + value $internalField; + } + + defaultFaces + { + type empty; + } +} + + +// ************************************************************************* // diff --git a/tutorials/multiphase/interFoam/ras/weirOverflow/0.org/include/initialConditions b/tutorials/multiphase/interFoam/ras/weirOverflow/0.org/include/initialConditions new file mode 100644 index 0000000000000000000000000000000000000000..1d05333331873e6eaab17c218e348e99e9f278e3 --- /dev/null +++ b/tutorials/multiphase/interFoam/ras/weirOverflow/0.org/include/initialConditions @@ -0,0 +1,15 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ + +inletFlowRate 75; +pressure 0; +turbulentKE 4.14e-03; +turbulentEpsilon 4.39e-05; +#inputMode merge + +// ************************************************************************* // diff --git a/tutorials/multiphase/interFoam/ras/weirOverflow/0.org/k b/tutorials/multiphase/interFoam/ras/weirOverflow/0.org/k new file mode 100644 index 0000000000000000000000000000000000000000..18dafe0a9a9d6e547dc69ff3e78865e2854ddf82 --- /dev/null +++ b/tutorials/multiphase/interFoam/ras/weirOverflow/0.org/k @@ -0,0 +1,59 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + location "0"; + object k; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "include/initialConditions" + +dimensions [0 2 -2 0 0 0 0]; + +internalField uniform $turbulentKE; + +boundaryField +{ + inlet + { + type fixedValue; + value $internalField; + } + + outlet + { + type inletOutlet; + inletValue $internalField; + value $internalField; + } + + lowerWall + { + type kqRWallFunction; + value $internalField; + } + + atmosphere + { + type inletOutlet; + inletValue $internalField; + value $internalField; + } + + defaultFaces + { + type empty; + } +} + + +// ************************************************************************* // diff --git a/tutorials/multiphase/interFoam/ras/weirOverflow/0.org/nut b/tutorials/multiphase/interFoam/ras/weirOverflow/0.org/nut new file mode 100644 index 0000000000000000000000000000000000000000..2d6b6f0067ba0fa590c5a94aa6ed04985273f49c --- /dev/null +++ b/tutorials/multiphase/interFoam/ras/weirOverflow/0.org/nut @@ -0,0 +1,52 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + location "0"; + object nut; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 2 -1 0 0 0 0]; + +internalField uniform 0; + +boundaryField +{ + inlet + { + type calculated; + value uniform 0; + } + outlet + { + type calculated; + value uniform 0; + } + lowerWall + { + type nutkWallFunction; + value uniform 0; + } + atmosphere + { + type calculated; + value uniform 0; + } + + defaultFaces + { + type empty; + } +} + + +// ************************************************************************* // diff --git a/tutorials/multiphase/interFoam/ras/weirOverflow/0.org/p_rgh b/tutorials/multiphase/interFoam/ras/weirOverflow/0.org/p_rgh new file mode 100644 index 0000000000000000000000000000000000000000..026164723a181e39cb132e04a3a40d6333abb0b9 --- /dev/null +++ b/tutorials/multiphase/interFoam/ras/weirOverflow/0.org/p_rgh @@ -0,0 +1,58 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object p_rgh; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "include/initialConditions" + +dimensions [1 -1 -2 0 0 0 0]; + +internalField uniform $pressure; + +boundaryField +{ + inlet + { + type zeroGradient; + } + + outlet + { + type zeroGradient; + } + + lowerWall + { + type zeroGradient; + } + + atmosphere + { + type totalPressure; + p0 uniform 0; + U U; + phi phi; + rho none; + psi none; + gamma 1; + value uniform $pressure; + } + + defaultFaces + { + type empty; + } +} + +// ************************************************************************* // diff --git a/tutorials/multiphase/interFoam/ras/weirOverflow/Allclean b/tutorials/multiphase/interFoam/ras/weirOverflow/Allclean new file mode 100755 index 0000000000000000000000000000000000000000..2c5a008802e8e91116267233274623cc5c062969 --- /dev/null +++ b/tutorials/multiphase/interFoam/ras/weirOverflow/Allclean @@ -0,0 +1,8 @@ +#!/bin/sh + +# Source tutorial clean functions +. $WM_PROJECT_DIR/bin/tools/CleanFunctions + +rm -rf 0 > /dev/null 2>&1 + +cleanCase diff --git a/tutorials/multiphase/interFoam/ras/weirOverflow/Allrun b/tutorials/multiphase/interFoam/ras/weirOverflow/Allrun new file mode 100755 index 0000000000000000000000000000000000000000..da58c047f11167b7accb35d26053883de19febc6 --- /dev/null +++ b/tutorials/multiphase/interFoam/ras/weirOverflow/Allrun @@ -0,0 +1,14 @@ +#!/bin/bash + +# Source tutorial run functions +. $WM_PROJECT_DIR/bin/tools/RunFunctions + +cp -r 0.org 0 > /dev/null 2>&1 + +runApplication blockMesh + +cp 0/alpha1.org 0/alpha1 + +runApplication setFields + +runApplication `getApplication` diff --git a/tutorials/multiphase/interFoam/ras/weirOverflow/constant/RASProperties b/tutorials/multiphase/interFoam/ras/weirOverflow/constant/RASProperties new file mode 100644 index 0000000000000000000000000000000000000000..a4937b503a46850b2626f0d301e4a07b9f691507 --- /dev/null +++ b/tutorials/multiphase/interFoam/ras/weirOverflow/constant/RASProperties @@ -0,0 +1,25 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object RASProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +RASModel kEpsilon; + +turbulence on; + +printCoeffs on; + + +// ************************************************************************* // diff --git a/tutorials/multiphase/interFoam/ras/weirOverflow/constant/g b/tutorials/multiphase/interFoam/ras/weirOverflow/constant/g new file mode 100644 index 0000000000000000000000000000000000000000..e0ac2653b5b370ad62f6770588121d30cac51627 --- /dev/null +++ b/tutorials/multiphase/interFoam/ras/weirOverflow/constant/g @@ -0,0 +1,22 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class uniformDimensionedVectorField; + location "constant"; + object g; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 1 -2 0 0 0 0]; +value ( 0 -9.81 0 ); + + +// ************************************************************************* // diff --git a/tutorials/multiphase/interFoam/ras/weirOverflow/constant/polyMesh/blockMeshDict b/tutorials/multiphase/interFoam/ras/weirOverflow/constant/polyMesh/blockMeshDict new file mode 100644 index 0000000000000000000000000000000000000000..cc77285f11efa60e0fddb80e868a7ed3d1dfa865 --- /dev/null +++ b/tutorials/multiphase/interFoam/ras/weirOverflow/constant/polyMesh/blockMeshDict @@ -0,0 +1,93 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object blockMeshDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +convertToMeters 1; + +vertices +( + (-18 0 -0.5) + ( 0 0 -0.5) + ( 30 0 -0.5) + ( 90 0 -0.5) + (-18 30 -0.5) + ( 0 30 -0.5) + ( 15 30 -0.5) + ( 90 30 -0.5) + (-18 54 -0.5) + ( 0 54 -0.5) + ( 15 54 -0.5) + ( 90 54 -0.5) + + (-18 0 0.5) + ( 0 0 0.5) + ( 30 0 0.5) + ( 90 0 0.5) + (-18 30 0.5) + ( 0 30 0.5) + ( 15 30 0.5) + ( 90 30 0.5) + (-18 54 0.5) + ( 0 54 0.5) + ( 15 54 0.5) + ( 90 54 0.5) +); + +blocks +( + hex (0 1 5 4 12 13 17 16) (20 20 1) simpleGrading (1 0.5 1) + hex (2 3 7 6 14 15 19 18) (60 40 1) simpleGrading (1 2 1) + hex (4 5 9 8 16 17 21 20) (20 24 1) simpleGrading (1 1 1) + hex (5 6 10 9 17 18 22 21) (15 24 1) simpleGrading (1 1 1) + hex (6 7 11 10 18 19 23 22) (60 24 1) simpleGrading (1 1 1) +); + +edges +( +); + +patches +( + patch inlet + ( + (0 12 16 4) + (4 16 20 8) + ) + patch outlet + ( + (7 19 15 3) + (11 23 19 7) + ) + wall lowerWall + ( + (0 1 13 12) + (1 5 17 13) + (5 6 18 17) + (2 14 18 6) + (2 3 15 14) + ) + patch atmosphere + ( + (8 20 21 9) + (9 21 22 10) + (10 22 23 11) + ) +); + +mergePatchPairs +( +); + +// ************************************************************************* // diff --git a/tutorials/multiphase/interFoam/ras/weirOverflow/constant/polyMesh/boundary b/tutorials/multiphase/interFoam/ras/weirOverflow/constant/polyMesh/boundary new file mode 100644 index 0000000000000000000000000000000000000000..e7fe171353ef2ef89026649538494718c28d655c --- /dev/null +++ b/tutorials/multiphase/interFoam/ras/weirOverflow/constant/polyMesh/boundary @@ -0,0 +1,52 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class polyBoundaryMesh; + location "constant/polyMesh"; + object boundary; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +5 +( + inlet + { + type patch; + nFaces 44; + startFace 9981; + } + outlet + { + type patch; + nFaces 64; + startFace 10025; + } + lowerWall + { + type wall; + nFaces 155; + startFace 10089; + } + atmosphere + { + type patch; + nFaces 95; + startFace 10244; + } + defaultFaces + { + type empty; + nFaces 10160; + startFace 10339; + } +) + +// ************************************************************************* // diff --git a/tutorials/multiphase/interFoam/ras/weirOverflow/constant/transportProperties b/tutorials/multiphase/interFoam/ras/weirOverflow/constant/transportProperties new file mode 100644 index 0000000000000000000000000000000000000000..ef3e8c7b4b6b6b1979253b534cc30d07c0f63826 --- /dev/null +++ b/tutorials/multiphase/interFoam/ras/weirOverflow/constant/transportProperties @@ -0,0 +1,72 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object transportProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +twoPhase +{ + transportModel twoPhase; + phase1 phase1; + phase2 phase2; +} + +phase1 +{ + transportModel Newtonian; + nu nu [ 0 2 -1 0 0 0 0 ] 1e-06; + rho rho [ 1 -3 0 0 0 0 0 ] 1000; + CrossPowerLawCoeffs + { + nu0 nu0 [ 0 2 -1 0 0 0 0 ] 1e-06; + nuInf nuInf [ 0 2 -1 0 0 0 0 ] 1e-06; + m m [ 0 0 1 0 0 0 0 ] 1; + n n [ 0 0 0 0 0 0 0 ] 0; + } + + BirdCarreauCoeffs + { + nu0 nu0 [ 0 2 -1 0 0 0 0 ] 0.0142515; + nuInf nuInf [ 0 2 -1 0 0 0 0 ] 1e-06; + k k [ 0 0 1 0 0 0 0 ] 99.6; + n n [ 0 0 0 0 0 0 0 ] 0.1003; + } +} + +phase2 +{ + transportModel Newtonian; + nu nu [ 0 2 -1 0 0 0 0 ] 1.48e-05; + rho rho [ 1 -3 0 0 0 0 0 ] 1; + CrossPowerLawCoeffs + { + nu0 nu0 [ 0 2 -1 0 0 0 0 ] 1e-06; + nuInf nuInf [ 0 2 -1 0 0 0 0 ] 1e-06; + m m [ 0 0 1 0 0 0 0 ] 1; + n n [ 0 0 0 0 0 0 0 ] 0; + } + + BirdCarreauCoeffs + { + nu0 nu0 [ 0 2 -1 0 0 0 0 ] 0.0142515; + nuInf nuInf [ 0 2 -1 0 0 0 0 ] 1e-06; + k k [ 0 0 1 0 0 0 0 ] 99.6; + n n [ 0 0 0 0 0 0 0 ] 0.1003; + } +} + +sigma sigma [ 1 0 -2 0 0 0 0 ] 0.07; + + +// ************************************************************************* // diff --git a/tutorials/multiphase/interFoam/ras/weirOverflow/constant/turbulenceProperties b/tutorials/multiphase/interFoam/ras/weirOverflow/constant/turbulenceProperties new file mode 100644 index 0000000000000000000000000000000000000000..3721a46a2ead37eb2bf10434bcde59afa9fe9bf6 --- /dev/null +++ b/tutorials/multiphase/interFoam/ras/weirOverflow/constant/turbulenceProperties @@ -0,0 +1,21 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object turbulenceProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +simulationType RASModel; + + +// ************************************************************************* // diff --git a/tutorials/multiphase/interFoam/ras/weirOverflow/system/controlDict b/tutorials/multiphase/interFoam/ras/weirOverflow/system/controlDict new file mode 100644 index 0000000000000000000000000000000000000000..85c6938c48b6625f8aeb251e8282cb213ec58c80 --- /dev/null +++ b/tutorials/multiphase/interFoam/ras/weirOverflow/system/controlDict @@ -0,0 +1,55 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object controlDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +application interFoam; + +startFrom latestTime; + +startTime 0; + +stopAt endTime; + +endTime 60; + +deltaT 0.001; + +writeControl adjustableRunTime; + +writeInterval 2; + +purgeWrite 0; + +writeFormat ascii; + +writePrecision 6; + +writeCompression uncompressed; + +timeFormat general; + +timePrecision 6; + +runTimeModifiable yes; + +adjustTimeStep on; + +maxCo 0.2; +maxAlphaCo 0.2; + +maxDeltaT 1; + +// ************************************************************************* // diff --git a/tutorials/multiphase/interFoam/ras/weirOverflow/system/fvSchemes b/tutorials/multiphase/interFoam/ras/weirOverflow/system/fvSchemes new file mode 100644 index 0000000000000000000000000000000000000000..28b3d7d20aeb00f17348671a1a85ba2700c6f874 --- /dev/null +++ b/tutorials/multiphase/interFoam/ras/weirOverflow/system/fvSchemes @@ -0,0 +1,65 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object fvSchemes; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +ddtSchemes +{ + default Euler; +} + +gradSchemes +{ + default Gauss linear; +} + +divSchemes +{ + div(rho*phi,U) Gauss linear; + div(phi,alpha) Gauss vanLeer; + div(phirb,alpha) Gauss interfaceCompression; + div(phi,k) Gauss upwind; + div(phi,epsilon) Gauss upwind; + div(phi,R) Gauss upwind; + div(R) Gauss linear; + div(phi,nuTilda) Gauss upwind; + div((nuEff*dev(T(grad(U))))) Gauss linear; +} + +laplacianSchemes +{ + default Gauss linear corrected; +} + +interpolationSchemes +{ + default linear; +} + +snGradSchemes +{ + default corrected; +} + +fluxRequired +{ + default no; + p_rgh; + pcorr; + alpha; +} + + +// ************************************************************************* // diff --git a/tutorials/multiphase/interFoam/ras/weirOverflow/system/fvSolution b/tutorials/multiphase/interFoam/ras/weirOverflow/system/fvSolution new file mode 100644 index 0000000000000000000000000000000000000000..b8d411303f41ffe1b2722fc28817c4470164f3b5 --- /dev/null +++ b/tutorials/multiphase/interFoam/ras/weirOverflow/system/fvSolution @@ -0,0 +1,67 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object fvSolution; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +solvers +{ + pcorr + { + solver PCG; + preconditioner DIC; + tolerance 1e-10; + relTol 0; + } + + p_rgh + { + solver PCG; + preconditioner DIC; + tolerance 1e-07; + relTol 0.05; + } + + p_rghFinal + { + $p_rgh; + relTol 0; + } + + "(U|k|epsilon)" + { + solver PBiCG; + preconditioner DILU; + tolerance 1e-8; + relTol 0.1; + } + + "(U|k|epsilon)Final" + { + $U; + relTol 0; + } +} + +PIMPLE +{ + momentumPredictor no; + nCorrectors 3; + nNonOrthogonalCorrectors 0; + nAlphaCorr 1; + nAlphaSubCycles 2; + cAlpha 1; +} + + +// ************************************************************************* // diff --git a/tutorials/multiphase/interFoam/ras/weirOverflow/system/setFieldsDict b/tutorials/multiphase/interFoam/ras/weirOverflow/system/setFieldsDict new file mode 100644 index 0000000000000000000000000000000000000000..26d6b7f2a6c7f2db74d61eb3caf13bdece363db9 --- /dev/null +++ b/tutorials/multiphase/interFoam/ras/weirOverflow/system/setFieldsDict @@ -0,0 +1,35 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object setFieldsDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +defaultFieldValues +( + volScalarFieldValue alpha1 0 +); + +regions +( + boxToCell + { + box (-100 0 -100) (0 20 100); + + fieldValues + ( + volScalarFieldValue alpha1 1 + ); + } +); + +// ************************************************************************* // diff --git a/tutorials/multiphase/twoPhaseEulerFoam/mixerVessel2D/system/topoSetDict b/tutorials/multiphase/twoPhaseEulerFoam/mixerVessel2D/system/topoSetDict new file mode 100644 index 0000000000000000000000000000000000000000..bf749449bfe3a53cee9b2d709eb66a9b2aff4bfe --- /dev/null +++ b/tutorials/multiphase/twoPhaseEulerFoam/mixerVessel2D/system/topoSetDict @@ -0,0 +1,32 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object topoSetDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +actions +( + { + name rotor; + type cellSet; + action new; + source zoneToCell; + sourceInfo + { + name rotor; + } + } +); + +// ************************************************************************* //