mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-01-27 04:00:34 +05:00
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:
parent
e0cbb6f531
commit
8a1ff9ba77
@ -280,6 +280,7 @@ void SMESH_VisualObjDef::buildPrs(bool buildGrid)
|
||||
myLocalGrid = false;
|
||||
if (!GetMesh()->isCompacted())
|
||||
{
|
||||
NulData(); // detach from the SMDS grid to allow immediate memory de-allocation in compactMesh()
|
||||
if ( MYDEBUG ) MESSAGE("*** buildPrs ==> compactMesh!");
|
||||
GetMesh()->compactMesh();
|
||||
}
|
||||
@ -570,6 +571,7 @@ vtkUnstructuredGrid* SMESH_VisualObjDef::GetUnstructuredGrid()
|
||||
{
|
||||
if ( !myLocalGrid && !GetMesh()->isCompacted() )
|
||||
{
|
||||
NulData(); // detach from the SMDS grid to allow immediate memory de-allocation in compactMesh()
|
||||
GetMesh()->compactMesh();
|
||||
updateEntitiesFlags();
|
||||
vtkUnstructuredGrid *theGrid = GetMesh()->getGrid();
|
||||
|
@ -155,26 +155,33 @@ void SMDS_UnstructuredGrid::compactGrid(std::vector<int>& idNodesOldToNew, int n
|
||||
newPoints->SetDataType(VTK_DOUBLE);
|
||||
newPoints->SetNumberOfPoints(newNodeSize);
|
||||
if (newNodeSize)
|
||||
{
|
||||
// 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.
|
||||
int oldNodeSize = idNodesOldToNew.size();
|
||||
{
|
||||
// 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.
|
||||
int oldNodeSize = idNodesOldToNew.size();
|
||||
|
||||
int i = 0;
|
||||
while ( i < oldNodeSize )
|
||||
{
|
||||
// skip a hole if any
|
||||
while ( i < oldNodeSize && idNodesOldToNew[i] < 0 )
|
||||
++i;
|
||||
int startBloc = i;
|
||||
// look for a block end
|
||||
while ( i < oldNodeSize && idNodesOldToNew[i] >= 0 )
|
||||
++i;
|
||||
int endBloc = i;
|
||||
copyNodes(newPoints, idNodesOldToNew, alreadyCopied, startBloc, endBloc);
|
||||
}
|
||||
newPoints->Squeeze();
|
||||
int i = 0;
|
||||
while ( i < oldNodeSize )
|
||||
{
|
||||
// skip a hole if any
|
||||
while ( i < oldNodeSize && idNodesOldToNew[i] < 0 )
|
||||
++i;
|
||||
int startBloc = i;
|
||||
// look for a block end
|
||||
while ( i < oldNodeSize && idNodesOldToNew[i] >= 0 )
|
||||
++i;
|
||||
int endBloc = i;
|
||||
copyNodes(newPoints, idNodesOldToNew, alreadyCopied, startBloc, endBloc);
|
||||
}
|
||||
newPoints->Squeeze();
|
||||
}
|
||||
|
||||
if (1/*newNodeSize*/)
|
||||
{
|
||||
this->SetPoints(newPoints);
|
||||
}
|
||||
newPoints->Delete();
|
||||
|
||||
|
||||
// --- create new compacted Connectivity, Locations and Types
|
||||
|
||||
@ -218,11 +225,6 @@ void SMDS_UnstructuredGrid::compactGrid(std::vector<int>& idNodesOldToNew, int n
|
||||
}
|
||||
newConnectivity->Squeeze();
|
||||
|
||||
if (1/*newNodeSize*/)
|
||||
{
|
||||
this->SetPoints(newPoints);
|
||||
}
|
||||
|
||||
if (vtkDoubleArray* diameters =
|
||||
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);
|
||||
}
|
||||
|
||||
newPoints->Delete();
|
||||
newTypes->Delete();
|
||||
newLocations->Delete();
|
||||
newConnectivity->Delete();
|
||||
|
@ -3994,11 +3994,11 @@ void SMESH_MeshEditor::Smooth (TIDSortedElemSet & theElems,
|
||||
fToler2 = BRep_Tool::Tolerance( face );
|
||||
fToler2 *= fToler2 * 10.;
|
||||
isUPeriodic = surface->IsUPeriodic();
|
||||
if ( isUPeriodic )
|
||||
surface->UPeriod();
|
||||
// if ( isUPeriodic )
|
||||
// surface->UPeriod();
|
||||
isVPeriodic = surface->IsVPeriodic();
|
||||
if ( isVPeriodic )
|
||||
surface->VPeriod();
|
||||
// if ( isVPeriodic )
|
||||
// surface->VPeriod();
|
||||
surface->Bounds( u1, u2, v1, v2 );
|
||||
helper.SetSubShape( face );
|
||||
}
|
||||
@ -4057,9 +4057,9 @@ void SMESH_MeshEditor::Smooth (TIDSortedElemSet & theElems,
|
||||
{
|
||||
// check if all faces around the node are on faceSubMesh
|
||||
// because a node on edge may be bound to face
|
||||
SMDS_ElemIteratorPtr eIt = node->GetInverseElementIterator(SMDSAbs_Face);
|
||||
bool all = true;
|
||||
if ( faceSubMesh ) {
|
||||
SMDS_ElemIteratorPtr eIt = node->GetInverseElementIterator(SMDSAbs_Face);
|
||||
while ( eIt->more() && all ) {
|
||||
const SMDS_MeshElement* e = eIt->next();
|
||||
all = faceSubMesh->Contains( e );
|
||||
|
@ -1398,11 +1398,7 @@ int SMESHDS_Mesh::MaxSubMeshIndex() const
|
||||
//=======================================================================
|
||||
int SMESHDS_Mesh::ShapeToIndex(const TopoDS_Shape & S) const
|
||||
{
|
||||
if (myShape.IsNull())
|
||||
MESSAGE("myShape is NULL");
|
||||
|
||||
int index = myIndexToShape.FindIndex(S);
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
|
@ -975,6 +975,7 @@ namespace
|
||||
aSel->selectedObjects( selected );
|
||||
|
||||
if ( selected.Extent() >= 1 ) {
|
||||
SUIT_OverrideCursor wc;
|
||||
SALOME_ListIteratorOfListIO It( selected );
|
||||
for( ; It.More(); It.Next()){
|
||||
Handle(SALOME_InteractiveObject) IObject = It.Value();
|
||||
@ -1595,6 +1596,7 @@ namespace
|
||||
return;
|
||||
} // case SMESHOp::OpProperties:
|
||||
} // switch(theCommandID)
|
||||
SUIT_OverrideCursor wc;
|
||||
SALOME_ListIteratorOfListIO It( selected );
|
||||
for( ; It.More(); It.Next()){
|
||||
Handle(SALOME_InteractiveObject) IObject = It.Value();
|
||||
@ -2599,6 +2601,7 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
|
||||
|
||||
case SMESHOp::OpOrientationOnFaces:
|
||||
{
|
||||
SUIT_OverrideCursor wc;
|
||||
LightApp_SelectionMgr* mgr = selectionMgr();
|
||||
SALOME_ListIO selected; mgr->selectedObjects( selected );
|
||||
|
||||
|
@ -162,6 +162,12 @@ namespace {
|
||||
{
|
||||
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 );
|
||||
bool isPlanar = GeomLib_IsPlanarSurface( surface ).IsPlanar();
|
||||
|
||||
bool isFixed = false;
|
||||
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 =
|
||||
iAttemp ? SMESH_MeshEditor::CENTROIDAL : SMESH_MeshEditor::LAPLACIAN;
|
||||
isCentroidal ? SMESH_MeshEditor::CENTROIDAL : SMESH_MeshEditor::LAPLACIAN;
|
||||
|
||||
// smoothing
|
||||
editor.Smooth( faces, fixedNodes, algo, /*nbIterations=*/ 10,
|
||||
/*theTgtAspectRatio=*/1.0, /*the2D=*/!isPlanar);
|
||||
int nbAttempts = isCentroidal ? 1 : 10;
|
||||
for ( int iAttemp = 0; iAttemp < nbAttempts; ++iAttemp )
|
||||
{
|
||||
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()
|
||||
<< " to face #" << topSM->GetId()
|
||||
<< " failed: inverted elements created"));
|
||||
}
|
||||
|
||||
TProjction2dAlgo::instance( this )->SetEventListener( topSM );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -2426,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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user