23315: [CEA 1929] Too much memory used to display a mesh in shading and wireframe

This commit is contained in:
eap 2016-10-24 18:07:46 +03:00
parent 0bd9fcdbe7
commit eef0bf5cc7
20 changed files with 348 additions and 222 deletions

View File

@ -26,23 +26,23 @@
// Module : SMESH
#include "SMESH_ActorDef.h"
#include "SMDS_UnstructuredGrid.hxx"
#include "SMESH_ActorUtils.h"
#include "SMESH_CellLabelActor.h"
#include "SMESH_ControlsDef.hxx"
#include "SMESH_DeviceActor.h"
#include "SMESH_NodeLabelActor.h"
#include "SMESH_CellLabelActor.h"
#include "SMESH_ObjectDef.h"
#include "SMESH_ControlsDef.hxx"
#include "SMDS_UnstructuredGrid.hxx"
#include "SMESH_ScalarBarActor.h"
#include "VTKViewer_ExtractUnstructuredGrid.h"
#include "VTKViewer_FramedTextActor.h"
#include "SALOME_InteractiveObject.hxx"
#include "SMESH_SVTKActor.h"
#include "SUIT_Session.h"
#include "SUIT_ResourceMgr.h"
#include "SMESH_ScalarBarActor.h"
#include <Qtx.h>
#include <SALOME_InteractiveObject.hxx>
#include <SUIT_ResourceMgr.h>
#include <SUIT_Session.h>
#include <VTKViewer_ExtractUnstructuredGrid.h>
#include <VTKViewer_FramedTextActor.h>
#ifndef DISABLE_PLOT2DVIEWER
#include <SPlot2d_Histogram.h>
@ -117,6 +117,9 @@ SMESH_Actor* SMESH_Actor::New(TVisualObjPtr theVisualObj,
SMESH_ActorDef::SMESH_ActorDef()
{
if(MYDEBUG) MESSAGE("SMESH_ActorDef - "<<this);
SALOME_Actor::SetVisibility(false); // avoid update of pipelines
myBaseActor = SMESH_DeviceActor::New();
myTimeStamp = vtkTimeStamp::New();
@ -1134,6 +1137,13 @@ int SMESH_ActorDef::GetNumberControlEntities()
void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer)
{
if ( !mySelector || !mySelector->IsSelectionEnabled() )
{
myBaseActor->SetUnstructuredGrid( NULL );
myHighlitableActor->SetUnstructuredGrid( NULL );
// theRenderer->AddActor(this);
// cout << "SMESH_ActorDef " << this << endl;
}
theRenderer->AddActor(myBaseActor);
theRenderer->AddActor(myNodeExtActor);
theRenderer->AddActor(my1DExtActor);
@ -1274,7 +1284,9 @@ bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
double* SMESH_ActorDef::GetBounds()
{
if ( GetNumberOfClippingPlanes() + myPlaneCollection->GetNumberOfItems() > 0 )
return myNodeActor->GetBounds();
return myVisualObj->GetUnstructuredGrid()->GetPoints()->GetBounds();
}
@ -1603,17 +1615,29 @@ void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
myBaseActor->myGeomFilter->SetInside(myEntityMode != myEntityState);
myEntityMode = theMode;
VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
aFilter = myBaseActor->GetExtractUnstructuredGrid();
aFilter->ClearRegisteredCellsWithType();
aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
VTKViewer_ExtractUnstructuredGrid* aFilter = myBaseActor->GetExtractUnstructuredGrid();
aFilter->ClearRegisteredCellsWithType();
VTKViewer_ExtractUnstructuredGrid* aHightFilter = myHighlitableActor->GetExtractUnstructuredGrid();
aHightFilter->ClearRegisteredCellsWithType();
bool isPassAll =
(( myEntityMode & e0DElements || myVisualObj->GetNbEntities(SMDSAbs_0DElement) == 0 ) &&
( myEntityMode & eBallElem || myVisualObj->GetNbEntities(SMDSAbs_Ball) == 0 ) &&
( myEntityMode & eEdges || myVisualObj->GetNbEntities(SMDSAbs_Edge) == 0 ) &&
( myEntityMode & eFaces || myVisualObj->GetNbEntities(SMDSAbs_Face) == 0 ) &&
( myEntityMode & eVolumes || myVisualObj->GetNbEntities(SMDSAbs_Volume) == 0 ));
if ( isPassAll && myEntityMode )
{
aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::ePassAll);
aHightFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::ePassAll);
}
else
{
aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
aHightFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
if (myEntityMode & e0DElements) {
if (MYDEBUG) MESSAGE("0D ELEMENTS");
aFilter->RegisterCellsWithType(VTK_VERTEX);
aHightFilter->RegisterCellsWithType(VTK_VERTEX);
}
@ -1623,7 +1647,6 @@ void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
}
if (myEntityMode & eEdges) {
if (MYDEBUG) MESSAGE("EDGES");
aFilter->RegisterCellsWithType(VTK_LINE);
aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
@ -1632,7 +1655,6 @@ void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
}
if (myEntityMode & eFaces) {
if (MYDEBUG) MESSAGE("FACES");
aFilter->RegisterCellsWithType(VTK_TRIANGLE);
aFilter->RegisterCellsWithType(VTK_QUAD);
aFilter->RegisterCellsWithType(VTK_POLYGON);
@ -1653,7 +1675,6 @@ void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
}
if (myEntityMode & eVolumes) {
if (MYDEBUG) MESSAGE("VOLUMES");
aFilter->RegisterCellsWithType(VTK_TETRA);
aFilter->RegisterCellsWithType(VTK_VOXEL);
aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
@ -1682,6 +1703,8 @@ void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
aHightFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
aHightFilter->RegisterCellsWithType(VTK_POLYHEDRON);
}
}
if ( GetVisibility() )
aFilter->Update();
if (MYDEBUG) MESSAGE(aFilter->GetOutput()->GetNumberOfCells());
SetVisibility(GetVisibility(),false);
@ -1835,6 +1858,11 @@ void SMESH_ActorDef::UpdateHighlight()
case SMESH_DeviceActor::eSurface:
case SMESH_DeviceActor::eWireframe:
{
// if ( !mySelector || !mySelector->IsSelectionEnabled() )
// myHighlitableActor->SetUnstructuredGrid( NULL );
// else if ( !myHighlitableActor->myExtractUnstructuredGrid->GetInput() )
// myHighlitableActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
if(myIsHighlighted) {
myHighlitableActor->SetProperty(myHighlightProp);
}else if(myIsPreselected){
@ -1868,6 +1896,24 @@ void SMESH_ActorDef::UpdateHighlight()
}
}
void SMESH_ActorDef::EnableSelection( bool enable )
{
// selection in the Viewer enabled/disabled
if ( enable && ! myBaseActor->myExtractUnstructuredGrid->GetInput() )
{
myBaseActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
myHighlitableActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
myBaseActor->myExtractUnstructuredGrid->Update();
myHighlitableActor->myExtractUnstructuredGrid->Update();
}
if ( !enable && myBaseActor->myExtractUnstructuredGrid->GetInput() )
{
myBaseActor->SetUnstructuredGrid( NULL );
myHighlitableActor->SetUnstructuredGrid( NULL );
myBaseActor->myExtractUnstructuredGrid->Update();
myHighlitableActor->myExtractUnstructuredGrid->Update();
}
}
void SMESH_ActorDef::highlight(bool theHighlight)
{
@ -2297,6 +2343,11 @@ void SMESH_ActorDef::SetOpenGLClippingPlane()
myHighlitableActor->SetPlaneCollection( myPlaneCollection );
myHighlitableActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
if ( !mySelector || !mySelector->IsSelectionEnabled() )
{
myBaseActor->SetUnstructuredGrid( NULL );
myHighlitableActor->SetUnstructuredGrid( NULL );
}
my1DActor->SetPlaneCollection( myPlaneCollection );
my1DActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());

