Version: 6.3.1
Data Structures | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions

SMESH_Mesh Class Reference

#include <SMESH_Mesh.hxx>

Data Structures

struct  TRmGroupCallUp

Public Types

typedef
TopTools_IndexedDataMapOfShapeListOfShape 
TAncestorMap
 Return data map of descendant to ancestor shapes.
typedef boost::shared_ptr
< SMDS_Iterator< SMESH_Group * > > 
GroupIteratorPtr

Public Member Functions

 SMESH_Mesh (int theLocalId, int theStudyId, SMESH_Gen *theGen, bool theIsEmbeddedMode, SMESHDS_Document *theDocument)
virtual ~SMESH_Mesh ()
void ShapeToMesh (const TopoDS_Shape &aShape)
 Set geometry to be meshed.
TopoDS_Shape GetShapeToMesh () const
 Return geometry to be meshed.
bool HasShapeToMesh () const
 Return true if there is a geometry to be meshed, not PseudoShape()
double GetShapeDiagonalSize () const
 Return diagonal size of bounding box of shape to mesh.
void Clear ()
 Remove all nodes and elements.
void ClearSubMesh (const int theShapeId)
 Remove all nodes and elements of indicated shape.
int UNVToMesh (const char *theFileName)
int MEDToMesh (const char *theFileName, const char *theMeshName)
 consult DriverMED_R_SMESHDS_Mesh.ReadStatus for returned value
int STLToMesh (const char *theFileName)
SMESH_Hypothesis::Hypothesis_Status AddHypothesis (const TopoDS_Shape &aSubShape, int anHypId) throw (SALOME_Exception)
SMESH_Hypothesis::Hypothesis_Status RemoveHypothesis (const TopoDS_Shape &aSubShape, int anHypId) throw (SALOME_Exception)
const std::list< const
SMESHDS_Hypothesis * > & 
GetHypothesisList (const TopoDS_Shape &aSubShape) const throw (SALOME_Exception)
const SMESH_HypothesisGetHypothesis (const TopoDS_Shape &aSubShape, const SMESH_HypoFilter &aFilter, const bool andAncestors, TopoDS_Shape *assignedTo=0) const
int GetHypotheses (const TopoDS_Shape &aSubShape, const SMESH_HypoFilter &aFilter, std::list< const SMESHDS_Hypothesis * > &aHypList, const bool andAncestors) const
 Return hypothesis assigned to the shape.
const std::list
< SMESHDS_Command * > & 
GetLog () throw (SALOME_Exception)
void ClearLog () throw (SALOME_Exception)
int GetId () const
SMESHDS_MeshGetMeshDS ()
const SMESHDS_MeshGetMeshDS () const
SMESH_GenGetGen ()
SMESH_subMeshGetSubMesh (const TopoDS_Shape &aSubShape) throw (SALOME_Exception)
 Get or Create the SMESH_subMesh object implementation.
SMESH_subMeshGetSubMeshContaining (const TopoDS_Shape &aSubShape) const throw (SALOME_Exception)
SMESH_subMeshGetSubMeshContaining (const int aShapeID) const throw (SALOME_Exception)
std::list< SMESH_subMesh * > GetGroupSubMeshesContaining (const TopoDS_Shape &shape) const throw (SALOME_Exception)
 Return submeshes of groups containing the given subshape.
void NotifySubMeshesHypothesisModification (const SMESH_Hypothesis *theChangedHyp)
 Say all submeshes that theChangedHyp has been modified.
const std::list< SMESH_subMesh * > & GetSubMeshUsingHypothesis (SMESHDS_Hypothesis *anHyp) throw (SALOME_Exception)
bool IsUsedHypothesis (SMESHDS_Hypothesis *anHyp, const SMESH_subMesh *aSubMesh)
 Return True if anHyp is used to mesh aSubShape.
bool IsNotConformAllowed () const
 check if a hypothesis alowing notconform mesh is present
bool IsMainShape (const TopoDS_Shape &theShape) const
const TopTools_ListOfShape & GetAncestors (const TopoDS_Shape &theSubShape) const
 Return list of ancestors of theSubShape in the order that lower dimention shapes come first.
void SetAutoColor (bool theAutoColor) throw (SALOME_Exception)
 Auto color functionality.
bool GetAutoColor () throw (SALOME_Exception)
void SetIsModified (bool isModified)
 Set the flag meaning that the mesh has been edited "manually".
bool GetIsModified () const
bool HasModificationsToDiscard () const
 Return true if the mesh has been edited since a total re-compute and those modifications may prevent successful partial re-compute.
const TAncestorMapGetAncestorMap () const
bool HasDuplicatedGroupNamesMED ()
 Check group names for duplications.
void ExportMED (const char *file, const char *theMeshName=NULL, bool theAutoGroups=true, int theVersion=0) throw (SALOME_Exception)
void ExportDAT (const char *file) throw (SALOME_Exception)
void ExportUNV (const char *file) throw (SALOME_Exception)
void ExportSTL (const char *file, const bool isascii) throw (SALOME_Exception)
int NbNodes () const throw (SALOME_Exception)
int Nb0DElements () const throw (SALOME_Exception)
int NbEdges (SMDSAbs_ElementOrder order=ORDER_ANY) const throw (SALOME_Exception)
int NbFaces (SMDSAbs_ElementOrder order=ORDER_ANY) const throw (SALOME_Exception)
int NbTriangles (SMDSAbs_ElementOrder order=ORDER_ANY) const throw (SALOME_Exception)
int NbQuadrangles (SMDSAbs_ElementOrder order=ORDER_ANY) const throw (SALOME_Exception)
int NbPolygons () const throw (SALOME_Exception)
int NbVolumes (SMDSAbs_ElementOrder order=ORDER_ANY) const throw (SALOME_Exception)
int NbTetras (SMDSAbs_ElementOrder order=ORDER_ANY) const throw (SALOME_Exception)
int NbHexas (SMDSAbs_ElementOrder order=ORDER_ANY) const throw (SALOME_Exception)
int NbPyramids (SMDSAbs_ElementOrder order=ORDER_ANY) const throw (SALOME_Exception)
int NbPrisms (SMDSAbs_ElementOrder order=ORDER_ANY) const throw (SALOME_Exception)
int NbPolyhedrons () const throw (SALOME_Exception)
int NbSubMesh () const throw (SALOME_Exception)
int NbGroup () const
SMESH_GroupAddGroup (const SMDSAbs_ElementType theType, const char *theName, int &theId, const TopoDS_Shape &theShape=TopoDS_Shape())
GroupIteratorPtr GetGroups () const
std::list< intGetGroupIds () const
 Return IDs of all groups.
SMESH_GroupGetGroup (const int theGroupID)
 Return a group by ID.
bool RemoveGroup (const int theGroupID)
SMESH_GroupConvertToStandalone (int theGroupID)
 Convert group on geometry into standalone group.
void SetRemoveGroupCallUp (TRmGroupCallUp *upCaller)
 Set a caller of RemoveGroup() at level of CORBA API implementation.
SMDSAbs_ElementType GetElementType (const int id, const bool iselem)
void ClearMeshOrder ()
 remove submesh order from Mesh
void SetMeshOrder (const TListOfListOfInt &theOrder)
 remove submesh order from Mesh
const TListOfListOfIntGetMeshOrder () const
bool SortByMeshOrder (std::list< SMESH_subMesh * > &theListToSort) const
 sort submeshes according to stored mesh order
ostream & Dump (ostream &save)

Static Public Member Functions

static double GetShapeDiagonalSize (const TopoDS_Shape &aShape)
 Return diagonal size of bounding box of a shape.
static const TopoDS_Solid & PseudoShape ()
 Return a solid which is returned by GetShapeToMesh() if a real geometry to be meshed was not set.

Protected Member Functions

 SMESH_Mesh ()
 Constructor of SMESH_Mesh being a base of some descendant class.
 SMESH_Mesh (const SMESH_Mesh &)

Protected Attributes

int _id
int _studyId
int _idDoc
int _groupId
int _nbSubShapes
bool _isShapeToMesh
std::list< SMESH_subMesh * > _subMeshesUsingHypothesisList
SMESHDS_Document_myDocument
SMESHDS_Mesh_myMeshDS
SMESH_Gen_gen
std::map< int, SMESH_subMesh * > _mapSubMesh
std::map< int, SMESH_Group * > _mapGroup
bool _isAutoColor
bool _isModified
 modified since last total re-compute, issue 0020693
