1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | cfMesh: A library for mesh generation
5 \\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
6 \\/ M anipulation | Copyright (C) Creative Fields, Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of cfMesh.
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.
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
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/>.
26 \*---------------------------------------------------------------------------*/
28 #include "meshOctreeModifier.H"
30 #include "demandDrivenData.H"
32 // #define DEBUGSearch
34 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
39 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 void meshOctreeModifier::reduceMemoryConsumption()
43 //createListOfLeaves();
45 const LongList<meshOctreeCube*>& leaves = octree_.leaves_;
47 forAll(octree_.dataSlots_, slotI)
49 //- deleting triangles
50 VRWGraph& containedTriangles =
51 octree_.dataSlots_[slotI].containedTriangles_;
52 label nElmts = containedTriangles.size();
53 boolList mayDeleteData(nElmts, true);
56 const meshOctreeCube& oc = *leaves[leafI];
59 oc.hasContainedElements() &&
60 oc.slotPtr() == &octree_.dataSlots_[slotI]
62 mayDeleteData[oc.containedElements()] = false;
65 for(label i=0;i<nElmts;++i)
66 if( mayDeleteData[i] )
67 containedTriangles.setRowSize(i, 0);
68 containedTriangles.optimizeMemoryUsage();
71 VRWGraph& containedEdges =
72 octree_.dataSlots_[slotI].containedEdges_;
73 nElmts = containedEdges.size();
74 mayDeleteData.setSize(nElmts);
78 const meshOctreeCube& oc = *leaves[leafI];
81 oc.hasContainedEdges() &&
82 oc.slotPtr() == &octree_.dataSlots_[slotI]
84 mayDeleteData[oc.containedEdges()] = false;
87 for(label i=0;i<nElmts;++i)
88 if( mayDeleteData[i] )
89 containedEdges.setRowSize(i, 0);
91 containedEdges.optimizeMemoryUsage();
95 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
97 } // End namespace Foam
99 // ************************************************************************* //