1 // Copyright (C) 2007-2022 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, or (at your option) any later version.
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 : implementation of SMESH idl descriptions
24 // File : SMESH_Gen.cxx
25 // Author : Paul RASCLE, EDF
31 #include "SMESH_Gen.hxx"
33 #include "SMESH_DriverMesh.hxx"
34 #include "SMDS_Mesh.hxx"
35 #include "SMDS_MeshElement.hxx"
36 #include "SMDS_MeshNode.hxx"
37 #include "SMESHDS_Document.hxx"
38 #include "SMESH_HypoFilter.hxx"
39 #include "SMESH_Mesh.hxx"
40 #include "SMESH_MesherHelper.hxx"
41 #include "SMESH_subMesh.hxx"
43 #include <utilities.h>
44 #include <Utils_ExceptHandlers.hxx>
46 #include <TopExp_Explorer.hxx>
48 #include <TopoDS_Iterator.hxx>
57 #include <Basics_Utils.hxx>
60 #include <boost/filesystem.hpp>
61 #include <boost/asio.hpp>
62 namespace fs = boost::filesystem;
64 // Environment variable separator
73 // a structure used to nullify SMESH_Gen field of SMESH_Hypothesis,
74 // which is needed for SMESH_Hypothesis not deleted before ~SMESH_Gen()
75 struct _Hyp : public SMESH_Hypothesis
83 //================================================================================
85 * \brief Fill a map of shapes with all sub-shape of a sub-mesh
87 //================================================================================
89 TopTools_IndexedMapOfShape * fillAllowed( SMESH_subMesh* sm,
91 TopTools_IndexedMapOfShape * allowedSub )
93 if ( !toFill || !allowedSub )
97 if ( allowedSub->IsEmpty() )
99 allowedSub->ReSize( sm->DependsOn().size() + 1 );
100 allowedSub->Add( sm->GetSubShape() );
101 for ( const auto & key_sm : sm->DependsOn() )
102 allowedSub->Add( key_sm.second->GetSubShape() );
108 //=============================================================================
112 //=============================================================================
114 SMESH_Gen::SMESH_Gen()
116 _studyContext = new StudyContextStruct;
117 _studyContext->myDocument = new SMESHDS_Document();
120 _segmentation = _nbSegments = 10;
121 _compute_canceled = false;
124 //=============================================================================
128 //=============================================================================
130 SMESH_Gen::~SMESH_Gen()
132 std::map < int, SMESH_Hypothesis * >::iterator i_hyp = _studyContext->mapHypothesis.begin();
133 for ( ; i_hyp != _studyContext->mapHypothesis.end(); ++i_hyp )
135 if ( _Hyp* h = static_cast< _Hyp*>( i_hyp->second ))
138 delete _studyContext->myDocument;
139 delete _studyContext;
142 //=============================================================================
144 * Creates a mesh in a study.
145 * if (theIsEmbeddedMode) { mesh modification commands are not logged }
147 //=============================================================================
149 SMESH_Mesh* SMESH_Gen::CreateMesh(bool theIsEmbeddedMode)
151 Unexpect aCatch(SalomeException);
153 // create a new SMESH_mesh object
154 SMESH_Mesh *aMesh = new SMESH_Mesh(_localId++,
157 _studyContext->myDocument);
158 _studyContext->mapMesh[_localId-1] = aMesh;
165 bool SMESH_Gen::sequentialComputeSubMeshes(
167 const TopoDS_Shape & aShape,
168 const ::MeshDimension aDim,
169 TSetOfInt* aShapesId /*=0*/,
170 TopTools_IndexedMapOfShape* allowedSubShapes,
171 SMESH_subMesh::compute_event &computeEvent,
172 const bool includeSelf,
173 const bool complexShapeFirst,
174 const bool aShapeOnly)
176 MESSAGE("Compute submeshes sequentialy");
180 SMESH_subMeshIteratorPtr smIt;
181 SMESH_subMesh *shapeSM = aMesh.GetSubMesh(aShape);
183 smIt = shapeSM->getDependsOnIterator(includeSelf, !complexShapeFirst);
184 while ( smIt->more() )
186 SMESH_subMesh* smToCompute = smIt->next();
188 // do not mesh vertices of a pseudo shape
189 const TopoDS_Shape& shape = smToCompute->GetSubShape();
190 const TopAbs_ShapeEnum shapeType = shape.ShapeType();
191 if ( !aMesh.HasShapeToMesh() && shapeType == TopAbs_VERTEX )
194 // check for preview dimension limitations
195 if ( aShapesId && GetShapeDim( shapeType ) > (int)aDim )
197 // clear compute state not to show previous compute errors
198 // if preview invoked less dimension less than previous
199 smToCompute->ComputeStateEngine( SMESH_subMesh::CHECK_COMPUTE_STATE );
203 if (smToCompute->GetComputeState() == SMESH_subMesh::READY_TO_COMPUTE)
205 if (_compute_canceled)
207 smToCompute->SetAllowedSubShapes( fillAllowed( shapeSM, aShapeOnly, allowedSubShapes ));
208 setCurrentSubMesh( smToCompute );
209 smToCompute->ComputeStateEngine( computeEvent );
210 setCurrentSubMesh( nullptr );
211 smToCompute->SetAllowedSubShapes( nullptr );
214 // we check all the sub-meshes here and detect if any of them failed to compute
215 if (smToCompute->GetComputeState() == SMESH_subMesh::FAILED_TO_COMPUTE &&
216 ( shapeType != TopAbs_EDGE || !SMESH_Algo::isDegenerated( TopoDS::Edge( shape ))))
218 else if ( aShapesId )
219 aShapesId->insert( smToCompute->GetId() );
221 //aMesh.GetMeshDS()->Modified();
226 //=============================================================================
228 * Parallel compute of a submesh
229 * This function is used to pass to thread_pool
231 //=============================================================================
232 const std::function<void(SMESH_subMesh*,
233 SMESH_subMesh::compute_event,
236 TopTools_IndexedMapOfShape *,
238 compute_function([&] (SMESH_subMesh* sm,
239 SMESH_subMesh::compute_event event,
240 SMESH_subMesh *shapeSM,
242 TopTools_IndexedMapOfShape *allowedSubShapes,
243 TSetOfInt* aShapesId) -> void
245 if (sm->GetComputeState() == SMESH_subMesh::READY_TO_COMPUTE)
247 sm->SetAllowedSubShapes( fillAllowed( shapeSM, aShapeOnly, allowedSubShapes ));
248 //setCurrentSubMesh( sm );
249 sm->ComputeStateEngine(event);
250 //setCurrentSubMesh( nullptr );
251 sm->SetAllowedSubShapes( nullptr );
255 aShapesId->insert( sm->GetId() );
259 bool SMESH_Gen::parallelComputeSubMeshes(
261 const TopoDS_Shape & aShape,
262 const ::MeshDimension aDim,
263 TSetOfInt* aShapesId /*=0*/,
264 TopTools_IndexedMapOfShape* allowedSubShapes,
265 SMESH_subMesh::compute_event &computeEvent,
266 const bool includeSelf,
267 const bool complexShapeFirst,
268 const bool aShapeOnly)
273 SMESH_subMeshIteratorPtr smIt;
274 SMESH_subMesh *shapeSM = aMesh.GetSubMesh(aShape);
276 // Pool of thread for computation
277 // TODO: move when parallelMesh created
278 aMesh.InitPoolThreads();
280 TopAbs_ShapeEnum previousShapeType = TopAbs_VERTEX;
281 int nbThreads = aMesh.GetNbThreads();
282 MESSAGE("Compute submeshes with threads: " << nbThreads << " mesher: " << aMesh.GetMesherNbThreads());
285 smIt = shapeSM->getDependsOnIterator(includeSelf, !complexShapeFirst);
286 while ( smIt->more() )
288 SMESH_subMesh* smToCompute = smIt->next();
290 // do not mesh vertices of a pseudo shape
291 const TopoDS_Shape& shape = smToCompute->GetSubShape();
292 const TopAbs_ShapeEnum shapeType = shape.ShapeType();
293 // Not doing in parallel 1D and 2D meshes
294 if ( !aMesh.HasShapeToMesh() && shapeType == TopAbs_VERTEX )
296 if(shapeType==TopAbs_FACE||shapeType==TopAbs_EDGE)
297 aMesh.SetNbThreads(0);
299 aMesh.SetNbThreads(nbThreads);
302 if (shapeType != previousShapeType) {
303 // Waiting for all threads for the previous type to end
306 std::string file_name;
307 switch(previousShapeType){
309 file_name = "Mesh2D.med";
312 file_name = "Mesh1D.med";
315 file_name = "Mesh0D.med";
324 fs::path mesh_file = fs::path(aMesh.tmp_folder) / fs::path(file_name);
325 exportMesh(mesh_file.string(), aMesh, "MESH");
328 //Resetting threaded pool info
329 previousShapeType = shapeType;
332 // check for preview dimension limitations
333 if ( aShapesId && GetShapeDim( shapeType ) > (int)aDim )
335 // clear compute state not to show previous compute errors
336 // if preview invoked less dimension less than previous
337 smToCompute->ComputeStateEngine( SMESH_subMesh::CHECK_COMPUTE_STATE );
340 boost::asio::post(*(aMesh._pool), std::bind(compute_function, smToCompute, computeEvent,
341 shapeSM, aShapeOnly, allowedSubShapes,
345 // Waiting for the thread for Solids to finish
348 aMesh.GetMeshDS()->Modified();
354 //=============================================================================
358 //=============================================================================
360 bool SMESH_Gen::Compute(SMESH_Mesh & aMesh,
361 const TopoDS_Shape & aShape,
362 const int aFlags /*= COMPACT_MESH*/,
363 const ::MeshDimension aDim /*=::MeshDim_3D*/,
364 TSetOfInt* aShapesId /*=0*/,
365 TopTools_IndexedMapOfShape* anAllowedSubShapes/*=0*/)
369 const bool aShapeOnly = aFlags & SHAPE_ONLY;
370 const bool anUpward = aFlags & UPWARD;
371 const bool aCompactMesh = aFlags & COMPACT_MESH;
375 SMESH_subMesh *sm, *shapeSM = aMesh.GetSubMesh(aShape);
377 const bool includeSelf = true;
378 const bool complexShapeFirst = true;
379 const int globalAlgoDim = 100;
381 SMESH_subMeshIteratorPtr smIt;
383 // Fix of Issue 22150. Due to !BLSURF->OnlyUnaryInput(), BLSURF computes edges
384 // that must be computed by Projection 1D-2D while the Projection asks to compute
386 SMESH_subMesh::compute_event computeEvent =
387 aShapeOnly ? SMESH_subMesh::COMPUTE_SUBMESH : SMESH_subMesh::COMPUTE;
388 if ( !aMesh.HasShapeToMesh() )
389 computeEvent = SMESH_subMesh::COMPUTE_NOGEOM; // if several algos and no geometry
391 TopTools_IndexedMapOfShape *allowedSubShapes = anAllowedSubShapes, allowedSub;
392 if ( aShapeOnly && !allowedSubShapes )
393 allowedSubShapes = &allowedSub;
395 if ( anUpward ) // is called from the below code in this method
397 // ===============================================
398 // Mesh all the sub-shapes starting from vertices
399 // ===============================================
400 if (aMesh.IsParallel())
401 ret = parallelComputeSubMeshes(
403 aShapesId, allowedSubShapes,
409 ret = sequentialComputeSubMeshes(
411 aShapesId, allowedSubShapes,
421 // ================================================================
422 // Apply algos that do NOT require discretized boundaries
423 // ("all-dimensional") and do NOT support sub-meshes, starting from
424 // the most complex shapes and collect sub-meshes with algos that
425 // DO support sub-meshes
426 // ================================================================
427 list< SMESH_subMesh* > smWithAlgoSupportingSubmeshes[4]; // for each dim
429 // map to sort sm with same dim algos according to dim of
430 // the shape the algo assigned to (issue 0021217).
431 // Other issues influenced the algo applying order:
432 // 21406, 21556, 21893, 20206
433 multimap< int, SMESH_subMesh* > shDim2sm;
434 multimap< int, SMESH_subMesh* >::reverse_iterator shDim2smIt;
435 TopoDS_Shape algoShape;
436 int prevShapeDim = -1, aShapeDim;
438 smIt = shapeSM->getDependsOnIterator(includeSelf, complexShapeFirst);
439 while ( smIt->more() )
441 SMESH_subMesh* smToCompute = smIt->next();
442 if ( smToCompute->GetComputeState() != SMESH_subMesh::READY_TO_COMPUTE )
445 const TopoDS_Shape& aSubShape = smToCompute->GetSubShape();
446 aShapeDim = GetShapeDim( aSubShape );
447 if ( aShapeDim < 1 ) break;
449 // check for preview dimension limitations
450 if ( aShapesId && aShapeDim > (int)aDim )
453 SMESH_Algo* algo = GetAlgo( smToCompute, &algoShape );
454 if ( algo && !algo->NeedDiscreteBoundary() )
456 if ( algo->SupportSubmeshes() )
458 // reload sub-meshes from shDim2sm into smWithAlgoSupportingSubmeshes
459 // so that more local algos to go first
460 if ( prevShapeDim != aShapeDim )
462 prevShapeDim = aShapeDim;
463 for ( shDim2smIt = shDim2sm.rbegin(); shDim2smIt != shDim2sm.rend(); ++shDim2smIt )
464 if ( shDim2smIt->first == globalAlgoDim )
465 smWithAlgoSupportingSubmeshes[ aShapeDim ].push_back( shDim2smIt->second );
467 smWithAlgoSupportingSubmeshes[ aShapeDim ].push_front( shDim2smIt->second );
470 // add smToCompute to shDim2sm map
471 if ( algoShape.IsSame( aMesh.GetShapeToMesh() ))
473 aShapeDim = globalAlgoDim; // to compute last
477 aShapeDim = GetShapeDim( algoShape );
478 if ( algoShape.ShapeType() == TopAbs_COMPOUND )
480 TopoDS_Iterator it( algoShape );
481 aShapeDim += GetShapeDim( it.Value() );
484 shDim2sm.insert( make_pair( aShapeDim, smToCompute ));
486 else // Compute w/o support of sub-meshes
488 if (_compute_canceled)
490 smToCompute->SetAllowedSubShapes( fillAllowed( shapeSM, aShapeOnly, allowedSubShapes ));
491 setCurrentSubMesh( smToCompute );
492 smToCompute->ComputeStateEngine( computeEvent );
493 setCurrentSubMesh( nullptr );
494 smToCompute->SetAllowedSubShapes( nullptr );
496 aShapesId->insert( smToCompute->GetId() );
500 // reload sub-meshes from shDim2sm into smWithAlgoSupportingSubmeshes
501 for ( shDim2smIt = shDim2sm.rbegin(); shDim2smIt != shDim2sm.rend(); ++shDim2smIt )
502 if ( shDim2smIt->first == globalAlgoDim )
503 smWithAlgoSupportingSubmeshes[3].push_back( shDim2smIt->second );
505 smWithAlgoSupportingSubmeshes[0].push_front( shDim2smIt->second );
507 // ======================================================
508 // Apply all-dimensional algorithms supporing sub-meshes
509 // ======================================================
511 std::vector< SMESH_subMesh* > smVec;
512 for ( aShapeDim = 0; aShapeDim < 4; ++aShapeDim )
513 smVec.insert( smVec.end(),
514 smWithAlgoSupportingSubmeshes[aShapeDim].begin(),
515 smWithAlgoSupportingSubmeshes[aShapeDim].end() );
517 // gather sub-shapes with local uni-dimensional algos (bos #29143)
518 // ----------------------------------------------------------------
519 TopTools_MapOfShape uniDimAlgoShapes;
520 if ( !smVec.empty() )
522 ShapeToHypothesis::Iterator s2hyps( aMesh.GetMeshDS()->GetHypotheses() );
523 for ( ; s2hyps.More(); s2hyps.Next() )
525 const TopoDS_Shape& s = s2hyps.Key();
526 if ( s.IsSame( aMesh.GetShapeToMesh() ))
528 for ( auto & hyp : s2hyps.Value() )
530 if ( const SMESH_Algo* algo = dynamic_cast< const SMESH_Algo*>( hyp ))
531 if ( algo->NeedDiscreteBoundary() )
533 TopAbs_ShapeEnum sType;
534 switch ( algo->GetDim() ) {
535 case 3: sType = TopAbs_SOLID; break;
536 case 2: sType = TopAbs_FACE; break;
537 default: sType = TopAbs_EDGE; break;
539 for ( TopExp_Explorer ex( s2hyps.Key(), sType ); ex.More(); ex.Next() )
540 uniDimAlgoShapes.Add( ex.Current() );
547 // ------------------------------------------------
548 // sort list of sub-meshes according to mesh order
549 // ------------------------------------------------
550 aMesh.SortByMeshOrder( smVec );
552 // ------------------------------------------------------------
553 // compute sub-meshes with local uni-dimensional algos under
554 // sub-meshes with all-dimensional algos
555 // ------------------------------------------------------------
556 // start from lower shapes
557 for ( size_t i = 0; i < smVec.size(); ++i )
560 if ( sm->GetComputeState() != SMESH_subMesh::READY_TO_COMPUTE)
563 const TopAbs_ShapeEnum shapeType = sm->GetSubShape().ShapeType();
565 if ( !uniDimAlgoShapes.IsEmpty() )
567 // get a shape the algo is assigned to
568 if ( !GetAlgo( sm, & algoShape ))
569 continue; // strange...
571 // look for more local algos
572 if ( SMESH_subMesh* algoSM = aMesh.GetSubMesh( algoShape ))
573 smIt = algoSM->getDependsOnIterator(!includeSelf, !complexShapeFirst);
575 smIt = sm->getDependsOnIterator(!includeSelf, !complexShapeFirst);
577 while ( smIt->more() )
579 SMESH_subMesh* smToCompute = smIt->next();
581 const TopoDS_Shape& aSubShape = smToCompute->GetSubShape();
582 const int aShapeDim = GetShapeDim( aSubShape );
583 if ( aShapeDim < 1 || aSubShape.ShapeType() <= shapeType )
585 if ( !uniDimAlgoShapes.Contains( aSubShape ))
586 continue; // [bos #29143] aMesh.GetHypothesis() is too long
588 // check for preview dimension limitations
589 if ( aShapesId && GetShapeDim( aSubShape.ShapeType() ) > (int)aDim )
592 SMESH_HypoFilter filter( SMESH_HypoFilter::IsAlgo() );
594 .And( SMESH_HypoFilter::IsApplicableTo( aSubShape ))
595 .And( SMESH_HypoFilter::IsMoreLocalThan( algoShape, aMesh ));
597 if ( SMESH_Algo* subAlgo = (SMESH_Algo*) aMesh.GetHypothesis( smToCompute, filter, true))
599 if ( ! subAlgo->NeedDiscreteBoundary() ) continue;
600 TopTools_IndexedMapOfShape* localAllowed = allowedSubShapes;
601 if ( localAllowed && localAllowed->IsEmpty() )
602 localAllowed = 0; // prevent fillAllowed() with aSubShape
604 SMESH_Hypothesis::Hypothesis_Status status;
605 if ( subAlgo->CheckHypothesis( aMesh, aSubShape, status ))
606 // mesh a lower smToCompute starting from vertices
607 Compute( aMesh, aSubShape, aFlags | SHAPE_ONLY_UPWARD, aDim, aShapesId, localAllowed );
611 // --------------------------------
612 // apply the all-dimensional algo
613 // --------------------------------
615 if (_compute_canceled)
617 // check for preview dimension limitations
618 if ( aShapesId && GetShapeDim( shapeType ) > (int)aDim )
620 sm->SetAllowedSubShapes( fillAllowed( shapeSM, aShapeOnly, allowedSubShapes ));
621 setCurrentSubMesh( sm );
622 sm->ComputeStateEngine( computeEvent );
624 setCurrentSubMesh( NULL );
625 sm->SetAllowedSubShapes( nullptr );
627 aShapesId->insert( sm->GetId() );
632 // -----------------------------------------------
633 // mesh the rest sub-shapes starting from vertices
634 // -----------------------------------------------
635 ret = Compute( aMesh, aShape, aFlags | UPWARD, aDim, aShapesId, allowedSubShapes );
641 // fix quadratic mesh by bending iternal links near concave boundary
642 if ( aCompactMesh && // a final compute
643 aShape.IsSame( aMesh.GetShapeToMesh() ) &&
644 !aShapesId && // not preview
645 ret ) // everything is OK
647 SMESH_MesherHelper aHelper( aMesh );
648 if ( aHelper.IsQuadraticMesh() != SMESH_MesherHelper::LINEAR )
650 aHelper.FixQuadraticElements( shapeSM->GetComputeError() );
656 aMesh.GetMeshDS()->Modified();
657 aMesh.GetMeshDS()->CompactMesh();
662 //=============================================================================
664 * Prepare Compute a mesh
666 //=============================================================================
667 void SMESH_Gen::PrepareCompute(SMESH_Mesh & /*aMesh*/,
668 const TopoDS_Shape & /*aShape*/)
670 _compute_canceled = false;
671 resetCurrentSubMesh();
674 //=============================================================================
676 * Cancel Compute a mesh
678 //=============================================================================
679 void SMESH_Gen::CancelCompute(SMESH_Mesh & /*aMesh*/,
680 const TopoDS_Shape & /*aShape*/)
682 _compute_canceled = true;
683 if ( const SMESH_subMesh* sm = GetCurrentSubMesh() )
685 const_cast< SMESH_subMesh* >( sm )->ComputeStateEngine( SMESH_subMesh::COMPUTE_CANCELED );
687 resetCurrentSubMesh();
690 //================================================================================
692 * \brief Returns a sub-mesh being currently computed
694 //================================================================================
696 const SMESH_subMesh* SMESH_Gen::GetCurrentSubMesh() const
698 return _sm_current.empty() ? 0 : _sm_current.back();
701 //================================================================================
703 * \brief Sets a sub-mesh being currently computed.
705 * An algorithm can call Compute() for a sub-shape, hence we keep a stack of sub-meshes
707 //================================================================================
709 void SMESH_Gen::setCurrentSubMesh(SMESH_subMesh* sm)
712 _sm_current.push_back( sm );
714 else if ( !_sm_current.empty() )
715 _sm_current.pop_back();
718 void SMESH_Gen::resetCurrentSubMesh()
723 //=============================================================================
727 //=============================================================================
729 bool SMESH_Gen::Evaluate(SMESH_Mesh & aMesh,
730 const TopoDS_Shape & aShape,
731 MapShapeNbElems& aResMap,
733 TSetOfInt* aShapesId)
737 SMESH_subMesh *sm = aMesh.GetSubMesh(aShape);
739 const bool includeSelf = true;
740 const bool complexShapeFirst = true;
741 SMESH_subMeshIteratorPtr smIt;
743 if ( anUpward ) { // is called from below code here
744 // -----------------------------------------------
745 // mesh all the sub-shapes starting from vertices
746 // -----------------------------------------------
747 smIt = sm->getDependsOnIterator(includeSelf, !complexShapeFirst);
748 while ( smIt->more() ) {
749 SMESH_subMesh* smToCompute = smIt->next();
751 // do not mesh vertices of a pseudo shape
752 const TopAbs_ShapeEnum shapeType = smToCompute->GetSubShape().ShapeType();
753 //if ( !aMesh.HasShapeToMesh() && shapeType == TopAbs_VERTEX )
755 if ( !aMesh.HasShapeToMesh() ) {
756 if( shapeType == TopAbs_VERTEX || shapeType == TopAbs_WIRE ||
757 shapeType == TopAbs_SHELL )
761 smToCompute->Evaluate(aResMap);
763 aShapesId->insert( smToCompute->GetId() );
768 // -----------------------------------------------------------------
769 // apply algos that DO NOT require Discreteized boundaries and DO NOT
770 // support sub-meshes, starting from the most complex shapes
771 // and collect sub-meshes with algos that DO support sub-meshes
772 // -----------------------------------------------------------------
773 list< SMESH_subMesh* > smWithAlgoSupportingSubmeshes;
774 smIt = sm->getDependsOnIterator(includeSelf, complexShapeFirst);
775 while ( smIt->more() ) {
776 SMESH_subMesh* smToCompute = smIt->next();
777 const TopoDS_Shape& aSubShape = smToCompute->GetSubShape();
778 const int aShapeDim = GetShapeDim( aSubShape );
779 if ( aShapeDim < 1 ) break;
781 SMESH_Algo* algo = GetAlgo( smToCompute );
782 if ( algo && !algo->NeedDiscreteBoundary() ) {
783 if ( algo->SupportSubmeshes() ) {
784 smWithAlgoSupportingSubmeshes.push_front( smToCompute );
787 smToCompute->Evaluate(aResMap);
789 aShapesId->insert( smToCompute->GetId() );
794 // ------------------------------------------------------------
795 // sort list of meshes according to mesh order
796 // ------------------------------------------------------------
797 std::vector< SMESH_subMesh* > smVec( smWithAlgoSupportingSubmeshes.begin(),
798 smWithAlgoSupportingSubmeshes.end() );
799 aMesh.SortByMeshOrder( smVec );
801 // ------------------------------------------------------------
802 // compute sub-meshes under shapes with algos that DO NOT require
803 // Discreteized boundaries and DO support sub-meshes
804 // ------------------------------------------------------------
805 // start from lower shapes
806 for ( size_t i = 0; i < smVec.size(); ++i )
810 // get a shape the algo is assigned to
811 TopoDS_Shape algoShape;
812 if ( !GetAlgo( sm, & algoShape ))
813 continue; // strange...
815 // look for more local algos
816 smIt = sm->getDependsOnIterator(!includeSelf, !complexShapeFirst);
817 while ( smIt->more() ) {
818 SMESH_subMesh* smToCompute = smIt->next();
820 const TopoDS_Shape& aSubShape = smToCompute->GetSubShape();
821 const int aShapeDim = GetShapeDim( aSubShape );
822 if ( aShapeDim < 1 ) continue;
824 SMESH_HypoFilter filter( SMESH_HypoFilter::IsAlgo() );
826 .And( SMESH_HypoFilter::IsApplicableTo( aSubShape ))
827 .And( SMESH_HypoFilter::IsMoreLocalThan( algoShape, aMesh ));
829 if ( SMESH_Algo* subAlgo = (SMESH_Algo*) aMesh.GetHypothesis( smToCompute, filter, true ))
831 if ( ! subAlgo->NeedDiscreteBoundary() ) continue;
832 SMESH_Hypothesis::Hypothesis_Status status;
833 if ( subAlgo->CheckHypothesis( aMesh, aSubShape, status ))
834 // mesh a lower smToCompute starting from vertices
835 Evaluate( aMesh, aSubShape, aResMap, /*anUpward=*/true, aShapesId );
839 // ----------------------------------------------------------
840 // apply the algos that do not require Discreteized boundaries
841 // ----------------------------------------------------------
842 for ( size_t i = 0; i < smVec.size(); ++i )
845 sm->Evaluate(aResMap);
847 aShapesId->insert( sm->GetId() );
850 // -----------------------------------------------
851 // mesh the rest sub-shapes starting from vertices
852 // -----------------------------------------------
853 ret = Evaluate( aMesh, aShape, aResMap, /*anUpward=*/true, aShapesId );
860 //=======================================================================
861 //function : checkConformIgnoredAlgos
863 //=======================================================================
865 static bool checkConformIgnoredAlgos(SMESH_Mesh& aMesh,
866 SMESH_subMesh* aSubMesh,
867 const SMESH_Algo* aGlobIgnoAlgo,
868 const SMESH_Algo* aLocIgnoAlgo,
870 set<SMESH_subMesh*>& aCheckedMap,
871 list< SMESH_Gen::TAlgoStateError > & theErrors)
874 if ( aSubMesh->GetSubShape().ShapeType() == TopAbs_VERTEX)
880 const list<const SMESHDS_Hypothesis*>& listHyp =
881 aMesh.GetMeshDS()->GetHypothesis( aSubMesh->GetSubShape() );
882 list<const SMESHDS_Hypothesis*>::const_iterator it=listHyp.begin();
883 for ( ; it != listHyp.end(); it++)
885 const SMESHDS_Hypothesis * aHyp = *it;
886 if (aHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO)
889 const SMESH_Algo* algo = dynamic_cast<const SMESH_Algo*> (aHyp);
892 if ( aLocIgnoAlgo ) // algo is hidden by a local algo of upper dim
894 theErrors.push_back( SMESH_Gen::TAlgoStateError() );
895 theErrors.back().Set( SMESH_Hypothesis::HYP_HIDDEN_ALGO, algo, false );
896 INFOS( "Local <" << algo->GetName() << "> is hidden by local <"
897 << aLocIgnoAlgo->GetName() << ">");
901 bool isGlobal = (aMesh.IsMainShape( aSubMesh->GetSubShape() ));
902 int dim = algo->GetDim();
903 int aMaxGlobIgnoDim = ( aGlobIgnoAlgo ? aGlobIgnoAlgo->GetDim() : -1 );
904 bool isNeededDim = ( aGlobIgnoAlgo ? aGlobIgnoAlgo->NeedLowerHyps( dim ) : false );
906 if (( dim < aMaxGlobIgnoDim && !isNeededDim ) &&
907 ( isGlobal || !aGlobIgnoAlgo->SupportSubmeshes() ))
909 // algo is hidden by a global algo
910 theErrors.push_back( SMESH_Gen::TAlgoStateError() );
911 theErrors.back().Set( SMESH_Hypothesis::HYP_HIDDEN_ALGO, algo, true );
912 INFOS( ( isGlobal ? "Global" : "Local" )
913 << " <" << algo->GetName() << "> is hidden by global <"
914 << aGlobIgnoAlgo->GetName() << ">");
916 else if ( !algo->NeedDiscreteBoundary() && !isGlobal)
918 // local algo is not hidden and hides algos on sub-shapes
919 if (checkConform && !aSubMesh->IsConform( algo ))
922 checkConform = false; // no more check conformity
923 INFOS( "ERROR: Local <" << algo->GetName() <<
924 "> would produce not conform mesh: "
925 "<Not Conform Mesh Allowed> hypothesis is missing");
926 theErrors.push_back( SMESH_Gen::TAlgoStateError() );
927 theErrors.back().Set( SMESH_Hypothesis::HYP_NOTCONFORM, algo, false );
930 // sub-algos will be hidden by a local <algo> if <algo> does not support sub-meshes
931 if ( algo->SupportSubmeshes() )
933 SMESH_subMeshIteratorPtr revItSub =
934 aSubMesh->getDependsOnIterator( /*includeSelf=*/false, /*complexShapeFirst=*/true);
935 bool checkConform2 = false;
936 while ( revItSub->more() )
938 SMESH_subMesh* sm = revItSub->next();
939 checkConformIgnoredAlgos (aMesh, sm, aGlobIgnoAlgo,
940 algo, checkConform2, aCheckedMap, theErrors);
941 aCheckedMap.insert( sm );
950 //=======================================================================
951 //function : checkMissing
952 //purpose : notify on missing hypothesis
953 // Return false if algo or hipothesis is missing
954 //=======================================================================
956 static bool checkMissing(SMESH_Gen* aGen,
958 SMESH_subMesh* aSubMesh,
959 const int aTopAlgoDim,
961 const bool checkNoAlgo,
962 set<SMESH_subMesh*>& aCheckedMap,
963 list< SMESH_Gen::TAlgoStateError > & theErrors)
965 switch ( aSubMesh->GetSubShape().ShapeType() )
969 case TopAbs_SOLID: break; // check this sub-mesh, it can be meshed
971 return true; // not meshable sub-mesh
973 if ( aCheckedMap.count( aSubMesh ))
977 SMESH_Algo* algo = 0;
979 switch (aSubMesh->GetAlgoState())
981 case SMESH_subMesh::NO_ALGO: {
984 // should there be any algo?
985 int shapeDim = SMESH_Gen::GetShapeDim( aSubMesh->GetSubShape() );
986 if (aTopAlgoDim > shapeDim)
988 MESSAGE( "ERROR: " << shapeDim << "D algorithm is missing" );
990 theErrors.push_back( SMESH_Gen::TAlgoStateError() );
991 theErrors.back().Set( SMESH_Hypothesis::HYP_MISSING, shapeDim, true );
996 case SMESH_subMesh::MISSING_HYP: {
997 // notify if an algo missing hyp is attached to aSubMesh
998 algo = aSubMesh->GetAlgo();
1000 bool IsGlobalHypothesis = aGen->IsGlobalHypothesis( algo, aMesh );
1001 if (!IsGlobalHypothesis || !globalChecked[ algo->GetDim() ])
1003 TAlgoStateErrorName errName = SMESH_Hypothesis::HYP_MISSING;
1004 SMESH_Hypothesis::Hypothesis_Status status;
1005 algo->CheckHypothesis( aMesh, aSubMesh->GetSubShape(), status );
1006 if ( status == SMESH_Hypothesis::HYP_BAD_PARAMETER ) {
1007 MESSAGE( "ERROR: hypothesis of " << (IsGlobalHypothesis ? "Global " : "Local ")
1008 << "<" << algo->GetName() << "> has a bad parameter value");
1010 } else if ( status == SMESH_Hypothesis::HYP_BAD_GEOMETRY ) {
1011 MESSAGE( "ERROR: " << (IsGlobalHypothesis ? "Global " : "Local ")
1012 << "<" << algo->GetName() << "> assigned to mismatching geometry");
1015 MESSAGE( "ERROR: " << (IsGlobalHypothesis ? "Global " : "Local ")
1016 << "<" << algo->GetName() << "> misses some hypothesis");
1018 if (IsGlobalHypothesis)
1019 globalChecked[ algo->GetDim() ] = true;
1020 theErrors.push_back( SMESH_Gen::TAlgoStateError() );
1021 theErrors.back().Set( errName, algo, IsGlobalHypothesis );
1026 case SMESH_subMesh::HYP_OK:
1027 algo = aSubMesh->GetAlgo();
1029 if (!algo->NeedDiscreteBoundary())
1031 SMESH_subMeshIteratorPtr itsub = aSubMesh->getDependsOnIterator( /*includeSelf=*/false,
1032 /*complexShapeFirst=*/false);
1033 while ( itsub->more() )
1034 aCheckedMap.insert( itsub->next() );
1040 // do not check under algo that hides sub-algos or
1041 // re-start checking NO_ALGO state
1043 bool isTopLocalAlgo =
1044 ( aTopAlgoDim <= algo->GetDim() && !aGen->IsGlobalHypothesis( algo, aMesh ));
1045 if (!algo->NeedDiscreteBoundary() || isTopLocalAlgo)
1047 bool checkNoAlgo2 = ( algo->NeedDiscreteBoundary() );
1048 SMESH_subMeshIteratorPtr itsub = aSubMesh->getDependsOnIterator( /*includeSelf=*/false,
1049 /*complexShapeFirst=*/true);
1050 while ( itsub->more() )
1052 // sub-meshes should not be checked further more
1053 SMESH_subMesh* sm = itsub->next();
1057 //check algo on sub-meshes
1058 int aTopAlgoDim2 = algo->GetDim();
1059 if (!checkMissing (aGen, aMesh, sm, aTopAlgoDim2,
1060 globalChecked, checkNoAlgo2, aCheckedMap, theErrors))
1063 if (sm->GetAlgoState() == SMESH_subMesh::NO_ALGO )
1064 checkNoAlgo2 = false;
1067 aCheckedMap.insert( sm );
1073 //=======================================================================
1074 //function : CheckAlgoState
1075 //purpose : notify on bad state of attached algos, return false
1076 // if Compute() would fail because of some algo bad state
1077 //=======================================================================
1079 bool SMESH_Gen::CheckAlgoState(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape)
1081 list< TAlgoStateError > errors;
1082 return GetAlgoState( aMesh, aShape, errors );
1085 //=======================================================================
1086 //function : GetAlgoState
1087 //purpose : notify on bad state of attached algos, return false
1088 // if Compute() would fail because of some algo bad state
1089 // theErrors list contains problems description
1090 //=======================================================================
1092 bool SMESH_Gen::GetAlgoState(SMESH_Mesh& theMesh,
1093 const TopoDS_Shape& theShape,
1094 list< TAlgoStateError > & theErrors)
1097 bool hasAlgo = false;
1099 SMESH_subMesh* sm = theMesh.GetSubMesh(theShape);
1100 const SMESHDS_Mesh* meshDS = theMesh.GetMeshDS();
1101 TopoDS_Shape mainShape = meshDS->ShapeToMesh();
1103 // -----------------
1105 // -----------------
1107 const SMESH_Algo* aGlobAlgoArr[] = {0,0,0,0};
1109 const list<const SMESHDS_Hypothesis*>& listHyp = meshDS->GetHypothesis( mainShape );
1110 list<const SMESHDS_Hypothesis*>::const_iterator it=listHyp.begin();
1111 for ( ; it != listHyp.end(); it++)
1113 const SMESHDS_Hypothesis * aHyp = *it;
1114 if (aHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO)
1117 const SMESH_Algo* algo = dynamic_cast<const SMESH_Algo*> (aHyp);
1120 int dim = algo->GetDim();
1121 aGlobAlgoArr[ dim ] = algo;
1126 // --------------------------------------------------------
1127 // info on algos that will be ignored because of ones that
1128 // don't NeedDiscreteBoundary() attached to super-shapes,
1129 // check that a conform mesh will be produced
1130 // --------------------------------------------------------
1133 // find a global algo possibly hiding sub-algos
1135 const SMESH_Algo* aGlobIgnoAlgo = 0;
1136 for (dim = 3; dim > 0; dim--)
1138 if (aGlobAlgoArr[ dim ] &&
1139 !aGlobAlgoArr[ dim ]->NeedDiscreteBoundary() /*&&
1140 !aGlobAlgoArr[ dim ]->SupportSubmeshes()*/ )
1142 aGlobIgnoAlgo = aGlobAlgoArr[ dim ];
1147 set<SMESH_subMesh*> aCheckedSubs;
1148 bool checkConform = ( !theMesh.IsNotConformAllowed() );
1150 // loop on theShape and its sub-shapes
1151 SMESH_subMeshIteratorPtr revItSub = sm->getDependsOnIterator( /*includeSelf=*/true,
1152 /*complexShapeFirst=*/true);
1153 while ( revItSub->more() )
1155 SMESH_subMesh* smToCheck = revItSub->next();
1156 if ( smToCheck->GetSubShape().ShapeType() == TopAbs_VERTEX)
1159 if ( aCheckedSubs.insert( smToCheck ).second ) // not yet checked
1160 if (!checkConformIgnoredAlgos (theMesh, smToCheck, aGlobIgnoAlgo,
1161 0, checkConform, aCheckedSubs, theErrors))
1164 if ( smToCheck->GetAlgoState() != SMESH_subMesh::NO_ALGO )
1168 // ----------------------------------------------------------------
1169 // info on missing hypothesis and find out if all needed algos are
1171 // ----------------------------------------------------------------
1173 // find max dim of global algo
1174 int aTopAlgoDim = 0;
1175 for (dim = 3; dim > 0; dim--)
1177 if (aGlobAlgoArr[ dim ])
1183 bool checkNoAlgo = theMesh.HasShapeToMesh() ? bool( aTopAlgoDim ) : false;
1184 bool globalChecked[] = { false, false, false, false };
1186 // loop on theShape and its sub-shapes
1187 aCheckedSubs.clear();
1188 revItSub = sm->getDependsOnIterator( /*includeSelf=*/true, /*complexShapeFirst=*/true);
1189 while ( revItSub->more() )
1191 SMESH_subMesh* smToCheck = revItSub->next();
1192 if ( smToCheck->GetSubShape().ShapeType() == TopAbs_VERTEX)
1195 if (!checkMissing (this, theMesh, smToCheck, aTopAlgoDim,
1196 globalChecked, checkNoAlgo, aCheckedSubs, theErrors))
1199 if (smToCheck->GetAlgoState() == SMESH_subMesh::NO_ALGO )
1200 checkNoAlgo = false;
1206 theErrors.push_back( TAlgoStateError() );
1207 theErrors.back().Set( SMESH_Hypothesis::HYP_MISSING, theMesh.HasShapeToMesh() ? 1 : 3, true );
1213 //=======================================================================
1214 //function : IsGlobalHypothesis
1215 //purpose : check if theAlgo is attached to the main shape
1216 //=======================================================================
1218 bool SMESH_Gen::IsGlobalHypothesis(const SMESH_Hypothesis* theHyp, SMESH_Mesh& aMesh)
1220 SMESH_HypoFilter filter( SMESH_HypoFilter::Is( theHyp ));
1221 return aMesh.GetHypothesis( aMesh.GetMeshDS()->ShapeToMesh(), filter, false );
1224 //================================================================================
1226 * \brief Return paths to xml files of plugins
1228 //================================================================================
1230 std::vector< std::string > SMESH_Gen::GetPluginXMLPaths()
1232 // Get paths to xml files of plugins
1233 vector< string > xmlPaths;
1235 if ( const char* meshersList = getenv("SMESH_MeshersList") )
1237 string meshers = meshersList, plugin;
1238 string::size_type from = 0, pos;
1239 while ( from < meshers.size() )
1241 // cut off plugin name
1242 pos = meshers.find( env_sep, from );
1243 if ( pos != string::npos )
1244 plugin = meshers.substr( from, pos-from );
1246 plugin = meshers.substr( from ), pos = meshers.size();
1249 // get PLUGIN_ROOT_DIR path
1250 string rootDirVar, pluginSubDir = plugin;
1251 if ( plugin == "StdMeshers" )
1252 rootDirVar = "SMESH", pluginSubDir = "smesh";
1254 for ( pos = 0; pos < plugin.size(); ++pos )
1255 rootDirVar += toupper( plugin[pos] );
1256 rootDirVar += "_ROOT_DIR";
1258 const char* rootDir = getenv( rootDirVar.c_str() );
1259 if ( !rootDir || strlen(rootDir) == 0 )
1261 rootDirVar = plugin + "_ROOT_DIR"; // HexoticPLUGIN_ROOT_DIR
1262 rootDir = getenv( rootDirVar.c_str() );
1263 if ( !rootDir || strlen(rootDir) == 0 ) continue;
1266 // get a separator from rootDir
1267 for ( int i = strlen( rootDir )-1; i >= 0 && sep.empty(); --i )
1268 if ( rootDir[i] == '/' || rootDir[i] == '\\' )
1274 if (sep.empty() ) sep = "\\";
1276 if (sep.empty() ) sep = "/";
1279 // get a path to resource file
1280 string xmlPath = rootDir;
1281 if ( xmlPath[ xmlPath.size()-1 ] != sep[0] )
1283 xmlPath += "share" + sep + "salome" + sep + "resources" + sep;
1284 for ( pos = 0; pos < pluginSubDir.size(); ++pos )
1285 xmlPath += tolower( pluginSubDir[pos] );
1286 xmlPath += sep + plugin + ".xml";
1290 const wchar_t* path = Kernel_Utils::decode_s(xmlPath);
1291 SMESHUtils::ArrayDeleter<const wchar_t> deleter( path );
1293 const char* path = xmlPath.c_str();
1295 fileOK = (GetFileAttributes(path) != INVALID_FILE_ATTRIBUTES);
1298 fileOK = (access(xmlPath.c_str(), F_OK) == 0);
1301 xmlPaths.push_back( xmlPath );
1308 //=============================================================================
1310 * Finds algo to mesh a shape. Optionally returns a shape the found algo is bound to
1312 //=============================================================================
1314 SMESH_Algo *SMESH_Gen::GetAlgo(SMESH_Mesh & aMesh,
1315 const TopoDS_Shape & aShape,
1316 TopoDS_Shape* assignedTo)
1318 return GetAlgo( aMesh.GetSubMesh( aShape ), assignedTo );
1321 //=============================================================================
1323 * Finds algo to mesh a sub-mesh. Optionally returns a shape the found algo is bound to
1325 //=============================================================================
1327 SMESH_Algo *SMESH_Gen::GetAlgo(SMESH_subMesh * aSubMesh,
1328 TopoDS_Shape* assignedTo)
1330 if ( !aSubMesh ) return 0;
1332 const TopoDS_Shape & aShape = aSubMesh->GetSubShape();
1333 SMESH_Mesh& aMesh = *aSubMesh->GetFather();
1335 SMESH_HypoFilter filter( SMESH_HypoFilter::IsAlgo() );
1336 if ( aMesh.HasShapeToMesh() )
1337 filter.And( filter.IsApplicableTo( aShape ));
1339 typedef SMESH_Algo::Features AlgoData;
1341 TopoDS_Shape assignedToShape;
1343 (SMESH_Algo*) aMesh.GetHypothesis( aSubMesh, filter, true, &assignedToShape );
1346 aShape.ShapeType() == TopAbs_FACE &&
1347 !aShape.IsSame( assignedToShape ) &&
1348 SMESH_MesherHelper::NbAncestors( aShape, aMesh, TopAbs_SOLID ) > 1 )
1350 // Issue 0021559. If there is another 2D algo with different types of output
1351 // elements that can be used to mesh aShape, and 3D algos on adjacent SOLIDs
1352 // have different types of input elements, we choose a most appropriate 2D algo.
1354 // try to find a concurrent 2D algo
1355 filter.AndNot( filter.Is( algo ));
1356 TopoDS_Shape assignedToShape2;
1358 (SMESH_Algo*) aMesh.GetHypothesis( aSubMesh, filter, true, &assignedToShape2 );
1359 if ( algo2 && // algo found
1360 !assignedToShape2.IsSame( aMesh.GetShapeToMesh() ) && // algo is local
1361 ( SMESH_MesherHelper::GetGroupType( assignedToShape2 ) == // algo of the same level
1362 SMESH_MesherHelper::GetGroupType( assignedToShape )) &&
1363 aMesh.IsOrderOK( aMesh.GetSubMesh( assignedToShape2 ), // no forced order
1364 aMesh.GetSubMesh( assignedToShape )))
1366 // get algos on the adjacent SOLIDs
1367 filter.Init( filter.IsAlgo() ).And( filter.HasDim( 3 ));
1368 vector< SMESH_Algo* > algos3D;
1369 PShapeIteratorPtr solidIt = SMESH_MesherHelper::GetAncestors( aShape, aMesh,
1371 while ( const TopoDS_Shape* solid = solidIt->next() )
1372 if ( SMESH_Algo* algo3D = (SMESH_Algo*) aMesh.GetHypothesis( *solid, filter, true ))
1374 algos3D.push_back( algo3D );
1375 filter.AndNot( filter.HasName( algo3D->GetName() ));
1377 // check compatibility of algos
1378 if ( algos3D.size() > 1 )
1380 const AlgoData& algoData = algo->SMESH_Algo::GetFeatures();
1381 const AlgoData& algoData2 = algo2->SMESH_Algo::GetFeatures();
1382 const AlgoData& algoData3d0 = algos3D[0]->SMESH_Algo::GetFeatures();
1383 const AlgoData& algoData3d1 = algos3D[1]->SMESH_Algo::GetFeatures();
1384 if (( algoData2.IsCompatible( algoData3d0 ) &&
1385 algoData2.IsCompatible( algoData3d1 ))
1387 !(algoData.IsCompatible( algoData3d0 ) &&
1388 algoData.IsCompatible( algoData3d1 )))
1394 if ( assignedTo && algo )
1395 * assignedTo = assignedToShape;
1400 //=============================================================================
1402 * Returns StudyContextStruct for a study
1404 //=============================================================================
1406 StudyContextStruct *SMESH_Gen::GetStudyContext()
1408 return _studyContext;
1411 //================================================================================
1413 * \brief Return shape dimension by TopAbs_ShapeEnum
1415 //================================================================================
1417 int SMESH_Gen::GetShapeDim(const TopAbs_ShapeEnum & aShapeType)
1419 static vector<int> dim;
1422 dim.resize( TopAbs_SHAPE, -1 );
1423 dim[ TopAbs_COMPOUND ] = MeshDim_3D;
1424 dim[ TopAbs_COMPSOLID ] = MeshDim_3D;
1425 dim[ TopAbs_SOLID ] = MeshDim_3D;
1426 dim[ TopAbs_SHELL ] = MeshDim_2D;
1427 dim[ TopAbs_FACE ] = MeshDim_2D;
1428 dim[ TopAbs_WIRE ] = MeshDim_1D;
1429 dim[ TopAbs_EDGE ] = MeshDim_1D;
1430 dim[ TopAbs_VERTEX ] = MeshDim_0D;
1432 return dim[ aShapeType ];
1435 //================================================================================
1437 * \brief Return shape dimension by exploding compounds
1439 //================================================================================
1441 int SMESH_Gen::GetFlatShapeDim(const TopoDS_Shape &aShape)
1444 if ( aShape.ShapeType() == TopAbs_COMPOUND ||
1445 aShape.ShapeType() == TopAbs_COMPSOLID )
1447 TopoDS_Iterator it( aShape );
1448 aShapeDim = GetFlatShapeDim( it.Value() );
1451 aShapeDim = GetShapeDim( aShape );
1455 //=============================================================================
1457 * Generate a new id unique within this Gen
1459 //=============================================================================
1461 int SMESH_Gen::GetANewId()