-// 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
#include "SMESHDS_Script.hxx"
#include "SMESHDS_TSubMeshHolder.hxx"
-#include <Standard_ErrorHandler.hxx>
-#include <Standard_OutOfRange.hxx>
+// #include <BRep_Tool.hxx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Solid.hxx>
#include <TopoDS_Vertex.hxx>
+#include <Standard_ErrorHandler.hxx>
+#include <Standard_OutOfRange.hxx>
+
#include "utilities.h"
class SMESHDS_Mesh::SubMeshHolder : public SMESHDS_TSubMeshHolder< const SMESHDS_SubMesh >
void SMESHDS_Mesh::ClearMesh()
{
+ myRegularGrid.Clear();
+
myScript->ClearMesh();
SMDS_Mesh::Clear();
//=======================================================================
SMESHDS_Mesh::~SMESHDS_Mesh()
{
+ myRegularGrid.Clear();
// myScript
delete myScript;
// submeshes
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<SMESHUtils::SMESH_RegularGrid>(index,nx,ny,nz));
+ }
+
+}
+
+void SMESHDS_Mesh::SetNodeOnStructuredGrid( const TopoDS_Shape & shape, const std::shared_ptr<gp_Pnt>& 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<SMESHUtils::SMESH_RegularGrid>& 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