IMP 23373: [CEA 1170] Optimization of a 3D mesh using MG-Tetra

SMESHGUI_* - treat an algo that can work w/o geom only

+ fix a crash at mesh modif just after visualization
   SMDS_* - assure that grid->Links exist before grid->InsertNextLinkedCell()
This commit is contained in:
eap 2016-11-03 18:55:09 +03:00
parent cbad42bc85
commit 75d0234b45
18 changed files with 283 additions and 332 deletions

View File

@ -45,7 +45,8 @@
input - geometry of elements accepted by algorithm input. Used to define compatible algos of input - geometry of elements accepted by algorithm input. Used to define compatible algos of
different dimensions. Compatible algos have equal geometries in "input" and "output". different dimensions. Compatible algos have equal geometries in "input" and "output".
need-hyp - (optional) Boolean. Does the algo require a hypothesis or not. Default is "false". need-hyp - (optional) Boolean. Does the algo require a hypothesis or not. Default is "false".
need-geom - (optional) Boolean. Can the algo work w/o geometry or not. Default is "true". need-geom - (optional) [true, fasle, never]. Can the algo work w/o geometry or not.
Default is "true" "never" means that the algo can't work with geometry.
support-submeshes - (optional) Boolean. Does an multi-dimensional algo support sub-meshes. support-submeshes - (optional) Boolean. Does an multi-dimensional algo support sub-meshes.
Default is "false". Default is "false".

View File

