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,8 +46,8 @@ 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;
@ -142,8 +139,7 @@ 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
@ -160,9 +156,8 @@ 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
@ -176,7 +171,8 @@ SMESH_Algo::GetUsedHypothesis(SMESH_Mesh& aMesh,
nbHyp = _usedHypList.size();
}
}
if (nbHyp > 1) _usedHypList.clear(); //only one compatible hypothesis allowed
if (nbHyp > 1)
_usedHypList.clear(); //only one compatible hypothesis allowed
return _usedHypList;
}
@ -188,28 +184,27 @@ 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;
_appliedHypList.clear();
while (it.More())
while (it!=listHyp.end())
{
SMESHDS_Hypothesis* anHyp = it.Value();
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(),
vector < string >::iterator ith =
find(_compatibleHypothesis.begin(), _compatibleHypothesis.end(),
hypName);
if (ith != _compatibleHypothesis.end()) // count only relevant
{
@ -217,12 +212,11 @@ SMESH_Algo::GetAppliedHypothesis(SMESH_Mesh& aMesh,
//SCRUTE(hypName);
}
}
it.Next();
it++;
}
return _appliedHypList;
}
//=============================================================================
/*!
* Compute length of an edge
@ -233,11 +227,11 @@ double SMESH_Algo::EdgeLength(const TopoDS_Edge& E)
{
double UMin = 0, UMax = 0;
TopLoc_Location L;
if (BRep_Tool::Degenerated(E)) return 0;
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,12 +37,12 @@
#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);
@ -52,16 +52,13 @@ public:
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);
@ -72,8 +69,8 @@ public:
protected:
vector<string> _compatibleHypothesis;
list<SMESHDS_Hypothesis*> _appliedHypList;
list<SMESHDS_Hypothesis*> _usedHypList;
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"
@ -73,12 +67,11 @@ SMESH_Gen::~SMESH_Gen()
*/
//=============================================================================
SMESH_Hypothesis* SMESH_Gen::CreateHypothesis(const char* anHyp,
int studyId)
SMESH_Hypothesis *SMESH_Gen::CreateHypothesis(const char *anHyp, int studyId)
throw(SALOME_Exception)
{
MESSAGE("SMESH_Gen::CreateHypothesis");
MESSAGE("CreateHypothesis("<<anHyp<<","<<studyId<<")");
// Get studyContext, create it if it does'nt exist, with a SMESHDS_Document
StudyContextStruct *myStudyContext = GetStudyContext(studyId);
@ -94,6 +87,7 @@ SMESH_Hypothesis* SMESH_Gen::CreateHypothesis(const char* anHyp,
// store hypothesis in SMESHDS document
myStudyContext->myDocument->AddHypothesis(myHypothesis);
return myHypothesis;
}
//=============================================================================
@ -178,16 +172,13 @@ Solid, Collection de Solid : 3D
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());
SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
//MESSAGE("point "<<nodeId<<" "<<P1.X()<<" "<<P1.Y()<<" "<<P1.Z());
Handle (SMDS_MeshElement) elt = meshDS->FindNode(nodeId);
Handle (SMDS_MeshNode) node = meshDS->GetNode(1, elt);
SMDS_MeshNode * node = meshDS->AddNode(P1.X(), P1.Y(), P1.Z());
meshDS->SetNodeOnVertex(node, V1);
const Handle(SMESHDS_SubMesh)& subMeshDS
= smToCompute->GetSubMeshDS();
smToCompute->GetSubMeshDS();
smToCompute->_vertexSet = true;
bool ret1 = smToCompute->ComputeStateEngine(SMESH_subMesh::COMPUTE);
smToCompute->ComputeStateEngine(SMESH_subMesh::COMPUTE);
}
smToCompute = sm->GetFirstToCompute();
}
@ -201,14 +192,13 @@ Solid, Collection de Solid : 3D
*/
//=============================================================================
SMESH_Algo* SMESH_Gen::GetAlgo(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape)
SMESH_Algo *SMESH_Gen::GetAlgo(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape)
{
//MESSAGE("SMESH_Gen::GetAlgo");
SMESHDS_Hypothesis* theHyp = NULL;
const SMESHDS_Hypothesis *theHyp = NULL;
SMESH_Algo *algo = NULL;
const Handle(SMESHDS_Mesh)& meshDS = aMesh.GetMeshDS();
const SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
int hypType;
int hypId;
int algoDim;
@ -222,27 +212,35 @@ SMESH_Algo* SMESH_Gen::GetAlgo(SMESH_Mesh& aMesh,
{
TopoDS_Shape tryShape = (*shapeToTry[iShape]);
const SMESHDS_ListOfPtrHypothesis& listHyp
= meshDS->GetHypothesis(tryShape);
SMESHDS_ListIteratorOfListOfPtrHypothesis it(listHyp);
const list<const SMESHDS_Hypothesis*>& listHyp =
meshDS->GetHypothesis(tryShape);
list<const SMESHDS_Hypothesis*>::const_iterator it=listHyp.begin();
int nb_algo = 0;
int shapeDim = GetShapeDim(aShape);
int typeOfShape = aShape.ShapeType();
while (it.More())
while (it!=listHyp.end())
{
SMESHDS_Hypothesis* anHyp = it.Value();
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;
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);
@ -262,21 +260,21 @@ SMESH_Algo* SMESH_Gen::GetAlgo(SMESH_Mesh& aMesh,
}
}
if (nb_algo > 1) return NULL; // more than one algo
it.Next();
it++;
}
if (nb_algo == 1) // one algo found : OK
break; // do not try a parent shape
}
if (!theHyp) return NULL; // no algo found
if (!theHyp)
return NULL; // no algo found
hypType = theHyp->GetType();
hypId = theHyp->GetID();
ASSERT(_mapAlgo.find(hypId) != _mapAlgo.end());
algo = _mapAlgo[hypId];
const char* algoName = algo->GetName();
//MESSAGE("Algo found " << algoName << " Id " << hypId);
//MESSAGE("Algo found " << algo->GetName() << " Id " << hypId);
return algo;
}
@ -340,7 +338,6 @@ const char* SMESH_Gen::ComponentDataType()
{
}
//=============================================================================
/*!
*

View File

@ -44,12 +44,13 @@
#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;
SMESHDS_Document * myDocument;
} StudyContextStruct;
class SMESH_Gen

View File

@ -26,7 +26,6 @@
// Module : SMESH
// $Header$
using namespace std;
using namespace std;
#include "SMESH_Hexa_3D.hxx"
#include "SMESH_Quadrangle_2D.hxx"
@ -52,7 +51,6 @@ using namespace std;
#include "utilities.h"
//=============================================================================
/*!
*
@ -60,15 +58,15 @@ using namespace std;
//=============================================================================
SMESH_Hexa_3D::SMESH_Hexa_3D(int hypId, int studyId,
SMESH_Gen* gen)
: SMESH_3D_Algo(hypId, studyId, gen)
SMESH_Gen * gen):SMESH_3D_Algo(hypId, studyId, gen)
{
MESSAGE("SMESH_Hexa_3D::SMESH_Hexa_3D");
_name = "Hexa_3D";
// _shapeType = TopAbs_SOLID;
_shapeType = (1 << TopAbs_SHELL) | (1 << TopAbs_SOLID); // 1 bit /shape type
// MESSAGE("_shapeType octal " << oct << _shapeType);
for (int i=0; i<6; i++) _quads[i] = 0;
for (int i = 0; i < 6; i++)
_quads[i] = 0;
}
//=============================================================================
@ -114,15 +112,14 @@ bool SMESH_Hexa_3D::CheckHypothesis(SMESH_Mesh& aMesh,
//=============================================================================
bool SMESH_Hexa_3D::Compute(SMESH_Mesh & aMesh,
const TopoDS_Shape& aShape)
throw (SALOME_Exception)
const TopoDS_Shape & aShape)throw(SALOME_Exception)
{
MESSAGE("SMESH_Hexa_3D::Compute");
bool isOk = false;
const Handle(SMESHDS_Mesh)& meshDS = aMesh.GetMeshDS();
SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
SMESH_subMesh *theSubMesh = aMesh.GetSubMesh(aShape);
//const Handle(SMESHDS_SubMesh)& subMeshDS = theSubMesh->GetSubMeshDS();
//const SMESHDS_SubMesh *& subMeshDS = theSubMesh->GetSubMeshDS();
// 0. - shape and face mesh verification
// 0.1 - shape must be a solid (or a shell) with 6 faces
@ -157,7 +154,8 @@ bool SMESH_Hexa_3D::Compute(SMESH_Mesh& aMesh,
ASSERT(0);
return false;
}
SMESH_Quadrangle_2D* quadAlgo =dynamic_cast<SMESH_Quadrangle_2D*> (algo);
SMESH_Quadrangle_2D *quadAlgo =
dynamic_cast < SMESH_Quadrangle_2D * >(algo);
ASSERT(quadAlgo);
try
{
@ -194,7 +192,8 @@ bool SMESH_Hexa_3D::Compute(SMESH_Mesh& aMesh,
Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E, F, f, l);
TopoDS_Vertex VFirst, VLast;
TopExp::Vertices(E, VFirst, VLast); // corresponds to f and l
bool isForward = (((l-f)*(_quads[0]->last[i] - _quads[0]->first[i])) > 0);
bool isForward =
(((l - f) * (_quads[0]->last[i] - _quads[0]->first[i])) > 0);
if (isForward)
{
@ -212,16 +211,20 @@ bool SMESH_Hexa_3D::Compute(SMESH_Mesh& aMesh,
C2d = BRep_Tool::CurveOnSurface(E, F, f, l);
TopExp::Vertices(E, VFirst, VLast);
isForward = (((l - f) * (_quads[0]->last[i] - _quads[0]->first[i])) > 0);
if (isForward) _cube.V101 = VLast; // will be (1,0,1) on the unit cube
else _cube.V101 = VFirst;
if (isForward)
_cube.V101 = VLast; // will be (1,0,1) on the unit cube
else
_cube.V101 = VFirst;
i = 2;
E = _quads[0]->edge[i];
C2d = BRep_Tool::CurveOnSurface(E, F, f, l);
TopExp::Vertices(E, VFirst, VLast);
isForward = (((l - f) * (_quads[0]->last[i] - _quads[0]->first[i])) > 0);
if (isForward) _cube.V001 = VLast; // will be (0,0,1) on the unit cube
else _cube.V001 = VFirst;
if (isForward)
_cube.V001 = VLast; // will be (0,0,1) on the unit cube
else
_cube.V001 = VFirst;
// 1.4 - find edge X=0, Z=0 (ancestor of V000 not in face Y=0)
// - find edge X=1, Z=0 (ancestor of V100 not in face Y=0)
@ -245,20 +248,28 @@ bool SMESH_Hexa_3D::Compute(SMESH_Mesh& aMesh,
MESSAGE("---");
TopExp::Vertices(E_0Y0, VFirst, VLast);
if (VFirst.IsSame(_cube.V000)) _cube.V010 = VLast;
else _cube.V010 = VFirst;
if (VFirst.IsSame(_cube.V000))
_cube.V010 = VLast;
else
_cube.V010 = VFirst;
TopExp::Vertices(E_1Y0, VFirst, VLast);
if (VFirst.IsSame(_cube.V100)) _cube.V110 = VLast;
else _cube.V110 = VFirst;
if (VFirst.IsSame(_cube.V100))
_cube.V110 = VLast;
else
_cube.V110 = VFirst;
TopExp::Vertices(E_1Y1, VFirst, VLast);
if (VFirst.IsSame(_cube.V101)) _cube.V111 = VLast;
else _cube.V111 = VFirst;
if (VFirst.IsSame(_cube.V101))
_cube.V111 = VLast;
else
_cube.V111 = VFirst;
TopExp::Vertices(E_0Y1, VFirst, VLast);
if (VFirst.IsSame(_cube.V001)) _cube.V011 = VLast;
else _cube.V011 = VFirst;
if (VFirst.IsSame(_cube.V001))
_cube.V011 = VLast;
else
_cube.V011 = VFirst;
// 1.6 - find remaining faces given 4 vertices
MESSAGE("---");
@ -298,23 +309,17 @@ bool SMESH_Hexa_3D::Compute(SMESH_Mesh& aMesh,
Conv2DStruct cz1;
GetConv2DCoefs(*_cube.quad_X0, meshFaces[_indX0]->GetSubShape(),
_cube.V000,_cube.V010,_cube.V011,_cube.V001,
cx0);
_cube.V000, _cube.V010, _cube.V011, _cube.V001, cx0);
GetConv2DCoefs(*_cube.quad_X1, meshFaces[_indX1]->GetSubShape(),
_cube.V100,_cube.V110,_cube.V111,_cube.V101,
cx1);
_cube.V100, _cube.V110, _cube.V111, _cube.V101, cx1);
GetConv2DCoefs(*_cube.quad_Y0, meshFaces[_indY0]->GetSubShape(),
_cube.V000,_cube.V100,_cube.V101,_cube.V001,
cy0);
_cube.V000, _cube.V100, _cube.V101, _cube.V001, cy0);
GetConv2DCoefs(*_cube.quad_Y1, meshFaces[_indY1]->GetSubShape(),
_cube.V010,_cube.V110,_cube.V111,_cube.V011,
cy1);
_cube.V010, _cube.V110, _cube.V111, _cube.V011, cy1);
GetConv2DCoefs(*_cube.quad_Z0, meshFaces[_indZ0]->GetSubShape(),
_cube.V000,_cube.V100,_cube.V110,_cube.V010,
cz0);
_cube.V000, _cube.V100, _cube.V110, _cube.V010, cz0);
GetConv2DCoefs(*_cube.quad_Z1, meshFaces[_indZ1]->GetSubShape(),
_cube.V001,_cube.V101,_cube.V111,_cube.V011,
cz1);
_cube.V001, _cube.V101, _cube.V111, _cube.V011, cz1);
// 1.8 - create a 3D structure for normalized values
@ -322,8 +327,10 @@ bool SMESH_Hexa_3D::Compute(SMESH_Mesh& aMesh,
int nbx = _cube.quad_Y0->nbPts[0];
int nby = _cube.quad_Y0->nbPts[1];
int nbz;
if (cx0.a1 != 0) nbz = _cube.quad_X0->nbPts[1];
else nbz = _cube.quad_X0->nbPts[0];
if (cx0.a1 != 0)
nbz = _cube.quad_X0->nbPts[1];
else
nbz = _cube.quad_X0->nbPts[0];
//SCRUTE(nbx);
//SCRUTE(nby);
//SCRUTE(nbz);
@ -334,22 +341,20 @@ bool SMESH_Hexa_3D::Compute(SMESH_Mesh& aMesh,
{
const TopoDS_Face & F = TopoDS::Face(meshFaces[_indX0]->GetSubShape());
const TColStd_ListOfInteger& indElt
const vector<int> & indElt
= aMesh.GetSubMesh(F)->GetSubMeshDS()->GetIDNodes();
TColStd_ListIteratorOfListOfInteger itf(indElt);
faceQuadStruct *quad = _cube.quad_X0;
int i = 0; // j = x/face , k = y/face
int nbdown = quad->nbPts[0];
int nbright = quad->nbPts[1];
for (; itf.More(); itf.Next())
for (int itf=0; itf<indElt.size(); itf++)
{
int nodeId = itf.Value();
Handle (SMDS_MeshElement) elt = meshDS->FindNode(nodeId);
Handle (SMDS_MeshNode) node = meshDS->GetNode(1, elt);
Handle (SMDS_FacePosition) fpos
= Handle (SMDS_FacePosition)::DownCast(node->GetPosition());
int nodeId = indElt[itf];
const SMDS_MeshNode * node = meshDS->FindNode(nodeId);
const SMDS_FacePosition* fpos
= static_cast<const SMDS_FacePosition*>(node->GetPosition());
double ri = fpos->GetUParameter();
double rj = fpos->GetVParameter();
int i1 = int (ri);
@ -373,22 +378,20 @@ bool SMESH_Hexa_3D::Compute(SMESH_Mesh& aMesh,
{
const TopoDS_Face & F = TopoDS::Face(meshFaces[_indX1]->GetSubShape());
const TColStd_ListOfInteger& indElt
const vector<int> & indElt
= aMesh.GetSubMesh(F)->GetSubMeshDS()->GetIDNodes();
TColStd_ListIteratorOfListOfInteger itf(indElt);
faceQuadStruct *quad = _cube.quad_X1;
int i = nbx - 1; // j = x/face , k = y/face
int nbdown = quad->nbPts[0];
int nbright = quad->nbPts[1];
for (; itf.More(); itf.Next())
for (int itf=0; itf<indElt.size(); itf++)
{
int nodeId = itf.Value();
Handle (SMDS_MeshElement) elt = meshDS->FindNode(nodeId);
Handle (SMDS_MeshNode) node = meshDS->GetNode(1, elt);
Handle (SMDS_FacePosition) fpos
= Handle (SMDS_FacePosition)::DownCast(node->GetPosition());
int nodeId = indElt[itf];
const SMDS_MeshNode * node = meshDS->FindNode(nodeId);
const SMDS_FacePosition* fpos
= static_cast<const SMDS_FacePosition*>(node->GetPosition());
double ri = fpos->GetUParameter();
double rj = fpos->GetVParameter();
int i1 = int (ri);
@ -412,22 +415,20 @@ bool SMESH_Hexa_3D::Compute(SMESH_Mesh& aMesh,
{
const TopoDS_Face & F = TopoDS::Face(meshFaces[_indY0]->GetSubShape());
const TColStd_ListOfInteger& indElt
const vector<int> & indElt
= aMesh.GetSubMesh(F)->GetSubMeshDS()->GetIDNodes();
TColStd_ListIteratorOfListOfInteger itf(indElt);
faceQuadStruct *quad = _cube.quad_Y0;
int j = 0; // i = x/face , k = y/face
int nbdown = quad->nbPts[0];
int nbright = quad->nbPts[1];
for (; itf.More(); itf.Next())
for (int itf=0; itf<indElt.size(); itf++)
{
int nodeId = itf.Value();
Handle (SMDS_MeshElement) elt = meshDS->FindNode(nodeId);
Handle (SMDS_MeshNode) node = meshDS->GetNode(1, elt);
Handle (SMDS_FacePosition) fpos
= Handle (SMDS_FacePosition)::DownCast(node->GetPosition());
int nodeId = indElt[itf];
const SMDS_MeshNode * node = meshDS->FindNode(nodeId);
const SMDS_FacePosition * fpos
= static_cast<const SMDS_FacePosition*>(node->GetPosition());
double ri = fpos->GetUParameter();
double rj = fpos->GetVParameter();
int i1 = int (ri);
@ -451,22 +452,20 @@ bool SMESH_Hexa_3D::Compute(SMESH_Mesh& aMesh,
{
const TopoDS_Face & F = TopoDS::Face(meshFaces[_indY1]->GetSubShape());
const TColStd_ListOfInteger& indElt
const vector<int> & indElt
= aMesh.GetSubMesh(F)->GetSubMeshDS()->GetIDNodes();
TColStd_ListIteratorOfListOfInteger itf(indElt);
faceQuadStruct *quad = _cube.quad_Y1;
int j = nby - 1; // i = x/face , k = y/face
int nbdown = quad->nbPts[0];
int nbright = quad->nbPts[1];
for (; itf.More(); itf.Next())
for (int itf=0; itf<indElt.size(); itf++)
{
int nodeId = itf.Value();
Handle (SMDS_MeshElement) elt = meshDS->FindNode(nodeId);
Handle (SMDS_MeshNode) node = meshDS->GetNode(1, elt);
Handle (SMDS_FacePosition) fpos
= Handle (SMDS_FacePosition)::DownCast(node->GetPosition());
int nodeId = indElt[itf];
const SMDS_MeshNode * node = meshDS->FindNode(nodeId);
const SMDS_FacePosition* fpos =
static_cast<const SMDS_FacePosition *>(node->GetPosition());
double ri = fpos->GetUParameter();
double rj = fpos->GetVParameter();
int i1 = int (ri);
@ -490,22 +489,20 @@ bool SMESH_Hexa_3D::Compute(SMESH_Mesh& aMesh,
{
const TopoDS_Face & F = TopoDS::Face(meshFaces[_indZ0]->GetSubShape());
const TColStd_ListOfInteger& indElt
const vector<int> & indElt
= aMesh.GetSubMesh(F)->GetSubMeshDS()->GetIDNodes();
TColStd_ListIteratorOfListOfInteger itf(indElt);
faceQuadStruct *quad = _cube.quad_Z0;
int k = 0; // i = x/face , j = y/face
int nbdown = quad->nbPts[0];
int nbright = quad->nbPts[1];
for (; itf.More(); itf.Next())
for (int itf=0; itf<indElt.size(); itf++)
{
int nodeId = itf.Value();
Handle (SMDS_MeshElement) elt = meshDS->FindNode(nodeId);
Handle (SMDS_MeshNode) node = meshDS->GetNode(1, elt);
Handle (SMDS_FacePosition) fpos
= Handle (SMDS_FacePosition)::DownCast(node->GetPosition());
int nodeId = indElt[itf];
const SMDS_MeshNode * node = meshDS->FindNode(nodeId);
const SMDS_FacePosition * fpos
= static_cast<const SMDS_FacePosition*>(node->GetPosition());
double ri = fpos->GetUParameter();
double rj = fpos->GetVParameter();
int i1 = int (ri);
@ -529,22 +526,20 @@ bool SMESH_Hexa_3D::Compute(SMESH_Mesh& aMesh,
{
const TopoDS_Face & F = TopoDS::Face(meshFaces[_indZ1]->GetSubShape());
const TColStd_ListOfInteger& indElt
const vector<int> & indElt
= aMesh.GetSubMesh(F)->GetSubMeshDS()->GetIDNodes();
TColStd_ListIteratorOfListOfInteger itf(indElt);
faceQuadStruct *quad = _cube.quad_Z1;
int k = nbz - 1; // i = x/face , j = y/face
int nbdown = quad->nbPts[0];
int nbright = quad->nbPts[1];
for (; itf.More(); itf.Next())
for(int itf=0; itf<indElt.size(); itf++)
{
int nodeId = itf.Value();
Handle (SMDS_MeshElement) elt = meshDS->FindNode(nodeId);
Handle (SMDS_MeshNode) node = meshDS->GetNode(1, elt);
Handle (SMDS_FacePosition) fpos
= Handle (SMDS_FacePosition)::DownCast(node->GetPosition());
int nodeId = indElt[itf];
const SMDS_MeshNode * node = meshDS->FindNode(nodeId);
const SMDS_FacePosition* fpos
= static_cast<const SMDS_FacePosition*>(node->GetPosition());
double ri = fpos->GetUParameter();
double rj = fpos->GetVParameter();
int i1 = int (ri);
@ -585,7 +580,6 @@ bool SMESH_Hexa_3D::Compute(SMESH_Mesh& aMesh,
ASSERT(0);
}
MESSAGE("---");
Pt3 p000, p001, p010, p011, p100, p101, p110, p111;
Pt3 px00, px01, px10, px11;
Pt3 p0y0, p0y1, p1y0, p1y1;
@ -656,13 +650,8 @@ bool SMESH_Hexa_3D::Compute(SMESH_Mesh& aMesh,
+ y * ((1 - z) * p110[i] + z * p111[i]));
}
int myNodeId = meshDS->AddNode(X[0],X[1],X[2]);
//MESSAGE("point "<<myNodeId<<" "<<X[0]<<" "<<X[1]<<" "<<X[2]);
np[ijk].nodeId = myNodeId;
Handle (SMDS_MeshElement) elt = meshDS->FindNode(myNodeId);
Handle (SMDS_MeshNode) node = meshDS->GetNode(1, elt);
SMDS_MeshNode * node = meshDS->AddNode(X[0], X[1], X[2]);
np[ijk].nodeId = node->GetID();
//meshDS->SetNodeInVolume(node, TopoDS::Solid(aShape));
meshDS->SetNodeInVolume(node, aShell);
}
@ -671,7 +660,7 @@ bool SMESH_Hexa_3D::Compute(SMESH_Mesh& aMesh,
//2.1 - for each node of the cube (less 3 *1 Faces):
// - store hexahedron in SMESHDS
MESSAGE("Storing hexahedron into the DS");
for (int i = 0; i < nbx - 1; i++)
for (int j = 0; j < nby - 1; j++)
for (int k = 0; k < nbz - 1; k++)
@ -688,7 +677,7 @@ bool SMESH_Hexa_3D::Compute(SMESH_Mesh& aMesh,
// MESSAGE(" "<<n1<<" "<<n2<<" "<<n3<<" "<<n4<<" "<<n5<<" "<<n6<<" "<<n7<<" "<<n8);
//MESSAGE(" "<<np[n1].nodeId<<" "<<np[n2].nodeId<<" "<<np[n3].nodeId<<" "<<np[n4].nodeId<<" "<<np[n5].nodeId<<" "<<np[n6].nodeId<<" "<<np[n7].nodeId<<" "<<np[n8].nodeId);
int hexa = meshDS->AddVolume(np[n1].nodeId,
SMDS_MeshVolume * elt = meshDS->AddVolume(np[n1].nodeId,
np[n2].nodeId,
np[n3].nodeId,
np[n4].nodeId,
@ -696,7 +685,7 @@ bool SMESH_Hexa_3D::Compute(SMESH_Mesh& aMesh,
np[n6].nodeId,
np[n7].nodeId,
np[n8].nodeId);
Handle (SMDS_MeshElement) elt = meshDS->FindElement(hexa);
;
meshDS->SetMeshElementOnShape(elt, aShell);
// *** 5 tetrahedres ... verifier orientations,
@ -725,6 +714,7 @@ bool SMESH_Hexa_3D::Compute(SMESH_Mesh& aMesh,
}
MESSAGE("End of SMESH_Hexa_3D::Compute()");
return true;
}
@ -734,16 +724,11 @@ bool SMESH_Hexa_3D::Compute(SMESH_Mesh& aMesh,
*/
//=============================================================================
void SMESH_Hexa_3D::GetPoint(Pt3 p,
int i, int j, int k,
int nbx, int nby, int nbz,
Point3DStruct *np,
const Handle(SMESHDS_Mesh)& meshDS)
void SMESH_Hexa_3D::GetPoint(Pt3 p, int i, int j, int k, int nbx, int nby,
int nbz, Point3DStruct * np, const SMESHDS_Mesh * meshDS)
{
int ijk = k * nbx * nby + j * nbx + i;
int nodeId = np[ijk].nodeId;
Handle (SMDS_MeshElement) elt = meshDS->FindNode(nodeId);
Handle (SMDS_MeshNode) node = meshDS->GetNode(1, elt);
const SMDS_MeshNode * node = meshDS->FindNode(np[ijk].nodeId);
p[0] = node->X();
p[1] = node->Y();
p[2] = node->Z();
@ -761,8 +746,7 @@ int SMESH_Hexa_3D::GetFaceIndex(SMESH_Mesh& aMesh,
const vector < SMESH_subMesh * >&meshFaces,
const TopoDS_Vertex & V0,
const TopoDS_Vertex & V1,
const TopoDS_Vertex& V2,
const TopoDS_Vertex& V3)
const TopoDS_Vertex & V2, const TopoDS_Vertex & V3)
{
MESSAGE("SMESH_Hexa_3D::GetFaceIndex");
int faceIndex = -1;
@ -776,7 +760,8 @@ int SMESH_Hexa_3D::GetFaceIndex(SMESH_Mesh& aMesh,
if (M.Contains(V0))
if (M.Contains(V1))
if (M.Contains(V2))
if (M.Contains(V3)) verticesInShape = true;
if (M.Contains(V3))
verticesInShape = true;
if (verticesInShape)
{
faceIndex = i;
@ -847,9 +832,7 @@ SMESH_Hexa_3D::EdgeNotInFace(SMESH_Mesh& aMesh,
const TopoDS_Shape & aShape,
const TopoDS_Vertex & V0,
const TopoDS_Vertex & V1,
const TopoDS_Vertex& V2,
const TopoDS_Vertex& V3,
Conv2DStruct& conv)
const TopoDS_Vertex & V2, const TopoDS_Vertex & V3, Conv2DStruct & conv)
{
MESSAGE("SMESH_Hexa_3D::GetConv2DCoefs");
const TopoDS_Face & F = TopoDS::Face(aShape);
@ -862,74 +845,114 @@ SMESH_Hexa_3D::EdgeNotInFace(SMESH_Mesh& aMesh,
TopoDS_Vertex VA, VB;
if (isForward)
{
VA = VFirst; VB = VLast;
VA = VFirst;
VB = VLast;
}
else
{
VA = VLast; VB = VFirst;
VA = VLast;
VB = VFirst;
}
int a1, b1, c1, a2, b2, c2;
if (VA.IsSame(V0))
if (VB.IsSame(V1))
{
a1= 1; b1= 0; c1= 0; // x
a2= 0; b2= 1; c2= 0; // y
a1 = 1;
b1 = 0;
c1 = 0; // x
a2 = 0;
b2 = 1;
c2 = 0; // y
}
else
{
ASSERT(VB.IsSame(V3));
a1= 0; b1= 1; c1= 0; // y
a2= 1; b2= 0; c2= 0; // x
a1 = 0;
b1 = 1;
c1 = 0; // y
a2 = 1;
b2 = 0;
c2 = 0; // x
}
if (VA.IsSame(V1))
if (VB.IsSame(V2))
{
a1= 0; b1=-1; c1= 1; // 1-y
a2= 1; b2= 0; c2= 0; // x
a1 = 0;
b1 = -1;
c1 = 1; // 1-y
a2 = 1;
b2 = 0;
c2 = 0; // x
}
else
{
ASSERT(VB.IsSame(V0));
a1=-1; b1= 0; c1= 1; // 1-x
a2= 0; b2= 1; c2= 0; // y
a1 = -1;
b1 = 0;
c1 = 1; // 1-x
a2 = 0;
b2 = 1;
c2 = 0; // y
}
if (VA.IsSame(V2))
if (VB.IsSame(V3))
{
a1=-1; b1= 0; c1= 1; // 1-x
a2= 0; b2=-1; c2= 1; // 1-y
a1 = -1;
b1 = 0;
c1 = 1; // 1-x
a2 = 0;
b2 = -1;
c2 = 1; // 1-y
}
else
{
ASSERT(VB.IsSame(V1));
a1= 0; b1=-1; c1= 1; // 1-y
a2=-1; b2= 0; c2= 1; // 1-x
a1 = 0;
b1 = -1;
c1 = 1; // 1-y
a2 = -1;
b2 = 0;
c2 = 1; // 1-x
}
if (VA.IsSame(V3))
if (VB.IsSame(V0))
{
a1= 0; b1= 1; c1= 0; // y
a2=-1; b2= 0; c2= 1; // 1-x
a1 = 0;
b1 = 1;
c1 = 0; // y
a2 = -1;
b2 = 0;
c2 = 1; // 1-x
}
else
{
ASSERT(VB.IsSame(V2));
a1= 1; b1= 0; c1= 0; // x
a2= 0; b2=-1; c2= 1; // 1-y
a1 = 1;
b1 = 0;
c1 = 0; // x
a2 = 0;
b2 = -1;
c2 = 1; // 1-y
}
MESSAGE("X = " << c1 << "+ " << a1 << "*x + " << b1 << "*y");
MESSAGE("Y = " << c2 << "+ " << a2 << "*x + " << b2 << "*y");
conv.a1=a1; conv.b1=b1; conv.c1=c1;
conv.a2=a2; conv.b2=b2; conv.c2=c2;
conv.a1 = a1;
conv.b1 = b1;
conv.c1 = c1;
conv.a2 = a2;
conv.b2 = b2;
conv.c2 = c2;
int nbdown = quad.nbPts[0];
int nbright = quad.nbPts[1];
conv.ia = int (a1);
conv.ib = int (b1);
conv.ic = int(c1*a1*a1)*(nbdown-1) + int(c1*b1*b1)*(nbright-1);
conv.ic =
int (c1 * a1 * a1) * (nbdown - 1) + int (c1 * b1 * b1) * (nbright - 1);
conv.ja = int (a2);
conv.jb = int (b2);
conv.jc = int(c2*a2*a2)*(nbdown-1) + int(c2*b2*b2)*(nbright-1);
conv.jc =
int (c2 * a2 * a2) * (nbdown - 1) + int (c2 * b2 * b2) * (nbright - 1);
MESSAGE("I " << conv.ia << " " << conv.ib << " " << conv.ic);
MESSAGE("J " << conv.ja << " " << conv.jb << " " << conv.jc);
}

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,8 +67,8 @@ 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";
@ -111,10 +108,10 @@ bool SMESH_MEFISTO_2D::CheckHypothesis(SMESH_Mesh& aMesh,
_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);
const list <const SMESHDS_Hypothesis * >&hyps = GetUsedHypothesis(aMesh, aShape);
int nbHyp = hyps.size();
if (nbHyp != 1) return false;// only one compatible hypothesis allowed
@ -129,7 +126,7 @@ bool SMESH_MEFISTO_2D::CheckHypothesis(SMESH_Mesh& aMesh,
if (hypName == "MaxElementArea")
{
_hypMaxElementArea = dynamic_cast<SMESH_MaxElementArea*> (theHyp);
_hypMaxElementArea = static_cast<const SMESH_MaxElementArea *>(theHyp);
ASSERT(_hypMaxElementArea);
_maxElementArea = _hypMaxElementArea->GetMaxArea();
_edgeLength = 0;
@ -138,14 +135,13 @@ bool SMESH_MEFISTO_2D::CheckHypothesis(SMESH_Mesh& aMesh,
if (hypName == "LengthFromEdges")
{
_hypLengthFromEdges = dynamic_cast<SMESH_LengthFromEdges*> (theHyp);
_hypLengthFromEdges = static_cast<const SMESH_LengthFromEdges *>(theHyp);
ASSERT(_hypLengthFromEdges);
_edgeLength = 0;
_maxElementArea = 0;
isOk = true;
}
if (isOk)
{
isOk = false;
@ -154,7 +150,8 @@ bool SMESH_MEFISTO_2D::CheckHypothesis(SMESH_Mesh& aMesh,
_edgeLength = 2 * sqrt(_maxElementArea); // triangles : minorant
isOk = true;
}
else isOk = (_hypLengthFromEdges != NULL); // **** check mode
else
isOk = (_hypLengthFromEdges != NULL); // **** check mode
}
//SCRUTE(_edgeLength);
@ -162,15 +159,13 @@ bool SMESH_MEFISTO_2D::CheckHypothesis(SMESH_Mesh& aMesh,
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");
@ -178,7 +173,7 @@ bool SMESH_MEFISTO_2D::Compute(SMESH_Mesh& aMesh,
_edgeLength = ComputeEdgeElementLength(aMesh, aShape);
bool isOk = false;
const Handle(SMESHDS_Mesh)& meshDS = aMesh.GetMeshDS();
const SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
SMESH_subMesh *theSubMesh = aMesh.GetSubMesh(aShape);
const TopoDS_Face & FF = TopoDS::Face(aShape);
@ -261,10 +256,7 @@ bool SMESH_MEFISTO_2D::Compute(SMESH_Mesh& aMesh,
uvst = NULL;
nust = NULL;
aptrte(nutysu, aretmx,
nblf, nudslf, uvslf,
nbpti, uvpti,
nbst, uvst, nbt, nust,
ierr );
nblf, nudslf, uvslf, nbpti, uvpti, nbst, uvst, nbt, nust, ierr);
if (ierr == 0)
{
@ -280,10 +272,14 @@ bool SMESH_MEFISTO_2D::Compute(SMESH_Mesh& aMesh,
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;
if (nudslf != NULL)
delete[]nudslf;
if (uvslf != NULL)
delete[]uvslf;
if (uvst != NULL)
delete[]uvst;
if (nust != NULL)
delete[]nust;
return isOk;
}
@ -295,14 +291,11 @@ 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)
const TopoDS_Wire & WW, R2 * uvslf, int &m, map < int, int >&mefistoToDS)
{
MESSAGE("SMESH_MEFISTO_2D::LoadPoints");
Handle (SMDS_Mesh) meshDS = aMesh.GetMeshDS();
SMDS_Mesh * meshDS = aMesh.GetMeshDS();
double scalex;
double scaley;
@ -322,16 +315,16 @@ void SMESH_MEFISTO_2D::LoadPoints(SMESH_Mesh& aMesh,
ASSERT(!VFirst.IsNull());
SMESH_subMesh *firstSubMesh = aMesh.GetSubMesh(VFirst);
const TColStd_ListOfInteger& lidf
const vector<int> & lidf
= firstSubMesh->GetSubMeshDS()->GetIDNodes();
int idFirst= lidf.First();
int idFirst = lidf[0];
// SCRUTE(idFirst);
ASSERT(!VLast.IsNull());
SMESH_subMesh *lastSubMesh = aMesh.GetSubMesh(VLast);
const TColStd_ListOfInteger& lidl
const vector<int> & lidl
= lastSubMesh->GetSubMeshDS()->GetIDNodes();
int idLast= lidl.First();
int idLast = lidl[0];
// SCRUTE(idLast);
// --- edge internal IDNodes (relies on good order storage, not checked)
@ -339,27 +332,23 @@ void SMESH_MEFISTO_2D::LoadPoints(SMESH_Mesh& aMesh,
int nbPoints = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes();
//SCRUTE(nbPoints);
Standard_Real f,l;
double f, l;
Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E, F, f, l);
const TColStd_ListOfInteger& indElt
const vector<int> & indElt
= aMesh.GetSubMesh(E)->GetSubMeshDS()->GetIDNodes();
TColStd_ListIteratorOfListOfInteger ite(indElt);
//SCRUTE(nbPoints);
//SCRUTE(indElt.Extent());
ASSERT(nbPoints == indElt.Extent());
ASSERT(nbPoints == indElt.size());
bool isForward = (E.Orientation() == TopAbs_FORWARD);
map < double, int >params;
for (; ite.More(); ite.Next())
for (int ite=0; ite<indElt.size(); ite++)
{
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());
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;
// MESSAGE(" " << param << " " << params[param]);
}
// --- load 2D values into MEFISTO structure,
@ -375,7 +364,7 @@ void SMESH_MEFISTO_2D::LoadPoints(SMESH_Mesh& aMesh,
//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
for (int i = 1; i <= nbPoints; i++) // nbPoints internal
{
double param = (*itp).first;
gp_Pnt2d p = C2d->Value(param);
@ -398,7 +387,7 @@ void SMESH_MEFISTO_2D::LoadPoints(SMESH_Mesh& aMesh,
// 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--)
for (int i = nbPoints; i >= 1; i--)
{
double param = (*itp).first;
gp_Pnt2d p = C2d->Value(param);
@ -423,9 +412,7 @@ 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)
const TopoDS_Face & aFace, double &scalex, double &scaley)
{
//MESSAGE("SMESH_MEFISTO_2D::ComputeScaleOnFace");
TopoDS_Face F = TopoDS::Face(aFace.Oriented(TopAbs_FORWARD));
@ -449,10 +436,14 @@ void SMESH_MEFISTO_2D::ComputeScaleOnFace(SMESH_Mesh& aMesh,
{
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();
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);
}
}
@ -469,7 +460,7 @@ void SMESH_MEFISTO_2D::ComputeScaleOnFace(SMESH_Mesh& aMesh,
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++)
for (int i = 1; i <= nbp; i++)
{
double x = xmin + (double (i) / double (nbp))*(xmax - xmin);
gp_Pnt PX = S->Value(x, ymoy);
@ -498,14 +489,13 @@ 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)
const TopoDS_Face & F, bool faceIsForward, map < int, int >&mefistoToDS)
{
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);
@ -518,16 +508,14 @@ void SMESH_MEFISTO_2D::StoreResult (SMESH_Mesh& aMesh,
if (mefistoToDS.find(n + 1) == mefistoToDS.end())
{
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);
SMDS_MeshNode * node = meshDS->AddNode(P.X(), P.Y(), P.Z());
meshDS->SetNodeOnFace(node, F);
//MESSAGE(nodeId<<" "<<P.X()<<" "<<P.Y()<<" "<<P.Z());
mefistoToDS[n+1] = nodeId;
mefistoToDS[n + 1] = node->GetID();
//MESSAGE(" "<<n<<" "<<mefistoToDS[n+1]);
Handle (SMDS_FacePosition) fpos
= Handle (SMDS_FacePosition)::DownCast(node->GetPosition());
SMDS_FacePosition* fpos
= static_cast<SMDS_FacePosition*>(node->GetPosition());
fpos->SetUParameter(u);
fpos->SetVParameter(v);
}
@ -552,16 +540,13 @@ void SMESH_MEFISTO_2D::StoreResult (SMESH_Mesh& aMesh,
// else they must be put clockwise
bool triangleIsWellOriented = faceIsForward;
int faceId;
SMDS_MeshElement * elt;
if (triangleIsWellOriented)
{
faceId = meshDS->AddFace(nodeId1, nodeId2, nodeId3);
}
elt = meshDS->AddFace(nodeId1, nodeId2, nodeId3);
else
{
faceId = meshDS->AddFace(nodeId1, nodeId3, nodeId2);
}
Handle (SMDS_MeshElement) elt = meshDS->FindElement(faceId);
elt = meshDS->AddFace(nodeId1, nodeId3, nodeId2);
meshDS->SetMeshElementOnShape(elt, F);
m++;
}
@ -647,4 +632,3 @@ istream & operator >> (istream & load, SMESH_MEFISTO_2D & hyp)
{
return load;
}

View File

@ -32,17 +32,15 @@
#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();
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);

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>
//=============================================================================
/*!
*
@ -69,9 +62,7 @@ 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;
@ -105,7 +96,9 @@ void SMESH_Mesh::ShapeToMesh(const TopoDS_Shape& aShape)
{
MESSAGE("SMESH_Mesh::ShapeToMesh");
if (_isShapeToMesh)
throw SALOME_Exception(LOCALIZED("a shape to mesh as already been defined"));
throw
SALOME_Exception(LOCALIZED
("a shape to mesh as already been defined"));
_isShapeToMesh = true;
_myMeshDS->ShapeToMesh(aShape);
@ -120,8 +113,7 @@ void SMESH_Mesh::ShapeToMesh(const TopoDS_Shape& aShape)
//=============================================================================
bool SMESH_Mesh::AddHypothesis(const TopoDS_Shape & aSubShape,
int anHypId)
throw (SALOME_Exception)
int anHypId) throw(SALOME_Exception)
{
MESSAGE("SMESH_Mesh::AddHypothesis");
@ -169,8 +161,7 @@ bool SMESH_Mesh::AddHypothesis(const TopoDS_Shape& aSubShape,
//=============================================================================
bool SMESH_Mesh::RemoveHypothesis(const TopoDS_Shape & aSubShape,
int anHypId)
throw (SALOME_Exception)
int anHypId)throw(SALOME_Exception)
{
MESSAGE("SMESH_Mesh::RemoveHypothesis");
@ -215,32 +206,32 @@ bool SMESH_Mesh::RemoveHypothesis(const TopoDS_Shape& aSubShape,
*/
//=============================================================================
const Handle(SMESHDS_Mesh)& SMESH_Mesh::GetMeshDS()
SMESHDS_Mesh * SMESH_Mesh::GetMeshDS()
{
return _myMeshDS;
}
//=============================================================================
/*!
*
*/
//=============================================================================
const list<SMESHDS_Hypothesis*>&
const list<const 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())
const list<const SMESHDS_Hypothesis*>& listHyp =
_myMeshDS->GetHypothesis(aSubShape);
list<const SMESHDS_Hypothesis*>::const_iterator it=listHyp.begin();
while (it!=listHyp.end())
{
SMESHDS_Hypothesis* anHyp = it.Value();
const SMESHDS_Hypothesis *anHyp = *it;
_subShapeHypothesisList.push_back(anHyp);
it.Next();
it++;
}
return _subShapeHypothesisList;
}
@ -251,20 +242,10 @@ SMESH_Mesh::GetHypothesisList(const TopoDS_Shape& aSubShape)
*/
//=============================================================================
const SMESHDS_ListOfCommand& SMESH_Mesh::GetLog()
throw (SALOME_Exception)
const list<SMESHDS_Command*> & SMESH_Mesh::GetLog() 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;
return _myMeshDS->GetScript()->GetCommands();
}
//=============================================================================
@ -272,12 +253,10 @@ const SMESHDS_ListOfCommand& SMESH_Mesh::GetLog()
*
*/
//=============================================================================
void SMESH_Mesh::ClearLog()
throw (SALOME_Exception)
void SMESH_Mesh::ClearLog() throw(SALOME_Exception)
{
MESSAGE("SMESH_Mesh::ClearLog");
Handle (SMESHDS_Script) scriptDS = _myMeshDS->GetScript();
scriptDS->Clear();
_myMeshDS->GetScript()->Clear();
}
//=============================================================================
@ -315,29 +294,32 @@ SMESH_subMesh* SMESH_Mesh::GetSubMesh(const TopoDS_Shape & aSubShape)
//MESSAGE("SMESH_Mesh::GetSubMesh");
SMESH_subMesh *aSubMesh;
int index = _subShapes.FindIndex(aSubShape);
if ( _mapSubMesh.find(index) != _mapSubMesh.end() ) {
if (_mapSubMesh.find(index) != _mapSubMesh.end())
{
aSubMesh = _mapSubMesh[index];
} else {
}
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);
}
* 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;
}
@ -366,21 +348,22 @@ SMESH_subMesh* SMESH_Mesh::GetSubMeshContaining(const TopoDS_Shape & aSubShape)
SMESH_subMesh *aSubMesh = NULL;
int index = _subShapes.FindIndex(aSubShape);
if ( _mapSubMesh.find(index) != _mapSubMesh.end() ) {
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);
}
* 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;
@ -391,7 +374,8 @@ SMESH_subMesh* SMESH_Mesh::GetSubMeshContaining(const TopoDS_Shape & aSubShape)
// if (isFound) break;
// }
if (! isFound) aSubMesh = NULL;
if (!isFound)
aSubMesh = NULL;
return aSubMesh;
}
@ -415,9 +399,9 @@ SMESH_Mesh::GetSubMeshUsingHypothesis(SMESHDS_Hypothesis* anHyp)
SMESH_Algo *algo = _gen->GetAlgo(*this, aSubMesh->GetSubShape());
if (algo != NULL)
{
const list<SMESHDS_Hypothesis*>& usedHyps
const list <const SMESHDS_Hypothesis * >&usedHyps
= algo->GetUsedHypothesis(*this, aSubMesh->GetSubShape());
list<SMESHDS_Hypothesis*>::const_iterator itl;
list <const SMESHDS_Hypothesis * >::const_iterator itl;
for (itl = usedHyps.begin(); itl != usedHyps.end(); itl++)
if (anHyp == (*itl))
{
@ -425,7 +409,8 @@ SMESH_Mesh::GetSubMeshUsingHypothesis(SMESHDS_Hypothesis* anHyp)
break;
}
}
if (usesHyp) _subMeshesUsingHypothesisList.push_back(aSubMesh);
if (usesHyp)
_subMeshesUsingHypothesisList.push_back(aSubMesh);
}
return _subMeshesUsingHypothesisList;
}
@ -436,19 +421,16 @@ 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 );
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));
@ -457,8 +439,7 @@ void SMESH_Mesh::ExportDAT( const char* file )
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));
@ -472,8 +453,7 @@ void SMESH_Mesh::ExportUNV( const char* file )
*
*/
//=============================================================================
int SMESH_Mesh::NbNodes()
throw (SALOME_Exception)
int SMESH_Mesh::NbNodes() throw(SALOME_Exception)
{
return _myMeshDS->NbNodes();
}
@ -483,8 +463,7 @@ int SMESH_Mesh::NbNodes()
*
*/
//=============================================================================
int SMESH_Mesh::NbEdges()
throw (SALOME_Exception)
int SMESH_Mesh::NbEdges() throw(SALOME_Exception)
{
return _myMeshDS->NbEdges();
}
@ -494,43 +473,34 @@ int SMESH_Mesh::NbEdges()
*
*/
//=============================================================================
int SMESH_Mesh::NbFaces()
throw (SALOME_Exception)
int SMESH_Mesh::NbFaces() throw(SALOME_Exception)
{
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 the number of 3 nodes faces in the mesh. This method run in O(n)
///////////////////////////////////////////////////////////////////////////////
int SMESH_Mesh::NbTriangles() throw(SALOME_Exception)
{
int Nb = 0;
SMDS_Iterator<const SMDS_MeshFace*> * itFaces=_myMeshDS->facesIterator();
while(itFaces->more()) if(itFaces->next()->NbNodes()==3) Nb++;
delete itFaces;
return Nb;
}
int SMESH_Mesh::NbQuadrangles()
throw (SALOME_Exception)
{
SMDS_MeshFacesIterator itFaces(_myMeshDS);
int Nb = 0;
for (;itFaces.More();itFaces.Next()) {
const Handle(SMDS_MeshElement)& elem = itFaces.Value();
switch (elem->NbNodes()) {
case 4 : {
Nb++;
break;
}
}
}
///////////////////////////////////////////////////////////////////////////////
/// 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,43 +509,26 @@ int SMESH_Mesh::NbQuadrangles()
*
*/
//=============================================================================
int SMESH_Mesh::NbVolumes()
throw (SALOME_Exception)
int SMESH_Mesh::NbVolumes() throw(SALOME_Exception)
{
return _myMeshDS->NbVolumes();
}
int SMESH_Mesh::NbTetras()
throw (SALOME_Exception)
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;
}
}
}
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 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;
}
}
}
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();
}

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>
@ -65,40 +61,33 @@ class SMESH_Mesh
{
public:
SMESH_Mesh();
SMESH_Mesh(int localId,
int studyId,
SMESH_Gen* gen,
const Handle(SMESHDS_Document)& myDocument);
SMESH_Mesh(int localId, int studyId, SMESH_Gen * gen,
SMESHDS_Document * myDocument);
virtual ~ SMESH_Mesh();
void ShapeToMesh(const TopoDS_Shape& aShape)
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)
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*>&
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();
SMESHDS_Mesh * GetMeshDS();
SMESH_Gen *GetGen();
@ -112,40 +101,27 @@ public:
GetSubMeshUsingHypothesis(SMESHDS_Hypothesis * anHyp)
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);
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 NbNodes() throw(SALOME_Exception);
int NbEdges()
throw (SALOME_Exception);
int NbEdges() throw(SALOME_Exception);
int NbFaces()
throw (SALOME_Exception);
int NbFaces() throw(SALOME_Exception);
int NbTriangles()
throw (SALOME_Exception);
int NbTriangles() throw(SALOME_Exception);
int NbQuadrangles()
throw (SALOME_Exception);
int NbQuadrangles() throw(SALOME_Exception);
int NbVolumes()
throw (SALOME_Exception);
int NbVolumes() throw(SALOME_Exception);
int NbTetras()
throw (SALOME_Exception);
int NbTetras() throw(SALOME_Exception);
int NbHexas()
throw (SALOME_Exception);
int NbSubMesh()
throw (SALOME_Exception);
int NbHexas() throw(SALOME_Exception);
int NbSubMesh() throw(SALOME_Exception);
private:
@ -153,10 +129,10 @@ private:
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<const SMESHDS_Hypothesis *> _subShapeHypothesisList;
list <SMESH_subMesh *> _subMeshesUsingHypothesisList;
Handle (SMESHDS_Document) _myDocument;
Handle (SMESHDS_Mesh) _myMeshDS;
SMESHDS_Document * _myDocument;
SMESHDS_Mesh * _myMeshDS;
TopTools_IndexedMapOfShape _subShapes;
map <int, SMESH_subMesh *>_mapSubMesh;
SMESH_Gen *_gen;

