+
+//================================================================================
+/*!
+ * \brief Projects internal nodes using transformation found by boundary nodes
+ */
+//================================================================================
+
+bool StdMeshers_Sweeper::projectIntPoints(const vector< gp_XYZ >& fromBndPoints,
+ const vector< gp_XYZ >& toBndPoints,
+ const vector< gp_XYZ >& fromIntPoints,
+ vector< gp_XYZ >& toIntPoints,
+ NSProjUtils::TrsfFinder3D& trsf,
+ vector< gp_XYZ > * bndError)
+{
+ // find transformation
+ if ( trsf.IsIdentity() && !trsf.Solve( fromBndPoints, toBndPoints ))
+ return false;
+
+ // compute internal points using the found trsf
+ for ( size_t iP = 0; iP < fromIntPoints.size(); ++iP )
+ {
+ toIntPoints[ iP ] = trsf.Transform( fromIntPoints[ iP ]);
+ }
+
+ // compute boundary error
+ if ( bndError )
+ {
+ bndError->resize( fromBndPoints.size() );
+ gp_XYZ fromTrsf;
+ for ( size_t iP = 0; iP < fromBndPoints.size(); ++iP )
+ {
+ fromTrsf = trsf.Transform( fromBndPoints[ iP ] );
+ (*bndError)[ iP ] = toBndPoints[ iP ] - fromTrsf;
+ }
+ }
+ return true;
+}
+
+//================================================================================
+/*!
+ * \brief Add boundary error to ineternal points
+ */
+//================================================================================
+
+void StdMeshers_Sweeper::applyBoundaryError(const vector< gp_XYZ >& bndPoints,
+ const vector< gp_XYZ >& bndError1,
+ const vector< gp_XYZ >& bndError2,
+ const double r,
+ vector< gp_XYZ >& intPoints,
+ vector< double >& int2BndDist)
+{
+ // fix each internal point
+ const double eps = 1e-100;
+ for ( size_t iP = 0; iP < intPoints.size(); ++iP )
+ {
+ gp_XYZ & intPnt = intPoints[ iP ];
+
+ // compute distance from intPnt to each boundary node
+ double int2BndDistSum = 0;
+ for ( size_t iBnd = 0; iBnd < bndPoints.size(); ++iBnd )
+ {
+ int2BndDist[ iBnd ] = 1 / (( intPnt - bndPoints[ iBnd ]).SquareModulus() + eps );
+ int2BndDistSum += int2BndDist[ iBnd ];
+ }
+
+ // apply bndError
+ for ( size_t iBnd = 0; iBnd < bndPoints.size(); ++iBnd )
+ {
+ intPnt += bndError1[ iBnd ] * ( 1 - r ) * int2BndDist[ iBnd ] / int2BndDistSum;
+ intPnt += bndError2[ iBnd ] * r * int2BndDist[ iBnd ] / int2BndDistSum;
+ }
+ }
+}
+
+//================================================================================
+/*!
+ * \brief Create internal nodes of the prism
+ */
+//================================================================================
+
+bool StdMeshers_Sweeper::ComputeNodes( SMESH_MesherHelper& helper,
+ const double tol,
+ const bool allowHighBndError)
+{
+ const size_t zSize = myBndColumns[0]->size();
+ const size_t zSrc = 0, zTgt = zSize-1;
+ if ( zSize < 3 ) return true;
+
+ vector< vector< gp_XYZ > > intPntsOfLayer( zSize ); // node coodinates to compute
+ // set coordinates of src and tgt nodes
+ for ( size_t z = 0; z < intPntsOfLayer.size(); ++z )
+ intPntsOfLayer[ z ].resize( myIntColumns.size() );
+ for ( size_t iP = 0; iP < myIntColumns.size(); ++iP )
+ {
+ intPntsOfLayer[ zSrc ][ iP ] = intPoint( iP, zSrc );
+ intPntsOfLayer[ zTgt ][ iP ] = intPoint( iP, zTgt );
+ }
+
+ // compute coordinates of internal nodes by projecting (transfroming) src and tgt
+ // nodes towards the central layer
+
+ vector< NSProjUtils::TrsfFinder3D > trsfOfLayer( zSize );
+ vector< vector< gp_XYZ > > bndError( zSize );
+
+ // boundary points used to compute an affine transformation from a layer to a next one
+ vector< gp_XYZ > fromSrcBndPnts( myBndColumns.size() ), fromTgtBndPnts( myBndColumns.size() );
+ vector< gp_XYZ > toSrcBndPnts ( myBndColumns.size() ), toTgtBndPnts ( myBndColumns.size() );
+ for ( size_t iP = 0; iP < myBndColumns.size(); ++iP )
+ {
+ fromSrcBndPnts[ iP ] = bndPoint( iP, zSrc );
+ fromTgtBndPnts[ iP ] = bndPoint( iP, zTgt );
+ }
+
+ size_t zS = zSrc + 1;
+ size_t zT = zTgt - 1;
+ for ( ; zS < zT; ++zS, --zT ) // vertical loop on layers
+ {
+ for ( size_t iP = 0; iP < myBndColumns.size(); ++iP )
+ {
+ toSrcBndPnts[ iP ] = bndPoint( iP, zS );
+ toTgtBndPnts[ iP ] = bndPoint( iP, zT );
+ }
+ if (! projectIntPoints( fromSrcBndPnts, toSrcBndPnts,
+ intPntsOfLayer[ zS-1 ], intPntsOfLayer[ zS ],
+ trsfOfLayer [ zS-1 ], & bndError[ zS-1 ]))
+ return false;
+ if (! projectIntPoints( fromTgtBndPnts, toTgtBndPnts,
+ intPntsOfLayer[ zT+1 ], intPntsOfLayer[ zT ],
+ trsfOfLayer [ zT+1 ], & bndError[ zT+1 ]))
+ return false;
+
+ // if ( zT == zTgt - 1 )
+ // {
+ // for ( size_t iP = 0; iP < myBndColumns.size(); ++iP )
+ // {
+ // gp_XYZ fromTrsf = trsfOfLayer [ zT+1].Transform( fromTgtBndPnts[ iP ] );
+ // cout << "mesh.AddNode( "
+ // << fromTrsf.X() << ", "
+ // << fromTrsf.Y() << ", "
+ // << fromTrsf.Z() << ") " << endl;
+ // }
+ // for ( size_t iP = 0; iP < myIntColumns.size(); ++iP )
+ // cout << "mesh.AddNode( "
+ // << intPntsOfLayer[ zT ][ iP ].X() << ", "
+ // << intPntsOfLayer[ zT ][ iP ].Y() << ", "
+ // << intPntsOfLayer[ zT ][ iP ].Z() << ") " << endl;
+ // }
+
+ fromTgtBndPnts.swap( toTgtBndPnts );
+ fromSrcBndPnts.swap( toSrcBndPnts );
+ }
+
+ // Compute two projections of internal points to the central layer
+ // in order to evaluate an error of internal points
+
+ bool centerIntErrorIsSmall;
+ vector< gp_XYZ > centerSrcIntPnts( myIntColumns.size() );
+ vector< gp_XYZ > centerTgtIntPnts( myIntColumns.size() );
+
+ for ( size_t iP = 0; iP < myBndColumns.size(); ++iP )
+ {
+ toSrcBndPnts[ iP ] = bndPoint( iP, zS );
+ toTgtBndPnts[ iP ] = bndPoint( iP, zT );
+ }
+ if (! projectIntPoints( fromSrcBndPnts, toSrcBndPnts,
+ intPntsOfLayer[ zS-1 ], centerSrcIntPnts,
+ trsfOfLayer [ zS-1 ], & bndError[ zS-1 ]))
+ return false;
+ if (! projectIntPoints( fromTgtBndPnts, toTgtBndPnts,
+ intPntsOfLayer[ zT+1 ], centerTgtIntPnts,
+ trsfOfLayer [ zT+1 ], & bndError[ zT+1 ]))
+ return false;
+
+ // evaluate an error of internal points on the central layer
+ centerIntErrorIsSmall = true;
+ if ( zS == zT ) // odd zSize
+ {
+ for ( size_t iP = 0; ( iP < myIntColumns.size() && centerIntErrorIsSmall ); ++iP )
+ centerIntErrorIsSmall =
+ (centerSrcIntPnts[ iP ] - centerTgtIntPnts[ iP ]).SquareModulus() < tol*tol;
+ }
+ else // even zSize
+ {
+ for ( size_t iP = 0; ( iP < myIntColumns.size() && centerIntErrorIsSmall ); ++iP )
+ centerIntErrorIsSmall =
+ (intPntsOfLayer[ zS-1 ][ iP ] - centerTgtIntPnts[ iP ]).SquareModulus() < tol*tol;
+ }
+
+ // Evaluate an error of boundary points
+
+ bool bndErrorIsSmall = true;
+ for ( size_t iP = 0; ( iP < myBndColumns.size() && bndErrorIsSmall ); ++iP )
+ {
+ double sumError = 0;
+ for ( size_t z = 1; z < zS; ++z ) // loop on layers
+ sumError += ( bndError[ z-1 ][ iP ].Modulus() +
+ bndError[ zSize-z ][ iP ].Modulus() );
+
+ bndErrorIsSmall = ( sumError < tol );
+ }
+
+ if ( !bndErrorIsSmall && !allowHighBndError )
+ return false;
+
+ // compute final points on the central layer
+ std::vector< double > int2BndDist( myBndColumns.size() ); // work array of applyBoundaryError()
+ double r = zS / ( zSize - 1.);
+ if ( zS == zT )
+ {
+ for ( size_t iP = 0; iP < myIntColumns.size(); ++iP )
+ {
+ intPntsOfLayer[ zS ][ iP ] =
+ ( 1 - r ) * centerSrcIntPnts[ iP ] + r * centerTgtIntPnts[ iP ];
+ }
+ if ( !bndErrorIsSmall )
+ {
+ applyBoundaryError( toSrcBndPnts, bndError[ zS-1 ], bndError[ zS+1 ], r,
+ intPntsOfLayer[ zS ], int2BndDist );
+ }
+ }
+ else
+ {
+ for ( size_t iP = 0; iP < myIntColumns.size(); ++iP )
+ {
+ intPntsOfLayer[ zS ][ iP ] =
+ r * intPntsOfLayer[ zS ][ iP ] + ( 1 - r ) * centerSrcIntPnts[ iP ];
+ intPntsOfLayer[ zT ][ iP ] =
+ r * intPntsOfLayer[ zT ][ iP ] + ( 1 - r ) * centerTgtIntPnts[ iP ];
+ }
+ if ( !bndErrorIsSmall )
+ {
+ applyBoundaryError( toSrcBndPnts, bndError[ zS-1 ], bndError[ zS+1 ], r,
+ intPntsOfLayer[ zS ], int2BndDist );
+ applyBoundaryError( toTgtBndPnts, bndError[ zT+1 ], bndError[ zT-1 ], r,
+ intPntsOfLayer[ zT ], int2BndDist );
+ }
+ }
+
+ centerIntErrorIsSmall = true; // 3D_mesh_Extrusion_00/A3
+ bndErrorIsSmall = true;
+ if ( !centerIntErrorIsSmall )
+ {
+ // Compensate the central error; continue adding projection
+ // by going from central layer to the source and target ones
+
+ vector< gp_XYZ >& fromSrcIntPnts = centerSrcIntPnts;
+ vector< gp_XYZ >& fromTgtIntPnts = centerTgtIntPnts;
+ vector< gp_XYZ > toSrcIntPnts( myIntColumns.size() );
+ vector< gp_XYZ > toTgtIntPnts( myIntColumns.size() );
+ vector< gp_XYZ > srcBndError( myBndColumns.size() );
+ vector< gp_XYZ > tgtBndError( myBndColumns.size() );
+
+ fromTgtBndPnts.swap( toTgtBndPnts );
+ fromSrcBndPnts.swap( toSrcBndPnts );
+
+ for ( ++zS, --zT; zS < zTgt; ++zS, --zT ) // vertical loop on layers
+ {
+ // invert transformation
+ if ( !trsfOfLayer[ zS+1 ].Invert() )
+ trsfOfLayer[ zS+1 ] = NSProjUtils::TrsfFinder3D(); // to recompute
+ if ( !trsfOfLayer[ zT-1 ].Invert() )
+ trsfOfLayer[ zT-1 ] = NSProjUtils::TrsfFinder3D();
+
+ // project internal nodes and compute bnd error
+ for ( size_t iP = 0; iP < myBndColumns.size(); ++iP )
+ {
+ toSrcBndPnts[ iP ] = bndPoint( iP, zS );
+ toTgtBndPnts[ iP ] = bndPoint( iP, zT );
+ }
+ projectIntPoints( fromSrcBndPnts, toSrcBndPnts,
+ fromSrcIntPnts, toSrcIntPnts,
+ trsfOfLayer[ zS+1 ], & srcBndError );
+ projectIntPoints( fromTgtBndPnts, toTgtBndPnts,
+ fromTgtIntPnts, toTgtIntPnts,
+ trsfOfLayer[ zT-1 ], & tgtBndError );
+
+ // if ( zS == zTgt - 1 )
+ // {
+ // cout << "mesh2 = smesh.Mesh()" << endl;
+ // for ( size_t iP = 0; iP < myBndColumns.size(); ++iP )
+ // {
+ // gp_XYZ fromTrsf = trsfOfLayer [ zS+1].Transform( fromSrcBndPnts[ iP ] );
+ // cout << "mesh2.AddNode( "
+ // << fromTrsf.X() << ", "
+ // << fromTrsf.Y() << ", "
+ // << fromTrsf.Z() << ") " << endl;
+ // }
+ // for ( size_t iP = 0; iP < myIntColumns.size(); ++iP )
+ // cout << "mesh2.AddNode( "
+ // << toSrcIntPnts[ iP ].X() << ", "
+ // << toSrcIntPnts[ iP ].Y() << ", "
+ // << toSrcIntPnts[ iP ].Z() << ") " << endl;
+ // }
+
+ // sum up 2 projections
+ r = zS / ( zSize - 1.);
+ vector< gp_XYZ >& zSIntPnts = intPntsOfLayer[ zS ];
+ vector< gp_XYZ >& zTIntPnts = intPntsOfLayer[ zT ];
+ for ( size_t iP = 0; iP < myIntColumns.size(); ++iP )
+ {
+ zSIntPnts[ iP ] = r * zSIntPnts[ iP ] + ( 1 - r ) * toSrcIntPnts[ iP ];
+ zTIntPnts[ iP ] = r * zTIntPnts[ iP ] + ( 1 - r ) * toTgtIntPnts[ iP ];
+ }
+
+ // compensate bnd error
+ if ( !bndErrorIsSmall )
+ {
+ applyBoundaryError( toSrcBndPnts, srcBndError, bndError[ zS+1 ], r,
+ intPntsOfLayer[ zS ], int2BndDist );
+ applyBoundaryError( toTgtBndPnts, tgtBndError, bndError[ zT-1 ], r,
+ intPntsOfLayer[ zT ], int2BndDist );
+ }
+
+ fromSrcBndPnts.swap( toSrcBndPnts );
+ fromSrcIntPnts.swap( toSrcIntPnts );
+ fromTgtBndPnts.swap( toTgtBndPnts );
+ fromTgtIntPnts.swap( toTgtIntPnts );
+ }
+ } // if ( !centerIntErrorIsSmall )
+
+ else if ( !bndErrorIsSmall )
+ {
+ zS = zSrc + 1;
+ zT = zTgt - 1;
+ for ( ; zS < zT; ++zS, --zT ) // vertical loop on layers
+ {
+ for ( size_t iP = 0; iP < myBndColumns.size(); ++iP )
+ {
+ toSrcBndPnts[ iP ] = bndPoint( iP, zS );
+ toTgtBndPnts[ iP ] = bndPoint( iP, zT );
+ }
+ // compensate bnd error
+ applyBoundaryError( toSrcBndPnts, bndError[ zS-1 ], bndError[ zS-1 ], 0.5,
+ intPntsOfLayer[ zS ], int2BndDist );
+ applyBoundaryError( toTgtBndPnts, bndError[ zT+1 ], bndError[ zT+1 ], 0.5,
+ intPntsOfLayer[ zT ], int2BndDist );
+ }
+ }
+
+ // cout << "centerIntErrorIsSmall = " << centerIntErrorIsSmall<< endl;
+ // cout << "bndErrorIsSmall = " << bndErrorIsSmall<< endl;
+
+ // Create nodes
+ for ( size_t iP = 0; iP < myIntColumns.size(); ++iP )
+ {
+ vector< const SMDS_MeshNode* > & nodeCol = *myIntColumns[ iP ];
+ for ( size_t z = zSrc + 1; z < zTgt; ++z ) // vertical loop on layers
+ {
+ const gp_XYZ & xyz = intPntsOfLayer[ z ][ iP ];
+ if ( !( nodeCol[ z ] = helper.AddNode( xyz.X(), xyz.Y(), xyz.Z() )))
+ return false;
+ }
+ }
+
+ return true;
+}
+
+//================================================================================
+/*!
+ * \brief Check if all nodes of each layers have same logical Z
+ */
+//================================================================================
+
+bool StdMeshers_Sweeper::CheckSameZ()
+{
+ myZColumns.resize( myBndColumns.size() );
+ fillZColumn( myZColumns[0], *myBndColumns[0] );
+
+ bool sameZ = true;
+ const double tol = 0.1 * 1./ myBndColumns[0]->size();
+
+ // check columns based on VERTEXes
+
+ vector< int > vertexIndex;
+ vertexIndex.push_back( 0 );
+ for ( size_t iC = 1; iC < myBndColumns.size() && sameZ; ++iC )
+ {
+ if ( myBndColumns[iC]->front()->GetPosition()->GetDim() > 0 )
+ continue; // not on VERTEX
+
+ vertexIndex.push_back( iC );
+ fillZColumn( myZColumns[iC], *myBndColumns[iC] );
+
+ for ( size_t iZ = 0; iZ < myZColumns[0].size() && sameZ; ++iZ )
+ sameZ = ( Abs( myZColumns[0][iZ] - myZColumns[iC][iZ]) < tol );
+ }
+
+ // check columns based on EDGEs, one per EDGE
+
+ for ( size_t i = 1; i < vertexIndex.size() && sameZ; ++i )
+ {
+ if ( vertexIndex[i] - vertexIndex[i-1] < 2 )
+ continue;
+
+ int iC = ( vertexIndex[i] + vertexIndex[i-1] ) / 2;
+ fillZColumn( myZColumns[iC], *myBndColumns[iC] );
+
+ for ( size_t iZ = 0; iZ < myZColumns[0].size() && sameZ; ++iZ )
+ sameZ = ( Abs( myZColumns[0][iZ] - myZColumns[iC][iZ]) < tol );
+ }
+
+ if ( sameZ )
+ {
+ myZColumns.resize(1);
+ }
+ else
+ {
+ for ( size_t iC = 1; iC < myBndColumns.size(); ++iC )
+ fillZColumn( myZColumns[iC], *myBndColumns[iC] );
+ }
+
+ return sameZ;
+}
+
+//================================================================================
+/*!
+ * \brief Create internal nodes of the prism all located on straight lines with
+ * the same distribution along the lines.
+ */
+//================================================================================
+
+bool StdMeshers_Sweeper::ComputeNodesOnStraightSameZ( SMESH_MesherHelper& helper )
+{
+ TZColumn& z = myZColumns[0];
+
+ for ( size_t i = 0; i < myIntColumns.size(); ++i )
+ {
+ TNodeColumn& nodes = *myIntColumns[i];
+ SMESH_NodeXYZ n0( nodes[0] ), n1( nodes.back() );
+
+ for ( size_t iZ = 0; iZ < z.size(); ++iZ )
+ {
+ gp_XYZ p = n0 * ( 1 - z[iZ] ) + n1 * z[iZ];
+ nodes[ iZ+1 ] = helper.AddNode( p.X(), p.Y(), p.Z() );
+ }
+ }
+
+ return true;
+}
+
+//================================================================================
+/*!
+ * \brief Create internal nodes of the prism all located on straight lines with
+ * different distributions along the lines.
+ */
+//================================================================================
+
+bool StdMeshers_Sweeper::ComputeNodesOnStraight( SMESH_MesherHelper& helper,
+ const TopoDS_Face& botFace,
+ const TopoDS_Face& topFace )
+{
+ // get data to create a Morph
+ UVPtStructVec botUV( myBndColumns.size() + 1 );
+ UVPtStructVec topUV( myBndColumns.size() + 1 );
+ for ( size_t i = 0; i < myBndColumns.size(); ++i )
+ {
+ TNodeColumn& nodes = *myBndColumns[i];
+ botUV[i].node = nodes[0];
+ botUV[i].SetUV( helper.GetNodeUV( botFace, nodes[0] ));
+ topUV[i].node = nodes.back();
+ topUV[i].SetUV( helper.GetNodeUV( topFace, nodes.back() ));
+ botUV[i].node->setIsMarked( true );
+ }
+ botUV.back() = botUV[0];
+ topUV.back() = topUV[0];
+
+ TopoDS_Edge dummyE;
+ TSideVector botWires( 1, StdMeshers_FaceSide::New( botUV, botFace, dummyE, helper.GetMesh() ));
+ TSideVector topWires( 1, StdMeshers_FaceSide::New( topUV, topFace, dummyE, helper.GetMesh() ));
+
+ // use Morph to make delauney mesh on the FACEs. Locating of a node within a
+ // delauney triangle will be used to get a weighted Z.
+ NSProjUtils::Morph botDelauney( botWires );
+ NSProjUtils::Morph topDelauney( topWires );
+
+ if ( helper.GetIsQuadratic() )
+ {
+ // mark all medium nodes of faces on botFace to avoid their treating
+ SMESHDS_SubMesh* smDS = helper.GetMeshDS()->MeshElements( botFace );
+ SMDS_ElemIteratorPtr eIt = smDS->GetElements();
+ while ( eIt->more() )
+ {
+ const SMDS_MeshElement* e = eIt->next();
+ for ( int i = e->NbCornerNodes(), nb = e->NbNodes(); i < nb; ++i )
+ e->GetNode( i )->setIsMarked( true );
+ }
+ }
+
+ // map to get a node column by a bottom node
+ TColStd_DataMapOfIntegerInteger iNode2iCol( myIntColumns.size() );
+
+ // un-mark nodes to treat (internal bottom nodes); later we will mark treated nodes
+ for ( size_t i = 0; i < myIntColumns.size(); ++i )
+ {
+ const SMDS_MeshNode* botNode = myIntColumns[i]->front();
+ botNode->setIsMarked( false );
+ iNode2iCol.Bind( botNode->GetID(), i );
+ }
+
+ const int botFaceID = helper.GetMesh()->GetSubMesh( botFace )->GetId();
+ const SMDS_MeshNode *botNode, *topNode;
+ const BRepMesh_Triangle *botTria, *topTria;
+ double botBC[3], topBC[3]; // barycentric coordinates
+ int botTriaNodes[3], topTriaNodes[3];
+ bool checkUV = true;
+
+ // a queue of bottom nodes with starting delauney triangles
+ NSProjUtils::Morph::TNodeTriaList botNoTriQueue;
+
+ size_t iBndN = 1; // index of a bottom boundary node
+ int nbNodesToProcess = myIntColumns.size();
+ while ( nbNodesToProcess > 0 )
+ {
+ while ( !botNoTriQueue.empty() ) // treat all nodes in the queue
+ {
+ botNode = botNoTriQueue.front().first;
+ botTria = botNoTriQueue.front().second;
+ botNoTriQueue.pop_front();
+ if ( botNode->isMarked() )
+ continue;
+ --nbNodesToProcess;
+ botNode->setIsMarked( true );
+
+ TNodeColumn* column = myIntColumns[ iNode2iCol( botNode->GetID() )];
+
+ // find a delauney triangle containing the botNode
+ gp_XY botUV = helper.GetNodeUV( botFace, botNode, NULL, &checkUV );
+ botUV *= botDelauney.GetScale();
+ botTria = botDelauney.FindTriangle( botUV, botTria, botBC, botTriaNodes );
+ if ( !botTria )
+ return false;
+
+ // find a delauney triangle containing the topNode
+ topNode = column->back();
+ gp_XY topUV = helper.GetNodeUV( topFace, topNode, NULL, &checkUV );
+ topUV *= topDelauney.GetScale();
+ // get a starting triangle basing on that top and bot boundary nodes have same index
+ topTria = topDelauney.GetTriangleNear( botTriaNodes[0] );
+ topTria = topDelauney.FindTriangle( topUV, topTria, topBC, topTriaNodes );
+ if ( !topTria )
+ return false;
+
+ // create nodes along a line
+ SMESH_NodeXYZ botP( botNode ), topP( topNode);
+ for ( size_t iZ = 0; iZ < myZColumns[0].size(); ++iZ )
+ {
+ // use barycentric coordinates as weight of Z of boundary columns
+ double botZ = 0, topZ = 0;
+ for ( int i = 0; i < 3; ++i )
+ {
+ botZ += botBC[i] * myZColumns[ botTriaNodes[i]-1 ][ iZ ];
+ topZ += topBC[i] * myZColumns[ topTriaNodes[i]-1 ][ iZ ];
+ }
+ double rZ = double( iZ + 1 ) / ( myZColumns[0].size() + 1 );
+ double z = botZ * ( 1 - rZ ) + topZ * rZ;
+ gp_XYZ p = botP * ( 1 - z ) + topP * z;
+ (*column)[ iZ+1 ] = helper.AddNode( p.X(), p.Y(), p.Z() );
+ }
+
+ // add neighbor nodes to the queue
+ botDelauney.AddCloseNodes( botNode, botTria, botFaceID, botNoTriQueue );
+ }
+
+ if ( nbNodesToProcess > 0 ) // fill the queue
+ {
+ // assure that all bot nodes are visited
+ for ( ; iBndN-1 < myBndColumns.size() && botNoTriQueue.empty(); ++iBndN )
+ {
+ botTria = botDelauney.GetTriangleNear( iBndN );
+ const SMDS_MeshNode* bndNode = botDelauney.GetBndNodes()[ iBndN ];
+ botDelauney.AddCloseNodes( bndNode, botTria, botFaceID, botNoTriQueue );
+ }
+ if ( botNoTriQueue.empty() )
+ {
+ for ( size_t i = 0; i < myIntColumns.size(); ++i )
+ {
+ botNode = myIntColumns[i]->front();
+ if ( !botNode->isMarked() )
+ botNoTriQueue.push_back( make_pair( botNode, botTria ));
+ }
+ }
+ }
+ }
+
+ return true;
+}
+
+//================================================================================
+/*!
+ * \brief Compute Z of nodes of a straight column
+ */
+//================================================================================
+
+void StdMeshers_Sweeper::fillZColumn( TZColumn& zColumn,
+ TNodeColumn& nodes )
+{
+ if ( zColumn.size() == nodes.size() - 2 )
+ return;
+
+ gp_Pnt p0 = SMESH_NodeXYZ( nodes[0] );
+ gp_Vec line( p0, SMESH_NodeXYZ( nodes.back() ));
+ double len2 = line.SquareMagnitude();
+
+ zColumn.resize( nodes.size() - 2 );
+ for ( size_t i = 0; i < zColumn.size(); ++i )
+ {
+ gp_Vec vec( p0, SMESH_NodeXYZ( nodes[ i+1] ));
+ zColumn[i] = ( line * vec ) / len2; // param [0,1] on the line
+ }
+}