2 //=============================================================================
3 // File : SMESH_HypothesisFactory.cxx
4 // Created : mer mai 15 13:45:50 CEST 2002
5 // Author : Paul RASCLE, EDF
7 // Copyright : EDF 2002
9 //=============================================================================
12 #include "SMESH_HypothesisFactory.hxx"
13 #include "SMESH_Hypothesis.hxx"
14 #include "SMESH_HypothesisCreator.hxx"
15 #include "SMESH_Gen.hxx"
17 #include "utilities.h"
19 // Add new hypothesis here (include file)
20 //---------------------------------------
21 #include "SMESH_LocalLength.hxx"
22 #include "SMESH_LengthFromEdges.hxx"
23 #include "SMESH_NumberOfSegments.hxx"
24 #include "SMESH_MaxElementArea.hxx"
25 #include "SMESH_Regular_1D.hxx"
26 #include "SMESH_MEFISTO_2D.hxx"
27 #include "SMESH_Quadrangle_2D.hxx"
28 #include "SMESH_Hexa_3D.hxx"
30 //---------------------------------------
32 //=============================================================================
34 * Specific Hypothesis Creators are generated with a template which inherits a
35 * generic hypothesis creator. Each creator returns an hypothesis of the type
36 * given in the template.
38 //=============================================================================
40 // template <class T> class HypothesisCreator: public GenericHypothesisCreator
43 // virtual T* Create (int hypId)
45 // // return new T(hypId);
50 //=============================================================================
52 * Constructor: instanciate specific hypothesis creators, fill a private map
53 * indexed by hypothesis names. THIS METHOD MUST BE COMPLETED WHEN A NEW
54 * HYPOTHESIS IS ADDED.
55 * Specific hypothesis creator are defined with the above template.
56 * Hypothesis names are related to the corresponding class names:
57 * prefix = SMESH_ ; suffix = .
59 //=============================================================================
61 SMESH_HypothesisFactory::SMESH_HypothesisFactory()
65 // Add new hypothesis here (creators)
66 //---------------------------------------
67 _creatorMap["LocalLength"] = new SMESH_HypothesisCreator<SMESH_LocalLength>;
68 _creatorMap["NumberOfSegments"] = new SMESH_HypothesisCreator<SMESH_NumberOfSegments>;
69 _creatorMap["LengthFromEdges"] = new SMESH_HypothesisCreator<SMESH_LengthFromEdges>;
70 _creatorMap["MaxElementArea"] = new SMESH_HypothesisCreator<SMESH_MaxElementArea>;
71 _creatorMap["Regular_1D"] = new SMESH_HypothesisCreator<SMESH_Regular_1D>;
72 _creatorMap["MEFISTO_2D"] = new SMESH_HypothesisCreator<SMESH_MEFISTO_2D>;
73 _creatorMap["Quadrangle_2D"] = new SMESH_HypothesisCreator<SMESH_Quadrangle_2D>;
74 _creatorMap["Hexa_3D"] = new SMESH_HypothesisCreator<SMESH_Hexa_3D>;
76 //---------------------------------------
79 //=============================================================================
81 * Destructor: deletes specific hypothesis creators instanciated in the
84 //=============================================================================
86 SMESH_HypothesisFactory::~SMESH_HypothesisFactory()
88 map<string, GenericHypothesisCreator*>::iterator it;
89 for (it = _creatorMap.begin(); it != _creatorMap.end(); it++)
96 //=============================================================================
100 //=============================================================================
102 SMESH_Hypothesis* SMESH_HypothesisFactory::Create(const char* anHypName,
104 throw (SALOME_Exception)
106 MESSAGE("SMESH_HypothesisFactory::Create " << anHypName);
107 if (_creatorMap.find(anHypName) == _creatorMap.end())
108 throw(SALOME_Exception(LOCALIZED("bad hypothesis type name")));
109 SMESH_Hypothesis* myHyp = _creatorMap[anHypName]->Create(_hypId++,
115 //=============================================================================
119 //=============================================================================
121 GenericHypothesisCreator*
122 SMESH_HypothesisFactory::GetCreator(const char* anHypName)
123 throw (SALOME_Exception)
125 MESSAGE("SMESH_HypothesisFactory::GetCreator " << anHypName);
126 if (_creatorMap.find(anHypName) == _creatorMap.end())
127 throw(SALOME_Exception(LOCALIZED("bad hypothesis type name")));
128 return _creatorMap[anHypName];
131 //=============================================================================
135 //=============================================================================
137 int SMESH_HypothesisFactory::GetANewId()
139 //MESSAGE("SMESH_HypothesisFactory::GetANewId");
143 //=============================================================================
147 //=============================================================================
149 void SMESH_HypothesisFactory::SetGen(SMESH_Gen* gen)
151 //MESSAGE("SMESH_HypothesisFactory::SetGen");