View File

@ -26,7 +26,6 @@
// Module : SMESH
// $Header$
using namespace std;
using namespace std;
#include "SMESH_Quadrangle_2D.hxx"
#include "SMESH_Gen.hxx"
@ -57,9 +56,7 @@ using namespace std;
//=============================================================================
SMESH_Quadrangle_2D::SMESH_Quadrangle_2D(int hypId,
int studyId,
SMESH_Gen* gen)
: SMESH_2D_Algo(hypId, studyId, gen)
int studyId, SMESH_Gen * gen):SMESH_2D_Algo(hypId, studyId, gen)
{
MESSAGE("SMESH_Quadrangle_2D::SMESH_Quadrangle_2D");
_name = "Quadrangle_2D";
@ -96,7 +93,6 @@ bool SMESH_Quadrangle_2D::CheckHypothesis(SMESH_Mesh& aMesh,
return isOk;
}
//=============================================================================
/*!
*
@ -104,15 +100,15 @@ bool SMESH_Quadrangle_2D::CheckHypothesis(SMESH_Mesh& aMesh,
//=============================================================================
bool SMESH_Quadrangle_2D::Compute(SMESH_Mesh & aMesh,
const TopoDS_Shape& aShape)
throw (SALOME_Exception)
const TopoDS_Shape & aShape)throw(SALOME_Exception)
{
//MESSAGE("SMESH_Quadrangle_2D::Compute");
const Handle(SMESHDS_Mesh)& meshDS = aMesh.GetMeshDS();
SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
SMESH_subMesh *theSubMesh = aMesh.GetSubMesh(aShape);
FaceQuadStruct *quad = CheckAnd2Dcompute(aMesh, aShape);
if (!quad) return false;
if (!quad)
return false;
// --- compute 3D values on points, store points & quadrangles
@ -137,17 +133,15 @@ bool SMESH_Quadrangle_2D::Compute(SMESH_Mesh& aMesh,
double u = quad->uv_grid[ij].u;
double v = quad->uv_grid[ij].v;
gp_Pnt P = S->Value(u, v);
int nodeId = meshDS->AddNode(P.X(), P.Y(), P.Z());
//MESSAGE("point "<< nodeId<<" "<<" "<<P.X()<<" "<<P.Y()<<" "<<P.Z());
Handle (SMDS_MeshElement) elt = meshDS->FindNode(nodeId);
Handle (SMDS_MeshNode) node = meshDS->GetNode(1, elt);
SMDS_MeshNode * node = meshDS->AddNode(P.X(), P.Y(), P.Z());
int nodeId = node->GetID();
meshDS->SetNodeOnFace(node, F);
quad->uv_grid[ij].nodeId = nodeId;
// Handle (SMDS_FacePosition) fpos
// = new SMDS_FacePosition(theSubMesh->GetId(),i,j); // easier than u,v
// node->SetPosition(fpos);
Handle (SMDS_FacePosition) fpos
= Handle (SMDS_FacePosition)::DownCast(node->GetPosition());
SMDS_FacePosition* fpos
= dynamic_cast<SMDS_FacePosition*>(node->GetPosition());
fpos->SetUParameter(i);
fpos->SetVParameter(j);
}
@ -163,9 +157,8 @@ bool SMESH_Quadrangle_2D::Compute(SMESH_Mesh& aMesh,
int faceId;
// if (isQuadForward) faceId = meshDS->AddFace(a,b,c,d);
// else faceId = meshDS->AddFace(a,d,c,b);
faceId = meshDS->AddFace(a,b,c,d);
Handle (SMDS_MeshElement) elt = meshDS->FindElement(faceId);
meshDS->SetMeshElementOnShape(elt, F);
SMDS_MeshFace * face = meshDS->AddFace(a, b, c, d);
meshDS->SetMeshElementOnShape(face, F);
}
QuadDelete(quad);
@ -179,10 +172,8 @@ bool SMESH_Quadrangle_2D::Compute(SMESH_Mesh& aMesh,
*/
//=============================================================================
FaceQuadStruct*
SMESH_Quadrangle_2D::CheckAnd2Dcompute(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape)
throw (SALOME_Exception)
FaceQuadStruct *SMESH_Quadrangle_2D::CheckAnd2Dcompute(SMESH_Mesh & aMesh,
const TopoDS_Shape & aShape)throw(SALOME_Exception)
{
//MESSAGE("SMESH_Quadrangle_2D::ComputeWithoutStore");
@ -208,7 +199,8 @@ SMESH_Quadrangle_2D::CheckAnd2Dcompute(SMESH_Mesh& aMesh,
BRepTools_WireExplorer wexp(W, F);
FaceQuadStruct *quad = new FaceQuadStruct;
for (int i=0; i<4; i++) quad->uv_edges[i] = 0;
for (int i = 0; i < 4; i++)
quad->uv_edges[i] = 0;
quad->uv_grid = 0;
int nbEdges = 0;
@ -257,7 +249,6 @@ SMESH_Quadrangle_2D::CheckAnd2Dcompute(SMESH_Mesh& aMesh,
return quad;
}
//=============================================================================
/*!
*
@ -271,10 +262,12 @@ SMESH_Quadrangle_2D::CheckAnd2Dcompute(SMESH_Mesh& aMesh,
{
for (int i = 0; i < 4; i++)
{
if (quad->uv_edges[i]) delete [] quad->uv_edges[i];
if (quad->uv_edges[i])
delete[]quad->uv_edges[i];
quad->edge[i].Nullify();
}
if (quad->uv_grid) delete [] quad->uv_grid;
if (quad->uv_grid)
delete[]quad->uv_grid;
delete quad;
}
}
@ -286,9 +279,7 @@ SMESH_Quadrangle_2D::CheckAnd2Dcompute(SMESH_Mesh& aMesh,
//=============================================================================
void SMESH_Quadrangle_2D::SetNormalizedGrid(SMESH_Mesh & aMesh,
const TopoDS_Shape& aShape,
FaceQuadStruct* quad)
throw (SALOME_Exception)
const TopoDS_Shape & aShape, FaceQuadStruct * quad) throw(SALOME_Exception)
{
// Algorithme décrit dans "Génération automatique de maillages"
// P.L. GEORGE, MASSON, § 6.4.1 p. 84-85
@ -317,9 +308,7 @@ void SMESH_Quadrangle_2D::SetNormalizedGrid(SMESH_Mesh& aMesh,
for (int i = 0; i < 4; i++)
{
c2d[i] = BRep_Tool::CurveOnSurface(quad->edge[i],
F,
quad->first[i],
quad->last[i]);
F, quad->first[i], quad->last[i]);
pf[i] = c2d[i]->Value(quad->first[i]);
pl[i] = c2d[i]->Value(quad->last[i]);
quad->isEdgeForward[i] = false;
@ -369,18 +358,14 @@ void SMESH_Quadrangle_2D::SetNormalizedGrid(SMESH_Mesh& aMesh,
for (int i = 0; i < 2; i++)
{
quad->uv_edges[i] = LoadEdgePoints(aMesh, F,
quad->edge[i],
quad->first[i],
quad->last[i]);
quad->edge[i], quad->first[i], quad->last[i]);
// quad->isEdgeForward[i]);
}
for (int i = 2; i < 4; i++)
{
quad->uv_edges[i] = LoadEdgePoints(aMesh, F,
quad->edge[i],
quad->last[i],
quad->first[i]);
quad->edge[i], quad->last[i], quad->first[i]);
// !quad->isEdgeForward[i]);
}
@ -457,14 +442,10 @@ void SMESH_Quadrangle_2D::SetNormalizedGrid(SMESH_Mesh& aMesh,
int ij = j * nbdown + i;
double x = uv_grid[ij].x;
double y = uv_grid[ij].y;
double param_0 = uv_e0[0].param
+ x*(uv_e0[nbdown-1].param -uv_e0[0].param); // sud
double param_2 = uv_e2[0].param
+ x*(uv_e2[nbdown-1].param -uv_e2[0].param); // nord
double param_1 = uv_e1[0].param
+ y*(uv_e1[nbright-1].param -uv_e1[0].param); // est
double param_3 = uv_e3[0].param
+ y*(uv_e3[nbright-1].param -uv_e3[0].param); // ouest
double param_0 = uv_e0[0].param + x * (uv_e0[nbdown - 1].param - uv_e0[0].param); // sud
double param_2 = uv_e2[0].param + x * (uv_e2[nbdown - 1].param - uv_e2[0].param); // nord
double param_1 = uv_e1[0].param + y * (uv_e1[nbright - 1].param - uv_e1[0].param); // est
double param_3 = uv_e3[0].param + y * (uv_e3[nbright - 1].param - uv_e3[0].param); // ouest
//MESSAGE("params "<<param_0<<" "<<param_1<<" "<<param_2<<" "<<param_3);
gp_Pnt2d p0 = c2d[0]->Value(param_0);
@ -472,11 +453,15 @@ void SMESH_Quadrangle_2D::SetNormalizedGrid(SMESH_Mesh& aMesh,
gp_Pnt2d p2 = c2d[2]->Value(param_2);
gp_Pnt2d p3 = c2d[3]->Value(param_3);
double u = (1-y)*p0.X() + x*p1.X() + y*p2.X() + (1-x)*p3.X();
double v = (1-y)*p0.Y() + x*p1.Y() + y*p2.Y() + (1-x)*p3.Y();
double u =
(1 - y) * p0.X() + x * p1.X() + y * p2.X() + (1 - x) * p3.X();
double v =
(1 - y) * p0.Y() + x * p1.Y() + y * p2.Y() + (1 - x) * p3.Y();
u -= (1-x)*(1-y)*a0.X() + x*(1-y)*a1.X() + x*y*a2.X() + (1-x)*y*a3.X();
v -= (1-x)*(1-y)*a0.Y() + x*(1-y)*a1.Y() + x*y*a2.Y() + (1-x)*y*a3.Y();
u -= (1 - x) * (1 - y) * a0.X() + x * (1 - y) * a1.X() +
x * y * a2.X() + (1 - x) * y * a3.X();
v -= (1 - x) * (1 - y) * a0.Y() + x * (1 - y) * a1.Y() +
x * y * a2.Y() + (1 - x) * y * a3.Y();
uv_grid[ij].u = u;
uv_grid[ij].v = v;
@ -492,15 +477,12 @@ void SMESH_Quadrangle_2D::SetNormalizedGrid(SMESH_Mesh& aMesh,
//=============================================================================
UVPtStruct *SMESH_Quadrangle_2D::LoadEdgePoints(SMESH_Mesh & aMesh,
const TopoDS_Face& F,
const TopoDS_Edge& E,
double first,
double last)
const TopoDS_Face & F, const TopoDS_Edge & E, double first, double last)
// bool isForward)
{
//MESSAGE("SMESH_Quadrangle_2D::LoadEdgePoints");
Handle (SMDS_Mesh) meshDS = aMesh.GetMeshDS();
SMDS_Mesh * meshDS = aMesh.GetMeshDS();
// --- IDNodes of first and last Vertex
@ -509,16 +491,16 @@ UVPtStruct* SMESH_Quadrangle_2D::LoadEdgePoints(SMESH_Mesh& aMesh,
ASSERT(!VFirst.IsNull());
SMESH_subMesh *firstSubMesh = aMesh.GetSubMesh(VFirst);
const TColStd_ListOfInteger& lidf
const vector<int>& lidf
= firstSubMesh->GetSubMeshDS()->GetIDNodes();
int idFirst= lidf.First();
int idFirst = lidf[0];
//SCRUTE(idFirst);
ASSERT(!VLast.IsNull());
SMESH_subMesh *lastSubMesh = aMesh.GetSubMesh(VLast);
const TColStd_ListOfInteger& lidl
const vector<int> & lidl
= lastSubMesh->GetSubMeshDS()->GetIDNodes();
int idLast= lidl.First();
int idLast = lidl[0];
//SCRUTE(idLast);
// --- edge internal IDNodes (relies on good order storage, not checked)
@ -530,21 +512,20 @@ UVPtStruct* SMESH_Quadrangle_2D::LoadEdgePoints(SMESH_Mesh& aMesh,
double f, l;
Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E, F, f, l);
const TColStd_ListOfInteger& indElt
const vector<int> & indElt
= aMesh.GetSubMesh(E)->GetSubMeshDS()->GetIDNodes();
TColStd_ListIteratorOfListOfInteger ite(indElt);
//SCRUTE(nbPoints);
//SCRUTE(indElt.Extent());
ASSERT(nbPoints == indElt.Extent());
ASSERT(nbPoints == indElt.size());
map<double, int> params;
for (; ite.More(); ite.Next())
for (int ite=0; ite<indElt.size(); ite++)
{
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());
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;
}

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,8 +57,8 @@ 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";
@ -140,10 +138,10 @@ bool SMESH_Regular_1D::CheckHypothesis(SMESH_Mesh& aMesh,
{
//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);
const list <const SMESHDS_Hypothesis * >&hyps = GetUsedHypothesis(aMesh, aShape);
int nbHyp = hyps.size();
if (nbHyp != 1) return false; // only one compatible hypothesis allowed
@ -158,7 +156,7 @@ bool SMESH_Regular_1D::CheckHypothesis(SMESH_Mesh& aMesh,
if (hypName == "LocalLength")
{
_hypLocalLength = dynamic_cast<SMESH_LocalLength*> (theHyp);
_hypLocalLength = dynamic_cast <const SMESH_LocalLength * >(theHyp);
ASSERT(_hypLocalLength);
_localLength = _hypLocalLength->GetLength();
_numberOfSegments = 0;
@ -167,7 +165,8 @@ bool SMESH_Regular_1D::CheckHypothesis(SMESH_Mesh& aMesh,
if (hypName == "NumberOfSegments")
{
_hypNumberOfSegments = dynamic_cast<SMESH_NumberOfSegments*> (theHyp);
_hypNumberOfSegments =
dynamic_cast <const SMESH_NumberOfSegments * >(theHyp);
ASSERT(_hypNumberOfSegments);
_numberOfSegments = _hypNumberOfSegments->GetNumberOfSegments();
_scaleFactor = _hypNumberOfSegments->GetScaleFactor();
@ -187,12 +186,11 @@ bool SMESH_Regular_1D::CheckHypothesis(SMESH_Mesh& aMesh,
*/
//=============================================================================
bool SMESH_Regular_1D::Compute(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape)
bool SMESH_Regular_1D::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape)
{
//MESSAGE("SMESH_Regular_1D::Compute");
MESSAGE("SMESH_Regular_1D::Compute");
const Handle(SMESHDS_Mesh)& meshDS = aMesh.GetMeshDS();
SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
SMESH_subMesh *theSubMesh = aMesh.GetSubMesh(aShape);
const TopoDS_Edge & EE = TopoDS::Edge(aShape);
@ -212,7 +210,8 @@ bool SMESH_Regular_1D::Compute(SMESH_Mesh& aMesh,
if (_localLength > 0)
{
double nbseg = ceil(length / _localLength); // integer sup
if (nbseg <=0) nbseg = 1; // degenerated edge
if (nbseg <= 0)
nbseg = 1; // degenerated edge
eltSize = length / nbseg;
}
else
@ -223,16 +222,16 @@ bool SMESH_Regular_1D::Compute(SMESH_Mesh& aMesh,
ASSERT(!VFirst.IsNull());
SMESH_subMesh *firstSubMesh = aMesh.GetSubMesh(VFirst);
const TColStd_ListOfInteger& lidf
const vector<int> & lidf
= firstSubMesh->GetSubMeshDS()->GetIDNodes();
int idFirst= lidf.First();
int idFirst = lidf[0];
//SCRUTE(idFirst);
ASSERT(!VLast.IsNull());
SMESH_subMesh *lastSubMesh = aMesh.GetSubMesh(VLast);
const TColStd_ListOfInteger& lidl
const vector<int> & lidl
= lastSubMesh->GetSubMeshDS()->GetIDNodes();
int idLast= lidl.First();
int idLast = lidl[0];
//SCRUTE(idLast);
if (!Curve.IsNull())
@ -255,8 +254,11 @@ bool SMESH_Regular_1D::Compute(SMESH_Mesh& aMesh,
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));
double alpha =
pow(_scaleFactor, 1.0 / (_numberOfSegments - 1));
double d =
length * (1 - pow(alpha, i - 1)) / (1 - pow(alpha,
_numberOfSegments));
param = d;
}
}
@ -264,28 +266,20 @@ bool SMESH_Regular_1D::Compute(SMESH_Mesh& aMesh,
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);
SMDS_MeshNode * node = meshDS->AddNode(P.X(), P.Y(), P.Z());
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());
SMDS_EdgePosition* epos=dynamic_cast<SMDS_EdgePosition *>(node->GetPosition());
epos->SetUParameter(param);
int edgeId = meshDS->AddEdge(idPrev, nodeId);
elt = meshDS->FindElement(edgeId);
meshDS->SetMeshElementOnShape(elt, E);
idPrev = nodeId;
SMDS_MeshEdge * edge = meshDS->AddEdge(idPrev, node->GetID());
meshDS->SetMeshElementOnShape(edge, E);
idPrev = node->GetID();
}
int edgeId = meshDS->AddEdge(idPrev, idLast);
Handle (SMDS_MeshElement) elt = meshDS->FindElement(edgeId);
meshDS->SetMeshElementOnShape(elt, E);
SMDS_MeshEdge* edge = meshDS->AddEdge(idPrev, idLast);
meshDS->SetMeshElementOnShape(edge, E);
}
else
{
@ -307,31 +301,25 @@ bool SMESH_Regular_1D::Compute(SMESH_Mesh& aMesh,
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);
Handle (SMDS_MeshElement) elt = meshDS->FindNode(nodeId);
Handle (SMDS_MeshNode) node = meshDS->GetNode(1, elt);
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);
Handle (SMDS_EdgePosition) epos
= Handle (SMDS_EdgePosition)::DownCast(node->GetPosition());
SMDS_EdgePosition* epos
= dynamic_cast<SMDS_EdgePosition*>(node->GetPosition());
epos->SetUParameter(param);
int edgeId = meshDS->AddEdge(idPrev, nodeId);
elt = meshDS->FindElement(edgeId);
meshDS->SetMeshElementOnShape(elt, E);
idPrev = nodeId;
SMDS_MeshEdge * edge = meshDS->AddEdge(idPrev, node->GetID());
meshDS->SetMeshElementOnShape(edge, E);
idPrev = node->GetID();
}
int edgeId = meshDS->AddEdge(idPrev, idLast);
Handle (SMDS_MeshElement) elt = meshDS->FindElement(edgeId);
meshDS->SetMeshElementOnShape(elt, E);
SMDS_MeshEdge * edge = meshDS->AddEdge(idPrev, idLast);
meshDS->SetMeshElementOnShape(edge, E);
}
else ASSERT(0);
else
ASSERT(0);
}
return true;
}

