Commit 6cc870a9 authored by Franjo's avatar Franjo

Removed unnecessary utilities

parent 7bd36dae
cellSetIntersectedByPlane.C
EXE = $(FOAM_APPBIN)/cellSetIntersectedByPlane
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(FOAM_USER_LIB)/meshGeneration/meshLibrary/lnInclude
EXE_LIBS = \
-lmeshLibrary \
-ltriSurface \
-lfiniteVolume \
-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/>.
Application
Prints topology of cells in a given cell set
Description
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "cellSet.H"
#include "polyMesh.H"
#include "IOobjectList.H"
#include "volFields.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
//argList::validArgs.append("cellSet");
# include "setRootCase.H"
# include "createTime.H"
Info<< "Reading mesh for time = " << runTime.value() << endl;
polyMesh mesh(runTime);
cellSet cs
(
IOobject
(
"c0",
runTime.timeName(),
"polyMesh/sets",
runTime,
IOobject::NO_READ
)
);
vector n, origin;
Info << "Normal x coord" ;
cin >> n.x();
Info << endl << "Normal y coord ";
cin >> n.y();
Info << endl << "Normal z coord";
cin >> n.z();
Info << "Origin x coord" ;
cin >> origin.x();
Info << endl << "Origin y coord ";
cin >> origin.y();
Info << endl << "Origin z coord";
cin >> origin.z();
//Info<< "Reading cell set from " << setName << endl << endl;
//cellSet cs(mesh, setName);
//- printCells contained in the cellSet
const pointField& points = mesh.points();
const edgeList& edges = mesh.edges();
const labelListList& edgeCells = mesh.edgeCells();
forAll(edges, eI)
{
const edge& e = edges[eI];
bool visibleS, visibleE;
if( ((points[e.start()] - origin) & n) >= 0.0 )
{
visibleS = true;
}
else
{
visibleS = false;
}
if( ((points[e.end()] - origin) & n) >= 0.0 )
{
visibleE = true;
}
else
{
visibleE = false;
}
if( visibleS ^ visibleE )
{
forAll(edgeCells[eI], ecI)
cs.insert(edgeCells[eI][ecI]);
}
}
cs.write();
Info << "End\n" << endl;
return 0;
}
// ************************************************************************* //
plyToSurface.C
EXE = $(FOAM_APPBIN)/plyToSurface
EXE_INC = -I$(FOAM_USER_LIB)/pMesh3D/pMeshLibrary/lnInclude \
-I$(LIB_SRC)/triSurface/lnInclude
EXE_LIBS = -ltriSurface -lmeshTools -lmeshLibrary
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
Converts STAR CD surfaces into stl or other formats
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "IFstream.H"
#include "fileName.H"
#include "triSurface.H"
#include "OFstream.H"
#include "OSspecific.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
using namespace Foam;
int main(int argc, char *argv[])
{
argList::noParallel();
argList::validArgs.clear();
argList::validOptions.insert("noCleanup", "");
argList::validOptions.insert("group", "");
argList::validArgs.append("input surface file");
argList::validArgs.append("output surface file");
argList args(argc, argv);
fileName inFileName(args.args()[1]);
fileName outFileName(args.args()[2]);
if( outFileName == inFileName )
{
FatalErrorIn(args.executable())
<< "Output file " << outFileName
<< " would overwrite input file."
<< exit(FatalError);
}
IFstream surfFile(inFileName);
//- parse the number of vertices
token t;
do
{
surfFile >> t;
} while( !t.isLabel() );
pointField points(t.labelToken());
Info << "Surface has " << points.size() << " points" << endl;
//- find the number of elements
do
{
surfFile >> t;
} while( !t.isLabel() );
List<labelledTri> triFaces(t.labelToken());
Info << "Surface has " << triFaces.size() << " facets" << endl;
//- read vertices
do
{
surfFile >> t;
} while( t.isWord() && (t.wordToken() != "end_header") );
forAll(points, pointI)
{
point& p = points[pointI];
surfFile >> p.x();
surfFile >> p.y();
surfFile >> p.z();
}
//- read triangles
forAll(triFaces, triI)
{
label nPts;
surfFile >> nPts;
if( nPts != 3 )
{
Info << "Facet " << triI << " is not a triangle!!" << endl;
Warning << "Cannot convert this surface!" << endl;
return 0;
}
for(label i=0;i<nPts;++i)
surfFile >> triFaces[triI][i];
triFaces[triI].region() = 0;
}
triSurface surf(triFaces, points);
Info << "Writing : " << outFileName << endl;
surf.write(outFileName);
Info << "End\n" << endl;
return 0;
}
// ************************************************************************* //
argList args(argc, argv);
if (!args.checkRootCase())
{
FatalError.exit();
}
printCellsInSet.C
EXE = $(FOAM_APPBIN)/printCellsInSet
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(FOAM_USER_LIB)/meshGeneration/meshLibrary/lnInclude
EXE_LIBS = -lmeshLibrary -ltriSurface -lfiniteVolume -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/>.
Application
Prints topology of cells in a given cell set
Description
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "cellSet.H"
#include "polyMesh.H"
#include "IOobjectList.H"
#include "volFields.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
argList::validArgs.append("cellSet");
# include "setRootCase.H"
# include "createTime.H"
Info<< "Reading mesh for time = " << runTime.value() << endl;
polyMesh mesh(runTime);
word setName(args.args()[3]);
Info<< "Reading cell set from " << setName << endl << endl;
cellSet cs(mesh, setName);
//- printCells contained in the cellSet
const cellList& cells = mesh.cells();
const faceList& faces = mesh.faces();
forAll(cells, cellI)
if( cs.found(cellI) )
{
const cell& c = cells[cellI];
Info << "Cell " << cellI << " consists of faces " << c << endl;
forAll(c, fI)
Info << "Face " << c[fI] << " is " << faces[c[fI]] << endl;
Info << nl << endl;
}
Info << "End\n" << endl;
return 0;
}
// ************************************************************************* //
starSurfaceToSTL.C
EXE = $(FOAM_APPBIN)/starSurfaceToSTL
EXE_INC = -I$(FOAM_USER_LIB)/pMesh3D/pMeshLibrary/lnInclude \
-I$(LIB_SRC)/triSurface/lnInclude
EXE_LIBS = -ltriSurface -lmeshTools -lmeshLibrary
argList args(argc, argv);
if (!args.checkRootCase())
{
FatalError.exit();
}
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
Converts STAR CD surfaces into stl or other formats
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "IFstream.H"
#include "fileName.H"
#include "triSurface.H"
#include "OFstream.H"
#include "OSspecific.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
using namespace Foam;
int main(int argc, char *argv[])
{
argList::noParallel();
argList::validArgs.clear();
argList::validOptions.insert("noCleanup", "");
argList::validOptions.insert("group", "");
argList::validArgs.append("input surface file");
argList::validArgs.append("output surface file");
argList args(argc, argv);
fileName inFileName(args.args()[1]);
fileName outFileName(args.args()[2]);
if (outFileName == inFileName)
{
FatalErrorIn(args.executable())
<< "Output file " << outFileName
<< " would overwrite input file."
<< exit(FatalError);
}
fileName vFile(inFileName+".vrt");
IFstream vertexFile(vFile.c_str());
pointField points(100);
label index(0);
bool finished(false);
do
{
token t(vertexFile);
if( t.isLabel() )
{
point p;
p.x() = readScalar(vertexFile);
p.y() = readScalar(vertexFile);
p.z() = readScalar(vertexFile);
points.newElmt(index++) = p;
}
else
{
finished = true;
}
} while( !finished );
points.setSize(index);
Info << "points " << points << endl;
index = 0;
SLList<labelledTri> triangles;
fileName cFile(inFileName+".cel");
IFstream cellFile(cFile);
finished = false;
do
{
token t(cellFile);
if( t.isLabel() )
{
label v0 = readLabel(cellFile) - 1;
label v1 = readLabel(cellFile) - 1;
label v2 = readLabel(cellFile) - 1;
label v3 = readLabel(cellFile) - 1;
readLabel(cellFile);
readLabel(cellFile);
readLabel(cellFile);
readLabel(cellFile);
if( v2 > 0 && v3 > 0 )
{
if( v2 == v3 )
{
triangles.append(labelledTri(v0,v1,v2,0));
}
else
{
triangles.append(labelledTri(v0,v1,v2,0));
triangles.append(labelledTri(v0,v2,v3,0));
}
}
readLabel(cellFile);
readLabel(cellFile);
}
else
{
finished = true;
}
} while( !finished );
List<labelledTri> triFaces(triangles);
triSurface surf(triFaces, points);
Info << "Writing : " << outFileName << endl;
surf.write(outFileName);
Info << "End\n" << endl;
return 0;
}
// ************************************************************************* //
surfaceClosedness.C
EXE = $(FOAM_APPBIN)/surfaceClosedness
EXE_INC = -I$(FOAM_USER_LIB)/pMesh3D/pMeshLibrary/lnInclude \
-I$(LIB_SRC)/triSurface/lnInclude
EXE_LIBS = -ltriSurface -lmeshTools -lmeshLibrary
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
Checks if the surface is geometrically closed
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "IFstream.H"
#include "fileName.H"
#include "triSurface.H"
#include "OFstream.H"
#include "OSspecific.H"
#define DEBUGStitch
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
using namespace Foam;
int main(int argc, char *argv[])
{
argList::noParallel();
argList::validArgs.clear();
argList::validOptions.insert("noCleanup", "");
argList::validOptions.insert("group", "");
argList::validArgs.append("input surface file");
argList args(argc, argv);
fileName inFileName(args.args()[1]);
triSurface ts(inFileName);
const List<labelledTri>& triangles = ts.localFaces();
const pointField& points = ts.localPoints();
const labelListList& edgeFaces = ts.edgeFaces();
forAll(edgeFaces, eI)
if( edgeFaces[eI].size() != 2 )
Info << "Edge " << eI << " is an open edge " << endl;
vector sum(vector::zero);
forAll(triangles, tI)
{
const vector n = triangles[tI].normal(points);
sum += n;
}
if( mag(sum) > 1e-12 )
{
Info << "Surface is not closed " << sum << endl;