0021364: EDF NETGENPLUGIN: Dump of netgen parameters has duplicate lines

dump parameters setting only of if needed, i.e. if a param is set for the
  1st time or is changed
This commit is contained in:
eap 2011-09-23 13:01:12 +00:00
parent 0e4677714e
commit 6968bbae2a
4 changed files with 115 additions and 68 deletions

View File

@ -25,7 +25,6 @@
// Author : Michael Sazonov (OCN) // Author : Michael Sazonov (OCN)
// Date : 03/04/2006 // Date : 03/04/2006
// Project : SALOME // Project : SALOME
// $Header$
//============================================================================= //=============================================================================
// //
#include "NETGENPlugin_Hypothesis_2D_i.hxx" #include "NETGENPlugin_Hypothesis_2D_i.hxx"
@ -81,10 +80,13 @@ NETGENPlugin_Hypothesis_2D_i::~NETGENPlugin_Hypothesis_2D_i()
//============================================================================= //=============================================================================
void NETGENPlugin_Hypothesis_2D_i::SetQuadAllowed (CORBA::Boolean theValue) void NETGENPlugin_Hypothesis_2D_i::SetQuadAllowed (CORBA::Boolean theValue)
{ {
MESSAGE("NETGENPlugin_Hypothesis_2D_i::SetQuadAllowed"); if ( NETGENPlugin_Hypothesis_i::isToSetParameter( GetQuadAllowed(),
ASSERT(myBaseImpl); theValue,
this->GetImpl()->SetQuadAllowed(theValue); METH_SetQuadAllowed ))
SMESH::TPythonDump() << _this() << ".SetQuadAllowed( " << theValue << " )"; {
this->GetImpl()->SetQuadAllowed(theValue);
SMESH::TPythonDump() << _this() << ".SetQuadAllowed( " << theValue << " )";
}
} }
//============================================================================= //=============================================================================
@ -96,8 +98,6 @@ void NETGENPlugin_Hypothesis_2D_i::SetQuadAllowed (CORBA::Boolean theValue)
//============================================================================= //=============================================================================
CORBA::Boolean NETGENPlugin_Hypothesis_2D_i::GetQuadAllowed() CORBA::Boolean NETGENPlugin_Hypothesis_2D_i::GetQuadAllowed()
{ {
MESSAGE("NETGENPlugin_Hypothesis_2D_i::GetQuadAllowed");
ASSERT(myBaseImpl);
return this->GetImpl()->GetQuadAllowed(); return this->GetImpl()->GetQuadAllowed();
} }
@ -110,7 +110,6 @@ CORBA::Boolean NETGENPlugin_Hypothesis_2D_i::GetQuadAllowed()
//============================================================================= //=============================================================================
::NETGENPlugin_Hypothesis_2D* NETGENPlugin_Hypothesis_2D_i::GetImpl() ::NETGENPlugin_Hypothesis_2D* NETGENPlugin_Hypothesis_2D_i::GetImpl()
{ {
MESSAGE("NETGENPlugin_Hypothesis_2D_i::GetImpl");
return (::NETGENPlugin_Hypothesis_2D*)myBaseImpl; return (::NETGENPlugin_Hypothesis_2D*)myBaseImpl;
} }

View File

@ -25,7 +25,6 @@
// Author : Michael Sazonov (OCN) // Author : Michael Sazonov (OCN)
// Date : 03/04/2006 // Date : 03/04/2006
// Project : SALOME // Project : SALOME
// $Header$
//============================================================================= //=============================================================================
// //
#ifndef _NETGENPlugin_Hypothesis_2D_i_HXX_ #ifndef _NETGENPlugin_Hypothesis_2D_i_HXX_
@ -63,6 +62,15 @@ class NETGENPLUGIN_EXPORT NETGENPlugin_Hypothesis_2D_i:
// Verify whether hypothesis supports given entity type // Verify whether hypothesis supports given entity type
CORBA::Boolean IsDimSupported( SMESH::Dimension type ); CORBA::Boolean IsDimSupported( SMESH::Dimension type );
protected:
// to remember whether a parameter is already set (issue 0021364)
enum SettingMethod
{
METH_SetQuadAllowed = NETGENPlugin_Hypothesis_i::METH_LAST * 2,
METH_LAST = METH_SetQuadAllowed
};
}; };
#endif #endif