View File

@ -47,9 +47,7 @@ using namespace std;
*/
//=============================================================================
SMESH_subMesh::SMESH_subMesh(int Id,
SMESH_Mesh* father,
const Handle(SMESHDS_Mesh)& meshDS,
SMESH_subMesh::SMESH_subMesh(int Id, SMESH_Mesh * father, SMESHDS_Mesh * meshDS,
const TopoDS_Shape & aSubShape)
{
//MESSAGE("SMESH_subMesh::SMESH_subMesh");
@ -178,15 +176,14 @@ int SMESH_subMesh::GetId()
*/
//=============================================================================
const Handle(SMESHDS_SubMesh)& SMESH_subMesh::GetSubMeshDS()
throw (SALOME_Exception)
SMESHDS_SubMesh * SMESH_subMesh::GetSubMeshDS() throw(SALOME_Exception)
{
//MESSAGE("SMESH_subMesh::GetSubMeshDS");
if (_subMeshDS.IsNull())
if (_subMeshDS==NULL)
{
//MESSAGE("subMesh pointer still null, trying to get it...");
_subMeshDS = _meshDS->MeshElements(_subShape); // may be null ...
if (_subMeshDS.IsNull())
if (_subMeshDS==NULL)
{
MESSAGE("problem... subMesh still empty");
//NRI ASSERT(0);
@ -202,8 +199,7 @@ const Handle(SMESHDS_SubMesh)& SMESH_subMesh::GetSubMeshDS()
*/
//=============================================================================
SMESH_subMesh* SMESH_subMesh::GetFirstToCompute()
throw (SALOME_Exception)
SMESH_subMesh *SMESH_subMesh::GetFirstToCompute() throw(SALOME_Exception)
{
//MESSAGE("SMESH_subMesh::GetFirstToCompute");
const map < int, SMESH_subMesh * >&subMeshes = DependsOn();
@ -243,8 +239,7 @@ SMESH_subMesh* SMESH_subMesh::GetFirstToCompute()
*/
//=============================================================================
bool SMESH_subMesh::SubMeshesComputed()
throw (SALOME_Exception)
bool SMESH_subMesh::SubMeshesComputed() throw(SALOME_Exception)
{
//MESSAGE("SMESH_subMesh::SubMeshesComputed");
const map < int, SMESH_subMesh * >&subMeshes = DependsOn();
@ -311,7 +306,8 @@ bool SMESH_subMesh::SubMeshesReady()
const map < int, SMESH_subMesh * >&SMESH_subMesh::DependsOn()
{
if (_dependenceAnalysed) return _mapDepend;
if (_dependenceAnalysed)
return _mapDepend;
//MESSAGE("SMESH_subMesh::DependsOn");
@ -323,7 +319,8 @@ const map<int, SMESH_subMesh*>& SMESH_subMesh::DependsOn()
{
//MESSAGE("compound");
list < TopoDS_Shape > shellInSolid;
for (TopExp_Explorer exp(_subShape,TopAbs_SOLID);exp.More();exp.Next())
for (TopExp_Explorer exp(_subShape, TopAbs_SOLID); exp.More();
exp.Next())
{
InsertDependence(exp.Current());
for (TopExp_Explorer
@ -332,7 +329,8 @@ const map<int, SMESH_subMesh*>& SMESH_subMesh::DependsOn()
shellInSolid.push_back(exp2.Current());
}
}
for (TopExp_Explorer exp(_subShape,TopAbs_SHELL);exp.More();exp.Next())
for (TopExp_Explorer exp(_subShape, TopAbs_SHELL); exp.More();
exp.Next())
{
list < TopoDS_Shape >::iterator it1;
bool isInSolid = false;
@ -348,11 +346,13 @@ const map<int, SMESH_subMesh*>& SMESH_subMesh::DependsOn()
if (!isInSolid)
InsertDependence(exp.Current()); //only shell not in solid
}
for (TopExp_Explorer exp(_subShape,TopAbs_FACE);exp.More();exp.Next())
for (TopExp_Explorer exp(_subShape, TopAbs_FACE); exp.More();
exp.Next())
{
InsertDependence(exp.Current());
}
for (TopExp_Explorer exp(_subShape,TopAbs_EDGE);exp.More();exp.Next())
for (TopExp_Explorer exp(_subShape, TopAbs_EDGE); exp.More();
exp.Next())
{
InsertDependence(exp.Current());
}
@ -361,7 +361,8 @@ const map<int, SMESH_subMesh*>& SMESH_subMesh::DependsOn()
case TopAbs_COMPSOLID:
{
//MESSAGE("compsolid");
for (TopExp_Explorer exp(_subShape,TopAbs_SOLID);exp.More();exp.Next())
for (TopExp_Explorer exp(_subShape, TopAbs_SOLID); exp.More();
exp.Next())
{
InsertDependence(exp.Current());
}
@ -380,7 +381,8 @@ const map<int, SMESH_subMesh*>& SMESH_subMesh::DependsOn()
case TopAbs_SHELL:
{
//MESSAGE("shell");
for (TopExp_Explorer exp(_subShape,TopAbs_FACE);exp.More();exp.Next())
for (TopExp_Explorer exp(_subShape, TopAbs_FACE); exp.More();
exp.Next())
{
InsertDependence(exp.Current());
}
@ -399,7 +401,8 @@ const map<int, SMESH_subMesh*>& SMESH_subMesh::DependsOn()
case TopAbs_WIRE:
{
//MESSAGE("wire");
for (TopExp_Explorer exp(_subShape,TopAbs_EDGE);exp.More();exp.Next())
for (TopExp_Explorer exp(_subShape, TopAbs_EDGE); exp.More();
exp.Next())
{
InsertDependence(exp.Current());
}
@ -422,7 +425,8 @@ const map<int, SMESH_subMesh*>& SMESH_subMesh::DependsOn()
// {
// InsertDependence(exp.Current());
// }
for (TopExp_Explorer exp(_subShape,TopAbs_FACE);exp.More();exp.Next())
for (TopExp_Explorer exp(_subShape, TopAbs_FACE); exp.More();
exp.Next())
{
InsertDependence(exp.Current());
}
@ -435,7 +439,8 @@ const map<int, SMESH_subMesh*>& SMESH_subMesh::DependsOn()
// {
// InsertDependence(exp.Current());
// }
for (TopExp_Explorer exp(_subShape,TopAbs_EDGE);exp.More();exp.Next())
for (TopExp_Explorer exp(_subShape, TopAbs_EDGE); exp.More();
exp.Next())
{
InsertDependence(exp.Current());
}
@ -444,7 +449,8 @@ const map<int, SMESH_subMesh*>& SMESH_subMesh::DependsOn()
case TopAbs_EDGE:
{
//MESSAGE("edge");
for (TopExp_Explorer exp(_subShape,TopAbs_VERTEX);exp.More();exp.Next())
for (TopExp_Explorer exp(_subShape, TopAbs_VERTEX); exp.More();
exp.Next())
{
InsertDependence(exp.Current());
}
@ -584,13 +590,16 @@ bool SMESH_subMesh::AlgoStateEngine(int event, SMESH_Hypothesis* anHyp)
ret = _meshDS->AddHypothesis(_subShape, anHyp);
// if (ret &&(anHyp->GetDim() == SMESH_Gen::GetShapeDim(_subShape)))
// if (ret &&(anHyp->GetShapeType() == _subShape.ShapeType()))
if (ret &&(anHyp->GetShapeType() & (1<< _subShape.ShapeType())))
if (ret &&
(anHyp->GetShapeType() & (1 << _subShape.ShapeType())))
{
SMESH_Algo *algo = gen->GetAlgo((*_father), _subShape);
ASSERT(algo);
ret = algo->CheckHypothesis((*_father), _subShape);
if (ret) SetAlgoState(HYP_OK);
else SetAlgoState(MISSING_HYP);
if (ret)
SetAlgoState(HYP_OK);
else
SetAlgoState(MISSING_HYP);
}
}
break;
@ -613,8 +622,10 @@ bool SMESH_subMesh::AlgoStateEngine(int event, SMESH_Hypothesis* anHyp)
SMESH_Algo *algo = gen->GetAlgo((*_father), _subShape);
ASSERT(algo);
ret = algo->CheckHypothesis((*_father), _subShape);
if (ret) SetAlgoState(HYP_OK);
else SetAlgoState(MISSING_HYP);
if (ret)
SetAlgoState(HYP_OK);
else
SetAlgoState(MISSING_HYP);
}
break;
case REMOVE_FATHER_HYP: // nothing to do
@ -640,8 +651,10 @@ bool SMESH_subMesh::AlgoStateEngine(int event, SMESH_Hypothesis* anHyp)
SMESH_Algo *algo = gen->GetAlgo((*_father), _subShape);
ASSERT(algo);
ret = algo->CheckHypothesis((*_father), _subShape);
if (ret) SetAlgoState(HYP_OK);
else SetAlgoState(MISSING_HYP);
if (ret)
SetAlgoState(HYP_OK);
else
SetAlgoState(MISSING_HYP);
}
break;
case ADD_ALGO: //already existing algo : on father ?
@ -651,7 +664,8 @@ bool SMESH_subMesh::AlgoStateEngine(int event, SMESH_Hypothesis* anHyp)
ret = _meshDS->AddHypothesis(_subShape, anHyp);
// if (ret &&(anHyp->GetDim() == SMESH_Gen::GetShapeDim(_subShape)))
// if (ret &&(anHyp->GetShapeType() == _subShape.ShapeType()))
if (ret &&(anHyp->GetShapeType() & (1<< _subShape.ShapeType())))
if (ret &&
(anHyp->GetShapeType() & (1 << _subShape.ShapeType())))
{
SMESH_Algo *algo = gen->GetAlgo((*_father), _subShape);
if (algo == NULL) // two algo on the same subShape...
@ -663,8 +677,10 @@ bool SMESH_subMesh::AlgoStateEngine(int event, SMESH_Hypothesis* anHyp)
else
{
ret = algo->CheckHypothesis((*_father), _subShape);
if (ret) SetAlgoState(HYP_OK);
else SetAlgoState(MISSING_HYP);
if (ret)
SetAlgoState(HYP_OK);
else
SetAlgoState(MISSING_HYP);
}
}
}
@ -688,8 +704,10 @@ bool SMESH_subMesh::AlgoStateEngine(int event, SMESH_Hypothesis* anHyp)
else
{
ret = algo->CheckHypothesis((*_father), _subShape);
if (ret) SetAlgoState(HYP_OK);
else SetAlgoState(MISSING_HYP);
if (ret)
SetAlgoState(HYP_OK);
else
SetAlgoState(MISSING_HYP);
}
}
break;
@ -699,8 +717,10 @@ bool SMESH_subMesh::AlgoStateEngine(int event, SMESH_Hypothesis* anHyp)
SMESH_Algo *algo = gen->GetAlgo((*_father), _subShape);
ASSERT(algo);
ret = algo->CheckHypothesis((*_father), _subShape);
if (ret) SetAlgoState(HYP_OK);
else SetAlgoState(MISSING_HYP);
if (ret)
SetAlgoState(HYP_OK);
else
SetAlgoState(MISSING_HYP);
}
break;
case ADD_FATHER_ALGO: // detect if two algo of same dim on father
@ -718,8 +738,10 @@ bool SMESH_subMesh::AlgoStateEngine(int event, SMESH_Hypothesis* anHyp)
else
{
ret = algo->CheckHypothesis((*_father), _subShape);
if (ret) SetAlgoState(HYP_OK);
else SetAlgoState(MISSING_HYP);
if (ret)
SetAlgoState(HYP_OK);
else
SetAlgoState(MISSING_HYP);
}
}
break;
@ -739,8 +761,10 @@ bool SMESH_subMesh::AlgoStateEngine(int event, SMESH_Hypothesis* anHyp)
else
{
ret = algo->CheckHypothesis((*_father), _subShape);
if (ret) SetAlgoState(HYP_OK);
else SetAlgoState(MISSING_HYP);
if (ret)
SetAlgoState(HYP_OK);
else
SetAlgoState(MISSING_HYP);
}
}
break;
@ -760,8 +784,7 @@ bool SMESH_subMesh::AlgoStateEngine(int event, SMESH_Hypothesis* anHyp)
ASSERT(anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO);
SMESH_Algo *algo = gen->GetAlgo((*_father), _subShape);
ASSERT(algo);
list<SMESHDS_Hypothesis*> originalUsedHyps
= algo->GetUsedHypothesis((*_father), _subShape); // copy
list<const SMESHDS_Hypothesis *> originalUsedHyps = algo->GetUsedHypothesis((*_father), _subShape); // copy
ret = _meshDS->AddHypothesis(_subShape, anHyp);
if (ret)
@ -776,7 +799,7 @@ bool SMESH_subMesh::AlgoStateEngine(int event, SMESH_Hypothesis* anHyp)
else // compare SMESHDS_Hypothesis* lists (order important)
{
MESSAGE("---");
const list<SMESHDS_Hypothesis*>& newUsedHyps
const list <const SMESHDS_Hypothesis *> & newUsedHyps
= algo->GetUsedHypothesis((*_father), _subShape);
modifiedHyp = (originalUsedHyps != newUsedHyps);
}
@ -790,7 +813,8 @@ bool SMESH_subMesh::AlgoStateEngine(int event, SMESH_Hypothesis* anHyp)
ret = _meshDS->AddHypothesis(_subShape, anHyp);
// if (ret &&(anHyp->GetDim() == SMESH_Gen::GetShapeDim(_subShape)))
// if (ret &&(anHyp->GetShapeType() == _subShape.ShapeType()))
if (ret &&(anHyp->GetShapeType() & (1<< _subShape.ShapeType())))
if (ret &&
(anHyp->GetShapeType() & (1 << _subShape.ShapeType())))
{
SMESH_Algo *algo = gen->GetAlgo((*_father), _subShape);
if (algo == NULL) // two algo on the same subShape...
@ -802,8 +826,10 @@ bool SMESH_subMesh::AlgoStateEngine(int event, SMESH_Hypothesis* anHyp)
else
{
ret = algo->CheckHypothesis((*_father), _subShape);
if (ret) SetAlgoState(HYP_OK);
else SetAlgoState(MISSING_HYP);
if (ret)
SetAlgoState(HYP_OK);
else
SetAlgoState(MISSING_HYP);
}
}
}
@ -816,8 +842,10 @@ bool SMESH_subMesh::AlgoStateEngine(int event, SMESH_Hypothesis* anHyp)
SMESH_Algo *algo = gen->GetAlgo((*_father), _subShape);
ASSERT(algo);
ret = algo->CheckHypothesis((*_father), _subShape);
if (ret) SetAlgoState(HYP_OK);
else SetAlgoState(MISSING_HYP);
if (ret)
SetAlgoState(HYP_OK);
else
SetAlgoState(MISSING_HYP);
modifiedHyp = true;
}
break;
@ -836,8 +864,10 @@ bool SMESH_subMesh::AlgoStateEngine(int event, SMESH_Hypothesis* anHyp)
else
{
ret = algo->CheckHypothesis((*_father), _subShape);
if (ret) SetAlgoState(HYP_OK);
else SetAlgoState(MISSING_HYP);
if (ret)
SetAlgoState(HYP_OK);
else
SetAlgoState(MISSING_HYP);
}
}
break;
@ -847,8 +877,10 @@ bool SMESH_subMesh::AlgoStateEngine(int event, SMESH_Hypothesis* anHyp)
SMESH_Algo *algo = gen->GetAlgo((*_father), _subShape);
ASSERT(algo);
ret = algo->CheckHypothesis((*_father), _subShape);
if (ret) SetAlgoState(HYP_OK);
else SetAlgoState(MISSING_HYP);
if (ret)
SetAlgoState(HYP_OK);
else
SetAlgoState(MISSING_HYP);
}
break;
case ADD_FATHER_ALGO: // detect if two algo of same dim on father
@ -866,8 +898,10 @@ bool SMESH_subMesh::AlgoStateEngine(int event, SMESH_Hypothesis* anHyp)
else
{
ret = algo->CheckHypothesis((*_father), _subShape);
if (ret) SetAlgoState(HYP_OK);
else SetAlgoState(MISSING_HYP);
if (ret)
SetAlgoState(HYP_OK);
else
SetAlgoState(MISSING_HYP);
}
}
break;
@ -877,8 +911,10 @@ bool SMESH_subMesh::AlgoStateEngine(int event, SMESH_Hypothesis* anHyp)
SMESH_Algo *algo = gen->GetAlgo((*_father), _subShape);
ASSERT(algo);
ret = algo->CheckHypothesis((*_father), _subShape);
if (ret) SetAlgoState(HYP_OK);
else SetAlgoState(MISSING_HYP);
if (ret)
SetAlgoState(HYP_OK);
else
SetAlgoState(MISSING_HYP);
}
break;
case REMOVE_FATHER_ALGO:
@ -895,8 +931,10 @@ bool SMESH_subMesh::AlgoStateEngine(int event, SMESH_Hypothesis* anHyp)
else
{
ret = algo->CheckHypothesis((*_father), _subShape);
if (ret) SetAlgoState(HYP_OK);
else SetAlgoState(MISSING_HYP);
if (ret)
SetAlgoState(HYP_OK);
else
SetAlgoState(MISSING_HYP);
}
}
break;
@ -938,8 +976,7 @@ void SMESH_subMesh::SetAlgoState(int state)
//=============================================================================
void SMESH_subMesh::SubMeshesAlgoStateEngine(int event,
SMESH_Hypothesis* anHyp)
throw (SALOME_Exception)
SMESH_Hypothesis * anHyp) throw(SALOME_Exception)
{
//MESSAGE("SMESH_subMesh::SubMeshesAlgoStateEngine");
int dim = SMESH_Gen::GetShapeDim(_subShape);
@ -981,16 +1018,30 @@ void SMESH_subMesh::DumpAlgoState(bool isMain)
MESSAGE("dim = " << dim << " type of shape " << type);
switch (_algoState)
{
case NO_ALGO: MESSAGE(" AlgoState = NO_ALGO"); break;
case MISSING_HYP: MESSAGE(" AlgoState = MISSING_HYP"); break;
case HYP_OK: MESSAGE(" AlgoState = HYP_OK"); break;
case NO_ALGO:
MESSAGE(" AlgoState = NO_ALGO");
break;
case MISSING_HYP:
MESSAGE(" AlgoState = MISSING_HYP");
break;
case HYP_OK:
MESSAGE(" AlgoState = HYP_OK");
break;
}
switch (_computeState)
{
case NOT_READY: MESSAGE(" ComputeState = NOT_READY"); break;
case READY_TO_COMPUTE: MESSAGE(" ComputeState = READY_TO_COMPUTE"); break;
case COMPUTE_OK: MESSAGE(" ComputeState = COMPUTE_OK"); break;
case FAILED_TO_COMPUTE: MESSAGE(" ComputeState = FAILED_TO_COMPUTE");break;
case NOT_READY:
MESSAGE(" ComputeState = NOT_READY");
break;
case READY_TO_COMPUTE:
MESSAGE(" ComputeState = READY_TO_COMPUTE");
break;
case COMPUTE_OK:
MESSAGE(" ComputeState = COMPUTE_OK");
break;
case FAILED_TO_COMPUTE:
MESSAGE(" ComputeState = FAILED_TO_COMPUTE");
break;
}
}
@ -1000,8 +1051,7 @@ void SMESH_subMesh::DumpAlgoState(bool isMain)
*/
//=============================================================================
bool SMESH_subMesh::ComputeStateEngine(int event)
throw (SALOME_Exception)
bool SMESH_subMesh::ComputeStateEngine(int event) throw(SALOME_Exception)
{
//MESSAGE("SMESH_subMesh::ComputeStateEngine");
//SCRUTE(_computeState);
@ -1011,8 +1061,10 @@ bool SMESH_subMesh::ComputeStateEngine(int event)
if (dim < 1)
{
if (_vertexSet) _computeState = COMPUTE_OK;
else _computeState = READY_TO_COMPUTE;
if (_vertexSet)
_computeState = COMPUTE_OK;
else
_computeState = READY_TO_COMPUTE;
//SCRUTE(_computeState);
return true;
}
@ -1062,7 +1114,8 @@ bool SMESH_subMesh::ComputeStateEngine(int event)
if (algo)
{
ret = algo->CheckHypothesis((*_father), _subShape);
if (ret) _computeState = READY_TO_COMPUTE;
if (ret)
_computeState = READY_TO_COMPUTE;
}
break;
case COMPUTE:
@ -1103,7 +1156,8 @@ bool SMESH_subMesh::ComputeStateEngine(int event)
if (algo)
{
ret = algo->CheckHypothesis((*_father), _subShape);
if (ret) _computeState = READY_TO_COMPUTE;
if (ret)
_computeState = READY_TO_COMPUTE;
}
break;
case CLEANDEP:
@ -1113,7 +1167,8 @@ bool SMESH_subMesh::ComputeStateEngine(int event)
if (algo)
{
ret = algo->CheckHypothesis((*_father), _subShape);
if (ret) _computeState = READY_TO_COMPUTE;
if (ret)
_computeState = READY_TO_COMPUTE;
}
break;
case SUBMESH_COMPUTED: // nothing to do
@ -1147,7 +1202,8 @@ bool SMESH_subMesh::ComputeStateEngine(int event)
if (algo)
{
ret = algo->CheckHypothesis((*_father), _subShape);
if (ret) _computeState = READY_TO_COMPUTE;
if (ret)
_computeState = READY_TO_COMPUTE;
}
break;
case SUBMESH_COMPUTED: // nothing to do
@ -1166,12 +1222,14 @@ bool SMESH_subMesh::ComputeStateEngine(int event)
case MODIF_HYP:
if (_algoState == HYP_OK)
_computeState = READY_TO_COMPUTE;
else _computeState = NOT_READY;
else
_computeState = NOT_READY;
break;
case MODIF_ALGO_STATE:
if (_algoState == HYP_OK)
_computeState = READY_TO_COMPUTE;
else _computeState = NOT_READY;
else
_computeState = NOT_READY;
break;
case COMPUTE: // nothing to do
break;
@ -1181,12 +1239,14 @@ bool SMESH_subMesh::ComputeStateEngine(int event)
RemoveSubMeshElementsAndNodes();
if (_algoState == HYP_OK)
_computeState = READY_TO_COMPUTE;
else _computeState = NOT_READY;
else
_computeState = NOT_READY;
break;
case SUBMESH_COMPUTED: // allow retry compute
if (_algoState == HYP_OK)
_computeState = READY_TO_COMPUTE;
else _computeState = NOT_READY;
else
_computeState = NOT_READY;
break;
default:
ASSERT(0);
@ -1245,6 +1305,7 @@ void SMESH_subMesh::CleanDependants()
}
ComputeStateEngine(CLEANDEP);
}
//=============================================================================
/*!
*
@ -1258,29 +1319,26 @@ void SMESH_subMesh::RemoveSubMeshElementsAndNodes()
SCRUTE(_Id);
_subMeshDS = _meshDS->MeshElements(_subShape);
if (!_subMeshDS.IsNull())
if (_subMeshDS!=NULL)
{
const TColStd_ListOfInteger& indElt
= _subMeshDS->GetIDElements();
TColStd_ListIteratorOfListOfInteger ite(indElt);
for (; ite.More(); ite.Next())
const vector<int> & indElt = _subMeshDS->GetIDElements();
vector<int>::const_iterator ite=indElt.begin();
for (; ite!=indElt.end(); ite++)
{
int eltId = ite.Value();
int eltId = *ite;
SCRUTE(eltId);
Handle (SMDS_MeshElement) elt = _meshDS->FindElement(eltId);
const SMDS_MeshElement * elt = _meshDS->FindElement(eltId);
_subMeshDS->RemoveElement(elt);
_meshDS->RemoveElement(eltId);
}
const TColStd_ListOfInteger& indNodes
= _subMeshDS->GetIDNodes();
TColStd_ListIteratorOfListOfInteger itn(indNodes);
for (; itn.More(); itn.Next())
const vector<int> & indNodes = _subMeshDS->GetIDNodes();
vector<int>::const_iterator itn=indNodes.begin();
for (; itn!=indNodes.end(); itn++)
{
int nodeId = itn.Value();
int nodeId = *itn;
SCRUTE(nodeId);
Handle (SMDS_MeshElement) elt = _meshDS->FindNode(nodeId);
Handle (SMDS_MeshNode) node = _meshDS->GetNode(1, elt);
const SMDS_MeshNode * node = _meshDS->FindNode(nodeId);
_subMeshDS->RemoveNode(node);
_meshDS->RemoveNode(nodeId);
}
@ -1295,7 +1353,8 @@ void SMESH_subMesh::RemoveSubMeshElementsAndNodes()
const map < int, SMESH_subMesh * >&SMESH_subMesh::Dependants()
{
if (_dependantsFound) return _mapDependants;
if (_dependantsFound)
return _mapDependants;
//MESSAGE("SMESH_subMesh::Dependants");
@ -1314,19 +1373,22 @@ const map<int, SMESH_subMesh*>& SMESH_subMesh::Dependants()
TopExp::MapShapesAndAncestors(mainShape, TopAbs_EDGE, TopAbs_FACE, M);
TopExp::MapShapesAndAncestors(mainShape, TopAbs_EDGE, TopAbs_SHELL, M);
TopExp::MapShapesAndAncestors(mainShape, TopAbs_EDGE, TopAbs_SOLID, M);
TopExp::MapShapesAndAncestors(mainShape, TopAbs_EDGE, TopAbs_COMPSOLID, M);
TopExp::MapShapesAndAncestors(mainShape, TopAbs_EDGE, TopAbs_COMPSOLID,
M);
ExtractDependants(M, TopAbs_EDGE);
break;
case TopAbs_FACE:
case TopAbs_SHELL:
TopExp::MapShapesAndAncestors(mainShape, TopAbs_FACE, TopAbs_SHELL, M);
TopExp::MapShapesAndAncestors(mainShape, TopAbs_FACE, TopAbs_SOLID, M);
TopExp::MapShapesAndAncestors(mainShape, TopAbs_FACE, TopAbs_COMPSOLID, M);
TopExp::MapShapesAndAncestors(mainShape, TopAbs_FACE, TopAbs_COMPSOLID,
M);
ExtractDependants(M, TopAbs_FACE);
break;
case TopAbs_SOLID:
case TopAbs_COMPSOLID:
TopExp::MapShapesAndAncestors(mainShape, TopAbs_SOLID, TopAbs_COMPSOLID, M);
TopExp::MapShapesAndAncestors(mainShape, TopAbs_SOLID, TopAbs_COMPSOLID,
M);
ExtractDependants(M, TopAbs_SOLID);
break;
case TopAbs_COMPOUND:
@ -1343,7 +1405,8 @@ const map<int, SMESH_subMesh*>& SMESH_subMesh::Dependants()
*/
//=============================================================================
void SMESH_subMesh::ExtractDependants(const TopTools_IndexedDataMapOfShapeListOfShape& M,
void SMESH_subMesh::
ExtractDependants(const TopTools_IndexedDataMapOfShapeListOfShape & M,
const TopAbs_ShapeEnum etype)
{
//MESSAGE("SMESH_subMesh::ExtractDependants");
@ -1394,8 +1457,10 @@ void SMESH_subMesh::ExtractDependants(const TopTools_IndexedDataMapOfShapeListOf
{
MESSAGE("---");
TopoDS_Shape ancestor = it.Value();
SMESH_subMesh* aSubMesh = _father->GetSubMeshContaining(ancestor);
if (! aSubMesh) aSubMesh = _father->GetSubMesh(ancestor);
SMESH_subMesh *aSubMesh =
_father->GetSubMeshContaining(ancestor);
if (!aSubMesh)
aSubMesh = _father->GetSubMesh(ancestor);
int type = aSubMesh->_subShape.ShapeType();
int cle = aSubMesh->GetId();
cle += 10000000 * type; // sort map by ordType then index
@ -1411,4 +1476,3 @@ void SMESH_subMesh::ExtractDependants(const TopTools_IndexedDataMapOfShapeListOf
break;
}
}

View File

@ -46,9 +46,7 @@ class SMESH_Hypothesis;
class SMESH_subMesh
{
public:
SMESH_subMesh(int Id,
SMESH_Mesh* father,
const Handle(SMESHDS_Mesh)& meshDS,
SMESH_subMesh(int Id, SMESH_Mesh * father, SMESHDS_Mesh * meshDS,
const TopoDS_Shape & aSubShape);
virtual ~ SMESH_subMesh();
@ -57,11 +55,9 @@ public:
// 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();
@ -70,15 +66,22 @@ public:
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,
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};
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);
@ -88,17 +91,18 @@ public:
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);
// void FinalizeDependence(list<TopoDS_Shape>& shapeList);
bool SubMeshesComputed()
throw (SALOME_Exception);
bool SubMeshesComputed() throw(SALOME_Exception);
bool SubMeshesReady();
@ -110,8 +114,8 @@ protected:
void SetAlgoState(int state);
TopoDS_Shape _subShape;
Handle (SMESHDS_Mesh) _meshDS;
Handle (SMESHDS_SubMesh) _subMeshDS;
SMESHDS_Mesh * _meshDS;
SMESHDS_SubMesh * _subMeshDS;
int _Id;
SMESH_Mesh *_father;
map < int, SMESH_subMesh * >_mapDepend;