PR: debug SMDS memimp

This commit is contained in:
prascle 2010-05-13 08:07:39 +00:00
parent 7163ce5c50
commit e3214b68d2
15 changed files with 203 additions and 49 deletions

View File

@ -532,12 +532,20 @@ bool SMESH_VisualObjDef::GetEdgeNodes( const int theElemId,
return true; return true;
} }
vtkUnstructuredGrid* SMESH_VisualObjDef::GetUnstructuredGrid()
{
MESSAGE("SMESH_VisualObjDef::GetUnstructuredGrid " << myGrid);
return myGrid;
}
//================================================================================= //=================================================================================
// function : IsValid // function : IsValid
// purpose : Return true if there are some entities // purpose : Return true if there are some entities
//================================================================================= //=================================================================================
bool SMESH_VisualObjDef::IsValid() const bool SMESH_VisualObjDef::IsValid() const
{ {
MESSAGE("SMESH_VisualObjDef::IsValid");
return GetNbEntities(SMDSAbs_Node) > 0 || return GetNbEntities(SMDSAbs_Node) > 0 ||
GetNbEntities(SMDSAbs_0DElement) > 0 || GetNbEntities(SMDSAbs_0DElement) > 0 ||
GetNbEntities(SMDSAbs_Edge) > 0 || GetNbEntities(SMDSAbs_Edge) > 0 ||
@ -557,6 +565,7 @@ bool SMESH_VisualObjDef::IsValid() const
SMESH_MeshObj::SMESH_MeshObj(SMESH::SMESH_Mesh_ptr theMesh): SMESH_MeshObj::SMESH_MeshObj(SMESH::SMESH_Mesh_ptr theMesh):
myClient(SalomeApp_Application::orb(),theMesh) myClient(SalomeApp_Application::orb(),theMesh)
{ {
myEmptyGrid = 0;
if ( MYDEBUG ) if ( MYDEBUG )
MESSAGE("SMESH_MeshObj - this = "<<this<<"; theMesh->_is_nil() = "<<theMesh->_is_nil()); MESSAGE("SMESH_MeshObj - this = "<<this<<"; theMesh->_is_nil() = "<<theMesh->_is_nil());
} }
@ -578,6 +587,7 @@ SMESH_MeshObj::~SMESH_MeshObj()
bool SMESH_MeshObj::Update( int theIsClear ) bool SMESH_MeshObj::Update( int theIsClear )
{ {
// Update SMDS_Mesh on client part // Update SMDS_Mesh on client part
MESSAGE("SMESH_MeshObj::Update");
if ( myClient.Update(theIsClear) || GetUnstructuredGrid()->GetNumberOfPoints()==0) { if ( myClient.Update(theIsClear) || GetUnstructuredGrid()->GetNumberOfPoints()==0) {
buildPrs(); // Fill unstructured grid buildPrs(); // Fill unstructured grid
return true; return true;
@ -585,6 +595,22 @@ bool SMESH_MeshObj::Update( int theIsClear )
return false; return false;
} }
bool SMESH_MeshObj::NulData()
{
MESSAGE ("SMESH_MeshObj::NulData() ==================================================================================");
if (!myEmptyGrid)
{
myEmptyGrid = SMDS_UnstructuredGrid::New();
myEmptyGrid->Initialize();
myEmptyGrid->Allocate();
vtkPoints* points = vtkPoints::New();
points->SetNumberOfPoints(0);
myEmptyGrid->SetPoints( points );
points->Delete();
myEmptyGrid->BuildLinks();
}
myGrid->ShallowCopy(myEmptyGrid);
}
//================================================================================= //=================================================================================
// function : GetElemDimension // function : GetElemDimension
// purpose : Get dimension of element // purpose : Get dimension of element

View File

@ -55,6 +55,7 @@ class SMESHOBJECT_EXPORT SMESH_VisualObj
{ {
public: public:
virtual bool Update( int theIsClear = true ) = 0; virtual bool Update( int theIsClear = true ) = 0;
virtual bool NulData() = 0;
virtual void UpdateFunctor( const SMESH::Controls::FunctorPtr& theFunctor ) = 0; virtual void UpdateFunctor( const SMESH::Controls::FunctorPtr& theFunctor ) = 0;
virtual int GetElemDimension( const int theObjId ) = 0; virtual int GetElemDimension( const int theObjId ) = 0;

View File

@ -61,6 +61,7 @@ public:
virtual ~SMESH_VisualObjDef(); virtual ~SMESH_VisualObjDef();
virtual bool Update( int theIsClear = true ) = 0; virtual bool Update( int theIsClear = true ) = 0;
virtual bool NulData() {return 0; };
virtual void UpdateFunctor( const SMESH::Controls::FunctorPtr& theFunctor ) = 0; virtual void UpdateFunctor( const SMESH::Controls::FunctorPtr& theFunctor ) = 0;
virtual int GetElemDimension( const int theObjId ) = 0; virtual int GetElemDimension( const int theObjId ) = 0;
@ -76,7 +77,7 @@ public:
int& theNodeId1, int& theNodeId1,
int& theNodeId2 ) const; int& theNodeId2 ) const;
virtual vtkUnstructuredGrid* GetUnstructuredGrid() { return myGrid; } virtual vtkUnstructuredGrid* GetUnstructuredGrid(); // { return myGrid; }
virtual vtkIdType GetNodeObjId( int theVTKID ); virtual vtkIdType GetNodeObjId( int theVTKID );
virtual vtkIdType GetNodeVTKId( int theObjID ); virtual vtkIdType GetNodeVTKId( int theObjID );
@ -90,7 +91,7 @@ protected:
// void buildNodePrs(); // void buildNodePrs();
// void buildElemPrs(); // void buildElemPrs();
private: //private:
// TMapOfIds mySMDS2VTKNodes; // TMapOfIds mySMDS2VTKNodes;
// TMapOfIds myVTK2SMDSNodes; // TMapOfIds myVTK2SMDSNodes;
@ -114,6 +115,7 @@ public:
virtual ~SMESH_MeshObj(); virtual ~SMESH_MeshObj();
virtual bool Update( int theIsClear = true ); virtual bool Update( int theIsClear = true );
virtual bool NulData();
virtual int GetNbEntities( const SMDSAbs_ElementType) const; virtual int GetNbEntities( const SMDSAbs_ElementType) const;
virtual int GetEntities( const SMDSAbs_ElementType, TEntityList& ) const; virtual int GetEntities( const SMDSAbs_ElementType, TEntityList& ) const;
@ -128,6 +130,7 @@ public:
protected: protected:
SMESH_Client myClient; SMESH_Client myClient;
vtkUnstructuredGrid* myEmptyGrid;
}; };

View File

@ -1,3 +1,16 @@
Problemes en cours
==================
- visualisation de groupe (type d'element): on voit tout le maillage, mais le groupe est OK
- inversion d'un volume (tetra): exception
- script de creation de noeuds et d'elements: OK, mais pas compatible avec version precedente (numerotation noeuds differente)
- affichage numeros noeuds: numeros en trop sur O (enlever dans vtkUnstructuredGrid)
A tester, non pris en compte
============================
- engine standalone
- polyedres (attendre vtk)
=============================== Hypothese de refonte de l'API de SMDS =============================== Hypothese de refonte de l'API de SMDS

View File

@ -2255,7 +2255,8 @@ SMDS_Mesh::~SMDS_Mesh()
void SMDS_Mesh::Clear() void SMDS_Mesh::Clear()
{ {
if (myParent!=NULL) { if (myParent!=NULL)
{
SMDS_ElemIteratorPtr eIt = elementsIterator(); SMDS_ElemIteratorPtr eIt = elementsIterator();
while ( eIt->more() ) while ( eIt->more() )
myElementIDFactory->ReleaseID(eIt->next()->GetID()); myElementIDFactory->ReleaseID(eIt->next()->GetID());
@ -2263,39 +2264,43 @@ void SMDS_Mesh::Clear()
while (itn->more()) while (itn->more())
myNodeIDFactory->ReleaseID(itn->next()->GetID()); myNodeIDFactory->ReleaseID(itn->next()->GetID());
} }
else { else
{
myNodeIDFactory->Clear(); myNodeIDFactory->Clear();
myElementIDFactory->Clear(); myElementIDFactory->Clear();
} }
SMDS_ElemIteratorPtr itv = elementsIterator(); SMDS_ElemIteratorPtr itv = elementsIterator();
while (itv->more()) while (itv->more())
delete itv->next(); {
SMDS_MeshElement* elem = (SMDS_MeshElement*)(itv->next());
SMDSAbs_ElementType aType = elem->GetType();
switch (aType)
{
case SMDSAbs_0DElement:
delete elem;
break;
case SMDSAbs_Edge:
myEdgePool->destroy(static_cast<SMDS_VtkEdge*>(elem));
break;
case SMDSAbs_Face:
myFacePool->destroy(static_cast<SMDS_VtkFace*>(elem));
break;
case SMDSAbs_Volume:
myVolumePool->destroy(static_cast<SMDS_VtkVolume*>(elem));
break;
default:
break;
}
}
myCells.clear(); myCells.clear();
// SMDS_VolumeIteratorPtr itv = volumesIterator();
// while (itv->more())
// delete itv->next();
// myVolumes.Clear();
//
// SMDS_FaceIteratorPtr itf = facesIterator();
// while (itf->more())
// delete itf->next();
// myFaces.Clear();
//
// SMDS_EdgeIteratorPtr ite = edgesIterator();
// while (ite->more())
// delete ite->next();
// myEdges.Clear();
//
// SMDS_0DElementIteratorPtr it0d = elements0dIterator();
// while (it0d->more())
// delete it0d->next();
// my0DElements.Clear();
SMDS_NodeIteratorPtr itn = nodesIterator(); SMDS_NodeIteratorPtr itn = nodesIterator();
while (itn->more()) while (itn->more())
delete itn->next(); {
SMDS_MeshNode *node = (SMDS_MeshNode*)(itn->next());
myNodePool->destroy(node);
}
myNodes.clear(); myNodes.clear();
list<SMDS_Mesh*>::iterator itc=myChildren.begin(); list<SMDS_Mesh*>::iterator itc=myChildren.begin();
@ -2303,6 +2308,14 @@ void SMDS_Mesh::Clear()
(*itc)->Clear(); (*itc)->Clear();
myInfo.Clear(); myInfo.Clear();
myGrid->Initialize();
myGrid->Allocate();
vtkPoints* points = vtkPoints::New();
points->SetNumberOfPoints(SMDS_Mesh::chunkSize);
myGrid->SetPoints( points );
points->Delete();
myGrid->BuildLinks();
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////

View File

@ -128,6 +128,7 @@ SMDS_MeshElement* SMDS_MeshElementIDFactory::MeshElement(int ID)
void SMDS_MeshElementIDFactory::ReleaseID(const int ID) void SMDS_MeshElementIDFactory::ReleaseID(const int ID)
{ {
int vtkId = myMesh->myIDElements[ID]; int vtkId = myMesh->myIDElements[ID];
//MESSAGE("~~~~~~~~~~~~~~ SMDS_MeshElementIDFactory::ReleaseID smdsId vtkId " << ID << " " << vtkId);
myMesh->myIDElements[ID] = -1; myMesh->myIDElements[ID] = -1;
myMesh->myVtkIndex[vtkId] = -1; myMesh->myVtkIndex[vtkId] = -1;
SMDS_MeshIDFactory::ReleaseID(ID); SMDS_MeshIDFactory::ReleaseID(ID);

View File

@ -51,18 +51,19 @@ SMDS_MeshNode::SMDS_MeshNode() :
SMDS_MeshElement(-1, -1, -1), SMDS_MeshElement(-1, -1, -1),
myPosition(SMDS_SpacePosition::originSpacePosition()) myPosition(SMDS_SpacePosition::originSpacePosition())
{ {
nbNodes++;
} }
SMDS_MeshNode::SMDS_MeshNode(int id, int meshId, int shapeId, double x, double y, double z): SMDS_MeshNode::SMDS_MeshNode(int id, int meshId, int shapeId, double x, double y, double z):
SMDS_MeshElement(id, meshId, shapeId), SMDS_MeshElement(id, meshId, shapeId),
myPosition(SMDS_SpacePosition::originSpacePosition()) myPosition(SMDS_SpacePosition::originSpacePosition())
{ {
nbNodes++;
init(id, meshId, shapeId, x, y ,z); init(id, meshId, shapeId, x, y ,z);
} }
void SMDS_MeshNode::init(int id, int meshId, int shapeId, double x, double y, double z) void SMDS_MeshNode::init(int id, int meshId, int shapeId, double x, double y, double z)
{ {
nbNodes++;
myID = id; myID = id;
myMeshId = meshId; myMeshId = meshId;
myShapeId = shapeId; myShapeId = shapeId;

View File

@ -4,6 +4,7 @@
#include "utilities.h" #include "utilities.h"
#include <vtkCellArray.h> #include <vtkCellArray.h>
#include <vtkCellLinks.h>
#include <vtkIdTypeArray.h> #include <vtkIdTypeArray.h>
#include <vtkUnsignedCharArray.h> #include <vtkUnsignedCharArray.h>
@ -33,6 +34,12 @@ unsigned long SMDS_UnstructuredGrid::GetMTime()
return mtime; return mtime;
} }
void SMDS_UnstructuredGrid::Update()
{
MESSAGE("SMDS_UnstructuredGrid::Update");
return vtkUnstructuredGrid::Update();
}
void SMDS_UnstructuredGrid::UpdateInformation() void SMDS_UnstructuredGrid::UpdateInformation()
{ {
MESSAGE("SMDS_UnstructuredGrid::UpdateInformation"); MESSAGE("SMDS_UnstructuredGrid::UpdateInformation");
@ -49,9 +56,16 @@ void SMDS_UnstructuredGrid::compactGrid(std::vector<int>& idNodesOldToNew, int n
int startBloc = 0; int startBloc = 0;
int endBloc = 0; int endBloc = 0;
int alreadyCopied = 0; int alreadyCopied = 0;
typedef enum {lookHoleStart, lookHoleEnd, lookBlocEnd} enumState; typedef enum {lookHoleStart, lookHoleEnd, lookBlocEnd} enumState;
enumState compactState = lookHoleStart; enumState compactState = lookHoleStart;
// if (this->Links)
// {
// this->Links->UnRegister(this);
// this->Links = 0;
// }
// --- if newNodeSize, create a new compacted vtkPoints // --- if newNodeSize, create a new compacted vtkPoints
vtkPoints *newPoints = 0; vtkPoints *newPoints = 0;
@ -71,6 +85,7 @@ void SMDS_UnstructuredGrid::compactGrid(std::vector<int>& idNodesOldToNew, int n
case lookHoleStart: case lookHoleStart:
if (idNodesOldToNew[i] < 0) if (idNodesOldToNew[i] < 0)
{ {
MESSAGE("-------------- newNodeSize, startHole " << i << " " << oldNodeSize);
startHole = i; startHole = i;
compactState = lookHoleEnd; compactState = lookHoleEnd;
} }
@ -78,6 +93,7 @@ void SMDS_UnstructuredGrid::compactGrid(std::vector<int>& idNodesOldToNew, int n
case lookHoleEnd: case lookHoleEnd:
if (idNodesOldToNew[i] >= 0) if (idNodesOldToNew[i] >= 0)
{ {
MESSAGE("-------------- newNodeSize, endHole " << i << " " << oldNodeSize);
endHole = i; endHole = i;
startBloc = i; startBloc = i;
compactState = lookBlocEnd; compactState = lookBlocEnd;
@ -88,7 +104,7 @@ void SMDS_UnstructuredGrid::compactGrid(std::vector<int>& idNodesOldToNew, int n
else if (i == (oldNodeSize-1)) endBloc = i+1; else if (i == (oldNodeSize-1)) endBloc = i+1;
if (endBloc) if (endBloc)
{ {
MESSAGE("-------------- newNodeSize, endbloc"); MESSAGE("-------------- newNodeSize, endbloc " << endBloc << " " << oldNodeSize);
void *target = newPoints->GetVoidPointer(3*alreadyCopied); void *target = newPoints->GetVoidPointer(3*alreadyCopied);
void *source = this->Points->GetVoidPointer(3*startBloc); void *source = this->Points->GetVoidPointer(3*startBloc);
int nbPoints = endBloc - startBloc; int nbPoints = endBloc - startBloc;
@ -106,7 +122,7 @@ void SMDS_UnstructuredGrid::compactGrid(std::vector<int>& idNodesOldToNew, int n
} }
if (!alreadyCopied) // no hole, but shorter, no need to modify idNodesOldToNew if (!alreadyCopied) // no hole, but shorter, no need to modify idNodesOldToNew
{ {
MESSAGE("------------- newNodeSize, shorter") MESSAGE("------------- newNodeSize, shorter " << oldNodeSize)
void *target = newPoints->GetVoidPointer(0); void *target = newPoints->GetVoidPointer(0);
void *source = this->Points->GetVoidPointer(0); void *source = this->Points->GetVoidPointer(0);
int nbPoints = newNodeSize; int nbPoints = newNodeSize;
@ -151,6 +167,7 @@ void SMDS_UnstructuredGrid::compactGrid(std::vector<int>& idNodesOldToNew, int n
case lookHoleStart: case lookHoleStart:
if (this->Types->GetValue(i) == VTK_EMPTY_CELL) if (this->Types->GetValue(i) == VTK_EMPTY_CELL)
{ {
MESSAGE(" -------- newCellSize, startHole " << i << " " << oldCellSize);
startHole = i; startHole = i;
compactState = lookHoleEnd; compactState = lookHoleEnd;
} }
@ -158,6 +175,7 @@ void SMDS_UnstructuredGrid::compactGrid(std::vector<int>& idNodesOldToNew, int n
case lookHoleEnd: case lookHoleEnd:
if (this->Types->GetValue(i) != VTK_EMPTY_CELL) if (this->Types->GetValue(i) != VTK_EMPTY_CELL)
{ {
MESSAGE(" -------- newCellSize, EndHole " << i << " " << oldCellSize);
endHole = i; endHole = i;
startBloc = i; startBloc = i;
compactState = lookBlocEnd; compactState = lookBlocEnd;
@ -168,39 +186,45 @@ void SMDS_UnstructuredGrid::compactGrid(std::vector<int>& idNodesOldToNew, int n
else if (i == (oldCellSize-1)) endBloc = i+1; else if (i == (oldCellSize-1)) endBloc = i+1;
if (endBloc) if (endBloc)
{ {
MESSAGE(" -------- newCellSize, endBloc"); MESSAGE(" -------- newCellSize, endBloc " << endBloc << " " << oldCellSize);
for (int j=startBloc; j<endBloc; j++) for (int j=startBloc; j<endBloc; j++)
{ {
newTypes->SetValue(alreadyCopied, this->Types->GetValue(j)); newTypes->SetValue(alreadyCopied, this->Types->GetValue(j));
idCellsOldToNew[j] = alreadyCopied; idCellsOldToNew[j] = alreadyCopied;
int oldLoc = this->Locations->GetValue(j); vtkIdType oldLoc = this->Locations->GetValue(j);
int nbpts; vtkIdType nbpts;
this->Connectivity->GetCell(oldLoc, nbpts, pointsCell); vtkIdType *oldPtsCell = 0;
this->Connectivity->GetCell(oldLoc, nbpts, oldPtsCell);
for (int l=0; l<nbpts; l++) for (int l=0; l<nbpts; l++)
pointsCell[l] = idNodesOldToNew[pointsCell[l]]; {
int oldval = oldPtsCell[l];
pointsCell[l] = idNodesOldToNew[oldval];
}
int newcnt = newConnectivity->InsertNextCell(nbpts, pointsCell); int newcnt = newConnectivity->InsertNextCell(nbpts, pointsCell);
int newLoc = newConnectivity->GetInsertLocation(nbpts); int newLoc = newConnectivity->GetInsertLocation(nbpts);
newLocations->SetValue(alreadyCopied, newLoc); newLocations->SetValue(alreadyCopied, newLoc);
alreadyCopied++; alreadyCopied++;
} }
compactState = lookHoleStart;
} }
break; break;
} }
} }
if (!alreadyCopied) // no hole, but shorter if (!alreadyCopied) // no hole, but shorter
{ {
MESSAGE(" -------- newCellSize, shorter"); MESSAGE(" -------- newCellSize, shorter " << oldCellSize);
for (int j=0; j<oldCellSize; j++) for (int j=0; j<oldCellSize; j++)
{ {
newTypes->SetValue(alreadyCopied, this->Types->GetValue(j)); newTypes->SetValue(alreadyCopied, this->Types->GetValue(j));
idCellsOldToNew[j] = alreadyCopied; idCellsOldToNew[j] = alreadyCopied;
int oldLoc = this->Locations->GetValue(j); vtkIdType oldLoc = this->Locations->GetValue(j);
int nbpts; vtkIdType nbpts;
this->Connectivity->GetCell(oldLoc, nbpts, pointsCell); vtkIdType *oldPtsCell = 0;
this->Connectivity->GetCell(oldLoc, nbpts, oldPtsCell);
//MESSAGE(j << " " << alreadyCopied << " " << (int)this->Types->GetValue(j) << " " << oldLoc << " " << nbpts ); //MESSAGE(j << " " << alreadyCopied << " " << (int)this->Types->GetValue(j) << " " << oldLoc << " " << nbpts );
for (int l=0; l<nbpts; l++) for (int l=0; l<nbpts; l++)
{ {
int oldval = pointsCell[l]; int oldval = oldPtsCell[l];
pointsCell[l] = idNodesOldToNew[oldval]; pointsCell[l] = idNodesOldToNew[oldval];
//MESSAGE(" " << oldval << " " << pointsCell[l]); //MESSAGE(" " << oldval << " " << pointsCell[l]);
} }

View File

@ -19,6 +19,7 @@ public:
std::vector<int>& idCellsOldToNew, int newCellSize); std::vector<int>& idCellsOldToNew, int newCellSize);
virtual unsigned long GetMTime(); virtual unsigned long GetMTime();
virtual void Update();
virtual void UpdateInformation(); virtual void UpdateInformation();
static SMDS_UnstructuredGrid* New(); static SMDS_UnstructuredGrid* New();

View File

@ -6,6 +6,7 @@
#include "utilities.h" #include "utilities.h"
#include <vector> #include <vector>
#include <cassert>
using namespace std; using namespace std;
@ -48,6 +49,7 @@ int SMDS_VtkEdge::NbNodes() const
{ {
vtkUnstructuredGrid* grid =SMDS_Mesh::_meshList[myMeshId]->getGrid(); vtkUnstructuredGrid* grid =SMDS_Mesh::_meshList[myMeshId]->getGrid();
int nbPoints = grid->GetCell(myVtkID)->GetNumberOfPoints(); int nbPoints = grid->GetCell(myVtkID)->GetNumberOfPoints();
assert(nbPoints >=2);
return nbPoints; return nbPoints;
} }

View File

@ -816,6 +816,7 @@ void SMESHDS_Mesh::RemoveFreeElement(const SMDS_MeshElement * elt,
SMESHDS_SubMesh * subMesh, SMESHDS_SubMesh * subMesh,
bool fromGroups) bool fromGroups)
{ {
//MESSAGE(" --------------------------------> SMESHDS_Mesh::RemoveFreeElement " << subMesh << " " << fromGroups);
if (elt->GetType() == SMDSAbs_Node) { if (elt->GetType() == SMDSAbs_Node) {
RemoveFreeNode( static_cast<const SMDS_MeshNode*>(elt), subMesh); RemoveFreeNode( static_cast<const SMDS_MeshNode*>(elt), subMesh);
return; return;
@ -1779,9 +1780,12 @@ void SMESHDS_Mesh::compactMesh()
{ {
int newNodeSize = 0; int newNodeSize = 0;
int nbNodes = myNodes.size(); int nbNodes = myNodes.size();
int nbVtkNodes = myGrid->GetNumberOfPoints();
MESSAGE("nbNodes=" << nbNodes << " nbVtkNodes=" << nbVtkNodes);
if (nbNodes > nbVtkNodes) nbVtkNodes = nbNodes;
vector<int> idNodesOldToNew; vector<int> idNodesOldToNew;
idNodesOldToNew.clear(); idNodesOldToNew.clear();
idNodesOldToNew.resize(nbNodes, -1); // all unused id will be -1 idNodesOldToNew.resize(nbVtkNodes, -1); // all unused id will be -1
bool areNodesModified = ! myNodeIDFactory->isPoolIdEmpty(); bool areNodesModified = ! myNodeIDFactory->isPoolIdEmpty();
MESSAGE("------------------------------------------------- SMESHDS_Mesh::compactMesh " << areNodesModified); MESSAGE("------------------------------------------------- SMESHDS_Mesh::compactMesh " << areNodesModified);
@ -1804,9 +1808,12 @@ void SMESHDS_Mesh::compactMesh()
int newCellSize = 0; int newCellSize = 0;
int nbCells = myCells.size(); int nbCells = myCells.size();
int nbVtkCells = myGrid->GetNumberOfCells();
MESSAGE("nbCells=" << nbCells << " nbVtkCells=" << nbVtkCells);
if (nbCells > nbVtkCells) nbVtkCells = nbCells;
vector<int> idCellsOldToNew; vector<int> idCellsOldToNew;
idCellsOldToNew.clear(); idCellsOldToNew.clear();
idCellsOldToNew.resize(nbCells, -1); // all unused id will be -1 idCellsOldToNew.resize(nbVtkCells, -1); // all unused id will be -1
for (int i=0; i<nbCells; i++) for (int i=0; i<nbCells; i++)
{ {
@ -1842,17 +1849,56 @@ void SMESHDS_Mesh::compactMesh()
// --- SMDS_MeshCell, myIDElements and myVtkIndex (myCells and myElementIdFactory are not compacted) // --- SMDS_MeshCell, myIDElements and myVtkIndex (myCells and myElementIdFactory are not compacted)
for (int oldVtkId=0; oldVtkId<nbCells; oldVtkId++) int vtkIndexSize = myVtkIndex.size();
int maxVtkId = 0;
for (int oldVtkId=0; oldVtkId<vtkIndexSize; oldVtkId++)
{ {
int smdsId = this->myVtkIndex[oldVtkId]; int smdsId = this->myVtkIndex[oldVtkId];
if (smdsId >=0) if (smdsId >=0)
{ {
int newVtkId = idCellsOldToNew[oldVtkId]; int newVtkId = idCellsOldToNew[oldVtkId];
if (newVtkId > maxVtkId) maxVtkId = newVtkId;
//MESSAGE("===========> smdsId newVtkId " << smdsId << " " << newVtkId);
myCells[smdsId]->setVtkId(newVtkId); myCells[smdsId]->setVtkId(newVtkId);
myIDElements[smdsId] = newVtkId; myIDElements[smdsId] = newVtkId;
myVtkIndex[newVtkId] = smdsId; myVtkIndex[newVtkId] = smdsId;
} }
} }
maxVtkId++;
MESSAGE("myCells.size()=" << myCells.size() << " myIDElements.size()=" << myIDElements.size() << " myVtkIndex.size()=" << myVtkIndex.size() );
MESSAGE("maxVtkId=" << maxVtkId);
SetOfCells newCells;
vector<int> newSmdsToVtk;
vector<int> newVtkToSmds;
newCells.resize(maxVtkId,0);
newSmdsToVtk.resize(maxVtkId,-1);
newVtkToSmds.resize(maxVtkId,-1);
int myCellsSize = myCells.size();
int newSmdsId =0;
for (int i=0; i<myCellsSize; i++)
{
if (myCells[i])
{
newCells[newSmdsId] = myCells[i];
int idvtk = myCells[i]->getVtkId();
newSmdsToVtk[newSmdsId] = idvtk;
assert(idvtk < maxVtkId);
newVtkToSmds[idvtk] = newSmdsId;
myCells[i]->setId(newSmdsId);
newSmdsId++;
assert(newSmdsId <= maxVtkId);
}
}
myCells.swap(newCells);
myIDElements.swap(newSmdsToVtk);
myVtkIndex.swap(newVtkToSmds);
MESSAGE("myCells.size()=" << myCells.size() << " myIDElements.size()=" << myIDElements.size() << " myVtkIndex.size()=" << myVtkIndex.size() );
// ---TODO: myNodes, myElements in submeshes // ---TODO: myNodes, myElements in submeshes

View File

@ -70,7 +70,7 @@ bool SMESHDS_SubMesh::RemoveElement(const SMDS_MeshElement * ME, bool isElemDele
if (!isElemDeleted) // alive element has valid ID and can be found if (!isElemDeleted) // alive element has valid ID and can be found
{ {
int idInSubShape = ME->getIdInShape(); int idInSubShape = ME->getIdInShape();
//MESSAGE("SMESHDS_SubMesh::RemoveElement " << idInSubShape << " " << ME->GetID()); //MESSAGE("SMESHDS_SubMesh::RemoveElement " << idInSubShape << " " << ME->GetID() << " " << myUnusedIdElements);
assert(idInSubShape >= 0); assert(idInSubShape >= 0);
assert(idInSubShape < myElements.size()); assert(idInSubShape < myElements.size());
myElements[idInSubShape] = 0; // this vector entry is no more used myElements[idInSubShape] = 0; // this vector entry is no more used

View File

@ -693,6 +693,7 @@ void SMESHGUI_BaseComputeOp::computeMesh()
#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
OCC_CATCH_SIGNALS; OCC_CATCH_SIGNALS;
#endif #endif
SMESH::UpdateNulData(myIObject, true);
if (gen->Compute(myMesh, myMainShape)) if (gen->Compute(myMesh, myMainShape))
computeFailed = false; computeFailed = false;
} }

View File

@ -252,7 +252,7 @@ namespace SMESH
*/ */
//================================================================================ //================================================================================
TVisualObjPtr GetVisualObj(int theStudyId, const char* theEntry){ TVisualObjPtr GetVisualObj(int theStudyId, const char* theEntry, bool nulData){
TVisualObjPtr aVisualObj; TVisualObjPtr aVisualObj;
TVisualObjCont::key_type aKey(theStudyId,theEntry); TVisualObjCont::key_type aKey(theStudyId,theEntry);
try{ try{
@ -326,6 +326,10 @@ namespace SMESH
#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
OCC_CATCH_SIGNALS; OCC_CATCH_SIGNALS;
#endif #endif
MESSAGE("GetVisualObj");
if (nulData)
objModified = aVisualObj->NulData();
else
objModified = aVisualObj->Update(); objModified = aVisualObj->Update();
} }
catch (...) { catch (...) {
@ -662,6 +666,7 @@ namespace SMESH
bool UpdateView(SUIT_ViewWindow *theWnd, EDisplaing theAction, const char* theEntry) bool UpdateView(SUIT_ViewWindow *theWnd, EDisplaing theAction, const char* theEntry)
{ {
MESSAGE("UpdateView");
bool OK = false; bool OK = false;
SVTK_ViewWindow* aViewWnd = GetVtkViewWindow(theWnd); SVTK_ViewWindow* aViewWnd = GetVtkViewWindow(theWnd);
if (!aViewWnd) if (!aViewWnd)
@ -736,6 +741,7 @@ namespace SMESH
bool UpdateView(EDisplaing theAction, const char* theEntry){ bool UpdateView(EDisplaing theAction, const char* theEntry){
MESSAGE("UpdateView");
SalomeApp_Study* aStudy = dynamic_cast< SalomeApp_Study* >( GetActiveStudy() ); SalomeApp_Study* aStudy = dynamic_cast< SalomeApp_Study* >( GetActiveStudy() );
SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( aStudy->application() ); SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( aStudy->application() );
SUIT_ViewWindow *aWnd = app->activeViewManager()->getActiveView(); SUIT_ViewWindow *aWnd = app->activeViewManager()->getActiveView();
@ -774,6 +780,7 @@ namespace SMESH
bool Update(const Handle(SALOME_InteractiveObject)& theIO, bool theDisplay) bool Update(const Handle(SALOME_InteractiveObject)& theIO, bool theDisplay)
{ {
MESSAGE("Update");
_PTR(Study) aStudy = GetActiveStudyDocument(); _PTR(Study) aStudy = GetActiveStudyDocument();
CORBA::Long anId = aStudy->StudyId(); CORBA::Long anId = aStudy->StudyId();
if ( TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId,theIO->getEntry())) { if ( TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId,theIO->getEntry())) {
@ -784,6 +791,18 @@ namespace SMESH
return false; return false;
} }
bool UpdateNulData(const Handle(SALOME_InteractiveObject)& theIO, bool theDisplay)
{
MESSAGE("UpdateNulData");
_PTR(Study) aStudy = GetActiveStudyDocument();
CORBA::Long anId = aStudy->StudyId();
if ( TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId,theIO->getEntry(), true)) {
if ( theDisplay )
UpdateView(SMESH::eDisplay,theIO->getEntry());
return true;
}
return false;
}
void UpdateSelectionProp( SMESHGUI* theModule ) { void UpdateSelectionProp( SMESHGUI* theModule ) {
if( !theModule ) if( !theModule )

View File

@ -62,7 +62,7 @@ namespace SMESH
typedef std::pair<int,std::string> TKeyOfVisualObj; typedef std::pair<int,std::string> TKeyOfVisualObj;
SMESHGUI_EXPORT SMESHGUI_EXPORT
TVisualObjPtr GetVisualObj( int, const char* ); TVisualObjPtr GetVisualObj( int, const char*, bool nulData =false );
SMESHGUI_EXPORT SMESHGUI_EXPORT
void OnVisuException(); // PAL16631 void OnVisuException(); // PAL16631
@ -119,7 +119,10 @@ SMESHGUI_EXPORT
void UpdateView(); void UpdateView();
SMESHGUI_EXPORT SMESHGUI_EXPORT
bool Update( const Handle(SALOME_InteractiveObject)&, bool ); bool UpdateNulData( const Handle(SALOME_InteractiveObject)& theIO, bool theDisplay);
SMESHGUI_EXPORT
bool Update( const Handle(SALOME_InteractiveObject)& theIO, bool theDisplay);
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
SMESHGUI_EXPORT SMESHGUI_EXPORT