Update to match the change of SMDS (new DS).

This commit is contained in:
jrt 2003-09-04 09:21:41 +00:00
parent 0273fe09c6
commit bb2c60c2b6
13 changed files with 3695 additions and 3736 deletions

View File

@ -32,9 +32,6 @@ using namespace std;
#include "SMESH_Gen.hxx" #include "SMESH_Gen.hxx"
#include "SMESH_Mesh.hxx" #include "SMESH_Mesh.hxx"
#include "SMESHDS_ListOfPtrHypothesis.hxx"
#include "SMESHDS_ListIteratorOfListOfPtrHypothesis.hxx"
#include <GeomAdaptor_Curve.hxx> #include <GeomAdaptor_Curve.hxx>
#include <BRep_Tool.hxx> #include <BRep_Tool.hxx>
#include <GCPnts_AbscissaPoint.hxx> #include <GCPnts_AbscissaPoint.hxx>
@ -49,8 +46,8 @@ using namespace std;
*/ */
//============================================================================= //=============================================================================
SMESH_Algo::SMESH_Algo(int hypId, int studyId, SMESH_Gen* gen) SMESH_Algo::SMESH_Algo(int hypId, int studyId,
: SMESH_Hypothesis(hypId, studyId, gen) SMESH_Gen * gen):SMESH_Hypothesis(hypId, studyId, gen)
{ {
// _compatibleHypothesis.push_back("hypothese_bidon"); // _compatibleHypothesis.push_back("hypothese_bidon");
_type = ALGO; _type = ALGO;
@ -73,7 +70,7 @@ SMESH_Algo::~SMESH_Algo()
*/ */
//============================================================================= //=============================================================================
const vector<string> & SMESH_Algo::GetCompatibleHypothesis() const vector < string > &SMESH_Algo::GetCompatibleHypothesis()
{ {
return _compatibleHypothesis; return _compatibleHypothesis;
} }
@ -106,7 +103,7 @@ istream & SMESH_Algo::LoadFrom(istream & load)
*/ */
//============================================================================= //=============================================================================
ostream& operator << (ostream & save, SMESH_Algo & hyp) ostream & operator <<(ostream & save, SMESH_Algo & hyp)
{ {
return save; return save;
} }
@ -117,7 +114,7 @@ ostream& operator << (ostream & save, SMESH_Algo & hyp)
*/ */
//============================================================================= //=============================================================================
istream& operator >> (istream & load, SMESH_Algo & hyp) istream & operator >>(istream & load, SMESH_Algo & hyp)
{ {
return load; return load;
} }
@ -128,8 +125,8 @@ istream& operator >> (istream & load, SMESH_Algo & hyp)
*/ */
//============================================================================= //=============================================================================
bool SMESH_Algo::CheckHypothesis(SMESH_Mesh& aMesh, bool SMESH_Algo::CheckHypothesis(SMESH_Mesh & aMesh,
const TopoDS_Shape& aShape) const TopoDS_Shape & aShape)
{ {
MESSAGE("SMESH_Algo::CheckHypothesis"); MESSAGE("SMESH_Algo::CheckHypothesis");
ASSERT(0); // use method from derived classes ASSERT(0); // use method from derived classes
@ -142,8 +139,7 @@ bool SMESH_Algo::CheckHypothesis(SMESH_Mesh& aMesh,
*/ */
//============================================================================= //=============================================================================
bool SMESH_Algo::Compute(SMESH_Mesh& aMesh, bool SMESH_Algo::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape)
const TopoDS_Shape& aShape)
{ {
MESSAGE("SMESH_Algo::Compute"); MESSAGE("SMESH_Algo::Compute");
ASSERT(0); // use method from derived classes ASSERT(0); // use method from derived classes
@ -160,9 +156,8 @@ bool SMESH_Algo::Compute(SMESH_Mesh& aMesh,
*/ */
//============================================================================= //=============================================================================
const list<SMESHDS_Hypothesis*>& const list <const SMESHDS_Hypothesis *> & SMESH_Algo::GetUsedHypothesis(
SMESH_Algo::GetUsedHypothesis(SMESH_Mesh& aMesh, SMESH_Mesh & aMesh, const TopoDS_Shape & aShape)
const TopoDS_Shape& aShape)
{ {
_usedHypList.clear(); _usedHypList.clear();
_usedHypList = GetAppliedHypothesis(aMesh, aShape); // copy _usedHypList = GetAppliedHypothesis(aMesh, aShape); // copy
@ -176,7 +171,8 @@ SMESH_Algo::GetUsedHypothesis(SMESH_Mesh& aMesh,
nbHyp = _usedHypList.size(); nbHyp = _usedHypList.size();
} }
} }
if (nbHyp > 1) _usedHypList.clear(); //only one compatible hypothesis allowed if (nbHyp > 1)
_usedHypList.clear(); //only one compatible hypothesis allowed
return _usedHypList; return _usedHypList;
} }
@ -188,28 +184,27 @@ SMESH_Algo::GetUsedHypothesis(SMESH_Mesh& aMesh,
*/ */
//============================================================================= //=============================================================================
const list<SMESHDS_Hypothesis*>& const list<const SMESHDS_Hypothesis *> & SMESH_Algo::GetAppliedHypothesis(
SMESH_Algo::GetAppliedHypothesis(SMESH_Mesh& aMesh, SMESH_Mesh & aMesh, const TopoDS_Shape & aShape)
const TopoDS_Shape& aShape)
{ {
const Handle(SMESHDS_Mesh)& meshDS = aMesh.GetMeshDS(); const SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
const SMESHDS_ListOfPtrHypothesis& listHyp = meshDS->GetHypothesis(aShape); const list<const SMESHDS_Hypothesis*> & listHyp = meshDS->GetHypothesis(aShape);
SMESHDS_ListIteratorOfListOfPtrHypothesis it(listHyp); list<const SMESHDS_Hypothesis*>::const_iterator it=listHyp.begin();
int hypType; int hypType;
string hypName; string hypName;
_appliedHypList.clear(); _appliedHypList.clear();
while (it.More()) while (it!=listHyp.end())
{ {
SMESHDS_Hypothesis* anHyp = it.Value(); const SMESHDS_Hypothesis *anHyp = *it;
hypType = anHyp->GetType(); hypType = anHyp->GetType();
//SCRUTE(hypType); //SCRUTE(hypType);
if (hypType == SMESHDS_Hypothesis::PARAM_ALGO) if (hypType == SMESHDS_Hypothesis::PARAM_ALGO)
{ {
hypName = anHyp->GetName(); hypName = anHyp->GetName();
vector<string>::iterator ith = find(_compatibleHypothesis.begin(), vector < string >::iterator ith =
_compatibleHypothesis.end(), find(_compatibleHypothesis.begin(), _compatibleHypothesis.end(),
hypName); hypName);
if (ith != _compatibleHypothesis.end()) // count only relevant if (ith != _compatibleHypothesis.end()) // count only relevant
{ {
@ -217,27 +212,26 @@ SMESH_Algo::GetAppliedHypothesis(SMESH_Mesh& aMesh,
//SCRUTE(hypName); //SCRUTE(hypName);
} }
} }
it.Next(); it++;
} }
return _appliedHypList; return _appliedHypList;
} }
//============================================================================= //=============================================================================
/*! /*!
* Compute length of an edge * Compute length of an edge
*/ */
//============================================================================= //=============================================================================
double SMESH_Algo::EdgeLength(const TopoDS_Edge& E) double SMESH_Algo::EdgeLength(const TopoDS_Edge & E)
{ {
double UMin = 0, UMax = 0; double UMin = 0, UMax = 0;
TopLoc_Location L; TopLoc_Location L;
if (BRep_Tool::Degenerated(E)) return 0; if (BRep_Tool::Degenerated(E))
Handle (Geom_Curve) C = BRep_Tool::Curve(E, L, UMin, UMax); return 0;
Handle(Geom_Curve) C = BRep_Tool::Curve(E, L, UMin, UMax);
GeomAdaptor_Curve AdaptCurve(C); GeomAdaptor_Curve AdaptCurve(C);
GCPnts_AbscissaPoint gabs; GCPnts_AbscissaPoint gabs;
double length = gabs.Length(AdaptCurve, UMin, UMax); double length = gabs.Length(AdaptCurve, UMin, UMax);
return length; return length;
} }

View File

@ -37,43 +37,40 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include <list> #include <list>
using namespace std;
class SMESH_gen; class SMESH_gen;
class SMESH_Mesh; class SMESH_Mesh;
class SMESH_Algo: class SMESH_Algo:public SMESH_Hypothesis
public SMESH_Hypothesis
{ {
public: public:
SMESH_Algo(int hypId, int studyId, SMESH_Gen* gen); SMESH_Algo(int hypId, int studyId, SMESH_Gen * gen);
virtual ~SMESH_Algo(); virtual ~ SMESH_Algo();
const vector<string> & GetCompatibleHypothesis(); const vector < string > &GetCompatibleHypothesis();
virtual bool CheckHypothesis(SMESH_Mesh& aMesh, virtual bool CheckHypothesis(SMESH_Mesh & aMesh,
const TopoDS_Shape& aShape); const TopoDS_Shape & aShape);
virtual bool Compute(SMESH_Mesh& aMesh, virtual bool Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape);
const TopoDS_Shape& aShape);
virtual const list<SMESHDS_Hypothesis*>& virtual const list <const SMESHDS_Hypothesis *> &
GetUsedHypothesis(SMESH_Mesh& aMesh, GetUsedHypothesis(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape);
const TopoDS_Shape& aShape);
const list<SMESHDS_Hypothesis*>& const list <const SMESHDS_Hypothesis *> &
GetAppliedHypothesis(SMESH_Mesh& aMesh, GetAppliedHypothesis(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape);
const TopoDS_Shape& aShape);
static double EdgeLength(const TopoDS_Edge& E); static double EdgeLength(const TopoDS_Edge & E);
virtual ostream & SaveTo(ostream & save); virtual ostream & SaveTo(ostream & save);
virtual istream & LoadFrom(istream & load); virtual istream & LoadFrom(istream & load);
friend ostream& operator << (ostream & save, SMESH_Algo & hyp); friend ostream & operator <<(ostream & save, SMESH_Algo & hyp);
friend istream& operator >> (istream & load, SMESH_Algo & hyp); friend istream & operator >>(istream & load, SMESH_Algo & hyp);
protected: protected:
vector<string> _compatibleHypothesis; vector<string> _compatibleHypothesis;
list<SMESHDS_Hypothesis*> _appliedHypList; list<const SMESHDS_Hypothesis *> _appliedHypList;
list<SMESHDS_Hypothesis*> _usedHypList; list<const SMESHDS_Hypothesis *> _usedHypList;
}; };
#endif #endif

View File

@ -26,14 +26,8 @@
// Module : SMESH // Module : SMESH
// $Header$ // $Header$
using namespace std;
using namespace std;
#include "SMESH_Gen.hxx" #include "SMESH_Gen.hxx"
#include "SMESH_subMesh.hxx" #include "SMESH_subMesh.hxx"
#include "SMESHDS_ListOfPtrHypothesis.hxx"
#include "SMESHDS_ListIteratorOfListOfPtrHypothesis.hxx"
#include "SMDS_MeshElement.hxx" #include "SMDS_MeshElement.hxx"
#include "SMDS_MeshNode.hxx" #include "SMDS_MeshNode.hxx"
@ -73,19 +67,18 @@ SMESH_Gen::~SMESH_Gen()
*/ */
//============================================================================= //=============================================================================
SMESH_Hypothesis* SMESH_Gen::CreateHypothesis(const char* anHyp, SMESH_Hypothesis *SMESH_Gen::CreateHypothesis(const char *anHyp, int studyId)
int studyId) throw(SALOME_Exception)
throw (SALOME_Exception)
{ {
MESSAGE("SMESH_Gen::CreateHypothesis");
MESSAGE("CreateHypothesis("<<anHyp<<","<<studyId<<")");
// 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 hypothesis object, store its ref. in studyContext // create a new hypothesis object, store its ref. in studyContext
SMESH_Hypothesis* myHypothesis = _hypothesisFactory.Create(anHyp, studyId); SMESH_Hypothesis *myHypothesis = _hypothesisFactory.Create(anHyp, studyId);
int hypId = myHypothesis->GetID(); int hypId = myHypothesis->GetID();
myStudyContext->mapHypothesis[hypId] = myHypothesis; myStudyContext->mapHypothesis[hypId] = myHypothesis;
SCRUTE(studyId); SCRUTE(studyId);
@ -94,6 +87,7 @@ SMESH_Hypothesis* SMESH_Gen::CreateHypothesis(const char* anHyp,
// store hypothesis in SMESHDS document // store hypothesis in SMESHDS document
myStudyContext->myDocument->AddHypothesis(myHypothesis); myStudyContext->myDocument->AddHypothesis(myHypothesis);
return myHypothesis;
} }
//============================================================================= //=============================================================================
@ -102,8 +96,8 @@ SMESH_Hypothesis* SMESH_Gen::CreateHypothesis(const char* anHyp,
*/ */
//============================================================================= //=============================================================================
SMESH_Mesh* SMESH_Gen::Init(int studyId, const TopoDS_Shape& aShape) SMESH_Mesh *SMESH_Gen::Init(int studyId, const TopoDS_Shape & aShape)
throw (SALOME_Exception) throw(SALOME_Exception)
{ {
MESSAGE("SMESH_Gen::Init"); MESSAGE("SMESH_Gen::Init");
// if (aShape.ShapeType() == TopAbs_COMPOUND) // if (aShape.ShapeType() == TopAbs_COMPOUND)
@ -114,11 +108,11 @@ SMESH_Mesh* SMESH_Gen::Init(int studyId, const TopoDS_Shape& aShape)
// 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++, SMESH_Mesh *mesh = new SMESH_Mesh(_localId++,
studyId, studyId,
this, this,
myStudyContext->myDocument); myStudyContext->myDocument);
@ -136,8 +130,8 @@ SMESH_Mesh* SMESH_Gen::Init(int studyId, const TopoDS_Shape& aShape)
*/ */
//============================================================================= //=============================================================================
bool SMESH_Gen::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape) bool SMESH_Gen::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape)
throw (SALOME_Exception) throw(SALOME_Exception)
{ {
MESSAGE("SMESH_Gen::Compute"); MESSAGE("SMESH_Gen::Compute");
// bool isDone = false; // bool isDone = false;
@ -159,9 +153,9 @@ Solid, Collection de Solid : 3D
bool ret = true; bool ret = true;
SMESH_subMesh* sm = aMesh.GetSubMesh(aShape); SMESH_subMesh *sm = aMesh.GetSubMesh(aShape);
// SCRUTE(sm); // SCRUTE(sm);
SMESH_subMesh* smToCompute = sm->GetFirstToCompute(); SMESH_subMesh *smToCompute = sm->GetFirstToCompute();
while (smToCompute) while (smToCompute)
{ {
TopoDS_Shape subShape = smToCompute->GetSubShape(); TopoDS_Shape subShape = smToCompute->GetSubShape();
@ -178,16 +172,13 @@ Solid, Collection de Solid : 3D
ASSERT(smToCompute->_vertexSet == false); ASSERT(smToCompute->_vertexSet == false);
TopoDS_Vertex V1 = TopoDS::Vertex(subShape); TopoDS_Vertex V1 = TopoDS::Vertex(subShape);
gp_Pnt P1 = BRep_Tool::Pnt(V1); gp_Pnt P1 = BRep_Tool::Pnt(V1);
const Handle(SMESHDS_Mesh)& meshDS = aMesh.GetMeshDS(); SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
int nodeId = meshDS->AddNode(P1.X(), P1.Y(), P1.Z());
//MESSAGE("point "<<nodeId<<" "<<P1.X()<<" "<<P1.Y()<<" "<<P1.Z()); //MESSAGE("point "<<nodeId<<" "<<P1.X()<<" "<<P1.Y()<<" "<<P1.Z());
Handle (SMDS_MeshElement) elt = meshDS->FindNode(nodeId); SMDS_MeshNode * node = meshDS->AddNode(P1.X(), P1.Y(), P1.Z());
Handle (SMDS_MeshNode) node = meshDS->GetNode(1, elt);
meshDS->SetNodeOnVertex(node, V1); meshDS->SetNodeOnVertex(node, V1);
const Handle(SMESHDS_SubMesh)& subMeshDS smToCompute->GetSubMeshDS();
= smToCompute->GetSubMeshDS();
smToCompute->_vertexSet = true; smToCompute->_vertexSet = true;
bool ret1 = smToCompute->ComputeStateEngine(SMESH_subMesh::COMPUTE); smToCompute->ComputeStateEngine(SMESH_subMesh::COMPUTE);
} }
smToCompute = sm->GetFirstToCompute(); smToCompute = sm->GetFirstToCompute();
} }
@ -201,14 +192,13 @@ Solid, Collection de Solid : 3D
*/ */
//============================================================================= //=============================================================================
SMESH_Algo* SMESH_Gen::GetAlgo(SMESH_Mesh& aMesh, SMESH_Algo *SMESH_Gen::GetAlgo(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape)
const TopoDS_Shape& aShape)
{ {
//MESSAGE("SMESH_Gen::GetAlgo"); //MESSAGE("SMESH_Gen::GetAlgo");
SMESHDS_Hypothesis* theHyp = NULL; const SMESHDS_Hypothesis *theHyp = NULL;
SMESH_Algo* algo = NULL; SMESH_Algo *algo = NULL;
const Handle(SMESHDS_Mesh)& meshDS = aMesh.GetMeshDS(); const SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
int hypType; int hypType;
int hypId; int hypId;
int algoDim; int algoDim;
@ -216,44 +206,52 @@ SMESH_Algo* SMESH_Gen::GetAlgo(SMESH_Mesh& aMesh,
// try shape first, then main shape // try shape first, then main shape
TopoDS_Shape mainShape = meshDS->ShapeToMesh(); TopoDS_Shape mainShape = meshDS->ShapeToMesh();
const TopoDS_Shape* shapeToTry[2] = {&aShape, &mainShape}; const TopoDS_Shape *shapeToTry[2] = { &aShape, &mainShape };
for (int iShape=0; iShape<2; iShape++) for (int iShape = 0; iShape < 2; iShape++)
{ {
TopoDS_Shape tryShape = (*shapeToTry[iShape]); TopoDS_Shape tryShape = (*shapeToTry[iShape]);
const SMESHDS_ListOfPtrHypothesis& listHyp const list<const SMESHDS_Hypothesis*>& listHyp =
= meshDS->GetHypothesis(tryShape); meshDS->GetHypothesis(tryShape);
SMESHDS_ListIteratorOfListOfPtrHypothesis it(listHyp); list<const SMESHDS_Hypothesis*>::const_iterator it=listHyp.begin();
int nb_algo = 0; int nb_algo = 0;
int shapeDim = GetShapeDim(aShape); int shapeDim = GetShapeDim(aShape);
int typeOfShape = aShape.ShapeType(); int typeOfShape = aShape.ShapeType();
while (it.More()) while (it!=listHyp.end())
{ {
SMESHDS_Hypothesis* anHyp = it.Value(); const SMESHDS_Hypothesis *anHyp = *it;
hypType = anHyp->GetType(); hypType = anHyp->GetType();
// SCRUTE(hypType); //SCRUTE(hypType);
if (hypType > SMESHDS_Hypothesis::PARAM_ALGO) if (hypType > SMESHDS_Hypothesis::PARAM_ALGO)
{ {
switch (hypType) switch (hypType)
{ {
case SMESHDS_Hypothesis::ALGO_1D: algoDim=1; break; case SMESHDS_Hypothesis::ALGO_1D:
case SMESHDS_Hypothesis::ALGO_2D: algoDim=2; break; algoDim = 1;
case SMESHDS_Hypothesis::ALGO_3D: algoDim=3; break; break;
default: algoDim=0; break; case SMESHDS_Hypothesis::ALGO_2D:
algoDim = 2;
break;
case SMESHDS_Hypothesis::ALGO_3D:
algoDim = 3;
break;
default:
algoDim = 0;
break;
} }
// SCRUTE(algoDim); //SCRUTE(algoDim);
// SCRUTE(shapeDim); //SCRUTE(shapeDim);
// SCRUTE(typeOfShape); //SCRUTE(typeOfShape);
if (shapeDim == algoDim) // count only algos of shape dim. if (shapeDim == algoDim) // count only algos of shape dim.
{ // discard algos for subshapes { // discard algos for subshapes
hypId = anHyp->GetID(); // (of lower dim.) hypId = anHyp->GetID(); // (of lower dim.)
ASSERT(_mapAlgo.find(hypId) != _mapAlgo.end()); ASSERT(_mapAlgo.find(hypId) != _mapAlgo.end());
SMESH_Algo* anAlgo = _mapAlgo[hypId]; SMESH_Algo *anAlgo = _mapAlgo[hypId];
//SCRUTE(anAlgo->GetShapeType()); //SCRUTE(anAlgo->GetShapeType());
// if (anAlgo->GetShapeType() == typeOfShape) //if (anAlgo->GetShapeType() == typeOfShape)
if ((anAlgo->GetShapeType()) & (1 << typeOfShape)) if ((anAlgo->GetShapeType()) & (1 << typeOfShape))
{ // only specific TopoDS_Shape { // only specific TopoDS_Shape
nb_algo++; nb_algo++;
@ -262,21 +260,21 @@ SMESH_Algo* SMESH_Gen::GetAlgo(SMESH_Mesh& aMesh,
} }
} }
if (nb_algo > 1) return NULL; // more than one algo if (nb_algo > 1) return NULL; // more than one algo
it.Next(); it++;
} }
if (nb_algo == 1) // one algo found : OK if (nb_algo == 1) // one algo found : OK
break; // do not try a parent shape break; // do not try a parent shape
} }
if (!theHyp) return NULL; // no algo found if (!theHyp)
return NULL; // no algo found
hypType = theHyp->GetType(); hypType = theHyp->GetType();
hypId = theHyp->GetID(); hypId = theHyp->GetID();
ASSERT(_mapAlgo.find(hypId) != _mapAlgo.end()); ASSERT(_mapAlgo.find(hypId) != _mapAlgo.end());
algo = _mapAlgo[hypId]; algo = _mapAlgo[hypId];
const char* algoName = algo->GetName(); //MESSAGE("Algo found " << algo->GetName() << " Id " << hypId);
//MESSAGE("Algo found " << algoName << " Id " << hypId);
return algo; return algo;
} }
@ -286,7 +284,7 @@ SMESH_Algo* SMESH_Gen::GetAlgo(SMESH_Mesh& aMesh,
*/ */
//============================================================================= //=============================================================================
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 // Get studyContext, create it if it does'nt exist, with a SMESHDS_Document
@ -295,7 +293,7 @@ StudyContextStruct* SMESH_Gen::GetStudyContext(int studyId)
_mapStudyContext[studyId] = new StudyContextStruct; _mapStudyContext[studyId] = new StudyContextStruct;
_mapStudyContext[studyId]->myDocument = new SMESHDS_Document(studyId); _mapStudyContext[studyId]->myDocument = new SMESHDS_Document(studyId);
} }
StudyContextStruct* myStudyContext = _mapStudyContext[studyId]; StudyContextStruct *myStudyContext = _mapStudyContext[studyId];
// ASSERT(_mapStudyContext.find(studyId) != _mapStudyContext.end()); // ASSERT(_mapStudyContext.find(studyId) != _mapStudyContext.end());
return myStudyContext; return myStudyContext;
} }
@ -336,19 +334,7 @@ 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)
{ {
} }
@ -358,7 +344,8 @@ const char* SMESH_Gen::IORToLocalPersistentID(const char* IORString,
*/ */
//============================================================================= //=============================================================================
const char* SMESH_Gen::LocalPersistentIDToIOR(const char* aLocalPersistentID) const char *SMESH_Gen::IORToLocalPersistentID(const char *IORString,
bool & IsAFile)
{ {
} }
@ -368,7 +355,17 @@ const char* SMESH_Gen::LocalPersistentIDToIOR(const char* aLocalPersistentID)
*/ */
//============================================================================= //=============================================================================
int SMESH_Gen::GetShapeDim(const TopoDS_Shape& aShape) const char *SMESH_Gen::LocalPersistentIDToIOR(const char *aLocalPersistentID)
{
}
//=============================================================================
/*!
*
*/
//=============================================================================
int SMESH_Gen::GetShapeDim(const TopoDS_Shape & aShape)
{ {
int shapeDim = -1; // Shape dimension: 0D, 1D, 2D, 3D int shapeDim = -1; // Shape dimension: 0D, 1D, 2D, 3D
int type = aShape.ShapeType(); int type = aShape.ShapeType();

View File

@ -44,52 +44,53 @@
#include <TopoDS_Shape.hxx> #include <TopoDS_Shape.hxx>
#include <map> #include <map>
using namespace std;
typedef struct studyContextStruct typedef struct studyContextStruct
{ {
map<int, SMESH_Hypothesis*> mapHypothesis; map < int, SMESH_Hypothesis * >mapHypothesis;
map<int, SMESH_Mesh*> mapMesh; map < int, SMESH_Mesh * >mapMesh;
Handle (SMESHDS_Document) myDocument; SMESHDS_Document * myDocument;
} StudyContextStruct ; } StudyContextStruct;
class SMESH_Gen class SMESH_Gen
{ {
public: public:
SMESH_Gen(); SMESH_Gen();
~SMESH_Gen(); ~SMESH_Gen();
SMESH_Hypothesis* CreateHypothesis(const char* anHyp, int studyId) SMESH_Hypothesis *CreateHypothesis(const char *anHyp, int studyId)
throw (SALOME_Exception); throw(SALOME_Exception);
SMESH_Mesh* Init(int studyId, const TopoDS_Shape& aShape) SMESH_Mesh *Init(int studyId, const TopoDS_Shape & aShape)
throw (SALOME_Exception); throw(SALOME_Exception);
bool Compute(::SMESH_Mesh& aMesh, const TopoDS_Shape& aShape) bool Compute(::SMESH_Mesh & aMesh, const TopoDS_Shape & aShape)
throw (SALOME_Exception); throw(SALOME_Exception);
StudyContextStruct* GetStudyContext(int studyId); StudyContextStruct *GetStudyContext(int studyId);
static int GetShapeDim(const TopoDS_Shape& aShape); static int GetShapeDim(const TopoDS_Shape & aShape);
SMESH_Algo* GetAlgo(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape); SMESH_Algo *GetAlgo(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape);
// inherited methods from SALOMEDS::Driver // inherited methods from SALOMEDS::Driver
void Save(int studyId, const char *aUrlOfFile); void Save(int studyId, const char *aUrlOfFile);
void Load(int studyId, const char *aUrlOfFile); void Load(int studyId, const char *aUrlOfFile);
void Close(int studyId); void Close(int studyId);
const char* ComponentDataType(); const char *ComponentDataType();
const char* IORToLocalPersistentID(const char* IORString, bool& IsAFile); const char *IORToLocalPersistentID(const char *IORString, bool & IsAFile);
const char* LocalPersistentIDToIOR(const char* aLocalPersistentID); const char *LocalPersistentIDToIOR(const char *aLocalPersistentID);
SMESH_HypothesisFactory _hypothesisFactory; SMESH_HypothesisFactory _hypothesisFactory;
map<int, SMESH_Algo*> _mapAlgo; map < int, SMESH_Algo * >_mapAlgo;
map<int, SMESH_1D_Algo*> _map1D_Algo; map < int, SMESH_1D_Algo * >_map1D_Algo;
map<int, SMESH_2D_Algo*> _map2D_Algo; map < int, SMESH_2D_Algo * >_map2D_Algo;
map<int, SMESH_3D_Algo*> _map3D_Algo; map < int, SMESH_3D_Algo * >_map3D_Algo;
private: private:
int _localId; // unique Id of created objects, within SMESH_Gen entity int _localId; // unique Id of created objects, within SMESH_Gen entity
map<int, StudyContextStruct*> _mapStudyContext; map < int, StudyContextStruct * >_mapStudyContext;
map<int, SMESH_Hypothesis*> _mapHypothesis; map < int, SMESH_Hypothesis * >_mapHypothesis;
}; };
#endif #endif

File diff suppressed because it is too large Load Diff

View File

@ -26,7 +26,6 @@
// Module : SMESH // Module : SMESH
// $Header$ // $Header$
using namespace std;
using namespace std; using namespace std;
#include "SMESH_MEFISTO_2D.hxx" #include "SMESH_MEFISTO_2D.hxx"
#include "SMESH_Gen.hxx" #include "SMESH_Gen.hxx"
@ -38,8 +37,6 @@ using namespace std;
#include "Rn.h" #include "Rn.h"
#include "aptrte.h" #include "aptrte.h"
#include "SMESHDS_ListOfPtrHypothesis.hxx"
#include "SMESHDS_ListIteratorOfListOfPtrHypothesis.hxx"
#include "SMDS_MeshElement.hxx" #include "SMDS_MeshElement.hxx"
#include "SMDS_MeshNode.hxx" #include "SMDS_MeshNode.hxx"
#include "SMDS_EdgePosition.hxx" #include "SMDS_EdgePosition.hxx"
@ -70,13 +67,13 @@ using namespace std;
*/ */
//============================================================================= //=============================================================================
SMESH_MEFISTO_2D::SMESH_MEFISTO_2D(int hypId, int studyId, SMESH_Gen* gen) SMESH_MEFISTO_2D::SMESH_MEFISTO_2D(int hypId, int studyId,
: SMESH_2D_Algo(hypId, studyId, gen) SMESH_Gen * gen):SMESH_2D_Algo(hypId, studyId, gen)
{ {
MESSAGE("SMESH_MEFISTO_2D::SMESH_MEFISTO_2D"); MESSAGE("SMESH_MEFISTO_2D::SMESH_MEFISTO_2D");
_name = "MEFISTO_2D"; _name = "MEFISTO_2D";
// _shapeType = TopAbs_FACE; // _shapeType = TopAbs_FACE;
_shapeType = (1<<TopAbs_FACE); _shapeType = (1 << TopAbs_FACE);
_compatibleHypothesis.push_back("MaxElementArea"); _compatibleHypothesis.push_back("MaxElementArea");
_compatibleHypothesis.push_back("LengthFromEdges"); _compatibleHypothesis.push_back("LengthFromEdges");
@ -103,20 +100,20 @@ SMESH_MEFISTO_2D::~SMESH_MEFISTO_2D()
*/ */
//============================================================================= //=============================================================================
bool SMESH_MEFISTO_2D::CheckHypothesis(SMESH_Mesh& aMesh, bool SMESH_MEFISTO_2D::CheckHypothesis(SMESH_Mesh & aMesh,
const TopoDS_Shape& aShape) const TopoDS_Shape & aShape)
{ {
//MESSAGE("SMESH_MEFISTO_2D::CheckHypothesis"); //MESSAGE("SMESH_MEFISTO_2D::CheckHypothesis");
_hypMaxElementArea = NULL; _hypMaxElementArea = NULL;
_hypLengthFromEdges = NULL; _hypLengthFromEdges = NULL;
list<SMESHDS_Hypothesis*>::const_iterator itl; list <const SMESHDS_Hypothesis * >::const_iterator itl;
SMESHDS_Hypothesis* theHyp; const SMESHDS_Hypothesis *theHyp;
const list<SMESHDS_Hypothesis*>& hyps = GetUsedHypothesis(aMesh, aShape); const list <const SMESHDS_Hypothesis * >&hyps = GetUsedHypothesis(aMesh, aShape);
int nbHyp = hyps.size(); int nbHyp = hyps.size();
if (nbHyp != 1) return false; // only one compatible hypothesis allowed if (nbHyp != 1) return false;// only one compatible hypothesis allowed
itl = hyps.begin(); itl = hyps.begin();
theHyp = (*itl); theHyp = (*itl);
@ -129,32 +126,32 @@ bool SMESH_MEFISTO_2D::CheckHypothesis(SMESH_Mesh& aMesh,
if (hypName == "MaxElementArea") if (hypName == "MaxElementArea")
{ {
_hypMaxElementArea = dynamic_cast<SMESH_MaxElementArea*> (theHyp); _hypMaxElementArea = static_cast<const SMESH_MaxElementArea *>(theHyp);
ASSERT(_hypMaxElementArea); ASSERT(_hypMaxElementArea);
_maxElementArea = _hypMaxElementArea->GetMaxArea(); _maxElementArea = _hypMaxElementArea->GetMaxArea();
_edgeLength = 0; _edgeLength = 0;
isOk =true; isOk = true;
} }
if (hypName == "LengthFromEdges") if (hypName == "LengthFromEdges")
{ {
_hypLengthFromEdges = dynamic_cast<SMESH_LengthFromEdges*> (theHyp); _hypLengthFromEdges = static_cast<const SMESH_LengthFromEdges *>(theHyp);
ASSERT(_hypLengthFromEdges); ASSERT(_hypLengthFromEdges);
_edgeLength = 0; _edgeLength = 0;
_maxElementArea = 0; _maxElementArea = 0;
isOk =true; isOk = true;
} }
if (isOk) if (isOk)
{ {
isOk = false; isOk = false;
if (_maxElementArea > 0) if (_maxElementArea > 0)
{ {
_edgeLength = 2*sqrt(_maxElementArea); // triangles : minorant _edgeLength = 2 * sqrt(_maxElementArea); // triangles : minorant
isOk = true; isOk = true;
} }
else isOk = (_hypLengthFromEdges != NULL); // **** check mode else
isOk = (_hypLengthFromEdges != NULL); // **** check mode
} }
//SCRUTE(_edgeLength); //SCRUTE(_edgeLength);
@ -162,15 +159,13 @@ bool SMESH_MEFISTO_2D::CheckHypothesis(SMESH_Mesh& aMesh,
return isOk; return isOk;
} }
//============================================================================= //=============================================================================
/*! /*!
* *
*/ */
//============================================================================= //=============================================================================
bool SMESH_MEFISTO_2D::Compute(SMESH_Mesh& aMesh, bool SMESH_MEFISTO_2D::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape)
const TopoDS_Shape& aShape)
{ {
MESSAGE("SMESH_MEFISTO_2D::Compute"); MESSAGE("SMESH_MEFISTO_2D::Compute");
@ -178,50 +173,50 @@ bool SMESH_MEFISTO_2D::Compute(SMESH_Mesh& aMesh,
_edgeLength = ComputeEdgeElementLength(aMesh, aShape); _edgeLength = ComputeEdgeElementLength(aMesh, aShape);
bool isOk = false; bool isOk = false;
const Handle(SMESHDS_Mesh)& meshDS = aMesh.GetMeshDS(); const SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
SMESH_subMesh* theSubMesh = aMesh.GetSubMesh(aShape); SMESH_subMesh *theSubMesh = aMesh.GetSubMesh(aShape);
const TopoDS_Face& FF = TopoDS::Face(aShape); const TopoDS_Face & FF = TopoDS::Face(aShape);
bool faceIsForward = (FF.Orientation() == TopAbs_FORWARD); bool faceIsForward = (FF.Orientation() == TopAbs_FORWARD);
TopoDS_Face F = TopoDS::Face(FF.Oriented(TopAbs_FORWARD)); TopoDS_Face F = TopoDS::Face(FF.Oriented(TopAbs_FORWARD));
Z nblf; //nombre de lignes fermees (enveloppe en tete) Z nblf; //nombre de lignes fermees (enveloppe en tete)
Z *nudslf=NULL; //numero du dernier sommet de chaque ligne fermee Z *nudslf = NULL; //numero du dernier sommet de chaque ligne fermee
R2 *uvslf=NULL; R2 *uvslf = NULL;
Z nbpti=0; //nombre points internes futurs sommets de la triangulation Z nbpti = 0; //nombre points internes futurs sommets de la triangulation
R2 *uvpti=NULL; R2 *uvpti = NULL;
Z nbst; Z nbst;
R2 *uvst=NULL; R2 *uvst = NULL;
Z nbt; Z nbt;
Z *nust=NULL; Z *nust = NULL;
Z ierr=0; Z ierr = 0;
Z nutysu=1; // 1: il existe un fonction areteideale_() Z nutysu = 1; // 1: il existe un fonction areteideale_()
// Z nutysu=0; // 0: on utilise aretmx // Z nutysu=0; // 0: on utilise aretmx
R aretmx=_edgeLength; // longueur max aretes future triangulation R aretmx = _edgeLength; // longueur max aretes future triangulation
//SCRUTE(aretmx); //SCRUTE(aretmx);
nblf = NumberOfWires(F); nblf = NumberOfWires(F);
//SCRUTE(nblf); //SCRUTE(nblf);
nudslf = new Z[1+nblf]; nudslf = new Z[1 + nblf];
nudslf[0] = 0; nudslf[0] = 0;
int iw = 1; int iw = 1;
int nbpnt = 0; int nbpnt = 0;
const TopoDS_Wire OW1 = BRepTools::OuterWire(F); const TopoDS_Wire OW1 = BRepTools::OuterWire(F);
nbpnt += NumberOfPoints (aMesh, OW1); nbpnt += NumberOfPoints(aMesh, OW1);
nudslf [iw++] = nbpnt; nudslf[iw++] = nbpnt;
//SCRUTE(nbpnt); //SCRUTE(nbpnt);
for (TopExp_Explorer exp (F, TopAbs_WIRE); exp.More(); exp.Next()) for (TopExp_Explorer exp(F, TopAbs_WIRE); exp.More(); exp.Next())
{ {
const TopoDS_Wire& W = TopoDS::Wire(exp.Current()); const TopoDS_Wire & W = TopoDS::Wire(exp.Current());
if (!OW1.IsSame(W)) if (!OW1.IsSame(W))
{ {
nbpnt += NumberOfPoints (aMesh, W); nbpnt += NumberOfPoints(aMesh, W);
nudslf [iw++] = nbpnt; nudslf[iw++] = nbpnt;
//SCRUTE(nbpnt); //SCRUTE(nbpnt);
} }
} }
@ -230,17 +225,17 @@ bool SMESH_MEFISTO_2D::Compute(SMESH_Mesh& aMesh,
//SCRUTE(nudslf[nblf]); //SCRUTE(nudslf[nblf]);
int m = 0; int m = 0;
map<int,int> mefistoToDS; // correspondence mefisto index--> points IDNodes map < int, int >mefistoToDS; // correspondence mefisto index--> points IDNodes
TopoDS_Wire OW = BRepTools::OuterWire(F); TopoDS_Wire OW = BRepTools::OuterWire(F);
LoadPoints (aMesh, F, OW, uvslf, m, mefistoToDS); LoadPoints(aMesh, F, OW, uvslf, m, mefistoToDS);
//SCRUTE(m); //SCRUTE(m);
for (TopExp_Explorer exp (F, TopAbs_WIRE); exp.More(); exp.Next()) for (TopExp_Explorer exp(F, TopAbs_WIRE); exp.More(); exp.Next())
{ {
const TopoDS_Wire& W = TopoDS::Wire(exp.Current()); const TopoDS_Wire & W = TopoDS::Wire(exp.Current());
if (!OW.IsSame(W)) if (!OW.IsSame(W))
{ {
LoadPoints (aMesh, F, W, uvslf, m, mefistoToDS); LoadPoints(aMesh, F, W, uvslf, m, mefistoToDS);
//SCRUTE(m); //SCRUTE(m);
} }
} }
@ -260,18 +255,15 @@ bool SMESH_MEFISTO_2D::Compute(SMESH_Mesh& aMesh,
MESSAGE("MEFISTO triangulation ..."); MESSAGE("MEFISTO triangulation ...");
uvst = NULL; uvst = NULL;
nust = NULL; nust = NULL;
aptrte( nutysu, aretmx, aptrte(nutysu, aretmx,
nblf, nudslf, uvslf, nblf, nudslf, uvslf, nbpti, uvpti, nbst, uvst, nbt, nust, ierr);
nbpti, uvpti,
nbst, uvst, nbt, nust,
ierr );
if( ierr == 0 ) if (ierr == 0)
{ {
MESSAGE("... End Triangulation"); MESSAGE("... End Triangulation");
//SCRUTE(nbst); //SCRUTE(nbst);
//SCRUTE(nbt); //SCRUTE(nbt);
StoreResult (aMesh, nbst, uvst, nbt, nust, F, StoreResult(aMesh, nbst, uvst, nbt, nust, F,
faceIsForward, mefistoToDS); faceIsForward, mefistoToDS);
isOk = true; isOk = true;
} }
@ -280,10 +272,14 @@ bool SMESH_MEFISTO_2D::Compute(SMESH_Mesh& aMesh,
MESSAGE("Error in Triangulation"); MESSAGE("Error in Triangulation");
isOk = false; isOk = false;
} }
if (nudslf != NULL) delete [] nudslf; if (nudslf != NULL)
if (uvslf != NULL) delete [] uvslf; delete[]nudslf;
if (uvst != NULL) delete [] uvst; if (uvslf != NULL)
if (nust != NULL) delete [] nust; delete[]uvslf;
if (uvst != NULL)
delete[]uvst;
if (nust != NULL)
delete[]nust;
return isOk; return isOk;
} }
@ -293,16 +289,13 @@ bool SMESH_MEFISTO_2D::Compute(SMESH_Mesh& aMesh,
*/ */
//============================================================================= //=============================================================================
void SMESH_MEFISTO_2D::LoadPoints(SMESH_Mesh& aMesh, void SMESH_MEFISTO_2D::LoadPoints(SMESH_Mesh & aMesh,
const TopoDS_Face& FF, const TopoDS_Face & FF,
const TopoDS_Wire& WW, const TopoDS_Wire & WW, R2 * uvslf, int &m, map < int, int >&mefistoToDS)
R2* uvslf,
int& m,
map<int,int>& mefistoToDS)
{ {
MESSAGE("SMESH_MEFISTO_2D::LoadPoints"); MESSAGE("SMESH_MEFISTO_2D::LoadPoints");
Handle (SMDS_Mesh) meshDS = aMesh.GetMeshDS(); SMDS_Mesh * meshDS = aMesh.GetMeshDS();
double scalex; double scalex;
double scaley; double scaley;
@ -310,10 +303,10 @@ void SMESH_MEFISTO_2D::LoadPoints(SMESH_Mesh& aMesh,
ComputeScaleOnFace(aMesh, F, scalex, scaley); ComputeScaleOnFace(aMesh, F, scalex, scaley);
TopoDS_Wire W = TopoDS::Wire(WW.Oriented(TopAbs_FORWARD)); TopoDS_Wire W = TopoDS::Wire(WW.Oriented(TopAbs_FORWARD));
BRepTools_WireExplorer wexp(W,F); BRepTools_WireExplorer wexp(W, F);
for (wexp.Init(W,F);wexp.More(); wexp.Next()) for (wexp.Init(W, F); wexp.More(); wexp.Next())
{ {
const TopoDS_Edge& E = wexp.Current(); const TopoDS_Edge & E = wexp.Current();
// --- IDNodes of first and last Vertex // --- IDNodes of first and last Vertex
@ -321,17 +314,17 @@ void SMESH_MEFISTO_2D::LoadPoints(SMESH_Mesh& aMesh,
TopExp::Vertices(E, VFirst, VLast); // corresponds to f and l TopExp::Vertices(E, VFirst, VLast); // corresponds to f and l
ASSERT(!VFirst.IsNull()); ASSERT(!VFirst.IsNull());
SMESH_subMesh* firstSubMesh = aMesh.GetSubMesh(VFirst); SMESH_subMesh *firstSubMesh = aMesh.GetSubMesh(VFirst);
const TColStd_ListOfInteger& lidf const vector<int> & lidf
= firstSubMesh->GetSubMeshDS()->GetIDNodes(); = firstSubMesh->GetSubMeshDS()->GetIDNodes();
int idFirst= lidf.First(); int idFirst = lidf[0];
// SCRUTE(idFirst); // SCRUTE(idFirst);
ASSERT(!VLast.IsNull()); ASSERT(!VLast.IsNull());
SMESH_subMesh* lastSubMesh = aMesh.GetSubMesh(VLast); SMESH_subMesh *lastSubMesh = aMesh.GetSubMesh(VLast);
const TColStd_ListOfInteger& lidl const vector<int> & lidl
= lastSubMesh->GetSubMeshDS()->GetIDNodes(); = lastSubMesh->GetSubMeshDS()->GetIDNodes();
int idLast= lidl.First(); int idLast = lidl[0];
// SCRUTE(idLast); // SCRUTE(idLast);
// --- edge internal IDNodes (relies on good order storage, not checked) // --- edge internal IDNodes (relies on good order storage, not checked)
@ -339,27 +332,23 @@ void SMESH_MEFISTO_2D::LoadPoints(SMESH_Mesh& aMesh,
int nbPoints = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes(); int nbPoints = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes();
//SCRUTE(nbPoints); //SCRUTE(nbPoints);
Standard_Real f,l; double f, l;
Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E,F,f,l); Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E, F, f, l);
const TColStd_ListOfInteger& indElt const vector<int> & indElt
= aMesh.GetSubMesh(E)->GetSubMeshDS()->GetIDNodes(); = aMesh.GetSubMesh(E)->GetSubMeshDS()->GetIDNodes();
TColStd_ListIteratorOfListOfInteger ite(indElt);
//SCRUTE(nbPoints); ASSERT(nbPoints == indElt.size());
//SCRUTE(indElt.Extent());
ASSERT(nbPoints == indElt.Extent());
bool isForward = (E.Orientation() == TopAbs_FORWARD); bool isForward = (E.Orientation() == TopAbs_FORWARD);
map<double,int> params; map < double, int >params;
for (; ite.More(); ite.Next()) for (int ite=0; ite<indElt.size(); ite++)
{ {
int nodeId = ite.Value(); int nodeId = indElt[ite];
Handle (SMDS_MeshElement) elt = meshDS->FindNode(nodeId); const SMDS_MeshNode * node = meshDS->FindNode(nodeId);
Handle (SMDS_MeshNode) node = meshDS->GetNode(1, elt); const SMDS_EdgePosition* epos
Handle (SMDS_EdgePosition) epos = static_cast<const SMDS_EdgePosition*>(node->GetPosition());
= Handle (SMDS_EdgePosition)::DownCast(node->GetPosition());
double param = epos->GetUParameter(); double param = epos->GetUParameter();
params[param] = nodeId; params[param] = nodeId;
// MESSAGE(" " << param << " " << params[param]);
} }
// --- load 2D values into MEFISTO structure, // --- load 2D values into MEFISTO structure,
@ -368,20 +357,20 @@ void SMESH_MEFISTO_2D::LoadPoints(SMESH_Mesh& aMesh,
if (E.Orientation() == TopAbs_FORWARD) if (E.Orientation() == TopAbs_FORWARD)
{ {
gp_Pnt2d p = C2d->Value(f); // first point = Vertex Forward gp_Pnt2d p = C2d->Value(f); // first point = Vertex Forward
uvslf [m].x = scalex * p.X(); uvslf[m].x = scalex * p.X();
uvslf [m].y = scaley * p.Y(); uvslf[m].y = scaley * p.Y();
mefistoToDS[m+1] = idFirst; mefistoToDS[m + 1] = idFirst;
//MESSAGE(" "<<m<<" "<<mefistoToDS[m+1]); //MESSAGE(" "<<m<<" "<<mefistoToDS[m+1]);
//MESSAGE("__ f "<<f<<" "<<uvslf[m].x <<" "<<uvslf[m].y); //MESSAGE("__ f "<<f<<" "<<uvslf[m].x <<" "<<uvslf[m].y);
m++; m++;
map<double,int>::iterator itp = params.begin(); map < double, int >::iterator itp = params.begin();
for (Standard_Integer i = 1; i<=nbPoints; i++) // nbPoints internal for (int i = 1; i <= nbPoints; i++) // nbPoints internal
{ {
double param = (*itp).first; double param = (*itp).first;
gp_Pnt2d p = C2d->Value(param); gp_Pnt2d p = C2d->Value(param);
uvslf [m].x = scalex * p.X(); uvslf[m].x = scalex * p.X();
uvslf [m].y = scaley * p.Y(); uvslf[m].y = scaley * p.Y();
mefistoToDS[m+1] = (*itp).second; mefistoToDS[m + 1] = (*itp).second;
// MESSAGE(" "<<m<<" "<<mefistoToDS[m+1]); // MESSAGE(" "<<m<<" "<<mefistoToDS[m+1]);
// MESSAGE("__ "<<i<<" "<<param<<" "<<uvslf[m].x <<" "<<uvslf[m].y); // MESSAGE("__ "<<i<<" "<<param<<" "<<uvslf[m].x <<" "<<uvslf[m].y);
m++; m++;
@ -391,20 +380,20 @@ void SMESH_MEFISTO_2D::LoadPoints(SMESH_Mesh& aMesh,
else else
{ {
gp_Pnt2d p = C2d->Value(l); // last point = Vertex Reversed gp_Pnt2d p = C2d->Value(l); // last point = Vertex Reversed
uvslf [m].x = scalex * p.X(); uvslf[m].x = scalex * p.X();
uvslf [m].y = scaley * p.Y(); uvslf[m].y = scaley * p.Y();
mefistoToDS[m+1] = idLast; mefistoToDS[m + 1] = idLast;
// MESSAGE(" "<<m<<" "<<mefistoToDS[m+1]); // MESSAGE(" "<<m<<" "<<mefistoToDS[m+1]);
// MESSAGE("__ l "<<l<<" "<<uvslf[m].x <<" "<<uvslf[m].y); // MESSAGE("__ l "<<l<<" "<<uvslf[m].x <<" "<<uvslf[m].y);
m++; m++;
map<double,int>::reverse_iterator itp = params.rbegin(); map < double, int >::reverse_iterator itp = params.rbegin();
for (Standard_Integer i = nbPoints ; i >= 1; i--) for (int i = nbPoints; i >= 1; i--)
{ {
double param = (*itp).first; double param = (*itp).first;
gp_Pnt2d p = C2d->Value(param); gp_Pnt2d p = C2d->Value(param);
uvslf [m].x = scalex * p.X(); uvslf[m].x = scalex * p.X();
uvslf [m].y = scaley * p.Y(); uvslf[m].y = scaley * p.Y();
mefistoToDS[m+1] = (*itp).second; mefistoToDS[m + 1] = (*itp).second;
// MESSAGE(" "<<m<<" "<<mefistoToDS[m+1]); // MESSAGE(" "<<m<<" "<<mefistoToDS[m+1]);
// MESSAGE("__ "<<i<<" "<<param<<" "<<uvslf[m].x <<" "<<uvslf[m].y); // MESSAGE("__ "<<i<<" "<<param<<" "<<uvslf[m].x <<" "<<uvslf[m].y);
m++; m++;
@ -422,16 +411,14 @@ void SMESH_MEFISTO_2D::LoadPoints(SMESH_Mesh& aMesh,
// **** a mettre dans SMESH_Algo ou SMESH_2D_Algo // **** a mettre dans SMESH_Algo ou SMESH_2D_Algo
void SMESH_MEFISTO_2D::ComputeScaleOnFace(SMESH_Mesh& aMesh, void SMESH_MEFISTO_2D::ComputeScaleOnFace(SMESH_Mesh & aMesh,
const TopoDS_Face& aFace, const TopoDS_Face & aFace, double &scalex, double &scaley)
double& scalex,
double& scaley)
{ {
//MESSAGE("SMESH_MEFISTO_2D::ComputeScaleOnFace"); //MESSAGE("SMESH_MEFISTO_2D::ComputeScaleOnFace");
TopoDS_Face F = TopoDS::Face(aFace.Oriented(TopAbs_FORWARD)); TopoDS_Face F = TopoDS::Face(aFace.Oriented(TopAbs_FORWARD));
TopoDS_Wire W = BRepTools::OuterWire(F); TopoDS_Wire W = BRepTools::OuterWire(F);
BRepTools_WireExplorer wexp(W,F); BRepTools_WireExplorer wexp(W, F);
double xmin = 1.e300; // min & max of face 2D parametric coord. double xmin = 1.e300; // min & max of face 2D parametric coord.
double xmax = -1.e300; double xmax = -1.e300;
@ -440,19 +427,23 @@ void SMESH_MEFISTO_2D::ComputeScaleOnFace(SMESH_Mesh& aMesh,
int nbp = 50; int nbp = 50;
scalex = 1; scalex = 1;
scaley = 1; scaley = 1;
for (wexp.Init(W,F);wexp.More(); wexp.Next()) for (wexp.Init(W, F); wexp.More(); wexp.Next())
{ {
const TopoDS_Edge& E = wexp.Current(); const TopoDS_Edge & E = wexp.Current();
double f,l; double f, l;
Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E,F,f,l); Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E, F, f, l);
for (int i = 0; i<= nbp; i++) for (int i = 0; i <= nbp; i++)
{ {
double param = f + (double(i)/double(nbp))*(l-f); double param = f + (double (i) / double (nbp))*(l - f);
gp_Pnt2d p = C2d->Value(param); gp_Pnt2d p = C2d->Value(param);
if (p.X() < xmin) xmin = p.X(); if (p.X() < xmin)
if (p.X() > xmax) xmax = p.X(); xmin = p.X();
if (p.Y() < ymin) ymin = p.Y(); if (p.X() > xmax)
if (p.Y() > ymax) ymax = p.Y(); xmax = p.X();
if (p.Y() < ymin)
ymin = p.Y();
if (p.Y() > ymax)
ymax = p.Y();
// MESSAGE(" "<< f<<" "<<l<<" "<<param<<" "<<xmin<<" "<<xmax<<" "<<ymin<<" "<<ymax); // MESSAGE(" "<< f<<" "<<l<<" "<<param<<" "<<xmin<<" "<<xmax<<" "<<ymin<<" "<<ymax);
} }
} }
@ -460,8 +451,8 @@ void SMESH_MEFISTO_2D::ComputeScaleOnFace(SMESH_Mesh& aMesh,
// SCRUTE(xmax); // SCRUTE(xmax);
// SCRUTE(ymin); // SCRUTE(ymin);
// SCRUTE(ymax); // SCRUTE(ymax);
double xmoy = (xmax + xmin)/2.; double xmoy = (xmax + xmin) / 2.;
double ymoy = (ymax + ymin)/2.; double ymoy = (ymax + ymin) / 2.;
Handle(Geom_Surface) S = BRep_Tool::Surface(F); // 3D surface Handle(Geom_Surface) S = BRep_Tool::Surface(F); // 3D surface
@ -469,21 +460,21 @@ void SMESH_MEFISTO_2D::ComputeScaleOnFace(SMESH_Mesh& aMesh,
double length_y = 0; double length_y = 0;
gp_Pnt PX0 = S->Value(xmin, ymoy); gp_Pnt PX0 = S->Value(xmin, ymoy);
gp_Pnt PY0 = S->Value(xmoy, ymin); gp_Pnt PY0 = S->Value(xmoy, ymin);
for (Standard_Integer i = 1; i<= nbp; i++) for (int i = 1; i <= nbp; i++)
{ {
double x = xmin + (double(i)/double(nbp))*(xmax-xmin); double x = xmin + (double (i) / double (nbp))*(xmax - xmin);
gp_Pnt PX = S->Value(x,ymoy); gp_Pnt PX = S->Value(x, ymoy);
double y = ymin + (double(i)/double(nbp))*(ymax-ymin); double y = ymin + (double (i) / double (nbp))*(ymax - ymin);
gp_Pnt PY = S->Value(xmoy,y); gp_Pnt PY = S->Value(xmoy, y);
length_x += PX.Distance(PX0); length_x += PX.Distance(PX0);
length_y += PY.Distance(PY0); length_y += PY.Distance(PY0);
PX0.SetCoord(PX.X(),PX.Y(),PX.Z()); PX0.SetCoord(PX.X(), PX.Y(), PX.Z());
PY0.SetCoord(PY.X(),PY.Y(),PY.Z()); PY0.SetCoord(PY.X(), PY.Y(), PY.Z());
} }
// SCRUTE(length_x); // SCRUTE(length_x);
// SCRUTE(length_y); // SCRUTE(length_y);
scalex = length_x/(xmax - xmin); scalex = length_x / (xmax - xmin);
scaley = length_y/(ymax - ymin); scaley = length_y / (ymax - ymin);
// SCRUTE(scalex); // SCRUTE(scalex);
// SCRUTE(scaley); // SCRUTE(scaley);
ASSERT(scalex); ASSERT(scalex);
@ -496,48 +487,45 @@ void SMESH_MEFISTO_2D::ComputeScaleOnFace(SMESH_Mesh& aMesh,
*/ */
//============================================================================= //=============================================================================
void SMESH_MEFISTO_2D::StoreResult (SMESH_Mesh& aMesh, void SMESH_MEFISTO_2D::StoreResult(SMESH_Mesh & aMesh,
Z nbst, R2* uvst, Z nbt, Z* nust, Z nbst, R2 * uvst, Z nbt, Z * nust,
const TopoDS_Face& F, bool faceIsForward, const TopoDS_Face & F, bool faceIsForward, map < int, int >&mefistoToDS)
map<int,int>& mefistoToDS)
{ {
double scalex; double scalex;
double scaley; double scaley;
ComputeScaleOnFace(aMesh, F, scalex, scaley); ComputeScaleOnFace(aMesh, F, scalex, scaley);
Handle (SMESHDS_Mesh) meshDS = aMesh.GetMeshDS(); SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
Z n,m; Z n, m;
Handle(Geom_Surface) S = BRep_Tool::Surface(F); Handle(Geom_Surface) S = BRep_Tool::Surface(F);
for ( n=0; n<nbst; n++ ) for (n = 0; n < nbst; n++)
{ {
double u = uvst[n][0]/scalex; double u = uvst[n][0] / scalex;
double v = uvst[n][1]/scaley; double v = uvst[n][1] / scaley;
gp_Pnt P = S->Value(u,v); gp_Pnt P = S->Value(u, v);
if (mefistoToDS.find(n+1) == mefistoToDS.end()) if (mefistoToDS.find(n + 1) == mefistoToDS.end())
{ {
int nodeId = meshDS->AddNode(P.X(), P.Y(), P.Z()); SMDS_MeshNode * node = meshDS->AddNode(P.X(), P.Y(), P.Z());
Handle (SMDS_MeshElement) elt = meshDS->FindNode(nodeId);
Handle (SMDS_MeshNode) node = meshDS->GetNode(1, elt);
meshDS->SetNodeOnFace(node, F); meshDS->SetNodeOnFace(node, F);
//MESSAGE(nodeId<<" "<<P.X()<<" "<<P.Y()<<" "<<P.Z()); //MESSAGE(nodeId<<" "<<P.X()<<" "<<P.Y()<<" "<<P.Z());
mefistoToDS[n+1] = nodeId; mefistoToDS[n + 1] = node->GetID();
//MESSAGE(" "<<n<<" "<<mefistoToDS[n+1]); //MESSAGE(" "<<n<<" "<<mefistoToDS[n+1]);
Handle (SMDS_FacePosition) fpos SMDS_FacePosition* fpos
= Handle (SMDS_FacePosition)::DownCast(node->GetPosition()); = static_cast<SMDS_FacePosition*>(node->GetPosition());
fpos->SetUParameter(u); fpos->SetUParameter(u);
fpos->SetVParameter(v); fpos->SetVParameter(v);
} }
} }
m=0; m = 0;
int mt=0; int mt = 0;
//SCRUTE(faceIsForward); //SCRUTE(faceIsForward);
for ( n=1; n<=nbt; n++ ) for (n = 1; n <= nbt; n++)
{ {
int inode1 = nust[m++]; int inode1 = nust[m++];
int inode2 = nust[m++]; int inode2 = nust[m++];
@ -552,16 +540,13 @@ void SMESH_MEFISTO_2D::StoreResult (SMESH_Mesh& aMesh,
// else they must be put clockwise // else they must be put clockwise
bool triangleIsWellOriented = faceIsForward; bool triangleIsWellOriented = faceIsForward;
int faceId;
SMDS_MeshElement * elt;
if (triangleIsWellOriented) if (triangleIsWellOriented)
{ elt = meshDS->AddFace(nodeId1, nodeId2, nodeId3);
faceId = meshDS->AddFace(nodeId1, nodeId2, nodeId3);
}
else else
{ elt = meshDS->AddFace(nodeId1, nodeId3, nodeId2);
faceId = meshDS->AddFace(nodeId1, nodeId3, nodeId2);
}
Handle (SMDS_MeshElement) elt = meshDS->FindElement(faceId);
meshDS->SetMeshElementOnShape(elt, F); meshDS->SetMeshElementOnShape(elt, F);
m++; m++;
} }
@ -573,25 +558,25 @@ void SMESH_MEFISTO_2D::StoreResult (SMESH_Mesh& aMesh,
*/ */
//============================================================================= //=============================================================================
double SMESH_MEFISTO_2D::ComputeEdgeElementLength(SMESH_Mesh& aMesh, double SMESH_MEFISTO_2D::ComputeEdgeElementLength(SMESH_Mesh & aMesh,
const TopoDS_Shape& aShape) const TopoDS_Shape & aShape)
{ {
MESSAGE("SMESH_MEFISTO_2D::ComputeEdgeElementLength"); MESSAGE("SMESH_MEFISTO_2D::ComputeEdgeElementLength");
// **** a mettre dans SMESH_2D_Algo ? // **** a mettre dans SMESH_2D_Algo ?
const TopoDS_Face& FF = TopoDS::Face(aShape); const TopoDS_Face & FF = TopoDS::Face(aShape);
bool faceIsForward = (FF.Orientation() == TopAbs_FORWARD); bool faceIsForward = (FF.Orientation() == TopAbs_FORWARD);
TopoDS_Face F = TopoDS::Face(FF.Oriented(TopAbs_FORWARD)); TopoDS_Face F = TopoDS::Face(FF.Oriented(TopAbs_FORWARD));
double meanElementLength = 100; double meanElementLength = 100;
double wireLength =0; double wireLength = 0;
int wireElementsNumber =0; int wireElementsNumber = 0;
for (TopExp_Explorer exp (F, TopAbs_WIRE); exp.More(); exp.Next()) for (TopExp_Explorer exp(F, TopAbs_WIRE); exp.More(); exp.Next())
{ {
const TopoDS_Wire& W = TopoDS::Wire(exp.Current()); const TopoDS_Wire & W = TopoDS::Wire(exp.Current());
for (TopExp_Explorer expe(W,TopAbs_EDGE); expe.More(); expe.Next()) for (TopExp_Explorer expe(W, TopAbs_EDGE); expe.More(); expe.Next())
{ {
const TopoDS_Edge& E = TopoDS::Edge(expe.Current()); const TopoDS_Edge & E = TopoDS::Edge(expe.Current());
int nb = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes(); int nb = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes();
double length = EdgeLength(E); double length = EdgeLength(E);
wireLength += length; wireLength += length;
@ -599,7 +584,7 @@ double SMESH_MEFISTO_2D::ComputeEdgeElementLength(SMESH_Mesh& aMesh,
} }
} }
if (wireElementsNumber) if (wireElementsNumber)
meanElementLength = wireLength/wireElementsNumber; meanElementLength = wireLength / wireElementsNumber;
//SCRUTE(meanElementLength); //SCRUTE(meanElementLength);
return meanElementLength; return meanElementLength;
} }
@ -632,7 +617,7 @@ istream & SMESH_MEFISTO_2D::LoadFrom(istream & load)
*/ */
//============================================================================= //=============================================================================
ostream & operator << (ostream & save, SMESH_MEFISTO_2D & hyp) ostream & operator <<(ostream & save, SMESH_MEFISTO_2D & hyp)
{ {
return save; return save;
} }
@ -643,8 +628,7 @@ ostream & operator << (ostream & save, SMESH_MEFISTO_2D & hyp)
*/ */
//============================================================================= //=============================================================================
istream & operator >> (istream & load, SMESH_MEFISTO_2D & hyp) istream & operator >>(istream & load, SMESH_MEFISTO_2D & hyp)
{ {
return load; return load;
} }

View File

@ -32,24 +32,22 @@
#include "SMESH_Hypothesis.hxx" #include "SMESH_Hypothesis.hxx"
#include "Utils_SALOME_Exception.hxx" #include "Utils_SALOME_Exception.hxx"
class SMESH_MaxElementArea: class SMESH_MaxElementArea:public SMESH_Hypothesis
public SMESH_Hypothesis
{ {
public: public:
SMESH_MaxElementArea(int hypId, int studyId, SMESH_Gen* gen); SMESH_MaxElementArea(int hypId, int studyId, SMESH_Gen * gen);
virtual ~SMESH_MaxElementArea(); virtual ~ SMESH_MaxElementArea();
void SetMaxArea(double maxArea) void SetMaxArea(double maxArea) throw(SALOME_Exception);
throw (SALOME_Exception);
double GetMaxArea(); double GetMaxArea() const;
virtual ostream & SaveTo(ostream & save); virtual ostream & SaveTo(ostream & save);
virtual istream & LoadFrom(istream & load); virtual istream & LoadFrom(istream & load);
friend ostream & operator << (ostream & save, SMESH_MaxElementArea & hyp); friend ostream & operator <<(ostream & save, SMESH_MaxElementArea & hyp);
friend istream & operator >> (istream & load, SMESH_MaxElementArea & hyp); friend istream & operator >>(istream & load, SMESH_MaxElementArea & hyp);
protected: protected:
double _maxArea; double _maxArea;
}; };

View File

@ -26,21 +26,12 @@
// Module : SMESH // Module : SMESH
// $Header$ // $Header$
using namespace std;
using namespace std;
#include "SMESH_Mesh.hxx" #include "SMESH_Mesh.hxx"
#include "SMESH_subMesh.hxx" #include "SMESH_subMesh.hxx"
#include "SMESH_Gen.hxx" #include "SMESH_Gen.hxx"
#include "SMESH_Hypothesis.hxx" #include "SMESH_Hypothesis.hxx"
#include "SMESHDS_Script.hxx" #include "SMESHDS_Script.hxx"
//#include "SMESHDS_ListOfAsciiString.hxx" #include "SMDS_MeshVolume.hxx"
//#include "SMESHDS_ListIteratorOfListOfAsciiString.hxx"
#include "SMESHDS_ListOfPtrHypothesis.hxx"
#include "SMESHDS_ListIteratorOfListOfPtrHypothesis.hxx"
#include "SMDS_MeshElement.hxx"
#include "SMDS_MeshFacesIterator.hxx"
#include "SMDS_MeshVolumesIterator.hxx"
#include "TCollection_AsciiString.hxx"
#include "utilities.h" #include "utilities.h"
@ -49,6 +40,8 @@ using namespace std;
#include "DriverDAT_W_SMESHDS_Mesh.h" #include "DriverDAT_W_SMESHDS_Mesh.h"
#include "DriverUNV_W_SMESHDS_Mesh.h" #include "DriverUNV_W_SMESHDS_Mesh.h"
#include <TCollection_AsciiString.hxx>
//============================================================================= //=============================================================================
/*! /*!
* *
@ -69,9 +62,7 @@ SMESH_Mesh::SMESH_Mesh()
//============================================================================= //=============================================================================
SMESH_Mesh::SMESH_Mesh(int localId, SMESH_Mesh::SMESH_Mesh(int localId,
int studyId, int studyId, SMESH_Gen * gen, SMESHDS_Document * myDocument)
SMESH_Gen* gen,
const Handle(SMESHDS_Document)& myDocument)
{ {
MESSAGE("SMESH_Mesh::SMESH_Mesh(int localId)"); MESSAGE("SMESH_Mesh::SMESH_Mesh(int localId)");
_id = localId; _id = localId;
@ -100,17 +91,19 @@ SMESH_Mesh::~SMESH_Mesh()
*/ */
//============================================================================= //=============================================================================
void SMESH_Mesh::ShapeToMesh(const TopoDS_Shape& aShape) void SMESH_Mesh::ShapeToMesh(const TopoDS_Shape & aShape)
throw (SALOME_Exception) throw(SALOME_Exception)
{ {
MESSAGE("SMESH_Mesh::ShapeToMesh"); MESSAGE("SMESH_Mesh::ShapeToMesh");
if (_isShapeToMesh) if (_isShapeToMesh)
throw SALOME_Exception(LOCALIZED("a shape to mesh as already been defined")); throw
SALOME_Exception(LOCALIZED
("a shape to mesh as already been defined"));
_isShapeToMesh = true; _isShapeToMesh = true;
_myMeshDS->ShapeToMesh(aShape); _myMeshDS->ShapeToMesh(aShape);
// NRI : 24/02/03 // NRI : 24/02/03
TopExp::MapShapes(aShape,_subShapes); TopExp::MapShapes(aShape, _subShapes);
} }
//============================================================================= //=============================================================================
@ -119,13 +112,12 @@ void SMESH_Mesh::ShapeToMesh(const TopoDS_Shape& aShape)
*/ */
//============================================================================= //=============================================================================
bool SMESH_Mesh::AddHypothesis(const TopoDS_Shape& aSubShape, bool SMESH_Mesh::AddHypothesis(const TopoDS_Shape & aSubShape,
int anHypId) int anHypId) throw(SALOME_Exception)
throw (SALOME_Exception)
{ {
MESSAGE("SMESH_Mesh::AddHypothesis"); MESSAGE("SMESH_Mesh::AddHypothesis");
StudyContextStruct* sc = _gen->GetStudyContext(_studyId); StudyContextStruct *sc = _gen->GetStudyContext(_studyId);
if (sc->mapHypothesis.find(anHypId) == sc->mapHypothesis.end()) if (sc->mapHypothesis.find(anHypId) == sc->mapHypothesis.end())
{ {
MESSAGE("Hypothesis ID does not give an hypothesis"); MESSAGE("Hypothesis ID does not give an hypothesis");
@ -134,8 +126,8 @@ bool SMESH_Mesh::AddHypothesis(const TopoDS_Shape& aSubShape,
throw SALOME_Exception(LOCALIZED("hypothesis does not exist")); throw SALOME_Exception(LOCALIZED("hypothesis does not exist"));
} }
SMESH_subMesh* subMesh = GetSubMesh(aSubShape); SMESH_subMesh *subMesh = GetSubMesh(aSubShape);
SMESH_Hypothesis* anHyp = sc->mapHypothesis[anHypId]; SMESH_Hypothesis *anHyp = sc->mapHypothesis[anHypId];
int event; int event;
// shape // shape
@ -168,18 +160,17 @@ bool SMESH_Mesh::AddHypothesis(const TopoDS_Shape& aSubShape,
*/ */
//============================================================================= //=============================================================================
bool SMESH_Mesh::RemoveHypothesis(const TopoDS_Shape& aSubShape, bool SMESH_Mesh::RemoveHypothesis(const TopoDS_Shape & aSubShape,
int anHypId) int anHypId)throw(SALOME_Exception)
throw (SALOME_Exception)
{ {
MESSAGE("SMESH_Mesh::RemoveHypothesis"); MESSAGE("SMESH_Mesh::RemoveHypothesis");
StudyContextStruct* sc = _gen->GetStudyContext(_studyId); StudyContextStruct *sc = _gen->GetStudyContext(_studyId);
if (sc->mapHypothesis.find(anHypId) == sc->mapHypothesis.end()) if (sc->mapHypothesis.find(anHypId) == sc->mapHypothesis.end())
throw SALOME_Exception(LOCALIZED("hypothesis does not exist")); throw SALOME_Exception(LOCALIZED("hypothesis does not exist"));
SMESH_subMesh* subMesh = GetSubMesh(aSubShape); SMESH_subMesh *subMesh = GetSubMesh(aSubShape);
SMESH_Hypothesis* anHyp = sc->mapHypothesis[anHypId]; SMESH_Hypothesis *anHyp = sc->mapHypothesis[anHypId];
int hypType = anHyp->GetType(); int hypType = anHyp->GetType();
SCRUTE(hypType); SCRUTE(hypType);
int event; int event;
@ -215,32 +206,32 @@ bool SMESH_Mesh::RemoveHypothesis(const TopoDS_Shape& aSubShape,
*/ */
//============================================================================= //=============================================================================
const Handle(SMESHDS_Mesh)& SMESH_Mesh::GetMeshDS() SMESHDS_Mesh * SMESH_Mesh::GetMeshDS()
{ {
return _myMeshDS; return _myMeshDS;
} }
//============================================================================= //=============================================================================
/*! /*!
* *
*/ */
//============================================================================= //=============================================================================
const list<SMESHDS_Hypothesis*>& const list<const SMESHDS_Hypothesis*>&
SMESH_Mesh::GetHypothesisList(const TopoDS_Shape& aSubShape) SMESH_Mesh::GetHypothesisList(const TopoDS_Shape & aSubShape)
throw (SALOME_Exception) throw(SALOME_Exception)
{ {
MESSAGE("SMESH_Mesh::GetHypothesisList"); MESSAGE("SMESH_Mesh::GetHypothesisList");
_subShapeHypothesisList.clear(); _subShapeHypothesisList.clear();
const SMESHDS_ListOfPtrHypothesis& listHyp const list<const SMESHDS_Hypothesis*>& listHyp =
= _myMeshDS->GetHypothesis(aSubShape); _myMeshDS->GetHypothesis(aSubShape);
SMESHDS_ListIteratorOfListOfPtrHypothesis it(listHyp);
while (it.More()) list<const SMESHDS_Hypothesis*>::const_iterator it=listHyp.begin();
while (it!=listHyp.end())
{ {
SMESHDS_Hypothesis* anHyp = it.Value(); const SMESHDS_Hypothesis *anHyp = *it;
_subShapeHypothesisList.push_back(anHyp); _subShapeHypothesisList.push_back(anHyp);
it.Next(); it++;
} }
return _subShapeHypothesisList; return _subShapeHypothesisList;
} }
@ -251,20 +242,10 @@ SMESH_Mesh::GetHypothesisList(const TopoDS_Shape& aSubShape)
*/ */
//============================================================================= //=============================================================================
const SMESHDS_ListOfCommand& SMESH_Mesh::GetLog() const list<SMESHDS_Command*> & SMESH_Mesh::GetLog() throw(SALOME_Exception)
throw (SALOME_Exception)
{ {
MESSAGE("SMESH_Mesh::GetLog"); MESSAGE("SMESH_Mesh::GetLog");
Handle (SMESHDS_Script) scriptDS = _myMeshDS->GetScript(); return _myMeshDS->GetScript()->GetCommands();
const SMESHDS_ListOfCommand& logDS = scriptDS->GetCommands();
// SMESHDS_ListIteratorOfListOfCommand its;
// const SMESHDS_ListOfAsciiString& logDS = scriptDS->GetCommands();
// SMESHDS_ListIteratorOfListOfAsciiString its;
// for (its.Initialize(logDS); its.More(); its.Next())
// {
// SCRUTE(its.Value().ToCString());
// }
return logDS;
} }
//============================================================================= //=============================================================================
@ -272,12 +253,10 @@ const SMESHDS_ListOfCommand& SMESH_Mesh::GetLog()
* *
*/ */
//============================================================================= //=============================================================================
void SMESH_Mesh::ClearLog() void SMESH_Mesh::ClearLog() throw(SALOME_Exception)
throw (SALOME_Exception)
{ {
MESSAGE("SMESH_Mesh::ClearLog"); MESSAGE("SMESH_Mesh::ClearLog");
Handle (SMESHDS_Script) scriptDS = _myMeshDS->GetScript(); _myMeshDS->GetScript()->Clear();
scriptDS->Clear();
} }
//============================================================================= //=============================================================================
@ -298,7 +277,7 @@ int SMESH_Mesh::GetId()
*/ */
//============================================================================= //=============================================================================
SMESH_Gen* SMESH_Mesh::GetGen() SMESH_Gen *SMESH_Mesh::GetGen()
{ {
return _gen; return _gen;
} }
@ -309,35 +288,38 @@ SMESH_Gen* SMESH_Mesh::GetGen()
*/ */
//============================================================================= //=============================================================================
SMESH_subMesh* SMESH_Mesh::GetSubMesh(const TopoDS_Shape & aSubShape) SMESH_subMesh *SMESH_Mesh::GetSubMesh(const TopoDS_Shape & aSubShape)
throw (SALOME_Exception) throw(SALOME_Exception)
{ {
//MESSAGE("SMESH_Mesh::GetSubMesh"); //MESSAGE("SMESH_Mesh::GetSubMesh");
SMESH_subMesh* aSubMesh; SMESH_subMesh *aSubMesh;
int index = _subShapes.FindIndex(aSubShape); int index = _subShapes.FindIndex(aSubShape);
if ( _mapSubMesh.find(index) != _mapSubMesh.end() ) { if (_mapSubMesh.find(index) != _mapSubMesh.end())
{
aSubMesh = _mapSubMesh[index]; aSubMesh = _mapSubMesh[index];
} else { }
else
{
aSubMesh = new SMESH_subMesh(index, this, _myMeshDS, aSubShape); aSubMesh = new SMESH_subMesh(index, this, _myMeshDS, aSubShape);
_mapSubMesh[index] = aSubMesh; _mapSubMesh[index] = aSubMesh;
} }
/* NRI 24/02/2003 /* NRI 24/02/2003
int index = -1; * int index = -1;
if (_subShapes.Contains(aSubShape)) * if (_subShapes.Contains(aSubShape))
{ * {
index = _subShapes.FindIndex(aSubShape); * index = _subShapes.FindIndex(aSubShape);
ASSERT(_mapSubMesh.find(index) != _mapSubMesh.end()); * ASSERT(_mapSubMesh.find(index) != _mapSubMesh.end());
aSubMesh = _mapSubMesh[index]; * aSubMesh = _mapSubMesh[index];
//MESSAGE("found submesh " << index); * //MESSAGE("found submesh " << index);
} * }
else * else
{ * {
index = _subShapes.Add(aSubShape); * index = _subShapes.Add(aSubShape);
aSubMesh = new SMESH_subMesh(index, this, _myMeshDS, aSubShape); * aSubMesh = new SMESH_subMesh(index, this, _myMeshDS, aSubShape);
_mapSubMesh[index] = aSubMesh; * _mapSubMesh[index] = aSubMesh;
//MESSAGE("created submesh " << index); * //MESSAGE("created submesh " << index);
} * }
*/ */
return aSubMesh; return aSubMesh;
} }
@ -358,29 +340,30 @@ SMESH_subMesh* SMESH_Mesh::GetSubMesh(const TopoDS_Shape & aSubShape)
// * returns first created submesh of the two. // * returns first created submesh of the two.
// * subMesh is not created, return may be NULL. // * subMesh is not created, return may be NULL.
SMESH_subMesh* SMESH_Mesh::GetSubMeshContaining(const TopoDS_Shape & aSubShape) SMESH_subMesh *SMESH_Mesh::GetSubMeshContaining(const TopoDS_Shape & aSubShape)
throw (SALOME_Exception) throw(SALOME_Exception)
{ {
//MESSAGE("SMESH_Mesh::GetSubMeshContaining"); //MESSAGE("SMESH_Mesh::GetSubMeshContaining");
bool isFound = false; bool isFound = false;
SMESH_subMesh* aSubMesh = NULL; SMESH_subMesh *aSubMesh = NULL;
int index = _subShapes.FindIndex(aSubShape); int index = _subShapes.FindIndex(aSubShape);
if ( _mapSubMesh.find(index) != _mapSubMesh.end() ) { if (_mapSubMesh.find(index) != _mapSubMesh.end())
{
aSubMesh = _mapSubMesh[index]; aSubMesh = _mapSubMesh[index];
isFound = true; isFound = true;
} }
/* NRI 24/02/2003 /* NRI 24/02/2003
int index = -1; * int index = -1;
if (_subShapes.Contains(aSubShape)) * if (_subShapes.Contains(aSubShape))
{ * {
index = _subShapes.FindIndex(aSubShape); * index = _subShapes.FindIndex(aSubShape);
ASSERT(_mapSubMesh.find(index) != _mapSubMesh.end()); * ASSERT(_mapSubMesh.find(index) != _mapSubMesh.end());
aSubMesh = _mapSubMesh[index]; * aSubMesh = _mapSubMesh[index];
isFound = true; * isFound = true;
//MESSAGE("found submesh " << index); * //MESSAGE("found submesh " << index);
} * }
*/ */
// map<int, SMESH_subMesh*>::iterator itsm; // map<int, SMESH_subMesh*>::iterator itsm;
@ -391,7 +374,8 @@ SMESH_subMesh* SMESH_Mesh::GetSubMeshContaining(const TopoDS_Shape & aSubShape)
// if (isFound) break; // if (isFound) break;
// } // }
if (! isFound) aSubMesh = NULL; if (!isFound)
aSubMesh = NULL;
return aSubMesh; return aSubMesh;
} }
@ -401,31 +385,32 @@ SMESH_subMesh* SMESH_Mesh::GetSubMeshContaining(const TopoDS_Shape & aSubShape)
*/ */
//============================================================================= //=============================================================================
const list <SMESH_subMesh*>& const list < SMESH_subMesh * >&
SMESH_Mesh::GetSubMeshUsingHypothesis(SMESHDS_Hypothesis* anHyp) SMESH_Mesh::GetSubMeshUsingHypothesis(SMESHDS_Hypothesis * anHyp)
throw (SALOME_Exception) throw(SALOME_Exception)
{ {
MESSAGE("SMESH_Mesh::GetSubMeshUsingHypothesis"); MESSAGE("SMESH_Mesh::GetSubMeshUsingHypothesis");
map<int, SMESH_subMesh*>::iterator itsm; map < int, SMESH_subMesh * >::iterator itsm;
_subMeshesUsingHypothesisList.clear(); _subMeshesUsingHypothesisList.clear();
for (itsm = _mapSubMesh.begin(); itsm != _mapSubMesh.end(); itsm++) for (itsm = _mapSubMesh.begin(); itsm != _mapSubMesh.end(); itsm++)
{ {
SMESH_subMesh* aSubMesh = (*itsm).second; SMESH_subMesh *aSubMesh = (*itsm).second;
bool usesHyp = false; bool usesHyp = false;
SMESH_Algo* algo = _gen->GetAlgo(*this, aSubMesh->GetSubShape()); SMESH_Algo *algo = _gen->GetAlgo(*this, aSubMesh->GetSubShape());
if (algo != NULL) if (algo != NULL)
{ {
const list<SMESHDS_Hypothesis*>& usedHyps const list <const SMESHDS_Hypothesis * >&usedHyps
= algo->GetUsedHypothesis(*this, aSubMesh->GetSubShape()); = algo->GetUsedHypothesis(*this, aSubMesh->GetSubShape());
list<SMESHDS_Hypothesis*>::const_iterator itl; list <const SMESHDS_Hypothesis * >::const_iterator itl;
for(itl=usedHyps.begin(); itl != usedHyps.end(); itl++) for (itl = usedHyps.begin(); itl != usedHyps.end(); itl++)
if (anHyp == (*itl)) if (anHyp == (*itl))
{ {
usesHyp = true; usesHyp = true;
break; break;
} }
} }
if (usesHyp) _subMeshesUsingHypothesisList.push_back(aSubMesh); if (usesHyp)
_subMeshesUsingHypothesisList.push_back(aSubMesh);
} }
return _subMeshesUsingHypothesisList; return _subMeshesUsingHypothesisList;
} }
@ -436,34 +421,30 @@ SMESH_Mesh::GetSubMeshUsingHypothesis(SMESHDS_Hypothesis* anHyp)
*/ */
//============================================================================= //=============================================================================
void SMESH_Mesh::ExportMED( const char* file ) void SMESH_Mesh::ExportMED(const char *file) throw(SALOME_Exception)
throw (SALOME_Exception)
{ {
Mesh_Writer* myWriter = new DriverMED_W_SMESHDS_Mesh; Mesh_Writer *myWriter = new DriverMED_W_SMESHDS_Mesh;
myWriter->SetFile( string(file) ); myWriter->SetFile(string(file));
myWriter->SetMesh( _myMeshDS ); myWriter->SetMesh(_myMeshDS);
MESSAGE ( " _idDoc " << _idDoc ) MESSAGE(" _idDoc " << _idDoc) myWriter->SetMeshId(_idDoc);
myWriter->SetMeshId( _idDoc );
myWriter->Add(); myWriter->Add();
} }
void SMESH_Mesh::ExportDAT( const char* file ) void SMESH_Mesh::ExportDAT(const char *file) throw(SALOME_Exception)
throw (SALOME_Exception)
{ {
Mesh_Writer* myWriter = new DriverDAT_W_SMESHDS_Mesh; Mesh_Writer *myWriter = new DriverDAT_W_SMESHDS_Mesh;
myWriter->SetFile( string(file) ); myWriter->SetFile(string(file));
myWriter->SetMesh( _myMeshDS ); myWriter->SetMesh(_myMeshDS);
myWriter->SetMeshId( _idDoc ); myWriter->SetMeshId(_idDoc);
myWriter->Add(); myWriter->Add();
} }
void SMESH_Mesh::ExportUNV( const char* file ) void SMESH_Mesh::ExportUNV(const char *file) throw(SALOME_Exception)
throw (SALOME_Exception)
{ {
Mesh_Writer* myWriter = new DriverUNV_W_SMESHDS_Mesh; Mesh_Writer *myWriter = new DriverUNV_W_SMESHDS_Mesh;
myWriter->SetFile( string(file) ); myWriter->SetFile(string(file));
myWriter->SetMesh( _myMeshDS ); myWriter->SetMesh(_myMeshDS);
myWriter->SetMeshId( _idDoc ); myWriter->SetMeshId(_idDoc);
myWriter->Add(); myWriter->Add();
} }
@ -472,8 +453,7 @@ void SMESH_Mesh::ExportUNV( const char* file )
* *
*/ */
//============================================================================= //=============================================================================
int SMESH_Mesh::NbNodes() int SMESH_Mesh::NbNodes() throw(SALOME_Exception)
throw (SALOME_Exception)
{ {
return _myMeshDS->NbNodes(); return _myMeshDS->NbNodes();
} }
@ -483,8 +463,7 @@ int SMESH_Mesh::NbNodes()
* *
*/ */
//============================================================================= //=============================================================================
int SMESH_Mesh::NbEdges() int SMESH_Mesh::NbEdges() throw(SALOME_Exception)
throw (SALOME_Exception)
{ {
return _myMeshDS->NbEdges(); return _myMeshDS->NbEdges();
} }
@ -494,43 +473,34 @@ int SMESH_Mesh::NbEdges()
* *
*/ */
//============================================================================= //=============================================================================
int SMESH_Mesh::NbFaces() int SMESH_Mesh::NbFaces() throw(SALOME_Exception)
throw (SALOME_Exception)
{ {
return _myMeshDS->NbFaces(); return _myMeshDS->NbFaces();
} }
int SMESH_Mesh::NbTriangles()
throw (SALOME_Exception)
{
SMDS_MeshFacesIterator itFaces(_myMeshDS);
int Nb = 0;
for (;itFaces.More();itFaces.Next()) {
const Handle(SMDS_MeshElement)& elem = itFaces.Value();
switch (elem->NbNodes()) { ///////////////////////////////////////////////////////////////////////////////
case 3 : { /// Return the number of 3 nodes faces in the mesh. This method run in O(n)
Nb++; ///////////////////////////////////////////////////////////////////////////////
break; int SMESH_Mesh::NbTriangles() throw(SALOME_Exception)
} {
} int Nb = 0;
}
SMDS_Iterator<const SMDS_MeshFace*> * itFaces=_myMeshDS->facesIterator();
while(itFaces->more()) if(itFaces->next()->NbNodes()==3) Nb++;
delete itFaces;
return Nb; return Nb;
} }
int SMESH_Mesh::NbQuadrangles()
throw (SALOME_Exception)
{
SMDS_MeshFacesIterator itFaces(_myMeshDS);
int Nb = 0;
for (;itFaces.More();itFaces.Next()) {
const Handle(SMDS_MeshElement)& elem = itFaces.Value();
switch (elem->NbNodes()) { ///////////////////////////////////////////////////////////////////////////////
case 4 : { /// Return the number of 4 nodes faces in the mesh. This method run in O(n)
Nb++; ///////////////////////////////////////////////////////////////////////////////
break; int SMESH_Mesh::NbQuadrangles() throw(SALOME_Exception)
} {
} int Nb = 0;
}
SMDS_Iterator<const SMDS_MeshFace*> * itFaces=_myMeshDS->facesIterator();
while(itFaces->more()) if(itFaces->next()->NbNodes()==4) Nb++;
delete itFaces;
return Nb; return Nb;
} }
@ -539,43 +509,26 @@ int SMESH_Mesh::NbQuadrangles()
* *
*/ */
//============================================================================= //=============================================================================
int SMESH_Mesh::NbVolumes() int SMESH_Mesh::NbVolumes() throw(SALOME_Exception)
throw (SALOME_Exception)
{ {
return _myMeshDS->NbVolumes(); return _myMeshDS->NbVolumes();
} }
int SMESH_Mesh::NbTetras()
throw (SALOME_Exception) int SMESH_Mesh::NbTetras() throw(SALOME_Exception)
{ {
int Nb = 0; int Nb = 0;
SMDS_MeshVolumesIterator itVolumes(_myMeshDS); SMDS_Iterator<const SMDS_MeshVolume*> * itVolumes=_myMeshDS->volumesIterator();
for (;itVolumes.More();itVolumes.Next()) { while(itVolumes->more()) if(itVolumes->next()->NbNodes()==4) Nb++;
const Handle(SMDS_MeshElement)& elem = itVolumes.Value(); delete itVolumes;
switch (elem->NbNodes()) {
case 4 : {
Nb++;
break;
}
}
}
return Nb; return Nb;
} }
int SMESH_Mesh::NbHexas()
throw (SALOME_Exception) int SMESH_Mesh::NbHexas() throw(SALOME_Exception)
{ {
int Nb = 0; int Nb = 0;
SMDS_MeshVolumesIterator itVolumes(_myMeshDS); SMDS_Iterator<const SMDS_MeshVolume*> * itVolumes=_myMeshDS->volumesIterator();
for (;itVolumes.More();itVolumes.Next()) { while(itVolumes->more()) if(itVolumes->next()->NbNodes()==8) Nb++;
const Handle(SMDS_MeshElement)& elem = itVolumes.Value(); delete itVolumes;
switch (elem->NbNodes()) {
case 8 : {
Nb++;
break;
}
}
}
return Nb; return Nb;
} }
@ -584,8 +537,7 @@ int SMESH_Mesh::NbHexas()
* *
*/ */
//============================================================================= //=============================================================================
int SMESH_Mesh::NbSubMesh() int SMESH_Mesh::NbSubMesh() throw(SALOME_Exception)
throw (SALOME_Exception)
{ {
return _myMeshDS->NbSubMesh(); return _myMeshDS->NbSubMesh();
} }

View File

@ -31,13 +31,9 @@
#include "SMESHDS_Document.hxx" #include "SMESHDS_Document.hxx"
#include "SMESHDS_Mesh.hxx" #include "SMESHDS_Mesh.hxx"
#include "SMESHDS_Command.hxx"
#include "SMESH_Hypothesis.hxx" #include "SMESH_Hypothesis.hxx"
#include "SMESH_subMesh.hxx" #include "SMESH_subMesh.hxx"
#include "SMESHDS_ListOfCommand.hxx"
//#include "SMESHDS_ListOfAsciiString.hxx"
//#include "SMESHDS_ListIteratorOfListOfAsciiString.hxx"
#include "Utils_SALOME_Exception.hxx" #include "Utils_SALOME_Exception.hxx"
#include <TopExp.hxx> #include <TopExp.hxx>
@ -63,103 +59,83 @@ class SMESH_Gen;
class SMESH_Mesh class SMESH_Mesh
{ {
public: public:
SMESH_Mesh(); SMESH_Mesh();
SMESH_Mesh(int localId, SMESH_Mesh(int localId, int studyId, SMESH_Gen * gen,
int studyId, SMESHDS_Document * myDocument);
SMESH_Gen* gen,
const Handle(SMESHDS_Document)& myDocument);
virtual ~SMESH_Mesh(); virtual ~ SMESH_Mesh();
void ShapeToMesh(const TopoDS_Shape& aShape) void ShapeToMesh(const TopoDS_Shape & aShape) throw(SALOME_Exception);
throw (SALOME_Exception);
bool AddHypothesis(const TopoDS_Shape& aSubShape, bool AddHypothesis(const TopoDS_Shape & aSubShape, int anHypId)
int anHypId) throw(SALOME_Exception);
throw (SALOME_Exception);
bool RemoveHypothesis(const TopoDS_Shape& aSubShape, bool RemoveHypothesis(const TopoDS_Shape & aSubShape, int anHypId)
int anHypId) throw(SALOME_Exception);
throw (SALOME_Exception);
const list<SMESHDS_Hypothesis*>& const list <const SMESHDS_Hypothesis * >&
GetHypothesisList(const TopoDS_Shape& aSubShape) GetHypothesisList(const TopoDS_Shape & aSubShape)
throw (SALOME_Exception); throw(SALOME_Exception);
const SMESHDS_ListOfCommand& GetLog() const list<SMESHDS_Command*> & GetLog() throw(SALOME_Exception);
throw (SALOME_Exception);
// const SMESHDS_ListOfAsciiString& GetLog() // const SMESHDS_ListOfAsciiString& GetLog()
// throw (SALOME_Exception); // throw (SALOME_Exception);
void ClearLog() void ClearLog() throw(SALOME_Exception);
throw (SALOME_Exception);
int GetId(); int GetId();
const Handle(SMESHDS_Mesh)& GetMeshDS(); SMESHDS_Mesh * GetMeshDS();
SMESH_Gen* GetGen(); SMESH_Gen *GetGen();
SMESH_subMesh* GetSubMesh(const TopoDS_Shape & aSubShape) SMESH_subMesh *GetSubMesh(const TopoDS_Shape & aSubShape)
throw (SALOME_Exception); throw(SALOME_Exception);
SMESH_subMesh* GetSubMeshContaining(const TopoDS_Shape & aSubShape) SMESH_subMesh *GetSubMeshContaining(const TopoDS_Shape & aSubShape)
throw (SALOME_Exception); throw(SALOME_Exception);
const list <SMESH_subMesh*>& const list < SMESH_subMesh * >&
GetSubMeshUsingHypothesis(SMESHDS_Hypothesis* anHyp) GetSubMeshUsingHypothesis(SMESHDS_Hypothesis * anHyp)
throw (SALOME_Exception); throw(SALOME_Exception);
void ExportDAT( const char* file ) void ExportDAT(const char *file) throw(SALOME_Exception);
throw (SALOME_Exception); void ExportMED(const char *file) throw(SALOME_Exception);
void ExportMED( const char* file ) void ExportUNV(const char *file) throw(SALOME_Exception);
throw (SALOME_Exception);
void ExportUNV( const char* file )
throw (SALOME_Exception);
int NbNodes() int NbNodes() throw(SALOME_Exception);
throw (SALOME_Exception);
int NbEdges() int NbEdges() throw(SALOME_Exception);
throw (SALOME_Exception);
int NbFaces() int NbFaces() throw(SALOME_Exception);
throw (SALOME_Exception);
int NbTriangles() int NbTriangles() throw(SALOME_Exception);
throw (SALOME_Exception);
int NbQuadrangles() int NbQuadrangles() throw(SALOME_Exception);
throw (SALOME_Exception);
int NbVolumes() int NbVolumes() throw(SALOME_Exception);
throw (SALOME_Exception);
int NbTetras() int NbTetras() throw(SALOME_Exception);
throw (SALOME_Exception);
int NbHexas() int NbHexas() throw(SALOME_Exception);
throw (SALOME_Exception);
int NbSubMesh() int NbSubMesh() throw(SALOME_Exception);
throw (SALOME_Exception);
private:
private:
int _id; // id given by creator (unique within the creator instance) int _id; // id given by creator (unique within the creator instance)
int _studyId; int _studyId;
int _idDoc; // id given by SMESHDS_Document int _idDoc; // id given by SMESHDS_Document
bool _isShapeToMesh; // set to true when a shape is given (only once) bool _isShapeToMesh; // set to true when a shape is given (only once)
list<SMESHDS_Hypothesis*> _subShapeHypothesisList; list<const SMESHDS_Hypothesis *> _subShapeHypothesisList;
list<SMESH_subMesh*> _subMeshesUsingHypothesisList; list <SMESH_subMesh *> _subMeshesUsingHypothesisList;
Handle (SMESHDS_Document) _myDocument; SMESHDS_Document * _myDocument;
Handle (SMESHDS_Mesh) _myMeshDS; SMESHDS_Mesh * _myMeshDS;
TopTools_IndexedMapOfShape _subShapes; TopTools_IndexedMapOfShape _subShapes;
map<int, SMESH_subMesh*> _mapSubMesh; map <int, SMESH_subMesh *>_mapSubMesh;
SMESH_Gen* _gen; SMESH_Gen *_gen;
}; };
#endif #endif

View File

@ -26,7 +26,6 @@
// Module : SMESH // Module : SMESH
// $Header$ // $Header$
using namespace std;
using namespace std; using namespace std;
#include "SMESH_Quadrangle_2D.hxx" #include "SMESH_Quadrangle_2D.hxx"
#include "SMESH_Gen.hxx" #include "SMESH_Gen.hxx"
@ -57,14 +56,12 @@ using namespace std;
//============================================================================= //=============================================================================
SMESH_Quadrangle_2D::SMESH_Quadrangle_2D(int hypId, SMESH_Quadrangle_2D::SMESH_Quadrangle_2D(int hypId,
int studyId, int studyId, SMESH_Gen * gen):SMESH_2D_Algo(hypId, studyId, gen)
SMESH_Gen* gen)
: SMESH_2D_Algo(hypId, studyId, gen)
{ {
MESSAGE("SMESH_Quadrangle_2D::SMESH_Quadrangle_2D"); MESSAGE("SMESH_Quadrangle_2D::SMESH_Quadrangle_2D");
_name = "Quadrangle_2D"; _name = "Quadrangle_2D";
// _shapeType = TopAbs_FACE; // _shapeType = TopAbs_FACE;
_shapeType = (1<<TopAbs_FACE); _shapeType = (1 << TopAbs_FACE);
} }
//============================================================================= //=============================================================================
@ -84,8 +81,8 @@ SMESH_Quadrangle_2D::~SMESH_Quadrangle_2D()
*/ */
//============================================================================= //=============================================================================
bool SMESH_Quadrangle_2D::CheckHypothesis(SMESH_Mesh& aMesh, bool SMESH_Quadrangle_2D::CheckHypothesis(SMESH_Mesh & aMesh,
const TopoDS_Shape& aShape) const TopoDS_Shape & aShape)
{ {
//MESSAGE("SMESH_Quadrangle_2D::CheckHypothesis"); //MESSAGE("SMESH_Quadrangle_2D::CheckHypothesis");
@ -96,76 +93,72 @@ bool SMESH_Quadrangle_2D::CheckHypothesis(SMESH_Mesh& aMesh,
return isOk; return isOk;
} }
//============================================================================= //=============================================================================
/*! /*!
* *
*/ */
//============================================================================= //=============================================================================
bool SMESH_Quadrangle_2D::Compute(SMESH_Mesh& aMesh, bool SMESH_Quadrangle_2D::Compute(SMESH_Mesh & aMesh,
const TopoDS_Shape& aShape) const TopoDS_Shape & aShape)throw(SALOME_Exception)
throw (SALOME_Exception)
{ {
//MESSAGE("SMESH_Quadrangle_2D::Compute"); //MESSAGE("SMESH_Quadrangle_2D::Compute");
const Handle(SMESHDS_Mesh)& meshDS = aMesh.GetMeshDS(); SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
SMESH_subMesh* theSubMesh = aMesh.GetSubMesh(aShape); SMESH_subMesh *theSubMesh = aMesh.GetSubMesh(aShape);
FaceQuadStruct* quad = CheckAnd2Dcompute(aMesh, aShape); FaceQuadStruct *quad = CheckAnd2Dcompute(aMesh, aShape);
if (!quad) return false; if (!quad)
return false;
// --- compute 3D values on points, store points & quadrangles // --- compute 3D values on points, store points & quadrangles
int nbdown = quad->nbPts[0]; int nbdown = quad->nbPts[0];
int nbright = quad->nbPts[1]; int nbright = quad->nbPts[1];
int nbVertices = nbdown*nbright; int nbVertices = nbdown * nbright;
int nbQuad = (nbdown-1)*(nbright-1); int nbQuad = (nbdown - 1) * (nbright - 1);
//SCRUTE(nbVertices); //SCRUTE(nbVertices);
//SCRUTE(nbQuad); //SCRUTE(nbQuad);
// const TopoDS_Face& FF = TopoDS::Face(aShape); // const TopoDS_Face& FF = TopoDS::Face(aShape);
// bool faceIsForward = (FF.Orientation() == TopAbs_FORWARD); // bool faceIsForward = (FF.Orientation() == TopAbs_FORWARD);
// TopoDS_Face F = TopoDS::Face(FF.Oriented(TopAbs_FORWARD)); // TopoDS_Face F = TopoDS::Face(FF.Oriented(TopAbs_FORWARD));
const TopoDS_Face& F = TopoDS::Face(aShape); const TopoDS_Face & F = TopoDS::Face(aShape);
bool faceIsForward = (F.Orientation() == TopAbs_FORWARD); bool faceIsForward = (F.Orientation() == TopAbs_FORWARD);
Handle(Geom_Surface) S = BRep_Tool::Surface(F); Handle(Geom_Surface) S = BRep_Tool::Surface(F);
for (int i=1; i<nbdown-1; i++) for (int i = 1; i < nbdown - 1; i++)
for (int j=1; j<nbright-1; j++) // internal points for (int j = 1; j < nbright - 1; j++) // internal points
{ {
int ij = j*nbdown +i; int ij = j * nbdown + i;
double u = quad->uv_grid[ij].u; double u = quad->uv_grid[ij].u;
double v = quad->uv_grid[ij].v; double v = quad->uv_grid[ij].v;
gp_Pnt P = S->Value(u,v); gp_Pnt P = S->Value(u, v);
int nodeId = meshDS->AddNode(P.X(), P.Y(), P.Z()); SMDS_MeshNode * node = meshDS->AddNode(P.X(), P.Y(), P.Z());
//MESSAGE("point "<< nodeId<<" "<<" "<<P.X()<<" "<<P.Y()<<" "<<P.Z()); int nodeId = node->GetID();
Handle (SMDS_MeshElement) elt = meshDS->FindNode(nodeId);
Handle (SMDS_MeshNode) node = meshDS->GetNode(1, elt);
meshDS->SetNodeOnFace(node, F); meshDS->SetNodeOnFace(node, F);
quad->uv_grid[ij].nodeId = nodeId; quad->uv_grid[ij].nodeId = nodeId;
// Handle (SMDS_FacePosition) fpos // Handle (SMDS_FacePosition) fpos
// = new SMDS_FacePosition(theSubMesh->GetId(),i,j); // easier than u,v // = new SMDS_FacePosition(theSubMesh->GetId(),i,j); // easier than u,v
// node->SetPosition(fpos); // node->SetPosition(fpos);
Handle (SMDS_FacePosition) fpos SMDS_FacePosition* fpos
= Handle (SMDS_FacePosition)::DownCast(node->GetPosition()); = dynamic_cast<SMDS_FacePosition*>(node->GetPosition());
fpos->SetUParameter(i); fpos->SetUParameter(i);
fpos->SetVParameter(j); fpos->SetVParameter(j);
} }
// bool isQuadForward = ( faceIsForward == quad->isEdgeForward[0]); // bool isQuadForward = ( faceIsForward == quad->isEdgeForward[0]);
for (int i=0; i<nbdown-1; i++) for (int i = 0; i < nbdown - 1; i++)
for (int j=0; j<nbright-1; j++) // faces for (int j = 0; j < nbright - 1; j++) // faces
{ {
int a = quad->uv_grid[ j *nbdown +i ].nodeId; int a = quad->uv_grid[j * nbdown + i].nodeId;
int b = quad->uv_grid[ j *nbdown +i+1].nodeId; int b = quad->uv_grid[j * nbdown + i + 1].nodeId;
int c = quad->uv_grid[(j+1)*nbdown +i+1].nodeId; int c = quad->uv_grid[(j + 1) * nbdown + i + 1].nodeId;
int d = quad->uv_grid[(j+1)*nbdown +i ].nodeId; int d = quad->uv_grid[(j + 1) * nbdown + i].nodeId;
int faceId; int faceId;
// if (isQuadForward) faceId = meshDS->AddFace(a,b,c,d); // if (isQuadForward) faceId = meshDS->AddFace(a,b,c,d);
// else faceId = meshDS->AddFace(a,d,c,b); // else faceId = meshDS->AddFace(a,d,c,b);
faceId = meshDS->AddFace(a,b,c,d); SMDS_MeshFace * face = meshDS->AddFace(a, b, c, d);
Handle (SMDS_MeshElement) elt = meshDS->FindElement(faceId); meshDS->SetMeshElementOnShape(face, F);
meshDS->SetMeshElementOnShape(elt, F);
} }
QuadDelete(quad); QuadDelete(quad);
@ -179,24 +172,22 @@ bool SMESH_Quadrangle_2D::Compute(SMESH_Mesh& aMesh,
*/ */
//============================================================================= //=============================================================================
FaceQuadStruct* FaceQuadStruct *SMESH_Quadrangle_2D::CheckAnd2Dcompute(SMESH_Mesh & aMesh,
SMESH_Quadrangle_2D::CheckAnd2Dcompute(SMESH_Mesh& aMesh, const TopoDS_Shape & aShape)throw(SALOME_Exception)
const TopoDS_Shape& aShape)
throw (SALOME_Exception)
{ {
//MESSAGE("SMESH_Quadrangle_2D::ComputeWithoutStore"); //MESSAGE("SMESH_Quadrangle_2D::ComputeWithoutStore");
SMESH_subMesh* theSubMesh = aMesh.GetSubMesh(aShape); SMESH_subMesh *theSubMesh = aMesh.GetSubMesh(aShape);
// const TopoDS_Face& FF = TopoDS::Face(aShape); // const TopoDS_Face& FF = TopoDS::Face(aShape);
// bool faceIsForward = (FF.Orientation() == TopAbs_FORWARD); // bool faceIsForward = (FF.Orientation() == TopAbs_FORWARD);
// TopoDS_Face F = TopoDS::Face(FF.Oriented(TopAbs_FORWARD)); // TopoDS_Face F = TopoDS::Face(FF.Oriented(TopAbs_FORWARD));
const TopoDS_Face& F = TopoDS::Face(aShape); const TopoDS_Face & F = TopoDS::Face(aShape);
bool faceIsForward = (F.Orientation() == TopAbs_FORWARD); bool faceIsForward = (F.Orientation() == TopAbs_FORWARD);
// verify 1 wire only, with 4 edges, same number of points on opposite edges // verify 1 wire only, with 4 edges, same number of points on opposite edges
if (NumberOfWires (F) != 1) if (NumberOfWires(F) != 1)
{ {
MESSAGE("only 1 wire by face (quadrangles)"); MESSAGE("only 1 wire by face (quadrangles)");
return 0; return 0;
@ -204,24 +195,25 @@ SMESH_Quadrangle_2D::CheckAnd2Dcompute(SMESH_Mesh& aMesh,
} }
// const TopoDS_Wire WW = BRepTools::OuterWire(F); // const TopoDS_Wire WW = BRepTools::OuterWire(F);
// TopoDS_Wire W = TopoDS::Wire(WW.Oriented(TopAbs_FORWARD)); // TopoDS_Wire W = TopoDS::Wire(WW.Oriented(TopAbs_FORWARD));
const TopoDS_Wire& W = BRepTools::OuterWire(F); const TopoDS_Wire & W = BRepTools::OuterWire(F);
BRepTools_WireExplorer wexp(W,F); BRepTools_WireExplorer wexp(W, F);
FaceQuadStruct* quad = new FaceQuadStruct; FaceQuadStruct *quad = new FaceQuadStruct;
for (int i=0; i<4; i++) quad->uv_edges[i] = 0; for (int i = 0; i < 4; i++)
quad->uv_edges[i] = 0;
quad->uv_grid = 0; quad->uv_grid = 0;
int nbEdges = 0; int nbEdges = 0;
for (wexp.Init(W,F);wexp.More(); wexp.Next()) for (wexp.Init(W, F); wexp.More(); wexp.Next())
{ {
// const TopoDS_Edge& EE = wexp.Current(); // const TopoDS_Edge& EE = wexp.Current();
// TopoDS_Edge E = TopoDS::Edge(EE.Oriented(TopAbs_FORWARD)); // TopoDS_Edge E = TopoDS::Edge(EE.Oriented(TopAbs_FORWARD));
const TopoDS_Edge& E = wexp.Current(); const TopoDS_Edge & E = wexp.Current();
int nb = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes(); int nb = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes();
if (nbEdges < 4) if (nbEdges < 4)
{ {
quad->edge[nbEdges] = E; quad->edge[nbEdges] = E;
quad->nbPts[nbEdges] = nb +2; // internal points + 2 extrema quad->nbPts[nbEdges] = nb + 2; // internal points + 2 extrema
} }
nbEdges++; nbEdges++;
} }
@ -257,24 +249,25 @@ SMESH_Quadrangle_2D::CheckAnd2Dcompute(SMESH_Mesh& aMesh,
return quad; return quad;
} }
//============================================================================= //=============================================================================
/*! /*!
* *
*/ */
//============================================================================= //=============================================================================
void SMESH_Quadrangle_2D::QuadDelete(FaceQuadStruct* quad) void SMESH_Quadrangle_2D::QuadDelete(FaceQuadStruct * quad)
{ {
//MESSAGE("SMESH_Quadrangle_2D::QuadDelete"); //MESSAGE("SMESH_Quadrangle_2D::QuadDelete");
if (quad) if (quad)
{ {
for (int i=0; i<4; i++) for (int i = 0; i < 4; i++)
{ {
if (quad->uv_edges[i]) delete [] quad->uv_edges[i]; if (quad->uv_edges[i])
delete[]quad->uv_edges[i];
quad->edge[i].Nullify(); quad->edge[i].Nullify();
} }
if (quad->uv_grid) delete [] quad->uv_grid; if (quad->uv_grid)
delete[]quad->uv_grid;
delete quad; delete quad;
} }
} }
@ -285,17 +278,15 @@ SMESH_Quadrangle_2D::CheckAnd2Dcompute(SMESH_Mesh& aMesh,
*/ */
//============================================================================= //=============================================================================
void SMESH_Quadrangle_2D::SetNormalizedGrid(SMESH_Mesh& aMesh, void SMESH_Quadrangle_2D::SetNormalizedGrid(SMESH_Mesh & aMesh,
const TopoDS_Shape& aShape, const TopoDS_Shape & aShape, FaceQuadStruct * quad) throw(SALOME_Exception)
FaceQuadStruct* quad)
throw (SALOME_Exception)
{ {
// Algorithme décrit dans "Génération automatique de maillages" // Algorithme décrit dans "Génération automatique de maillages"
// P.L. GEORGE, MASSON, § 6.4.1 p. 84-85 // P.L. GEORGE, MASSON, § 6.4.1 p. 84-85
// traitement dans le domaine paramétrique 2d u,v // traitement dans le domaine paramétrique 2d u,v
// transport - projection sur le carré unité // transport - projection sur le carré unité
const TopoDS_Face& F = TopoDS::Face(aShape); const TopoDS_Face & F = TopoDS::Face(aShape);
// 1 --- find orientation of the 4 edges, by test on extrema // 1 --- find orientation of the 4 edges, by test on extrema
@ -311,15 +302,13 @@ void SMESH_Quadrangle_2D::SetNormalizedGrid(SMESH_Mesh& aMesh,
// =down // =down
// //
Handle (Geom2d_Curve) c2d[4]; Handle(Geom2d_Curve) c2d[4];
gp_Pnt2d pf[4]; gp_Pnt2d pf[4];
gp_Pnt2d pl[4]; gp_Pnt2d pl[4];
for (int i=0; i<4; i++) for (int i = 0; i < 4; i++)
{ {
c2d[i] = BRep_Tool::CurveOnSurface(quad->edge[i], c2d[i] = BRep_Tool::CurveOnSurface(quad->edge[i],
F, F, quad->first[i], quad->last[i]);
quad->first[i],
quad->last[i]);
pf[i] = c2d[i]->Value(quad->first[i]); pf[i] = c2d[i]->Value(quad->first[i]);
pl[i] = c2d[i]->Value(quad->last[i]); pl[i] = c2d[i]->Value(quad->last[i]);
quad->isEdgeForward[i] = false; quad->isEdgeForward[i] = false;
@ -327,31 +316,31 @@ void SMESH_Quadrangle_2D::SetNormalizedGrid(SMESH_Mesh& aMesh,
double eps2d = 1.e-3; // *** utiliser plutot TopExp::CommonVertex, puis double eps2d = 1.e-3; // *** utiliser plutot TopExp::CommonVertex, puis
// distances si piece fausse // distances si piece fausse
int i=0; int i = 0;
if ((pf[1].Distance(pl[0]) < eps2d) || (pl[1].Distance(pl[0]) < eps2d)) if ((pf[1].Distance(pl[0]) < eps2d) || (pl[1].Distance(pl[0]) < eps2d))
{ {
quad->isEdgeForward[0] = true; quad->isEdgeForward[0] = true;
} }
else else
{ {
double tmp =quad->first[0]; double tmp = quad->first[0];
quad->first[0] = quad->last[0]; quad->first[0] = quad->last[0];
quad->last[0] = tmp; quad->last[0] = tmp;
pf[0] = c2d[0]->Value(quad->first[0]); pf[0] = c2d[0]->Value(quad->first[0]);
pl[0] = c2d[0]->Value(quad->last[0]); pl[0] = c2d[0]->Value(quad->last[0]);
} }
for (int i=1; i<4; i++) for (int i = 1; i < 4; i++)
{ {
quad->isEdgeForward[i] = (pf[i].Distance(pl[i-1]) < eps2d); quad->isEdgeForward[i] = (pf[i].Distance(pl[i - 1]) < eps2d);
if (! quad->isEdgeForward[i]) if (!quad->isEdgeForward[i])
{ {
double tmp =quad->first[i]; double tmp = quad->first[i];
quad->first[i] = quad->last[i]; quad->first[i] = quad->last[i];
quad->last[i] = tmp; quad->last[i] = tmp;
pf[i] = c2d[i]->Value(quad->first[i]); pf[i] = c2d[i]->Value(quad->first[i]);
pl[i] = c2d[i]->Value(quad->last[i]); pl[i] = c2d[i]->Value(quad->last[i]);
//SCRUTE(pf[i].Distance(pl[i-1])); //SCRUTE(pf[i].Distance(pl[i-1]));
ASSERT(pf[i].Distance(pl[i-1]) < eps2d); ASSERT(pf[i].Distance(pl[i - 1]) < eps2d);
} }
} }
//SCRUTE(pf[0].Distance(pl[3])); //SCRUTE(pf[0].Distance(pl[3]));
@ -366,21 +355,17 @@ void SMESH_Quadrangle_2D::SetNormalizedGrid(SMESH_Mesh& aMesh,
// 2 --- load 2d edge points (u,v) with orientation and value on unit square // 2 --- load 2d edge points (u,v) with orientation and value on unit square
for (int i=0; i<2; i++) for (int i = 0; i < 2; i++)
{ {
quad->uv_edges[i] = LoadEdgePoints(aMesh, F, quad->uv_edges[i] = LoadEdgePoints(aMesh, F,
quad->edge[i], quad->edge[i], quad->first[i], quad->last[i]);
quad->first[i],
quad->last[i]);
// quad->isEdgeForward[i]); // quad->isEdgeForward[i]);
} }
for (int i=2; i<4; i++) for (int i = 2; i < 4; i++)
{ {
quad->uv_edges[i] = LoadEdgePoints(aMesh, F, quad->uv_edges[i] = LoadEdgePoints(aMesh, F,
quad->edge[i], quad->edge[i], quad->last[i], quad->first[i]);
quad->last[i],
quad->first[i]);
// !quad->isEdgeForward[i]); // !quad->isEdgeForward[i]);
} }
@ -389,13 +374,13 @@ void SMESH_Quadrangle_2D::SetNormalizedGrid(SMESH_Mesh& aMesh,
int nbdown = quad->nbPts[0]; int nbdown = quad->nbPts[0];
int nbright = quad->nbPts[1]; int nbright = quad->nbPts[1];
quad->uv_grid = new UVPtStruct[nbright*nbdown]; quad->uv_grid = new UVPtStruct[nbright * nbdown];
UVPtStruct* uv_grid = quad->uv_grid; UVPtStruct *uv_grid = quad->uv_grid;
UVPtStruct* uv_e0 = quad->uv_edges[0]; UVPtStruct *uv_e0 = quad->uv_edges[0];
UVPtStruct* uv_e1 = quad->uv_edges[1]; UVPtStruct *uv_e1 = quad->uv_edges[1];
UVPtStruct* uv_e2 = quad->uv_edges[2]; UVPtStruct *uv_e2 = quad->uv_edges[2];
UVPtStruct* uv_e3 = quad->uv_edges[3]; UVPtStruct *uv_e3 = quad->uv_edges[3];
gp_Pnt2d a0 = pf[0]; gp_Pnt2d a0 = pf[0];
gp_Pnt2d a1 = pf[1]; gp_Pnt2d a1 = pf[1];
gp_Pnt2d a2 = pf[2]; gp_Pnt2d a2 = pf[2];
@ -404,36 +389,36 @@ void SMESH_Quadrangle_2D::SetNormalizedGrid(SMESH_Mesh& aMesh,
// nodes Id on edges // nodes Id on edges
int j = 0; int j = 0;
for (int i=0; i<nbdown; i++) for (int i = 0; i < nbdown; i++)
{ {
int ij = j*nbdown +i; int ij = j * nbdown + i;
uv_grid[ij].nodeId = uv_e0[i].nodeId; uv_grid[ij].nodeId = uv_e0[i].nodeId;
} }
i = nbdown-1; i = nbdown - 1;
for (int j=0; j<nbright; j++) for (int j = 0; j < nbright; j++)
{ {
int ij = j*nbdown +i; int ij = j * nbdown + i;
uv_grid[ij].nodeId = uv_e1[j].nodeId; uv_grid[ij].nodeId = uv_e1[j].nodeId;
} }
j = nbright -1; j = nbright - 1;
for (int i=0; i<nbdown; i++) for (int i = 0; i < nbdown; i++)
{ {
int ij = j*nbdown +i; int ij = j * nbdown + i;
uv_grid[ij].nodeId = uv_e2[i].nodeId; uv_grid[ij].nodeId = uv_e2[i].nodeId;
} }
i = 0; i = 0;
for (int j=0; j<nbright; j++) for (int j = 0; j < nbright; j++)
{ {
int ij = j*nbdown +i; int ij = j * nbdown + i;
uv_grid[ij].nodeId = uv_e3[j].nodeId; uv_grid[ij].nodeId = uv_e3[j].nodeId;
} }
// normalized 2d values on grid // normalized 2d values on grid
for (int i=0; i<nbdown; i++) for (int i = 0; i < nbdown; i++)
for (int j=0; j<nbright; j++) for (int j = 0; j < nbright; j++)
{ {
int ij = j*nbdown +i; int ij = j * nbdown + i;
// --- droite i cste : x = x0 + y(x1-x0) // --- droite i cste : x = x0 + y(x1-x0)
double x0 = uv_e0[i].normParam; // bas - sud double x0 = uv_e0[i].normParam; // bas - sud
double x1 = uv_e2[i].normParam; // haut - nord double x1 = uv_e2[i].normParam; // haut - nord
@ -441,8 +426,8 @@ void SMESH_Quadrangle_2D::SetNormalizedGrid(SMESH_Mesh& aMesh,
double y0 = uv_e3[j].normParam; // gauche-ouest double y0 = uv_e3[j].normParam; // gauche-ouest
double y1 = uv_e1[j].normParam; // droite - est double y1 = uv_e1[j].normParam; // droite - est
// --- intersection : x=x0+(y0+x(y1-y0))(x1-x0) // --- intersection : x=x0+(y0+x(y1-y0))(x1-x0)
double x=(x0+y0*(x1-x0))/(1-(y1-y0)*(x1-x0)); double x = (x0 + y0 * (x1 - x0)) / (1 - (y1 - y0) * (x1 - x0));
double y=y0+x*(y1-y0); double y = y0 + x * (y1 - y0);
uv_grid[ij].x = x; uv_grid[ij].x = x;
uv_grid[ij].y = y; uv_grid[ij].y = y;
//MESSAGE("-xy-01 "<<x0<<" "<<x1<<" "<<y0<<" "<<y1); //MESSAGE("-xy-01 "<<x0<<" "<<x1<<" "<<y0<<" "<<y1);
@ -451,20 +436,16 @@ void SMESH_Quadrangle_2D::SetNormalizedGrid(SMESH_Mesh& aMesh,
// 4 --- projection on 2d domain (u,v) // 4 --- projection on 2d domain (u,v)
for (int i=0; i<nbdown; i++) for (int i = 0; i < nbdown; i++)
for (int j=0; j<nbright; j++) for (int j = 0; j < nbright; j++)
{ {
int ij = j*nbdown +i; int ij = j * nbdown + i;
double x = uv_grid[ij].x; double x = uv_grid[ij].x;
double y = uv_grid[ij].y; double y = uv_grid[ij].y;
double param_0 = uv_e0[0].param double param_0 = uv_e0[0].param + x * (uv_e0[nbdown - 1].param - uv_e0[0].param); // sud
+ x*(uv_e0[nbdown-1].param -uv_e0[0].param); // sud double param_2 = uv_e2[0].param + x * (uv_e2[nbdown - 1].param - uv_e2[0].param); // nord
double param_2 = uv_e2[0].param double param_1 = uv_e1[0].param + y * (uv_e1[nbright - 1].param - uv_e1[0].param); // est
+ x*(uv_e2[nbdown-1].param -uv_e2[0].param); // nord double param_3 = uv_e3[0].param + y * (uv_e3[nbright - 1].param - uv_e3[0].param); // ouest
double param_1 = uv_e1[0].param
+ y*(uv_e1[nbright-1].param -uv_e1[0].param); // est
double param_3 = uv_e3[0].param
+ y*(uv_e3[nbright-1].param -uv_e3[0].param); // ouest
//MESSAGE("params "<<param_0<<" "<<param_1<<" "<<param_2<<" "<<param_3); //MESSAGE("params "<<param_0<<" "<<param_1<<" "<<param_2<<" "<<param_3);
gp_Pnt2d p0 = c2d[0]->Value(param_0); gp_Pnt2d p0 = c2d[0]->Value(param_0);
@ -472,11 +453,15 @@ void SMESH_Quadrangle_2D::SetNormalizedGrid(SMESH_Mesh& aMesh,
gp_Pnt2d p2 = c2d[2]->Value(param_2); gp_Pnt2d p2 = c2d[2]->Value(param_2);
gp_Pnt2d p3 = c2d[3]->Value(param_3); gp_Pnt2d p3 = c2d[3]->Value(param_3);
double u = (1-y)*p0.X() + x*p1.X() + y*p2.X() + (1-x)*p3.X(); double u =
double v = (1-y)*p0.Y() + x*p1.Y() + y*p2.Y() + (1-x)*p3.Y(); (1 - y) * p0.X() + x * p1.X() + y * p2.X() + (1 - x) * p3.X();
double v =
(1 - y) * p0.Y() + x * p1.Y() + y * p2.Y() + (1 - x) * p3.Y();
u -= (1-x)*(1-y)*a0.X() + x*(1-y)*a1.X() + x*y*a2.X() + (1-x)*y*a3.X(); u -= (1 - x) * (1 - y) * a0.X() + x * (1 - y) * a1.X() +
v -= (1-x)*(1-y)*a0.Y() + x*(1-y)*a1.Y() + x*y*a2.Y() + (1-x)*y*a3.Y(); x * y * a2.X() + (1 - x) * y * a3.X();
v -= (1 - x) * (1 - y) * a0.Y() + x * (1 - y) * a1.Y() +
x * y * a2.Y() + (1 - x) * y * a3.Y();
uv_grid[ij].u = u; uv_grid[ij].u = u;
uv_grid[ij].v = v; uv_grid[ij].v = v;
@ -491,16 +476,13 @@ void SMESH_Quadrangle_2D::SetNormalizedGrid(SMESH_Mesh& aMesh,
*/ */
//============================================================================= //=============================================================================
UVPtStruct* SMESH_Quadrangle_2D::LoadEdgePoints(SMESH_Mesh& aMesh, UVPtStruct *SMESH_Quadrangle_2D::LoadEdgePoints(SMESH_Mesh & aMesh,
const TopoDS_Face& F, const TopoDS_Face & F, const TopoDS_Edge & E, double first, double last)
const TopoDS_Edge& E,
double first,
double last)
// bool isForward) // bool isForward)
{ {
//MESSAGE("SMESH_Quadrangle_2D::LoadEdgePoints"); //MESSAGE("SMESH_Quadrangle_2D::LoadEdgePoints");
Handle (SMDS_Mesh) meshDS = aMesh.GetMeshDS(); SMDS_Mesh * meshDS = aMesh.GetMeshDS();
// --- IDNodes of first and last Vertex // --- IDNodes of first and last Vertex
@ -508,48 +490,47 @@ UVPtStruct* SMESH_Quadrangle_2D::LoadEdgePoints(SMESH_Mesh& aMesh,
TopExp::Vertices(E, VFirst, VLast); // corresponds to f and l TopExp::Vertices(E, VFirst, VLast); // corresponds to f and l
ASSERT(!VFirst.IsNull()); ASSERT(!VFirst.IsNull());
SMESH_subMesh* firstSubMesh = aMesh.GetSubMesh(VFirst); SMESH_subMesh *firstSubMesh = aMesh.GetSubMesh(VFirst);
const TColStd_ListOfInteger& lidf const vector<int>& lidf
= firstSubMesh->GetSubMeshDS()->GetIDNodes(); = firstSubMesh->GetSubMeshDS()->GetIDNodes();
int idFirst= lidf.First(); int idFirst = lidf[0];
//SCRUTE(idFirst); //SCRUTE(idFirst);
ASSERT(!VLast.IsNull()); ASSERT(!VLast.IsNull());
SMESH_subMesh* lastSubMesh = aMesh.GetSubMesh(VLast); SMESH_subMesh *lastSubMesh = aMesh.GetSubMesh(VLast);
const TColStd_ListOfInteger& lidl const vector<int> & lidl
= lastSubMesh->GetSubMeshDS()->GetIDNodes(); = lastSubMesh->GetSubMeshDS()->GetIDNodes();
int idLast= lidl.First(); int idLast = lidl[0];
//SCRUTE(idLast); //SCRUTE(idLast);
// --- edge internal IDNodes (relies on good order storage, not checked) // --- edge internal IDNodes (relies on good order storage, not checked)
int nbPoints = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes(); int nbPoints = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes();
//SCRUTE(nbPoints); //SCRUTE(nbPoints);
UVPtStruct * uvslf = new UVPtStruct[nbPoints+2]; UVPtStruct *uvslf = new UVPtStruct[nbPoints + 2];
double f,l; double f, l;
Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E,F,f,l); Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E, F, f, l);
const TColStd_ListOfInteger& indElt const vector<int> & indElt
= aMesh.GetSubMesh(E)->GetSubMeshDS()->GetIDNodes(); = aMesh.GetSubMesh(E)->GetSubMeshDS()->GetIDNodes();
TColStd_ListIteratorOfListOfInteger ite(indElt);
//SCRUTE(nbPoints); //SCRUTE(nbPoints);
//SCRUTE(indElt.Extent()); //SCRUTE(indElt.Extent());
ASSERT(nbPoints == indElt.Extent()); ASSERT(nbPoints == indElt.size());
map<double,int> params; map<double, int> params;
for (; ite.More(); ite.Next()) for (int ite=0; ite<indElt.size(); ite++)
{ {
int nodeId = ite.Value(); int nodeId = indElt[ite];
Handle (SMDS_MeshElement) elt = meshDS->FindNode(nodeId); const SMDS_MeshNode * node = meshDS->FindNode(nodeId);
Handle (SMDS_MeshNode) node = meshDS->GetNode(1, elt); const SMDS_EdgePosition* epos
Handle (SMDS_EdgePosition) epos = static_cast<const SMDS_EdgePosition*>(node->GetPosition());
= Handle (SMDS_EdgePosition)::DownCast(node->GetPosition());
double param = epos->GetUParameter(); double param = epos->GetUParameter();
params[param] = nodeId; params[param] = nodeId;
} }
bool isForward = (((l-f)*(last-first)) > 0); bool isForward = (((l - f) * (last - first)) > 0);
double paramin = 0; double paramin = 0;
double paramax = 0; double paramax = 0;
if (isForward) if (isForward)
@ -557,29 +538,29 @@ UVPtStruct* SMESH_Quadrangle_2D::LoadEdgePoints(SMESH_Mesh& aMesh,
paramin = f; paramin = f;
paramax = l; paramax = l;
gp_Pnt2d p = C2d->Value(f); // first point = Vertex Forward gp_Pnt2d p = C2d->Value(f); // first point = Vertex Forward
uvslf [0].x = p.X(); uvslf[0].x = p.X();
uvslf [0].y = p.Y(); uvslf[0].y = p.Y();
uvslf [0].param = f; uvslf[0].param = f;
uvslf [0].nodeId = idFirst; uvslf[0].nodeId = idFirst;
//MESSAGE("__ f "<<f<<" "<<uvslf[0].x <<" "<<uvslf[0].y); //MESSAGE("__ f "<<f<<" "<<uvslf[0].x <<" "<<uvslf[0].y);
map<double,int>::iterator itp = params.begin(); map < double, int >::iterator itp = params.begin();
for (int i = 1; i <= nbPoints; i++) // nbPoints internal for (int i = 1; i <= nbPoints; i++) // nbPoints internal
{ {
double param = (*itp).first; double param = (*itp).first;
int nodeId = (*itp).second; int nodeId = (*itp).second;
gp_Pnt2d p = C2d->Value(param); gp_Pnt2d p = C2d->Value(param);
uvslf [i].x = p.X(); uvslf[i].x = p.X();
uvslf [i].y = p.Y(); uvslf[i].y = p.Y();
uvslf[i].param = param; uvslf[i].param = param;
uvslf[i].nodeId = nodeId; uvslf[i].nodeId = nodeId;
//MESSAGE("__ "<<i<<" "<<param<<" "<<uvslf[i].x <<" "<<uvslf[i].y); //MESSAGE("__ "<<i<<" "<<param<<" "<<uvslf[i].x <<" "<<uvslf[i].y);
itp++; itp++;
} }
p = C2d->Value(l); // last point = Vertex Reversed p = C2d->Value(l); // last point = Vertex Reversed
uvslf [nbPoints+1].x = p.X(); uvslf[nbPoints + 1].x = p.X();
uvslf [nbPoints+1].y = p.Y(); uvslf[nbPoints + 1].y = p.Y();
uvslf [nbPoints+1].param = l; uvslf[nbPoints + 1].param = l;
uvslf [nbPoints+1].nodeId = idLast; uvslf[nbPoints + 1].nodeId = idLast;
//MESSAGE("__ l "<<l<<" "<<uvslf[nbPoints+1].x <<" "<<uvslf[nbPoints+1].y); //MESSAGE("__ l "<<l<<" "<<uvslf[nbPoints+1].x <<" "<<uvslf[nbPoints+1].y);
} }
else else
@ -587,37 +568,37 @@ UVPtStruct* SMESH_Quadrangle_2D::LoadEdgePoints(SMESH_Mesh& aMesh,
paramin = l; paramin = l;
paramax = f; paramax = f;
gp_Pnt2d p = C2d->Value(l); // first point = Vertex Reversed gp_Pnt2d p = C2d->Value(l); // first point = Vertex Reversed
uvslf [0].x = p.X(); uvslf[0].x = p.X();
uvslf [0].y = p.Y(); uvslf[0].y = p.Y();
uvslf [0].param = l; uvslf[0].param = l;
uvslf [0].nodeId = idLast; uvslf[0].nodeId = idLast;
//MESSAGE("__ l "<<l<<" "<<uvslf[0].x <<" "<<uvslf[0].y); //MESSAGE("__ l "<<l<<" "<<uvslf[0].x <<" "<<uvslf[0].y);
map<double,int>::reverse_iterator itp = params.rbegin(); map < double, int >::reverse_iterator itp = params.rbegin();
for (int j = nbPoints; j >= 1; j--) // nbPoints internal for (int j = nbPoints; j >= 1; j--) // nbPoints internal
{ {
double param = (*itp).first; double param = (*itp).first;
int nodeId = (*itp).second; int nodeId = (*itp).second;
int i = nbPoints +1 -j; int i = nbPoints + 1 - j;
gp_Pnt2d p = C2d->Value(param); gp_Pnt2d p = C2d->Value(param);
uvslf [i].x = p.X(); uvslf[i].x = p.X();
uvslf [i].y = p.Y(); uvslf[i].y = p.Y();
uvslf[i].param = param; uvslf[i].param = param;
uvslf[i].nodeId = nodeId; uvslf[i].nodeId = nodeId;
//MESSAGE("__ "<<i<<" "<<param<<" "<<uvslf[i].x <<" "<<uvslf[i].y); //MESSAGE("__ "<<i<<" "<<param<<" "<<uvslf[i].x <<" "<<uvslf[i].y);
itp++; itp++;
} }
p = C2d->Value(f); // last point = Vertex Forward p = C2d->Value(f); // last point = Vertex Forward
uvslf [nbPoints+1].x = p.X(); uvslf[nbPoints + 1].x = p.X();
uvslf [nbPoints+1].y = p.Y(); uvslf[nbPoints + 1].y = p.Y();
uvslf [nbPoints+1].param = f; uvslf[nbPoints + 1].param = f;
uvslf [nbPoints+1].nodeId = idFirst; uvslf[nbPoints + 1].nodeId = idFirst;
//MESSAGE("__ f "<<f<<" "<<uvslf[nbPoints+1].x <<" "<<uvslf[nbPoints+1].y); //MESSAGE("__ f "<<f<<" "<<uvslf[nbPoints+1].x <<" "<<uvslf[nbPoints+1].y);
} }
ASSERT(paramin != paramax); ASSERT(paramin != paramax);
for (int i = 0; i< nbPoints+2; i++) for (int i = 0; i < nbPoints + 2; i++)
{ {
uvslf[i].normParam = (uvslf[i].param -paramin)/(paramax -paramin); uvslf[i].normParam = (uvslf[i].param - paramin) / (paramax - paramin);
//SCRUTE(uvslf[i].normParam); //SCRUTE(uvslf[i].normParam);
} }
@ -652,7 +633,7 @@ istream & SMESH_Quadrangle_2D::LoadFrom(istream & load)
*/ */
//============================================================================= //=============================================================================
ostream & operator << (ostream & save, SMESH_Quadrangle_2D & hyp) ostream & operator <<(ostream & save, SMESH_Quadrangle_2D & hyp)
{ {
return save; return save;
} }
@ -663,7 +644,7 @@ ostream & operator << (ostream & save, SMESH_Quadrangle_2D & hyp)
*/ */
//============================================================================= //=============================================================================
istream & operator >> (istream & load, SMESH_Quadrangle_2D & hyp) istream & operator >>(istream & load, SMESH_Quadrangle_2D & hyp)
{ {
return load; return load;
} }

View File

@ -27,7 +27,7 @@
// $Header$ // $Header$
using namespace std; using namespace std;
using namespace std;
#include "SMESH_Regular_1D.hxx" #include "SMESH_Regular_1D.hxx"
#include "SMESH_Gen.hxx" #include "SMESH_Gen.hxx"
#include "SMESH_Mesh.hxx" #include "SMESH_Mesh.hxx"
@ -35,8 +35,6 @@ using namespace std;
#include "SMESH_LocalLength.hxx" #include "SMESH_LocalLength.hxx"
#include "SMESH_NumberOfSegments.hxx" #include "SMESH_NumberOfSegments.hxx"
#include "SMESHDS_ListOfPtrHypothesis.hxx"
#include "SMESHDS_ListIteratorOfListOfPtrHypothesis.hxx"
#include "SMDS_MeshElement.hxx" #include "SMDS_MeshElement.hxx"
#include "SMDS_MeshNode.hxx" #include "SMDS_MeshNode.hxx"
#include "SMDS_EdgePosition.hxx" #include "SMDS_EdgePosition.hxx"
@ -59,13 +57,13 @@ using namespace std;
*/ */
//============================================================================= //=============================================================================
SMESH_Regular_1D::SMESH_Regular_1D(int hypId, int studyId, SMESH_Gen* gen) SMESH_Regular_1D::SMESH_Regular_1D(int hypId, int studyId,
: SMESH_1D_Algo(hypId, studyId, gen) SMESH_Gen * gen):SMESH_1D_Algo(hypId, studyId, gen)
{ {
MESSAGE("SMESH_Regular_1D::SMESH_Regular_1D"); MESSAGE("SMESH_Regular_1D::SMESH_Regular_1D");
_name = "Regular_1D"; _name = "Regular_1D";
// _shapeType = TopAbs_EDGE; // _shapeType = TopAbs_EDGE;
_shapeType = (1<<TopAbs_EDGE); _shapeType = (1 << TopAbs_EDGE);
_compatibleHypothesis.push_back("LocalLength"); _compatibleHypothesis.push_back("LocalLength");
_compatibleHypothesis.push_back("NumberOfSegments"); _compatibleHypothesis.push_back("NumberOfSegments");
@ -113,7 +111,7 @@ istream & SMESH_Regular_1D::LoadFrom(istream & load)
*/ */
//============================================================================= //=============================================================================
ostream& operator << (ostream & save, SMESH_Regular_1D & hyp) ostream & operator <<(ostream & save, SMESH_Regular_1D & hyp)
{ {
return save; return save;
} }
@ -124,7 +122,7 @@ ostream& operator << (ostream & save, SMESH_Regular_1D & hyp)
*/ */
//============================================================================= //=============================================================================
istream& operator >> (istream & load, SMESH_Regular_1D & hyp) istream & operator >>(istream & load, SMESH_Regular_1D & hyp)
{ {
return load; return load;
} }
@ -135,15 +133,15 @@ istream& operator >> (istream & load, SMESH_Regular_1D & hyp)
*/ */
//============================================================================= //=============================================================================
bool SMESH_Regular_1D::CheckHypothesis(SMESH_Mesh& aMesh, bool SMESH_Regular_1D::CheckHypothesis(SMESH_Mesh & aMesh,
const TopoDS_Shape& aShape) const TopoDS_Shape & aShape)
{ {
//MESSAGE("SMESH_Regular_1D::CheckHypothesis"); //MESSAGE("SMESH_Regular_1D::CheckHypothesis");
list<SMESHDS_Hypothesis*>::const_iterator itl; list <const SMESHDS_Hypothesis * >::const_iterator itl;
SMESHDS_Hypothesis* theHyp; const SMESHDS_Hypothesis *theHyp;
const list<SMESHDS_Hypothesis*>& hyps = GetUsedHypothesis(aMesh, aShape); const list <const SMESHDS_Hypothesis * >&hyps = GetUsedHypothesis(aMesh, aShape);
int nbHyp = hyps.size(); int nbHyp = hyps.size();
if (nbHyp != 1) return false; // only one compatible hypothesis allowed if (nbHyp != 1) return false; // only one compatible hypothesis allowed
@ -158,16 +156,17 @@ bool SMESH_Regular_1D::CheckHypothesis(SMESH_Mesh& aMesh,
if (hypName == "LocalLength") if (hypName == "LocalLength")
{ {
_hypLocalLength = dynamic_cast<SMESH_LocalLength*> (theHyp); _hypLocalLength = dynamic_cast <const SMESH_LocalLength * >(theHyp);
ASSERT(_hypLocalLength); ASSERT(_hypLocalLength);
_localLength = _hypLocalLength->GetLength(); _localLength = _hypLocalLength->GetLength();
_numberOfSegments = 0; _numberOfSegments = 0;
isOk =true; isOk = true;
} }
if (hypName == "NumberOfSegments") if (hypName == "NumberOfSegments")
{ {
_hypNumberOfSegments = dynamic_cast<SMESH_NumberOfSegments*> (theHyp); _hypNumberOfSegments =
dynamic_cast <const SMESH_NumberOfSegments * >(theHyp);
ASSERT(_hypNumberOfSegments); ASSERT(_hypNumberOfSegments);
_numberOfSegments = _hypNumberOfSegments->GetNumberOfSegments(); _numberOfSegments = _hypNumberOfSegments->GetNumberOfSegments();
_scaleFactor = _hypNumberOfSegments->GetScaleFactor(); _scaleFactor = _hypNumberOfSegments->GetScaleFactor();
@ -187,19 +186,18 @@ bool SMESH_Regular_1D::CheckHypothesis(SMESH_Mesh& aMesh,
*/ */
//============================================================================= //=============================================================================
bool SMESH_Regular_1D::Compute(SMESH_Mesh& aMesh, bool SMESH_Regular_1D::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape)
const TopoDS_Shape& aShape)
{ {
//MESSAGE("SMESH_Regular_1D::Compute"); MESSAGE("SMESH_Regular_1D::Compute");
const Handle(SMESHDS_Mesh)& meshDS = aMesh.GetMeshDS(); SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
SMESH_subMesh* theSubMesh = aMesh.GetSubMesh(aShape); SMESH_subMesh *theSubMesh = aMesh.GetSubMesh(aShape);
const TopoDS_Edge& EE = TopoDS::Edge(aShape); const TopoDS_Edge & EE = TopoDS::Edge(aShape);
TopoDS_Edge E = TopoDS::Edge(EE.Oriented(TopAbs_FORWARD)); TopoDS_Edge E = TopoDS::Edge(EE.Oriented(TopAbs_FORWARD));
double f,l; double f, l;
Handle(Geom_Curve) Curve = BRep_Tool::Curve(E,f,l); Handle(Geom_Curve) Curve = BRep_Tool::Curve(E, f, l);
TopoDS_Vertex VFirst, VLast; TopoDS_Vertex VFirst, VLast;
TopExp::Vertices(E, VFirst, VLast); // Vfirst corresponds to f and Vlast to l TopExp::Vertices(E, VFirst, VLast); // Vfirst corresponds to f and Vlast to l
@ -211,34 +209,35 @@ bool SMESH_Regular_1D::Compute(SMESH_Mesh& aMesh,
// if (_localLength > 0) eltSize = _localLength; // if (_localLength > 0) eltSize = _localLength;
if (_localLength > 0) if (_localLength > 0)
{ {
double nbseg = ceil(length/_localLength); // integer sup double nbseg = ceil(length / _localLength); // integer sup
if (nbseg <=0) nbseg = 1; // degenerated edge if (nbseg <= 0)
eltSize = length/nbseg; nbseg = 1; // degenerated edge
eltSize = length / nbseg;
} }
else else
{ {
ASSERT(_numberOfSegments> 0); ASSERT(_numberOfSegments > 0);
eltSize = length/_numberOfSegments; eltSize = length / _numberOfSegments;
} }
ASSERT(!VFirst.IsNull()); ASSERT(!VFirst.IsNull());
SMESH_subMesh* firstSubMesh = aMesh.GetSubMesh(VFirst); SMESH_subMesh *firstSubMesh = aMesh.GetSubMesh(VFirst);
const TColStd_ListOfInteger& lidf const vector<int> & lidf
= firstSubMesh->GetSubMeshDS()->GetIDNodes(); = firstSubMesh->GetSubMeshDS()->GetIDNodes();
int idFirst= lidf.First(); int idFirst = lidf[0];
//SCRUTE(idFirst); //SCRUTE(idFirst);
ASSERT(!VLast.IsNull()); ASSERT(!VLast.IsNull());
SMESH_subMesh* lastSubMesh = aMesh.GetSubMesh(VLast); SMESH_subMesh *lastSubMesh = aMesh.GetSubMesh(VLast);
const TColStd_ListOfInteger& lidl const vector<int> & lidl
= lastSubMesh->GetSubMeshDS()->GetIDNodes(); = lastSubMesh->GetSubMeshDS()->GetIDNodes();
int idLast= lidl.First(); int idLast = lidl[0];
//SCRUTE(idLast); //SCRUTE(idLast);
if (!Curve.IsNull()) if (!Curve.IsNull())
{ {
GeomAdaptor_Curve C3d(Curve); GeomAdaptor_Curve C3d(Curve);
GCPnts_UniformAbscissa Discret(C3d,eltSize,f,l); GCPnts_UniformAbscissa Discret(C3d, eltSize, f, l);
int NbPoints = Discret.NbPoints(); int NbPoints = Discret.NbPoints();
//MESSAGE("nb points on edge : "<<NbPoints); //MESSAGE("nb points on edge : "<<NbPoints);
@ -246,17 +245,20 @@ bool SMESH_Regular_1D::Compute(SMESH_Mesh& aMesh,
// only internal nodes receive an edge position with param on curve // only internal nodes receive an edge position with param on curve
int idPrev = idFirst; int idPrev = idFirst;
for (int i=2; i<NbPoints; i++) for (int i = 2; i < NbPoints; i++)
{ {
double param = Discret.Parameter(i); double param = Discret.Parameter(i);
if(_numberOfSegments > 1) if (_numberOfSegments > 1)
{ {
double epsilon = 0.001; double epsilon = 0.001;
if( fabs(_scaleFactor-1.0) > epsilon ) if (fabs(_scaleFactor - 1.0) > epsilon)
{ {
double alpha = pow(_scaleFactor, 1.0/(_numberOfSegments-1) ); double alpha =
double d = length*(1-pow(alpha,i-1))/(1-pow(alpha,_numberOfSegments)); pow(_scaleFactor, 1.0 / (_numberOfSegments - 1));
double d =
length * (1 - pow(alpha, i - 1)) / (1 - pow(alpha,
_numberOfSegments));
param = d; param = d;
} }
} }
@ -264,28 +266,20 @@ bool SMESH_Regular_1D::Compute(SMESH_Mesh& aMesh,
gp_Pnt P = Curve->Value(param); gp_Pnt P = Curve->Value(param);
//Add the Node in the DataStructure //Add the Node in the DataStructure
int nodeId = meshDS->AddNode(P.X(), P.Y(), P.Z());
//MESSAGE("point "<<nodeId<<" "<<P.X()<<" "<<P.Y()<<" "<<P.Z()<<" - "<<i<<" "<<param); //MESSAGE("point "<<nodeId<<" "<<P.X()<<" "<<P.Y()<<" "<<P.Z()<<" - "<<i<<" "<<param);
Handle (SMDS_MeshElement) elt = meshDS->FindNode(nodeId); SMDS_MeshNode * node = meshDS->AddNode(P.X(), P.Y(), P.Z());
Handle (SMDS_MeshNode) node = meshDS->GetNode(1, elt);
meshDS->SetNodeOnEdge(node, E); meshDS->SetNodeOnEdge(node, E);
// **** edgePosition associe au point = param. // **** edgePosition associe au point = param.
// Handle (SMDS_EdgePosition) epos SMDS_EdgePosition* epos=dynamic_cast<SMDS_EdgePosition *>(node->GetPosition());
// = new SMDS_EdgePosition(theSubMesh->GetId(),param); // non, deja cree
// node->SetPosition(epos);
Handle (SMDS_EdgePosition) epos
= Handle (SMDS_EdgePosition)::DownCast(node->GetPosition());
epos->SetUParameter(param); epos->SetUParameter(param);
int edgeId = meshDS->AddEdge(idPrev, nodeId); SMDS_MeshEdge * edge = meshDS->AddEdge(idPrev, node->GetID());
elt = meshDS->FindElement(edgeId); meshDS->SetMeshElementOnShape(edge, E);
meshDS->SetMeshElementOnShape(elt, E); idPrev = node->GetID();
idPrev = nodeId;
} }
int edgeId = meshDS->AddEdge(idPrev, idLast); SMDS_MeshEdge* edge = meshDS->AddEdge(idPrev, idLast);
Handle (SMDS_MeshElement) elt = meshDS->FindElement(edgeId); meshDS->SetMeshElementOnShape(edge, E);
meshDS->SetMeshElementOnShape(elt, E);
} }
else else
{ {
@ -295,43 +289,37 @@ bool SMESH_Regular_1D::Compute(SMESH_Mesh& aMesh,
{ {
// Edge is a degenerated Edge : We put n = 5 points on the edge. // Edge is a degenerated Edge : We put n = 5 points on the edge.
int NbPoints = 5; int NbPoints = 5;
BRep_Tool::Range(E,f,l); BRep_Tool::Range(E, f, l);
double du = (l-f)/(NbPoints-1); double du = (l - f) / (NbPoints - 1);
MESSAGE("************* Degenerated edge! *****************"); MESSAGE("************* Degenerated edge! *****************");
TopoDS_Vertex V1,V2; TopoDS_Vertex V1, V2;
TopExp::Vertices (E,V1,V2); TopExp::Vertices(E, V1, V2);
gp_Pnt P = BRep_Tool::Pnt(V1); gp_Pnt P = BRep_Tool::Pnt(V1);
int idPrev = idFirst; int idPrev = idFirst;
for (int i=2; i<NbPoints; i++) for (int i = 2; i < NbPoints; i++)
{ {
double param = f + (i-1)*du; double param = f + (i - 1) * du;
//Add the Node in the DataStructure SMDS_MeshNode * node = meshDS->AddNode(P.X(), P.Y(), P.Z());
int nodeId = meshDS->AddNode(P.X(), P.Y(), P.Z());
//MESSAGE("point "<<nodeId<<" "<<P.X()<<" "<<P.Y()<<" "<<P.Z()<<" - "<<i<<" "<<param);
Handle (SMDS_MeshElement) elt = meshDS->FindNode(nodeId);
Handle (SMDS_MeshNode) node = meshDS->GetNode(1, elt);
meshDS->SetNodeOnEdge(node, E); meshDS->SetNodeOnEdge(node, E);
// Handle (SMDS_EdgePosition) epos // Handle (SMDS_EdgePosition) epos
// = new SMDS_EdgePosition(theSubMesh->GetId(),param); // = new SMDS_EdgePosition(theSubMesh->GetId(),param);
// node->SetPosition(epos); // node->SetPosition(epos);
Handle (SMDS_EdgePosition) epos SMDS_EdgePosition* epos
= Handle (SMDS_EdgePosition)::DownCast(node->GetPosition()); = dynamic_cast<SMDS_EdgePosition*>(node->GetPosition());
epos->SetUParameter(param); epos->SetUParameter(param);
int edgeId = meshDS->AddEdge(idPrev, nodeId); SMDS_MeshEdge * edge = meshDS->AddEdge(idPrev, node->GetID());
elt = meshDS->FindElement(edgeId); meshDS->SetMeshElementOnShape(edge, E);
meshDS->SetMeshElementOnShape(elt, E); idPrev = node->GetID();
idPrev = nodeId;
} }
int edgeId = meshDS->AddEdge(idPrev, idLast); SMDS_MeshEdge * edge = meshDS->AddEdge(idPrev, idLast);
Handle (SMDS_MeshElement) elt = meshDS->FindElement(edgeId); meshDS->SetMeshElementOnShape(edge, E);
meshDS->SetMeshElementOnShape(elt, E);
} }
else ASSERT(0); else
ASSERT(0);
} }
return true; return true;
} }

View File

@ -47,9 +47,7 @@ using namespace std;
*/ */
//============================================================================= //=============================================================================
SMESH_subMesh::SMESH_subMesh(int Id, SMESH_subMesh::SMESH_subMesh(int Id, SMESH_Mesh * father, SMESHDS_Mesh * meshDS,
SMESH_Mesh* father,
const Handle(SMESHDS_Mesh)& meshDS,
const TopoDS_Shape & aSubShape) const TopoDS_Shape & aSubShape)
{ {
//MESSAGE("SMESH_subMesh::SMESH_subMesh"); //MESSAGE("SMESH_subMesh::SMESH_subMesh");
@ -178,15 +176,14 @@ int SMESH_subMesh::GetId()
*/ */
//============================================================================= //=============================================================================
const Handle(SMESHDS_SubMesh)& SMESH_subMesh::GetSubMeshDS() SMESHDS_SubMesh * SMESH_subMesh::GetSubMeshDS() throw(SALOME_Exception)
throw (SALOME_Exception)
{ {
//MESSAGE("SMESH_subMesh::GetSubMeshDS"); //MESSAGE("SMESH_subMesh::GetSubMeshDS");
if (_subMeshDS.IsNull()) if (_subMeshDS==NULL)
{ {
//MESSAGE("subMesh pointer still null, trying to get it..."); //MESSAGE("subMesh pointer still null, trying to get it...");
_subMeshDS = _meshDS->MeshElements(_subShape); // may be null ... _subMeshDS = _meshDS->MeshElements(_subShape); // may be null ...
if (_subMeshDS.IsNull()) if (_subMeshDS==NULL)
{ {
MESSAGE("problem... subMesh still empty"); MESSAGE("problem... subMesh still empty");
//NRI ASSERT(0); //NRI ASSERT(0);
@ -202,17 +199,16 @@ const Handle(SMESHDS_SubMesh)& SMESH_subMesh::GetSubMeshDS()
*/ */
//============================================================================= //=============================================================================
SMESH_subMesh* SMESH_subMesh::GetFirstToCompute() SMESH_subMesh *SMESH_subMesh::GetFirstToCompute() throw(SALOME_Exception)
throw (SALOME_Exception)
{ {
//MESSAGE("SMESH_subMesh::GetFirstToCompute"); //MESSAGE("SMESH_subMesh::GetFirstToCompute");
const map<int, SMESH_subMesh*>& subMeshes = DependsOn(); const map < int, SMESH_subMesh * >&subMeshes = DependsOn();
SMESH_subMesh* firstToCompute = 0; SMESH_subMesh *firstToCompute = 0;
map<int, SMESH_subMesh*>::const_iterator itsub; map < int, SMESH_subMesh * >::const_iterator itsub;
for (itsub = subMeshes.begin(); itsub != subMeshes.end(); itsub++) for (itsub = subMeshes.begin(); itsub != subMeshes.end(); itsub++)
{ {
SMESH_subMesh* sm = (*itsub).second; SMESH_subMesh *sm = (*itsub).second;
// SCRUTE(sm->GetId()); // SCRUTE(sm->GetId());
// SCRUTE(sm->GetComputeState()); // SCRUTE(sm->GetComputeState());
bool readyToCompute = (sm->GetComputeState() == READY_TO_COMPUTE); bool readyToCompute = (sm->GetComputeState() == READY_TO_COMPUTE);
@ -243,21 +239,20 @@ SMESH_subMesh* SMESH_subMesh::GetFirstToCompute()
*/ */
//============================================================================= //=============================================================================
bool SMESH_subMesh::SubMeshesComputed() bool SMESH_subMesh::SubMeshesComputed() throw(SALOME_Exception)
throw (SALOME_Exception)
{ {
//MESSAGE("SMESH_subMesh::SubMeshesComputed"); //MESSAGE("SMESH_subMesh::SubMeshesComputed");
const map<int, SMESH_subMesh*>& subMeshes = DependsOn(); const map < int, SMESH_subMesh * >&subMeshes = DependsOn();
bool subMeshesComputed = true; bool subMeshesComputed = true;
map<int, SMESH_subMesh*>::const_iterator itsub; map < int, SMESH_subMesh * >::const_iterator itsub;
for (itsub = subMeshes.begin(); itsub != subMeshes.end(); itsub++) for (itsub = subMeshes.begin(); itsub != subMeshes.end(); itsub++)
{ {
SMESH_subMesh* sm = (*itsub).second; SMESH_subMesh *sm = (*itsub).second;
// SCRUTE(sm->GetId()); // SCRUTE(sm->GetId());
// SCRUTE(sm->GetComputeState()); // SCRUTE(sm->GetComputeState());
bool computeOk = (sm->GetComputeState() == COMPUTE_OK); bool computeOk = (sm->GetComputeState() == COMPUTE_OK);
if (! computeOk) if (!computeOk)
{ {
subMeshesComputed = false; subMeshesComputed = false;
SCRUTE(sm->GetId()); SCRUTE(sm->GetId());
@ -276,18 +271,18 @@ bool SMESH_subMesh::SubMeshesComputed()
bool SMESH_subMesh::SubMeshesReady() bool SMESH_subMesh::SubMeshesReady()
{ {
MESSAGE("SMESH_subMesh::SubMeshesReady"); MESSAGE("SMESH_subMesh::SubMeshesReady");
const map<int, SMESH_subMesh*>& subMeshes = DependsOn(); const map < int, SMESH_subMesh * >&subMeshes = DependsOn();
bool subMeshesReady = true; bool subMeshesReady = true;
map<int, SMESH_subMesh*>::const_iterator itsub; map < int, SMESH_subMesh * >::const_iterator itsub;
for (itsub = subMeshes.begin(); itsub != subMeshes.end(); itsub++) for (itsub = subMeshes.begin(); itsub != subMeshes.end(); itsub++)
{ {
SMESH_subMesh* sm = (*itsub).second; SMESH_subMesh *sm = (*itsub).second;
// SCRUTE(sm->GetId()); // SCRUTE(sm->GetId());
// SCRUTE(sm->GetComputeState()); // SCRUTE(sm->GetComputeState());
bool computeOk = ( (sm->GetComputeState() == COMPUTE_OK) bool computeOk = ((sm->GetComputeState() == COMPUTE_OK)
|| (sm->GetComputeState() == READY_TO_COMPUTE)) ; || (sm->GetComputeState() == READY_TO_COMPUTE));
if (! computeOk) if (!computeOk)
{ {
subMeshesReady = false; subMeshesReady = false;
SCRUTE(sm->GetId()); SCRUTE(sm->GetId());
@ -309,9 +304,10 @@ bool SMESH_subMesh::SubMeshesReady()
*/ */
//============================================================================= //=============================================================================
const map<int, SMESH_subMesh*>& SMESH_subMesh::DependsOn() const map < int, SMESH_subMesh * >&SMESH_subMesh::DependsOn()
{ {
if (_dependenceAnalysed) return _mapDepend; if (_dependenceAnalysed)
return _mapDepend;
//MESSAGE("SMESH_subMesh::DependsOn"); //MESSAGE("SMESH_subMesh::DependsOn");
@ -322,19 +318,21 @@ const map<int, SMESH_subMesh*>& SMESH_subMesh::DependsOn()
case TopAbs_COMPOUND: case TopAbs_COMPOUND:
{ {
//MESSAGE("compound"); //MESSAGE("compound");
list<TopoDS_Shape> shellInSolid; list < TopoDS_Shape > shellInSolid;
for (TopExp_Explorer exp(_subShape,TopAbs_SOLID);exp.More();exp.Next()) for (TopExp_Explorer exp(_subShape, TopAbs_SOLID); exp.More();
exp.Next())
{ {
InsertDependence(exp.Current()); InsertDependence(exp.Current());
for (TopExp_Explorer for (TopExp_Explorer
exp2(exp.Current(),TopAbs_SHELL);exp2.More();exp2.Next()) exp2(exp.Current(), TopAbs_SHELL); exp2.More(); exp2.Next())
{ {
shellInSolid.push_back(exp2.Current()); shellInSolid.push_back(exp2.Current());
} }
} }
for (TopExp_Explorer exp(_subShape,TopAbs_SHELL);exp.More();exp.Next()) for (TopExp_Explorer exp(_subShape, TopAbs_SHELL); exp.More();
exp.Next())
{ {
list<TopoDS_Shape>::iterator it1; list < TopoDS_Shape >::iterator it1;
bool isInSolid = false; bool isInSolid = false;
for (it1 = shellInSolid.begin(); it1 != shellInSolid.end(); it1++) for (it1 = shellInSolid.begin(); it1 != shellInSolid.end(); it1++)
{ {
@ -348,11 +346,13 @@ const map<int, SMESH_subMesh*>& SMESH_subMesh::DependsOn()
if (!isInSolid) if (!isInSolid)
InsertDependence(exp.Current()); //only shell not in solid InsertDependence(exp.Current()); //only shell not in solid
} }
for (TopExp_Explorer exp(_subShape,TopAbs_FACE);exp.More();exp.Next()) for (TopExp_Explorer exp(_subShape, TopAbs_FACE); exp.More();
exp.Next())
{ {
InsertDependence(exp.Current()); InsertDependence(exp.Current());
} }
for (TopExp_Explorer exp(_subShape,TopAbs_EDGE);exp.More();exp.Next()) for (TopExp_Explorer exp(_subShape, TopAbs_EDGE); exp.More();
exp.Next())
{ {
InsertDependence(exp.Current()); InsertDependence(exp.Current());
} }
@ -361,7 +361,8 @@ const map<int, SMESH_subMesh*>& SMESH_subMesh::DependsOn()
case TopAbs_COMPSOLID: case TopAbs_COMPSOLID:
{ {
//MESSAGE("compsolid"); //MESSAGE("compsolid");
for (TopExp_Explorer exp(_subShape,TopAbs_SOLID);exp.More();exp.Next()) for (TopExp_Explorer exp(_subShape, TopAbs_SOLID); exp.More();
exp.Next())
{ {
InsertDependence(exp.Current()); InsertDependence(exp.Current());
} }
@ -380,7 +381,8 @@ const map<int, SMESH_subMesh*>& SMESH_subMesh::DependsOn()
case TopAbs_SHELL: case TopAbs_SHELL:
{ {
//MESSAGE("shell"); //MESSAGE("shell");
for (TopExp_Explorer exp(_subShape,TopAbs_FACE);exp.More();exp.Next()) for (TopExp_Explorer exp(_subShape, TopAbs_FACE); exp.More();
exp.Next())
{ {
InsertDependence(exp.Current()); InsertDependence(exp.Current());
} }
@ -399,7 +401,8 @@ const map<int, SMESH_subMesh*>& SMESH_subMesh::DependsOn()
case TopAbs_WIRE: case TopAbs_WIRE:
{ {
//MESSAGE("wire"); //MESSAGE("wire");
for (TopExp_Explorer exp(_subShape,TopAbs_EDGE);exp.More();exp.Next()) for (TopExp_Explorer exp(_subShape, TopAbs_EDGE); exp.More();
exp.Next())
{ {
InsertDependence(exp.Current()); InsertDependence(exp.Current());
} }
@ -422,7 +425,8 @@ const map<int, SMESH_subMesh*>& SMESH_subMesh::DependsOn()
// { // {
// InsertDependence(exp.Current()); // InsertDependence(exp.Current());
// } // }
for (TopExp_Explorer exp(_subShape,TopAbs_FACE);exp.More();exp.Next()) for (TopExp_Explorer exp(_subShape, TopAbs_FACE); exp.More();
exp.Next())
{ {
InsertDependence(exp.Current()); InsertDependence(exp.Current());
} }
@ -435,7 +439,8 @@ const map<int, SMESH_subMesh*>& SMESH_subMesh::DependsOn()
// { // {
// InsertDependence(exp.Current()); // InsertDependence(exp.Current());
// } // }
for (TopExp_Explorer exp(_subShape,TopAbs_EDGE);exp.More();exp.Next()) for (TopExp_Explorer exp(_subShape, TopAbs_EDGE); exp.More();
exp.Next())
{ {
InsertDependence(exp.Current()); InsertDependence(exp.Current());
} }
@ -444,7 +449,8 @@ const map<int, SMESH_subMesh*>& SMESH_subMesh::DependsOn()
case TopAbs_EDGE: case TopAbs_EDGE:
{ {
//MESSAGE("edge"); //MESSAGE("edge");
for (TopExp_Explorer exp(_subShape,TopAbs_VERTEX);exp.More();exp.Next()) for (TopExp_Explorer exp(_subShape, TopAbs_VERTEX); exp.More();
exp.Next())
{ {
InsertDependence(exp.Current()); InsertDependence(exp.Current());
} }
@ -476,7 +482,7 @@ void SMESH_subMesh::InsertDependence(const TopoDS_Shape aSubShape)
//SCRUTE(aSubMesh); //SCRUTE(aSubMesh);
//if (! aSubMesh) aSubMesh = _father->GetSubMesh(aSubShape); //if (! aSubMesh) aSubMesh = _father->GetSubMesh(aSubShape);
SMESH_subMesh* aSubMesh = _father->GetSubMesh(aSubShape); SMESH_subMesh *aSubMesh = _father->GetSubMesh(aSubShape);
int type = aSubShape.ShapeType(); int type = aSubShape.ShapeType();
int ordType = 9 - type; // 2 = Vertex, 8 = CompSolid int ordType = 9 - type; // 2 = Vertex, 8 = CompSolid
int cle = aSubMesh->GetId(); int cle = aSubMesh->GetId();
@ -484,12 +490,12 @@ void SMESH_subMesh::InsertDependence(const TopoDS_Shape aSubShape)
if (_mapDepend.find(cle) == _mapDepend.end()) if (_mapDepend.find(cle) == _mapDepend.end())
{ {
_mapDepend[cle] = aSubMesh; _mapDepend[cle] = aSubMesh;
const map<int, SMESH_subMesh*>& subMap = aSubMesh->DependsOn(); const map < int, SMESH_subMesh * >&subMap = aSubMesh->DependsOn();
map<int, SMESH_subMesh*>::const_iterator im; map < int, SMESH_subMesh * >::const_iterator im;
for (im = subMap.begin(); im != subMap.end(); im++) for (im = subMap.begin(); im != subMap.end(); im++)
{ {
int clesub = (*im).first; int clesub = (*im).first;
SMESH_subMesh* sm = (*im).second; SMESH_subMesh *sm = (*im).second;
if (_mapDepend.find(clesub) == _mapDepend.end()) if (_mapDepend.find(clesub) == _mapDepend.end())
_mapDepend[clesub] = sm; _mapDepend[clesub] = sm;
} }
@ -528,7 +534,7 @@ void SMESH_subMesh::InsertDependence(const TopoDS_Shape aSubShape)
*/ */
//============================================================================= //=============================================================================
const TopoDS_Shape& SMESH_subMesh::GetSubShape() const TopoDS_Shape & SMESH_subMesh::GetSubShape()
{ {
//MESSAGE("SMESH_subMesh::GetSubShape"); //MESSAGE("SMESH_subMesh::GetSubShape");
return _subShape; return _subShape;
@ -540,8 +546,8 @@ void SMESH_subMesh::InsertDependence(const TopoDS_Shape aSubShape)
*/ */
//============================================================================= //=============================================================================
bool SMESH_subMesh::AlgoStateEngine(int event, SMESH_Hypothesis* anHyp) bool SMESH_subMesh::AlgoStateEngine(int event, SMESH_Hypothesis * anHyp)
throw (SALOME_Exception) throw(SALOME_Exception)
{ {
// MESSAGE("SMESH_subMesh::AlgoStateEngine"); // MESSAGE("SMESH_subMesh::AlgoStateEngine");
//SCRUTE(_algoState); //SCRUTE(_algoState);
@ -559,7 +565,7 @@ bool SMESH_subMesh::AlgoStateEngine(int event, SMESH_Hypothesis* anHyp)
return true; return true;
} }
SMESH_Gen* gen =_father->GetGen(); SMESH_Gen *gen = _father->GetGen();
bool ret; bool ret;
_oldAlgoState = _algoState; _oldAlgoState = _algoState;
bool modifiedHyp = false; // if set to true, force event MODIF_ALGO_STATE bool modifiedHyp = false; // if set to true, force event MODIF_ALGO_STATE
@ -584,13 +590,16 @@ bool SMESH_subMesh::AlgoStateEngine(int event, SMESH_Hypothesis* anHyp)
ret = _meshDS->AddHypothesis(_subShape, anHyp); ret = _meshDS->AddHypothesis(_subShape, anHyp);
// if (ret &&(anHyp->GetDim() == SMESH_Gen::GetShapeDim(_subShape))) // if (ret &&(anHyp->GetDim() == SMESH_Gen::GetShapeDim(_subShape)))
// if (ret &&(anHyp->GetShapeType() == _subShape.ShapeType())) // if (ret &&(anHyp->GetShapeType() == _subShape.ShapeType()))
if (ret &&(anHyp->GetShapeType() & (1<< _subShape.ShapeType()))) if (ret &&
(anHyp->GetShapeType() & (1 << _subShape.ShapeType())))
{ {
SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape); SMESH_Algo *algo = gen->GetAlgo((*_father), _subShape);
ASSERT(algo); ASSERT(algo);
ret = algo->CheckHypothesis((*_father),_subShape); ret = algo->CheckHypothesis((*_father), _subShape);
if (ret) SetAlgoState(HYP_OK); if (ret)
else SetAlgoState(MISSING_HYP); SetAlgoState(HYP_OK);
else
SetAlgoState(MISSING_HYP);
} }
} }
break; break;
@ -608,13 +617,15 @@ bool SMESH_subMesh::AlgoStateEngine(int event, SMESH_Hypothesis* anHyp)
ASSERT(anHyp->GetType() != SMESHDS_Hypothesis::PARAM_ALGO); ASSERT(anHyp->GetType() != SMESHDS_Hypothesis::PARAM_ALGO);
// if (anHyp->GetDim() == SMESH_Gen::GetShapeDim(_subShape)) // if (anHyp->GetDim() == SMESH_Gen::GetShapeDim(_subShape))
// if (anHyp->GetShapeType() == _subShape.ShapeType()) // if (anHyp->GetShapeType() == _subShape.ShapeType())
if (anHyp->GetShapeType() & (1<< _subShape.ShapeType())) if (anHyp->GetShapeType() & (1 << _subShape.ShapeType()))
{ {
SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape); SMESH_Algo *algo = gen->GetAlgo((*_father), _subShape);
ASSERT(algo); ASSERT(algo);
ret = algo->CheckHypothesis((*_father),_subShape); ret = algo->CheckHypothesis((*_father), _subShape);
if (ret) SetAlgoState(HYP_OK); if (ret)
else SetAlgoState(MISSING_HYP); SetAlgoState(HYP_OK);
else
SetAlgoState(MISSING_HYP);
} }
break; break;
case REMOVE_FATHER_HYP: // nothing to do case REMOVE_FATHER_HYP: // nothing to do
@ -637,11 +648,13 @@ bool SMESH_subMesh::AlgoStateEngine(int event, SMESH_Hypothesis* anHyp)
ret = _meshDS->AddHypothesis(_subShape, anHyp); ret = _meshDS->AddHypothesis(_subShape, anHyp);
if (ret) if (ret)
{ {
SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape); SMESH_Algo *algo = gen->GetAlgo((*_father), _subShape);
ASSERT(algo); ASSERT(algo);
ret = algo->CheckHypothesis((*_father),_subShape); ret = algo->CheckHypothesis((*_father), _subShape);
if (ret) SetAlgoState(HYP_OK); if (ret)
else SetAlgoState(MISSING_HYP); SetAlgoState(HYP_OK);
else
SetAlgoState(MISSING_HYP);
} }
break; break;
case ADD_ALGO: //already existing algo : on father ? case ADD_ALGO: //already existing algo : on father ?
@ -651,9 +664,10 @@ bool SMESH_subMesh::AlgoStateEngine(int event, SMESH_Hypothesis* anHyp)
ret = _meshDS->AddHypothesis(_subShape, anHyp); ret = _meshDS->AddHypothesis(_subShape, anHyp);
// if (ret &&(anHyp->GetDim() == SMESH_Gen::GetShapeDim(_subShape))) // if (ret &&(anHyp->GetDim() == SMESH_Gen::GetShapeDim(_subShape)))
// if (ret &&(anHyp->GetShapeType() == _subShape.ShapeType())) // if (ret &&(anHyp->GetShapeType() == _subShape.ShapeType()))
if (ret &&(anHyp->GetShapeType() & (1<< _subShape.ShapeType()))) if (ret &&
(anHyp->GetShapeType() & (1 << _subShape.ShapeType())))
{ {
SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape); SMESH_Algo *algo = gen->GetAlgo((*_father), _subShape);
if (algo == NULL) // two algo on the same subShape... if (algo == NULL) // two algo on the same subShape...
{ {
MESSAGE("two algo on the same subshape not allowed"); MESSAGE("two algo on the same subshape not allowed");
@ -662,9 +676,11 @@ bool SMESH_subMesh::AlgoStateEngine(int event, SMESH_Hypothesis* anHyp)
} }
else else
{ {
ret = algo->CheckHypothesis((*_father),_subShape); ret = algo->CheckHypothesis((*_father), _subShape);
if (ret) SetAlgoState(HYP_OK); if (ret)
else SetAlgoState(MISSING_HYP); SetAlgoState(HYP_OK);
else
SetAlgoState(MISSING_HYP);
} }
} }
} }
@ -678,38 +694,42 @@ bool SMESH_subMesh::AlgoStateEngine(int event, SMESH_Hypothesis* anHyp)
ret = _meshDS->RemoveHypothesis(_subShape, anHyp); ret = _meshDS->RemoveHypothesis(_subShape, anHyp);
// if (ret &&(anHyp->GetDim() == SMESH_Gen::GetShapeDim(_subShape))) // if (ret &&(anHyp->GetDim() == SMESH_Gen::GetShapeDim(_subShape)))
// if (ret &&(anHyp->GetShapeType() == _subShape.ShapeType())) // if (ret &&(anHyp->GetShapeType() == _subShape.ShapeType()))
if (ret &&(anHyp->GetShapeType() & (1<<_subShape.ShapeType()))) if (ret && (anHyp->GetShapeType() & (1 << _subShape.ShapeType())))
{ {
SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape); SMESH_Algo *algo = gen->GetAlgo((*_father), _subShape);
if (algo == NULL) // no more algo applying on subShape... if (algo == NULL) // no more algo applying on subShape...
{ {
SetAlgoState(NO_ALGO); SetAlgoState(NO_ALGO);
} }
else else
{ {
ret = algo->CheckHypothesis((*_father),_subShape); ret = algo->CheckHypothesis((*_father), _subShape);
if (ret) SetAlgoState(HYP_OK); if (ret)
else SetAlgoState(MISSING_HYP); SetAlgoState(HYP_OK);
else
SetAlgoState(MISSING_HYP);
} }
} }
break; break;
case ADD_FATHER_HYP: case ADD_FATHER_HYP:
ASSERT(anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO); ASSERT(anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO);
{ {
SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape); SMESH_Algo *algo = gen->GetAlgo((*_father), _subShape);
ASSERT(algo); ASSERT(algo);
ret = algo->CheckHypothesis((*_father),_subShape); ret = algo->CheckHypothesis((*_father), _subShape);
if (ret) SetAlgoState(HYP_OK); if (ret)
else SetAlgoState(MISSING_HYP); SetAlgoState(HYP_OK);
else
SetAlgoState(MISSING_HYP);
} }
break; break;
case ADD_FATHER_ALGO: // detect if two algo of same dim on father case ADD_FATHER_ALGO: // detect if two algo of same dim on father
ASSERT(anHyp->GetType() != SMESHDS_Hypothesis::PARAM_ALGO); ASSERT(anHyp->GetType() != SMESHDS_Hypothesis::PARAM_ALGO);
// if (anHyp->GetDim() == SMESH_Gen::GetShapeDim(_subShape)) // if (anHyp->GetDim() == SMESH_Gen::GetShapeDim(_subShape))
// if (anHyp->GetShapeType() == _subShape.ShapeType()) // if (anHyp->GetShapeType() == _subShape.ShapeType())
if (anHyp->GetShapeType() & (1<< _subShape.ShapeType())) if (anHyp->GetShapeType() & (1 << _subShape.ShapeType()))
{ {
SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape); SMESH_Algo *algo = gen->GetAlgo((*_father), _subShape);
if (algo == NULL) // two applying algo on father if (algo == NULL) // two applying algo on father
{ {
MESSAGE("two applying algo on fatherShape..."); MESSAGE("two applying algo on fatherShape...");
@ -717,9 +737,11 @@ bool SMESH_subMesh::AlgoStateEngine(int event, SMESH_Hypothesis* anHyp)
} }
else else
{ {
ret = algo->CheckHypothesis((*_father),_subShape); ret = algo->CheckHypothesis((*_father), _subShape);
if (ret) SetAlgoState(HYP_OK); if (ret)
else SetAlgoState(MISSING_HYP); SetAlgoState(HYP_OK);
else
SetAlgoState(MISSING_HYP);
} }
} }
break; break;
@ -729,18 +751,20 @@ bool SMESH_subMesh::AlgoStateEngine(int event, SMESH_Hypothesis* anHyp)
ASSERT(anHyp->GetType() != SMESHDS_Hypothesis::PARAM_ALGO); ASSERT(anHyp->GetType() != SMESHDS_Hypothesis::PARAM_ALGO);
// if (anHyp->GetDim() == SMESH_Gen::GetShapeDim(_subShape)) // if (anHyp->GetDim() == SMESH_Gen::GetShapeDim(_subShape))
// if (anHyp->GetShapeType() == _subShape.ShapeType()) // if (anHyp->GetShapeType() == _subShape.ShapeType())
if (anHyp->GetShapeType() & (1<< _subShape.ShapeType())) if (anHyp->GetShapeType() & (1 << _subShape.ShapeType()))
{ {
SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape); SMESH_Algo *algo = gen->GetAlgo((*_father), _subShape);
if (algo == NULL) // no more applying algo on father if (algo == NULL) // no more applying algo on father
{ {
SetAlgoState(NO_ALGO); SetAlgoState(NO_ALGO);
} }
else else
{ {
ret = algo->CheckHypothesis((*_father),_subShape); ret = algo->CheckHypothesis((*_father), _subShape);
if (ret) SetAlgoState(HYP_OK); if (ret)
else SetAlgoState(MISSING_HYP); SetAlgoState(HYP_OK);
else
SetAlgoState(MISSING_HYP);
} }
} }
break; break;
@ -758,16 +782,15 @@ bool SMESH_subMesh::AlgoStateEngine(int event, SMESH_Hypothesis* anHyp)
case ADD_HYP: case ADD_HYP:
{ {
ASSERT(anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO); ASSERT(anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO);
SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape); SMESH_Algo *algo = gen->GetAlgo((*_father), _subShape);
ASSERT(algo); ASSERT(algo);
list<SMESHDS_Hypothesis*> originalUsedHyps list<const SMESHDS_Hypothesis *> originalUsedHyps = algo->GetUsedHypothesis((*_father), _subShape); // copy
= algo->GetUsedHypothesis((*_father), _subShape); // copy
ret = _meshDS->AddHypothesis(_subShape, anHyp); ret = _meshDS->AddHypothesis(_subShape, anHyp);
if (ret) if (ret)
{ {
ret = algo->CheckHypothesis((*_father),_subShape); ret = algo->CheckHypothesis((*_father), _subShape);
if (! ret) if (!ret)
{ {
INFOS("two applying algo on the same shape not allowed"); INFOS("two applying algo on the same shape not allowed");
ret = _meshDS->RemoveHypothesis(_subShape, anHyp); ret = _meshDS->RemoveHypothesis(_subShape, anHyp);
@ -776,7 +799,7 @@ bool SMESH_subMesh::AlgoStateEngine(int event, SMESH_Hypothesis* anHyp)
else // compare SMESHDS_Hypothesis* lists (order important) else // compare SMESHDS_Hypothesis* lists (order important)
{ {
MESSAGE("---"); MESSAGE("---");
const list<SMESHDS_Hypothesis*>& newUsedHyps const list <const SMESHDS_Hypothesis *> & newUsedHyps
= algo->GetUsedHypothesis((*_father), _subShape); = algo->GetUsedHypothesis((*_father), _subShape);
modifiedHyp = (originalUsedHyps != newUsedHyps); modifiedHyp = (originalUsedHyps != newUsedHyps);
} }
@ -790,9 +813,10 @@ bool SMESH_subMesh::AlgoStateEngine(int event, SMESH_Hypothesis* anHyp)
ret = _meshDS->AddHypothesis(_subShape, anHyp); ret = _meshDS->AddHypothesis(_subShape, anHyp);
// if (ret &&(anHyp->GetDim() == SMESH_Gen::GetShapeDim(_subShape))) // if (ret &&(anHyp->GetDim() == SMESH_Gen::GetShapeDim(_subShape)))
// if (ret &&(anHyp->GetShapeType() == _subShape.ShapeType())) // if (ret &&(anHyp->GetShapeType() == _subShape.ShapeType()))
if (ret &&(anHyp->GetShapeType() & (1<< _subShape.ShapeType()))) if (ret &&
(anHyp->GetShapeType() & (1 << _subShape.ShapeType())))
{ {
SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape); SMESH_Algo *algo = gen->GetAlgo((*_father), _subShape);
if (algo == NULL) // two algo on the same subShape... if (algo == NULL) // two algo on the same subShape...
{ {
INFOS("two algo on the same subshape not allowed"); INFOS("two algo on the same subshape not allowed");
@ -801,9 +825,11 @@ bool SMESH_subMesh::AlgoStateEngine(int event, SMESH_Hypothesis* anHyp)
} }
else else
{ {
ret = algo->CheckHypothesis((*_father),_subShape); ret = algo->CheckHypothesis((*_father), _subShape);
if (ret) SetAlgoState(HYP_OK); if (ret)
else SetAlgoState(MISSING_HYP); SetAlgoState(HYP_OK);
else
SetAlgoState(MISSING_HYP);
} }
} }
} }
@ -813,11 +839,13 @@ bool SMESH_subMesh::AlgoStateEngine(int event, SMESH_Hypothesis* anHyp)
ret = _meshDS->RemoveHypothesis(_subShape, anHyp); ret = _meshDS->RemoveHypothesis(_subShape, anHyp);
if (ret) if (ret)
{ {
SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape); SMESH_Algo *algo = gen->GetAlgo((*_father), _subShape);
ASSERT(algo); ASSERT(algo);
ret = algo->CheckHypothesis((*_father),_subShape); ret = algo->CheckHypothesis((*_father), _subShape);
if (ret) SetAlgoState(HYP_OK); if (ret)
else SetAlgoState(MISSING_HYP); SetAlgoState(HYP_OK);
else
SetAlgoState(MISSING_HYP);
modifiedHyp = true; modifiedHyp = true;
} }
break; break;
@ -826,38 +854,42 @@ bool SMESH_subMesh::AlgoStateEngine(int event, SMESH_Hypothesis* anHyp)
ret = _meshDS->RemoveHypothesis(_subShape, anHyp); ret = _meshDS->RemoveHypothesis(_subShape, anHyp);
// if (ret &&(anHyp->GetDim() == SMESH_Gen::GetShapeDim(_subShape))) // if (ret &&(anHyp->GetDim() == SMESH_Gen::GetShapeDim(_subShape)))
// if (ret &&(anHyp->GetShapeType() == _subShape.ShapeType())) // if (ret &&(anHyp->GetShapeType() == _subShape.ShapeType()))
if (ret &&(anHyp->GetShapeType() & (1<< _subShape.ShapeType()))) if (ret && (anHyp->GetShapeType() & (1 << _subShape.ShapeType())))
{ {
SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape); SMESH_Algo *algo = gen->GetAlgo((*_father), _subShape);
if (algo == NULL) // no more algo applying on subShape... if (algo == NULL) // no more algo applying on subShape...
{ {
SetAlgoState(NO_ALGO); SetAlgoState(NO_ALGO);
} }
else else
{ {
ret = algo->CheckHypothesis((*_father),_subShape); ret = algo->CheckHypothesis((*_father), _subShape);
if (ret) SetAlgoState(HYP_OK); if (ret)
else SetAlgoState(MISSING_HYP); SetAlgoState(HYP_OK);
else
SetAlgoState(MISSING_HYP);
} }
} }
break; break;
case ADD_FATHER_HYP: case ADD_FATHER_HYP:
ASSERT(anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO); ASSERT(anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO);
{ {
SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape); SMESH_Algo *algo = gen->GetAlgo((*_father), _subShape);
ASSERT(algo); ASSERT(algo);
ret = algo->CheckHypothesis((*_father),_subShape); ret = algo->CheckHypothesis((*_father), _subShape);
if (ret) SetAlgoState(HYP_OK); if (ret)
else SetAlgoState(MISSING_HYP); SetAlgoState(HYP_OK);
else
SetAlgoState(MISSING_HYP);
} }
break; break;
case ADD_FATHER_ALGO: // detect if two algo of same dim on father case ADD_FATHER_ALGO: // detect if two algo of same dim on father
ASSERT(anHyp->GetType() != SMESHDS_Hypothesis::PARAM_ALGO); ASSERT(anHyp->GetType() != SMESHDS_Hypothesis::PARAM_ALGO);
// if (anHyp->GetDim() == SMESH_Gen::GetShapeDim(_subShape)) // if (anHyp->GetDim() == SMESH_Gen::GetShapeDim(_subShape))
// if (anHyp->GetShapeType() == _subShape.ShapeType()) // if (anHyp->GetShapeType() == _subShape.ShapeType())
if (anHyp->GetShapeType() & (1<< _subShape.ShapeType())) if (anHyp->GetShapeType() & (1 << _subShape.ShapeType()))
{ {
SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape); SMESH_Algo *algo = gen->GetAlgo((*_father), _subShape);
if (algo == NULL) // two applying algo on father if (algo == NULL) // two applying algo on father
{ {
MESSAGE("two applying algo on fatherShape..."); MESSAGE("two applying algo on fatherShape...");
@ -865,38 +897,44 @@ bool SMESH_subMesh::AlgoStateEngine(int event, SMESH_Hypothesis* anHyp)
} }
else else
{ {
ret = algo->CheckHypothesis((*_father),_subShape); ret = algo->CheckHypothesis((*_father), _subShape);
if (ret) SetAlgoState(HYP_OK); if (ret)
else SetAlgoState(MISSING_HYP); SetAlgoState(HYP_OK);
else
SetAlgoState(MISSING_HYP);
} }
} }
break; break;
case REMOVE_FATHER_HYP: case REMOVE_FATHER_HYP:
ASSERT(anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO); ASSERT(anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO);
{ {
SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape); SMESH_Algo *algo = gen->GetAlgo((*_father), _subShape);
ASSERT(algo); ASSERT(algo);
ret = algo->CheckHypothesis((*_father),_subShape); ret = algo->CheckHypothesis((*_father), _subShape);
if (ret) SetAlgoState(HYP_OK); if (ret)
else SetAlgoState(MISSING_HYP); SetAlgoState(HYP_OK);
else
SetAlgoState(MISSING_HYP);
} }
break; break;
case REMOVE_FATHER_ALGO: case REMOVE_FATHER_ALGO:
ASSERT(anHyp->GetType() != SMESHDS_Hypothesis::PARAM_ALGO); ASSERT(anHyp->GetType() != SMESHDS_Hypothesis::PARAM_ALGO);
// if (anHyp->GetDim() == SMESH_Gen::GetShapeDim(_subShape)) // if (anHyp->GetDim() == SMESH_Gen::GetShapeDim(_subShape))
// if (anHyp->GetShapeType() == _subShape.ShapeType()) // if (anHyp->GetShapeType() == _subShape.ShapeType())
if (anHyp->GetShapeType() & (1<< _subShape.ShapeType())) if (anHyp->GetShapeType() & (1 << _subShape.ShapeType()))
{ {
SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape); SMESH_Algo *algo = gen->GetAlgo((*_father), _subShape);
if (algo == NULL) // no more applying algo on father if (algo == NULL) // no more applying algo on father
{ {
SetAlgoState(NO_ALGO); SetAlgoState(NO_ALGO);
} }
else else
{ {
ret = algo->CheckHypothesis((*_father),_subShape); ret = algo->CheckHypothesis((*_father), _subShape);
if (ret) SetAlgoState(HYP_OK); if (ret)
else SetAlgoState(MISSING_HYP); SetAlgoState(HYP_OK);
else
SetAlgoState(MISSING_HYP);
} }
} }
break; break;
@ -938,19 +976,18 @@ void SMESH_subMesh::SetAlgoState(int state)
//============================================================================= //=============================================================================
void SMESH_subMesh::SubMeshesAlgoStateEngine(int event, void SMESH_subMesh::SubMeshesAlgoStateEngine(int event,
SMESH_Hypothesis* anHyp) SMESH_Hypothesis * anHyp) throw(SALOME_Exception)
throw (SALOME_Exception)
{ {
//MESSAGE("SMESH_subMesh::SubMeshesAlgoStateEngine"); //MESSAGE("SMESH_subMesh::SubMeshesAlgoStateEngine");
int dim = SMESH_Gen::GetShapeDim(_subShape); int dim = SMESH_Gen::GetShapeDim(_subShape);
if (dim > 1) if (dim > 1)
{ {
const map<int, SMESH_subMesh*>& subMeshes = DependsOn(); const map < int, SMESH_subMesh * >&subMeshes = DependsOn();
map<int, SMESH_subMesh*>::const_iterator itsub; map < int, SMESH_subMesh * >::const_iterator itsub;
for (itsub = subMeshes.begin(); itsub != subMeshes.end(); itsub++) for (itsub = subMeshes.begin(); itsub != subMeshes.end(); itsub++)
{ {
SMESH_subMesh* sm = (*itsub).second; SMESH_subMesh *sm = (*itsub).second;
sm->AlgoStateEngine(event, anHyp); sm->AlgoStateEngine(event, anHyp);
} }
} }
@ -968,29 +1005,43 @@ void SMESH_subMesh::DumpAlgoState(bool isMain)
// if (dim < 1) return; // if (dim < 1) return;
if (isMain) if (isMain)
{ {
const map<int, SMESH_subMesh*>& subMeshes = DependsOn(); const map < int, SMESH_subMesh * >&subMeshes = DependsOn();
map<int, SMESH_subMesh*>::const_iterator itsub; map < int, SMESH_subMesh * >::const_iterator itsub;
for (itsub = subMeshes.begin(); itsub != subMeshes.end(); itsub++) for (itsub = subMeshes.begin(); itsub != subMeshes.end(); itsub++)
{ {
SMESH_subMesh* sm = (*itsub).second; SMESH_subMesh *sm = (*itsub).second;
sm->DumpAlgoState(false); sm->DumpAlgoState(false);
} }
} }
int type = _subShape.ShapeType(); int type = _subShape.ShapeType();
MESSAGE("dim = " << dim << " type of shape " << type); MESSAGE("dim = " << dim << " type of shape " << type);
switch(_algoState) switch (_algoState)
{ {
case NO_ALGO: MESSAGE(" AlgoState = NO_ALGO"); break; case NO_ALGO:
case MISSING_HYP: MESSAGE(" AlgoState = MISSING_HYP"); break; MESSAGE(" AlgoState = NO_ALGO");
case HYP_OK: MESSAGE(" AlgoState = HYP_OK"); break; break;
case MISSING_HYP:
MESSAGE(" AlgoState = MISSING_HYP");
break;
case HYP_OK:
MESSAGE(" AlgoState = HYP_OK");
break;
} }
switch (_computeState) switch (_computeState)
{ {
case NOT_READY: MESSAGE(" ComputeState = NOT_READY"); break; case NOT_READY:
case READY_TO_COMPUTE: MESSAGE(" ComputeState = READY_TO_COMPUTE"); break; MESSAGE(" ComputeState = NOT_READY");
case COMPUTE_OK: MESSAGE(" ComputeState = COMPUTE_OK"); break; break;
case FAILED_TO_COMPUTE: MESSAGE(" ComputeState = FAILED_TO_COMPUTE");break; case READY_TO_COMPUTE:
MESSAGE(" ComputeState = READY_TO_COMPUTE");
break;
case COMPUTE_OK:
MESSAGE(" ComputeState = COMPUTE_OK");
break;
case FAILED_TO_COMPUTE:
MESSAGE(" ComputeState = FAILED_TO_COMPUTE");
break;
} }
} }
@ -1000,8 +1051,7 @@ void SMESH_subMesh::DumpAlgoState(bool isMain)
*/ */
//============================================================================= //=============================================================================
bool SMESH_subMesh::ComputeStateEngine(int event) bool SMESH_subMesh::ComputeStateEngine(int event) throw(SALOME_Exception)
throw (SALOME_Exception)
{ {
//MESSAGE("SMESH_subMesh::ComputeStateEngine"); //MESSAGE("SMESH_subMesh::ComputeStateEngine");
//SCRUTE(_computeState); //SCRUTE(_computeState);
@ -1011,16 +1061,18 @@ bool SMESH_subMesh::ComputeStateEngine(int event)
if (dim < 1) if (dim < 1)
{ {
if (_vertexSet) _computeState = COMPUTE_OK; if (_vertexSet)
else _computeState = READY_TO_COMPUTE; _computeState = COMPUTE_OK;
else
_computeState = READY_TO_COMPUTE;
//SCRUTE(_computeState); //SCRUTE(_computeState);
return true; return true;
} }
SMESH_Gen* gen =_father->GetGen(); SMESH_Gen *gen = _father->GetGen();
SMESH_Algo* algo = 0; SMESH_Algo *algo = 0;
bool ret; bool ret;
switch(_computeState) switch (_computeState)
{ {
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
@ -1061,16 +1113,17 @@ bool SMESH_subMesh::ComputeStateEngine(int event)
algo = gen->GetAlgo((*_father), _subShape); algo = gen->GetAlgo((*_father), _subShape);
if (algo) if (algo)
{ {
ret = algo->CheckHypothesis((*_father),_subShape); ret = algo->CheckHypothesis((*_father), _subShape);
if (ret) _computeState = READY_TO_COMPUTE; if (ret)
_computeState = READY_TO_COMPUTE;
} }
break; break;
case COMPUTE: case COMPUTE:
{ {
algo = gen->GetAlgo((*_father), _subShape); algo = gen->GetAlgo((*_father), _subShape);
ASSERT(algo); ASSERT(algo);
ret = algo->CheckHypothesis((*_father),_subShape); ret = algo->CheckHypothesis((*_father), _subShape);
if (! ret) if (!ret)
{ {
MESSAGE("***** verify compute state *****"); MESSAGE("***** verify compute state *****");
_computeState = NOT_READY; _computeState = NOT_READY;
@ -1083,7 +1136,7 @@ bool SMESH_subMesh::ComputeStateEngine(int event)
_computeState = FAILED_TO_COMPUTE; _computeState = FAILED_TO_COMPUTE;
break; break;
} }
ret = algo->Compute((*_father),_subShape); ret = algo->Compute((*_father), _subShape);
if (!ret) if (!ret)
{ {
MESSAGE("problem in algo execution: failed to compute"); MESSAGE("problem in algo execution: failed to compute");
@ -1102,8 +1155,9 @@ bool SMESH_subMesh::ComputeStateEngine(int event)
algo = gen->GetAlgo((*_father), _subShape); algo = gen->GetAlgo((*_father), _subShape);
if (algo) if (algo)
{ {
ret = algo->CheckHypothesis((*_father),_subShape); ret = algo->CheckHypothesis((*_father), _subShape);
if (ret) _computeState = READY_TO_COMPUTE; if (ret)
_computeState = READY_TO_COMPUTE;
} }
break; break;
case CLEANDEP: case CLEANDEP:
@ -1112,8 +1166,9 @@ bool SMESH_subMesh::ComputeStateEngine(int event)
algo = gen->GetAlgo((*_father), _subShape); algo = gen->GetAlgo((*_father), _subShape);
if (algo) if (algo)
{ {
ret = algo->CheckHypothesis((*_father),_subShape); ret = algo->CheckHypothesis((*_father), _subShape);
if (ret) _computeState = READY_TO_COMPUTE; if (ret)
_computeState = READY_TO_COMPUTE;
} }
break; break;
case SUBMESH_COMPUTED: // nothing to do case SUBMESH_COMPUTED: // nothing to do
@ -1146,8 +1201,9 @@ bool SMESH_subMesh::ComputeStateEngine(int event)
algo = gen->GetAlgo((*_father), _subShape); algo = gen->GetAlgo((*_father), _subShape);
if (algo) if (algo)
{ {
ret = algo->CheckHypothesis((*_father),_subShape); ret = algo->CheckHypothesis((*_father), _subShape);
if (ret) _computeState = READY_TO_COMPUTE; if (ret)
_computeState = READY_TO_COMPUTE;
} }
break; break;
case SUBMESH_COMPUTED: // nothing to do case SUBMESH_COMPUTED: // nothing to do
@ -1166,12 +1222,14 @@ bool SMESH_subMesh::ComputeStateEngine(int event)
case MODIF_HYP: case MODIF_HYP:
if (_algoState == HYP_OK) if (_algoState == HYP_OK)
_computeState = READY_TO_COMPUTE; _computeState = READY_TO_COMPUTE;
else _computeState = NOT_READY; else
_computeState = NOT_READY;
break; break;
case MODIF_ALGO_STATE: case MODIF_ALGO_STATE:
if (_algoState == HYP_OK) if (_algoState == HYP_OK)
_computeState = READY_TO_COMPUTE; _computeState = READY_TO_COMPUTE;
else _computeState = NOT_READY; else
_computeState = NOT_READY;
break; break;
case COMPUTE: // nothing to do case COMPUTE: // nothing to do
break; break;
@ -1181,12 +1239,14 @@ bool SMESH_subMesh::ComputeStateEngine(int event)
RemoveSubMeshElementsAndNodes(); RemoveSubMeshElementsAndNodes();
if (_algoState == HYP_OK) if (_algoState == HYP_OK)
_computeState = READY_TO_COMPUTE; _computeState = READY_TO_COMPUTE;
else _computeState = NOT_READY; else
_computeState = NOT_READY;
break; break;
case SUBMESH_COMPUTED: // allow retry compute case SUBMESH_COMPUTED: // allow retry compute
if (_algoState == HYP_OK) if (_algoState == HYP_OK)
_computeState = READY_TO_COMPUTE; _computeState = READY_TO_COMPUTE;
else _computeState = NOT_READY; else
_computeState = NOT_READY;
break; break;
default: default:
ASSERT(0); ASSERT(0);
@ -1214,11 +1274,11 @@ void SMESH_subMesh::UpdateDependantsState()
{ {
//MESSAGE("SMESH_subMesh::UpdateDependantsState"); //MESSAGE("SMESH_subMesh::UpdateDependantsState");
const map<int, SMESH_subMesh*>& dependants = Dependants(); const map < int, SMESH_subMesh * >&dependants = Dependants();
map<int, SMESH_subMesh*>::const_iterator its; map < int, SMESH_subMesh * >::const_iterator its;
for (its = dependants.begin(); its != dependants.end(); its++) for (its = dependants.begin(); its != dependants.end(); its++)
{ {
SMESH_subMesh* sm = (*its).second; SMESH_subMesh *sm = (*its).second;
//SCRUTE((*its).first); //SCRUTE((*its).first);
sm->ComputeStateEngine(SUBMESH_COMPUTED); sm->ComputeStateEngine(SUBMESH_COMPUTED);
} }
@ -1235,16 +1295,17 @@ void SMESH_subMesh::CleanDependants()
MESSAGE("SMESH_subMesh::CleanDependants"); MESSAGE("SMESH_subMesh::CleanDependants");
// **** parcourir les ancetres dans l'ordre de dépendance // **** parcourir les ancetres dans l'ordre de dépendance
const map<int, SMESH_subMesh*>& dependants = Dependants(); const map < int, SMESH_subMesh * >&dependants = Dependants();
map<int, SMESH_subMesh*>::const_iterator its; map < int, SMESH_subMesh * >::const_iterator its;
for (its = dependants.begin(); its != dependants.end(); its++) for (its = dependants.begin(); its != dependants.end(); its++)
{ {
SMESH_subMesh* sm = (*its).second; SMESH_subMesh *sm = (*its).second;
SCRUTE((*its).first); SCRUTE((*its).first);
sm->ComputeStateEngine(CLEANDEP); sm->ComputeStateEngine(CLEANDEP);
} }
ComputeStateEngine(CLEANDEP); ComputeStateEngine(CLEANDEP);
} }
//============================================================================= //=============================================================================
/*! /*!
* *
@ -1258,29 +1319,26 @@ void SMESH_subMesh::RemoveSubMeshElementsAndNodes()
SCRUTE(_Id); SCRUTE(_Id);
_subMeshDS = _meshDS->MeshElements(_subShape); _subMeshDS = _meshDS->MeshElements(_subShape);
if (!_subMeshDS.IsNull()) if (_subMeshDS!=NULL)
{ {
const TColStd_ListOfInteger& indElt const vector<int> & indElt = _subMeshDS->GetIDElements();
= _subMeshDS->GetIDElements(); vector<int>::const_iterator ite=indElt.begin();
TColStd_ListIteratorOfListOfInteger ite(indElt); for (; ite!=indElt.end(); ite++)
for (; ite.More(); ite.Next())
{ {
int eltId = ite.Value(); int eltId = *ite;
SCRUTE(eltId); SCRUTE(eltId);
Handle (SMDS_MeshElement) elt = _meshDS->FindElement(eltId); const SMDS_MeshElement * elt = _meshDS->FindElement(eltId);
_subMeshDS->RemoveElement(elt); _subMeshDS->RemoveElement(elt);
_meshDS->RemoveElement(eltId); _meshDS->RemoveElement(eltId);
} }
const TColStd_ListOfInteger& indNodes const vector<int> & indNodes = _subMeshDS->GetIDNodes();
= _subMeshDS->GetIDNodes(); vector<int>::const_iterator itn=indNodes.begin();
TColStd_ListIteratorOfListOfInteger itn(indNodes); for (; itn!=indNodes.end(); itn++)
for (; itn.More(); itn.Next())
{ {
int nodeId = itn.Value(); int nodeId = *itn;
SCRUTE(nodeId); SCRUTE(nodeId);
Handle (SMDS_MeshElement) elt = _meshDS->FindNode(nodeId); const SMDS_MeshNode * node = _meshDS->FindNode(nodeId);
Handle (SMDS_MeshNode) node = _meshDS->GetNode(1, elt);
_subMeshDS->RemoveNode(node); _subMeshDS->RemoveNode(node);
_meshDS->RemoveNode(nodeId); _meshDS->RemoveNode(nodeId);
} }
@ -1293,9 +1351,10 @@ void SMESH_subMesh::RemoveSubMeshElementsAndNodes()
*/ */
//============================================================================= //=============================================================================
const map<int, SMESH_subMesh*>& SMESH_subMesh::Dependants() const map < int, SMESH_subMesh * >&SMESH_subMesh::Dependants()
{ {
if (_dependantsFound) return _mapDependants; if (_dependantsFound)
return _mapDependants;
//MESSAGE("SMESH_subMesh::Dependants"); //MESSAGE("SMESH_subMesh::Dependants");
@ -1314,19 +1373,22 @@ const map<int, SMESH_subMesh*>& SMESH_subMesh::Dependants()
TopExp::MapShapesAndAncestors(mainShape, TopAbs_EDGE, TopAbs_FACE, M); TopExp::MapShapesAndAncestors(mainShape, TopAbs_EDGE, TopAbs_FACE, M);
TopExp::MapShapesAndAncestors(mainShape, TopAbs_EDGE, TopAbs_SHELL, M); TopExp::MapShapesAndAncestors(mainShape, TopAbs_EDGE, TopAbs_SHELL, M);
TopExp::MapShapesAndAncestors(mainShape, TopAbs_EDGE, TopAbs_SOLID, M); TopExp::MapShapesAndAncestors(mainShape, TopAbs_EDGE, TopAbs_SOLID, M);
TopExp::MapShapesAndAncestors(mainShape, TopAbs_EDGE, TopAbs_COMPSOLID, M); TopExp::MapShapesAndAncestors(mainShape, TopAbs_EDGE, TopAbs_COMPSOLID,
M);
ExtractDependants(M, TopAbs_EDGE); ExtractDependants(M, TopAbs_EDGE);
break; break;
case TopAbs_FACE: case TopAbs_FACE:
case TopAbs_SHELL: case TopAbs_SHELL:
TopExp::MapShapesAndAncestors(mainShape, TopAbs_FACE, TopAbs_SHELL, M); TopExp::MapShapesAndAncestors(mainShape, TopAbs_FACE, TopAbs_SHELL, M);
TopExp::MapShapesAndAncestors(mainShape, TopAbs_FACE, TopAbs_SOLID, M); TopExp::MapShapesAndAncestors(mainShape, TopAbs_FACE, TopAbs_SOLID, M);
TopExp::MapShapesAndAncestors(mainShape, TopAbs_FACE, TopAbs_COMPSOLID, M); TopExp::MapShapesAndAncestors(mainShape, TopAbs_FACE, TopAbs_COMPSOLID,
M);
ExtractDependants(M, TopAbs_FACE); ExtractDependants(M, TopAbs_FACE);
break; break;
case TopAbs_SOLID: case TopAbs_SOLID:
case TopAbs_COMPSOLID: case TopAbs_COMPSOLID:
TopExp::MapShapesAndAncestors(mainShape, TopAbs_SOLID, TopAbs_COMPSOLID, M); TopExp::MapShapesAndAncestors(mainShape, TopAbs_SOLID, TopAbs_COMPSOLID,
M);
ExtractDependants(M, TopAbs_SOLID); ExtractDependants(M, TopAbs_SOLID);
break; break;
case TopAbs_COMPOUND: case TopAbs_COMPOUND:
@ -1343,7 +1405,8 @@ const map<int, SMESH_subMesh*>& SMESH_subMesh::Dependants()
*/ */
//============================================================================= //=============================================================================
void SMESH_subMesh::ExtractDependants(const TopTools_IndexedDataMapOfShapeListOfShape& M, void SMESH_subMesh::
ExtractDependants(const TopTools_IndexedDataMapOfShapeListOfShape & M,
const TopAbs_ShapeEnum etype) const TopAbs_ShapeEnum etype)
{ {
//MESSAGE("SMESH_subMesh::ExtractDependants"); //MESSAGE("SMESH_subMesh::ExtractDependants");
@ -1361,12 +1424,12 @@ void SMESH_subMesh::ExtractDependants(const TopTools_IndexedDataMapOfShapeListOf
case TopAbs_FACE: case TopAbs_FACE:
case TopAbs_SOLID: case TopAbs_SOLID:
{ {
const TopTools_ListOfShape& ancestors = M.FindFromKey(_subShape); const TopTools_ListOfShape & ancestors = M.FindFromKey(_subShape);
TopTools_ListIteratorOfListOfShape it(ancestors); TopTools_ListIteratorOfListOfShape it(ancestors);
for ( ; it.More();it.Next()) for (; it.More(); it.Next())
{ {
TopoDS_Shape ancestor = it.Value(); TopoDS_Shape ancestor = it.Value();
SMESH_subMesh* aSubMesh = _father->GetSubMeshContaining(ancestor); SMESH_subMesh *aSubMesh = _father->GetSubMeshContaining(ancestor);
// if (! aSubMesh) aSubMesh = _father->GetSubMesh(ancestor); // if (! aSubMesh) aSubMesh = _father->GetSubMesh(ancestor);
if (aSubMesh) if (aSubMesh)
{ {
@ -1388,14 +1451,16 @@ void SMESH_subMesh::ExtractDependants(const TopTools_IndexedDataMapOfShapeListOf
for (TopExp_Explorer expE(_subShape, etype); expE.More(); expE.Next()) for (TopExp_Explorer expE(_subShape, etype); expE.More(); expE.Next())
{ {
TopoDS_Shape aShape = expE.Current(); TopoDS_Shape aShape = expE.Current();
const TopTools_ListOfShape& ancestors = M.FindFromKey( aShape); const TopTools_ListOfShape & ancestors = M.FindFromKey(aShape);
TopTools_ListIteratorOfListOfShape it(ancestors); TopTools_ListIteratorOfListOfShape it(ancestors);
for ( ; it.More();it.Next()) for (; it.More(); it.Next())
{ {
MESSAGE("---"); MESSAGE("---");
TopoDS_Shape ancestor = it.Value(); TopoDS_Shape ancestor = it.Value();
SMESH_subMesh* aSubMesh = _father->GetSubMeshContaining(ancestor); SMESH_subMesh *aSubMesh =
if (! aSubMesh) aSubMesh = _father->GetSubMesh(ancestor); _father->GetSubMeshContaining(ancestor);
if (!aSubMesh)
aSubMesh = _father->GetSubMesh(ancestor);
int type = aSubMesh->_subShape.ShapeType(); int type = aSubMesh->_subShape.ShapeType();
int cle = aSubMesh->GetId(); int cle = aSubMesh->GetId();
cle += 10000000 * type; // sort map by ordType then index cle += 10000000 * type; // sort map by ordType then index
@ -1411,4 +1476,3 @@ void SMESH_subMesh::ExtractDependants(const TopTools_IndexedDataMapOfShapeListOf
break; break;
} }
} }

View File

@ -45,77 +45,81 @@ class SMESH_Hypothesis;
class SMESH_subMesh class SMESH_subMesh
{ {
public: public:
SMESH_subMesh(int Id, SMESH_subMesh(int Id, SMESH_Mesh * father, SMESHDS_Mesh * meshDS,
SMESH_Mesh* father,
const Handle(SMESHDS_Mesh)& meshDS,
const TopoDS_Shape & aSubShape); const TopoDS_Shape & aSubShape);
virtual ~SMESH_subMesh(); virtual ~ SMESH_subMesh();
int GetId(); int GetId();
// bool Contains(const TopoDS_Shape & aSubShape) // bool Contains(const TopoDS_Shape & aSubShape)
// throw (SALOME_Exception); // throw (SALOME_Exception);
const Handle(SMESHDS_SubMesh)& GetSubMeshDS() SMESHDS_SubMesh * GetSubMeshDS() throw(SALOME_Exception);
throw (SALOME_Exception);
SMESH_subMesh* GetFirstToCompute() SMESH_subMesh *GetFirstToCompute() throw(SALOME_Exception);
throw (SALOME_Exception);
const map<int, SMESH_subMesh*>& DependsOn(); const map < int, SMESH_subMesh * >&DependsOn();
const map<int, SMESH_subMesh*>& Dependants(); const map < int, SMESH_subMesh * >&Dependants();
const TopoDS_Shape& GetSubShape(); const TopoDS_Shape & GetSubShape();
bool _vertexSet; // only for vertex subMesh, set to false for dim > 0 bool _vertexSet; // only for vertex subMesh, set to false for dim > 0
enum compute_state { NOT_READY, READY_TO_COMPUTE, enum compute_state
COMPUTE_OK, FAILED_TO_COMPUTE }; { NOT_READY, READY_TO_COMPUTE,
enum algo_state { NO_ALGO, MISSING_HYP, HYP_OK }; COMPUTE_OK, FAILED_TO_COMPUTE
enum algo_event {ADD_HYP, ADD_ALGO, };
enum algo_state
{ NO_ALGO, MISSING_HYP, HYP_OK };
enum algo_event
{ ADD_HYP, ADD_ALGO,
REMOVE_HYP, REMOVE_ALGO, REMOVE_HYP, REMOVE_ALGO,
ADD_FATHER_HYP, ADD_FATHER_ALGO, ADD_FATHER_HYP, ADD_FATHER_ALGO,
REMOVE_FATHER_HYP, REMOVE_FATHER_ALGO}; REMOVE_FATHER_HYP, REMOVE_FATHER_ALGO
enum compute_event {MODIF_HYP, MODIF_ALGO_STATE, COMPUTE, };
CLEAN, CLEANDEP, SUBMESH_COMPUTED}; enum compute_event
{ MODIF_HYP, MODIF_ALGO_STATE, COMPUTE,
CLEAN, CLEANDEP, SUBMESH_COMPUTED
};
bool AlgoStateEngine(int event, SMESH_Hypothesis* anHyp) bool AlgoStateEngine(int event, SMESH_Hypothesis * anHyp)
throw (SALOME_Exception); throw(SALOME_Exception);
void SubMeshesAlgoStateEngine(int event, SMESH_Hypothesis* anHyp) void SubMeshesAlgoStateEngine(int event, SMESH_Hypothesis * anHyp)
throw (SALOME_Exception); throw(SALOME_Exception);
void DumpAlgoState(bool isMain); void DumpAlgoState(bool isMain);
bool ComputeStateEngine(int event) bool ComputeStateEngine(int event) throw(SALOME_Exception);
throw (SALOME_Exception);
int GetComputeState() {return _computeState;}; int GetComputeState()
{
return _computeState;
};
protected: protected:
void InsertDependence(const TopoDS_Shape aSubShape); void InsertDependence(const TopoDS_Shape aSubShape);
// void FinalizeDependence(list<TopoDS_Shape>& shapeList); // void FinalizeDependence(list<TopoDS_Shape>& shapeList);
bool SubMeshesComputed() bool SubMeshesComputed() throw(SALOME_Exception);
throw (SALOME_Exception);
bool SubMeshesReady(); bool SubMeshesReady();
void RemoveSubMeshElementsAndNodes(); void RemoveSubMeshElementsAndNodes();
void UpdateDependantsState(); void UpdateDependantsState();
void CleanDependants(); void CleanDependants();
void ExtractDependants(const TopTools_IndexedDataMapOfShapeListOfShape& M, void ExtractDependants(const TopTools_IndexedDataMapOfShapeListOfShape & M,
const TopAbs_ShapeEnum etype); const TopAbs_ShapeEnum etype);
void SetAlgoState(int state); void SetAlgoState(int state);
TopoDS_Shape _subShape; TopoDS_Shape _subShape;
Handle (SMESHDS_Mesh) _meshDS; SMESHDS_Mesh * _meshDS;
Handle (SMESHDS_SubMesh) _subMeshDS; SMESHDS_SubMesh * _subMeshDS;
int _Id; int _Id;
SMESH_Mesh* _father; SMESH_Mesh *_father;
map<int, SMESH_subMesh*> _mapDepend; map < int, SMESH_subMesh * >_mapDepend;
map<int, SMESH_subMesh*> _mapDependants; map < int, SMESH_subMesh * >_mapDependants;
bool _dependenceAnalysed; bool _dependenceAnalysed;
bool _dependantsFound; bool _dependantsFound;