1 // Copyright (C) 2010-2014 CEA/DEN, EDF R&D, OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // SMESH SMDS : implementaion of Salome mesh data structure
22 // File : SMDS_BallElement.cxx
23 // Author : Edward AGAPOV (eap)
25 #include "SMDS_BallElement.hxx"
27 #include "SMDS_ElemIterator.hxx"
28 #include "SMDS_Mesh.hxx"
29 #include "SMDS_MeshNode.hxx"
30 #include "SMDS_VtkCellIterator.hxx"
32 SMDS_BallElement::SMDS_BallElement()
34 SMDS_MeshCell::init();
37 SMDS_BallElement::SMDS_BallElement (const SMDS_MeshNode * node, double diameter)
39 init( node->getVtkId(), diameter, SMDS_Mesh::_meshList[ node->getMeshId() ] );
42 SMDS_BallElement::SMDS_BallElement(vtkIdType nodeId, double diameter, SMDS_Mesh* mesh)
44 init( nodeId, diameter, mesh );
47 void SMDS_BallElement::init(vtkIdType nodeId, double diameter, SMDS_Mesh* mesh)
49 SMDS_MeshCell::init();
50 SMDS_UnstructuredGrid* grid = mesh->getGrid();
51 myVtkID = grid->InsertNextLinkedCell( GetVtkType(), 1, &nodeId );
52 myMeshId = mesh->getMeshId();
53 grid->SetBallDiameter( myVtkID, diameter );
54 mesh->setMyModified();
57 double SMDS_BallElement::GetDiameter() const
59 return SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetBallDiameter( myVtkID );
62 void SMDS_BallElement::SetDiameter(double diameter)
64 SMDS_Mesh::_meshList[myMeshId]->getGrid()->SetBallDiameter( myVtkID, diameter );
67 bool SMDS_BallElement::ChangeNode (const SMDS_MeshNode * node)
69 vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
72 grid->GetCellPoints(myVtkID, npts, pts);
73 pts[0] = node->getVtkId();
74 SMDS_Mesh::_meshList[myMeshId]->setMyModified();
78 void SMDS_BallElement::Print (std::ostream & OS) const
80 OS << "ball<" << GetID() << "> : ";
83 const SMDS_MeshNode* SMDS_BallElement::GetNode (const int ind) const
85 vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
87 grid->GetCellPoints( myVtkID, npts, pts );
88 return SMDS_Mesh::_meshList[myMeshId]->FindNodeVtk( pts[ 0 ]);
91 SMDS_ElemIteratorPtr SMDS_BallElement::elementsIterator (SMDSAbs_ElementType type) const
96 return SMDS_ElemIteratorPtr(new SMDS_VtkCellIterator(SMDS_Mesh::_meshList[myMeshId], myVtkID, GetEntityType()));
99 return SMDS_ElemIteratorPtr((SMDS_ElemIterator*) NULL);