IPAL54425: Quadrangle mapping fails on a quadrangle face with a seam

Issue reported in https://www.salome-platform.org/forum/forum_10/984373499

+
1) Fix a bug in Python dump
2) Expose corners in Quadrangle Param gui
This commit is contained in:
eap 2019-08-05 20:02:26 +03:00
parent 0146a69d82
commit f65b9b8b24
10 changed files with 125 additions and 37 deletions

View File

@ -334,7 +334,7 @@
dim ="2"> dim ="2">
<python-wrap> <python-wrap>
<algo>Quadrangle_2D=Quadrangle(algo=smeshBuilder.QUADRANGLE)</algo> <algo>Quadrangle_2D=Quadrangle(algo=smeshBuilder.QUADRANGLE)</algo>
<hypo>QuadrangleParams=QuadrangleParameters(SetQuadType(),SetTriaVertex(),SetEnforcedNodes(1),SetEnforcedNodes(2))</hypo> <hypo>QuadrangleParams=QuadrangleParameters(SetQuadType(),SetTriaVertex(),SetEnforcedNodes(1),SetEnforcedNodes(2),SetCorners())</hypo>
<hypo>ViscousLayers2D=ViscousLayers2D(SetTotalThickness(),SetNumberLayers(),SetStretchFactor(),SetIgnoreEdges())</hypo> <hypo>ViscousLayers2D=ViscousLayers2D(SetTotalThickness(),SetNumberLayers(),SetStretchFactor(),SetIgnoreEdges())</hypo>
</python-wrap> </python-wrap>
</algorithm> </algorithm>

View File

@ -635,6 +635,10 @@ public:
* \retval int - 1 for U, 2 for V direction * \retval int - 1 for U, 2 for V direction
*/ */
int GetPeriodicIndex() const { return myParIndex; } int GetPeriodicIndex() const { return myParIndex; }
/*!
* \brief Return period in given direction [1,2]
*/
double GetPeriod(int perioIndex) const { return myPar2[ perioIndex-1 ] - myPar1[ perioIndex-1 ]; }
/*! /*!
* \brief Return an alternative parameter for a node on seam * \brief Return an alternative parameter for a node on seam
*/ */

View File

@ -1971,7 +1971,7 @@ void _pyMesh::Process( const Handle(_pyCommand)& theCommand )
if ( !obj->CanClear() ) if ( !obj->CanClear() )
allGroupsRemoved = false; allGroupsRemoved = false;
} }
if ( nbGroupsBefore == myGroups.size() ) // no new _pyGroup created if ( nbGroupsBefore == myGroups.size() && !obj.IsNull() ) // no new _pyGroup created
obj->AddProcessedCmd( theCommand ); // to clear theCommand if all groups are removed obj->AddProcessedCmd( theCommand ); // to clear theCommand if all groups are removed
if ( !allGroupsRemoved && !theGen->IsToKeepAllCommands() ) if ( !allGroupsRemoved && !theGen->IsToKeepAllCommands() )

View File

