Fix regression of SALOME_TESTS/Grids/smesh/3D_mesh_Extrusion_01/B2

(StdMeshers_Prism_3D.cxx)

+ small optimization of SMDS_UnstructuredGrid::compactGrid()
   (SMDS_UnstructuredGrid.cxx, SMESH_Object.cxx)
   - de-allocate old data as soon as possible, not at the and of compacting

+ some minor changes
This commit is contained in:
eap 2016-09-01 20:47:02 +03:00
parent e0cbb6f531
commit 8a1ff9ba77
6 changed files with 65 additions and 45 deletions

View File

@ -280,6 +280,7 @@ void SMESH_VisualObjDef::buildPrs(bool buildGrid)
myLocalGrid = false; myLocalGrid = false;
if (!GetMesh()->isCompacted()) if (!GetMesh()->isCompacted())
{ {
NulData(); // detach from the SMDS grid to allow immediate memory de-allocation in compactMesh()
if ( MYDEBUG ) MESSAGE("*** buildPrs ==> compactMesh!"); if ( MYDEBUG ) MESSAGE("*** buildPrs ==> compactMesh!");
GetMesh()->compactMesh(); GetMesh()->compactMesh();
} }
@ -570,6 +571,7 @@ vtkUnstructuredGrid* SMESH_VisualObjDef::GetUnstructuredGrid()
{ {
if ( !myLocalGrid && !GetMesh()->isCompacted() ) if ( !myLocalGrid && !GetMesh()->isCompacted() )
{ {
NulData(); // detach from the SMDS grid to allow immediate memory de-allocation in compactMesh()
GetMesh()->compactMesh(); GetMesh()->compactMesh();
updateEntitiesFlags(); updateEntitiesFlags();
vtkUnstructuredGrid *theGrid = GetMesh()->getGrid(); vtkUnstructuredGrid *theGrid = GetMesh()->getGrid();

View File

@ -155,26 +155,33 @@ void SMDS_UnstructuredGrid::compactGrid(std::vector<int>& idNodesOldToNew, int n
newPoints->SetDataType(VTK_DOUBLE); newPoints->SetDataType(VTK_DOUBLE);
newPoints->SetNumberOfPoints(newNodeSize); newPoints->SetNumberOfPoints(newNodeSize);
if (newNodeSize) if (newNodeSize)
{ {
// rnv: to fix bug "21125: EDF 1233 SMESH: Degradation of precision in a test case for quadratic conversion" // rnv: to fix bug "21125: EDF 1233 SMESH: Degradation of precision in a test case for quadratic conversion"
// using double type for storing coordinates of nodes instead float. // using double type for storing coordinates of nodes instead float.
int oldNodeSize = idNodesOldToNew.size(); int oldNodeSize = idNodesOldToNew.size();
int i = 0; int i = 0;
while ( i < oldNodeSize ) while ( i < oldNodeSize )
{ {
// skip a hole if any // skip a hole if any
while ( i < oldNodeSize && idNodesOldToNew[i] < 0 ) while ( i < oldNodeSize && idNodesOldToNew[i] < 0 )
++i; ++i;
int startBloc = i; int startBloc = i;
// look for a block end // look for a block end
while ( i < oldNodeSize && idNodesOldToNew[i] >= 0 ) while ( i < oldNodeSize && idNodesOldToNew[i] >= 0 )
++i; ++i;
int endBloc = i; int endBloc = i;
copyNodes(newPoints, idNodesOldToNew, alreadyCopied, startBloc, endBloc); copyNodes(newPoints, idNodesOldToNew, alreadyCopied, startBloc, endBloc);
}
newPoints->Squeeze();
} }
newPoints->Squeeze();
}
if (1/*newNodeSize*/)
{
this->SetPoints(newPoints);
}
newPoints->Delete();
// --- create new compacted Connectivity, Locations and Types // --- create new compacted Connectivity, Locations and Types
@ -218,11 +225,6 @@ void SMDS_UnstructuredGrid::compactGrid(std::vector<int>& idNodesOldToNew, int n
} }
newConnectivity->Squeeze(); newConnectivity->Squeeze();
if (1/*newNodeSize*/)
{
this->SetPoints(newPoints);
}
if (vtkDoubleArray* diameters = if (vtkDoubleArray* diameters =
vtkDoubleArray::SafeDownCast( vtkDataSet::CellData->GetScalars() )) // Balls vtkDoubleArray::SafeDownCast( vtkDataSet::CellData->GetScalars() )) // Balls
{ {
@ -282,7 +284,6 @@ void SMDS_UnstructuredGrid::compactGrid(std::vector<int>& idNodesOldToNew, int n
this->SetCells(newTypes, newLocations, newConnectivity, FaceLocations, Faces); this->SetCells(newTypes, newLocations, newConnectivity, FaceLocations, Faces);
} }
newPoints->Delete();
newTypes->Delete(); newTypes->Delete();
newLocations->Delete(); newLocations->Delete();
newConnectivity->Delete(); newConnectivity->Delete();

View File

@ -3994,11 +3994,11 @@ void SMESH_MeshEditor::Smooth (TIDSortedElemSet & theElems,
fToler2 = BRep_Tool::Tolerance( face ); fToler2 = BRep_Tool::Tolerance( face );
fToler2 *= fToler2 * 10.; fToler2 *= fToler2 * 10.;
isUPeriodic = surface->IsUPeriodic(); isUPeriodic = surface->IsUPeriodic();
if ( isUPeriodic ) // if ( isUPeriodic )
surface->UPeriod(); // surface->UPeriod();
isVPeriodic = surface->IsVPeriodic(); isVPeriodic = surface->IsVPeriodic();
if ( isVPeriodic ) // if ( isVPeriodic )
surface->VPeriod(); // surface->VPeriod();
surface->Bounds( u1, u2, v1, v2 ); surface->Bounds( u1, u2, v1, v2 );
helper.SetSubShape( face ); helper.SetSubShape( face );
} }
@ -4057,9 +4057,9 @@ void SMESH_MeshEditor::Smooth (TIDSortedElemSet & theElems,
{ {
// check if all faces around the node are on faceSubMesh // check if all faces around the node are on faceSubMesh
// because a node on edge may be bound to face // because a node on edge may be bound to face
SMDS_ElemIteratorPtr eIt = node->GetInverseElementIterator(SMDSAbs_Face);
bool all = true; bool all = true;
if ( faceSubMesh ) { if ( faceSubMesh ) {
SMDS_ElemIteratorPtr eIt = node->GetInverseElementIterator(SMDSAbs_Face);
while ( eIt->more() && all ) { while ( eIt->more() && all ) {
const SMDS_MeshElement* e = eIt->next(); const SMDS_MeshElement* e = eIt->next();
all = faceSubMesh->Contains( e ); all = faceSubMesh->Contains( e );

View File

@ -1398,11 +1398,7 @@ int SMESHDS_Mesh::MaxSubMeshIndex() const
//======================================================================= //=======================================================================
int SMESHDS_Mesh::ShapeToIndex(const TopoDS_Shape & S) const int SMESHDS_Mesh::ShapeToIndex(const TopoDS_Shape & S) const
{ {
if (myShape.IsNull())
MESSAGE("myShape is NULL");
int index = myIndexToShape.FindIndex(S); int index = myIndexToShape.FindIndex(S);
return index; return index;
} }

View File

@ -975,6 +975,7 @@ namespace
aSel->selectedObjects( selected ); aSel->selectedObjects( selected );
if ( selected.Extent() >= 1 ) { if ( selected.Extent() >= 1 ) {
SUIT_OverrideCursor wc;
SALOME_ListIteratorOfListIO It( selected ); SALOME_ListIteratorOfListIO It( selected );
for( ; It.More(); It.Next()){ for( ; It.More(); It.Next()){
Handle(SALOME_InteractiveObject) IObject = It.Value(); Handle(SALOME_InteractiveObject) IObject = It.Value();
@ -1595,6 +1596,7 @@ namespace
return; return;
} // case SMESHOp::OpProperties: } // case SMESHOp::OpProperties:
} // switch(theCommandID) } // switch(theCommandID)
SUIT_OverrideCursor wc;
SALOME_ListIteratorOfListIO It( selected ); SALOME_ListIteratorOfListIO It( selected );
for( ; It.More(); It.Next()){ for( ; It.More(); It.Next()){
Handle(SALOME_InteractiveObject) IObject = It.Value(); Handle(SALOME_InteractiveObject) IObject = It.Value();
@ -2599,6 +2601,7 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
case SMESHOp::OpOrientationOnFaces: case SMESHOp::OpOrientationOnFaces:
{ {
SUIT_OverrideCursor wc;
LightApp_SelectionMgr* mgr = selectionMgr(); LightApp_SelectionMgr* mgr = selectionMgr();
SALOME_ListIO selected; mgr->selectedObjects( selected ); SALOME_ListIO selected; mgr->selectedObjects( selected );

View File

@ -162,6 +162,12 @@ namespace {
{ {
return _src2tgtNodes; return _src2tgtNodes;
} }
void SetEventListener( SMESH_subMesh* tgtSubMesh )
{
NSProjUtils::SetEventListener( tgtSubMesh,
_sourceHypo->GetSourceFace(),
_sourceHypo->GetSourceMesh() );
}
}; };
//======================================================================= //=======================================================================
/*! /*!
@ -2265,29 +2271,39 @@ bool StdMeshers_Prism_3D::projectBottomToTop( const gp_Trsf & bottom
Handle(Geom_Surface) surface = BRep_Tool::Surface( topFace, loc ); Handle(Geom_Surface) surface = BRep_Tool::Surface( topFace, loc );
bool isPlanar = GeomLib_IsPlanarSurface( surface ).IsPlanar(); bool isPlanar = GeomLib_IsPlanarSurface( surface ).IsPlanar();
bool isFixed = false;
set<const SMDS_MeshNode*> fixedNodes; set<const SMDS_MeshNode*> fixedNodes;
for ( int iAttemp = 0; !isFixed && iAttemp < 10; ++iAttemp ) TIDSortedElemSet faces;
for ( faceIt = topSMDS->GetElements(); faceIt->more(); )
faces.insert( faces.end(), faceIt->next() );
bool isOk = false;
for ( int isCentroidal = 0; isCentroidal < 2; ++isCentroidal )
{ {
TIDSortedElemSet faces;
for ( faceIt = topSMDS->GetElements(); faceIt->more(); )
faces.insert( faces.end(), faceIt->next() );
SMESH_MeshEditor::SmoothMethod algo = SMESH_MeshEditor::SmoothMethod algo =
iAttemp ? SMESH_MeshEditor::CENTROIDAL : SMESH_MeshEditor::LAPLACIAN; isCentroidal ? SMESH_MeshEditor::CENTROIDAL : SMESH_MeshEditor::LAPLACIAN;
// smoothing int nbAttempts = isCentroidal ? 1 : 10;
editor.Smooth( faces, fixedNodes, algo, /*nbIterations=*/ 10, for ( int iAttemp = 0; iAttemp < nbAttempts; ++iAttemp )
/*theTgtAspectRatio=*/1.0, /*the2D=*/!isPlanar); {
TIDSortedElemSet workFaces = faces;
isFixed = !topHelper.IsDistorted2D( topSM, /*checkUV=*/true ); // smoothing
editor.Smooth( workFaces, fixedNodes, algo, /*nbIterations=*/ 10,
/*theTgtAspectRatio=*/1.0, /*the2D=*/!isPlanar);
if (( isOk = !topHelper.IsDistorted2D( topSM, /*checkUV=*/true )) &&
( !isCentroidal ))
break;
}
} }
if ( !isFixed ) if ( !isOk )
return toSM( error( TCom("Projection from face #") << botSM->GetId() return toSM( error( TCom("Projection from face #") << botSM->GetId()
<< " to face #" << topSM->GetId() << " to face #" << topSM->GetId()
<< " failed: inverted elements created")); << " failed: inverted elements created"));
} }
TProjction2dAlgo::instance( this )->SetEventListener( topSM );
return true; return true;
} }
@ -2426,6 +2442,8 @@ bool StdMeshers_Prism_3D::project2dMesh(const TopoDS_Face& theSrcFace,
tgtSM->ComputeStateEngine ( SMESH_subMesh::CHECK_COMPUTE_STATE ); tgtSM->ComputeStateEngine ( SMESH_subMesh::CHECK_COMPUTE_STATE );
tgtSM->ComputeSubMeshStateEngine( SMESH_subMesh::CHECK_COMPUTE_STATE ); tgtSM->ComputeSubMeshStateEngine( SMESH_subMesh::CHECK_COMPUTE_STATE );
projector2D->SetEventListener( tgtSM );
return ok; return ok;
} }