@ -47,10 +47,9 @@ SMDS_BallElement::SMDS_BallElement(vtkIdType nodeId, double diameter, SMDS_Mesh*
void SMDS_BallElement::init(vtkIdType nodeId, double diameter, SMDS_Mesh* mesh) void SMDS_BallElement::init(vtkIdType nodeId, double diameter, SMDS_Mesh* mesh)
{ {
SMDS_MeshCell::init(); SMDS_MeshCell::init();
SMDS_UnstructuredGrid* grid = mesh->getGrid();
myVtkID = grid->InsertNextLinkedCell( GetVtkType(), 1, &nodeId );
myMeshId = mesh->getMeshId(); myMeshId = mesh->getMeshId();
grid->SetBallDiameter( myVtkID, diameter ); myVtkID = mesh->getGrid()->InsertNextLinkedCell( GetVtkType(), 1, &nodeId );
mesh->getGrid()->SetBallDiameter( myVtkID, diameter );
mesh->setMyModified(); mesh->setMyModified();
} }

View File

@ -73,8 +73,8 @@ public:
static std::vector<SMDS_Mesh*> _meshList; static std::vector<SMDS_Mesh*> _meshList;
//! actual nodes coordinates, cells definition and reverse connectivity are stored in a vtkUnstructuredGrid //! actual nodes coordinates, cells definition and reverse connectivity are stored in a vtkUnstructuredGrid
inline SMDS_UnstructuredGrid* getGrid() {return myGrid; } inline SMDS_UnstructuredGrid* getGrid() { return myGrid; }
inline int getMeshId() {return myMeshId; } inline int getMeshId() { return myMeshId; }
virtual SMDS_NodeIteratorPtr nodesIterator (bool idInceasingOrder=false) const; virtual SMDS_NodeIteratorPtr nodesIterator (bool idInceasingOrder=false) const;
virtual SMDS_EdgeIteratorPtr edgesIterator (bool idInceasingOrder=false) const; virtual SMDS_EdgeIteratorPtr edgesIterator (bool idInceasingOrder=false) const;

View File

@ -53,27 +53,23 @@ SMDS_MeshElementIDFactory::SMDS_MeshElementIDFactory():
int SMDS_MeshElementIDFactory::SetInVtkGrid(SMDS_MeshElement * elem) int SMDS_MeshElementIDFactory::SetInVtkGrid(SMDS_MeshElement * elem)
{ {
// --- retrieve nodes ID // --- retrieve nodes ID
SMDS_MeshCell *cell = dynamic_cast<SMDS_MeshCell*>(elem); SMDS_MeshCell *cell = dynamic_cast<SMDS_MeshCell*>(elem);
assert(cell); assert(cell);
vector<vtkIdType> nodeIds; vector<vtkIdType> nodeIds( elem->NbNodes() );
SMDS_ElemIteratorPtr it = elem->nodesIterator(); SMDS_ElemIteratorPtr it = elem->nodesIterator();
while(it->more()) for( int i = 0; it->more(); ++i )
{ {
int nodeId = (static_cast<const SMDS_MeshNode*>(it->next()))->getVtkId(); int nodeId = (static_cast<const SMDS_MeshNode*>(it->next()))->getVtkId();
MESSAGE(" node in cell " << cell->getVtkId() << " : " << nodeId) nodeIds[i] = nodeId;
nodeIds.push_back(nodeId);
} }
// --- insert cell in vtkUnstructuredGrid // --- insert cell in vtkUnstructuredGrid
vtkUnstructuredGrid * grid = myMesh->getGrid(); int typ = VTK_VERTEX;
//int locType = elem->GetType(); int cellId = myMesh->getGrid()->InsertNextLinkedCell(typ, nodeIds.size(), &nodeIds[0]);
int typ = VTK_VERTEX;//GetVtkCellType(locType);
int cellId = grid->InsertNextLinkedCell(typ, nodeIds.size(), &nodeIds[0]);
cell->setVtkId(cellId); cell->setVtkId(cellId);
//MESSAGE("SMDS_MeshElementIDFactory::SetInVtkGrid " << cellId);
return cellId; return cellId;
} }
@ -122,17 +118,16 @@ int SMDS_MeshElementIDFactory::GetFreeID()
void SMDS_MeshElementIDFactory::ReleaseID(int ID, int vtkId) void SMDS_MeshElementIDFactory::ReleaseID(int ID, int vtkId)
{ {
if (ID < 1) // TODO check case ID == O if (ID < 1) // TODO check case ID == O
{ {
MESSAGE("~~~~~~~~~~~~~~ SMDS_MeshElementIDFactory::ReleaseID ID = " << ID); MESSAGE("~~~~~~~~~~~~~~ SMDS_MeshElementIDFactory::ReleaseID ID = " << ID);
return; return;
} }
//MESSAGE("~~~~~~~~~~~~~~ SMDS_MeshElementIDFactory::ReleaseID smdsId vtkId " << ID << " " << vtkId);
if (vtkId >= 0) if (vtkId >= 0)
{ {
assert(vtkId < (int)myMesh->myCellIdVtkToSmds.size()); assert(vtkId < (int)myMesh->myCellIdVtkToSmds.size());
myMesh->myCellIdVtkToSmds[vtkId] = -1; myMesh->myCellIdVtkToSmds[vtkId] = -1;
myMesh->setMyModified(); myMesh->setMyModified();
} }
SMDS_MeshIDFactory::ReleaseID(ID); SMDS_MeshIDFactory::ReleaseID(ID);
if (ID == myMax) if (ID == myMax)
myMax = 0; myMax = 0;
@ -150,16 +145,16 @@ void SMDS_MeshElementIDFactory::updateMinMax() const
myMin = INT_MAX; myMin = INT_MAX;
myMax = 0; myMax = 0;
for (size_t i = 0; i < myMesh->myCells.size(); i++) for (size_t i = 0; i < myMesh->myCells.size(); i++)
{
if (myMesh->myCells[i])
{ {
if (myMesh->myCells[i]) int id = myMesh->myCells[i]->GetID();
{ if (id > myMax)
int id = myMesh->myCells[i]->GetID(); myMax = id;
if (id > myMax) if (id < myMin)
myMax = id; myMin = id;
if (id < myMin)
myMin = id;
}
} }
}
if (myMin == INT_MAX) if (myMin == INT_MAX)
myMin = 0; myMin = 0;
} }
@ -171,12 +166,11 @@ void SMDS_MeshElementIDFactory::updateMinMax() const
SMDS_ElemIteratorPtr SMDS_MeshElementIDFactory::elementsIterator() const SMDS_ElemIteratorPtr SMDS_MeshElementIDFactory::elementsIterator() const
{ {
return myMesh->elementsIterator(SMDSAbs_All); return myMesh->elementsIterator(SMDSAbs_All);
} }
void SMDS_MeshElementIDFactory::Clear() void SMDS_MeshElementIDFactory::Clear()
{ {
//myMesh->myCellIdSmdsToVtk.clear();
myMesh->myCellIdVtkToSmds.clear(); myMesh->myCellIdVtkToSmds.clear();
myMin = myMax = 0; myMin = myMax = 0;
SMDS_MeshIDFactory::Clear(); SMDS_MeshIDFactory::Clear();

View File

@ -130,27 +130,18 @@ unsigned long SMDS_UnstructuredGrid::GetMTime()
unsigned long mtime = vtkUnstructuredGrid::GetMTime(); unsigned long mtime = vtkUnstructuredGrid::GetMTime();
return mtime; return mtime;
} }
// OUV_PORTING_VTK6: seems to be useless
/*
void SMDS_UnstructuredGrid::Update()
{
return vtkUnstructuredGrid::Update();
}
void SMDS_UnstructuredGrid::UpdateInformation()
{
return vtkUnstructuredGrid::UpdateInformation();
}
*/
vtkPoints* SMDS_UnstructuredGrid::GetPoints() vtkPoints* SMDS_UnstructuredGrid::GetPoints()
{ {
// TODO erreur incomprehensible de la macro vtk GetPoints apparue avec la version paraview de fin aout 2010 // TODO erreur incomprehensible de la macro vtk GetPoints apparue avec la version paraview de fin aout 2010
return this->Points; return this->Points;
} }
//#ifdef VTK_HAVE_POLYHEDRON
int SMDS_UnstructuredGrid::InsertNextLinkedCell(int type, int npts, vtkIdType *pts) int SMDS_UnstructuredGrid::InsertNextLinkedCell(int type, int npts, vtkIdType *pts)
{ {
if ( !this->Links )
BuildLinks();
if (type != VTK_POLYHEDRON) if (type != VTK_POLYHEDRON)
return vtkUnstructuredGrid::InsertNextLinkedCell(type, npts, pts); return vtkUnstructuredGrid::InsertNextLinkedCell(type, npts, pts);
@ -162,26 +153,25 @@ int SMDS_UnstructuredGrid::InsertNextLinkedCell(int type, int npts, vtkIdType *p
int nbfaces = npts; int nbfaces = npts;
int i = 0; int i = 0;
for (int nf = 0; nf < nbfaces; nf++) for (int nf = 0; nf < nbfaces; nf++)
{
int nbnodes = pts[i];
i++;
for (int k = 0; k < nbnodes; k++)
{ {
int nbnodes = pts[i]; setOfNodes.insert(pts[i]);
i++; i++;
for (int k = 0; k < nbnodes; k++)
{
setOfNodes.insert(pts[i]);
i++;
}
} }
}
set<vtkIdType>::iterator it = setOfNodes.begin(); set<vtkIdType>::iterator it = setOfNodes.begin();
for (; it != setOfNodes.end(); ++it) for (; it != setOfNodes.end(); ++it)
{ {
this->Links->ResizeCellList(*it, 1); this->Links->ResizeCellList(*it, 1);
this->Links->AddCellReference(cellid, *it); this->Links->AddCellReference(cellid, *it);
} }
return cellid; return cellid;
} }
//#endif
void SMDS_UnstructuredGrid::setSMDS_mesh(SMDS_Mesh *mesh) void SMDS_UnstructuredGrid::setSMDS_mesh(SMDS_Mesh *mesh)
{ {
@ -191,7 +181,6 @@ void SMDS_UnstructuredGrid::setSMDS_mesh(SMDS_Mesh *mesh)
void SMDS_UnstructuredGrid::compactGrid(std::vector<int>& idNodesOldToNew, int newNodeSize, void SMDS_UnstructuredGrid::compactGrid(std::vector<int>& idNodesOldToNew, int newNodeSize,
std::vector<int>& idCellsOldToNew, int newCellSize) std::vector<int>& idCellsOldToNew, int newCellSize)
{ {
//MESSAGE("------------------------- compactGrid " << newNodeSize << " " << newCellSize);//CHRONO(1);
int alreadyCopied = 0; int alreadyCopied = 0;
this->DeleteLinks(); this->DeleteLinks();
@ -234,8 +223,16 @@ void SMDS_UnstructuredGrid::compactGrid(std::vector<int>& idNodesOldToNew, int n
int oldCellSize = this->Types->GetNumberOfTuples(); int oldCellSize = this->Types->GetNumberOfTuples();
if ( oldCellSize == newCellSize ) if ( oldCellSize == newCellSize ) // no holes in elements
{ {
this->Connectivity->Squeeze();
this->Locations->Squeeze();
this->Types->Squeeze();
if ( this->FaceLocations )
{
this->FaceLocations->Squeeze();
this->Faces->Squeeze();
}
for ( int i = 0; i < oldCellSize; ++i ) for ( int i = 0; i < oldCellSize; ++i )
idCellsOldToNew[i] = i; idCellsOldToNew[i] = i;
return; return;
@ -352,11 +349,11 @@ void SMDS_UnstructuredGrid::copyNodes(vtkPoints * newPoints,
void *source = this->Points->GetVoidPointer(3 * start); void *source = this->Points->GetVoidPointer(3 * start);
int nbPoints = end - start; int nbPoints = end - start;
if (nbPoints > 0) if (nbPoints > 0)
{ {
memcpy(target, source, 3 * sizeof(double) * nbPoints); memcpy(target, source, 3 * sizeof(double) * nbPoints);
for (int j = start; j < end; j++) for (int j = start; j < end; j++)
idNodesOldToNew[j] = alreadyCopied++; // old vtkId --> new vtkId idNodesOldToNew[j] = alreadyCopied++; // old vtkId --> new vtkId
} }
} }
void SMDS_UnstructuredGrid::copyBloc(vtkUnsignedCharArray *newTypes, void SMDS_UnstructuredGrid::copyBloc(vtkUnsignedCharArray *newTypes,
@ -370,24 +367,24 @@ void SMDS_UnstructuredGrid::copyBloc(vtkUnsignedCharArray *newTypes,
int end) int end)
{ {
for (int j = start; j < end; j++) for (int j = start; j < end; j++)
{
newTypes->SetValue(alreadyCopied, this->Types->GetValue(j));
idCellsOldToNew[j] = alreadyCopied; // old vtkId --> new vtkId
vtkIdType oldLoc = this->Locations->GetValue(j);
vtkIdType nbpts;
vtkIdType *oldPtsCell = 0;
this->Connectivity->GetCell(oldLoc, nbpts, oldPtsCell);
assert(nbpts < NBMAXNODESINCELL);
for (int l = 0; l < nbpts; l++)
{ {
newTypes->SetValue(alreadyCopied, this->Types->GetValue(j)); int oldval = oldPtsCell[l];
idCellsOldToNew[j] = alreadyCopied; // old vtkId --> new vtkId pointsCell[l] = idNodesOldToNew[oldval];
vtkIdType oldLoc = this->Locations->GetValue(j);
vtkIdType nbpts;
vtkIdType *oldPtsCell = 0;
this->Connectivity->GetCell(oldLoc, nbpts, oldPtsCell);
assert(nbpts < NBMAXNODESINCELL);
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++;
} }
/*int newcnt = */newConnectivity->InsertNextCell(nbpts, pointsCell);
int newLoc = newConnectivity->GetInsertLocation(nbpts);
newLocations->SetValue(alreadyCopied, newLoc);
alreadyCopied++;
}
} }
int SMDS_UnstructuredGrid::CellIdToDownId(int vtkCellId) int SMDS_UnstructuredGrid::CellIdToDownId(int vtkCellId)

View File

@ -70,14 +70,9 @@ public:
std::vector<int>& idCellsOldToNew, std::vector<int>& idCellsOldToNew,
int newCellSize); int newCellSize);
virtual unsigned long GetMTime(); virtual unsigned long GetMTime();
// OUV_PORTING_VTK6: seems to be useless
//virtual void Update();
//virtual void UpdateInformation();
virtual vtkPoints *GetPoints(); virtual vtkPoints *GetPoints();
//#ifdef VTK_HAVE_POLYHEDRON
int InsertNextLinkedCell(int type, int npts, vtkIdType *pts); int InsertNextLinkedCell(int type, int npts, vtkIdType *pts);
//#endif
int CellIdToDownId(int vtkCellId); int CellIdToDownId(int vtkCellId);
void setCellIdToDownId(int vtkCellId, int downId); void setCellIdToDownId(int vtkCellId, int downId);

View File

@ -45,14 +45,10 @@ SMDS_VtkEdge::~SMDS_VtkEdge()
void SMDS_VtkEdge::init(std::vector<vtkIdType>& nodeIds, SMDS_Mesh* mesh) void SMDS_VtkEdge::init(std::vector<vtkIdType>& nodeIds, SMDS_Mesh* mesh)
{ {
SMDS_MeshEdge::init(); SMDS_MeshEdge::init();
vtkUnstructuredGrid* grid = mesh->getGrid();
myMeshId = mesh->getMeshId(); myMeshId = mesh->getMeshId();
vtkIdType aType = VTK_LINE; vtkIdType aType = ( nodeIds.size() == 3 ) ? VTK_QUADRATIC_EDGE : VTK_LINE;
if (nodeIds.size() == 3) myVtkID = mesh->getGrid()->InsertNextLinkedCell(aType, nodeIds.size(), &nodeIds[0]);
aType = VTK_QUADRATIC_EDGE;
myVtkID = grid->InsertNextLinkedCell(aType, nodeIds.size(), &nodeIds[0]);
mesh->setMyModified(); mesh->setMyModified();
//MESSAGE("SMDS_VtkEdge::init myVtkID " << myVtkID);
} }
bool SMDS_VtkEdge::ChangeNodes(const SMDS_MeshNode * node1, const SMDS_MeshNode * node2) bool SMDS_VtkEdge::ChangeNodes(const SMDS_MeshNode * node1, const SMDS_MeshNode * node2)
@ -69,14 +65,14 @@ bool SMDS_VtkEdge::ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes)
vtkIdType* pts = 0; vtkIdType* pts = 0;
grid->GetCellPoints(myVtkID, npts, pts); grid->GetCellPoints(myVtkID, npts, pts);
if (nbNodes != npts) if (nbNodes != npts)
{ {
MESSAGE("ChangeNodes problem: not the same number of nodes " << npts << " -> " << nbNodes); MESSAGE("ChangeNodes problem: not the same number of nodes " << npts << " -> " << nbNodes);
return false; return false;
} }
for (int i = 0; i < nbNodes; i++) for (int i = 0; i < nbNodes; i++)
{ {
pts[i] = nodes[i]->getVtkId(); pts[i] = nodes[i]->getVtkId();
} }
SMDS_Mesh::_meshList[myMeshId]->setMyModified(); SMDS_Mesh::_meshList[myMeshId]->setMyModified();
return true; return true;
} }
@ -87,7 +83,6 @@ bool SMDS_VtkEdge::IsMediumNode(const SMDS_MeshNode* node) const
vtkIdType npts = 0; vtkIdType npts = 0;
vtkIdType* pts = 0; vtkIdType* pts = 0;
grid->GetCellPoints(myVtkID, npts, pts); grid->GetCellPoints(myVtkID, npts, pts);
//MESSAGE("IsMediumNode " << npts << " " << (node->getVtkId() == pts[npts-1]));
return ((npts == 3) && (node->getVtkId() == pts[2])); return ((npts == 3) && (node->getVtkId() == pts[2]));
} }

View File

@ -44,53 +44,37 @@ SMDS_VtkFace::~SMDS_VtkFace()
void SMDS_VtkFace::init(const std::vector<vtkIdType>& nodeIds, SMDS_Mesh* mesh) void SMDS_VtkFace::init(const std::vector<vtkIdType>& nodeIds, SMDS_Mesh* mesh)
{ {
SMDS_MeshFace::init(); SMDS_MeshFace::init();
vtkUnstructuredGrid* grid = mesh->getGrid();
myMeshId = mesh->getMeshId(); myMeshId = mesh->getMeshId();
vtkIdType aType = VTK_TRIANGLE; vtkIdType aType = VTK_TRIANGLE;
switch (nodeIds.size()) switch (nodeIds.size())
{ {
case 3: case 3: aType = VTK_TRIANGLE; break;
aType = VTK_TRIANGLE; case 4: aType = VTK_QUAD; break;
break; case 6: aType = VTK_QUADRATIC_TRIANGLE; break;
case 4: case 8: aType = VTK_QUADRATIC_QUAD; break;
aType = VTK_QUAD; case 9: aType = VTK_BIQUADRATIC_QUAD; break;
break; case 7: aType = VTK_BIQUADRATIC_TRIANGLE;break;
case 6: default: aType = VTK_POLYGON;
aType = VTK_QUADRATIC_TRIANGLE;
break;
case 8:
aType = VTK_QUADRATIC_QUAD;
break;
case 9:
aType = VTK_BIQUADRATIC_QUAD;
break;
case 7:
aType = VTK_BIQUADRATIC_TRIANGLE;
break;
default:
aType = VTK_POLYGON;
break;
} }
myVtkID = grid->InsertNextLinkedCell(aType, nodeIds.size(), (vtkIdType*) &nodeIds[0]); myVtkID = mesh->getGrid()->InsertNextLinkedCell(aType, nodeIds.size(), (vtkIdType*) &nodeIds[0]);
mesh->setMyModified(); mesh->setMyModified();
//MESSAGE("SMDS_VtkFace::init myVtkID " << myVtkID);
} }
void SMDS_VtkFace::initPoly(const std::vector<vtkIdType>& nodeIds, SMDS_Mesh* mesh) void SMDS_VtkFace::initPoly(const std::vector<vtkIdType>& nodeIds, SMDS_Mesh* mesh)
{ {
SMDS_MeshFace::init(); SMDS_MeshFace::init();
vtkUnstructuredGrid* grid = mesh->getGrid();
myMeshId = mesh->getMeshId(); myMeshId = mesh->getMeshId();
myVtkID = grid->InsertNextLinkedCell(VTK_POLYGON, nodeIds.size(), (vtkIdType*) &nodeIds[0]); vtkIdType aType = VTK_POLYGON;
myVtkID = mesh->getGrid()->InsertNextLinkedCell(aType, nodeIds.size(), (vtkIdType*) &nodeIds[0]);
mesh->setMyModified(); mesh->setMyModified();
} }
void SMDS_VtkFace::initQuadPoly(const std::vector<vtkIdType>& nodeIds, SMDS_Mesh* mesh) void SMDS_VtkFace::initQuadPoly(const std::vector<vtkIdType>& nodeIds, SMDS_Mesh* mesh)
{ {
SMDS_MeshFace::init(); SMDS_MeshFace::init();
vtkUnstructuredGrid* grid = mesh->getGrid();
myMeshId = mesh->getMeshId(); myMeshId = mesh->getMeshId();
myVtkID = grid->InsertNextLinkedCell(VTK_QUADRATIC_POLYGON, nodeIds.size(), (vtkIdType*) &nodeIds[0]); vtkIdType aType = VTK_QUADRATIC_POLYGON;
myVtkID = mesh->getGrid()->InsertNextLinkedCell(aType, nodeIds.size(), (vtkIdType*) &nodeIds[0]);
mesh->setMyModified(); mesh->setMyModified();
} }
@ -101,14 +85,14 @@ bool SMDS_VtkFace::ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes)
vtkIdType* pts = 0; vtkIdType* pts = 0;
grid->GetCellPoints(myVtkID, npts, pts); grid->GetCellPoints(myVtkID, npts, pts);
if (nbNodes != npts) if (nbNodes != npts)
{ {
MESSAGE("ChangeNodes problem: not the same number of nodes " << npts << " -> " << nbNodes); MESSAGE("ChangeNodes problem: not the same number of nodes " << npts << " -> " << nbNodes);
return false; return false;
} }
for (int i = 0; i < nbNodes; i++) for (int i = 0; i < nbNodes; i++)
{ {
pts[i] = nodes[i]->getVtkId(); pts[i] = nodes[i]->getVtkId();
} }
SMDS_Mesh::_meshList[myMeshId]->setMyModified(); SMDS_Mesh::_meshList[myMeshId]->setMyModified();
return true; return true;
} }

