From 6cf440ddd4db6833af295e1cf0fe329e7a55ce14 Mon Sep 17 00:00:00 2001 From: prascle Date: Thu, 24 Sep 2009 12:26:05 +0000 Subject: [PATCH] PR: test of use of vtk structures in SMDS, first part: only nodes, tested only with hexahedrons. --- adm_local/unix/config_files/check_qwt.m4 | 3 + doc/salome/tui/doxyfile.in | 46 +- src/Controls/Makefile.am | 1 + src/Controls/SMESH_Controls.cxx | 6 +- src/DriverDAT/Makefile.am | 1 + src/DriverMED/Makefile.am | 1 + src/DriverSTL/Makefile.am | 1 + src/DriverUNV/Makefile.am | 1 + src/SMDS/Makefile.am | 4 + src/SMDS/SMDS_Mesh.cxx | 550 ++++++++++++++--------- src/SMDS/SMDS_Mesh.hxx | 56 ++- src/SMDS/SMDS_Mesh0DElement.cxx | 4 +- src/SMDS/SMDS_Mesh0DElement.hxx | 2 +- src/SMDS/SMDS_MeshEdge.cxx | 2 + src/SMDS/SMDS_MeshEdge.hxx | 2 +- src/SMDS/SMDS_MeshElement.cxx | 10 + src/SMDS/SMDS_MeshElement.hxx | 31 +- src/SMDS/SMDS_MeshElementIDFactory.cxx | 167 ++++--- src/SMDS/SMDS_MeshElementIDFactory.hxx | 22 +- src/SMDS/SMDS_MeshFace.hxx | 2 +- src/SMDS/SMDS_MeshIDFactory.cxx | 30 +- src/SMDS/SMDS_MeshIDFactory.hxx | 14 +- src/SMDS/SMDS_MeshNode.cxx | 214 ++++++--- src/SMDS/SMDS_MeshNode.hxx | 7 +- src/SMDS/SMDS_MeshVolume.hxx | 2 +- src/SMESH/Makefile.am | 1 + src/SMESH/SMESH_Gen.cxx | 7 + src/SMESHClient/Makefile.am | 1 + src/SMESHDS/Makefile.am | 1 + src/SMESH_I/Makefile.am | 1 + src/SMESH_I/SMESH_Gen_i.cxx | 2 + src/SMESH_I/SMESH_Mesh_i.cxx | 88 ++-- src/StdMeshers/Makefile.am | 1 + src/StdMeshers_I/Makefile.am | 1 + 34 files changed, 811 insertions(+), 471 deletions(-) diff --git a/adm_local/unix/config_files/check_qwt.m4 b/adm_local/unix/config_files/check_qwt.m4 index c62506993..7fde4754c 100644 --- a/adm_local/unix/config_files/check_qwt.m4 +++ b/adm_local/unix/config_files/check_qwt.m4 @@ -76,6 +76,9 @@ if test -z $QWTHOME; then if test ! -f $QWT_INCDIR/qwt.h ; then QWT_INCDIR=/usr/lib/qt4/include/qwt fi + if test ! -f $QWT_INCDIR/qwt.h ; then + QWT_INCDIR=/usr/include/qwt-qt4 + fi fi else qwt_ok=no diff --git a/doc/salome/tui/doxyfile.in b/doc/salome/tui/doxyfile.in index bd927280e..787e16464 100755 --- a/doc/salome/tui/doxyfile.in +++ b/doc/salome/tui/doxyfile.in @@ -31,7 +31,7 @@ CREATE_SUBDIRS = NO OUTPUT_LANGUAGE = English USE_WINDOWS_ENCODING = NO BRIEF_MEMBER_DESC = YES -REPEAT_BRIEF = NO +REPEAT_BRIEF = YES ABBREVIATE_BRIEF = ALWAYS_DETAILED_SEC = YES INLINE_INHERITED_MEMB = YES @@ -69,7 +69,7 @@ CASE_SENSE_NAMES = YES HIDE_SCOPE_NAMES = NO SHOW_INCLUDE_FILES = YES INLINE_INFO = YES -SORT_MEMBER_DOCS = NO +SORT_MEMBER_DOCS = YES SORT_BRIEF_DOCS = NO SORT_BY_SCOPE_NAME = NO GENERATE_TODOLIST = YES @@ -91,7 +91,7 @@ WARN_IF_UNDOCUMENTED = YES WARN_IF_DOC_ERROR = YES WARN_NO_PARAMDOC = NO WARN_FORMAT = "$file:$line: $text" -WARN_LOGFILE = +WARN_LOGFILE = log.txt #--------------------------------------------------------------------------- # configuration options related to the input files @@ -116,19 +116,19 @@ FILTER_SOURCE_FILES = YES #--------------------------------------------------------------------------- # configuration options related to source browsing #--------------------------------------------------------------------------- -SOURCE_BROWSER = NO -INLINE_SOURCES = NO +SOURCE_BROWSER = YES +INLINE_SOURCES = YES STRIP_CODE_COMMENTS = YES -REFERENCED_BY_RELATION = NO +REFERENCED_BY_RELATION = YES REFERENCES_RELATION = YES -USE_HTAGS = NO +#USE_HTAGS = NO VERBATIM_HEADERS = YES #--------------------------------------------------------------------------- # configuration options related to the alphabetical class index #--------------------------------------------------------------------------- ALPHABETICAL_INDEX = YES -COLS_IN_ALPHA_INDEX = 3 +COLS_IN_ALPHA_INDEX = 2 IGNORE_PREFIX = #--------------------------------------------------------------------------- @@ -137,19 +137,19 @@ IGNORE_PREFIX = GENERATE_HTML = YES HTML_OUTPUT = . HTML_FILE_EXTENSION = .html -HTML_HEADER = @srcdir@/static/myheader.html -HTML_FOOTER = @srcdir@/static/footer.html -HTML_STYLESHEET = @srcdir@/static/doxygen.css +#HTML_HEADER = @srcdir@/static/myheader.html +#HTML_FOOTER = @srcdir@/static/footer.html +#HTML_STYLESHEET = @srcdir@/static/doxygen.css HTML_ALIGN_MEMBERS = YES GENERATE_HTMLHELP = NO CHM_FILE = HHC_LOCATION = GENERATE_CHI = NO -BINARY_TOC = YES -TOC_EXPAND = YES +BINARY_TOC = NO +TOC_EXPAND = NO DISABLE_INDEX = NO ENUM_VALUES_PER_LINE = 4 -GENERATE_TREEVIEW = NO +GENERATE_TREEVIEW = YES TREEVIEW_WIDTH = 250 #--------------------------------------------------------------------------- @@ -212,14 +212,14 @@ PERLMOD_MAKEVAR_PREFIX = # Configuration options related to the preprocessor #--------------------------------------------------------------------------- ENABLE_PREPROCESSING = YES -MACRO_EXPANSION = NO +MACRO_EXPANSION = YES EXPAND_ONLY_PREDEF = NO SEARCH_INCLUDES = YES INCLUDE_PATH = INCLUDE_FILE_PATTERNS = PREDEFINED = EXPAND_AS_DEFINED = -SKIP_FUNCTION_MACROS = NO +SKIP_FUNCTION_MACROS = YES #--------------------------------------------------------------------------- # Configuration::additions related to external references @@ -237,24 +237,24 @@ CLASS_DIAGRAMS = YES HIDE_UNDOC_RELATIONS = NO HAVE_DOT = YES CLASS_GRAPH = YES -COLLABORATION_GRAPH = NO -GROUP_GRAPHS = NO +COLLABORATION_GRAPH = YES +GROUP_GRAPHS = YES UML_LOOK = NO TEMPLATE_RELATIONS = YES INCLUDE_GRAPH = YES -INCLUDED_BY_GRAPH = NO +INCLUDED_BY_GRAPH = YES CALL_GRAPH = NO GRAPHICAL_HIERARCHY = YES DIRECTORY_GRAPH = YES -DOT_IMAGE_FORMAT = jpg +DOT_IMAGE_FORMAT = png DOT_PATH = DOTFILE_DIRS = MAX_DOT_GRAPH_WIDTH = 1024 -MAX_DOT_GRAPH_HEIGHT = 1200 -MAX_DOT_GRAPH_DEPTH = 0 +MAX_DOT_GRAPH_HEIGHT = 1024 +MAX_DOT_GRAPH_DEPTH = 1000 DOT_TRANSPARENT = NO DOT_MULTI_TARGETS = NO -GENERATE_LEGEND = NO +GENERATE_LEGEND = YES DOT_CLEANUP = YES #--------------------------------------------------------------------------- diff --git a/src/Controls/Makefile.am b/src/Controls/Makefile.am index 90707cadb..05d06b465 100644 --- a/src/Controls/Makefile.am +++ b/src/Controls/Makefile.am @@ -45,6 +45,7 @@ dist_SMESHControls_SOURCES = \ # additionnal information to compil and link file libSMESHControls_la_CPPFLAGS = \ $(CAS_CPPFLAGS) \ + $(VTK_INCLUDES) \ $(BOOST_CPPFLAGS) \ $(KERNEL_CXXFLAGS) \ -I$(srcdir)/../SMDS \ diff --git a/src/Controls/SMESH_Controls.cxx b/src/Controls/SMESH_Controls.cxx index 2ae7f399b..cc390e500 100644 --- a/src/Controls/SMESH_Controls.cxx +++ b/src/Controls/SMESH_Controls.cxx @@ -2815,7 +2815,7 @@ void ManifoldPart::expandBoundary void ManifoldPart::getFacesByLink( const ManifoldPart::Link& theLink, ManifoldPart::TVectorOfFacePtr& theFaces ) const { - SMDS_Mesh::SetOfFaces aSetOfFaces; + std::set aSetOfFaces; // take all faces that shared first node SMDS_ElemIteratorPtr anItr = theLink.myNode1->facesIterator(); for ( ; anItr->more(); ) @@ -2823,7 +2823,7 @@ void ManifoldPart::getFacesByLink( const ManifoldPart::Link& theLink, SMDS_MeshFace* aFace = (SMDS_MeshFace*)anItr->next(); if ( !aFace ) continue; - aSetOfFaces.Add( aFace ); + aSetOfFaces.insert( aFace ); } // take all faces that shared second node anItr = theLink.myNode2->facesIterator(); @@ -2831,7 +2831,7 @@ void ManifoldPart::getFacesByLink( const ManifoldPart::Link& theLink, for ( ; anItr->more(); ) { SMDS_MeshFace* aFace = (SMDS_MeshFace*)anItr->next(); - if ( aSetOfFaces.Contains( aFace ) ) + if ( aSetOfFaces.count( aFace ) ) theFaces.push_back( aFace ); } } diff --git a/src/DriverDAT/Makefile.am b/src/DriverDAT/Makefile.am index 2a9973796..e681fa4f0 100644 --- a/src/DriverDAT/Makefile.am +++ b/src/DriverDAT/Makefile.am @@ -58,6 +58,7 @@ dist_DAT_Test_SOURCES = \ libMeshDriverDAT_la_CPPFLAGS = \ $(KERNEL_CXXFLAGS) \ $(CAS_CPPFLAGS) \ + $(VTK_INCLUDES) \ $(BOOST_CPPFLAGS) \ -I$(srcdir)/../Driver \ -I$(srcdir)/../SMDS \ diff --git a/src/DriverMED/Makefile.am b/src/DriverMED/Makefile.am index 79da654fb..e70d83000 100644 --- a/src/DriverMED/Makefile.am +++ b/src/DriverMED/Makefile.am @@ -63,6 +63,7 @@ libMeshDriverMED_la_CPPFLAGS = \ @HDF5_INCLUDES@ \ $(KERNEL_CXXFLAGS) \ $(CAS_CPPFLAGS) \ + $(VTK_INCLUDES) \ $(BOOST_CPPFLAGS) \ -I$(srcdir)/../Driver \ -I$(srcdir)/../SMDS \ diff --git a/src/DriverSTL/Makefile.am b/src/DriverSTL/Makefile.am index aa49c013c..af0c75aa8 100644 --- a/src/DriverSTL/Makefile.am +++ b/src/DriverSTL/Makefile.am @@ -52,6 +52,7 @@ dist_STL_Test_SOURCES = \ libMeshDriverSTL_la_CPPFLAGS = \ $(KERNEL_CXXFLAGS) \ $(CAS_CPPFLAGS) \ + $(VTK_INCLUDES) \ $(BOOST_CPPFLAGS) \ -I$(srcdir)/../Driver \ -I$(srcdir)/../SMDS diff --git a/src/DriverUNV/Makefile.am b/src/DriverUNV/Makefile.am index 5b5775f6d..ba6910285 100644 --- a/src/DriverUNV/Makefile.am +++ b/src/DriverUNV/Makefile.am @@ -71,6 +71,7 @@ libMeshDriverUNV_la_CPPFLAGS = \ $(CAS_CPPFLAGS) \ $(CORBA_CXXFLAGS) \ $(CORBA_INCLUDES) \ + $(VTK_INCLUDES) \ $(BOOST_CPPFLAGS) \ -I$(srcdir)/../Driver \ -I$(srcdir)/../SMDS \ diff --git a/src/SMDS/Makefile.am b/src/SMDS/Makefile.am index 56ad4fc65..2e8347604 100644 --- a/src/SMDS/Makefile.am +++ b/src/SMDS/Makefile.am @@ -43,6 +43,7 @@ salomeinclude_HEADERS = \ SMDS_MeshGroup.hxx \ SMDS_MeshIDFactory.hxx \ SMDS_MeshNode.hxx \ + SMDS_MeshNodeIDFactory.hxx \ SMDS_MeshObject.hxx \ SMDS_MeshVolume.hxx \ SMDS_Position.hxx \ @@ -81,6 +82,7 @@ dist_libSMDS_la_SOURCES = \ SMDS_MeshEdge.cxx \ SMDS_MeshFace.cxx \ SMDS_MeshVolume.cxx \ + SMDS_MeshNodeIDFactory.cxx \ SMDS_MeshElementIDFactory.cxx \ SMDS_MeshGroup.cxx \ SMDS_MeshIDFactory.cxx \ @@ -101,9 +103,11 @@ dist_libSMDS_la_SOURCES = \ libSMDS_la_CPPFLAGS = \ $(KERNEL_CXXFLAGS) \ $(CAS_CPPFLAGS) \ + $(VTK_INCLUDES) \ $(BOOST_CPPFLAGS) libSMDS_la_LDFLAGS = \ + $(VTK_LIBS) \ $(KERNEL_LDFLAGS) -lSALOMELocalTrace \ $(CAS_KERNEL) diff --git a/src/SMDS/SMDS_Mesh.cxx b/src/SMDS/SMDS_Mesh.cxx index 890ed0c47..693fd38fd 100644 --- a/src/SMDS/SMDS_Mesh.cxx +++ b/src/SMDS/SMDS_Mesh.cxx @@ -37,6 +37,8 @@ #include "SMDS_QuadraticFaceOfNodes.hxx" #include "SMDS_QuadraticVolumeOfNodes.hxx" +#include + #include #include using namespace std; @@ -48,6 +50,9 @@ using namespace std; // number of added entitis to check memory after #define CHECKMEMORY_INTERVAL 1000 +vector SMDS_Mesh::_meshList = vector(); +int SMDS_Mesh::chunkSize = 1000; + //================================================================================ /*! * \brief Raise an exception if free memory (ram+swap) too low @@ -104,11 +109,27 @@ int SMDS_Mesh::CheckMemory(const bool doNotRaise) throw (std::bad_alloc) /////////////////////////////////////////////////////////////////////////////// SMDS_Mesh::SMDS_Mesh() :myParent(NULL), - myNodeIDFactory(new SMDS_MeshElementIDFactory()), - myElementIDFactory(new SMDS_MeshElementIDFactory()), - myHasConstructionEdges(false), myHasConstructionFaces(false), - myHasInverseElements(true) + myNodeIDFactory(new SMDS_MeshNodeIDFactory()), + myElementIDFactory(new SMDS_MeshElementIDFactory()), + myHasConstructionEdges(false), myHasConstructionFaces(false), + myHasInverseElements(true), + myNodeMin(0), myNodeMax(0), myCellLinksSize(0) { + myMeshId = _meshList.size(); // --- index of the mesh to push back in the vector + MESSAGE("myMeshId=" << myMeshId); + myNodeIDFactory->SetMesh(this); + myElementIDFactory->SetMesh(this); + _meshList.push_back(this); + myNodes.clear(); + myCells.clear(); + myGrid = vtkUnstructuredGrid::New(); + myGrid->Initialize(); + myGrid->Allocate(); + vtkPoints* points = vtkPoints::New(); + points->SetNumberOfPoints(SMDS_Mesh::chunkSize); + myGrid->SetPoints( points ); + points->Delete(); + myGrid->BuildLinks(); } /////////////////////////////////////////////////////////////////////////////// @@ -156,9 +177,14 @@ 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){ - if ( myNodes.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory(); - SMDS_MeshNode * node=new SMDS_MeshNode(x, y, z); - myNodes.Add(node); + //if ( myNodes.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory(); + SMDS_MeshNode * node=new SMDS_MeshNode(ID, myMeshId, -1, x, y, z); + if (ID >= myNodes.size()) + { + myNodes.resize(ID+SMDS_Mesh::chunkSize, 0); + //MESSAGE(" ------------------ myNodes resize " << ID << " --> " << ID+SMDS_Mesh::chunkSize); + } + myNodes[ID] = node; myNodeIDFactory->BindID(ID,node); myInfo.myNbNodes++; return node; @@ -197,13 +223,14 @@ SMDS_Mesh0DElement* SMDS_Mesh::Add0DElementWithID(const SMDS_MeshNode * n, int I { if (!n) return 0; - if (my0DElements.Extent() % CHECKMEMORY_INTERVAL == 0) CheckMemory(); - + //if (my0DElements.Extent() % CHECKMEMORY_INTERVAL == 0) CheckMemory(); + //MESSAGE("Add0DElementWithID" << ID) SMDS_Mesh0DElement * el0d = new SMDS_Mesh0DElement(n); if (myElementIDFactory->BindID(ID, el0d)) { SMDS_MeshNode *node = const_cast(n); - node->AddInverseElement(el0d); - my0DElements.Add(el0d); + //node->AddInverseElement(el0d);// --- fait avec BindID + adjustmyCellsCapacity(ID); + myCells[ID] = el0d; myInfo.myNb0DElements++; return el0d; } @@ -251,23 +278,19 @@ SMDS_MeshEdge* SMDS_Mesh::AddEdgeWithID(const SMDS_MeshNode * n1, { if ( !n1 || !n2 ) return 0; - if ( myEdges.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory(); - + //if ( myEdges.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory(); + //MESSAGE("AddEdgeWithID " << ID) SMDS_MeshEdge * edge=new SMDS_MeshEdge(n1,n2); - if(myElementIDFactory->BindID(ID, edge)) { - SMDS_MeshNode *node1,*node2; - node1=const_cast(n1); - node2=const_cast(n2); - node1->AddInverseElement(edge); - node2->AddInverseElement(edge); - myEdges.Add(edge); - myInfo.myNbEdges++; - return edge; - } - else { - delete edge; - return NULL; + adjustmyCellsCapacity(ID); + myCells[ID] = edge; + myInfo.myNbEdges++; + + if (edge && !registerElement(ID, edge)) + { + RemoveElement(edge, false); + edge = NULL; } + return edge; } /////////////////////////////////////////////////////////////////////////////// @@ -304,6 +327,7 @@ SMDS_MeshFace* SMDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1, const SMDS_MeshNode * n3, int ID) { + //MESSAGE("AddFaceWithID " << ID) SMDS_MeshFace * face=createTriangle(n1, n2, n3); if (face && !registerElement(ID, face)) { @@ -355,7 +379,8 @@ SMDS_MeshFace* SMDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1, const SMDS_MeshNode * n4, int ID) { - SMDS_MeshFace * face=createQuadrangle(n1, n2, n3, n4); + //MESSAGE("AddFaceWithID " << ID); + SMDS_MeshFace * face=createQuadrangle(n1, n2, n3, n4, ID); if (face && !registerElement(ID, face)) { RemoveElement(face, false); @@ -375,7 +400,8 @@ SMDS_MeshFace* SMDS_Mesh::AddFace(const SMDS_MeshEdge * e1, { if (!hasConstructionEdges()) return NULL; - return AddFaceWithID(e1,e2,e3, myElementIDFactory->GetFreeID()); + //MESSAGE("AddFaceWithID"); + return AddFaceWithID(e1,e2,e3, myElementIDFactory->GetFreeID()); } /////////////////////////////////////////////////////////////////////////////// @@ -391,10 +417,12 @@ SMDS_MeshFace* SMDS_Mesh::AddFaceWithID(const SMDS_MeshEdge * e1, return NULL; if ( !e1 || !e2 || !e3 ) return 0; - if ( myFaces.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory(); + //if ( myFaces.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory(); + //MESSAGE("AddFaceWithID" << ID); SMDS_MeshFace * face = new SMDS_FaceOfEdges(e1,e2,e3); - myFaces.Add(face); + adjustmyCellsCapacity(ID); + myCells[ID] = face; myInfo.myNbTriangles++; if (!registerElement(ID, face)) { @@ -416,7 +444,8 @@ SMDS_MeshFace* SMDS_Mesh::AddFace(const SMDS_MeshEdge * e1, { if (!hasConstructionEdges()) return NULL; - return AddFaceWithID(e1,e2,e3,e4, myElementIDFactory->GetFreeID()); + //MESSAGE("AddFaceWithID" ); + return AddFaceWithID(e1,e2,e3,e4, myElementIDFactory->GetFreeID()); } /////////////////////////////////////////////////////////////////////////////// @@ -431,10 +460,12 @@ SMDS_MeshFace* SMDS_Mesh::AddFaceWithID(const SMDS_MeshEdge * e1, { if (!hasConstructionEdges()) return NULL; + //MESSAGE("AddFaceWithID" << ID); if ( !e1 || !e2 || !e3 || !e4 ) return 0; - if ( myFaces.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory(); + //if ( myFaces.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory(); SMDS_MeshFace * face = new SMDS_FaceOfEdges(e1,e2,e3,e4); - myFaces.Add(face); + adjustmyCellsCapacity(ID); + myCells[ID] = face; myInfo.myNbQuadrangles++; if (!registerElement(ID, face)) @@ -456,6 +487,7 @@ 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; @@ -474,6 +506,7 @@ 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); @@ -495,16 +528,18 @@ 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 ( myVolumes.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory(); + //if ( myVolumes.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory(); if(hasConstructionFaces()) { SMDS_MeshFace * f1=FindFaceOrCreate(n1,n2,n3); SMDS_MeshFace * f2=FindFaceOrCreate(n1,n2,n4); SMDS_MeshFace * f3=FindFaceOrCreate(n1,n3,n4); SMDS_MeshFace * f4=FindFaceOrCreate(n2,n3,n4); volume=new SMDS_VolumeOfFaces(f1,f2,f3,f4); - myVolumes.Add(volume); + adjustmyCellsCapacity(ID); + myCells[ID] = volume; myInfo.myNbTetras++; } else if(hasConstructionEdges()) { @@ -513,7 +548,8 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1, } else { volume=new SMDS_VolumeOfNodes(n1,n2,n3,n4); - myVolumes.Add(volume); + adjustmyCellsCapacity(ID); + myCells[ID] = volume; myInfo.myNbTetras++; } @@ -537,6 +573,7 @@ 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; @@ -557,6 +594,7 @@ 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); @@ -581,16 +619,18 @@ 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 ( myVolumes.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory(); + //if ( myVolumes.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory(); if(hasConstructionFaces()) { SMDS_MeshFace * f1=FindFaceOrCreate(n1,n2,n3,n4); SMDS_MeshFace * f2=FindFaceOrCreate(n1,n2,n5); SMDS_MeshFace * f3=FindFaceOrCreate(n2,n3,n5); SMDS_MeshFace * f4=FindFaceOrCreate(n3,n4,n5); volume=new SMDS_VolumeOfFaces(f1,f2,f3,f4); - myVolumes.Add(volume); + adjustmyCellsCapacity(ID); + myCells[ID] = volume; myInfo.myNbPyramids++; } else if(hasConstructionEdges()) { @@ -599,7 +639,8 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1, } else { volume=new SMDS_VolumeOfNodes(n1,n2,n3,n4,n5); - myVolumes.Add(volume); + adjustmyCellsCapacity(ID); + myCells[ID] = volume; myInfo.myNbPyramids++; } @@ -624,6 +665,7 @@ 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; @@ -645,6 +687,7 @@ 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); @@ -671,9 +714,10 @@ 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 ( myVolumes.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory(); + //if ( myVolumes.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory(); if(hasConstructionFaces()) { SMDS_MeshFace * f1=FindFaceOrCreate(n1,n2,n3); SMDS_MeshFace * f2=FindFaceOrCreate(n4,n5,n6); @@ -681,7 +725,8 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1, SMDS_MeshFace * f4=FindFaceOrCreate(n2,n5,n6,n3); SMDS_MeshFace * f5=FindFaceOrCreate(n3,n6,n4,n1); volume=new SMDS_VolumeOfFaces(f1,f2,f3,f4,f5); - myVolumes.Add(volume); + adjustmyCellsCapacity(ID); + myCells[ID] = volume; myInfo.myNbPrisms++; } else if(hasConstructionEdges()) { @@ -690,7 +735,8 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1, } else { volume=new SMDS_VolumeOfNodes(n1,n2,n3,n4,n5,n6); - myVolumes.Add(volume); + adjustmyCellsCapacity(ID); + myCells[ID] = volume; myInfo.myNbPrisms++; } @@ -717,7 +763,8 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolume(const SMDS_MeshNode * n1, const SMDS_MeshNode * n8) { int ID = myElementIDFactory->GetFreeID(); - SMDS_MeshVolume * v = SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, n5, n6, n7, n8, ID); + //MESSAGE("AddVolumeWithID " << ID); + SMDS_MeshVolume * v = SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, n5, n6, n7, n8, ID); if(v==NULL) myElementIDFactory->ReleaseID(ID); return v; } @@ -740,6 +787,7 @@ 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); @@ -773,9 +821,10 @@ 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 ( myVolumes.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory(); + //if ( myVolumes.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory(); if(hasConstructionFaces()) { SMDS_MeshFace * f1=FindFaceOrCreate(n1,n2,n3,n4); SMDS_MeshFace * f2=FindFaceOrCreate(n5,n6,n7,n8); @@ -784,7 +833,8 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1, SMDS_MeshFace * f5=FindFaceOrCreate(n2,n3,n7,n6); SMDS_MeshFace * f6=FindFaceOrCreate(n3,n4,n8,n7); volume=new SMDS_VolumeOfFaces(f1,f2,f3,f4,f5,f6); - myVolumes.Add(volume); + adjustmyCellsCapacity(ID); + myCells[ID] = volume; myInfo.myNbHexas++; } else if(hasConstructionEdges()) { @@ -794,7 +844,8 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1, else { // volume=new SMDS_HexahedronOfNodes(n1,n2,n3,n4,n5,n6,n7,n8); volume=new SMDS_VolumeOfNodes(n1,n2,n3,n4,n5,n6,n7,n8); - myVolumes.Add(volume); + adjustmyCellsCapacity(ID); + myCells[ID] = volume; myInfo.myNbHexas++; } @@ -815,6 +866,7 @@ 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()); @@ -832,12 +884,14 @@ 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; - if ( myVolumes.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory(); + //if ( myVolumes.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory(); SMDS_MeshVolume * volume = new SMDS_VolumeOfFaces(f1,f2,f3,f4); - myVolumes.Add(volume); + adjustmyCellsCapacity(ID); + myCells[ID] = volume; myInfo.myNbTetras++; if (!registerElement(ID, volume)) { @@ -858,7 +912,8 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolume(const SMDS_MeshFace * f1, const SMDS_MeshFace * f4, const SMDS_MeshFace * f5) { - if (!hasConstructionFaces()) + //MESSAGE("AddVolumeWithID"); + if (!hasConstructionFaces()) return NULL; return AddVolumeWithID(f1,f2,f3,f4,f5, myElementIDFactory->GetFreeID()); } @@ -876,12 +931,14 @@ 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; - if ( myVolumes.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory(); + //if ( myVolumes.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory(); SMDS_MeshVolume * volume = new SMDS_VolumeOfFaces(f1,f2,f3,f4,f5); - myVolumes.Add(volume); + adjustmyCellsCapacity(ID); + myCells[ID] = volume; myInfo.myNbPyramids++; if (!registerElement(ID, volume)) { @@ -903,7 +960,8 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolume(const SMDS_MeshFace * f1, const SMDS_MeshFace * f5, const SMDS_MeshFace * f6) { - if (!hasConstructionFaces()) + //MESSAGE("AddVolumeWithID" ); + if (!hasConstructionFaces()) return NULL; return AddVolumeWithID(f1,f2,f3,f4,f5,f6, myElementIDFactory->GetFreeID()); } @@ -922,12 +980,14 @@ 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; - if ( myVolumes.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory(); + //if ( myVolumes.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory(); SMDS_MeshVolume * volume = new SMDS_VolumeOfFaces(f1,f2,f3,f4,f5,f6); - myVolumes.Add(volume); + adjustmyCellsCapacity(ID); + myCells[ID] = volume; myInfo.myNbPrisms++; if (!registerElement(ID, volume)) { @@ -963,7 +1023,7 @@ SMDS_MeshFace* SMDS_Mesh::AddPolygonalFaceWithID { SMDS_MeshFace * face; - if ( myFaces.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory(); + //if ( myFaces.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory(); if (hasConstructionEdges()) { MESSAGE("Error : Not implemented"); @@ -974,7 +1034,8 @@ SMDS_MeshFace* SMDS_Mesh::AddPolygonalFaceWithID for ( int i = 0; i < nodes.size(); ++i ) if ( !nodes[ i ] ) return 0; face = new SMDS_PolygonalFaceOfNodes(nodes); - myFaces.Add(face); + adjustmyCellsCapacity(ID); + myCells[ID] = face; myInfo.myNbPolygons++; } @@ -1028,7 +1089,7 @@ SMDS_MeshVolume* SMDS_Mesh::AddPolyhedralVolumeWithID const int ID) { SMDS_MeshVolume* volume; - if ( myVolumes.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory(); + //if ( myVolumes.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory(); if (hasConstructionFaces()) { MESSAGE("Error : Not implemented"); return NULL; @@ -1039,7 +1100,8 @@ SMDS_MeshVolume* SMDS_Mesh::AddPolyhedralVolumeWithID for ( int i = 0; i < nodes.size(); ++i ) if ( !nodes[ i ] ) return 0; volume = new SMDS_PolyhedralVolumeOfNodes(nodes, quantities); - myVolumes.Add(volume); + adjustmyCellsCapacity(ID); + myCells[ID] = volume; myInfo.myNbPolyhedrons++; } @@ -1070,15 +1132,11 @@ SMDS_MeshVolume* SMDS_Mesh::AddPolyhedralVolume /////////////////////////////////////////////////////////////////////////////// bool SMDS_Mesh::registerElement(int ID, SMDS_MeshElement * element) { + //MESSAGE("registerElement " << ID) if (myElementIDFactory->BindID(ID, element)) { - SMDS_ElemIteratorPtr it = element->nodesIterator(); - while (it->more()) { - SMDS_MeshNode *node = static_cast - (const_cast(it->next())); - node->AddInverseElement(element); - } return true; } + MESSAGE("BindID " << ID << " false!---------------"); return false; } @@ -1087,7 +1145,9 @@ bool SMDS_Mesh::registerElement(int ID, SMDS_MeshElement * element) /////////////////////////////////////////////////////////////////////////////// const SMDS_MeshNode * SMDS_Mesh::FindNode(int ID) const { - return (const SMDS_MeshNode *)myNodeIDFactory->MeshElement(ID); + if (ID <0 || ID >= myNodes.size()) + return NULL; + return (const SMDS_MeshNode *)myNodes[ID]; } /////////////////////////////////////////////////////////////////////////////// @@ -1099,7 +1159,7 @@ SMDS_MeshFace * SMDS_Mesh::createTriangle(const SMDS_MeshNode * node1, const SMDS_MeshNode * node3) { if ( !node1 || !node2 || !node3) return 0; - if ( myFaces.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory(); +// if ( myFaces.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory(); if(hasConstructionEdges()) { SMDS_MeshEdge *edge1, *edge2, *edge3; @@ -1107,15 +1167,19 @@ SMDS_MeshFace * SMDS_Mesh::createTriangle(const SMDS_MeshNode * node1, edge2=FindEdgeOrCreate(node2,node3); edge3=FindEdgeOrCreate(node3,node1); + int ID = myElementIDFactory->GetFreeID(); // -PR- voir si on range cet element SMDS_MeshFace * face = new SMDS_FaceOfEdges(edge1,edge2,edge3); - myFaces.Add(face); + adjustmyCellsCapacity(ID); + myCells[ID] = face; myInfo.myNbTriangles++; return face; } else { + int ID = myElementIDFactory->GetFreeID(); // -PR- voir si on range cet element SMDS_MeshFace * face = new SMDS_FaceOfNodes(node1,node2,node3); - myFaces.Add(face); + adjustmyCellsCapacity(ID); + myCells[ID] = face; myInfo.myNbTriangles++; return face; } @@ -1128,12 +1192,14 @@ SMDS_MeshFace * SMDS_Mesh::createTriangle(const SMDS_MeshNode * node1, SMDS_MeshFace * SMDS_Mesh::createQuadrangle(const SMDS_MeshNode * node1, const SMDS_MeshNode * node2, const SMDS_MeshNode * node3, - const SMDS_MeshNode * node4) + const SMDS_MeshNode * node4, + int ID) { if ( !node1 || !node2 || !node3 || !node4 ) return 0; - if ( myFaces.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory(); +// if ( myFaces.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory(); if(hasConstructionEdges()) { + //MESSAGE("createQuadrangle hasConstructionEdges "<< ID); SMDS_MeshEdge *edge1, *edge2, *edge3, *edge4; edge1=FindEdgeOrCreate(node1,node2); edge2=FindEdgeOrCreate(node2,node3); @@ -1141,14 +1207,17 @@ SMDS_MeshFace * SMDS_Mesh::createQuadrangle(const SMDS_MeshNode * node1, edge4=FindEdgeOrCreate(node4,node1); SMDS_MeshFace * face = new SMDS_FaceOfEdges(edge1,edge2,edge3,edge4); - myFaces.Add(face); + adjustmyCellsCapacity(ID); + myCells[ID] = face; myInfo.myNbQuadrangles++; return face; } else { + //MESSAGE("createQuadrangle " << ID); SMDS_MeshFace * face = new SMDS_FaceOfNodes(node1,node2,node3,node4); - myFaces.Add(face); + adjustmyCellsCapacity(ID); + myCells[ID] = face; myInfo.myNbQuadrangles++; return face; } @@ -1160,6 +1229,7 @@ SMDS_MeshFace * SMDS_Mesh::createQuadrangle(const SMDS_MeshNode * node1, void SMDS_Mesh::RemoveNode(const SMDS_MeshNode * node) { + MESSAGE("RemoveNode"); RemoveElement(node, true); } @@ -1169,6 +1239,7 @@ void SMDS_Mesh::RemoveNode(const SMDS_MeshNode * node) void SMDS_Mesh::Remove0DElement(const SMDS_Mesh0DElement * elem0d) { + MESSAGE("Remove0DElement"); RemoveElement(elem0d,true); } @@ -1178,6 +1249,7 @@ void SMDS_Mesh::Remove0DElement(const SMDS_Mesh0DElement * elem0d) void SMDS_Mesh::RemoveEdge(const SMDS_MeshEdge * edge) { + MESSAGE("RemoveEdge"); RemoveElement(edge,true); } @@ -1187,6 +1259,7 @@ void SMDS_Mesh::RemoveEdge(const SMDS_MeshEdge * edge) void SMDS_Mesh::RemoveFace(const SMDS_MeshFace * face) { + MESSAGE("RemoveFace"); RemoveElement(face, true); } @@ -1196,6 +1269,7 @@ void SMDS_Mesh::RemoveFace(const SMDS_MeshFace * face) void SMDS_Mesh::RemoveVolume(const SMDS_MeshVolume * volume) { + MESSAGE("RemoveVolume"); RemoveElement(volume, true); } @@ -1411,19 +1485,19 @@ const SMDS_Mesh0DElement* SMDS_Mesh::Find0DElement(const SMDS_MeshNode * node) //function : Find0DElementOrCreate //purpose : //======================================================================= -SMDS_Mesh0DElement* SMDS_Mesh::Find0DElementOrCreate(const SMDS_MeshNode * node) -{ - if (!node) return 0; - SMDS_Mesh0DElement * toReturn = NULL; - toReturn = const_cast(Find0DElement(node)); - if (toReturn == NULL) { - if (my0DElements.Extent() % CHECKMEMORY_INTERVAL == 0) CheckMemory(); - toReturn = new SMDS_Mesh0DElement(node); - my0DElements.Add(toReturn); - myInfo.myNb0DElements++; - } - return toReturn; -} +//SMDS_Mesh0DElement* SMDS_Mesh::Find0DElementOrCreate(const SMDS_MeshNode * node) +//{ +// if (!node) return 0; +// SMDS_Mesh0DElement * toReturn = NULL; +// toReturn = const_cast(Find0DElement(node)); +// if (toReturn == NULL) { +// //if (my0DElements.Extent() % CHECKMEMORY_INTERVAL == 0) CheckMemory(); +// toReturn = new SMDS_Mesh0DElement(node); +// my0DElements.Add(toReturn); +// myInfo.myNb0DElements++; +// } +// return toReturn; +//} //======================================================================= @@ -1474,9 +1548,11 @@ SMDS_MeshEdge* SMDS_Mesh::FindEdgeOrCreate(const SMDS_MeshNode * node1, SMDS_MeshEdge * toReturn=NULL; toReturn=const_cast(FindEdge(node1,node2)); if(toReturn==NULL) { - if ( myEdges.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory(); + //if ( myEdges.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory(); + int ID = myElementIDFactory->GetFreeID(); // -PR- voir si on range cet element + adjustmyCellsCapacity(ID); toReturn=new SMDS_MeshEdge(node1,node2); - myEdges.Add(toReturn); + myCells[ID] = toReturn; myInfo.myNbEdges++; } return toReturn; @@ -1631,7 +1707,8 @@ SMDS_MeshFace* SMDS_Mesh::FindFaceOrCreate(const SMDS_MeshNode *node1, SMDS_MeshFace * toReturn=NULL; toReturn=const_cast(FindFace(node1,node2,node3,node4)); if(toReturn==NULL) { - toReturn=createQuadrangle(node1,node2,node3,node4); + int ID = myElementIDFactory->GetFreeID(); + toReturn=createQuadrangle(node1,node2,node3,node4,ID); } return toReturn; } @@ -1755,7 +1832,9 @@ const SMDS_MeshFace* SMDS_Mesh::FindFace(const SMDS_MeshNode *node1, const SMDS_MeshElement* SMDS_Mesh::FindElement(int IDelem) const { - return myElementIDFactory->MeshElement(IDelem); + if ((IDelem < 0) || IDelem >= myCells.size()) + return 0; + return myCells[IDelem]; } //======================================================================= @@ -1806,7 +1885,7 @@ void SMDS_Mesh::DumpNodes() const { MESSAGE("dump nodes of mesh : "); SMDS_NodeIteratorPtr itnode=nodesIterator(); - while(itnode->more()) MESSAGE(itnode->next()); + while(itnode->more()) ; //MESSAGE(itnode->next()); } //======================================================================= @@ -1817,7 +1896,7 @@ void SMDS_Mesh::Dump0DElements() const { MESSAGE("dump 0D elements of mesh : "); SMDS_0DElementIteratorPtr it0d = elements0dIterator(); - while(it0d->more()) MESSAGE(it0d->next()); + while(it0d->more()) ; //MESSAGE(it0d->next()); } //======================================================================= @@ -1829,7 +1908,7 @@ void SMDS_Mesh::DumpEdges() const { MESSAGE("dump edges of mesh : "); SMDS_EdgeIteratorPtr itedge=edgesIterator(); - while(itedge->more()) MESSAGE(itedge->next()); + while(itedge->more()) ; //MESSAGE(itedge->next()); } //======================================================================= @@ -1841,7 +1920,7 @@ void SMDS_Mesh::DumpFaces() const { MESSAGE("dump faces of mesh : "); SMDS_FaceIteratorPtr itface=facesIterator(); - while(itface->more()) MESSAGE(itface->next()); + while(itface->more()) ; //MESSAGE(itface->next()); } //======================================================================= @@ -1853,7 +1932,7 @@ void SMDS_Mesh::DumpVolumes() const { MESSAGE("dump volumes of mesh : "); SMDS_VolumeIteratorPtr itvol=volumesIterator(); - while(itvol->more()) MESSAGE(itvol->next()); + while(itvol->more()) ; //MESSAGE(itvol->next()); } //======================================================================= @@ -1911,7 +1990,7 @@ void SMDS_Mesh::DebugStats() const /////////////////////////////////////////////////////////////////////////////// int SMDS_Mesh::NbNodes() const { - return myNodes.Size(); + return myNodes.size(); } /////////////////////////////////////////////////////////////////////////////// @@ -1919,7 +1998,7 @@ int SMDS_Mesh::NbNodes() const /////////////////////////////////////////////////////////////////////////////// int SMDS_Mesh::Nb0DElements() const { - return my0DElements.Size(); + return myInfo.Nb0DElements(); // -PR- a verfier } /////////////////////////////////////////////////////////////////////////////// @@ -1927,7 +2006,7 @@ int SMDS_Mesh::Nb0DElements() const /////////////////////////////////////////////////////////////////////////////// int SMDS_Mesh::NbEdges() const { - return myEdges.Size(); + return myInfo.NbEdges(); // -PR- a verfier } /////////////////////////////////////////////////////////////////////////////// @@ -1935,7 +2014,7 @@ int SMDS_Mesh::NbEdges() const /////////////////////////////////////////////////////////////////////////////// int SMDS_Mesh::NbFaces() const { - return myFaces.Size(); + return myInfo.NbFaces(); // -PR- a verfier } /////////////////////////////////////////////////////////////////////////////// @@ -1943,7 +2022,7 @@ int SMDS_Mesh::NbFaces() const /////////////////////////////////////////////////////////////////////////////// int SMDS_Mesh::NbVolumes() const { - return myVolumes.Size(); + return myInfo.NbVolumes(); // -PR- a verfier } /////////////////////////////////////////////////////////////////////////////// @@ -1984,37 +2063,37 @@ SMDS_Mesh::~SMDS_Mesh() myNodeIDFactory->ReleaseID(itn->next()->GetID()); } - SetOfNodes::Iterator itn(myNodes); - for (; itn.More(); itn.Next()) - delete itn.Value(); +// SetOfNodes::Iterator itn(myNodes); +// for (; itn.More(); itn.Next()) +// delete itn.Value(); - SetOf0DElements::Iterator it0d (my0DElements); - for (; it0d.More(); it0d.Next()) - { - SMDS_MeshElement* elem = it0d.Value(); - delete elem; - } +// SetOf0DElements::Iterator it0d (my0DElements); +// for (; it0d.More(); it0d.Next()) +// { +// SMDS_MeshElement* elem = it0d.Value(); +// delete elem; +// } - SetOfEdges::Iterator ite(myEdges); - for (; ite.More(); ite.Next()) - { - SMDS_MeshElement* elem = ite.Value(); - delete elem; - } +// SetOfEdges::Iterator ite(myEdges); +// for (; ite.More(); ite.Next()) +// { +// SMDS_MeshElement* elem = ite.Value(); +// delete elem; +// } - SetOfFaces::Iterator itf(myFaces); - for (; itf.More(); itf.Next()) - { - SMDS_MeshElement* elem = itf.Value(); - delete elem; - } +// SetOfFaces::Iterator itf(myFaces); +// for (; itf.More(); itf.Next()) +// { +// SMDS_MeshElement* elem = itf.Value(); +// delete elem; +// } - SetOfVolumes::Iterator itv(myVolumes); - for (; itv.More(); itv.Next()) - { - SMDS_MeshElement* elem = itv.Value(); - delete elem; - } +// SetOfVolumes::Iterator itv(myVolumes); +// for (; itv.More(); itv.Next()) +// { +// SMDS_MeshElement* elem = itv.Value(); +// delete elem; +// } } //================================================================================ @@ -2038,30 +2117,35 @@ void SMDS_Mesh::Clear() myElementIDFactory->Clear(); } - SMDS_VolumeIteratorPtr itv = volumesIterator(); + SMDS_ElemIteratorPtr itv = elementsIterator(); while (itv->more()) delete itv->next(); - myVolumes.Clear(); + myCells.clear(); - SMDS_FaceIteratorPtr itf = facesIterator(); - while (itf->more()) - delete itf->next(); - myFaces.Clear(); - - SMDS_EdgeIteratorPtr ite = edgesIterator(); - while (ite->more()) - delete ite->next(); - myEdges.Clear(); - - SMDS_0DElementIteratorPtr it0d = elements0dIterator(); - while (it0d->more()) - delete it0d->next(); - my0DElements.Clear(); +// SMDS_VolumeIteratorPtr itv = volumesIterator(); +// while (itv->more()) +// delete itv->next(); +// myVolumes.Clear(); +// +// SMDS_FaceIteratorPtr itf = facesIterator(); +// while (itf->more()) +// delete itf->next(); +// myFaces.Clear(); +// +// SMDS_EdgeIteratorPtr ite = edgesIterator(); +// while (ite->more()) +// delete ite->next(); +// myEdges.Clear(); +// +// SMDS_0DElementIteratorPtr it0d = elements0dIterator(); +// while (it0d->more()) +// delete it0d->next(); +// my0DElements.Clear(); SMDS_NodeIteratorPtr itn = nodesIterator(); while (itn->more()) delete itn->next(); - myNodes.Clear(); + myNodes.clear(); list::iterator itc=myChildren.begin(); while(itc!=myChildren.end()) @@ -2133,27 +2217,62 @@ void SMDS_Mesh::setInverseElements(bool b) ///Iterator on NCollection_Map /////////////////////////////////////////////////////////////////////////////// template -struct MYNCollection_Map_Iterator: public FATHER +struct MYNode_Map_Iterator: public FATHER { - typename MAP::Iterator myIterator; - - MYNCollection_Map_Iterator(const MAP& map):myIterator(map){} + int _ctr; + const MAP& _map; + MYNode_Map_Iterator(const MAP& map): _map(map) // map is a std::vector + { + _ctr = 0; + } bool more() { - while(myIterator.More()) - { - if(myIterator.Value()->GetID()!=-1) - return true; - myIterator.Next(); - } - return false; + while (_ctr < _map.size()) + { + if (_map[_ctr]) + return true; + _ctr++; + } + return false; } ELEM next() { - ELEM current = (ELEM) myIterator.Value(); - myIterator.Next(); + ELEM current = _map[_ctr]; + _ctr++; + return current; + } +}; + +template +struct MYElem_Map_Iterator: public FATHER +{ + int _ctr; + int _type; + const MAP& _map; + MYElem_Map_Iterator(const MAP& map, int typ): _map(map) // map is a std::vector + { + _ctr = 0; + _type = typ; + } + + bool more() + { + while (_ctr < _map.size()) + { + if (_map[_ctr]) + if ( (_type == SMDSAbs_All) || (_map[_ctr]->GetType() == _type)) + return true; + _ctr++; + } + return false; + } + + ELEM next() + { + ELEM current = dynamic_cast (_map[_ctr]); + _ctr++; return current; } }; @@ -2166,7 +2285,7 @@ SMDS_NodeIteratorPtr SMDS_Mesh::nodesIterator() const { //return SMDS_NodeIteratorPtr // (new SMDS_Mesh_MyNodeIterator(myNodeIDFactory->elementsIterator())); - typedef MYNCollection_Map_Iterator + typedef MYNode_Map_Iterator < SetOfNodes, const SMDS_MeshNode*, SMDS_NodeIterator > TIterator; return SMDS_NodeIteratorPtr(new TIterator(myNodes)); } @@ -2177,9 +2296,9 @@ SMDS_NodeIteratorPtr SMDS_Mesh::nodesIterator() const SMDS_0DElementIteratorPtr SMDS_Mesh::elements0dIterator() const { - typedef MYNCollection_Map_Iterator - < SetOf0DElements, const SMDS_Mesh0DElement*, SMDS_0DElementIterator > TIterator; - return SMDS_0DElementIteratorPtr(new TIterator(my0DElements)); + typedef MYElem_Map_Iterator + < SetOfCells, const SMDS_Mesh0DElement*, SMDS_0DElementIterator > TIterator; + return SMDS_0DElementIteratorPtr(new TIterator(myCells, SMDSAbs_0DElement)); } /////////////////////////////////////////////////////////////////////////////// @@ -2188,9 +2307,9 @@ SMDS_0DElementIteratorPtr SMDS_Mesh::elements0dIterator() const SMDS_EdgeIteratorPtr SMDS_Mesh::edgesIterator() const { - typedef MYNCollection_Map_Iterator - < SetOfEdges, const SMDS_MeshEdge*, SMDS_EdgeIterator > TIterator; - return SMDS_EdgeIteratorPtr(new TIterator(myEdges)); + typedef MYElem_Map_Iterator + < SetOfCells, const SMDS_MeshEdge*, SMDS_EdgeIterator > TIterator; + return SMDS_EdgeIteratorPtr(new TIterator(myCells, SMDSAbs_Edge)); } /////////////////////////////////////////////////////////////////////////////// @@ -2199,9 +2318,9 @@ SMDS_EdgeIteratorPtr SMDS_Mesh::edgesIterator() const SMDS_FaceIteratorPtr SMDS_Mesh::facesIterator() const { - typedef MYNCollection_Map_Iterator - < SetOfFaces, const SMDS_MeshFace*, SMDS_FaceIterator > TIterator; - return SMDS_FaceIteratorPtr(new TIterator(myFaces)); + typedef MYElem_Map_Iterator + < SetOfCells, const SMDS_MeshFace*, SMDS_FaceIterator > TIterator; + return SMDS_FaceIteratorPtr(new TIterator(myCells, SMDSAbs_Face)); } /////////////////////////////////////////////////////////////////////////////// @@ -2210,9 +2329,9 @@ SMDS_FaceIteratorPtr SMDS_Mesh::facesIterator() const SMDS_VolumeIteratorPtr SMDS_Mesh::volumesIterator() const { - typedef MYNCollection_Map_Iterator - < SetOfVolumes, const SMDS_MeshVolume*, SMDS_VolumeIterator > TIterator; - return SMDS_VolumeIteratorPtr(new TIterator(myVolumes)); + typedef MYElem_Map_Iterator + < SetOfCells, const SMDS_MeshVolume*, SMDS_VolumeIterator > TIterator; + return SMDS_VolumeIteratorPtr(new TIterator(myCells, SMDSAbs_Volume)); } /////////////////////////////////////////////////////////////////////////////// @@ -2222,17 +2341,19 @@ SMDS_ElemIteratorPtr SMDS_Mesh::elementsIterator(SMDSAbs_ElementType type) const { switch (type) { case SMDSAbs_All: + return SMDS_ElemIteratorPtr (new MYElem_Map_Iterator< SetOfCells >(myCells, SMDSAbs_All)); break; case SMDSAbs_Volume: - return SMDS_ElemIteratorPtr (new MYNCollection_Map_Iterator< SetOfVolumes >(myVolumes)); + return SMDS_ElemIteratorPtr (new MYElem_Map_Iterator< SetOfCells >(myCells, SMDSAbs_Volume)); case SMDSAbs_Face: - return SMDS_ElemIteratorPtr (new MYNCollection_Map_Iterator< SetOfFaces >(myFaces)); + return SMDS_ElemIteratorPtr (new MYElem_Map_Iterator< SetOfCells >(myCells, SMDSAbs_Face)); case SMDSAbs_Edge: - return SMDS_ElemIteratorPtr (new MYNCollection_Map_Iterator< SetOfEdges >(myEdges)); + return SMDS_ElemIteratorPtr (new MYElem_Map_Iterator< SetOfCells >(myCells, SMDSAbs_Edge)); case SMDSAbs_0DElement: - return SMDS_ElemIteratorPtr (new MYNCollection_Map_Iterator< SetOf0DElements >(my0DElements)); + return SMDS_ElemIteratorPtr (new MYElem_Map_Iterator< SetOfCells >(myCells, SMDSAbs_0DElement)); case SMDSAbs_Node: - return myNodeIDFactory->elementsIterator(); + return SMDS_ElemIteratorPtr (new MYElem_Map_Iterator< SetOfNodes >(myNodes, SMDSAbs_All)); + //return myNodeIDFactory->elementsIterator(); default:; } return myElementIDFactory->elementsIterator(); @@ -2461,24 +2582,19 @@ void SMDS_Mesh::RemoveElement(const SMDS_MeshElement * elem, MESSAGE("Internal Error: This should not happen"); break; case SMDSAbs_0DElement: - my0DElements.Remove(static_cast - (const_cast(*it))); - //myInfo.Remove0DElement(*it); + myCells[(*it)->GetID()] = 0; // -PR- ici ou dans myElementIDFactory->ReleaseID ? myInfo.remove(*it); break; case SMDSAbs_Edge: - myEdges.Remove(static_cast - (const_cast(*it))); + myCells[(*it)->GetID()] = 0; myInfo.RemoveEdge(*it); break; case SMDSAbs_Face: - myFaces.Remove(static_cast - (const_cast(*it))); + myCells[(*it)->GetID()] = 0; myInfo.RemoveFace(*it); break; case SMDSAbs_Volume: - myVolumes.Remove(static_cast - (const_cast(*it))); + myCells[(*it)->GetID()] = 0; myInfo.RemoveVolume(*it); break; } @@ -2496,8 +2612,7 @@ void SMDS_Mesh::RemoveElement(const SMDS_MeshElement * elem, while(it!=s2->end()) { //MESSAGE( "SMDS: RM node " << (*it)->GetID() ); - myNodes.Remove(static_cast - (const_cast(*it))); + myNodes[(*it)->GetID()] = 0; myInfo.myNbNodes--; myNodeIDFactory->ReleaseID((*it)->GetID()); removedNodes.push_back( (*it) ); @@ -2522,7 +2637,7 @@ void SMDS_Mesh::RemoveFreeElement(const SMDS_MeshElement * elem) const SMDS_MeshNode* n = static_cast(elem); SMDS_ElemIteratorPtr itFe = n->GetInverseElementIterator(); if (!itFe->more()) { // free node - myNodes.Remove(const_cast(n)); + myNodes[elem->GetID()] = 0; myInfo.myNbNodes--; myNodeIDFactory->ReleaseID(elem->GetID()); delete elem; @@ -2543,24 +2658,19 @@ void SMDS_Mesh::RemoveFreeElement(const SMDS_MeshElement * elem) // in meshes without descendants elements are always free switch (aType) { case SMDSAbs_0DElement: - my0DElements.Remove(static_cast - (const_cast(elem))); - //myInfo.Remove0DElement(elem); + myCells[elem->GetID()] = 0; myInfo.remove(elem); break; case SMDSAbs_Edge: - myEdges.Remove(static_cast - (const_cast(elem))); + myCells[elem->GetID()] = 0; myInfo.RemoveEdge(elem); break; case SMDSAbs_Face: - myFaces.Remove(static_cast - (const_cast(elem))); + myCells[elem->GetID()] = 0; myInfo.RemoveFace(elem); break; case SMDSAbs_Volume: - myVolumes.Remove(static_cast - (const_cast(elem))); + myCells[elem->GetID()] = 0; myInfo.RemoveVolume(elem); break; default: @@ -2609,7 +2719,7 @@ bool SMDS_Mesh::Contains (const SMDS_MeshElement* elem) const int SMDS_Mesh::MaxNodeID() const { - return myNodeIDFactory->GetMaxID(); + return myNodeMax; } //======================================================================= @@ -2619,7 +2729,7 @@ int SMDS_Mesh::MaxNodeID() const int SMDS_Mesh::MinNodeID() const { - return myNodeIDFactory->GetMinID(); + return myNodeMin; } //======================================================================= @@ -2649,10 +2759,11 @@ int SMDS_Mesh::MinElementID() const void SMDS_Mesh::Renumber (const bool isNodes, const int startID, const int deltaID) { + MESSAGE("Renumber"); if ( deltaID == 0 ) return; - SMDS_MeshElementIDFactory * idFactory = + SMDS_MeshNodeIDFactory * idFactory = isNodes ? myNodeIDFactory : myElementIDFactory; // get existing elements in the order of ID increasing @@ -2750,13 +2861,14 @@ SMDS_MeshEdge* SMDS_Mesh::AddEdgeWithID(const SMDS_MeshNode * n1, SMDS_QuadraticEdge* edge = new SMDS_QuadraticEdge(n1,n2,n12); if(myElementIDFactory->BindID(ID, edge)) { SMDS_MeshNode *node1,*node2, *node12; - node1 = const_cast(n1); - node2 = const_cast(n2); - node12 = const_cast(n12); - node1->AddInverseElement(edge); - node2->AddInverseElement(edge); - node12->AddInverseElement(edge); - myEdges.Add(edge); + //node1 = const_cast(n1); + //node2 = const_cast(n2); + //node12 = const_cast(n12); + //node1->AddInverseElement(edge); // --- fait avec BindID + //node2->AddInverseElement(edge); + //node12->AddInverseElement(edge); + adjustmyCellsCapacity(ID); + myCells[ID] = edge; myInfo.myNbQuadEdges++; return edge; } @@ -2818,7 +2930,8 @@ SMDS_MeshFace* SMDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1, } SMDS_QuadraticFaceOfNodes* face = new SMDS_QuadraticFaceOfNodes(n1,n2,n3,n12,n23,n31); - myFaces.Add(face); + adjustmyCellsCapacity(ID); + myCells[ID] = face; myInfo.myNbQuadTriangles++; if (!registerElement(ID, face)) { @@ -2885,7 +2998,8 @@ SMDS_MeshFace* SMDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1, } SMDS_QuadraticFaceOfNodes* face = new SMDS_QuadraticFaceOfNodes(n1,n2,n3,n4,n12,n23,n34,n41); - myFaces.Add(face); + adjustmyCellsCapacity(ID); + myCells[ID] = face; myInfo.myNbQuadQuadrangles++; if (!registerElement(ID, face)) { @@ -2964,7 +3078,8 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1, } SMDS_QuadraticVolumeOfNodes * volume = new SMDS_QuadraticVolumeOfNodes(n1,n2,n3,n4,n12,n23,n31,n14,n24,n34); - myVolumes.Add(volume); + adjustmyCellsCapacity(ID); + myCells[ID] = volume; myInfo.myNbQuadTetras++; if (!registerElement(ID, volume)) { @@ -3055,7 +3170,8 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1, SMDS_QuadraticVolumeOfNodes * volume = new SMDS_QuadraticVolumeOfNodes(n1,n2,n3,n4,n5,n12,n23, n34,n41,n15,n25,n35,n45); - myVolumes.Add(volume); + adjustmyCellsCapacity(ID); + myCells[ID] = volume; myInfo.myNbQuadPyramids++; if (!registerElement(ID, volume)) { @@ -3154,7 +3270,8 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1, SMDS_QuadraticVolumeOfNodes * volume = new SMDS_QuadraticVolumeOfNodes(n1,n2,n3,n4,n5,n6,n12,n23,n31, n45,n56,n64,n14,n25,n36); - myVolumes.Add(volume); + adjustmyCellsCapacity(ID); + myCells[ID] = volume; myInfo.myNbQuadPrisms++; if (!registerElement(ID, volume)) { @@ -3268,7 +3385,8 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1, SMDS_QuadraticVolumeOfNodes * volume = new SMDS_QuadraticVolumeOfNodes(n1,n2,n3,n4,n5,n6,n7,n8,n12,n23,n34,n41, n56,n67,n78,n85,n15,n26,n37,n48); - myVolumes.Add(volume); + adjustmyCellsCapacity(ID); + myCells[ID] = volume; myInfo.myNbQuadHexas++; if (!registerElement(ID, volume)) { @@ -3277,3 +3395,13 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1, } return volume; } + +void SMDS_Mesh::updateNodeMinMax() +{ + myNodeMin = 0; + while (!myNodes[myNodeMin] && (myNodeMin=0)) + myNodeMin--; +} diff --git a/src/SMDS/SMDS_Mesh.hxx b/src/SMDS/SMDS_Mesh.hxx index df4a2b356..8a68e9a1e 100644 --- a/src/SMDS/SMDS_Mesh.hxx +++ b/src/SMDS/SMDS_Mesh.hxx @@ -33,20 +33,28 @@ #include "SMDS_MeshEdge.hxx" #include "SMDS_MeshFace.hxx" #include "SMDS_MeshVolume.hxx" +#include "SMDS_MeshNodeIDFactory.hxx" #include "SMDS_MeshElementIDFactory.hxx" #include "SMDS_MeshInfo.hxx" #include "SMDS_ElemIterator.hxx" -#include #include #include #include +#include +#include + +class vtkUnstructuredGrid; class SMDS_EXPORT SMDS_Mesh:public SMDS_MeshObject{ public: + static std::vector _meshList; // --- to find the SMDS_mesh from its elements + SMDS_Mesh(); + inline vtkUnstructuredGrid* getGrid() {return myGrid; }; + SMDS_NodeIteratorPtr nodesIterator() const; SMDS_0DElementIteratorPtr elements0dIterator() const; SMDS_EdgeIteratorPtr edgesIterator() const; @@ -537,11 +545,15 @@ public: */ bool Contains (const SMDS_MeshElement* elem) const; - typedef NCollection_Map SetOfNodes; - typedef NCollection_Map SetOf0DElements; - typedef NCollection_Map SetOfEdges; - typedef NCollection_Map SetOfFaces; - typedef NCollection_Map SetOfVolumes; + typedef std::vector SetOfNodes; + typedef std::vector SetOfCells; + + void updateNodeMinMax(); + int fromVtkToSmds(int vtkid) { return myElementIDFactory->fromVtkToSmds(vtkid); }; + + int myCellLinksSize; + + static int chunkSize; private: SMDS_Mesh(SMDS_Mesh * parent); @@ -552,8 +564,9 @@ private: SMDS_MeshFace * createQuadrangle(const SMDS_MeshNode * node1, const SMDS_MeshNode * node2, const SMDS_MeshNode * node3, - const SMDS_MeshNode * node4); - SMDS_Mesh0DElement* Find0DElementOrCreate(const SMDS_MeshNode * n); + const SMDS_MeshNode * node4, + int ID); +// SMDS_Mesh0DElement* Find0DElementOrCreate(const SMDS_MeshNode * n); SMDS_MeshEdge* FindEdgeOrCreate(const SMDS_MeshNode * n1, const SMDS_MeshNode * n2); SMDS_MeshFace* FindFaceOrCreate(const SMDS_MeshNode *n1, @@ -570,19 +583,36 @@ private: const SMDS_MeshElement * element, std::set& nodes); + inline void adjustmyCellsCapacity(int ID) + { + assert(ID >= 0); + if (ID >= myCells.size()) + myCells.resize(ID+SMDS_Mesh::chunkSize,0); + }; + // Fields PRIVATE + int myMeshId; // --- index for this mesh in the vector + vtkUnstructuredGrid* myGrid; + + SetOfNodes myNodes; - SetOf0DElements my0DElements; - SetOfEdges myEdges; - SetOfFaces myFaces; - SetOfVolumes myVolumes; + SetOfCells myCells; + +// SetOf0DElements my0DElements; +// SetOfEdges myEdges; +// SetOfFaces myFaces; +// SetOfVolumes myVolumes; + SMDS_Mesh * myParent; std::list myChildren; - SMDS_MeshElementIDFactory *myNodeIDFactory; + SMDS_MeshNodeIDFactory *myNodeIDFactory; SMDS_MeshElementIDFactory *myElementIDFactory; SMDS_MeshInfo myInfo; + int myNodeMin; + int myNodeMax; + bool myHasConstructionEdges; bool myHasConstructionFaces; bool myHasInverseElements; diff --git a/src/SMDS/SMDS_Mesh0DElement.cxx b/src/SMDS/SMDS_Mesh0DElement.cxx index b4fbe8bc4..4eb47238d 100644 --- a/src/SMDS/SMDS_Mesh0DElement.cxx +++ b/src/SMDS/SMDS_Mesh0DElement.cxx @@ -31,6 +31,7 @@ #include "SMDS_Mesh0DElement.hxx" #include "SMDS_IteratorOfElements.hxx" #include "SMDS_MeshNode.hxx" +#include "utilities.h" using namespace std; @@ -39,7 +40,8 @@ using namespace std; //purpose : //======================================================================= SMDS_Mesh0DElement::SMDS_Mesh0DElement (const SMDS_MeshNode * node) -{ +{ + MESSAGE("SMDS_Mesh0DElement " << GetID()); myNode = node; } diff --git a/src/SMDS/SMDS_Mesh0DElement.hxx b/src/SMDS/SMDS_Mesh0DElement.hxx index b1be0b28f..b3273a6b1 100644 --- a/src/SMDS/SMDS_Mesh0DElement.hxx +++ b/src/SMDS/SMDS_Mesh0DElement.hxx @@ -32,7 +32,7 @@ #include -class SMDS_EXPORT SMDS_Mesh0DElement: public SMDS_MeshElement +class SMDS_EXPORT SMDS_Mesh0DElement: public SMDS_MeshCell { public: SMDS_Mesh0DElement (const SMDS_MeshNode * node); diff --git a/src/SMDS/SMDS_MeshEdge.cxx b/src/SMDS/SMDS_MeshEdge.cxx index 526236e80..96112df91 100644 --- a/src/SMDS/SMDS_MeshEdge.cxx +++ b/src/SMDS/SMDS_MeshEdge.cxx @@ -31,6 +31,7 @@ #include "SMDS_MeshEdge.hxx" #include "SMDS_IteratorOfElements.hxx" #include "SMDS_MeshNode.hxx" +#include "utilities.h" using namespace std; @@ -42,6 +43,7 @@ using namespace std; SMDS_MeshEdge::SMDS_MeshEdge(const SMDS_MeshNode * node1, const SMDS_MeshNode * node2) { + //MESSAGE("SMDS_MeshEdge " << GetID()); myNodes[0]=node1; myNodes[1]=node2; } diff --git a/src/SMDS/SMDS_MeshEdge.hxx b/src/SMDS/SMDS_MeshEdge.hxx index c0108c2e4..3edbd91d7 100644 --- a/src/SMDS/SMDS_MeshEdge.hxx +++ b/src/SMDS/SMDS_MeshEdge.hxx @@ -31,7 +31,7 @@ #include "SMDS_MeshElement.hxx" #include -class SMDS_EXPORT SMDS_MeshEdge:public SMDS_MeshElement +class SMDS_EXPORT SMDS_MeshEdge:public SMDS_MeshCell { public: diff --git a/src/SMDS/SMDS_MeshElement.cxx b/src/SMDS/SMDS_MeshElement.cxx index a24cbff94..5f1669885 100644 --- a/src/SMDS/SMDS_MeshElement.cxx +++ b/src/SMDS/SMDS_MeshElement.cxx @@ -38,6 +38,11 @@ SMDS_MeshElement::SMDS_MeshElement(int ID):myID(ID) { } +SMDS_MeshElement::SMDS_MeshElement(int id, UShortType meshId, ShortType shapeId): + myID(id), myMeshId(meshId), myShapeId(shapeId) +{ +} + void SMDS_MeshElement::Print(ostream & OS) const { OS << "dump of mesh element" << endl; @@ -238,3 +243,8 @@ int SMDS_MeshElement::GetNodeIndex( const SMDS_MeshNode* node ) const return i; return -1; } + +SMDS_MeshCell::SMDS_MeshCell() +{ + myVtkID = -1; +}; \ No newline at end of file diff --git a/src/SMDS/SMDS_MeshElement.hxx b/src/SMDS/SMDS_MeshElement.hxx index 5b52efbf7..eb0179ccc 100644 --- a/src/SMDS/SMDS_MeshElement.hxx +++ b/src/SMDS/SMDS_MeshElement.hxx @@ -36,6 +36,9 @@ #include #include +typedef unsigned short UShortType; +typedef short ShortType; + class SMDS_MeshNode; class SMDS_MeshEdge; class SMDS_MeshFace; @@ -116,14 +119,38 @@ public: */ int GetNodeIndex( const SMDS_MeshNode* node ) const; + inline int getId() {return myID; }; + inline UShortType getMeshId() {return myMeshId; }; + inline ShortType getshapeId() {return myShapeId; }; + inline void setShapeId(UShortType shapeId) {myShapeId = shapeId; }; + protected: SMDS_MeshElement(int ID=-1); + SMDS_MeshElement(int id, UShortType meshId, ShortType shapeId=-1); virtual void Print(std::ostream & OS) const; -private: - int myID; + int myID; // --- element index + UShortType myMeshId; + ShortType myShapeId; }; +// ============================================================ +/*! + * \brief Base class for all cells + */ +// ============================================================ + +class SMDS_EXPORT SMDS_MeshCell:public SMDS_MeshElement +{ +public: + SMDS_MeshCell(); + inline void setVtkId(int vtkId) { myVtkID = vtkId; }; + inline int getVtkId() const {return myVtkID; }; +protected: + int myVtkID; +}; + + // ============================================================ /*! * \brief Comparator of elements by ID for usage in std containers diff --git a/src/SMDS/SMDS_MeshElementIDFactory.cxx b/src/SMDS/SMDS_MeshElementIDFactory.cxx index 7ecfba5b0..2dd43e6d0 100644 --- a/src/SMDS/SMDS_MeshElementIDFactory.cxx +++ b/src/SMDS/SMDS_MeshElementIDFactory.cxx @@ -30,6 +30,12 @@ #include "SMDS_MeshElementIDFactory.hxx" #include "SMDS_MeshElement.hxx" +#include "SMDS_Mesh.hxx" + +#include "utilities.h" + +#include +#include using namespace std; @@ -38,9 +44,32 @@ using namespace std; //purpose : //======================================================================= SMDS_MeshElementIDFactory::SMDS_MeshElementIDFactory(): - SMDS_MeshIDFactory(), - myMin(0), myMax(0) + SMDS_MeshNodeIDFactory() { + myIDElements.clear(); + myVtkIndex.clear(); + myVtkCellTypes.clear(); + myVtkCellTypes.reserve(SMDSEntity_Last); + myVtkCellTypes[SMDSEntity_Node] = VTK_VERTEX; + myVtkCellTypes[SMDSEntity_0D] = VTK_VERTEX; + myVtkCellTypes[SMDSEntity_Edge] = VTK_LINE; + myVtkCellTypes[SMDSEntity_Quad_Edge] = VTK_QUADRATIC_EDGE; + myVtkCellTypes[SMDSEntity_Triangle] = VTK_TRIANGLE; + myVtkCellTypes[SMDSEntity_Quad_Triangle] = VTK_QUADRATIC_TRIANGLE; + myVtkCellTypes[SMDSEntity_Quadrangle] = VTK_QUAD; + myVtkCellTypes[SMDSEntity_Quad_Quadrangle] = VTK_QUADRATIC_TRIANGLE; + myVtkCellTypes[SMDSEntity_Polygon] = VTK_POLYGON; + myVtkCellTypes[SMDSEntity_Quad_Polygon] = VTK_POLYGON; // -PR- verifer + myVtkCellTypes[SMDSEntity_Tetra] = VTK_TETRA; + myVtkCellTypes[SMDSEntity_Quad_Tetra] = VTK_QUADRATIC_TETRA; + myVtkCellTypes[SMDSEntity_Pyramid] = VTK_PYRAMID; + myVtkCellTypes[SMDSEntity_Quad_Pyramid] = VTK_CONVEX_POINT_SET; + myVtkCellTypes[SMDSEntity_Hexa] = VTK_HEXAHEDRON; + myVtkCellTypes[SMDSEntity_Quad_Hexa] = VTK_QUADRATIC_HEXAHEDRON; + myVtkCellTypes[SMDSEntity_Penta] = VTK_WEDGE; + myVtkCellTypes[SMDSEntity_Quad_Penta] = VTK_QUADRATIC_WEDGE; + myVtkCellTypes[SMDSEntity_Polyhedra] = VTK_CONVEX_POINT_SET; + myVtkCellTypes[SMDSEntity_Quad_Polyhedra] = VTK_CONVEX_POINT_SET; } //======================================================================= @@ -49,10 +78,51 @@ SMDS_MeshElementIDFactory::SMDS_MeshElementIDFactory(): //======================================================================= bool SMDS_MeshElementIDFactory::BindID(int ID, SMDS_MeshElement * elem) { - if (myIDElements.IsBound(ID)) - return false; - myIDElements.Bind(ID,elem); + if ((ID < myIDElements.size()) && myIDElements[ID] >= 0) // --- already bound + { + MESSAGE(" --------------------------------- already bound "<< ID << " " << myIDElements[ID]); + return false; + } + + if (ID >= myIDElements.size()) // --- resize local vector + { + //MESSAGE(" ------------------- resize myIDElements " << ID << " --> " << ID+SMDS_Mesh::chunkSize); + myIDElements.resize(ID+SMDS_Mesh::chunkSize,-1); // fill new elements with -1 + } + + // --- retreive nodes ID + + vector nodeIds; + SMDS_ElemIteratorPtr it = elem->nodesIterator(); + while(it->more()) + { + int nodeId = it->next()->GetID(); + //MESSAGE(" node in cell " << ID << " : " <getGrid(); + int typ = GetVtkCellType(elem->GetType()); + int cellId = grid->InsertNextLinkedCell(typ, nodeIds.size(), &nodeIds[0]); + + // --- fill local vector + + myIDElements[ID] = cellId; + //MESSAGE("smds:" << ID << " vtk:" << cellId ); + + if (cellId >= myVtkIndex.size()) // --- resize local vector + { + //MESSAGE(" --------------------- resize myVtkIndex " << cellId << " --> " << cellId+SMDS_Mesh::chunkSize); + myVtkIndex.resize(cellId+SMDS_Mesh::chunkSize, -1); + } + myVtkIndex[cellId] = ID; + elem->myID=ID; + SMDS_MeshCell *cell = dynamic_cast(elem); + assert(cell); + cell->setVtkId(cellId); updateMinMax (ID); return true; } @@ -63,23 +133,10 @@ bool SMDS_MeshElementIDFactory::BindID(int ID, SMDS_MeshElement * elem) //======================================================================= SMDS_MeshElement* SMDS_MeshElementIDFactory::MeshElement(int ID) { - if (!myIDElements.IsBound(ID)) + if ((ID<0) || (ID>myMax) || (myIDElements[ID]<0)) return NULL; - return myIDElements.Find(ID); -} - - -//======================================================================= -//function : GetFreeID -//purpose : -//======================================================================= -int SMDS_MeshElementIDFactory::GetFreeID() -{ - int ID; - do { - ID = SMDS_MeshIDFactory::GetFreeID(); - } while (myIDElements.IsBound(ID)); - return ID; + const SMDS_MeshElement* elem = GetMesh()->FindElement(ID); + return (SMDS_MeshElement*)(elem); } //======================================================================= @@ -88,36 +145,12 @@ int SMDS_MeshElementIDFactory::GetFreeID() //======================================================================= void SMDS_MeshElementIDFactory::ReleaseID(const int ID) { - myIDElements.UnBind(ID); + myIDElements[ID] = -1; SMDS_MeshIDFactory::ReleaseID(ID); if (ID == myMax) myMax = 0; if (ID == myMin) - myMin = 0; -} - -//======================================================================= -//function : GetMaxID -//purpose : -//======================================================================= - -int SMDS_MeshElementIDFactory::GetMaxID() const -{ - if (myMax == 0) - updateMinMax(); - return myMax; -} - -//======================================================================= -//function : GetMinID -//purpose : -//======================================================================= - -int SMDS_MeshElementIDFactory::GetMinID() const -{ - if (myMin == 0) - updateMinMax(); - return myMin; + myMax = 0; } //======================================================================= @@ -129,9 +162,12 @@ void SMDS_MeshElementIDFactory::updateMinMax() const { myMin = IntegerLast(); myMax = 0; - SMDS_IdElementMap::Iterator it(myIDElements); - for (; it.More(); it.Next()) - updateMinMax (it.Key()); + for (int i=0; i=0) + { + if (id > myMax) myMax = id; + if (id < myMin) myMin = id; + } if (myMin == IntegerLast()) myMin = 0; } @@ -141,35 +177,20 @@ void SMDS_MeshElementIDFactory::updateMinMax() const //purpose : Return an iterator on elements of the factory //======================================================================= -class SMDS_Fact_MyElemIterator:public SMDS_ElemIterator -{ - SMDS_IdElementMap::Iterator myIterator; - public: - SMDS_Fact_MyElemIterator(const SMDS_IdElementMap& s):myIterator(s) - {} - - bool more() - { - return myIterator.More() != Standard_False; - } - - const SMDS_MeshElement* next() - { - const SMDS_MeshElement* current = myIterator.Value(); - myIterator.Next(); - return current; - } -}; - SMDS_ElemIteratorPtr SMDS_MeshElementIDFactory::elementsIterator() const { - return SMDS_ElemIteratorPtr - (new SMDS_Fact_MyElemIterator(myIDElements)); + return myMesh->elementsIterator(SMDSAbs_All); } void SMDS_MeshElementIDFactory::Clear() { - myIDElements.Clear(); + myIDElements.clear(); myMin = myMax = 0; SMDS_MeshIDFactory::Clear(); } + +int SMDS_MeshElementIDFactory::GetVtkCellType(int SMDSType) +{ + assert((SMDSType >=0) && (SMDSType< SMDSEntity_Last)); + return myVtkCellTypes[SMDSType]; +} diff --git a/src/SMDS/SMDS_MeshElementIDFactory.hxx b/src/SMDS/SMDS_MeshElementIDFactory.hxx index a574def92..bebac0973 100644 --- a/src/SMDS/SMDS_MeshElementIDFactory.hxx +++ b/src/SMDS/SMDS_MeshElementIDFactory.hxx @@ -28,28 +28,25 @@ #include "SMESH_SMDS.hxx" -#include "SMDS_MeshIDFactory.hxx" -#include "SMDS_ElemIterator.hxx" +#include "SMDS_MeshNodeIDFactory.hxx" -#include +#include class SMDS_MeshElement; -typedef NCollection_DataMap SMDS_IdElementMap; - -class SMDS_EXPORT SMDS_MeshElementIDFactory:public SMDS_MeshIDFactory +class SMDS_EXPORT SMDS_MeshElementIDFactory:public SMDS_MeshNodeIDFactory { public: SMDS_MeshElementIDFactory(); bool BindID(int ID, SMDS_MeshElement * elem); SMDS_MeshElement * MeshElement(int ID); - virtual int GetFreeID(); virtual void ReleaseID(int ID); - int GetMaxID() const; - int GetMinID() const; SMDS_ElemIteratorPtr elementsIterator() const; virtual void Clear(); -private: + int GetVtkCellType(int SMDSType); + int fromVtkToSmds(int vtkid) { return myVtkIndex[vtkid]; }; + +protected: void updateMinMax() const; void updateMinMax(int id) const { @@ -57,8 +54,9 @@ private: if (id < myMin) myMin = id; } - SMDS_IdElementMap myIDElements; - mutable int myMin, myMax; + std::vector myIDElements; // index = ID client, value = ID vtk + std::vector myVtkIndex; // index = ID vtk, value = ID client + std::vector myVtkCellTypes; }; diff --git a/src/SMDS/SMDS_MeshFace.hxx b/src/SMDS/SMDS_MeshFace.hxx index a633e4ecf..8593c1d95 100644 --- a/src/SMDS/SMDS_MeshFace.hxx +++ b/src/SMDS/SMDS_MeshFace.hxx @@ -30,7 +30,7 @@ #include "SMDS_MeshElement.hxx" -class SMDS_EXPORT SMDS_MeshFace:public SMDS_MeshElement +class SMDS_EXPORT SMDS_MeshFace:public SMDS_MeshCell { public: SMDSAbs_ElementType GetType() const; diff --git a/src/SMDS/SMDS_MeshIDFactory.cxx b/src/SMDS/SMDS_MeshIDFactory.cxx index 88b9ce38d..c8045954d 100644 --- a/src/SMDS/SMDS_MeshIDFactory.cxx +++ b/src/SMDS/SMDS_MeshIDFactory.cxx @@ -25,6 +25,8 @@ // Module : SMESH // #include "SMDS_MeshIDFactory.hxx" +#include "SMDS_Mesh.hxx" +#include "utilities.h" using namespace std; @@ -33,20 +35,26 @@ using namespace std; //purpose : //======================================================================= -SMDS_MeshIDFactory::SMDS_MeshIDFactory():myMaxID(0) +SMDS_MeshIDFactory::SMDS_MeshIDFactory():myMaxID(-1), myMesh(0) { } int SMDS_MeshIDFactory::GetFreeID() { - if (myPoolOfID.empty()) return ++myMaxID; + int newid; + if (myPoolOfID.empty()) + { + newid = ++myMaxID; + //MESSAGE("GetFreeID new " << newid); + } else { set::iterator i = myPoolOfID.begin(); - int ID = *i;//myPoolOfID.top(); + newid = *i;//myPoolOfID.top(); myPoolOfID.erase( i );//myPoolOfID.pop(); - return ID; + MESSAGE("GetFreeID pool " << newid); } + return newid; } //======================================================================= @@ -55,7 +63,7 @@ int SMDS_MeshIDFactory::GetFreeID() //======================================================================= void SMDS_MeshIDFactory::ReleaseID(const int ID) { - if ( ID > 0 ) + if ( ID >= 0 ) { if ( ID < myMaxID ) { @@ -82,6 +90,16 @@ void SMDS_MeshIDFactory::ReleaseID(const int ID) void SMDS_MeshIDFactory::Clear() { - myMaxID = 0; + myMaxID = -1; myPoolOfID.clear(); } + + void SMDS_MeshIDFactory::SetMesh(SMDS_Mesh *mesh) + { + myMesh = mesh; + } + + SMDS_Mesh* SMDS_MeshIDFactory::GetMesh() + { + return myMesh; + } diff --git a/src/SMDS/SMDS_MeshIDFactory.hxx b/src/SMDS/SMDS_MeshIDFactory.hxx index e81b41890..09ed074b9 100644 --- a/src/SMDS/SMDS_MeshIDFactory.hxx +++ b/src/SMDS/SMDS_MeshIDFactory.hxx @@ -31,18 +31,22 @@ #include "SMDS_MeshObject.hxx" #include +class SMDS_Mesh; class SMDS_EXPORT SMDS_MeshIDFactory:public SMDS_MeshObject { public: - virtual int GetFreeID(); + int GetFreeID(); virtual void ReleaseID(int ID); virtual void Clear(); - protected: - SMDS_MeshIDFactory(); - int myMaxID; - std::set myPoolOfID; + void SetMesh(SMDS_Mesh *mesh); + SMDS_Mesh* GetMesh(); +protected: + SMDS_MeshIDFactory(); + int myMaxID; + std::set myPoolOfID; + SMDS_Mesh *myMesh; }; #endif diff --git a/src/SMDS/SMDS_MeshNode.cxx b/src/SMDS/SMDS_MeshNode.cxx index d7c291b52..d10ec465d 100644 --- a/src/SMDS/SMDS_MeshNode.cxx +++ b/src/SMDS/SMDS_MeshNode.cxx @@ -28,6 +28,14 @@ #include "SMDS_MeshNode.hxx" #include "SMDS_SpacePosition.hxx" #include "SMDS_IteratorOfElements.hxx" +#include "SMDS_Mesh.hxx" +#include + +#define protected public +#include +#define protected protected + +#include "utilities.h" using namespace std; @@ -36,10 +44,50 @@ using namespace std; //purpose : //======================================================================= -SMDS_MeshNode::SMDS_MeshNode(double x, double y, double z): - myX(x), myY(y), myZ(z), - myPosition(SMDS_SpacePosition::originSpacePosition()) +SMDS_MeshNode::SMDS_MeshNode(int id, int meshId, int shapeId, double x, double y, double z): + SMDS_MeshElement(id, meshId, shapeId), + myPosition(SMDS_SpacePosition::originSpacePosition()) { + //MESSAGE("Node " << myID << " (" << x << ", " << y << ", " << z << ")"); + SMDS_Mesh* mesh = SMDS_Mesh::_meshList[myMeshId]; + vtkUnstructuredGrid * grid = mesh->getGrid(); + vtkPoints *points = grid->GetPoints(); + //int nbp = points->GetNumberOfPoints(); + points->InsertPoint(myID, x, y, z); + if (myID >= mesh->myCellLinksSize) + { + //points->SetNumberOfPoints(myID+SMDS_Mesh::chunkSize); + vtkCellLinks *cellLinks = grid->GetCellLinks(); + +// int imax = cellLinks->Size; +// for (int i =0; iGetLink(i); +// int ncells = ilink.ncells; +// int *cells = ilink.cells; +// MESSAGE("NODE " << i << " " << cellLinks << " " << cells << " " << ncells); +// for (int j=0; j< ncells; j++) +// MESSAGE(" " << j << " " << cells[j]); +// } + + cellLinks->Resize(myID+SMDS_Mesh::chunkSize); + +// cellLinks = grid->GetCellLinks(); +// imax = cellLinks->Size; +// for (int i =0; iGetLink(i); +// int ncells = ilink.ncells; +// int *cells = ilink.cells; +// MESSAGE("NODE " << i << " " << cellLinks << " " << cells << " " << ncells); +// for (int j=0; j< ncells; j++) +// MESSAGE(" " << j << " " << cells[j]); +// } + + mesh->myCellLinksSize = cellLinks->Size; + //MESSAGE(" -------------------------------------- resize CellLinks " << myID << " --> " << mesh->myCellLinksSize); + } + //setXYZ(x, y, z); } //======================================================================= @@ -49,14 +97,8 @@ SMDS_MeshNode::SMDS_MeshNode(double x, double y, double z): void SMDS_MeshNode::RemoveInverseElement(const SMDS_MeshElement * parent) { - NCollection_List::Iterator it(myInverseElements); - while (it.More()) { - const SMDS_MeshElement* elem = it.Value(); - if (elem == parent) - myInverseElements.Remove(it); - else - it.Next(); - } + MESSAGE("RemoveInverseElement " << myID << " " << parent->GetID()); + SMDS_Mesh::_meshList[myMeshId]->getGrid()->RemoveReferenceToCell(myID, parent->GetID()); // -PR- GetVtkID ? } //======================================================================= @@ -66,8 +108,8 @@ void SMDS_MeshNode::RemoveInverseElement(const SMDS_MeshElement * parent) void SMDS_MeshNode::Print(ostream & OS) const { - OS << "Node <" << GetID() << "> : X = " << myX << " Y = " - << myY << " Z = " << myZ << endl; + OS << "Node <" << myID << "> : X = " << X() << " Y = " + << Y() << " Z = " << Z() << endl; } //======================================================================= @@ -98,74 +140,88 @@ const SMDS_PositionPtr& SMDS_MeshNode::GetPosition() const class SMDS_MeshNode_MyInvIterator:public SMDS_ElemIterator { - NCollection_List::Iterator myIterator; +private: + SMDS_Mesh* myMesh; + int* myCells; + int myNcells; SMDSAbs_ElementType myType; + int iter; + public: - SMDS_MeshNode_MyInvIterator(const NCollection_List& s, + SMDS_MeshNode_MyInvIterator(SMDS_Mesh *mesh, + int* cells, + int ncells, SMDSAbs_ElementType type): - myIterator(s), myType(type) - {} + myMesh(mesh), myCells(cells), myNcells(ncells), myType(type), iter(0) + { + //MESSAGE("SMDS_MeshNode_MyInvIterator : ncells " << myNcells); + } bool more() { - if ( myType != SMDSAbs_All ) { - while ( myIterator.More() && myIterator.Value()->GetType() != myType) - myIterator.Next(); - } - return myIterator.More() != Standard_False; + return (iter< myNcells); } const SMDS_MeshElement* next() { - const SMDS_MeshElement* current=myIterator.Value(); - myIterator.Next(); - return current; + int vtkId = myCells[iter]; + int smdsId = myMesh->fromVtkToSmds(vtkId); + const SMDS_MeshElement* elem = myMesh->FindElement(smdsId); + iter++; + return elem; } }; SMDS_ElemIteratorPtr SMDS_MeshNode:: GetInverseElementIterator(SMDSAbs_ElementType type) const { - return SMDS_ElemIteratorPtr(new SMDS_MeshNode_MyInvIterator(myInverseElements,type)); + vtkCellLinks::Link l = SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetCellLinks()->GetLink(myID); + //MESSAGE("ncells " << l.ncells); + return SMDS_ElemIteratorPtr(new SMDS_MeshNode_MyInvIterator(SMDS_Mesh::_meshList[myMeshId], l.cells, l.ncells, type)); } // Same as GetInverseElementIterator but the create iterator only return // wanted type elements. class SMDS_MeshNode_MyIterator:public SMDS_ElemIterator { - NCollection_List mySet; - NCollection_List::Iterator myIterator; +private: + SMDS_Mesh* myMesh; + int* myCells; + int myNcells; + SMDSAbs_ElementType myType; + int iter; + vector myFiltCells; + public: - SMDS_MeshNode_MyIterator(SMDSAbs_ElementType type, - const NCollection_List& s) + SMDS_MeshNode_MyIterator(SMDS_Mesh *mesh, + int* cells, + int ncells, + SMDSAbs_ElementType type): + myMesh(mesh), myCells(cells), myNcells(ncells), myType(type), iter(0) { - const SMDS_MeshElement * e; - bool toInsert; - NCollection_List::Iterator it(s); - for(; it.More(); it.Next()) - { - e=it.Value(); - switch(type) - { - case SMDSAbs_Edge: toInsert=true; break; - case SMDSAbs_Face: toInsert=(e->GetType()!=SMDSAbs_Edge); break; - case SMDSAbs_Volume: toInsert=(e->GetType()==SMDSAbs_Volume); break; - } - if(toInsert) mySet.Append(e); - } - myIterator.Init(mySet); + for (; iterfromVtkToSmds(vtkId); + const SMDS_MeshElement* elem = myMesh->FindElement(smdsId); + if (elem->GetType() == type) + myFiltCells.push_back((SMDS_MeshElement*)elem); + } + myNcells = myFiltCells.size(); + iter = 0; + //MESSAGE("SMDS_MeshNode_MyIterator (filter) " << ncells << " " << myNcells); } bool more() { - return myIterator.More() != Standard_False; + return (iter< myNcells); } const SMDS_MeshElement* next() { - const SMDS_MeshElement* current=myIterator.Value(); - myIterator.Next(); - return current; + const SMDS_MeshElement* elem = myFiltCells[iter]; + iter++; + return elem; } }; @@ -175,10 +231,10 @@ SMDS_ElemIteratorPtr SMDS_MeshNode:: if(type==SMDSAbs_Node) return SMDS_MeshElement::elementsIterator(SMDSAbs_Node); else - return SMDS_ElemIteratorPtr - (new SMDS_IteratorOfElements - (this,type, - SMDS_ElemIteratorPtr(new SMDS_MeshNode_MyIterator(type, myInverseElements)))); + { + vtkCellLinks::Link l = SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetCellLinks()->GetLink(myID); + return SMDS_ElemIteratorPtr(new SMDS_MeshNode_MyIterator(SMDS_Mesh::_meshList[myMeshId], l.cells, l.ncells, type)); + } } int SMDS_MeshNode::NbNodes() const @@ -186,26 +242,35 @@ int SMDS_MeshNode::NbNodes() const return 1; } + +double* SMDS_MeshNode::getCoord() const +{ + return SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetPoint(myID); +} + double SMDS_MeshNode::X() const { - return myX; + double *coord = getCoord(); + return coord[0]; } double SMDS_MeshNode::Y() const { - return myY; + double *coord = getCoord(); + return coord[1]; } double SMDS_MeshNode::Z() const { - return myZ; + double *coord = getCoord(); + return coord[2]; } +//* resize the vtkPoints structure every SMDS_Mesh::chunkSize points void SMDS_MeshNode::setXYZ(double x, double y, double z) { - myX=x; - myY=y; - myZ=z; + vtkPoints *points = SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetPoints(); + points->InsertPoint(myID, x, y, z); } SMDSAbs_ElementType SMDS_MeshNode::GetType() const @@ -219,13 +284,9 @@ SMDSAbs_ElementType SMDS_MeshNode::GetType() const //======================================================================= void SMDS_MeshNode::AddInverseElement(const SMDS_MeshElement* ME) { - NCollection_List::Iterator it(myInverseElements); - for (; it.More(); it.Next()) { - const SMDS_MeshElement* elem = it.Value(); - if (elem == ME) - return; - } - myInverseElements.Append(ME); + const SMDS_MeshCell *cell = dynamic_cast(ME); + assert(cell); + SMDS_Mesh::_meshList[myMeshId]->getGrid()->AddReferenceToCell(myID, cell->getVtkId()); } //======================================================================= @@ -234,12 +295,13 @@ void SMDS_MeshNode::AddInverseElement(const SMDS_MeshElement* ME) //======================================================================= void SMDS_MeshNode::ClearInverseElements() { - myInverseElements.Clear(); + SMDS_Mesh::_meshList[myMeshId]->getGrid()->ResizeCellList(myID, 0); } bool SMDS_MeshNode::emptyInverseElements() { - return myInverseElements.IsEmpty() != Standard_False; + vtkCellLinks::Link l = SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetCellLinks()->GetLink(myID); + return (l.ncells == 0); } //================================================================================ @@ -250,13 +312,19 @@ bool SMDS_MeshNode::emptyInverseElements() int SMDS_MeshNode::NbInverseElements(SMDSAbs_ElementType type) const { + vtkCellLinks::Link l = SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetCellLinks()->GetLink(myID); + if ( type == SMDSAbs_All ) - return myInverseElements.Extent(); + return l.ncells; + int nb = 0; - NCollection_List::Iterator it( myInverseElements ); - for ( ; it.More(); it.Next() ) - if ( it.Value()->GetType() == type ) - nb++; + SMDS_Mesh *mesh = SMDS_Mesh::_meshList[myMeshId]; + for (int i=0; iFindNode(l.cells[i]); + if (elem->GetType() == type) + nb++; + } return nb; } diff --git a/src/SMDS/SMDS_MeshNode.hxx b/src/SMDS/SMDS_MeshNode.hxx index b35a9a85b..64ecc0847 100644 --- a/src/SMDS/SMDS_MeshNode.hxx +++ b/src/SMDS/SMDS_MeshNode.hxx @@ -36,7 +36,10 @@ class SMDS_EXPORT SMDS_MeshNode:public SMDS_MeshElement { public: - SMDS_MeshNode(double x, double y, double z); + SMDS_MeshNode(int id, int meshId, int shapeId = -1, double x=0, double y=0, double z=0); + + double* getCoord() const; + void Print(std::ostream & OS) const; double X() const; double Y() const; @@ -67,9 +70,7 @@ protected: elementsIterator(SMDSAbs_ElementType type) const; private: - double myX, myY, myZ; SMDS_PositionPtr myPosition; - NCollection_List myInverseElements; }; #endif diff --git a/src/SMDS/SMDS_MeshVolume.hxx b/src/SMDS/SMDS_MeshVolume.hxx index aa3498eac..58a55c48e 100644 --- a/src/SMDS/SMDS_MeshVolume.hxx +++ b/src/SMDS/SMDS_MeshVolume.hxx @@ -30,7 +30,7 @@ #include "SMDS_MeshElement.hxx" -class SMDS_EXPORT SMDS_MeshVolume:public SMDS_MeshElement +class SMDS_EXPORT SMDS_MeshVolume:public SMDS_MeshCell { public: diff --git a/src/SMESH/Makefile.am b/src/SMESH/Makefile.am index b286778f9..e7045b594 100644 --- a/src/SMESH/Makefile.am +++ b/src/SMESH/Makefile.am @@ -85,6 +85,7 @@ libSMESHimpl_la_CPPFLAGS = \ $(CAS_CPPFLAGS) \ $(MED_CXXFLAGS) \ $(GEOM_CXX_FLAGS) \ + $(VTK_INCLUDES) \ $(BOOST_CPPFLAGS) \ @HDF5_INCLUDES@ \ -I$(srcdir)/../Controls \ diff --git a/src/SMESH/SMESH_Gen.cxx b/src/SMESH/SMESH_Gen.cxx index 38a64e884..4a998052c 100644 --- a/src/SMESH/SMESH_Gen.cxx +++ b/src/SMESH/SMESH_Gen.cxx @@ -30,6 +30,7 @@ #include "SMESHDS_Document.hxx" #include "SMDS_MeshElement.hxx" #include "SMDS_MeshNode.hxx" +#include "SMDS_Mesh.hxx" #include "utilities.h" #include "OpUtil.hxx" @@ -40,6 +41,8 @@ #include #include +#include "memoire.h" + using namespace std; //============================================================================= @@ -54,6 +57,8 @@ SMESH_Gen::SMESH_Gen() _localId = 0; _hypId = 0; _segmentation = 10; + SMDS_Mesh::_meshList.clear(); + MESSAGE(SMDS_Mesh::_meshList.size()); } //============================================================================= @@ -135,6 +140,7 @@ bool SMESH_Gen::Compute(SMESH_Mesh & aMesh, TSetOfInt* aShapesId) { MESSAGE("SMESH_Gen::Compute"); + MEMOSTAT; bool ret = true; @@ -284,6 +290,7 @@ bool SMESH_Gen::Compute(SMESH_Mesh & aMesh, } MESSAGE( "VSR - SMESH_Gen::Compute() finished, OK = " << ret); + MEMOSTAT; return ret; } diff --git a/src/SMESHClient/Makefile.am b/src/SMESHClient/Makefile.am index dfde2987e..1f54c88e0 100644 --- a/src/SMESHClient/Makefile.am +++ b/src/SMESHClient/Makefile.am @@ -47,6 +47,7 @@ libSMESHClient_la_CPPFLAGS = \ $(MED_CXXFLAGS) \ $(GEOM_CXXFLAGS) \ $(BOOST_CPPFLAGS) \ + $(VTK_INCLUDES) \ $(CAS_CPPFLAGS) \ $(CORBA_CXXFLAGS) \ $(CORBA_INCLUDES) \ diff --git a/src/SMESHDS/Makefile.am b/src/SMESHDS/Makefile.am index b9c3673f3..d1e49ad33 100644 --- a/src/SMESHDS/Makefile.am +++ b/src/SMESHDS/Makefile.am @@ -60,6 +60,7 @@ dist_libSMESHDS_la_SOURCES = \ libSMESHDS_la_CPPFLAGS = \ $(KERNEL_CXXFLAGS) \ $(CAS_CPPFLAGS) \ + $(VTK_INCLUDES) \ $(BOOST_CPPFLAGS) \ -I$(srcdir)/../SMDS diff --git a/src/SMESH_I/Makefile.am b/src/SMESH_I/Makefile.am index b9282322d..d74457f35 100644 --- a/src/SMESH_I/Makefile.am +++ b/src/SMESH_I/Makefile.am @@ -92,6 +92,7 @@ libSMESHEngine_la_CPPFLAGS = \ $(CORBA_INCLUDES) \ $(CAS_CPPFLAGS) \ @HDF5_INCLUDES@ \ + $(VTK_INCLUDES) \ $(BOOST_CPPFLAGS) \ $(KERNEL_CXXFLAGS) \ $(GUI_CXXFLAGS) \ diff --git a/src/SMESH_I/SMESH_Gen_i.cxx b/src/SMESH_I/SMESH_Gen_i.cxx index d1c66c4e0..7e85c91ea 100644 --- a/src/SMESH_I/SMESH_Gen_i.cxx +++ b/src/SMESH_I/SMESH_Gen_i.cxx @@ -110,6 +110,7 @@ #include "GEOM_Client.hxx" #include "Utils_ExceptHandlers.hxx" +#include "memoire.h" #include @@ -1375,6 +1376,7 @@ CORBA::Boolean SMESH_Gen_i::Compute( SMESH::SMESH_Mesh_ptr theMesh, GEOM::GEOM_Object_ptr theShapeObject ) throw ( SALOME::SALOME_Exception ) { + MEMOSTAT; Unexpect aCatch(SALOME_SalomeException); if(MYDEBUG) MESSAGE( "SMESH_Gen_i::Compute" ); diff --git a/src/SMESH_I/SMESH_Mesh_i.cxx b/src/SMESH_I/SMESH_Mesh_i.cxx index 0e5a51e29..175be3dad 100644 --- a/src/SMESH_I/SMESH_Mesh_i.cxx +++ b/src/SMESH_I/SMESH_Mesh_i.cxx @@ -965,7 +965,7 @@ throw (SALOME::SALOME_Exception) try { - NCollection_Map< int > anIds; + vector< int > anIds; SMESH::ElementType aType = SMESH::ALL; for ( int g = 0, n = theGroups.length(); g < n; g++ ) { @@ -988,7 +988,7 @@ throw (SALOME::SALOME_Exception) for ( int i = 0, n = aCurrIds->length(); i < n; i++ ) { int aCurrId = aCurrIds[ i ]; - anIds.Add( aCurrId ); + anIds.push_back( aCurrId ); } } @@ -999,12 +999,12 @@ throw (SALOME::SALOME_Exception) // Create array of identifiers SMESH::long_array_var aResIds = new SMESH::long_array; - aResIds->length( anIds.Extent() ); + aResIds->length( anIds.size() ); - NCollection_Map< int >::Iterator anIter( anIds ); - for ( int i = 0; anIter.More(); anIter.Next(), i++ ) + //NCollection_Map< int >::Iterator anIter( anIds ); + for ( int i = 0; iAdd( aResIds ); @@ -1130,14 +1130,14 @@ throw (SALOME::SALOME_Exception) // create map of ids int nbGrp = theGroups.length(); - NCollection_Map< int > anIds; + vector< int > anIds; NCollection_DataMap< int, int >::Iterator anIter( anIdToCount ); for ( ; anIter.More(); anIter.Next() ) { int aCurrId = anIter.Key(); int aCurrNb = anIter.Value(); if ( aCurrNb == nbGrp ) - anIds.Add( aCurrId ); + anIds.push_back( aCurrId ); } // Create group @@ -1147,12 +1147,12 @@ throw (SALOME::SALOME_Exception) // Create array of identifiers SMESH::long_array_var aResIds = new SMESH::long_array; - aResIds->length( anIds.Extent() ); + aResIds->length( anIds.size() ); - NCollection_Map< int >::Iterator aListIter( anIds ); - for ( int i = 0; aListIter.More(); aListIter.Next(), i++ ) + //NCollection_Map< int >::Iterator aListIter( anIds ); + for ( int i = 0; iAdd( aResIds ); @@ -1249,7 +1249,7 @@ SMESH::SMESH_Group_ptr SMESH_Mesh_i::CutListOfGroups( try { - NCollection_Map< int > aToolIds; + set< int > aToolIds; SMESH::ElementType aType = SMESH::ALL; int g, n; // iterate through tool groups @@ -1274,11 +1274,11 @@ SMESH::SMESH_Group_ptr SMESH_Mesh_i::CutListOfGroups( for ( int i = 0, n = aCurrIds->length(); i < n; i++ ) { int aCurrId = aCurrIds[ i ]; - aToolIds.Add( aCurrId ); + aToolIds.insert( aCurrId ); } } - NCollection_Map< int > anIds; // result + vector< int > anIds; // result // Iterate through main group for ( g = 0, n = theMainGroups.length(); g < n; g++ ) @@ -1302,8 +1302,8 @@ SMESH::SMESH_Group_ptr SMESH_Mesh_i::CutListOfGroups( for ( int i = 0, n = aCurrIds->length(); i < n; i++ ) { int aCurrId = aCurrIds[ i ]; - if ( !aToolIds.Contains( aCurrId ) ) - anIds.Add( aCurrId ); + if ( !aToolIds.count( aCurrId ) ) + anIds.push_back( aCurrId ); } } @@ -1314,12 +1314,11 @@ SMESH::SMESH_Group_ptr SMESH_Mesh_i::CutListOfGroups( // Create array of identifiers SMESH::long_array_var aResIds = new SMESH::long_array; - aResIds->length( anIds.Extent() ); + aResIds->length( anIds.size() ); - NCollection_Map< int >::Iterator anIter( anIds ); - for ( int i = 0; anIter.More(); anIter.Next(), i++ ) + for (int i=0; iAdd( aResIds ); @@ -1371,7 +1370,7 @@ SMESH::SMESH_Group_ptr SMESH_Mesh_i::CreateDimGroup( { // Create map of nodes from all groups - NCollection_Map< int > aNodeMap; + set< int > aNodeMap; for ( int g = 0, n = theGroups.length(); g < n; g++ ) { @@ -1390,7 +1389,7 @@ SMESH::SMESH_Group_ptr SMESH_Mesh_i::CreateDimGroup( int aCurrId = aCurrIds[ i ]; const SMDS_MeshNode* aNode = aMeshDS->FindNode( aCurrId ); if ( aNode ) - aNodeMap.Add( aNode->GetID() ); + aNodeMap.insert( aNode->GetID() ); } } else @@ -1408,7 +1407,7 @@ SMESH::SMESH_Group_ptr SMESH_Mesh_i::CreateDimGroup( const SMDS_MeshNode* aNode = dynamic_cast( aNodeIter->next() ); if ( aNode ) - aNodeMap.Add( aNode->GetID() ); + aNodeMap.insert( aNode->GetID() ); } } } @@ -1416,22 +1415,25 @@ SMESH::SMESH_Group_ptr SMESH_Mesh_i::CreateDimGroup( // Get result identifiers - NCollection_Map< int > aResultIds; + vector< int > aResultIds; if ( theElemType == SMESH::NODE ) { - NCollection_Map< int >::Iterator aNodeIter( aNodeMap ); - for ( ; aNodeIter.More(); aNodeIter.Next() ) - aResultIds.Add( aNodeIter.Value() ); + //NCollection_Map< int >::Iterator aNodeIter( aNodeMap ); + set::iterator iter = aNodeMap.begin(); + for ( ; iter != aNodeMap.end(); iter++ ) + aResultIds.push_back( *iter); } else { // Create list of elements of given dimension constructed on the nodes - NCollection_Map< int > anElemList; - NCollection_Map< int >::Iterator aNodeIter( aNodeMap ); - for ( ; aNodeIter.More(); aNodeIter.Next() ) + vector< int > anElemList; + //NCollection_Map< int >::Iterator aNodeIter( aNodeMap ); + //for ( ; aNodeIter.More(); aNodeIter.Next() ) + set::iterator iter = aNodeMap.begin(); + for ( ; iter != aNodeMap.end(); iter++ ) { const SMDS_MeshElement* aNode = - dynamic_cast( aMeshDS->FindNode( aNodeIter.Value() ) ); + dynamic_cast( aMeshDS->FindNode( *iter ) ); if ( !aNode ) continue; @@ -1441,15 +1443,16 @@ SMESH::SMESH_Group_ptr SMESH_Mesh_i::CreateDimGroup( const SMDS_MeshElement* anElem = dynamic_cast( anElemIter->next() ); if ( anElem && anElem->GetType() == anElemType ) - anElemList.Add( anElem->GetID() ); + anElemList.push_back( anElem->GetID() ); } } // check whether all nodes of elements are present in nodes map - NCollection_Map< int >::Iterator anIter( anElemList ); - for ( ; anIter.More(); anIter.Next() ) + //NCollection_Map< int >::Iterator anIter( anElemList ); + //for ( ; anIter.More(); anIter.Next() ) + for (int i=0; i< anElemList.size(); i++) { - const SMDS_MeshElement* anElem = aMeshDS->FindElement( anIter.Value() ); + const SMDS_MeshElement* anElem = aMeshDS->FindElement( anElemList[i] ); if ( !anElem ) continue; @@ -1459,14 +1462,14 @@ SMESH::SMESH_Group_ptr SMESH_Mesh_i::CreateDimGroup( { const SMDS_MeshNode* aNode = dynamic_cast( aNodeIter->next() ); - if ( !aNode || !aNodeMap.Contains( aNode->GetID() ) ) + if ( !aNode || !aNodeMap.count( aNode->GetID() ) ) { isOk = false; break; } } if ( isOk ) - aResultIds.Add( anElem->GetID() ); + aResultIds.push_back( anElem->GetID() ); } } @@ -1478,11 +1481,12 @@ SMESH::SMESH_Group_ptr SMESH_Mesh_i::CreateDimGroup( // Create array of identifiers SMESH::long_array_var aResIds = new SMESH::long_array; - aResIds->length( aResultIds.Extent() ); + aResIds->length( aResultIds.size() ); - NCollection_Map< int >::Iterator aResIter( aResultIds ); - for ( int i = 0; aResIter.More(); aResIter.Next(), i++ ) - aResIds[ i ] = aResIter.Value(); + //NCollection_Map< int >::Iterator aResIter( aResultIds ); + //for ( int i = 0; aResIter.More(); aResIter.Next(), i++ ) + for (int i=0; i< aResultIds.size(); i++) + aResIds[ i ] = aResultIds[i]; aResGrp->Add( aResIds ); // Remove strings corresponding to group creation diff --git a/src/StdMeshers/Makefile.am b/src/StdMeshers/Makefile.am index c10d17e66..1b51b3afb 100644 --- a/src/StdMeshers/Makefile.am +++ b/src/StdMeshers/Makefile.am @@ -130,6 +130,7 @@ dist_libStdMeshers_la_SOURCES = \ libStdMeshers_la_CPPFLAGS = \ $(CAS_CPPFLAGS) \ $(BOOST_CPPFLAGS) \ + $(VTK_INCLUDES) \ $(KERNEL_CXXFLAGS) \ $(GUI_CXXFLAGS) \ -I$(srcdir)/../SMESHImpl \ diff --git a/src/StdMeshers_I/Makefile.am b/src/StdMeshers_I/Makefile.am index d1068d1d6..b91367abf 100644 --- a/src/StdMeshers_I/Makefile.am +++ b/src/StdMeshers_I/Makefile.am @@ -117,6 +117,7 @@ libStdMeshersEngine_la_CPPFLAGS = \ $(GEOM_CXXFLAGS) \ $(MED_CXXFLAGS) \ $(BOOST_CPPFLAGS) \ + $(VTK_INCLUDES) \ $(CORBA_CXXFLAGS) \ $(CORBA_INCLUDES) \ -I$(srcdir)/../SMESHImpl \