View File

@ -95,6 +95,7 @@ class SMESH_ActorDef : public SMESH_Actor
virtual void AddToRender(vtkRenderer* theRenderer);
virtual void RemoveFromRender(vtkRenderer* theRenderer);
virtual void EnableSelection( bool enable );
virtual bool hasHighlight() { return true; }
virtual void highlight(bool theHighlight);
virtual void SetPreSelected(bool thePreselect = false);

View File

@ -204,7 +204,6 @@ SMESH_DeviceActor
SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
}
void
SMESH_DeviceActor
::SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
@ -224,12 +223,12 @@ void
SMESH_DeviceActor
::SetUnstructuredGrid(vtkUnstructuredGrid* theGrid)
{
if(theGrid){
//myIsShrinkable = theGrid->GetNumberOfCells() > 10;
myIsShrinkable = true;
myExtractUnstructuredGrid->SetInputData(theGrid);
if ( theGrid )
{
myIsShrinkable = true;
myMergeFilter->SetGeometryConnection(myExtractUnstructuredGrid->GetOutputPort());
//Pass diameters of the balls
@ -263,8 +262,8 @@ SMESH_DeviceActor
myMapper->SetClippingPlanes( myPlaneCollection );
vtkLODActor::SetMapper( myMapper );
Modified();
}
Modified();
}
void
@ -281,6 +280,7 @@ SMESH_DeviceActor
return myExtractUnstructuredGrid;
}
#include "SMDS_Mesh.hxx"
vtkUnstructuredGrid*
SMESH_DeviceActor
@ -611,6 +611,15 @@ unsigned long int
SMESH_DeviceActor
::GetMTime()
{
// cout << this->myExtractUnstructuredGrid
// << " " << this->Superclass::GetMTime()
// << " " << myExtractGeometry->GetMTime()
// << " " << myExtractUnstructuredGrid->GetMTime()
// << " " << myMergeFilter->GetMTime()
// << " " << myGeomFilter->GetMTime()
// << " " << myTransformFilter->GetMTime()
// << " " << myFaceOrientationFilter->GetMTime() << endl;
unsigned long mTime = this->Superclass::GetMTime();
mTime = max(mTime,myExtractGeometry->GetMTime());
mTime = max(mTime,myExtractUnstructuredGrid->GetMTime());
@ -718,7 +727,7 @@ SMESH_DeviceActor
::UpdateFaceOrientation()
{
bool aShowFaceOrientation = myIsFacesOriented;
aShowFaceOrientation &= GetVisibility();
aShowFaceOrientation &= vtkLODActor::GetVisibility(); //GetVisibility(); -- avoid calling GetUnstructuredGrid()
aShowFaceOrientation &= myRepresentation == eSurface;
myFaceOrientation->SetVisibility(aShowFaceOrientation);
}
@ -762,8 +771,9 @@ void
SMESH_DeviceActor
::SetVisibility(int theMode)
{
if(!myExtractUnstructuredGrid->GetInput() ||
GetUnstructuredGrid()->GetNumberOfCells())
if(( theMode ) &&
( !myExtractUnstructuredGrid->GetInput() ||
GetUnstructuredGrid()->GetNumberOfCells()))
{
vtkLODActor::SetVisibility(theMode);
}else{
@ -777,10 +787,12 @@ int
SMESH_DeviceActor
::GetVisibility()
{
if(!GetUnstructuredGrid()->GetNumberOfCells()){
int visibi = vtkLODActor::GetVisibility();
if(visibi && !GetUnstructuredGrid()->GetNumberOfCells()){
vtkLODActor::SetVisibility(false);
visibi = 0;
}
return vtkLODActor::GetVisibility();
return visibi;
}
@ -821,7 +833,7 @@ SMESH_DeviceActor
{
vtkDataSet* aDataSet = myMergeFilter->GetOutput();
vtkIdType anID = myVisualObj->GetNodeVTKId(theObjID);
double* aCoord = (anID >=0) ? aDataSet->GetPoint(anID) : NULL;
double* aCoord = (anID >=0 && anID < aDataSet->GetNumberOfPoints()) ? aDataSet->GetPoint(anID) : NULL;
if(MYDEBUG) MESSAGE("GetNodeCoord - theObjID = "<<theObjID<<"; anID = "<<anID);
return aCoord;
}

View File

@ -719,7 +719,7 @@ bool SMESH_MeshObj::NulData()
points->SetNumberOfPoints(0);
myEmptyGrid->SetPoints( points );
points->Delete();
myEmptyGrid->BuildLinks();
//myEmptyGrid->BuildLinks();
}
myGrid->ShallowCopy(myEmptyGrid);
return true;

View File

@ -119,11 +119,10 @@ SMESH_SVTKActor
myBallGrid->Initialize();
myBallGrid->Allocate();
vtkDataSet *aSourceDataSet = theMapActor->GetInput();
SVTK::CopyPoints( GetSource(), aSourceDataSet );
SVTK::CopyPoints( myBallGrid, aSourceDataSet );
SVTK::CopyPoints( my0DGrid, aSourceDataSet );
vtkUnstructuredGrid * aSourceGrid = (vtkUnstructuredGrid *)theMapActor->GetInput();
GetSource()->SetPoints( aSourceGrid->GetPoints() );
myBallGrid->SetPoints( aSourceGrid->GetPoints() );
my0DGrid->SetPoints( aSourceGrid->GetPoints() );
int aNbOfParts = theMapIndex.Extent();
@ -132,7 +131,7 @@ SMESH_SVTKActor
//Copy deamaters of the balls
if(myVisualObj) {
outputCD = myBallGrid->GetCellData();
cd = aSourceDataSet->GetCellData();
cd = aSourceGrid->GetCellData();
}
outputCD->CopyAllocate(cd,aNbOfParts,aNbOfParts/2);
for(int ind = 1; ind <= aNbOfParts; ind++){

View File

@ -160,7 +160,7 @@ SMDS_Mesh::SMDS_Mesh():
points->SetNumberOfPoints(0 /*SMDS_Mesh::chunkSize*/);
myGrid->SetPoints( points );
points->Delete();
myGrid->BuildLinks();
//myGrid->BuildLinks();
this->Modified();
// initialize static maps in SMDS_MeshCell, to be thread-safe
@ -2757,7 +2757,7 @@ void SMDS_Mesh::Clear()
points->SetNumberOfPoints(0 /*SMDS_Mesh::chunkSize*/);
myGrid->SetPoints( points );
points->Delete();
myGrid->BuildLinks();
myGrid->DeleteLinks();
}
///////////////////////////////////////////////////////////////////////////////
@ -4702,7 +4702,7 @@ void SMDS_Mesh::dumpGrid(string ficdump)
ficcon << endl;
}
ficcon << "-------------------------------- connectivity " << nbPoints << endl;
vtkCellLinks *links = myGrid->GetCellLinks();
vtkCellLinks *links = myGrid->GetLinks();
for (int i=0; i<nbPoints; i++)
{
int ncells = links->GetNcells(i);
@ -4720,7 +4720,7 @@ void SMDS_Mesh::dumpGrid(string ficdump)
void SMDS_Mesh::compactMesh()
{
MESSAGE("SMDS_Mesh::compactMesh do nothing!");
this->myCompactTime = this->myModifTime;
}
int SMDS_Mesh::fromVtkToSmds(int vtkid)
@ -4780,10 +4780,5 @@ unsigned long SMDS_Mesh::GetMTime() const
bool SMDS_Mesh::isCompacted()
{
if (this->myModifTime > this->myCompactTime)
{
this->myCompactTime = this->myModifTime;
return false;
}
return true;
return this->myCompactTime == this->myModifTime;
}

View File

@ -64,14 +64,10 @@ void SMDS_MeshNode::init(int id, int meshId, int shapeId, double x, double y, do
SMDS_MeshElement::init(id, meshId, shapeId);
myVtkID = id - 1;
assert(myVtkID >= 0);
//MESSAGE("Node " << myID << " " << myVtkID << " (" << x << ", " << y << ", " << z << ")");
SMDS_Mesh* mesh = SMDS_Mesh::_meshList[myMeshId];
SMDS_UnstructuredGrid * grid = mesh->getGrid();
SMDS_UnstructuredGrid * grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
vtkPoints *points = grid->GetPoints();
points->InsertPoint(myVtkID, x, y, z);
SMDS_CellLinks *cellLinks = dynamic_cast<SMDS_CellLinks*>(grid->GetCellLinks());
assert(cellLinks);
cellLinks->ResizeForPoint( myVtkID );
grid->GetLinks()->ResizeForPoint( myVtkID );
}
SMDS_MeshNode::~SMDS_MeshNode()
@ -91,6 +87,7 @@ void SMDS_MeshNode::RemoveInverseElement(const SMDS_MeshElement * parent)
//MESSAGE("RemoveInverseElement " << myID << " " << parent->GetID());
const SMDS_MeshCell* cell = dynamic_cast<const SMDS_MeshCell*>(parent);
MYASSERT(cell);
if ( SMDS_Mesh::_meshList[myMeshId]->getGrid()->HasLinks() )
SMDS_Mesh::_meshList[myMeshId]->getGrid()->RemoveReferenceToCell(myVtkID, cell->getVtkId());
}
@ -189,7 +186,7 @@ public:
SMDS_ElemIteratorPtr SMDS_MeshNode::GetInverseElementIterator(SMDSAbs_ElementType type) const
{
vtkCellLinks::Link l = SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetCellLinks()->GetLink(myVtkID);
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));
}
@ -248,7 +245,7 @@ elementsIterator(SMDSAbs_ElementType type) const
return SMDS_MeshElement::elementsIterator(SMDSAbs_Node);
else
{
vtkCellLinks::Link l = SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetCellLinks()->GetLink(myVtkID);
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));
}
}
@ -319,7 +316,7 @@ void SMDS_MeshNode::AddInverseElement(const SMDS_MeshElement* ME)
const SMDS_MeshCell *cell = dynamic_cast<const SMDS_MeshCell*> (ME);
assert(cell);
SMDS_UnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
vtkCellLinks *Links = grid->GetCellLinks();
vtkCellLinks *Links = grid->GetLinks();
Links->ResizeCellList(myVtkID, 1);
Links->AddCellReference(cell->getVtkId(), myVtkID);
}
@ -335,7 +332,7 @@ void SMDS_MeshNode::ClearInverseElements()
bool SMDS_MeshNode::emptyInverseElements()
{
vtkCellLinks::Link l = SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetCellLinks()->GetLink(myVtkID);
vtkCellLinks::Link l = SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetLinks()->GetLink(myVtkID);
return (l.ncells == 0);
}
@ -347,7 +344,7 @@ bool SMDS_MeshNode::emptyInverseElements()
int SMDS_MeshNode::NbInverseElements(SMDSAbs_ElementType type) const
{
vtkCellLinks::Link l = SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetCellLinks()->GetLink(myVtkID);
vtkCellLinks::Link l = SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetLinks()->GetLink(myVtkID);
if ( type == SMDSAbs_All )
return l.ncells;

View File

@ -53,6 +53,51 @@ void SMDS_CellLinks::ResizeForPoint(vtkIdType vtkID)
}
}
void SMDS_CellLinks::BuildLinks(vtkDataSet *data, vtkCellArray *Connectivity, vtkUnsignedCharArray* types)
{
// build links taking into account removed cells
vtkIdType numPts = data->GetNumberOfPoints();
vtkIdType j, cellId = 0;
unsigned short *linkLoc;
vtkIdType npts=0;
vtkIdType *pts=0;
vtkIdType loc = Connectivity->GetTraversalLocation();
// traverse data to determine number of uses of each point
cellId = 0;
for (Connectivity->InitTraversal();
Connectivity->GetNextCell(npts,pts); cellId++)
{
if ( types->GetValue( cellId ) != VTK_EMPTY_CELL )
for (j=0; j < npts; j++)
{
this->IncrementLinkCount(pts[j]);
}
}
// now allocate storage for the links
this->AllocateLinks(numPts);
this->MaxId = numPts - 1;
// fill out lists with references to cells
linkLoc = new unsigned short[numPts];
memset(linkLoc, 0, numPts*sizeof(unsigned short));
cellId = 0;
for (Connectivity->InitTraversal();
Connectivity->GetNextCell(npts,pts); cellId++)
{
if ( types->GetValue( cellId ) != VTK_EMPTY_CELL )
for (j=0; j < npts; j++)
{
this->InsertCellReference(pts[j], (linkLoc[pts[j]])++, cellId);
}
}
delete [] linkLoc;
Connectivity->SetTraversalLocation(loc);
}
SMDS_CellLinks::SMDS_CellLinks() :
vtkCellLinks()
{
@ -149,6 +194,8 @@ void SMDS_UnstructuredGrid::compactGrid(std::vector<int>& idNodesOldToNew, int n
//MESSAGE("------------------------- compactGrid " << newNodeSize << " " << newCellSize);//CHRONO(1);
int alreadyCopied = 0;
this->DeleteLinks();
// --- if newNodeSize, create a new compacted vtkPoints
vtkPoints *newPoints = vtkPoints::New();
@ -187,6 +234,12 @@ void SMDS_UnstructuredGrid::compactGrid(std::vector<int>& idNodesOldToNew, int n
int oldCellSize = this->Types->GetNumberOfTuples();
if ( oldCellSize == newCellSize )
{
for ( int i = 0; i < oldCellSize; ++i )
idCellsOldToNew[i] = i;
return;
}
vtkCellArray *newConnectivity = vtkCellArray::New();
newConnectivity->Initialize();
int oldCellDataSize = this->Connectivity->GetData()->GetSize();
@ -287,7 +340,6 @@ void SMDS_UnstructuredGrid::compactGrid(std::vector<int>& idNodesOldToNew, int n
newTypes->Delete();
newLocations->Delete();
newConnectivity->Delete();
this->BuildLinks();
}
void SMDS_UnstructuredGrid::copyNodes(vtkPoints * newPoints,
@ -979,13 +1031,30 @@ void SMDS_UnstructuredGrid::BuildLinks()
this->Links->UnRegister(this);
}
this->Links = SMDS_CellLinks::New();
SMDS_CellLinks* links;
this->Links = links = SMDS_CellLinks::New();
this->Links->Allocate(this->GetNumberOfPoints());
this->Links->Register(this);
this->Links->BuildLinks(this, this->Connectivity);
links->BuildLinks(this, this->Connectivity,this->GetCellTypesArray() );
this->Links->Delete();
}
void SMDS_UnstructuredGrid::DeleteLinks()
{
// Remove the old links if they are already built
if (this->Links)
{
this->Links->UnRegister(this);
this->Links = NULL;
}
}
SMDS_CellLinks* SMDS_UnstructuredGrid::GetLinks()
{
if ( !this->Links )
BuildLinks();
return static_cast< SMDS_CellLinks* >( this->Links );
}
/*! Create a volume (prism or hexahedron) by duplication of a face.
* Designed for use in creation of flat elements separating volume domains.
* A face separating two domains is shared by two volume cells.

View File

@ -54,6 +54,7 @@ class SMDS_EXPORT SMDS_CellLinks: public vtkCellLinks
{
public:
void ResizeForPoint(vtkIdType vtkID);
void BuildLinks(vtkDataSet *data, vtkCellArray *Connectivity, vtkUnsignedCharArray* types);
static SMDS_CellLinks* New();
protected:
SMDS_CellLinks();
@ -88,15 +89,15 @@ public:
void GetNodeIds(std::set<int>& nodeSet, int downId, unsigned char downType);
void ModifyCellNodes(int vtkVolId, std::map<int, int> localClonedNodeIds);
int getOrderedNodesOfFace(int vtkVolId, int& dim, std::vector<vtkIdType>& orderedNodes);
void BuildLinks();
SMDS_MeshCell* extrudeVolumeFromFace(int vtkVolId, int domain1, int domain2,
std::set<int>& originalNodes,
std::map<int, std::map<int, int> >& nodeDomains,
std::map<int, std::map<long,int> >& nodeQuadDomains);
vtkCellLinks* GetLinks()
{
return Links;
}
void BuildLinks();
void DeleteLinks();
SMDS_CellLinks* GetLinks();
bool HasLinks() const { return this->Links; }
SMDS_Downward* getDownArray(unsigned char vtkType)
{
return _downArray[vtkType];

View File

@ -123,13 +123,16 @@ SMESH_Mesh* SMESH_Gen::CreateMesh(int theStudyId, bool theIsEmbeddedMode)
bool SMESH_Gen::Compute(SMESH_Mesh & aMesh,
const TopoDS_Shape & aShape,
const bool aShapeOnly /*=false*/,
const bool anUpward /*=false*/,
const int aFlags /*= COMPACT_MESH*/,
const ::MeshDimension aDim /*=::MeshDim_3D*/,
TSetOfInt* aShapesId /*=0*/)
{
MEMOSTAT;
const bool aShapeOnly = aFlags & SHAPE_ONLY;
const bool anUpward = aFlags & UPWARD;
const bool aCompactMesh = aFlags & COMPACT_MESH;
bool ret = true;
SMESH_subMesh *sm = aMesh.GetSubMesh(aShape);
@ -141,7 +144,7 @@ bool SMESH_Gen::Compute(SMESH_Mesh & aMesh,
SMESH_subMeshIteratorPtr smIt;
// Fix of Issue 22150. Due to !BLSURF->OnlyUnaryInput(), BLSURF computes edges
// that must be computed by Projection 1D-2D when Projection asks to compute
// that must be computed by Projection 1D-2D while the Projection asks to compute
// one face only.
SMESH_subMesh::compute_event computeEvent =
aShapeOnly ? SMESH_subMesh::COMPUTE_SUBMESH : SMESH_subMesh::COMPUTE;
@ -331,7 +334,7 @@ bool SMESH_Gen::Compute(SMESH_Mesh & aMesh,
SMESH_Hypothesis::Hypothesis_Status status;
if ( subAlgo->CheckHypothesis( aMesh, aSubShape, status ))
// mesh a lower smToCompute starting from vertices
Compute( aMesh, aSubShape, true, /*anUpward=*/true, aDim, aShapesId );
Compute( aMesh, aSubShape, aFlags | SHAPE_ONLY_UPWARD, aDim, aShapesId );
// Compute( aMesh, aSubShape, aShapeOnly, /*anUpward=*/true, aDim, aShapesId );
}
}
@ -363,17 +366,17 @@ bool SMESH_Gen::Compute(SMESH_Mesh & aMesh,
// -----------------------------------------------
// mesh the rest sub-shapes starting from vertices
// -----------------------------------------------
ret = Compute( aMesh, aShape, aShapeOnly, /*anUpward=*/true, aDim, aShapesId );
ret = Compute( aMesh, aShape, aFlags | UPWARD, aDim, aShapesId );
}
MEMOSTAT;
SMESHDS_Mesh *myMesh = aMesh.GetMeshDS();
//MESSAGE("*** compactMesh after compute");
myMesh->compactMesh();
if ( aCompactMesh )
aMesh.GetMeshDS()->compactMesh();
// fix quadratic mesh by bending iternal links near concave boundary
if ( aShape.IsSame( aMesh.GetShapeToMesh() ) &&
if ( aCompactMesh && // a final compute
aShape.IsSame( aMesh.GetShapeToMesh() ) &&
!aShapesId && // not preview
ret ) // everything is OK
{

View File

@ -69,19 +69,25 @@ public:
SMESH_Mesh* CreateMesh(int theStudyId, bool theIsEmbeddedMode)
throw(SALOME_Exception);
enum ComputeFlags
{
SHAPE_ONLY = 1, // to ignore algo->OnlyUnaryInput() feature and to compute a given shape only.
UPWARD = 2, // to compute from vertices up to more complex shape (internal usage)
COMPACT_MESH = 4, // to compact the mesh at the end
SHAPE_ONLY_UPWARD = 3 // SHAPE_ONLY | UPWARD
};
/*!
* \brief Computes aMesh on aShape
* \param aShapeOnly - if true, algo->OnlyUnaryInput() feature is ignored and
* only \a aShape is computed.
* \param anUpward - compute from vertices up to more complex shape (internal usage)
* \param aDim - upper level dimension of the mesh computation
* \param aMesh - the mesh.
* \param aShape - the shape.
* \param aFlags - ComputeFlags. By default compute the whole mesh and compact at the end.
* \param aDim - upper level dimension of the mesh computation (for preview)
* \param aShapesId - list of shapes with computed mesh entities (elements or nodes)
* \retval bool - true if none submesh failed to compute
* \retval bool - true if none sub-mesh failed to compute
*/
bool Compute(::SMESH_Mesh & aMesh,
const TopoDS_Shape & aShape,
const bool aShapeOnly=false,
const bool anUpward=false,
const int aFlags = COMPACT_MESH,
const ::MeshDimension aDim=::MeshDim_3D,
TSetOfInt* aShapesId=0);

View File

@ -11650,7 +11650,7 @@ bool SMESH_MeshEditor::DoubleNodesOnGroupBoundaries( const std::vector<TIDSorted
}
meshDS->CleanDownWardConnectivity(); // Mesh has been modified, downward connectivity is no more usable, free memory
grid->BuildLinks();
grid->DeleteLinks();
CHRONOSTOP(50);
counters::stats();

View File

@ -2145,10 +2145,13 @@ SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
void SMESHDS_Mesh::compactMesh()
{
if ( isCompacted() )
return;
SMDS_Mesh::compactMesh();
int newNodeSize = 0;
int nbNodes = myNodes.size();
int nbVtkNodes = myGrid->GetNumberOfPoints();
//MESSAGE("nbNodes=" << nbNodes << " nbVtkNodes=" << nbVtkNodes);
int nbNodeTemp = nbVtkNodes;
if (nbNodes > nbVtkNodes)
nbNodeTemp = nbNodes;
@ -2166,13 +2169,11 @@ void SMESHDS_Mesh::compactMesh()
}
}
bool areNodesModified = (newNodeSize < nbVtkNodes);
//MESSAGE("------------------------- compactMesh Nodes Modified: " << areNodesModified);
areNodesModified = true;
int newCellSize = 0;
int nbCells = myCells.size();
int nbVtkCells = myGrid->GetNumberOfCells();
//MESSAGE("nbCells=" << nbCells << " nbVtkCells=" << nbVtkCells);
int nbCellTemp = nbVtkCells;
if (nbCells > nbVtkCells)
nbCellTemp = nbCells;
@ -2184,9 +2185,6 @@ void SMESHDS_Mesh::compactMesh()
{
if (myCells[i])
{
// //idCellsOldToNew[i] = myCellIdVtkToSmds[i]; // valid vtk indexes are > = 0
// int vtkid = myCells[i]->getVtkId();
// idCellsOldToNew[vtkid] = i; // old vtkId --> old smdsId (not used in input)
newCellSize++;
}
}
@ -2212,7 +2210,6 @@ void SMESHDS_Mesh::compactMesh()
if (areNodesModified)
{
//MESSAGE("-------------- modify myNodes");
SetOfNodes newNodes;
newNodes.resize(newNodeSize+1,0); // 0 not used, SMDS numbers 1..n
int newSmdsId = 0;
@ -2223,16 +2220,13 @@ void SMESHDS_Mesh::compactMesh()
newSmdsId++; // SMDS id start to 1
int oldVtkId = myNodes[i]->getVtkId();
int newVtkId = idNodesOldToNew[oldVtkId];
//MESSAGE("myNodes["<< i << "] vtkId " << oldVtkId << " --> " << newVtkId);
myNodes[i]->setVtkId(newVtkId);
myNodes[i]->setId(newSmdsId);
newNodes[newSmdsId] = myNodes[i];
//MESSAGE("myNodes["<< i << "] --> newNodes[" << newSmdsId << "]");
}
}
myNodes.swap(newNodes);
this->myNodeIDFactory->emptyPool(newSmdsId); // newSmdsId = number of nodes
//MESSAGE("myNodes.size " << myNodes.size());
}
// --- SMDS_MeshCell, myCellIdVtkToSmds, myCellIdSmdsToVtk, myCells
@ -2247,21 +2241,15 @@ void SMESHDS_Mesh::compactMesh()
int newVtkId = idCellsOldToNew[oldVtkId];
if (newVtkId > maxVtkId)
maxVtkId = newVtkId;
//MESSAGE("myCells["<< oldSmdsId << "] vtkId " << oldVtkId << " --> " << newVtkId);
myCells[oldSmdsId]->setVtkId(newVtkId);
}
}
// MESSAGE("myCells.size()=" << myCells.size()
// << " myCellIdSmdsToVtk.size()=" << myCellIdSmdsToVtk.size()
// << " myCellIdVtkToSmds.size()=" << myCellIdVtkToSmds.size() );
SetOfCells newCells;
//vector<int> newSmdsToVtk;
vector<int> newVtkToSmds;
assert(maxVtkId < newCellSize);
newCells.resize(newCellSize+1, 0); // 0 not used, SMDS numbers 1..n
//newSmdsToVtk.resize(newCellSize+1, -1);
newVtkToSmds.resize(newCellSize+1, -1);
int myCellsSize = myCells.size();
@ -2274,18 +2262,14 @@ void SMESHDS_Mesh::compactMesh()
assert(newSmdsId <= newCellSize);
newCells[newSmdsId] = myCells[i];
newCells[newSmdsId]->setId(newSmdsId);
//MESSAGE("myCells["<< i << "] --> newCells[" << newSmdsId << "]");
int idvtk = myCells[i]->getVtkId();
//newSmdsToVtk[newSmdsId] = idvtk;
assert(idvtk < newCellSize);
newVtkToSmds[idvtk] = newSmdsId;
}
}
myCells.swap(newCells);
//myCellIdSmdsToVtk.swap(newSmdsToVtk);
myCellIdVtkToSmds.swap(newVtkToSmds);
//MESSAGE("myCells.size()="<< myCells.size()<<" myCellIdVtkToSmds.size()="<<myCellIdVtkToSmds.size() );
this->myElementIDFactory->emptyPool(newSmdsId);
this->myScript->SetModified(true); // notify GUI client for buildPrs when update

