-// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
if ( !e1 || !e2 || !e3 ) return 0;
if ( NbFaces() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory();
- MESSAGE("AddFaceWithID" << ID);
SMDS_MeshFace * face = new SMDS_FaceOfEdges(e1,e2,e3);
adjustmyCellsCapacity(ID);
{
if (!hasConstructionEdges())
return NULL;
- //MESSAGE("AddFaceWithID" );
return AddFaceWithID(e1,e2,e3,e4, myElementIDFactory->GetFreeID());
}
{
if (!hasConstructionEdges())
return NULL;
- MESSAGE("AddFaceWithID" << ID);
if ( !e1 || !e2 || !e3 || !e4 ) return 0;
if ( NbFaces() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory();
SMDS_MeshFace * face = new SMDS_FaceOfEdges(e1,e2,e3,e4);
const SMDS_MeshNode * n4)
{
int ID = myElementIDFactory->GetFreeID();
- //MESSAGE("AddVolumeWithID " << ID);
SMDS_MeshVolume * v = SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, ID);
if(v==NULL) myElementIDFactory->ReleaseID(ID);
return v;
int idnode4,
int ID)
{
- //MESSAGE("AddVolumeWithID" << ID);
SMDS_MeshNode *node1, *node2, *node3, *node4;
node1 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode1);
node2 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode2);
const SMDS_MeshNode * n4,
int ID)
{
- //MESSAGE("AddVolumeWithID " << ID);
SMDS_MeshVolume* volume = 0;
if ( !n1 || !n2 || !n3 || !n4) return volume;
if ( NbVolumes() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory();
myInfo.myNbTetras++;
}
else if(hasConstructionEdges()) {
- MESSAGE("Error : Not implemented");
return NULL;
}
else {
const SMDS_MeshNode * n5)
{
int ID = myElementIDFactory->GetFreeID();
- //MESSAGE("AddVolumeWithID " << ID);
SMDS_MeshVolume * v = SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, n5, ID);
if(v==NULL) myElementIDFactory->ReleaseID(ID);
return v;
int idnode5,
int ID)
{
- //MESSAGE("AddVolumeWithID " << ID);
SMDS_MeshNode *node1, *node2, *node3, *node4, *node5;
node1 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode1);
node2 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode2);
const SMDS_MeshNode * n5,
int ID)
{
- //MESSAGE("AddVolumeWithID " << ID);
SMDS_MeshVolume* volume = 0;
if ( !n1 || !n2 || !n3 || !n4 || !n5) return volume;
if ( NbVolumes() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory();
myInfo.myNbPyramids++;
}
else if(hasConstructionEdges()) {
- MESSAGE("Error : Not implemented");
return NULL;
}
else {
const SMDS_MeshNode * n6)
{
int ID = myElementIDFactory->GetFreeID();
- //MESSAGE("AddVolumeWithID " << ID);
SMDS_MeshVolume * v = SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, n5, n6, ID);
if(v==NULL) myElementIDFactory->ReleaseID(ID);
return v;
int idnode6,
int ID)
{
- //MESSAGE("AddVolumeWithID " << ID);
SMDS_MeshNode *node1, *node2, *node3, *node4, *node5, *node6;
node1 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode1);
node2 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode2);
const SMDS_MeshNode * n6,
int ID)
{
- //MESSAGE("AddVolumeWithID " << ID);
SMDS_MeshVolume* volume = 0;
if ( !n1 || !n2 || !n3 || !n4 || !n5 || !n6) return volume;
if ( NbVolumes() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory();
myInfo.myNbPrisms++;
}
else if(hasConstructionEdges()) {
- MESSAGE("Error : Not implemented");
return NULL;
}
else {
return volume;
if ( NbVolumes() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory();
if(hasConstructionFaces()) {
- MESSAGE("Error : Not implemented");
return NULL;
}
else if(hasConstructionEdges()) {
- MESSAGE("Error : Not implemented");
return NULL;
}
else {
int idnode8,
int ID)
{
- //MESSAGE("AddVolumeWithID " << ID);
SMDS_MeshNode *node1, *node2, *node3, *node4, *node5, *node6, *node7, *node8;
node1 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode1);
node2 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(idnode2);
const SMDS_MeshNode * n8,
int ID)
{
- //MESSAGE("AddVolumeWithID " << ID);
SMDS_MeshVolume* volume = 0;
if ( !n1 || !n2 || !n3 || !n4 || !n5 || !n6 || !n7 || !n8) return volume;
if ( NbVolumes() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory();
myInfo.myNbHexas++;
}
else if(hasConstructionEdges()) {
- MESSAGE("Error : Not implemented");
return NULL;
}
else {
const SMDS_MeshFace * f3,
const SMDS_MeshFace * f4)
{
- //MESSAGE("AddVolumeWithID");
if (!hasConstructionFaces())
return NULL;
return AddVolumeWithID(f1,f2,f3,f4, myElementIDFactory->GetFreeID());
const SMDS_MeshFace * f4,
int ID)
{
- MESSAGE("AddVolumeWithID" << ID);
if (!hasConstructionFaces())
return NULL;
if ( !f1 || !f2 || !f3 || !f4) return 0;
const SMDS_MeshFace * f4,
const SMDS_MeshFace * f5)
{
- //MESSAGE("AddVolumeWithID");
if (!hasConstructionFaces())
return NULL;
return AddVolumeWithID(f1,f2,f3,f4,f5, myElementIDFactory->GetFreeID());
const SMDS_MeshFace * f5,
int ID)
{
- MESSAGE("AddVolumeWithID" << ID);
if (!hasConstructionFaces())
return NULL;
if ( !f1 || !f2 || !f3 || !f4 || !f5) return 0;
const SMDS_MeshFace * f5,
const SMDS_MeshFace * f6)
{
- //MESSAGE("AddVolumeWithID" );
if (!hasConstructionFaces())
return NULL;
return AddVolumeWithID(f1,f2,f3,f4,f5,f6, myElementIDFactory->GetFreeID());
const SMDS_MeshFace * f6,
int ID)
{
- MESSAGE("AddVolumeWithID" << ID);
if (!hasConstructionFaces())
return NULL;
if ( !f1 || !f2 || !f3 || !f4 || !f5 || !f6) return 0;
if ( NbFaces() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory();
if (hasConstructionEdges())
{
- MESSAGE("Error : Not implemented");
return NULL;
}
else
if ( NbFaces() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory();
if (hasConstructionEdges())
{
- MESSAGE("Error : Not implemented");
return NULL;
}
else
if ( NbVolumes() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory();
if (hasConstructionFaces())
{
- MESSAGE("Error : Not implemented");
return NULL;
}
else if (hasConstructionEdges())
{
- MESSAGE("Error : Not implemented");
return NULL;
}
else
{
//#ifdef VTK_HAVE_POLYHEDRON
- //MESSAGE("AddPolyhedralVolumeWithID vtk " << ID);
myNodeIds.resize( nodes.size() );
for ( size_t i = 0; i < nodes.size(); ++i )
myNodeIds[i] = nodes[i]->getVtkId();
}
volume = volvtk;
//#else
- // MESSAGE("AddPolyhedralVolumeWithID smds " << ID);
// for ( int i = 0; i < nodes.size(); ++i )
// if ( !nodes[ i ] ) return 0;
// volume = new SMDS_PolyhedralVolumeOfNodes(nodes, quantities);
///////////////////////////////////////////////////////////////////////////////
bool SMDS_Mesh::registerElement(int ID, SMDS_MeshElement* element)
{
- //MESSAGE("registerElement " << ID);
if ((ID >=0) && (ID < (int)myCells.size()) && myCells[ID]) // --- already bound
{
MESSAGE(" ------------------ already bound "<< ID << " " << myCells[ID]->getVtkId());
if (vtkId >= (int)myCellIdVtkToSmds.size()) // --- resize local vector
{
-// MESSAGE(" --------------------- resize myCellIdVtkToSmds " << vtkId << " --> " << vtkId + SMDS_Mesh::chunkSize);
myCellIdVtkToSmds.resize(vtkId + SMDS_Mesh::chunkSize, -1);
}
myCellIdVtkToSmds[vtkId] = ID;
{
if (ID < 1 || ID >= (int)myNodes.size())
{
-// MESSAGE("------------------------------------------------------------------------- ");
-// MESSAGE("----------------------------------- bad ID " << ID << " " << myNodes.size());
-// MESSAGE("------------------------------------------------------------------------- ");
return 0;
}
return (const SMDS_MeshNode *)myNodes[ID];
face = facevtk;
adjustmyCellsCapacity(ID);
myCells[ID] = face;
- //MESSAGE("createTriangle " << ID << " " << face);
myInfo.myNbTriangles++;
return face;
}
if ( NbFaces() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory();
if(hasConstructionEdges())
{
- //MESSAGE("createQuadrangle hasConstructionEdges "<< ID);
SMDS_MeshEdge *edge1, *edge2, *edge3, *edge4;
edge1=FindEdgeOrCreate(node1,node2);
edge2=FindEdgeOrCreate(node2,node3);
void SMDS_Mesh::RemoveNode(const SMDS_MeshNode * node)
{
- MESSAGE("RemoveNode");
RemoveElement(node, true);
}
void SMDS_Mesh::Remove0DElement(const SMDS_Mesh0DElement * elem0d)
{
- MESSAGE("Remove0DElement");
RemoveElement(elem0d,true);
}
void SMDS_Mesh::RemoveEdge(const SMDS_MeshEdge * edge)
{
- MESSAGE("RemoveEdge");
RemoveElement(edge,true);
}
void SMDS_Mesh::RemoveFace(const SMDS_MeshFace * face)
{
- MESSAGE("RemoveFace");
RemoveElement(face, true);
}
void SMDS_Mesh::RemoveVolume(const SMDS_MeshVolume * volume)
{
- MESSAGE("RemoveVolume");
RemoveElement(volume, true);
}
const SMDS_MeshNode * nodes[],
const int nbnodes)
{
- MESSAGE("SMDS_Mesh::ChangeElementNodes");
// keep current nodes of elem
set<const SMDS_MeshNode*> oldNodes( element->begin_nodes(), element->end_nodes() );
{
if ( IDelem <= 0 || IDelem >= (int)myCells.size() )
{
- MESSAGE("--------------------------------------------------------------------------------- ");
- MESSAGE("----------------------------------- bad IDelem " << IDelem << " " << myCells.size());
- MESSAGE("--------------------------------------------------------------------------------- ");
- // TODO raise an exception
- //assert(0);
return 0;
}
return myCells[IDelem];
void SMDS_Mesh::DumpNodes() const
{
- MESSAGE("dump nodes of mesh : ");
- SMDS_NodeIteratorPtr itnode=nodesIterator();
- while(itnode->more()) ; //MESSAGE(itnode->next());
+ SMDS_NodeIteratorPtr itnode=nodesIterator();
+ while(itnode->more()) ; //MESSAGE(itnode->next());
}
//=======================================================================
//=======================================================================
void SMDS_Mesh::Dump0DElements() const
{
- MESSAGE("dump 0D elements of mesh : ");
SMDS_ElemIteratorPtr it0d = elementsIterator(SMDSAbs_0DElement);
while(it0d->more()) ; //MESSAGE(it0d->next());
}
void SMDS_Mesh::DumpEdges() const
{
- MESSAGE("dump edges of mesh : ");
- SMDS_EdgeIteratorPtr itedge=edgesIterator();
- while(itedge->more()) ; //MESSAGE(itedge->next());
+ SMDS_EdgeIteratorPtr itedge=edgesIterator();
+ while(itedge->more()) ; //MESSAGE(itedge->next());
}
//=======================================================================
void SMDS_Mesh::DumpFaces() const
{
- MESSAGE("dump faces of mesh : ");
- SMDS_FaceIteratorPtr itface=facesIterator();
- while(itface->more()) ; //MESSAGE(itface->next());
+ SMDS_FaceIteratorPtr itface=facesIterator();
+ while(itface->more()) ; //MESSAGE(itface->next());
}
//=======================================================================
void SMDS_Mesh::DumpVolumes() const
{
- MESSAGE("dump volumes of mesh : ");
- SMDS_VolumeIteratorPtr itvol=volumesIterator();
- while(itvol->more()) ; //MESSAGE(itvol->next());
+ SMDS_VolumeIteratorPtr itvol=volumesIterator();
+ while(itvol->more()) ; //MESSAGE(itvol->next());
}
//=======================================================================
///////////////////////////////////////////////////////////////////////////////
int SMDS_Mesh::NbNodes() const
{
- //MESSAGE(myGrid->GetNumberOfPoints());
- //MESSAGE(myInfo.NbNodes());
- //MESSAGE(myNodeMax);
- return myInfo.NbNodes();
+ return myInfo.NbNodes();
}
///////////////////////////////////////////////////////////////////////////////
void SMDS_Mesh::Clear()
{
- MESSAGE("SMDS_Mesh::Clear");
if (myParent!=NULL)
{
SMDS_ElemIteratorPtr eIt = elementsIterator();
///////////////////////////////////////////////////////////////////////////////
static set<const SMDS_MeshElement*> * getFinitElements(const SMDS_MeshElement * element)
{
- int numberOfSets=element->NbNodes();
- set<const SMDS_MeshElement*> *initSet = new set<const SMDS_MeshElement*>[numberOfSets];
+ int numberOfSets=element->NbNodes();
+ set<const SMDS_MeshElement*> *initSet = new set<const SMDS_MeshElement*>[numberOfSets];
- SMDS_ElemIteratorPtr itNodes=element->nodesIterator();
-
- int i=0;
- while(itNodes->more())
- {
- const SMDS_MeshElement* node = itNodes->next();
- MYASSERT(node);
- const SMDS_MeshNode * n=static_cast<const SMDS_MeshNode*>(node);
- SMDS_ElemIteratorPtr itFe = n->GetInverseElementIterator();
+ SMDS_ElemIteratorPtr itNodes=element->nodesIterator();
- //initSet[i]=set<const SMDS_MeshElement*>();
- while(itFe->more())
- {
- const SMDS_MeshElement* elem = itFe->next();
- MYASSERT(elem);
- initSet[i].insert(elem);
+ int i = 0;
+ while ( itNodes->more() )
+ {
+ const SMDS_MeshElement* node = itNodes->next();
+ MYASSERT(node);
+ const SMDS_MeshNode * n=static_cast<const SMDS_MeshNode*>(node);
+ SMDS_ElemIteratorPtr itFe = n->GetInverseElementIterator();
- }
+ while ( itFe->more() )
+ {
+ const SMDS_MeshElement* elem = itFe->next();
+ MYASSERT(elem);
+ initSet[i].insert(elem);
+ }
- i++;
- }
- set<const SMDS_MeshElement*> *retSet=intersectionOfSets(initSet, numberOfSets);
-// MESSAGE("nb elems " << i << " intersection " << retSet->size());
- delete [] initSet;
- return retSet;
+ i++;
+ }
+ set<const SMDS_MeshElement*> *retSet = intersectionOfSets( initSet, numberOfSets );
+ delete [] initSet;
+ return retSet;
}
///////////////////////////////////////////////////////////////////////////////
{
int elemId = elem->GetID();
int vtkId = elem->getVtkId();
- //MESSAGE("RemoveFreeElement " << elemId);
SMDSAbs_ElementType aType = elem->GetType();
SMDS_MeshElement* todest = (SMDS_MeshElement*)(elem);
if (aType == SMDSAbs_Node) {
- //MESSAGE("Remove free node " << elemId);
// only free node can be removed by this method
const SMDS_MeshNode* n = static_cast<SMDS_MeshNode*>(todest);
SMDS_ElemIteratorPtr itFe = n->GetInverseElementIterator();
// this methods is only for meshes without descendants
return;
- //MESSAGE("Remove free element " << elemId);
// Remove element from <InverseElements> of its nodes
SMDS_ElemIteratorPtr itn = elem->nodesIterator();
while (itn->more()) {
void SMDS_Mesh::Renumber (const bool isNodes, const int startID, const int deltaID)
{
- MESSAGE("Renumber");
if ( deltaID == 0 )
return;
// MESSAGE(" ------------------- resize myCellIdSmdsToVtk " << val << " --> " << val + nbNodes);
// myCellIdSmdsToVtk.resize(val + nbNodes, -1); // fill new elements with -1
int val = myNodes.size();
- MESSAGE(" ------------------- resize myNodes " << val << " --> " << val + nbNodes);
myNodes.resize(val +nbNodes, 0);
}
void SMDS_Mesh::incrementCellsCapacity(int nbCells)
{
int val = myCellIdVtkToSmds.size();
- MESSAGE(" ------------------- resize myCellIdVtkToSmds " << val << " --> " << val + nbCells);
myCellIdVtkToSmds.resize(val + nbCells, -1); // fill new elements with -1
val = myCells.size();
- MESSAGE(" ------------------- resize myCells " << val << " --> " << val + nbCells);
myNodes.resize(val +nbCells, 0);
}
void SMDS_Mesh::dumpGrid(string ficdump)
{
- MESSAGE("SMDS_Mesh::dumpGrid " << ficdump);
-// vtkUnstructuredGridWriter* aWriter = vtkUnstructuredGridWriter::New();
-// aWriter->SetFileName(ficdump.c_str());
-// aWriter->SetInput(myGrid);
-// if(myGrid->GetNumberOfCells())
-// {
-// aWriter->Write();
-// }
-// aWriter->Delete();
+ // vtkUnstructuredGridWriter* aWriter = vtkUnstructuredGridWriter::New();
+ // aWriter->SetFileName(ficdump.c_str());
+ // aWriter->SetInput(myGrid);
+ // if(myGrid->GetNumberOfCells())
+ // {
+ // aWriter->Write();
+ // }
+ // aWriter->Delete();
ficdump = ficdump + "_connectivity";
ofstream ficcon(ficdump.c_str(), ios::out);
int nbPoints = myGrid->GetNumberOfPoints();
ficcon << "-------------------------------- points " << nbPoints << endl;
for (int i=0; i<nbPoints; i++)
{
- ficcon << i << " " << *(myGrid->GetPoint(i)) << " " << *(myGrid->GetPoint(i)+1) << " " << " " << *(myGrid->GetPoint(i)+2) << endl;
+ ficcon << i << " " << *(myGrid->GetPoint(i)) << " " << *(myGrid->GetPoint(i)+1) << " " << " " << *(myGrid->GetPoint(i)+2) << endl;
}
int nbCells = myGrid->GetNumberOfCells();
ficcon << "-------------------------------- cells " << nbCells << endl;
for (int i=0; i<nbCells; i++)
{
-// MESSAGE(i << " " << myGrid->GetCell(i));
-// MESSAGE(" " << myGrid->GetCell(i)->GetCellType());
- ficcon << i << " - " << myGrid->GetCell(i)->GetCellType() << " -";
- int nbptcell = myGrid->GetCell(i)->GetNumberOfPoints();
- vtkIdList *listid = myGrid->GetCell(i)->GetPointIds();
- for (int j=0; j<nbptcell; j++)
- {
- ficcon << " " << listid->GetId(j);
- }
- ficcon << endl;
+ ficcon << i << " - " << myGrid->GetCell(i)->GetCellType() << " -";
+ int nbptcell = myGrid->GetCell(i)->GetNumberOfPoints();
+ vtkIdList *listid = myGrid->GetCell(i)->GetPointIds();
+ for (int j=0; j<nbptcell; j++)
+ {
+ ficcon << " " << listid->GetId(j);
+ }
+ ficcon << endl;
}
ficcon << "-------------------------------- connectivity " << nbPoints << endl;
- vtkCellLinks *links = myGrid->GetCellLinks();
+ vtkCellLinks *links = myGrid->GetCellLinks();
for (int i=0; i<nbPoints; i++)
{
- int ncells = links->GetNcells(i);
- vtkIdType *cells = links->GetCells(i);
- ficcon << i << " - " << ncells << " -";
- for (int j=0; j<ncells; j++)
- {
- ficcon << " " << cells[j];
+ int ncells = links->GetNcells(i);
+ vtkIdType *cells = links->GetCells(i);
+ ficcon << i << " - " << ncells << " -";
+ for (int j=0; j<ncells; j++)
+ {
+ ficcon << " " << cells[j];
}
ficcon << endl;
}
if ((xmax - xmin) > dmax) dmax = xmax -xmin;
if ((ymax - ymin) > dmax) dmax = ymax -ymin;
if ((zmax - zmin) > dmax) dmax = zmax -zmin;
- MESSAGE("getMaxDim " << dmax);
return dmax;
}
void SMDS_Mesh::Modified()
{
if (this->myModified)
- {
- this->myModifTime++;
- MESSAGE("modified");
- myModified = false;
- }
+ {
+ this->myModifTime++;
+ myModified = false;
+ }
}
//! get last modification timeStamp
bool SMDS_Mesh::isCompacted()
{
if (this->myModifTime > this->myCompactTime)
- {
- MESSAGE(" *** isCompacted " << myCompactTime << " < " << myModifTime);
- this->myCompactTime = this->myModifTime;
- return false;
- }
+ {
+ this->myCompactTime = this->myModifTime;
+ return false;
+ }
return true;
}