Salome HOME
Fix bug 12796: Warning missed for the bad file 'test18.med'
[modules/smesh.git] / src / SMESH / SMESH_Gen.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.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //
23 //
24 //  File   : SMESH_Gen.cxx
25 //  Author : Paul RASCLE, EDF
26 //  Module : SMESH
27 //  $Header$
28
29 #include "SMESH_Gen.hxx"
30 #include "SMESH_subMesh.hxx"
31 #include "SMESH_HypoFilter.hxx"
32 #include "SMDS_MeshElement.hxx"
33 #include "SMDS_MeshNode.hxx"
34
35 #include "utilities.h"
36 #include "OpUtil.hxx"
37 #include "Utils_ExceptHandlers.hxx"
38
39 #include <gp_Pnt.hxx>
40 #include <BRep_Tool.hxx>
41 #include <TopTools_ListOfShape.hxx>
42 #include <TopTools_ListIteratorOfListOfShape.hxx>
43
44 using namespace std;
45
46 //=============================================================================
47 /*!
48  *  default constructor:
49  */
50 //=============================================================================
51
52 SMESH_Gen::SMESH_Gen()
53 {
54         MESSAGE("SMESH_Gen::SMESH_Gen");
55         _localId = 0;
56         _hypId = 0;
57 }
58
59 //=============================================================================
60 /*!
61  *
62  */
63 //=============================================================================
64
65 SMESH_Gen::~SMESH_Gen()
66 {
67         MESSAGE("SMESH_Gen::~SMESH_Gen");
68 }
69
70 //=============================================================================
71 /*!
72  *
73  */
74 //=============================================================================
75
76 /*SMESH_Hypothesis *SMESH_Gen::CreateHypothesis(const char *anHyp, int studyId)
77         throw(SALOME_Exception)
78 {
79
80         MESSAGE("CreateHypothesis("<<anHyp<<","<<studyId<<")");
81         // Get studyContext, create it if it does'nt exist, with a SMESHDS_Document
82
83         StudyContextStruct *myStudyContext = GetStudyContext(studyId);
84
85         // create a new hypothesis object, store its ref. in studyContext
86
87         SMESH_Hypothesis *myHypothesis = _hypothesisFactory.Create(anHyp, studyId);
88         int hypId = myHypothesis->GetID();
89         myStudyContext->mapHypothesis[hypId] = myHypothesis;
90         SCRUTE(studyId);
91         SCRUTE(hypId);
92
93         // store hypothesis in SMESHDS document
94
95         myStudyContext->myDocument->AddHypothesis(myHypothesis);
96         return myHypothesis;
97 }*/
98
99 //=============================================================================
100 /*!
101  *
102  */
103 //=============================================================================
104
105 SMESH_Mesh* SMESH_Gen::CreateMesh(int theStudyId, bool theIsEmbeddedMode)
106   throw(SALOME_Exception)
107 {
108   Unexpect aCatch(SalomeException);
109   MESSAGE("SMESH_Gen::CreateMesh");
110
111   // Get studyContext, create it if it does'nt exist, with a SMESHDS_Document
112   StudyContextStruct *aStudyContext = GetStudyContext(theStudyId);
113
114   // create a new SMESH_mesh object
115   SMESH_Mesh *aMesh = new SMESH_Mesh(_localId++,
116                                      theStudyId,
117                                      this,
118                                      theIsEmbeddedMode,
119                                      aStudyContext->myDocument);
120   aStudyContext->mapMesh[_localId] = aMesh;
121
122   return aMesh;
123 }
124
125 //=============================================================================
126 /*!
127  *
128  */
129 //=============================================================================
130
131 bool SMESH_Gen::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape)
132 {
133   MESSAGE("SMESH_Gen::Compute");
134   //   bool isDone = false;
135   /*
136      Algo : s'appuie ou non sur une geometrie
137      Si geometrie:
138      Vertex : rien à faire (range le point)
139      Edge, Wire, collection d'edge et wire : 1D
140      Face, Shell, collection de Face et Shells : 2D
141      Solid, Collection de Solid : 3D
142      */
143   // *** corriger commentaires
144   // check hypothesis associated to the mesh :
145   // - only one algo : type compatible with the type of the shape
146   // - hypothesis = compatible with algo
147   //    - check if hypothesis are applicable to this algo
148   //    - check contradictions within hypothesis
149   //    (test if enough hypothesis is done further)
150
151   bool ret = true;
152
153 //   if ( !CheckAlgoState( aMesh, aShape ))
154 //   {
155 //     INFOS( "ABORT MESHING: some algos or hypothesis are missing");
156 //     return false;
157 //   }
158
159   SMESH_subMesh *sm = aMesh.GetSubMesh(aShape);
160
161   if ( sm->GetComputeState() == SMESH_subMesh::COMPUTE_OK )
162     return true; // already computed
163
164   // -----------------------------------------------------------------
165   // apply algos that do not require descretized boundaries, starting
166   // from the most complex shapes
167   // -----------------------------------------------------------------
168
169   // map containing all subshapes in the order: vertices, edges, faces...
170   const map<int, SMESH_subMesh*>& smMap = sm->DependsOn();
171   map<int, SMESH_subMesh*>::const_reverse_iterator revItSub = smMap.rbegin();
172
173   SMESH_subMesh* smToCompute = sm;
174   while ( smToCompute )
175   {
176     const TopoDS_Shape& aSubShape = smToCompute->GetSubShape();
177     if ( GetShapeDim( aSubShape ) < 1 ) break;
178
179     SMESH_Algo* algo = GetAlgo( aMesh, aSubShape );
180     if (algo && !algo->NeedDescretBoundary()) {
181       if (smToCompute->GetComputeState() == SMESH_subMesh::READY_TO_COMPUTE) {
182         ret = smToCompute->ComputeStateEngine( SMESH_subMesh::COMPUTE );
183       } else if (smToCompute->GetComputeState() == SMESH_subMesh::FAILED_TO_COMPUTE) {
184         // JFA for PAL6524
185         ret = false;
186       } else {
187       }
188     }
189     if (!ret)
190       return false;
191
192     // next subMesh
193     if (revItSub != smMap.rend())
194     {
195       smToCompute = (*revItSub).second;
196       revItSub++;
197     }
198     else
199       smToCompute = 0;
200   }
201
202   // -----------------------------------------------
203   // mesh the rest subshapes starting from vertices
204   // -----------------------------------------------
205
206   int i, nbSub = smMap.size();
207   map<int, SMESH_subMesh*>::const_iterator itSub = smMap.begin();
208   for ( i = 0; i <= nbSub; ++i ) // loop on the whole map plus <sm>
209   {
210     if ( itSub == smMap.end() )
211       smToCompute = sm;
212     else
213       smToCompute = (itSub++)->second;
214     if (smToCompute->GetComputeState() != SMESH_subMesh::READY_TO_COMPUTE) {
215       if (smToCompute->GetComputeState() == SMESH_subMesh::FAILED_TO_COMPUTE)
216         ret = false;
217       continue;
218     }
219     TopoDS_Shape subShape = smToCompute->GetSubShape();
220     if ( subShape.ShapeType() != TopAbs_VERTEX )
221     {
222       if ( !smToCompute->ComputeStateEngine(SMESH_subMesh::COMPUTE) )
223         ret = false;
224     }
225     else
226     {
227       TopoDS_Vertex V1 = TopoDS::Vertex(subShape);
228       gp_Pnt P1 = BRep_Tool::Pnt(V1);
229       SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
230       SMDS_MeshNode * node = meshDS->AddNode(P1.X(), P1.Y(), P1.Z());
231       if ( node ) {  // san - increase robustness
232         meshDS->SetNodeOnVertex(node, V1);
233         smToCompute->ComputeStateEngine(SMESH_subMesh::COMPUTE);
234       }
235     }
236   }
237
238   MESSAGE( "VSR - SMESH_Gen::Compute() finished, OK = " << ret);
239   return ret;
240 }
241
242
243 //=======================================================================
244 //function : checkConformIgnoredAlgos
245 //purpose  :
246 //=======================================================================
247
248 static bool checkConformIgnoredAlgos(SMESH_Mesh&               aMesh,
249                                      SMESH_subMesh*            aSubMesh,
250                                      const SMESH_Algo*         aGlobIgnoAlgo,
251                                      const SMESH_Algo*         aLocIgnoAlgo,
252                                      bool &                    checkConform,
253                                      map<int, SMESH_subMesh*>& aCheckedMap,
254                                      list< SMESH_Gen::TAlgoStateError > & theErrors)
255 {
256   ASSERT( aSubMesh );
257   if ( aSubMesh->GetSubShape().ShapeType() == TopAbs_VERTEX)
258     return true;
259
260
261   bool ret = true;
262
263   const list<const SMESHDS_Hypothesis*>& listHyp =
264     aMesh.GetMeshDS()->GetHypothesis( aSubMesh->GetSubShape() );
265   list<const SMESHDS_Hypothesis*>::const_iterator it=listHyp.begin();
266   for ( ; it != listHyp.end(); it++)
267   {
268     const SMESHDS_Hypothesis * aHyp = *it;
269     if (aHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO)
270       continue;
271
272     const SMESH_Algo* algo = dynamic_cast<const SMESH_Algo*> (aHyp);
273     ASSERT ( algo );
274
275     if ( aLocIgnoAlgo ) // algo is hidden by a local algo of upper dim
276     {
277       INFOS( "Local <" << algo->GetName() << "> is hidden by local <"
278             << aLocIgnoAlgo->GetName() << ">");
279     }
280     else
281     {
282       bool isGlobal = (aMesh.IsMainShape( aSubMesh->GetSubShape() ));
283       int dim = algo->GetDim();
284       int aMaxGlobIgnoDim = ( aGlobIgnoAlgo ? aGlobIgnoAlgo->GetDim() : -1 );
285
286       if ( dim < aMaxGlobIgnoDim )
287       {
288         // algo is hidden by a global algo
289         INFOS( ( isGlobal ? "Global" : "Local" )
290               << " <" << algo->GetName() << "> is hidden by global <"
291               << aGlobIgnoAlgo->GetName() << ">");
292       }
293       else if ( !algo->NeedDescretBoundary() && !isGlobal)
294       {
295         // local algo is not hidden and hides algos on sub-shapes
296         if (checkConform && !aSubMesh->IsConform( algo ))
297         {
298           ret = false;
299           checkConform = false; // no more check conformity
300           INFOS( "ERROR: Local <" << algo->GetName() <<
301                 "> would produce not conform mesh: "
302                 "<Not Conform Mesh Allowed> hypotesis is missing");
303           theErrors.push_back( SMESH_Gen::TAlgoStateError() );
304           theErrors.back().Set( SMESH_Gen::NOT_CONFORM_MESH, algo, false );
305         }
306
307         // sub-algos will be hidden by a local <algo>
308         const map<int, SMESH_subMesh*>& smMap = aSubMesh->DependsOn();
309         map<int, SMESH_subMesh*>::const_reverse_iterator revItSub;
310         bool checkConform2 = false;
311         for ( revItSub = smMap.rbegin(); revItSub != smMap.rend(); revItSub++)
312         {
313           checkConformIgnoredAlgos (aMesh, (*revItSub).second, aGlobIgnoAlgo,
314                                     algo, checkConform2, aCheckedMap, theErrors);
315           int key = (*revItSub).first;
316           SMESH_subMesh* sm = (*revItSub).second;
317           if ( aCheckedMap.find( key ) == aCheckedMap.end() )
318           {
319             aCheckedMap[ key ] = sm;
320           }
321         }
322       }
323     }
324   }
325
326   return ret;
327 }
328
329 //=======================================================================
330 //function : checkMissing
331 //purpose  : notify on missing hypothesis
332 //           Return false if algo or hipothesis is missing
333 //=======================================================================
334
335 static bool checkMissing(SMESH_Gen*                aGen,
336                          SMESH_Mesh&               aMesh,
337                          SMESH_subMesh*            aSubMesh,
338                          const int                 aTopAlgoDim,
339                          bool*                     globalChecked,
340                          const bool                checkNoAlgo,
341                          map<int, SMESH_subMesh*>& aCheckedMap,
342                          list< SMESH_Gen::TAlgoStateError > & theErrors)
343 {
344   if ( aSubMesh->GetSubShape().ShapeType() == TopAbs_VERTEX)
345     return true;
346
347   //MESSAGE("=====checkMissing");
348
349   int ret = true;
350   SMESH_Algo* algo = 0;
351
352   switch (aSubMesh->GetAlgoState())
353   {
354   case SMESH_subMesh::NO_ALGO: {
355     if (checkNoAlgo)
356     {
357       // should there be any algo?
358       int shapeDim = SMESH_Gen::GetShapeDim( aSubMesh->GetSubShape() );
359       if (aTopAlgoDim > shapeDim)
360       {
361         INFOS( "ERROR: " << shapeDim << "D algorithm is missing" );
362         ret = false;
363         theErrors.push_back( SMESH_Gen::TAlgoStateError() );
364         theErrors.back().Set( SMESH_Gen::MISSING_ALGO, shapeDim, true );
365       }
366     }
367     return ret;
368   }
369   case SMESH_subMesh::MISSING_HYP: {
370     // notify if an algo missing hyp is attached to aSubMesh
371     algo = aGen->GetAlgo( aMesh, aSubMesh->GetSubShape() );
372     ASSERT( algo );
373     bool IsGlobalHypothesis = aGen->IsGlobalHypothesis( algo, aMesh );
374     if (!IsGlobalHypothesis || !globalChecked[ algo->GetDim() ])
375     {
376       INFOS( "ERROR: " << (IsGlobalHypothesis ? "Global " : "Local ")
377             << "<" << algo->GetName() << "> misses some hypothesis");
378       if (IsGlobalHypothesis)
379         globalChecked[ algo->GetDim() ] = true;
380       theErrors.push_back( SMESH_Gen::TAlgoStateError() );
381       theErrors.back().Set( SMESH_Gen::MISSING_HYPO, algo, IsGlobalHypothesis );
382     }
383     ret = false;
384     break;
385   }
386   case SMESH_subMesh::HYP_OK:
387     algo = aGen->GetAlgo( aMesh, aSubMesh->GetSubShape() );
388     ret = true;
389     break;
390   default: ASSERT(0);
391   }
392
393   // do not check under algo that hides sub-algos or
394   // re-start checking NO_ALGO state
395   ASSERT (algo);
396   bool isTopLocalAlgo =
397     ( aTopAlgoDim <= algo->GetDim() && !aGen->IsGlobalHypothesis( algo, aMesh ));
398   if (!algo->NeedDescretBoundary() || isTopLocalAlgo)
399   {
400     bool checkNoAlgo2 = ( algo->NeedDescretBoundary() );
401     const map<int, SMESH_subMesh*>& subMeshes = aSubMesh->DependsOn();
402     map<int, SMESH_subMesh*>::const_iterator itsub;
403     for (itsub = subMeshes.begin(); itsub != subMeshes.end(); itsub++)
404     {
405       // sub-meshes should not be checked further more
406       int key = (*itsub).first;
407       SMESH_subMesh* sm = (*itsub).second;
408       if ( aCheckedMap.find( key ) == aCheckedMap.end() )
409         aCheckedMap[ key ] = sm;
410
411       if (isTopLocalAlgo)
412       {
413         //check algo on sub-meshes
414         int aTopAlgoDim2 = algo->GetDim();
415         if (!checkMissing (aGen, aMesh, sm, aTopAlgoDim2,
416                            globalChecked, checkNoAlgo2, aCheckedMap, theErrors))
417         {
418           ret = false;
419           if (sm->GetAlgoState() == SMESH_subMesh::NO_ALGO )
420             checkNoAlgo2 = false;
421         }
422       }
423     }
424   }
425   return ret;
426 }
427
428 //=======================================================================
429 //function : CheckAlgoState
430 //purpose  : notify on bad state of attached algos, return false
431 //           if Compute() would fail because of some algo bad state
432 //=======================================================================
433
434 bool SMESH_Gen::CheckAlgoState(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape)
435 {
436   list< TAlgoStateError > errors;
437   return GetAlgoState( aMesh, aShape, errors );
438 }
439
440 //=======================================================================
441 //function : GetAlgoState
442 //purpose  : notify on bad state of attached algos, return false
443 //           if Compute() would fail because of some algo bad state
444 //           theErrors list contains problems description
445 //=======================================================================
446
447 bool SMESH_Gen::GetAlgoState(SMESH_Mesh&               theMesh,
448                              const TopoDS_Shape&       theShape,
449                              list< TAlgoStateError > & theErrors)
450 {
451   //MESSAGE("SMESH_Gen::CheckAlgoState");
452
453   bool ret = true;
454   bool hasAlgo = false;
455
456   SMESH_subMesh* sm = theMesh.GetSubMesh(theShape);
457   const SMESHDS_Mesh* meshDS = theMesh.GetMeshDS();
458   TopoDS_Shape mainShape = meshDS->ShapeToMesh();
459
460   // -----------------
461   // get global algos
462   // -----------------
463
464   const SMESH_Algo* aGlobAlgoArr[] = {0,0,0,0};
465
466   const list<const SMESHDS_Hypothesis*>& listHyp = meshDS->GetHypothesis( mainShape );
467   list<const SMESHDS_Hypothesis*>::const_iterator it=listHyp.begin();
468   for ( ; it != listHyp.end(); it++)
469   {
470     const SMESHDS_Hypothesis * aHyp = *it;
471     if (aHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO)
472       continue;
473
474     const SMESH_Algo* algo = dynamic_cast<const SMESH_Algo*> (aHyp);
475     ASSERT ( algo );
476
477     int dim = algo->GetDim();
478     aGlobAlgoArr[ dim ] = algo;
479
480     hasAlgo = true;
481   }
482
483   // --------------------------------------------------------
484   // info on algos that will be ignored because of ones that
485   // don't NeedDescretBoundary() attached to super-shapes,
486   // check that a conform mesh will be produced
487   // --------------------------------------------------------
488
489
490   // find a global algo possibly hidding sub-algos
491   int dim;
492   const SMESH_Algo* aGlobIgnoAlgo = 0;
493   for (dim = 3; dim > 0; dim--)
494   {
495     if (aGlobAlgoArr[ dim ] &&
496         !aGlobAlgoArr[ dim ]->NeedDescretBoundary())
497     {
498       aGlobIgnoAlgo = aGlobAlgoArr[ dim ];
499       break;
500     }
501   }
502
503   const map<int, SMESH_subMesh*>& smMap = sm->DependsOn();
504   map<int, SMESH_subMesh*>::const_reverse_iterator revItSub = smMap.rbegin();
505   map<int, SMESH_subMesh*> aCheckedMap;
506   bool checkConform = ( !theMesh.IsNotConformAllowed() );
507   int aKey = 1;
508   SMESH_subMesh* smToCheck = sm;
509
510   // loop on theShape and its sub-shapes
511   while ( smToCheck )
512   {
513     if ( smToCheck->GetSubShape().ShapeType() == TopAbs_VERTEX)
514       break;
515
516     if ( aCheckedMap.find( aKey ) == aCheckedMap.end() )
517       if (!checkConformIgnoredAlgos (theMesh, smToCheck, aGlobIgnoAlgo,
518                                      0, checkConform, aCheckedMap, theErrors))
519         ret = false;
520
521     if ( smToCheck->GetAlgoState() != SMESH_subMesh::NO_ALGO )
522       hasAlgo = true;
523
524     // next subMesh
525     if (revItSub != smMap.rend())
526     {
527       aKey = (*revItSub).first;
528       smToCheck = (*revItSub).second;
529       revItSub++;
530     }
531     else
532     {
533       smToCheck = 0;
534     }
535
536   }
537
538   // ----------------------------------------------------------------
539   // info on missing hypothesis and find out if all needed algos are
540   // well defined
541   // ----------------------------------------------------------------
542
543   //MESSAGE( "---info on missing hypothesis and find out if all needed algos are");
544
545   // find max dim of global algo
546   int aTopAlgoDim = 0;
547   for (dim = 3; dim > 0; dim--)
548   {
549     if (aGlobAlgoArr[ dim ])
550     {
551       aTopAlgoDim = dim;
552       break;
553     }
554   }
555   aCheckedMap.clear();
556   smToCheck = sm;
557   revItSub = smMap.rbegin();
558   bool checkNoAlgo = (bool) aTopAlgoDim;
559   bool globalChecked[] = { false, false, false, false };
560
561   // loop on theShape and its sub-shapes
562   while ( smToCheck )
563   {
564     if ( smToCheck->GetSubShape().ShapeType() == TopAbs_VERTEX)
565       break;
566
567     if ( aCheckedMap.find( aKey ) == aCheckedMap.end() )
568       if (!checkMissing (this, theMesh, smToCheck, aTopAlgoDim,
569                          globalChecked, checkNoAlgo, aCheckedMap, theErrors))
570       {
571         ret = false;
572         if (smToCheck->GetAlgoState() == SMESH_subMesh::NO_ALGO )
573           checkNoAlgo = false;
574       }
575
576     // next subMesh
577     if (revItSub != smMap.rend())
578     {
579       aKey = (*revItSub).first;
580       smToCheck = (*revItSub).second;
581       revItSub++;
582     }
583     else
584       smToCheck = 0;
585   }
586
587   if ( !hasAlgo ) {
588     ret = false;
589     INFOS( "None algorithm attached" );
590     theErrors.push_back( TAlgoStateError() );
591     theErrors.back().Set( MISSING_ALGO, 1, true );
592   }
593
594   return ret;
595 }
596
597 //=======================================================================
598 //function : IsGlobalHypothesis
599 //purpose  : check if theAlgo is attached to the main shape
600 //=======================================================================
601
602 bool SMESH_Gen::IsGlobalHypothesis(const SMESH_Hypothesis* theHyp, SMESH_Mesh& aMesh)
603 {
604   SMESH_HypoFilter filter( SMESH_HypoFilter::Is( theHyp ));
605   return aMesh.GetHypothesis( aMesh.GetMeshDS()->ShapeToMesh(), filter, false );
606 }
607
608 //=============================================================================
609 /*!
610  *
611  */
612 //=============================================================================
613
614 SMESH_Algo *SMESH_Gen::GetAlgo(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape)
615 {
616 //  MESSAGE("SMESH_Gen::GetAlgo");
617
618   SMESH_HypoFilter filter( SMESH_HypoFilter::IsAlgo() );
619   filter.And( filter.IsApplicableTo( aShape ));
620
621   list <const SMESHDS_Hypothesis * > algoList;
622   aMesh.GetHypotheses( aShape, filter, algoList, true );
623
624   if ( algoList.empty() )
625     return NULL;
626
627   // Now it is checked in SMESH_Mesh::GetHypotheses()
628 //   if (algoList.size() > 1 ) { // check if there is one algo several times
629 //     list <const SMESHDS_Hypothesis * >::iterator algo = algoList.begin();
630 //     for ( ; algo != algoList.end(); ++algo )
631 //       if ( (*algo) != algoList.front() &&
632 //            (*algo)->GetName() != algoList.front()->GetName() )
633 //         return NULL;
634 //   }
635
636   return const_cast<SMESH_Algo*> ( static_cast<const SMESH_Algo* >( algoList.front() ));
637 }
638
639 //=============================================================================
640 /*!
641  *
642  */
643 //=============================================================================
644
645 StudyContextStruct *SMESH_Gen::GetStudyContext(int studyId)
646 {
647         // Get studyContext, create it if it does'nt exist, with a SMESHDS_Document
648
649         if (_mapStudyContext.find(studyId) == _mapStudyContext.end())
650         {
651                 _mapStudyContext[studyId] = new StudyContextStruct;
652                 _mapStudyContext[studyId]->myDocument = new SMESHDS_Document(studyId);
653         }
654         StudyContextStruct *myStudyContext = _mapStudyContext[studyId];
655 //   ASSERT(_mapStudyContext.find(studyId) != _mapStudyContext.end());
656         return myStudyContext;
657 }
658
659 //=============================================================================
660 /*!
661  *
662  */
663 //=============================================================================
664
665 void SMESH_Gen::Save(int studyId, const char *aUrlOfFile)
666 {
667 }
668
669 //=============================================================================
670 /*!
671  *
672  */
673 //=============================================================================
674
675 void SMESH_Gen::Load(int studyId, const char *aUrlOfFile)
676 {
677 }
678
679 //=============================================================================
680 /*!
681  *
682  */
683 //=============================================================================
684
685 void SMESH_Gen::Close(int studyId)
686 {
687 }
688
689 //=============================================================================
690 /*!
691  *
692  */
693 //=============================================================================
694
695 int SMESH_Gen::GetShapeDim(const TopAbs_ShapeEnum & aShapeType)
696 {
697   static vector<int> dim;
698   if ( dim.empty() )
699   {
700     dim.resize( TopAbs_SHAPE, -1 );
701     dim[ TopAbs_COMPOUND ]  = 3;
702     dim[ TopAbs_COMPSOLID ] = 3;
703     dim[ TopAbs_SOLID ]     = 3;
704     dim[ TopAbs_SHELL ]     = 3;
705     dim[ TopAbs_FACE  ]     = 2;
706     dim[ TopAbs_WIRE ]      = 1;
707     dim[ TopAbs_EDGE ]      = 1;
708     dim[ TopAbs_VERTEX ]    = 0;
709   }
710   return dim[ aShapeType ];
711 }
712
713 //=============================================================================
714 /*!
715  *
716  */
717 //=============================================================================
718
719 int SMESH_Gen::GetANewId()
720 {
721         //MESSAGE("SMESH_Gen::GetANewId");
722         return _hypId++;
723 }