1 // Copyright (C) 2007-2010 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.
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 : implementaion of SMESH idl descriptions
24 // File : SMESH_Gen.cxx
25 // Author : Paul RASCLE, EDF
28 #include "SMESH_Gen.hxx"
29 #include "SMESH_subMesh.hxx"
30 #include "SMESH_HypoFilter.hxx"
31 #include "SMESHDS_Document.hxx"
32 #include "SMDS_MeshElement.hxx"
33 #include "SMDS_MeshNode.hxx"
35 #include "utilities.h"
37 #include "Utils_ExceptHandlers.hxx"
40 #include <BRep_Tool.hxx>
41 #include <TopTools_ListOfShape.hxx>
42 #include <TopTools_ListIteratorOfListOfShape.hxx>
46 //=============================================================================
50 //=============================================================================
52 SMESH_Gen::SMESH_Gen()
54 MESSAGE("SMESH_Gen::SMESH_Gen");
57 _segmentation = _nbSegments = 10;
60 //=============================================================================
64 //=============================================================================
66 SMESH_Gen::~SMESH_Gen()
68 MESSAGE("SMESH_Gen::~SMESH_Gen");
71 //=============================================================================
73 * Creates a mesh in a study.
74 * if (theIsEmbeddedMode) { mesh modification commands are not logged }
76 //=============================================================================
78 SMESH_Mesh* SMESH_Gen::CreateMesh(int theStudyId, bool theIsEmbeddedMode)
79 throw(SALOME_Exception)
81 Unexpect aCatch(SalomeException);
82 MESSAGE("SMESH_Gen::CreateMesh");
84 // Get studyContext, create it if it does'nt exist, with a SMESHDS_Document
85 StudyContextStruct *aStudyContext = GetStudyContext(theStudyId);
87 // create a new SMESH_mesh object
88 SMESH_Mesh *aMesh = new SMESH_Mesh(_localId++,
92 aStudyContext->myDocument);
93 aStudyContext->mapMesh[_localId] = aMesh;
98 //=============================================================================
102 //=============================================================================
104 bool SMESH_Gen::Compute(SMESH_Mesh & aMesh,
105 const TopoDS_Shape & aShape,
107 const ::MeshDimension aDim,
108 TSetOfInt* aShapesId)
110 MESSAGE("SMESH_Gen::Compute");
114 SMESH_subMesh *sm = aMesh.GetSubMesh(aShape);
116 const bool includeSelf = true;
117 const bool complexShapeFirst = true;
119 SMESH_subMeshIteratorPtr smIt;
121 if ( anUpward ) // is called from below code here
123 // -----------------------------------------------
124 // mesh all the subshapes starting from vertices
125 // -----------------------------------------------
126 smIt = sm->getDependsOnIterator(includeSelf, !complexShapeFirst);
127 while ( smIt->more() )
129 SMESH_subMesh* smToCompute = smIt->next();
131 // do not mesh vertices of a pseudo shape
132 const TopAbs_ShapeEnum aShType = smToCompute->GetSubShape().ShapeType();
133 if ( !aMesh.HasShapeToMesh() && aShType == TopAbs_VERTEX )
136 // check for preview dimension limitations
137 if ( aShapesId && GetShapeDim( aShType ) > (int)aDim )
139 // clear compute state to not show previous compute errors
140 // if preview invoked less dimension less than previous
141 smToCompute->ComputeStateEngine( SMESH_subMesh::CHECK_COMPUTE_STATE );
145 if (smToCompute->GetComputeState() == SMESH_subMesh::READY_TO_COMPUTE)
146 smToCompute->ComputeStateEngine( SMESH_subMesh::COMPUTE );
148 // we check all the submeshes here and detect if any of them failed to compute
149 if (smToCompute->GetComputeState() == SMESH_subMesh::FAILED_TO_COMPUTE)
151 else if ( aShapesId )
152 aShapesId->insert( smToCompute->GetId() );
158 // -----------------------------------------------------------------
159 // apply algos that DO NOT require descretized boundaries and DO NOT
160 // support submeshes, starting from the most complex shapes
161 // and collect submeshes with algos that DO support submeshes
162 // -----------------------------------------------------------------
163 list< SMESH_subMesh* > smWithAlgoSupportingSubmeshes;
164 smIt = sm->getDependsOnIterator(includeSelf, complexShapeFirst);
165 while ( smIt->more() )
167 SMESH_subMesh* smToCompute = smIt->next();
168 if ( smToCompute->GetComputeState() != SMESH_subMesh::READY_TO_COMPUTE )
171 const TopoDS_Shape& aSubShape = smToCompute->GetSubShape();
172 const int aShapeDim = GetShapeDim( aSubShape );
173 if ( aShapeDim < 1 ) break;
175 // check for preview dimension limitations
176 if ( aShapesId && aShapeDim > (int)aDim )
179 SMESH_Algo* algo = GetAlgo( aMesh, aSubShape );
180 if ( algo && !algo->NeedDescretBoundary() )
182 if ( algo->SupportSubmeshes() )
183 smWithAlgoSupportingSubmeshes.push_front( smToCompute );
186 smToCompute->ComputeStateEngine( SMESH_subMesh::COMPUTE );
188 aShapesId->insert( smToCompute->GetId() );
193 // ------------------------------------------------------------
194 // sort list of submeshes according to mesh order
195 // ------------------------------------------------------------
196 aMesh.SortByMeshOrder( smWithAlgoSupportingSubmeshes );
198 // ------------------------------------------------------------
199 // compute submeshes under shapes with algos that DO NOT require
200 // descretized boundaries and DO support submeshes
201 // ------------------------------------------------------------
202 list< SMESH_subMesh* >::iterator subIt, subEnd;
203 subIt = smWithAlgoSupportingSubmeshes.begin();
204 subEnd = smWithAlgoSupportingSubmeshes.end();
205 // start from lower shapes
206 for ( ; subIt != subEnd; ++subIt )
210 // get a shape the algo is assigned to
211 TopoDS_Shape algoShape;
212 if ( !GetAlgo( aMesh, sm->GetSubShape(), & algoShape ))
213 continue; // strange...
215 // look for more local algos
216 smIt = sm->getDependsOnIterator(!includeSelf, !complexShapeFirst);
217 while ( smIt->more() )
219 SMESH_subMesh* smToCompute = smIt->next();
221 const TopoDS_Shape& aSubShape = smToCompute->GetSubShape();
222 const int aShapeDim = GetShapeDim( aSubShape );
223 //if ( aSubShape.ShapeType() == TopAbs_VERTEX ) continue;
224 if ( aShapeDim < 1 ) continue;
226 // check for preview dimension limitations
227 if ( aShapesId && GetShapeDim( aSubShape.ShapeType() ) > (int)aDim )
230 SMESH_HypoFilter filter( SMESH_HypoFilter::IsAlgo() );
232 .And( SMESH_HypoFilter::IsApplicableTo( aSubShape ))
233 .And( SMESH_HypoFilter::IsMoreLocalThan( algoShape ));
235 if ( SMESH_Algo* subAlgo = (SMESH_Algo*) aMesh.GetHypothesis( aSubShape, filter, true )) {
236 SMESH_Hypothesis::Hypothesis_Status status;
237 if ( subAlgo->CheckHypothesis( aMesh, aSubShape, status ))
238 // mesh a lower smToCompute starting from vertices
239 Compute( aMesh, aSubShape, /*anUpward=*/true, aDim, aShapesId );
243 // ----------------------------------------------------------
244 // apply the algos that do not require descretized boundaries
245 // ----------------------------------------------------------
246 for ( subIt = smWithAlgoSupportingSubmeshes.begin(); subIt != subEnd; ++subIt )
249 if ( sm->GetComputeState() == SMESH_subMesh::READY_TO_COMPUTE)
251 const TopAbs_ShapeEnum aShType = sm->GetSubShape().ShapeType();
252 // check for preview dimension limitations
253 if ( aShapesId && GetShapeDim( aShType ) > (int)aDim )
256 sm->ComputeStateEngine( SMESH_subMesh::COMPUTE );
258 aShapesId->insert( sm->GetId() );
261 // -----------------------------------------------
262 // mesh the rest subshapes starting from vertices
263 // -----------------------------------------------
264 ret = Compute( aMesh, aShape, /*anUpward=*/true, aDim, aShapesId );
267 MESSAGE( "VSR - SMESH_Gen::Compute() finished, OK = " << ret);
272 //=============================================================================
276 //=============================================================================
278 bool SMESH_Gen::Evaluate(SMESH_Mesh & aMesh,
279 const TopoDS_Shape & aShape,
280 MapShapeNbElems& aResMap,
282 TSetOfInt* aShapesId)
284 MESSAGE("SMESH_Gen::Evaluate");
288 SMESH_subMesh *sm = aMesh.GetSubMesh(aShape);
290 const bool includeSelf = true;
291 const bool complexShapeFirst = true;
292 SMESH_subMeshIteratorPtr smIt;
294 if ( anUpward ) { // is called from below code here
295 // -----------------------------------------------
296 // mesh all the subshapes starting from vertices
297 // -----------------------------------------------
298 smIt = sm->getDependsOnIterator(includeSelf, !complexShapeFirst);
299 while ( smIt->more() ) {
300 SMESH_subMesh* smToCompute = smIt->next();
302 // do not mesh vertices of a pseudo shape
303 const TopAbs_ShapeEnum aShType = smToCompute->GetSubShape().ShapeType();
304 //if ( !aMesh.HasShapeToMesh() && aShType == TopAbs_VERTEX )
306 if ( !aMesh.HasShapeToMesh() ) {
307 if( aShType == TopAbs_VERTEX || aShType == TopAbs_WIRE ||
308 aShType == TopAbs_SHELL )
312 smToCompute->Evaluate(aResMap);
314 aShapesId->insert( smToCompute->GetId() );
319 // -----------------------------------------------------------------
320 // apply algos that DO NOT require descretized boundaries and DO NOT
321 // support submeshes, starting from the most complex shapes
322 // and collect submeshes with algos that DO support submeshes
323 // -----------------------------------------------------------------
324 list< SMESH_subMesh* > smWithAlgoSupportingSubmeshes;
325 smIt = sm->getDependsOnIterator(includeSelf, complexShapeFirst);
326 while ( smIt->more() ) {
327 SMESH_subMesh* smToCompute = smIt->next();
328 const TopoDS_Shape& aSubShape = smToCompute->GetSubShape();
329 const int aShapeDim = GetShapeDim( aSubShape );
330 if ( aShapeDim < 1 ) break;
332 SMESH_Algo* algo = GetAlgo( aMesh, aSubShape );
333 if ( algo && !algo->NeedDescretBoundary() ) {
334 if ( algo->SupportSubmeshes() ) {
335 smWithAlgoSupportingSubmeshes.push_front( smToCompute );
338 smToCompute->Evaluate(aResMap);
340 aShapesId->insert( smToCompute->GetId() );
345 // ------------------------------------------------------------
346 // sort list of meshes according to mesh order
347 // ------------------------------------------------------------
348 aMesh.SortByMeshOrder( smWithAlgoSupportingSubmeshes );
350 // ------------------------------------------------------------
351 // compute submeshes under shapes with algos that DO NOT require
352 // descretized boundaries and DO support submeshes
353 // ------------------------------------------------------------
354 list< SMESH_subMesh* >::iterator subIt, subEnd;
355 subIt = smWithAlgoSupportingSubmeshes.begin();
356 subEnd = smWithAlgoSupportingSubmeshes.end();
357 // start from lower shapes
358 for ( ; subIt != subEnd; ++subIt ) {
361 // get a shape the algo is assigned to
362 TopoDS_Shape algoShape;
363 if ( !GetAlgo( aMesh, sm->GetSubShape(), & algoShape ))
364 continue; // strange...
366 // look for more local algos
367 smIt = sm->getDependsOnIterator(!includeSelf, !complexShapeFirst);
368 while ( smIt->more() ) {
369 SMESH_subMesh* smToCompute = smIt->next();
371 const TopoDS_Shape& aSubShape = smToCompute->GetSubShape();
372 const int aShapeDim = GetShapeDim( aSubShape );
373 if ( aShapeDim < 1 ) continue;
375 //const TopAbs_ShapeEnum aShType = smToCompute->GetSubShape().ShapeType();
377 SMESH_HypoFilter filter( SMESH_HypoFilter::IsAlgo() );
379 .And( SMESH_HypoFilter::IsApplicableTo( aSubShape ))
380 .And( SMESH_HypoFilter::IsMoreLocalThan( algoShape ));
382 if ( SMESH_Algo* subAlgo = (SMESH_Algo*) aMesh.GetHypothesis( aSubShape, filter, true )) {
383 SMESH_Hypothesis::Hypothesis_Status status;
384 if ( subAlgo->CheckHypothesis( aMesh, aSubShape, status ))
385 // mesh a lower smToCompute starting from vertices
386 Evaluate( aMesh, aSubShape, aResMap, /*anUpward=*/true, aShapesId );
390 // ----------------------------------------------------------
391 // apply the algos that do not require descretized boundaries
392 // ----------------------------------------------------------
393 for ( subIt = smWithAlgoSupportingSubmeshes.begin(); subIt != subEnd; ++subIt )
396 sm->Evaluate(aResMap);
398 aShapesId->insert( sm->GetId() );
401 // -----------------------------------------------
402 // mesh the rest subshapes starting from vertices
403 // -----------------------------------------------
404 ret = Evaluate( aMesh, aShape, aResMap, /*anUpward=*/true, aShapesId );
407 MESSAGE( "VSR - SMESH_Gen::Evaluate() finished, OK = " << ret);
412 //=======================================================================
413 //function : checkConformIgnoredAlgos
415 //=======================================================================
417 static bool checkConformIgnoredAlgos(SMESH_Mesh& aMesh,
418 SMESH_subMesh* aSubMesh,
419 const SMESH_Algo* aGlobIgnoAlgo,
420 const SMESH_Algo* aLocIgnoAlgo,
422 set<SMESH_subMesh*>& aCheckedMap,
423 list< SMESH_Gen::TAlgoStateError > & theErrors)
426 if ( aSubMesh->GetSubShape().ShapeType() == TopAbs_VERTEX)
432 const list<const SMESHDS_Hypothesis*>& listHyp =
433 aMesh.GetMeshDS()->GetHypothesis( aSubMesh->GetSubShape() );
434 list<const SMESHDS_Hypothesis*>::const_iterator it=listHyp.begin();
435 for ( ; it != listHyp.end(); it++)
437 const SMESHDS_Hypothesis * aHyp = *it;
438 if (aHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO)
441 const SMESH_Algo* algo = dynamic_cast<const SMESH_Algo*> (aHyp);
444 if ( aLocIgnoAlgo ) // algo is hidden by a local algo of upper dim
446 INFOS( "Local <" << algo->GetName() << "> is hidden by local <"
447 << aLocIgnoAlgo->GetName() << ">");
451 bool isGlobal = (aMesh.IsMainShape( aSubMesh->GetSubShape() ));
452 int dim = algo->GetDim();
453 int aMaxGlobIgnoDim = ( aGlobIgnoAlgo ? aGlobIgnoAlgo->GetDim() : -1 );
455 if ( dim < aMaxGlobIgnoDim )
457 // algo is hidden by a global algo
458 INFOS( ( isGlobal ? "Global" : "Local" )
459 << " <" << algo->GetName() << "> is hidden by global <"
460 << aGlobIgnoAlgo->GetName() << ">");
462 else if ( !algo->NeedDescretBoundary() && !isGlobal)
464 // local algo is not hidden and hides algos on sub-shapes
465 if (checkConform && !aSubMesh->IsConform( algo ))
468 checkConform = false; // no more check conformity
469 INFOS( "ERROR: Local <" << algo->GetName() <<
470 "> would produce not conform mesh: "
471 "<Not Conform Mesh Allowed> hypotesis is missing");
472 theErrors.push_back( SMESH_Gen::TAlgoStateError() );
473 theErrors.back().Set( SMESH_Hypothesis::HYP_NOTCONFORM, algo, false );
476 // sub-algos will be hidden by a local <algo>
477 SMESH_subMeshIteratorPtr revItSub =
478 aSubMesh->getDependsOnIterator( /*includeSelf=*/false, /*complexShapeFirst=*/true);
479 bool checkConform2 = false;
480 while ( revItSub->more() )
482 SMESH_subMesh* sm = revItSub->next();
483 checkConformIgnoredAlgos (aMesh, sm, aGlobIgnoAlgo,
484 algo, checkConform2, aCheckedMap, theErrors);
485 aCheckedMap.insert( sm );
494 //=======================================================================
495 //function : checkMissing
496 //purpose : notify on missing hypothesis
497 // Return false if algo or hipothesis is missing
498 //=======================================================================
500 static bool checkMissing(SMESH_Gen* aGen,
502 SMESH_subMesh* aSubMesh,
503 const int aTopAlgoDim,
505 const bool checkNoAlgo,
506 set<SMESH_subMesh*>& aCheckedMap,
507 list< SMESH_Gen::TAlgoStateError > & theErrors)
509 if ( aSubMesh->GetSubShape().ShapeType() == TopAbs_VERTEX)
512 //MESSAGE("=====checkMissing");
515 SMESH_Algo* algo = 0;
517 switch (aSubMesh->GetAlgoState())
519 case SMESH_subMesh::NO_ALGO: {
522 // should there be any algo?
523 int shapeDim = SMESH_Gen::GetShapeDim( aSubMesh->GetSubShape() );
524 if (aTopAlgoDim > shapeDim)
526 MESSAGE( "ERROR: " << shapeDim << "D algorithm is missing" );
528 theErrors.push_back( SMESH_Gen::TAlgoStateError() );
529 theErrors.back().Set( SMESH_Hypothesis::HYP_MISSING, shapeDim, true );
534 case SMESH_subMesh::MISSING_HYP: {
535 // notify if an algo missing hyp is attached to aSubMesh
536 algo = aGen->GetAlgo( aMesh, aSubMesh->GetSubShape() );
538 bool IsGlobalHypothesis = aGen->IsGlobalHypothesis( algo, aMesh );
539 if (!IsGlobalHypothesis || !globalChecked[ algo->GetDim() ])
541 TAlgoStateErrorName errName = SMESH_Hypothesis::HYP_MISSING;
542 SMESH_Hypothesis::Hypothesis_Status status;
543 algo->CheckHypothesis( aMesh, aSubMesh->GetSubShape(), status );
544 if ( status == SMESH_Hypothesis::HYP_BAD_PARAMETER ) {
545 MESSAGE( "ERROR: hypothesis of " << (IsGlobalHypothesis ? "Global " : "Local ")
546 << "<" << algo->GetName() << "> has a bad parameter value");
548 } else if ( status == SMESH_Hypothesis::HYP_BAD_GEOMETRY ) {
549 MESSAGE( "ERROR: " << (IsGlobalHypothesis ? "Global " : "Local ")
550 << "<" << algo->GetName() << "> assigned to mismatching geometry");
553 MESSAGE( "ERROR: " << (IsGlobalHypothesis ? "Global " : "Local ")
554 << "<" << algo->GetName() << "> misses some hypothesis");
556 if (IsGlobalHypothesis)
557 globalChecked[ algo->GetDim() ] = true;
558 theErrors.push_back( SMESH_Gen::TAlgoStateError() );
559 theErrors.back().Set( errName, algo, IsGlobalHypothesis );
564 case SMESH_subMesh::HYP_OK:
565 algo = aGen->GetAlgo( aMesh, aSubMesh->GetSubShape() );
571 // do not check under algo that hides sub-algos or
572 // re-start checking NO_ALGO state
574 bool isTopLocalAlgo =
575 ( aTopAlgoDim <= algo->GetDim() && !aGen->IsGlobalHypothesis( algo, aMesh ));
576 if (!algo->NeedDescretBoundary() || isTopLocalAlgo)
578 bool checkNoAlgo2 = ( algo->NeedDescretBoundary() );
579 SMESH_subMeshIteratorPtr itsub = aSubMesh->getDependsOnIterator( /*includeSelf=*/false,
580 /*complexShapeFirst=*/false);
581 while ( itsub->more() )
583 // sub-meshes should not be checked further more
584 SMESH_subMesh* sm = itsub->next();
585 aCheckedMap.insert( sm );
589 //check algo on sub-meshes
590 int aTopAlgoDim2 = algo->GetDim();
591 if (!checkMissing (aGen, aMesh, sm, aTopAlgoDim2,
592 globalChecked, checkNoAlgo2, aCheckedMap, theErrors))
595 if (sm->GetAlgoState() == SMESH_subMesh::NO_ALGO )
596 checkNoAlgo2 = false;
604 //=======================================================================
605 //function : CheckAlgoState
606 //purpose : notify on bad state of attached algos, return false
607 // if Compute() would fail because of some algo bad state
608 //=======================================================================
610 bool SMESH_Gen::CheckAlgoState(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape)
612 list< TAlgoStateError > errors;
613 return GetAlgoState( aMesh, aShape, errors );
616 //=======================================================================
617 //function : GetAlgoState
618 //purpose : notify on bad state of attached algos, return false
619 // if Compute() would fail because of some algo bad state
620 // theErrors list contains problems description
621 //=======================================================================
623 bool SMESH_Gen::GetAlgoState(SMESH_Mesh& theMesh,
624 const TopoDS_Shape& theShape,
625 list< TAlgoStateError > & theErrors)
627 //MESSAGE("SMESH_Gen::CheckAlgoState");
630 bool hasAlgo = false;
632 SMESH_subMesh* sm = theMesh.GetSubMesh(theShape);
633 const SMESHDS_Mesh* meshDS = theMesh.GetMeshDS();
634 TopoDS_Shape mainShape = meshDS->ShapeToMesh();
640 const SMESH_Algo* aGlobAlgoArr[] = {0,0,0,0};
642 const list<const SMESHDS_Hypothesis*>& listHyp = meshDS->GetHypothesis( mainShape );
643 list<const SMESHDS_Hypothesis*>::const_iterator it=listHyp.begin();
644 for ( ; it != listHyp.end(); it++)
646 const SMESHDS_Hypothesis * aHyp = *it;
647 if (aHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO)
650 const SMESH_Algo* algo = dynamic_cast<const SMESH_Algo*> (aHyp);
653 int dim = algo->GetDim();
654 aGlobAlgoArr[ dim ] = algo;
659 // --------------------------------------------------------
660 // info on algos that will be ignored because of ones that
661 // don't NeedDescretBoundary() attached to super-shapes,
662 // check that a conform mesh will be produced
663 // --------------------------------------------------------
666 // find a global algo possibly hiding sub-algos
668 const SMESH_Algo* aGlobIgnoAlgo = 0;
669 for (dim = 3; dim > 0; dim--)
671 if (aGlobAlgoArr[ dim ] &&
672 !aGlobAlgoArr[ dim ]->NeedDescretBoundary())
674 aGlobIgnoAlgo = aGlobAlgoArr[ dim ];
679 set<SMESH_subMesh*> aCheckedSubs;
680 bool checkConform = ( !theMesh.IsNotConformAllowed() );
682 // loop on theShape and its sub-shapes
683 SMESH_subMeshIteratorPtr revItSub = sm->getDependsOnIterator( /*includeSelf=*/true,
684 /*complexShapeFirst=*/true);
685 while ( revItSub->more() )
687 SMESH_subMesh* smToCheck = revItSub->next();
688 if ( smToCheck->GetSubShape().ShapeType() == TopAbs_VERTEX)
691 if ( aCheckedSubs.insert( smToCheck ).second ) // not yet checked
692 if (!checkConformIgnoredAlgos (theMesh, smToCheck, aGlobIgnoAlgo,
693 0, checkConform, aCheckedSubs, theErrors))
696 if ( smToCheck->GetAlgoState() != SMESH_subMesh::NO_ALGO )
700 // ----------------------------------------------------------------
701 // info on missing hypothesis and find out if all needed algos are
703 // ----------------------------------------------------------------
705 //MESSAGE( "---info on missing hypothesis and find out if all needed algos are");
707 // find max dim of global algo
709 for (dim = 3; dim > 0; dim--)
711 if (aGlobAlgoArr[ dim ])
717 bool checkNoAlgo = theMesh.HasShapeToMesh() ? bool( aTopAlgoDim ) : false;
718 bool globalChecked[] = { false, false, false, false };
720 // loop on theShape and its sub-shapes
721 aCheckedSubs.clear();
722 revItSub = sm->getDependsOnIterator( /*includeSelf=*/true, /*complexShapeFirst=*/true);
723 while ( revItSub->more() )
725 SMESH_subMesh* smToCheck = revItSub->next();
726 if ( smToCheck->GetSubShape().ShapeType() == TopAbs_VERTEX)
729 if ( aCheckedSubs.insert( smToCheck ).second ) // not yet checked
730 if (!checkMissing (this, theMesh, smToCheck, aTopAlgoDim,
731 globalChecked, checkNoAlgo, aCheckedSubs, theErrors))
734 if (smToCheck->GetAlgoState() == SMESH_subMesh::NO_ALGO )
741 INFOS( "None algorithm attached" );
742 theErrors.push_back( TAlgoStateError() );
743 theErrors.back().Set( SMESH_Hypothesis::HYP_MISSING, 1, true );
749 //=======================================================================
750 //function : IsGlobalHypothesis
751 //purpose : check if theAlgo is attached to the main shape
752 //=======================================================================
754 bool SMESH_Gen::IsGlobalHypothesis(const SMESH_Hypothesis* theHyp, SMESH_Mesh& aMesh)
756 SMESH_HypoFilter filter( SMESH_HypoFilter::Is( theHyp ));
757 return aMesh.GetHypothesis( aMesh.GetMeshDS()->ShapeToMesh(), filter, false );
760 //=============================================================================
762 * Finds algo to mesh a shape. Optionally returns a shape the found algo is bound to
764 //=============================================================================
766 SMESH_Algo *SMESH_Gen::GetAlgo(SMESH_Mesh & aMesh,
767 const TopoDS_Shape & aShape,
768 TopoDS_Shape* assignedTo)
770 SMESH_HypoFilter filter( SMESH_HypoFilter::IsAlgo() );
771 filter.And( filter.IsApplicableTo( aShape ));
773 return (SMESH_Algo*) aMesh.GetHypothesis( aShape, filter, true, assignedTo );
776 //=============================================================================
778 * Returns StudyContextStruct for a study
780 //=============================================================================
782 StudyContextStruct *SMESH_Gen::GetStudyContext(int studyId)
784 // Get studyContext, create it if it does'nt exist, with a SMESHDS_Document
786 if (_mapStudyContext.find(studyId) == _mapStudyContext.end())
788 _mapStudyContext[studyId] = new StudyContextStruct;
789 _mapStudyContext[studyId]->myDocument = new SMESHDS_Document(studyId);
791 StudyContextStruct *myStudyContext = _mapStudyContext[studyId];
792 return myStudyContext;
795 //================================================================================
797 * \brief Return shape dimension by TopAbs_ShapeEnum
799 //================================================================================
801 int SMESH_Gen::GetShapeDim(const TopAbs_ShapeEnum & aShapeType)
803 static vector<int> dim;
806 dim.resize( TopAbs_SHAPE, -1 );
807 dim[ TopAbs_COMPOUND ] = MeshDim_3D;
808 dim[ TopAbs_COMPSOLID ] = MeshDim_3D;
809 dim[ TopAbs_SOLID ] = MeshDim_3D;
810 dim[ TopAbs_SHELL ] = MeshDim_3D;
811 dim[ TopAbs_FACE ] = MeshDim_2D;
812 dim[ TopAbs_WIRE ] = MeshDim_1D;
813 dim[ TopAbs_EDGE ] = MeshDim_1D;
814 dim[ TopAbs_VERTEX ] = MeshDim_0D;
816 return dim[ aShapeType ];
819 //=============================================================================
821 * Genarate a new id unique withing this Gen
823 //=============================================================================
825 int SMESH_Gen::GetANewId()