1 // SMESH SMESH : implementaion of SMESH idl descriptions
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
24 // File : SMESH_HypothesisFactory.cxx
25 // Author : Paul RASCLE, EDF
31 #include "SMESH_HypothesisFactory.hxx"
32 #include "SMESH_Hypothesis.hxx"
33 #include "SMESH_HypothesisCreator.hxx"
34 #include "SMESH_Gen.hxx"
36 #include "utilities.h"
38 // Add new hypothesis here (include file)
39 //---------------------------------------
40 #include "SMESH_LocalLength.hxx"
41 #include "SMESH_LengthFromEdges.hxx"
42 #include "SMESH_NumberOfSegments.hxx"
43 #include "SMESH_MaxElementArea.hxx"
44 #include "SMESH_Regular_1D.hxx"
45 #include "SMESH_MEFISTO_2D.hxx"
46 #include "SMESH_Quadrangle_2D.hxx"
47 #include "SMESH_Hexa_3D.hxx"
49 //---------------------------------------
51 //=============================================================================
53 * Specific Hypothesis Creators are generated with a template which inherits a
54 * generic hypothesis creator. Each creator returns an hypothesis of the type
55 * given in the template.
57 //=============================================================================
59 // template <class T> class HypothesisCreator: public GenericHypothesisCreator
62 // virtual T* Create (int hypId)
64 // // return new T(hypId);
69 //=============================================================================
71 * Constructor: instanciate specific hypothesis creators, fill a private map
72 * indexed by hypothesis names. THIS METHOD MUST BE COMPLETED WHEN A NEW
73 * HYPOTHESIS IS ADDED.
74 * Specific hypothesis creator are defined with the above template.
75 * Hypothesis names are related to the corresponding class names:
76 * prefix = SMESH_ ; suffix = .
78 //=============================================================================
80 SMESH_HypothesisFactory::SMESH_HypothesisFactory()
84 // Add new hypothesis here (creators)
85 //---------------------------------------
86 _creatorMap["LocalLength"] = new SMESH_HypothesisCreator<SMESH_LocalLength>;
87 _creatorMap["NumberOfSegments"] = new SMESH_HypothesisCreator<SMESH_NumberOfSegments>;
88 _creatorMap["LengthFromEdges"] = new SMESH_HypothesisCreator<SMESH_LengthFromEdges>;
89 _creatorMap["MaxElementArea"] = new SMESH_HypothesisCreator<SMESH_MaxElementArea>;
90 _creatorMap["Regular_1D"] = new SMESH_HypothesisCreator<SMESH_Regular_1D>;
91 _creatorMap["MEFISTO_2D"] = new SMESH_HypothesisCreator<SMESH_MEFISTO_2D>;
92 _creatorMap["Quadrangle_2D"] = new SMESH_HypothesisCreator<SMESH_Quadrangle_2D>;
93 _creatorMap["Hexa_3D"] = new SMESH_HypothesisCreator<SMESH_Hexa_3D>;
95 //---------------------------------------
98 //=============================================================================
100 * Destructor: deletes specific hypothesis creators instanciated in the
103 //=============================================================================
105 SMESH_HypothesisFactory::~SMESH_HypothesisFactory()
107 map<string, GenericHypothesisCreator*>::iterator it;
108 for (it = _creatorMap.begin(); it != _creatorMap.end(); it++)
115 //=============================================================================
119 //=============================================================================
121 SMESH_Hypothesis* SMESH_HypothesisFactory::Create(const char* anHypName,
123 throw (SALOME_Exception)
125 MESSAGE("SMESH_HypothesisFactory::Create " << anHypName);
126 if (_creatorMap.find(anHypName) == _creatorMap.end())
127 throw(SALOME_Exception(LOCALIZED("bad hypothesis type name")));
128 SMESH_Hypothesis* myHyp = _creatorMap[anHypName]->Create(_hypId++,
134 //=============================================================================
138 //=============================================================================
140 GenericHypothesisCreator*
141 SMESH_HypothesisFactory::GetCreator(const char* anHypName)
142 throw (SALOME_Exception)
144 MESSAGE("SMESH_HypothesisFactory::GetCreator " << anHypName);
145 if (_creatorMap.find(anHypName) == _creatorMap.end())
146 throw(SALOME_Exception(LOCALIZED("bad hypothesis type name")));
147 return _creatorMap[anHypName];
150 //=============================================================================
154 //=============================================================================
156 int SMESH_HypothesisFactory::GetANewId()
158 //MESSAGE("SMESH_HypothesisFactory::GetANewId");
162 //=============================================================================
166 //=============================================================================
168 void SMESH_HypothesisFactory::SetGen(SMESH_Gen* gen)
170 //MESSAGE("SMESH_HypothesisFactory::SetGen");