23395: EDF 13855 - Crash SALOME when creating a mesh

+ sort objects in Clipping plane dlg
This commit is contained in:
eap 2016-12-13 20:30:15 +03:00
parent e64112ab22
commit 831b40eb01
19 changed files with 131 additions and 151 deletions

View File

@ -3,9 +3,6 @@
# create mesh # create mesh
from SMESH_mechanic import * from SMESH_mechanic import *
# get faces with warping angle = 2.0e-13 with tolerance 5.0e-14 # 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) filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Warping, "=", 2.0e-13, Tolerance=5.0e-14)
criterion.Tolerance = 5.0e-14
filter = smesh.CreateFilterManager().CreateFilter()
filter.SetCriteria([criterion])
ids = mesh.GetIdsFromFilter(filter) ids = mesh.GetIdsFromFilter(filter)
print "Number of faces with warping angle = 2.0e-13 (tolerance 5.0e-14):", len(ids) print "Number of faces with warping angle = 2.0e-13 (tolerance 5.0e-14):", len(ids)

View File

@ -3,10 +3,8 @@
# create mesh # create mesh
from SMESH_mechanic import * from SMESH_mechanic import *
# get faces with area > 60 and < 90 # get faces with area > 60 and < 90
criterion1 = smesh.GetCriterion(SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, 60,\ criterion1 = smesh.GetCriterion(SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, 60)
SMESH.FT_Undefined, SMESH.FT_LogicalAND)
criterion2 = smesh.GetCriterion(SMESH.FACE, SMESH.FT_Area, SMESH.FT_LessThan, 90) criterion2 = smesh.GetCriterion(SMESH.FACE, SMESH.FT_Area, SMESH.FT_LessThan, 90)
filter = smesh.CreateFilterManager().CreateFilter() filter = smesh.GetFilterFromCriteria([criterion1,criterion2], SMESH.FT_LogicalAND)
filter.SetCriteria([criterion1,criterion2])
ids = mesh.GetIdsFromFilter(filter) ids = mesh.GetIdsFromFilter(filter)
print "Number of faces with area in range (60,90):", len(ids) print "Number of faces with area in range (60,90):", len(ids)

View File

@ -9,8 +9,7 @@ from salome.smesh import smeshBuilder
smesh = smeshBuilder.New(salome.myStudy) smesh = smeshBuilder.New(salome.myStudy)
# create mesh # create mesh
face = geompy.MakeFaceHW(100, 100, 1) face = geompy.MakeFaceHW(100, 100, 1, theName="quadrangle")
geompy.addToStudy( face, "quadrangle" )
mesh = smesh.Mesh(face) mesh = smesh.Mesh(face)
mesh.Segment().NumberOfSegments(10) mesh.Segment().NumberOfSegments(10)
mesh.Triangle().MaxElementArea(25) mesh.Triangle().MaxElementArea(25)

View File