double _shapeDiagonal
 diagonal size of bounding box of shape to mesh
TopTools_IndexedDataMapOfShapeListOfShape _mapAncestors
TListOfListOfInt _mySubMeshOrder
TRmGroupCallUp_rmGroupCallUp

Private Member Functions

void fillAncestorsMap (const TopoDS_Shape &theShape)
 fill _mapAncestors
std::list< SMESH_subMesh * > getAncestorsSubMeshes (const TopoDS_Shape &theSubShape) const
 sort submeshes according to stored mesh order

Detailed Description

Definition at line 63 of file SMESH_Mesh.hxx.


Member Typedef Documentation

typedef boost::shared_ptr< SMDS_Iterator<SMESH_Group*> > SMESH_Mesh.GroupIteratorPtr

Definition at line 264 of file SMESH_Mesh.hxx.

typedef TopTools_IndexedDataMapOfShapeListOfShape SMESH_Mesh.TAncestorMap

Return data map of descendant to ancestor shapes.

Definition at line 211 of file SMESH_Mesh.hxx.


Constructor & Destructor Documentation

SMESH_Mesh::SMESH_Mesh ( int  theLocalId,
int  theStudyId,
SMESH_Gen theGen,
bool  theIsEmbeddedMode,
SMESHDS_Document theDocument 
)

Definition at line 86 of file SMESH_Mesh.cxx.

References _gen, _id, _idDoc, _isAutoColor, _isModified, _isShapeToMesh, _myDocument, _myMeshDS, _rmGroupCallUp, _shapeDiagonal, _studyId, SMESHDS_Document.GetMesh(), MESSAGE, SMESHDS_Document.NewMesh(), PseudoShape(), and SMESHDS_Mesh.ShapeToMesh().

                                                     :
  _groupId( 0 ), _nbSubShapes( 0 )
{
  MESSAGE("SMESH_Mesh::SMESH_Mesh(int localId)");
  _id            = theLocalId;
  _studyId       = theStudyId;
  _gen           = theGen;
  _myDocument    = theDocument;
  _idDoc         = theDocument->NewMesh(theIsEmbeddedMode);
  _myMeshDS      = theDocument->GetMesh(_idDoc);
  _isShapeToMesh = false;
  _isAutoColor   = false;
  _isModified    = false;
  _shapeDiagonal = 0.0;
  _rmGroupCallUp = 0;
  _myMeshDS->ShapeToMesh( PseudoShape() );
}
SMESH_Mesh::~SMESH_Mesh ( ) [virtual]

Definition at line 131 of file SMESH_Mesh.cxx.

References SMESH_controls.aGroup, SMESH_subMesh.MESH_ENTITY_REMOVED, and MESSAGE.

{
  MESSAGE("SMESH_Mesh::~SMESH_Mesh");

  // issue 0020340: EDF 1022 SMESH : Crash with FindNodeClosestTo in a second new study
  //   Notify event listeners at least that something happens
  if ( SMESH_subMesh * sm = GetSubMeshContaining(1))
    sm->ComputeStateEngine( SMESH_subMesh::MESH_ENTITY_REMOVED );

  // delete groups
  map < int, SMESH_Group * >::iterator itg;
  for (itg = _mapGroup.begin(); itg != _mapGroup.end(); itg++) {
    SMESH_Group *aGroup = (*itg).second;
    delete aGroup;
  }
  _mapGroup.clear();

  if ( _rmGroupCallUp) delete _rmGroupCallUp;
  _rmGroupCallUp = 0;
}
SMESH_Mesh::SMESH_Mesh ( ) [protected]

Constructor of SMESH_Mesh being a base of some descendant class.

Definition at line 114 of file SMESH_Mesh.cxx.

References _isAutoColor, _isModified, _isShapeToMesh, _myMeshDS, _rmGroupCallUp, and _shapeDiagonal.

                      :
  _groupId( 0 ), _nbSubShapes( 0 )
{
  _myMeshDS      = 0;
  _isShapeToMesh = false;
  _isAutoColor   = false;
  _isModified    = false;
  _shapeDiagonal = 0.0;
  _rmGroupCallUp = 0;
}
SMESH_Mesh.SMESH_Mesh ( const SMESH_Mesh ) [protected]

Definition at line 336 of file SMESH_Mesh.hxx.

{};

Member Function Documentation

SMESH_Group* SMESH_Mesh.AddGroup ( const SMDSAbs_ElementType  theType,
const char *  theName,
int theId,
const TopoDS_Shape &  theShape = TopoDS_Shape() 
)
SMESH_Hypothesis::Hypothesis_Status SMESH_Mesh::AddHypothesis ( const TopoDS_Shape &  aSubShape,
int  anHypId 
) throw (SALOME_Exception)

Definition at line 451 of file SMESH_Mesh.cxx.

References SMESH_subMesh.ADD_ALGO, SMESH_subMesh.ADD_FATHER_ALGO, SMESH_subMesh.ADD_FATHER_HYP, SMESH_subMesh.ADD_HYP, SMESH_Gen.GetShapeDim(), SMESH_Hypothesis.HYP_BAD_SUBSHAPE, SMESH_Hypothesis.HYP_CONCURENT, SMESH.HYP_INCOMPATIBLE, SMESH_Hypothesis.IsStatusFatal(), studyContextStruct.mapHypothesis, MESSAGE, MYDEBUG, SMESHDS_Hypothesis.PARAM_ALGO, and PAL_MESH_041_mesh.ret.

{
  Unexpect aCatch(SalomeException);
  if(MYDEBUG) MESSAGE("SMESH_Mesh::AddHypothesis");

  SMESH_subMesh *subMesh = GetSubMesh(aSubShape);
  if ( !subMesh || !subMesh->GetId())
    return SMESH_Hypothesis::HYP_BAD_SUBSHAPE;

  StudyContextStruct *sc = _gen->GetStudyContext(_studyId);
  if (sc->mapHypothesis.find(anHypId) == sc->mapHypothesis.end())
  {
    if(MYDEBUG) MESSAGE("Hypothesis ID does not give an hypothesis");
    if(MYDEBUG) {
      SCRUTE(_studyId);
      SCRUTE(anHypId);
    }
    throw SALOME_Exception(LOCALIZED("hypothesis does not exist"));
  }

  SMESH_Hypothesis *anHyp = sc->mapHypothesis[anHypId];
  MESSAGE( "SMESH_Mesh::AddHypothesis " << anHyp->GetName() );

  bool isGlobalHyp = IsMainShape( aSubShape );

  // NotConformAllowed can be only global
  if ( !isGlobalHyp )
  {
    // NOTE: this is not a correct way to check a name of hypothesis,
    // there should be an attribute of hypothesis saying that it can/can't
    // be global/local
    string hypName = anHyp->GetName();
    if ( hypName == "NotConformAllowed" )
    {
      if(MYDEBUG) MESSAGE( "Hypotesis <NotConformAllowed> can be only global" );
      return SMESH_Hypothesis::HYP_INCOMPATIBLE;
    }
  }

  // shape 

  bool isAlgo = ( !anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO );
  int event = isAlgo ? SMESH_subMesh::ADD_ALGO : SMESH_subMesh::ADD_HYP;

  SMESH_Hypothesis::Hypothesis_Status ret = subMesh->AlgoStateEngine(event, anHyp);

  // subShapes
  if (!SMESH_Hypothesis::IsStatusFatal(ret) &&
      anHyp->GetDim() <= SMESH_Gen::GetShapeDim(aSubShape)) // is added on father
  {
    event = isAlgo ? SMESH_subMesh::ADD_FATHER_ALGO : SMESH_subMesh::ADD_FATHER_HYP;

    SMESH_Hypothesis::Hypothesis_Status ret2 =
      subMesh->SubMeshesAlgoStateEngine(event, anHyp);
    if (ret2 > ret)
      ret = ret2;

    // check concurent hypotheses on ancestors
    if (ret < SMESH_Hypothesis::HYP_CONCURENT && !isGlobalHyp )
    {
      SMESH_subMeshIteratorPtr smIt = subMesh->getDependsOnIterator(false,false);
      while ( smIt->more() ) {
        SMESH_subMesh* sm = smIt->next();
        if ( sm->IsApplicableHypotesis( anHyp )) {
          ret2 = sm->CheckConcurentHypothesis( anHyp->GetType() );
          if (ret2 > ret) {
            ret = ret2;
            break;
          }
        }
      }
    }
  }
  HasModificationsToDiscard(); // to reset _isModified flag if a mesh becomes empty

  GetMeshDS()->Modified();

  if(MYDEBUG) subMesh->DumpAlgoState(true);
  if(MYDEBUG) SCRUTE(ret);
  return ret;
}
void SMESH_Mesh.Clear ( )

