Salome HOME
Add support for tetra, pyramid and prism
[modules/smesh.git] / src / SMESH / SMESH_Hypothesis.cxx
1 //  SMESH SMESH : implementaion of SMESH idl descriptions
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
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. 
10 // 
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. 
15 // 
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 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : SMESH_Hypothesis.cxx
25 //  Author : Paul RASCLE, EDF
26 //  Module : SMESH
27 //  $Header$
28
29 using namespace std;
30 using namespace std;
31 #include "SMESH_Hypothesis.hxx"
32 #include "SMESH_Gen.hxx"
33 #include "utilities.h"
34
35 //=============================================================================
36 /*!
37  * 
38  */
39 //=============================================================================
40
41 SMESH_Hypothesis::SMESH_Hypothesis(int hypId,
42                                    int studyId,
43                                    SMESH_Gen* gen) : SMESHDS_Hypothesis(hypId)
44 {
45   //MESSAGE("SMESH_Hypothesis::SMESH_Hypothesis");
46   _gen = gen;
47   _studyId = studyId;
48   StudyContextStruct* myStudyContext = _gen->GetStudyContext(_studyId);
49   myStudyContext->mapHypothesis[_hypId] = this;
50   _type = PARAM_ALGO;
51 //   _shapeType = -1; // to be set by algo with TopAbs_Enum
52   _shapeType = 0; // to be set by algo with TopAbs_Enum
53 }
54
55 //=============================================================================
56 /*!
57  * 
58  */
59 //=============================================================================
60
61 SMESH_Hypothesis::~SMESH_Hypothesis()
62 {
63   MESSAGE("SMESH_Hypothesis::~SMESH_Hypothesis");
64 }
65
66 //=============================================================================
67 /*!
68  * 
69  */
70 //=============================================================================
71
72 int SMESH_Hypothesis::GetDim()
73 {
74   int dim = -1;
75   switch (_type)
76     {
77     case ALGO_1D: dim = 1; break;
78     case ALGO_2D: dim = 2; break;
79     case ALGO_3D: dim = 3; break;
80     }
81   return dim;
82 }
83
84 //=============================================================================
85 /*!
86  *  
87  */
88 //=============================================================================
89
90 int SMESH_Hypothesis::GetShapeType()
91 {
92   return _shapeType;
93 }
94
95 //=============================================================================
96 /*!
97  * 
98  */
99 //=============================================================================
100
101 int SMESH_Hypothesis::GetStudyId()
102 {
103   return _studyId;
104 }
105
106 //=============================================================================
107 /*!
108  * 
109  */
110 //=============================================================================
111
112 void SMESH_Hypothesis::NotifySubMeshesHypothesisModification()
113 {
114   MESSAGE("SMESH_Hypothesis::NotifySubMeshesHypothesisModification");
115
116   // for all meshes in study
117
118   StudyContextStruct* myStudyContext = _gen->GetStudyContext(_studyId);
119   map<int, SMESH_Mesh*>::iterator itm;
120   for (itm = myStudyContext->mapMesh.begin();
121        itm != myStudyContext->mapMesh.end();
122        itm++)
123     {
124       SMESH_Mesh* mesh = (*itm).second;
125       const list<SMESH_subMesh*>& subMeshes =
126          mesh->GetSubMeshUsingHypothesis(this);
127
128       //for all subMeshes using hypothesis
129         
130       list<SMESH_subMesh*>::const_iterator its;
131       for (its = subMeshes.begin(); its != subMeshes.end(); its++)
132         (*its)->ComputeStateEngine(SMESH_subMesh::MODIF_HYP);
133     }
134 }
135