+ F = TopoDS::Face( meshDS->IndexToShape( faceID ));
+ bool check;
+ gp_XY uv1 = GetNodeUV( F, n1, n23, &check );
+ gp_XY uv2 = GetNodeUV( F, n2, n31, &check );
+ gp_XY uv3 = GetNodeUV( F, n3, n12, &check );
+ gp_XY uv12 = GetNodeUV( F, n12, n3, &check );
+ gp_XY uv23 = GetNodeUV( F, n23, n1, &check );
+ gp_XY uv31 = GetNodeUV( F, n31, n2, &check );
+ uvAvg = GetCenterUV( uv1,uv2,uv3, uv12,uv23,uv31, &badTria );
+ if ( badTria )
+ force3d = false;
+ }
+
+ // Create a central node
+
+ gp_Pnt P;
+ if ( !F.IsNull() && !force3d )
+ {
+ TopLoc_Location loc;
+ Handle( Geom_Surface ) S = BRep_Tool::Surface( F, loc );
+ P = S->Value( uvAvg.X(), uvAvg.Y() ).Transformed( loc );
+ centralNode = meshDS->AddNode( P.X(), P.Y(), P.Z() );
+ // if ( mySetElemOnShape ) node is not elem!
+ meshDS->SetNodeOnFace( centralNode, faceID, uvAvg.X(), uvAvg.Y() );
+ }
+ else // ( force3d || F.IsNull() )
+ {
+ P = ( SMESH_TNodeXYZ( n12 ) +
+ SMESH_TNodeXYZ( n23 ) +
+ SMESH_TNodeXYZ( n31 ) ) / 3;
+ centralNode = meshDS->AddNode( P.X(), P.Y(), P.Z() );
+
+ if ( !F.IsNull() ) // force3d
+ {
+ meshDS->SetNodeOnFace( centralNode, faceID, uvAvg.X(), uvAvg.Y() );
+ }
+ else if ( solidID > 0 )
+ {
+ meshDS->SetNodeInVolume( centralNode, solidID );
+ }
+ else if ( myShapeID > 0 && mySetElemOnShape )
+ {
+ meshDS->SetMeshElementOnShape( centralNode, myShapeID );
+ }