-// Copyright (C) 2007-2013 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
_compatibleHypothesis.push_back("ImportSource1D");
}
-//=============================================================================
-/*!
- * Check presence of a hypothesis
- */
-//=============================================================================
-
-bool StdMeshers_Import_1D::CheckHypothesis
- (SMESH_Mesh& aMesh,
- const TopoDS_Shape& aShape,
- SMESH_Hypothesis::Hypothesis_Status& aStatus)
-{
- _sourceHyp = 0;
-
- const list <const SMESHDS_Hypothesis * >&hyps = GetUsedHypothesis(aMesh, aShape);
- if ( hyps.size() == 0 )
- {
- aStatus = SMESH_Hypothesis::HYP_MISSING;
- return false; // can't work with no hypothesis
- }
-
- if ( hyps.size() > 1 )
- {
- aStatus = SMESH_Hypothesis::HYP_ALREADY_EXIST;
- return false;
- }
-
- const SMESHDS_Hypothesis *theHyp = hyps.front();
-
- string hypName = theHyp->GetName();
-
- if (hypName == _compatibleHypothesis.front())
- {
- _sourceHyp = (StdMeshers_ImportSource1D *)theHyp;
- aStatus = SMESH_Hypothesis::HYP_OK;
- return true;
- }
-
- aStatus = SMESH_Hypothesis::HYP_INCOMPATIBLE;
- return true;
-}
-
//================================================================================
namespace // INTERNAL STUFF
//================================================================================
if ( !_importMeshSubDS ) return;
SMDS_ElemIteratorPtr eIt = _importMeshSubDS->GetElements();
while ( eIt->more() )
- meshDS->RemoveFreeElement( eIt->next(), _importMeshSubDS, /*fromGroups=*/false );
+ meshDS->RemoveFreeElement( eIt->next(), 0, /*fromGroups=*/false );
SMDS_NodeIteratorPtr nIt = _importMeshSubDS->GetNodes();
while ( nIt->more() )
- meshDS->RemoveFreeNode( nIt->next(), _importMeshSubDS, /*fromGroups=*/false );
+ meshDS->RemoveFreeNode( nIt->next(), 0, /*fromGroups=*/false );
+ _importMeshSubDS->Clear();
_n2n.clear();
_e2e.clear();
}
switch ( sm->GetSubShape().ShapeType() )
{
case TopAbs_EDGE:
+ if ( SMESH_Algo::isDegenerated( TopoDS::Edge( sm->GetSubShape() )))
+ continue;
case TopAbs_FACE:
_subM.insert( sm );
if ( !sm->IsEmpty() )
const SMESH_Hypothesis* hyp);
void removeSubmesh( SMESH_subMesh* sm, _ListenerData* data );
void clearSubmesh ( SMESH_subMesh* sm, _ListenerData* data, bool clearAllSub );
+ void clearN2N ( SMESH_Mesh* tgtMesh );
// mark sm as missing src hyp with valid groups
static void waitHypModification(SMESH_subMesh* sm)
bool rmGroups = (d->_copyGroupSubM.erase( sm ) && d->_copyGroupSubM.empty()) || rmMesh;
if ( rmMesh )
d->removeImportedMesh( sm->GetFather()->GetMeshDS() );
- if ( rmGroups && data )
+ if ( rmGroups && data && data->myType == SRC_HYP )
d->removeGroups( sm, data->_srcHyp );
}
}
//--------------------------------------------------------------------------------
+ /*!
+ * \brief Clear _ImportData::_n2n.
+ * _n2n is usefull within one mesh.Compute() only
+ */
+ void _Listener::clearN2N( SMESH_Mesh* tgtMesh )
+ {
+ list< _ImportData >& dList = get()->_tgtMesh2ImportData[tgtMesh];
+ list< _ImportData >::iterator d = dList.begin();
+ for ( ; d != dList.end(); ++d )
+ d->_n2n.clear();
+ }
+ //--------------------------------------------------------------------------------
/*!
* \brief Clear submeshes and remove imported mesh and/or groups if necessary
* \param sm - cleared submesh
// remove imported mesh and groups
d->removeImportedMesh( sm->GetFather()->GetMeshDS() );
- if ( data )
+ if ( data && data->myType == SRC_HYP )
d->removeGroups( sm, data->_srcHyp );
// clear the rest submeshes
{
SMESH_subMesh* subM = *sub;
_ListenerData* hypData = (_ListenerData*) subM->GetEventListenerData( get() );
- if ( hypData )
+ if ( hypData && hypData->myType == SRC_HYP )
d->removeGroups( sm, hypData->_srcHyp );
subM->ComputeStateEngine( SMESH_subMesh::CLEAN );
if ( sm->GetSubShape().ShapeType() == TopAbs_FACE )
sm->ComputeSubMeshStateEngine( SMESH_subMesh::CLEAN );
}
- if ( data )
+ if ( data && data->myType == SRC_HYP )
d->trackHypParams( sm, data->_srcHyp );
d->_n2n.clear();
d->_e2e.clear();
default:;
}
}
+ if ( !data->mySubMeshes.empty() )
+ clearN2N( data->mySubMeshes.front()->GetFather() );
}
else // event of Import submesh
{
d->_computedSubM.insert( *smIt);
}
}
+ // Clear _ImportData::_n2n if it's no more useful, i.e. when
+ // the event is not within mesh.Compute()
+ if ( SMESH_subMesh::ALGO_EVENT == eventType )
+ clearN2N( subMesh->GetFather() );
}
}
aBuilder.MakeCompound( comp );
shapeForSrcMesh = comp;
for ( int iSub = 0; iSub < nbSubShapes; ++iSub )
- aBuilder.Add( comp, pseudoSubShapes( subIndex+iSub ));
+ if ( subIndex+iSub <= pseudoSubShapes.Extent() )
+ aBuilder.Add( comp, pseudoSubShapes( subIndex+iSub ));
TopExp_Explorer vExp( tgtMeshDS->ShapeToMesh(), TopAbs_VERTEX );
aBuilder.Add( comp, vExp.Current() );
}
} // namespace
+//=============================================================================
+/*!
+ * Check presence of a hypothesis
+ */
+//=============================================================================
+
+bool StdMeshers_Import_1D::CheckHypothesis
+ (SMESH_Mesh& aMesh,
+ const TopoDS_Shape& aShape,
+ SMESH_Hypothesis::Hypothesis_Status& aStatus)
+{
+ _sourceHyp = 0;
+
+ const list <const SMESHDS_Hypothesis * >&hyps = GetUsedHypothesis(aMesh, aShape);
+ if ( hyps.size() == 0 )
+ {
+ aStatus = SMESH_Hypothesis::HYP_MISSING;
+ return false; // can't work with no hypothesis
+ }
+
+ if ( hyps.size() > 1 )
+ {
+ aStatus = SMESH_Hypothesis::HYP_ALREADY_EXIST;
+ return false;
+ }
+
+ const SMESHDS_Hypothesis *theHyp = hyps.front();
+
+ string hypName = theHyp->GetName();
+
+ if (hypName == _compatibleHypothesis.front())
+ {
+ _sourceHyp = (StdMeshers_ImportSource1D *)theHyp;
+ aStatus = _sourceHyp->GetGroups().empty() ? HYP_BAD_PARAMETER : HYP_OK;
+ if ( aStatus == HYP_BAD_PARAMETER )
+ _Listener::waitHypModification( aMesh.GetSubMesh( aShape ));
+ return aStatus == HYP_OK;
+ }
+
+ aStatus = SMESH_Hypothesis::HYP_INCOMPATIBLE;
+ return false;
+}
//=============================================================================
/*!