// Module : SMESH
// $Header$
-using namespace std;
-using namespace std;
#include "SMESH_Gen.hxx"
-
#include "SMESH_subMesh.hxx"
-
-#include "SMESHDS_ListOfPtrHypothesis.hxx"
-#include "SMESHDS_ListIteratorOfListOfPtrHypothesis.hxx"
#include "SMDS_MeshElement.hxx"
#include "SMDS_MeshNode.hxx"
SMESH_Gen::SMESH_Gen()
{
- MESSAGE("SMESH_Gen::SMESH_Gen");
- _localId = 0;
- _hypothesisFactory.SetGen(this);
+ MESSAGE("SMESH_Gen::SMESH_Gen");
+ _localId = 0;
+ _hypothesisFactory.SetGen(this);
}
//=============================================================================
SMESH_Gen::~SMESH_Gen()
{
- MESSAGE("SMESH_Gen::~SMESH_Gen");
+ MESSAGE("SMESH_Gen::~SMESH_Gen");
}
//=============================================================================
*/
//=============================================================================
-SMESH_Hypothesis* SMESH_Gen::CreateHypothesis(const char* anHyp,
- int studyId)
- throw (SALOME_Exception)
+SMESH_Hypothesis *SMESH_Gen::CreateHypothesis(const char *anHyp, int studyId)
+ throw(SALOME_Exception)
{
- MESSAGE("SMESH_Gen::CreateHypothesis");
- // Get studyContext, create it if it does'nt exist, with a SMESHDS_Document
+ MESSAGE("CreateHypothesis("<<anHyp<<","<<studyId<<")");
+ // Get studyContext, create it if it does'nt exist, with a SMESHDS_Document
- StudyContextStruct* myStudyContext = GetStudyContext(studyId);
+ StudyContextStruct *myStudyContext = GetStudyContext(studyId);
- // create a new hypothesis object, store its ref. in studyContext
+ // create a new hypothesis object, store its ref. in studyContext
- SMESH_Hypothesis* myHypothesis = _hypothesisFactory.Create(anHyp, studyId);
- int hypId = myHypothesis->GetID();
- myStudyContext->mapHypothesis[hypId] = myHypothesis;
- SCRUTE(studyId);
- SCRUTE(hypId);
+ SMESH_Hypothesis *myHypothesis = _hypothesisFactory.Create(anHyp, studyId);
+ int hypId = myHypothesis->GetID();
+ myStudyContext->mapHypothesis[hypId] = myHypothesis;
+ SCRUTE(studyId);
+ SCRUTE(hypId);
- // store hypothesis in SMESHDS document
+ // store hypothesis in SMESHDS document
- myStudyContext->myDocument->AddHypothesis(myHypothesis);
+ myStudyContext->myDocument->AddHypothesis(myHypothesis);
+ return myHypothesis;
}
//=============================================================================
*/
//=============================================================================
-SMESH_Mesh* SMESH_Gen::Init(int studyId, const TopoDS_Shape& aShape)
- throw (SALOME_Exception)
+SMESH_Mesh *SMESH_Gen::Init(int studyId, const TopoDS_Shape & aShape)
+throw(SALOME_Exception)
{
- MESSAGE("SMESH_Gen::Init");
+ MESSAGE("SMESH_Gen::Init");
// if (aShape.ShapeType() == TopAbs_COMPOUND)
// {
// INFOS("Mesh Compound not yet implemented!");
// throw(SALOME_Exception(LOCALIZED("Mesh Compound not yet implemented!")));
// }
- // Get studyContext, create it if it does'nt exist, with a SMESHDS_Document
+ // Get studyContext, create it if it does'nt exist, with a SMESHDS_Document
- StudyContextStruct* myStudyContext = GetStudyContext(studyId);
+ StudyContextStruct *myStudyContext = GetStudyContext(studyId);
- // create a new SMESH_mesh object
+ // create a new SMESH_mesh object
- SMESH_Mesh* mesh = new SMESH_Mesh(_localId++,
- studyId,
- this,
- myStudyContext->myDocument);
- myStudyContext->mapMesh[_localId] = mesh;
+ SMESH_Mesh *mesh = new SMESH_Mesh(_localId++,
+ studyId,
+ this,
+ myStudyContext->myDocument);
+ myStudyContext->mapMesh[_localId] = mesh;
- // associate a TopoDS_Shape to the mesh
+ // associate a TopoDS_Shape to the mesh
- mesh->ShapeToMesh(aShape);
- return mesh;
+ mesh->ShapeToMesh(aShape);
+ return mesh;
}
//=============================================================================
*/
//=============================================================================
-bool SMESH_Gen::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape)
- throw (SALOME_Exception)
+bool SMESH_Gen::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape)
+throw(SALOME_Exception)
{
- MESSAGE("SMESH_Gen::Compute");
+ MESSAGE("SMESH_Gen::Compute");
// bool isDone = false;
/*
Algo : s'appuie ou non sur une geometrie
Solid, Collection de Solid : 3D
*/
// *** corriger commentaires
- // check hypothesis associated to the mesh :
- // - only one algo : type compatible with the type of the shape
- // - hypothesis = compatible with algo
- // - check if hypothesis are applicable to this algo
- // - check contradictions within hypothesis
- // (test if enough hypothesis is done further)
+ // check hypothesis associated to the mesh :
+ // - only one algo : type compatible with the type of the shape
+ // - hypothesis = compatible with algo
+ // - check if hypothesis are applicable to this algo
+ // - check contradictions within hypothesis
+ // (test if enough hypothesis is done further)
- bool ret = true;
+ bool ret = true;
- SMESH_subMesh* sm = aMesh.GetSubMesh(aShape);
+ SMESH_subMesh *sm = aMesh.GetSubMesh(aShape);
// SCRUTE(sm);
- SMESH_subMesh* smToCompute = sm->GetFirstToCompute();
- while (smToCompute)
- {
- TopoDS_Shape subShape = smToCompute->GetSubShape();
- int dim = GetShapeDim(subShape);
- //SCRUTE(dim);
- if (dim > 0)
- {
- bool ret1 = smToCompute->ComputeStateEngine(SMESH_subMesh::COMPUTE);
- ret = ret && ret1;
- }
- else
+ SMESH_subMesh *smToCompute = sm->GetFirstToCompute();
+ while (smToCompute)
{
- ASSERT(dim == 0);
- ASSERT(smToCompute->_vertexSet == false);
- TopoDS_Vertex V1 = TopoDS::Vertex(subShape);
- gp_Pnt P1 = BRep_Tool::Pnt(V1);
- const Handle(SMESHDS_Mesh)& meshDS = aMesh.GetMeshDS();
- int nodeId = meshDS->AddNode(P1.X(), P1.Y(), P1.Z());
- //MESSAGE("point "<<nodeId<<" "<<P1.X()<<" "<<P1.Y()<<" "<<P1.Z());
- Handle (SMDS_MeshElement) elt = meshDS->FindNode(nodeId);
- Handle (SMDS_MeshNode) node = meshDS->GetNode(1, elt);
- meshDS->SetNodeOnVertex(node, V1);
- const Handle(SMESHDS_SubMesh)& subMeshDS
- = smToCompute->GetSubMeshDS();
- smToCompute->_vertexSet = true;
- bool ret1 = smToCompute->ComputeStateEngine(SMESH_subMesh::COMPUTE);
+ TopoDS_Shape subShape = smToCompute->GetSubShape();
+ int dim = GetShapeDim(subShape);
+ //SCRUTE(dim);
+ if (dim > 0)
+ {
+ bool ret1 = smToCompute->ComputeStateEngine(SMESH_subMesh::COMPUTE);
+ ret = ret && ret1;
+ }
+ else
+ {
+ ASSERT(dim == 0);
+ ASSERT(smToCompute->_vertexSet == false);
+ TopoDS_Vertex V1 = TopoDS::Vertex(subShape);
+ gp_Pnt P1 = BRep_Tool::Pnt(V1);
+ SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
+ //MESSAGE("point "<<nodeId<<" "<<P1.X()<<" "<<P1.Y()<<" "<<P1.Z());
+ SMDS_MeshNode * node = meshDS->AddNode(P1.X(), P1.Y(), P1.Z());
+ meshDS->SetNodeOnVertex(node, V1);
+ smToCompute->GetSubMeshDS();
+ smToCompute->_vertexSet = true;
+ smToCompute->ComputeStateEngine(SMESH_subMesh::COMPUTE);
+ }
+ smToCompute = sm->GetFirstToCompute();
}
- smToCompute = sm->GetFirstToCompute();
- }
- return ret;
+ return ret;
}
//=============================================================================
*/
//=============================================================================
-SMESH_Algo* SMESH_Gen::GetAlgo(SMESH_Mesh& aMesh,
- const TopoDS_Shape& aShape)
+SMESH_Algo *SMESH_Gen::GetAlgo(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape)
{
- //MESSAGE("SMESH_Gen::GetAlgo");
-
- SMESHDS_Hypothesis* theHyp = NULL;
- SMESH_Algo* algo = NULL;
- const Handle(SMESHDS_Mesh)& meshDS = aMesh.GetMeshDS();
- int hypType;
- int hypId;
- int algoDim;
+ //MESSAGE("SMESH_Gen::GetAlgo");
- // try shape first, then main shape
+ const SMESHDS_Hypothesis *theHyp = NULL;
+ SMESH_Algo *algo = NULL;
+ const SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
+ int hypType;
+ int hypId;
+ int algoDim;
- TopoDS_Shape mainShape = meshDS->ShapeToMesh();
- const TopoDS_Shape* shapeToTry[2] = {&aShape, &mainShape};
+ // try shape first, then main shape
- for (int iShape=0; iShape<2; iShape++)
- {
- TopoDS_Shape tryShape = (*shapeToTry[iShape]);
+ TopoDS_Shape mainShape = meshDS->ShapeToMesh();
+ const TopoDS_Shape *shapeToTry[2] = { &aShape, &mainShape };
- const SMESHDS_ListOfPtrHypothesis& listHyp
- = meshDS->GetHypothesis(tryShape);
- SMESHDS_ListIteratorOfListOfPtrHypothesis it(listHyp);
+ for (int iShape = 0; iShape < 2; iShape++)
+ {
+ TopoDS_Shape tryShape = (*shapeToTry[iShape]);
- int nb_algo = 0;
- int shapeDim = GetShapeDim(aShape);
- int typeOfShape = aShape.ShapeType();
+ const list<const SMESHDS_Hypothesis*>& listHyp =
+ meshDS->GetHypothesis(tryShape);
+ list<const SMESHDS_Hypothesis*>::const_iterator it=listHyp.begin();
+
+ int nb_algo = 0;
+ int shapeDim = GetShapeDim(aShape);
+ int typeOfShape = aShape.ShapeType();
- while (it.More())
- {
- SMESHDS_Hypothesis* anHyp = it.Value();
- hypType = anHyp->GetType();
-// SCRUTE(hypType);
- if (hypType > SMESHDS_Hypothesis::PARAM_ALGO)
- {
- switch (hypType)
+ while (it!=listHyp.end())
{
- case SMESHDS_Hypothesis::ALGO_1D: algoDim=1; break;
- case SMESHDS_Hypothesis::ALGO_2D: algoDim=2; break;
- case SMESHDS_Hypothesis::ALGO_3D: algoDim=3; break;
- default: algoDim=0; break;
+ const SMESHDS_Hypothesis *anHyp = *it;
+ hypType = anHyp->GetType();
+ //SCRUTE(hypType);
+ if (hypType > SMESHDS_Hypothesis::PARAM_ALGO)
+ {
+ switch (hypType)
+ {
+ case SMESHDS_Hypothesis::ALGO_1D:
+ algoDim = 1;
+ break;
+ case SMESHDS_Hypothesis::ALGO_2D:
+ algoDim = 2;
+ break;
+ case SMESHDS_Hypothesis::ALGO_3D:
+ algoDim = 3;
+ break;
+ default:
+ algoDim = 0;
+ break;
+ }
+ //SCRUTE(algoDim);
+ //SCRUTE(shapeDim);
+ //SCRUTE(typeOfShape);
+ if (shapeDim == algoDim) // count only algos of shape dim.
+ { // discard algos for subshapes
+ hypId = anHyp->GetID(); // (of lower dim.)
+ ASSERT(_mapAlgo.find(hypId) != _mapAlgo.end());
+ SMESH_Algo *anAlgo = _mapAlgo[hypId];
+ //SCRUTE(anAlgo->GetShapeType());
+ //if (anAlgo->GetShapeType() == typeOfShape)
+ if ((anAlgo->GetShapeType()) & (1 << typeOfShape))
+ { // only specific TopoDS_Shape
+ nb_algo++;
+ theHyp = anHyp;
+ }
+ }
+ }
+ if (nb_algo > 1) return NULL; // more than one algo
+ it++;
}
-// SCRUTE(algoDim);
-// SCRUTE(shapeDim);
-// SCRUTE(typeOfShape);
- if (shapeDim == algoDim) // count only algos of shape dim.
- { // discard algos for subshapes
- hypId = anHyp->GetID(); // (of lower dim.)
- ASSERT(_mapAlgo.find(hypId) != _mapAlgo.end());
- SMESH_Algo* anAlgo = _mapAlgo[hypId];
- //SCRUTE(anAlgo->GetShapeType());
-// if (anAlgo->GetShapeType() == typeOfShape)
- if ((anAlgo->GetShapeType()) & (1 << typeOfShape))
- { // only specific TopoDS_Shape
- nb_algo++;
- theHyp = anHyp;
- }
- }
- }
- if (nb_algo > 1) return NULL; // more than one algo
- it.Next();
+ if (nb_algo == 1) // one algo found : OK
+ break; // do not try a parent shape
}
- if (nb_algo == 1) // one algo found : OK
- break; // do not try a parent shape
- }
- if (!theHyp) return NULL; // no algo found
+ if (!theHyp)
+ return NULL; // no algo found
- hypType = theHyp->GetType();
- hypId = theHyp->GetID();
+ hypType = theHyp->GetType();
+ hypId = theHyp->GetID();
- ASSERT(_mapAlgo.find(hypId) != _mapAlgo.end());
- algo = _mapAlgo[hypId];
- const char* algoName = algo->GetName();
- //MESSAGE("Algo found " << algoName << " Id " << hypId);
- return algo;
+ ASSERT(_mapAlgo.find(hypId) != _mapAlgo.end());
+ algo = _mapAlgo[hypId];
+ //MESSAGE("Algo found " << algo->GetName() << " Id " << hypId);
+ return algo;
}
//=============================================================================
*/
//=============================================================================
-StudyContextStruct* SMESH_Gen::GetStudyContext(int studyId)
+StudyContextStruct *SMESH_Gen::GetStudyContext(int studyId)
{
- // Get studyContext, create it if it does'nt exist, with a SMESHDS_Document
-
- if (_mapStudyContext.find(studyId) == _mapStudyContext.end())
- {
- _mapStudyContext[studyId] = new StudyContextStruct;
- _mapStudyContext[studyId]->myDocument = new SMESHDS_Document(studyId);
- }
- StudyContextStruct* myStudyContext = _mapStudyContext[studyId];
+ // Get studyContext, create it if it does'nt exist, with a SMESHDS_Document
+
+ if (_mapStudyContext.find(studyId) == _mapStudyContext.end())
+ {
+ _mapStudyContext[studyId] = new StudyContextStruct;
+ _mapStudyContext[studyId]->myDocument = new SMESHDS_Document(studyId);
+ }
+ StudyContextStruct *myStudyContext = _mapStudyContext[studyId];
// ASSERT(_mapStudyContext.find(studyId) != _mapStudyContext.end());
- return myStudyContext;
+ return myStudyContext;
}
//=============================================================================
void SMESH_Gen::Load(int studyId, const char *aUrlOfFile)
{
-}
+}
//=============================================================================
/*!
void SMESH_Gen::Close(int studyId)
{
}
-
+
//=============================================================================
/*!
*
*/
//=============================================================================
-const char* SMESH_Gen::ComponentDataType()
+const char *SMESH_Gen::ComponentDataType()
{
}
-
//=============================================================================
/*!
*
*/
//=============================================================================
-const char* SMESH_Gen::IORToLocalPersistentID(const char* IORString,
- bool& IsAFile)
+const char *SMESH_Gen::IORToLocalPersistentID(const char *IORString,
+ bool & IsAFile)
{
}
*/
//=============================================================================
-const char* SMESH_Gen::LocalPersistentIDToIOR(const char* aLocalPersistentID)
+const char *SMESH_Gen::LocalPersistentIDToIOR(const char *aLocalPersistentID)
{
}
*/
//=============================================================================
-int SMESH_Gen::GetShapeDim(const TopoDS_Shape& aShape)
+int SMESH_Gen::GetShapeDim(const TopoDS_Shape & aShape)
{
- int shapeDim = -1; // Shape dimension: 0D, 1D, 2D, 3D
- int type = aShape.ShapeType();
- switch (type)
- {
+ int shapeDim = -1; // Shape dimension: 0D, 1D, 2D, 3D
+ int type = aShape.ShapeType();
+ switch (type)
+ {
// case TopAbs_COMPOUND:
// {
-// break;
+// break;
// }
- case TopAbs_COMPOUND:
- case TopAbs_COMPSOLID:
- case TopAbs_SOLID:
- case TopAbs_SHELL:
- {
- shapeDim = 3;
- break;
- }
- // case TopAbs_SHELL:
- case TopAbs_FACE:
- {
- shapeDim = 2;
- break;
- }
- case TopAbs_WIRE:
- case TopAbs_EDGE:
- {
- shapeDim = 1;
- break;
- }
- case TopAbs_VERTEX:
- {
- shapeDim = 0;
- break;
- }
- }
+ case TopAbs_COMPOUND:
+ case TopAbs_COMPSOLID:
+ case TopAbs_SOLID:
+ case TopAbs_SHELL:
+ {
+ shapeDim = 3;
+ break;
+ }
+ // case TopAbs_SHELL:
+ case TopAbs_FACE:
+ {
+ shapeDim = 2;
+ break;
+ }
+ case TopAbs_WIRE:
+ case TopAbs_EDGE:
+ {
+ shapeDim = 1;
+ break;
+ }
+ case TopAbs_VERTEX:
+ {
+ shapeDim = 0;
+ break;
+ }
+ }
// SCRUTE(shapeDim);
- return shapeDim;
+ return shapeDim;
}