X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FSMESHDS%2FSMESHDS_Mesh.cxx;h=df229269b72301b0883d5975b9a08eb8b62c3144;hb=HEAD;hp=f15fe1b1f21ac987b4580f86f8a0935550bf2576;hpb=274fd4f2db8d3a7fa23701764280ea1d175b194b;p=modules%2Fsmesh.git diff --git a/src/SMESHDS/SMESHDS_Mesh.cxx b/src/SMESHDS/SMESHDS_Mesh.cxx index f15fe1b1f..8e616d920 100644 --- a/src/SMESHDS/SMESHDS_Mesh.cxx +++ b/src/SMESHDS/SMESHDS_Mesh.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2023 CEA, EDF, OPEN CASCADE +// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -37,8 +37,7 @@ #include "SMESHDS_Script.hxx" #include "SMESHDS_TSubMeshHolder.hxx" -#include -#include +// #include #include #include #include @@ -48,6 +47,9 @@ #include #include +#include +#include + #include "utilities.h" class SMESHDS_Mesh::SubMeshHolder : public SMESHDS_TSubMeshHolder< const SMESHDS_SubMesh > @@ -1030,6 +1032,8 @@ void SMESHDS_Mesh::RemoveFreeElement(const SMDS_MeshElement * elt, void SMESHDS_Mesh::ClearMesh() { + myRegularGrid.Clear(); + myScript->ClearMesh(); SMDS_Mesh::Clear(); @@ -1483,6 +1487,7 @@ void SMESHDS_Mesh::SetMeshElementOnShape(const SMDS_MeshElement* anElement, //======================================================================= SMESHDS_Mesh::~SMESHDS_Mesh() { + myRegularGrid.Clear(); // myScript delete myScript; // submeshes @@ -2280,3 +2285,81 @@ bool SMESHDS_Mesh::ModifyCellNodes(vtkIdType vtkVolId, std::map localCl myGrid->ModifyCellNodes(vtkVolId, localClonedNodeIds); return true; } + +/* Create a structured grid associated to the shapeId meshed + * @remark the grid dimension (nx, ny, nz) is not associated to a space direction, those dimensions denotes which index + * run faster in the nested loop defining the nodes of a structured grid. + * for( k in range(0,nz) ) + * for( j in range(0,ny) ) + * for( i in range(0,nx) ) + * @param shape been meshed, pass the shape that would be passed to SetNodeOnFace or SetNodeInVolume method. + * @param nx, faster dimension + * @param ny, medium dimension + * @param nz, slower dimension + * @return define a new * SMESH_StructuredGrid to the shapeId. + */ +void SMESHDS_Mesh::SetStructuredGrid( const TopoDS_Shape & shape, const int nx, const int ny, const int nz ) +{ + int index = myIndexToShape.FindIndex(shape); + if ( index != 0 ) + { + if ( myRegularGrid.IsBound(index) ) + myRegularGrid.UnBind(index); + + myRegularGrid.Bind(index, std::make_shared(index,nx,ny,nz)); + } + +} + +void SMESHDS_Mesh::SetNodeOnStructuredGrid( const TopoDS_Shape & shape, const std::shared_ptr& P, const int iIndex, const int jIndex, const int kIndex ) +{ + int index = myIndexToShape.FindIndex(shape); + if ( index != 0 && myRegularGrid.IsBound(index) ) + myRegularGrid.Seek(index)->get()->SetNode( P, iIndex, jIndex, kIndex ); +} + +void SMESHDS_Mesh::SetNodeOnStructuredGrid( const TopoDS_Shape & shape, const SMDS_MeshNode* P, const int iIndex, const int jIndex, const int kIndex ) +{ + int index = myIndexToShape.FindIndex(shape); + if ( index != 0 && myRegularGrid.IsBound(index) ) + myRegularGrid.Seek(index)->get()->SetNode( P, iIndex, jIndex, kIndex ); +} + +void SMESHDS_Mesh::SetNodeOnStructuredGrid( const TopoDS_Shape & shape, const SMDS_MeshNode* P, const int index ) +{ + int shapeIndex = myIndexToShape.FindIndex(shape); + if ( shapeIndex != 0 && myRegularGrid.IsBound(shapeIndex) ) + myRegularGrid.Seek(shapeIndex)->get()->SetNode( P, index ); +} + +bool SMESHDS_Mesh::HasStructuredGridFilled( const TopoDS_Shape & shape ) const +{ + int index = myIndexToShape.FindIndex(shape); + if ( index != 0 && myRegularGrid.IsBound(index) ) + return true; + else + return false; +} + +bool SMESHDS_Mesh::HasSomeStructuredGridFilled() const +{ + bool hasSomeStructuredGrid = false; + for ( TopExp_Explorer fEx( myShape, TopAbs_SOLID ); fEx.More(); fEx.Next() ) + { + TopoDS_Solid solid = TopoDS::Solid(fEx.Current()); + if ( HasStructuredGridFilled( solid ) ) hasSomeStructuredGrid = true; + } + for ( TopExp_Explorer fEx( myShape, TopAbs_FACE ); fEx.More(); fEx.Next() ) + { + TopoDS_Face face = TopoDS::Face(fEx.Current()); + if ( HasStructuredGridFilled( face ) ) hasSomeStructuredGrid = true; + } + return hasSomeStructuredGrid; +} + +const std::shared_ptr& SMESHDS_Mesh::GetTheGrid( const TopoDS_Shape & shape ) +{ + int index = myIndexToShape.FindIndex(shape); + if ( index != 0 && myRegularGrid.IsBound(index) ) + return *myRegularGrid.Seek(index); +} \ No newline at end of file