0021543: EDF 1978 SMESH: Viscous layer for 2D meshes

1) Move struct uvPtStruct to SMESH_TypeDefs.hxx
2) Enable work with a SMESH_ProxyMesh
This commit is contained in:
eap 2012-10-15 14:41:16 +00:00
parent 8b733351ad
commit 40e5fd72da
2 changed files with 298 additions and 133 deletions

View File

@ -66,10 +66,12 @@ StdMeshers_FaceSide::StdMeshers_FaceSide(const TopoDS_Face& theFace,
const TopoDS_Edge& theEdge, const TopoDS_Edge& theEdge,
SMESH_Mesh* theMesh, SMESH_Mesh* theMesh,
const bool theIsForward, const bool theIsForward,
const bool theIgnoreMediumNodes) const bool theIgnoreMediumNodes,
SMESH_ProxyMesh::Ptr theProxyMesh)
{ {
list<TopoDS_Edge> edges(1,theEdge); list<TopoDS_Edge> edges(1,theEdge);
*this = StdMeshers_FaceSide( theFace, edges, theMesh, theIsForward, theIgnoreMediumNodes ); *this = StdMeshers_FaceSide( theFace, edges, theMesh, theIsForward,
theIgnoreMediumNodes, theProxyMesh );
} }
//================================================================================ //================================================================================
@ -84,7 +86,8 @@ StdMeshers_FaceSide::StdMeshers_FaceSide(const TopoDS_Face& theFace,
list<TopoDS_Edge>& theEdges, list<TopoDS_Edge>& theEdges,
SMESH_Mesh* theMesh, SMESH_Mesh* theMesh,
const bool theIsForward, const bool theIsForward,
const bool theIgnoreMediumNodes) const bool theIgnoreMediumNodes,
SMESH_ProxyMesh::Ptr theProxyMesh)
{ {
int nbEdges = theEdges.size(); int nbEdges = theEdges.size();
myEdge.resize ( nbEdges ); myEdge.resize ( nbEdges );
@ -98,13 +101,14 @@ StdMeshers_FaceSide::StdMeshers_FaceSide(const TopoDS_Face& theFace,
myIsUniform.resize ( nbEdges, true ); myIsUniform.resize ( nbEdges, true );
myLength = 0; myLength = 0;
myNbPonits = myNbSegments = 0; myNbPonits = myNbSegments = 0;
myMesh = theMesh; myProxyMesh = theProxyMesh;
myMissingVertexNodes = false; myMissingVertexNodes = false;
myIgnoreMediumNodes = theIgnoreMediumNodes; myIgnoreMediumNodes = theIgnoreMediumNodes;
myDefaultPnt2d = gp_Pnt2d( 1e+100, 1e+100 ); myDefaultPnt2d = gp_Pnt2d( 1e+100, 1e+100 );
if ( !myProxyMesh ) myProxyMesh.reset( new SMESH_ProxyMesh( *theMesh ));
if ( nbEdges == 0 ) return; if ( nbEdges == 0 ) return;
SMESHDS_Mesh* meshDS = theMesh->GetMeshDS(); SMESHDS_Mesh* meshDS = myProxyMesh->GetMeshDS();
int nbDegen = 0; int nbDegen = 0;
list<TopoDS_Edge>::iterator edge = theEdges.begin(); list<TopoDS_Edge>::iterator edge = theEdges.begin();
@ -126,7 +130,7 @@ StdMeshers_FaceSide::StdMeshers_FaceSide(const TopoDS_Face& theFace,
if ( myEdge[i].Orientation() == TopAbs_REVERSED ) if ( myEdge[i].Orientation() == TopAbs_REVERSED )
std::swap( myFirst[i], myLast[i] ); std::swap( myFirst[i], myLast[i] );
if ( SMESHDS_SubMesh* sm = meshDS->MeshElements( *edge )) { if ( const SMESHDS_SubMesh* sm = myProxyMesh->GetSubMesh( *edge )) {
int nbN = sm->NbNodes(); int nbN = sm->NbNodes();
if ( theIgnoreMediumNodes ) { if ( theIgnoreMediumNodes ) {
SMDS_ElemIteratorPtr elemIt = sm->GetElements(); SMDS_ElemIteratorPtr elemIt = sm->GetElements();
@ -136,6 +140,7 @@ StdMeshers_FaceSide::StdMeshers_FaceSide(const TopoDS_Face& theFace,
myNbPonits += nbN; myNbPonits += nbN;
myNbSegments += sm->NbElements(); myNbSegments += sm->NbElements();
} }
// TopExp::FirstVertex() and TopExp::LastVertex() return NULL from INTERNAL edge // TopExp::FirstVertex() and TopExp::LastVertex() return NULL from INTERNAL edge
vExp.Initialize( *edge ); vExp.Initialize( *edge );
if ( vExp.Value().Orientation() == TopAbs_REVERSED ) vExp.Next(); if ( vExp.Value().Orientation() == TopAbs_REVERSED ) vExp.Next();
@ -144,7 +149,7 @@ StdMeshers_FaceSide::StdMeshers_FaceSide(const TopoDS_Face& theFace,
else else
myMissingVertexNodes = true; myMissingVertexNodes = true;
// check if edge has non-uniform parametrization (issue 0020705) // check if the edge has a non-uniform parametrization (issue 0020705)
if ( !myC2d[i].IsNull() && myEdgeLength[i] > DBL_MIN) if ( !myC2d[i].IsNull() && myEdgeLength[i] > DBL_MIN)
{ {
Geom2dAdaptor_Curve A2dC( myC2d[i], Geom2dAdaptor_Curve A2dC( myC2d[i],
@ -163,7 +168,12 @@ StdMeshers_FaceSide::StdMeshers_FaceSide(const TopoDS_Face& theFace,
myC3dAdaptor[i].Load( C3d, fp,lp ); myC3dAdaptor[i].Load( C3d, fp,lp );
} }
} }
} // reverse a proxy submesh
if ( !theIsForward )
reverseProxySubmesh( myEdge[i] );
} // loop on edges
vExp.Initialize( theEdges.back() ); vExp.Initialize( theEdges.back() );
if ( vExp.Value().Orientation() != TopAbs_REVERSED ) vExp.Next(); if ( vExp.Value().Orientation() != TopAbs_REVERSED ) vExp.Next();
if ( vExp.More() ) if ( vExp.More() )
@ -204,7 +214,7 @@ StdMeshers_FaceSide::StdMeshers_FaceSide(const SMDS_MeshNode* theNode,
{ {
myC2d.resize(1); myC2d.resize(1);
myLength = 0; myLength = 0;
myMesh = theSide->GetMesh(); myProxyMesh = theSide->myProxyMesh;
myDefaultPnt2d = thePnt2d; myDefaultPnt2d = thePnt2d;
myPoints = theSide->GetUVPtStruct(); myPoints = theSide->GetUVPtStruct();
@ -232,55 +242,70 @@ const vector<UVPtStruct>& StdMeshers_FaceSide::GetUVPtStruct(bool isXConst,
if ( NbEdges() == 0 ) return myPoints; if ( NbEdges() == 0 ) return myPoints;
SMESHDS_Mesh* meshDS = myMesh->GetMeshDS(); SMESHDS_Mesh* meshDS = myProxyMesh->GetMeshDS();
SMESH_MesherHelper helper(*myMesh); SMESH_MesherHelper helper(*myProxyMesh->GetMesh());
bool paramOK; bool paramOK;
double eps = 1e-100;
// sort nodes of all edges putting them into a map // sort nodes of all edges putting them into a map
map< double, const SMDS_MeshNode*> u2node; map< double, const SMDS_MeshNode*> u2node;
//int nbOnDegen = 0; vector< const SMESH_ProxyMesh::SubMesh* > proxySubMesh( myEdge.size());
for ( int i = 0; i < myEdge.size(); ++i ) int nbProxyNodes = 0;
for ( size_t iE = 0; iE < myEdge.size(); ++iE )
{ {
proxySubMesh[iE] = myProxyMesh->GetProxySubMesh( myEdge[iE] );
if ( proxySubMesh[iE] )
{
if ( proxySubMesh[iE]->GetUVPtStructVec().empty() ) {
proxySubMesh[iE] = 0;
}
else {
nbProxyNodes += proxySubMesh[iE]->GetUVPtStructVec().size() - 1;
if ( iE+1 == myEdge.size() )
++nbProxyNodes;
continue;
}
}
// Put 1st vertex node of a current edge // Put 1st vertex node of a current edge
TopoDS_Vertex VV[2]; // TopExp::FirstVertex() returns NULL for INTERNAL edge TopoDS_Vertex VV[2]; // TopExp::FirstVertex() returns NULL for INTERNAL edge
VV[0] = SMESH_MesherHelper::IthVertex( 0, myEdge[i]); VV[0] = SMESH_MesherHelper::IthVertex( 0, myEdge[iE]);
VV[1] = SMESH_MesherHelper::IthVertex( 1, myEdge[i]); VV[1] = SMESH_MesherHelper::IthVertex( 1, myEdge[iE]);
const SMDS_MeshNode* node = SMESH_Algo::VertexNode( VV[0], meshDS ); const SMDS_MeshNode* node = SMESH_Algo::VertexNode( VV[0], meshDS );
double prevNormPar = ( i == 0 ? 0 : myNormPar[ i-1 ]); // normalized param double prevNormPar = ( iE == 0 ? 0 : myNormPar[ iE-1 ]); // normalized param
if ( node ) { // nodes on internal vertices may be missing if ( node ) { // nodes on internal vertices may be missing
u2node.insert( u2node.end(), make_pair( prevNormPar, node )); u2node.insert( u2node.end(), make_pair( prevNormPar, node ));
} }
else if ( i == 0 ) { else if ( iE == 0 ) {
MESSAGE(" NO NODE on VERTEX" ); MESSAGE(" NO NODE on VERTEX" );
return myPoints; return myPoints;
} }
// Put internal nodes // Put internal nodes
if ( SMESHDS_SubMesh* sm = meshDS->MeshElements( myEdge[i] )) if ( const SMESHDS_SubMesh* sm = myProxyMesh->GetSubMesh( myEdge[iE] ))
{ {
vector< pair< double, const SMDS_MeshNode*> > u2nodeVec; vector< pair< double, const SMDS_MeshNode*> > u2nodeVec;
u2nodeVec.reserve( sm->NbNodes() ); u2nodeVec.reserve( sm->NbNodes() );
SMDS_NodeIteratorPtr nItr = sm->GetNodes(); SMDS_NodeIteratorPtr nItr = sm->GetNodes();
double paramSize = myLast[i] - myFirst[i]; double paramSize = myLast[iE] - myFirst[iE];
double r = myNormPar[i] - prevNormPar; double r = myNormPar[iE] - prevNormPar;
helper.SetSubShape( myEdge[i] ); helper.SetSubShape( myEdge[iE] );
helper.ToFixNodeParameters( true ); helper.ToFixNodeParameters( true );
if ( !myIsUniform[i] ) if ( !myIsUniform[iE] )
while ( nItr->more() ) while ( nItr->more() )
{ {
const SMDS_MeshNode* node = nItr->next(); const SMDS_MeshNode* node = nItr->next();
if ( myIgnoreMediumNodes && SMESH_MeshEditor::IsMedium( node, SMDSAbs_Edge )) if ( myIgnoreMediumNodes && SMESH_MeshEditor::IsMedium( node, SMDSAbs_Edge ))
continue; continue;
double u = helper.GetNodeU( myEdge[i], node, 0, &paramOK ); double u = helper.GetNodeU( myEdge[iE], node, 0, &paramOK );
double aLenU = GCPnts_AbscissaPoint::Length double aLenU = GCPnts_AbscissaPoint::Length
( const_cast<GeomAdaptor_Curve&>( myC3dAdaptor[i]), myFirst[i], u ); ( const_cast<GeomAdaptor_Curve&>( myC3dAdaptor[iE]), myFirst[iE], u );
if ( myEdgeLength[i] < aLenU ) // nonregression test "3D_mesh_NETGEN/G6" if ( myEdgeLength[iE] < aLenU ) // nonregression test "3D_mesh_NETGEN/G6"
{ {
u2nodeVec.clear(); u2nodeVec.clear();
break; break;
} }
double normPar = prevNormPar + r*aLenU/myEdgeLength[i]; double normPar = prevNormPar + r*aLenU/myEdgeLength[iE];
u2nodeVec.push_back( make_pair( normPar, node )); u2nodeVec.push_back( make_pair( normPar, node ));
} }
nItr = sm->GetNodes(); nItr = sm->GetNodes();
@ -290,10 +315,10 @@ const vector<UVPtStruct>& StdMeshers_FaceSide::GetUVPtStruct(bool isXConst,
const SMDS_MeshNode* node = nItr->next(); const SMDS_MeshNode* node = nItr->next();
if ( myIgnoreMediumNodes && SMESH_MeshEditor::IsMedium( node, SMDSAbs_Edge )) if ( myIgnoreMediumNodes && SMESH_MeshEditor::IsMedium( node, SMDSAbs_Edge ))
continue; continue;
double u = helper.GetNodeU( myEdge[i], node, 0, &paramOK ); double u = helper.GetNodeU( myEdge[iE], node, 0, &paramOK );
// paramSize is signed so orientation is taken into account // paramSize is signed so orientation is taken into account
double normPar = prevNormPar + r * ( u - myFirst[i] ) / paramSize; double normPar = prevNormPar + r * ( u - myFirst[iE] ) / paramSize;
u2nodeVec.push_back( make_pair( normPar, node )); u2nodeVec.push_back( make_pair( normPar, node ));
} }
for ( size_t j = 0; j < u2nodeVec.size(); ++j ) for ( size_t j = 0; j < u2nodeVec.size(); ++j )
@ -301,7 +326,7 @@ const vector<UVPtStruct>& StdMeshers_FaceSide::GetUVPtStruct(bool isXConst,
} }
// Put 2nd vertex node for a last edge // Put 2nd vertex node for a last edge
if ( i+1 == myEdge.size() ) { if ( iE+1 == myEdge.size() ) {
node = SMESH_Algo::VertexNode( VV[1], meshDS ); node = SMESH_Algo::VertexNode( VV[1], meshDS );
if ( !node ) { if ( !node ) {
MESSAGE(" NO NODE on VERTEX" ); MESSAGE(" NO NODE on VERTEX" );
@ -309,8 +334,10 @@ const vector<UVPtStruct>& StdMeshers_FaceSide::GetUVPtStruct(bool isXConst,
} }
u2node.insert( u2node.end(), make_pair( 1., node )); u2node.insert( u2node.end(), make_pair( 1., node ));
} }
} } // loop on myEdge's
if ( u2node.size() != myNbPonits ) {
if ( u2node.size() + nbProxyNodes != myNbPonits )
{
MESSAGE("Wrong node parameters on edges, u2node.size():" MESSAGE("Wrong node parameters on edges, u2node.size():"
<<u2node.size()<<" != myNbPonits:"<<myNbPonits); <<u2node.size()<<" != myNbPonits:"<<myNbPonits);
return myPoints; return myPoints;
@ -318,46 +345,54 @@ const vector<UVPtStruct>& StdMeshers_FaceSide::GetUVPtStruct(bool isXConst,
// fill array of UVPtStruct // fill array of UVPtStruct
vector<uvPtStruct>* points = const_cast<vector<uvPtStruct>*>( &myPoints ); UVPtStructVec& points = const_cast< UVPtStructVec& >( myPoints );
points->resize( myNbPonits ); points.resize( myNbPonits );
int EdgeIndex = 0; int iPt = 0;
double prevNormPar = 0, paramSize = myNormPar[ EdgeIndex ]; double prevNormPar = 0, paramSize = myNormPar[ 0 ];
map< double, const SMDS_MeshNode*>::iterator u_node = u2node.begin(); map< double, const SMDS_MeshNode*>::iterator u_node = u2node.begin();
for (int i = 0 ; u_node != u2node.end(); ++u_node, ++i ) { for ( size_t iE = 0; iE < myEdge.size(); ++iE )
UVPtStruct & uvPt = (*points)[i]; {
if ( proxySubMesh[ iE ] ) // copy data from a proxy sub-mesh
{
const UVPtStructVec& edgeUVPtStruct = proxySubMesh[iE]->GetUVPtStructVec();
std::copy( edgeUVPtStruct.begin(), edgeUVPtStruct.end(), & points[iPt] );
// update normalized params
if ( myEdge.size() > 1 ) {
for ( size_t i = 0; i < edgeUVPtStruct.size(); ++i, ++iPt )
{
UVPtStruct & uvPt = points[iPt];
uvPt.normParam = prevNormPar + uvPt.normParam * paramSize;
uvPt.x = uvPt.y = uvPt.normParam;
}
--iPt; // to point to the 1st VERTEX of the next EDGE
}
}
else
{
for ( ; u_node != u2node.end(); ++u_node, ++iPt )
{
if ( myNormPar[ iE ]-eps < u_node->first )
break; // u_node is at VERTEX of the next EDGE
UVPtStruct & uvPt = points[iPt];
uvPt.node = u_node->second; uvPt.node = u_node->second;
uvPt.x = uvPt.y = uvPt.normParam = u_node->first; // -- normParam, x, y --------------------------------
if ( isXConst ) uvPt.x = constValue; uvPt.normParam = u_node->first;
else uvPt.y = constValue; uvPt.x = uvPt.y = uvPt.normParam;
// -- U ----------------------------------------------
const SMDS_EdgePosition* epos = const SMDS_EdgePosition* epos =
dynamic_cast<const SMDS_EdgePosition*>(uvPt.node->GetPosition()); dynamic_cast<const SMDS_EdgePosition*>(uvPt.node->GetPosition());
if (( myNormPar[ EdgeIndex ] < uvPt.normParam ) ||
( epos && uvPt.node->getshapeId() != myEdgeID[ EdgeIndex ])) // for myMissingVertexNodes
{
prevNormPar = myNormPar[ EdgeIndex ];
++EdgeIndex;
#ifdef _DEBUG_
if ( EdgeIndex >= myEdge.size() ) {
dump("DEBUG");
MESSAGE ( "WRONg EdgeIndex " << 1+EdgeIndex
<< " myNormPar.size()="<<myNormPar.size()
<< " myNormPar["<< EdgeIndex<<"]="<< myNormPar[ EdgeIndex ]
<< " uvPt.normParam="<<uvPt.normParam );
}
#endif
paramSize = myNormPar[ EdgeIndex ] - prevNormPar;
}
if ( epos ) { if ( epos ) {
uvPt.param = epos->GetUParameter(); uvPt.param = epos->GetUParameter();
} }
else { else {
double r = ( uvPt.normParam - prevNormPar )/ paramSize; double r = ( uvPt.normParam - prevNormPar )/ paramSize;
// uvPt.param = myFirst[EdgeIndex] * ( 1 - r ) + myLast[EdgeIndex] * r; uvPt.param = ( r > 0.5 ? myLast[iE] : myFirst[iE] );
uvPt.param = ( r > 0.5 ? myLast[EdgeIndex] : myFirst[EdgeIndex] );
} }
if ( !myC2d[ EdgeIndex ].IsNull() ) { // -- UV ---------------------------------------------
gp_Pnt2d p = myC2d[ EdgeIndex ]->Value( uvPt.param ); if ( !myC2d[ iE ].IsNull() ) {
gp_Pnt2d p = myC2d[ iE ]->Value( uvPt.param );
uvPt.u = p.X(); uvPt.u = p.X();
uvPt.v = p.Y(); uvPt.v = p.Y();
} }
@ -366,6 +401,22 @@ const vector<UVPtStruct>& StdMeshers_FaceSide::GetUVPtStruct(bool isXConst,
} }
} }
} }
// prepare for the next EDGE
if ( iE+1 < myEdge.size() )
{
prevNormPar = myNormPar[ iE ];
paramSize = myNormPar[ iE+1 ] - prevNormPar;
}
} // loop on myEdge's
// set <constValue>
if ( isXConst )
for ( iPt = 0; iPt < points.size(); ++iPt ) points[ iPt ].x = constValue;
else
for ( iPt = 0; iPt < points.size(); ++iPt ) points[ iPt ].y = constValue;
} // if ( myPoints.empty())
return myPoints; return myPoints;
} }
@ -429,8 +480,8 @@ std::vector<const SMDS_MeshNode*> StdMeshers_FaceSide::GetOrderedNodes() const
{ {
if ( NbEdges() == 0 ) return resultNodes; if ( NbEdges() == 0 ) return resultNodes;
SMESHDS_Mesh* meshDS = myMesh->GetMeshDS(); SMESHDS_Mesh* meshDS = myProxyMesh->GetMeshDS();
SMESH_MesherHelper helper(*myMesh); SMESH_MesherHelper helper(*myProxyMesh->GetMesh());
bool paramOK; bool paramOK;
// Sort nodes of all edges putting them into a map // Sort nodes of all edges putting them into a map
@ -547,6 +598,31 @@ void StdMeshers_FaceSide::Reverse()
myNormPar[nbEdges-1]=1.; myNormPar[nbEdges-1]=1.;
myPoints.clear(); myPoints.clear();
myFalsePoints.clear(); myFalsePoints.clear();
for ( size_t i = 0; i < myEdge.size(); ++i )
reverseProxySubmesh( myEdge[i] );
}
}
//================================================================================
/*!
* \brief Reverse UVPtStructVec if a proxy sub-mesh of E
*/
//================================================================================
void StdMeshers_FaceSide::reverseProxySubmesh( const TopoDS_Edge& E )
{
if ( !myProxyMesh ) return;
if ( const SMESH_ProxyMesh::SubMesh* sm = myProxyMesh->GetProxySubMesh( E ))
{
UVPtStructVec& edgeUVPtStruct = (UVPtStructVec& ) sm->GetUVPtStructVec();
for ( size_t i = 0; i < edgeUVPtStruct.size(); ++i )
{
UVPtStruct & uvPt = edgeUVPtStruct[i];
uvPt.normParam = 1 - uvPt.normParam;
uvPt.x = 1 - uvPt.x;
uvPt.y = 1 - uvPt.y;
}
reverse( edgeUVPtStruct );
} }
} }
@ -676,7 +752,8 @@ gp_Pnt2d StdMeshers_FaceSide::Value2d(double U) const
TSideVector StdMeshers_FaceSide::GetFaceWires(const TopoDS_Face& theFace, TSideVector StdMeshers_FaceSide::GetFaceWires(const TopoDS_Face& theFace,
SMESH_Mesh & theMesh, SMESH_Mesh & theMesh,
const bool theIgnoreMediumNodes, const bool theIgnoreMediumNodes,
TError & theError) TError & theError,
SMESH_ProxyMesh::Ptr theProxyMesh)
{ {
TopoDS_Vertex V1; TopoDS_Vertex V1;
list< TopoDS_Edge > edges, internalEdges; list< TopoDS_Edge > edges, internalEdges;
@ -720,14 +797,16 @@ TSideVector StdMeshers_FaceSide::GetFaceWires(const TopoDS_Face& theFace,
} }
StdMeshers_FaceSide* wire = new StdMeshers_FaceSide( theFace, wireEdges, &theMesh, StdMeshers_FaceSide* wire = new StdMeshers_FaceSide( theFace, wireEdges, &theMesh,
/*isForward=*/true, theIgnoreMediumNodes); /*isForward=*/true, theIgnoreMediumNodes,
theProxyMesh );
wires[ iW ] = StdMeshers_FaceSidePtr( wire ); wires[ iW ] = StdMeshers_FaceSidePtr( wire );
from = to; from = to;
} }
while ( !internalEdges.empty() ) while ( !internalEdges.empty() )
{ {
StdMeshers_FaceSide* wire = new StdMeshers_FaceSide( theFace, internalEdges.back(), &theMesh, StdMeshers_FaceSide* wire = new StdMeshers_FaceSide( theFace, internalEdges.back(), &theMesh,
/*isForward=*/true, theIgnoreMediumNodes); /*isForward=*/true, theIgnoreMediumNodes,
theProxyMesh );
wires.push_back( StdMeshers_FaceSidePtr( wire )); wires.push_back( StdMeshers_FaceSidePtr( wire ));
internalEdges.pop_back(); internalEdges.pop_back();
} }

View File

@ -30,6 +30,8 @@
#include "SMESH_StdMeshers.hxx" #include "SMESH_StdMeshers.hxx"
#include "SMESH_ProxyMesh.hxx"
#include <Geom2d_Curve.hxx> #include <Geom2d_Curve.hxx>
#include <GeomAdaptor_Curve.hxx> #include <GeomAdaptor_Curve.hxx>
#include <TopoDS_Edge.hxx> #include <TopoDS_Edge.hxx>
@ -47,23 +49,11 @@ class Adaptor3d_Curve;
class BRepAdaptor_CompCurve; class BRepAdaptor_CompCurve;
class TopoDS_Face; class TopoDS_Face;
struct SMESH_ComputeError; struct SMESH_ComputeError;
typedef struct uvPtStruct
{
double param;
//int curvIndex;
double normParam;
double u; // original 2d parameter
double v;
double x; // 2d parameter, normalized [0,1]
double y;
const SMDS_MeshNode * node;
} UVPtStruct;
class StdMeshers_FaceSide; class StdMeshers_FaceSide;
typedef boost::shared_ptr< SMESH_ComputeError > TError;
typedef boost::shared_ptr< StdMeshers_FaceSide > StdMeshers_FaceSidePtr; typedef boost::shared_ptr< StdMeshers_FaceSide > StdMeshers_FaceSidePtr;
typedef std::vector< StdMeshers_FaceSidePtr > TSideVector; typedef std::vector< StdMeshers_FaceSidePtr > TSideVector;
typedef boost::shared_ptr< SMESH_ComputeError > TError;
//================================================================================ //================================================================================
/*! /*!
@ -82,7 +72,8 @@ public:
const TopoDS_Edge& theEdge, const TopoDS_Edge& theEdge,
SMESH_Mesh* theMesh, SMESH_Mesh* theMesh,
const bool theIsForward, const bool theIsForward,
const bool theIgnoreMediumNodes); const bool theIgnoreMediumNodes,
SMESH_ProxyMesh::Ptr theProxyMesh = SMESH_ProxyMesh::Ptr());
/*! /*!
* \brief Wrap several edges. Edges must be properly ordered and oriented. * \brief Wrap several edges. Edges must be properly ordered and oriented.
*/ */
@ -90,7 +81,8 @@ public:
std::list<TopoDS_Edge>& theEdges, std::list<TopoDS_Edge>& theEdges,
SMESH_Mesh* theMesh, SMESH_Mesh* theMesh,
const bool theIsForward, const bool theIsForward,
const bool theIgnoreMediumNodes); const bool theIgnoreMediumNodes,
SMESH_ProxyMesh::Ptr theProxyMesh = SMESH_ProxyMesh::Ptr());
/*! /*!
* \brief Simulate a side from a vertex using data from other FaceSide * \brief Simulate a side from a vertex using data from other FaceSide
*/ */
@ -103,8 +95,8 @@ public:
static TSideVector GetFaceWires(const TopoDS_Face& theFace, static TSideVector GetFaceWires(const TopoDS_Face& theFace,
SMESH_Mesh & theMesh, SMESH_Mesh & theMesh,
const bool theIgnoreMediumNodes, const bool theIgnoreMediumNodes,
TError & theError); TError & theError,
SMESH_ProxyMesh::Ptr theProxyMesh = SMESH_ProxyMesh::Ptr());
/*! /*!
* \brief Change orientation of side geometry * \brief Change orientation of side geometry
*/ */
@ -120,7 +112,7 @@ public:
/*! /*!
* \brief Return mesh * \brief Return mesh
*/ */
SMESH_Mesh* GetMesh() const { return myMesh; } SMESH_Mesh* GetMesh() const { return myProxyMesh->GetMesh(); }
/*! /*!
* \brief Return true if there are vertices without nodes * \brief Return true if there are vertices without nodes
*/ */
@ -133,13 +125,13 @@ public:
* Missing nodes are allowed only on internal vertices. * Missing nodes are allowed only on internal vertices.
* For a closed side, the 1st point repeats at end * For a closed side, the 1st point repeats at end
*/ */
const std::vector<UVPtStruct>& GetUVPtStruct(bool isXConst =0, double constValue =0) const; const UVPtStructVec& GetUVPtStruct(bool isXConst =0, double constValue =0) const;
/*! /*!
* \brief Simulates detailed data on nodes * \brief Simulates detailed data on nodes
* \param isXConst - true if normalized parameter X is constant * \param isXConst - true if normalized parameter X is constant
* \param constValue - constant parameter value * \param constValue - constant parameter value
*/ */
const std::vector<UVPtStruct>& SimulateUVPtStruct(int nbSeg, const UVPtStructVec& SimulateUVPtStruct(int nbSeg,
bool isXConst = 0, bool isXConst = 0,
double constValue = 0) const; double constValue = 0) const;
/*! /*!
@ -183,14 +175,6 @@ public:
* \brief Return last vertex of the i-the edge (count starts from zero) * \brief Return last vertex of the i-the edge (count starts from zero)
*/ */
TopoDS_Vertex LastVertex(int i=-1) const; TopoDS_Vertex LastVertex(int i=-1) const;
/*!
* \brief Return first normalized parameter of the i-the edge (count starts from zero)
*/
inline double FirstParameter(int i) const;
/*!
* \brief Return ast normalized parameter of the i-the edge (count starts from zero)
*/
inline double LastParameter(int i) const;
/*! /*!
* \brief Return side length * \brief Return side length
*/ */
@ -204,9 +188,45 @@ public:
void dump(const char* msg=0) const; void dump(const char* msg=0) const;
/*!
* \brief Return ID of i-th wrapped edge (count starts from zero)
*/
inline int EdgeID(int i) const;
/*!
* \brief Return p-curve of i-th wrapped edge (count starts from zero)
*/
inline Handle(Geom2d_Curve) Curve2d(int i) const;
/*!
* \brief Return first normalized parameter of the i-the edge (count starts from zero)
*/
inline double FirstParameter(int i) const;
/*!
* \brief Return last normalized parameter of the i-the edge (count starts from zero)
*/
inline double LastParameter(int i) const;
/*!
* \brief Return first parameter of the i-the edge (count starts from zero).
* EDGE orientation is taken into account
*/
inline double FirstU(int i) const;
/*!
* \brief Return last parameter of the i-the edge (count starts from zero).
* EDGE orientation is taken into account
*/
inline double LastU(int i) const;
/*!
* \brief Return length of i-th wrapped edge (count starts from zero)
*/
inline double EdgeLength(int i) const;
/*!
* \brief Return orientation of i-th wrapped edge (count starts from zero)
*/
inline bool IsReversed(int i) const;
protected: protected:
void reverseProxySubmesh( const TopoDS_Edge& E );
// DON't FORGET to update Reverse() when adding one more vector! // DON't FORGET to update Reverse() when adding one more vector!
std::vector<uvPtStruct> myPoints, myFalsePoints; std::vector<uvPtStruct> myPoints, myFalsePoints;
std::vector<TopoDS_Edge> myEdge; std::vector<TopoDS_Edge> myEdge;
@ -219,7 +239,7 @@ protected:
std::vector<double> myIsUniform; std::vector<double> myIsUniform;
double myLength; double myLength;
int myNbPonits, myNbSegments; int myNbPonits, myNbSegments;
SMESH_Mesh* myMesh; SMESH_ProxyMesh::Ptr myProxyMesh;
bool myMissingVertexNodes, myIgnoreMediumNodes; bool myMissingVertexNodes, myIgnoreMediumNodes;
gp_Pnt2d myDefaultPnt2d; gp_Pnt2d myDefaultPnt2d;
}; };
@ -265,7 +285,7 @@ inline double StdMeshers_FaceSide::Parameter(double U, TopoDS_Edge & edge) const
inline double StdMeshers_FaceSide::FirstParameter(int i) const inline double StdMeshers_FaceSide::FirstParameter(int i) const
{ {
return i==0 ? 0. : i<myNormPar.size() ? myNormPar[i-1] : 1.; return i==0 ? 0. : i<(int)myNormPar.size() ? myNormPar[i-1] : 1.;
} }
//================================================================================ //================================================================================
@ -276,7 +296,73 @@ inline double StdMeshers_FaceSide::FirstParameter(int i) const
inline double StdMeshers_FaceSide::LastParameter(int i) const inline double StdMeshers_FaceSide::LastParameter(int i) const
{ {
return i<myNormPar.size() ? myNormPar[i] : 1; return i < (int)myNormPar.size() ? myNormPar[i] : 1;
}
//================================================================================
/*!
* \brief Return first parameter of the i-the edge
*/
//================================================================================
inline double StdMeshers_FaceSide::FirstU(int i) const
{
return myFirst[ i % myFirst.size() ];
}
//================================================================================
/*!
* \brief Return last parameter of the i-the edge
*/
//================================================================================
inline double StdMeshers_FaceSide::LastU(int i) const
{
return myLast[ i % myLast.size() ];
}
//================================================================================
/*!
* \brief Return ID of i-th wrapped edge (count starts from zero)
*/
//================================================================================
inline int StdMeshers_FaceSide::EdgeID(int i) const
{
return myEdgeID[ i % myEdgeID.size() ];
}
//================================================================================
/*!
* \brief Return p-curve of i-th wrapped edge (count starts from zero)
*/
//================================================================================
inline Handle(Geom2d_Curve) StdMeshers_FaceSide::Curve2d(int i) const
{
return myC2d[ i % myC2d.size() ];
}
//================================================================================
/*!
* \brief Return length of i-th wrapped edge (count starts from zero)
*/
//================================================================================
inline double StdMeshers_FaceSide::EdgeLength(int i) const
{
return myEdgeLength[ i % myEdgeLength.size() ];
}
//================================================================================
/*!
* \brief Return orientation of i-th wrapped edge (count starts from zero)
*/
//================================================================================
inline bool StdMeshers_FaceSide::IsReversed(int i) const
{
return myFirst[i] > myLast[i];
} }
#endif #endif