#include "SMDS_SpacePosition.hxx"
#include <vtkUnstructuredGrid.h>
+#include <vtkUnstructuredGridWriter.h>
#include <vtkUnsignedCharArray.h>
+#include <vtkCell.h>
+#include <vtkCellLinks.h>
+#include <vtkIdList.h>
#include <algorithm>
#include <map>
+#include <iostream>
+#include <fstream>
using namespace std;
#ifndef WIN32
int ID)
{
//MESSAGE("AddFaceWithID " << ID)
- SMDS_MeshFace * face=createTriangle(n1, n2, n3, myElementIDFactory->GetFreeID());
+ SMDS_MeshFace * face=createTriangle(n1, n2, n3, ID);
if (face && !registerElement(ID, face)) {
RemoveElement(face, false);
///////////////////////////////////////////////////////////////////////////////
bool SMDS_Mesh::registerElement(int ID, SMDS_MeshElement* element)
{
- //MESSAGE("registerElement " << ID)
+ //MESSAGE("registerElement " << ID);
if ((ID < myIDElements.size()) && myIDElements[ID] >= 0) // --- already bound
{
MESSAGE(" --------------------------------- already bound "<< ID << " " << myIDElements[ID]);
}
myIDElements[ID] = vtkId;
- //MESSAGE("smds:" << ID << " vtk:" << cellId );
+ //MESSAGE("smds:" << ID << " vtk:" << vtkId );
if (vtkId >= myVtkIndex.size()) // --- resize local vector
{
face = facevtk;
adjustmyCellsCapacity(ID);
myCells[ID] = face;
+ //MESSAGE("createTriangle " << ID << " " << face);
myInfo.myNbTriangles++;
return face;
}
///////////////////////////////////////////////////////////////////////////////
int SMDS_Mesh::NbNodes() const
{
- return myNodes.size();
+ //MESSAGE(myGrid->GetNumberOfPoints());
+ //MESSAGE(myInfo.NbNodes());
+ //MESSAGE(myNodeMax);
+ return myInfo.NbNodes();
}
///////////////////////////////////////////////////////////////////////////////
void SMDS_Mesh::updateNodeMinMax()
{
myNodeMin = 0;
+ if (myNodes.size() == 0)
+ {
+ myNodeMax=0;
+ return;
+ }
while (!myNodes[myNodeMin] && (myNodeMin<myNodes.size()))
myNodeMin++;
myNodeMax=myNodes.size()-1;
myGrid->GetPoints()->GetData()->SetNumberOfTuples(myNodeIDFactory->GetMaxID()+1);
}
+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();
+ 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;
+ }
+ int nbCells = myGrid->GetNumberOfCells();
+ ficcon << "-------------------------------- cells " << nbCells << endl;
+ for (int i=0; i<nbCells; i++)
+ {
+ 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();
+ 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];
+ }
+ ficcon << endl;
+ }
+ ficcon.close();
+
+}
#define protected protected
#include "utilities.h"
+#include "Utils_SALOME_Exception.hxx"
+#include <cassert>
using namespace std;
int vtkId = myCells[iter];
int smdsId = myMesh->fromVtkToSmds(vtkId);
const SMDS_MeshElement* elem = myMesh->FindElement(smdsId);
+ if (!elem)
+ {
+ assert(0);
+ throw SALOME_Exception("SMDS_MeshNode_MyInvIterator problem Null element");
+ }
+ //MESSAGE("vtkId " << vtkId << " smdsId " << smdsId << " " << (elem!=0));
iter++;
return elem;
}
GetInverseElementIterator(SMDSAbs_ElementType type) const
{
vtkCellLinks::Link l = SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetCellLinks()->GetLink(myID);
- //MESSAGE("ncells " << l.ncells);
+ //MESSAGE("myID " << myID << " ncells " << l.ncells);
return SMDS_ElemIteratorPtr(new SMDS_MeshNode_MyInvIterator(SMDS_Mesh::_meshList[myMeshId], l.cells, l.ncells, type));
}
SMDSAbs_ElementType type):
myMesh(mesh), myCells(cells), myNcells(ncells), myType(type), iter(0)
{
- for (; iter<ncells; iter++)
+ //MESSAGE("myNcells " << myNcells);
+ for (; iter<ncells; iter++)
{
int vtkId = myCells[iter];
int smdsId = myMesh->fromVtkToSmds(vtkId);
+ //MESSAGE("vtkId " << vtkId << " smdsId " << smdsId);
const SMDS_MeshElement* elem = myMesh->FindElement(smdsId);
if (elem->GetType() == type)
myFiltCells.push_back((SMDS_MeshElement*)elem);
}
myNcells = myFiltCells.size();
- iter = 0;
+ //MESSAGE("myNcells " << myNcells);
+ iter = 0;
//MESSAGE("SMDS_MeshNode_MyIterator (filter) " << ncells << " " << myNcells);
}