@ -2570,6 +2570,13 @@ int SMDS_Mesh::NbNodes() const
return myInfo.NbNodes(); return myInfo.NbNodes();
} }
///////////////////////////////////////////////////////////////////////////////
/// Return the number of elements
///////////////////////////////////////////////////////////////////////////////
int SMDS_Mesh::NbElements() const
{
return myInfo.NbElements();
}
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
/// Return the number of 0D elements /// 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) void SMDS_Mesh::RemoveFreeElement(const SMDS_MeshElement * elem)
{ {
int elemId = elem->GetID(); int elemId = elem->GetID();
int vtkId = elem->getVtkId(); int vtkId = elem->getVtkId();
SMDSAbs_ElementType aType = elem->GetType(); SMDSAbs_ElementType aType = elem->GetType();
SMDS_MeshElement* todest = (SMDS_MeshElement*)(elem); SMDS_MeshElement* todest = (SMDS_MeshElement*)(elem);
if (aType == SMDSAbs_Node) { if ( aType == SMDSAbs_Node )
{
// only free node can be removed by this method // only free node can be removed by this method
const SMDS_MeshNode* n = static_cast<SMDS_MeshNode*>(todest); const SMDS_MeshNode* n = static_cast<SMDS_MeshNode*>(todest);
SMDS_ElemIteratorPtr itFe = n->GetInverseElementIterator(); if ( n->NbInverseElements() == 0 ) { // free node
if (!itFe->more()) { // free node
myNodes[elemId] = 0; myNodes[elemId] = 0;
myInfo.myNbNodes--; myInfo.myNbNodes--;
((SMDS_MeshNode*) n)->SetPosition(SMDS_SpacePosition::originSpacePosition()); ((SMDS_MeshNode*) n)->SetPosition(SMDS_SpacePosition::originSpacePosition());
@ -3337,7 +3344,9 @@ void SMDS_Mesh::RemoveFreeElement(const SMDS_MeshElement * elem)
myNodePool->destroy(static_cast<SMDS_MeshNode*>(todest)); myNodePool->destroy(static_cast<SMDS_MeshNode*>(todest));
myNodeIDFactory->ReleaseID(elemId, vtkId); myNodeIDFactory->ReleaseID(elemId, vtkId);
} }
} else { }
else
{
if (hasConstructionEdges() || hasConstructionFaces()) if (hasConstructionEdges() || hasConstructionFaces())
// this methods is only for meshes without descendants // this methods is only for meshes without descendants
return; return;

View File

@ -705,6 +705,7 @@ public:
const SMDS_MeshInfo& GetMeshInfo() const { return myInfo; } const SMDS_MeshInfo& GetMeshInfo() const { return myInfo; }
virtual int NbNodes() const; virtual int NbNodes() const;
virtual int NbElements() const;
virtual int Nb0DElements() const; virtual int Nb0DElements() const;
virtual int NbBalls() const; virtual int NbBalls() const;
virtual int NbEdges() const; virtual int NbEdges() const;

View File

@ -143,22 +143,29 @@ public:
SMDS_MeshNode_MyInvIterator(SMDS_Mesh *mesh, vtkIdType* cells, int ncells, SMDSAbs_ElementType type) : SMDS_MeshNode_MyInvIterator(SMDS_Mesh *mesh, vtkIdType* cells, int ncells, SMDSAbs_ElementType type) :
myMesh(mesh), myCells(cells), myNcells(ncells), myType(type), iter(0) myMesh(mesh), myCells(cells), myNcells(ncells), myType(type), iter(0)
{ {
cellList.reserve( ncells ); if ( ncells )
if (type == SMDSAbs_All) {
cellList.assign( cells, cells + ncells ); cellList.reserve( ncells );
else if (type == SMDSAbs_All)
for (int i = 0; i < ncells; i++)
{ {
int vtkId = cells[i]; cellList.assign( cells, cells + ncells );
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]; else
myNcells = cellList.size(); {
for (int i = 0; i < ncells; i++)
{
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();
}
}
} }
bool more() bool more()
@ -183,66 +190,25 @@ public:
SMDS_ElemIteratorPtr SMDS_MeshNode::GetInverseElementIterator(SMDSAbs_ElementType type) const SMDS_ElemIteratorPtr SMDS_MeshNode::GetInverseElementIterator(SMDSAbs_ElementType type) const
{ {
vtkCellLinks::Link l = SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetLinks()->GetLink(myVtkID); if ( SMDS_Mesh::_meshList[myMeshId]->NbElements() > 0 ) // avoid building links
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<SMDS_MeshElement*> 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)
{ {
for (; iter<ncells; iter++) 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));
int vtkId = myCells[iter];
int smdsId = myMesh->fromVtkToSmds(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);
}
const SMDS_MeshElement* next()
{
const SMDS_MeshElement* elem = myFiltCells[iter];
iter++;
return elem;
}
};
SMDS_ElemIteratorPtr SMDS_MeshNode::
elementsIterator(SMDSAbs_ElementType type) const
{
if(type==SMDSAbs_Node)
return SMDS_MeshElement::elementsIterator(SMDSAbs_Node);
else else
{ {
vtkCellLinks::Link l = SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetLinks()->GetLink(myVtkID); return SMDS_ElemIteratorPtr(new SMDS_MeshNode_MyInvIterator(SMDS_Mesh::_meshList[myMeshId], 0, 0, type));
return SMDS_ElemIteratorPtr(new SMDS_MeshNode_MyIterator(SMDS_Mesh::_meshList[myMeshId], l.cells, l.ncells, type));
} }
} }
SMDS_ElemIteratorPtr SMDS_MeshNode::elementsIterator(SMDSAbs_ElementType type) const
{
if ( type == SMDSAbs_Node )
return SMDS_MeshElement::elementsIterator( SMDSAbs_Node );
else
return GetInverseElementIterator( type );
}
int SMDS_MeshNode::NbNodes() const int SMDS_MeshNode::NbNodes() const
{ {
return 1; return 1;
@ -275,12 +241,14 @@ double SMDS_MeshNode::Z() const
/*! /*!
* \brief thread safe getting coords * \brief thread safe getting coords
*/ */
//================================================================================
void SMDS_MeshNode::GetXYZ(double xyz[3]) const void SMDS_MeshNode::GetXYZ(double xyz[3]) const
{ {
return SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetPoint(myVtkID,xyz); 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) void SMDS_MeshNode::setXYZ(double x, double y, double z)
{ {
SMDS_Mesh *mesh = SMDS_Mesh::_meshList[myMeshId]; SMDS_Mesh *mesh = SMDS_Mesh::_meshList[myMeshId];
@ -321,12 +289,6 @@ void SMDS_MeshNode::ClearInverseElements()
SMDS_Mesh::_meshList[myMeshId]->getGrid()->ResizeCellList(myVtkID, 0); 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 * \brief Count inverse elements of given type
@ -335,35 +297,20 @@ bool SMDS_MeshNode::emptyInverseElements()
int SMDS_MeshNode::NbInverseElements(SMDSAbs_ElementType type) const 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; int nb = 0;
SMDS_Mesh *mesh = SMDS_Mesh::_meshList[myMeshId]; if ( SMDS_Mesh::_meshList[myMeshId]->NbElements() > 0 ) // avoid building links
for (int i=0; i<l.ncells; i++)
{ {
const SMDS_MeshElement* elem = mesh->FindElement(mesh->fromVtkToSmds(l.cells[i])); vtkCellLinks::Link& l = SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetLinks()->GetLink(myVtkID);
if (elem->GetType() == type)
nb++; if ( type == SMDSAbs_All )
return l.ncells;
SMDS_Mesh *mesh = SMDS_Mesh::_meshList[myMeshId];
for ( int i = 0; i < l.ncells; i++ )
{
const SMDS_MeshElement* elem = mesh->FindElement( mesh->fromVtkToSmds( l.cells[i] ));
nb += ( elem->GetType() == type );
}
} }
return nb; return nb;
} }
///////////////////////////////////////////////////////////////////////////////
/// To be used with STL set
///////////////////////////////////////////////////////////////////////////////
bool operator<(const SMDS_MeshNode& e1, const SMDS_MeshNode& e2)
{
return e1.getVtkId()<e2.getVtkId();
/*if(e1.myX<e2.myX) return true;
else if(e1.myX==e2.myX)
{
if(e1.myY<e2.myY) return true;
else if(e1.myY==e2.myY) return (e1.myZ<e2.myZ);
else return false;
}
else return false;*/
}

View File

@ -69,7 +69,6 @@ protected:
void AddInverseElement(const SMDS_MeshElement * ME); void AddInverseElement(const SMDS_MeshElement * ME);
void RemoveInverseElement(const SMDS_MeshElement * parent); void RemoveInverseElement(const SMDS_MeshElement * parent);
void ClearInverseElements(); void ClearInverseElements();
bool emptyInverseElements();
SMDS_ElemIteratorPtr SMDS_ElemIteratorPtr
elementsIterator(SMDSAbs_ElementType type) const; elementsIterator(SMDSAbs_ElementType type) const;

View File

@ -4635,7 +4635,7 @@ namespace { // Structures used by FixQuadraticElements()
SMDS_ElemIteratorPtr faceIter( new TIterOnIter( faceIterVec )); SMDS_ElemIteratorPtr faceIter( new TIterOnIter( faceIterVec ));
// a seacher to check if a volume is close to a concave face // 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 )); ( SMESH_MeshAlgos::GetElementSearcher( *theHelper.GetMeshDS(), faceIter ));
// classifier // classifier
@ -4737,7 +4737,7 @@ namespace { // Structures used by FixQuadraticElements()
gp_Pnt pMedium = SMESH_TNodeXYZ( linkIt->second ); gp_Pnt pMedium = SMESH_TNodeXYZ( linkIt->second );
double hMedium = faceNorm * gp_Vec( pOnFace0, pMedium ).XYZ(); double hMedium = faceNorm * gp_Vec( pOnFace0, pMedium ).XYZ();
double hVol = faceNorm * gp_Vec( pOnFace0, pInSolid ).XYZ(); double hVol = faceNorm * gp_Vec( pOnFace0, pInSolid ).XYZ();
isDistorted = ( Abs( hMedium ) > Abs( hVol * 0.5 )); isDistorted = ( Abs( hMedium ) > Abs( hVol * 0.75 ));
} }
} }
} }

View File

@ -794,7 +794,7 @@ bool SMESH_Pattern::Load (SMESH_Mesh* theMesh,
double u = epos->GetUParameter(); double u = epos->GetUParameter();
paramNodeMap.insert( make_pair( u, node )); paramNodeMap.insert( make_pair( u, node ));
} }
if ((int) paramNodeMap.size() != eSubMesh->NbNodes() ) { if ((int) paramNodeMap.size() != eSubMesh->NbNodes() - nbMeduimNodes ) {
// wrong U on edge, project // wrong U on edge, project
Extrema_ExtPC proj; Extrema_ExtPC proj;
BRepAdaptor_Curve aCurve( edge ); BRepAdaptor_Curve aCurve( edge );

View File

@ -1086,6 +1086,8 @@ void SMESHGUI_ClippingDlg::updateActorList()
std::for_each( myPlanes.begin(),myPlanes.end(), TSetVisibility( PreviewCheckBox->isChecked() ) ); std::for_each( myPlanes.begin(),myPlanes.end(), TSetVisibility( PreviewCheckBox->isChecked() ) );
aPlaneData.Plane.GetPointer()->myActor->SetVisibility( false ); aPlaneData.Plane.GetPointer()->myActor->SetVisibility( false );
std::map< std::string, QListWidgetItem* > itemMap; // used to sort items by entry
VTK::ActorCollectionCopy aCopy( myViewWindow->getRenderer()->GetActors() ); VTK::ActorCollectionCopy aCopy( myViewWindow->getRenderer()->GetActors() );
vtkActorCollection* anAllActors = aCopy.GetActors(); vtkActorCollection* anAllActors = aCopy.GetActors();
anAllActors->InitTraversal(); anAllActors->InitTraversal();
@ -1111,13 +1113,20 @@ void SMESHGUI_ClippingDlg::updateActorList()
if ( !aFatherName.isEmpty() ) if ( !aFatherName.isEmpty() )
aName = aFatherName + " / " + aName; aName = aFatherName + " / " + aName;
aName += QString(" (%1)").arg( aSObj->GetID().c_str() ); 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 ); 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::OrientedPlane* aPlane = SMESH::OrientedPlane::New(myViewWindow);
SMESH::TPlane aTPlane(aPlane); SMESH::TPlane aTPlane(aPlane);
aPlane->PlaneMode = CurrentMode; aPlane->PlaneMode = CurrentMode;
SMESH::TActorList anActorList; SMESH::TActorList anActorList, aVisibleActorList;
VTK::ActorCollectionCopy aCopy( myViewWindow->getRenderer()->GetActors() ); VTK::ActorCollectionCopy aCopy( myViewWindow->getRenderer()->GetActors() );
vtkActorCollection* anAllActors = aCopy.GetActors(); vtkActorCollection* anAllActors = aCopy.GetActors();
anAllActors->InitTraversal(); anAllActors->InitTraversal();
while( vtkActor* aVTKActor = anAllActors->GetNextActor() ) while( vtkActor* aVTKActor = anAllActors->GetNextActor() )
if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( aVTKActor ) ) if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( aVTKActor ) )
{
anActorList.push_back( anActor ); anActorList.push_back( anActor );
if ( anActor->GetVisibility() )
SMESH::TPlaneData aPlaneData(aTPlane, anActorList); aVisibleActorList.push_back( anActor );
}
SMESH::TPlaneData aPlaneData(aTPlane,
aVisibleActorList.empty() ? anActorList : aVisibleActorList);
myPlanes.push_back(aPlaneData); myPlanes.push_back(aPlaneData);

View File

@ -203,9 +203,9 @@ QWidget* SMESHGUI_ReorientFacesDlg::createMainFrame (QWidget* theParent)
myDY->SetValue(0); myDY->SetValue(0);
myDZ->SetValue(0); myDZ->SetValue(0);
myDX->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, 10.0, "length_precision"); myDY->RangeStepAndValidator(COORD_MIN, COORD_MAX, 1.0, "length_precision");
myDZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision"); myDZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, 1.0, "length_precision");
width = Max( aFaceBut->fontMetrics().width( tr("SMESH_X")), width = Max( aFaceBut->fontMetrics().width( tr("SMESH_X")),
aFaceBut->fontMetrics().width( tr("SMESH_DX"))); aFaceBut->fontMetrics().width( tr("SMESH_DX")));

