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_MaxElementVolume.hxx"
45 #include "SMESH_Regular_1D.hxx"
46 #include "SMESH_MEFISTO_2D.hxx"
47 #include "SMESH_Quadrangle_2D.hxx"
48 #include "SMESH_Hexa_3D.hxx"
50 #include "SMESH_NETGEN_3D.hxx"
52 //---------------------------------------
54 //=============================================================================
56 * Specific Hypothesis Creators are generated with a template which inherits a
57 * generic hypothesis creator. Each creator returns an hypothesis of the type
58 * given in the template.
60 //=============================================================================
62 // template <class T> class HypothesisCreator: public GenericHypothesisCreator
65 // virtual T* Create (int hypId)
67 // // return new T(hypId);
72 //=============================================================================
74 * Constructor: instanciate specific hypothesis creators, fill a private map
75 * indexed by hypothesis names. THIS METHOD MUST BE COMPLETED WHEN A NEW
76 * HYPOTHESIS IS ADDED.
77 * Specific hypothesis creator are defined with the above template.
78 * Hypothesis names are related to the corresponding class names:
79 * prefix = SMESH_ ; suffix = .
81 //=============================================================================
83 SMESH_HypothesisFactory::SMESH_HypothesisFactory()
87 // Add new hypothesis here (creators)
88 //---------------------------------------
89 _creatorMap["LocalLength"] = new SMESH_HypothesisCreator<SMESH_LocalLength>;
90 _creatorMap["NumberOfSegments"] = new SMESH_HypothesisCreator<SMESH_NumberOfSegments>;
91 _creatorMap["LengthFromEdges"] = new SMESH_HypothesisCreator<SMESH_LengthFromEdges>;
92 _creatorMap["MaxElementArea"] = new SMESH_HypothesisCreator<SMESH_MaxElementArea>;
93 _creatorMap["MaxElementVolume"] = new SMESH_HypothesisCreator<SMESH_MaxElementVolume>;
94 _creatorMap["Regular_1D"] = new SMESH_HypothesisCreator<SMESH_Regular_1D>;
95 _creatorMap["MEFISTO_2D"] = new SMESH_HypothesisCreator<SMESH_MEFISTO_2D>;
96 _creatorMap["Quadrangle_2D"] = new SMESH_HypothesisCreator<SMESH_Quadrangle_2D>;
97 _creatorMap["Hexa_3D"] = new SMESH_HypothesisCreator<SMESH_Hexa_3D>;
99 _creatorMap["NETGEN_3D"] = new SMESH_HypothesisCreator<SMESH_NETGEN_3D>;
101 //---------------------------------------
104 //=============================================================================
106 * Destructor: deletes specific hypothesis creators instanciated in the
109 //=============================================================================
111 SMESH_HypothesisFactory::~SMESH_HypothesisFactory()
113 map<string, GenericHypothesisCreator*>::iterator it;
114 for (it = _creatorMap.begin(); it != _creatorMap.end(); it++)
121 //=============================================================================
125 //=============================================================================
127 SMESH_Hypothesis* SMESH_HypothesisFactory::Create(const char* anHypName,
129 throw (SALOME_Exception)
131 MESSAGE("SMESH_HypothesisFactory::Create " << anHypName);
132 if (_creatorMap.find(anHypName) == _creatorMap.end())
133 throw(SALOME_Exception(LOCALIZED("bad hypothesis type name")));
134 SMESH_Hypothesis* myHyp = _creatorMap[anHypName]->Create(_hypId++,
140 //=============================================================================
144 //=============================================================================
146 GenericHypothesisCreator*
147 SMESH_HypothesisFactory::GetCreator(const char* anHypName)
148 throw (SALOME_Exception)
150 MESSAGE("SMESH_HypothesisFactory::GetCreator " << anHypName);
151 if (_creatorMap.find(anHypName) == _creatorMap.end())
152 throw(SALOME_Exception(LOCALIZED("bad hypothesis type name")));
153 return _creatorMap[anHypName];
156 //=============================================================================
160 //=============================================================================
162 int SMESH_HypothesisFactory::GetANewId()
164 //MESSAGE("SMESH_HypothesisFactory::GetANewId");
168 //=============================================================================
172 //=============================================================================
174 void SMESH_HypothesisFactory::SetGen(SMESH_Gen* gen)
176 //MESSAGE("SMESH_HypothesisFactory::SetGen");