File: SliverRegionHandler.h

package info (click to toggle)
madlib 1.3.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,196 kB
  • sloc: cpp: 39,851; sh: 10,041; makefile: 473
file content (200 lines) | stat: -rw-r--r-- 7,666 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
// -*- C++ -*-
// -------------------------------------------------------------------
// MAdLib - Copyright (C) 2008-2009 Universite catholique de Louvain
//
// See the Copyright.txt and License.txt files for license information. 
// You should have received a copy of these files along with MAdLib. 
// If not, see <http://www.madlib.be/license/>
//
// Please report all bugs and problems to <contrib@madlib.be>
//
// Authors: Gaetan Compere, Jean-Francois Remacle
// -------------------------------------------------------------------

#ifndef _H_SLIVERREGIONHANDLER
#define _H_SLIVERREGIONHANDLER

#include "MAdOperatorBase.h"

#include <set>
#include <iostream>
#include <string>

#define MAKESTATS 1

namespace MAd {

  // -------------------------------------------------------------------
  class sliverRegionHandler {

  public:

    sliverRegionHandler(pMesh, DiscreteSF *);
    ~sliverRegionHandler() {}

  public:

    void removeSliverRegions(int * nbIn=NULL, int * nbOut=NULL);

    void setSizeField(DiscreteSF *);

    // whether we can use operations on boundaries
    void collapseOnBoundary(bool, double);
    void swapOnBoundary(bool, double);

    // whether we can use operations that add nodes
    void newVertexPermission(bool);
    bool getNewVertexPermission() const { return addNodes; }

    void enableReport(std::string);
    void setTestAllOperators(bool);

  private:

    int findOperation(pRegion, pMAdOperator *);
    bool R_isSliver(pRegion);
    bool R_isSliver(pRegion, double *);

    int getSliverType(const pRegion, pEntity[4]);

    void reportSliver(pRegion);

  private:

    pMesh mesh;
    DiscreteSF * sizeField;

    MeshQualityManager& mqm;

    bool collapseOnBdry; // whether or not we can collapse boundary edges
    double dVTolClps;
    bool swapOnBdry; // whether or not we can swap boundary edges
    double dVTolSwap;

    bool addNodes; // whether or not we can use operators that add nodes 
                   // (edge split, face collapse, DESC)

    bool   reportFailures;
    int    reportId;
    std::string reportPrefix;

    bool testOperators;

#ifdef MAKESTATS

  private:

    // statistics:

    int numTypeI_In, numTypeI_Out, numTypeII_In, numTypeII_Out;
    int numSwapTested_I, numSwapAvailable_I, numSwapOperated_I, numSwapToSliver_I;
    int numEClpsTested_I, numEClpsAvailable_I, numEClpsOperated_I, numEClpsToSliver_I;
    int numFClpsTested_I, numFClpsAvailable_I, numFClpsOperated_I, numFClpsToSliver_I;
    int numDESCTested_I, numDESCAvailable_I, numDESCOperated_I, numDESCToSliver_I;
    int numSplitTested_I, numSplitAvailable_I, numSplitOperated_I, numSplitToSliver_I;
    int numVMoveTested_I, numVMoveAvailable_I, numVMoveOperated_I, numVMoveToSliver_I;

    int numSwapTested_II, numSwapAvailable_II, numSwapOperated_II, numSwapToSliver_II;
    int numEClpsTested_II, numEClpsAvailable_II, numEClpsOperated_II, numEClpsToSliver_II;
    int numFSwapTested_II, numFSwapAvailable_II, numFSwapOperated_II, numFSwapToSliver_II;
    int numFClpsTested_II, numFClpsAvailable_II, numFClpsOperated_II, numFClpsToSliver_II;
    int numVMoveTested_II, numVMoveAvailable_II, numVMoveOperated_II, numVMoveToSliver_II;

    // remaining slivers
    std::set<pRegion> sliversOut;

#endif

    // test operators
    std::set<pRegion> sliversIn;
    int tested_I, tested_II, notSolved_I, notSolved_II, solvedWithSliver_I, solvedWithSliver_II;
    int notSolvedDuplicated_I, notSolvedDuplicated_II, solvedWithSliverDuplicated_I, solvedWithSliverDuplicated_II;

    int swapSolves_I,clpsSolves_I,fclpsSolves_I,descSolves_I,splitSolves_I,nodeSolves_I;
    int swapSolvesToSliver_I,clpsSolvesToSliver_I,fclpsSolvesToSliver_I,descSolvesToSliver_I,splitSolvesToSliver_I,nodeSolvesToSliver_I;

