+ err = 1;
+ str << "Exception in netgen::OCCGenerateMesh()"
+ << " at " << netgen::multithread.task
+ << ": " << ex.DynamicType()->Name();
+ if ( ex.GetMessageString() && strlen( ex.GetMessageString() ))
+ str << ": " << ex.GetMessageString();
+ }
+ catch (...) {
+ err = 1;
+ str << "Exception in netgen::OCCGenerateMesh()"
+ << " at " << netgen::multithread.task;
+ }
+ if ( err )
+ {
+ if ( aMesher.FixFaceMesh( occgeom, *ngMesh, 1 ))
+ break;
+ if ( iLoop == LOC_SIZE )
+ {
+ netgen::mparam.minh = netgen::mparam.maxh;
+ netgen::mparam.maxh = 0;
+ for ( size_t iW = 0; iW < wires.size(); ++iW )
+ {
+ StdMeshers_FaceSidePtr wire = wires[ iW ];
+ const vector<UVPtStruct>& uvPtVec = wire->GetUVPtStruct();
+ for ( size_t iP = 1; iP < uvPtVec.size(); ++iP )
+ {
+ SMESH_TNodeXYZ p( uvPtVec[ iP ].node );
+ netgen::Point3d np( p.X(),p.Y(),p.Z());
+ double segLen = p.Distance( uvPtVec[ iP-1 ].node );
+ double size = ngMesh->GetH( np );
+ netgen::mparam.minh = Min( netgen::mparam.minh, size );
+ netgen::mparam.maxh = Max( netgen::mparam.maxh, segLen );
+ }
+ }
+ //cerr << "min " << netgen::mparam.minh << " max " << netgen::mparam.maxh << endl;
+ netgen::mparam.minh *= 0.9;
+ netgen::mparam.maxh *= 1.1;
+ continue;
+ }
+ else
+ {
+ faceErr.reset( new SMESH_ComputeError( COMPERR_ALGO_FAILED, str ));
+ }
+ }
+
+
+ // ----------------------------------------------------
+ // Fill the SMESHDS with the generated nodes and faces
+ // ----------------------------------------------------
+
+ int nbNodes = ngMesh->GetNP();
+ int nbFaces = ngMesh->GetNSE();
+
+ int nbInputNodes = (int) nodeVec.size()-1;
+ nodeVec.resize( nbNodes+1, 0 );
+
+ // add nodes
+ for ( int ngID = nbInputNodes + 1; ngID <= nbNodes; ++ngID )
+ {
+ const MeshPoint& ngPoint = ngMesh->Point( ngID );
+ SMDS_MeshNode * node = meshDS->AddNode(ngPoint(0), ngPoint(1), ngPoint(2));
+ nodeVec[ ngID ] = node;
+ }
+
+ // create faces
+ int i,j;
+ vector<const SMDS_MeshNode*> nodes;
+ for ( i = 1; i <= nbFaces ; ++i )
+ {
+ const Element2d& elem = ngMesh->SurfaceElement(i);
+ nodes.resize( elem.GetNP() );
+ for (j=1; j <= elem.GetNP(); ++j)
+ {
+ int pind = elem.PNum(j);
+ if ( pind < 1 )
+ break;
+ nodes[ j-1 ] = nodeVec[ pind ];
+ if ( nodes[ j-1 ]->GetPosition()->GetTypeOfPosition() == SMDS_TOP_3DSPACE )
+ {
+ const PointGeomInfo& pgi = elem.GeomInfoPi(j);
+ meshDS->SetNodeOnFace( nodes[ j-1 ], faceID, pgi.u, pgi.v);
+ }
+ }
+ if ( j > elem.GetNP() )
+ {
+ if ( elem.GetType() == TRIG )
+ helper.AddFace(nodes[0],nodes[1],nodes[2]);
+ else
+ helper.AddFace(nodes[0],nodes[1],nodes[2],nodes[3]);
+ }