X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMDS%2FSMDS_Mesh.cxx;h=40caa2c8854d51f04cbb99b91ba3f5943a34f8cd;hp=86524eb8d2c2d08a2135116b6a89dcd87a3b0223;hb=ccb5e3c25bf204e839c0094f50f543eacedba5e6;hpb=3c33b141570dd9eee180f7149b5f97a0a30884db diff --git a/src/SMDS/SMDS_Mesh.cxx b/src/SMDS/SMDS_Mesh.cxx index 86524eb8d..40caa2c88 100644 --- a/src/SMDS/SMDS_Mesh.cxx +++ b/src/SMDS/SMDS_Mesh.cxx @@ -1,4 +1,4 @@ -// 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 @@ -56,7 +56,7 @@ #include using namespace std; -#ifndef WIN32 +#if !defined WIN32 && !defined __APPLE__ #include #endif @@ -77,7 +77,7 @@ int SMDS_Mesh::chunkSize = 1024; int SMDS_Mesh::CheckMemory(const bool doNotRaise) throw (std::bad_alloc) { -#ifndef WIN32 +#if !defined WIN32 && !defined __APPLE__ struct sysinfo si; int err = sysinfo( &si ); if ( err ) @@ -130,7 +130,6 @@ SMDS_Mesh::SMDS_Mesh(): myNodeIDFactory(new SMDS_MeshNodeIDFactory()), myElementIDFactory(new SMDS_MeshElementIDFactory()), myModified(false), myModifTime(0), myCompactTime(0), - myNodeMin(0), myNodeMax(0), myHasConstructionEdges(false), myHasConstructionFaces(false), myHasInverseElements(true), xmin(0), xmax(0), ymin(0), ymax(0), zmin(0), zmax(0) @@ -160,8 +159,19 @@ SMDS_Mesh::SMDS_Mesh(): points->SetNumberOfPoints(0 /*SMDS_Mesh::chunkSize*/); myGrid->SetPoints( points ); points->Delete(); - myGrid->BuildLinks(); + //myGrid->BuildLinks(); this->Modified(); + + // initialize static maps in SMDS_MeshCell, to be thread-safe + if ( myMeshId == 0 ) + { + SMDS_MeshCell::toVtkType( SMDSEntity_Node ); + SMDS_MeshCell::toVtkOrder( SMDSEntity_Node ); + SMDS_MeshCell::reverseSmdsOrder( SMDSEntity_Node ); + SMDS_MeshCell::interlacedSmdsOrder( SMDSEntity_Node ); + SMDS_MeshCell::toSmdsType( VTK_VERTEX ); + SMDS_MeshCell::fromVtkOrder( SMDSEntity_Node ); + } } /////////////////////////////////////////////////////////////////////////////// @@ -373,7 +383,7 @@ SMDS_MeshEdge* SMDS_Mesh::AddEdgeWithID(const SMDS_MeshNode * n1, if ( !n1 || !n2 ) return 0; SMDS_MeshEdge * edge = 0; - // --- retreive nodes ID + // --- retrieve nodes ID vector nodeIds; nodeIds.clear(); nodeIds.push_back(n1->getVtkId()); @@ -525,7 +535,6 @@ SMDS_MeshFace* SMDS_Mesh::AddFaceWithID(const SMDS_MeshEdge * e1, 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); @@ -552,7 +561,6 @@ SMDS_MeshFace* SMDS_Mesh::AddFace(const SMDS_MeshEdge * e1, { if (!hasConstructionEdges()) return NULL; - //MESSAGE("AddFaceWithID" ); return AddFaceWithID(e1,e2,e3,e4, myElementIDFactory->GetFreeID()); } @@ -568,7 +576,6 @@ SMDS_MeshFace* SMDS_Mesh::AddFaceWithID(const SMDS_MeshEdge * e1, { 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); @@ -596,7 +603,6 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolume(const SMDS_MeshNode * n1, 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; @@ -615,7 +621,6 @@ SMDS_MeshVolume * SMDS_Mesh::AddVolumeWithID(int idnode1, 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); @@ -637,7 +642,6 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1, 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(); @@ -652,7 +656,6 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1, myInfo.myNbTetras++; } else if(hasConstructionEdges()) { - MESSAGE("Error : Not implemented"); return NULL; } else { @@ -697,7 +700,6 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolume(const SMDS_MeshNode * n1, 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; @@ -718,7 +720,6 @@ SMDS_MeshVolume * SMDS_Mesh::AddVolumeWithID(int idnode1, 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); @@ -743,7 +744,6 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1, 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(); @@ -758,7 +758,6 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1, myInfo.myNbPyramids++; } else if(hasConstructionEdges()) { - MESSAGE("Error : Not implemented"); return NULL; } else { @@ -805,7 +804,6 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolume(const SMDS_MeshNode * n1, 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; @@ -827,7 +825,6 @@ SMDS_MeshVolume * SMDS_Mesh::AddVolumeWithID(int idnode1, 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); @@ -854,7 +851,6 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1, 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(); @@ -870,7 +866,6 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1, myInfo.myNbPrisms++; } else if(hasConstructionEdges()) { - MESSAGE("Error : Not implemented"); return NULL; } else { @@ -994,11 +989,9 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1, 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 { @@ -1074,7 +1067,6 @@ SMDS_MeshVolume * SMDS_Mesh::AddVolumeWithID(int idnode1, 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); @@ -1108,7 +1100,6 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1, 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(); @@ -1125,7 +1116,6 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1, myInfo.myNbHexas++; } else if(hasConstructionEdges()) { - MESSAGE("Error : Not implemented"); return NULL; } else { @@ -1171,7 +1161,6 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolume(const SMDS_MeshFace * f1, const SMDS_MeshFace * f3, const SMDS_MeshFace * f4) { - //MESSAGE("AddVolumeWithID"); if (!hasConstructionFaces()) return NULL; return AddVolumeWithID(f1,f2,f3,f4, myElementIDFactory->GetFreeID()); @@ -1189,7 +1178,6 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshFace * f1, const SMDS_MeshFace * f4, int ID) { - MESSAGE("AddVolumeWithID" << ID); if (!hasConstructionFaces()) return NULL; if ( !f1 || !f2 || !f3 || !f4) return 0; @@ -1218,7 +1206,6 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolume(const SMDS_MeshFace * f1, const SMDS_MeshFace * f4, const SMDS_MeshFace * f5) { - //MESSAGE("AddVolumeWithID"); if (!hasConstructionFaces()) return NULL; return AddVolumeWithID(f1,f2,f3,f4,f5, myElementIDFactory->GetFreeID()); @@ -1237,7 +1224,6 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshFace * f1, const SMDS_MeshFace * f5, int ID) { - MESSAGE("AddVolumeWithID" << ID); if (!hasConstructionFaces()) return NULL; if ( !f1 || !f2 || !f3 || !f4 || !f5) return 0; @@ -1267,7 +1253,6 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolume(const SMDS_MeshFace * f1, const SMDS_MeshFace * f5, const SMDS_MeshFace * f6) { - //MESSAGE("AddVolumeWithID" ); if (!hasConstructionFaces()) return NULL; return AddVolumeWithID(f1,f2,f3,f4,f5,f6, myElementIDFactory->GetFreeID()); @@ -1287,7 +1272,6 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshFace * f1, const SMDS_MeshFace * f6, int ID) { - MESSAGE("AddVolumeWithID" << ID); if (!hasConstructionFaces()) return NULL; if ( !f1 || !f2 || !f3 || !f4 || !f5 || !f6) return 0; @@ -1334,7 +1318,6 @@ SMDS_Mesh::AddPolygonalFaceWithID (const vector & nodes, if ( NbFaces() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory(); if (hasConstructionEdges()) { - MESSAGE("Error : Not implemented"); return NULL; } else @@ -1399,7 +1382,6 @@ SMDS_Mesh::AddQuadPolygonalFaceWithID (const vector & node if ( NbFaces() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory(); if (hasConstructionEdges()) { - MESSAGE("Error : Not implemented"); return NULL; } else @@ -1472,18 +1454,15 @@ SMDS_Mesh::AddPolyhedralVolumeWithID (const vector& nodes, 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(); @@ -1498,7 +1477,6 @@ SMDS_Mesh::AddPolyhedralVolumeWithID (const vector& nodes, } 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); @@ -1578,9 +1556,15 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeFromVtkIdsWithID(const std::vector& /////////////////////////////////////////////////////////////////////////////// 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()); @@ -1666,7 +1649,6 @@ bool SMDS_Mesh::registerElement(int ID, SMDS_MeshElement* element) 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; @@ -1693,9 +1675,6 @@ const SMDS_MeshNode * SMDS_Mesh::FindNode(int ID) const { if (ID < 1 || ID >= (int)myNodes.size()) { -// MESSAGE("------------------------------------------------------------------------- "); -// MESSAGE("----------------------------------- bad ID " << ID << " " << myNodes.size()); -// MESSAGE("------------------------------------------------------------------------- "); return 0; } return (const SMDS_MeshNode *)myNodes[ID]; @@ -1717,10 +1696,10 @@ const SMDS_MeshNode * SMDS_Mesh::FindNodeVtk(int vtkId) const return (const SMDS_MeshNode *)myNodes[vtkId+1]; } -/////////////////////////////////////////////////////////////////////////////// -///Create a triangle and add it to the current mesh. This method do not bind an -///ID to the create triangle. -/////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// +///Create a triangle and add it to the current mesh. This method does not bind +///an ID to the create triangle. +////////////////////////////////////////////////////////////////////////////// SMDS_MeshFace * SMDS_Mesh::createTriangle(const SMDS_MeshNode * node1, const SMDS_MeshNode * node2, const SMDS_MeshNode * node3, @@ -1762,16 +1741,15 @@ SMDS_MeshFace * SMDS_Mesh::createTriangle(const SMDS_MeshNode * node1, face = facevtk; adjustmyCellsCapacity(ID); myCells[ID] = face; - //MESSAGE("createTriangle " << ID << " " << face); myInfo.myNbTriangles++; return face; } } -/////////////////////////////////////////////////////////////////////////////// -///Create a quadrangle and add it to the current mesh. This methode do not bind -///a ID to the create triangle. -/////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// +///Create a quadrangle and add it to the current mesh. This method does not bind +///an ID to the create triangle. +//////////////////////////////////////////////////////////////////////////////// SMDS_MeshFace * SMDS_Mesh::createQuadrangle(const SMDS_MeshNode * node1, const SMDS_MeshNode * node2, const SMDS_MeshNode * node3, @@ -1782,7 +1760,6 @@ SMDS_MeshFace * SMDS_Mesh::createQuadrangle(const SMDS_MeshNode * node1, 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); @@ -1827,7 +1804,6 @@ SMDS_MeshFace * SMDS_Mesh::createQuadrangle(const SMDS_MeshNode * node1, void SMDS_Mesh::RemoveNode(const SMDS_MeshNode * node) { - MESSAGE("RemoveNode"); RemoveElement(node, true); } @@ -1837,7 +1813,6 @@ void SMDS_Mesh::RemoveNode(const SMDS_MeshNode * node) void SMDS_Mesh::Remove0DElement(const SMDS_Mesh0DElement * elem0d) { - MESSAGE("Remove0DElement"); RemoveElement(elem0d,true); } @@ -1847,7 +1822,6 @@ void SMDS_Mesh::Remove0DElement(const SMDS_Mesh0DElement * elem0d) void SMDS_Mesh::RemoveEdge(const SMDS_MeshEdge * edge) { - MESSAGE("RemoveEdge"); RemoveElement(edge,true); } @@ -1857,7 +1831,6 @@ void SMDS_Mesh::RemoveEdge(const SMDS_MeshEdge * edge) void SMDS_Mesh::RemoveFace(const SMDS_MeshFace * face) { - MESSAGE("RemoveFace"); RemoveElement(face, true); } @@ -1867,7 +1840,6 @@ void SMDS_Mesh::RemoveFace(const SMDS_MeshFace * face) void SMDS_Mesh::RemoveVolume(const SMDS_MeshVolume * volume) { - MESSAGE("RemoveVolume"); RemoveElement(volume, true); } @@ -1914,7 +1886,6 @@ bool SMDS_Mesh::ChangeElementNodes(const SMDS_MeshElement * element, const SMDS_MeshNode * nodes[], const int nbnodes) { - MESSAGE("SMDS_Mesh::ChangeElementNodes"); // keep current nodes of elem set oldNodes( element->begin_nodes(), element->end_nodes() ); @@ -2428,11 +2399,6 @@ const SMDS_MeshElement* SMDS_Mesh::FindElement(int IDelem) const { 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]; @@ -2498,6 +2464,49 @@ const SMDS_MeshElement* SMDS_Mesh::FindElement (const vector& nodes, + std::vector& foundElems, + const SMDSAbs_ElementType type) +{ + // chose a node with minimal number of inverse elements + const SMDS_MeshNode* n0 = nodes[0]; + int minNbInverse = n0 ? n0->NbInverseElements( type ) : 1000; + for ( size_t i = 1; i < nodes.size(); ++i ) + if ( nodes[i] && nodes[i]->NbInverseElements( type ) < minNbInverse ) + { + n0 = nodes[i]; + minNbInverse = n0->NbInverseElements( type ); + } + + foundElems.clear(); + if ( n0 ) + { + foundElems.reserve( minNbInverse ); + SMDS_ElemIteratorPtr eIt = n0->GetInverseElementIterator( type ); + while ( eIt->more() ) + { + const SMDS_MeshElement* e = eIt->next(); + bool includeAll = true; + for ( size_t i = 0; i < nodes.size() && includeAll; ++i ) + if ( nodes[i] != n0 && e->GetNodeIndex( nodes[i] ) < 0 ) + includeAll = false; + if ( includeAll ) + foundElems.push_back( e ); + } + } + return foundElems.size(); +} + //======================================================================= //function : DumpNodes //purpose : @@ -2505,9 +2514,8 @@ const SMDS_MeshElement* SMDS_Mesh::FindElement (const vectormore()) ; //MESSAGE(itnode->next()); + SMDS_NodeIteratorPtr itnode=nodesIterator(); + while(itnode->more()) ; //MESSAGE(itnode->next()); } //======================================================================= @@ -2516,7 +2524,6 @@ void SMDS_Mesh::DumpNodes() const //======================================================================= void SMDS_Mesh::Dump0DElements() const { - MESSAGE("dump 0D elements of mesh : "); SMDS_ElemIteratorPtr it0d = elementsIterator(SMDSAbs_0DElement); while(it0d->more()) ; //MESSAGE(it0d->next()); } @@ -2528,9 +2535,8 @@ void SMDS_Mesh::Dump0DElements() const 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()); } //======================================================================= @@ -2540,9 +2546,8 @@ void SMDS_Mesh::DumpEdges() const 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()); } //======================================================================= @@ -2552,9 +2557,8 @@ void SMDS_Mesh::DumpFaces() const 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()); } //======================================================================= @@ -2612,12 +2616,16 @@ void SMDS_Mesh::DebugStats() const /////////////////////////////////////////////////////////////////////////////// int SMDS_Mesh::NbNodes() const { - //MESSAGE(myGrid->GetNumberOfPoints()); - //MESSAGE(myInfo.NbNodes()); - //MESSAGE(myNodeMax); - return myInfo.NbNodes(); + return myInfo.NbNodes(); } +/////////////////////////////////////////////////////////////////////////////// +/// Return the number of elements +/////////////////////////////////////////////////////////////////////////////// +int SMDS_Mesh::NbElements() const +{ + return myInfo.NbElements(); +} /////////////////////////////////////////////////////////////////////////////// /// Return the number of 0D elements /////////////////////////////////////////////////////////////////////////////// @@ -2718,54 +2726,27 @@ SMDS_Mesh::~SMDS_Mesh() void SMDS_Mesh::Clear() { - MESSAGE("SMDS_Mesh::Clear"); if (myParent!=NULL) - { + { SMDS_ElemIteratorPtr eIt = elementsIterator(); while ( eIt->more() ) - { - const SMDS_MeshElement *elem = eIt->next(); - myElementIDFactory->ReleaseID(elem->GetID(), elem->getVtkId()); - } + { + const SMDS_MeshElement *elem = eIt->next(); + myElementIDFactory->ReleaseID(elem->GetID(), elem->getVtkId()); + } SMDS_NodeIteratorPtr itn = nodesIterator(); while (itn->more()) - { - const SMDS_MeshNode *node = itn->next(); - myNodeIDFactory->ReleaseID(node->GetID(), node->getVtkId()); - } + { + const SMDS_MeshNode *node = itn->next(); + myNodeIDFactory->ReleaseID(node->GetID(), node->getVtkId()); } + } else - { + { myNodeIDFactory->Clear(); myElementIDFactory->Clear(); - } + } - // SMDS_ElemIteratorPtr itv = elementsIterator(); - // while (itv->more()) - // { - // SMDS_MeshElement* elem = (SMDS_MeshElement*)(itv->next()); - // SMDSAbs_ElementType aType = elem->GetType(); - // switch (aType) - // { - // case SMDSAbs_0DElement: - // delete elem; - // break; - // case SMDSAbs_Edge: - // myEdgePool->destroy(static_cast(elem)); - // break; - // case SMDSAbs_Face: - // myFacePool->destroy(static_cast(elem)); - // break; - // case SMDSAbs_Volume: - // myVolumePool->destroy(static_cast(elem)); - // break; - // case SMDSAbs_Ball: - // myBallPool->destroy(static_cast(elem)); - // break; - // default: - // break; - // } - // } myVolumePool->clear(); myFacePool->clear(); myEdgePool->clear(); @@ -2776,11 +2757,11 @@ void SMDS_Mesh::Clear() SMDS_NodeIteratorPtr itn = nodesIterator(); while (itn->more()) - { - SMDS_MeshNode *node = (SMDS_MeshNode*)(itn->next()); - node->SetPosition(SMDS_SpacePosition::originSpacePosition()); - //myNodePool->destroy(node); - } + { + SMDS_MeshNode *node = (SMDS_MeshNode*)(itn->next()); + node->SetPosition(SMDS_SpacePosition::originSpacePosition()); + //myNodePool->destroy(node); + } myNodePool->clear(); clearVector( myNodes ); @@ -2802,10 +2783,10 @@ void SMDS_Mesh::Clear() // 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*/); + points->SetNumberOfPoints( 0 ); myGrid->SetPoints( points ); points->Delete(); - myGrid->BuildLinks(); + myGrid->DeleteLinks(); } /////////////////////////////////////////////////////////////////////////////// @@ -2815,7 +2796,7 @@ void SMDS_Mesh::Clear() /////////////////////////////////////////////////////////////////////////////// bool SMDS_Mesh::hasConstructionEdges() { - return myHasConstructionEdges; + return myHasConstructionEdges; } /////////////////////////////////////////////////////////////////////////////// @@ -2827,7 +2808,7 @@ bool SMDS_Mesh::hasConstructionEdges() /////////////////////////////////////////////////////////////////////////////// bool SMDS_Mesh::hasConstructionFaces() { - return myHasConstructionFaces; + return myHasConstructionFaces; } /////////////////////////////////////////////////////////////////////////////// @@ -2836,7 +2817,7 @@ bool SMDS_Mesh::hasConstructionFaces() /////////////////////////////////////////////////////////////////////////////// bool SMDS_Mesh::hasInverseElements() { - return myHasInverseElements; + return myHasInverseElements; } /////////////////////////////////////////////////////////////////////////////// @@ -2845,7 +2826,7 @@ bool SMDS_Mesh::hasInverseElements() /////////////////////////////////////////////////////////////////////////////// void SMDS_Mesh::setConstructionEdges(bool b) { - myHasConstructionEdges=b; + myHasConstructionEdges=b; } /////////////////////////////////////////////////////////////////////////////// @@ -2854,7 +2835,7 @@ void SMDS_Mesh::setConstructionEdges(bool b) /////////////////////////////////////////////////////////////////////////////// void SMDS_Mesh::setConstructionFaces(bool b) { - myHasConstructionFaces=b; + myHasConstructionFaces=b; } /////////////////////////////////////////////////////////////////////////////// @@ -2887,7 +2868,7 @@ namespace { IdSortedIterator(const SMDS_MeshElementIDFactory& fact, const SMDSAbs_ElementType type, // SMDSAbs_All NOT allowed!!! const int totalNb) - :myIDFact( fact ), + :myIDFact( const_cast(fact) ), myID(1), myMaxID( myIDFact.GetMaxID() ),myNbFound(0), myTotalNb( totalNb ), myType( type ), myElem(0) @@ -3077,34 +3058,31 @@ static set * intersectionOfSets( /////////////////////////////////////////////////////////////////////////////// static set * getFinitElements(const SMDS_MeshElement * element) { - int numberOfSets=element->NbNodes(); - set *initSet = new set[numberOfSets]; + int numberOfSets=element->NbNodes(); + set *initSet = new set[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(node); - SMDS_ElemIteratorPtr itFe = n->GetInverseElementIterator(); + SMDS_ElemIteratorPtr itNodes=element->nodesIterator(); - //initSet[i]=set(); - 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(node); + SMDS_ElemIteratorPtr itFe = n->GetInverseElementIterator(); - } + while ( itFe->more() ) + { + const SMDS_MeshElement* elem = itFe->next(); + MYASSERT(elem); + initSet[i].insert(elem); + } - i++; - } - set *retSet=intersectionOfSets(initSet, numberOfSets); -// MESSAGE("nb elems " << i << " intersection " << retSet->size()); - delete [] initSet; - return retSet; + i++; + } + set *retSet = intersectionOfSets( initSet, numberOfSets ); + delete [] initSet; + return retSet; } /////////////////////////////////////////////////////////////////////////////// @@ -3301,12 +3279,12 @@ void SMDS_Mesh::RemoveElement(const SMDS_MeshElement * elem, } removedElems.push_back((*it)); myElementIDFactory->ReleaseID(IdToRemove, vtkid); - if (const SMDS_VtkEdge* vtkElem = dynamic_cast(*it)) { + if (const SMDS_VtkEdge* vtkElem = dynamic_cast(*it)) myEdgePool->destroy((SMDS_VtkEdge*) vtkElem); - ((SMDS_MeshElement*) *it)->init( -1, -1, -1 ); // avoid reuse - } - else + else { + ((SMDS_MeshElement*) *it)->init( 0, -1, -1 ); // avoid reuse delete (*it); + } break; case SMDSAbs_Face: if (IdToRemove >= 0) @@ -3316,12 +3294,12 @@ void SMDS_Mesh::RemoveElement(const SMDS_MeshElement * elem, } removedElems.push_back((*it)); myElementIDFactory->ReleaseID(IdToRemove, vtkid); - if (const SMDS_VtkFace* vtkElem = dynamic_cast(*it)) { + if (const SMDS_VtkFace* vtkElem = dynamic_cast(*it)) myFacePool->destroy((SMDS_VtkFace*) vtkElem); - ((SMDS_MeshElement*) *it)->init( -1, -1, -1 ); // avoid reuse - } - else + else { + ((SMDS_MeshElement*) *it)->init( 0, -1, -1 ); // avoid reuse delete (*it); + } break; case SMDSAbs_Volume: if (IdToRemove >= 0) @@ -3331,12 +3309,12 @@ void SMDS_Mesh::RemoveElement(const SMDS_MeshElement * elem, } removedElems.push_back((*it)); myElementIDFactory->ReleaseID(IdToRemove, vtkid); - if (const SMDS_VtkVolume* vtkElem = dynamic_cast(*it)) { + if (const SMDS_VtkVolume* vtkElem = dynamic_cast(*it)) myVolumePool->destroy((SMDS_VtkVolume*) vtkElem); - ((SMDS_MeshElement*) *it)->init( -1, -1, -1 ); // avoid reuse - } - else + else { + ((SMDS_MeshElement*) *it)->init( 0, -1, -1 ); // avoid reuse delete (*it); + } break; case SMDSAbs_Ball: if (IdToRemove >= 0) @@ -3346,48 +3324,48 @@ void SMDS_Mesh::RemoveElement(const SMDS_MeshElement * elem, } removedElems.push_back((*it)); myElementIDFactory->ReleaseID(IdToRemove, vtkid); - if (const SMDS_BallElement* vtkElem = dynamic_cast(*it)) { + if (const SMDS_BallElement* vtkElem = dynamic_cast(*it)) myBallPool->destroy(const_cast( vtkElem )); - ((SMDS_MeshElement*) *it)->init( -1, -1, -1 ); // avoid reuse - } - else + else { + ((SMDS_MeshElement*) *it)->init( 0, -1, -1 ); // avoid reuse delete (*it); + } break; case SMDSAbs_All: // avoid compilation warning case SMDSAbs_NbElementTypes: break; } if (vtkid >= 0) - { - this->myGrid->GetCellTypesArray()->SetValue(vtkid, VTK_EMPTY_CELL); - } + { + this->myGrid->GetCellTypesArray()->SetValue(vtkid, VTK_EMPTY_CELL); + } it++; } // remove exclusive (free) nodes if (removenodes) + { + it = s2->begin(); + while (it != s2->end()) { - it = s2->begin(); - while (it != s2->end()) - { - int IdToRemove = (*it)->GetID(); - if (IdToRemove >= 0) - { - myNodes[IdToRemove] = 0; - myInfo.myNbNodes--; - } - 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++; - } + int IdToRemove = (*it)->GetID(); + if (IdToRemove >= 0) + { + myNodes[IdToRemove] = 0; + myInfo.myNbNodes--; + } + 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++; } + } delete s2; delete s1; @@ -3400,29 +3378,28 @@ void SMDS_Mesh::RemoveElement(const SMDS_MeshElement * elem, void SMDS_Mesh::RemoveFreeElement(const SMDS_MeshElement * elem) { int elemId = elem->GetID(); - int vtkId = elem->getVtkId(); - //MESSAGE("RemoveFreeElement " << elemId); + int vtkId = elem->getVtkId(); SMDSAbs_ElementType aType = elem->GetType(); - SMDS_MeshElement* todest = (SMDS_MeshElement*)(elem); - if (aType == SMDSAbs_Node) { - //MESSAGE("Remove free node " << elemId); + SMDS_MeshElement* todest = (SMDS_MeshElement*)(elem); + if ( aType == SMDSAbs_Node ) + { // only free node can be removed by this method const SMDS_MeshNode* n = static_cast(todest); - SMDS_ElemIteratorPtr itFe = n->GetInverseElementIterator(); - if (!itFe->more()) { // free node + if ( n->NbInverseElements() == 0 ) { // free node myNodes[elemId] = 0; myInfo.myNbNodes--; ((SMDS_MeshNode*) n)->SetPosition(SMDS_SpacePosition::originSpacePosition()); - ((SMDS_MeshNode*) n)->SMDS_MeshElement::init( -1, -1, -1 ); // avoid reuse + ((SMDS_MeshNode*) n)->SMDS_MeshElement::init( 0, -1, -1 ); // avoid reuse myNodePool->destroy(static_cast(todest)); myNodeIDFactory->ReleaseID(elemId, vtkId); } - } else { + } + else + { if (hasConstructionEdges() || hasConstructionFaces()) // this methods is only for meshes without descendants return; - //MESSAGE("Remove free element " << elemId); // Remove element from of its nodes SMDS_ElemIteratorPtr itn = elem->nodesIterator(); while (itn->more()) { @@ -3468,7 +3445,7 @@ void SMDS_Mesh::RemoveFreeElement(const SMDS_MeshElement * elem) // --- to do: keep vtkid in a list of reusable cells if ( elem ) - ((SMDS_MeshElement*) elem)->init( -1, -1, -1 ); // avoid reuse + ((SMDS_MeshElement*) elem)->init( 0, -1, -1 ); // avoid reuse } } @@ -3478,7 +3455,7 @@ void SMDS_Mesh::RemoveFreeElement(const SMDS_MeshElement * elem) */ bool SMDS_Mesh::Contains (const SMDS_MeshElement* elem) const { - // we should not imply on validity of *elem, so iterate on containers + // we should not rely on validity of *elem, so iterate on containers // of all types in the hope of finding somewhere there SMDS_NodeIteratorPtr itn = nodesIterator(); while (itn->more()) @@ -3498,7 +3475,7 @@ bool SMDS_Mesh::Contains (const SMDS_MeshElement* elem) const int SMDS_Mesh::MaxNodeID() const { - return myNodeMax; + return myNodeIDFactory->GetMaxID(); } //======================================================================= @@ -3508,7 +3485,7 @@ int SMDS_Mesh::MaxNodeID() const int SMDS_Mesh::MinNodeID() const { - return myNodeMin; + return myNodeIDFactory->GetMinID(); } //======================================================================= @@ -3538,7 +3515,6 @@ int SMDS_Mesh::MinElementID() const void SMDS_Mesh::Renumber (const bool isNodes, const int startID, const int deltaID) { - MESSAGE("Renumber"); if ( deltaID == 0 ) return; @@ -4240,7 +4216,7 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1, //======================================================================= //function : AddVolume -//purpose : +//purpose : 2d order Pentahedron (prism) with 15 nodes //======================================================================= SMDS_MeshVolume* SMDS_Mesh::AddVolume(const SMDS_MeshNode * n1, const SMDS_MeshNode * n2, @@ -4268,7 +4244,7 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolume(const SMDS_MeshNode * n1, //======================================================================= //function : AddVolumeWithID -//purpose : +//purpose : 2d order Pentahedron (prism) with 15 nodes //======================================================================= SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int n5, int n6, @@ -4297,7 +4273,7 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, //======================================================================= //function : AddVolumeWithID -//purpose : 2d order Pentahedron with 15 nodes +//purpose : 2d order Pentahedron (prism) with 15 nodes //======================================================================= SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1, const SMDS_MeshNode * n2, @@ -4364,6 +4340,149 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1, return volvtk; } +//======================================================================= +//function : AddVolume +//purpose : 2d order Pentahedron (prism) with 18 nodes +//======================================================================= +SMDS_MeshVolume* SMDS_Mesh::AddVolume(const SMDS_MeshNode * n1, + const SMDS_MeshNode * n2, + const SMDS_MeshNode * n3, + const SMDS_MeshNode * n4, + const SMDS_MeshNode * n5, + const SMDS_MeshNode * n6, + const SMDS_MeshNode * n12, + const SMDS_MeshNode * n23, + const SMDS_MeshNode * n31, + const SMDS_MeshNode * n45, + const SMDS_MeshNode * n56, + const SMDS_MeshNode * n64, + const SMDS_MeshNode * n14, + const SMDS_MeshNode * n25, + const SMDS_MeshNode * n36, + const SMDS_MeshNode * n1245, + const SMDS_MeshNode * n2356, + const SMDS_MeshNode * n1346) +{ + //MESSAGE("AddVolume penta18"); + int ID = myElementIDFactory->GetFreeID(); + SMDS_MeshVolume * v = + SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, n5, n6, n12, n23, n31, + n45, n56, n64, n14, n25, n36, n1245, n2356, n1346, ID); + if(v==NULL) myElementIDFactory->ReleaseID(ID); + return v; +} + +//======================================================================= +//function : AddVolumeWithID +//purpose : 2d order Pentahedron (prism) with 18 nodes +//======================================================================= +SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, + int n4, int n5, int n6, + int n12,int n23,int n31, + int n45,int n56,int n64, + int n14,int n25,int n36, + int n1245, int n2356, int n1346, int ID) +{ + //MESSAGE("AddVolumeWithID penta18 " << ID); + return SMDS_Mesh::AddVolumeWithID + ((SMDS_MeshNode*) myNodeIDFactory->MeshElement(n1) , + (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n2) , + (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n3) , + (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n4) , + (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n5) , + (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n6) , + (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n12), + (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n23), + (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n31), + (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n45), + (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n56), + (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n64), + (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n14), + (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n25), + (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n36), + (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n1245), + (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n2356), + (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n1346), + ID); +} + +//======================================================================= +//function : AddVolumeWithID +//purpose : 2d order Pentahedron (prism) with 18 nodes +//======================================================================= +SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1, + const SMDS_MeshNode * n2, + const SMDS_MeshNode * n3, + const SMDS_MeshNode * n4, + const SMDS_MeshNode * n5, + const SMDS_MeshNode * n6, + const SMDS_MeshNode * n12, + const SMDS_MeshNode * n23, + const SMDS_MeshNode * n31, + const SMDS_MeshNode * n45, + const SMDS_MeshNode * n56, + const SMDS_MeshNode * n64, + const SMDS_MeshNode * n14, + const SMDS_MeshNode * n25, + const SMDS_MeshNode * n36, + const SMDS_MeshNode * n1245, + const SMDS_MeshNode * n2356, + const SMDS_MeshNode * n1346, + int ID) +{ + //MESSAGE("AddVolumeWithID penta18 "<< ID); + if (!n1 || !n2 || !n3 || !n4 || !n5 || !n6 || !n12 || !n23 || + !n31 || !n45 || !n56 || !n64 || !n14 || !n25 || !n36 || !n1245 || !n2356 || !n1346) + return 0; + if(hasConstructionFaces()) { + // creation quadratic faces - not implemented + return 0; + } + // --- retrieve nodes ID + myNodeIds.resize(18); + myNodeIds[0] = n1->getVtkId(); + myNodeIds[1] = n2->getVtkId(); + myNodeIds[2] = n3->getVtkId(); + + myNodeIds[3] = n4->getVtkId(); + myNodeIds[4] = n5->getVtkId(); + myNodeIds[5] = n6->getVtkId(); + + myNodeIds[6] = n12->getVtkId(); + myNodeIds[7] = n23->getVtkId(); + myNodeIds[8] = n31->getVtkId(); + + myNodeIds[9] = n45->getVtkId(); + myNodeIds[10] = n56->getVtkId(); + myNodeIds[11] = n64->getVtkId(); + + myNodeIds[12] = n14->getVtkId(); + myNodeIds[13] = n25->getVtkId(); + myNodeIds[14] = n36->getVtkId(); + + myNodeIds[15] = n1245->getVtkId(); + myNodeIds[16] = n2356->getVtkId(); + myNodeIds[17] = n1346->getVtkId(); + + SMDS_VtkVolume *volvtk = myVolumePool->getNew(); + volvtk->init(myNodeIds, this); + if (!this->registerElement(ID,volvtk)) + { + this->myGrid->GetCellTypesArray()->SetValue(volvtk->getVtkId(), VTK_EMPTY_CELL); + myVolumePool->destroy(volvtk); + return 0; + } + adjustmyCellsCapacity(ID); + myCells[ID] = volvtk; + myInfo.myNbBiQuadPrisms++; + + // if (!registerElement(ID, volvtk)) { + // RemoveElement(volvtk, false); + // volvtk = NULL; + // } + return volvtk; +} + //======================================================================= //function : AddVolume @@ -4687,93 +4806,49 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1, return volvtk; } - -void SMDS_Mesh::updateNodeMinMax() -{ - myNodeMin = 0; - if (myNodes.size() == 0) - { - myNodeMax=0; - return; - } - while ( !myNodes[myNodeMin] && myNodeMin < (int)myNodes.size() ) - myNodeMin++; - myNodeMax=myNodes.size()-1; - while (!myNodes[myNodeMax] && (myNodeMin>=0)) - myNodeMin--; -} - -void SMDS_Mesh::incrementNodesCapacity(int nbNodes) -{ -// int val = myCellIdSmdsToVtk.size(); -// 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::adjustStructure() -{ - myGrid->GetPoints()->GetData()->SetNumberOfTuples(myNodeIDFactory->GetMaxID()); -} - 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; 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; + 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->GetLinks(); 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; jmyCompactTime = this->myModifTime; } int SMDS_Mesh::fromVtkToSmds(int vtkid) @@ -4791,28 +4866,28 @@ int SMDS_Mesh::fromVtkToSmds(int vtkid) throw SALOME_Exception(LOCALIZED ("vtk id out of bounds")); } -void SMDS_Mesh::updateBoundingBox() -{ - xmin = 0; xmax = 0; - ymin = 0; ymax = 0; - zmin = 0; zmax = 0; - vtkPoints *points = myGrid->GetPoints(); - int myNodesSize = this->myNodes.size(); - for (int i = 0; i < myNodesSize; i++) - { - if (SMDS_MeshNode *n = myNodes[i]) - { - double coords[3]; - points->GetPoint(n->myVtkID, coords); - if (coords[0] < xmin) xmin = coords[0]; - else if (coords[0] > xmax) xmax = coords[0]; - if (coords[1] < ymin) ymin = coords[1]; - else if (coords[1] > ymax) ymax = coords[1]; - if (coords[2] < zmin) zmin = coords[2]; - else if (coords[2] > zmax) zmax = coords[2]; - } - } -} +// void SMDS_Mesh::updateBoundingBox() +// { +// xmin = 0; xmax = 0; +// ymin = 0; ymax = 0; +// zmin = 0; zmax = 0; +// vtkPoints *points = myGrid->GetPoints(); +// int myNodesSize = this->myNodes.size(); +// for (int i = 0; i < myNodesSize; i++) +// { +// if (SMDS_MeshNode *n = myNodes[i]) +// { +// double coords[3]; +// points->GetPoint(n->myVtkID, coords); +// if (coords[0] < xmin) xmin = coords[0]; +// else if (coords[0] > xmax) xmax = coords[0]; +// if (coords[1] < ymin) ymin = coords[1]; +// else if (coords[1] > ymax) ymax = coords[1]; +// if (coords[2] < zmin) zmin = coords[2]; +// else if (coords[2] > zmax) zmax = coords[2]; +// } +// } +// } double SMDS_Mesh::getMaxDim() { @@ -4820,7 +4895,6 @@ double SMDS_Mesh::getMaxDim() 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; } @@ -4828,26 +4902,19 @@ double SMDS_Mesh::getMaxDim() void SMDS_Mesh::Modified() { if (this->myModified) - { - this->myModifTime++; - MESSAGE("modified"); - myModified = false; - } + { + this->myModifTime++; + myModified = false; + } } //! get last modification timeStamp -unsigned long SMDS_Mesh::GetMTime() const +vtkMTimeType SMDS_Mesh::GetMTime() const { return this->myModifTime; } bool SMDS_Mesh::isCompacted() { - if (this->myModifTime > this->myCompactTime) - { - MESSAGE(" *** isCompacted " << myCompactTime << " < " << myModifTime); - this->myCompactTime = this->myModifTime; - return false; - } - return true; + return this->myCompactTime == this->myModifTime; }