View File

@ -2919,12 +2919,18 @@ SMESHGUI_MeshInfoDlg::~SMESHGUI_MeshInfoDlg()
*/
void SMESHGUI_MeshInfoDlg::showInfo( const Handle(SALOME_InteractiveObject)& IO )
{
if ( !IO.IsNull() )
myIO = IO;
SMESH::SMESH_IDSource_var obj = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>( IO );
if ( !CORBA::is_nil( obj ) ) {
if ( !CORBA::is_nil( obj ) )
{
myAddInfo->showInfo( obj ); // nb of nodes in a group can be computed by myAddInfo,
myBaseInfo->showInfo( obj ); // and it will be used by myBaseInfo (IPAL52871)
if ( myTabWidget->currentIndex() == CtrlInfo )
myCtrlInfo->showInfo( obj );
{
myActor = SMESH::FindActorByEntry( IO->getEntry() );
SVTK_Selector* selector = SMESH::GetSelector();
QString ID;
@ -2949,6 +2955,7 @@ void SMESHGUI_MeshInfoDlg::showInfo( const Handle(SALOME_InteractiveObject)& IO
}
}
}
}
/*!
\brief Perform clean-up actions on the dialog box closing.
@ -3049,11 +3056,9 @@ void SMESHGUI_MeshInfoDlg::updateInfo()
Handle(SALOME_InteractiveObject) IO = selected.First();
showInfo( IO );
}
// else {
// myBaseInfo->clear();
// myElemInfo->clear();
// myAddInfo->clear();
// }
else {
showInfo( myIO );
}
}
/*!

View File

@ -395,6 +395,7 @@ private:
SMESHGUI_AddInfo* myAddInfo;
SMESHGUI_CtrlInfo* myCtrlInfo;
SMESH_Actor* myActor;
Handle(SALOME_InteractiveObject) myIO;
};
class SMESHGUI_EXPORT SMESHGUI_CtrlInfoDlg : public QDialog

View File

@ -2001,7 +2001,7 @@ SMESH::MeshPreviewStruct* SMESH_Gen_i::Precompute( SMESH::SMESH_Mesh_ptr theMesh
::SMESH_Mesh& myLocMesh = meshServant->GetImpl();
TSetOfInt shapeIds;
::MeshDimension aDim = (MeshDimension)theDimension;
if ( myGen.Compute( myLocMesh, myLocShape, false, false, aDim, &shapeIds ) )
if ( myGen.Compute( myLocMesh, myLocShape, ::SMESH_Gen::COMPACT_MESH, aDim, &shapeIds ) )
{
int nbShapeId = shapeIds.size();
theShapesId.length( nbShapeId );

View File

@ -2952,8 +2952,9 @@ SMESH_MeshEditor_i::ExtrusionAlongPathObjects(const SMESH::ListOfIDSources & the
}
if ( !myIsPreviewMode ) {
aPythonDump << "(" << aGroups << ", error) = "
<< this << ".ExtrusionAlongPathObjects( "
if ( aGroups->length() > 0 ) aPythonDump << "(" << aGroups << ", error) = ";
else aPythonDump << "(_noGroups, error) = ";
aPythonDump << this << ".ExtrusionAlongPathObjects( "
<< theNodes << ", "
<< theEdges << ", "
<< theFaces << ", "

View File

@ -383,7 +383,7 @@ namespace
tmpMesh.ShapeToMesh( theEdges[i] );
try {
if ( !mesh->GetGen() ) continue; // tmp mesh
mesh->GetGen()->Compute( tmpMesh, theEdges[i], true, true ); // make nodes on VERTEXes
mesh->GetGen()->Compute( tmpMesh, theEdges[i], SMESH_Gen::SHAPE_ONLY_UPWARD ); // make nodes on VERTEXes
if ( !algo->Compute( tmpMesh, theEdges[i] ))
continue;
}
@ -868,7 +868,7 @@ namespace
TmpMesh tmpMesh;
tmpMesh.ShapeToMesh( branchEdge );
try {
mesh->GetGen()->Compute( tmpMesh, branchEdge, true, true ); // make nodes on VERTEXes
mesh->GetGen()->Compute( tmpMesh, branchEdge, SMESH_Gen::SHAPE_ONLY_UPWARD ); // make nodes on VERTEXes
if ( !algo->Compute( tmpMesh, branchEdge ))
return false;
}
@ -1930,7 +1930,8 @@ namespace
{
if ( !theHasRadialHyp )
// use global hyps
theHelper.GetGen()->Compute( *theHelper.GetMesh(), theShortEdges[i], true, true );
theHelper.GetGen()->Compute( *theHelper.GetMesh(), theShortEdges[i],
SMESH_Gen::SHAPE_ONLY_UPWARD );
SMESH_subMesh* sm = theHelper.GetMesh()->GetSubMesh(theShortEdges[i] );
if ( sm->IsEmpty() )

View File

@ -675,7 +675,7 @@ bool StdMeshers_Regular_1D::computeInternalParameters(SMESH_Mesh & theMesh,
if ( !_mainEdge.IsNull() && _isPropagOfDistribution )
{
TopoDS_Edge mainEdge = TopoDS::Edge( _mainEdge ); // should not be a reference!
_gen->Compute( theMesh, mainEdge, /*aShapeOnly=*/true, /*anUpward=*/true);
_gen->Compute( theMesh, mainEdge, SMESH_Gen::SHAPE_ONLY_UPWARD );
SMESHDS_SubMesh* smDS = theMesh.GetMeshDS()->MeshElements( mainEdge );
if ( !smDS )