Don't use BRep_Tool::Degenerated() which sometimes gives a wrong answer,
use SMESH_Algo::isDegenerated() instead
This commit is contained in:
eap 2013-08-23 07:44:07 +00:00
parent b293f7af31
commit 3c53917e76
8 changed files with 30 additions and 12 deletions

View File

@ -310,10 +310,10 @@ SMESH_Algo::GetAppliedHypothesis(SMESH_Mesh & aMesh,
double SMESH_Algo::EdgeLength(const TopoDS_Edge & E)
{
double UMin = 0, UMax = 0;
if (BRep_Tool::Degenerated(E))
return 0;
TopLoc_Location L;
Handle(Geom_Curve) C = BRep_Tool::Curve(E, L, UMin, UMax);
if ( C.IsNull() )
return 0.;
GeomAdaptor_Curve AdaptCurve(C, UMin, UMax); //range is important for periodic curves
double length = GCPnts_AbscissaPoint::Length(AdaptCurve, UMin, UMax);
return length;
@ -580,6 +580,20 @@ bool SMESH_Algo::isStraight( const TopoDS_Edge & E,
return true;
}
//================================================================================
/*!
* \brief Return true if an edge has no 3D curve
*/
//================================================================================
bool SMESH_Algo::isDegenerated( const TopoDS_Edge & E )
{
double f,l;
TopLoc_Location loc;
Handle(Geom_Curve) C = BRep_Tool::Curve( E, loc, f,l );
return C.IsNull();
}
//================================================================================
/*!
* \brief Return the node built on a vertex

View File

@ -361,6 +361,10 @@ public:
* \brief Return true if an edge can be considered straight
*/
static bool isStraight( const TopoDS_Edge & E, const bool degenResult=false );
/*!
* \brief Return true if an edge has no 3D curve
*/
static bool isDegenerated( const TopoDS_Edge & E );
/*!
* \brief Return the node built on a vertex

View File

@ -4976,7 +4976,7 @@ SMESH_MeshEditor::ExtrusionAlongTrack (TIDSortedElemSet & theElements,
if( aS.ShapeType() == TopAbs_EDGE ) {
aTrackEdge = TopoDS::Edge( aS );
// the Edge must not be degenerated
if ( BRep_Tool::Degenerated( aTrackEdge ) )
if ( SMESH_Algo::isDegenerated( aTrackEdge ) )
return EXTR_BAD_PATH_SHAPE;
TopExp::Vertices( aTrackEdge, aV1, aV2 );
aItN = theTrack->GetFather()->GetSubMesh( aV1 )->GetSubMeshDS()->GetNodes();
@ -5264,7 +5264,7 @@ SMESH_MeshEditor::ExtrusionAlongTrack (TIDSortedElemSet & theElements,
else if( aS.ShapeType() == TopAbs_EDGE ) {
aTrackEdge = TopoDS::Edge( aS );
// the Edge must not be degenerated
if ( BRep_Tool::Degenerated( aTrackEdge ) )
if ( SMESH_Algo::isDegenerated( aTrackEdge ) )
return EXTR_BAD_PATH_SHAPE;
TopExp::Vertices( aTrackEdge, aV1, aV2 );
const SMDS_MeshNode* aN1 = SMESH_Algo::VertexNode( aV1, pMeshDS );
@ -5290,7 +5290,7 @@ SMESH_MeshEditor::ExtrusionAlongTrack (TIDSortedElemSet & theElements,
TopExp_Explorer eExp(aS, TopAbs_EDGE);
for(; eExp.More(); eExp.Next()) {
TopoDS_Edge E = TopoDS::Edge( eExp.Current() );
if( BRep_Tool::Degenerated(E) ) continue;
if( SMESH_Algo::isDegenerated(E) ) continue;
SMESH_subMesh* SM = theTrack->GetSubMesh(E);
if(SM) {
LSM.push_back(SM);

View File

@ -281,7 +281,7 @@ void SMESH_MesherHelper::SetSubShape(const TopoDS_Shape& aSh)
}
// look for a degenerated edge
if ( BRep_Tool::Degenerated( edge )) {
if ( SMESH_Algo::isDegenerated( edge )) {
myDegenShapeIds.insert( meshDS->ShapeToIndex( edge ));
for ( TopExp_Explorer v( edge, TopAbs_VERTEX ); v.More(); v.Next() )
myDegenShapeIds.insert( meshDS->ShapeToIndex( v.Current() ));
@ -3825,7 +3825,7 @@ namespace { // Structures used by FixQuadraticElements()
{
// check if the EDGE needs checking
const TopoDS_Edge& edge = TopoDS::Edge( edgeIt.Current() );
if ( BRep_Tool::Degenerated( edge ) )
if ( SMESH_Algo::isDegenerated( edge ) )
continue;
if ( theHelper.IsRealSeam( edge ) &&
edge.Orientation() == TopAbs_REVERSED )

View File

@ -1965,7 +1965,7 @@ bool SMESH_subMesh::checkComputeError(SMESH_Algo* theAlgo,
if ( _computeState != COMPUTE_OK )
{
if ( _subShape.ShapeType() == TopAbs_EDGE &&
BRep_Tool::Degenerated( TopoDS::Edge( _subShape )) )
SMESH_Algo::isDegenerated( TopoDS::Edge( _subShape )) )
_computeState = COMPUTE_OK;
else if ( theComputeOK )
_computeError = SMESH_ComputeError::New(COMPERR_NO_MESH_ON_SHAPE,"",theAlgo);

View File

@ -2088,7 +2088,7 @@ bool StdMeshers_Prism_3D::initPrism(Prism_3D::TPrismTopo& thePrism,
if ( botSM ) {
if ( ! botSM->GetSubShape().IsSame( thePrism.myBottom )) {
std::swap( botSM, topSM );
if ( ! botSM->GetSubShape().IsSame( thePrism.myBottom ))
if ( !botSM || ! botSM->GetSubShape().IsSame( thePrism.myBottom ))
return toSM( error( COMPERR_BAD_INPUT_MESH,
"Incompatible non-structured sub-meshes"));
}
@ -2571,7 +2571,7 @@ bool StdMeshers_PrismAsBlock::GetLayersTransformation(vector<gp_Trsf> &
list< TopoDS_Edge >::const_iterator edgeIt = prism.myBottomEdges.begin();
for ( int iE = 0; iE < prism.myNbEdgesInWires.front(); ++iE, ++edgeIt )
{
if ( BRep_Tool::Degenerated( *edgeIt )) continue;
if ( SMESH_Algo::isDegenerated( *edgeIt )) continue;
const TParam2ColumnMap* u2colMap =
GetParam2ColumnMap( MeshDS()->ShapeToIndex( *edgeIt ), isReverse );
if ( !u2colMap ) return false;

View File

@ -901,7 +901,7 @@ FaceQuadStruct::Ptr StdMeshers_Quadrangle_2D::CheckNbEdges(SMESH_Mesh &
sideEdges.splice(sideEdges.begin(), edges, --edges.end());
}
}
if ( sideEdges.size() == 1 && BRep_Tool::Degenerated( sideEdges.front() ))
if ( sideEdges.size() == 1 && SMESH_Algo::isDegenerated( sideEdges.front() ))
degenSides.push_back( nbSides );
quad->side.push_back(new StdMeshers_FaceSide(F, sideEdges, &aMesh, nbSides < QUAD_TOP_SIDE,

View File

@ -786,7 +786,7 @@ namespace
for ( ; eExp.More(); eExp.Next() )
{
const TopoDS_Edge& E = TopoDS::Edge( eExp.Current() );
if ( BRep_Tool::Degenerated( E )) continue;
if ( SMESH_Algo::isDegenerated( E )) continue;
// check if 2D curve is concave
BRepAdaptor_Curve2d curve( E, F );
const int nbIntervals = curve.NbIntervals( GeomAbs_C2 );