Remove all nodes and elements.

void SMESH_Mesh.ClearLog ( ) throw (SALOME_Exception)
void SMESH_Mesh::ClearMeshOrder ( )

remove submesh order from Mesh

Definition at line 1613 of file SMESH_Mesh.cxx.

{
  _mySubMeshOrder.clear();
}
void SMESH_Mesh::ClearSubMesh ( const int  theShapeId)

Remove all nodes and elements of indicated shape.

Definition at line 301 of file SMESH_Mesh.cxx.

References SMESH_subMesh.CHECK_COMPUTE_STATE, and SMESH_subMesh.CLEAN.

{
  // clear sub-meshes; get ready to re-compute as a side-effect 
  if ( SMESH_subMesh *sm = GetSubMeshContaining( theShapeId ) )
  {
    SMESH_subMeshIteratorPtr smIt = sm->getDependsOnIterator(/*includeSelf=*/true,
                                                             /*complexShapeFirst=*/false);
    while ( smIt->more() )
    {
      sm = smIt->next();
      TopAbs_ShapeEnum shapeType = sm->GetSubShape().ShapeType();      
      if ( shapeType == TopAbs_VERTEX || shapeType < TopAbs_SOLID )
        // all other shapes depends on vertices so they are already cleaned
        sm->ComputeStateEngine( SMESH_subMesh::CLEAN );
      // to recompute even if failed
      sm->ComputeStateEngine( SMESH_subMesh::CHECK_COMPUTE_STATE );
    }
  }
}
SMESH_Group * SMESH_Mesh::ConvertToStandalone ( int  theGroupID)

Convert group on geometry into standalone group.

Definition at line 1576 of file SMESH_Mesh.cxx.

References SMESHDS_Group.Add(), SMESH_controls.aGroup, SMESHDS_GroupBase.GetElements(), and SMESHDS_GroupBase.GetType().

{
  SMESH_Group* aGroup = 0;
  map < int, SMESH_Group * >::iterator itg = _mapGroup.find( theGroupID );
  if ( itg == _mapGroup.end() )
    return aGroup;

  SMESH_Group* anOldGrp = (*itg).second;
  SMESHDS_GroupBase* anOldGrpDS = anOldGrp->GetGroupDS();
  if ( !anOldGrp || !anOldGrpDS )
    return aGroup;

  // create new standalone group
  aGroup = new SMESH_Group (theGroupID, this, anOldGrpDS->GetType(), anOldGrp->GetName() );
  _mapGroup[theGroupID] = aGroup;

  SMESHDS_Group* aNewGrpDS = dynamic_cast<SMESHDS_Group*>( aGroup->GetGroupDS() );
  GetMeshDS()->RemoveGroup( anOldGrpDS );
  GetMeshDS()->AddGroup( aNewGrpDS );

  // add elements (or nodes) into new created group
  SMDS_ElemIteratorPtr anItr = anOldGrpDS->GetElements();
  while ( anItr->more() )
    aNewGrpDS->Add( (anItr->next())->GetID() );

  // remove old group
  delete anOldGrp;

  return aGroup;
}
ostream & SMESH_Mesh::Dump ( ostream &  save)

Definition at line 1492 of file SMESH_Mesh.cxx.

References ORDER_LINEAR, and ORDER_QUADRATIC.

{
  int clause = 0;
  save << "========================== Dump contents of mesh ==========================" << endl << endl;
  save << ++clause << ") Total number of nodes:   \t"    << NbNodes() << endl;
  save << ++clause << ") Total number of edges:   \t"    << NbEdges() << endl;
  save << ++clause << ") Total number of faces:   \t"    << NbFaces() << endl;
  save << ++clause << ") Total number of polygons:\t"    << NbPolygons() << endl;
  save << ++clause << ") Total number of volumes:\t"     << NbVolumes() << endl;
  save << ++clause << ") Total number of polyhedrons:\t" << NbPolyhedrons() << endl << endl;
  for ( int isQuadratic = 0; isQuadratic < 2; ++isQuadratic )
  {
    string orderStr = isQuadratic ? "quadratic" : "linear";
    SMDSAbs_ElementOrder order  = isQuadratic ? ORDER_QUADRATIC : ORDER_LINEAR;

    save << ++clause << ") Total number of " << orderStr << " edges:\t" << NbEdges(order) << endl;
    save << ++clause << ") Total number of " << orderStr << " faces:\t" << NbFaces(order) << endl;
    if ( NbFaces(order) > 0 ) {
      int nb3 = NbTriangles(order);
      int nb4 = NbQuadrangles(order);
      save << clause << ".1) Number of " << orderStr << " triangles:  \t" << nb3 << endl;
      save << clause << ".2) Number of " << orderStr << " quadrangles:\t" << nb4 << endl;
      if ( nb3 + nb4 !=  NbFaces(order) ) {
        map<int,int> myFaceMap;
        SMDS_FaceIteratorPtr itFaces=_myMeshDS->facesIterator();
        while( itFaces->more( ) ) {
          int nbNodes = itFaces->next()->NbNodes();
          if ( myFaceMap.find( nbNodes ) == myFaceMap.end() )
            myFaceMap[ nbNodes ] = 0;
          myFaceMap[ nbNodes ] = myFaceMap[ nbNodes ] + 1;
        }
        save << clause << ".3) Faces in detail: " << endl;
        map <int,int>::iterator itF;
        for (itF = myFaceMap.begin(); itF != myFaceMap.end(); itF++)
          save << "--> nb nodes: " << itF->first << " - nb elemens:\t" << itF->second << endl;
      }
    }
    save << ++clause << ") Total number of " << orderStr << " volumes:\t" << NbVolumes(order) << endl;
    if ( NbVolumes(order) > 0 ) {
      int nb8 = NbHexas(order);
      int nb4 = NbTetras(order);
      int nb5 = NbPyramids(order);
      int nb6 = NbPrisms(order);
      save << clause << ".1) Number of " << orderStr << " hexahedrons:\t" << nb8 << endl;
      save << clause << ".2) Number of " << orderStr << " tetrahedrons:\t" << nb4 << endl;
      save << clause << ".3) Number of " << orderStr << " prisms:      \t" << nb6 << endl;
      save << clause << ".4) Number of " << orderStr << " pyramids:\t" << nb5 << endl;
      if ( nb8 + nb4 + nb5 + nb6 != NbVolumes(order) ) {
        map<int,int> myVolumesMap;
        SMDS_VolumeIteratorPtr itVolumes=_myMeshDS->volumesIterator();
        while( itVolumes->more( ) ) {
          int nbNodes = itVolumes->next()->NbNodes();
          if ( myVolumesMap.find( nbNodes ) == myVolumesMap.end() )
            myVolumesMap[ nbNodes ] = 0;
          myVolumesMap[ nbNodes ] = myVolumesMap[ nbNodes ] + 1;
        }
        save << clause << ".5) Volumes in detail: " << endl;
        map <int,int>::iterator itV;
        for (itV = myVolumesMap.begin(); itV != myVolumesMap.end(); itV++)
          save << "--> nb nodes: " << itV->first << " - nb elemens:\t" << itV->second << endl;
      }
    }
    save << endl;
  }
  save << "===========================================================================" << endl;
  return save;
}
void SMESH_Mesh::ExportDAT ( const char *  file) throw (SALOME_Exception)

Definition at line 1147 of file SMESH_Mesh.cxx.

References DriverDAT_W_SMDS_Mesh.Perform(), Driver_Mesh.SetFile(), Driver_SMDS_Mesh.SetMesh(), and Driver_Mesh.SetMeshId().