View File

@ -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] ); gp_Vec edge2( xyz[i+1], xyz[(i+2)%nbNodes] );
faceNorm += edge1 ^ edge2; faceNorm += edge1 ^ edge2;
} }
double normSize = faceNorm.Magnitude(); double fNormSize = faceNorm.Magnitude();
if ( normSize <= tol ) if ( fNormSize <= tol )
{ {
// degenerated face: point is out if it is out of all face edges // degenerated face: point is out if it is out of all face edges
for ( i = 0; i < nbNodes; ++i ) for ( i = 0; i < nbNodes; ++i )
@ -1175,7 +1175,7 @@ bool SMESH_MeshAlgos::IsOut( const SMDS_MeshElement* element, const gp_Pnt& poin
} }
return true; return true;
} }
faceNorm /= normSize; faceNorm /= fNormSize;
// check if the point lays on face plane // check if the point lays on face plane
gp_Vec n2p( xyz[0], point ); 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. // to find intersections of the ray with the boundary.
gp_Vec ray = n2p; gp_Vec ray = n2p;
gp_Vec plnNorm = ray ^ faceNorm; gp_Vec plnNorm = ray ^ faceNorm;
normSize = plnNorm.Magnitude(); double n2pSize = plnNorm.Magnitude();
if ( normSize <= tol ) return false; // point coincides with the first node if ( n2pSize <= tol ) return false; // point coincides with the first node
plnNorm /= normSize; 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 // for each node of the face, compute its signed distance to the cutting plane
vector<double> dist( nbNodes + 1); vector<double> dist( nbNodes + 1);
for ( i = 0; i < nbNodes; ++i ) 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 if ( rClosest > 0. && rClosest < 1. ) // not node intersection
return out; 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 p1 = xyz[ (rClosest == 0.) ? ((iClosest+nbNodes-1) % nbNodes) : (iClosest+1) ];
gp_Pnt p2 = xyz[ (rClosest == 0.) ? iClosest : ((iClosest+2) % nbNodes) ]; gp_Pnt p2 = xyz[ (rClosest == 0.) ? iClosest : ((iClosest+2) % nbNodes) ];
gp_Vec edgeAdjacent( p1, p2 ); gp_Vec edgeAdjacent( p1, p2 );

