1 // Copyright (C) 2007-2008 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
22 // SMESH SMESH : implementaion of SMESH idl descriptions
23 // File : SMESH_Gen.cxx
24 // Author : Paul RASCLE, EDF
27 #include "SMESH_Gen.hxx"
28 #include "SMESH_subMesh.hxx"
29 #include "SMESH_HypoFilter.hxx"
30 #include "SMESHDS_Document.hxx"
31 #include "SMDS_MeshElement.hxx"
32 #include "SMDS_MeshNode.hxx"
33 #include "SMDS_Mesh.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>
48 //=============================================================================
50 * default constructor:
52 //=============================================================================
54 SMESH_Gen::SMESH_Gen()
56 MESSAGE("SMESH_Gen::SMESH_Gen");
60 SMDS_Mesh::_meshList.clear();
61 MESSAGE(SMDS_Mesh::_meshList.size());
64 //=============================================================================
68 //=============================================================================
70 SMESH_Gen::~SMESH_Gen()
72 MESSAGE("SMESH_Gen::~SMESH_Gen");
75 //=============================================================================
79 //=============================================================================
81 /*SMESH_Hypothesis *SMESH_Gen::CreateHypothesis(const char *anHyp, int studyId)
82 throw(SALOME_Exception)
85 MESSAGE("CreateHypothesis("<<anHyp<<","<<studyId<<")");
86 // Get studyContext, create it if it does'nt exist, with a SMESHDS_Document
88 StudyContextStruct *myStudyContext = GetStudyContext(studyId);
90 // create a new hypothesis object, store its ref. in studyContext
92 SMESH_Hypothesis *myHypothesis = _hypothesisFactory.Create(anHyp, studyId);
93 int hypId = myHypothesis->GetID();
94 myStudyContext->mapHypothesis[hypId] = myHypothesis;
98 // store hypothesis in SMESHDS document
100 myStudyContext->myDocument->AddHypothesis(myHypothesis);
104 //=============================================================================
108 //=============================================================================
110 SMESH_Mesh* SMESH_Gen::CreateMesh(int theStudyId, bool theIsEmbeddedMode)
111 throw(SALOME_Exception)
113 Unexpect aCatch(SalomeException);
114 MESSAGE("SMESH_Gen::CreateMesh");
116 // Get studyContext, create it if it does'nt exist, with a SMESHDS_Document
117 StudyContextStruct *aStudyContext = GetStudyContext(theStudyId);
119 // create a new SMESH_mesh object
120 SMESH_Mesh *aMesh = new SMESH_Mesh(_localId++,
124 aStudyContext->myDocument);
125 aStudyContext->mapMesh[_localId] = aMesh;
130 //=============================================================================
134 //=============================================================================
136 bool SMESH_Gen::Compute(SMESH_Mesh & aMesh,
137 const TopoDS_Shape & aShape,
139 const ::MeshDimension aDim,
140 TSetOfInt* aShapesId)
142 MESSAGE("SMESH_Gen::Compute");
147 SMESH_subMesh *sm = aMesh.GetSubMesh(aShape);
149 const bool includeSelf = true;
150 const bool complexShapeFirst = true;
152 SMESH_subMeshIteratorPtr smIt;
154 if ( anUpward ) // is called from below code here
156 // -----------------------------------------------
157 // mesh all the subshapes starting from vertices
158 // -----------------------------------------------
159 smIt = sm->getDependsOnIterator(includeSelf, !complexShapeFirst);
160 while ( smIt->more() )
162 SMESH_subMesh* smToCompute = smIt->next();
164 // do not mesh vertices of a pseudo shape
165 const TopAbs_ShapeEnum aShType = smToCompute->GetSubShape().ShapeType();
166 if ( !aMesh.HasShapeToMesh() && aShType == TopAbs_VERTEX )
169 // check for preview dimension limitations
170 if ( aShapesId && GetShapeDim( aShType ) > (int)aDim )
172 // clear compute state to not show previous compute errors
173 // if preview invoked less dimension less than previous
174 smToCompute->ComputeStateEngine( SMESH_subMesh::CHECK_COMPUTE_STATE );
178 if (smToCompute->GetComputeState() == SMESH_subMesh::READY_TO_COMPUTE)
179 smToCompute->ComputeStateEngine( SMESH_subMesh::COMPUTE );
181 // we check all the submeshes here and detect if any of them failed to compute
182 if (smToCompute->GetComputeState() == SMESH_subMesh::FAILED_TO_COMPUTE)
184 else if ( aShapesId )
185 aShapesId->insert( smToCompute->GetId() );
191 // -----------------------------------------------------------------
192 // apply algos that DO NOT require descretized boundaries and DO NOT
193 // support submeshes, starting from the most complex shapes
194 // and collect submeshes with algos that DO support submeshes
195 // -----------------------------------------------------------------
196 list< SMESH_subMesh* > smWithAlgoSupportingSubmeshes;
197 smIt = sm->getDependsOnIterator(includeSelf, complexShapeFirst);
198 while ( smIt->more() )
200 SMESH_subMesh* smToCompute = smIt->next();
201 if ( smToCompute->GetComputeState() != SMESH_subMesh::READY_TO_COMPUTE )
204 const TopoDS_Shape& aSubShape = smToCompute->GetSubShape();
205 const int aShapeDim = GetShapeDim( aSubShape );
206 if ( aShapeDim < 1 ) break;
208 // check for preview dimension limitations
209 if ( aShapesId && aShapeDim > (int)aDim )
212 SMESH_Algo* algo = GetAlgo( aMesh, aSubShape );
213 if ( algo && !algo->NeedDescretBoundary() )
215 if ( algo->SupportSubmeshes() )
216 smWithAlgoSupportingSubmeshes.push_back( smToCompute );
219 smToCompute->ComputeStateEngine( SMESH_subMesh::COMPUTE );
221 aShapesId->insert( smToCompute->GetId() );
225 // ------------------------------------------------------------
226 // compute submeshes under shapes with algos that DO NOT require
227 // descretized boundaries and DO support submeshes
228 // ------------------------------------------------------------
229 list< SMESH_subMesh* >::reverse_iterator subIt, subEnd;
230 subIt = smWithAlgoSupportingSubmeshes.rbegin();
231 subEnd = smWithAlgoSupportingSubmeshes.rend();
232 // start from lower shapes
233 for ( ; subIt != subEnd; ++subIt )
237 // get a shape the algo is assigned to
238 TopoDS_Shape algoShape;
239 if ( !GetAlgo( aMesh, sm->GetSubShape(), & algoShape ))
240 continue; // strange...
242 // look for more local algos
243 smIt = sm->getDependsOnIterator(!includeSelf, !complexShapeFirst);
244 while ( smIt->more() )
246 SMESH_subMesh* smToCompute = smIt->next();
248 const TopoDS_Shape& aSubShape = smToCompute->GetSubShape();
249 const int aShapeDim = GetShapeDim( aSubShape );
250 //if ( aSubShape.ShapeType() == TopAbs_VERTEX ) continue;
251 if ( aShapeDim < 1 ) continue;
253 // check for preview dimension limitations
254 if ( aShapesId && GetShapeDim( aSubShape.ShapeType() ) > (int)aDim )
257 SMESH_HypoFilter filter( SMESH_HypoFilter::IsAlgo() );
259 .And( SMESH_HypoFilter::IsApplicableTo( aSubShape ))
260 .And( SMESH_HypoFilter::IsMoreLocalThan( algoShape ));
262 if ( SMESH_Algo* subAlgo = (SMESH_Algo*) aMesh.GetHypothesis( aSubShape, filter, true )) {
263 SMESH_Hypothesis::Hypothesis_Status status;
264 if ( subAlgo->CheckHypothesis( aMesh, aSubShape, status ))
265 // mesh a lower smToCompute starting from vertices
266 Compute( aMesh, aSubShape, /*anUpward=*/true, aDim, aShapesId );
270 // ----------------------------------------------------------
271 // apply the algos that do not require descretized boundaries
272 // ----------------------------------------------------------
273 for ( subIt = smWithAlgoSupportingSubmeshes.rbegin(); subIt != subEnd; ++subIt )
276 if ( sm->GetComputeState() == SMESH_subMesh::READY_TO_COMPUTE)
278 const TopAbs_ShapeEnum aShType = sm->GetSubShape().ShapeType();
279 // check for preview dimension limitations
280 if ( aShapesId && GetShapeDim( aShType ) > (int)aDim )
283 sm->ComputeStateEngine( SMESH_subMesh::COMPUTE );
285 aShapesId->insert( sm->GetId() );
288 // -----------------------------------------------
289 // mesh the rest subshapes starting from vertices
290 // -----------------------------------------------
291 ret = Compute( aMesh, aShape, /*anUpward=*/true, aDim, aShapesId );
294 MESSAGE( "VSR - SMESH_Gen::Compute() finished, OK = " << ret);
297 SMESHDS_Mesh *myMesh = aMesh.GetMeshDS();
298 myMesh->adjustStructure();
299 list<int> listind = myMesh->SubMeshIndices();
300 list<int>::iterator it = listind.begin();
302 for(; it != listind.end(); ++it)
304 ::SMESHDS_SubMesh *subMesh = myMesh->MeshElements(*it);
305 total += subMesh->getSize();
307 cerr << "total elements and nodes in submesh sets:" << total << endl;
308 cerr << "Number of node objects " << SMDS_MeshNode::nbNodes << endl;
309 cerr << "Number of cell objects " << SMDS_MeshCell::nbCells << endl;
314 //=============================================================================
318 //=============================================================================
320 bool SMESH_Gen::Evaluate(SMESH_Mesh & aMesh,
321 const TopoDS_Shape & aShape,
322 MapShapeNbElems& aResMap,
324 TSetOfInt* aShapesId)
326 MESSAGE("SMESH_Gen::Evaluate");
330 SMESH_subMesh *sm = aMesh.GetSubMesh(aShape);
332 const bool includeSelf = true;
333 const bool complexShapeFirst = true;
334 SMESH_subMeshIteratorPtr smIt;
336 if ( anUpward ) { // is called from below code here
337 // -----------------------------------------------
338 // mesh all the subshapes starting from vertices
339 // -----------------------------------------------
340 smIt = sm->getDependsOnIterator(includeSelf, !complexShapeFirst);
341 while ( smIt->more() ) {
342 SMESH_subMesh* smToCompute = smIt->next();
344 // do not mesh vertices of a pseudo shape
345 const TopAbs_ShapeEnum aShType = smToCompute->GetSubShape().ShapeType();
346 //if ( !aMesh.HasShapeToMesh() && aShType == TopAbs_VERTEX )
348 if ( !aMesh.HasShapeToMesh() ) {
349 if( aShType == TopAbs_VERTEX || aShType == TopAbs_WIRE ||
350 aShType == TopAbs_SHELL )
354 smToCompute->Evaluate(aResMap);
356 aShapesId->insert( smToCompute->GetId() );
361 // -----------------------------------------------------------------
362 // apply algos that DO NOT require descretized boundaries and DO NOT
363 // support submeshes, starting from the most complex shapes
364 // and collect submeshes with algos that DO support submeshes
365 // -----------------------------------------------------------------
366 list< SMESH_subMesh* > smWithAlgoSupportingSubmeshes;
367 smIt = sm->getDependsOnIterator(includeSelf, complexShapeFirst);
368 while ( smIt->more() ) {
369 SMESH_subMesh* smToCompute = smIt->next();
370 const TopoDS_Shape& aSubShape = smToCompute->GetSubShape();
371 const int aShapeDim = GetShapeDim( aSubShape );
372 if ( aShapeDim < 1 ) break;
374 SMESH_Algo* algo = GetAlgo( aMesh, aSubShape );
375 if ( algo && !algo->NeedDescretBoundary() ) {
376 if ( algo->SupportSubmeshes() ) {
377 smWithAlgoSupportingSubmeshes.push_back( smToCompute );
380 smToCompute->Evaluate(aResMap);
382 aShapesId->insert( smToCompute->GetId() );
386 // ------------------------------------------------------------
387 // compute submeshes under shapes with algos that DO NOT require
388 // descretized boundaries and DO support submeshes
389 // ------------------------------------------------------------
390 list< SMESH_subMesh* >::reverse_iterator subIt, subEnd;
391 subIt = smWithAlgoSupportingSubmeshes.rbegin();
392 subEnd = smWithAlgoSupportingSubmeshes.rend();
393 // start from lower shapes
394 for ( ; subIt != subEnd; ++subIt ) {
397 // get a shape the algo is assigned to
398 TopoDS_Shape algoShape;
399 if ( !GetAlgo( aMesh, sm->GetSubShape(), & algoShape ))
400 continue; // strange...
402 // look for more local algos
403 smIt = sm->getDependsOnIterator(!includeSelf, !complexShapeFirst);
404 while ( smIt->more() ) {
405 SMESH_subMesh* smToCompute = smIt->next();
407 const TopoDS_Shape& aSubShape = smToCompute->GetSubShape();
408 const int aShapeDim = GetShapeDim( aSubShape );
409 if ( aShapeDim < 1 ) continue;
411 //const TopAbs_ShapeEnum aShType = smToCompute->GetSubShape().ShapeType();
413 SMESH_HypoFilter filter( SMESH_HypoFilter::IsAlgo() );
415 .And( SMESH_HypoFilter::IsApplicableTo( aSubShape ))
416 .And( SMESH_HypoFilter::IsMoreLocalThan( algoShape ));
418 if ( SMESH_Algo* subAlgo = (SMESH_Algo*) aMesh.GetHypothesis( aSubShape, filter, true )) {
419 SMESH_Hypothesis::Hypothesis_Status status;
420 if ( subAlgo->CheckHypothesis( aMesh, aSubShape, status ))
421 // mesh a lower smToCompute starting from vertices
422 Evaluate( aMesh, aSubShape, aResMap, /*anUpward=*/true, aShapesId );
426 // ----------------------------------------------------------
427 // apply the algos that do not require descretized boundaries
428 // ----------------------------------------------------------
429 for ( subIt = smWithAlgoSupportingSubmeshes.rbegin(); subIt != subEnd; ++subIt )
432 sm->Evaluate(aResMap);
434 aShapesId->insert( sm->GetId() );
437 // -----------------------------------------------
438 // mesh the rest subshapes starting from vertices
439 // -----------------------------------------------
440 ret = Evaluate( aMesh, aShape, aResMap, /*anUpward=*/true, aShapesId );
443 MESSAGE( "VSR - SMESH_Gen::Evaluate() finished, OK = " << ret);
448 //=======================================================================
449 //function : checkConformIgnoredAlgos
451 //=======================================================================
453 static bool checkConformIgnoredAlgos(SMESH_Mesh& aMesh,
454 SMESH_subMesh* aSubMesh,
455 const SMESH_Algo* aGlobIgnoAlgo,
456 const SMESH_Algo* aLocIgnoAlgo,
458 set<SMESH_subMesh*>& aCheckedMap,
459 list< SMESH_Gen::TAlgoStateError > & theErrors)
462 if ( aSubMesh->GetSubShape().ShapeType() == TopAbs_VERTEX)
468 const list<const SMESHDS_Hypothesis*>& listHyp =
469 aMesh.GetMeshDS()->GetHypothesis( aSubMesh->GetSubShape() );
470 list<const SMESHDS_Hypothesis*>::const_iterator it=listHyp.begin();
471 for ( ; it != listHyp.end(); it++)
473 const SMESHDS_Hypothesis * aHyp = *it;
474 if (aHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO)
477 const SMESH_Algo* algo = dynamic_cast<const SMESH_Algo*> (aHyp);
480 if ( aLocIgnoAlgo ) // algo is hidden by a local algo of upper dim
482 INFOS( "Local <" << algo->GetName() << "> is hidden by local <"
483 << aLocIgnoAlgo->GetName() << ">");
487 bool isGlobal = (aMesh.IsMainShape( aSubMesh->GetSubShape() ));
488 int dim = algo->GetDim();
489 int aMaxGlobIgnoDim = ( aGlobIgnoAlgo ? aGlobIgnoAlgo->GetDim() : -1 );
491 if ( dim < aMaxGlobIgnoDim )
493 // algo is hidden by a global algo
494 INFOS( ( isGlobal ? "Global" : "Local" )
495 << " <" << algo->GetName() << "> is hidden by global <"
496 << aGlobIgnoAlgo->GetName() << ">");
498 else if ( !algo->NeedDescretBoundary() && !isGlobal)
500 // local algo is not hidden and hides algos on sub-shapes
501 if (checkConform && !aSubMesh->IsConform( algo ))
504 checkConform = false; // no more check conformity
505 INFOS( "ERROR: Local <" << algo->GetName() <<
506 "> would produce not conform mesh: "
507 "<Not Conform Mesh Allowed> hypotesis is missing");
508 theErrors.push_back( SMESH_Gen::TAlgoStateError() );
509 theErrors.back().Set( SMESH_Hypothesis::HYP_NOTCONFORM, algo, false );
512 // sub-algos will be hidden by a local <algo>
513 SMESH_subMeshIteratorPtr revItSub =
514 aSubMesh->getDependsOnIterator( /*includeSelf=*/false, /*complexShapeFirst=*/true);
515 bool checkConform2 = false;
516 while ( revItSub->more() )
518 SMESH_subMesh* sm = revItSub->next();
519 checkConformIgnoredAlgos (aMesh, sm, aGlobIgnoAlgo,
520 algo, checkConform2, aCheckedMap, theErrors);
521 aCheckedMap.insert( sm );
530 //=======================================================================
531 //function : checkMissing
532 //purpose : notify on missing hypothesis
533 // Return false if algo or hipothesis is missing
534 //=======================================================================
536 static bool checkMissing(SMESH_Gen* aGen,
538 SMESH_subMesh* aSubMesh,
539 const int aTopAlgoDim,
541 const bool checkNoAlgo,
542 set<SMESH_subMesh*>& aCheckedMap,
543 list< SMESH_Gen::TAlgoStateError > & theErrors)
545 if ( aSubMesh->GetSubShape().ShapeType() == TopAbs_VERTEX)
548 //MESSAGE("=====checkMissing");
551 SMESH_Algo* algo = 0;
553 switch (aSubMesh->GetAlgoState())
555 case SMESH_subMesh::NO_ALGO: {
558 // should there be any algo?
559 int shapeDim = SMESH_Gen::GetShapeDim( aSubMesh->GetSubShape() );
560 if (aTopAlgoDim > shapeDim)
562 MESSAGE( "ERROR: " << shapeDim << "D algorithm is missing" );
564 theErrors.push_back( SMESH_Gen::TAlgoStateError() );
565 theErrors.back().Set( SMESH_Hypothesis::HYP_MISSING, shapeDim, true );
570 case SMESH_subMesh::MISSING_HYP: {
571 // notify if an algo missing hyp is attached to aSubMesh
572 algo = aGen->GetAlgo( aMesh, aSubMesh->GetSubShape() );
574 bool IsGlobalHypothesis = aGen->IsGlobalHypothesis( algo, aMesh );
575 if (!IsGlobalHypothesis || !globalChecked[ algo->GetDim() ])
577 TAlgoStateErrorName errName = SMESH_Hypothesis::HYP_MISSING;
578 SMESH_Hypothesis::Hypothesis_Status status;
579 algo->CheckHypothesis( aMesh, aSubMesh->GetSubShape(), status );
580 if ( status == SMESH_Hypothesis::HYP_BAD_PARAMETER ) {
581 MESSAGE( "ERROR: hypothesis of " << (IsGlobalHypothesis ? "Global " : "Local ")
582 << "<" << algo->GetName() << "> has a bad parameter value");
584 } else if ( status == SMESH_Hypothesis::HYP_BAD_GEOMETRY ) {
585 MESSAGE( "ERROR: " << (IsGlobalHypothesis ? "Global " : "Local ")
586 << "<" << algo->GetName() << "> assigned to mismatching geometry");
589 MESSAGE( "ERROR: " << (IsGlobalHypothesis ? "Global " : "Local ")
590 << "<" << algo->GetName() << "> misses some hypothesis");
592 if (IsGlobalHypothesis)
593 globalChecked[ algo->GetDim() ] = true;
594 theErrors.push_back( SMESH_Gen::TAlgoStateError() );
595 theErrors.back().Set( errName, algo, IsGlobalHypothesis );
600 case SMESH_subMesh::HYP_OK:
601 algo = aGen->GetAlgo( aMesh, aSubMesh->GetSubShape() );
607 // do not check under algo that hides sub-algos or
608 // re-start checking NO_ALGO state
610 bool isTopLocalAlgo =
611 ( aTopAlgoDim <= algo->GetDim() && !aGen->IsGlobalHypothesis( algo, aMesh ));
612 if (!algo->NeedDescretBoundary() || isTopLocalAlgo)
614 bool checkNoAlgo2 = ( algo->NeedDescretBoundary() );
615 SMESH_subMeshIteratorPtr itsub = aSubMesh->getDependsOnIterator( /*includeSelf=*/false,
616 /*complexShapeFirst=*/false);
617 while ( itsub->more() )
619 // sub-meshes should not be checked further more
620 SMESH_subMesh* sm = itsub->next();
621 aCheckedMap.insert( sm );
625 //check algo on sub-meshes
626 int aTopAlgoDim2 = algo->GetDim();
627 if (!checkMissing (aGen, aMesh, sm, aTopAlgoDim2,
628 globalChecked, checkNoAlgo2, aCheckedMap, theErrors))
631 if (sm->GetAlgoState() == SMESH_subMesh::NO_ALGO )
632 checkNoAlgo2 = false;
640 //=======================================================================
641 //function : CheckAlgoState
642 //purpose : notify on bad state of attached algos, return false
643 // if Compute() would fail because of some algo bad state
644 //=======================================================================
646 bool SMESH_Gen::CheckAlgoState(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape)
648 list< TAlgoStateError > errors;
649 return GetAlgoState( aMesh, aShape, errors );
652 //=======================================================================
653 //function : GetAlgoState
654 //purpose : notify on bad state of attached algos, return false
655 // if Compute() would fail because of some algo bad state
656 // theErrors list contains problems description
657 //=======================================================================
659 bool SMESH_Gen::GetAlgoState(SMESH_Mesh& theMesh,
660 const TopoDS_Shape& theShape,
661 list< TAlgoStateError > & theErrors)
663 //MESSAGE("SMESH_Gen::CheckAlgoState");
666 bool hasAlgo = false;
668 SMESH_subMesh* sm = theMesh.GetSubMesh(theShape);
669 const SMESHDS_Mesh* meshDS = theMesh.GetMeshDS();
670 TopoDS_Shape mainShape = meshDS->ShapeToMesh();
676 const SMESH_Algo* aGlobAlgoArr[] = {0,0,0,0};
678 const list<const SMESHDS_Hypothesis*>& listHyp = meshDS->GetHypothesis( mainShape );
679 list<const SMESHDS_Hypothesis*>::const_iterator it=listHyp.begin();
680 for ( ; it != listHyp.end(); it++)
682 const SMESHDS_Hypothesis * aHyp = *it;
683 if (aHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO)
686 const SMESH_Algo* algo = dynamic_cast<const SMESH_Algo*> (aHyp);
689 int dim = algo->GetDim();
690 aGlobAlgoArr[ dim ] = algo;
695 // --------------------------------------------------------
696 // info on algos that will be ignored because of ones that
697 // don't NeedDescretBoundary() attached to super-shapes,
698 // check that a conform mesh will be produced
699 // --------------------------------------------------------
702 // find a global algo possibly hiding sub-algos
704 const SMESH_Algo* aGlobIgnoAlgo = 0;
705 for (dim = 3; dim > 0; dim--)
707 if (aGlobAlgoArr[ dim ] &&
708 !aGlobAlgoArr[ dim ]->NeedDescretBoundary())
710 aGlobIgnoAlgo = aGlobAlgoArr[ dim ];
715 set<SMESH_subMesh*> aCheckedSubs;
716 bool checkConform = ( !theMesh.IsNotConformAllowed() );
718 // loop on theShape and its sub-shapes
719 SMESH_subMeshIteratorPtr revItSub = sm->getDependsOnIterator( /*includeSelf=*/true,
720 /*complexShapeFirst=*/true);
721 while ( revItSub->more() )
723 SMESH_subMesh* smToCheck = revItSub->next();
724 if ( smToCheck->GetSubShape().ShapeType() == TopAbs_VERTEX)
727 if ( aCheckedSubs.insert( smToCheck ).second ) // not yet checked
728 if (!checkConformIgnoredAlgos (theMesh, smToCheck, aGlobIgnoAlgo,
729 0, checkConform, aCheckedSubs, theErrors))
732 if ( smToCheck->GetAlgoState() != SMESH_subMesh::NO_ALGO )
736 // ----------------------------------------------------------------
737 // info on missing hypothesis and find out if all needed algos are
739 // ----------------------------------------------------------------
741 //MESSAGE( "---info on missing hypothesis and find out if all needed algos are");
743 // find max dim of global algo
745 for (dim = 3; dim > 0; dim--)
747 if (aGlobAlgoArr[ dim ])
753 bool checkNoAlgo = theMesh.HasShapeToMesh() ? bool( aTopAlgoDim ) : false;
754 bool globalChecked[] = { false, false, false, false };
756 // loop on theShape and its sub-shapes
757 aCheckedSubs.clear();
758 revItSub = sm->getDependsOnIterator( /*includeSelf=*/true, /*complexShapeFirst=*/true);
759 while ( revItSub->more() )
761 SMESH_subMesh* smToCheck = revItSub->next();
762 if ( smToCheck->GetSubShape().ShapeType() == TopAbs_VERTEX)
765 if ( aCheckedSubs.insert( smToCheck ).second ) // not yet checked
766 if (!checkMissing (this, theMesh, smToCheck, aTopAlgoDim,
767 globalChecked, checkNoAlgo, aCheckedSubs, theErrors))
770 if (smToCheck->GetAlgoState() == SMESH_subMesh::NO_ALGO )
777 INFOS( "None algorithm attached" );
778 theErrors.push_back( TAlgoStateError() );
779 theErrors.back().Set( SMESH_Hypothesis::HYP_MISSING, 1, true );
785 //=======================================================================
786 //function : IsGlobalHypothesis
787 //purpose : check if theAlgo is attached to the main shape
788 //=======================================================================
790 bool SMESH_Gen::IsGlobalHypothesis(const SMESH_Hypothesis* theHyp, SMESH_Mesh& aMesh)
792 SMESH_HypoFilter filter( SMESH_HypoFilter::Is( theHyp ));
793 return aMesh.GetHypothesis( aMesh.GetMeshDS()->ShapeToMesh(), filter, false );
796 //=============================================================================
800 //=============================================================================
802 SMESH_Algo *SMESH_Gen::GetAlgo(SMESH_Mesh & aMesh,
803 const TopoDS_Shape & aShape,
804 TopoDS_Shape* assignedTo)
807 SMESH_HypoFilter filter( SMESH_HypoFilter::IsAlgo() );
808 filter.And( filter.IsApplicableTo( aShape ));
810 return (SMESH_Algo*) aMesh.GetHypothesis( aShape, filter, true, assignedTo );
813 //=============================================================================
817 //=============================================================================
819 StudyContextStruct *SMESH_Gen::GetStudyContext(int studyId)
821 // Get studyContext, create it if it does'nt exist, with a SMESHDS_Document
823 if (_mapStudyContext.find(studyId) == _mapStudyContext.end())
825 _mapStudyContext[studyId] = new StudyContextStruct;
826 _mapStudyContext[studyId]->myDocument = new SMESHDS_Document(studyId);
828 StudyContextStruct *myStudyContext = _mapStudyContext[studyId];
829 // ASSERT(_mapStudyContext.find(studyId) != _mapStudyContext.end());
830 return myStudyContext;
833 // //=============================================================================
837 // //=============================================================================
839 // void SMESH_Gen::Save(int studyId, const char *aUrlOfFile)
843 // //=============================================================================
847 // //=============================================================================
849 // void SMESH_Gen::Load(int studyId, const char *aUrlOfFile)
853 // //=============================================================================
857 // //=============================================================================
859 // void SMESH_Gen::Close(int studyId)
863 //=============================================================================
867 //=============================================================================
869 int SMESH_Gen::GetShapeDim(const TopAbs_ShapeEnum & aShapeType)
871 static vector<int> dim;
874 dim.resize( TopAbs_SHAPE, -1 );
875 dim[ TopAbs_COMPOUND ] = MeshDim_3D;
876 dim[ TopAbs_COMPSOLID ] = MeshDim_3D;
877 dim[ TopAbs_SOLID ] = MeshDim_3D;
878 dim[ TopAbs_SHELL ] = MeshDim_3D;
879 dim[ TopAbs_FACE ] = MeshDim_2D;
880 dim[ TopAbs_WIRE ] = MeshDim_1D;
881 dim[ TopAbs_EDGE ] = MeshDim_1D;
882 dim[ TopAbs_VERTEX ] = MeshDim_0D;
884 return dim[ aShapeType ];
887 //=============================================================================
891 //=============================================================================
893 int SMESH_Gen::GetANewId()
895 //MESSAGE("SMESH_Gen::GetANewId");