X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMDS%2FSMDS_Mesh.cxx;h=72aa928c979880a80d2223d13d47b2c3c19dd7f7;hb=63710c8cead2a2466e106949660e56f8637a892e;hp=d6f7e1813f23d8b5d56944b27b7e4cc3ccfdcb3a;hpb=8fa039a796957b302d86d90b22afc0a998573f83;p=modules%2Fsmesh.git diff --git a/src/SMDS/SMDS_Mesh.cxx b/src/SMDS/SMDS_Mesh.cxx index d6f7e1813..72aa928c9 100644 --- a/src/SMDS/SMDS_Mesh.cxx +++ b/src/SMDS/SMDS_Mesh.cxx @@ -154,6 +154,9 @@ SMDS_Mesh::SMDS_Mesh() myGrid->Initialize(); myGrid->Allocate(); vtkPoints* points = vtkPoints::New(); + // rnv: to fix bug "21125: EDF 1233 SMESH: Degrardation of precision in a test case for quadratic conversion" + // using double type for storing coordinates of nodes instead float. + points->SetDataType(VTK_DOUBLE); points->SetNumberOfPoints(SMDS_Mesh::chunkSize); myGrid->SetPoints( points ); points->Delete(); @@ -210,8 +213,7 @@ SMDS_MeshNode * SMDS_Mesh::AddNodeWithID(double x, double y, double z, int ID) // find the MeshNode corresponding to ID const SMDS_MeshElement *node = myNodeIDFactory->MeshElement(ID); if(!node){ - // TODO ID < 1 - if (ID <= 0) + if (ID < 1) { MESSAGE("=============> Bad Node Id: " << ID); ID = myNodeIDFactory->GetFreeID(); @@ -219,6 +221,7 @@ SMDS_MeshNode * SMDS_Mesh::AddNodeWithID(double x, double y, double z, int ID) myNodeIDFactory->adjustMaxId(ID); SMDS_MeshNode * node = myNodePool->getNew(); node->init(ID, myMeshId, 0, x, y, z); + if (ID >= myNodes.size()) { myNodes.resize(ID+SMDS_Mesh::chunkSize, 0); @@ -269,7 +272,7 @@ SMDS_Mesh0DElement* SMDS_Mesh::Add0DElementWithID(const SMDS_MeshNode * n, int I //MESSAGE("Add0DElementWithID" << ID) SMDS_Mesh0DElement * el0d = new SMDS_Mesh0DElement(n); if (myElementIDFactory->BindID(ID, el0d)) { - SMDS_MeshNode *node = const_cast(n); + //SMDS_MeshNode *node = const_cast(n); //node->AddInverseElement(el0d);// --- fait avec BindID adjustmyCellsCapacity(ID); myCells[ID] = el0d; @@ -1162,7 +1165,7 @@ SMDS_MeshFace* SMDS_Mesh::AddPolygonalFaceWithID else { //#ifdef VTK_HAVE_POLYHEDRON - MESSAGE("AddPolygonalFaceWithID vtk " << ID); + //MESSAGE("AddPolygonalFaceWithID vtk " << ID); vector nodeIds; nodeIds.clear(); vector::iterator it = nodes.begin(); @@ -1257,7 +1260,7 @@ SMDS_MeshVolume* SMDS_Mesh::AddPolyhedralVolumeWithID else { //#ifdef VTK_HAVE_POLYHEDRON - MESSAGE("AddPolyhedralVolumeWithID vtk " << ID); + //MESSAGE("AddPolyhedralVolumeWithID vtk " << ID); vector nodeIds; nodeIds.clear(); vector::iterator it = nodes.begin(); @@ -1310,7 +1313,7 @@ SMDS_MeshVolume* SMDS_Mesh::AddPolyhedralVolume return v; } -SMDS_MeshVolume* SMDS_Mesh::AddVolumeFromVtkIds(const std::vector& vtkNodeIds) +SMDS_MeshVolume* SMDS_Mesh::AddVolumeFromVtkIds(const std::vector& vtkNodeIds) { int ID = myElementIDFactory->GetFreeID(); SMDS_MeshVolume * v = SMDS_Mesh::AddVolumeFromVtkIdsWithID(vtkNodeIds, ID); @@ -1318,7 +1321,7 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeFromVtkIds(const std::vector& vtkNodeI return v; } -SMDS_MeshVolume* SMDS_Mesh::AddVolumeFromVtkIdsWithID(const std::vector& vtkNodeIds, const int ID) +SMDS_MeshVolume* SMDS_Mesh::AddVolumeFromVtkIdsWithID(const std::vector& vtkNodeIds, const int ID) { SMDS_VtkVolume *volvtk = myVolumePool->getNew(); volvtk->init(vtkNodeIds, this); @@ -2309,9 +2312,9 @@ void SMDS_Mesh::DebugStats() const /////////////////////////////////////////////////////////////////////////////// int SMDS_Mesh::NbNodes() const { - //MESSAGE(myGrid->GetNumberOfPoints()); - //MESSAGE(myInfo.NbNodes()); - //MESSAGE(myNodeMax); + //MESSAGE(myGrid->GetNumberOfPoints()); + //MESSAGE(myInfo.NbNodes()); + //MESSAGE(myNodeMax); return myInfo.NbNodes(); } @@ -2387,6 +2390,7 @@ SMDS_Mesh::~SMDS_Mesh() while (itn->more()) { const SMDS_MeshNode *node = itn->next(); + ((SMDS_MeshNode*)node)->SetPosition(SMDS_SpacePosition::originSpacePosition()); myNodeIDFactory->ReleaseID(node->GetID(), node->getVtkId()); } } @@ -2485,6 +2489,7 @@ void SMDS_Mesh::Clear() while (itn->more()) { SMDS_MeshNode *node = (SMDS_MeshNode*)(itn->next()); + node->SetPosition(SMDS_SpacePosition::originSpacePosition()); myNodePool->destroy(node); } myNodes.clear(); @@ -2503,7 +2508,10 @@ void SMDS_Mesh::Clear() myGrid->Initialize(); myGrid->Allocate(); vtkPoints* points = vtkPoints::New(); - points->SetNumberOfPoints(SMDS_Mesh::chunkSize); + // rnv: to fix bug "21125: EDF 1233 SMESH: Degrardation of precision in a test case for quadratic conversion" + // using double type for storing coordinates of nodes instead float. + points->SetDataType(VTK_DOUBLE); + points->SetNumberOfPoints(0 /*SMDS_Mesh::chunkSize*/); myGrid->SetPoints( points ); points->Delete(); myGrid->BuildLinks(); @@ -2988,8 +2996,10 @@ void SMDS_Mesh::RemoveElement(const SMDS_MeshElement * elem, //MESSAGE("SMDS_Mesh::RemoveElement " << elem->getVtkId() << " " << removenodes); // get finite elements built on elem set * s1; - if (elem->GetType() == SMDSAbs_0DElement || elem->GetType() == SMDSAbs_Edge && !hasConstructionEdges() - || elem->GetType() == SMDSAbs_Face && !hasConstructionFaces() || elem->GetType() == SMDSAbs_Volume) + if ( (elem->GetType() == SMDSAbs_0DElement) + || ((elem->GetType() == SMDSAbs_Edge) && !hasConstructionEdges()) + || ((elem->GetType() == SMDSAbs_Face) && !hasConstructionFaces()) + || (elem->GetType() == SMDSAbs_Volume) ) { s1 = new set (); s1->insert(elem); @@ -3116,7 +3126,10 @@ void SMDS_Mesh::RemoveElement(const SMDS_MeshElement * elem, myNodeIDFactory->ReleaseID((*it)->GetID(), (*it)->getVtkId()); removedNodes.push_back((*it)); if (const SMDS_MeshNode* vtkElem = dynamic_cast(*it)) + { + ((SMDS_MeshNode*)vtkElem)->SetPosition(SMDS_SpacePosition::originSpacePosition()); myNodePool->destroy((SMDS_MeshNode*) vtkElem); + } else delete (*it); it++; @@ -3146,6 +3159,7 @@ void SMDS_Mesh::RemoveFreeElement(const SMDS_MeshElement * elem) if (!itFe->more()) { // free node myNodes[elemId] = 0; myInfo.myNbNodes--; + ((SMDS_MeshNode*) n)->SetPosition(SMDS_SpacePosition::originSpacePosition()); myNodePool->destroy(static_cast(todest)); myNodeIDFactory->ReleaseID(elemId, vtkId); } @@ -3395,8 +3409,8 @@ SMDS_MeshEdge* SMDS_Mesh::AddEdgeWithID(const SMDS_MeshNode * n1, myInfo.myNbQuadEdges++; // if (!registerElement(ID, edge)) { -// RemoveElement(edge, false); -// edge = NULL; +// RemoveElement(edge, false); +// edge = NULL; // } return edge; @@ -3540,7 +3554,7 @@ SMDS_MeshFace* SMDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1, if ( !n1 || !n2 || !n3 || !n4 || !n12 || !n23 || !n34 || !n41) return 0; if(hasConstructionEdges()) { // creation quadratic edges - not implemented - return 0; + return 0; } else { @@ -4077,8 +4091,8 @@ void SMDS_Mesh::updateNodeMinMax() myNodeMin = 0; if (myNodes.size() == 0) { - myNodeMax=0; - return; + myNodeMax=0; + return; } while (!myNodes[myNodeMin] && (myNodeMinSetFileName(ficdump.c_str()); // aWriter->SetInput(myGrid); @@ -4129,35 +4143,35 @@ void SMDS_Mesh::dumpGrid(string ficdump) ficcon << "-------------------------------- points " << nbPoints << endl; for (int i=0; iGetPoint(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; iGetCell(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; jGetId(j); - } - ficcon << endl; +// 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; jGetId(j); + } + ficcon << endl; } ficcon << "-------------------------------- connectivity " << nbPoints << endl; - vtkCellLinks *links = myGrid->GetCellLinks(); + vtkCellLinks *links = myGrid->GetCellLinks(); for (int i=0; iGetNcells(i); - vtkIdType *cells = links->GetCells(i); - ficcon << i << " - " << ncells << " -"; - for (int j=0; jGetNcells(i); + vtkIdType *cells = links->GetCells(i); + ficcon << i << " - " << ncells << " -"; + for (int j=0; j