View File

@ -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 # 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 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 # @param theToBiQuad If True, converts the mesh to bi-quadratic
# @return SMESH.ComputeError which can hold a warning
# @ingroup l2_modif_tofromqu # @ingroup l2_modif_tofromqu
def ConvertToQuadratic(self, theForce3d=False, theSubMesh=None, theToBiQuad=False): def ConvertToQuadratic(self, theForce3d=False, theSubMesh=None, theToBiQuad=False):
if isinstance( theSubMesh, Mesh ): if isinstance( theSubMesh, Mesh ):
@ -3620,6 +3621,7 @@ class Mesh:
error = self.editor.GetLastError() error = self.editor.GetLastError()
if error and error.comment: if error and error.comment:
print error.comment print error.comment
return error
## Converts the mesh from quadratic to ordinary, ## Converts the mesh from quadratic to ordinary,
# deletes old quadratic elements, \n replacing # deletes old quadratic elements, \n replacing

View File

@ -183,7 +183,7 @@ class Mesh_Algorithm:
## Private method. ## Private method.
def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"): def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
if geom is None and mesh.mesh.HasShapeToMesh(): 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) algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
if algo is None: if algo is None:
algo = mesh.smeshpyD.CreateHypothesis(hypo, so) algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
@ -195,7 +195,7 @@ class Mesh_Algorithm:
def Assign(self, algo, mesh, geom): def Assign(self, algo, mesh, geom):
from salome.smesh.smeshBuilder import AssureGeomPublished, TreatHypoStatus, GetName from salome.smesh.smeshBuilder import AssureGeomPublished, TreatHypoStatus, GetName
if geom is None and mesh.mesh.HasShapeToMesh(): 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 self.mesh = mesh
if not geom or geom.IsSame( mesh.geom ): if not geom or geom.IsSame( mesh.geom ):
self.geom = mesh.geom self.geom = mesh.geom

