#include "SMESH_Group.hxx"
#include "SMESHDS_Group.hxx"
#include "SMESHDS_Script.hxx"
+#include "SMESHDS_GroupOnGeom.hxx"
#include "SMDS_MeshVolume.hxx"
#include "utilities.h"
*/
//=============================================================================
-void SMESH_Mesh::ShapeToMesh(const TopoDS_Shape & aShape){
+void SMESH_Mesh::ShapeToMesh(const TopoDS_Shape & aShape)
+{
if(MYDEBUG) MESSAGE("SMESH_Mesh::ShapeToMesh");
- if (_isShapeToMesh)
- throw
- SALOME_Exception(LOCALIZED
- ("a shape to mesh as already been defined"));
+
+ if ( !_myMeshDS->ShapeToMesh().IsNull() && aShape.IsNull() )
+ {
+ // removal of a shape to mesh, delete objects referring to sub-shapes:
+ // - sub-meshes
+ map <int, SMESH_subMesh *>::iterator i_sm = _mapSubMesh.begin();
+ for ( ; i_sm != _mapSubMesh.end(); ++i_sm )
+ delete i_sm->second;
+ _mapSubMesh.clear();
+ // - groups on geometry
+ map <int, SMESH_Group *>::iterator i_gr = _mapGroup.begin();
+ while ( i_gr != _mapGroup.end() ) {
+ if ( dynamic_cast<SMESHDS_GroupOnGeom*>( i_gr->second->GetGroupDS() )) {
+ _myMeshDS->RemoveGroup( i_gr->second->GetGroupDS() );
+ delete i_gr->second;
+ _mapGroup.erase( i_gr++ );
+ }
+ else
+ i_gr++;
+ }
+ _mapAncestors.Clear();
+ _mapPropagationChains.Clear();
+ }
+ else
+ {
+ if (_isShapeToMesh)
+ throw SALOME_Exception(LOCALIZED ("a shape to mesh has already been defined"));
+ }
_isShapeToMesh = true;
_myMeshDS->ShapeToMesh(aShape);
-
// NRI : 24/02/03
//EAP: 1/9/04 TopExp::MapShapes(aShape, _subShapes); USE the same map of _myMeshDS
}
{
if(MYDEBUG) MESSAGE("UNVToMesh - theFileName = "<<theFileName);
if(_isShapeToMesh)
- throw SALOME_Exception(LOCALIZED("a shape to mesh as already been defined"));
+ throw SALOME_Exception(LOCALIZED("a shape to mesh has already been defined"));
_isShapeToMesh = true;
DriverUNV_R_SMDS_Mesh myReader;
myReader.SetMesh(_myMeshDS);
{
if(MYDEBUG) MESSAGE("MEDToMesh - theFileName = "<<theFileName<<", mesh name = "<<theMeshName);
if(_isShapeToMesh)
- throw SALOME_Exception(LOCALIZED("a shape to mesh as already been defined"));
+ throw SALOME_Exception(LOCALIZED("a shape to mesh has already been defined"));
_isShapeToMesh = true;
DriverMED_R_SMESHDS_Mesh myReader;
myReader.SetMesh(_myMeshDS);
{
if(MYDEBUG) MESSAGE("UNVToMesh - theFileName = "<<theFileName);
if(_isShapeToMesh)
- throw SALOME_Exception(LOCALIZED("a shape to mesh as already been defined"));
+ throw SALOME_Exception(LOCALIZED("a shape to mesh has already been defined"));
_isShapeToMesh = true;
DriverSTL_R_SMDS_Mesh myReader;
myReader.SetMesh(_myMeshDS);
*/
//=============================================================================
-void SMESH_Mesh::ExportMED(const char *file, const char* theMeshName, bool theAutoGroups) throw(SALOME_Exception)
+void SMESH_Mesh::ExportMED(const char *file,
+ const char* theMeshName,
+ bool theAutoGroups,
+ int theVersion)
+ throw(SALOME_Exception)
{
Unexpect aCatch(SalomeException);
DriverMED_W_SMESHDS_Mesh myWriter;
- myWriter.SetFile ( file );
+ myWriter.SetFile ( file, MED::EVersion(theVersion) );
myWriter.SetMesh ( _myMeshDS );
if ( !theMeshName )
myWriter.SetMeshId ( _idDoc );
return false;
}
+//=============================================================================
+/*!
+ * IsReversedInChain
+ */
+//=============================================================================
+
+bool SMESH_Mesh::IsReversedInChain (const TopoDS_Shape& theEdge,
+ const TopoDS_Shape& theMainEdge)
+{
+ if ( !theMainEdge.IsNull() && !theEdge.IsNull() &&
+ _mapPropagationChains.Contains( theMainEdge ))
+ {
+ const TopTools_IndexedMapOfShape& aChain =
+ _mapPropagationChains.FindFromKey( theMainEdge );
+ int index = aChain.FindIndex( theEdge );
+ if ( index )
+ return aChain(index).Orientation() == TopAbs_REVERSED;
+ }
+ return false;
+}
//=============================================================================
/*!
// List of edges, added to chain on the previous cycle pass
TopTools_ListOfShape listPrevEdges;
- listPrevEdges.Append(theMainEdge);
+ listPrevEdges.Append(theMainEdge.Oriented( TopAbs_FORWARD ));
// 5____4____3____4____5____6
// | | | | | |
if (!_mapAncestors.Contains(anEdges(nb))) {
MESSAGE("WIRE EXPLORER HAVE GIVEN AN INVALID EDGE !!!");
break;
- } else {
- int ind = _mapAncestors.FindIndex(anEdges(nb));
- anEdges(nb) = _mapAncestors.FindKey(ind);
}
if (anEdges(nb).IsSame(anE)) found = nb;
}
aChain.Clear();
return false;
} else {
- // Add found edge to the chain
+ // Add found edge to the chain oriented so that to
+ // have it in aChain co-directed with theMainEdge
+ TopAbs_Orientation ori = anE.Orientation();
+ if ( anEdges(opp).Orientation() == anEdges(found).Orientation() )
+ ori = TopAbs::Reverse( ori );
+ anOppE.Orientation( ori );
aChain.Add(anOppE);
listCurEdges.Append(anOppE);
}