From 831b40eb011a5f2ad1738518e86fdc6d924f891d Mon Sep 17 00:00:00 2001 From: eap Date: Tue, 13 Dec 2016 20:30:15 +0300 Subject: [PATCH] 23395: EDF 13855 - Crash SALOME when creating a mesh + sort objects in Clipping plane dlg --- doc/salome/examples/filters_ex03.py | 5 +- doc/salome/examples/filters_ex07.py | 6 +- doc/salome/examples/filters_ex09.py | 3 +- src/SMDS/SMDS_Mesh.cxx | 21 ++- src/SMDS/SMDS_Mesh.hxx | 1 + src/SMDS/SMDS_MeshNode.cxx | 139 ++++++------------ src/SMDS/SMDS_MeshNode.hxx | 1 - src/SMESH/SMESH_MesherHelper.cxx | 4 +- src/SMESH/SMESH_Pattern.cxx | 2 +- src/SMESHGUI/SMESHGUI_ClippingDlg.cxx | 24 ++- src/SMESHGUI/SMESHGUI_ReorientFacesDlg.cxx | 6 +- src/SMESHUtils/SMESH_MeshAlgos.cxx | 15 +- src/SMESH_SWIG/smeshBuilder.py | 2 + src/SMESH_SWIG/smesh_algorithm.py | 4 +- src/StdMeshers/StdMeshers_Projection_2D.cxx | 15 +- .../StdMeshers_QuadToTriaAdaptor.cxx | 9 +- src/StdMeshersGUI/StdMeshers_images.ts | 8 + .../StdMeshers_AutomaticLength_i.cxx | 2 - ...StdMeshers_SegmentLengthAroundVertex_i.cxx | 5 - 19 files changed, 126 insertions(+), 146 deletions(-) diff --git a/doc/salome/examples/filters_ex03.py b/doc/salome/examples/filters_ex03.py index c9313bceb..9d5467e6f 100644 --- a/doc/salome/examples/filters_ex03.py +++ b/doc/salome/examples/filters_ex03.py @@ -3,9 +3,6 @@ # create mesh from SMESH_mechanic import * # get faces with warping angle = 2.0e-13 with tolerance 5.0e-14 -criterion = smesh.GetCriterion(SMESH.FACE, SMESH.FT_Warping, SMESH.FT_EqualTo, 2.0e-13) -criterion.Tolerance = 5.0e-14 -filter = smesh.CreateFilterManager().CreateFilter() -filter.SetCriteria([criterion]) +filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Warping, "=", 2.0e-13, Tolerance=5.0e-14) ids = mesh.GetIdsFromFilter(filter) print "Number of faces with warping angle = 2.0e-13 (tolerance 5.0e-14):", len(ids) diff --git a/doc/salome/examples/filters_ex07.py b/doc/salome/examples/filters_ex07.py index 6c42d5217..3afee5e1a 100644 --- a/doc/salome/examples/filters_ex07.py +++ b/doc/salome/examples/filters_ex07.py @@ -3,10 +3,8 @@ # create mesh from SMESH_mechanic import * # get faces with area > 60 and < 90 -criterion1 = smesh.GetCriterion(SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, 60,\ - SMESH.FT_Undefined, SMESH.FT_LogicalAND) +criterion1 = smesh.GetCriterion(SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, 60) criterion2 = smesh.GetCriterion(SMESH.FACE, SMESH.FT_Area, SMESH.FT_LessThan, 90) -filter = smesh.CreateFilterManager().CreateFilter() -filter.SetCriteria([criterion1,criterion2]) +filter = smesh.GetFilterFromCriteria([criterion1,criterion2], SMESH.FT_LogicalAND) ids = mesh.GetIdsFromFilter(filter) print "Number of faces with area in range (60,90):", len(ids) diff --git a/doc/salome/examples/filters_ex09.py b/doc/salome/examples/filters_ex09.py index dd6415930..032d55ddd 100644 --- a/doc/salome/examples/filters_ex09.py +++ b/doc/salome/examples/filters_ex09.py @@ -9,8 +9,7 @@ from salome.smesh import smeshBuilder smesh = smeshBuilder.New(salome.myStudy) # create mesh -face = geompy.MakeFaceHW(100, 100, 1) -geompy.addToStudy( face, "quadrangle" ) +face = geompy.MakeFaceHW(100, 100, 1, theName="quadrangle") mesh = smesh.Mesh(face) mesh.Segment().NumberOfSegments(10) mesh.Triangle().MaxElementArea(25) diff --git a/src/SMDS/SMDS_Mesh.cxx b/src/SMDS/SMDS_Mesh.cxx index d70ff4bcd..13a2aa40f 100644 --- a/src/SMDS/SMDS_Mesh.cxx +++ b/src/SMDS/SMDS_Mesh.cxx @@ -2570,6 +2570,13 @@ int SMDS_Mesh::NbNodes() const return myInfo.NbNodes(); } +/////////////////////////////////////////////////////////////////////////////// +/// Return the number of elements +/////////////////////////////////////////////////////////////////////////////// +int SMDS_Mesh::NbElements() const +{ + return myInfo.NbElements(); +} /////////////////////////////////////////////////////////////////////////////// /// Return the number of 0D elements /////////////////////////////////////////////////////////////////////////////// @@ -3322,14 +3329,14 @@ void SMDS_Mesh::RemoveElement(const SMDS_MeshElement * elem, void SMDS_Mesh::RemoveFreeElement(const SMDS_MeshElement * elem) { int elemId = elem->GetID(); - int vtkId = elem->getVtkId(); + int vtkId = elem->getVtkId(); SMDSAbs_ElementType aType = elem->GetType(); - SMDS_MeshElement* todest = (SMDS_MeshElement*)(elem); - if (aType == SMDSAbs_Node) { + SMDS_MeshElement* todest = (SMDS_MeshElement*)(elem); + if ( aType == SMDSAbs_Node ) + { // only free node can be removed by this method const SMDS_MeshNode* n = static_cast(todest); - SMDS_ElemIteratorPtr itFe = n->GetInverseElementIterator(); - if (!itFe->more()) { // free node + if ( n->NbInverseElements() == 0 ) { // free node myNodes[elemId] = 0; myInfo.myNbNodes--; ((SMDS_MeshNode*) n)->SetPosition(SMDS_SpacePosition::originSpacePosition()); @@ -3337,7 +3344,9 @@ void SMDS_Mesh::RemoveFreeElement(const SMDS_MeshElement * elem) myNodePool->destroy(static_cast(todest)); myNodeIDFactory->ReleaseID(elemId, vtkId); } - } else { + } + else + { if (hasConstructionEdges() || hasConstructionFaces()) // this methods is only for meshes without descendants return; diff --git a/src/SMDS/SMDS_Mesh.hxx b/src/SMDS/SMDS_Mesh.hxx index 459befaa9..814fe9bac 100644 --- a/src/SMDS/SMDS_Mesh.hxx +++ b/src/SMDS/SMDS_Mesh.hxx @@ -705,6 +705,7 @@ public: const SMDS_MeshInfo& GetMeshInfo() const { return myInfo; } virtual int NbNodes() const; + virtual int NbElements() const; virtual int Nb0DElements() const; virtual int NbBalls() const; virtual int NbEdges() const; diff --git a/src/SMDS/SMDS_MeshNode.cxx b/src/SMDS/SMDS_MeshNode.cxx index 1f49f82dc..553d568f0 100644 --- a/src/SMDS/SMDS_MeshNode.cxx +++ b/src/SMDS/SMDS_MeshNode.cxx @@ -143,22 +143,29 @@ public: SMDS_MeshNode_MyInvIterator(SMDS_Mesh *mesh, vtkIdType* cells, int ncells, SMDSAbs_ElementType type) : myMesh(mesh), myCells(cells), myNcells(ncells), myType(type), iter(0) { - cellList.reserve( ncells ); - if (type == SMDSAbs_All) - cellList.assign( cells, cells + ncells ); - else - for (int i = 0; i < ncells; i++) + if ( ncells ) + { + cellList.reserve( ncells ); + if (type == SMDSAbs_All) + { + cellList.assign( cells, cells + ncells ); + } + else { - int vtkId = cells[i]; - int smdsId = myMesh->fromVtkToSmds(vtkId); - const SMDS_MeshElement* elem = myMesh->FindElement(smdsId); - if (elem->GetType() == type) + for (int i = 0; i < ncells; i++) { - cellList.push_back(vtkId); + int vtkId = cells[i]; + int smdsId = myMesh->fromVtkToSmds(vtkId); + const SMDS_MeshElement* elem = myMesh->FindElement(smdsId); + if (elem->GetType() == type) + { + cellList.push_back(vtkId); + } } + myCells = cellList.empty() ? 0 : &cellList[0]; + myNcells = cellList.size(); } - myCells = cellList.empty() ? 0 : &cellList[0]; - myNcells = cellList.size(); + } } bool more() @@ -183,64 +190,23 @@ public: SMDS_ElemIteratorPtr SMDS_MeshNode::GetInverseElementIterator(SMDSAbs_ElementType type) const { - vtkCellLinks::Link l = SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetLinks()->GetLink(myVtkID); - return SMDS_ElemIteratorPtr(new SMDS_MeshNode_MyInvIterator(SMDS_Mesh::_meshList[myMeshId], l.cells, l.ncells, type)); -} - -// Same as GetInverseElementIterator but the created iterator only returns -// wanted type elements. -class SMDS_MeshNode_MyIterator:public SMDS_ElemIterator -{ -private: - SMDS_Mesh* myMesh; - vtkIdType* myCells; - int myNcells; - SMDSAbs_ElementType myType; - int iter; - vector myFiltCells; - -public: - SMDS_MeshNode_MyIterator(SMDS_Mesh *mesh, - vtkIdType* cells, - int ncells, - SMDSAbs_ElementType type): - myMesh(mesh), myCells(cells), myNcells(ncells), myType(type), iter(0) + if ( SMDS_Mesh::_meshList[myMeshId]->NbElements() > 0 ) // avoid building links { - for (; iterfromVtkToSmds(vtkId); - const SMDS_MeshElement* elem = myMesh->FindElement(smdsId); - if (elem->GetType() == type) - myFiltCells.push_back((SMDS_MeshElement*)elem); - } - myNcells = myFiltCells.size(); - iter = 0; - } - - bool more() - { - return (iter< myNcells); + vtkCellLinks::Link& l = SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetLinks()->GetLink(myVtkID); + return SMDS_ElemIteratorPtr(new SMDS_MeshNode_MyInvIterator(SMDS_Mesh::_meshList[myMeshId], l.cells, l.ncells, type)); } - - const SMDS_MeshElement* next() + else { - const SMDS_MeshElement* elem = myFiltCells[iter]; - iter++; - return elem; + return SMDS_ElemIteratorPtr(new SMDS_MeshNode_MyInvIterator(SMDS_Mesh::_meshList[myMeshId], 0, 0, type)); } -}; +} -SMDS_ElemIteratorPtr SMDS_MeshNode:: -elementsIterator(SMDSAbs_ElementType type) const +SMDS_ElemIteratorPtr SMDS_MeshNode::elementsIterator(SMDSAbs_ElementType type) const { - if(type==SMDSAbs_Node) - return SMDS_MeshElement::elementsIterator(SMDSAbs_Node); + if ( type == SMDSAbs_Node ) + return SMDS_MeshElement::elementsIterator( SMDSAbs_Node ); else - { - vtkCellLinks::Link l = SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetLinks()->GetLink(myVtkID); - return SMDS_ElemIteratorPtr(new SMDS_MeshNode_MyIterator(SMDS_Mesh::_meshList[myMeshId], l.cells, l.ncells, type)); - } + return GetInverseElementIterator( type ); } int SMDS_MeshNode::NbNodes() const @@ -275,12 +241,14 @@ double SMDS_MeshNode::Z() const /*! * \brief thread safe getting coords */ +//================================================================================ + void SMDS_MeshNode::GetXYZ(double xyz[3]) const { return SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetPoint(myVtkID,xyz); } -//* resize the vtkPoints structure every SMDS_Mesh::chunkSize points +//================================================================================ void SMDS_MeshNode::setXYZ(double x, double y, double z) { SMDS_Mesh *mesh = SMDS_Mesh::_meshList[myMeshId]; @@ -321,12 +289,6 @@ void SMDS_MeshNode::ClearInverseElements() SMDS_Mesh::_meshList[myMeshId]->getGrid()->ResizeCellList(myVtkID, 0); } -bool SMDS_MeshNode::emptyInverseElements() -{ - vtkCellLinks::Link l = SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetLinks()->GetLink(myVtkID); - return (l.ncells == 0); -} - //================================================================================ /*! * \brief Count inverse elements of given type @@ -335,35 +297,20 @@ bool SMDS_MeshNode::emptyInverseElements() int SMDS_MeshNode::NbInverseElements(SMDSAbs_ElementType type) const { - vtkCellLinks::Link l = SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetLinks()->GetLink(myVtkID); - - if ( type == SMDSAbs_All ) - return l.ncells; - int nb = 0; - SMDS_Mesh *mesh = SMDS_Mesh::_meshList[myMeshId]; - for (int i=0; iNbElements() > 0 ) // avoid building links { - const SMDS_MeshElement* elem = mesh->FindElement(mesh->fromVtkToSmds(l.cells[i])); - if (elem->GetType() == type) - nb++; - } - return nb; -} + vtkCellLinks::Link& l = SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetLinks()->GetLink(myVtkID); -/////////////////////////////////////////////////////////////////////////////// -/// To be used with STL set -/////////////////////////////////////////////////////////////////////////////// -bool operator<(const SMDS_MeshNode& e1, const SMDS_MeshNode& e2) -{ - return e1.getVtkId()FindElement( mesh->fromVtkToSmds( l.cells[i] )); + nb += ( elem->GetType() == type ); } - else return false;*/ + } + return nb; } - diff --git a/src/SMDS/SMDS_MeshNode.hxx b/src/SMDS/SMDS_MeshNode.hxx index a61e673f3..43dc9c7f2 100644 --- a/src/SMDS/SMDS_MeshNode.hxx +++ b/src/SMDS/SMDS_MeshNode.hxx @@ -69,7 +69,6 @@ protected: void AddInverseElement(const SMDS_MeshElement * ME); void RemoveInverseElement(const SMDS_MeshElement * parent); void ClearInverseElements(); - bool emptyInverseElements(); SMDS_ElemIteratorPtr elementsIterator(SMDSAbs_ElementType type) const; diff --git a/src/SMESH/SMESH_MesherHelper.cxx b/src/SMESH/SMESH_MesherHelper.cxx index 67df8daeb..c6c34ed47 100644 --- a/src/SMESH/SMESH_MesherHelper.cxx +++ b/src/SMESH/SMESH_MesherHelper.cxx @@ -4635,7 +4635,7 @@ namespace { // Structures used by FixQuadraticElements() SMDS_ElemIteratorPtr faceIter( new TIterOnIter( faceIterVec )); // a seacher to check if a volume is close to a concave face - std::auto_ptr< SMESH_ElementSearcher > faceSearcher + SMESHUtils::Deleter< SMESH_ElementSearcher > faceSearcher ( SMESH_MeshAlgos::GetElementSearcher( *theHelper.GetMeshDS(), faceIter )); // classifier @@ -4737,7 +4737,7 @@ namespace { // Structures used by FixQuadraticElements() gp_Pnt pMedium = SMESH_TNodeXYZ( linkIt->second ); double hMedium = faceNorm * gp_Vec( pOnFace0, pMedium ).XYZ(); double hVol = faceNorm * gp_Vec( pOnFace0, pInSolid ).XYZ(); - isDistorted = ( Abs( hMedium ) > Abs( hVol * 0.5 )); + isDistorted = ( Abs( hMedium ) > Abs( hVol * 0.75 )); } } } diff --git a/src/SMESH/SMESH_Pattern.cxx b/src/SMESH/SMESH_Pattern.cxx index bfcaeab50..6f3c1b076 100644 --- a/src/SMESH/SMESH_Pattern.cxx +++ b/src/SMESH/SMESH_Pattern.cxx @@ -794,7 +794,7 @@ bool SMESH_Pattern::Load (SMESH_Mesh* theMesh, double u = epos->GetUParameter(); paramNodeMap.insert( make_pair( u, node )); } - if ((int) paramNodeMap.size() != eSubMesh->NbNodes() ) { + if ((int) paramNodeMap.size() != eSubMesh->NbNodes() - nbMeduimNodes ) { // wrong U on edge, project Extrema_ExtPC proj; BRepAdaptor_Curve aCurve( edge ); diff --git a/src/SMESHGUI/SMESHGUI_ClippingDlg.cxx b/src/SMESHGUI/SMESHGUI_ClippingDlg.cxx index 09c3a3942..d7d455b6d 100644 --- a/src/SMESHGUI/SMESHGUI_ClippingDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_ClippingDlg.cxx @@ -1086,6 +1086,8 @@ void SMESHGUI_ClippingDlg::updateActorList() std::for_each( myPlanes.begin(),myPlanes.end(), TSetVisibility( PreviewCheckBox->isChecked() ) ); aPlaneData.Plane.GetPointer()->myActor->SetVisibility( false ); + std::map< std::string, QListWidgetItem* > itemMap; // used to sort items by entry + VTK::ActorCollectionCopy aCopy( myViewWindow->getRenderer()->GetActors() ); vtkActorCollection* anAllActors = aCopy.GetActors(); anAllActors->InitTraversal(); @@ -1111,13 +1113,20 @@ void SMESHGUI_ClippingDlg::updateActorList() if ( !aFatherName.isEmpty() ) aName = aFatherName + " / " + aName; aName += QString(" (%1)").arg( aSObj->GetID().c_str() ); - QListWidgetItem* anItem = new ActorItem( anActor, aName, ActorList ); + QListWidgetItem* anItem = new ActorItem( anActor, aName, 0 ); anItem->setCheckState( anIsChecked ? Qt::Checked : Qt::Unchecked ); - updateActorItem( anItem, true, false ); + itemMap.insert( std::make_pair( aSObj->GetID(), anItem )); } } } } + std::map< std::string, QListWidgetItem* >::iterator s2i = itemMap.begin(); + for ( ; s2i != itemMap.end(); ++s2i ) + { + QListWidgetItem* anItem = s2i->second; + ActorList->addItem( anItem ); + } + updateActorItem( 0, true, false ); } /*! @@ -1258,16 +1267,19 @@ void SMESHGUI_ClippingDlg::ClickOnNew() SMESH::OrientedPlane* aPlane = SMESH::OrientedPlane::New(myViewWindow); SMESH::TPlane aTPlane(aPlane); aPlane->PlaneMode = CurrentMode; - SMESH::TActorList anActorList; + SMESH::TActorList anActorList, aVisibleActorList; VTK::ActorCollectionCopy aCopy( myViewWindow->getRenderer()->GetActors() ); vtkActorCollection* anAllActors = aCopy.GetActors(); anAllActors->InitTraversal(); while( vtkActor* aVTKActor = anAllActors->GetNextActor() ) if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( aVTKActor ) ) + { anActorList.push_back( anActor ); - - SMESH::TPlaneData aPlaneData(aTPlane, anActorList); - + if ( anActor->GetVisibility() ) + aVisibleActorList.push_back( anActor ); + } + SMESH::TPlaneData aPlaneData(aTPlane, + aVisibleActorList.empty() ? anActorList : aVisibleActorList); myPlanes.push_back(aPlaneData); diff --git a/src/SMESHGUI/SMESHGUI_ReorientFacesDlg.cxx b/src/SMESHGUI/SMESHGUI_ReorientFacesDlg.cxx index 9d4495083..cb3828246 100644 --- a/src/SMESHGUI/SMESHGUI_ReorientFacesDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_ReorientFacesDlg.cxx @@ -203,9 +203,9 @@ QWidget* SMESHGUI_ReorientFacesDlg::createMainFrame (QWidget* theParent) myDY->SetValue(0); myDZ->SetValue(0); - myDX->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision"); - myDY->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision"); - myDZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision"); + myDX->RangeStepAndValidator(COORD_MIN, COORD_MAX, 1.0, "length_precision"); + myDY->RangeStepAndValidator(COORD_MIN, COORD_MAX, 1.0, "length_precision"); + myDZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, 1.0, "length_precision"); width = Max( aFaceBut->fontMetrics().width( tr("SMESH_X")), aFaceBut->fontMetrics().width( tr("SMESH_DX"))); diff --git a/src/SMESHUtils/SMESH_MeshAlgos.cxx b/src/SMESHUtils/SMESH_MeshAlgos.cxx index 6670e509e..a26695858 100644 --- a/src/SMESHUtils/SMESH_MeshAlgos.cxx +++ b/src/SMESHUtils/SMESH_MeshAlgos.cxx @@ -1163,8 +1163,8 @@ bool SMESH_MeshAlgos::IsOut( const SMDS_MeshElement* element, const gp_Pnt& poin gp_Vec edge2( xyz[i+1], xyz[(i+2)%nbNodes] ); faceNorm += edge1 ^ edge2; } - double normSize = faceNorm.Magnitude(); - if ( normSize <= tol ) + double fNormSize = faceNorm.Magnitude(); + if ( fNormSize <= tol ) { // degenerated face: point is out if it is out of all face edges for ( i = 0; i < nbNodes; ++i ) @@ -1175,7 +1175,7 @@ bool SMESH_MeshAlgos::IsOut( const SMDS_MeshElement* element, const gp_Pnt& poin } return true; } - faceNorm /= normSize; + faceNorm /= fNormSize; // check if the point lays on face plane gp_Vec n2p( xyz[0], point ); @@ -1204,9 +1204,10 @@ bool SMESH_MeshAlgos::IsOut( const SMDS_MeshElement* element, const gp_Pnt& poin // to find intersections of the ray with the boundary. gp_Vec ray = n2p; gp_Vec plnNorm = ray ^ faceNorm; - normSize = plnNorm.Magnitude(); - if ( normSize <= tol ) return false; // point coincides with the first node - plnNorm /= normSize; + double n2pSize = plnNorm.Magnitude(); + if ( n2pSize <= tol ) return false; // point coincides with the first node + if ( n2pSize * n2pSize > fNormSize * 100 ) return true; // point is very far + plnNorm /= n2pSize; // for each node of the face, compute its signed distance to the cutting plane vector dist( nbNodes + 1); for ( i = 0; i < nbNodes; ++i ) @@ -1252,7 +1253,7 @@ bool SMESH_MeshAlgos::IsOut( const SMDS_MeshElement* element, const gp_Pnt& poin if ( rClosest > 0. && rClosest < 1. ) // not node intersection return out; - // ray pass through a face node; analyze transition through an adjacent edge + // the ray passes through a face node; analyze transition through an adjacent edge gp_Pnt p1 = xyz[ (rClosest == 0.) ? ((iClosest+nbNodes-1) % nbNodes) : (iClosest+1) ]; gp_Pnt p2 = xyz[ (rClosest == 0.) ? iClosest : ((iClosest+2) % nbNodes) ]; gp_Vec edgeAdjacent( p1, p2 ); diff --git a/src/SMESH_SWIG/smeshBuilder.py b/src/SMESH_SWIG/smeshBuilder.py index e779c7a7a..9a7b7611b 100644 --- a/src/SMESH_SWIG/smeshBuilder.py +++ b/src/SMESH_SWIG/smeshBuilder.py @@ -3606,6 +3606,7 @@ class Mesh: # 1 - the medium node lies at the middle of the line segments connecting two nodes of a mesh element # @param theSubMesh a group or a sub-mesh to convert; WARNING: in this case the mesh can become not conformal # @param theToBiQuad If True, converts the mesh to bi-quadratic + # @return SMESH.ComputeError which can hold a warning # @ingroup l2_modif_tofromqu def ConvertToQuadratic(self, theForce3d=False, theSubMesh=None, theToBiQuad=False): if isinstance( theSubMesh, Mesh ): @@ -3620,6 +3621,7 @@ class Mesh: error = self.editor.GetLastError() if error and error.comment: print error.comment + return error ## Converts the mesh from quadratic to ordinary, # deletes old quadratic elements, \n replacing diff --git a/src/SMESH_SWIG/smesh_algorithm.py b/src/SMESH_SWIG/smesh_algorithm.py index 3a2939151..c68606886 100644 --- a/src/SMESH_SWIG/smesh_algorithm.py +++ b/src/SMESH_SWIG/smesh_algorithm.py @@ -183,7 +183,7 @@ class Mesh_Algorithm: ## Private method. def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"): if geom is None and mesh.mesh.HasShapeToMesh(): - raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape" + raise RuntimeError, "Attemp to create " + hypo + " algorithm on None shape" algo = self.FindAlgorithm(hypo, mesh.smeshpyD) if algo is None: algo = mesh.smeshpyD.CreateHypothesis(hypo, so) @@ -195,7 +195,7 @@ class Mesh_Algorithm: def Assign(self, algo, mesh, geom): from salome.smesh.smeshBuilder import AssureGeomPublished, TreatHypoStatus, GetName if geom is None and mesh.mesh.HasShapeToMesh(): - raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape" + raise RuntimeError, "Attemp to create " + algo + " algorithm on None shape" self.mesh = mesh if not geom or geom.IsSame( mesh.geom ): self.geom = mesh.geom diff --git a/src/StdMeshers/StdMeshers_Projection_2D.cxx b/src/StdMeshers/StdMeshers_Projection_2D.cxx index 2888a362c..10f862696 100644 --- a/src/StdMeshers/StdMeshers_Projection_2D.cxx +++ b/src/StdMeshers/StdMeshers_Projection_2D.cxx @@ -72,6 +72,10 @@ using namespace std; #define RETURN_BAD_RESULT(msg) { MESSAGE(")-: Error: " << msg); return false; } +#ifdef _DEBUG_ +// enable printing algo + projection shapes while meshing +//#define PRINT_WHO_COMPUTE_WHAT +#endif namespace TAssocTool = StdMeshers_ProjectionUtils; //typedef StdMeshers_ProjectionUtils TAssocTool; @@ -436,7 +440,11 @@ namespace { if (( err && !err->IsOK() ) || ( srcWires.empty() )) return err; - +#ifdef PRINT_WHO_COMPUTE_WHAT + cout << "Projection_2D" << " F " + << tgtMesh->GetMeshDS()->ShapeToIndex( tgtFace ) << " <- " + << srcMesh->GetMeshDS()->ShapeToIndex( srcFace ) << endl; +#endif SMESH_MesherHelper srcHelper( *srcMesh ); srcHelper.SetSubShape( srcFace ); @@ -492,6 +500,11 @@ namespace { for ( int iE = 0; iE < srcWire->NbEdges(); ++iE ) { +#ifdef PRINT_WHO_COMPUTE_WHAT + if ( tgtMesh->GetSubMesh( tgtWire->Edge(iE) )->IsEmpty() ) + cout << "Projection_2D" << " E " + << tgtWire->EdgeID(iE) << " <- " << srcWire->EdgeID(iE) << endl; +#endif if ( srcMesh->GetSubMesh( srcWire->Edge(iE) )->IsEmpty() || tgtMesh->GetSubMesh( tgtWire->Edge(iE) )->IsEmpty() ) { diff --git a/src/StdMeshers/StdMeshers_QuadToTriaAdaptor.cxx b/src/StdMeshers/StdMeshers_QuadToTriaAdaptor.cxx index 9259d2e1d..2e4ea50b8 100644 --- a/src/StdMeshers/StdMeshers_QuadToTriaAdaptor.cxx +++ b/src/StdMeshers/StdMeshers_QuadToTriaAdaptor.cxx @@ -485,9 +485,6 @@ static bool HasIntersection3(const gp_Pnt& P, const gp_Pnt& PC, gp_Pnt& Pint, gp_XYZ vert1 = P2.XYZ(); gp_XYZ vert2 = P3.XYZ(); - /* calculate distance from vert0 to ray origin */ - gp_XYZ tvec = orig - vert0; - gp_XYZ edge1 = vert1 - vert0; gp_XYZ edge2 = vert2 - vert0; @@ -497,9 +494,13 @@ static bool HasIntersection3(const gp_Pnt& P, const gp_Pnt& PC, gp_Pnt& Pint, /* if determinant is near zero, ray lies in plane of triangle */ double det = edge1 * pvec; - if (det > -EPSILON && det < EPSILON) + const double ANGL_EPSILON = 1e-12; + if ( det > -ANGL_EPSILON && det < ANGL_EPSILON ) return false; + /* calculate distance from vert0 to ray origin */ + gp_XYZ tvec = orig - vert0; + /* calculate U parameter and test bounds */ double u = ( tvec * pvec ) / det; //if (u < 0.0 || u > 1.0) diff --git a/src/StdMeshersGUI/StdMeshers_images.ts b/src/StdMeshersGUI/StdMeshers_images.ts index 0f56903ef..4bfcece28 100644 --- a/src/StdMeshersGUI/StdMeshers_images.ts +++ b/src/StdMeshersGUI/StdMeshers_images.ts @@ -135,6 +135,10 @@ ICON_SMESH_TREE_ALGO_Projection_2D mesh_tree_algo_projection_2d.png + + ICON_SMESH_TREE_ALGO_Projection_1D2D + mesh_tree_algo_projection_2d.png + ICON_SMESH_TREE_ALGO_Projection_3D mesh_tree_hypo_projection_3d.png @@ -251,6 +255,10 @@ ICON_SMESH_TREE_HYPO_QuadranglePreference mesh_tree_algo_quad.png + + ICON_SMESH_TREE_HYPO_QuadrangleParams + mesh_tree_algo_quad.png + ICON_SMESH_TREE_HYPO_TrianglePreference mesh_tree_algo_mefisto.png diff --git a/src/StdMeshers_I/StdMeshers_AutomaticLength_i.cxx b/src/StdMeshers_I/StdMeshers_AutomaticLength_i.cxx index 580ccb653..d532e3935 100644 --- a/src/StdMeshers_I/StdMeshers_AutomaticLength_i.cxx +++ b/src/StdMeshers_I/StdMeshers_AutomaticLength_i.cxx @@ -52,7 +52,6 @@ StdMeshers_AutomaticLength_i::StdMeshers_AutomaticLength_i( PortableServer::POA_ : SALOME::GenericObj_i( thePOA ), SMESH_Hypothesis_i( thePOA ) { - MESSAGE( "StdMeshers_AutomaticLength_i::StdMeshers_AutomaticLength_i" ); myBaseImpl = new ::StdMeshers_AutomaticLength( theGenImpl->GetANewId(), theStudyId, theGenImpl ); @@ -68,7 +67,6 @@ StdMeshers_AutomaticLength_i::StdMeshers_AutomaticLength_i( PortableServer::POA_ StdMeshers_AutomaticLength_i::~StdMeshers_AutomaticLength_i() { - MESSAGE( "StdMeshers_AutomaticLength_i::~StdMeshers_AutomaticLength_i" ); } //============================================================================= diff --git a/src/StdMeshers_I/StdMeshers_SegmentLengthAroundVertex_i.cxx b/src/StdMeshers_I/StdMeshers_SegmentLengthAroundVertex_i.cxx index 605395f2b..5801115bb 100644 --- a/src/StdMeshers_I/StdMeshers_SegmentLengthAroundVertex_i.cxx +++ b/src/StdMeshers_I/StdMeshers_SegmentLengthAroundVertex_i.cxx @@ -50,7 +50,6 @@ StdMeshers_SegmentLengthAroundVertex_i::StdMeshers_SegmentLengthAroundVertex_i : SALOME::GenericObj_i( thePOA ), SMESH_Hypothesis_i( thePOA ) { - MESSAGE( "StdMeshers_SegmentLengthAroundVertex_i::StdMeshers_SegmentLengthAroundVertex_i" ); myBaseImpl = new ::StdMeshers_SegmentLengthAroundVertex( theGenImpl->GetANewId(), theStudyId, theGenImpl ); @@ -66,7 +65,6 @@ StdMeshers_SegmentLengthAroundVertex_i::StdMeshers_SegmentLengthAroundVertex_i StdMeshers_SegmentLengthAroundVertex_i::~StdMeshers_SegmentLengthAroundVertex_i() { - MESSAGE( "StdMeshers_SegmentLengthAroundVertex_i::~StdMeshers_SegmentLengthAroundVertex_i" ); } //============================================================================= @@ -80,7 +78,6 @@ StdMeshers_SegmentLengthAroundVertex_i::~StdMeshers_SegmentLengthAroundVertex_i( void StdMeshers_SegmentLengthAroundVertex_i::SetLength( CORBA::Double theLength ) throw ( SALOME::SALOME_Exception ) { - MESSAGE( "StdMeshers_SegmentLengthAroundVertex_i::SetLength" ); ASSERT( myBaseImpl ); try { this->GetImpl()->SetLength( theLength ); @@ -103,7 +100,6 @@ void StdMeshers_SegmentLengthAroundVertex_i::SetLength( CORBA::Double theLength CORBA::Double StdMeshers_SegmentLengthAroundVertex_i::GetLength() { - MESSAGE( "StdMeshers_SegmentLengthAroundVertex_i::GetLength" ); ASSERT( myBaseImpl ); return this->GetImpl()->GetLength(); } @@ -118,7 +114,6 @@ CORBA::Double StdMeshers_SegmentLengthAroundVertex_i::GetLength() ::StdMeshers_SegmentLengthAroundVertex* StdMeshers_SegmentLengthAroundVertex_i::GetImpl() { - MESSAGE( "StdMeshers_SegmentLengthAroundVertex_i::GetImpl" ); return ( ::StdMeshers_SegmentLengthAroundVertex* )myBaseImpl; } -- 2.39.2