From 1d17befa343b9042836395a0ed66d04edc8a14e6 Mon Sep 17 00:00:00 2001 From: eap Date: Thu, 19 Jul 2012 12:55:29 +0000 Subject: [PATCH] 0021459: EDF 1495 SMESH: Manipulation of discrete elements with attributes + SMDS_BallElement.hxx --- src/SMDS/Makefile.am | 10 ++-- src/SMDS/SMDS_BallElement.cxx | 102 ++++++++++++++++++++++++++++++++++ src/SMDS/SMDS_BallElement.hxx | 60 ++++++++++++++++++++ 3 files changed, 167 insertions(+), 5 deletions(-) create mode 100644 src/SMDS/SMDS_BallElement.cxx create mode 100644 src/SMDS/SMDS_BallElement.hxx diff --git a/src/SMDS/Makefile.am b/src/SMDS/Makefile.am index 1b4fdb209..9afd8d83b 100644 --- a/src/SMDS/Makefile.am +++ b/src/SMDS/Makefile.am @@ -74,14 +74,15 @@ salomeinclude_HEADERS = \ SMDS_UnstructuredGrid.hxx \ SMDS_Downward.hxx \ SMDS_StdIterator.hxx \ - SMDS_IteratorOnIterators.hxx + SMDS_IteratorOnIterators.hxx \ + SMDS_BallElement.hxx # Libraries targets lib_LTLIBRARIES = libSMDS.la dist_libSMDS_la_SOURCES = \ - chrono.cxx \ + chrono.cxx \ SMDS_MeshObject.cxx \ SMDS_MeshElement.cxx \ SMDS_MeshCell.cxx \ @@ -117,7 +118,8 @@ dist_libSMDS_la_SOURCES = \ SMDS_QuadraticFaceOfNodes.cxx \ SMDS_QuadraticVolumeOfNodes.cxx \ SMDS_UnstructuredGrid.cxx \ - SMDS_Downward.cxx + SMDS_Downward.cxx \ + SMDS_BallElement.cxx # additionnal information to compil and link file libSMDS_la_CPPFLAGS = \ @@ -133,5 +135,3 @@ libSMDS_la_LDFLAGS = \ bin_PROGRAMS = SMDS_MemoryLimit dist_SMDS_MemoryLimit_SOURCES = \ SMDS_MemoryLimit.cxx - -#libSMDS_la_LDFLAGS += -L/data/eap/S5_MV/INSTALL/SMESH/lib/salome -lPerfmeter diff --git a/src/SMDS/SMDS_BallElement.cxx b/src/SMDS/SMDS_BallElement.cxx new file mode 100644 index 000000000..9595e9889 --- /dev/null +++ b/src/SMDS/SMDS_BallElement.cxx @@ -0,0 +1,102 @@ +// Copyright (C) 2010-2012 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +// SMESH SMDS : implementaion of Salome mesh data structure +// Module : SMESH +// File : SMDS_BallElement.cxx +// Author : Edward AGAPOV (eap) + +#include "SMDS_BallElement.hxx" + +#include "SMDS_ElemIterator.hxx" +#include "SMDS_Mesh.hxx" +#include "SMDS_MeshNode.hxx" +#include "SMDS_VtkCellIterator.hxx" + +SMDS_BallElement::SMDS_BallElement() +{ + SMDS_MeshCell::init(); +} + +SMDS_BallElement::SMDS_BallElement (const SMDS_MeshNode * node, double diameter) +{ + init( node->getVtkId(), diameter, SMDS_Mesh::_meshList[ node->getMeshId() ] ); +} + +SMDS_BallElement::SMDS_BallElement(vtkIdType nodeId, double diameter, SMDS_Mesh* mesh) +{ + init( nodeId, diameter, mesh ); +} + +void SMDS_BallElement::init(vtkIdType nodeId, double diameter, SMDS_Mesh* mesh) +{ + SMDS_MeshCell::init(); + SMDS_UnstructuredGrid* grid = mesh->getGrid(); + myVtkID = grid->InsertNextLinkedCell( GetVtkType(), 1, &nodeId ); + myMeshId = mesh->getMeshId(); + grid->SetBallDiameter( myVtkID, diameter ); + mesh->setMyModified(); +} + +double SMDS_BallElement::GetDiameter() const +{ + return SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetBallDiameter( myVtkID ); +} + +void SMDS_BallElement::SetDiameter(double diameter) +{ + SMDS_Mesh::_meshList[myMeshId]->getGrid()->SetBallDiameter( myVtkID, diameter ); +} + +bool SMDS_BallElement::ChangeNode (const SMDS_MeshNode * node) +{ + vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid(); + vtkIdType npts = 0; + vtkIdType* pts = 0; + grid->GetCellPoints(myVtkID, npts, pts); + pts[0] = node->getVtkId(); + SMDS_Mesh::_meshList[myMeshId]->setMyModified(); + return true; +} + +void SMDS_BallElement::Print (std::ostream & OS) const +{ + OS << "ball<" << GetID() << "> : "; +} + +const SMDS_MeshNode* SMDS_BallElement::GetNode (const int ind) const +{ + vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid(); + vtkIdType npts, *pts; + grid->GetCellPoints( myVtkID, npts, pts ); + return SMDS_Mesh::_meshList[myMeshId]->FindNodeVtk( pts[ 0 ]); +} + +SMDS_ElemIteratorPtr SMDS_BallElement::elementsIterator (SMDSAbs_ElementType type) const +{ + switch (type) + { + case SMDSAbs_Node: + return SMDS_ElemIteratorPtr(new SMDS_VtkCellIterator(SMDS_Mesh::_meshList[myMeshId], myVtkID, GetEntityType())); + default: + ; + return SMDS_ElemIteratorPtr((SMDS_ElemIterator*) NULL); + } +} + diff --git a/src/SMDS/SMDS_BallElement.hxx b/src/SMDS/SMDS_BallElement.hxx new file mode 100644 index 000000000..c8ead2a7a --- /dev/null +++ b/src/SMDS/SMDS_BallElement.hxx @@ -0,0 +1,60 @@ +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +// SMESH SMDS : implementaion of Salome mesh data structure +// File : SMDS_BallElement.hxx +// Module : SMESH +// +#ifndef _SMDS_BallElement_HeaderFile +#define _SMDS_BallElement_HeaderFile + +#include "SMESH_SMDS.hxx" +#include "SMDS_MeshCell.hxx" + +#include + +class SMDS_EXPORT SMDS_BallElement: public SMDS_MeshCell +{ + public: + SMDS_BallElement(); + SMDS_BallElement (const SMDS_MeshNode * node, double diameter); + SMDS_BallElement(vtkIdType nodeId, double diameter, SMDS_Mesh* mesh); + void init(vtkIdType nodeId, double diameter, SMDS_Mesh* mesh); + double GetDiameter() const; + void SetDiameter(double diameter); + bool ChangeNode (const SMDS_MeshNode * node); + + virtual bool ChangeNodes(const SMDS_MeshNode* nodes[], + const int nbNodes) { return ChangeNode( nodes[0] ); } + virtual void Print (std::ostream & OS) const; + + virtual SMDSAbs_ElementType GetType() const { return SMDSAbs_Ball; } + virtual vtkIdType GetVtkType() const { return VTK_POLY_VERTEX; } + virtual SMDSAbs_EntityType GetEntityType() const { return SMDSEntity_Ball; } + virtual SMDSAbs_GeometryType GetGeomType() const { return SMDSGeom_BALL; } + virtual int NbNodes() const { return 1; } + virtual int NbEdges() const { return 0; } + virtual int NbFaces() const { return 0; } + virtual const SMDS_MeshNode* GetNode (const int ind) const; + + protected: + SMDS_ElemIteratorPtr elementsIterator (SMDSAbs_ElementType type) const; +}; + +#endif