Commit 20bd0f12 authored by Franjo's avatar Franjo

Initial implementation

parent d35f1b4e
......@@ -86,6 +86,7 @@ checkNonMappableCellConnections = $(topology)/checkNonMappableCellConnections
triSurfaceTools = utilities/triSurfaceTools
triSurface2DCheck = $(triSurfaceTools)/triSurface2DCheck
triSurfaceChecks = $(triSurfaceTools)/triSurfaceChecks
triSurfaceCleanupDuplicates = $(triSurfaceTools)/triSurfaceCleanupDuplicates
triSurfaceCleanupDuplicateTriangles = $(triSurfaceTools)/triSurfaceCleanupDuplicateTriangles
triSurfaceCopyParts = $(triSurfaceTools)/triSurfaceCopyParts
......@@ -407,6 +408,8 @@ $(objectRefinement)/hollowConeRefinement.C
$(triSurface2DCheck)/triSurface2DCheck.C
$(triSurfaceChecks)/triSurfaceChecks.C
$(triSurfaceCleanupDuplicates)/triSurfaceCleanupDuplicates.C
$(triSurfaceCleanupDuplicates)/triSurfaceCleanupDuplicatesFunctions.C
......
......@@ -35,57 +35,99 @@ SourceFiles
#ifndef triSurface2DCheck_H
#define triSurface2DCheck_H
#include "triSurf.H"
#include "symmTensor.H"
#include "labelLongList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class triSurf;
class boundBox;
/*---------------------------------------------------------------------------*\
Class triSurface2DCheck Declaration
Namespace triSurfaceChecka Declaration
\*---------------------------------------------------------------------------*/
class triSurface2DCheck
namespace triSurfaceChecks
{
// Private data
//- reference to triSurf
const triSurf& surf_;
//- covariance matrix
symmTensor covarianceMatrix_;
// Private member functions
//- create covariance matrix
void createCovarianceMatrix();
//- Disallow default bitwise copy construct
triSurface2DCheck(const triSurface2DCheck&);
//- Disallow default bitwise assignment
void operator=(const triSurface2DCheck&);
public:
// Constructors
//- check the angles of triangles. Triangles wth the smallest angle below
//- the given threshold are marked as bad-quality triangles
label checkAngles
(
const triSurf&,
labelLongList&,
const scalar angleTol = 5.0
);
label checkAngles
(
triSurf&,
const word subsetName = "smallAngles",
const scalar angleTol = 5.0
);
//- check for existence of boudary and non-manifold edges
label checkSurfaceManifolds(const triSurf&, labelLongList&triangleInManifold);
label checkSurfaceManifolds(triSurf&, const word subsetPrefix="manifold_");
//- check for existence of holes in the surface mesh
label checkForHoles(const triSurf&, labelLongList&);
label checkForHoles(triSurf&, const word subsetPrefix="hole_");
//- check for existence of non-manifold edges
label checkForNonManifoldEdges(const triSurf&, labelLongList&);
label checkForNonManifoldEdges
(
triSurf&,
const word subsetPrefix="nonManifold_"
);
//- check orientation of triangles
label checkOrientation(const triSurf&, labelLongList& triangleInGroup);
label checkOrientation(triSurf&, const word subsetPrefix="orientation_");
//- check for disconnected surface parts
label checkDisconnectedParts(const triSurf&, labelLongList& triangleInRegion);
label checkDisconnectedParts(triSurf&, const word subsetPrefix="region_");
//- calculate bounding box of the surface mesh
void calculateBoundingBox(const triSurf&, boundBox&);
//- check if there exist any self-intersections
label checkSelfIntersections
(
const triSurf&,
labelLongList&,
const scalar tol=1e-6
);
label checkSelfIntersections
(
triSurf&,
const word subsetName="selfIntersect",
const scalar tol=1e-6
);
//- check if there exist any overlaps
label checkOverlaps
(
const triSurf&,
labelLongList&,
const scalar tol = 1e-6,
const scalar angleTol = 5.0
);
label checkOverlaps
(
triSurf&,
const word subsetName="overlappingTriangles",
const scalar tol = 1e-6,
const scalar angleTol = 5.0
);
//- Construct from octree
triSurface2DCheck(const triSurf& surface);
// Destructor
~triSurface2DCheck();
// Member Functions
//- checks if the surface is a 2D triangulation
bool is2DSurface() const;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//- create subset containing invalid facets
void createSubsets();
};
} // End namespace triSurfaceChecks
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......
checkSurfaceMesh.C
EXE = $(FOAM_USER_APPBIN)/checkSurfaceMesh
EXE_INC = \
-I../../meshLibrary/lnInclude \
-I$(LIB_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
EXE_LIBS = \
-ltriSurface \
-L$(FOAM_USER_LIBBIN) \
-lmeshLibrary \
-lmeshTools
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh 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.
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
Description
Reads the specified surface and writes it in the fms format.
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "IFstream.H"
#include "fileName.H"
#include "triSurf.H"
#include "triSurfModifier.H"
#include "helperFunctions.H"
#include "demandDrivenData.H"
#include "coordinateModifier.H"
#include "checkMeshDict.H"
#include "surfaceMeshGeometryModification.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
using namespace Foam;
int main(int argc, char *argv[])
{
# include "setRootCase.H"
# include "createTime.H"
IOdictionary meshDict
(
IOobject
(
"meshDict",
runTime.system(),
runTime,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);
checkMeshDict cmd(meshDict);
fileName surfaceFile = meshDict.lookup("surfaceFile");
if( Pstream::parRun() )
surfaceFile = ".."/surfaceFile;
triSurf surface(runTime.path()/surfaceFile);
surfaceMeshGeometryModification gMod(surface, meshDict);
//- modify points
const triSurf* modSurfPtr = gMod.modifyGeometry();
Info << "Writting modified surface" << endl;
modSurfPtr->writeSurface("modifiedSurf.stl");
# ifdef DEBUGScaling
//- apply backward modification
Info << "Here" << endl;
coordinateModifier cMod(meshDict.subDict("anisotropicSources"));
Info << "Starting modifications" << endl;
forAll(surface.points(), i)
{
Info << "\nOrig point " << i << " coordinates " << surface.points()[i]
<< " modified point " << modSurfPtr->points()[i] << endl;
const point p = cMod.backwardModifiedPoint(modSurfPtr->points()[i]);
if( mag(p - surface.points()[i]) > 1e-14 )
{
Warning << "Point " << i << " is different "
<< p
<< " from original " << surface.points()[i]
<< " modified point "
<< cMod.modifiedPoint(surface.points()[i]) << endl;
::exit(0);
}
}
Info << "Backscaling Ok" << endl;
::exit(0);
# endif
surfaceMeshGeometryModification bgMod(*modSurfPtr, meshDict);
const triSurf* backModSurfPtr = bgMod.revertGeometryModification();
Info << "Writting backward transformed surface" << endl;
backModSurfPtr->writeSurface("backwardModifiedSurf.stl");
# ifdef DEBUGScaling
forAll(backModSurfPtr->points(), pI)
if( mag(backModSurfPtr->points()[pI] - surface.points()[pI]) > 1e-14 )
Warning << "Point " << pI << " is different "
<< backModSurfPtr->points()[pI]
<< " from original " << surface.points()[pI] << endl;
# endif
deleteDemandDrivenData(modSurfPtr);
deleteDemandDrivenData(backModSurfPtr);
Info << "End\n" << endl;
return 0;
}
// ************************************************************************* //
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment