_ngMesh(NULL),
_occgeom(NULL),
_curShapeIndex(-1),
+ _progressTic(1),
+ _totalTime(1.0),
_simpleHyp(NULL),
_ptrToMe(NULL)
{
str << ": " << ex.What();
return str;
}
+
+ const double edgeMeshingTime = 0.001;
+ const double faceMeshingTime = 0.019;
+ const double edgeFaceMeshingTime = edgeMeshingTime + faceMeshingTime;
+ const double faceOptimizTime = 0.06;
+ const double voluMeshingTime = 0.15;
+ const double volOptimizeTime = 0.77;
}
//=============================================================================
NETGENPlugin_Internals internals( *_mesh, _shape, _isVolume );
PrepareOCCgeometry( occgeo, _shape, *_mesh, meshedSM, &internals );
_occgeom = &occgeo;
+
+ _totalTime = edgeFaceMeshingTime;
+ if ( _optimize )
+ _totalTime += faceOptimizTime;
+ if ( _isVolume )
+ _totalTime += voluMeshingTime + ( _optimize ? volOptimizeTime : 0 );
+ double doneTime = 0;
+ _ticTime = -1;
+ _progressTic = 1;
_curShapeIndex = -1;
// -------------------------
err = 1;
}
}
+ if ( _isVolume )
+ _ticTime = ( doneTime += edgeMeshingTime ) / _totalTime / _progressTic;
+
mparams.uselocalh = true; // restore as it is used at surface optimization
// ---------------------
//err = 1; -- try to make volumes anyway
}
}
+ if ( _isVolume )
+ {
+ doneTime += faceMeshingTime + ( _optimize ? faceOptimizTime : 0 );
+ _ticTime = doneTime / _totalTime / _progressTic;
+ }
// ---------------------
// generate volume mesh
// ---------------------
comment << text(exc);
err = 1;
}
+ _ticTime = ( doneTime += voluMeshingTime ) / _totalTime / _progressTic;
+
// Let netgen optimize 3D mesh
if ( !err && _optimize )
{
}
}
}
+
+ _ticTime = 0.98 / _progressTic;
+
int nbNod = _ngMesh->GetNP();
int nbSeg = _ngMesh->GetNSeg();
int nbFac = _ngMesh->GetNSE();
}
double NETGENPlugin_Mesher::GetProgress(const SMESH_Algo* holder,
- const int * algoProgressTic ) const
+ const int * algoProgressTic,
+ const double * algoProgress) const
{
- double progress = holder->GetProgressByTic();
+ ((int&) _progressTic ) = *algoProgressTic + 1;
- if ( _ngMesh && _occgeom )
- if ( _isVolume )
+ double progress = -1;
+ if ( !_isVolume )
+ {
+ if ( _ticTime < 0 && netgen::multithread.task[0] == 'O'/*Optimizing surface*/ )
{
- if ( _occgeom->somap.Extent() > 1 )
- {
- int curShapeIndex = 0;
- if ( _ngMesh->GetNE() > 0 )
- {
- netgen::Element el = (*_ngMesh)[netgen::ElementIndex( _ngMesh->GetNE()-1 )];
- curShapeIndex = el.GetIndex();
- }
- if ( curShapeIndex != _curShapeIndex )
- {
- ((int&) * algoProgressTic ) = 1;
- ((int&) _curShapeIndex ) = curShapeIndex;
- }
- double progressPerShape = 1./ ( _occgeom->somap.Extent() + 1 );
- progress = progressPerShape * ( _curShapeIndex + holder->GetProgressByTic() );
- }
+ ((double&) _ticTime ) = edgeFaceMeshingTime / _totalTime / _progressTic;
}
- else
+ else if ( !_optimize /*&& _occgeom->fmap.Extent() > 1*/ )
{
- if ( _occgeom->fmap.Extent() > 1 )
+ int doneShapeIndex = -1;
+ while ( doneShapeIndex+1 < _occgeom->facemeshstatus.Size() &&
+ _occgeom->facemeshstatus[ doneShapeIndex+1 ])
+ doneShapeIndex++;
+ if ( doneShapeIndex+1 != _curShapeIndex )
{
- int doneShapeIndex = -1;
- while ( doneShapeIndex+1 < _occgeom->facemeshstatus.Size() &&
- _occgeom->facemeshstatus[ doneShapeIndex+1 ])
- doneShapeIndex++;
- if ( doneShapeIndex+1 != _curShapeIndex )
- {
- ((int&) * algoProgressTic ) = 1;
- ((int&) _curShapeIndex ) = doneShapeIndex+1;
- }
- double progressPerShape = 1./ ( _occgeom->fmap.Extent() + 1 );
- progress = progressPerShape * ( _curShapeIndex + holder->GetProgressByTic() );
+ ((int&) _curShapeIndex) = doneShapeIndex+1;
+ double doneShapeRate = _curShapeIndex / double( _occgeom->fmap.Extent() );
+ double doneTime = edgeMeshingTime + doneShapeRate * faceMeshingTime;
+ ((double&) _ticTime) = doneTime / _totalTime / _progressTic;
+ // cout << "shape " << _curShapeIndex << " _ticTime " << _ticTime
+ // << " " << doneTime / _totalTime / _progressTic << endl;
}
}
- return Min( progress, 0.98 );
+ }
+ else if ( !_optimize && _occgeom->somap.Extent() > 1 )
+ {
+ int curShapeIndex = _curShapeIndex;
+ if ( _ngMesh->GetNE() > 0 )
+ {
+ netgen::Element el = (*_ngMesh)[netgen::ElementIndex( _ngMesh->GetNE()-1 )];
+ curShapeIndex = el.GetIndex();
+ }
+ if ( curShapeIndex != _curShapeIndex )
+ {
+ ((int&) _curShapeIndex) = curShapeIndex;
+ double doneShapeRate = _curShapeIndex / double( _occgeom->somap.Extent() );
+ double doneTime = edgeFaceMeshingTime + doneShapeRate * voluMeshingTime;
+ ((double&) _ticTime) = doneTime / _totalTime / _progressTic;
+ // cout << "shape " << _curShapeIndex << " _ticTime " << _ticTime
+ // << " " << doneTime / _totalTime / _progressTic << endl;
+ }
+ }
+ if ( _ticTime > 0 )
+ progress = Max( *algoProgressTic * _ticTime, *algoProgress );
+ if ( progress > 0 )
+ {
+ ((int&) *algoProgressTic )++;
+ ((double&) *algoProgress) = progress;
+ }
+ //cout << progress << " " << *algoProgressTic << " " << netgen::multithread.task << " "<< _ticTime << endl;
+
+ return Min( progress, 0.99 );
}
//================================================================================
//
#include "NETGENPlugin_NETGEN_2D3D.hxx"
#include "NETGENPlugin_Hypothesis.hxx"
-#include "NETGENPlugin_SimpleHypothesis_2D.hxx"
+#include "NETGENPlugin_SimpleHypothesis_3D.hxx"
#include "NETGENPlugin_Mesher.hxx"
#include <SMESH_Gen.hxx>
#include <list>
-#ifdef WITH_SMESH_CANCEL_COMPUTE
namespace nglib {
#include <nglib.h>
}
#include <meshing.hpp>
-#endif
using namespace std;
MESSAGE("NETGENPlugin_NETGEN_2D3D::CheckHypothesis");
_hypothesis = NULL;
+ _mesher = NULL;
const list<const SMESHDS_Hypothesis*>& hyps = GetUsedHypothesis(aMesh, aShape);
int nbHyp = hyps.size();
bool NETGENPlugin_NETGEN_2D3D::Compute(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape)
{
-#ifdef WITH_SMESH_CANCEL_COMPUTE
netgen::multithread.terminate = 0;
-#endif
NETGENPlugin_Mesher mesher(&aMesh, aShape, true);
mesher.SetParameters(dynamic_cast<const NETGENPlugin_Hypothesis*>(_hypothesis));
- mesher.SetParameters(dynamic_cast<const NETGENPlugin_SimpleHypothesis_2D*>(_hypothesis));
+ mesher.SetParameters(dynamic_cast<const NETGENPlugin_SimpleHypothesis_3D*>(_hypothesis));
+ mesher.SetSelfPointer( &_mesher );
return mesher.Compute();
}
*/
//=============================================================================
-#ifdef WITH_SMESH_CANCEL_COMPUTE
void NETGENPlugin_NETGEN_2D3D::CancelCompute()
{
SMESH_Algo::CancelCompute();
netgen::multithread.terminate = 1;
}
-#endif
+
+//================================================================================
+/*!
+ * \brief Return progress of Compute() [0.,1]
+ */
+//================================================================================
+
+double NETGENPlugin_NETGEN_2D3D::GetProgress() const
+{
+ double & progress = (double &)_progress;
+ if ( _mesher )
+ progress = _mesher->GetProgress(this, &_progressTic, &_progress);
+ else if ( _progress > 0.001 )
+ progress = 0.99;
+
+ return _progress;
+}
//=============================================================================
/*!