//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)
/* liberation memoire */
free(connectivite);
free(numele);
+ free(nomele);
free(nufael);
MESSAGE(" End " << typmai[i]);
}
{
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();
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++)
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();
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++)
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();
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++)
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();
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++)
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();
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++)
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();
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++)
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);
}
}
}
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);
}
// 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);
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();
typedef struct point3Dstruct
{
- int nodeId;
+ const SMDS_MeshNode * node;
} Point3DStruct;
typedef double Pt3[3];
//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);
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");
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)
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
//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;
// 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;
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;
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());
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
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++;
#include "SMESH_LengthFromEdges.hxx"
#include "Rn.h"
+class SMDS_MeshNode;
#include <TopoDS_Face.hxx>
-
#include <map>
class SMESH_MEFISTO_2D:
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,
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);
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);
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);
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
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)
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;
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++;
}
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
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++;
}
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);
}
double v;
double x; // 2d parameter, normalized [0,1]
double y;
- int nodeId;
+ const SMDS_MeshNode * node;
} UVPtStruct;
typedef struct faceQuadStruct
}
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())
{
// 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);
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);
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;
= 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);
_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);
}
-
- const vector<int> & indNodes = _subMeshDS->GetIDNodes();
- vector<int>::const_iterator itn=indNodes.begin();
- for (; itn!=indNodes.end(); itn++)
+ delete ite;
+
+ 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;
}
}
//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;
}
//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;
}
//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;
}
//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;
}
//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;
}
//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;
}
//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;
}
//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());
}
//=======================================================================
//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);
}
//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);
}
//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);
}
//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);
}
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);
}
{
if (myShapeIndexToSubMesh.find(Index)==myShapeIndexToSubMesh.end())
{
- SMESHDS_SubMesh* SM = new SMESHDS_SubMesh(this);
+ SMESHDS_SubMesh* SM = new SMESHDS_SubMesh();
myShapeIndexToSubMesh[Index]=SM;
}
}
//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);
}
//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);
}
//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);
}
//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);
}
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()
+{
+}
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);
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 :
void SMESHDS_SubMesh::AddElement(const SMDS_MeshElement * ME)
{
myElements.insert(ME);
- myListOfEltIDIsUpdate = false;
}
//=======================================================================
void SMESHDS_SubMesh::RemoveElement(const SMDS_MeshElement * ME)
{
myElements.erase(ME);
- myListOfEltIDIsUpdate = false;
}
//=======================================================================
void SMESHDS_SubMesh::AddNode(const SMDS_MeshNode * N)
{
myNodes.insert(N);
- myListOfNodeIDIsUpdate = false;
}
//=======================================================================
void SMESHDS_SubMesh::RemoveNode(const SMDS_MeshNode * N)
{
myNodes.erase(N);
- myListOfNodeIDIsUpdate = false;
}
//=======================================================================
return myElements.size();
}
-//=======================================================================
-//function : GetElements
-//purpose :
-//=======================================================================
-const set<const SMDS_MeshElement*> & SMESHDS_SubMesh::GetElements()
-{
- return myElements;
-}
-
//=======================================================================
//function : NbNodes
//purpose :
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;
-//=======================================================================
-//function : GetIDElements
-//purpose :
-//=======================================================================
-const vector<int> & SMESHDS_SubMesh::GetIDElements()
-{
- if (!myListOfEltIDIsUpdate)
+ public:
+ MySetIterator(const set<const T*>& s):mySet(s), myIt(s.begin())
{
- myListOfEltID.clear();
- set<const SMDS_MeshElement*>::iterator it=myElements.begin();
- for (; it!=myElements.end(); it++)
- {
- myListOfEltID.push_back((*it)->GetID());
- }
- myListOfEltIDIsUpdate = true;
}
- return myListOfEltID;
-}
-//=======================================================================
-//function : GetIDNodes
-//purpose :
-//=======================================================================
-const vector<int> & SMESHDS_SubMesh::GetIDNodes()
-{
- if (!myListOfNodeIDIsUpdate)
+ bool more()
+ {
+ return myIt!=mySet.end();
+ }
+ const T* next()
{
- myListOfNodeID.clear();
- set<const SMDS_MeshNode*>::iterator it=myNodes.begin();
- for (; it!=myNodes.end(); it++)
- {
- myListOfNodeID.push_back((*it)->GetID());
- }
- myListOfNodeIDIsUpdate = true;
+ const T* t=*myIt;
+ myIt++;
+ return t;
}
- return myListOfNodeID;
+};
+///////////////////////////////////////////////////////////////////////////////
+///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);
}
+
+///////////////////////////////////////////////////////////////////////////////
+///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
+{
+ return new MySetIterator<SMDS_MeshNode>(myNodes);
+}
+
#define _SMESHDS_SubMesh_HeaderFile
#include "SMDS_Mesh.hxx"
-#include <vector>
#include <set>
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
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");
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;
<<" not found");
continue;
}
- _myMeshDS->RemoveNode(IDsOfNodes[i]);
- MESSAGE("Node " << index << " was removed")
+ _myMeshDS->RemoveNode(node);
+ MESSAGE("Node " << IDsOfNodes[i] << " was removed")
}
return true;
};
{
CORBA::Long index1 = IDsOfNodes[0];
CORBA::Long index2 = IDsOfNodes[1];
- _myMeshDS->AddEdge(index1, index2);
+ _myMeshDS->AddEdge(_myMeshDS->FindNode(index1), _myMeshDS->FindNode(index2));
}
return true;
}
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;
};
long_array & IDsOfNodes)
{
int NbNodes = IDsOfNodes.length();
- if (NbNodes == 4)
- {
- 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)
+ 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];
- 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;
};