View File

@ -25,7 +25,6 @@
// Author : Michael Sazonov (OCN) // Author : Michael Sazonov (OCN)
// Date : 03/04/2006 // Date : 03/04/2006
// Project : SALOME // Project : SALOME
// $Header$
//============================================================================= //=============================================================================
// //
#include "NETGENPlugin_Hypothesis_i.hxx" #include "NETGENPlugin_Hypothesis_i.hxx"
@ -38,6 +37,20 @@
using namespace std; using namespace std;
//=============================================================================
/*!
* Specialization of isToSetParameter<T> for double
*/
//=============================================================================
template<>
bool NETGENPlugin_Hypothesis_i::isToSetParameter<double>(double curValue,
double newValue,
/*SettingMethod*/int meth)
{
return isToSetParameter(true, (fabs(curValue - newValue) < 1e-20), meth);
}
//============================================================================= //=============================================================================
/*! /*!
* NETGENPlugin_Hypothesis_i::NETGENPlugin_Hypothesis_i * NETGENPlugin_Hypothesis_i::NETGENPlugin_Hypothesis_i
@ -50,7 +63,8 @@ NETGENPlugin_Hypothesis_i (PortableServer::POA_ptr thePOA,
int theStudyId, int theStudyId,
::SMESH_Gen* theGenImpl) ::SMESH_Gen* theGenImpl)
: SALOME::GenericObj_i( thePOA ), : SALOME::GenericObj_i( thePOA ),
SMESH_Hypothesis_i( thePOA ) SMESH_Hypothesis_i( thePOA ),
mySetMethodFlags(0)
{ {
MESSAGE( "NETGENPlugin_Hypothesis_i::NETGENPlugin_Hypothesis_i" ); MESSAGE( "NETGENPlugin_Hypothesis_i::NETGENPlugin_Hypothesis_i" );
myBaseImpl = new ::NETGENPlugin_Hypothesis (theGenImpl->GetANewId(), myBaseImpl = new ::NETGENPlugin_Hypothesis (theGenImpl->GetANewId(),
@ -79,10 +93,11 @@ NETGENPlugin_Hypothesis_i::~NETGENPlugin_Hypothesis_i()
//============================================================================= //=============================================================================
void NETGENPlugin_Hypothesis_i::SetMaxSize (CORBA::Double theValue) void NETGENPlugin_Hypothesis_i::SetMaxSize (CORBA::Double theValue)
{ {
MESSAGE("NETGENPlugin_Hypothesis_i::SetMaxSize"); if ( isToSetParameter( GetMaxSize(), theValue, METH_SetMaxSize ))
ASSERT(myBaseImpl); {
this->GetImpl()->SetMaxSize(theValue); this->GetImpl()->SetMaxSize(theValue);
SMESH::TPythonDump() << _this() << ".SetMaxSize( " << theValue << " )"; SMESH::TPythonDump() << _this() << ".SetMaxSize( " << theValue << " )";
}
} }
//============================================================================= //=============================================================================
@ -94,8 +109,6 @@ void NETGENPlugin_Hypothesis_i::SetMaxSize (CORBA::Double theValue)
//============================================================================= //=============================================================================
CORBA::Double NETGENPlugin_Hypothesis_i::GetMaxSize() CORBA::Double NETGENPlugin_Hypothesis_i::GetMaxSize()
{ {
MESSAGE("NETGENPlugin_Hypothesis_i::GetMaxSize");
ASSERT(myBaseImpl);
return this->GetImpl()->GetMaxSize(); return this->GetImpl()->GetMaxSize();
} }
@ -108,10 +121,11 @@ CORBA::Double NETGENPlugin_Hypothesis_i::GetMaxSize()
//============================================================================= //=============================================================================
void NETGENPlugin_Hypothesis_i::SetMinSize (CORBA::Double theValue) void NETGENPlugin_Hypothesis_i::SetMinSize (CORBA::Double theValue)
{ {
MESSAGE("NETGENPlugin_Hypothesis_i::SetMinSize"); if ( isToSetParameter( GetMinSize(), theValue, METH_SetMinSize ))
ASSERT(myBaseImpl); {
this->GetImpl()->SetMinSize(theValue); this->GetImpl()->SetMinSize(theValue);
SMESH::TPythonDump() << _this() << ".SetMinSize( " << theValue << " )"; SMESH::TPythonDump() << _this() << ".SetMinSize( " << theValue << " )";
}
} }
//============================================================================= //=============================================================================
@ -123,8 +137,6 @@ void NETGENPlugin_Hypothesis_i::SetMinSize (CORBA::Double theValue)
//============================================================================= //=============================================================================
CORBA::Double NETGENPlugin_Hypothesis_i::GetMinSize() CORBA::Double NETGENPlugin_Hypothesis_i::GetMinSize()
{ {
MESSAGE("NETGENPlugin_Hypothesis_i::GetMinSize");
ASSERT(myBaseImpl);
return this->GetImpl()->GetMinSize(); return this->GetImpl()->GetMinSize();
} }
@ -137,10 +149,11 @@ CORBA::Double NETGENPlugin_Hypothesis_i::GetMinSize()
//============================================================================= //=============================================================================
void NETGENPlugin_Hypothesis_i::SetSecondOrder (CORBA::Boolean theValue) void NETGENPlugin_Hypothesis_i::SetSecondOrder (CORBA::Boolean theValue)
{ {
MESSAGE("NETGENPlugin_Hypothesis_i::SetSecondOrder"); if ( isToSetParameter( GetSecondOrder(), theValue, METH_SetSecondOrder ))
ASSERT(myBaseImpl); {
this->GetImpl()->SetSecondOrder(theValue); this->GetImpl()->SetSecondOrder(theValue);
SMESH::TPythonDump() << _this() << ".SetSecondOrder( " << theValue << " )"; SMESH::TPythonDump() << _this() << ".SetSecondOrder( " << theValue << " )";
}
} }
//============================================================================= //=============================================================================
@ -152,8 +165,6 @@ void NETGENPlugin_Hypothesis_i::SetSecondOrder (CORBA::Boolean theValue)
//============================================================================= //=============================================================================
CORBA::Boolean NETGENPlugin_Hypothesis_i::GetSecondOrder() CORBA::Boolean NETGENPlugin_Hypothesis_i::GetSecondOrder()
{ {
MESSAGE("NETGENPlugin_Hypothesis_i::GetSecondOrder");
ASSERT(myBaseImpl);
return this->GetImpl()->GetSecondOrder(); return this->GetImpl()->GetSecondOrder();
} }
@ -166,10 +177,11 @@ CORBA::Boolean NETGENPlugin_Hypothesis_i::GetSecondOrder()
//============================================================================= //=============================================================================
void NETGENPlugin_Hypothesis_i::SetOptimize (CORBA::Boolean theValue) void NETGENPlugin_Hypothesis_i::SetOptimize (CORBA::Boolean theValue)
{ {
MESSAGE("NETGENPlugin_Hypothesis_i::SetOptimize"); if ( isToSetParameter( GetOptimize(), theValue, METH_SetOptimize ))
ASSERT(myBaseImpl); {
this->GetImpl()->SetOptimize(theValue); this->GetImpl()->SetOptimize(theValue);
SMESH::TPythonDump() << _this() << ".SetOptimize( " << theValue << " )"; SMESH::TPythonDump() << _this() << ".SetOptimize( " << theValue << " )";
}
} }
//============================================================================= //=============================================================================
@ -181,8 +193,6 @@ void NETGENPlugin_Hypothesis_i::SetOptimize (CORBA::Boolean theValue)
//============================================================================= //=============================================================================
CORBA::Boolean NETGENPlugin_Hypothesis_i::GetOptimize() CORBA::Boolean NETGENPlugin_Hypothesis_i::GetOptimize()
{ {
MESSAGE("NETGENPlugin_Hypothesis_i::GetOptimize");
ASSERT(myBaseImpl);
return this->GetImpl()->GetOptimize(); return this->GetImpl()->GetOptimize();
} }
@ -195,10 +205,11 @@ CORBA::Boolean NETGENPlugin_Hypothesis_i::GetOptimize()
//============================================================================= //=============================================================================
void NETGENPlugin_Hypothesis_i::SetFineness (CORBA::Long theValue) void NETGENPlugin_Hypothesis_i::SetFineness (CORBA::Long theValue)
{ {
MESSAGE("NETGENPlugin_Hypothesis_i::SetFineness"); if ( isToSetParameter( GetFineness(), theValue, METH_SetFineness ))
ASSERT(myBaseImpl); {
this->GetImpl()->SetFineness((::NETGENPlugin_Hypothesis::Fineness)theValue); this->GetImpl()->SetFineness((::NETGENPlugin_Hypothesis::Fineness)theValue);
SMESH::TPythonDump() << _this() << ".SetFineness( " << theValue << " )"; SMESH::TPythonDump() << _this() << ".SetFineness( " << theValue << " )";
}
} }
//============================================================================= //=============================================================================
@ -210,8 +221,6 @@ void NETGENPlugin_Hypothesis_i::SetFineness (CORBA::Long theValue)
//============================================================================= //=============================================================================
CORBA::Long NETGENPlugin_Hypothesis_i::GetFineness() CORBA::Long NETGENPlugin_Hypothesis_i::GetFineness()
{ {
MESSAGE("NETGENPlugin_Hypothesis_i::GetFineness");
ASSERT(myBaseImpl);
return this->GetImpl()->GetFineness(); return this->GetImpl()->GetFineness();
} }
@ -224,10 +233,11 @@ CORBA::Long NETGENPlugin_Hypothesis_i::GetFineness()
//============================================================================= //=============================================================================
void NETGENPlugin_Hypothesis_i::SetGrowthRate (CORBA::Double theValue) void NETGENPlugin_Hypothesis_i::SetGrowthRate (CORBA::Double theValue)
{ {
MESSAGE("NETGENPlugin_Hypothesis_i::SetGrowthRate"); if ( isToSetParameter( GetGrowthRate(), theValue, METH_SetGrowthRate ))
ASSERT(myBaseImpl); {
this->GetImpl()->SetGrowthRate(theValue); this->GetImpl()->SetGrowthRate(theValue);
SMESH::TPythonDump() << _this() << ".SetGrowthRate( " << theValue << " )"; SMESH::TPythonDump() << _this() << ".SetGrowthRate( " << theValue << " )";
}
} }
//============================================================================= //=============================================================================
@ -239,8 +249,6 @@ void NETGENPlugin_Hypothesis_i::SetGrowthRate (CORBA::Double theValue)
//============================================================================= //=============================================================================
CORBA::Double NETGENPlugin_Hypothesis_i::GetGrowthRate() CORBA::Double NETGENPlugin_Hypothesis_i::GetGrowthRate()
{ {
MESSAGE("NETGENPlugin_Hypothesis_i::GetGrowthRate");
ASSERT(myBaseImpl);
return this->GetImpl()->GetGrowthRate(); return this->GetImpl()->GetGrowthRate();
} }
@ -253,10 +261,11 @@ CORBA::Double NETGENPlugin_Hypothesis_i::GetGrowthRate()
//============================================================================= //=============================================================================
void NETGENPlugin_Hypothesis_i::SetNbSegPerEdge (CORBA::Double theValue) void NETGENPlugin_Hypothesis_i::SetNbSegPerEdge (CORBA::Double theValue)
{ {
MESSAGE("NETGENPlugin_Hypothesis_i::SetNbSegPerEdge"); if ( isToSetParameter( GetNbSegPerEdge(), theValue, METH_SetNbSegPerEdge ))
ASSERT(myBaseImpl); {
this->GetImpl()->SetNbSegPerEdge(theValue); this->GetImpl()->SetNbSegPerEdge(theValue);
SMESH::TPythonDump() << _this() << ".SetNbSegPerEdge( " << theValue << " )"; SMESH::TPythonDump() << _this() << ".SetNbSegPerEdge( " << theValue << " )";
}
} }
//============================================================================= //=============================================================================
@ -268,8 +277,6 @@ void NETGENPlugin_Hypothesis_i::SetNbSegPerEdge (CORBA::Double theValue)
//============================================================================= //=============================================================================
CORBA::Double NETGENPlugin_Hypothesis_i::GetNbSegPerEdge() CORBA::Double NETGENPlugin_Hypothesis_i::GetNbSegPerEdge()
{ {
MESSAGE("NETGENPlugin_Hypothesis_i::GetNbSegPerEdge");
ASSERT(myBaseImpl);
return this->GetImpl()->GetNbSegPerEdge(); return this->GetImpl()->GetNbSegPerEdge();
} }
@ -282,10 +289,11 @@ CORBA::Double NETGENPlugin_Hypothesis_i::GetNbSegPerEdge()
//============================================================================= //=============================================================================
void NETGENPlugin_Hypothesis_i::SetNbSegPerRadius (CORBA::Double theValue) void NETGENPlugin_Hypothesis_i::SetNbSegPerRadius (CORBA::Double theValue)
{ {
MESSAGE("NETGENPlugin_Hypothesis_i::SetNbSegPerRadius"); if ( isToSetParameter( GetNbSegPerRadius(), theValue, METH_SetNbSegPerRadius ))
ASSERT(myBaseImpl); {
this->GetImpl()->SetNbSegPerRadius(theValue); this->GetImpl()->SetNbSegPerRadius(theValue);
SMESH::TPythonDump() << _this() << ".SetNbSegPerRadius( " << theValue << " )"; SMESH::TPythonDump() << _this() << ".SetNbSegPerRadius( " << theValue << " )";
}
} }
//============================================================================= //=============================================================================
@ -297,14 +305,13 @@ void NETGENPlugin_Hypothesis_i::SetNbSegPerRadius (CORBA::Double theValue)
//============================================================================= //=============================================================================
CORBA::Double NETGENPlugin_Hypothesis_i::GetNbSegPerRadius() CORBA::Double NETGENPlugin_Hypothesis_i::GetNbSegPerRadius()
{ {
MESSAGE("NETGENPlugin_Hypothesis_i::GetNbSegPerRadius");
ASSERT(myBaseImpl);
return this->GetImpl()->GetNbSegPerRadius(); return this->GetImpl()->GetNbSegPerRadius();
} }
//============================================================================= //=============================================================================
void NETGENPlugin_Hypothesis_i::SetLocalSizeOnShape(GEOM::GEOM_Object_ptr GeomObj, CORBA::Double localSize) void NETGENPlugin_Hypothesis_i::SetLocalSizeOnShape(GEOM::GEOM_Object_ptr GeomObj,
CORBA::Double localSize)
{ {
string entry; string entry;
entry = GeomObj->GetStudyEntry(); entry = GeomObj->GetStudyEntry();
@ -313,14 +320,15 @@ void NETGENPlugin_Hypothesis_i::SetLocalSizeOnShape(GEOM::GEOM_Object_ptr GeomOb
//============================================================================= //=============================================================================
void NETGENPlugin_Hypothesis_i::SetLocalSizeOnEntry(const char* entry, CORBA::Double localSize) void NETGENPlugin_Hypothesis_i::SetLocalSizeOnEntry(const char* entry,
CORBA::Double localSize)
{ {
bool valueChanged = false; if ( isToSetParameter( GetLocalSizeOnEntry(entry), localSize, METH_SetLocalSizeOnEntry ))
valueChanged = ( this->GetImpl()->GetLocalSizeOnEntry(entry) != localSize ); {
if ( valueChanged )
this->GetImpl()->SetLocalSizeOnEntry(entry, localSize); this->GetImpl()->SetLocalSizeOnEntry(entry, localSize);
if ( valueChanged ) SMESH::TPythonDump()
SMESH::TPythonDump() << _this() << ".SetLocalSizeOnShape(" << entry << ", " << localSize << ")"; << _this() << ".SetLocalSizeOnShape(" << entry << ", " << localSize << ")";
}
} }
//============================================================================= //=============================================================================
@ -335,7 +343,8 @@ CORBA::Double NETGENPlugin_Hypothesis_i::GetLocalSizeOnEntry(const char* entry)
NETGENPlugin::string_array* NETGENPlugin_Hypothesis_i::GetLocalSizeEntries() NETGENPlugin::string_array* NETGENPlugin_Hypothesis_i::GetLocalSizeEntries()
{ {
NETGENPlugin::string_array_var result = new NETGENPlugin::string_array(); NETGENPlugin::string_array_var result = new NETGENPlugin::string_array();
const ::NETGENPlugin_Hypothesis::TLocalSize localSizes = this->GetImpl()->GetLocalSizesAndEntries(); const ::NETGENPlugin_Hypothesis::TLocalSize localSizes =
this->GetImpl()->GetLocalSizesAndEntries();
result->length(localSizes.size()); result->length(localSizes.size());
::NETGENPlugin_Hypothesis::TLocalSize::const_iterator it = localSizes.begin(); ::NETGENPlugin_Hypothesis::TLocalSize::const_iterator it = localSizes.begin();
for (int i=0 ; it != localSizes.end() ; i++, it++) for (int i=0 ; it != localSizes.end() ; i++, it++)
@ -363,7 +372,6 @@ void NETGENPlugin_Hypothesis_i::UnsetLocalSizeOnEntry(const char* entry)
//============================================================================= //=============================================================================
::NETGENPlugin_Hypothesis* NETGENPlugin_Hypothesis_i::GetImpl() ::NETGENPlugin_Hypothesis* NETGENPlugin_Hypothesis_i::GetImpl()
{ {
MESSAGE("NETGENPlugin_Hypothesis_i::GetImpl");
return (::NETGENPlugin_Hypothesis*)myBaseImpl; return (::NETGENPlugin_Hypothesis*)myBaseImpl;
} }

View File

@ -90,6 +90,38 @@ class NETGENPLUGIN_EXPORT NETGENPlugin_Hypothesis_i:
// Verify whether hypothesis supports given entity type // Verify whether hypothesis supports given entity type
CORBA::Boolean IsDimSupported( SMESH::Dimension type ); CORBA::Boolean IsDimSupported( SMESH::Dimension type );
protected:
// to remember whether a parameter is already set (issue 0021364)
enum SettingMethod
{
METH_SetMaxSize = 1,
METH_SetMinSize = 2,
METH_SetSecondOrder = 4,
METH_SetOptimize = 8,
METH_SetFineness = 16,
METH_SetGrowthRate = 32,
METH_SetNbSegPerEdge = 64,
METH_SetNbSegPerRadius = 128,
METH_SetLocalSizeOnEntry = 256,
METH_LAST = METH_SetLocalSizeOnEntry
};
int mySetMethodFlags;
// Return true if a parameter is not yet set, else return true if a parameter changes.
// PythonDumping depends on the result of this function.
// Checking only change of a parameter is not enough because then the default values are
// not dumped and if the defaults will change then the behaviour of scripts
// created without dump of the default parameters will also change what is not good.
template<typename T>
bool isToSetParameter(T curValue, T newValue, /*SettingMethod*/int meth)
{
if ( mySetMethodFlags & meth ) // already set, check if a value is changing
return ( curValue != newValue );
else
return ( mySetMethodFlags |= meth ); // == return true
}
}; };
#endif #endif