Use nodes and elements pointer instead on IDs

This commit is contained in:
jrt 2003-09-05 10:31:32 +00:00
parent 145c89df59
commit f7fbf1c622
15 changed files with 331 additions and 367 deletions

View File

@ -530,14 +530,11 @@ void DriverMED_W_SMESHDS_Mesh::Add()
//MESSAGE ("********* Traitement de la Famille "<<-t);
SMESHDS_SubMesh * SM = mySMESHDSMesh->MeshElements(S);
const vector<int>& indElt = SM->GetIDElements();
vector<int>::const_iterator ite=indElt.begin();
SMDS_Iterator<const SMDS_MeshElement*> * ite=SM->GetElements();
bool plein = false;
for (; ite!=indElt.end(); ite++)
while(ite->more())
{
int eltId = *ite;
mapFamille[eltId] = -t;
mapFamille[ite->next()->GetID()] = -t;
plein = true;
}
if (plein)
@ -640,6 +637,7 @@ void DriverMED_W_SMESHDS_Mesh::Add()
/* liberation memoire */
free(connectivite);
free(numele);
free(nomele);
free(nufael);
MESSAGE(" End " << typmai[i]);
}

View File

@ -341,18 +341,19 @@ bool SMESH_Hexa_3D::Compute(SMESH_Mesh & aMesh,
{
const TopoDS_Face & F = TopoDS::Face(meshFaces[_indX0]->GetSubShape());
const vector<int> & indElt
= aMesh.GetSubMesh(F)->GetSubMeshDS()->GetIDNodes();
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 (int itf=0; itf<indElt.size(); itf++)
SMDS_Iterator<const SMDS_MeshNode *> * itf=
aMesh.GetSubMesh(F)->GetSubMeshDS()->GetNodes();
while(itf->more())
{
int nodeId = indElt[itf];
const SMDS_MeshNode * node = meshDS->FindNode(nodeId);
const SMDS_MeshNode * node = itf->next();
const SMDS_FacePosition* fpos
= static_cast<const SMDS_FacePosition*>(node->GetPosition());
double ri = fpos->GetUParameter();
@ -360,8 +361,9 @@ bool SMESH_Hexa_3D::Compute(SMESH_Mesh & aMesh,
int i1 = int (ri);
int j1 = int (rj);
int ij1 = j1 * nbdown + i1;
quad->uv_grid[ij1].nodeId = nodeId;
quad->uv_grid[ij1].node = node;
}
delete itf;
for (int i1 = 0; i1 < nbdown; i1++)
for (int j1 = 0; j1 < nbright; j1++)
@ -371,25 +373,25 @@ bool SMESH_Hexa_3D::Compute(SMESH_Mesh & aMesh,
int k = cx0.ja * i1 + cx0.jb * j1 + cx0.jc; // k = y/face
int ijk = k * nbx * nby + j * nbx + i;
//MESSAGE(" "<<ij1<<" "<<i<<" "<<j<<" "<<ijk);
np[ijk].nodeId = quad->uv_grid[ij1].nodeId;
np[ijk].node = quad->uv_grid[ij1].node;
//SCRUTE(np[ijk].nodeId);
}
}
{
const TopoDS_Face & F = TopoDS::Face(meshFaces[_indX1]->GetSubShape());
const vector<int> & indElt
= aMesh.GetSubMesh(F)->GetSubMeshDS()->GetIDNodes();
SMDS_Iterator<const SMDS_MeshNode *> * itf=
aMesh.GetSubMesh(F)->GetSubMeshDS()->GetNodes();
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 (int itf=0; itf<indElt.size(); itf++)
while(itf->more())
{
int nodeId = indElt[itf];
const SMDS_MeshNode * node = meshDS->FindNode(nodeId);
const SMDS_MeshNode * node = itf->next();
const SMDS_FacePosition* fpos
= static_cast<const SMDS_FacePosition*>(node->GetPosition());
double ri = fpos->GetUParameter();
@ -397,8 +399,9 @@ bool SMESH_Hexa_3D::Compute(SMESH_Mesh & aMesh,
int i1 = int (ri);
int j1 = int (rj);
int ij1 = j1 * nbdown + i1;
quad->uv_grid[ij1].nodeId = nodeId;
quad->uv_grid[ij1].node = node;
}
delete itf;
for (int i1 = 0; i1 < nbdown; i1++)
for (int j1 = 0; j1 < nbright; j1++)
@ -408,25 +411,25 @@ bool SMESH_Hexa_3D::Compute(SMESH_Mesh & aMesh,
int k = cx1.ja * i1 + cx1.jb * j1 + cx1.jc; // k = y/face
int ijk = k * nbx * nby + j * nbx + i;
//MESSAGE(" "<<ij1<<" "<<i<<" "<<j<<" "<<ijk);
np[ijk].nodeId = quad->uv_grid[ij1].nodeId;
np[ijk].node = quad->uv_grid[ij1].node;
//SCRUTE(np[ijk].nodeId);
}
}
{
const TopoDS_Face & F = TopoDS::Face(meshFaces[_indY0]->GetSubShape());
const vector<int> & indElt
= aMesh.GetSubMesh(F)->GetSubMeshDS()->GetIDNodes();
SMDS_Iterator<const SMDS_MeshNode *> * itf=
aMesh.GetSubMesh(F)->GetSubMeshDS()->GetNodes();
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 (int itf=0; itf<indElt.size(); itf++)
while(itf->more())
{
int nodeId = indElt[itf];
const SMDS_MeshNode * node = meshDS->FindNode(nodeId);
const SMDS_MeshNode * node = itf->next();
const SMDS_FacePosition * fpos
= static_cast<const SMDS_FacePosition*>(node->GetPosition());
double ri = fpos->GetUParameter();
@ -434,7 +437,7 @@ bool SMESH_Hexa_3D::Compute(SMESH_Mesh & aMesh,
int i1 = int (ri);
int j1 = int (rj);
int ij1 = j1 * nbdown + i1;
quad->uv_grid[ij1].nodeId = nodeId;
quad->uv_grid[ij1].node = node;
}
for (int i1 = 0; i1 < nbdown; i1++)
@ -445,25 +448,25 @@ bool SMESH_Hexa_3D::Compute(SMESH_Mesh & aMesh,
int k = cy0.ja * i1 + cy0.jb * j1 + cy0.jc; // k = y/face
int ijk = k * nbx * nby + j * nbx + i;
//MESSAGE(" "<<ij1<<" "<<i<<" "<<j<<" "<<ijk);
np[ijk].nodeId = quad->uv_grid[ij1].nodeId;
np[ijk].node = quad->uv_grid[ij1].node;
//SCRUTE(np[ijk].nodeId);
}
}
{
const TopoDS_Face & F = TopoDS::Face(meshFaces[_indY1]->GetSubShape());
const vector<int> & indElt
= aMesh.GetSubMesh(F)->GetSubMeshDS()->GetIDNodes();
SMDS_Iterator<const SMDS_MeshNode *> * itf=
aMesh.GetSubMesh(F)->GetSubMeshDS()->GetNodes();
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 (int itf=0; itf<indElt.size(); itf++)
while(itf->more())
{
int nodeId = indElt[itf];
const SMDS_MeshNode * node = meshDS->FindNode(nodeId);
const SMDS_MeshNode * node = itf->next();
const SMDS_FacePosition* fpos =
static_cast<const SMDS_FacePosition *>(node->GetPosition());
double ri = fpos->GetUParameter();
@ -471,7 +474,7 @@ bool SMESH_Hexa_3D::Compute(SMESH_Mesh & aMesh,
int i1 = int (ri);
int j1 = int (rj);
int ij1 = j1 * nbdown + i1;
quad->uv_grid[ij1].nodeId = nodeId;
quad->uv_grid[ij1].node = node;
}
for (int i1 = 0; i1 < nbdown; i1++)
@ -482,25 +485,25 @@ bool SMESH_Hexa_3D::Compute(SMESH_Mesh & aMesh,
int k = cy1.ja * i1 + cy1.jb * j1 + cy1.jc; // k = y/face
int ijk = k * nbx * nby + j * nbx + i;
//MESSAGE(" "<<ij1<<" "<<i<<" "<<j<<" "<<ijk);
np[ijk].nodeId = quad->uv_grid[ij1].nodeId;
np[ijk].node = quad->uv_grid[ij1].node;
//SCRUTE(np[ijk].nodeId);
}
}
{
const TopoDS_Face & F = TopoDS::Face(meshFaces[_indZ0]->GetSubShape());
const vector<int> & indElt
= aMesh.GetSubMesh(F)->GetSubMeshDS()->GetIDNodes();
SMDS_Iterator<const SMDS_MeshNode *> * itf=
aMesh.GetSubMesh(F)->GetSubMeshDS()->GetNodes();
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 (int itf=0; itf<indElt.size(); itf++)
while(itf->more())
{
int nodeId = indElt[itf];
const SMDS_MeshNode * node = meshDS->FindNode(nodeId);
const SMDS_MeshNode * node = itf->next();
const SMDS_FacePosition * fpos
= static_cast<const SMDS_FacePosition*>(node->GetPosition());
double ri = fpos->GetUParameter();
@ -508,7 +511,7 @@ bool SMESH_Hexa_3D::Compute(SMESH_Mesh & aMesh,
int i1 = int (ri);
int j1 = int (rj);
int ij1 = j1 * nbdown + i1;
quad->uv_grid[ij1].nodeId = nodeId;
quad->uv_grid[ij1].node = node;
}
for (int i1 = 0; i1 < nbdown; i1++)
@ -519,25 +522,25 @@ bool SMESH_Hexa_3D::Compute(SMESH_Mesh & aMesh,
int j = cz0.ja * i1 + cz0.jb * j1 + cz0.jc; // j = y/face
int ijk = k * nbx * nby + j * nbx + i;
//MESSAGE(" "<<ij1<<" "<<i<<" "<<j<<" "<<ijk);
np[ijk].nodeId = quad->uv_grid[ij1].nodeId;
np[ijk].node = quad->uv_grid[ij1].node;
//SCRUTE(np[ijk].nodeId);
}
}
{
const TopoDS_Face & F = TopoDS::Face(meshFaces[_indZ1]->GetSubShape());
const vector<int> & indElt
= aMesh.GetSubMesh(F)->GetSubMeshDS()->GetIDNodes();
SMDS_Iterator<const SMDS_MeshNode *> * itf=
aMesh.GetSubMesh(F)->GetSubMeshDS()->GetNodes();
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(int itf=0; itf<indElt.size(); itf++)
while(itf->more())
{
int nodeId = indElt[itf];
const SMDS_MeshNode * node = meshDS->FindNode(nodeId);
const SMDS_MeshNode * node = itf->next();
const SMDS_FacePosition* fpos
= static_cast<const SMDS_FacePosition*>(node->GetPosition());
double ri = fpos->GetUParameter();
@ -545,7 +548,7 @@ bool SMESH_Hexa_3D::Compute(SMESH_Mesh & aMesh,
int i1 = int (ri);
int j1 = int (rj);
int ij1 = j1 * nbdown + i1;
quad->uv_grid[ij1].nodeId = nodeId;
quad->uv_grid[ij1].node = node;
}
for (int i1 = 0; i1 < nbdown; i1++)
@ -556,7 +559,7 @@ bool SMESH_Hexa_3D::Compute(SMESH_Mesh & aMesh,
int j = cz1.ja * i1 + cz1.jb * j1 + cz1.jc; // j = y/face
int ijk = k * nbx * nby + j * nbx + i;
//MESSAGE(" "<<ij1<<" "<<i<<" "<<j<<" "<<ijk);
np[ijk].nodeId = quad->uv_grid[ij1].nodeId;
np[ijk].node = quad->uv_grid[ij1].node;
//SCRUTE(np[ijk].nodeId);
}
}
@ -651,7 +654,7 @@ bool SMESH_Hexa_3D::Compute(SMESH_Mesh & aMesh,
}
SMDS_MeshNode * node = meshDS->AddNode(X[0], X[1], X[2]);
np[ijk].nodeId = node->GetID();
np[ijk].node = node;
//meshDS->SetNodeInVolume(node, TopoDS::Solid(aShape));
meshDS->SetNodeInVolume(node, aShell);
}
@ -677,14 +680,14 @@ 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);
SMDS_MeshVolume * elt = meshDS->AddVolume(np[n1].nodeId,
np[n2].nodeId,
np[n3].nodeId,
np[n4].nodeId,
np[n5].nodeId,
np[n6].nodeId,
np[n7].nodeId,
np[n8].nodeId);
SMDS_MeshVolume * elt = meshDS->AddVolume(np[n1].node,
np[n2].node,
np[n3].node,
np[n4].node,
np[n5].node,
np[n6].node,
np[n7].node,
np[n8].node);
;
meshDS->SetMeshElementOnShape(elt, aShell);
@ -728,7 +731,7 @@ 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;
const SMDS_MeshNode * node = meshDS->FindNode(np[ijk].nodeId);
const SMDS_MeshNode * node = np[ijk].node;
p[0] = node->X();
p[1] = node->Y();
p[2] = node->Z();

View File

@ -36,7 +36,7 @@
typedef struct point3Dstruct
{
int nodeId;
const SMDS_MeshNode * node;
} Point3DStruct;
typedef double Pt3[3];

View File

@ -225,7 +225,7 @@ bool SMESH_MEFISTO_2D::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape)
//SCRUTE(nudslf[nblf]);
int m = 0;
map < int, int >mefistoToDS; // correspondence mefisto index--> points IDNodes
map<int, const SMDS_MeshNode*> mefistoToDS; // correspondence mefisto index--> points IDNodes
TopoDS_Wire OW = BRepTools::OuterWire(F);
LoadPoints(aMesh, F, OW, uvslf, m, mefistoToDS);
//SCRUTE(m);
@ -291,7 +291,8 @@ bool SMESH_MEFISTO_2D::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape)
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, const SMDS_MeshNode*>&mefistoToDS)
{
MESSAGE("SMESH_MEFISTO_2D::LoadPoints");
@ -313,19 +314,16 @@ void SMESH_MEFISTO_2D::LoadPoints(SMESH_Mesh & aMesh,
TopoDS_Vertex VFirst, VLast;
TopExp::Vertices(E, VFirst, VLast); // corresponds to f and l
ASSERT(!VFirst.IsNull());
SMESH_subMesh *firstSubMesh = aMesh.GetSubMesh(VFirst);
const vector<int> & lidf
= firstSubMesh->GetSubMeshDS()->GetIDNodes();
int idFirst = lidf[0];
// SCRUTE(idFirst);
ASSERT(!VFirst.IsNull());
SMDS_Iterator<const SMDS_MeshNode *> * lid=
aMesh.GetSubMesh(VFirst)->GetSubMeshDS()->GetNodes();
const SMDS_MeshNode* idFirst = lid->next();
delete lid;
ASSERT(!VLast.IsNull());
SMESH_subMesh *lastSubMesh = aMesh.GetSubMesh(VLast);
const vector<int> & lidl
= lastSubMesh->GetSubMeshDS()->GetIDNodes();
int idLast = lidl[0];
// SCRUTE(idLast);
lid=aMesh.GetSubMesh(VLast)->GetSubMeshDS()->GetNodes();
const SMDS_MeshNode* idLast = lid->next();
delete lid;
// --- edge internal IDNodes (relies on good order storage, not checked)
@ -335,22 +333,21 @@ void SMESH_MEFISTO_2D::LoadPoints(SMESH_Mesh & aMesh,
double f, l;
Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E, F, f, l);
const vector<int> & indElt
= aMesh.GetSubMesh(E)->GetSubMeshDS()->GetIDNodes();
SMDS_Iterator<const SMDS_MeshNode *> * ite=
aMesh.GetSubMesh(E)->GetSubMeshDS()->GetNodes();
ASSERT(nbPoints == indElt.size());
bool isForward = (E.Orientation() == TopAbs_FORWARD);
map < double, int >params;
for (int ite=0; ite<indElt.size(); ite++)
map<double, const SMDS_MeshNode*> params;
while(ite->more())
{
int nodeId = indElt[ite];
const SMDS_MeshNode * node = meshDS->FindNode(nodeId);
const SMDS_MeshNode * node = ite->next();
const SMDS_EdgePosition* epos
= static_cast<const SMDS_EdgePosition*>(node->GetPosition());
double param = epos->GetUParameter();
params[param] = nodeId;
params[param] = node;
}
delete ite;
// --- load 2D values into MEFISTO structure,
// add IDNodes in mefistoToDS map
@ -363,7 +360,7 @@ void SMESH_MEFISTO_2D::LoadPoints(SMESH_Mesh & aMesh,
//MESSAGE(" "<<m<<" "<<mefistoToDS[m+1]);
//MESSAGE("__ f "<<f<<" "<<uvslf[m].x <<" "<<uvslf[m].y);
m++;
map < double, int >::iterator itp = params.begin();
map<double, const SMDS_MeshNode*>::iterator itp = params.begin();
for (int i = 1; i <= nbPoints; i++) // nbPoints internal
{
double param = (*itp).first;
@ -386,7 +383,7 @@ void SMESH_MEFISTO_2D::LoadPoints(SMESH_Mesh & aMesh,
// MESSAGE(" "<<m<<" "<<mefistoToDS[m+1]);
// MESSAGE("__ l "<<l<<" "<<uvslf[m].x <<" "<<uvslf[m].y);
m++;
map < double, int >::reverse_iterator itp = params.rbegin();
map<double, const SMDS_MeshNode*>::reverse_iterator itp = params.rbegin();
for (int i = nbPoints; i >= 1; i--)
{
double param = (*itp).first;
@ -489,7 +486,8 @@ 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, const SMDS_MeshNode*>&mefistoToDS)
{
double scalex;
double scaley;
@ -512,7 +510,7 @@ void SMESH_MEFISTO_2D::StoreResult(SMESH_Mesh & aMesh,
meshDS->SetNodeOnFace(node, F);
//MESSAGE(nodeId<<" "<<P.X()<<" "<<P.Y()<<" "<<P.Z());
mefistoToDS[n + 1] = node->GetID();
mefistoToDS[n + 1] = node;
//MESSAGE(" "<<n<<" "<<mefistoToDS[n+1]);
SMDS_FacePosition* fpos
= static_cast<SMDS_FacePosition*>(node->GetPosition());
@ -531,9 +529,10 @@ void SMESH_MEFISTO_2D::StoreResult(SMESH_Mesh & aMesh,
int inode2 = nust[m++];
int inode3 = nust[m++];
int nodeId1 = mefistoToDS[inode1];
int nodeId2 = mefistoToDS[inode2];
int nodeId3 = mefistoToDS[inode3];
const SMDS_MeshNode *n1, *n2, *n3;
n1 = mefistoToDS[inode1];
n2 = mefistoToDS[inode2];
n3 = mefistoToDS[inode3];
//MESSAGE("-- "<<inode1<<" "<<inode2<<" "<<inode3<<" ++ "<<nodeId1<<" "<<nodeId2<<" "<<nodeId3);
// triangle points must be in trigonometric order if face is Forward
@ -543,9 +542,9 @@ void SMESH_MEFISTO_2D::StoreResult(SMESH_Mesh & aMesh,
SMDS_MeshElement * elt;
if (triangleIsWellOriented)
elt = meshDS->AddFace(nodeId1, nodeId2, nodeId3);
elt = meshDS->AddFace(n1, n2, n3);
else
elt = meshDS->AddFace(nodeId1, nodeId3, nodeId2);
elt = meshDS->AddFace(n1, n3, n2);
meshDS->SetMeshElementOnShape(elt, F);
m++;

View File

@ -34,8 +34,8 @@
#include "SMESH_LengthFromEdges.hxx"
#include "Rn.h"
class SMDS_MeshNode;
#include <TopoDS_Face.hxx>
#include <map>
class SMESH_MEFISTO_2D:
@ -59,7 +59,7 @@ public:
const TopoDS_Wire& W,
R2* uvslf,
int& m,
map<int,int>& mefistoToDS);
map<int,const SMDS_MeshNode*>& mefistoToDS);
void ComputeScaleOnFace(SMESH_Mesh& aMesh,
const TopoDS_Face& aFace,
@ -69,7 +69,7 @@ public:
void StoreResult (SMESH_Mesh& aMesh,
Z nbst, R2* uvst, Z nbt, Z* nust,
const TopoDS_Face& F, bool faceIsForward,
map<int,int>& mefistoToDS);
map<int,const SMDS_MeshNode*>& mefistoToDS);
ostream & SaveTo(ostream & save);
istream & LoadFrom(istream & load);

View File

@ -134,9 +134,8 @@ bool SMESH_Quadrangle_2D::Compute(SMESH_Mesh & aMesh,
double v = quad->uv_grid[ij].v;
gp_Pnt P = S->Value(u, v);
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;
quad->uv_grid[ij].node = node;
// Handle (SMDS_FacePosition) fpos
// = new SMDS_FacePosition(theSubMesh->GetId(),i,j); // easier than u,v
// node->SetPosition(fpos);
@ -150,11 +149,11 @@ bool SMESH_Quadrangle_2D::Compute(SMESH_Mesh & aMesh,
for (int i = 0; i < nbdown - 1; i++)
for (int j = 0; j < nbright - 1; j++) // faces
{
int a = quad->uv_grid[j * nbdown + i].nodeId;
int b = quad->uv_grid[j * nbdown + i + 1].nodeId;
int c = quad->uv_grid[(j + 1) * nbdown + i + 1].nodeId;
int d = quad->uv_grid[(j + 1) * nbdown + i].nodeId;
int faceId;
const SMDS_MeshNode *a, *b, *c, *d;
a = quad->uv_grid[j * nbdown + i].node;
b = quad->uv_grid[j * nbdown + i + 1].node;
c = quad->uv_grid[(j + 1) * nbdown + i + 1].node;
d = quad->uv_grid[(j + 1) * nbdown + i].node;
// if (isQuadForward) faceId = meshDS->AddFace(a,b,c,d);
// else faceId = meshDS->AddFace(a,d,c,b);
SMDS_MeshFace * face = meshDS->AddFace(a, b, c, d);
@ -392,25 +391,25 @@ void SMESH_Quadrangle_2D::SetNormalizedGrid(SMESH_Mesh & aMesh,
for (int i = 0; i < nbdown; i++)
{
int ij = j * nbdown + i;
uv_grid[ij].nodeId = uv_e0[i].nodeId;
uv_grid[ij].node = uv_e0[i].node;
}
i = nbdown - 1;
for (int j = 0; j < nbright; j++)
{
int ij = j * nbdown + i;
uv_grid[ij].nodeId = uv_e1[j].nodeId;
uv_grid[ij].node = uv_e1[j].node;
}
j = nbright - 1;
for (int i = 0; i < nbdown; i++)
{
int ij = j * nbdown + i;
uv_grid[ij].nodeId = uv_e2[i].nodeId;
uv_grid[ij].node = uv_e2[i].node;
}
i = 0;
for (int j = 0; j < nbright; j++)
{
int ij = j * nbdown + i;
uv_grid[ij].nodeId = uv_e3[j].nodeId;
uv_grid[ij].node = uv_e3[j].node;
}
// normalized 2d values on grid
@ -489,19 +488,16 @@ UVPtStruct *SMESH_Quadrangle_2D::LoadEdgePoints(SMESH_Mesh & aMesh,
TopoDS_Vertex VFirst, VLast;
TopExp::Vertices(E, VFirst, VLast); // corresponds to f and l
ASSERT(!VFirst.IsNull());
SMESH_subMesh *firstSubMesh = aMesh.GetSubMesh(VFirst);
const vector<int>& lidf
= firstSubMesh->GetSubMeshDS()->GetIDNodes();
int idFirst = lidf[0];
//SCRUTE(idFirst);
ASSERT(!VFirst.IsNull());
SMDS_Iterator<const SMDS_MeshNode *> * lid=
aMesh.GetSubMesh(VFirst)->GetSubMeshDS()->GetNodes();
const SMDS_MeshNode * idFirst = lid->next();
delete lid;
ASSERT(!VLast.IsNull());
SMESH_subMesh *lastSubMesh = aMesh.GetSubMesh(VLast);
const vector<int> & lidl
= lastSubMesh->GetSubMeshDS()->GetIDNodes();
int idLast = lidl[0];
//SCRUTE(idLast);
ASSERT(!VLast.IsNull());
lid=aMesh.GetSubMesh(VLast)->GetSubMeshDS()->GetNodes();
const SMDS_MeshNode * idLast = lid->next();
delete lid;
// --- edge internal IDNodes (relies on good order storage, not checked)
@ -512,23 +508,19 @@ UVPtStruct *SMESH_Quadrangle_2D::LoadEdgePoints(SMESH_Mesh & aMesh,
double f, l;
Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E, F, f, l);
const vector<int> & indElt
= aMesh.GetSubMesh(E)->GetSubMeshDS()->GetIDNodes();
map<double, const SMDS_MeshNode *> params;
SMDS_Iterator<const SMDS_MeshNode *> * ite=
aMesh.GetSubMesh(E)->GetSubMeshDS()->GetNodes();
//SCRUTE(nbPoints);
//SCRUTE(indElt.Extent());
ASSERT(nbPoints == indElt.size());
map<double, int> params;
for (int ite=0; ite<indElt.size(); ite++)
while(ite->more())
{
int nodeId = indElt[ite];
const SMDS_MeshNode * node = meshDS->FindNode(nodeId);
const SMDS_MeshNode * node = ite->next();
const SMDS_EdgePosition* epos
= static_cast<const SMDS_EdgePosition*>(node->GetPosition());
double param = epos->GetUParameter();
params[param] = nodeId;
params[param] = node;
}
delete ite;
bool isForward = (((l - f) * (last - first)) > 0);
double paramin = 0;
@ -541,18 +533,17 @@ UVPtStruct *SMESH_Quadrangle_2D::LoadEdgePoints(SMESH_Mesh & aMesh,
uvslf[0].x = p.X();
uvslf[0].y = p.Y();
uvslf[0].param = f;
uvslf[0].nodeId = idFirst;
uvslf[0].node = idFirst;
//MESSAGE("__ f "<<f<<" "<<uvslf[0].x <<" "<<uvslf[0].y);
map < double, int >::iterator itp = params.begin();
map < double, const SMDS_MeshNode* >::iterator itp = params.begin();
for (int i = 1; i <= nbPoints; i++) // nbPoints internal
{
double param = (*itp).first;
int nodeId = (*itp).second;
gp_Pnt2d p = C2d->Value(param);
uvslf[i].x = p.X();
uvslf[i].y = p.Y();
uvslf[i].param = param;
uvslf[i].nodeId = nodeId;
uvslf[i].node = (*itp).second;
//MESSAGE("__ "<<i<<" "<<param<<" "<<uvslf[i].x <<" "<<uvslf[i].y);
itp++;
}
@ -560,7 +551,7 @@ UVPtStruct *SMESH_Quadrangle_2D::LoadEdgePoints(SMESH_Mesh & aMesh,
uvslf[nbPoints + 1].x = p.X();
uvslf[nbPoints + 1].y = p.Y();
uvslf[nbPoints + 1].param = l;
uvslf[nbPoints + 1].nodeId = idLast;
uvslf[nbPoints + 1].node = idLast;
//MESSAGE("__ l "<<l<<" "<<uvslf[nbPoints+1].x <<" "<<uvslf[nbPoints+1].y);
}
else
@ -571,19 +562,18 @@ UVPtStruct *SMESH_Quadrangle_2D::LoadEdgePoints(SMESH_Mesh & aMesh,
uvslf[0].x = p.X();
uvslf[0].y = p.Y();
uvslf[0].param = l;
uvslf[0].nodeId = idLast;
uvslf[0].node = idLast;
//MESSAGE("__ l "<<l<<" "<<uvslf[0].x <<" "<<uvslf[0].y);
map < double, int >::reverse_iterator itp = params.rbegin();
map < double, const SMDS_MeshNode* >::reverse_iterator itp = params.rbegin();
for (int j = nbPoints; j >= 1; j--) // nbPoints internal
{
double param = (*itp).first;
int nodeId = (*itp).second;
int i = nbPoints + 1 - j;
gp_Pnt2d p = C2d->Value(param);
uvslf[i].x = p.X();
uvslf[i].y = p.Y();
uvslf[i].param = param;
uvslf[i].nodeId = nodeId;
uvslf[i].node = (*itp).second;
//MESSAGE("__ "<<i<<" "<<param<<" "<<uvslf[i].x <<" "<<uvslf[i].y);
itp++;
}
@ -591,7 +581,7 @@ UVPtStruct *SMESH_Quadrangle_2D::LoadEdgePoints(SMESH_Mesh & aMesh,
uvslf[nbPoints + 1].x = p.X();
uvslf[nbPoints + 1].y = p.Y();
uvslf[nbPoints + 1].param = f;
uvslf[nbPoints + 1].nodeId = idFirst;
uvslf[nbPoints + 1].node = idFirst;
//MESSAGE("__ f "<<f<<" "<<uvslf[nbPoints+1].x <<" "<<uvslf[nbPoints+1].y);
}

View File

@ -41,7 +41,7 @@ typedef struct uvPtStruct
double v;
double x; // 2d parameter, normalized [0,1]
double y;
int nodeId;
const SMDS_MeshNode * node;
} UVPtStruct;
typedef struct faceQuadStruct

View File

@ -221,18 +221,15 @@ bool SMESH_Regular_1D::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape)
}
ASSERT(!VFirst.IsNull());
SMESH_subMesh *firstSubMesh = aMesh.GetSubMesh(VFirst);
const vector<int> & lidf
= firstSubMesh->GetSubMeshDS()->GetIDNodes();
int idFirst = lidf[0];
//SCRUTE(idFirst);
SMDS_Iterator<const SMDS_MeshNode *> * lid=
aMesh.GetSubMesh(VFirst)->GetSubMeshDS()->GetNodes();
const SMDS_MeshNode * idFirst = lid->next();
delete lid;
ASSERT(!VLast.IsNull());
SMESH_subMesh *lastSubMesh = aMesh.GetSubMesh(VLast);
const vector<int> & lidl
= lastSubMesh->GetSubMeshDS()->GetIDNodes();
int idLast = lidl[0];
//SCRUTE(idLast);
lid=aMesh.GetSubMesh(VLast)->GetSubMeshDS()->GetNodes();
const SMDS_MeshNode * idLast = lid->next();
delete lid;
if (!Curve.IsNull())
{
@ -244,7 +241,7 @@ bool SMESH_Regular_1D::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape)
// edge extrema (indexes : 1 & NbPoints) already in SMDS (TopoDS_Vertex)
// only internal nodes receive an edge position with param on curve
int idPrev = idFirst;
const SMDS_MeshNode * idPrev = idFirst;
for (int i = 2; i < NbPoints; i++)
{
double param = Discret.Parameter(i);
@ -274,9 +271,9 @@ bool SMESH_Regular_1D::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape)
SMDS_EdgePosition* epos=dynamic_cast<SMDS_EdgePosition *>(node->GetPosition());
epos->SetUParameter(param);
SMDS_MeshEdge * edge = meshDS->AddEdge(idPrev, node->GetID());
SMDS_MeshEdge * edge = meshDS->AddEdge(idPrev, node);
meshDS->SetMeshElementOnShape(edge, E);
idPrev = node->GetID();
idPrev = node;
}
SMDS_MeshEdge* edge = meshDS->AddEdge(idPrev, idLast);
meshDS->SetMeshElementOnShape(edge, E);
@ -297,7 +294,7 @@ bool SMESH_Regular_1D::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape)
TopExp::Vertices(E, V1, V2);
gp_Pnt P = BRep_Tool::Pnt(V1);
int idPrev = idFirst;
const SMDS_MeshNode * idPrev = idFirst;
for (int i = 2; i < NbPoints; i++)
{
double param = f + (i - 1) * du;
@ -311,9 +308,9 @@ bool SMESH_Regular_1D::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape)
= dynamic_cast<SMDS_EdgePosition*>(node->GetPosition());
epos->SetUParameter(param);
SMDS_MeshEdge * edge = meshDS->AddEdge(idPrev, node->GetID());
SMDS_MeshEdge * edge = meshDS->AddEdge(idPrev, node);
meshDS->SetMeshElementOnShape(edge, E);
idPrev = node->GetID();
idPrev = node;
}
SMDS_MeshEdge * edge = meshDS->AddEdge(idPrev, idLast);
meshDS->SetMeshElementOnShape(edge, E);

View File

@ -1321,27 +1321,23 @@ void SMESH_subMesh::RemoveSubMeshElementsAndNodes()
_subMeshDS = _meshDS->MeshElements(_subShape);
if (_subMeshDS!=NULL)
{
const vector<int> & indElt = _subMeshDS->GetIDElements();
vector<int>::const_iterator ite=indElt.begin();
for (; ite!=indElt.end(); ite++)
SMDS_Iterator<const SMDS_MeshElement *> * ite=_subMeshDS->GetElements();
while(ite->more())
{
int eltId = *ite;
SCRUTE(eltId);
const SMDS_MeshElement * elt = _meshDS->FindElement(eltId);
const SMDS_MeshElement * elt = ite->next();
_subMeshDS->RemoveElement(elt);
_meshDS->RemoveElement(eltId);
_meshDS->RemoveElement(elt);
}
delete ite;
const vector<int> & indNodes = _subMeshDS->GetIDNodes();
vector<int>::const_iterator itn=indNodes.begin();
for (; itn!=indNodes.end(); itn++)
SMDS_Iterator<const SMDS_MeshNode *> * itn=_subMeshDS->GetNodes();
while(itn->more())
{
int nodeId = *itn;
SCRUTE(nodeId);
const SMDS_MeshNode * node = _meshDS->FindNode(nodeId);
const SMDS_MeshNode * node = itn->next();
_subMeshDS->RemoveNode(node);
_meshDS->RemoveNode(nodeId);
_meshDS->RemoveNode(node);
}
delete itn;
}
}

View File

@ -111,21 +111,22 @@ SMDS_MeshNode* SMESHDS_Mesh::AddNode(double x, double y, double z)
//function : MoveNode
//purpose :
//=======================================================================
void SMESHDS_Mesh::MoveNode(int ID, double x, double y, double z)
void SMESHDS_Mesh::MoveNode(const SMDS_MeshNode *n, double x, double y, double z)
{
SMDS_MeshNode * node=const_cast<SMDS_MeshNode*>(FindNode(ID));
SMDS_MeshNode * node=const_cast<SMDS_MeshNode*>(n);
node->setXYZ(x,y,z);
myScript->MoveNode(ID, x, y, z);
myScript->MoveNode(n->GetID(), x, y, z);
}
//=======================================================================
//function : AddEdge
//purpose :
//=======================================================================
SMDS_MeshEdge* SMESHDS_Mesh::AddEdge(int idnode1, int idnode2)
SMDS_MeshEdge* SMESHDS_Mesh::AddEdge(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2)
{
SMDS_MeshEdge* e = SMDS_Mesh::AddEdge(idnode1, idnode2);
if(e!=NULL) myScript->AddEdge(e->GetID(), idnode1, idnode2);
SMDS_MeshEdge* e = SMDS_Mesh::AddEdge(n1,n2);
if(e!=NULL) myScript->AddEdge(e->GetID(), n1->GetID(), n2->GetID());
return e;
}
@ -133,10 +134,13 @@ SMDS_MeshEdge* SMESHDS_Mesh::AddEdge(int idnode1, int idnode2)
//function :AddFace
//purpose :
//=======================================================================
SMDS_MeshFace* SMESHDS_Mesh::AddFace(int idnode1, int idnode2, int idnode3)
SMDS_MeshFace* SMESHDS_Mesh::AddFace( const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3)
{
SMDS_MeshFace *f = SMDS_Mesh::AddFace(idnode1, idnode2, idnode3);
if(f!=NULL) myScript->AddFace(f->GetID(), idnode1, idnode2, idnode3);
SMDS_MeshFace *f = SMDS_Mesh::AddFace(n1, n2, n3);
if(f!=NULL) myScript->AddFace(f->GetID(), n1->GetID(), n2->GetID(),
n3->GetID());
return f;
}
@ -144,12 +148,15 @@ SMDS_MeshFace* SMESHDS_Mesh::AddFace(int idnode1, int idnode2, int idnode3)
//function :AddFace
//purpose :
//=======================================================================
SMDS_MeshFace* SMESHDS_Mesh::AddFace(int idnode1, int idnode2, int idnode3,
int idnode4)
SMDS_MeshFace* SMESHDS_Mesh::AddFace(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n4)
{
SMDS_MeshFace *f = SMDS_Mesh::AddFace(idnode1, idnode2, idnode3, idnode4);
SMDS_MeshFace *f = SMDS_Mesh::AddFace(n1, n2, n3, n4);
if(f!=NULL)
myScript->AddFace(f->GetID(), idnode1, idnode2, idnode3, idnode4);
myScript->AddFace(f->GetID(), n1->GetID(), n2->GetID(), n3->GetID(),
n4->GetID());
return f;
}
@ -157,13 +164,16 @@ SMDS_MeshFace* SMESHDS_Mesh::AddFace(int idnode1, int idnode2, int idnode3,
//function :AddVolume
//purpose :
//=======================================================================
SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(int idnode1, int idnode2, int idnode3,
int idnode4)
SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(
const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n4)
{
SMDS_MeshVolume *f = SMDS_Mesh::AddVolume(idnode1, idnode2, idnode3,
idnode4);
SMDS_MeshVolume *f = SMDS_Mesh::AddVolume(n1, n2, n3, n4);
if(f!=NULL)
myScript->AddVolume(f->GetID(), idnode1, idnode2, idnode3, idnode4);
myScript->AddVolume(f->GetID(), n1->GetID(), n2->GetID(), n3->GetID(),
n4->GetID());
return f;
}
@ -171,14 +181,17 @@ SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(int idnode1, int idnode2, int idnode3,
//function :AddVolume
//purpose :
//=======================================================================
SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(int idnode1, int idnode2, int idnode3,
int idnode4, int idnode5)
SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(
const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n4,
const SMDS_MeshNode * n5)
{
SMDS_MeshVolume *v = SMDS_Mesh::AddVolume(idnode1, idnode2, idnode3,
idnode4, idnode5);
SMDS_MeshVolume *v = SMDS_Mesh::AddVolume(n1, n2, n3, n4, n5);
if(v!=NULL)
myScript->AddVolume(v->GetID(), idnode1, idnode2, idnode3, idnode4,
idnode5);
myScript->AddVolume(v->GetID(), n1->GetID(), n2->GetID(), n3->GetID(),
n4->GetID(), n5->GetID());
return v;
}
@ -186,15 +199,18 @@ SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(int idnode1, int idnode2, int idnode3,
//function :AddVolume
//purpose :
//=======================================================================
SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(int idnode1, int idnode2, int idnode3,
int idnode4, int idnode5, int idnode6)
SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(
const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n4,
const SMDS_MeshNode * n5,
const SMDS_MeshNode * n6)
{
SMDS_MeshVolume *v=
SMDS_Mesh::AddVolume(idnode1, idnode2, idnode3, idnode4, idnode5,
idnode6);
SMDS_MeshVolume *v= SMDS_Mesh::AddVolume(n1, n2, n3, n4, n5, n6);
if(v!=NULL)
myScript->AddVolume(v->GetID(), idnode1, idnode2, idnode3, idnode4,
idnode5, idnode6);
myScript->AddVolume(v->GetID(), n1->GetID(), n2->GetID(), n3->GetID(),
n4->GetID(), n5->GetID(), n6->GetID());
return v;
}
@ -202,15 +218,21 @@ SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(int idnode1, int idnode2, int idnode3,
//function :AddVolume
//purpose :
//=======================================================================
SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(int idnode1, int idnode2, int idnode3,
int idnode4, int idnode5, int idnode6, int idnode7, int idnode8)
SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(
const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n4,
const SMDS_MeshNode * n5,
const SMDS_MeshNode * n6,
const SMDS_MeshNode * n7,
const SMDS_MeshNode * n8)
{
SMDS_MeshVolume *v=
SMDS_Mesh::AddVolume(idnode1, idnode2, idnode3, idnode4, idnode5,
idnode6, idnode7, idnode8);
SMDS_Mesh::AddVolume(n1, n2, n3, n4, n5, n6, n7, n8);
if(v!=NULL)
myScript->AddVolume(v->GetID(), idnode1, idnode2, idnode3, idnode4,
idnode5, idnode6, idnode7, idnode8);
myScript->AddVolume(v->GetID(), n1->GetID(), n2->GetID(), n3->GetID(),
n4->GetID(), n5->GetID(), n6->GetID(), n7->GetID(), n8->GetID());
return v;
}
@ -218,20 +240,20 @@ SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(int idnode1, int idnode2, int idnode3,
//function : RemoveNode
//purpose :
//=======================================================================
void SMESHDS_Mesh::RemoveNode(int ID)
void SMESHDS_Mesh::RemoveNode(const SMDS_MeshNode * n)
{
SMDS_Mesh::RemoveNode(ID);
myScript->RemoveNode(ID);
SMDS_Mesh::RemoveNode(n);
myScript->RemoveNode(n->GetID());
}
//=======================================================================
//function : RemoveElement
//purpose :
//========================================================================
void SMESHDS_Mesh::RemoveElement(int ID)
void SMESHDS_Mesh::RemoveElement(const SMDS_MeshElement * elt)
{
SMDS_Mesh::RemoveElement(ID);
myScript->RemoveElement(ID);
SMDS_Mesh::RemoveElement(elt);
myScript->RemoveElement(elt->GetID());
}
//=======================================================================
@ -252,7 +274,7 @@ void SMESHDS_Mesh::SetNodeInVolume(SMDS_MeshNode * aNode,
//Update or build submesh
map<int,SMESHDS_SubMesh*>::iterator it=myShapeIndexToSubMesh.find(Index);
if (it==myShapeIndexToSubMesh.end())
myShapeIndexToSubMesh[Index]= new SMESHDS_SubMesh(this);
myShapeIndexToSubMesh[Index]= new SMESHDS_SubMesh();
myShapeIndexToSubMesh[Index]->AddNode(aNode);
}
@ -274,7 +296,7 @@ void SMESHDS_Mesh::SetNodeOnFace(SMDS_MeshNode * aNode,
//Update or build submesh
map<int,SMESHDS_SubMesh*>::iterator it=myShapeIndexToSubMesh.find(Index);
if (it==myShapeIndexToSubMesh.end())
myShapeIndexToSubMesh[Index]= new SMESHDS_SubMesh(this);
myShapeIndexToSubMesh[Index]= new SMESHDS_SubMesh();
myShapeIndexToSubMesh[Index]->AddNode(aNode);
}
@ -296,7 +318,7 @@ void SMESHDS_Mesh::SetNodeOnEdge(SMDS_MeshNode * aNode,
//Update or build submesh
map<int,SMESHDS_SubMesh*>::iterator it=myShapeIndexToSubMesh.find(Index);
if (it==myShapeIndexToSubMesh.end())
myShapeIndexToSubMesh[Index]= new SMESHDS_SubMesh(this);
myShapeIndexToSubMesh[Index]= new SMESHDS_SubMesh();
myShapeIndexToSubMesh[Index]->AddNode(aNode);
}
@ -318,7 +340,7 @@ void SMESHDS_Mesh::SetNodeOnVertex(SMDS_MeshNode * aNode,
//Update or build submesh
map<int,SMESHDS_SubMesh*>::iterator it=myShapeIndexToSubMesh.find(Index);
if (it==myShapeIndexToSubMesh.end())
myShapeIndexToSubMesh[Index]= new SMESHDS_SubMesh(this);
myShapeIndexToSubMesh[Index]= new SMESHDS_SubMesh();
myShapeIndexToSubMesh[Index]->AddNode(aNode);
}
@ -344,7 +366,7 @@ void SMESHDS_Mesh::SetMeshElementOnShape(const SMDS_MeshElement * anElement,
int Index = myIndexToShape.FindIndex(S);
if (myShapeIndexToSubMesh.find(Index)==myShapeIndexToSubMesh.end())
myShapeIndexToSubMesh[Index]=new SMESHDS_SubMesh(this);
myShapeIndexToSubMesh[Index]=new SMESHDS_SubMesh();
myShapeIndexToSubMesh[Index]->AddElement(anElement);
}
@ -450,7 +472,7 @@ void SMESHDS_Mesh::NewSubMesh(int Index)
{
if (myShapeIndexToSubMesh.find(Index)==myShapeIndexToSubMesh.end())
{
SMESHDS_SubMesh* SM = new SMESHDS_SubMesh(this);
SMESHDS_SubMesh* SM = new SMESHDS_SubMesh();
myShapeIndexToSubMesh[Index]=SM;
}
}
@ -486,7 +508,7 @@ void SMESHDS_Mesh::SetNodeInVolume(const SMDS_MeshNode* aNode, int Index)
//Update or build submesh
if (myShapeIndexToSubMesh.find(Index)==myShapeIndexToSubMesh.end())
myShapeIndexToSubMesh[Index]=new SMESHDS_SubMesh(this);
myShapeIndexToSubMesh[Index]=new SMESHDS_SubMesh();
myShapeIndexToSubMesh[Index]->AddNode(aNode);
}
@ -502,7 +524,7 @@ void SMESHDS_Mesh::SetNodeOnFace(SMDS_MeshNode* aNode, int Index)
//Update or build submesh
if (myShapeIndexToSubMesh.find(Index)==myShapeIndexToSubMesh.end())
myShapeIndexToSubMesh[Index]=new SMESHDS_SubMesh(this);
myShapeIndexToSubMesh[Index]=new SMESHDS_SubMesh();
myShapeIndexToSubMesh[Index]->AddNode(aNode);
}
@ -518,7 +540,7 @@ void SMESHDS_Mesh::SetNodeOnEdge(SMDS_MeshNode* aNode, int Index)
//Update or build submesh
if (myShapeIndexToSubMesh.find(Index)==myShapeIndexToSubMesh.end())
myShapeIndexToSubMesh[Index]=new SMESHDS_SubMesh(this);
myShapeIndexToSubMesh[Index]=new SMESHDS_SubMesh();
myShapeIndexToSubMesh[Index]->AddNode(aNode);
}
@ -534,7 +556,7 @@ void SMESHDS_Mesh::SetNodeOnVertex(SMDS_MeshNode* aNode, int Index)
//Update or build submesh
if (myShapeIndexToSubMesh.find(Index)==myShapeIndexToSubMesh.end())
myShapeIndexToSubMesh[Index]=new SMESHDS_SubMesh(this);
myShapeIndexToSubMesh[Index]=new SMESHDS_SubMesh();
myShapeIndexToSubMesh[Index]->AddNode(aNode);
}
@ -547,7 +569,11 @@ void SMESHDS_Mesh::SetMeshElementOnShape(const SMDS_MeshElement* anElement,
int Index)
{
if (myShapeIndexToSubMesh.find(Index)==myShapeIndexToSubMesh.end())
myShapeIndexToSubMesh[Index]=new SMESHDS_SubMesh(this);
myShapeIndexToSubMesh[Index]=new SMESHDS_SubMesh();
myShapeIndexToSubMesh[Index]->AddElement(anElement);
}
SMESHDS_Mesh::~SMESHDS_Mesh()
{
}

View File

@ -58,19 +58,49 @@ class SMESHDS_Mesh:public SMDS_Mesh
bool AddHypothesis(const TopoDS_Shape & SS, const SMESHDS_Hypothesis * H);
bool RemoveHypothesis(const TopoDS_Shape & S, const SMESHDS_Hypothesis * H);
SMDS_MeshNode * AddNode(double x, double y, double z);
virtual void RemoveNode(int ID);
void MoveNode(int ID, double x, double y, double z);
SMDS_MeshEdge* AddEdge(int idnode1, int idnode2);
SMDS_MeshFace* AddFace(int idnode1, int idnode2, int idnode3);
SMDS_MeshFace* AddFace(int idnode1, int idnode2, int idnode3, int idnode4);
SMDS_MeshVolume* AddVolume(int idnode1, int idnode2, int idnode3, int idnode4);
SMDS_MeshVolume* AddVolume(int idnode1, int idnode2, int idnode3, int idnode4,
int idnode5);
SMDS_MeshVolume* AddVolume(int idnode1, int idnode2, int idnode3, int idnode4,
int idnode5, int idnode6);
SMDS_MeshVolume* AddVolume(int idnode1, int idnode2, int idnode3, int idnode4,
int idnode5, int idnode6, int idnode7, int idnode8);
virtual void RemoveElement(int IDelem);
void RemoveNode(const SMDS_MeshNode *);
void MoveNode(const SMDS_MeshNode *, double x, double y, double z);
SMDS_MeshEdge* AddEdge(
const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2);
SMDS_MeshFace* AddFace(
const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3);
SMDS_MeshFace* AddFace(
const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n4);
SMDS_MeshVolume* AddVolume(
const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n4);
SMDS_MeshVolume* AddVolume(
const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n4,
const SMDS_MeshNode * n5);
SMDS_MeshVolume* AddVolume(
const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n4,
const SMDS_MeshNode * n5,
const SMDS_MeshNode * n6);
SMDS_MeshVolume* AddVolume(
const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n4,
const SMDS_MeshNode * n5,
const SMDS_MeshNode * n6,
const SMDS_MeshNode * n7,
const SMDS_MeshNode * n8);
void RemoveElement(const SMDS_MeshElement *);
void SetNodeInVolume(SMDS_MeshNode * aNode, const TopoDS_Shell & S);
void SetNodeOnFace(SMDS_MeshNode * aNode, const TopoDS_Face & S);
void SetNodeOnEdge(SMDS_MeshNode * aNode, const TopoDS_Edge & S);

View File

@ -29,16 +29,6 @@
using namespace std;
#include "SMESHDS_SubMesh.hxx"
//=======================================================================
//function : SMESHDS_SubMesh
//purpose :
//=======================================================================
SMESHDS_SubMesh::SMESHDS_SubMesh(const SMDS_Mesh * M):myMesh(M)
{
myListOfEltIDIsUpdate = false;
myListOfNodeIDIsUpdate = false;
}
//=======================================================================
//function : AddElement
//purpose :
@ -46,7 +36,6 @@ SMESHDS_SubMesh::SMESHDS_SubMesh(const SMDS_Mesh * M):myMesh(M)
void SMESHDS_SubMesh::AddElement(const SMDS_MeshElement * ME)
{
myElements.insert(ME);
myListOfEltIDIsUpdate = false;
}
//=======================================================================
@ -56,7 +45,6 @@ void SMESHDS_SubMesh::AddElement(const SMDS_MeshElement * ME)
void SMESHDS_SubMesh::RemoveElement(const SMDS_MeshElement * ME)
{
myElements.erase(ME);
myListOfEltIDIsUpdate = false;
}
//=======================================================================
@ -66,7 +54,6 @@ void SMESHDS_SubMesh::RemoveElement(const SMDS_MeshElement * ME)
void SMESHDS_SubMesh::AddNode(const SMDS_MeshNode * N)
{
myNodes.insert(N);
myListOfNodeIDIsUpdate = false;
}
//=======================================================================
@ -76,7 +63,6 @@ void SMESHDS_SubMesh::AddNode(const SMDS_MeshNode * N)
void SMESHDS_SubMesh::RemoveNode(const SMDS_MeshNode * N)
{
myNodes.erase(N);
myListOfNodeIDIsUpdate = false;
}
//=======================================================================
@ -88,15 +74,6 @@ int SMESHDS_SubMesh::NbElements() const
return myElements.size();
}
//=======================================================================
//function : GetElements
//purpose :
//=======================================================================
const set<const SMDS_MeshElement*> & SMESHDS_SubMesh::GetElements()
{
return myElements;
}
//=======================================================================
//function : NbNodes
//purpose :
@ -106,49 +83,42 @@ int SMESHDS_SubMesh::NbNodes() const
return myNodes.size();
}
//=======================================================================
//function : GetNodes
//purpose :
//=======================================================================
const set<const SMDS_MeshNode*> & SMESHDS_SubMesh::GetNodes() const
template<typename T> class MySetIterator:public SMDS_Iterator<const T*>
{
return myNodes;
const set<const T*>& mySet;
set<const T*>::const_iterator myIt;
public:
MySetIterator(const set<const T*>& s):mySet(s), myIt(s.begin())
{
}
bool more()
{
return myIt!=mySet.end();
}
const T* next()
{
const T* t=*myIt;
myIt++;
return t;
}
};
///////////////////////////////////////////////////////////////////////////////
///Return an iterator on the elements of submesh
///The created iterator must be free by the caller
///////////////////////////////////////////////////////////////////////////////
SMDS_Iterator<const SMDS_MeshElement*> * SMESHDS_SubMesh::GetElements() const
{
return new MySetIterator<SMDS_MeshElement>(myElements);
}
//=======================================================================
//function : GetIDElements
//purpose :
//=======================================================================
const vector<int> & SMESHDS_SubMesh::GetIDElements()
///////////////////////////////////////////////////////////////////////////////
///Return an iterator on the nodes of submesh
///The created iterator must be free by the caller
///////////////////////////////////////////////////////////////////////////////
SMDS_Iterator<const SMDS_MeshNode*> * SMESHDS_SubMesh::GetNodes() const
{
if (!myListOfEltIDIsUpdate)
{
myListOfEltID.clear();
set<const SMDS_MeshElement*>::iterator it=myElements.begin();
for (; it!=myElements.end(); it++)
{
myListOfEltID.push_back((*it)->GetID());
}
myListOfEltIDIsUpdate = true;
}
return myListOfEltID;
return new MySetIterator<SMDS_MeshNode>(myNodes);
}
//=======================================================================
//function : GetIDNodes
//purpose :
//=======================================================================
const vector<int> & SMESHDS_SubMesh::GetIDNodes()
{
if (!myListOfNodeIDIsUpdate)
{
myListOfNodeID.clear();
set<const SMDS_MeshNode*>::iterator it=myNodes.begin();
for (; it!=myNodes.end(); it++)
{
myListOfNodeID.push_back((*it)->GetID());
}
myListOfNodeIDIsUpdate = true;
}
return myListOfNodeID;
}

View File

@ -28,7 +28,6 @@
#define _SMESHDS_SubMesh_HeaderFile
#include "SMDS_Mesh.hxx"
#include <vector>
#include <set>
using namespace std;
@ -36,25 +35,18 @@ using namespace std;
class SMESHDS_SubMesh
{
public:
SMESHDS_SubMesh(const SMDS_Mesh * M);
void AddElement(const SMDS_MeshElement * ME);
void RemoveElement(const SMDS_MeshElement * ME);
void AddNode(const SMDS_MeshNode * ME);
void RemoveNode(const SMDS_MeshNode * ME);
int NbElements() const;
const set<const SMDS_MeshElement*> & GetElements();
const vector<int> & GetIDElements();
SMDS_Iterator<const SMDS_MeshElement*> * GetElements() const;
int NbNodes() const;
const set<const SMDS_MeshNode*> & GetNodes() const;
const vector<int> & GetIDNodes();
~SMESHDS_SubMesh();
SMDS_Iterator<const SMDS_MeshNode*> * GetNodes() const;
private:
const SMDS_Mesh * myMesh;
set<const SMDS_MeshElement*> myElements;
set<const SMDS_MeshNode*> myNodes;
bool myListOfEltIDIsUpdate;
vector<int> myListOfEltID;
bool myListOfNodeIDIsUpdate;
vector<int> myListOfNodeID;
};
#endif

View File

@ -308,16 +308,14 @@ Engines::long_array * SMESH_MEDSupport_i::getNumber(
int i = 0;
myseq->length(_subMeshDS->NbNodes());
const set<const SMDS_MeshNode*> & myNodesMap = _subMeshDS->GetNodes();
set<const SMDS_MeshNode*>::const_iterator it=myNodesMap.begin();
for (; it!=myNodesMap.end(); it++)
SMDS_Iterator<const SMDS_MeshNode*> * it = _subMeshDS->GetNodes();
while(it->more())
{
myseq[i] = (*it)->GetID();
SCRUTE((*it)->GetID());
SCRUTE(myseq[i]);
myseq[i] = it->next()->GetID();
i++;
};
delete it;
SCRUTE(myseq->length());
MESSAGE("End of SMESH_MEDSupport_i::getNumber");

View File

@ -61,7 +61,7 @@ CORBA::Boolean SMESH_MeshEditor_i::RemoveElements(const SMESH::
for (int i = 0; i < IDsOfElements.length(); i++)
{
CORBA::Long index = IDsOfElements[i];
_myMeshDS->RemoveElement(index);
_myMeshDS->RemoveElement(_myMeshDS->FindElement(index));
MESSAGE("Element " << index << " was removed")
}
return true;
@ -86,8 +86,8 @@ CORBA::Boolean SMESH_MeshEditor_i::RemoveNodes(const SMESH::
<<" not found");
continue;
}
_myMeshDS->RemoveNode(IDsOfNodes[i]);
MESSAGE("Node " << index << " was removed")
_myMeshDS->RemoveNode(node);
MESSAGE("Node " << IDsOfNodes[i] << " was removed")
}
return true;
};
@ -105,7 +105,7 @@ CORBA::Boolean SMESH_MeshEditor_i::AddEdge(const SMESH::long_array & IDsOfNodes)
{
CORBA::Long index1 = IDsOfNodes[0];
CORBA::Long index2 = IDsOfNodes[1];
_myMeshDS->AddEdge(index1, index2);
_myMeshDS->AddEdge(_myMeshDS->FindNode(index1), _myMeshDS->FindNode(index2));
}
return true;
}
@ -133,20 +133,15 @@ CORBA::Boolean SMESH_MeshEditor_i::AddNode(CORBA::Double x,
CORBA::Boolean SMESH_MeshEditor_i::AddFace(const SMESH::long_array & IDsOfNodes)
{
int NbNodes = IDsOfNodes.length();
const SMDS_MeshNode* nodes[4];
for(int i=0;i<NbNodes;i++) nodes[i]=_myMeshDS->FindNode(IDsOfNodes[i]);
if (NbNodes == 3)
{
CORBA::Long index1 = IDsOfNodes[0];
CORBA::Long index2 = IDsOfNodes[1];
CORBA::Long index3 = IDsOfNodes[2];
_myMeshDS->AddFace(index1, index2, index3);
_myMeshDS->AddFace(nodes[0], nodes[1], nodes[2]);
}
else if (NbNodes == 4)
{
CORBA::Long index1 = IDsOfNodes[0];
CORBA::Long index2 = IDsOfNodes[1];
CORBA::Long index3 = IDsOfNodes[2];
CORBA::Long index4 = IDsOfNodes[3];
_myMeshDS->AddFace(index1, index2, index3, index4);
_myMeshDS->AddFace(nodes[0], nodes[1], nodes[2], nodes[3]);
}
return true;
};
@ -161,45 +156,15 @@ CORBA::Boolean SMESH_MeshEditor_i::AddVolume(const SMESH::
long_array & IDsOfNodes)
{
int NbNodes = IDsOfNodes.length();
if (NbNodes == 4)
const SMDS_MeshNode* n[8];
for(int i=0;i<NbNodes;i++) n[i]=_myMeshDS->FindNode(IDsOfNodes[i]);
switch(NbNodes)
{
CORBA::Long index1 = IDsOfNodes[0];
CORBA::Long index2 = IDsOfNodes[1];
CORBA::Long index3 = IDsOfNodes[2];
CORBA::Long index4 = IDsOfNodes[3];
_myMeshDS->AddVolume(index1, index2, index3, index4);
}
else if (NbNodes == 5)
{
CORBA::Long index1 = IDsOfNodes[0];
CORBA::Long index2 = IDsOfNodes[1];
CORBA::Long index3 = IDsOfNodes[2];
CORBA::Long index4 = IDsOfNodes[3];
CORBA::Long index5 = IDsOfNodes[4];
_myMeshDS->AddVolume(index1, index2, index3, index4, index5);
}
else if (NbNodes == 6)
{
CORBA::Long index1 = IDsOfNodes[0];
CORBA::Long index2 = IDsOfNodes[1];
CORBA::Long index3 = IDsOfNodes[2];
CORBA::Long index4 = IDsOfNodes[3];
CORBA::Long index5 = IDsOfNodes[4];
CORBA::Long index6 = IDsOfNodes[5];
_myMeshDS->AddVolume(index1, index2, index3, index4, index5, index6);
}
else if (NbNodes == 8)
{
CORBA::Long index1 = IDsOfNodes[0];
CORBA::Long index2 = IDsOfNodes[1];
CORBA::Long index3 = IDsOfNodes[2];
CORBA::Long index4 = IDsOfNodes[3];
CORBA::Long index5 = IDsOfNodes[4];
CORBA::Long index6 = IDsOfNodes[5];
CORBA::Long index7 = IDsOfNodes[6];
CORBA::Long index8 = IDsOfNodes[7];
_myMeshDS->AddVolume(index1, index2, index3, index4, index5, index6,
index7, index8);
case 4:_myMeshDS->AddVolume(n[0],n[1],n[2],n[3]); break;
case 5:_myMeshDS->AddVolume(n[0],n[1],n[2],n[3],n[4]); break;
case 6:_myMeshDS->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5]); break;
case 8:_myMeshDS->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7]); break;
}
return true;
};