some inline function, logs on file (precompiler directive)
This commit is contained in:
parent
1a66972c51
commit
4d02036998
|
@ -22,6 +22,9 @@
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
$Log: not supported by cvs2svn $
|
$Log: not supported by cvs2svn $
|
||||||
|
Revision 1.7 2004/09/29 17:08:39 ganovelli
|
||||||
|
changed > to < in heapelem comparison
|
||||||
|
|
||||||
Revision 1.6 2004/09/28 09:57:08 cignoni
|
Revision 1.6 2004/09/28 09:57:08 cignoni
|
||||||
Better Doxygen docs
|
Better Doxygen docs
|
||||||
|
|
||||||
|
@ -70,7 +73,7 @@ class LocalModification
|
||||||
typedef typename MeshType::ScalarType ScalarType;
|
typedef typename MeshType::ScalarType ScalarType;
|
||||||
|
|
||||||
|
|
||||||
LocalModification(){};
|
inline LocalModification(){};
|
||||||
virtual ~LocalModification(){};
|
virtual ~LocalModification(){};
|
||||||
|
|
||||||
/// return the type of operation
|
/// return the type of operation
|
||||||
|
@ -141,14 +144,15 @@ public:
|
||||||
nTargetSimplices,
|
nTargetSimplices,
|
||||||
nTargetVertices;
|
nTargetVertices;
|
||||||
|
|
||||||
float timeBudget,
|
int timeBudget,
|
||||||
start,
|
start;
|
||||||
|
float
|
||||||
currMetric,
|
currMetric,
|
||||||
targetMetric;
|
targetMetric;
|
||||||
|
|
||||||
void SetTerminationFlag (int v){tf |= v;}
|
void SetTerminationFlag (int v){tf |= v;}
|
||||||
void ClearTerminationFlag (int v){tf &= ~v;}
|
void ClearTerminationFlag (int v){tf &= ~v;}
|
||||||
bool IsTerminationFlag (int v){return (tf & v);}
|
bool IsTerminationFlag (int v){return ((tf & v)!=0);}
|
||||||
|
|
||||||
void SetTargetSimplices (int ts ){nTargetSimplices = ts; SetTerminationFlag(LOnSimplices); }
|
void SetTargetSimplices (int ts ){nTargetSimplices = ts; SetTerminationFlag(LOnSimplices); }
|
||||||
void SetTargetVertices (int tv ){nTargetVertices = tv; SetTerminationFlag(LOnVertices); }
|
void SetTargetVertices (int tv ){nTargetVertices = tv; SetTerminationFlag(LOnVertices); }
|
||||||
|
@ -181,14 +185,14 @@ public:
|
||||||
|
|
||||||
struct HeapElem
|
struct HeapElem
|
||||||
{
|
{
|
||||||
HeapElem(){locModPtr = NULL;}
|
inline HeapElem(){locModPtr = NULL;}
|
||||||
~HeapElem(){}
|
~HeapElem(){}
|
||||||
|
|
||||||
///pointer to instance of local modifier
|
///pointer to instance of local modifier
|
||||||
LocModPtrType locModPtr;
|
LocModPtrType locModPtr;
|
||||||
|
|
||||||
|
|
||||||
HeapElem( LocModPtrType _locModPtr)
|
inline HeapElem( LocModPtrType _locModPtr)
|
||||||
{
|
{
|
||||||
locModPtr = _locModPtr;
|
locModPtr = _locModPtr;
|
||||||
};
|
};
|
||||||
|
@ -208,8 +212,6 @@ public:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Default Constructor
|
|
||||||
LocalOptimization(MeshType *_m):m(_m){};
|
|
||||||
/// Default distructor
|
/// Default distructor
|
||||||
~LocalOptimization(){};
|
~LocalOptimization(){};
|
||||||
|
|
||||||
|
@ -220,8 +222,9 @@ public:
|
||||||
{
|
{
|
||||||
start=clock();
|
start=clock();
|
||||||
nPerfmormedOps =0;
|
nPerfmormedOps =0;
|
||||||
|
#ifdef __SAVE__LOG__
|
||||||
FILE * fo=fopen("log.txt","w");
|
FILE * fo=fopen("log.txt","w");
|
||||||
|
#endif __SAVE__LOG__
|
||||||
while( !GoalReached() && !h.empty())
|
while( !GoalReached() && !h.empty())
|
||||||
{
|
{
|
||||||
std::pop_heap(h.begin(),h.end());
|
std::pop_heap(h.begin(),h.end());
|
||||||
|
@ -234,10 +237,10 @@ public:
|
||||||
// check if it is feasible
|
// check if it is feasible
|
||||||
if (locMod->IsFeasible())
|
if (locMod->IsFeasible())
|
||||||
{
|
{
|
||||||
//assert(e>locMod->Priority());
|
#ifdef __SAVE__LOG__
|
||||||
//e = locMod->Priority();
|
fprintf(fo,"%s",locMod->Info(m));
|
||||||
fprintf(fo,"%.22f\n",locMod->Priority());
|
#endif __SAVE__LOG__
|
||||||
// printf("ops: %d heap: %d \n",nPerfmormedOps,h.size());
|
|
||||||
nPerfmormedOps++;
|
nPerfmormedOps++;
|
||||||
locMod->Execute(m);
|
locMod->Execute(m);
|
||||||
locMod->UpdateHeap(h);
|
locMod->UpdateHeap(h);
|
||||||
|
@ -246,7 +249,9 @@ public:
|
||||||
//else printf("popped out unfeasible\n");
|
//else printf("popped out unfeasible\n");
|
||||||
delete locMod;
|
delete locMod;
|
||||||
}
|
}
|
||||||
|
#ifdef __SAVE__LOG__
|
||||||
fclose(fo);
|
fclose(fo);
|
||||||
|
#endif __SAVE__LOG__
|
||||||
return !(h.empty());
|
return !(h.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -272,8 +277,8 @@ public:
|
||||||
assert ( ( ( tf & LOMetric )==0) || ( targetMetric != -1));
|
assert ( ( ( tf & LOMetric )==0) || ( targetMetric != -1));
|
||||||
assert ( ( ( tf & LOTime )==0) || ( timeBudget != -1));
|
assert ( ( ( tf & LOTime )==0) || ( timeBudget != -1));
|
||||||
|
|
||||||
if ( IsTerminationFlag(LOnSimplices) && ( m.SimplexNumber()< nTargetSimplices)) return true;
|
if ( IsTerminationFlag(LOnSimplices) && ( m.SimplexNumber()<= nTargetSimplices)) return true;
|
||||||
if ( IsTerminationFlag(LOnVertices) && ( m.VertexNumber() < nTargetVertices)) return true;
|
if ( IsTerminationFlag(LOnVertices) && ( m.VertexNumber() <= nTargetVertices)) return true;
|
||||||
if ( IsTerminationFlag(LOnOps) && (nPerfmormedOps == nTargetOps)) return true;
|
if ( IsTerminationFlag(LOnOps) && (nPerfmormedOps == nTargetOps)) return true;
|
||||||
if ( IsTerminationFlag(LOMetric) && ( currMetric > targetMetric)) return true;
|
if ( IsTerminationFlag(LOMetric) && ( currMetric > targetMetric)) return true;
|
||||||
if ( IsTerminationFlag(LOTime) && ( (clock()-start)/(float)CLOCKS_PER_SEC > timeBudget)) return true;
|
if ( IsTerminationFlag(LOTime) && ( (clock()-start)/(float)CLOCKS_PER_SEC > timeBudget)) return true;
|
||||||
|
|
Loading…
Reference in New Issue