    int swapSolves_II, fswapSolves_II, clpsSolves_II, fclpsSolves_II, nodeSolves_II;
    int swapSolvesToSliver_II, fswapSolvesToSliver_II, clpsSolvesToSliver_II, fclpsSolvesToSliver_II, nodeSolvesToSliver_II;

    // remaining slivers
    std::set<pRegion> notSolved;

  public:

    void testOperations(pRegion);

    void printStats(std::ostream&) const;
    void printOperatorsTest(std::ostream&) const;

  };

  // -------------------------------------------------------------------
  inline sliverRegionHandler::sliverRegionHandler(pMesh m, DiscreteSF * sf):
    mesh(m),sizeField(sf), mqm(MeshQualityManagerSgl::instance()), 
    collapseOnBdry(false),dVTolClps(MAdTOL),swapOnBdry(false),dVTolSwap(MAdTOL), 
    addNodes(true), 
    reportFailures(false),reportId(0),reportPrefix(""),testOperators(false)
#ifdef MAKESTATS
    , numTypeI_In(0), numTypeI_Out(0), numTypeII_In(0), numTypeII_Out(0),
    numSwapTested_I(0), numSwapAvailable_I(0), numSwapOperated_I(0), numSwapToSliver_I(0),
    numEClpsTested_I(0), numEClpsAvailable_I(0), numEClpsOperated_I(0), numEClpsToSliver_I(0),
    numFClpsTested_I(0), numFClpsAvailable_I(0), numFClpsOperated_I(0), numFClpsToSliver_I(0),
    numDESCTested_I(0), numDESCAvailable_I(0), numDESCOperated_I(0), numDESCToSliver_I(0),
    numSplitTested_I(0), numSplitAvailable_I(0), numSplitOperated_I(0), numSplitToSliver_I(0),
    numVMoveTested_I(0), numVMoveAvailable_I(0), numVMoveOperated_I(0), numVMoveToSliver_I(0),
    numSwapTested_II(0), numSwapAvailable_II(0), numSwapOperated_II(0), numSwapToSliver_II(0),
    numEClpsTested_II(0), numEClpsAvailable_II(0), numEClpsOperated_II(0), numEClpsToSliver_II(0),
    numFSwapTested_II(0), numFSwapAvailable_II(0), numFSwapOperated_II(0), numFSwapToSliver_II(0),
    numFClpsTested_II(0), numFClpsAvailable_II(0), numFClpsOperated_II(0), numFClpsToSliver_II(0),
    numVMoveTested_II(0), numVMoveAvailable_II(0), numVMoveOperated_II(0), numVMoveToSliver_II(0),
#endif
    tested_I(0), tested_II(0), notSolved_I(0), notSolved_II(0), solvedWithSliver_I(0), solvedWithSliver_II(0), 
    notSolvedDuplicated_I(0), notSolvedDuplicated_II(0), solvedWithSliverDuplicated_I(0), solvedWithSliverDuplicated_II(0),
    swapSolves_I(0),clpsSolves_I(0),fclpsSolves_I(0),descSolves_I(0),splitSolves_I(0),nodeSolves_I(0), swapSolvesToSliver_I(0),clpsSolvesToSliver_I(0),fclpsSolvesToSliver_I(0),descSolvesToSliver_I(0),splitSolvesToSliver_I(0),nodeSolvesToSliver_I(0), 
    swapSolves_II(0), fswapSolves_II(0), clpsSolves_II(0), fclpsSolves_II(0), nodeSolves_II(0), swapSolvesToSliver_II(0), fswapSolvesToSliver_II(0), clpsSolvesToSliver_II(0), fclpsSolvesToSliver_II(0), nodeSolvesToSliver_II(0)
  {}

  // -------------------------------------------------------------------
  inline void sliverRegionHandler::setSizeField(DiscreteSF * sf)
  {
    sizeField = sf;
  }

  // -------------------------------------------------------------------
  inline void sliverRegionHandler::collapseOnBoundary(bool cob, double tolerance)
  {
    collapseOnBdry = cob;
    dVTolClps = tolerance;
  }

  // -------------------------------------------------------------------
  inline void sliverRegionHandler::swapOnBoundary(bool sob, double tolerance)
  {
    swapOnBdry = sob;
    dVTolSwap = tolerance;
  }

  // -------------------------------------------------------------------
  inline void sliverRegionHandler::newVertexPermission(bool allow)
  {
    addNodes = allow;
  }

  // -------------------------------------------------------------------
  inline void sliverRegionHandler::enableReport(std::string prefix)
  {
    reportFailures = true; 
    reportPrefix   = prefix;
  }

  // -------------------------------------------------------------------
  inline void sliverRegionHandler::setTestAllOperators(bool test)
  {
    testOperators = test;
  }

  // -------------------------------------------------------------------

}

#endif