-// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
#include <TopoDS_Wire.hxx>
#include <map>
+#include <limits>
#include "utilities.h"
*/
//================================================================================
-StdMeshers_FaceSide::StdMeshers_FaceSide(const TopoDS_Face& theFace,
- const TopoDS_Edge& theEdge,
- SMESH_Mesh* theMesh,
- const bool theIsForward,
- const bool theIgnoreMediumNodes)
+StdMeshers_FaceSide::StdMeshers_FaceSide(const TopoDS_Face& theFace,
+ const TopoDS_Edge& theEdge,
+ SMESH_Mesh* theMesh,
+ const bool theIsForward,
+ const bool theIgnoreMediumNodes,
+ SMESH_ProxyMesh::Ptr theProxyMesh)
{
list<TopoDS_Edge> edges(1,theEdge);
- *this = StdMeshers_FaceSide( theFace, edges, theMesh, theIsForward, theIgnoreMediumNodes );
+ *this = StdMeshers_FaceSide( theFace, edges, theMesh, theIsForward,
+ theIgnoreMediumNodes, theProxyMesh );
}
//================================================================================
*/
//================================================================================
-StdMeshers_FaceSide::StdMeshers_FaceSide(const TopoDS_Face& theFace,
- list<TopoDS_Edge>& theEdges,
- SMESH_Mesh* theMesh,
- const bool theIsForward,
- const bool theIgnoreMediumNodes)
+StdMeshers_FaceSide::StdMeshers_FaceSide(const TopoDS_Face& theFace,
+ list<TopoDS_Edge>& theEdges,
+ SMESH_Mesh* theMesh,
+ const bool theIsForward,
+ const bool theIgnoreMediumNodes,
+ SMESH_ProxyMesh::Ptr theProxyMesh)
{
int nbEdges = theEdges.size();
myEdge.resize ( nbEdges );
myIsUniform.resize ( nbEdges, true );
myLength = 0;
myNbPonits = myNbSegments = 0;
- myMesh = theMesh;
+ myProxyMesh = theProxyMesh;
myMissingVertexNodes = false;
myIgnoreMediumNodes = theIgnoreMediumNodes;
myDefaultPnt2d = gp_Pnt2d( 1e+100, 1e+100 );
+ if ( !myProxyMesh ) myProxyMesh.reset( new SMESH_ProxyMesh( *theMesh ));
if ( nbEdges == 0 ) return;
- SMESHDS_Mesh* meshDS = theMesh->GetMeshDS();
+ SMESHDS_Mesh* meshDS = myProxyMesh->GetMeshDS();
int nbDegen = 0;
list<TopoDS_Edge>::iterator edge = theEdges.begin();
if ( myEdge[i].Orientation() == TopAbs_REVERSED )
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();
if ( theIgnoreMediumNodes ) {
SMDS_ElemIteratorPtr elemIt = sm->GetElements();
myNbPonits += nbN;
myNbSegments += sm->NbElements();
}
+
// TopExp::FirstVertex() and TopExp::LastVertex() return NULL from INTERNAL edge
vExp.Initialize( *edge );
if ( vExp.Value().Orientation() == TopAbs_REVERSED ) vExp.Next();
else
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)
{
Geom2dAdaptor_Curve A2dC( myC2d[i],
double d4 = GCPnts_AbscissaPoint::Length( A2dC, myFirst[i], p4 );
//cout<<"len = "<<len<<" d2 = "<<d2<<" fabs(2*d2/len-1.0) = "<<fabs(2*d2/len-1.0)<<endl;
myIsUniform[i] = !( fabs(2*d2/myEdgeLength[i]-1.0) > 0.01 || fabs(2*d4/d2-1.0) > 0.01 );
- if ( !myIsUniform[i] )
+ //if ( !myIsUniform[i] ) to implement Value3d(u)
{
double fp,lp;
- TopLoc_Location L;
- Handle(Geom_Curve) C3d = BRep_Tool::Curve(myEdge[i],L,fp,lp);
+ Handle(Geom_Curve) C3d = BRep_Tool::Curve(myEdge[i],fp,lp);
myC3dAdaptor[i].Load( C3d, fp,lp );
}
}
- }
+ // reverse a proxy submesh
+ if ( !theIsForward )
+ reverseProxySubmesh( myEdge[i] );
+
+ } // loop on edges
+
vExp.Initialize( theEdges.back() );
if ( vExp.Value().Orientation() != TopAbs_REVERSED ) vExp.Next();
if ( vExp.More() )
//================================================================================
/*!
* \brief Constructor of a side for vertex using data from other FaceSide
- * \param theVertex - the vertex
- * \param theSide - the side
+ * \param theVertex - the vertex
+ * \param theSide - the side
*/
//================================================================================
-StdMeshers_FaceSide::StdMeshers_FaceSide(const SMDS_MeshNode* theNode,
- const gp_Pnt2d thePnt2d,
- const StdMeshers_FaceSide* theSide)
+StdMeshers_FaceSide::StdMeshers_FaceSide(const StdMeshers_FaceSide* theSide,
+ const SMDS_MeshNode* theNode,
+ const gp_Pnt2d* thePnt2d1,
+ const gp_Pnt2d* thePnt2d2,
+ const Handle(Geom2d_Curve)& theC2d,
+ const double theUFirst,
+ const double theULast)
{
- myC2d.resize(1);
+ myC2d.push_back ( theC2d );
+ myFirst.push_back ( theUFirst );
+ myLast.push_back ( theULast );
+ myNormPar.push_back ( 1. );
+ myIsUniform.push_back( true );
+ myEdgeID.push_back ( 0 );
+ myLength = 0;
+ myProxyMesh = theSide->myProxyMesh;
+ myDefaultPnt2d = *thePnt2d1;
+ myPoints = theSide->GetUVPtStruct();
+ myNbPonits = myPoints.size();
+ myNbSegments = theSide->myNbSegments;
+ if ( thePnt2d2 )
+ for ( size_t i = 0; i < myPoints.size(); ++i )
+ {
+ double r = i / ( myPoints.size() - 1. );
+ myPoints[i].u = (1-r) * thePnt2d1->X() + r * thePnt2d2->X();
+ myPoints[i].v = (1-r) * thePnt2d1->Y() + r * thePnt2d2->Y();
+ myPoints[i].node = theNode;
+ }
+ else
+ for ( size_t i = 0; i < myPoints.size(); ++i )
+ {
+ myPoints[i].u = thePnt2d1->X();
+ myPoints[i].v = thePnt2d1->Y();
+ myPoints[i].node = theNode;
+ }
+}
+
+//================================================================================
+/*
+ * Create a side from an UVPtStructVec
+ */
+//================================================================================
+
+StdMeshers_FaceSide::StdMeshers_FaceSide(UVPtStructVec& theSideNodes,
+ const TopoDS_Face& theFace)
+{
+ myEdge.resize( 1 );
+ myEdgeID.resize( 1, -1 );
+ myC2d.resize( 1 );
+ myC3dAdaptor.resize( 1 );
+ myFirst.resize( 1, 0. );
+ myLast.resize( 1, 1. );
+ myNormPar.resize( 1, 1. );
+ myIsUniform.resize( 1, 1 );
+ myMissingVertexNodes = myIgnoreMediumNodes = false;
+ myDefaultPnt2d.SetCoord( 1e100, 1e100 );
+
+ myPoints = theSideNodes;
+ myNbPonits = myPoints.size();
+ myNbSegments = myNbPonits + 1;
+
myLength = 0;
- myMesh = theSide->GetMesh();
- myDefaultPnt2d = thePnt2d;
-
- myPoints = theSide->GetUVPtStruct();
- myNbPonits = myNbSegments = myPoints.size();
- std::vector<uvPtStruct>::iterator it = myPoints.begin();
- for(; it!=myPoints.end(); it++) {
- (*it).u = thePnt2d.X();
- (*it).v = thePnt2d.Y();
- (*it).y = 0.0;
- (*it).node = theNode;
+ if ( !myPoints.empty() )
+ {
+ myPoints[0].normParam = 0;
+ if ( myPoints[0].node &&
+ myPoints.back().node &&
+ myPoints[ myNbPonits/2 ].node )
+ {
+ gp_Pnt pPrev = SMESH_TNodeXYZ( myPoints[0].node );
+ for ( size_t i = 1; i < myPoints.size(); ++i )
+ {
+ gp_Pnt p = SMESH_TNodeXYZ( myPoints[i].node );
+ myLength += p.Distance( pPrev );
+ myPoints[i].normParam = myLength;
+ pPrev = p;
+ }
+ }
+ else if ( !theFace.IsNull() )
+ {
+ TopLoc_Location loc;
+ Handle(Geom_Surface) surf = BRep_Tool::Surface( theFace, loc );
+ gp_Pnt pPrev = surf->Value( myPoints[0].u, myPoints[0].v );
+ for ( size_t i = 1; i < myPoints.size(); ++i )
+ {
+ gp_Pnt p = surf->Value( myPoints[i].u, myPoints[i].v );
+ myLength += p.Distance( pPrev );
+ myPoints[i].normParam = myLength;
+ pPrev = p;
+ }
+ }
+ else
+ {
+ gp_Pnt2d pPrev = myPoints[0].UV();
+ for ( size_t i = 1; i < myPoints.size(); ++i )
+ {
+ gp_Pnt2d p = myPoints[i].UV();
+ myLength += p.Distance( pPrev );
+ myPoints[i].normParam = myLength;
+ pPrev = p;
+ }
+ }
+ if ( myLength > std::numeric_limits<double>::min() )
+ for ( size_t i = 1; i < myPoints.size(); ++i )
+ myPoints[i].normParam /= myLength;
}
+ myEdgeLength.resize( 1, myLength );
}
//================================================================================
-/*!
- * \brief Return info on nodes on the side
- * \retval UVPtStruct* - array of data structures
+/*
+ * Return info on nodes on the side
*/
//================================================================================
if ( NbEdges() == 0 ) return myPoints;
- SMESHDS_Mesh* meshDS = myMesh->GetMeshDS();
- SMESH_MesherHelper helper(*myMesh);
+ SMESHDS_Mesh* meshDS = myProxyMesh->GetMeshDS();
+ SMESH_MesherHelper helper(*myProxyMesh->GetMesh());
bool paramOK;
+ double eps = 1e-100;
// sort nodes of all edges putting them into a map
map< double, const SMDS_MeshNode*> u2node;
- //int nbOnDegen = 0;
- for ( int i = 0; i < myEdge.size(); ++i )
+ vector< const SMESH_ProxyMesh::SubMesh* > proxySubMesh( myEdge.size());
+ 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
TopoDS_Vertex VV[2]; // TopExp::FirstVertex() returns NULL for INTERNAL edge
- VV[0] = SMESH_MesherHelper::IthVertex( 0, myEdge[i]);
- VV[1] = SMESH_MesherHelper::IthVertex( 1, myEdge[i]);
+ VV[0] = SMESH_MesherHelper::IthVertex( 0, myEdge[iE]);
+ VV[1] = SMESH_MesherHelper::IthVertex( 1, myEdge[iE]);
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
u2node.insert( u2node.end(), make_pair( prevNormPar, node ));
}
- else if ( i == 0 ) {
+ else if ( iE == 0 ) {
MESSAGE(" NO NODE on VERTEX" );
return myPoints;
}
// 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;
u2nodeVec.reserve( sm->NbNodes() );
SMDS_NodeIteratorPtr nItr = sm->GetNodes();
- double paramSize = myLast[i] - myFirst[i];
- double r = myNormPar[i] - prevNormPar;
- helper.SetSubShape( myEdge[i] );
+ double paramSize = myLast[iE] - myFirst[iE];
+ double r = myNormPar[iE] - prevNormPar;
+ helper.SetSubShape( myEdge[iE] );
helper.ToFixNodeParameters( true );
- if ( !myIsUniform[i] )
+ if ( !myIsUniform[iE] )
while ( nItr->more() )
{
const SMDS_MeshNode* node = nItr->next();
if ( myIgnoreMediumNodes && SMESH_MeshEditor::IsMedium( node, SMDSAbs_Edge ))
continue;
- double u = helper.GetNodeU( myEdge[i], node, 0, ¶mOK );
+ double u = helper.GetNodeU( myEdge[iE], node, 0, ¶mOK );
double aLenU = GCPnts_AbscissaPoint::Length
- ( const_cast<GeomAdaptor_Curve&>( myC3dAdaptor[i]), myFirst[i], u );
- if ( myEdgeLength[i] < aLenU ) // nonregression test "3D_mesh_NETGEN/G6"
+ ( const_cast<GeomAdaptor_Curve&>( myC3dAdaptor[iE]), myFirst[iE], u );
+ if ( myEdgeLength[iE] < aLenU ) // nonregression test "3D_mesh_NETGEN/G6"
{
u2nodeVec.clear();
break;
}
- double normPar = prevNormPar + r*aLenU/myEdgeLength[i];
+ double normPar = prevNormPar + r*aLenU/myEdgeLength[iE];
u2nodeVec.push_back( make_pair( normPar, node ));
}
nItr = sm->GetNodes();
const SMDS_MeshNode* node = nItr->next();
if ( myIgnoreMediumNodes && SMESH_MeshEditor::IsMedium( node, SMDSAbs_Edge ))
continue;
- double u = helper.GetNodeU( myEdge[i], node, 0, ¶mOK );
+ double u = helper.GetNodeU( myEdge[iE], node, 0, ¶mOK );
// 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 ));
}
for ( size_t j = 0; j < u2nodeVec.size(); ++j )
- u2node.insert( u2node.end(), u2nodeVec[j] );
+ u2node.insert( u2node.end(), u2nodeVec[j] );
}
// 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 );
if ( !node ) {
MESSAGE(" NO NODE on VERTEX" );
}
u2node.insert( u2node.end(), make_pair( 1., node ));
}
- }
- if ( u2node.size() != myNbPonits ) {
+ } // loop on myEdge's
+
+ if ( u2node.size() + nbProxyNodes != myNbPonits &&
+ u2node.size() + nbProxyNodes != NbPoints( /*update=*/true ))
+ {
MESSAGE("Wrong node parameters on edges, u2node.size():"
<<u2node.size()<<" != myNbPonits:"<<myNbPonits);
return myPoints;
// fill array of UVPtStruct
- vector<uvPtStruct>* points = const_cast<vector<uvPtStruct>*>( &myPoints );
- points->resize( myNbPonits );
+ UVPtStructVec& points = const_cast< UVPtStructVec& >( myPoints );
+ points.resize( myNbPonits );
- int EdgeIndex = 0;
- double prevNormPar = 0, paramSize = myNormPar[ EdgeIndex ];
+ int iPt = 0;
+ double prevNormPar = 0, paramSize = myNormPar[ 0 ];
map< double, const SMDS_MeshNode*>::iterator u_node = u2node.begin();
- for (int i = 0 ; u_node != u2node.end(); ++u_node, ++i ) {
- UVPtStruct & uvPt = (*points)[i];
- uvPt.node = u_node->second;
- uvPt.x = uvPt.y = uvPt.normParam = u_node->first;
- if ( isXConst ) uvPt.x = constValue;
- else uvPt.y = constValue;
- const SMDS_EdgePosition* epos =
- dynamic_cast<const SMDS_EdgePosition*>(uvPt.node->GetPosition());
- if (( myNormPar[ EdgeIndex ] < uvPt.normParam ) ||
- ( epos && uvPt.node->getshapeId() != myEdgeID[ EdgeIndex ])) // for myMissingVertexNodes
+ for ( size_t iE = 0; iE < myEdge.size(); ++iE )
+ {
+ if ( proxySubMesh[ iE ] ) // copy data from a proxy sub-mesh
{
- 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 );
+ const UVPtStructVec& edgeUVPtStruct = proxySubMesh[iE]->GetUVPtStructVec();
+ std::copy( edgeUVPtStruct.begin(), edgeUVPtStruct.end(), & points[iPt] );
+ // check orientation
+ double du1 = edgeUVPtStruct.back().param - edgeUVPtStruct[0].param;
+ double du2 = myLast[iE] - myFirst[iE];
+ if ( du1 * du2 < 0 )
+ {
+ std::reverse( & points[iPt], & points[iPt + edgeUVPtStruct.size()]);
+ for ( size_t i = 0; i < edgeUVPtStruct.size(); ++i )
+ points[iPt+i].normParam = 1. - points[iPt+i].normParam;
+ }
+ // 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
}
-#endif
- paramSize = myNormPar[ EdgeIndex ] - prevNormPar;
- }
- if ( epos ) {
- uvPt.param = epos->GetUParameter();
- }
- else {
- double r = ( uvPt.normParam - prevNormPar )/ paramSize;
-// uvPt.param = myFirst[EdgeIndex] * ( 1 - r ) + myLast[EdgeIndex] * r;
- uvPt.param = ( r > 0.5 ? myLast[EdgeIndex] : myFirst[EdgeIndex] );
}
- if ( !myC2d[ EdgeIndex ].IsNull() ) {
- gp_Pnt2d p = myC2d[ EdgeIndex ]->Value( uvPt.param );
- uvPt.u = p.X();
- uvPt.v = p.Y();
+ 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;
+ // -- normParam, x, y --------------------------------
+ uvPt.normParam = u_node->first;
+ uvPt.x = uvPt.y = uvPt.normParam;
+ // -- U ----------------------------------------------
+ const SMDS_EdgePosition* epos =
+ dynamic_cast<const SMDS_EdgePosition*>(uvPt.node->GetPosition());
+ if ( epos ) {
+ uvPt.param = epos->GetUParameter();
+ }
+ else {
+ double r = ( uvPt.normParam - prevNormPar )/ paramSize;
+ uvPt.param = ( r > 0.5 ? myLast[iE] : myFirst[iE] );
+ }
+ // -- UV ---------------------------------------------
+ if ( !myC2d[ iE ].IsNull() ) {
+ gp_Pnt2d p = myC2d[ iE ]->Value( uvPt.param );
+ uvPt.u = p.X();
+ uvPt.v = p.Y();
+ }
+ else {
+ uvPt.u = uvPt.v = 1e+100;
+ }
+ }
}
- else {
- uvPt.u = uvPt.v = 1e+100;
+ // 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;
}
//================================================================================
/*!
* \brief Falsificate info on nodes
- * \param nbSeg - nb of segments on the side
- * \retval UVPtStruct* - array of data structures
+ * \param nbSeg - nb of segments on the side
+ * \retval UVPtStruct* - array of data structures
*/
//================================================================================
{
if ( NbEdges() == 0 ) return resultNodes;
- SMESHDS_Mesh* meshDS = myMesh->GetMeshDS();
- SMESH_MesherHelper helper(*myMesh);
+ SMESHDS_Mesh* meshDS = myProxyMesh->GetMeshDS();
+ SMESH_MesherHelper helper(*myProxyMesh->GetMesh());
bool paramOK;
// Sort nodes of all edges putting them into a map
int nbEdges = myEdge.size();
for ( int i = nbEdges-1; i >= 0; --i ) {
std::swap( myFirst[i], myLast[i] );
- myEdge[i].Reverse();
+ if ( !myEdge[i].IsNull() )
+ myEdge[i].Reverse();
if ( i > 0 ) // at the first loop 1. is overwritten
myNormPar[i] = 1 - myNormPar[i-1];
}
reverse( myEdge );
reverse( myEdgeID );
reverse( myC2d );
- reverse( myC3dAdaptor );
+ //reverse( myC3dAdaptor );
reverse( myFirst );
reverse( myLast );
reverse( myNormPar );
if ( nbEdges > 0 )
{
myNormPar[nbEdges-1]=1.;
- myPoints.clear();
- myFalsePoints.clear();
+ if ( !myEdge[0].IsNull() )
+ {
+ for ( size_t i = 0; i < myEdge.size(); ++i )
+ reverseProxySubmesh( myEdge[i] );
+ myPoints.clear();
+ myFalsePoints.clear();
+ }
+ else
+ {
+ for ( size_t i = 0; i < myPoints.size(); ++i )
+ {
+ UVPtStruct & uvPt = myPoints[i];
+ uvPt.normParam = 1 - uvPt.normParam;
+ uvPt.x = 1 - uvPt.x;
+ uvPt.y = 1 - uvPt.y;
+ }
+ reverse( myPoints );
+
+ for ( size_t i = 0; i < myFalsePoints.size(); ++i )
+ {
+ UVPtStruct & uvPt = myFalsePoints[i];
+ uvPt.normParam = 1 - uvPt.normParam;
+ uvPt.x = 1 - uvPt.x;
+ uvPt.y = 1 - uvPt.y;
+ }
+ reverse( myFalsePoints );
+ }
+ }
+ for ( size_t i = 0; i < myEdge.size(); ++i )
+ {
+ if ( myEdge[i].IsNull() ) continue; // for a side on points only
+ double fp,lp;
+ Handle(Geom_Curve) C3d = BRep_Tool::Curve(myEdge[i],fp,lp);
+ if ( !C3d.IsNull() )
+ myC3dAdaptor[i].Load( C3d, fp,lp );
+ }
+}
+
+//=======================================================================
+//function : SetIgnoreMediumNodes
+//purpose : Make ignore medium nodes
+//=======================================================================
+
+void StdMeshers_FaceSide::SetIgnoreMediumNodes(bool toIgnore)
+{
+ if ( myIgnoreMediumNodes != toIgnore )
+ {
+ myIgnoreMediumNodes = toIgnore;
+
+ if ( !myPoints.empty() )
+ {
+ UVPtStructVec newPoints;
+ newPoints.reserve( myPoints.size()/2 + 1 );
+ for ( size_t i = 0; i < myPoints.size(); i += 2 )
+ newPoints.push_back( myPoints[i] );
+
+ myPoints.swap( newPoints );
+ }
+ else
+ {
+ NbPoints( /*update=*/true );
+ }
+ }
+}
+
+//=======================================================================
+//function : NbPoints
+//purpose : Return nb nodes on edges and vertices (+1 to be == GetUVPtStruct().size() )
+// Call it with update == true if mesh of this side can be recomputed
+// since creation of this side
+//=======================================================================
+
+int StdMeshers_FaceSide::NbPoints(const bool update) const
+{
+ if ( !myPoints.empty() )
+ return myPoints.size();
+
+ // if ( !myFalsePoints.empty() )
+ // return myFalsePoints.size();
+
+ if ( update && myEdge.size() > 0 )
+ {
+ StdMeshers_FaceSide* me = (StdMeshers_FaceSide*) this;
+ me->myNbPonits = 0;
+ me->myNbSegments = 0;
+ me->myMissingVertexNodes = false;
+
+ for ( int i = 0; i < NbEdges(); ++i )
+ {
+ TopoDS_Vertex v1 = SMESH_MesherHelper::IthVertex( 0, myEdge[i] );
+ if ( SMESH_Algo::VertexNode( v1, myProxyMesh->GetMeshDS() ))
+ me->myNbPonits += 1; // for the first end
+ else
+ me->myMissingVertexNodes = true;
+
+ if ( const SMESHDS_SubMesh* sm = myProxyMesh->GetSubMesh( Edge(i) )) {
+ int nbN = sm->NbNodes();
+ if ( myIgnoreMediumNodes ) {
+ SMDS_ElemIteratorPtr elemIt = sm->GetElements();
+ if ( elemIt->more() && elemIt->next()->IsQuadratic() )
+ nbN -= sm->NbElements();
+ }
+ me->myNbPonits += nbN;
+ me->myNbSegments += sm->NbElements();
+ }
+ }
+ TopoDS_Vertex v1 = SMESH_MesherHelper::IthVertex( 1, Edge( NbEdges()-1 ));
+ if ( SMESH_Algo::VertexNode( v1, myProxyMesh->GetMeshDS() ))
+ me->myNbPonits++; // for the last end
+ else
+ me->myMissingVertexNodes = true;
+ }
+ return myNbPonits;
+}
+
+//=======================================================================
+//function : NbSegments
+//purpose : Return nb edges
+// Call it with update == true if mesh of this side can be recomputed
+// since creation of this side
+//=======================================================================
+
+int StdMeshers_FaceSide::NbSegments(const bool update) const
+{
+ return NbPoints( update ), myNbSegments;
+}
+
+//================================================================================
+/*!
+ * \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 );
}
}
return new BRepAdaptor_CompCurve( aWire );
}
-
//================================================================================
/*!
* \brief Return 2D point by normalized parameter
return myC2d[ i ]->Value(par);
}
+ else if ( !myPoints.empty() )
+ {
+ int i = U * double( myPoints.size()-1 );
+ while ( i > 0 && myPoints[ i ].normParam > U )
+ --i;
+ while ( i+1 < myPoints.size() && myPoints[ i+1 ].normParam < U )
+ ++i;
+ double r = (( U - myPoints[ i ].normParam ) /
+ ( myPoints[ i+1 ].normParam - myPoints[ i ].normParam ));
+ return ( myPoints[ i ].UV() * ( 1 - r ) +
+ myPoints[ i+1 ].UV() * r );
+ }
return myDefaultPnt2d;
}
+//================================================================================
+/*!
+ * \brief Return XYZ by normalized parameter
+ * \param U - normalized parameter value
+ * \retval gp_Pnt - point
+ */
+//================================================================================
+
+gp_Pnt StdMeshers_FaceSide::Value3d(double U) const
+{
+ int i = EdgeIndex( U );
+ double prevU = i ? myNormPar[ i-1 ] : 0;
+ double r = ( U - prevU )/ ( myNormPar[ i ] - prevU );
+
+ double par = myFirst[i] * ( 1 - r ) + myLast[i] * r;
+
+ // check parametrization of curve
+ if( !myIsUniform[i] )
+ {
+ double aLen3dU = r * myEdgeLength[i] * ( myFirst[i]>myLast[i] ? -1. : 1.);
+ GCPnts_AbscissaPoint AbPnt
+ ( const_cast<GeomAdaptor_Curve&>( myC3dAdaptor[i]), aLen3dU, myFirst[i] );
+ if( AbPnt.IsDone() ) {
+ par = AbPnt.Parameter();
+ }
+ }
+ return myC3dAdaptor[ i ].Value(par);
+}
+
//================================================================================
/*!
* \brief Return wires of a face as StdMeshers_FaceSide's
*/
//================================================================================
-TSideVector StdMeshers_FaceSide::GetFaceWires(const TopoDS_Face& theFace,
- SMESH_Mesh & theMesh,
- const bool theIgnoreMediumNodes,
- TError & theError)
+TSideVector StdMeshers_FaceSide::GetFaceWires(const TopoDS_Face& theFace,
+ SMESH_Mesh & theMesh,
+ const bool theIgnoreMediumNodes,
+ TError & theError,
+ SMESH_ProxyMesh::Ptr theProxyMesh)
{
- TopoDS_Vertex V1;
list< TopoDS_Edge > edges, internalEdges;
list< int > nbEdgesInWires;
- int nbWires = SMESH_Block::GetOrderedEdges (theFace, V1, edges, nbEdgesInWires);
+ int nbWires = SMESH_Block::GetOrderedEdges (theFace, edges, nbEdgesInWires);
// split list of all edges into separate wires
TSideVector wires( nbWires );
}
StdMeshers_FaceSide* wire = new StdMeshers_FaceSide( theFace, wireEdges, &theMesh,
- /*isForward=*/true, theIgnoreMediumNodes);
+ /*isForward=*/true, theIgnoreMediumNodes,
+ theProxyMesh );
wires[ iW ] = StdMeshers_FaceSidePtr( wire );
from = to;
}
while ( !internalEdges.empty() )
{
StdMeshers_FaceSide* wire = new StdMeshers_FaceSide( theFace, internalEdges.back(), &theMesh,
- /*isForward=*/true, theIgnoreMediumNodes);
+ /*isForward=*/true, theIgnoreMediumNodes,
+ theProxyMesh );
wires.push_back( StdMeshers_FaceSidePtr( wire ));
internalEdges.pop_back();
}