- // create faces
- bool reverse = ( aShape.Orientation() == TopAbs_REVERSED );
- for ( int i = 1; i <= nbFaces ; ++i )
- {
- const Element2d& elem = ngMesh->SurfaceElement(i);
- vector<const SMDS_MeshNode*> nodes( elem.GetNP() );
- for (int j=1; j <= elem.GetNP(); ++j)
- {
- int pind = elem.PNum(j);
- const SMDS_MeshNode* node = nodeVec.at(pind-1);
- if ( reverse )
- nodes[ nodes.size()-j ] = node;
- else
- nodes[ j-1 ] = node;
- if ( node->GetPosition()->GetTypeOfPosition() == SMDS_TOP_3DSPACE )
- {
- const PointGeomInfo& pgi = elem.GeomInfoPi(j);
- meshDS->SetNodeOnFace((SMDS_MeshNode*)node, faceID, pgi.u, pgi.v);
- }
+void NETGENPlugin_NETGEN_2D_ONLY::CancelCompute()
+{
+ SMESH_Algo::CancelCompute();
+ netgen::multithread.terminate = 1;
+}
+
+//================================================================================
+/*!
+ * \brief Return progress of Compute() [0.,1]
+ */
+//================================================================================
+
+double NETGENPlugin_NETGEN_2D_ONLY::GetProgress() const
+{
+ return -1;
+ // const char* task1 = "Surface meshing";
+ // //const char* task2 = "Optimizing surface";
+ // double& progress = const_cast<NETGENPlugin_NETGEN_2D_ONLY*>( this )->_progress;
+ // if ( _progressByTic < 0. &&
+ // strncmp( netgen::multithread.task, task1, 3 ) == 0 )
+ // {
+ // progress = Min( 0.25, SMESH_Algo::GetProgressByTic() ); // [0, 0.25]
+ // }
+ // else //if ( strncmp( netgen::multithread.task, task2, 3 ) == 0)
+ // {
+ // if ( _progressByTic < 0 )
+ // {
+ // NETGENPlugin_NETGEN_2D_ONLY* me = (NETGENPlugin_NETGEN_2D_ONLY*) this;
+ // me->_progressByTic = 0.25 / (_progressTic+1);
+ // }
+ // const_cast<NETGENPlugin_NETGEN_2D_ONLY*>( this )->_progressTic++;
+ // progress = Max( progress, _progressByTic * _progressTic );
+ // }
+ // //cout << netgen::multithread.task << " " << _progressTic << endl;
+ // return Min( progress, 0.99 );
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+bool NETGENPlugin_NETGEN_2D_ONLY::Evaluate(SMESH_Mesh& aMesh,
+ const TopoDS_Shape& aShape,
+ MapShapeNbElems& aResMap)
+{
+ TopoDS_Face F = TopoDS::Face(aShape);
+ if(F.IsNull())
+ return false;
+
+ // collect info from edges
+ smIdType nb0d = 0, nb1d = 0;
+ bool IsQuadratic = false;
+ bool IsFirst = true;
+ double fullLen = 0.0;
+ TopTools_MapOfShape tmpMap;
+ for (TopExp_Explorer exp(F, TopAbs_EDGE); exp.More(); exp.Next()) {
+ TopoDS_Edge E = TopoDS::Edge(exp.Current());
+ if( tmpMap.Contains(E) )
+ continue;
+ tmpMap.Add(E);
+ SMESH_subMesh *aSubMesh = aMesh.GetSubMesh(exp.Current());
+ MapShapeNbElemsItr anIt = aResMap.find(aSubMesh);
+ if( anIt==aResMap.end() ) {
+ SMESH_subMesh *sm = aMesh.GetSubMesh(F);
+ SMESH_ComputeErrorPtr& smError = sm->GetComputeError();
+ smError.reset( new SMESH_ComputeError(COMPERR_ALGO_FAILED,"Submesh can not be evaluated",this));
+ return false;
+ }
+ std::vector<smIdType> aVec = (*anIt).second;
+ nb0d += aVec[SMDSEntity_Node];
+ nb1d += std::max(aVec[SMDSEntity_Edge],aVec[SMDSEntity_Quad_Edge]);
+ double aLen = SMESH_Algo::EdgeLength(E);
+ fullLen += aLen;
+ if(IsFirst) {
+ IsQuadratic = (aVec[SMDSEntity_Quad_Edge] > aVec[SMDSEntity_Edge]);
+ IsFirst = false;