return true;
}
+vtkUnstructuredGrid* SMESH_VisualObjDef::GetUnstructuredGrid()
+{
+ MESSAGE("SMESH_VisualObjDef::GetUnstructuredGrid " << myGrid);
+ return myGrid;
+}
+
+
//=================================================================================
// function : IsValid
// purpose : Return true if there are some entities
//=================================================================================
bool SMESH_VisualObjDef::IsValid() const
{
+ MESSAGE("SMESH_VisualObjDef::IsValid");
return GetNbEntities(SMDSAbs_Node) > 0 ||
GetNbEntities(SMDSAbs_0DElement) > 0 ||
GetNbEntities(SMDSAbs_Edge) > 0 ||
SMESH_MeshObj::SMESH_MeshObj(SMESH::SMESH_Mesh_ptr theMesh):
myClient(SalomeApp_Application::orb(),theMesh)
{
+ myEmptyGrid = 0;
if ( MYDEBUG )
MESSAGE("SMESH_MeshObj - this = "<<this<<"; theMesh->_is_nil() = "<<theMesh->_is_nil());
}
bool SMESH_MeshObj::Update( int theIsClear )
{
// Update SMDS_Mesh on client part
+ MESSAGE("SMESH_MeshObj::Update");
if ( myClient.Update(theIsClear) || GetUnstructuredGrid()->GetNumberOfPoints()==0) {
buildPrs(); // Fill unstructured grid
return true;
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
// purpose : Get dimension of element
{
public:
virtual bool Update( int theIsClear = true ) = 0;
+ virtual bool NulData() = 0;
virtual void UpdateFunctor( const SMESH::Controls::FunctorPtr& theFunctor ) = 0;
virtual int GetElemDimension( const int theObjId ) = 0;
virtual ~SMESH_VisualObjDef();
virtual bool Update( int theIsClear = true ) = 0;
+ virtual bool NulData() {return 0; };
virtual void UpdateFunctor( const SMESH::Controls::FunctorPtr& theFunctor ) = 0;
virtual int GetElemDimension( const int theObjId ) = 0;
int& theNodeId1,
int& theNodeId2 ) const;
- virtual vtkUnstructuredGrid* GetUnstructuredGrid() { return myGrid; }
+ virtual vtkUnstructuredGrid* GetUnstructuredGrid(); // { return myGrid; }
virtual vtkIdType GetNodeObjId( int theVTKID );
virtual vtkIdType GetNodeVTKId( int theObjID );
// void buildNodePrs();
// void buildElemPrs();
-private:
+//private:
// TMapOfIds mySMDS2VTKNodes;
// TMapOfIds myVTK2SMDSNodes;
virtual ~SMESH_MeshObj();
virtual bool Update( int theIsClear = true );
+ virtual bool NulData();
virtual int GetNbEntities( const SMDSAbs_ElementType) const;
virtual int GetEntities( const SMDSAbs_ElementType, TEntityList& ) const;
protected:
SMESH_Client myClient;
+ vtkUnstructuredGrid* myEmptyGrid;
};
+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
void SMDS_Mesh::Clear()
{
- if (myParent!=NULL) {
+ if (myParent!=NULL)
+ {
SMDS_ElemIteratorPtr eIt = elementsIterator();
while ( eIt->more() )
myElementIDFactory->ReleaseID(eIt->next()->GetID());
SMDS_NodeIteratorPtr itn = nodesIterator();
while (itn->more())
myNodeIDFactory->ReleaseID(itn->next()->GetID());
- }
- else {
+ }
+ else
+ {
myNodeIDFactory->Clear();
myElementIDFactory->Clear();
- }
+ }
SMDS_ElemIteratorPtr itv = elementsIterator();
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();
-// 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();
while (itn->more())
- delete itn->next();
+ {
+ SMDS_MeshNode *node = (SMDS_MeshNode*)(itn->next());
+ myNodePool->destroy(node);
+ }
myNodes.clear();
list<SMDS_Mesh*>::iterator itc=myChildren.begin();
(*itc)->Clear();
myInfo.Clear();
+
+ myGrid->Initialize();
+ myGrid->Allocate();
+ vtkPoints* points = vtkPoints::New();
+ points->SetNumberOfPoints(SMDS_Mesh::chunkSize);
+ myGrid->SetPoints( points );
+ points->Delete();
+ myGrid->BuildLinks();
}
///////////////////////////////////////////////////////////////////////////////
void SMDS_MeshElementIDFactory::ReleaseID(const int ID)
{
int vtkId = myMesh->myIDElements[ID];
+ //MESSAGE("~~~~~~~~~~~~~~ SMDS_MeshElementIDFactory::ReleaseID smdsId vtkId " << ID << " " << vtkId);
myMesh->myIDElements[ID] = -1;
myMesh->myVtkIndex[vtkId] = -1;
SMDS_MeshIDFactory::ReleaseID(ID);
SMDS_MeshElement(-1, -1, -1),
myPosition(SMDS_SpacePosition::originSpacePosition())
{
+ nbNodes++;
}
SMDS_MeshNode::SMDS_MeshNode(int id, int meshId, int shapeId, double x, double y, double z):
SMDS_MeshElement(id, meshId, shapeId),
myPosition(SMDS_SpacePosition::originSpacePosition())
{
+ nbNodes++;
init(id, meshId, shapeId, x, y ,z);
}
void SMDS_MeshNode::init(int id, int meshId, int shapeId, double x, double y, double z)
{
- nbNodes++;
myID = id;
myMeshId = meshId;
myShapeId = shapeId;
#include "utilities.h"
#include <vtkCellArray.h>
+#include <vtkCellLinks.h>
#include <vtkIdTypeArray.h>
#include <vtkUnsignedCharArray.h>
return mtime;
}
+void SMDS_UnstructuredGrid::Update()
+{
+ MESSAGE("SMDS_UnstructuredGrid::Update");
+ return vtkUnstructuredGrid::Update();
+}
+
void SMDS_UnstructuredGrid::UpdateInformation()
{
MESSAGE("SMDS_UnstructuredGrid::UpdateInformation");
int startBloc = 0;
int endBloc = 0;
int alreadyCopied = 0;
+
typedef enum {lookHoleStart, lookHoleEnd, lookBlocEnd} enumState;
enumState compactState = lookHoleStart;
+// if (this->Links)
+// {
+// this->Links->UnRegister(this);
+// this->Links = 0;
+// }
+
// --- if newNodeSize, create a new compacted vtkPoints
vtkPoints *newPoints = 0;
case lookHoleStart:
if (idNodesOldToNew[i] < 0)
{
+ MESSAGE("-------------- newNodeSize, startHole " << i << " " << oldNodeSize);
startHole = i;
compactState = lookHoleEnd;
}
case lookHoleEnd:
if (idNodesOldToNew[i] >= 0)
{
+ MESSAGE("-------------- newNodeSize, endHole " << i << " " << oldNodeSize);
endHole = i;
startBloc = i;
compactState = lookBlocEnd;
else if (i == (oldNodeSize-1)) endBloc = i+1;
if (endBloc)
{
- MESSAGE("-------------- newNodeSize, endbloc");
+ MESSAGE("-------------- newNodeSize, endbloc " << endBloc << " " << oldNodeSize);
void *target = newPoints->GetVoidPointer(3*alreadyCopied);
void *source = this->Points->GetVoidPointer(3*startBloc);
int nbPoints = endBloc - startBloc;
}
if (!alreadyCopied) // no hole, but shorter, no need to modify idNodesOldToNew
{
- MESSAGE("------------- newNodeSize, shorter")
+ MESSAGE("------------- newNodeSize, shorter " << oldNodeSize)
void *target = newPoints->GetVoidPointer(0);
void *source = this->Points->GetVoidPointer(0);
int nbPoints = newNodeSize;
case lookHoleStart:
if (this->Types->GetValue(i) == VTK_EMPTY_CELL)
{
+ MESSAGE(" -------- newCellSize, startHole " << i << " " << oldCellSize);
startHole = i;
compactState = lookHoleEnd;
}
case lookHoleEnd:
if (this->Types->GetValue(i) != VTK_EMPTY_CELL)
{
+ MESSAGE(" -------- newCellSize, EndHole " << i << " " << oldCellSize);
endHole = i;
startBloc = i;
compactState = lookBlocEnd;
else if (i == (oldCellSize-1)) endBloc = i+1;
if (endBloc)
{
- MESSAGE(" -------- newCellSize, endBloc");
+ MESSAGE(" -------- newCellSize, endBloc " << endBloc << " " << oldCellSize);
for (int j=startBloc; j<endBloc; j++)
{
newTypes->SetValue(alreadyCopied, this->Types->GetValue(j));
idCellsOldToNew[j] = alreadyCopied;
- int oldLoc = this->Locations->GetValue(j);
- int nbpts;
- this->Connectivity->GetCell(oldLoc, nbpts, pointsCell);
+ vtkIdType oldLoc = this->Locations->GetValue(j);
+ vtkIdType nbpts;
+ vtkIdType *oldPtsCell = 0;
+ this->Connectivity->GetCell(oldLoc, nbpts, oldPtsCell);
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 newLoc = newConnectivity->GetInsertLocation(nbpts);
newLocations->SetValue(alreadyCopied, newLoc);
alreadyCopied++;
}
+ compactState = lookHoleStart;
}
break;
}
}
if (!alreadyCopied) // no hole, but shorter
{
- MESSAGE(" -------- newCellSize, shorter");
+ MESSAGE(" -------- newCellSize, shorter " << oldCellSize);
for (int j=0; j<oldCellSize; j++)
{
newTypes->SetValue(alreadyCopied, this->Types->GetValue(j));
idCellsOldToNew[j] = alreadyCopied;
- int oldLoc = this->Locations->GetValue(j);
- int nbpts;
- this->Connectivity->GetCell(oldLoc, nbpts, pointsCell);
+ vtkIdType oldLoc = this->Locations->GetValue(j);
+ vtkIdType nbpts;
+ vtkIdType *oldPtsCell = 0;
+ this->Connectivity->GetCell(oldLoc, nbpts, oldPtsCell);
//MESSAGE(j << " " << alreadyCopied << " " << (int)this->Types->GetValue(j) << " " << oldLoc << " " << nbpts );
for (int l=0; l<nbpts; l++)
{
- int oldval = pointsCell[l];
+ int oldval = oldPtsCell[l];
pointsCell[l] = idNodesOldToNew[oldval];
//MESSAGE(" " << oldval << " " << pointsCell[l]);
}
std::vector<int>& idCellsOldToNew, int newCellSize);
virtual unsigned long GetMTime();
+ virtual void Update();
virtual void UpdateInformation();
static SMDS_UnstructuredGrid* New();
#include "utilities.h"
#include <vector>
+#include <cassert>
using namespace std;
{
vtkUnstructuredGrid* grid =SMDS_Mesh::_meshList[myMeshId]->getGrid();
int nbPoints = grid->GetCell(myVtkID)->GetNumberOfPoints();
+ assert(nbPoints >=2);
return nbPoints;
}
SMESHDS_SubMesh * subMesh,
bool fromGroups)
{
+ //MESSAGE(" --------------------------------> SMESHDS_Mesh::RemoveFreeElement " << subMesh << " " << fromGroups);
if (elt->GetType() == SMDSAbs_Node) {
RemoveFreeNode( static_cast<const SMDS_MeshNode*>(elt), subMesh);
return;
{
int newNodeSize = 0;
int nbNodes = myNodes.size();
+ int nbVtkNodes = myGrid->GetNumberOfPoints();
+ MESSAGE("nbNodes=" << nbNodes << " nbVtkNodes=" << nbVtkNodes);
+ if (nbNodes > nbVtkNodes) nbVtkNodes = nbNodes;
vector<int> idNodesOldToNew;
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();
MESSAGE("------------------------------------------------- SMESHDS_Mesh::compactMesh " << areNodesModified);
int newCellSize = 0;
int nbCells = myCells.size();
+ int nbVtkCells = myGrid->GetNumberOfCells();
+ MESSAGE("nbCells=" << nbCells << " nbVtkCells=" << nbVtkCells);
+ if (nbCells > nbVtkCells) nbVtkCells = nbCells;
vector<int> idCellsOldToNew;
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++)
{
// --- 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];
if (smdsId >=0)
{
int newVtkId = idCellsOldToNew[oldVtkId];
+ if (newVtkId > maxVtkId) maxVtkId = newVtkId;
+ //MESSAGE("===========> smdsId newVtkId " << smdsId << " " << newVtkId);
myCells[smdsId]->setVtkId(newVtkId);
myIDElements[smdsId] = newVtkId;
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
if (!isElemDeleted) // alive element has valid ID and can be found
{
int idInSubShape = ME->getIdInShape();
- //MESSAGE("SMESHDS_SubMesh::RemoveElement " << idInSubShape << " " << ME->GetID());
+ //MESSAGE("SMESHDS_SubMesh::RemoveElement " << idInSubShape << " " << ME->GetID() << " " << myUnusedIdElements);
assert(idInSubShape >= 0);
assert(idInSubShape < myElements.size());
myElements[idInSubShape] = 0; // this vector entry is no more used
#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
OCC_CATCH_SIGNALS;
#endif
+ SMESH::UpdateNulData(myIObject, true);
if (gen->Compute(myMesh, myMainShape))
computeFailed = false;
}
*/
//================================================================================
- TVisualObjPtr GetVisualObj(int theStudyId, const char* theEntry){
+ TVisualObjPtr GetVisualObj(int theStudyId, const char* theEntry, bool nulData){
TVisualObjPtr aVisualObj;
TVisualObjCont::key_type aKey(theStudyId,theEntry);
try{
#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
OCC_CATCH_SIGNALS;
#endif
- objModified = aVisualObj->Update();
+ MESSAGE("GetVisualObj");
+ if (nulData)
+ objModified = aVisualObj->NulData();
+ else
+ objModified = aVisualObj->Update();
}
catch (...) {
#ifdef _DEBUG_
bool UpdateView(SUIT_ViewWindow *theWnd, EDisplaing theAction, const char* theEntry)
{
+ MESSAGE("UpdateView");
bool OK = false;
SVTK_ViewWindow* aViewWnd = GetVtkViewWindow(theWnd);
if (!aViewWnd)
bool UpdateView(EDisplaing theAction, const char* theEntry){
+ MESSAGE("UpdateView");
SalomeApp_Study* aStudy = dynamic_cast< SalomeApp_Study* >( GetActiveStudy() );
SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( aStudy->application() );
SUIT_ViewWindow *aWnd = app->activeViewManager()->getActiveView();
bool Update(const Handle(SALOME_InteractiveObject)& theIO, bool theDisplay)
{
+ MESSAGE("Update");
_PTR(Study) aStudy = GetActiveStudyDocument();
CORBA::Long anId = aStudy->StudyId();
if ( TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId,theIO->getEntry())) {
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 ) {
if( !theModule )
typedef std::pair<int,std::string> TKeyOfVisualObj;
SMESHGUI_EXPORT
- TVisualObjPtr GetVisualObj( int, const char* );
+ TVisualObjPtr GetVisualObj( int, const char*, bool nulData =false );
SMESHGUI_EXPORT
void OnVisuException(); // PAL16631
void UpdateView();
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