{
  Unexpect aCatch(SalomeException);
  DriverDAT_W_SMDS_Mesh myWriter;
  myWriter.SetFile(string(file));
  myWriter.SetMesh(_myMeshDS);
  myWriter.SetMeshId(_idDoc);
  myWriter.Perform();
}
void SMESH_Mesh.ExportMED ( const char *  file,
const char *  theMeshName = NULL,
bool  theAutoGroups = true,
int  theVersion = 0 
) throw (SALOME_Exception)
void SMESH_Mesh::ExportSTL ( const char *  file,
const bool  isascii 
) throw (SALOME_Exception)

Definition at line 1178 of file SMESH_Mesh.cxx.

References DriverSTL_W_SMDS_Mesh.Perform(), Driver_Mesh.SetFile(), DriverSTL_W_SMDS_Mesh.SetIsAscii(), Driver_SMDS_Mesh.SetMesh(), and Driver_Mesh.SetMeshId().

{
  Unexpect aCatch(SalomeException);
  DriverSTL_W_SMDS_Mesh myWriter;
  myWriter.SetFile(string(file));
  myWriter.SetIsAscii( isascii );
  myWriter.SetMesh(_myMeshDS);
  myWriter.SetMeshId(_idDoc);
  myWriter.Perform();
}
void SMESH_Mesh::ExportUNV ( const char *  file) throw (SALOME_Exception)

Definition at line 1157 of file SMESH_Mesh.cxx.

References DriverUNV_W_SMDS_Mesh.AddGroup(), DriverUNV_W_SMDS_Mesh.Perform(), Driver_Mesh.SetFile(), Driver_SMDS_Mesh.SetMesh(), Driver_Mesh.SetMeshId(), and SMESHDS_GroupBase.SetStoreName().

{
  Unexpect aCatch(SalomeException);
  DriverUNV_W_SMDS_Mesh myWriter;
  myWriter.SetFile(string(file));
  myWriter.SetMesh(_myMeshDS);
  myWriter.SetMeshId(_idDoc);
  //  myWriter.SetGroups(_mapGroup);

  for ( map<int, SMESH_Group*>::iterator it = _mapGroup.begin(); it != _mapGroup.end(); it++ ) {
    SMESH_Group*       aGroup   = it->second;
    SMESHDS_GroupBase* aGroupDS = aGroup->GetGroupDS();
    if ( aGroupDS ) {
      string aGroupName = aGroup->GetName();
      aGroupDS->SetStoreName( aGroupName.c_str() );
      myWriter.AddGroup( aGroupDS );
    }
  }
  myWriter.Perform();
}
void SMESH_Mesh::fillAncestorsMap ( const TopoDS_Shape &  theShape) [private]

fill _mapAncestors

Definition at line 1646 of file SMESH_Mesh.cxx.

{

  int desType, ancType;
  if ( !theShape.IsSame( GetShapeToMesh()) && theShape.ShapeType() == TopAbs_COMPOUND )
  {
    // a geom group is added. Insert it into lists of ancestors before
    // the first ancestor more complex than group members
    int memberType = TopoDS_Iterator( theShape ).Value().ShapeType();
    for ( desType = TopAbs_VERTEX; desType >= memberType; desType-- )
      for (TopExp_Explorer des( theShape, TopAbs_ShapeEnum( desType )); des.More(); des.Next())
      {
        if ( !_mapAncestors.Contains( des.Current() )) continue;// issue 0020982
        TopTools_ListOfShape& ancList = _mapAncestors.ChangeFromKey( des.Current() );
        TopTools_ListIteratorOfListOfShape ancIt (ancList);
        while ( ancIt.More() && ancIt.Value().ShapeType() >= memberType )
          ancIt.Next();
        if ( ancIt.More() )
          ancList.InsertBefore( theShape, ancIt );
      }
  }
  {
    for ( desType = TopAbs_VERTEX; desType > TopAbs_COMPOUND; desType-- )
      for ( ancType = desType - 1; ancType >= TopAbs_COMPOUND; ancType-- )
        TopExp::MapShapesAndAncestors ( theShape,
                                        (TopAbs_ShapeEnum) desType,
                                        (TopAbs_ShapeEnum) ancType,
                                        _mapAncestors );
  }
}
const TAncestorMap& SMESH_Mesh.GetAncestorMap ( ) const

Definition at line 212 of file SMESH_Mesh.hxx.

{ return _mapAncestors; }
const TopTools_ListOfShape& SMESH_Mesh.GetAncestors ( const TopoDS_Shape &  theSubShape) const

Return list of ancestors of theSubShape in the order that lower dimention shapes come first.

Referenced by SMESH_ProxyMesh.GetProxyNode().

list< SMESH_subMesh * > SMESH_Mesh::getAncestorsSubMeshes ( const TopoDS_Shape &  theSubShape) const [private]

sort submeshes according to stored mesh order

Parameters:
theListToSortin out list to be sorted
Returns:
FALSE if nothing sorted

Definition at line 1735 of file SMESH_Mesh.cxx.

{
  list<SMESH_subMesh*> listOfSubMesh;
  TopTools_ListIteratorOfListOfShape it( GetAncestors( theSubShape ));
  for (; it.More(); it.Next() )
    if ( SMESH_subMesh* sm = GetSubMeshContaining( it.Value() ))
      listOfSubMesh.push_back(sm);

  // sort submeshes according to stored mesh order
  SortByMeshOrder( listOfSubMesh );

  return listOfSubMesh;
}
bool SMESH_Mesh.GetAutoColor ( ) throw (SALOME_Exception)
SMDSAbs_ElementType SMESH_Mesh::GetElementType ( const int  id,
const bool  iselem 
)

Definition at line 1565 of file SMESH_Mesh.cxx.

{
  return _myMeshDS->GetElementType( id, iselem );
}
SMESH_Gen* SMESH_Mesh.GetGen ( )

Definition at line 150 of file SMESH_Mesh.hxx.

{ return _gen; }
SMESH_Group * SMESH_Mesh::GetGroup ( const int  theGroupID)

Return a group by ID.

Definition at line 1418 of file SMESH_Mesh.cxx.

{
  if (_mapGroup.find(theGroupID) == _mapGroup.end())
    return NULL;
  return _mapGroup[theGroupID];
}
list< int > SMESH_Mesh::GetGroupIds ( ) const

Return IDs of all groups.

Definition at line 1432 of file SMESH_Mesh.cxx.

References SMESH_BelongToGeom.anIds.

{
  list<int> anIds;
  for ( map<int, SMESH_Group*>::const_iterator it = _mapGroup.begin(); it != _mapGroup.end(); it++ )
    anIds.push_back( it->first );
  
  return anIds;
}
GroupIteratorPtr SMESH_Mesh.GetGroups ( ) const
list< SMESH_subMesh * > SMESH_Mesh::GetGroupSubMeshesContaining ( const TopoDS_Shape &  shape) const throw (SALOME_Exception)

Return submeshes of groups containing the given subshape.

Definition at line 859 of file SMESH_Mesh.cxx.

References SMESHDS_SubMesh.IsComplexSubmesh().

{
  Unexpect aCatch(SalomeException);
  list<SMESH_subMesh*> found;

  SMESH_subMesh * subMesh = GetSubMeshContaining(aSubShape);
  if ( !subMesh )
    return found;

  // submeshes of groups have max IDs, so search from the map end
  map<int, SMESH_subMesh *>::const_reverse_iterator i_sm;
  for ( i_sm = _mapSubMesh.rbegin(); i_sm != _mapSubMesh.rend(); ++i_sm) {
    SMESHDS_SubMesh * ds = i_sm->second->GetSubMeshDS();
    if ( ds && ds->IsComplexSubmesh() ) {
      TopExp_Explorer exp( i_sm->second->GetSubShape(), aSubShape.ShapeType() );
      for ( ; exp.More(); exp.Next() ) {
        if ( aSubShape.IsSame( exp.Current() )) {
          found.push_back( i_sm->second );
          break;
        }
      }
    } else {
      break;
    }
  }
  return found;
}
int SMESH_Mesh::GetHypotheses ( const TopoDS_Shape &  aSubShape,
const SMESH_HypoFilter aFilter,
std::list< const SMESHDS_Hypothesis * > &  aHypList,
const bool  andAncestors 
) const

Return hypothesis assigned to the shape.

Parameters:
aSubShape- the shape to check
aFilter- the hypothesis filter
aHypList- the list of the found hypotheses
andAncestors- flag to check hypos assigned to ancestors of the shape
Return values:
int- number of unique hypos in aHypList

