#include "DriverSTL_R_SMDS_Mesh.h"
#include <BRepTools_WireExplorer.hxx>
+#include <BRepPrimAPI_MakeBox.hxx>
#include <BRep_Builder.hxx>
#include <gp_Pnt.hxx>
static int MYDEBUG = 0;
#endif
+#define cSMESH_Hyp(h) static_cast<const SMESH_Hypothesis*>(h)
//=============================================================================
/*!
*/
//=============================================================================
-SMESH_Mesh::SMESH_Mesh(int theLocalId,
- int theStudyId,
- SMESH_Gen* theGen,
- bool theIsEmbeddedMode,
+SMESH_Mesh::SMESH_Mesh(int theLocalId,
+ int theStudyId,
+ SMESH_Gen* theGen,
+ bool theIsEmbeddedMode,
SMESHDS_Document* theDocument):
_groupId( 0 )
{
- INFOS("SMESH_Mesh::SMESH_Mesh(int localId)");
- _id = theLocalId;
- _studyId = theStudyId;
- _gen = theGen;
- _myDocument = theDocument;
- _idDoc = theDocument->NewMesh(theIsEmbeddedMode);
- _myMeshDS = theDocument->GetMesh(_idDoc);
+ 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;
+ _myMeshDS->ShapeToMesh( PseudoShape() );
}
//=============================================================================
//=============================================================================
/*!
- *
+ * \brief Set geometry to be meshed
*/
//=============================================================================
{
if(MYDEBUG) MESSAGE("SMESH_Mesh::ShapeToMesh");
- if ( !_myMeshDS->ShapeToMesh().IsNull() && aShape.IsNull() )
+ if ( !aShape.IsNull() && _isShapeToMesh )
+ throw SALOME_Exception(LOCALIZED ("a shape to mesh has already been defined"));
+
+ // clear current data
+ if ( !_myMeshDS->ShapeToMesh().IsNull() )
{
// removal of a shape to mesh, delete objects referring to sub-shapes:
// - sub-meshes
else
i_gr++;
}
+ _mapAncestors.Clear();
_mapPropagationChains.Clear();
+
+ // clear SMESHDS
+ TopoDS_Shape aNullShape;
+ _myMeshDS->ShapeToMesh( aNullShape );
}
- else
+
+ // set a new geometry
+ if ( !aShape.IsNull() )
{
- if (_isShapeToMesh)
- throw SALOME_Exception(LOCALIZED ("a shape to mesh has already been defined"));
+ _myMeshDS->ShapeToMesh(aShape);
+ _isShapeToMesh = true;
+
+ // fill _mapAncestors
+ int desType, ancType;
+ for ( desType = TopAbs_VERTEX; desType > TopAbs_COMPOUND; desType-- )
+ for ( ancType = desType - 1; ancType >= TopAbs_COMPOUND; ancType-- )
+ TopExp::MapShapesAndAncestors ( aShape,
+ (TopAbs_ShapeEnum) desType,
+ (TopAbs_ShapeEnum) ancType,
+ _mapAncestors );
}
- _isShapeToMesh = true;
- _myMeshDS->ShapeToMesh(aShape);
-
- // fill _mapAncestors
- _mapAncestors.Clear();
- int desType, ancType;
- for ( desType = TopAbs_VERTEX; desType > TopAbs_COMPOUND; desType-- )
- for ( ancType = desType - 1; ancType >= TopAbs_COMPOUND; ancType-- )
- TopExp::MapShapesAndAncestors ( aShape,
- (TopAbs_ShapeEnum) desType,
- (TopAbs_ShapeEnum) ancType,
- _mapAncestors );
-
- // NRI : 24/02/03
- //EAP: 1/9/04 TopExp::MapShapes(aShape, _subShapes); USE the same map of _myMeshDS
+}
+
+//=======================================================================
+/*!
+ * \brief Return geometry to be meshed. (It may be a PseudoShape()!)
+ */
+//=======================================================================
+
+TopoDS_Shape SMESH_Mesh::GetShapeToMesh() const
+{
+ return _myMeshDS->ShapeToMesh();
+}
+
+//=======================================================================
+/*!
+ * \brief Return a solid which is returned by GetShapeToMesh() if
+ * a real geometry to be meshed was not set
+ */
+//=======================================================================
+
+const TopoDS_Solid& SMESH_Mesh::PseudoShape()
+{
+ static TopoDS_Solid aSolid;
+ if ( aSolid.IsNull() )
+ {
+ aSolid = BRepPrimAPI_MakeBox(1,1,1);
+ }
+ return aSolid;
}
//=======================================================================
// shape
- int event;
- if (anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO)
- event = SMESH_subMesh::ADD_HYP;
- else
- event = SMESH_subMesh::ADD_ALGO;
+ 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) &&
- !subMesh->IsApplicableHypotesis( anHyp )) // is added on father
+ anHyp->GetDim() <= SMESH_Gen::GetShapeDim(aSubShape)) // is added on father
{
- if (anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO)
- event = SMESH_subMesh::ADD_FATHER_HYP;
- else
- event = SMESH_subMesh::ADD_FATHER_ALGO;
+ event = isAlgo ? SMESH_subMesh::ADD_FATHER_ALGO : SMESH_subMesh::ADD_FATHER_HYP;
+
SMESH_Hypothesis::Hypothesis_Status ret2 =
subMesh->SubMeshesAlgoStateEngine(event, anHyp);
if (ret2 > ret)
SMESH_Hypothesis *anHyp = sc->mapHypothesis[anHypId];
int hypType = anHyp->GetType();
if(MYDEBUG) SCRUTE(hypType);
- int event;
// shape
- if (anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO)
- event = SMESH_subMesh::REMOVE_HYP;
- else
- event = SMESH_subMesh::REMOVE_ALGO;
+ bool isAlgo = ( !anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO );
+ int event = isAlgo ? SMESH_subMesh::REMOVE_ALGO : SMESH_subMesh::REMOVE_HYP;
+
SMESH_Hypothesis::Hypothesis_Status ret = subMesh->AlgoStateEngine(event, anHyp);
// there may appear concurrent hyps that were covered by the removed hyp
// subShapes
if (!SMESH_Hypothesis::IsStatusFatal(ret) &&
- !subMesh->IsApplicableHypotesis( anHyp )) // is removed from father
+ anHyp->GetDim() <= SMESH_Gen::GetShapeDim(aSubShape)) // is removed from father
{
- if (anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO)
- event = SMESH_subMesh::REMOVE_FATHER_HYP;
- else
- event = SMESH_subMesh::REMOVE_FATHER_ALGO;
+ 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
*/
//=============================================================================
-SMESHDS_Mesh * SMESH_Mesh::GetMeshDS()
-{
- return _myMeshDS;
-}
-
-//=============================================================================
-/*!
- *
- */
-//=============================================================================
-
const list<const SMESHDS_Hypothesis*>&
SMESH_Mesh::GetHypothesisList(const TopoDS_Shape & aSubShape) const
throw(SALOME_Exception)
}
//=======================================================================
-//function : GetHypothesis
-//purpose :
+/*!
+ * \brief Return the hypothesis assigned to the shape
+ * \param aSubShape - the shape to check
+ * \param aFilter - the hypothesis filter
+ * \param andAncestors - flag to check hypos assigned to ancestors of the shape
+ * \retval SMESH_Hypothesis* - the first hypo passed through aFilter
+ */
//=======================================================================
const SMESH_Hypothesis * SMESH_Mesh::GetHypothesis(const TopoDS_Shape & aSubShape,
const list<const SMESHDS_Hypothesis*>& hypList = _myMeshDS->GetHypothesis(aSubShape);
list<const SMESHDS_Hypothesis*>::const_iterator hyp = hypList.begin();
for ( ; hyp != hypList.end(); hyp++ ) {
- const SMESH_Hypothesis * h = static_cast<const SMESH_Hypothesis*>( *hyp );
+ const SMESH_Hypothesis * h = cSMESH_Hyp( *hyp );
if ( aFilter.IsOk( h, aSubShape))
return h;
}
const list<const SMESHDS_Hypothesis*>& hypList = _myMeshDS->GetHypothesis(it.Value());
list<const SMESHDS_Hypothesis*>::const_iterator hyp = hypList.begin();
for ( ; hyp != hypList.end(); hyp++ ) {
- const SMESH_Hypothesis * h = static_cast<const SMESH_Hypothesis*>( *hyp );
+ const SMESH_Hypothesis * h = cSMESH_Hyp( *hyp );
if (aFilter.IsOk( h, it.Value() ))
return h;
}
return 0;
}
-//=======================================================================
-//function : GetHypotheses
-//purpose :
-//=======================================================================
-
//================================================================================
/*!
* \brief Return hypothesis assigned to the shape
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++ )
+ 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 (static_cast<const SMESH_Hypothesis*>( *hyp ), aSubShape) &&
+ 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;
}
}
continue;
const list<const SMESHDS_Hypothesis*>& hypList = _myMeshDS->GetHypothesis(it.Value());
for ( hyp = hypList.begin(); hyp != hypList.end(); hyp++ )
- if (aFilter.IsOk( static_cast<const SMESH_Hypothesis*>( *hyp ), it.Value() ) &&
- hypTypes.insert( (*hyp)->GetName() ).second ) {
+ if (aFilter.IsOk( cSMESH_Hyp( *hyp ), it.Value() ) &&
+ ( cSMESH_Hyp(*hyp)->IsAuxiliary() || !mainHypFound ) &&
+ hypTypes.insert( (*hyp)->GetName() ).second )
+ {
aHypList.push_back( *hyp );
nbHyps++;
+ if ( !cSMESH_Hyp(*hyp)->IsAuxiliary() )
+ mainHypFound = true;
}
}
}
_myMeshDS->GetScript()->Clear();
}
-//=============================================================================
-/*!
- *
- */
-//=============================================================================
-
-int SMESH_Mesh::GetId()
-{
- if(MYDEBUG) MESSAGE("SMESH_Mesh::GetId");
- return _id;
-}
-
-//=============================================================================
-/*!
- *
- */
-//=============================================================================
-
-SMESH_Gen *SMESH_Mesh::GetGen()
-{
- return _gen;
-}
-
//=============================================================================
/*!
* Get or Create the SMESH_subMesh object implementation
{
Unexpect aCatch(SalomeException);
- const SMESH_Hypothesis* hyp = static_cast<const SMESH_Hypothesis*>(theChangedHyp);
+ const SMESH_Hypothesis* hyp = cSMESH_Hyp(theChangedHyp);
const SMESH_Algo *foundAlgo = 0;
SMESH_HypoFilter algoKind( SMESH_HypoFilter::IsAlgo() );
if ( GetHypotheses( aSubShape, compatibleHypoKind, usedHyps, true ) &&
find( usedHyps.begin(), usedHyps.end(), hyp ) != usedHyps.end() )
{
- aSubMesh->ComputeStateEngine(SMESH_subMesh::MODIF_HYP);
+ aSubMesh->AlgoStateEngine(SMESH_subMesh::MODIF_HYP,
+ const_cast< SMESH_Hypothesis*>( hyp ));
if ( algo->GetDim() == 1 && IsPropagationHypothesis( aSubShape ))
CleanMeshOnPropagationChain( aSubShape );
{
int clause = 0;
save << "========================== Dump contents of mesh ==========================" << endl << endl;
- save << ++clause << ") Total number of nodes: " << NbNodes() << 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";
ElementOrder order = isQuadratic ? ORDER_QUADRATIC : ORDER_LINEAR;
- save << ++clause << ") Total number of " << orderStr << " edges: " << NbEdges(order) << endl;
- save << ++clause << ") Total number of " << orderStr << " faces: " << NbFaces(order) << endl;
+ 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: " << nb3 << endl;
- save << clause << ".2.) Number of " << orderStr << " quadrangles: " << nb4 << endl;
+ 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();
myFaceMap[ nbNodes ] = 0;
myFaceMap[ nbNodes ] = myFaceMap[ nbNodes ] + 1;
}
- save << clause << ".3.) Faces in detail: " << endl;
+ 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: " << itF->second << endl;
+ save << "--> nb nodes: " << itF->first << " - nb elemens:\t" << itF->second << endl;
}
}
- save << ++clause << ") Total number of " << orderStr << " volumes: " << NbVolumes(order) << 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: " << nb8 << endl;
- save << clause << ".2.) Number of " << orderStr << " tetrahedrons: " << nb4 << endl;
- save << clause << ".3.) Number of " << orderStr << " prisms: " << nb6 << endl;
- save << clause << ".4.) Number of " << orderStr << " pyramides: " << nb5 << endl;
+ 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();
myVolumesMap[ nbNodes ] = 0;
myVolumesMap[ nbNodes ] = myVolumesMap[ nbNodes ] + 1;
}
- save << clause << ".5.) Volumes in detail: " << endl;
+ 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: " << itV->second << endl;
+ save << "--> nb nodes: " << itV->first << " - nb elemens:\t" << itV->second << endl;
}
}
save << endl;