-// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
//=======================================================================
//function : SMDS_MeshNode
-//purpose :
+//purpose :
//=======================================================================
SMDS_MeshNode::SMDS_MeshNode() :
SMDS_MeshElement(-1, -1, 0),
//=======================================================================
//function : RemoveInverseElement
-//purpose :
+//purpose :
//=======================================================================
void SMDS_MeshNode::RemoveInverseElement(const SMDS_MeshElement * parent)
{
- //MESSAGE("RemoveInverseElement " << myID << " " << parent->GetID());
- const SMDS_MeshCell* cell = dynamic_cast<const SMDS_MeshCell*>(parent);
- MYASSERT(cell);
- SMDS_Mesh::_meshList[myMeshId]->getGrid()->RemoveReferenceToCell(myVtkID, cell->getVtkId());
+ //MESSAGE("RemoveInverseElement " << myID << " " << parent->GetID());
+ const SMDS_MeshCell* cell = dynamic_cast<const SMDS_MeshCell*>(parent);
+ MYASSERT(cell);
+ SMDS_Mesh::_meshList[myMeshId]->getGrid()->RemoveReferenceToCell(myVtkID, cell->getVtkId());
}
//=======================================================================
//function : Print
-//purpose :
+//purpose :
//=======================================================================
void SMDS_MeshNode::Print(ostream & OS) const
{
- OS << "Node <" << myID << "> : X = " << X() << " Y = "
- << Y() << " Z = " << Z() << endl;
+ OS << "Node <" << myID << "> : X = " << X() << " Y = "
+ << Y() << " Z = " << Z() << endl;
}
//=======================================================================
//function : SetPosition
-//purpose :
+//purpose :
//=======================================================================
void SMDS_MeshNode::SetPosition(const SMDS_PositionPtr& aPos)
//=======================================================================
//function : GetPosition
-//purpose :
+//purpose :
//=======================================================================
const SMDS_PositionPtr& SMDS_MeshNode::GetPosition() const
{
- return myPosition;
+ return myPosition;
}
//=======================================================================
SMDS_MeshNode_MyInvIterator(SMDS_Mesh *mesh, vtkIdType* cells, int ncells, SMDSAbs_ElementType type) :
myMesh(mesh), myCells(cells), myNcells(ncells), myType(type), iter(0)
{
- //MESSAGE("SMDS_MeshNode_MyInvIterator : ncells " << myNcells);
- cellList.clear();
+ cellList.reserve( ncells );
if (type == SMDSAbs_All)
+ cellList.assign( cells, cells + ncells );
+ else
for (int i = 0; i < ncells; i++)
- cellList.push_back(cells[i]);
- else for (int i = 0; i < ncells; i++)
{
int vtkId = cells[i];
int smdsId = myMesh->fromVtkToSmds(vtkId);
const SMDS_MeshElement* elem = myMesh->FindElement(smdsId);
if (elem->GetType() == type)
- {
- //MESSAGE("Add element vtkId " << vtkId << " " << elem->GetType())
- cellList.push_back(vtkId);
- }
+ {
+ cellList.push_back(vtkId);
+ }
}
- myCells = &cellList[0];
+ myCells = cellList.empty() ? 0 : &cellList[0];
myNcells = cellList.size();
- //MESSAGE("myNcells="<<myNcells);
}
bool more()
{
- //MESSAGE("iter " << iter << " ncells " << myNcells);
return (iter < myNcells);
}
int smdsId = myMesh->fromVtkToSmds(vtkId);
const SMDS_MeshElement* elem = myMesh->FindElement(smdsId);
if (!elem)
- {
- MESSAGE("SMDS_MeshNode_MyInvIterator problem Null element");
- throw SALOME_Exception("SMDS_MeshNode_MyInvIterator problem Null element");
- }
- //MESSAGE("vtkId " << vtkId << " smdsId " << smdsId << " " << elem->GetType());
+ {
+ MESSAGE("SMDS_MeshNode_MyInvIterator problem Null element");
+ throw SALOME_Exception("SMDS_MeshNode_MyInvIterator problem Null element");
+ }
iter++;
return elem;
}
};
-SMDS_ElemIteratorPtr SMDS_MeshNode::
- GetInverseElementIterator(SMDSAbs_ElementType type) const
+SMDS_ElemIteratorPtr SMDS_MeshNode::GetInverseElementIterator(SMDSAbs_ElementType type) const
{
- vtkCellLinks::Link l = SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetCellLinks()->GetLink(myVtkID);
- //MESSAGE("myID " << myID << " ncells " << l.ncells);
- return SMDS_ElemIteratorPtr(new SMDS_MeshNode_MyInvIterator(SMDS_Mesh::_meshList[myMeshId], l.cells, l.ncells, type));
+ vtkCellLinks::Link l = SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetCellLinks()->GetLink(myVtkID);
+ return SMDS_ElemIteratorPtr(new SMDS_MeshNode_MyInvIterator(SMDS_Mesh::_meshList[myMeshId], l.cells, l.ncells, type));
}
// Same as GetInverseElementIterator but the create iterator only return
int iter;
vector<SMDS_MeshElement*> myFiltCells;
- public:
+public:
SMDS_MeshNode_MyIterator(SMDS_Mesh *mesh,
vtkIdType* cells,
int ncells,
SMDSAbs_ElementType type):
myMesh(mesh), myCells(cells), myNcells(ncells), myType(type), iter(0)
{
- //MESSAGE("myNcells " << myNcells);
- for (; iter<ncells; iter++)
- {
- int vtkId = myCells[iter];
- int smdsId = myMesh->fromVtkToSmds(vtkId);
- //MESSAGE("vtkId " << vtkId << " smdsId " << smdsId);
- const SMDS_MeshElement* elem = myMesh->FindElement(smdsId);
- if (elem->GetType() == type)
- myFiltCells.push_back((SMDS_MeshElement*)elem);
- }
- myNcells = myFiltCells.size();
- //MESSAGE("myNcells " << myNcells);
- iter = 0;
- //MESSAGE("SMDS_MeshNode_MyIterator (filter) " << ncells << " " << myNcells);
+ //MESSAGE("myNcells " << myNcells);
+ for (; iter<ncells; iter++)
+ {
+ int vtkId = myCells[iter];
+ int smdsId = myMesh->fromVtkToSmds(vtkId);
+ //MESSAGE("vtkId " << vtkId << " smdsId " << smdsId);
+ const SMDS_MeshElement* elem = myMesh->FindElement(smdsId);
+ if (elem->GetType() == type)
+ myFiltCells.push_back((SMDS_MeshElement*)elem);
+ }
+ myNcells = myFiltCells.size();
+ //MESSAGE("myNcells " << myNcells);
+ iter = 0;
+ //MESSAGE("SMDS_MeshNode_MyIterator (filter) " << ncells << " " << myNcells);
}
bool more()
{
- return (iter< myNcells);
+ return (iter< myNcells);
}
const SMDS_MeshElement* next()
{
- const SMDS_MeshElement* elem = myFiltCells[iter];
- iter++;
- return elem;
+ const SMDS_MeshElement* elem = myFiltCells[iter];
+ iter++;
+ return elem;
}
};
SMDS_ElemIteratorPtr SMDS_MeshNode::
- elementsIterator(SMDSAbs_ElementType type) const
+elementsIterator(SMDSAbs_ElementType type) const
{
if(type==SMDSAbs_Node)
- return SMDS_MeshElement::elementsIterator(SMDSAbs_Node);
+ return SMDS_MeshElement::elementsIterator(SMDSAbs_Node);
else
{
vtkCellLinks::Link l = SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetCellLinks()->GetLink(myVtkID);
int SMDS_MeshNode::NbNodes() const
{
- return 1;
+ return 1;
}
double* SMDS_MeshNode::getCoord() const
SMDSAbs_ElementType SMDS_MeshNode::GetType() const
{
- return SMDSAbs_Node;
+ return SMDSAbs_Node;
}
vtkIdType SMDS_MeshNode::GetVtkType() const
int nb = 0;
SMDS_Mesh *mesh = SMDS_Mesh::_meshList[myMeshId];
for (int i=0; i<l.ncells; i++)
- {
- const SMDS_MeshElement* elem = mesh->FindElement(mesh->fromVtkToSmds(l.cells[i]));
- if (elem->GetType() == type)
- nb++;
- }
+ {
+ const SMDS_MeshElement* elem = mesh->FindElement(mesh->fromVtkToSmds(l.cells[i]));
+ if (elem->GetType() == type)
+ nb++;
+ }
return nb;
}
///////////////////////////////////////////////////////////////////////////////
bool operator<(const SMDS_MeshNode& e1, const SMDS_MeshNode& e2)
{
- return e1.getVtkId()<e2.getVtkId();
- /*if(e1.myX<e2.myX) return true;
- else if(e1.myX==e2.myX)
- {
- if(e1.myY<e2.myY) return true;
- else if(e1.myY==e2.myY) return (e1.myZ<e2.myZ);
- else return false;
- }
- else return false;*/
+ return e1.getVtkId()<e2.getVtkId();
+ /*if(e1.myX<e2.myX) return true;
+ else if(e1.myX==e2.myX)
+ {
+ if(e1.myY<e2.myY) return true;
+ else if(e1.myY==e2.myY) return (e1.myZ<e2.myZ);
+ else return false;
+ }
+ else return false;*/
}