View File

@ -41,57 +41,31 @@ SMDS_VtkVolume::SMDS_VtkVolume(const std::vector<vtkIdType>& nodeIds, SMDS_Mesh*
void SMDS_VtkVolume::init(const std::vector<vtkIdType>& nodeIds, SMDS_Mesh* mesh) void SMDS_VtkVolume::init(const std::vector<vtkIdType>& nodeIds, SMDS_Mesh* mesh)
{ {
SMDS_MeshVolume::init(); SMDS_MeshVolume::init();
vtkUnstructuredGrid* grid = mesh->getGrid();
myMeshId = mesh->getMeshId(); myMeshId = mesh->getMeshId();
vtkIdType aType = VTK_TETRA; vtkIdType aType = VTK_TETRA;
switch (nodeIds.size()) // cases are in order of usage frequency switch (nodeIds.size()) // cases are in order of usage frequency
{ {
case 4: case 4: aType = VTK_TETRA; break;
aType = VTK_TETRA; case 8: aType = VTK_HEXAHEDRON; break;
break; case 5: aType = VTK_PYRAMID; break;
case 8: case 6: aType = VTK_WEDGE; break;
aType = VTK_HEXAHEDRON; case 10: aType = VTK_QUADRATIC_TETRA; break;
break; case 20: aType = VTK_QUADRATIC_HEXAHEDRON; break;
case 5: case 13: aType = VTK_QUADRATIC_PYRAMID; break;
aType = VTK_PYRAMID; case 15: aType = VTK_QUADRATIC_WEDGE; break;
break; case 12: aType = VTK_HEXAGONAL_PRISM; break;
case 6: case 27: aType = VTK_TRIQUADRATIC_HEXAHEDRON;break;
aType = VTK_WEDGE; default: aType = VTK_HEXAHEDRON;
break;
case 10:
aType = VTK_QUADRATIC_TETRA;
break;
case 20:
aType = VTK_QUADRATIC_HEXAHEDRON;
break;
case 13:
aType = VTK_QUADRATIC_PYRAMID;
break;
case 15:
aType = VTK_QUADRATIC_WEDGE;
break;
case 12:
aType = VTK_HEXAGONAL_PRISM;
break;
case 27:
aType = VTK_TRIQUADRATIC_HEXAHEDRON;
break;
default:
aType = VTK_HEXAHEDRON;
break;
} }
myVtkID = grid->InsertNextLinkedCell(aType, nodeIds.size(), (vtkIdType *) &nodeIds[0]); myVtkID = mesh->getGrid()->InsertNextLinkedCell(aType, nodeIds.size(), (vtkIdType *) &nodeIds[0]);
mesh->setMyModified(); mesh->setMyModified();
//MESSAGE("SMDS_VtkVolume::init myVtkID " << myVtkID);
} }
//#ifdef VTK_HAVE_POLYHEDRON
void SMDS_VtkVolume::initPoly(const std::vector<vtkIdType>& nodeIds, void SMDS_VtkVolume::initPoly(const std::vector<vtkIdType>& nodeIds,
const std::vector<int>& nbNodesPerFace, const std::vector<int>& nbNodesPerFace,
SMDS_Mesh* mesh) SMDS_Mesh* mesh)
{ {
SMDS_MeshVolume::init(); SMDS_MeshVolume::init();
//MESSAGE("SMDS_VtkVolume::initPoly");
SMDS_UnstructuredGrid* grid = mesh->getGrid(); SMDS_UnstructuredGrid* grid = mesh->getGrid();
//double center[3]; //double center[3];
//this->gravityCenter(grid, &nodeIds[0], nodeIds.size(), &center[0]); //this->gravityCenter(grid, &nodeIds[0], nodeIds.size(), &center[0]);
@ -99,36 +73,34 @@ void SMDS_VtkVolume::initPoly(const std::vector<vtkIdType>& nodeIds,
vtkIdType nbFaces = nbNodesPerFace.size(); vtkIdType nbFaces = nbNodesPerFace.size();
int k = 0; int k = 0;
for (int i = 0; i < nbFaces; i++) for (int i = 0; i < nbFaces; i++)
{ {
int nf = nbNodesPerFace[i]; int nf = nbNodesPerFace[i];
ptIds.push_back(nf); ptIds.push_back(nf);
// EAP: a right approach is: // EAP: a right approach is:
// - either the user should care of order of nodes or // - either the user should care of order of nodes or
// - the user should use a service method arranging nodes if he // - the user should use a service method arranging nodes if he
// don't want or can't to do it by him-self // don't want or can't to do it by him-self
// The method below works OK only with planar faces and convex polyhedrones // The method below works OK only with planar faces and convex polyhedrones
// //
// double a[3]; // double a[3];
// double b[3]; // double b[3];
// double c[3]; // double c[3];
// grid->GetPoints()->GetPoint(nodeIds[k], a); // grid->GetPoints()->GetPoint(nodeIds[k], a);
// grid->GetPoints()->GetPoint(nodeIds[k + 1], b); // grid->GetPoints()->GetPoint(nodeIds[k + 1], b);
// grid->GetPoints()->GetPoint(nodeIds[k + 2], c); // grid->GetPoints()->GetPoint(nodeIds[k + 2], c);
// bool isFaceForward = this->isForward(a, b, c, center); // bool isFaceForward = this->isForward(a, b, c, center);
//MESSAGE("isFaceForward " << i << " " << isFaceForward); const vtkIdType *facePts = &nodeIds[k];
const vtkIdType *facePts = &nodeIds[k]; //if (isFaceForward)
//if (isFaceForward) for (int n = 0; n < nf; n++)
for (int n = 0; n < nf; n++) ptIds.push_back(facePts[n]);
ptIds.push_back(facePts[n]); // else
// else // for (int n = nf - 1; n >= 0; n--)
// for (int n = nf - 1; n >= 0; n--) // ptIds.push_back(facePts[n]);
// ptIds.push_back(facePts[n]); k += nf;
k += nf; }
}
myVtkID = grid->InsertNextLinkedCell(VTK_POLYHEDRON, nbFaces, &ptIds[0]); myVtkID = grid->InsertNextLinkedCell(VTK_POLYHEDRON, nbFaces, &ptIds[0]);
mesh->setMyModified(); mesh->setMyModified();
} }
//#endif
bool SMDS_VtkVolume::ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes) bool SMDS_VtkVolume::ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes)
{ {
@ -137,14 +109,14 @@ bool SMDS_VtkVolume::ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes
vtkIdType* pts = 0; vtkIdType* pts = 0;
grid->GetCellPoints(myVtkID, npts, pts); grid->GetCellPoints(myVtkID, npts, pts);
if (nbNodes != npts) if (nbNodes != npts)
{ {
MESSAGE("ChangeNodes problem: not the same number of nodes " << npts << " -> " << nbNodes); MESSAGE("ChangeNodes problem: not the same number of nodes " << npts << " -> " << nbNodes);
return false; return false;
} }
for (int i = 0; i < nbNodes; i++) for (int i = 0; i < nbNodes; i++)
{ {
pts[i] = nodes[i]->getVtkId(); pts[i] = nodes[i]->getVtkId();
} }
SMDS_Mesh::_meshList[myMeshId]->setMyModified(); SMDS_Mesh::_meshList[myMeshId]->setMyModified();
return true; return true;
} }
@ -156,10 +128,10 @@ bool SMDS_VtkVolume::ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes
bool SMDS_VtkVolume::vtkOrder(const SMDS_MeshNode* nodes[], const int nbNodes) bool SMDS_VtkVolume::vtkOrder(const SMDS_MeshNode* nodes[], const int nbNodes)
{ {
if (nbNodes != this->NbNodes()) if (nbNodes != this->NbNodes())
{ {
MESSAGE("vtkOrder, wrong number of nodes " << nbNodes << " instead of "<< this->NbNodes()); MESSAGE("vtkOrder, wrong number of nodes " << nbNodes << " instead of "<< this->NbNodes());
return false; return false;
} }
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid(); vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
vtkIdType aVtkType = grid->GetCellType(this->myVtkID); vtkIdType aVtkType = grid->GetCellType(this->myVtkID);
const std::vector<int>& interlace = SMDS_MeshCell::toVtkOrder( VTKCellType( aVtkType )); const std::vector<int>& interlace = SMDS_MeshCell::toVtkOrder( VTKCellType( aVtkType ));
@ -230,23 +202,23 @@ int SMDS_VtkVolume::NbNodes() const
vtkIdType aVtkType = grid->GetCellType(this->myVtkID); vtkIdType aVtkType = grid->GetCellType(this->myVtkID);
vtkIdType nbPoints = 0; vtkIdType nbPoints = 0;
if (aVtkType != VTK_POLYHEDRON) if (aVtkType != VTK_POLYHEDRON)
{ {
vtkIdType *pts; vtkIdType *pts;
grid->GetCellPoints( myVtkID, nbPoints, pts ); grid->GetCellPoints( myVtkID, nbPoints, pts );
} }
else else
{
vtkIdType nFaces = 0;
vtkIdType* ptIds = 0;
grid->GetFaceStream(this->myVtkID, nFaces, ptIds);
int id = 0;
for (int i = 0; i < nFaces; i++)
{ {
vtkIdType nFaces = 0; int nodesInFace = ptIds[id];
vtkIdType* ptIds = 0; nbPoints += nodesInFace;
grid->GetFaceStream(this->myVtkID, nFaces, ptIds); id += (nodesInFace + 1);
int id = 0;
for (int i = 0; i < nFaces; i++)
{
int nodesInFace = ptIds[id];
nbPoints += nodesInFace;
id += (nodesInFace + 1);
}
} }
}
return nbPoints; return nbPoints;
} }
@ -311,22 +283,22 @@ int SMDS_VtkVolume::NbFaceNodes(const int face_ind) const
vtkIdType aVtkType = grid->GetCellType(this->myVtkID); vtkIdType aVtkType = grid->GetCellType(this->myVtkID);
int nbNodes = 0; int nbNodes = 0;
if (aVtkType == VTK_POLYHEDRON) if (aVtkType == VTK_POLYHEDRON)
{
vtkIdType nFaces = 0;
vtkIdType* ptIds = 0;
grid->GetFaceStream(this->myVtkID, nFaces, ptIds);
int id = 0;
for (int i = 0; i < nFaces; i++)
{ {
vtkIdType nFaces = 0; int nodesInFace = ptIds[id];
vtkIdType* ptIds = 0; id += (nodesInFace + 1);
grid->GetFaceStream(this->myVtkID, nFaces, ptIds); if (i == face_ind - 1)
int id = 0; {
for (int i = 0; i < nFaces; i++) nbNodes = nodesInFace;
{ break;
int nodesInFace = ptIds[id]; }
id += (nodesInFace + 1);
if (i == face_ind - 1)
{
nbNodes = nodesInFace;
break;
}
}
} }
}
return nbNodes; return nbNodes;
} }
@ -341,23 +313,23 @@ const SMDS_MeshNode* SMDS_VtkVolume::GetFaceNode(const int face_ind, const int n
vtkIdType aVtkType = grid->GetCellType(this->myVtkID); vtkIdType aVtkType = grid->GetCellType(this->myVtkID);
const SMDS_MeshNode* node = 0; const SMDS_MeshNode* node = 0;
if (aVtkType == VTK_POLYHEDRON) if (aVtkType == VTK_POLYHEDRON)
{
vtkIdType nFaces = 0;
vtkIdType* ptIds = 0;
grid->GetFaceStream(this->myVtkID, nFaces, ptIds);
int id = 0;
for (int i = 0; i < nFaces; i++)
{ {
vtkIdType nFaces = 0; int nodesInFace = ptIds[id]; // nodeIds in ptIds[id+1 .. id+nodesInFace]
vtkIdType* ptIds = 0; if (i == face_ind - 1) // first face is number 1
grid->GetFaceStream(this->myVtkID, nFaces, ptIds); {
int id = 0; if ((node_ind > 0) && (node_ind <= nodesInFace))
for (int i = 0; i < nFaces; i++) node = mesh->FindNodeVtk(ptIds[id + node_ind]); // ptIds[id+1] : first node
{ break;
int nodesInFace = ptIds[id]; // nodeIds in ptIds[id+1 .. id+nodesInFace] }
if (i == face_ind - 1) // first face is number 1 id += (nodesInFace + 1);
{
if ((node_ind > 0) && (node_ind <= nodesInFace))
node = mesh->FindNodeVtk(ptIds[id + node_ind]); // ptIds[id+1] : first node
break;
}
id += (nodesInFace + 1);
}
} }
}
return node; return node;
} }
@ -371,18 +343,18 @@ std::vector<int> SMDS_VtkVolume::GetQuantities() const
vtkUnstructuredGrid* grid = mesh->getGrid(); vtkUnstructuredGrid* grid = mesh->getGrid();
vtkIdType aVtkType = grid->GetCellType(this->myVtkID); vtkIdType aVtkType = grid->GetCellType(this->myVtkID);
if (aVtkType == VTK_POLYHEDRON) if (aVtkType == VTK_POLYHEDRON)
{
vtkIdType nFaces = 0;
vtkIdType* ptIds = 0;
grid->GetFaceStream(this->myVtkID, nFaces, ptIds);
int id = 0;
for (int i = 0; i < nFaces; i++)
{ {
vtkIdType nFaces = 0; int nodesInFace = ptIds[id]; // nodeIds in ptIds[id+1 .. id+nodesInFace]
vtkIdType* ptIds = 0; quantities.push_back(nodesInFace);
grid->GetFaceStream(this->myVtkID, nFaces, ptIds); id += (nodesInFace + 1);
int id = 0;
for (int i = 0; i < nFaces; i++)
{
int nodesInFace = ptIds[id]; // nodeIds in ptIds[id+1 .. id+nodesInFace]
quantities.push_back(nodesInFace);
id += (nodesInFace + 1);
}
} }
}
return quantities; return quantities;
} }
@ -539,16 +511,15 @@ bool SMDS_VtkVolume::IsMediumNode(const SMDS_MeshNode* node) const
grid->GetCellPoints(myVtkID, npts, pts); grid->GetCellPoints(myVtkID, npts, pts);
vtkIdType nodeId = node->getVtkId(); vtkIdType nodeId = node->getVtkId();
for (int rank = 0; rank < npts; rank++) for (int rank = 0; rank < npts; rank++)
{
if (pts[rank] == nodeId)
{ {
if (pts[rank] == nodeId) if (rank < rankFirstMedium)
{ return false;
if (rank < rankFirstMedium) else
return false; return true;
else
return true;
}
} }
//throw SALOME_Exception(LOCALIZED("node does not belong to this element")); }
MESSAGE("======================================================"); MESSAGE("======================================================");
MESSAGE("= IsMediumNode: node does not belong to this element ="); MESSAGE("= IsMediumNode: node does not belong to this element =");
MESSAGE("======================================================"); MESSAGE("======================================================");
@ -609,11 +580,9 @@ SMDSAbs_EntityType SMDS_VtkVolume::GetEntityType() const
case VTK_HEXAGONAL_PRISM: case VTK_HEXAGONAL_PRISM:
aType = SMDSEntity_Hexagonal_Prism; aType = SMDSEntity_Hexagonal_Prism;
break; break;
//#ifdef VTK_HAVE_POLYHEDRON
case VTK_POLYHEDRON: case VTK_POLYHEDRON:
aType = SMDSEntity_Polyhedra; aType = SMDSEntity_Polyhedra;
break; break;
//#endif
default: default:
aType = SMDSEntity_Polyhedra; aType = SMDSEntity_Polyhedra;
break; break;
@ -649,11 +618,9 @@ SMDSAbs_GeometryType SMDS_VtkVolume::GetGeomType() const
case VTK_HEXAGONAL_PRISM: case VTK_HEXAGONAL_PRISM:
aType = SMDSGeom_HEXAGONAL_PRISM; aType = SMDSGeom_HEXAGONAL_PRISM;
break; break;
//#ifdef VTK_HAVE_POLYHEDRON
case VTK_POLYHEDRON: case VTK_POLYHEDRON:
aType = SMDSGeom_POLYHEDRA; aType = SMDSGeom_POLYHEDRA;
break; break;
//#endif
default: default:
aType = SMDSGeom_POLYHEDRA; aType = SMDSGeom_POLYHEDRA;
break; break;
@ -685,7 +652,6 @@ void SMDS_VtkVolume::gravityCenter(SMDS_UnstructuredGrid* grid,
} }
for (int j = 0; j < 3; j++) for (int j = 0; j < 3; j++)
result[j] = result[j] / nbNodes; result[j] = result[j] / nbNodes;
//MESSAGE("center " << result[0] << " " << result[1] << " " << result[2]);
return; return;
} }
@ -693,16 +659,14 @@ bool SMDS_VtkVolume::isForward(double* a, double* b, double* c, double* d)
{ {
double u[3], v[3], w[3]; double u[3], v[3], w[3];
for (int j = 0; j < 3; j++) for (int j = 0; j < 3; j++)
{ {
//MESSAGE("a,b,c,d " << a[j] << " " << b[j] << " " << c[j] << " " << d[j]); u[j] = b[j] - a[j];
u[j] = b[j] - a[j]; v[j] = c[j] - a[j];
v[j] = c[j] - a[j]; w[j] = d[j] - a[j];
w[j] = d[j] - a[j]; }
//MESSAGE("u,v,w " << u[j] << " " << v[j] << " " << w[j]); double prodmixte = ((u[1]*v[2] - u[2]*v[1]) * w[0]
} + (u[2]*v[0] - u[0]*v[2]) * w[1]
double prodmixte = (u[1]*v[2] - u[2]*v[1]) * w[0] + (u[0]*v[1] - u[1]*v[0]) * w[2] );
+ (u[2]*v[0] - u[0]*v[2]) * w[1]
+ (u[0]*v[1] - u[1]*v[0]) * w[2];
return (prodmixte < 0); return (prodmixte < 0);
} }
@ -720,6 +684,5 @@ int SMDS_VtkVolume::NbUniqueNodes() const
*/ */
SMDS_ElemIteratorPtr SMDS_VtkVolume::uniqueNodesIterator() const SMDS_ElemIteratorPtr SMDS_VtkVolume::uniqueNodesIterator() const
{ {
//MESSAGE("uniqueNodesIterator");
return SMDS_ElemIteratorPtr(new SMDS_VtkCellIterator(SMDS_Mesh::_meshList[myMeshId], myVtkID, GetEntityType())); return SMDS_ElemIteratorPtr(new SMDS_VtkCellIterator(SMDS_Mesh::_meshList[myMeshId], myVtkID, GetEntityType()));
} }

