case GeomAbs_Hyperbola:
case GeomAbs_Parabola:
return false;
- // case GeomAbs_BezierCurve:
- // case GeomAbs_BSplineCurve:
- // case GeomAbs_OtherCurve:
+ // case GeomAbs_BezierCurve:
+ // case GeomAbs_BSplineCurve:
+ // case GeomAbs_OtherCurve:
default:;
}
- const double f = curve.FirstParameter();
- const double l = curve.LastParameter();
- const gp_Pnt pf = curve.Value( f );
- const gp_Pnt pl = curve.Value( l );
- const gp_Vec v1( pf, pl );
- const double v1Len = v1.Magnitude();
- if ( v1Len < std::numeric_limits< double >::min() )
+
+ // evaluate how far from a straight line connecting the curve ends
+ // stand internal points of the curve
+ double f = curve.FirstParameter();
+ double l = curve.LastParameter();
+ gp_Pnt pf = curve.Value( f );
+ gp_Pnt pl = curve.Value( l );
+ gp_Vec lineVec( pf, pl );
+ double lineLen2 = lineVec.SquareMagnitude();
+ if ( lineLen2 < std::numeric_limits< double >::min() )
return false; // E seems closed
- const double tol = Min( 10 * curve.Tolerance(), v1Len * 1e-2 );
+
+ double edgeTol = 10 * curve.Tolerance();
+ double lenTol2 = lineLen2 * 1e-4;
+ double tol2 = Min( edgeTol * edgeTol, lenTol2 );
+
const double nbSamples = 7;
for ( int i = 0; i < nbSamples; ++i )
{
- const double r = ( i + 1 ) / nbSamples;
- const gp_Pnt pi = curve.Value( f * r + l * ( 1 - r ));
- const gp_Vec vi( pf, pi );
- const double h = 0.5 * v1.Crossed( vi ).Magnitude() / v1Len;
- if ( h > tol )
+ double r = ( i + 1 ) / nbSamples;
+ gp_Pnt pi = curve.Value( f * r + l * ( 1 - r ));
+ gp_Vec vi( pf, pi );
+ double h2 = lineVec.Crossed( vi ).SquareMagnitude() / lineLen2;
+ if ( h2 > tol2 )
return false;
}
return true;
}
// Remove bad elements, then equal nodes (order important)
- Remove( rmElemIds, false );
- Remove( rmNodeIds, true );
+ Remove( rmElemIds, /*isNodes=*/false );
+ Remove( rmNodeIds, /*isNodes=*/true );
return;
}
toRemove = true;
nbResElems = 0;
- if ( elem->IsQuadratic() && newElemDefs[0].myType == SMDSAbs_Face && nbNodes > 6 )
+ if ( newElemDefs[0].myIsQuad && newElemDefs[0].myType == SMDSAbs_Face && nbNodes > 6 )
{
// if corner nodes stick, remove medium nodes between them from uniqueNodes
int nbCorners = nbNodes / 2;
for ( int iCur = 0; iCur < nbCorners; ++iCur )
{
- int iPrev = ( iCur + 1 ) % nbCorners;
- if ( curNodes[ iCur ] == curNodes[ iPrev ] ) // corners stick
+ int iNext = ( iCur + 1 ) % nbCorners;
+ if ( curNodes[ iCur ] == curNodes[ iNext ] ) // corners stick
{
int iMedium = iCur + nbCorners;
vector< const SMDS_MeshNode* >::iterator i =
// | |
// +---+---+
// 0 7 3
- if (( nbUniqueNodes == 7 && nbRepl == 2 && iRepl[1] != 8 ) &&
- (( iRepl[0] == 1 && iRepl[1] == 4 && curNodes[1] == curNodes[0] ) ||
- ( iRepl[0] == 2 && iRepl[1] == 5 && curNodes[2] == curNodes[1] ) ||
- ( iRepl[0] == 3 && iRepl[1] == 6 && curNodes[3] == curNodes[2] ) ||
- ( iRepl[0] == 3 && iRepl[1] == 7 && curNodes[3] == curNodes[0] )))
+ if ( nbUniqueNodes == 7 &&
+ iRepl[0] < 4 &&
+ ( nbRepl == 1 || iRepl[1] != 8 ))
{
toRemove = false;
}
nodeUVs[1] = _triaDS->GetNode( nodeIDs[1] ).Coord();
nodeUVs[2] = _triaDS->GetNode( nodeIDs[2] ).Coord();
- SMESH_MeshAlgos::GetBarycentricCoords( uv,
- nodeUVs[0], nodeUVs[1], nodeUVs[2],
- bc[0], bc[1] );
- if ( bc[0] >= 0 && bc[1] >= 0 && bc[0] + bc[1] <= 1 )
+ if ( _triaDS->GetNode( nodeIDs[0] ).Movability() == BRepMesh_Frontier &&
+ _triaDS->GetNode( nodeIDs[1] ).Movability() == BRepMesh_Frontier &&
+ _triaDS->GetNode( nodeIDs[2] ).Movability() == BRepMesh_Frontier )
{
- bc[2] = 1 - bc[0] - bc[1];
- triaNodes[0] = nodeIDs[0] - 1;
- triaNodes[1] = nodeIDs[1] - 1;
- triaNodes[2] = nodeIDs[2] - 1;
- return tria;
+ SMESH_MeshAlgos::GetBarycentricCoords( uv,
+ nodeUVs[0], nodeUVs[1], nodeUVs[2],
+ bc[0], bc[1] );
+ if ( bc[0] >= 0 && bc[1] >= 0 && bc[0] + bc[1] <= 1 )
+ {
+ bc[2] = 1 - bc[0] - bc[1];
+ triaNodes[0] = nodeIDs[0] - 1;
+ triaNodes[1] = nodeIDs[1] - 1;
+ triaNodes[2] = nodeIDs[2] - 1;
+ return tria;
+ }
}
// look for a neighbor triangle, which is adjacent to a link intersected
// check parametrization of curve
if( !myIsUniform[i] )
{
- double aLen3dU = r * myEdgeLength[i] * ( myFirst[i]>myLast[i] ? -1. : 1.);
+ 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() ) {
// for each internal column find boundary nodes whose error to use for correction
prepareTopBotDelaunay();
- findDelaunayTriangles();
+ if ( !findDelaunayTriangles())
+ return false;
// compute coordinates of internal nodes by projecting (transfroming) src and tgt
// nodes towards the central layer
//================================================================================
/*!
* \brief For each internal node column, find Delaunay triangles including it
- * and Barycentric Coordinates withing the triangles. Fill in myTopBotTriangles
+ * and Barycentric Coordinates within the triangles. Fill in myTopBotTriangles
*/
//================================================================================
-void StdMeshers_Sweeper::findDelaunayTriangles()
+bool StdMeshers_Sweeper::findDelaunayTriangles()
{
const SMDS_MeshNode *botNode, *topNode;
const BRepMesh_Triangle *topTria;
myTopBotTriangles[ colID ] = tbTrias;
}
-#ifdef _DEBUG_
if ( myBotDelaunay->NbVisitedNodes() < nbInternalNodes )
- throw SALOME_Exception(LOCALIZED("Not all internal nodes found by Delaunay"));
-#endif
+ return false;
myBotDelaunay.reset();
myTopDelaunay.reset();
myNodeID2ColID.Clear();
+
+ return true;
}
//================================================================================
TNodeColumn& nodes );
void prepareTopBotDelaunay();
- void findDelaunayTriangles();
+ bool findDelaunayTriangles();
std::vector< TZColumn > myZColumns; // Z distribution of boundary nodes