triSurfaceCleanupDuplicateTrianglesFunctions.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 "triSurfModifier.H"
30 
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35 
36 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 
39 {
40  labelLongList newTriangleLabel(surf_.size(), -1);
41 
42  const VRWGraph& pointTriangles = surf_.pointFacets();
43 
44  //- check if there exist duplicate triangles
45  label counter(0);
46 
47  forAll(surf_, triI)
48  {
49  if( newTriangleLabel[triI] != -1 )
50  continue;
51 
52  newTriangleLabel[triI] = counter;
53  ++counter;
54 
55  const labelledTri& tri = surf_[triI];
56 
57  forAll(pointTriangles[tri[0]], ptI)
58  {
59  const label triJ = pointTriangles(tri[0], ptI);
60 
61  if( triJ <= triI )
62  continue;
63 
64  const labelledTri& otherTri = surf_[triJ];
65 
66  if( tri == otherTri )
67  newTriangleLabel[triJ] = newTriangleLabel[triI];
68  }
69  }
70 
71  Info << "Found " << (newTriangleLabel.size()-counter)
72  << " duplicate triangles" << endl;
73 
74  //- return if there exist no duplicate triangles
75  if( counter == newTriangleLabel.size() )
76  return;
77 
78  Info << "Current number of triangles" << surf_.size() << endl;
79  Info << "New number of triangles " << counter << endl;
80 
81  //- create new list of triangles and store it in the surface mesh
82  LongList<labelledTri> newTriangles(counter);
83 
84  forAll(newTriangleLabel, triI)
85  {
86  newTriangles[newTriangleLabel[triI]] = surf_[triI];
87  }
88 
89  triSurfModifier(surf_).facetsAccess().transfer(newTriangles);
90  surf_.updateFacetsSubsets(newTriangleLabel);
91 
94 }
95 
96 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
97 
98 } // End namespace Foam
99 
100 // ************************************************************************* //
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
triSurfModifier.H
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::triSurfModifier
Definition: triSurfModifier.H:48
Foam::LongList::size
label size() const
Size of the active part of the list.
Definition: LongListI.H:203
Foam::triSurfaceCleanupDuplicateTriangles::surf_
triSurf & surf_
reference to triSurf
Definition: triSurfaceCleanupDuplicateTriangles.H:56
Foam::LongList< label >
Foam::triSurfAddressing::clearAddressing
void clearAddressing()
delete all data
Definition: triSurfAddressing.C:340
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Foam::Info
messageStream Info
Foam::triSurfaceCleanupDuplicateTriangles::checkDuplicateTriangles
void checkDuplicateTriangles()
Check duplicate triangles.
Definition: triSurfaceCleanupDuplicateTrianglesFunctions.C:38
Foam::triSurfModifier::facetsAccess
LongList< labelledTri > & facetsAccess()
access to facets
Definition: triSurfModifierI.H:42
Foam::triSurfAddressing::clearGeometry
void clearGeometry()
delete geometry data
Definition: triSurfAddressing.C:350
Foam::triSurfAddressing::pointFacets
const VRWGraph & pointFacets() const
return point-facets addressing
Definition: triSurfAddressingI.H:43
triSurfaceCleanupDuplicateTriangles.H
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::triSurfFacets::size
label size() const
return the number of triangles
Definition: triSurfFacetsI.H:39
Foam::labelledTri
Triangle with additional region number.
Definition: labelledTri.H:49
Foam::triSurfFacets::updateFacetsSubsets
void updateFacetsSubsets(const ListType &)
Definition: triSurfFacetsI.H:135
Foam::VRWGraph
Definition: VRWGraph.H:101