View File

@ -1499,7 +1499,6 @@ bool SMESH_subMesh::ComputeStateEngine(compute_event event)
MESSAGE("std::bad_alloc thrown inside algo->Compute()"); MESSAGE("std::bad_alloc thrown inside algo->Compute()");
if ( _computeError ) { if ( _computeError ) {
_computeError->myName = COMPERR_MEMORY_PB; _computeError->myName = COMPERR_MEMORY_PB;
//_computeError->myComment = exc.what();
} }
cleanSubMesh( this ); cleanSubMesh( this );
throw exc; throw exc;
@ -1508,7 +1507,6 @@ bool SMESH_subMesh::ComputeStateEngine(compute_event event)
MESSAGE("Standard_OutOfMemory thrown inside algo->Compute()"); MESSAGE("Standard_OutOfMemory thrown inside algo->Compute()");
if ( _computeError ) { if ( _computeError ) {
_computeError->myName = COMPERR_MEMORY_PB; _computeError->myName = COMPERR_MEMORY_PB;
//_computeError->myComment = exc.what();
} }
cleanSubMesh( this ); cleanSubMesh( this );
throw std::bad_alloc(); throw std::bad_alloc();
@ -1549,7 +1547,7 @@ bool SMESH_subMesh::ComputeStateEngine(compute_event event)
ret = false; ret = false;
// check if anything was built // check if anything was built
TopExp_Explorer subS(shape, _subShape.ShapeType()); TopExp_Explorer subS(shape, _subShape.ShapeType());
if (ret) if ( ret )
{ {
for (; ret && subS.More(); subS.Next()) for (; ret && subS.More(); subS.Next())
if ( !_father->GetSubMesh( subS.Current() )->IsMeshComputed() && if ( !_father->GetSubMesh( subS.Current() )->IsMeshComputed() &&
@ -1558,9 +1556,9 @@ bool SMESH_subMesh::ComputeStateEngine(compute_event event)
ret = false; ret = false;
} }
// Set _computeError // Set _computeError
if (!ret && !isComputeErrorSet) if ( !ret && !isComputeErrorSet )
{ {
for (subS.ReInit(); subS.More(); subS.Next()) for ( subS.ReInit(); subS.More(); subS.Next() )
{ {
SMESH_subMesh* sm = _father->GetSubMesh( subS.Current() ); SMESH_subMesh* sm = _father->GetSubMesh( subS.Current() );
if ( !sm->IsMeshComputed() ) if ( !sm->IsMeshComputed() )
@ -1574,7 +1572,7 @@ bool SMESH_subMesh::ComputeStateEngine(compute_event event)
} }
} }
} }
if (ret && _computeError && _computeError->myName != COMPERR_WARNING ) if ( ret && _computeError && _computeError->myName != COMPERR_WARNING )
{ {
_computeError.reset(); _computeError.reset();
} }

