1 // Copyright (C) 2007-2022 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 SMESH : implementation of SMESH idl descriptions
24 // File : SMESH_Hypothesis.cxx
25 // Author : Paul RASCLE, EDF
29 #include "SMESH_Gen.hxx"
31 #include "SMESHDS_Mesh.hxx"
32 #include "SMESH_Hypothesis.hxx"
33 #include "SMESH_Mesh.hxx"
37 //=============================================================================
41 //=============================================================================
43 SMESH_Hypothesis::SMESH_Hypothesis(int hypId,
44 SMESH_Gen* gen) : SMESHDS_Hypothesis(hypId)
48 _shapeType = 0; // to be set by algo with TopAbs_Enum
49 _param_algo_dim = -1; // to be set by algo parameter
50 StudyContextStruct* myStudyContext = gen->GetStudyContext();
51 myStudyContext->mapHypothesis[hypId] = this;
54 //=============================================================================
58 //=============================================================================
60 SMESH_Hypothesis::~SMESH_Hypothesis()
64 StudyContextStruct* myStudyContext = _gen->GetStudyContext();
65 myStudyContext->mapHypothesis[_hypId] = 0;
69 //=============================================================================
73 //=============================================================================
75 int SMESH_Hypothesis::GetDim() const
80 case ALGO_1D: dim = 1; break;
81 case ALGO_2D: dim = 2; break;
82 case ALGO_3D: dim = 3; break;
83 case ALGO_0D: dim = 0; break;
85 dim = ( _param_algo_dim < 0 ) ? -_param_algo_dim : _param_algo_dim; break;
90 //=============================================================================
94 //=============================================================================
96 int SMESH_Hypothesis::GetShapeType() const
101 //=============================================================================
105 //=============================================================================
107 void SMESH_Hypothesis::NotifySubMeshesHypothesisModification()
109 // for all meshes in study
111 StudyContextStruct* myStudyContext = _gen->GetStudyContext();
112 map<int, SMESH_Mesh*>::iterator itm;
113 for (itm = myStudyContext->mapMesh.begin();
114 itm != myStudyContext->mapMesh.end();
117 SMESH_Mesh* mesh = (*itm).second;
118 mesh->NotifySubMeshesHypothesisModification( this );
122 //=============================================================================
126 //=============================================================================
128 const char* SMESH_Hypothesis::GetLibName() const
130 return _libName.c_str();
133 //=============================================================================
137 //=============================================================================
139 void SMESH_Hypothesis::SetLibName(const char* theLibName)
141 _libName = string(theLibName);
144 //=======================================================================
145 //function : GetMeshByPersistentID
146 //purpose : Find a mesh with given persistent ID
147 //=======================================================================
149 SMESH_Mesh* SMESH_Hypothesis::GetMeshByPersistentID(int id) const
151 StudyContextStruct* myStudyContext = _gen->GetStudyContext();
152 map<int, SMESH_Mesh*>::iterator itm = myStudyContext->mapMesh.begin();
153 for ( ; itm != myStudyContext->mapMesh.end(); itm++)
155 SMESH_Mesh* mesh = (*itm).second;
156 if ( mesh->GetMeshDS()->GetPersistentId() == id )