X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FStdMeshers%2FStdMeshers_Prism_3D.cxx;h=5734c02e99354a81c2242fb804dc4edc558be3b0;hp=d60f1397e9d3ee62ab209b2c9d57cd49b1700628;hb=8a1ff9ba77b7b72b64b08134f941b56aac80ff55;hpb=c98d9fcd7f02c1f1f5c24dd3e709ed75228d66c4 diff --git a/src/StdMeshers/StdMeshers_Prism_3D.cxx b/src/StdMeshers/StdMeshers_Prism_3D.cxx index d60f1397e..5734c02e9 100644 --- a/src/StdMeshers/StdMeshers_Prism_3D.cxx +++ b/src/StdMeshers/StdMeshers_Prism_3D.cxx @@ -162,6 +162,12 @@ namespace { { return _src2tgtNodes; } + void SetEventListener( SMESH_subMesh* tgtSubMesh ) + { + NSProjUtils::SetEventListener( tgtSubMesh, + _sourceHypo->GetSourceFace(), + _sourceHypo->GetSourceMesh() ); + } }; //======================================================================= /*! @@ -561,7 +567,9 @@ StdMeshers_Prism_3D::StdMeshers_Prism_3D(int hypId, int studyId, SMESH_Gen* gen) //================================================================================ StdMeshers_Prism_3D::~StdMeshers_Prism_3D() -{} +{ + pointsToPython( std::vector() ); // avoid warning: pointsToPython defined but not used +} //======================================================================= //function : CheckHypothesis @@ -2263,29 +2271,39 @@ bool StdMeshers_Prism_3D::projectBottomToTop( const gp_Trsf & bottom Handle(Geom_Surface) surface = BRep_Tool::Surface( topFace, loc ); bool isPlanar = GeomLib_IsPlanarSurface( surface ).IsPlanar(); - bool isFixed = false; set fixedNodes; - for ( int iAttemp = 0; !isFixed && iAttemp < 10; ++iAttemp ) - { - TIDSortedElemSet faces; - for ( faceIt = topSMDS->GetElements(); faceIt->more(); ) - faces.insert( faces.end(), faceIt->next() ); + TIDSortedElemSet faces; + for ( faceIt = topSMDS->GetElements(); faceIt->more(); ) + faces.insert( faces.end(), faceIt->next() ); + bool isOk = false; + for ( int isCentroidal = 0; isCentroidal < 2; ++isCentroidal ) + { SMESH_MeshEditor::SmoothMethod algo = - iAttemp ? SMESH_MeshEditor::CENTROIDAL : SMESH_MeshEditor::LAPLACIAN; + isCentroidal ? SMESH_MeshEditor::CENTROIDAL : SMESH_MeshEditor::LAPLACIAN; + + int nbAttempts = isCentroidal ? 1 : 10; + for ( int iAttemp = 0; iAttemp < nbAttempts; ++iAttemp ) + { + TIDSortedElemSet workFaces = faces; - // smoothing - editor.Smooth( faces, fixedNodes, algo, /*nbIterations=*/ 10, - /*theTgtAspectRatio=*/1.0, /*the2D=*/!isPlanar); + // smoothing + editor.Smooth( workFaces, fixedNodes, algo, /*nbIterations=*/ 10, + /*theTgtAspectRatio=*/1.0, /*the2D=*/!isPlanar); - isFixed = !topHelper.IsDistorted2D( topSM, /*checkUV=*/true ); + if (( isOk = !topHelper.IsDistorted2D( topSM, /*checkUV=*/true )) && + ( !isCentroidal )) + break; + } } - if ( !isFixed ) + if ( !isOk ) return toSM( error( TCom("Projection from face #") << botSM->GetId() << " to face #" << topSM->GetId() << " failed: inverted elements created")); } + TProjction2dAlgo::instance( this )->SetEventListener( topSM ); + return true; } @@ -2424,6 +2442,8 @@ bool StdMeshers_Prism_3D::project2dMesh(const TopoDS_Face& theSrcFace, tgtSM->ComputeStateEngine ( SMESH_subMesh::CHECK_COMPUTE_STATE ); tgtSM->ComputeSubMeshStateEngine( SMESH_subMesh::CHECK_COMPUTE_STATE ); + projector2D->SetEventListener( tgtSM ); + return ok; } @@ -2639,19 +2659,19 @@ namespace // utils used by StdMeshers_Prism_3D::IsApplicable() /*! * \brief Return number of faces sharing given edges */ - int nbAdjacentFaces( const std::vector< EdgeWithNeighbors >& edges, - const TopTools_IndexedDataMapOfShapeListOfShape& facesOfEdge ) - { - TopTools_MapOfShape adjFaces; - - for ( size_t i = 0; i < edges.size(); ++i ) - { - TopTools_ListIteratorOfListOfShape faceIt( facesOfEdge.FindFromKey( edges[i]._edge )); - for ( ; faceIt.More(); faceIt.Next() ) - adjFaces.Add( faceIt.Value() ); - } - return adjFaces.Extent(); - } + // int nbAdjacentFaces( const std::vector< EdgeWithNeighbors >& edges, + // const TopTools_IndexedDataMapOfShapeListOfShape& facesOfEdge ) + // { + // TopTools_MapOfShape adjFaces; + + // for ( size_t i = 0; i < edges.size(); ++i ) + // { + // TopTools_ListIteratorOfListOfShape faceIt( facesOfEdge.FindFromKey( edges[i]._edge )); + // for ( ; faceIt.More(); faceIt.Next() ) + // adjFaces.Add( faceIt.Value() ); + // } + // return adjFaces.Extent(); + // } } //================================================================================ @@ -3016,7 +3036,6 @@ bool StdMeshers_Prism_3D::initPrism(Prism_3D::TPrismTopo& thePrism, list< SMESH_subMesh* > meshedSubMesh; int nbFaces = 0; // - SMESH_subMesh* anyFaceSM = 0; SMESH_subMeshIteratorPtr smIt = mainSubMesh->getDependsOnIterator(false,true); while ( smIt->more() ) { @@ -3025,7 +3044,6 @@ bool StdMeshers_Prism_3D::initPrism(Prism_3D::TPrismTopo& thePrism, if ( face.ShapeType() > TopAbs_FACE ) break; else if ( face.ShapeType() < TopAbs_FACE ) continue; nbFaces++; - anyFaceSM = sm; // is quadrangle FACE? list< TopoDS_Edge > orderedEdges; @@ -3155,7 +3173,7 @@ bool StdMeshers_Prism_3D::initPrism(Prism_3D::TPrismTopo& thePrism, // find vertex 000 - the one with smallest coordinates (for easy DEBUG :-) TopoDS_Vertex V000; - double minVal = DBL_MAX, minX, val; + double minVal = DBL_MAX, minX = 0, val; for ( TopExp_Explorer exp( botSM->GetSubShape(), TopAbs_VERTEX ); exp.More(); exp.Next() ) {