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".
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.
Default is "false".
void SMDS_BallElement::init(vtkIdType nodeId, double diameter, SMDS_Mesh* mesh)
{
SMDS_MeshCell::init();
- SMDS_UnstructuredGrid* grid = mesh->getGrid();
- myVtkID = grid->InsertNextLinkedCell( GetVtkType(), 1, &nodeId );
myMeshId = mesh->getMeshId();
- grid->SetBallDiameter( myVtkID, diameter );
+ myVtkID = mesh->getGrid()->InsertNextLinkedCell( GetVtkType(), 1, &nodeId );
+ mesh->getGrid()->SetBallDiameter( myVtkID, diameter );
mesh->setMyModified();
}
static std::vector<SMDS_Mesh*> _meshList;
//! actual nodes coordinates, cells definition and reverse connectivity are stored in a vtkUnstructuredGrid
- inline SMDS_UnstructuredGrid* getGrid() {return myGrid; }
- inline int getMeshId() {return myMeshId; }
+ inline SMDS_UnstructuredGrid* getGrid() { return myGrid; }
+ inline int getMeshId() { return myMeshId; }
virtual SMDS_NodeIteratorPtr nodesIterator (bool idInceasingOrder=false) const;
virtual SMDS_EdgeIteratorPtr edgesIterator (bool idInceasingOrder=false) const;
int SMDS_MeshElementIDFactory::SetInVtkGrid(SMDS_MeshElement * elem)
{
- // --- retrieve nodes ID
+ // --- retrieve nodes ID
SMDS_MeshCell *cell = dynamic_cast<SMDS_MeshCell*>(elem);
assert(cell);
- vector<vtkIdType> nodeIds;
+ vector<vtkIdType> nodeIds( elem->NbNodes() );
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();
- MESSAGE(" node in cell " << cell->getVtkId() << " : " << nodeId)
- nodeIds.push_back(nodeId);
+ int nodeId = (static_cast<const SMDS_MeshNode*>(it->next()))->getVtkId();
+ nodeIds[i] = nodeId;
}
// --- insert cell in vtkUnstructuredGrid
- vtkUnstructuredGrid * grid = myMesh->getGrid();
- //int locType = elem->GetType();
- int typ = VTK_VERTEX;//GetVtkCellType(locType);
- int cellId = grid->InsertNextLinkedCell(typ, nodeIds.size(), &nodeIds[0]);
- cell->setVtkId(cellId);
- //MESSAGE("SMDS_MeshElementIDFactory::SetInVtkGrid " << cellId);
+ int typ = VTK_VERTEX;
+ int cellId = myMesh->getGrid()->InsertNextLinkedCell(typ, nodeIds.size(), &nodeIds[0]);
+ cell->setVtkId(cellId);
return cellId;
}
//=======================================================================
//function : BindID
-//purpose :
+//purpose :
//=======================================================================
bool SMDS_MeshElementIDFactory::BindID(int ID, SMDS_MeshElement * elem)
void SMDS_MeshElementIDFactory::ReleaseID(int ID, int vtkId)
{
if (ID < 1) // TODO check case ID == O
- {
- MESSAGE("~~~~~~~~~~~~~~ SMDS_MeshElementIDFactory::ReleaseID ID = " << ID);
- return;
- }
- //MESSAGE("~~~~~~~~~~~~~~ SMDS_MeshElementIDFactory::ReleaseID smdsId vtkId " << ID << " " << vtkId);
+ {
+ MESSAGE("~~~~~~~~~~~~~~ SMDS_MeshElementIDFactory::ReleaseID ID = " << ID);
+ return;
+ }
if (vtkId >= 0)
- {
- assert(vtkId < (int)myMesh->myCellIdVtkToSmds.size());
- myMesh->myCellIdVtkToSmds[vtkId] = -1;
- myMesh->setMyModified();
- }
+ {
+ assert(vtkId < (int)myMesh->myCellIdVtkToSmds.size());
+ myMesh->myCellIdVtkToSmds[vtkId] = -1;
+ myMesh->setMyModified();
+ }
SMDS_MeshIDFactory::ReleaseID(ID);
if (ID == myMax)
myMax = 0;
//=======================================================================
//function : updateMinMax
-//purpose :
+//purpose :
//=======================================================================
void SMDS_MeshElementIDFactory::updateMinMax() const
myMin = INT_MAX;
myMax = 0;
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)
- myMax = id;
- if (id < myMin)
- myMin = id;
- }
+ int id = myMesh->myCells[i]->GetID();
+ if (id > myMax)
+ myMax = id;
+ if (id < myMin)
+ myMin = id;
}
+ }
if (myMin == INT_MAX)
myMin = 0;
}
SMDS_ElemIteratorPtr SMDS_MeshElementIDFactory::elementsIterator() const
{
- return myMesh->elementsIterator(SMDSAbs_All);
+ return myMesh->elementsIterator(SMDSAbs_All);
}
void SMDS_MeshElementIDFactory::Clear()
{
- //myMesh->myCellIdSmdsToVtk.clear();
myMesh->myCellIdVtkToSmds.clear();
myMin = myMax = 0;
SMDS_MeshIDFactory::Clear();
unsigned long mtime = vtkUnstructuredGrid::GetMTime();
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()
{
// TODO erreur incomprehensible de la macro vtk GetPoints apparue avec la version paraview de fin aout 2010
return this->Points;
}
-//#ifdef VTK_HAVE_POLYHEDRON
int SMDS_UnstructuredGrid::InsertNextLinkedCell(int type, int npts, vtkIdType *pts)
{
+ if ( !this->Links )
+ BuildLinks();
+
if (type != VTK_POLYHEDRON)
return vtkUnstructuredGrid::InsertNextLinkedCell(type, npts, pts);
int nbfaces = npts;
int i = 0;
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++;
- for (int k = 0; k < nbnodes; k++)
- {
- setOfNodes.insert(pts[i]);
- i++;
- }
}
+ }
set<vtkIdType>::iterator it = setOfNodes.begin();
for (; it != setOfNodes.end(); ++it)
- {
- this->Links->ResizeCellList(*it, 1);
- this->Links->AddCellReference(cellid, *it);
- }
+ {
+ this->Links->ResizeCellList(*it, 1);
+ this->Links->AddCellReference(cellid, *it);
+ }
return cellid;
}
-//#endif
void SMDS_UnstructuredGrid::setSMDS_mesh(SMDS_Mesh *mesh)
{
void SMDS_UnstructuredGrid::compactGrid(std::vector<int>& idNodesOldToNew, int newNodeSize,
std::vector<int>& idCellsOldToNew, int newCellSize)
{
- //MESSAGE("------------------------- compactGrid " << newNodeSize << " " << newCellSize);//CHRONO(1);
int alreadyCopied = 0;
this->DeleteLinks();
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 )
idCellsOldToNew[i] = i;
return;
void *source = this->Points->GetVoidPointer(3 * start);
int nbPoints = end - start;
if (nbPoints > 0)
- {
- memcpy(target, source, 3 * sizeof(double) * nbPoints);
- for (int j = start; j < end; j++)
- idNodesOldToNew[j] = alreadyCopied++; // old vtkId --> new vtkId
- }
+ {
+ memcpy(target, source, 3 * sizeof(double) * nbPoints);
+ for (int j = start; j < end; j++)
+ idNodesOldToNew[j] = alreadyCopied++; // old vtkId --> new vtkId
+ }
}
void SMDS_UnstructuredGrid::copyBloc(vtkUnsignedCharArray *newTypes,
int end)
{
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));
- 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++)
- {
- 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 oldval = oldPtsCell[l];
+ pointsCell[l] = idNodesOldToNew[oldval];
}
+ /*int newcnt = */newConnectivity->InsertNextCell(nbpts, pointsCell);
+ int newLoc = newConnectivity->GetInsertLocation(nbpts);
+ newLocations->SetValue(alreadyCopied, newLoc);
+ alreadyCopied++;
+ }
}
int SMDS_UnstructuredGrid::CellIdToDownId(int vtkCellId)
std::vector<int>& idCellsOldToNew,
int newCellSize);
virtual unsigned long GetMTime();
- // OUV_PORTING_VTK6: seems to be useless
- //virtual void Update();
- //virtual void UpdateInformation();
virtual vtkPoints *GetPoints();
- //#ifdef VTK_HAVE_POLYHEDRON
int InsertNextLinkedCell(int type, int npts, vtkIdType *pts);
- //#endif
int CellIdToDownId(int vtkCellId);
void setCellIdToDownId(int vtkCellId, int downId);
void SMDS_VtkEdge::init(std::vector<vtkIdType>& nodeIds, SMDS_Mesh* mesh)
{
SMDS_MeshEdge::init();
- vtkUnstructuredGrid* grid = mesh->getGrid();
myMeshId = mesh->getMeshId();
- vtkIdType aType = VTK_LINE;
- if (nodeIds.size() == 3)
- aType = VTK_QUADRATIC_EDGE;
- myVtkID = grid->InsertNextLinkedCell(aType, nodeIds.size(), &nodeIds[0]);
+ vtkIdType aType = ( nodeIds.size() == 3 ) ? VTK_QUADRATIC_EDGE : VTK_LINE;
+ myVtkID = mesh->getGrid()->InsertNextLinkedCell(aType, nodeIds.size(), &nodeIds[0]);
mesh->setMyModified();
- //MESSAGE("SMDS_VtkEdge::init myVtkID " << myVtkID);
}
bool SMDS_VtkEdge::ChangeNodes(const SMDS_MeshNode * node1, const SMDS_MeshNode * node2)
vtkIdType* pts = 0;
grid->GetCellPoints(myVtkID, npts, pts);
if (nbNodes != npts)
- {
- MESSAGE("ChangeNodes problem: not the same number of nodes " << npts << " -> " << nbNodes);
- return false;
- }
+ {
+ MESSAGE("ChangeNodes problem: not the same number of nodes " << npts << " -> " << nbNodes);
+ return false;
+ }
for (int i = 0; i < nbNodes; i++)
- {
- pts[i] = nodes[i]->getVtkId();
- }
+ {
+ pts[i] = nodes[i]->getVtkId();
+ }
SMDS_Mesh::_meshList[myMeshId]->setMyModified();
return true;
}
vtkIdType npts = 0;
vtkIdType* pts = 0;
grid->GetCellPoints(myVtkID, npts, pts);
- //MESSAGE("IsMediumNode " << npts << " " << (node->getVtkId() == pts[npts-1]));
return ((npts == 3) && (node->getVtkId() == pts[2]));
}
void SMDS_VtkFace::init(const std::vector<vtkIdType>& nodeIds, SMDS_Mesh* mesh)
{
SMDS_MeshFace::init();
- vtkUnstructuredGrid* grid = mesh->getGrid();
myMeshId = mesh->getMeshId();
vtkIdType aType = VTK_TRIANGLE;
switch (nodeIds.size())
{
- case 3:
- aType = VTK_TRIANGLE;
- break;
- case 4:
- aType = VTK_QUAD;
- break;
- case 6:
- 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;
+ case 3: aType = VTK_TRIANGLE; break;
+ case 4: aType = VTK_QUAD; break;
+ case 6: 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;
}
- myVtkID = grid->InsertNextLinkedCell(aType, nodeIds.size(), (vtkIdType*) &nodeIds[0]);
+ myVtkID = mesh->getGrid()->InsertNextLinkedCell(aType, nodeIds.size(), (vtkIdType*) &nodeIds[0]);
mesh->setMyModified();
- //MESSAGE("SMDS_VtkFace::init myVtkID " << myVtkID);
}
void SMDS_VtkFace::initPoly(const std::vector<vtkIdType>& nodeIds, SMDS_Mesh* mesh)
{
SMDS_MeshFace::init();
- vtkUnstructuredGrid* grid = mesh->getGrid();
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();
}
void SMDS_VtkFace::initQuadPoly(const std::vector<vtkIdType>& nodeIds, SMDS_Mesh* mesh)
{
SMDS_MeshFace::init();
- vtkUnstructuredGrid* grid = mesh->getGrid();
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();
}
vtkIdType* pts = 0;
grid->GetCellPoints(myVtkID, npts, pts);
if (nbNodes != npts)
- {
- MESSAGE("ChangeNodes problem: not the same number of nodes " << npts << " -> " << nbNodes);
- return false;
- }
+ {
+ MESSAGE("ChangeNodes problem: not the same number of nodes " << npts << " -> " << nbNodes);
+ return false;
+ }
for (int i = 0; i < nbNodes; i++)
- {
- pts[i] = nodes[i]->getVtkId();
- }
+ {
+ pts[i] = nodes[i]->getVtkId();
+ }
SMDS_Mesh::_meshList[myMeshId]->setMyModified();
return true;
}
void SMDS_VtkVolume::init(const std::vector<vtkIdType>& nodeIds, SMDS_Mesh* mesh)
{
SMDS_MeshVolume::init();
- vtkUnstructuredGrid* grid = mesh->getGrid();
myMeshId = mesh->getMeshId();
vtkIdType aType = VTK_TETRA;
switch (nodeIds.size()) // cases are in order of usage frequency
{
- case 4:
- aType = VTK_TETRA;
- break;
- case 8:
- aType = VTK_HEXAHEDRON;
- break;
- case 5:
- aType = VTK_PYRAMID;
- break;
- case 6:
- aType = VTK_WEDGE;
- 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;
+ case 4: aType = VTK_TETRA; break;
+ case 8: aType = VTK_HEXAHEDRON; break;
+ case 5: aType = VTK_PYRAMID; break;
+ case 6: aType = VTK_WEDGE; 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;
}
- myVtkID = grid->InsertNextLinkedCell(aType, nodeIds.size(), (vtkIdType *) &nodeIds[0]);
+ myVtkID = mesh->getGrid()->InsertNextLinkedCell(aType, nodeIds.size(), (vtkIdType *) &nodeIds[0]);
mesh->setMyModified();
- //MESSAGE("SMDS_VtkVolume::init myVtkID " << myVtkID);
}
-//#ifdef VTK_HAVE_POLYHEDRON
void SMDS_VtkVolume::initPoly(const std::vector<vtkIdType>& nodeIds,
const std::vector<int>& nbNodesPerFace,
SMDS_Mesh* mesh)
{
SMDS_MeshVolume::init();
- //MESSAGE("SMDS_VtkVolume::initPoly");
SMDS_UnstructuredGrid* grid = mesh->getGrid();
//double center[3];
//this->gravityCenter(grid, &nodeIds[0], nodeIds.size(), ¢er[0]);
vtkIdType nbFaces = nbNodesPerFace.size();
int k = 0;
for (int i = 0; i < nbFaces; i++)
- {
- int nf = nbNodesPerFace[i];
- ptIds.push_back(nf);
- // EAP: a right approach is:
- // - either the user should care of order of nodes or
- // - the user should use a service method arranging nodes if he
- // don't want or can't to do it by him-self
- // The method below works OK only with planar faces and convex polyhedrones
- //
- // double a[3];
- // double b[3];
- // double c[3];
- // grid->GetPoints()->GetPoint(nodeIds[k], a);
- // grid->GetPoints()->GetPoint(nodeIds[k + 1], b);
- // grid->GetPoints()->GetPoint(nodeIds[k + 2], c);
- // bool isFaceForward = this->isForward(a, b, c, center);
- //MESSAGE("isFaceForward " << i << " " << isFaceForward);
- const vtkIdType *facePts = &nodeIds[k];
- //if (isFaceForward)
- for (int n = 0; n < nf; n++)
- ptIds.push_back(facePts[n]);
- // else
- // for (int n = nf - 1; n >= 0; n--)
- // ptIds.push_back(facePts[n]);
- k += nf;
- }
+ {
+ int nf = nbNodesPerFace[i];
+ ptIds.push_back(nf);
+ // EAP: a right approach is:
+ // - either the user should care of order of nodes or
+ // - the user should use a service method arranging nodes if he
+ // don't want or can't to do it by him-self
+ // The method below works OK only with planar faces and convex polyhedrones
+ //
+ // double a[3];
+ // double b[3];
+ // double c[3];
+ // grid->GetPoints()->GetPoint(nodeIds[k], a);
+ // grid->GetPoints()->GetPoint(nodeIds[k + 1], b);
+ // grid->GetPoints()->GetPoint(nodeIds[k + 2], c);
+ // bool isFaceForward = this->isForward(a, b, c, center);
+ const vtkIdType *facePts = &nodeIds[k];
+ //if (isFaceForward)
+ for (int n = 0; n < nf; n++)
+ ptIds.push_back(facePts[n]);
+ // else
+ // for (int n = nf - 1; n >= 0; n--)
+ // ptIds.push_back(facePts[n]);
+ k += nf;
+ }
myVtkID = grid->InsertNextLinkedCell(VTK_POLYHEDRON, nbFaces, &ptIds[0]);
mesh->setMyModified();
}
-//#endif
bool SMDS_VtkVolume::ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes)
{
vtkIdType* pts = 0;
grid->GetCellPoints(myVtkID, npts, pts);
if (nbNodes != npts)
- {
- MESSAGE("ChangeNodes problem: not the same number of nodes " << npts << " -> " << nbNodes);
- return false;
- }
+ {
+ MESSAGE("ChangeNodes problem: not the same number of nodes " << npts << " -> " << nbNodes);
+ return false;
+ }
for (int i = 0; i < nbNodes; i++)
- {
- pts[i] = nodes[i]->getVtkId();
- }
+ {
+ pts[i] = nodes[i]->getVtkId();
+ }
SMDS_Mesh::_meshList[myMeshId]->setMyModified();
return true;
}
bool SMDS_VtkVolume::vtkOrder(const SMDS_MeshNode* nodes[], const int nbNodes)
{
if (nbNodes != this->NbNodes())
- {
- MESSAGE("vtkOrder, wrong number of nodes " << nbNodes << " instead of "<< this->NbNodes());
- return false;
- }
+ {
+ MESSAGE("vtkOrder, wrong number of nodes " << nbNodes << " instead of "<< this->NbNodes());
+ return false;
+ }
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
vtkIdType aVtkType = grid->GetCellType(this->myVtkID);
const std::vector<int>& interlace = SMDS_MeshCell::toVtkOrder( VTKCellType( aVtkType ));
vtkIdType aVtkType = grid->GetCellType(this->myVtkID);
vtkIdType nbPoints = 0;
if (aVtkType != VTK_POLYHEDRON)
- {
- vtkIdType *pts;
- grid->GetCellPoints( myVtkID, nbPoints, pts );
- }
+ {
+ vtkIdType *pts;
+ grid->GetCellPoints( myVtkID, nbPoints, pts );
+ }
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;
- vtkIdType* ptIds = 0;
- grid->GetFaceStream(this->myVtkID, nFaces, ptIds);
- int id = 0;
- for (int i = 0; i < nFaces; i++)
- {
- int nodesInFace = ptIds[id];
- nbPoints += nodesInFace;
- id += (nodesInFace + 1);
- }
+ int nodesInFace = ptIds[id];
+ nbPoints += nodesInFace;
+ id += (nodesInFace + 1);
}
+ }
return nbPoints;
}
vtkIdType aVtkType = grid->GetCellType(this->myVtkID);
int nbNodes = 0;
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;
- vtkIdType* ptIds = 0;
- grid->GetFaceStream(this->myVtkID, nFaces, ptIds);
- int id = 0;
- for (int i = 0; i < nFaces; i++)
- {
- int nodesInFace = ptIds[id];
- id += (nodesInFace + 1);
- if (i == face_ind - 1)
- {
- nbNodes = nodesInFace;
- break;
- }
- }
+ int nodesInFace = ptIds[id];
+ id += (nodesInFace + 1);
+ if (i == face_ind - 1)
+ {
+ nbNodes = nodesInFace;
+ break;
+ }
}
+ }
return nbNodes;
}
vtkIdType aVtkType = grid->GetCellType(this->myVtkID);
const SMDS_MeshNode* node = 0;
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;
- vtkIdType* ptIds = 0;
- grid->GetFaceStream(this->myVtkID, nFaces, ptIds);
- int id = 0;
- for (int i = 0; i < nFaces; i++)
- {
- int nodesInFace = ptIds[id]; // nodeIds in ptIds[id+1 .. id+nodesInFace]
- if (i == face_ind - 1) // first face is number 1
- {
- if ((node_ind > 0) && (node_ind <= nodesInFace))
- node = mesh->FindNodeVtk(ptIds[id + node_ind]); // ptIds[id+1] : first node
- break;
- }
- id += (nodesInFace + 1);
- }
+ int nodesInFace = ptIds[id]; // nodeIds in ptIds[id+1 .. id+nodesInFace]
+ if (i == face_ind - 1) // first face is number 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;
}
vtkUnstructuredGrid* grid = mesh->getGrid();
vtkIdType aVtkType = grid->GetCellType(this->myVtkID);
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;
- vtkIdType* ptIds = 0;
- grid->GetFaceStream(this->myVtkID, nFaces, ptIds);
- 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);
- }
+ int nodesInFace = ptIds[id]; // nodeIds in ptIds[id+1 .. id+nodesInFace]
+ quantities.push_back(nodesInFace);
+ id += (nodesInFace + 1);
}
+ }
return quantities;
}
grid->GetCellPoints(myVtkID, npts, pts);
vtkIdType nodeId = node->getVtkId();
for (int rank = 0; rank < npts; rank++)
+ {
+ if (pts[rank] == nodeId)
{
- if (pts[rank] == nodeId)
- {
- if (rank < rankFirstMedium)
- return false;
- else
- return true;
- }
+ if (rank < rankFirstMedium)
+ return false;
+ else
+ return true;
}
- //throw SALOME_Exception(LOCALIZED("node does not belong to this element"));
+ }
MESSAGE("======================================================");
MESSAGE("= IsMediumNode: node does not belong to this element =");
MESSAGE("======================================================");
case VTK_HEXAGONAL_PRISM:
aType = SMDSEntity_Hexagonal_Prism;
break;
-//#ifdef VTK_HAVE_POLYHEDRON
case VTK_POLYHEDRON:
aType = SMDSEntity_Polyhedra;
break;
-//#endif
default:
aType = SMDSEntity_Polyhedra;
break;
case VTK_HEXAGONAL_PRISM:
aType = SMDSGeom_HEXAGONAL_PRISM;
break;
-//#ifdef VTK_HAVE_POLYHEDRON
case VTK_POLYHEDRON:
aType = SMDSGeom_POLYHEDRA;
break;
-//#endif
default:
aType = SMDSGeom_POLYHEDRA;
break;
}
for (int j = 0; j < 3; j++)
result[j] = result[j] / nbNodes;
- //MESSAGE("center " << result[0] << " " << result[1] << " " << result[2]);
return;
}
{
double u[3], v[3], w[3];
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];
- v[j] = c[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]
- + (u[0]*v[1] - u[1]*v[0]) * w[2];
+ {
+ u[j] = b[j] - a[j];
+ v[j] = c[j] - a[j];
+ w[j] = d[j] - a[j];
+ }
+ double prodmixte = ((u[1]*v[2] - u[2]*v[1]) * w[0]
+ + (u[2]*v[0] - u[0]*v[2]) * w[1]
+ + (u[0]*v[1] - u[1]*v[0]) * w[2] );
return (prodmixte < 0);
}
*/
SMDS_ElemIteratorPtr SMDS_VtkVolume::uniqueNodesIterator() const
{
- //MESSAGE("uniqueNodesIterator");
return SMDS_ElemIteratorPtr(new SMDS_VtkCellIterator(SMDS_Mesh::_meshList[myMeshId], myVtkID, GetEntityType()));
}
MESSAGE("std::bad_alloc thrown inside algo->Compute()");
if ( _computeError ) {
_computeError->myName = COMPERR_MEMORY_PB;
- //_computeError->myComment = exc.what();
}
cleanSubMesh( this );
throw exc;
MESSAGE("Standard_OutOfMemory thrown inside algo->Compute()");
if ( _computeError ) {
_computeError->myName = COMPERR_MEMORY_PB;
- //_computeError->myComment = exc.what();
}
cleanSubMesh( this );
throw std::bad_alloc();
ret = false;
// check if anything was built
TopExp_Explorer subS(shape, _subShape.ShapeType());
- if (ret)
+ if ( ret )
{
for (; ret && subS.More(); subS.Next())
if ( !_father->GetSubMesh( subS.Current() )->IsMeshComputed() &&
ret = false;
}
// 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() );
if ( !sm->IsMeshComputed() )
}
}
}
- if (ret && _computeError && _computeError->myName != COMPERR_WARNING )
+ if ( ret && _computeError && _computeError->myName != COMPERR_WARNING )
{
_computeError.reset();
}
myTypeLabel->setText( t );
}
-HypothesisData::HypothesisData( const QString& theTypeName,
- const QString& thePluginName,
- const QString& theServerLibName,
- const QString& theClientLibName,
- const QString& theLabel,
- const QString& theIconId,
- const QString& theContext,
- const int theGroupID,
- const int thePriority,
- const QList<int>& theDim,
- const bool theIsAuxOrNeedHyp,
+HypothesisData::HypothesisData( const QString& theTypeName,
+ const QString& thePluginName,
+ const QString& theServerLibName,
+ const QString& theClientLibName,
+ const QString& theLabel,
+ const QString& theIconId,
+ const QString& theContext,
+ const int theGroupID,
+ const int thePriority,
+ const QList<int>& theDim,
+ const bool theIsAuxOrNeedHyp,
const QStringList& theBasicHypos,
const QStringList& theOptionalHypos,
const QStringList& theInputTypes,
const QStringList& theOutputTypes,
- const bool theIsNeedGeometry,
- const bool supportSub)
+ const int theIsNeedGeometry,
+ const bool theSupportSub)
: TypeName( theTypeName ),
PluginName( thePluginName ),
ServerLibName( theServerLibName ),
Dim( theDim ),
IsAuxOrNeedHyp( theIsAuxOrNeedHyp ),
IsNeedGeometry( theIsNeedGeometry ),
- IsSupportSubmeshes( supportSub ),
+ IsSupportSubmeshes( theSupportSub ),
BasicHypos( theBasicHypos ),
OptionalHypos( theOptionalHypos ),
InputTypes( theInputTypes ),
QString getMainShapeEntry() const { return myMainShapeEntry; }
void setMainShapeEntry( const QString& theEntry ) { myMainShapeEntry = theEntry; }
+ void setNoGeomMesh( const bool noGeom ) { myNoGeomMesh = noGeom; }
+ bool getNoGeomMesh() const { return myNoGeomMesh; }
+
signals:
void finished( int );
ListOfWidgets myParamWidgets;
ListOfWidgets myParamLabels;
bool myIsCreate;
+ bool myNoGeomMesh; //!< true for a mesh not based on geometry
QtxDialog* myDlg;
QString myShapeEntry;
QString myMainShapeEntry;
const QList<int>&, const bool,
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 PluginName; //!< plugin name
QList<int> Dim; //!< list of supported dimensions (see SMESH::Dimension enumeration)
bool IsAuxOrNeedHyp; //!< TRUE if given HYPOTHESIS is auxiliary one, FALSE otherwise
//!< 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
// for algorithm only: dependencies algo <-> algo and algo -> hypos
QStringList GetAvailableHypotheses( const bool isAlgo,
const int theDim,
const bool isAux,
- const bool isNeedGeometry,
+ const bool hasGeometry,
const bool isSubMesh)
{
QStringList aHypList;
// Init list of available hypotheses, if needed
InitAvailableHypotheses();
- bool checkGeometry = ( !isNeedGeometry && isAlgo );
+ bool checkGeometry = ( isAlgo );
const char* context = isSubMesh ? "LOCAL" : "GLOBAL";
// fill list of hypotheses/algorithms
THypothesisDataMap& pMap = isAlgo ? myAlgorithmsMap : myHypothesesMap;
( theDim < 0 || aData->Dim.contains( theDim )) &&
( isAlgo || aData->IsAuxOrNeedHyp == isAux ) &&
( aData->Context == "ANY" || aData->Context == context ) &&
- ( !checkGeometry || aData->IsNeedGeometry == isNeedGeometry ))
+ ( !checkGeometry || (!aData->IsNeedGeometry ||
+ ( aData->IsNeedGeometry > 0 ) == hasGeometry)))
{
aHypList.append(anIter.key());
}
QList<int> dummyIL; dummyIL << 1;
QStringList dummySL;
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
int key = 0;
theGroups[ key ].push_back( group );
// Set shapes, of mesh and sub-mesh if any
// get Entry of the Geom object
- QString aGeomEntry = "";
- QString aMeshEntry = "";
- QString anObjEntry = "";
- aGeomEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom );
- aMeshEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh );
- anObjEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Obj );
+ QString aGeomEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom );
+ QString aMeshEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh );
+ QString anObjEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Obj );
if ( myToCreate && myIsMesh )
aMeshEntry = aGeomEntry;
theCreator->setShapeEntry( aGeomEntry );
if ( aMeshEntry != "" )
theCreator->setMainShapeEntry( aMeshEntry );
+
+ theCreator->setNoGeomMesh( !myIsOnGeometry && myIsMesh && !myToCreate );
}
//================================================================================
aCreator->create(initParamHyp, aHypName, myDlg, this, SLOT( onHypoCreated( int ) ) );
dialog = true;
}
- else {
+ else
+ {
SMESH::SMESH_Hypothesis_var aHyp =
SMESH::CreateHypothesis(theTypeName, aHypName, false);
aHyp.out();
bool isAuxOrNeedHyp = ( qName == "hypothesis" ?
atts.value("auxiliary") == "true" :
atts.value("need-hyp" ) == "true" );
- bool isNeedGeom = true, isSupportSubmeshes = false;
+ int isNeedGeom = 1;
+ bool isSupportSubmeshes = false;
QString aNeedGeom = atts.value("need-geom");
if ( !aNeedGeom.isEmpty() )
- isNeedGeom = (aNeedGeom == "true");
+ isNeedGeom = (aNeedGeom == "true") ? 1 : (aNeedGeom == "never") ? -1 : 0;
QString suppSub = atts.value("support-submeshes");
if ( !suppSub.isEmpty() )
isSupportSubmeshes = (suppSub == "true");
return *this;
}
+ TPythonDump&
+ TPythonDump::
+ operator<<(const std::string& theArg){
+ myStream<<theArg;
+ return *this;
+ }
+
TPythonDump&
TPythonDump::
operator<<(const SMESH::ElementType& theArg)
{
if ( !foundMesh->_is_nil() ) // not a sole mesh
{
- GEOM::GEOM_Object_var s1 = mesh_i ->GetShapeToMesh();
- GEOM::GEOM_Object_var s2 = foundMesh->GetShapeToMesh();
- if ( ! ( isSole = s1->IsSame( s2 )))
- break;
+ 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 s2 = foundMesh->GetShapeToMesh();
+ isSole = s1->IsSame( s2 );
+ }
}
foundMesh = SMESH::SMESH_Mesh::_narrow( obj );
}
TPythonDump&
operator<<(const SMESH::CoincidentFreeBorders& theCFB);
+ TPythonDump&
+ operator<<(const std::string& theArg);
+
static const char* SMESHGenName() { return "smeshgen"; }
static const char* MeshEditorName() { return "mesh_editor"; }
static const char* NotPublishedObjectName();