Definition at line 683 of file SMESH_Mesh.cxx.

References cSMESH_Hyp, SMESH_demo_hexa2_upd.hyp, and SMESH_HypoFilter.IsOk().

{
  set<string> hypTypes; // to exclude same type hypos from the result list
  int nbHyps = 0;

  // only one main hypothesis is allowed
  bool mainHypFound = false;

  // fill in hypTypes
  list<const SMESHDS_Hypothesis*>::const_iterator hyp;
  for ( hyp = aHypList.begin(); hyp != aHypList.end(); hyp++ ) {
    if ( hypTypes.insert( (*hyp)->GetName() ).second )
      nbHyps++;
    if ( !cSMESH_Hyp(*hyp)->IsAuxiliary() )
      mainHypFound = true;
  }

  // get hypos from aSubShape
  {
    const list<const SMESHDS_Hypothesis*>& hypList = _myMeshDS->GetHypothesis(aSubShape);
    for ( hyp = hypList.begin(); hyp != hypList.end(); hyp++ )
      if ( aFilter.IsOk (cSMESH_Hyp( *hyp ), aSubShape) &&
           ( cSMESH_Hyp(*hyp)->IsAuxiliary() || !mainHypFound ) &&
           hypTypes.insert( (*hyp)->GetName() ).second )
      {
        aHypList.push_back( *hyp );
        nbHyps++;
        if ( !cSMESH_Hyp(*hyp)->IsAuxiliary() )
          mainHypFound = true;
      }
  }

  // get hypos from ancestors of aSubShape
  if ( andAncestors )
  {
    TopTools_MapOfShape map;

    // user sorted submeshes of ancestors, according to stored submesh priority
    const list<SMESH_subMesh*> smList = getAncestorsSubMeshes( aSubShape );
    list<SMESH_subMesh*>::const_iterator smIt = smList.begin(); 
    for ( ; smIt != smList.end(); smIt++ )
    {
      const TopoDS_Shape& curSh = (*smIt)->GetSubShape();
     if ( !map.Add( curSh ))
        continue;
      const list<const SMESHDS_Hypothesis*>& hypList = _myMeshDS->GetHypothesis(curSh);
      for ( hyp = hypList.begin(); hyp != hypList.end(); hyp++ )
        if (aFilter.IsOk( cSMESH_Hyp( *hyp ), curSh ) &&
            ( cSMESH_Hyp(*hyp)->IsAuxiliary() || !mainHypFound ) &&
            hypTypes.insert( (*hyp)->GetName() ).second )
        {
          aHypList.push_back( *hyp );
          nbHyps++;
          if ( !cSMESH_Hyp(*hyp)->IsAuxiliary() )
            mainHypFound = true;
        }
    }
  }
  return nbHyps;
}
const SMESH_Hypothesis* SMESH_Mesh.GetHypothesis ( const TopoDS_Shape &  aSubShape,
const SMESH_HypoFilter aFilter,
const bool  andAncestors,
TopoDS_Shape *  assignedTo = 0 
) const
const std::list<const SMESHDS_Hypothesis * >& SMESH_Mesh.GetHypothesisList ( const TopoDS_Shape &  aSubShape) const throw (SALOME_Exception)
int SMESH_Mesh.GetId ( ) const

Definition at line 144 of file SMESH_Mesh.hxx.

Referenced by SMESH_MeshEditor_i.GetMeshId().

{ return _id; }
bool SMESH_Mesh.GetIsModified ( ) const

Definition at line 199 of file SMESH_Mesh.hxx.

{ return _isModified; }
const list< SMESHDS_Command * > & SMESH_Mesh::GetLog ( ) throw (SALOME_Exception)

Definition at line 753 of file SMESH_Mesh.cxx.

References MESSAGE, and MYDEBUG.

{
  Unexpect aCatch(SalomeException);
  if(MYDEBUG) MESSAGE("SMESH_Mesh::GetLog");
  return _myMeshDS->GetScript()->GetCommands();
}
const SMESHDS_Mesh* SMESH_Mesh.GetMeshDS ( ) const

Definition at line 148 of file SMESH_Mesh.hxx.

{ return _myMeshDS; }
SMESHDS_Mesh* SMESH_Mesh.GetMeshDS ( )
const TListOfListOfInt& SMESH_Mesh.GetMeshOrder ( ) const
double SMESH_Mesh::GetShapeDiagonalSize ( const TopoDS_Shape &  aShape) [static]

Return diagonal size of bounding box of a shape.

Definition at line 249 of file SMESH_Mesh.cxx.

{
  if ( !aShape.IsNull() ) {
    Bnd_Box Box;
    BRepBndLib::Add(aShape, Box);
    return sqrt( Box.SquareExtent() );
  }
  return 0;
}
double SMESH_Mesh.GetShapeDiagonalSize ( ) const

Return diagonal size of bounding box of shape to mesh.

Referenced by SMESH_Gen_i.GetHypothesisParameterValues().

TopoDS_Shape SMESH_Mesh.GetShapeToMesh ( ) const

Return geometry to be meshed.

(It may be a PseudoShape()!)

Referenced by SMESH_ProxyMesh.NbFaces().

SMESH_subMesh * SMESH_Mesh::GetSubMesh ( const TopoDS_Shape &  aSubShape) throw (SALOME_Exception)

Get or Create the SMESH_subMesh object implementation.

Definition at line 778 of file SMESH_Mesh.cxx.

Referenced by StdMeshers_Projection_3D.Compute(), StdMeshers_Projection_3D.Evaluate(), StdMeshers_HexaFromSkin_3D.Evaluate(), StdMeshers_CompositeHexa_3D.Evaluate(), GetNb2d(), _FaceSide.GetNbSegments(), and _QuadFaceGrid.LoadGrid().

{
  Unexpect aCatch(SalomeException);
  SMESH_subMesh *aSubMesh;
  int index = _myMeshDS->ShapeToIndex(aSubShape);

  // for submeshes on GEOM Group
  if (( !index || index > _nbSubShapes ) && aSubShape.ShapeType() == TopAbs_COMPOUND ) {
    TopoDS_Iterator it( aSubShape );
    if ( it.More() )
    {
      index = _myMeshDS->AddCompoundSubmesh( aSubShape, it.Value().ShapeType() );
      if ( index > _nbSubShapes ) _nbSubShapes = index; // not to create sm for this group again

      // fill map of Ancestors
      fillAncestorsMap(aSubShape);
    }
  }
//   if ( !index )
//     return NULL; // neither sub-shape nor a group

  map <int, SMESH_subMesh *>::iterator i_sm = _mapSubMesh.find(index);
  if ( i_sm != _mapSubMesh.end())
  {
    aSubMesh = i_sm->second;
  }
  else
  {
    aSubMesh = new SMESH_subMesh(index, this, _myMeshDS, aSubShape);
    _mapSubMesh[index] = aSubMesh;
    ClearMeshOrder();
  }
  return aSubMesh;
}
SMESH_subMesh* SMESH_Mesh.GetSubMeshContaining ( const TopoDS_Shape &  aSubShape) const throw (SALOME_Exception)
SMESH_subMesh* SMESH_Mesh.GetSubMeshContaining ( const int  aShapeID) const throw (SALOME_Exception)
const list< SMESH_subMesh * > & SMESH_Mesh::GetSubMeshUsingHypothesis ( SMESHDS_Hypothesis anHyp) throw (SALOME_Exception)

Definition at line 933 of file SMESH_Mesh.cxx.

References MESSAGE, and MYDEBUG.

{
  Unexpect aCatch(SalomeException);
  if(MYDEBUG) MESSAGE("SMESH_Mesh::GetSubMeshUsingHypothesis");
  map < int, SMESH_subMesh * >::iterator itsm;
  _subMeshesUsingHypothesisList.clear();
  for (itsm = _mapSubMesh.begin(); itsm != _mapSubMesh.end(); itsm++)
  {
    SMESH_subMesh *aSubMesh = (*itsm).second;
    if ( IsUsedHypothesis ( anHyp, aSubMesh ))
      _subMeshesUsingHypothesisList.push_back(aSubMesh);
  }
  return _subMeshesUsingHypothesisList;
}
bool SMESH_Mesh.HasDuplicatedGroupNamesMED ( )