View File

@ -742,23 +742,23 @@ void SMESHGUI_HypothesisDlg::setType( const QString& t )
myTypeLabel->setText( t ); myTypeLabel->setText( t );
} }
HypothesisData::HypothesisData( const QString& theTypeName, HypothesisData::HypothesisData( const QString& theTypeName,
const QString& thePluginName, const QString& thePluginName,
const QString& theServerLibName, const QString& theServerLibName,
const QString& theClientLibName, const QString& theClientLibName,
const QString& theLabel, const QString& theLabel,
const QString& theIconId, const QString& theIconId,
const QString& theContext, const QString& theContext,
const int theGroupID, const int theGroupID,
const int thePriority, const int thePriority,
const QList<int>& theDim, const QList<int>& theDim,
const bool theIsAuxOrNeedHyp, const bool theIsAuxOrNeedHyp,
const QStringList& theBasicHypos, const QStringList& theBasicHypos,
const QStringList& theOptionalHypos, const QStringList& theOptionalHypos,
const QStringList& theInputTypes, const QStringList& theInputTypes,
const QStringList& theOutputTypes, const QStringList& theOutputTypes,
const bool theIsNeedGeometry, const int theIsNeedGeometry,
const bool supportSub) const bool theSupportSub)
: TypeName( theTypeName ), : TypeName( theTypeName ),
PluginName( thePluginName ), PluginName( thePluginName ),
ServerLibName( theServerLibName ), ServerLibName( theServerLibName ),
@ -771,7 +771,7 @@ HypothesisData::HypothesisData( const QString& theTypeName,
Dim( theDim ), Dim( theDim ),
IsAuxOrNeedHyp( theIsAuxOrNeedHyp ), IsAuxOrNeedHyp( theIsAuxOrNeedHyp ),
IsNeedGeometry( theIsNeedGeometry ), IsNeedGeometry( theIsNeedGeometry ),
IsSupportSubmeshes( supportSub ), IsSupportSubmeshes( theSupportSub ),
BasicHypos( theBasicHypos ), BasicHypos( theBasicHypos ),
OptionalHypos( theOptionalHypos ), OptionalHypos( theOptionalHypos ),
InputTypes( theInputTypes ), InputTypes( theInputTypes ),

View File

@ -72,6 +72,9 @@ public:
QString getMainShapeEntry() const { return myMainShapeEntry; } QString getMainShapeEntry() const { return myMainShapeEntry; }
void setMainShapeEntry( const QString& theEntry ) { myMainShapeEntry = theEntry; } void setMainShapeEntry( const QString& theEntry ) { myMainShapeEntry = theEntry; }
void setNoGeomMesh( const bool noGeom ) { myNoGeomMesh = noGeom; }
bool getNoGeomMesh() const { return myNoGeomMesh; }
signals: signals:
void finished( int ); void finished( int );
@ -138,6 +141,7 @@ private:
ListOfWidgets myParamWidgets; ListOfWidgets myParamWidgets;
ListOfWidgets myParamLabels; ListOfWidgets myParamLabels;
bool myIsCreate; bool myIsCreate;
bool myNoGeomMesh; //!< true for a mesh not based on geometry
QtxDialog* myDlg; QtxDialog* myDlg;
QString myShapeEntry; QString myShapeEntry;
QString myMainShapeEntry; QString myMainShapeEntry;
@ -177,7 +181,7 @@ struct HypothesisData
const QList<int>&, const bool, const QList<int>&, const bool,
const QStringList&, const QStringList&, const QStringList&, const QStringList&,
const QStringList&, const QStringList&, const QStringList&, const QStringList&,
const bool=true, const bool supportSub=false ); const int, const bool supportSub );
QString TypeName; //!< hypothesis type name QString TypeName; //!< hypothesis type name
QString PluginName; //!< plugin name QString PluginName; //!< plugin name
@ -191,7 +195,9 @@ struct HypothesisData
QList<int> Dim; //!< list of supported dimensions (see SMESH::Dimension enumeration) QList<int> Dim; //!< list of supported dimensions (see SMESH::Dimension enumeration)
bool IsAuxOrNeedHyp; //!< TRUE if given HYPOTHESIS is auxiliary one, FALSE otherwise bool IsAuxOrNeedHyp; //!< TRUE if given HYPOTHESIS is auxiliary one, FALSE otherwise
//!< TRUE if given ALGORITHM can't work w/o hypotheses //!< TRUE if given ALGORITHM can't work w/o hypotheses
bool IsNeedGeometry; //!< TRUE if the algorithm works with shapes only, FALSE otherwise int IsNeedGeometry; //!< 1 if the algorithm works with shapes only,
//!< -1 if the algorithm works without shapes only,
//!< 0 if the algorithm works in both cases
bool IsSupportSubmeshes; //!< TRUE if the algorithm building all-dim elems supports sub-meshes bool IsSupportSubmeshes; //!< TRUE if the algorithm building all-dim elems supports sub-meshes
// for algorithm only: dependencies algo <-> algo and algo -> hypos // for algorithm only: dependencies algo <-> algo and algo -> hypos

View File

@ -282,14 +282,14 @@ namespace SMESH
QStringList GetAvailableHypotheses( const bool isAlgo, QStringList GetAvailableHypotheses( const bool isAlgo,
const int theDim, const int theDim,
const bool isAux, const bool isAux,
const bool isNeedGeometry, const bool hasGeometry,
const bool isSubMesh) const bool isSubMesh)
{ {
QStringList aHypList; QStringList aHypList;
// Init list of available hypotheses, if needed // Init list of available hypotheses, if needed
InitAvailableHypotheses(); InitAvailableHypotheses();
bool checkGeometry = ( !isNeedGeometry && isAlgo ); bool checkGeometry = ( isAlgo );
const char* context = isSubMesh ? "LOCAL" : "GLOBAL"; const char* context = isSubMesh ? "LOCAL" : "GLOBAL";
// fill list of hypotheses/algorithms // fill list of hypotheses/algorithms
THypothesisDataMap& pMap = isAlgo ? myAlgorithmsMap : myHypothesesMap; THypothesisDataMap& pMap = isAlgo ? myAlgorithmsMap : myHypothesesMap;
@ -301,7 +301,8 @@ namespace SMESH
( theDim < 0 || aData->Dim.contains( theDim )) && ( theDim < 0 || aData->Dim.contains( theDim )) &&
( isAlgo || aData->IsAuxOrNeedHyp == isAux ) && ( isAlgo || aData->IsAuxOrNeedHyp == isAux ) &&
( aData->Context == "ANY" || aData->Context == context ) && ( aData->Context == "ANY" || aData->Context == context ) &&
( !checkGeometry || aData->IsNeedGeometry == isNeedGeometry )) ( !checkGeometry || (!aData->IsNeedGeometry ||
( aData->IsNeedGeometry > 0 ) == hasGeometry)))
{ {
aHypList.append(anIter.key()); aHypList.append(anIter.key());
} }
@ -386,7 +387,7 @@ namespace SMESH
QList<int> dummyIL; dummyIL << 1; QList<int> dummyIL; dummyIL << 1;
QStringList dummySL; QStringList dummySL;
HypothesisData group( dummyS,dummyS,dummyS,dummyS,dummyS,dummyS,dummyS,-1,-1, HypothesisData group( dummyS,dummyS,dummyS,dummyS,dummyS,dummyS,dummyS,-1,-1,
dummyIL, 0, dummySL,dummySL,dummySL,dummySL ); dummyIL, 0, dummySL,dummySL,dummySL,dummySL,0,0 );
// no group // no group
int key = 0; int key = 0;
theGroups[ key ].push_back( group ); theGroups[ key ].push_back( group );

View File

@ -1192,12 +1192,9 @@ void SMESHGUI_MeshOp::initHypCreator( SMESHGUI_GenericHypothesisCreator* theCrea
// Set shapes, of mesh and sub-mesh if any // Set shapes, of mesh and sub-mesh if any
// get Entry of the Geom object // get Entry of the Geom object
QString aGeomEntry = ""; QString aGeomEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom );
QString aMeshEntry = ""; QString aMeshEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh );
QString anObjEntry = ""; QString anObjEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Obj );
aGeomEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom );
aMeshEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh );
anObjEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Obj );
if ( myToCreate && myIsMesh ) if ( myToCreate && myIsMesh )
aMeshEntry = aGeomEntry; aMeshEntry = aGeomEntry;
@ -1242,6 +1239,8 @@ void SMESHGUI_MeshOp::initHypCreator( SMESHGUI_GenericHypothesisCreator* theCrea
theCreator->setShapeEntry( aGeomEntry ); theCreator->setShapeEntry( aGeomEntry );
if ( aMeshEntry != "" ) if ( aMeshEntry != "" )
theCreator->setMainShapeEntry( aMeshEntry ); theCreator->setMainShapeEntry( aMeshEntry );
theCreator->setNoGeomMesh( !myIsOnGeometry && myIsMesh && !myToCreate );
} }
//================================================================================ //================================================================================
@ -1368,7 +1367,8 @@ void SMESHGUI_MeshOp::createHypothesis(const int theDim,
aCreator->create(initParamHyp, aHypName, myDlg, this, SLOT( onHypoCreated( int ) ) ); aCreator->create(initParamHyp, aHypName, myDlg, this, SLOT( onHypoCreated( int ) ) );
dialog = true; dialog = true;
} }
else { else
{
SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis_var aHyp =
SMESH::CreateHypothesis(theTypeName, aHypName, false); SMESH::CreateHypothesis(theTypeName, aHypName, false);
aHyp.out(); aHyp.out();

View File

@ -128,10 +128,11 @@ bool SMESHGUI_XmlHandler::startElement (const QString&, const QString&,
bool isAuxOrNeedHyp = ( qName == "hypothesis" ? bool isAuxOrNeedHyp = ( qName == "hypothesis" ?
atts.value("auxiliary") == "true" : atts.value("auxiliary") == "true" :
atts.value("need-hyp" ) == "true" ); atts.value("need-hyp" ) == "true" );
bool isNeedGeom = true, isSupportSubmeshes = false; int isNeedGeom = 1;
bool isSupportSubmeshes = false;
QString aNeedGeom = atts.value("need-geom"); QString aNeedGeom = atts.value("need-geom");
if ( !aNeedGeom.isEmpty() ) if ( !aNeedGeom.isEmpty() )
isNeedGeom = (aNeedGeom == "true"); isNeedGeom = (aNeedGeom == "true") ? 1 : (aNeedGeom == "never") ? -1 : 0;
QString suppSub = atts.value("support-submeshes"); QString suppSub = atts.value("support-submeshes");
if ( !suppSub.isEmpty() ) if ( !suppSub.isEmpty() )
isSupportSubmeshes = (suppSub == "true"); isSupportSubmeshes = (suppSub == "true");

View File

@ -162,6 +162,13 @@ namespace SMESH
return *this; return *this;
} }
TPythonDump&
TPythonDump::
operator<<(const std::string& theArg){
myStream<<theArg;
return *this;
}
TPythonDump& TPythonDump&
TPythonDump:: TPythonDump::
operator<<(const SMESH::ElementType& theArg) operator<<(const SMESH::ElementType& theArg)

View File

@ -876,10 +876,17 @@ CORBA::Boolean SMESH_Gen_i::GetSoleSubMeshUsingHyp( SMESH::SMESH_Hypothesis_ptr
{ {
if ( !foundMesh->_is_nil() ) // not a sole mesh if ( !foundMesh->_is_nil() ) // not a sole mesh
{ {
GEOM::GEOM_Object_var s1 = mesh_i ->GetShapeToMesh(); if ( !foundMesh->HasShapeToMesh() ||
GEOM::GEOM_Object_var s2 = foundMesh->GetShapeToMesh(); !mesh_i ->HasShapeToMesh() )
if ( ! ( isSole = s1->IsSame( s2 ))) {
break; isSole = ( foundMesh->HasShapeToMesh() == mesh_i->HasShapeToMesh() );
}
else
{
GEOM::GEOM_Object_var s1 = mesh_i ->GetShapeToMesh();
GEOM::GEOM_Object_var s2 = foundMesh->GetShapeToMesh();
isSole = s1->IsSame( s2 );
}
} }
foundMesh = SMESH::SMESH_Mesh::_narrow( obj ); foundMesh = SMESH::SMESH_Mesh::_narrow( obj );
} }

View File

@ -234,6 +234,9 @@ namespace SMESH
TPythonDump& TPythonDump&
operator<<(const SMESH::CoincidentFreeBorders& theCFB); operator<<(const SMESH::CoincidentFreeBorders& theCFB);
TPythonDump&
operator<<(const std::string& theArg);
static const char* SMESHGenName() { return "smeshgen"; } static const char* SMESHGenName() { return "smeshgen"; }
static const char* MeshEditorName() { return "mesh_editor"; } static const char* MeshEditorName() { return "mesh_editor"; }
static const char* NotPublishedObjectName(); static const char* NotPublishedObjectName();