Salome HOME
Merge from V6_main (04/10/2012)
[modules/paravis.git] / src / Plugins / MedReader / IO / vtkMedFamilyOnEntity.cxx
1 // Copyright (C) 2010-2012  CEA/DEN, EDF R&D
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #include "vtkMedFamilyOnEntity.h"
21
22 #include "vtkObjectFactory.h"
23 #include "vtkMedUtilities.h"
24 #include "vtkMedFamily.h"
25 #include "vtkMedEntityArray.h"
26 #include "vtkMedMesh.h"
27 #include "vtkMedGrid.h"
28 #include "vtkMedFamilyOnEntityOnProfile.h"
29
30 vtkCxxSetObjectMacro(vtkMedFamilyOnEntity, Family, vtkMedFamily);
31 vtkCxxSetObjectMacro(vtkMedFamilyOnEntity, EntityArray, vtkMedEntityArray);
32
33 vtkCxxSetObjectMacro(vtkMedFamilyOnEntity, ParentGrid,vtkMedGrid);
34
35 vtkCxxRevisionMacro(vtkMedFamilyOnEntity, "$Revision$");
36 vtkStandardNewMacro(vtkMedFamilyOnEntity)
37
38 vtkMedFamilyOnEntity::vtkMedFamilyOnEntity()
39 {
40   this->Family = NULL;
41   this->EntityArray = NULL;
42   this->ParentGrid = NULL;
43 }
44
45 vtkMedFamilyOnEntity::~vtkMedFamilyOnEntity()
46 {
47   this->SetFamily(NULL);
48   this->SetEntityArray(NULL);
49   this->SetParentGrid(NULL);
50 }
51
52 vtkMedEntity vtkMedFamilyOnEntity::GetEntity()
53 {
54   if(this->EntityArray != NULL)
55     {
56     return this->EntityArray->GetEntity();
57     }
58
59   return vtkMedEntity(MED_NODE, MED_POINT1);
60 }
61
62 int vtkMedFamilyOnEntity::GetPointOrCell()
63 {
64   if(this->GetEntity().EntityType == MED_NODE)
65     return vtkMedUtilities::OnPoint;
66   return vtkMedUtilities::OnCell;
67 }
68
69 int vtkMedFamilyOnEntity::GetVertexOnly()
70 {
71   if(this->GetPointOrCell() == vtkMedUtilities::OnPoint ||
72      this->EntityArray == NULL)
73     return true;
74
75   vtkMedEntity entity = this->EntityArray->GetEntity();
76   if(entity.EntityType == MED_POINT1 || entity.GeometryType == MED_NONE)
77     return true;
78
79   if(entity.GeometryName == MED_BALL_NAME && entity.EntityType == MED_STRUCT_ELEMENT)
80     return true;
81
82   if(entity.GeometryName == MED_PARTICLE_NAME && entity.EntityType == MED_STRUCT_ELEMENT)
83     return true;
84
85   return false;
86 }
87
88 void  vtkMedFamilyOnEntity::AddFamilyOnEntityOnProfile(
89     vtkMedFamilyOnEntityOnProfile* foep)
90 {
91   this->FamilyOnEntityOnProfile[foep->GetProfile()] = foep;
92 }
93
94 int vtkMedFamilyOnEntity::GetNumberOfFamilyOnEntityOnProfile()
95 {
96   return this->FamilyOnEntityOnProfile.size();
97 }
98
99 vtkMedFamilyOnEntityOnProfile* vtkMedFamilyOnEntity::
100     GetFamilyOnEntityOnProfile(vtkMedProfile* profile)
101 {
102   if(this->FamilyOnEntityOnProfile.find(profile)
103     != this->FamilyOnEntityOnProfile.end())
104     return this->FamilyOnEntityOnProfile[profile];
105
106   return NULL;
107 }
108
109 vtkMedFamilyOnEntityOnProfile* vtkMedFamilyOnEntity::
110     GetFamilyOnEntityOnProfile(int index)
111 {
112   if(index < 0 || index >= this->FamilyOnEntityOnProfile.size())
113     return NULL;
114
115   std::map<vtkMedProfile*,
116   vtkSmartPointer<vtkMedFamilyOnEntityOnProfile> >::iterator it =
117   this->FamilyOnEntityOnProfile.begin();
118
119   for(int ii=0; ii<index; ii++)
120     it++;
121
122   return it->second;
123 }
124
125 void vtkMedFamilyOnEntity::PrintSelf(ostream& os, vtkIndent indent)
126 {
127   this->Superclass::PrintSelf(os, indent);
128   PRINT_OBJECT(os, indent, Family);
129   PRINT_OBJECT(os, indent, EntityArray);
130 }