Check group names for duplications.

Consider maximum group name length stored in MED file

bool SMESH_Mesh.HasModificationsToDiscard ( ) const

Return true if the mesh has been edited since a total re-compute and those modifications may prevent successful partial re-compute.

As a side effect reset _isModified flag if mesh is empty

bool SMESH_Mesh.HasShapeToMesh ( ) const

Return true if there is a geometry to be meshed, not PseudoShape()

Definition at line 85 of file SMESH_Mesh.hxx.

Referenced by SMESH_ProxyMesh.GetFaces(), SMESH_ProxyMesh.NbFaces(), and SMESH_ProxyMesh.shapeIndex().

{ return _isShapeToMesh; }
bool SMESH_Mesh::IsMainShape ( const TopoDS_Shape &  theShape) const

Definition at line 1375 of file SMESH_Mesh.cxx.

{
  return theShape.IsSame(_myMeshDS->ShapeToMesh() );
}
bool SMESH_Mesh::IsNotConformAllowed ( ) const

check if a hypothesis alowing notconform mesh is present

Definition at line 1362 of file SMESH_Mesh.cxx.

References SMESH_HypoFilter.HasName(), MESSAGE, and MYDEBUG.

{
  if(MYDEBUG) MESSAGE("SMESH_Mesh::IsNotConformAllowed");

  static SMESH_HypoFilter filter( SMESH_HypoFilter::HasName( "NotConformAllowed" ));
  return GetHypothesis( _myMeshDS->ShapeToMesh(), filter, false );
}
bool SMESH_Mesh::IsUsedHypothesis ( SMESHDS_Hypothesis anHyp,
const SMESH_subMesh aSubMesh 
)

Return True if anHyp is used to mesh aSubShape.

Definition at line 892 of file SMESH_Mesh.cxx.

References ex01_cube2build.algo, SMESH.GetSubShape(), SMESHDS_Hypothesis.GetType(), and SMESHDS_Hypothesis.PARAM_ALGO.

{
  SMESH_Hypothesis* hyp = static_cast<SMESH_Hypothesis*>(anHyp);

  // check if anHyp can be used to mesh aSubMesh
  if ( !aSubMesh || !aSubMesh->IsApplicableHypotesis( hyp ))
    return false;

  const TopoDS_Shape & aSubShape = const_cast<SMESH_subMesh*>( aSubMesh )->GetSubShape();

  SMESH_Algo *algo = _gen->GetAlgo(*this, aSubShape );

  // algorithm
  if (anHyp->GetType() > SMESHDS_Hypothesis::PARAM_ALGO)
    return ( anHyp == algo );

  // algorithm parameter
  if (algo)
  {
    // look trough hypotheses used by algo
    SMESH_HypoFilter hypoKind;
    if ( algo->InitCompatibleHypoFilter( hypoKind, !hyp->IsAuxiliary() )) {
      list <const SMESHDS_Hypothesis * > usedHyps;
      if ( GetHypotheses( aSubShape, hypoKind, usedHyps, true ))
        return ( find( usedHyps.begin(), usedHyps.end(), anHyp ) != usedHyps.end() );
    }
  }

  // look through all assigned hypotheses
  //SMESH_HypoFilter filter( SMESH_HypoFilter::Is( hyp ));
  return false; //GetHypothesis( aSubShape, filter, true );
}
int SMESH_Mesh::MEDToMesh ( const char *  theFileName,
const char *  theMeshName 
)

consult DriverMED_R_SMESHDS_Mesh.ReadStatus for returned value

Definition at line 381 of file SMESH_Mesh.cxx.

References SMESH.AddGroup(), SMESH_controls.aGroup, DriverMED_R_SMESHDS_Mesh.GetGroup(), DriverMED_R_SMESHDS_Mesh.GetGroupNamesAndTypes(), MESSAGE, MYDEBUG, DriverMED_R_SMESHDS_Mesh.Perform(), Driver_Mesh.SetFile(), Driver_SMESHDS_Mesh.SetMesh(), Driver_Mesh.SetMeshId(), DriverMED_R_SMESHDS_Mesh.SetMeshName(), SMESHDS_GroupBase.SetStoreName(), and ex30_tepal.status.

{
  if(MYDEBUG) MESSAGE("MEDToMesh - theFileName = "<<theFileName<<", mesh name = "<<theMeshName);
  if(_isShapeToMesh)
    throw SALOME_Exception(LOCALIZED("a shape to mesh has already been defined"));
  _isShapeToMesh = false;
  DriverMED_R_SMESHDS_Mesh myReader;
  myReader.SetMesh(_myMeshDS);
  myReader.SetMeshId(-1);
  myReader.SetFile(theFileName);
  myReader.SetMeshName(theMeshName);
  Driver_Mesh::Status status = myReader.Perform();
  if(MYDEBUG){
    MESSAGE("MEDToMesh - _myMeshDS->NbNodes() = "<<_myMeshDS->NbNodes());
    MESSAGE("MEDToMesh - _myMeshDS->NbEdges() = "<<_myMeshDS->NbEdges());
    MESSAGE("MEDToMesh - _myMeshDS->NbFaces() = "<<_myMeshDS->NbFaces());
    MESSAGE("MEDToMesh - _myMeshDS->NbVolumes() = "<<_myMeshDS->NbVolumes());
  }

  // Reading groups (sub-meshes are out of scope of MED import functionality)
  list<TNameAndType> aGroupNames = myReader.GetGroupNamesAndTypes();
  if(MYDEBUG) MESSAGE("MEDToMesh - Nb groups = "<<aGroupNames.size()); 
  int anId;
  list<TNameAndType>::iterator name_type = aGroupNames.begin();
  for ( ; name_type != aGroupNames.end(); name_type++ ) {
    SMESH_Group* aGroup = AddGroup( name_type->second, name_type->first.c_str(), anId );
    if ( aGroup ) {
      if(MYDEBUG) MESSAGE("MEDToMesh - group added: "<<name_type->first.c_str());      
      SMESHDS_Group* aGroupDS = dynamic_cast<SMESHDS_Group*>( aGroup->GetGroupDS() );
      if ( aGroupDS ) {
        aGroupDS->SetStoreName( name_type->first.c_str() );
        myReader.GetGroup( aGroupDS );
      }
    }
  }
  return (int) status;
}
int SMESH_Mesh.Nb0DElements ( ) const throw (SALOME_Exception)
int SMESH_Mesh.NbEdges ( SMDSAbs_ElementOrder  order = ORDER_ANY) const throw (SALOME_Exception)
int SMESH_Mesh.NbFaces ( SMDSAbs_ElementOrder  order = ORDER_ANY) const throw (SALOME_Exception)
int SMESH_Mesh.NbGroup ( ) const

Definition at line 257 of file SMESH_Mesh.hxx.

{ return _mapGroup.size(); }
int SMESH_Mesh.NbHexas ( SMDSAbs_ElementOrder  order = ORDER_ANY) const throw (SALOME_Exception)
int SMESH_Mesh.NbNodes ( ) const throw (SALOME_Exception)
int SMESH_Mesh.NbPolygons ( ) const throw (SALOME_Exception)
int SMESH_Mesh.NbPolyhedrons ( ) const throw (SALOME_Exception)
int SMESH_Mesh.NbPrisms ( SMDSAbs_ElementOrder  order = ORDER_ANY) const throw (SALOME_Exception)
int SMESH_Mesh.NbPyramids ( SMDSAbs_ElementOrder  order = ORDER_ANY) const throw (SALOME_Exception)
int SMESH_Mesh.NbQuadrangles ( SMDSAbs_ElementOrder  order = ORDER_ANY) const throw (SALOME_Exception)
int SMESH_Mesh.NbSubMesh ( ) const throw (SALOME_Exception)
int SMESH_Mesh.NbTetras ( SMDSAbs_ElementOrder  order = ORDER_ANY) const throw (SALOME_Exception)
int SMESH_Mesh.NbTriangles ( SMDSAbs_ElementOrder  order = ORDER_ANY) const throw (SALOME_Exception)
int SMESH_Mesh.NbVolumes ( SMDSAbs_ElementOrder  order = ORDER_ANY) const throw (SALOME_Exception)
void SMESH_Mesh::NotifySubMeshesHypothesisModification ( const SMESH_Hypothesis theChangedHyp)

