myLocalGrid = false;
vtkUnstructuredGrid *theGrid = GetMesh()->getGrid();
myGrid->ShallowCopy(theGrid);
- MESSAGE(myGrid->GetReferenceCount());
- MESSAGE( "Update - myGrid->GetNumberOfCells() = "<<myGrid->GetNumberOfCells() );
- MESSAGE( "Update - myGrid->GetNumberOfPoints() = "<<myGrid->GetNumberOfPoints() );
+ //MESSAGE(myGrid->GetReferenceCount());
+ //MESSAGE( "Update - myGrid->GetNumberOfCells() = "<<myGrid->GetNumberOfCells() );
+ //MESSAGE( "Update - myGrid->GetNumberOfPoints() = "<<myGrid->GetNumberOfPoints() );
if( MYDEBUGWITHFILES ) SMESH::WriteUnstructuredGrid( myGrid,"/tmp/buildPrs" );
}
}
vtkUnstructuredGrid* SMESH_VisualObjDef::GetUnstructuredGrid()
{
- MESSAGE("SMESH_VisualObjDef::GetUnstructuredGrid " << myGrid);
+ //MESSAGE("SMESH_VisualObjDef::GetUnstructuredGrid " << myGrid);
return myGrid;
}
//=================================================================================
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 ||
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;
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
============================
int startBloc = 0;
int endBloc = 0;
int alreadyCopied = 0;
+ int holes = 0;
typedef enum {lookHoleStart, lookHoleEnd, lookBlocEnd} enumState;
enumState compactState = lookHoleStart;
vtkPoints *newPoints = 0;
if (newNodeSize)
{
- MESSAGE("-------------- compactGrid, newNodeSize");
+ MESSAGE("-------------- compactGrid, newNodeSize " << newNodeSize);
newPoints = vtkPoints::New();
newPoints->Initialize();
newPoints->Allocate(newNodeSize);
{
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;
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<endBloc; j++)
- idNodesOldToNew[j] = alreadyCopied++;
+ copyNodes(newPoints, idNodesOldToNew, alreadyCopied, startBloc, endBloc);
compactState = lookHoleStart;
startHole = i;
endHole = 0;
}
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
startBloc = 0;
endBloc = 0;
alreadyCopied = 0;
+ holes = 0;
compactState = lookHoleStart;
vtkIdType tmpid[50];
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; j<endBloc; j++)
- {
- newTypes->SetValue(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; l<nbpts; 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;
+ MESSAGE(" -------- newCellSize, endBloc " << endBloc << " " << oldCellSize);
+ copyBloc(newTypes, idCellsOldToNew, idNodesOldToNew, newConnectivity, newLocations, pointsCell, alreadyCopied, startBloc, endBloc);
+ compactState = lookHoleStart;
}
break;
}
if (!alreadyCopied) // no hole, but shorter
{
MESSAGE(" -------- newCellSize, shorter " << oldCellSize);
- for (int j=0; j<oldCellSize; j++)
- {
- newTypes->SetValue(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; l<nbpts; l++)
- {
- int oldval = oldPtsCell[l];
- pointsCell[l] = idNodesOldToNew[oldval];
- //MESSAGE(" " << oldval << " " << pointsCell[l]);
- }
- int newcnt = newConnectivity->InsertNextCell(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();
{
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<int>& 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<end; j++)
+ idNodesOldToNew[j] = alreadyCopied++;
+ }
+}
+
+void SMDS_UnstructuredGrid::copyBloc(vtkUnsignedCharArray *newTypes,
+ std::vector<int>& idCellsOldToNew,
+ std::vector<int>& 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; j<end; j++)
+ {
+ newTypes->SetValue(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; l<nbpts; l++)
+ {
+ int oldval = oldPtsCell[l];
+ pointsCell[l] = idNodesOldToNew[oldval];
+ //MESSAGE(" " << oldval << " " << pointsCell[l]);
+ }
+ int newcnt = newConnectivity->InsertNextCell(nbpts, pointsCell);
+ int newLoc = newConnectivity->GetInsertLocation(nbpts);
+ //MESSAGE(newcnt << " " << newLoc);
+ newLocations->SetValue(alreadyCopied, newLoc);
+ alreadyCopied++;
+ }
+}
protected:
SMDS_UnstructuredGrid();
~SMDS_UnstructuredGrid();
+ void copyNodes(vtkPoints *newPoints,
+ std::vector<int>& idNodesOldToNew,
+ int& alreadyCopied,
+ int start,
+ int end);
+ void copyBloc(vtkUnsignedCharArray *newTypes,
+ std::vector<int>& idCellsOldToNew,
+ std::vector<int>& idNodesOldToNew,
+ vtkCellArray* newConnectivity,
+ vtkIdTypeArray* newLocations,
+ vtkIdType* pointsCell,
+ int& alreadyCopied,
+ int start,
+ int end);
+
};
#endif /* _SMDS_UNSTRUCTUREDGRID_HXX */
#endif
#ifdef _DEBUG_
-static int MYDEBUG = 0;
+static int MYDEBUG = 1;
#else
static int MYDEBUG = 0;
#endif
mySMESHDSMesh(NULL),
mySMDSMesh(NULL)
{
+ MESSAGE("SMESH_Client::SMESH_Client");
myMeshServer->Register();
CORBA::Boolean anIsEmbeddedMode;
SMESH_Mesh* aMesh = reinterpret_cast<SMESH_Mesh*> (pointeur);
if ( MYDEBUG )
MESSAGE("SMESH_Client::SMESH_Client aMesh "<<aMesh);
- if(aMesh->GetMeshDS()->IsEmbeddedMode()){
+ //if(aMesh->GetMeshDS()->IsEmbeddedMode()){
+ if(anIsEmbeddedMode){
mySMESHDSMesh = aMesh->GetMeshDS();
mySMDSMesh = mySMESHDSMesh;
}
{
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;
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<int> 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);
{
for (int i=0; i<nbNodes; i++)
idNodesOldToNew[i] = i;
+ if (nbNodes > 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<int> 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<nbCells; i++)
{
if (areNodesModified)
{
MESSAGE("-------------- modify myNodes");
+ SetOfNodes newNodes;
+ newNodes.resize(newNodeSize);
+
for (int i=0; i<nbNodes; i++)
{
if (myNodes[i])
{
int newid = idNodesOldToNew[i];
- if (newid != i)
- {
- MESSAGE(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);
}
{
if (myCells[i])
{
+ //MESSAGE(newSmdsId << " " << i);
newCells[newSmdsId] = myCells[i];
int idvtk = myCells[i]->getVtkId();
newSmdsToVtk[newSmdsId] = idvtk;
{
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);
#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
bool UpdateView(SUIT_ViewWindow *theWnd, EDisplaing theAction, const char* theEntry)
{
- MESSAGE("UpdateView");
+ //MESSAGE("UpdateView");
bool OK = false;
SVTK_ViewWindow* aViewWnd = GetVtkViewWindow(theWnd);
if (!aViewWnd)
}
case eDisplayOnly:
case eEraseAll: {
- MESSAGE("---case eDisplayOnly");
+ //MESSAGE("---case eDisplayOnly");
while (vtkActor *anAct = aCollection->GetNextActor()) {
if (SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)) {
- MESSAGE("--- erase " << anActor);
+ //MESSAGE("--- erase " << anActor);
anActor->SetVisibility(false);
}
}
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;
}
case eDisplay:
case eDisplayOnly:
{
- MESSAGE("---");
+ //MESSAGE("---");
SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(theWnd->getViewManager()->study());
_PTR(Study) aDocument = aStudy->studyDS();
// Pass non-visual objects (hypotheses, etc.), return true in this case
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();
// 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
void SMESH_Gen_i::SetEmbeddedMode( CORBA::Boolean theMode )
{
myIsEmbeddedMode = theMode;
+ MESSAGE("myIsEmbeddedMode " << myIsEmbeddedMode);
if ( !myIsEmbeddedMode ) {
//PAL10867: disable signals catching with "noexcepthandler" option