sm->ComputeSubMeshStateEngine( SMESH_subMesh::CHECK_COMPUTE_STATE );
}
}
+ GetMeshDS()->Modified();
_isModified = false;
}
//purpose :
//=======================================================================
-int SMESH_Mesh::STLToMesh(const char* theFileName)
+std::string SMESH_Mesh::STLToMesh(const char* theFileName)
{
if(_isShapeToMesh)
throw SALOME_Exception(LOCALIZED("a shape to mesh has already been defined"));
myReader.SetMeshId(-1);
myReader.Perform();
- return 1;
+ return myReader.GetName();
}
//================================================================================
}
}
HasModificationsToDiscard(); // to reset _isModified flag if a mesh becomes empty
+ GetMeshDS()->Modified();
if(MYDEBUG) subMesh->DumpAlgoState(true);
if(MYDEBUG) SCRUTE(ret);
}
HasModificationsToDiscard(); // to reset _isModified flag if mesh become empty
+ GetMeshDS()->Modified();
if(MYDEBUG) subMesh->DumpAlgoState(true);
if(MYDEBUG) SCRUTE(ret);
//=============================================================================
/*!
- * Get the SMESH_subMesh object implementation. Dont create it, return null
+ * Get the SMESH_subMesh object implementation. Don't create it, return null
* if it does not exist.
*/
//=============================================================================
//=============================================================================
/*!
- * Get the SMESH_subMesh object implementation. Dont create it, return null
+ * Get the SMESH_subMesh object implementation. Don't create it, return null
* if it does not exist.
*/
//=============================================================================
SMESH_Algo *algo;
const SMESH_HypoFilter* compatibleHypoKind;
list <const SMESHDS_Hypothesis * > usedHyps;
-
- // keep sub-meshes not to miss ones whose state can change due to notifying others
vector< SMESH_subMesh* > smToNotify;
+ bool allMeshedEdgesNotified = true;
SMESH_subMeshIteratorPtr smIt( _subMeshHolder->GetIterator() );
while ( smIt->more() )
{
SMESH_subMesh* aSubMesh = smIt->next();
+ bool toNotify = false;
// if aSubMesh meshing depends on hyp,
// we call aSubMesh->AlgoStateEngine( MODIF_HYP, hyp ) that causes either
// 1) clearing already computed aSubMesh or
// 2) changing algo_state from MISSING_HYP to HYP_OK when parameters of hyp becomes valid,
// other possible changes are not interesting. (IPAL0052457 - assigning hyp performance pb)
- if ( aSubMesh->GetComputeState() != SMESH_subMesh::COMPUTE_OK &&
- aSubMesh->GetComputeState() != SMESH_subMesh::FAILED_TO_COMPUTE &&
- aSubMesh->GetAlgoState() != SMESH_subMesh::MISSING_HYP &&
- !hyp->DataDependOnParams() )
- continue;
-
- const TopoDS_Shape & aSubShape = aSubMesh->GetSubShape();
-
- if (( aSubMesh->IsApplicableHypotesis( hyp )) &&
- ( algo = aSubMesh->GetAlgo() ) &&
- ( compatibleHypoKind = algo->GetCompatibleHypoFilter( !hyp->IsAuxiliary() )) &&
- ( compatibleHypoKind->IsOk( hyp, aSubShape )))
+ if ( aSubMesh->GetComputeState() == SMESH_subMesh::COMPUTE_OK ||
+ aSubMesh->GetComputeState() == SMESH_subMesh::FAILED_TO_COMPUTE ||
+ aSubMesh->GetAlgoState() == SMESH_subMesh::MISSING_HYP ||
+ hyp->DataDependOnParams() )
{
- // check if hyp is used by algo
- usedHyps.clear();
- if ( GetHypotheses( aSubMesh, *compatibleHypoKind, usedHyps, true ) &&
- find( usedHyps.begin(), usedHyps.end(), hyp ) != usedHyps.end() )
+ const TopoDS_Shape & aSubShape = aSubMesh->GetSubShape();
+
+ if (( aSubMesh->IsApplicableHypotesis( hyp )) &&
+ ( algo = aSubMesh->GetAlgo() ) &&
+ ( compatibleHypoKind = algo->GetCompatibleHypoFilter( !hyp->IsAuxiliary() )) &&
+ ( compatibleHypoKind->IsOk( hyp, aSubShape )))
{
- smToNotify.push_back( aSubMesh );
+ // check if hyp is used by algo
+ usedHyps.clear();
+ toNotify = ( GetHypotheses( aSubMesh, *compatibleHypoKind, usedHyps, true ) &&
+ std::find( usedHyps.begin(), usedHyps.end(), hyp ) != usedHyps.end() );
}
}
+ if ( toNotify )
+ {
+ smToNotify.push_back( aSubMesh );
+ if ( aSubMesh->GetAlgoState() == SMESH_subMesh::MISSING_HYP )
+ allMeshedEdgesNotified = false; // update of algo state needed, not mesh clearing
+ }
+ else
+ {
+ if ( !aSubMesh->IsEmpty() &&
+ aSubMesh->GetSubShape().ShapeType() == TopAbs_EDGE )
+ allMeshedEdgesNotified = false;
+ }
}
+ if ( smToNotify.empty() )
+ return;
- for ( size_t i = 0; i < smToNotify.size(); ++i )
+ // if all meshed EDGEs will be notified then the notification is equivalent
+ // to the whole mesh clearing, which is usually faster
+ if ( allMeshedEdgesNotified && NbNodes() > 0 )
{
- smToNotify[i]->AlgoStateEngine(SMESH_subMesh::MODIF_HYP,
- const_cast< SMESH_Hypothesis*>( hyp ));
+ Clear();
+ }
+ else
+ {
+ // notify in reverse order to avoid filling the pool of IDs
+ for ( int i = smToNotify.size()-1; i >= 0; --i )
+ smToNotify[i]->AlgoStateEngine(SMESH_subMesh::MODIF_HYP,
+ const_cast< SMESH_Hypothesis*>( hyp ));
}
-
HasModificationsToDiscard(); // to reset _isModified flag if mesh becomes empty
GetMeshDS()->Modified();
}
* - 2D if all mesh nodes lie on XOY coordinate plane, or
* - 3D in the rest cases.
* If \a theAutoDimension is \c false, the space dimension is always 3.
+ * \param [in] theAddODOnVertices - to create 0D elements on all vertices
+ * \param [in] theAllElemsToGroup - to make every element to belong to any group (PAL23413)
* \return int - mesh index in the file
*/
//================================================================================
int theVersion,
const SMESHDS_Mesh* meshPart,
bool theAutoDimension,
- bool theAddODOnVertices)
+ bool theAddODOnVertices,
+ bool theAllElemsToGroup)
throw(SALOME_Exception)
{
+ //MESSAGE("MED_VERSION:"<< theVersion);
SMESH_TRY;
DriverMED_W_SMESHDS_Mesh myWriter;
myWriter.AddGroupOfEdges();
myWriter.AddGroupOfFaces();
myWriter.AddGroupOfVolumes();
+ myWriter.AddGroupOf0DElems();
+ myWriter.AddGroupOfBalls();
}
+ if ( theAllElemsToGroup )
+ myWriter.AddAllToGroup();
// Pass groups to writer. Provide unique group names.
//set<string> aGroupNames; // Corrected for Mantis issue 0020028
cmd += "from medutilities import my_remove ; my_remove(r'" + medfilename + "')";
cmd += "\"";
system(cmd.c_str());
- ExportMED(medfilename.c_str(), theMeshName, theAutoGroups, 1);
+ ExportMED(medfilename.c_str(), theMeshName, theAutoGroups, /*theVersion=*/1,
+ /*meshPart=*/NULL, /*theAutoDimension=*/false, /*theAddODOnVertices=*/false,
+ /*theAllElemsToGroup=*/true ); // theAllElemsToGroup is for PAL0023413
#ifdef WIN32
cmd = "%PYTHONBIN% ";
#else
myWriter.SetMeshId(_id);
// myWriter.SetGroups(_mapGroup);
+ // pass group names to SMESHDS
if ( !meshPart )
{
for ( map<int, SMESH_Group*>::iterator it = _mapGroup.begin(); it != _mapGroup.end(); it++ ) {
void SMESH_Mesh::ExportSTL(const char * file,
const bool isascii,
+ const char * name,
const SMESHDS_Mesh* meshPart) throw(SALOME_Exception)
{
Unexpect aCatch(SalomeException);
myWriter.SetIsAscii( isascii );
myWriter.SetMesh( meshPart ? (SMESHDS_Mesh*) meshPart : _myMeshDS);
myWriter.SetMeshId(_id);
+ if ( name ) myWriter.SetName( name );
myWriter.Perform();
}
void SMESH_Mesh::ExportCGNS(const char * file,
const SMESHDS_Mesh* meshDS,
- const char * meshName)
+ const char * meshName,
+ const bool groupElemsByType)
{
int res = Driver_Mesh::DRS_FAIL;
+
+ // pass group names to SMESHDS
+ for ( map<int, SMESH_Group*>::iterator it = _mapGroup.begin(); it != _mapGroup.end(); it++ ) {
+ SMESH_Group* group = it->second;
+ SMESHDS_GroupBase* groupDS = group->GetGroupDS();
+ if ( groupDS ) {
+ string groupName = group->GetName();
+ groupDS->SetStoreName( groupName.c_str() );
+ }
+ }
#ifdef WITH_CGNS
+
DriverCGNS_Write myWriter;
myWriter.SetFile( file );
myWriter.SetMesh( const_cast<SMESHDS_Mesh*>( meshDS ));
myWriter.SetMeshName( SMESH_Comment("Mesh_") << meshDS->GetPersistentId());
if ( meshName && meshName[0] )
myWriter.SetMeshName( meshName );
+ myWriter.SetElementsByType( groupElemsByType );
res = myWriter.Perform();
+ if ( res != Driver_Mesh::DRS_OK )
+ {
+ SMESH_ComputeErrorPtr err = myWriter.GetError();
+ if ( err && !err->IsOK() && !err->myComment.empty() )
+ throw SALOME_Exception(("Export failed: " + err->myComment ).c_str() );
+ }
+
#endif
if ( res != Driver_Mesh::DRS_OK )
throw SALOME_Exception("Export failed");
return _myMeshDS->GetMeshInfo().NbPrisms(order);
}
+int SMESH_Mesh::NbQuadPrisms() const throw (SALOME_Exception)
+{
+ Unexpect aCatch(SalomeException);
+ return _myMeshDS->GetMeshInfo().NbQuadPrisms();
+}
+
+int SMESH_Mesh::NbBiQuadPrisms() const throw (SALOME_Exception)
+{
+ Unexpect aCatch(SalomeException);
+ return _myMeshDS->GetMeshInfo().NbBiQuadPrisms();
+}
+
+
//================================================================================
/*!
* \brief Return number of hexagonal prisms in the mesh
//=======================================================================
//function : IsNotConformAllowed
-//purpose : check if a hypothesis alowing notconform mesh is present
+//purpose : check if a hypothesis allowing notconform mesh is present
//=======================================================================
bool SMESH_Mesh::IsNotConformAllowed() const
//=======================================================================
//function : GetAncestors
//purpose : return list of ancestors of theSubShape in the order
-// that lower dimention shapes come first.
+// that lower dimension shapes come first.
//=======================================================================
const TopTools_ListOfShape& SMESH_Mesh::GetAncestors(const TopoDS_Shape& theS) const
vector<SMESH_subMesh*>::iterator onlyBIt = onlyOrderedList.begin();
vector<SMESH_subMesh*>::iterator onlyEIt = onlyOrderedList.end();
- // iterate on ordered submeshes and insert them in detected positions
+ // iterate on ordered sub-meshes and insert them in detected positions
map< int, TPosInList >::iterator i_pos = sortedPos.begin();
for ( ; onlyBIt != onlyEIt; ++onlyBIt, ++i_pos )
*(i_pos->second) = *onlyBIt;
const SMESH_subMesh* smAfter ) const
{
TListOfListOfInt::const_iterator listIdsIt = _mySubMeshOrder.begin();
- TListOfInt::const_iterator idBef, idAft;
for( ; listIdsIt != _mySubMeshOrder.end(); listIdsIt++)
{
const TListOfInt& listOfId = *listIdsIt;
- idBef = std::find( listOfId.begin(), listOfId.end(), smBefore->GetId() );
- if ( idBef != listOfId.end() )
- idAft = std::find( listOfId.begin(), listOfId.end(), smAfter->GetId() );
- if ( idAft != listOfId.end () )
- return ( std::distance( listOfId.begin(), idBef ) <
- std::distance( listOfId.begin(), idAft ) );
+ int iB = -1, iA = -1, i = 0;
+ for ( TListOfInt::const_iterator id = listOfId.begin(); id != listOfId.end(); ++id, ++i )
+ {
+ if ( *id == smBefore->GetId() )
+ {
+ iB = i;
+ if ( iA > -1 )
+ return iB < iA;
+ }
+ else if ( *id == smAfter->GetId() )
+ {
+ iA = i;
+ if ( iB > -1 )
+ return iB < iA;
+ }
+ }
}
- return true; // no order imposed to given submeshes
+ return true; // no order imposed to given sub-meshes
}
//=============================================================================