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_Mesh.hxx"
#include "SMESHDS_ListOfPtrHypothesis.hxx"
#include "SMESHDS_ListIteratorOfListOfPtrHypothesis.hxx"
#include <GeomAdaptor_Curve.hxx>
#include <BRep_Tool.hxx>
#include <GCPnts_AbscissaPoint.hxx>
@ -49,12 +46,12 @@ using namespace std;
*/
//=============================================================================
SMESH_Algo::SMESH_Algo(int hypId, int studyId, SMESH_Gen* gen)
: SMESH_Hypothesis(hypId, studyId, gen)
SMESH_Algo::SMESH_Algo(int hypId, int studyId,
SMESH_Gen * gen):SMESH_Hypothesis(hypId, studyId, gen)
{
// _compatibleHypothesis.push_back("hypothese_bidon");
_type = ALGO;
gen->_mapAlgo[hypId] = this;
_type = ALGO;
gen->_mapAlgo[hypId] = this;
}
//=============================================================================
@ -73,9 +70,9 @@ SMESH_Algo::~SMESH_Algo()
*/
//=============================================================================
const vector<string> & SMESH_Algo::GetCompatibleHypothesis()
const vector < string > &SMESH_Algo::GetCompatibleHypothesis()
{
return _compatibleHypothesis;
return _compatibleHypothesis;
}
//=============================================================================
@ -86,7 +83,7 @@ const vector<string> & SMESH_Algo::GetCompatibleHypothesis()
ostream & SMESH_Algo::SaveTo(ostream & save)
{
return save << this;
return save << this;
}
//=============================================================================
@ -97,7 +94,7 @@ ostream & SMESH_Algo::SaveTo(ostream & save)
istream & SMESH_Algo::LoadFrom(istream & load)
{
return load >> (*this);
return load >> (*this);
}
//=============================================================================
@ -106,9 +103,9 @@ 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,9 +114,9 @@ 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,12 +125,12 @@ istream& operator >> (istream & load, SMESH_Algo & hyp)
*/
//=============================================================================
bool SMESH_Algo::CheckHypothesis(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape)
bool SMESH_Algo::CheckHypothesis(SMESH_Mesh & aMesh,
const TopoDS_Shape & aShape)
{
MESSAGE("SMESH_Algo::CheckHypothesis");
ASSERT(0); // use method from derived classes
return false;
MESSAGE("SMESH_Algo::CheckHypothesis");
ASSERT(0); // use method from derived classes
return false;
}
//=============================================================================
@ -142,12 +139,11 @@ bool SMESH_Algo::CheckHypothesis(SMESH_Mesh& aMesh,
*/
//=============================================================================
bool SMESH_Algo::Compute(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape)
bool SMESH_Algo::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape)
{
MESSAGE("SMESH_Algo::Compute");
ASSERT(0); // use method from derived classes
return false;
MESSAGE("SMESH_Algo::Compute");
ASSERT(0); // use method from derived classes
return false;
}
//=============================================================================
@ -160,24 +156,24 @@ bool SMESH_Algo::Compute(SMESH_Mesh& aMesh,
*/
//=============================================================================
const list<SMESHDS_Hypothesis*>&
SMESH_Algo::GetUsedHypothesis(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape)
const list <const SMESHDS_Hypothesis *> & SMESH_Algo::GetUsedHypothesis(
SMESH_Mesh & aMesh, const TopoDS_Shape & aShape)
{
_usedHypList.clear();
_usedHypList = GetAppliedHypothesis(aMesh, aShape); // copy
int nbHyp = _usedHypList.size();
if (nbHyp == 0)
{
TopoDS_Shape mainShape = aMesh.GetMeshDS()->ShapeToMesh();
if (!mainShape.IsSame(aShape))
_usedHypList.clear();
_usedHypList = GetAppliedHypothesis(aMesh, aShape); // copy
int nbHyp = _usedHypList.size();
if (nbHyp == 0)
{
_usedHypList = GetAppliedHypothesis(aMesh, mainShape); // copy
nbHyp = _usedHypList.size();
TopoDS_Shape mainShape = aMesh.GetMeshDS()->ShapeToMesh();
if (!mainShape.IsSame(aShape))
{
_usedHypList = GetAppliedHypothesis(aMesh, mainShape); // copy
nbHyp = _usedHypList.size();
}
}
}
if (nbHyp > 1) _usedHypList.clear(); //only one compatible hypothesis allowed
return _usedHypList;
if (nbHyp > 1)
_usedHypList.clear(); //only one compatible hypothesis allowed
return _usedHypList;
}
//=============================================================================
@ -188,56 +184,54 @@ SMESH_Algo::GetUsedHypothesis(SMESH_Mesh& aMesh,
*/
//=============================================================================
const list<SMESHDS_Hypothesis*>&
SMESH_Algo::GetAppliedHypothesis(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape)
const list<const SMESHDS_Hypothesis *> & SMESH_Algo::GetAppliedHypothesis(
SMESH_Mesh & aMesh, const TopoDS_Shape & aShape)
{
const Handle(SMESHDS_Mesh)& meshDS = aMesh.GetMeshDS();
const SMESHDS_ListOfPtrHypothesis& listHyp = meshDS->GetHypothesis(aShape);
SMESHDS_ListIteratorOfListOfPtrHypothesis it(listHyp);
const SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
const list<const SMESHDS_Hypothesis*> & listHyp = meshDS->GetHypothesis(aShape);
list<const SMESHDS_Hypothesis*>::const_iterator it=listHyp.begin();
int hypType;
string hypName;
int hypType;
string hypName;
_appliedHypList.clear();
while (it.More())
{
SMESHDS_Hypothesis* anHyp = it.Value();
hypType = anHyp->GetType();
//SCRUTE(hypType);
if (hypType == SMESHDS_Hypothesis::PARAM_ALGO)
_appliedHypList.clear();
while (it!=listHyp.end())
{
hypName = anHyp->GetName();
vector<string>::iterator ith = find(_compatibleHypothesis.begin(),
_compatibleHypothesis.end(),
hypName);
if (ith != _compatibleHypothesis.end()) // count only relevant
{
_appliedHypList.push_back(anHyp);
//SCRUTE(hypName);
}
const SMESHDS_Hypothesis *anHyp = *it;
hypType = anHyp->GetType();
//SCRUTE(hypType);
if (hypType == SMESHDS_Hypothesis::PARAM_ALGO)
{
hypName = anHyp->GetName();
vector < string >::iterator ith =
find(_compatibleHypothesis.begin(), _compatibleHypothesis.end(),
hypName);
if (ith != _compatibleHypothesis.end()) // count only relevant
{
_appliedHypList.push_back(anHyp);
//SCRUTE(hypName);
}
}
it++;
}
it.Next();
}
return _appliedHypList;
return _appliedHypList;
}
//=============================================================================
/*!
* 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;
TopLoc_Location L;
if (BRep_Tool::Degenerated(E)) return 0;
Handle (Geom_Curve) C = BRep_Tool::Curve(E, L, UMin, UMax);
GeomAdaptor_Curve AdaptCurve(C);
GCPnts_AbscissaPoint gabs;
double length = gabs.Length(AdaptCurve, UMin, UMax);
return length;
double UMin = 0, UMax = 0;
TopLoc_Location L;
if (BRep_Tool::Degenerated(E))
return 0;
Handle(Geom_Curve) C = BRep_Tool::Curve(E, L, UMin, UMax);
GeomAdaptor_Curve AdaptCurve(C);
GCPnts_AbscissaPoint gabs;
double length = gabs.Length(AdaptCurve, UMin, UMax);
return length;
}

View File

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

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

@ -26,7 +26,6 @@
// Module : SMESH
// $Header$
using namespace std;
using namespace std;
#include "SMESH_MEFISTO_2D.hxx"
#include "SMESH_Gen.hxx"
@ -38,8 +37,6 @@ using namespace std;
#include "Rn.h"
#include "aptrte.h"
#include "SMESHDS_ListOfPtrHypothesis.hxx"
#include "SMESHDS_ListIteratorOfListOfPtrHypothesis.hxx"
#include "SMDS_MeshElement.hxx"
#include "SMDS_MeshNode.hxx"
#include "SMDS_EdgePosition.hxx"
@ -70,20 +67,20 @@ using namespace std;
*/
//=============================================================================
SMESH_MEFISTO_2D::SMESH_MEFISTO_2D(int hypId, int studyId, SMESH_Gen* gen)
: SMESH_2D_Algo(hypId, studyId, gen)
SMESH_MEFISTO_2D::SMESH_MEFISTO_2D(int hypId, int studyId,
SMESH_Gen * gen):SMESH_2D_Algo(hypId, studyId, gen)
{
MESSAGE("SMESH_MEFISTO_2D::SMESH_MEFISTO_2D");
_name = "MEFISTO_2D";
MESSAGE("SMESH_MEFISTO_2D::SMESH_MEFISTO_2D");
_name = "MEFISTO_2D";
// _shapeType = TopAbs_FACE;
_shapeType = (1<<TopAbs_FACE);
_compatibleHypothesis.push_back("MaxElementArea");
_compatibleHypothesis.push_back("LengthFromEdges");
_shapeType = (1 << TopAbs_FACE);
_compatibleHypothesis.push_back("MaxElementArea");
_compatibleHypothesis.push_back("LengthFromEdges");
_edgeLength = 0;
_maxElementArea = 0;
_hypMaxElementArea = NULL;
_hypLengthFromEdges = NULL;
_edgeLength = 0;
_maxElementArea = 0;
_hypMaxElementArea = NULL;
_hypLengthFromEdges = NULL;
}
//=============================================================================
@ -94,7 +91,7 @@ SMESH_MEFISTO_2D::SMESH_MEFISTO_2D(int hypId, int studyId, SMESH_Gen* gen)
SMESH_MEFISTO_2D::~SMESH_MEFISTO_2D()
{
MESSAGE("SMESH_MEFISTO_2D::~SMESH_MEFISTO_2D");
MESSAGE("SMESH_MEFISTO_2D::~SMESH_MEFISTO_2D");
}
//=============================================================================
@ -103,147 +100,145 @@ SMESH_MEFISTO_2D::~SMESH_MEFISTO_2D()
*/
//=============================================================================
bool SMESH_MEFISTO_2D::CheckHypothesis(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape)
bool SMESH_MEFISTO_2D::CheckHypothesis(SMESH_Mesh & aMesh,
const TopoDS_Shape & aShape)
{
//MESSAGE("SMESH_MEFISTO_2D::CheckHypothesis");
//MESSAGE("SMESH_MEFISTO_2D::CheckHypothesis");
_hypMaxElementArea = NULL;
_hypLengthFromEdges = NULL;
_hypMaxElementArea = NULL;
_hypLengthFromEdges = NULL;
list<SMESHDS_Hypothesis*>::const_iterator itl;
SMESHDS_Hypothesis* theHyp;
list <const SMESHDS_Hypothesis * >::const_iterator itl;
const SMESHDS_Hypothesis *theHyp;
const list<SMESHDS_Hypothesis*>& hyps = GetUsedHypothesis(aMesh, aShape);
int nbHyp = hyps.size();
if (nbHyp != 1) return false; // only one compatible hypothesis allowed
const list <const SMESHDS_Hypothesis * >&hyps = GetUsedHypothesis(aMesh, aShape);
int nbHyp = hyps.size();
if (nbHyp != 1) return false;// only one compatible hypothesis allowed
itl = hyps.begin();
theHyp = (*itl);
itl = hyps.begin();
theHyp = (*itl);
string hypName = theHyp->GetName();
int hypId = theHyp->GetID();
//SCRUTE(hypName);
string hypName = theHyp->GetName();
int hypId = theHyp->GetID();
//SCRUTE(hypName);
bool isOk = false;
bool isOk = false;
if (hypName == "MaxElementArea")
{
_hypMaxElementArea = dynamic_cast<SMESH_MaxElementArea*> (theHyp);
ASSERT(_hypMaxElementArea);
_maxElementArea = _hypMaxElementArea->GetMaxArea();
_edgeLength = 0;
isOk =true;
}
if (hypName == "LengthFromEdges")
{
_hypLengthFromEdges = dynamic_cast<SMESH_LengthFromEdges*> (theHyp);
ASSERT(_hypLengthFromEdges);
_edgeLength = 0;
_maxElementArea = 0;
isOk =true;
}
if (isOk)
{
isOk = false;
if (_maxElementArea > 0)
if (hypName == "MaxElementArea")
{
_edgeLength = 2*sqrt(_maxElementArea); // triangles : minorant
isOk = true;
_hypMaxElementArea = static_cast<const SMESH_MaxElementArea *>(theHyp);
ASSERT(_hypMaxElementArea);
_maxElementArea = _hypMaxElementArea->GetMaxArea();
_edgeLength = 0;
isOk = true;
}
else isOk = (_hypLengthFromEdges != NULL); // **** check mode
}
//SCRUTE(_edgeLength);
//SCRUTE(_maxElementArea);
return isOk;
if (hypName == "LengthFromEdges")
{
_hypLengthFromEdges = static_cast<const SMESH_LengthFromEdges *>(theHyp);
ASSERT(_hypLengthFromEdges);
_edgeLength = 0;
_maxElementArea = 0;
isOk = true;
}
if (isOk)
{
isOk = false;
if (_maxElementArea > 0)
{
_edgeLength = 2 * sqrt(_maxElementArea); // triangles : minorant
isOk = true;
}
else
isOk = (_hypLengthFromEdges != NULL); // **** check mode
}
//SCRUTE(_edgeLength);
//SCRUTE(_maxElementArea);
return isOk;
}
//=============================================================================
/*!
*
*/
//=============================================================================
bool SMESH_MEFISTO_2D::Compute(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape)
bool SMESH_MEFISTO_2D::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape)
{
MESSAGE("SMESH_MEFISTO_2D::Compute");
MESSAGE("SMESH_MEFISTO_2D::Compute");
if (_hypLengthFromEdges)
_edgeLength = ComputeEdgeElementLength(aMesh, aShape);
if (_hypLengthFromEdges)
_edgeLength = ComputeEdgeElementLength(aMesh, aShape);
bool isOk = false;
const Handle(SMESHDS_Mesh)& meshDS = aMesh.GetMeshDS();
SMESH_subMesh* theSubMesh = aMesh.GetSubMesh(aShape);
bool isOk = false;
const SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
SMESH_subMesh *theSubMesh = aMesh.GetSubMesh(aShape);
const TopoDS_Face& FF = TopoDS::Face(aShape);
bool faceIsForward = (FF.Orientation() == TopAbs_FORWARD);
TopoDS_Face F = TopoDS::Face(FF.Oriented(TopAbs_FORWARD));
const TopoDS_Face & FF = TopoDS::Face(aShape);
bool faceIsForward = (FF.Orientation() == TopAbs_FORWARD);
TopoDS_Face F = TopoDS::Face(FF.Oriented(TopAbs_FORWARD));
Z nblf; //nombre de lignes fermees (enveloppe en tete)
Z *nudslf=NULL; //numero du dernier sommet de chaque ligne fermee
R2 *uvslf=NULL;
Z nbpti=0; //nombre points internes futurs sommets de la triangulation
R2 *uvpti=NULL;
Z nbst;
R2 *uvst=NULL;
Z nbt;
Z *nust=NULL;
Z ierr=0;
Z nutysu=1; // 1: il existe un fonction areteideale_()
// Z nutysu=0; // 0: on utilise aretmx
R aretmx=_edgeLength; // longueur max aretes future triangulation
//SCRUTE(aretmx);
Z nblf; //nombre de lignes fermees (enveloppe en tete)
Z *nudslf = NULL; //numero du dernier sommet de chaque ligne fermee
R2 *uvslf = NULL;
Z nbpti = 0; //nombre points internes futurs sommets de la triangulation
R2 *uvpti = NULL;
nblf = NumberOfWires(F);
//SCRUTE(nblf);
Z nbst;
R2 *uvst = NULL;
Z nbt;
Z *nust = NULL;
Z ierr = 0;
nudslf = new Z[1+nblf];
nudslf[0] = 0;
int iw = 1;
int nbpnt = 0;
Z nutysu = 1; // 1: il existe un fonction areteideale_()
// Z nutysu=0; // 0: on utilise aretmx
R aretmx = _edgeLength; // longueur max aretes future triangulation
//SCRUTE(aretmx);
const TopoDS_Wire OW1 = BRepTools::OuterWire(F);
nbpnt += NumberOfPoints (aMesh, OW1);
nudslf [iw++] = nbpnt;
//SCRUTE(nbpnt);
nblf = NumberOfWires(F);
//SCRUTE(nblf);
for (TopExp_Explorer exp (F, TopAbs_WIRE); exp.More(); exp.Next())
{
const TopoDS_Wire& W = TopoDS::Wire(exp.Current());
if (!OW1.IsSame(W))
nudslf = new Z[1 + nblf];
nudslf[0] = 0;
int iw = 1;
int nbpnt = 0;
const TopoDS_Wire OW1 = BRepTools::OuterWire(F);
nbpnt += NumberOfPoints(aMesh, OW1);
nudslf[iw++] = nbpnt;
//SCRUTE(nbpnt);
for (TopExp_Explorer exp(F, TopAbs_WIRE); exp.More(); exp.Next())
{
nbpnt += NumberOfPoints (aMesh, W);
nudslf [iw++] = nbpnt;
//SCRUTE(nbpnt);
const TopoDS_Wire & W = TopoDS::Wire(exp.Current());
if (!OW1.IsSame(W))
{
nbpnt += NumberOfPoints(aMesh, W);
nudslf[iw++] = nbpnt;
//SCRUTE(nbpnt);
}
}
}
uvslf = new R2[nudslf[nblf]];
//SCRUTE(nudslf[nblf]);
int m = 0;
uvslf = new R2[nudslf[nblf]];
//SCRUTE(nudslf[nblf]);
int m = 0;
map<int,int> mefistoToDS; // correspondence mefisto index--> points IDNodes
TopoDS_Wire OW = BRepTools::OuterWire(F);
LoadPoints (aMesh, F, OW, uvslf, m, mefistoToDS);
//SCRUTE(m);
for (TopExp_Explorer exp (F, TopAbs_WIRE); exp.More(); exp.Next())
{
const TopoDS_Wire& W = TopoDS::Wire(exp.Current());
if (!OW.IsSame(W))
map < int, int >mefistoToDS; // correspondence mefisto index--> points IDNodes
TopoDS_Wire OW = BRepTools::OuterWire(F);
LoadPoints(aMesh, F, OW, uvslf, m, mefistoToDS);
//SCRUTE(m);
for (TopExp_Explorer exp(F, TopAbs_WIRE); exp.More(); exp.Next())
{
LoadPoints (aMesh, F, W, uvslf, m, mefistoToDS);
//SCRUTE(m);
const TopoDS_Wire & W = TopoDS::Wire(exp.Current());
if (!OW.IsSame(W))
{
LoadPoints(aMesh, F, W, uvslf, m, mefistoToDS);
//SCRUTE(m);
}
}
}
// SCRUTE(nudslf[nblf]);
// for (int i=0; i<=nblf; i++)
// {
@ -257,34 +252,35 @@ bool SMESH_MEFISTO_2D::Compute(SMESH_Mesh& aMesh,
// SCRUTE(aretmx);
// SCRUTE(nblf);
MESSAGE("MEFISTO triangulation ...");
uvst = NULL;
nust = NULL;
aptrte( nutysu, aretmx,
nblf, nudslf, uvslf,
nbpti, uvpti,
nbst, uvst, nbt, nust,
ierr );
MESSAGE("MEFISTO triangulation ...");
uvst = NULL;
nust = NULL;
aptrte(nutysu, aretmx,
nblf, nudslf, uvslf, nbpti, uvpti, nbst, uvst, nbt, nust, ierr);
if( ierr == 0 )
{
MESSAGE("... End Triangulation");
//SCRUTE(nbst);
//SCRUTE(nbt);
StoreResult (aMesh, nbst, uvst, nbt, nust, F,
faceIsForward, mefistoToDS);
isOk = true;
}
else
{
MESSAGE("Error in Triangulation");
isOk = false;
}
if (nudslf != NULL) delete [] nudslf;
if (uvslf != NULL) delete [] uvslf;
if (uvst != NULL) delete [] uvst;
if (nust != NULL) delete [] nust;
return isOk;
if (ierr == 0)
{
MESSAGE("... End Triangulation");
//SCRUTE(nbst);
//SCRUTE(nbt);
StoreResult(aMesh, nbst, uvst, nbt, nust, F,
faceIsForward, mefistoToDS);
isOk = true;
}
else
{
MESSAGE("Error in Triangulation");
isOk = false;
}
if (nudslf != NULL)
delete[]nudslf;
if (uvslf != NULL)
delete[]uvslf;
if (uvst != NULL)
delete[]uvst;
if (nust != NULL)
delete[]nust;
return isOk;
}
//=============================================================================
@ -293,125 +289,118 @@ bool SMESH_MEFISTO_2D::Compute(SMESH_Mesh& aMesh,
*/
//=============================================================================
void SMESH_MEFISTO_2D::LoadPoints(SMESH_Mesh& aMesh,
const TopoDS_Face& FF,
const TopoDS_Wire& WW,
R2* uvslf,
int& m,
map<int,int>& mefistoToDS)
void SMESH_MEFISTO_2D::LoadPoints(SMESH_Mesh & aMesh,
const TopoDS_Face & FF,
const TopoDS_Wire & WW, 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 scaley;
TopoDS_Face F = TopoDS::Face(FF.Oriented(TopAbs_FORWARD));
ComputeScaleOnFace(aMesh, F, scalex, scaley);
double scalex;
double scaley;
TopoDS_Face F = TopoDS::Face(FF.Oriented(TopAbs_FORWARD));
ComputeScaleOnFace(aMesh, F, scalex, scaley);
TopoDS_Wire W = TopoDS::Wire(WW.Oriented(TopAbs_FORWARD));
BRepTools_WireExplorer wexp(W,F);
for (wexp.Init(W,F);wexp.More(); wexp.Next())
{
const TopoDS_Edge& E = wexp.Current();
TopoDS_Wire W = TopoDS::Wire(WW.Oriented(TopAbs_FORWARD));
BRepTools_WireExplorer wexp(W, F);
for (wexp.Init(W, F); wexp.More(); wexp.Next())
{
const TopoDS_Edge & E = wexp.Current();
// --- IDNodes of first and last Vertex
// --- IDNodes of first and last Vertex
TopoDS_Vertex VFirst, VLast;
TopExp::Vertices(E, VFirst, VLast); // corresponds to f and l
TopoDS_Vertex VFirst, VLast;
TopExp::Vertices(E, VFirst, VLast); // corresponds to f and l
ASSERT(!VFirst.IsNull());
SMESH_subMesh* firstSubMesh = aMesh.GetSubMesh(VFirst);
const TColStd_ListOfInteger& lidf
= firstSubMesh->GetSubMeshDS()->GetIDNodes();
int idFirst= lidf.First();
ASSERT(!VFirst.IsNull());
SMESH_subMesh *firstSubMesh = aMesh.GetSubMesh(VFirst);
const vector<int> & lidf
= firstSubMesh->GetSubMeshDS()->GetIDNodes();
int idFirst = lidf[0];
// SCRUTE(idFirst);
ASSERT(!VLast.IsNull());
SMESH_subMesh* lastSubMesh = aMesh.GetSubMesh(VLast);
const TColStd_ListOfInteger& lidl
= lastSubMesh->GetSubMeshDS()->GetIDNodes();
int idLast= lidl.First();
ASSERT(!VLast.IsNull());
SMESH_subMesh *lastSubMesh = aMesh.GetSubMesh(VLast);
const vector<int> & lidl
= lastSubMesh->GetSubMeshDS()->GetIDNodes();
int idLast = lidl[0];
// 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();
//SCRUTE(nbPoints);
Standard_Real f,l;
Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E,F,f,l);
const TColStd_ListOfInteger& indElt
= aMesh.GetSubMesh(E)->GetSubMeshDS()->GetIDNodes();
TColStd_ListIteratorOfListOfInteger ite(indElt);
//SCRUTE(nbPoints);
//SCRUTE(indElt.Extent());
ASSERT(nbPoints == indElt.Extent());
bool isForward = (E.Orientation() == TopAbs_FORWARD);
map<double,int> params;
for (; ite.More(); ite.Next())
{
int nodeId = ite.Value();
Handle (SMDS_MeshElement) elt = meshDS->FindNode(nodeId);
Handle (SMDS_MeshNode) node = meshDS->GetNode(1, elt);
Handle (SMDS_EdgePosition) epos
= Handle (SMDS_EdgePosition)::DownCast(node->GetPosition());
double param = epos->GetUParameter();
params[param] = nodeId;
// MESSAGE(" " << param << " " << params[param]);
}
int nbPoints = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes();
//SCRUTE(nbPoints);
// --- load 2D values into MEFISTO structure,
// add IDNodes in mefistoToDS map
double f, l;
Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E, F, f, l);
if (E.Orientation() == TopAbs_FORWARD)
{
gp_Pnt2d p = C2d->Value(f); // first point = Vertex Forward
uvslf [m].x = scalex * p.X();
uvslf [m].y = scaley * p.Y();
mefistoToDS[m+1] = idFirst;
//MESSAGE(" "<<m<<" "<<mefistoToDS[m+1]);
//MESSAGE("__ f "<<f<<" "<<uvslf[m].x <<" "<<uvslf[m].y);
m++;
map<double,int>::iterator itp = params.begin();
for (Standard_Integer i = 1; i<=nbPoints; i++) // nbPoints internal
{
double param = (*itp).first;
gp_Pnt2d p = C2d->Value(param);
uvslf [m].x = scalex * p.X();
uvslf [m].y = scaley * p.Y();
mefistoToDS[m+1] = (*itp).second;
// MESSAGE(" "<<m<<" "<<mefistoToDS[m+1]);
// MESSAGE("__ "<<i<<" "<<param<<" "<<uvslf[m].x <<" "<<uvslf[m].y);
m++;
itp++;
}
const vector<int> & indElt
= aMesh.GetSubMesh(E)->GetSubMeshDS()->GetIDNodes();
ASSERT(nbPoints == indElt.size());
bool isForward = (E.Orientation() == TopAbs_FORWARD);
map < double, int >params;
for (int ite=0; ite<indElt.size(); ite++)
{
int nodeId = indElt[ite];
const SMDS_MeshNode * node = meshDS->FindNode(nodeId);
const SMDS_EdgePosition* epos
= static_cast<const SMDS_EdgePosition*>(node->GetPosition());
double param = epos->GetUParameter();
params[param] = nodeId;
}
// --- load 2D values into MEFISTO structure,
// add IDNodes in mefistoToDS map
if (E.Orientation() == TopAbs_FORWARD)
{
gp_Pnt2d p = C2d->Value(f); // first point = Vertex Forward
uvslf[m].x = scalex * p.X();
uvslf[m].y = scaley * p.Y();
mefistoToDS[m + 1] = idFirst;
//MESSAGE(" "<<m<<" "<<mefistoToDS[m+1]);
//MESSAGE("__ f "<<f<<" "<<uvslf[m].x <<" "<<uvslf[m].y);
m++;
map < double, int >::iterator itp = params.begin();
for (int i = 1; i <= nbPoints; i++) // nbPoints internal
{
double param = (*itp).first;
gp_Pnt2d p = C2d->Value(param);
uvslf[m].x = scalex * p.X();
uvslf[m].y = scaley * p.Y();
mefistoToDS[m + 1] = (*itp).second;
// MESSAGE(" "<<m<<" "<<mefistoToDS[m+1]);
// MESSAGE("__ "<<i<<" "<<param<<" "<<uvslf[m].x <<" "<<uvslf[m].y);
m++;
itp++;
}
}
else
{
gp_Pnt2d p = C2d->Value(l); // last point = Vertex Reversed
uvslf[m].x = scalex * p.X();
uvslf[m].y = scaley * p.Y();
mefistoToDS[m + 1] = idLast;
// MESSAGE(" "<<m<<" "<<mefistoToDS[m+1]);
// MESSAGE("__ l "<<l<<" "<<uvslf[m].x <<" "<<uvslf[m].y);
m++;
map < double, int >::reverse_iterator itp = params.rbegin();
for (int i = nbPoints; i >= 1; i--)
{
double param = (*itp).first;
gp_Pnt2d p = C2d->Value(param);
uvslf[m].x = scalex * p.X();
uvslf[m].y = scaley * p.Y();
mefistoToDS[m + 1] = (*itp).second;
// MESSAGE(" "<<m<<" "<<mefistoToDS[m+1]);
// MESSAGE("__ "<<i<<" "<<param<<" "<<uvslf[m].x <<" "<<uvslf[m].y);
m++;
itp++;
}
}
}
else
{
gp_Pnt2d p = C2d->Value(l); // last point = Vertex Reversed
uvslf [m].x = scalex * p.X();
uvslf [m].y = scaley * p.Y();
mefistoToDS[m+1] = idLast;
// MESSAGE(" "<<m<<" "<<mefistoToDS[m+1]);
// MESSAGE("__ l "<<l<<" "<<uvslf[m].x <<" "<<uvslf[m].y);
m++;
map<double,int>::reverse_iterator itp = params.rbegin();
for (Standard_Integer i = nbPoints ; i >= 1; i--)
{
double param = (*itp).first;
gp_Pnt2d p = C2d->Value(param);
uvslf [m].x = scalex * p.X();
uvslf [m].y = scaley * p.Y();
mefistoToDS[m+1] = (*itp).second;
// MESSAGE(" "<<m<<" "<<mefistoToDS[m+1]);
// MESSAGE("__ "<<i<<" "<<param<<" "<<uvslf[m].x <<" "<<uvslf[m].y);
m++;
itp++;
}
}
}
}
//=============================================================================
@ -422,72 +411,74 @@ void SMESH_MEFISTO_2D::LoadPoints(SMESH_Mesh& aMesh,
// **** a mettre dans SMESH_Algo ou SMESH_2D_Algo
void SMESH_MEFISTO_2D::ComputeScaleOnFace(SMESH_Mesh& aMesh,
const TopoDS_Face& aFace,
double& scalex,
double& scaley)
void SMESH_MEFISTO_2D::ComputeScaleOnFace(SMESH_Mesh & aMesh,
const TopoDS_Face & aFace, double &scalex, double &scaley)
{
//MESSAGE("SMESH_MEFISTO_2D::ComputeScaleOnFace");
TopoDS_Face F = TopoDS::Face(aFace.Oriented(TopAbs_FORWARD));
TopoDS_Wire W = BRepTools::OuterWire(F);
//MESSAGE("SMESH_MEFISTO_2D::ComputeScaleOnFace");
TopoDS_Face F = TopoDS::Face(aFace.Oriented(TopAbs_FORWARD));
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 xmax = -1.e300;
double ymin = 1.e300;
double ymax = -1.e300;
int nbp = 50;
scalex = 1;
scaley = 1;
for (wexp.Init(W,F);wexp.More(); wexp.Next())
{
const TopoDS_Edge& E = wexp.Current();
double f,l;
Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E,F,f,l);
for (int i = 0; i<= nbp; i++)
double xmin = 1.e300; // min & max of face 2D parametric coord.
double xmax = -1.e300;
double ymin = 1.e300;
double ymax = -1.e300;
int nbp = 50;
scalex = 1;
scaley = 1;
for (wexp.Init(W, F); wexp.More(); wexp.Next())
{
double param = f + (double(i)/double(nbp))*(l-f);
gp_Pnt2d p = C2d->Value(param);
if (p.X() < xmin) xmin = p.X();
if (p.X() > xmax) 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);
const TopoDS_Edge & E = wexp.Current();
double f, l;
Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E, F, f, l);
for (int i = 0; i <= nbp; i++)
{
double param = f + (double (i) / double (nbp))*(l - f);
gp_Pnt2d p = C2d->Value(param);
if (p.X() < xmin)
xmin = p.X();
if (p.X() > xmax)
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);
}
}
}
// SCRUTE(xmin);
// SCRUTE(xmax);
// SCRUTE(ymin);
// SCRUTE(ymax);
double xmoy = (xmax + xmin)/2.;
double ymoy = (ymax + ymin)/2.;
double xmoy = (xmax + xmin) / 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
double length_x = 0;
double length_y = 0;
gp_Pnt PX0 = S->Value(xmin, ymoy);
gp_Pnt PY0 = S->Value(xmoy, ymin);
for (Standard_Integer i = 1; i<= nbp; i++)
{
double x = xmin + (double(i)/double(nbp))*(xmax-xmin);
gp_Pnt PX = S->Value(x,ymoy);
double y = ymin + (double(i)/double(nbp))*(ymax-ymin);
gp_Pnt PY = S->Value(xmoy,y);
length_x += PX.Distance(PX0);
length_y += PY.Distance(PY0);
PX0.SetCoord(PX.X(),PX.Y(),PX.Z());
PY0.SetCoord(PY.X(),PY.Y(),PY.Z());
}
double length_x = 0;
double length_y = 0;
gp_Pnt PX0 = S->Value(xmin, ymoy);
gp_Pnt PY0 = S->Value(xmoy, ymin);
for (int i = 1; i <= nbp; i++)
{
double x = xmin + (double (i) / double (nbp))*(xmax - xmin);
gp_Pnt PX = S->Value(x, ymoy);
double y = ymin + (double (i) / double (nbp))*(ymax - ymin);
gp_Pnt PY = S->Value(xmoy, y);
length_x += PX.Distance(PX0);
length_y += PY.Distance(PY0);
PX0.SetCoord(PX.X(), PX.Y(), PX.Z());
PY0.SetCoord(PY.X(), PY.Y(), PY.Z());
}
// SCRUTE(length_x);
// SCRUTE(length_y);
scalex = length_x/(xmax - xmin);
scaley = length_y/(ymax - ymin);
scalex = length_x / (xmax - xmin);
scaley = length_y / (ymax - ymin);
// SCRUTE(scalex);
// SCRUTE(scaley);
ASSERT(scalex);
ASSERT(scaley);
ASSERT(scalex);
ASSERT(scaley);
}
//=============================================================================
@ -496,75 +487,69 @@ void SMESH_MEFISTO_2D::ComputeScaleOnFace(SMESH_Mesh& aMesh,
*/
//=============================================================================
void SMESH_MEFISTO_2D::StoreResult (SMESH_Mesh& aMesh,
Z nbst, R2* uvst, Z nbt, Z* nust,
const TopoDS_Face& F, bool faceIsForward,
map<int,int>& mefistoToDS)
void SMESH_MEFISTO_2D::StoreResult(SMESH_Mesh & aMesh,
Z nbst, R2 * uvst, Z nbt, Z * nust,
const TopoDS_Face & F, bool faceIsForward, map < int, int >&mefistoToDS)
{
double scalex;
double scaley;
ComputeScaleOnFace(aMesh, F, scalex, scaley);
double scalex;
double scaley;
ComputeScaleOnFace(aMesh, F, scalex, scaley);
Handle (SMESHDS_Mesh) meshDS = aMesh.GetMeshDS();
SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
Z n,m;
Handle(Geom_Surface) S = BRep_Tool::Surface(F);
for ( n=0; n<nbst; n++ )
{
double u = uvst[n][0]/scalex;
double v = uvst[n][1]/scaley;
gp_Pnt P = S->Value(u,v);
if (mefistoToDS.find(n+1) == mefistoToDS.end())
Z n, m;
Handle(Geom_Surface) S = BRep_Tool::Surface(F);
for (n = 0; n < nbst; n++)
{
int nodeId = 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);
//MESSAGE(nodeId<<" "<<P.X()<<" "<<P.Y()<<" "<<P.Z());
mefistoToDS[n+1] = nodeId;
//MESSAGE(" "<<n<<" "<<mefistoToDS[n+1]);
Handle (SMDS_FacePosition) fpos
= Handle (SMDS_FacePosition)::DownCast(node->GetPosition());
fpos->SetUParameter(u);
fpos->SetVParameter(v);
}
}
m=0;
int mt=0;
double u = uvst[n][0] / scalex;
double v = uvst[n][1] / scaley;
gp_Pnt P = S->Value(u, v);
//SCRUTE(faceIsForward);
for ( n=1; n<=nbt; n++ )
{
int inode1 = nust[m++];
int inode2 = nust[m++];
int inode3 = nust[m++];
if (mefistoToDS.find(n + 1) == mefistoToDS.end())
{
SMDS_MeshNode * node = meshDS->AddNode(P.X(), P.Y(), P.Z());
meshDS->SetNodeOnFace(node, F);
int nodeId1 = mefistoToDS[inode1];
int nodeId2 = mefistoToDS[inode2];
int nodeId3 = mefistoToDS[inode3];
//MESSAGE("-- "<<inode1<<" "<<inode2<<" "<<inode3<<" ++ "<<nodeId1<<" "<<nodeId2<<" "<<nodeId3);
// triangle points must be in trigonometric order if face is Forward
// else they must be put clockwise
bool triangleIsWellOriented = faceIsForward;
int faceId;
if (triangleIsWellOriented)
{
faceId = meshDS->AddFace(nodeId1, nodeId2, nodeId3);
//MESSAGE(nodeId<<" "<<P.X()<<" "<<P.Y()<<" "<<P.Z());
mefistoToDS[n + 1] = node->GetID();
//MESSAGE(" "<<n<<" "<<mefistoToDS[n+1]);
SMDS_FacePosition* fpos
= static_cast<SMDS_FacePosition*>(node->GetPosition());
fpos->SetUParameter(u);
fpos->SetVParameter(v);
}
}
else
m = 0;
int mt = 0;
//SCRUTE(faceIsForward);
for (n = 1; n <= nbt; n++)
{
faceId = meshDS->AddFace(nodeId1, nodeId3, nodeId2);
int inode1 = nust[m++];
int inode2 = nust[m++];
int inode3 = nust[m++];
int nodeId1 = mefistoToDS[inode1];
int nodeId2 = mefistoToDS[inode2];
int nodeId3 = mefistoToDS[inode3];
//MESSAGE("-- "<<inode1<<" "<<inode2<<" "<<inode3<<" ++ "<<nodeId1<<" "<<nodeId2<<" "<<nodeId3);
// triangle points must be in trigonometric order if face is Forward
// else they must be put clockwise
bool triangleIsWellOriented = faceIsForward;
SMDS_MeshElement * elt;
if (triangleIsWellOriented)
elt = meshDS->AddFace(nodeId1, nodeId2, nodeId3);
else
elt = meshDS->AddFace(nodeId1, nodeId3, nodeId2);
meshDS->SetMeshElementOnShape(elt, F);
m++;
}
Handle (SMDS_MeshElement) elt = meshDS->FindElement(faceId);
meshDS->SetMeshElementOnShape(elt, F);
m++;
}
}
//=============================================================================
@ -573,35 +558,35 @@ void SMESH_MEFISTO_2D::StoreResult (SMESH_Mesh& aMesh,
*/
//=============================================================================
double SMESH_MEFISTO_2D::ComputeEdgeElementLength(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape)
double SMESH_MEFISTO_2D::ComputeEdgeElementLength(SMESH_Mesh & aMesh,
const TopoDS_Shape & aShape)
{
MESSAGE("SMESH_MEFISTO_2D::ComputeEdgeElementLength");
// **** a mettre dans SMESH_2D_Algo ?
MESSAGE("SMESH_MEFISTO_2D::ComputeEdgeElementLength");
// **** a mettre dans SMESH_2D_Algo ?
const TopoDS_Face& FF = TopoDS::Face(aShape);
bool faceIsForward = (FF.Orientation() == TopAbs_FORWARD);
TopoDS_Face F = TopoDS::Face(FF.Oriented(TopAbs_FORWARD));
const TopoDS_Face & FF = TopoDS::Face(aShape);
bool faceIsForward = (FF.Orientation() == TopAbs_FORWARD);
TopoDS_Face F = TopoDS::Face(FF.Oriented(TopAbs_FORWARD));
double meanElementLength = 100;
double wireLength =0;
int wireElementsNumber =0;
for (TopExp_Explorer exp (F, TopAbs_WIRE); exp.More(); exp.Next())
{
const TopoDS_Wire& W = TopoDS::Wire(exp.Current());
for (TopExp_Explorer expe(W,TopAbs_EDGE); expe.More(); expe.Next())
double meanElementLength = 100;
double wireLength = 0;
int wireElementsNumber = 0;
for (TopExp_Explorer exp(F, TopAbs_WIRE); exp.More(); exp.Next())
{
const TopoDS_Edge& E = TopoDS::Edge(expe.Current());
int nb = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes();
double length = EdgeLength(E);
wireLength += length;
wireElementsNumber += nb;
const TopoDS_Wire & W = TopoDS::Wire(exp.Current());
for (TopExp_Explorer expe(W, TopAbs_EDGE); expe.More(); expe.Next())
{
const TopoDS_Edge & E = TopoDS::Edge(expe.Current());
int nb = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes();
double length = EdgeLength(E);
wireLength += length;
wireElementsNumber += nb;
}
}
}
if (wireElementsNumber)
meanElementLength = wireLength/wireElementsNumber;
//SCRUTE(meanElementLength);
return meanElementLength;
if (wireElementsNumber)
meanElementLength = wireLength / wireElementsNumber;
//SCRUTE(meanElementLength);
return meanElementLength;
}
//=============================================================================
@ -612,7 +597,7 @@ double SMESH_MEFISTO_2D::ComputeEdgeElementLength(SMESH_Mesh& aMesh,
ostream & SMESH_MEFISTO_2D::SaveTo(ostream & save)
{
return save << this;
return save << this;
}
//=============================================================================
@ -623,7 +608,7 @@ ostream & SMESH_MEFISTO_2D::SaveTo(ostream & save)
istream & SMESH_MEFISTO_2D::LoadFrom(istream & load)
{
return load >> (*this);
return load >> (*this);
}
//=============================================================================
@ -632,9 +617,9 @@ 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,25 +32,23 @@
#include "SMESH_Hypothesis.hxx"
#include "Utils_SALOME_Exception.hxx"
class SMESH_MaxElementArea:
public SMESH_Hypothesis
class SMESH_MaxElementArea:public SMESH_Hypothesis
{
public:
SMESH_MaxElementArea(int hypId, int studyId, SMESH_Gen* gen);
virtual ~SMESH_MaxElementArea();
public:
SMESH_MaxElementArea(int hypId, int studyId, SMESH_Gen * gen);
virtual ~ SMESH_MaxElementArea();
void SetMaxArea(double maxArea)
throw (SALOME_Exception);
void SetMaxArea(double maxArea) throw(SALOME_Exception);
double GetMaxArea();
double GetMaxArea() const;
virtual ostream & SaveTo(ostream & save);
virtual istream & LoadFrom(istream & load);
friend ostream & operator << (ostream & save, SMESH_MaxElementArea & hyp);
friend istream & operator >> (istream & load, SMESH_MaxElementArea & hyp);
virtual ostream & SaveTo(ostream & save);
virtual istream & LoadFrom(istream & load);
friend ostream & operator <<(ostream & save, SMESH_MaxElementArea & hyp);
friend istream & operator >>(istream & load, SMESH_MaxElementArea & hyp);
protected:
double _maxArea;
protected:
double _maxArea;
};
#endif

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

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

File diff suppressed because it is too large Load Diff

View File

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