1 // SMESH SMDS : implementaion of Salome mesh data structure
3 // Copyright (C) 2003 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.
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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
23 #pragma warning(disable:4786)
26 #include "SMDS_PolyhedralVolumeOfNodes.hxx"
27 #include "SMDS_MeshNode.hxx"
28 #include "utilities.h"
34 //=======================================================================
35 //function : Constructor
36 //purpose : Create a volume of many faces
37 //=======================================================================
38 SMDS_PolyhedralVolumeOfNodes::SMDS_PolyhedralVolumeOfNodes
39 (std::vector<const SMDS_MeshNode *> nodes,
40 std::vector<int> quantities)
41 : SMDS_VolumeOfNodes(NULL, NULL, NULL, NULL)
43 ChangeNodes(nodes, quantities);
46 //=======================================================================
49 //=======================================================================
50 SMDSAbs_ElementType SMDS_PolyhedralVolumeOfNodes::GetType() const
52 // return SMDSAbs_PolyhedralVolume;
53 return SMDSAbs_Volume;
56 //=======================================================================
57 //function : ChangeNodes
59 //=======================================================================
60 bool SMDS_PolyhedralVolumeOfNodes::ChangeNodes (std::vector<const SMDS_MeshNode *> nodes,
61 std::vector<int> quantities)
63 myNodesByFaces = nodes;
64 myQuantities = quantities;
66 // Init fields of parent class
68 std::set<const SMDS_MeshNode *> aSet;
69 int nodes_len = nodes.size();
70 for (int j = 0; j < nodes_len; j++) {
71 if (aSet.find(nodes[j]) == aSet.end()) {
72 aSet.insert(nodes[j]);
79 const SMDS_MeshNode* aNodes [aNbNodes];
81 const SMDS_MeshNode** aNodes = (const SMDS_MeshNode **)new SMDS_MeshNode*[aNbNodes];
83 std::set<const SMDS_MeshNode *>::iterator anIter = aSet.begin();
84 for (; anIter != aSet.end(); anIter++, k++) {
88 //SMDS_VolumeOfNodes::ChangeNodes(aNodes, aNbNodes);
90 //myNbNodes = nodes.size();
92 myNodes = new const SMDS_MeshNode* [myNbNodes];
93 for (int i = 0; i < myNbNodes; i++) {
94 //myNodes[i] = nodes[i];
95 myNodes[i] = aNodes[i];
105 //=======================================================================
108 //=======================================================================
109 int SMDS_PolyhedralVolumeOfNodes::NbEdges() const
113 for (int ifa = 0; ifa < myQuantities.size(); ifa++) {
114 nbEdges += myQuantities[ifa];
121 //=======================================================================
124 //=======================================================================
125 int SMDS_PolyhedralVolumeOfNodes::NbFaces() const
127 return myQuantities.size();
130 //=======================================================================
131 //function : NbFaceNodes
133 //=======================================================================
134 int SMDS_PolyhedralVolumeOfNodes::NbFaceNodes (const int face_ind) const
136 if (face_ind < 1 || myQuantities.size() < face_ind)
138 return myQuantities[face_ind - 1];
141 //=======================================================================
142 //function : GetFaceNode
144 //=======================================================================
145 const SMDS_MeshNode* SMDS_PolyhedralVolumeOfNodes::GetFaceNode (const int face_ind,
146 const int node_ind) const
148 if (node_ind < 1 || NbFaceNodes(face_ind) < node_ind)
151 int i, first_node = 0;
152 for (i = 0; i < face_ind - 1; i++) {
153 first_node += myQuantities[i];
156 return myNodesByFaces[first_node + node_ind - 1];
159 //=======================================================================
162 //=======================================================================
163 void SMDS_PolyhedralVolumeOfNodes::Print (ostream & OS) const
165 OS << "polyhedral volume <" << GetID() << "> : ";
167 int faces_len = myQuantities.size();
168 //int nodes_len = myNodesByFaces.size();
169 int cur_first_node = 0;
172 for (i = 0; i < faces_len; i++) {
173 OS << "face_" << i << " (";
174 for (j = 0; j < myQuantities[i] - 1; j++) {
175 OS << myNodesByFaces[cur_first_node + j] << ",";
177 OS << myNodesByFaces[cur_first_node + j] << ") ";
178 cur_first_node += myQuantities[i];
182 //=======================================================================
183 //function : ChangeNodes
184 //purpose : usage disabled
185 //=======================================================================
186 bool SMDS_PolyhedralVolumeOfNodes::ChangeNodes (const SMDS_MeshNode* nodes[],