From 64be032249f21ff884326a9b1d5e6b1a6eed93dc Mon Sep 17 00:00:00 2001 From: prascle Date: Wed, 19 May 2010 16:07:15 +0000 Subject: [PATCH] PR: debug gui display --- src/OBJECT/SMESH_Object.cxx | 12 +-- src/SMDS/Notes | 8 +- src/SMDS/SMDS_UnstructuredGrid.cxx | 134 +++++++++++++++++------------ src/SMDS/SMDS_UnstructuredGrid.hxx | 15 ++++ src/SMESHClient/SMESH_Client.cxx | 8 +- src/SMESHDS/SMESHDS_Mesh.cxx | 27 +++--- src/SMESHGUI/SMESHGUI.cxx | 1 + src/SMESHGUI/SMESHGUI_VTKUtils.cxx | 16 ++-- src/SMESH_I/SMESH_Gen_i.cxx | 2 + 9 files changed, 140 insertions(+), 83 deletions(-) diff --git a/src/OBJECT/SMESH_Object.cxx b/src/OBJECT/SMESH_Object.cxx index 1566d3506..b9d857fad 100644 --- a/src/OBJECT/SMESH_Object.cxx +++ b/src/OBJECT/SMESH_Object.cxx @@ -264,9 +264,9 @@ void SMESH_VisualObjDef::buildPrs(bool buildGrid) myLocalGrid = false; vtkUnstructuredGrid *theGrid = GetMesh()->getGrid(); myGrid->ShallowCopy(theGrid); - MESSAGE(myGrid->GetReferenceCount()); - MESSAGE( "Update - myGrid->GetNumberOfCells() = "<GetNumberOfCells() ); - MESSAGE( "Update - myGrid->GetNumberOfPoints() = "<GetNumberOfPoints() ); + //MESSAGE(myGrid->GetReferenceCount()); + //MESSAGE( "Update - myGrid->GetNumberOfCells() = "<GetNumberOfCells() ); + //MESSAGE( "Update - myGrid->GetNumberOfPoints() = "<GetNumberOfPoints() ); if( MYDEBUGWITHFILES ) SMESH::WriteUnstructuredGrid( myGrid,"/tmp/buildPrs" ); } } @@ -558,7 +558,7 @@ bool SMESH_VisualObjDef::GetEdgeNodes( const int theElemId, vtkUnstructuredGrid* SMESH_VisualObjDef::GetUnstructuredGrid() { - MESSAGE("SMESH_VisualObjDef::GetUnstructuredGrid " << myGrid); + //MESSAGE("SMESH_VisualObjDef::GetUnstructuredGrid " << myGrid); return myGrid; } @@ -569,7 +569,7 @@ vtkUnstructuredGrid* SMESH_VisualObjDef::GetUnstructuredGrid() //================================================================================= bool SMESH_VisualObjDef::IsValid() const { - MESSAGE("SMESH_VisualObjDef::IsValid"); + //MESSAGE("SMESH_VisualObjDef::IsValid"); return GetNbEntities(SMDSAbs_Node) > 0 || GetNbEntities(SMDSAbs_0DElement) > 0 || GetNbEntities(SMDSAbs_Edge) > 0 || @@ -611,7 +611,7 @@ SMESH_MeshObj::~SMESH_MeshObj() bool SMESH_MeshObj::Update( int theIsClear ) { // Update SMDS_Mesh on client part - MESSAGE("SMESH_MeshObj::Update " << this); + //MESSAGE("SMESH_MeshObj::Update " << this); if ( myClient.Update(theIsClear) || GetUnstructuredGrid()->GetNumberOfPoints()==0) { buildPrs(); // Fill unstructured grid return true; diff --git a/src/SMDS/Notes b/src/SMDS/Notes index 0cdb92abb..0af44e59e 100644 --- a/src/SMDS/Notes +++ b/src/SMDS/Notes @@ -8,7 +8,13 @@ Problemes en cours creation d'une structure vtkUnstructuredGrid locale : iteration un peu lourde, et pas de partage avec la structure du maillage (pas evident) - 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,0,0) pas systematique, trouver la condition (enlever dans vtkUnstructuredGrid ?) ++ affichage numeros noeuds: numeros en trop sur (O,0,0) pas systematique, trouver la condition (enlever dans vtkUnstructuredGrid ?) + ==> purge systematique noeuds et cellules en trop dans compactage grid. ++ gestion du mode embedded mal faite lors d'un script python : journal commandes intempestif +- affichage des noeuds apres changement lineaire <--> quadratique à l'IHM : pas pris en compte, alors que maillage OK, + mais script OK + ==> cassé apres mode embedded ou elimination noeuds en trop ? +- extrusion elements 2D along a path : affichage apres calcul pas toujours OK (filaire) A tester, non pris en compte ============================ diff --git a/src/SMDS/SMDS_UnstructuredGrid.cxx b/src/SMDS/SMDS_UnstructuredGrid.cxx index 143d54334..eef966593 100644 --- a/src/SMDS/SMDS_UnstructuredGrid.cxx +++ b/src/SMDS/SMDS_UnstructuredGrid.cxx @@ -56,6 +56,7 @@ void SMDS_UnstructuredGrid::compactGrid(std::vector& idNodesOldToNew, int n int startBloc = 0; int endBloc = 0; int alreadyCopied = 0; + int holes = 0; typedef enum {lookHoleStart, lookHoleEnd, lookBlocEnd} enumState; enumState compactState = lookHoleStart; @@ -71,7 +72,7 @@ void SMDS_UnstructuredGrid::compactGrid(std::vector& idNodesOldToNew, int n vtkPoints *newPoints = 0; if (newNodeSize) { - MESSAGE("-------------- compactGrid, newNodeSize"); + MESSAGE("-------------- compactGrid, newNodeSize " << newNodeSize); newPoints = vtkPoints::New(); newPoints->Initialize(); newPoints->Allocate(newNodeSize); @@ -87,6 +88,11 @@ void SMDS_UnstructuredGrid::compactGrid(std::vector& idNodesOldToNew, int n { MESSAGE("-------------- newNodeSize, startHole " << i << " " << oldNodeSize); startHole = i; + if (!alreadyCopied) // copy the first bloc + { + MESSAGE("--------- copy first nodes before hole " << i << " " << oldNodeSize); + copyNodes(newPoints, idNodesOldToNew, alreadyCopied, 0, startHole); + } compactState = lookHoleEnd; } break; @@ -105,12 +111,7 @@ void SMDS_UnstructuredGrid::compactGrid(std::vector& idNodesOldToNew, int n if (endBloc) { MESSAGE("-------------- newNodeSize, endbloc " << endBloc << " " << oldNodeSize); - void *target = newPoints->GetVoidPointer(3*alreadyCopied); - void *source = this->Points->GetVoidPointer(3*startBloc); - int nbPoints = endBloc - startBloc; - memcpy(target, source, 3*sizeof(float)*nbPoints); - for (int j=startBloc; j& idNodesOldToNew, int n } if (!alreadyCopied) // no hole, but shorter, no need to modify idNodesOldToNew { - MESSAGE("------------- newNodeSize, shorter " << oldNodeSize) - void *target = newPoints->GetVoidPointer(0); - void *source = this->Points->GetVoidPointer(0); - int nbPoints = newNodeSize; - memcpy(target, source, 3*sizeof(float)*nbPoints); + MESSAGE("------------- newNodeSize, shorter " << oldNodeSize); + copyNodes(newPoints, idNodesOldToNew, alreadyCopied, 0, newNodeSize); } + newPoints->Squeeze(); } // --- create new compacted Connectivity, Locations and Types @@ -155,6 +154,7 @@ void SMDS_UnstructuredGrid::compactGrid(std::vector& idNodesOldToNew, int n startBloc = 0; endBloc = 0; alreadyCopied = 0; + holes = 0; compactState = lookHoleStart; vtkIdType tmpid[50]; @@ -167,45 +167,36 @@ void SMDS_UnstructuredGrid::compactGrid(std::vector& idNodesOldToNew, int n case lookHoleStart: if (this->Types->GetValue(i) == VTK_EMPTY_CELL) { - MESSAGE(" -------- newCellSize, startHole " << i << " " << oldCellSize); + MESSAGE(" -------- newCellSize, startHole " << i << " " << oldCellSize); startHole = i; compactState = lookHoleEnd; + if (!alreadyCopied) // copy the first bloc + { + MESSAGE("--------- copy first bloc before hole " << i << " " << oldCellSize); + copyBloc(newTypes, idCellsOldToNew, idNodesOldToNew, newConnectivity, newLocations, pointsCell, alreadyCopied, 0, startHole); + } } break; case lookHoleEnd: if (this->Types->GetValue(i) != VTK_EMPTY_CELL) { - MESSAGE(" -------- newCellSize, EndHole " << i << " " << oldCellSize); + MESSAGE(" -------- newCellSize, EndHole " << i << " " << oldCellSize); endHole = i; startBloc = i; compactState = lookBlocEnd; + holes += endHole - startHole; + //alreadyCopied = startBloc -holes; } break; case lookBlocEnd: + endBloc =0; if (this->Types->GetValue(i) == VTK_EMPTY_CELL) endBloc =i; else if (i == (oldCellSize-1)) endBloc = i+1; if (endBloc) { - MESSAGE(" -------- newCellSize, endBloc " << endBloc << " " << oldCellSize); - for (int j=startBloc; jSetValue(alreadyCopied, this->Types->GetValue(j)); - idCellsOldToNew[j] = alreadyCopied; - vtkIdType oldLoc = this->Locations->GetValue(j); - vtkIdType nbpts; - vtkIdType *oldPtsCell = 0; - this->Connectivity->GetCell(oldLoc, nbpts, oldPtsCell); - for (int l=0; lInsertNextCell(nbpts, pointsCell); - int newLoc = newConnectivity->GetInsertLocation(nbpts); - newLocations->SetValue(alreadyCopied, newLoc); - alreadyCopied++; - } - compactState = lookHoleStart; + MESSAGE(" -------- newCellSize, endBloc " << endBloc << " " << oldCellSize); + copyBloc(newTypes, idCellsOldToNew, idNodesOldToNew, newConnectivity, newLocations, pointsCell, alreadyCopied, startBloc, endBloc); + compactState = lookHoleStart; } break; } @@ -213,27 +204,7 @@ void SMDS_UnstructuredGrid::compactGrid(std::vector& idNodesOldToNew, int n if (!alreadyCopied) // no hole, but shorter { MESSAGE(" -------- newCellSize, shorter " << oldCellSize); - for (int j=0; jSetValue(alreadyCopied, this->Types->GetValue(j)); - idCellsOldToNew[j] = alreadyCopied; - 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; lInsertNextCell(nbpts, pointsCell); - int newLoc = newConnectivity->GetInsertLocation(nbpts); - //MESSAGE(newcnt << " " << newLoc); - newLocations->SetValue(alreadyCopied, newLoc); - alreadyCopied++; - } + copyBloc(newTypes, idCellsOldToNew, idNodesOldToNew, newConnectivity, newLocations, pointsCell, alreadyCopied, 0, oldCellSize); } newConnectivity->Squeeze(); @@ -244,7 +215,60 @@ void SMDS_UnstructuredGrid::compactGrid(std::vector& idNodesOldToNew, int n { MESSAGE("------- newNodeSize, setPoints"); this->SetPoints(newPoints); + MESSAGE("NumberOfPoints: " << this->GetNumberOfPoints()); } this->SetCells(newTypes, newLocations, newConnectivity); this->BuildLinks(); } + +void SMDS_UnstructuredGrid::copyNodes(vtkPoints *newPoints, + std::vector& idNodesOldToNew, + int& alreadyCopied, + int start, + int end) +{ + MESSAGE("copyNodes " << alreadyCopied << " " << start << " " << end << " size: " << end - start << " total: " << alreadyCopied + end - start); + void *target = newPoints->GetVoidPointer(3*alreadyCopied); + void *source = this->Points->GetVoidPointer(3*start); + int nbPoints = end - start; + if (nbPoints >0) + { + memcpy(target, source, 3*sizeof(float)*nbPoints); + for (int j=start; j& idCellsOldToNew, + std::vector& idNodesOldToNew, + vtkCellArray* newConnectivity, + vtkIdTypeArray* newLocations, + vtkIdType* pointsCell, + int& alreadyCopied, + int start, + int end) +{ + MESSAGE("copyBloc " << alreadyCopied << " " << start << " " << end << " size: " << end - start << " total: " << alreadyCopied + end - start); + for (int j=start; jSetValue(alreadyCopied, this->Types->GetValue(j)); + idCellsOldToNew[j] = alreadyCopied; + 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; lInsertNextCell(nbpts, pointsCell); + int newLoc = newConnectivity->GetInsertLocation(nbpts); + //MESSAGE(newcnt << " " << newLoc); + newLocations->SetValue(alreadyCopied, newLoc); + alreadyCopied++; + } +} diff --git a/src/SMDS/SMDS_UnstructuredGrid.hxx b/src/SMDS/SMDS_UnstructuredGrid.hxx index 9840dcc39..87ae00eb7 100644 --- a/src/SMDS/SMDS_UnstructuredGrid.hxx +++ b/src/SMDS/SMDS_UnstructuredGrid.hxx @@ -26,6 +26,21 @@ public: protected: SMDS_UnstructuredGrid(); ~SMDS_UnstructuredGrid(); + void copyNodes(vtkPoints *newPoints, + std::vector& idNodesOldToNew, + int& alreadyCopied, + int start, + int end); + void copyBloc(vtkUnsignedCharArray *newTypes, + std::vector& idCellsOldToNew, + std::vector& idNodesOldToNew, + vtkCellArray* newConnectivity, + vtkIdTypeArray* newLocations, + vtkIdType* pointsCell, + int& alreadyCopied, + int start, + int end); + }; #endif /* _SMDS_UNSTRUCTUREDGRID_HXX */ diff --git a/src/SMESHClient/SMESH_Client.cxx b/src/SMESHClient/SMESH_Client.cxx index e62753123..342a5d2d4 100644 --- a/src/SMESHClient/SMESH_Client.cxx +++ b/src/SMESHClient/SMESH_Client.cxx @@ -54,7 +54,7 @@ #endif #ifdef _DEBUG_ -static int MYDEBUG = 0; +static int MYDEBUG = 1; #else static int MYDEBUG = 0; #endif @@ -634,6 +634,7 @@ SMESH_Client::SMESH_Client(CORBA::ORB_ptr theORB, mySMESHDSMesh(NULL), mySMDSMesh(NULL) { + MESSAGE("SMESH_Client::SMESH_Client"); myMeshServer->Register(); CORBA::Boolean anIsEmbeddedMode; @@ -649,7 +650,8 @@ SMESH_Client::SMESH_Client(CORBA::ORB_ptr theORB, SMESH_Mesh* aMesh = reinterpret_cast (pointeur); if ( MYDEBUG ) MESSAGE("SMESH_Client::SMESH_Client aMesh "<GetMeshDS()->IsEmbeddedMode()){ + //if(aMesh->GetMeshDS()->IsEmbeddedMode()){ + if(anIsEmbeddedMode){ mySMESHDSMesh = aMesh->GetMeshDS(); mySMDSMesh = mySMESHDSMesh; } @@ -704,10 +706,12 @@ SMESH_Client::Update(bool theIsClear) { bool anIsModified = true; if(mySMESHDSMesh){ + MESSAGE("Update mySMESHDSMesh"); SMESHDS_Script* aScript = mySMESHDSMesh->GetScript(); anIsModified = aScript->IsModified(); aScript->SetModified(false); }else{ + MESSAGE("Update CORBA"); SMESH::log_array_var aSeq = myMeshServer->GetLog( theIsClear ); CORBA::Long aLength = aSeq->length(); anIsModified = aLength > 0; diff --git a/src/SMESHDS/SMESHDS_Mesh.cxx b/src/SMESHDS/SMESHDS_Mesh.cxx index 880cda0e3..944df5abf 100644 --- a/src/SMESHDS/SMESHDS_Mesh.cxx +++ b/src/SMESHDS/SMESHDS_Mesh.cxx @@ -1782,10 +1782,11 @@ void SMESHDS_Mesh::compactMesh() int nbNodes = myNodes.size(); int nbVtkNodes = myGrid->GetNumberOfPoints(); MESSAGE("nbNodes=" << nbNodes << " nbVtkNodes=" << nbVtkNodes); - if (nbNodes > nbVtkNodes) nbVtkNodes = nbNodes; + int nbNodeTemp = nbVtkNodes; + if (nbNodes > nbVtkNodes) nbNodeTemp = nbNodes; vector idNodesOldToNew; idNodesOldToNew.clear(); - idNodesOldToNew.resize(nbVtkNodes, -1); // all unused id will be -1 + idNodesOldToNew.resize(nbNodeTemp, -1); // all unused id will be -1 bool areNodesModified = ! myNodeIDFactory->isPoolIdEmpty(); MESSAGE("------------------------------------------------- SMESHDS_Mesh::compactMesh " << areNodesModified); @@ -1804,16 +1805,19 @@ void SMESHDS_Mesh::compactMesh() { for (int i=0; i nbVtkNodes) + newNodeSize = nbVtkNodes; // else 0 means nothing to change (no need to compact vtkPoints) } int newCellSize = 0; int nbCells = myCells.size(); int nbVtkCells = myGrid->GetNumberOfCells(); MESSAGE("nbCells=" << nbCells << " nbVtkCells=" << nbVtkCells); - if (nbCells > nbVtkCells) nbVtkCells = nbCells; + int nbCellTemp = nbVtkCells; + if (nbCells > nbVtkCells) nbCellTemp = nbCells; vector idCellsOldToNew; idCellsOldToNew.clear(); - idCellsOldToNew.resize(nbVtkCells, -1); // all unused id will be -1 + idCellsOldToNew.resize(nbCellTemp, -1); // all unused id will be -1 for (int i=0; i " << newid); - myNodes[i]->setId(newid); - ASSERT(!myNodes[newid]); - myNodes[newid] = myNodes[i]; - } + //MESSAGE(i << " --> " << newid);; + myNodes[i]->setId(newid); + newNodes[newid] = myNodes[i]; } } + myNodes.swap(newNodes); this->myNodeIDFactory->emptyPool(newNodeSize); } @@ -1882,6 +1886,7 @@ void SMESHDS_Mesh::compactMesh() { if (myCells[i]) { + //MESSAGE(newSmdsId << " " << i); newCells[newSmdsId] = myCells[i]; int idvtk = myCells[i]->getVtkId(); newSmdsToVtk[newSmdsId] = idvtk; diff --git a/src/SMESHGUI/SMESHGUI.cxx b/src/SMESHGUI/SMESHGUI.cxx index 53d8b7373..1b6d3fb83 100644 --- a/src/SMESHGUI/SMESHGUI.cxx +++ b/src/SMESHGUI/SMESHGUI.cxx @@ -1093,6 +1093,7 @@ LightApp_Module( "SMESH" ) { CORBA::Boolean anIsEmbeddedMode; myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode); + MESSAGE("-------------------------------> anIsEmbeddedMode=" << anIsEmbeddedMode); // 0019923: EDF 765 SMESH : default values of hypothesis SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this); diff --git a/src/SMESHGUI/SMESHGUI_VTKUtils.cxx b/src/SMESHGUI/SMESHGUI_VTKUtils.cxx index 61d21573a..8e16d0898 100644 --- a/src/SMESHGUI/SMESHGUI_VTKUtils.cxx +++ b/src/SMESHGUI/SMESHGUI_VTKUtils.cxx @@ -326,7 +326,7 @@ namespace SMESH #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 OCC_CATCH_SIGNALS; #endif - MESSAGE("GetVisualObj"); + //MESSAGE("GetVisualObj"); if (nulData) objModified = aVisualObj->NulData(); else @@ -669,7 +669,7 @@ namespace SMESH bool UpdateView(SUIT_ViewWindow *theWnd, EDisplaing theAction, const char* theEntry) { - MESSAGE("UpdateView"); + //MESSAGE("UpdateView"); bool OK = false; SVTK_ViewWindow* aViewWnd = GetVtkViewWindow(theWnd); if (!aViewWnd) @@ -694,10 +694,10 @@ namespace SMESH } case eDisplayOnly: case eEraseAll: { - MESSAGE("---case eDisplayOnly"); + //MESSAGE("---case eDisplayOnly"); while (vtkActor *anAct = aCollection->GetNextActor()) { if (SMESH_Actor *anActor = dynamic_cast(anAct)) { - MESSAGE("--- erase " << anActor); + //MESSAGE("--- erase " << anActor); anActor->SetVisibility(false); } } @@ -707,12 +707,12 @@ namespace SMESH switch (theAction) { case eDisplay: case eDisplayOnly: - MESSAGE("--- display " << anActor); + //MESSAGE("--- display " << anActor); anActor->SetVisibility(true); if (theAction == eDisplayOnly) aRenderer->ResetCameraClippingRange(); break; case eErase: - MESSAGE("--- erase " << anActor); + //MESSAGE("--- erase " << anActor); anActor->SetVisibility(false); break; } @@ -721,7 +721,7 @@ namespace SMESH case eDisplay: case eDisplayOnly: { - MESSAGE("---"); + //MESSAGE("---"); SalomeApp_Study* aStudy = dynamic_cast(theWnd->getViewManager()->study()); _PTR(Study) aDocument = aStudy->studyDS(); // Pass non-visual objects (hypotheses, etc.), return true in this case @@ -750,7 +750,7 @@ namespace SMESH bool UpdateView(EDisplaing theAction, const char* theEntry){ - MESSAGE("UpdateView"); + //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(); diff --git a/src/SMESH_I/SMESH_Gen_i.cxx b/src/SMESH_I/SMESH_Gen_i.cxx index 488accd76..b00a7e8a0 100644 --- a/src/SMESH_I/SMESH_Gen_i.cxx +++ b/src/SMESH_I/SMESH_Gen_i.cxx @@ -459,6 +459,7 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::createMesh() // create a new mesh object servant, store it in a map in study context SMESH_Mesh_i* meshServant = new SMESH_Mesh_i( GetPOA(), this, GetCurrentStudyID() ); // create a new mesh object + MESSAGE("myIsEmbeddedMode " << myIsEmbeddedMode); meshServant->SetImpl( myGen.CreateMesh( GetCurrentStudyID(), myIsEmbeddedMode )); // activate the CORBA servant of Mesh @@ -516,6 +517,7 @@ void SMESH_Gen_i::SetGeomEngine( GEOM::GEOM_Gen_ptr geomcompo ) void SMESH_Gen_i::SetEmbeddedMode( CORBA::Boolean theMode ) { myIsEmbeddedMode = theMode; + MESSAGE("myIsEmbeddedMode " << myIsEmbeddedMode); if ( !myIsEmbeddedMode ) { //PAL10867: disable signals catching with "noexcepthandler" option -- 2.39.2