1 // Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // SMESH SMDS : implementation of Salome mesh data structure
26 #pragma warning(disable:4786)
29 #include "SMDS_VolumeOfNodes.hxx"
31 #include "SMDS_MeshNode.hxx"
32 #include "SMDS_SetIterator.hxx"
34 #include <boost/make_shared.hpp>
36 #include <utilities.h>
38 ///////////////////////////////////////////////////////////////////////////////
39 /// Create an hexahedron. node 1,2,3,4 and 5,6,7,8 are quadrangle and
40 /// 5,1 and 7,3 are an edges.
41 ///////////////////////////////////////////////////////////////////////////////
42 SMDS_VolumeOfNodes::SMDS_VolumeOfNodes(const SMDS_MeshNode * node1,
43 const SMDS_MeshNode * node2,
44 const SMDS_MeshNode * node3,
45 const SMDS_MeshNode * node4,
46 const SMDS_MeshNode * node5,
47 const SMDS_MeshNode * node6,
48 const SMDS_MeshNode * node7,
49 const SMDS_MeshNode * node8)
52 myNodes = new const SMDS_MeshNode* [myNbNodes];
63 SMDS_VolumeOfNodes::SMDS_VolumeOfNodes(const SMDS_MeshNode * node1,
64 const SMDS_MeshNode * node2,
65 const SMDS_MeshNode * node3,
66 const SMDS_MeshNode * node4)
69 myNodes = new const SMDS_MeshNode* [myNbNodes];
76 SMDS_VolumeOfNodes::SMDS_VolumeOfNodes(const SMDS_MeshNode * node1,
77 const SMDS_MeshNode * node2,
78 const SMDS_MeshNode * node3,
79 const SMDS_MeshNode * node4,
80 const SMDS_MeshNode * node5)
83 myNodes = new const SMDS_MeshNode* [myNbNodes];
91 SMDS_VolumeOfNodes::SMDS_VolumeOfNodes(const SMDS_MeshNode * node1,
92 const SMDS_MeshNode * node2,
93 const SMDS_MeshNode * node3,
94 const SMDS_MeshNode * node4,
95 const SMDS_MeshNode * node5,
96 const SMDS_MeshNode * node6)
99 myNodes = new const SMDS_MeshNode* [myNbNodes];
108 bool SMDS_VolumeOfNodes::ChangeNodes(const SMDS_MeshNode* nodes[],
111 if (nbNodes < 4 || nbNodes > 8 || nbNodes == 7)
116 myNodes = new const SMDS_MeshNode* [myNbNodes];
117 for ( int i = 0; i < nbNodes; i++ )
118 myNodes[ i ] = nodes [ i ];
123 SMDS_VolumeOfNodes::~SMDS_VolumeOfNodes()
125 if (myNodes != NULL) {
131 void SMDS_VolumeOfNodes::Print(std::ostream & OS) const
133 OS << "volume <" << GetID() << "> : ";
135 for (i = 0; i < NbNodes()-1; ++i) OS << myNodes[i] << ",";
136 OS << myNodes[NbNodes()-1]<< ") " << std::endl;
139 int SMDS_VolumeOfNodes::NbFaces() const
147 default: MESSAGE("invalid number of nodes");
152 int SMDS_VolumeOfNodes::NbNodes() const
157 int SMDS_VolumeOfNodes::NbEdges() const
165 default: MESSAGE("invalid number of nodes");
171 SMDSAbs_ElementType SMDS_VolumeOfNodes::GetType() const
173 return SMDSAbs_Volume;
177 * \brief Return node by its index
178 * \param ind - node index
179 * \retval const SMDS_MeshNode* - the node
181 const SMDS_MeshNode* SMDS_VolumeOfNodes::GetNode(const int ind) const
183 return myNodes[ ind ];
186 SMDSAbs_EntityType SMDS_VolumeOfNodes::GetEntityType() const
188 SMDSAbs_EntityType aType = SMDSEntity_Tetra;
191 case 4: aType = SMDSEntity_Tetra; break;
192 case 5: aType = SMDSEntity_Pyramid; break;
193 case 6: aType = SMDSEntity_Penta; break;
195 default: aType = SMDSEntity_Hexa; break;
200 SMDSAbs_GeometryType SMDS_VolumeOfNodes::GetGeomType() const
202 SMDSAbs_GeometryType aType = SMDSGeom_NONE;
205 case 4: aType = SMDSGeom_TETRA; break;
206 case 5: aType = SMDSGeom_PYRAMID; break;
207 case 6: aType = SMDSGeom_PENTA; break;
208 case 12: aType = SMDSGeom_HEXAGONAL_PRISM; break;
210 default: aType = SMDSGeom_HEXA; break;
215 int SMDS_VolumeOfNodes::GetNodeIndex( const SMDS_MeshNode* node ) const
217 for ( int i = 0; i < myNbNodes; ++i )
218 if ( myNodes[i] == node )
223 SMDS_ElemIteratorPtr SMDS_VolumeOfNodes::nodesIterator() const
225 return boost::make_shared< SMDS_NodeArrayElemIterator >( &myNodes[0], &myNodes[0] + NbNodes() );
228 SMDS_NodeIteratorPtr SMDS_VolumeOfNodes::nodeIterator() const
230 return boost::make_shared< SMDS_NodeArrayIterator >( &myNodes[0], &myNodes[0] + NbNodes() );