View File

@ -72,6 +72,10 @@
using namespace std; using namespace std;
#define RETURN_BAD_RESULT(msg) { MESSAGE(")-: Error: " << msg); return false; } #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; namespace TAssocTool = StdMeshers_ProjectionUtils;
//typedef StdMeshers_ProjectionUtils TAssocTool; //typedef StdMeshers_ProjectionUtils TAssocTool;
@ -436,7 +440,11 @@ namespace {
if (( err && !err->IsOK() ) || if (( err && !err->IsOK() ) ||
( srcWires.empty() )) ( srcWires.empty() ))
return err; 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 ); SMESH_MesherHelper srcHelper( *srcMesh );
srcHelper.SetSubShape( srcFace ); srcHelper.SetSubShape( srcFace );
@ -492,6 +500,11 @@ namespace {
for ( int iE = 0; iE < srcWire->NbEdges(); ++iE ) 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() || if ( srcMesh->GetSubMesh( srcWire->Edge(iE) )->IsEmpty() ||
tgtMesh->GetSubMesh( tgtWire->Edge(iE) )->IsEmpty() ) tgtMesh->GetSubMesh( tgtWire->Edge(iE) )->IsEmpty() )
{ {

View File

@ -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 vert1 = P2.XYZ();
gp_XYZ vert2 = P3.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 edge1 = vert1 - vert0;
gp_XYZ edge2 = vert2 - 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 */ /* if determinant is near zero, ray lies in plane of triangle */
double det = edge1 * pvec; double det = edge1 * pvec;
if (det > -EPSILON && det < EPSILON) const double ANGL_EPSILON = 1e-12;
if ( det > -ANGL_EPSILON && det < ANGL_EPSILON )
return false; return false;
/* calculate distance from vert0 to ray origin */
gp_XYZ tvec = orig - vert0;
/* calculate U parameter and test bounds */ /* calculate U parameter and test bounds */
double u = ( tvec * pvec ) / det; double u = ( tvec * pvec ) / det;
//if (u < 0.0 || u > 1.0) //if (u < 0.0 || u > 1.0)

View File

@ -135,6 +135,10 @@
<source>ICON_SMESH_TREE_ALGO_Projection_2D</source> <source>ICON_SMESH_TREE_ALGO_Projection_2D</source>
<translation>mesh_tree_algo_projection_2d.png</translation> <translation>mesh_tree_algo_projection_2d.png</translation>
</message> </message>
<message>
<source>ICON_SMESH_TREE_ALGO_Projection_1D2D</source>
<translation>mesh_tree_algo_projection_2d.png</translation>
</message>
<message> <message>
<source>ICON_SMESH_TREE_ALGO_Projection_3D</source> <source>ICON_SMESH_TREE_ALGO_Projection_3D</source>
<translation>mesh_tree_hypo_projection_3d.png</translation> <translation>mesh_tree_hypo_projection_3d.png</translation>
@ -251,6 +255,10 @@
<source>ICON_SMESH_TREE_HYPO_QuadranglePreference</source> <source>ICON_SMESH_TREE_HYPO_QuadranglePreference</source>
<translation>mesh_tree_algo_quad.png</translation> <translation>mesh_tree_algo_quad.png</translation>
</message> </message>
<message>
<source>ICON_SMESH_TREE_HYPO_QuadrangleParams</source>
<translation>mesh_tree_algo_quad.png</translation>
</message>
<message> <message>
<source>ICON_SMESH_TREE_HYPO_TrianglePreference</source> <source>ICON_SMESH_TREE_HYPO_TrianglePreference</source>
<translation>mesh_tree_algo_mefisto.png</translation> <translation>mesh_tree_algo_mefisto.png</translation>

View File

@ -52,7 +52,6 @@ StdMeshers_AutomaticLength_i::StdMeshers_AutomaticLength_i( PortableServer::POA_
: SALOME::GenericObj_i( thePOA ), : SALOME::GenericObj_i( thePOA ),
SMESH_Hypothesis_i( thePOA ) SMESH_Hypothesis_i( thePOA )
{ {
MESSAGE( "StdMeshers_AutomaticLength_i::StdMeshers_AutomaticLength_i" );
myBaseImpl = new ::StdMeshers_AutomaticLength( theGenImpl->GetANewId(), myBaseImpl = new ::StdMeshers_AutomaticLength( theGenImpl->GetANewId(),
theStudyId, theStudyId,
theGenImpl ); theGenImpl );
@ -68,7 +67,6 @@ StdMeshers_AutomaticLength_i::StdMeshers_AutomaticLength_i( PortableServer::POA_
StdMeshers_AutomaticLength_i::~StdMeshers_AutomaticLength_i() StdMeshers_AutomaticLength_i::~StdMeshers_AutomaticLength_i()
{ {
MESSAGE( "StdMeshers_AutomaticLength_i::~StdMeshers_AutomaticLength_i" );
} }
//============================================================================= //=============================================================================

View File

@ -50,7 +50,6 @@ StdMeshers_SegmentLengthAroundVertex_i::StdMeshers_SegmentLengthAroundVertex_i
: SALOME::GenericObj_i( thePOA ), : SALOME::GenericObj_i( thePOA ),
SMESH_Hypothesis_i( thePOA ) SMESH_Hypothesis_i( thePOA )
{ {
MESSAGE( "StdMeshers_SegmentLengthAroundVertex_i::StdMeshers_SegmentLengthAroundVertex_i" );
myBaseImpl = new ::StdMeshers_SegmentLengthAroundVertex( theGenImpl->GetANewId(), myBaseImpl = new ::StdMeshers_SegmentLengthAroundVertex( theGenImpl->GetANewId(),
theStudyId, theStudyId,
theGenImpl ); theGenImpl );
@ -66,7 +65,6 @@ StdMeshers_SegmentLengthAroundVertex_i::StdMeshers_SegmentLengthAroundVertex_i
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 ) void StdMeshers_SegmentLengthAroundVertex_i::SetLength( CORBA::Double theLength )
throw ( SALOME::SALOME_Exception ) throw ( SALOME::SALOME_Exception )
{ {
MESSAGE( "StdMeshers_SegmentLengthAroundVertex_i::SetLength" );
ASSERT( myBaseImpl ); ASSERT( myBaseImpl );
try { try {
this->GetImpl()->SetLength( theLength ); this->GetImpl()->SetLength( theLength );
@ -103,7 +100,6 @@ void StdMeshers_SegmentLengthAroundVertex_i::SetLength( CORBA::Double theLength
CORBA::Double StdMeshers_SegmentLengthAroundVertex_i::GetLength() CORBA::Double StdMeshers_SegmentLengthAroundVertex_i::GetLength()
{ {
MESSAGE( "StdMeshers_SegmentLengthAroundVertex_i::GetLength" );
ASSERT( myBaseImpl ); ASSERT( myBaseImpl );
return this->GetImpl()->GetLength(); return this->GetImpl()->GetLength();
} }
@ -118,7 +114,6 @@ CORBA::Double StdMeshers_SegmentLengthAroundVertex_i::GetLength()
::StdMeshers_SegmentLengthAroundVertex* StdMeshers_SegmentLengthAroundVertex_i::GetImpl() ::StdMeshers_SegmentLengthAroundVertex* StdMeshers_SegmentLengthAroundVertex_i::GetImpl()
{ {
MESSAGE( "StdMeshers_SegmentLengthAroundVertex_i::GetImpl" );
return ( ::StdMeshers_SegmentLengthAroundVertex* )myBaseImpl; return ( ::StdMeshers_SegmentLengthAroundVertex* )myBaseImpl;
} }