Say all submeshes that theChangedHyp has been modified.

Definition at line 116 of file SMESH_Hypothesis.cxx.

References studyContextStruct.mapMesh, PAL_MESH_041_mesh.mesh, and MESSAGE.

{
  MESSAGE("SMESH_Hypothesis::NotifySubMeshesHypothesisModification");

  // for all meshes in study

  StudyContextStruct* myStudyContext = _gen->GetStudyContext(_studyId);
  map<int, SMESH_Mesh*>::iterator itm;
  for (itm = myStudyContext->mapMesh.begin();
       itm != myStudyContext->mapMesh.end();
       itm++)
    {
      SMESH_Mesh* mesh = (*itm).second;
      mesh->NotifySubMeshesHypothesisModification( this );
    }
}
const TopoDS_Solid & SMESH_Mesh::PseudoShape ( ) [static]

Return a solid which is returned by GetShapeToMesh() if a real geometry to be meshed was not set.

Definition at line 233 of file SMESH_Mesh.cxx.

Referenced by SMESH_Gen_i.CancelCompute(), SMESH_Gen_i.Compute(), SMESH_Gen_i.Evaluate(), SMESH_Gen_i.GetAlgoState(), SMESH_Gen_i.GetComputeErrors(), SMESH_Gen_i.GetMeshOrSubmeshByShape(), SMESH_Gen_i.Load(), and SMESH_Mesh().

{
  static TopoDS_Solid aSolid;
  if ( aSolid.IsNull() )
  {
    aSolid = BRepPrimAPI_MakeBox(1,1,1);
  }
  return aSolid;
}
bool SMESH_Mesh::RemoveGroup ( const int  theGroupID)

Definition at line 1460 of file SMESH_Mesh.cxx.

{
  if (_mapGroup.find(theGroupID) == _mapGroup.end())
    return false;
  GetMeshDS()->RemoveGroup( _mapGroup[theGroupID]->GetGroupDS() );
  delete _mapGroup[theGroupID];
  _mapGroup.erase (theGroupID);
  if (_rmGroupCallUp)
    _rmGroupCallUp->RemoveGroup( theGroupID );
  return true;
}
SMESH_Hypothesis::Hypothesis_Status SMESH_Mesh::RemoveHypothesis ( const TopoDS_Shape &  aSubShape,
int  anHypId 
) throw (SALOME_Exception)

Definition at line 541 of file SMESH_Mesh.cxx.

References SMESH_Gen.GetShapeDim(), SMESH.HYP_CONCURENT, SMESH_Hypothesis.HYP_CONCURENT, SMESH_Hypothesis.HYP_OK, SMESH_Hypothesis.IsStatusFatal(), studyContextStruct.mapHypothesis, MESSAGE, MYDEBUG, SMESHDS_Hypothesis.PARAM_ALGO, SMESH_subMesh.REMOVE_ALGO, SMESH_subMesh.REMOVE_FATHER_ALGO, SMESH_subMesh.REMOVE_FATHER_HYP, SMESH_subMesh.REMOVE_HYP, and PAL_MESH_041_mesh.ret.

{
  Unexpect aCatch(SalomeException);
  if(MYDEBUG) MESSAGE("SMESH_Mesh::RemoveHypothesis");
  
  StudyContextStruct *sc = _gen->GetStudyContext(_studyId);
  if (sc->mapHypothesis.find(anHypId) == sc->mapHypothesis.end())
    throw SALOME_Exception(LOCALIZED("hypothesis does not exist"));
  
  SMESH_Hypothesis *anHyp = sc->mapHypothesis[anHypId];
  if(MYDEBUG) {
    int hypType = anHyp->GetType();
    SCRUTE(hypType);
  }
  
  // shape 
  
  bool isAlgo = ( !anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO );
  int event = isAlgo ? SMESH_subMesh::REMOVE_ALGO : SMESH_subMesh::REMOVE_HYP;

  SMESH_subMesh *subMesh = GetSubMesh(aSubShape);

  SMESH_Hypothesis::Hypothesis_Status ret = subMesh->AlgoStateEngine(event, anHyp);

  // there may appear concurrent hyps that were covered by the removed hyp
  if (ret < SMESH_Hypothesis::HYP_CONCURENT &&
      subMesh->IsApplicableHypotesis( anHyp ) &&
      subMesh->CheckConcurentHypothesis( anHyp->GetType() ) != SMESH_Hypothesis::HYP_OK)
    ret = SMESH_Hypothesis::HYP_CONCURENT;

  // subShapes
  if (!SMESH_Hypothesis::IsStatusFatal(ret) &&
      anHyp->GetDim() <= SMESH_Gen::GetShapeDim(aSubShape)) // is removed from father
  {
    event = isAlgo ? SMESH_subMesh::REMOVE_FATHER_ALGO : SMESH_subMesh::REMOVE_FATHER_HYP;

    SMESH_Hypothesis::Hypothesis_Status ret2 =
      subMesh->SubMeshesAlgoStateEngine(event, anHyp);
    if (ret2 > ret) // more severe
      ret = ret2;

    // check concurent hypotheses on ancestors
    if (ret < SMESH_Hypothesis::HYP_CONCURENT && !IsMainShape( aSubShape ) )
    {
      SMESH_subMeshIteratorPtr smIt = subMesh->getDependsOnIterator(false,false);
      while ( smIt->more() ) {
        SMESH_subMesh* sm = smIt->next();
        if ( sm->IsApplicableHypotesis( anHyp )) {
          ret2 = sm->CheckConcurentHypothesis( anHyp->GetType() );
          if (ret2 > ret) {
            ret = ret2;
            break;
          }
        }
      }
    }
  }

  HasModificationsToDiscard(); // to reset _isModified flag if mesh become empty

  GetMeshDS()->Modified();

  if(MYDEBUG) subMesh->DumpAlgoState(true);
  if(MYDEBUG) SCRUTE(ret);
  return ret;
}
void SMESH_Mesh::SetAutoColor ( bool  theAutoColor) throw (SALOME_Exception)

Auto color functionality.

Definition at line 1009 of file SMESH_Mesh.cxx.

{
  Unexpect aCatch(SalomeException);
  _isAutoColor = theAutoColor;
}
void SMESH_Mesh::SetIsModified ( bool  isModified)

Set the flag meaning that the mesh has been edited "manually".

It is to set to false after Clear() and to set to true by MeshEditor

Definition at line 1026 of file SMESH_Mesh.cxx.

{
  _isModified = isModified;

  if ( _isModified )
    // check if mesh becomes empty as result of modification
    HasModificationsToDiscard();
}
void SMESH_Mesh::SetMeshOrder ( const TListOfListOfInt theOrder)

remove submesh order from Mesh

Definition at line 1624 of file SMESH_Mesh.cxx.

{
  _mySubMeshOrder = theOrder;
}
void SMESH_Mesh::SetRemoveGroupCallUp ( TRmGroupCallUp upCaller)

Set a caller of RemoveGroup() at level of CORBA API implementation.

The set upCaller will be deleted by SMESH_Mesh

Definition at line 1448 of file SMESH_Mesh.cxx.

{
  if ( _rmGroupCallUp ) delete _rmGroupCallUp;
  _rmGroupCallUp = upCaller;
}
void SMESH_Mesh.ShapeToMesh ( const TopoDS_Shape &  aShape)

Set geometry to be meshed.

bool SMESH_Mesh::SortByMeshOrder ( std::list< SMESH_subMesh * > &  theListToSort) const

sort submeshes according to stored mesh order

Parameters:
theListToSortin out list to be sorted
Returns:
FALSE if nothing sorted

Definition at line 1685 of file SMESH_Mesh.cxx.

References SMESH_AdvancedEditor.res.

