triSurfaceCleanupDuplicates.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | cfMesh: A library for mesh generation
4  \\ / O peration |
5  \\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
6  \\/ M anipulation | Copyright (C) Creative Fields, Ltd.
7 -------------------------------------------------------------------------------
8 License
9  This file is part of cfMesh.
10 
11  cfMesh is free software; you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by the
13  Free Software Foundation; either version 3 of the License, or (at your
14  option) any later version.
15 
16  cfMesh is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with cfMesh. If not, see <http://www.gnu.org/licenses/>.
23 
24 Description
25 
26 \*---------------------------------------------------------------------------*/
27 
29 #include "meshOctree.H"
30 #include "demandDrivenData.H"
31 
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 
37 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 
40 (
41  const meshOctree& octree,
42  const scalar tol
43 )
44 :
45  tolerance_(tol),
46  surf_(const_cast<triSurf&>(octree.surface())),
47  octree_(octree),
48  newTriangleLabel_(),
49  done_(false)
50 {}
51 
53 {}
54 
55 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
56 
58 {
59  if( Pstream::parRun() )
60  FatalError << "Material detection does not run in parallel"
61  << exit(FatalError);
62 
63  if( done_ )
64  {
65  WarningIn("void triSurfaceCleanupDuplicates::mergeIdentities()")
66  << "Operation is already performed" << endl;
67  return;
68  }
69 
72  newTriangleLabel_[triI] = triI;
73 
74  bool finished;
75  do
76  {
77  finished = true;
78 
80  finished = false;
81  if( mergeDuplicatePoints() )
82  finished = false;
83  } while( !finished );
84 
85  done_ = true;
86 }
87 
88 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
89 
90 } // End namespace Foam
91 
92 // ************************************************************************* //
Foam::triSurfaceCleanupDuplicates::~triSurfaceCleanupDuplicates
~triSurfaceCleanupDuplicates()
Definition: triSurfaceCleanupDuplicates.C:52
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::triSurfaceCleanupDuplicates::surf_
triSurf & surf_
reference to triSurf
Definition: triSurfaceCleanupDuplicates.H:60
demandDrivenData.H
Template functions to aid in the implementation of demand driven data.
Foam::UPstream::parRun
static bool & parRun()
Is this a parallel run?
Definition: UPstream.H:377
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
meshOctree.H
Foam::triSurfaceCleanupDuplicates::checkDuplicateTriangles
bool checkDuplicateTriangles()
Check duplicate triangles.
Definition: triSurfaceCleanupDuplicatesFunctions.C:45
Foam::LongList::setSize
void setSize(const label)
Reset size of List.
Definition: LongListI.H:223
Foam::triSurfaceCleanupDuplicates::triSurfaceCleanupDuplicates
triSurfaceCleanupDuplicates(const triSurfaceCleanupDuplicates &)
Disallow default bitwise copy construct.
Foam::triSurfaceCleanupDuplicates::mergeIdentities
void mergeIdentities()
merge duplicate vertices and triangles
Definition: triSurfaceCleanupDuplicates.C:57
Foam::triSurfaceCleanupDuplicates::newTriangleLabel_
labelLongList newTriangleLabel_
new triangle labels in case some of them is removed
Definition: triSurfaceCleanupDuplicates.H:66
Foam::FatalError
error FatalError
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
Foam::triSurfaceCleanupDuplicates::done_
bool done_
check if the operation has already been performed
Definition: triSurfaceCleanupDuplicates.H:69
Foam::triSurfaceCleanupDuplicates::mergeDuplicatePoints
bool mergeDuplicatePoints()
Check duplicate points.
Definition: triSurfaceCleanupDuplicatesFunctions.C:104
Foam::triSurfFacets::size
label size() const
return the number of triangles
Definition: triSurfFacetsI.H:39
Foam::meshOctree
Definition: meshOctree.H:55
WarningIn
#define WarningIn(functionName)
Report a warning using Foam::Warning.
Definition: messageStream.H:254
Foam::meshOctree::surface
const triSurf & surface() const
return a reference to the surface
Definition: meshOctreeI.H:130
Foam::triSurf
Definition: triSurf.H:59
triSurfaceCleanupDuplicates.H