@ -77,6 +77,7 @@ StdMeshers_Hexa_3D::StdMeshers_Hexa_3D(int hypId, SMESH_Gen * gen)
_shapeType = (1 << TopAbs_SHELL) | (1 << TopAbs_SOLID); // 1 bit /shape type _shapeType = (1 << TopAbs_SHELL) | (1 << TopAbs_SOLID); // 1 bit /shape type
_requireShape = false; _requireShape = false;
_compatibleHypothesis.push_back("ViscousLayers"); _compatibleHypothesis.push_back("ViscousLayers");
_quadAlgo = new StdMeshers_Quadrangle_2D( gen->GetANewId(), _gen );
} }
//============================================================================= //=============================================================================
@ -87,6 +88,8 @@ StdMeshers_Hexa_3D::StdMeshers_Hexa_3D(int hypId, SMESH_Gen * gen)
StdMeshers_Hexa_3D::~StdMeshers_Hexa_3D() StdMeshers_Hexa_3D::~StdMeshers_Hexa_3D()
{ {
delete _quadAlgo;
_quadAlgo = 0;
} }
//============================================================================= //=============================================================================
@ -231,7 +234,7 @@ namespace
for ( int i = 1; i < 6; ++i ) for ( int i = 1; i < 6; ++i )
{ {
if ( !quad[i] ) continue; if ( !quad[i] ) continue;
for ( unsigned iS = 0; iS < quad[i]->side.size(); ++iS ) for ( size_t iS = 0; iS < quad[i]->side.size(); ++iS )
{ {
const StdMeshers_FaceSidePtr side2 = quad[i]->side[iS]; const StdMeshers_FaceSidePtr side2 = quad[i]->side[iS];
if (( side->FirstVertex().IsSame( side2->FirstVertex() ) || if (( side->FirstVertex().IsSame( side2->FirstVertex() ) ||
@ -244,9 +247,9 @@ namespace
if ( iS != Q_BOTTOM ) if ( iS != Q_BOTTOM )
{ {
vector< FaceQuadStruct::Side > newSides; vector< FaceQuadStruct::Side > newSides;
for ( unsigned j = iS; j < quad[i]->side.size(); ++j ) for ( size_t j = iS; j < quad[i]->side.size(); ++j )
newSides.push_back( quad[i]->side[j] ); newSides.push_back( quad[i]->side[j] );
for ( unsigned j = 0; j < iS; ++j ) for ( size_t j = 0; j < iS; ++j )
newSides.push_back( quad[i]->side[j] ); newSides.push_back( quad[i]->side[j] );
quad[i]->side.swap( newSides ); quad[i]->side.swap( newSides );
} }
@ -363,7 +366,7 @@ bool StdMeshers_Hexa_3D::Compute(SMESH_Mesh & aMesh,
if ( exp.Next(), exp.More() ) if ( exp.Next(), exp.More() )
return error(COMPERR_BAD_SHAPE, "More than one SHELL in the geometry"); return error(COMPERR_BAD_SHAPE, "More than one SHELL in the geometry");
TopTools_IndexedMapOfShape FF; TopTools_IndexedMapOfShape FF, EE;
TopExp::MapShapes( aShape, TopAbs_FACE, FF); TopExp::MapShapes( aShape, TopAbs_FACE, FF);
if ( FF.Extent() != 6) if ( FF.Extent() != 6)
{ {
@ -376,13 +379,22 @@ bool StdMeshers_Hexa_3D::Compute(SMESH_Mesh & aMesh,
// Find sides of a cube // Find sides of a cube
// --------------------- // ---------------------
// tool creating quadratic elements if needed
SMESH_MesherHelper helper (aMesh);
_quadraticMesh = helper.IsQuadraticSubMesh(aShape);
TopExp::MapShapes( aShape, TopAbs_EDGE, EE );
SMESH_MesherHelper* faceHelper = ( EE.Size() == 12 ) ? 0 : &helper;
FaceQuadStructPtr quad[ 6 ]; FaceQuadStructPtr quad[ 6 ];
StdMeshers_Quadrangle_2D quadAlgo( _gen->GetANewId(), _gen);
for ( int i = 0; i < 6; ++i ) for ( int i = 0; i < 6; ++i )
{ {
if ( !( quad[i] = FaceQuadStructPtr( quadAlgo.CheckNbEdges( aMesh, FF( i+1 ), if ( faceHelper )
/*considerMesh=*/true)))) faceHelper->SetSubShape( FF( i+1 ));
return error( quadAlgo.GetComputeError() ); if ( !( quad[i] = FaceQuadStructPtr( _quadAlgo->CheckNbEdges( aMesh, FF( i+1 ),
/*considerMesh=*/true,
faceHelper))))
return error( _quadAlgo->GetComputeError() );
if ( quad[i]->side.size() != 4 ) if ( quad[i]->side.size() != 4 )
return error( COMPERR_BAD_SHAPE, "Not a quadrangular box side" ); return error( COMPERR_BAD_SHAPE, "Not a quadrangular box side" );
} }
@ -437,10 +449,6 @@ bool StdMeshers_Hexa_3D::Compute(SMESH_Mesh & aMesh,
// Check presence of regular grid mesh on FACEs of the cube // Check presence of regular grid mesh on FACEs of the cube
// ------------------------------------------------------------ // ------------------------------------------------------------
// tool creating quadratic elements if needed
SMESH_MesherHelper helper (aMesh);
_quadraticMesh = helper.IsQuadraticSubMesh(aShape);
for ( int i = 0; i < 6; ++i ) for ( int i = 0; i < 6; ++i )
{ {
const TopoDS_Face& F = aCubeSide[i]._quad->face; const TopoDS_Face& F = aCubeSide[i]._quad->face;
@ -513,8 +521,8 @@ bool StdMeshers_Hexa_3D::Compute(SMESH_Mesh & aMesh,
if ( proxymesh ) if ( proxymesh )
for ( int i = 0; i < 6; ++i ) for ( int i = 0; i < 6; ++i )
for ( unsigned j = 0; j < aCubeSide[i]._columns.size(); ++j) for ( size_t j = 0; j < aCubeSide[i]._columns.size(); ++j)
for ( unsigned k = 0; k < aCubeSide[i]._columns[j].size(); ++k) for ( size_t k = 0; k < aCubeSide[i]._columns[j].size(); ++k)
{ {
const SMDS_MeshNode* & n = aCubeSide[i]._columns[j][k]; const SMDS_MeshNode* & n = aCubeSide[i]._columns[j][k];
n = proxymesh->GetProxyNode( n ); n = proxymesh->GetProxyNode( n );

View File

@ -34,8 +34,9 @@
#include "SMESH_Algo.hxx" #include "SMESH_Algo.hxx"
class StdMeshers_ViscousLayers;
class SMESH_MesherHelper; class SMESH_MesherHelper;
class StdMeshers_Quadrangle_2D;
class StdMeshers_ViscousLayers;
class STDMESHERS_EXPORT StdMeshers_Hexa_3D : public SMESH_3D_Algo class STDMESHERS_EXPORT StdMeshers_Hexa_3D : public SMESH_3D_Algo
{ {
@ -63,6 +64,7 @@ public:
protected: protected:
const StdMeshers_ViscousLayers* _viscousLayersHyp; const StdMeshers_ViscousLayers* _viscousLayersHyp;
StdMeshers_Quadrangle_2D* _quadAlgo;
}; };
#endif #endif

View File

@ -51,6 +51,7 @@
#include <Geom_Surface.hxx> #include <Geom_Surface.hxx>
#include <NCollection_DefineArray2.hxx> #include <NCollection_DefineArray2.hxx>
#include <Precision.hxx> #include <Precision.hxx>
#include <ShapeAnalysis.hxx>
#include <TColStd_SequenceOfInteger.hxx> #include <TColStd_SequenceOfInteger.hxx>
#include <TColStd_SequenceOfReal.hxx> #include <TColStd_SequenceOfReal.hxx>
#include <TColgp_SequenceOfXY.hxx> #include <TColgp_SequenceOfXY.hxx>
@ -1221,7 +1222,9 @@ namespace
* \param [in] theNbCorners - the required number of sides, 3 or 4 * \param [in] theNbCorners - the required number of sides, 3 or 4
* \param [in] theConsiderMesh - to considered only meshed VERTEXes * \param [in] theConsiderMesh - to considered only meshed VERTEXes
* \param [in] theFaceSide - the FACE EDGEs * \param [in] theFaceSide - the FACE EDGEs
* \param [in] theFixedVertices - VERTEXes to be used as corners
* \param [out] theVertices - the found corner vertices * \param [out] theVertices - the found corner vertices
* \param [out] theHaveConcaveVertices - return if there are concave vertices
*/ */
//================================================================================ //================================================================================
@ -1432,6 +1435,39 @@ namespace
return; return;
} }
//================================================================================
/*!
* \brief Remove a seam and degenerated edge from a wire if the shape is
* a quadrangle with a seam inside.
*/
//================================================================================
bool removeInternalSeam( std::list<TopoDS_Edge>& theWire,
SMESH_MesherHelper& theHelper)
{
if ( !theHelper.HasRealSeam() ||
theHelper.NbDegeneratedEdges() != 2 ) // 1 EDGE + 1 VERTEX
return false;
typedef std::list<TopoDS_Edge>::iterator TEdgeIter;
std::vector< TEdgeIter > edgesToRemove;
edgesToRemove.reserve( 5 );
for ( TEdgeIter eIt = theWire.begin(); eIt != theWire.end(); ++eIt )
{
int eID = theHelper.ShapeToIndex( *eIt );
if ( theHelper.IsRealSeam( eID ) || theHelper.IsDegenShape( eID ))
edgesToRemove.push_back( eIt );
}
if ( theWire.size() - edgesToRemove.size() < 4 )
return false; // cone e.g.
for ( size_t i = 0; i < edgesToRemove.size(); ++i )
theWire.erase( edgesToRemove[ i ]);
return true;
}
} // namespace } // namespace
//================================================================================ //================================================================================
@ -1462,6 +1498,9 @@ int StdMeshers_Quadrangle_2D::getCorners(const TopoDS_Face& theFace,
if ( myHelper ) if ( myHelper )
helper.CopySubShapeInfo( *myHelper ); helper.CopySubShapeInfo( *myHelper );
if ( removeInternalSeam( theWire, helper ))
theNbDegenEdges = 1;
StdMeshers_FaceSide faceSide( theFace, theWire, &theMesh, StdMeshers_FaceSide faceSide( theFace, theWire, &theMesh,
/*isFwd=*/true, /*skipMedium=*/true, &helper ); /*isFwd=*/true, /*skipMedium=*/true, &helper );
@ -4774,20 +4813,35 @@ bool StdMeshers_Quadrangle_2D::check()
default:; default:;
} }
// if ( isBad && myHelper->HasRealSeam() ) if ( isBad && myHelper->HasRealSeam() )
// { {
// // detect a case where a face intersects the seam // fix uv for a case where a face intersects the seam
// for ( int iPar = 1; iPar < 3; ++iPar ) for ( int iPar = 1; iPar < 3; ++iPar )
// if ( iPar & myHelper->GetPeriodicIndex() ) if ( iPar & myHelper->GetPeriodicIndex() )
// { {
// double min = uv[0].Coord( iPar ), max = uv[0].Coord( iPar ); double max = uv[0].Coord( iPar );
// for ( int i = 1; i < nbN; ++i ) for ( int i = 1; i < nbN; ++i )
// { max = Max( max, uv[i].Coord( iPar ));
// min = Min( min, uv[i].Coord( iPar ));
// max = Max( max, uv[i].Coord( iPar )); for ( int i = 0; i < nbN; ++i )
// } {
// } double par = uv[i].Coord( iPar );
// } double shift = ShapeAnalysis::AdjustByPeriod( par, max, myHelper->GetPeriod( iPar ));
uv[i].SetCoord( iPar, par + shift );
}
}
double sign1 = getArea( uv[0], uv[1], uv[2] );
double sign2 = getArea( uv[0], uv[2], uv[3] );
if ( sign1 * sign2 < 0 )
{
sign2 = getArea( uv[1], uv[2], uv[3] );
sign1 = getArea( uv[1], uv[3], uv[0] );
if ( sign1 * sign2 < 0 )
continue; // this should not happen
}
isBad = ( sign1 * okSign < 0 );
}
if ( isBad ) if ( isBad )
badFaces.push_back ( f ); badFaces.push_back ( f );
} }

View File

@ -55,7 +55,7 @@
#define SPACING 6 #define SPACING 6
#define MARGIN 11 #define MARGIN 11
enum { TAB_TRANSITION, TAB_VERTEX, TAB_ENF_POINTS }; enum { TAB_TRANSITION, TAB_VERTEX, TAB_CORNERS, TAB_ENF_POINTS };
//================================================================================ //================================================================================
// function : Constructor // function : Constructor
@ -153,10 +153,16 @@ QFrame* StdMeshersGUI_QuadrangleParamCreator::buildFrame()
pointsLay->addWidget( shapesGroup ); pointsLay->addWidget( shapesGroup );
pointsLay->addWidget( coordsGroup ); pointsLay->addWidget( coordsGroup );
// Corners
myCornersSelWdg = new StdMeshersGUI_SubShapeSelectorWdg( fr, TopAbs_VERTEX );
myCornersSelWdg->layout()->setMargin( MARGIN );
// Tabs // Tabs
myTabs = new QTabWidget( fr ); myTabs = new QTabWidget( fr );
myTabs->addTab( myTypeWdg, tr("TRANSITION")); myTabs->addTab( myTypeWdg, tr("TRANSITION"));
myTabs->addTab( myVertexSelWdg, tr("SMESH_BASE_VERTEX")); myTabs->addTab( myVertexSelWdg, tr("SMESH_BASE_VERTEX"));
myTabs->addTab( myCornersSelWdg, tr("CORNERS"));
myTabs->addTab( pointsFrame, tr("ENF_NODES")); myTabs->addTab( pointsFrame, tr("ENF_NODES"));
lay->addWidget( myTabs, row, 0, 2, 3 ); lay->addWidget( myTabs, row, 0, 2, 3 );
@ -196,6 +202,7 @@ void StdMeshersGUI_QuadrangleParamCreator::retrieveParams() const
if ( anEntry.isEmpty() ) if ( anEntry.isEmpty() )
anEntry = h->GetObjectEntry(); anEntry = h->GetObjectEntry();
myVertexSelWdg->SetGeomShapeEntry(anEntry,aMainEntry); myVertexSelWdg->SetGeomShapeEntry(anEntry,aMainEntry);
myCornersSelWdg->SetGeomShapeEntry(anEntry,aMainEntry);
if ( !isCreation()) if ( !isCreation())
{ {
@ -211,6 +218,10 @@ void StdMeshersGUI_QuadrangleParamCreator::retrieveParams() const
myVertexSelWdg->SetListOfIDs(aVec); myVertexSelWdg->SetListOfIDs(aVec);
} }
// corners
SMESH::long_array_var aVec = h->GetCorners();
myCornersSelWdg->SetListOfIDs( aVec );
// enforced nodes // enforced nodes
GEOM::ListOfGO_var shapes; GEOM::ListOfGO_var shapes;
SMESH::nodes_array_var points; SMESH::nodes_array_var points;
@ -265,6 +276,9 @@ QString StdMeshersGUI_QuadrangleParamCreator::storeParams() const
h->SetTriaVertex( -1 ); h->SetTriaVertex( -1 );
} }
// corners
h->SetCorners( myCornersSelWdg->GetListOfIDs() );
// enfored nodes // enfored nodes
GEOM::ListOfGO_var goList = new GEOM::ListOfGO; GEOM::ListOfGO_var goList = new GEOM::ListOfGO;
@ -408,6 +422,7 @@ void StdMeshersGUI_QuadrangleParamCreator::onSelectionChanged()
void StdMeshersGUI_QuadrangleParamCreator::onTabChanged(int i) void StdMeshersGUI_QuadrangleParamCreator::onTabChanged(int i)
{ {
myVertexSelWdg->ShowPreview( i == TAB_VERTEX ); myVertexSelWdg->ShowPreview( i == TAB_VERTEX );
myCornersSelWdg->ShowPreview( i == TAB_CORNERS );
} }
//================================================================================ //================================================================================

View File

@ -78,6 +78,7 @@ class STDMESHERSGUI_EXPORT StdMeshersGUI_QuadrangleParamCreator : public StdMesh
QLineEdit* myName; QLineEdit* myName;
StdMeshersGUI_QuadrangleParamWdg* myTypeWdg; StdMeshersGUI_QuadrangleParamWdg* myTypeWdg;
StdMeshersGUI_SubShapeSelectorWdg* myVertexSelWdg; StdMeshersGUI_SubShapeSelectorWdg* myVertexSelWdg;
StdMeshersGUI_SubShapeSelectorWdg* myCornersSelWdg;
QListWidget* myShapesList; QListWidget* myShapesList;
QPushButton* myAddShapeBut; QPushButton* myAddShapeBut;
QTreeWidget* myCoordsTreeWdg; QTreeWidget* myCoordsTreeWdg;

View File

@ -53,7 +53,7 @@ public:
StdMeshersGUI_SubShapeSelectorWdg( QWidget* parent = 0, StdMeshersGUI_SubShapeSelectorWdg( QWidget* parent = 0,
TopAbs_ShapeEnum subShType = TopAbs_EDGE, TopAbs_ShapeEnum subShType = TopAbs_EDGE,
const bool toShowList = true, const bool toShowList = true,
const bool toShowActivateBtn = false); const bool toShowSelectBtn = false);
~StdMeshersGUI_SubShapeSelectorWdg(); ~StdMeshersGUI_SubShapeSelectorWdg();
SMESH::long_array_var GetListOfIDs(); SMESH::long_array_var GetListOfIDs();

View File

@ -542,6 +542,10 @@ this one for this mesh/sub-mesh.</translation>
<source>ENF_NODES</source> <source>ENF_NODES</source>
<translation>Enforced nodes</translation> <translation>Enforced nodes</translation>
</message> </message>
<message>
<source>CORNERS</source>
<translation>Corner Vertices</translation>
</message>
</context> </context>
<context> <context>
<name>StdMeshersGUI_LayerDistributionParamWdg</name> <name>StdMeshersGUI_LayerDistributionParamWdg</name>