{
  if ( !_mySubMeshOrder.size() || theListToSort.size() < 2)
    return true;
  
  bool res = false;
  list<SMESH_subMesh*> onlyOrderedList;
  // collect all ordered submeshes in one list as pointers
  // and get their positions within theListToSort
  typedef list<SMESH_subMesh*>::iterator TPosInList;
  map< int, TPosInList > sortedPos;
  TPosInList smBeg = theListToSort.begin(), smEnd = theListToSort.end();
  TListOfListOfInt::const_iterator listIddIt = _mySubMeshOrder.begin();
  for( ; listIddIt != _mySubMeshOrder.end(); listIddIt++) {
    const TListOfInt& listOfId = *listIddIt;
    TListOfInt::const_iterator idIt = listOfId.begin();
    for ( ; idIt != listOfId.end(); idIt++ ) {
      if ( SMESH_subMesh * sm = GetSubMeshContaining( *idIt )) {
        TPosInList smPos = find( smBeg, smEnd, sm );
        if ( smPos != smEnd ) {
          onlyOrderedList.push_back( sm );
          sortedPos[ distance( smBeg, smPos )] = smPos;
        }
      }
    }
  }
  if (onlyOrderedList.size() < 2)
    return res;
  res = true;

  list<SMESH_subMesh*>::iterator onlyBIt = onlyOrderedList.begin();
  list<SMESH_subMesh*>::iterator onlyEIt = onlyOrderedList.end();

  // iterates on ordered submeshes and insert them in detected positions
  map< int, TPosInList >::iterator i_pos = sortedPos.begin();
  for ( ; onlyBIt != onlyEIt; ++onlyBIt, ++i_pos )
    *(i_pos->second) = *onlyBIt;

  return res;
}
int SMESH_Mesh::STLToMesh ( const char *  theFileName)

Definition at line 424 of file SMESH_Mesh.cxx.

References MESSAGE, MYDEBUG, DriverSTL_R_SMDS_Mesh.Perform(), Driver_Mesh.SetFile(), Driver_SMDS_Mesh.SetMesh(), and Driver_Mesh.SetMeshId().

{
  if(MYDEBUG) MESSAGE("STLToMesh - theFileName = "<<theFileName);
  if(_isShapeToMesh)
    throw SALOME_Exception(LOCALIZED("a shape to mesh has already been defined"));
  _isShapeToMesh = false;
  DriverSTL_R_SMDS_Mesh myReader;
  myReader.SetMesh(_myMeshDS);
  myReader.SetFile(theFileName);
  myReader.SetMeshId(-1);
  myReader.Perform();
  if(MYDEBUG){
    MESSAGE("STLToMesh - _myMeshDS->NbNodes() = "<<_myMeshDS->NbNodes());
    MESSAGE("STLToMesh - _myMeshDS->NbEdges() = "<<_myMeshDS->NbEdges());
    MESSAGE("STLToMesh - _myMeshDS->NbFaces() = "<<_myMeshDS->NbFaces());
    MESSAGE("STLToMesh - _myMeshDS->NbVolumes() = "<<_myMeshDS->NbVolumes());
  }
  return 1;
}
int SMESH_Mesh::UNVToMesh ( const char *  theFileName)

Definition at line 326 of file SMESH_Mesh.cxx.

References SMDS_MeshGroup.Add(), SMESH.AddGroup(), SMESH_controls.aGroup, DriverUNV_R_SMDS_Mesh.GetGroup(), DriverUNV_R_SMDS_Mesh.GetGroupNamesMap(), SMDS_MeshElement.GetType(), SMDS_MeshGroup.GetType(), SMDS_MeshGroup.InitIterator(), SMDS_MeshGroup.InitSubGroupsIterator(), MESSAGE, SMDS_MeshGroup.More(), SMDS_MeshGroup.MoreSubGroups(), MYDEBUG, SMDS_MeshGroup.Next(), SMDS_MeshGroup.NextSubGroup(), DriverUNV_R_SMDS_Mesh.Perform(), Driver_Mesh.SetFile(), Driver_SMDS_Mesh.SetMesh(), Driver_Mesh.SetMeshId(), SMESHDS_GroupBase.SetStoreName(), SMESHDS_Group.SetType(), and SMESHDS_Group.SMDSGroup().

{
  if(MYDEBUG) MESSAGE("UNVToMesh - theFileName = "<<theFileName);
  if(_isShapeToMesh)
    throw SALOME_Exception(LOCALIZED("a shape to mesh has already been defined"));
  _isShapeToMesh = false;
  DriverUNV_R_SMDS_Mesh myReader;
  myReader.SetMesh(_myMeshDS);
  myReader.SetFile(theFileName);
  myReader.SetMeshId(-1);
  myReader.Perform();
  if(MYDEBUG){
    MESSAGE("UNVToMesh - _myMeshDS->NbNodes() = "<<_myMeshDS->NbNodes());
    MESSAGE("UNVToMesh - _myMeshDS->NbEdges() = "<<_myMeshDS->NbEdges());
    MESSAGE("UNVToMesh - _myMeshDS->NbFaces() = "<<_myMeshDS->NbFaces());
    MESSAGE("UNVToMesh - _myMeshDS->NbVolumes() = "<<_myMeshDS->NbVolumes());
  }
  SMDS_MeshGroup* aGroup = (SMDS_MeshGroup*) myReader.GetGroup();
  if (aGroup != 0) {
    TGroupNamesMap aGroupNames = myReader.GetGroupNamesMap();
    //const TGroupIdMap& aGroupId = myReader.GetGroupIdMap();
    aGroup->InitSubGroupsIterator();
    while (aGroup->MoreSubGroups()) {
      SMDS_MeshGroup* aSubGroup = (SMDS_MeshGroup*) aGroup->NextSubGroup();
      string aName = aGroupNames[aSubGroup];
      int aId;

      SMESH_Group* aSMESHGroup = AddGroup( aSubGroup->GetType(), aName.c_str(), aId );
      if ( aSMESHGroup ) {
        if(MYDEBUG) MESSAGE("UNVToMesh - group added: "<<aName);      
        SMESHDS_Group* aGroupDS = dynamic_cast<SMESHDS_Group*>( aSMESHGroup->GetGroupDS() );
        if ( aGroupDS ) {
          aGroupDS->SetStoreName(aName.c_str());
          aSubGroup->InitIterator();
          const SMDS_MeshElement* aElement = 0;
          while (aSubGroup->More()) {
            aElement = aSubGroup->Next();
            if (aElement) {
              aGroupDS->SMDSGroup().Add(aElement);
            }
          }
          if (aElement)
            aGroupDS->SetType(aElement->GetType());
        }
      }
    }
  }
  return 1;
}

Field Documentation

SMESH_Gen* SMESH_Mesh._gen [protected]

Definition at line 316 of file SMESH_Mesh.hxx.

Referenced by SMESH_Mesh().

int SMESH_Mesh._groupId [protected]

Definition at line 310 of file SMESH_Mesh.hxx.

int SMESH_Mesh._id [protected]

Definition at line 307 of file SMESH_Mesh.hxx.

Referenced by SMESH_Mesh().

int SMESH_Mesh._idDoc [protected]

Definition at line 309 of file SMESH_Mesh.hxx.

Referenced by SMESH_Mesh().

Definition at line 320 of file SMESH_Mesh.hxx.

Referenced by SMESH_Mesh().

modified since last total re-compute, issue 0020693

Definition at line 321 of file SMESH_Mesh.hxx.

Referenced by SMESH_Mesh().

Definition at line 312 of file SMESH_Mesh.hxx.

Referenced by SMESH_Mesh().

TopTools_IndexedDataMapOfShapeListOfShape SMESH_Mesh._mapAncestors [protected]

Definition at line 325 of file SMESH_Mesh.hxx.

std::map<int, SMESH_Group*> SMESH_Mesh._mapGroup [protected]

Definition at line 318 of file SMESH_Mesh.hxx.

std::map<int, SMESH_subMesh*> SMESH_Mesh._mapSubMesh [protected]

Definition at line 317 of file SMESH_Mesh.hxx.

Definition at line 314 of file SMESH_Mesh.hxx.

Referenced by SMESH_Mesh().

Definition at line 315 of file SMESH_Mesh.hxx.

Referenced by SMESH_Mesh().

Definition at line 327 of file SMESH_Mesh.hxx.

Definition at line 311 of file SMESH_Mesh.hxx.

Definition at line 332 of file SMESH_Mesh.hxx.

Referenced by SMESH_Mesh().

double SMESH_Mesh._shapeDiagonal [protected]

diagonal size of bounding box of shape to mesh

Definition at line 323 of file SMESH_Mesh.hxx.

Referenced by SMESH_Mesh().

int SMESH_Mesh._studyId [protected]

Definition at line 308 of file SMESH_Mesh.hxx.

Referenced by SMESH_Mesh().

Definition at line 313 of file SMESH_Mesh.hxx.

Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS