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

@ -57,23 +57,19 @@ int SMDS_MeshElementIDFactory::SetInVtkGrid(SMDS_MeshElement * elem)
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;
} }
@ -126,7 +122,6 @@ void SMDS_MeshElementIDFactory::ReleaseID(int ID, int vtkId)
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());
@ -176,7 +171,6 @@ SMDS_ElemIteratorPtr SMDS_MeshElementIDFactory::elementsIterator() const
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);
@ -181,7 +172,6 @@ int SMDS_UnstructuredGrid::InsertNextLinkedCell(int type, int npts, vtkIdType *p
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;

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)
@ -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();
} }

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]);
@ -115,7 +89,6 @@ void SMDS_VtkVolume::initPoly(const std::vector<vtkIdType>& nodeIds,
// 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++)
@ -128,7 +101,6 @@ void SMDS_VtkVolume::initPoly(const std::vector<vtkIdType>& nodeIds,
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)
{ {
@ -548,7 +520,6 @@ bool SMDS_VtkVolume::IsMediumNode(const SMDS_MeshNode* node) const
return true; 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;
} }
@ -694,15 +660,13 @@ 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] double prodmixte = ((u[1]*v[2] - u[2]*v[1]) * w[0]
+ (u[2]*v[0] - u[0]*v[2]) * w[1] + (u[2]*v[0] - u[0]*v[2]) * w[1]
+ (u[0]*v[1] - u[1]*v[0]) * w[2]; + (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();

View File

@ -757,8 +757,8 @@ HypothesisData::HypothesisData( const QString& theTypeName,
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

@ -875,11 +875,18 @@ CORBA::Boolean SMESH_Gen_i::GetSoleSubMeshUsingHyp( SMESH::SMESH_Hypothesis_ptr
if ( isHypFound && !foundShape.IsNull() ) // a mesh using theHyp is found if ( isHypFound && !foundShape.IsNull() ) // a mesh using theHyp is found
{ {
if ( !foundMesh->_is_nil() ) // not a sole mesh if ( !foundMesh->_is_nil() ) // not a sole mesh
{
if ( !foundMesh->HasShapeToMesh() ||
!mesh_i ->HasShapeToMesh() )
{
isSole = ( foundMesh->HasShapeToMesh() == mesh_i->HasShapeToMesh() );
}
else
{ {
GEOM::GEOM_Object_var s1 = mesh_i ->GetShapeToMesh(); GEOM::GEOM_Object_var s1 = mesh_i ->GetShapeToMesh();
GEOM::GEOM_Object_var s2 = foundMesh->GetShapeToMesh(); GEOM::GEOM_Object_var s2 = foundMesh->GetShapeToMesh();
if ( ! ( isSole = s1->IsSame( s2 ))) isSole = s1->IsSame( s2 );
break; }
} }
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();