Overview
This tutorial provides the basic usage of HyperBlock (block-structured meshing), including importing geometric files for generating structured meshes, initializing and editing mesh blocks based on geometric models, and finally discretizing the mesh to achieve structured mesh generation based on geometric models. The NMBlock API includes mesh block initialization, block editing, association constraints, projection transformations, movement operations, edge matching, node distribution control, mesh discretization, quality optimization, and data query.
Functional Categories
Initialization Operations
- Init - Initialize mesh blocks
Block Editing Operations
- SplitEdge - Edge splitting
- SplitEdgeByProject - Edge splitting by projection points
- SplitEdgeUniform - Uniform edge splitting
- OSplit - O-type splitting operation
- JoinHex - Connect hexahedrons
- DeleteHex - Delete hexahedrons
Association Operations
- AssociateVertex - Vertex association
- AssociateEdge - Edge association
- AssociateFace - Face association
- DisassociateVertex - Cancel vertex association
- DisassociateEdge - Cancel edge association
- DisassociateFace - Cancel face association
Projection Transformation Operations
- ProjectNode - Project nodes
- ProjectEdge - Project edges
- MoveNodes - Move nodes
- MoveEdges - Move edges
- MoveFaces - Move faces
Edge Matching Operations
- MatchEdgeToEdge - Edge-to-edge matching
- MatchEdgeToCurve - Edge-to-curve matching
- MatchEdgeToPoints - Edge-to-points matching
Distribution Control Operations
- SetEdgesDistribution - Set edge distribution
- RevertEdgesDistribution - Revert edge distribution
Discretization Operations
- DiscreteHyperFaces - Discretize all block faces
- DiscreteFace - Discretize block faces
- DiscreteHyperBlock - Discretize all blocks
- DiscreteBlock - Discretize blocks
Smoothing Operations
- SmoothFaces - Smooth faces
- SmoothBlocks - Smooth blocks
Data Query
- GetVertexCount - Get vertex count
- GetEdgeCount - Get edge count
- GetFaceCount - Get face count
- GetBlockCount - Get block count
- GetEdgeVertexs - Get edge vertices
- GetFaceVertexs - Get face vertices
- GetBlockVertexs - Get block vertices
- GetFaceEdges - Get face edges
- GetBlockEdges - Get block edges
- GetBlockFaces - Get block faces
- GetVertexRepresentation - Get vertex geometric representation
- GetEdgeRepresentation - Get edge geometric representation
- GetFaceRepresentation - Get face geometric representation
- GetAllMeshNodes - Get all mesh nodes
- GetEdgeMesh - Get edge mesh
- GetFaceMesh - Get face quadrilateral mesh
- GetBlockMesh - Get block hexahedral mesh
Namespace
For clear example code, use namespace.
Namespace of all interface in the AMCAX NextMesh module.
Definition misc.docu:42
Namespace of all interface in the AMCAX kernel.
Definition misc.docu:8
Import Geometric Model
Import geometric file.
const std::string filedir = "./data/7.brep";
std::vector<NMEntity> ents0, ents1, ents2;
Class of model in NextMesh.
Definition NMAPIModel.hpp:22
AMCAX_API void ImportModel(const std::vector< NMShape > &shapes, const bool replace=true)
Load a cad model represented by AMCAX TopoShape. Note: this import method does not specify any entity...
AMCAX_API void GetEntities(std::vector< NMEntity > &ents, const DimType dim)
get all the entities in the specified dim
Base class of shape, containing an underlying shape with a location and an orientation.
Definition TopoShape.hpp:15
The geometric model is shown below:
Edit Mesh Blocks
Get mesh block operation object
AMCAX_API NMBlock & GetNMBlock()
Get the mesh block handle.
Class of Block in NextMesh.
Definition NMBlock.hpp:20
Initialize mesh blocks
AMCAX_API void Init()
Initializes the NMBlock with bounding box from the geometric model.
Mesh block initialization result:
Edge splitting
AMCAX_API void SplitEdge(const Indext eid, const std::vector< double > &ratios)
Splits an edge at specified ratios.
Based on mesh block initialization, edge splitting result:
Projection point edge splitting
NMPoint3 projectionPoint = {1.5, 2.0, 3.0};
AMCAX_API void SplitEdgeByProject(const Indext eid, const NMPoint3 &pos, double tol=1e-2)
Splits an edge by projecting a point onto it.
AMCAX::Coord3d NMPoint3
Type of point/vector.
Definition Macros.hpp:25
Based on mesh block initialization, projection point edge splitting result:
Uniform edge splitting
AMCAX_API void SplitEdgeUniform(const Indext eid, const Indext segNum)
Splits an edge into uniform segments.
Based on mesh block initialization, uniform edge splitting result:
O-type splitting operation
std::vector<Indext> blockIds = {0};
std::vector<Indext> faceIds = {0, 5};
double offset = 0.5;
blockapi.
OSplit(blockIds, faceIds, offset);
AMCAX_API void OSplit(const std::vector< Indext > &hids, const std::vector< Indext > &fids, const double &offset)
Performs offset split on specified hexes and faces.
Based on mesh block initialization, O-type splitting result:
Connect hexahedrons
std::vector<Indext> connectFaces = {8, 9, 10};
bool success = blockapi.
JoinHex(connectFaces);
AMCAX_API bool JoinHex(const std::vector< Indext > &fids)
Joins hex elements along specified faces.
Based on projection point edge splitting, hexahedron connection result:
Delete hexahedrons
std::vector<Indext> hexToDelete = {1, 3};
AMCAX_API void DeleteHex(const std::vector< Indext > &hids)
Deletes specified hex elements.
Based on uniform edge splitting, hexahedron deletion result:
Vertex association
std::vector<Indext> vertexIds = { 5 };
std::vector<NMEntity> NMEnts = { ents0[0]};
AMCAX_API bool AssociateVertex(const std::vector< Indext > &vids, DimType dim, const std::vector< NMEntity > &NMEnts, bool translate=false)
Associates vertices with geometric entities.
Based on mesh block initialization, vertex association to geometric points result:
vertexIds = { 1 };
NMEnts = { ents1[1] };
Based on previous operation, vertex association to geometric edges result:
vertexIds = { 2 };
NMEnts = { ents2[0] };
Based on previous operation, vertex association to geometric faces result:
Edge association
std::vector<Indext> edgeIds = { 8, 9, 10, 11 };
std::vector<NMEntity> NMEnts = { ents1[0] };
bool success = blockapi.
AssociateEdge(edgeIds, DimType::D1, NMEnts);
AMCAX_API bool AssociateEdge(const std::vector< Indext > &eids, DimType dim, const std::vector< NMEntity > &NMEnts, bool translate=false)
Associates edges with geometric entities.
Based on mesh block initialization, block edge association to geometric edges result:
Face association
std::vector<Indext> faceIds = {0, 2, 5, 8};
std::vector<NMEntity> geoFaces = { ents2[0] };
AMCAX_API bool AssociateFace(const std::vector< Indext > &fids, const std::vector< NMEntity > &NMEnts, bool translate=false)
Associates faces with geometric entities.
Based on O-type splitting, block face association to geometric faces result:
Cancel vertex association
std::vector<Indext> vertexIds = {1, 2, 3};
AMCAX_API bool DisassociateVertex(const std::vector< Indext > &vids)
Disassociates specified vertices from geometric entities.
Canceling block vertex association does not cause vertex position changes.
Cancel edge association
std::vector<Indext> edgeIds = {5, 6};
AMCAX_API bool DisassociateEdge(const std::vector< Indext > &eids)
Disassociates specified edges from geometric entities.
Canceling block edge association does not cause vertex position changes.
Cancel face association
std::vector<Indext> faceIds = {3, 4};
AMCAX_API bool DisassociateFace(const std::vector< Indext > &fids)
Disassociates specified faces from geometric entities.
Canceling block face association does not cause vertex position changes.
Project nodes
std::vector<Indext> vertexIds = { 5 };
std::vector<NMEntity> NMEnts = { ents0[0]};
bool success = blockapi.
ProjectNode(vertexIds, NodeType::Vertex, DimType::D0, NMEnts);
AMCAX_API bool ProjectNode(const std::vector< Indext > &nids, NodeType type, DimType dim, const std::vector< NMEntity > &NMEnts, bool translate=false)
Projects nodes onto geometric entities.
Based on mesh block initialization, node projection to geometric points result:
Project edges
std::vector<Indext> edgeIds = { 3, 5 };
std::vector<NMEntity> NMEnts = { ents1[2] };
bool success = blockapi.
ProjectEdge(edgeIds, DimType::D1, NMEnts);
AMCAX_API bool ProjectEdge(const std::vector< Indext > &eids, DimType dim, const std::vector< NMEntity > &NMEnts, bool translate=false)
Projects edges onto geometric entities.
Based on mesh block initialization, edge projection to geometric curves result:
Move nodes
Currently only supports moving vertices
std::vector<Indext> nodeIds = { 5, 7 };
NMVector3 moveVector = { 0., 0.0, 5.0 };
bool success = blockapi.
MoveNodes(nodeIds, NodeType::Vertex, moveVector);
AMCAX_API bool MoveNodes(const std::vector< Indext > &nids, NodeType type, const NMVector3 &dir, bool translate=false)
Moves nodes in a specified direction.
Based on mesh block initialization, node movement result:
Move edges
std::vector<Indext> edgeIds = { 10, 11 };
NMVector3 moveVector = { 0.0, 5.0, 0.0 };
bool success = blockapi.
MoveEdges(edgeIds, moveVector,
true);
AMCAX_API bool MoveEdges(const std::vector< Indext > &eids, const NMVector3 &dir, bool translate=false)
Moves edges in a specified direction.
Based on mesh block initialization, edge movement result:
Move faces
std::vector<Indext> faceIds = { 0, 4 };
NMVector3 moveVector = { 0.0, 5.0, 0.0 };
bool success = blockapi.
MoveFaces(faceIds, moveVector);
AMCAX_API bool MoveFaces(const std::vector< Indext > &fids, const NMVector3 &dir, bool translate=false)
Moves faces in a specified direction.
Based on mesh block initialization, face movement result:
Edge-to-edge matching
std::vector<Indext> sourceEdges = { 20 };
std::vector<Indext> targetEdges = { 0 };
matchFactor = 0.5;
sourceEdges = { 23 };
targetEdges = { 4 };
matchFactor = 0.5;
sourceEdges = { 25 };
targetEdges = { 7 };
matchFactor = 0.5;
sourceEdges = { 21 };
targetEdges = { 1 };
matchFactor = 0.5;
sourceEdges = { 28 };
targetEdges = { 12 };
matchFactor = 0.5;
sourceEdges = { 30 };
targetEdges = { 15 };
matchFactor = 0.5;
sourceEdges = { 31 };
targetEdges = { 17 };
matchFactor = 0.5;
sourceEdges = { 29 };
targetEdges = { 13 };
matchFactor = 0.5;
AMCAX_API bool MatchEdgeToEdge(const std::vector< Indext > &sourceEIds, const std::vector< Indext > &targetEIds, double matchFactor, bool translate=false)
Matches source edges to target edges.
Based on face association, edge-to-edge matching result:
Edge-to-curve matching
std::vector<Indext> edgeIds = { 10, 11 };
std::vector<NMEntity> NMEnts = { ents1[2] };
double matchFactor = 0.8;
AMCAX_API bool MatchEdgeToCurve(const std::vector< Indext > &sourceEIds, const std::vector< NMEntity > &NMEnts, double matchFactor, bool translate=false)
Matches edges to curves.
Based on edge projection, edge-to-curve matching result:
Edge-to-points matching
std::vector<Indext> edgeIds = { 10, 11 };
std::vector<NMEntity> NMEnts = { ents0[0], ents0[1]};
double matchFactor = 0.5;
AMCAX_API bool MatchEdgeToPoints(const std::vector< Indext > &sourceEIds, const std::vector< NMEntity > &NMEnts, double matchFactor, bool translate=false)
Matches edges to points.
Based on edge projection, edge-to-points matching result:
Set edge distribution
Uniform node count distribution
std::vector<Indext> faceIds = {1, 2, 3, 4};
std::vector<NMEntity> geoFaces = { ents2[0] };
param.
_type = SpacingType::Number;
std::vector<Indext> edgeIds = { 0, 1 };;
AMCAX_API bool SetEdgesDistribution(const std::vector< Indext > &eids, const SpacingParam ¶m)
Sets the point distribution along edges.
Control parameters for edge distribution.
Definition BlockMacros.hpp:48
bool _parallel
Apply distribution to parallel edges.
Definition BlockMacros.hpp:56
SpacingType _type
Distribution type.
Definition BlockMacros.hpp:49
bool _reverse
Reverse distribution direction.
Definition BlockMacros.hpp:55
unsigned _num
Number of nodes/segments.
Definition BlockMacros.hpp:52
Based on block initialization, first associate faces, then set Number distribution result:
Fixed length distribution
std::vector<Indext> faceIds = {1, 2, 3, 4};
std::vector<NMEntity> geoFaces = { ents2[0] };
param.
_type = SpacingType::Length;
std::vector<Indext> edgeIds = { 0, 1 };;
double _startLen
Starting spacing length.
Definition BlockMacros.hpp:53
Based on block initialization, first associate faces, then set Length distribution result:
Linear distribution
std::vector<Indext> faceIds = {1, 2, 3, 4};
std::vector<NMEntity> geoFaces = { ents2[0] };
param.
_type = SpacingType::Linear;
std::vector<Indext> edgeIds = { 8, 9 };
double _factor
Spacing ratio factor.
Definition BlockMacros.hpp:51
unsigned _mode
0=count factor, 1=size control
Definition BlockMacros.hpp:50
Based on block initialization, first associate faces, then set Linear distribution result:
Geometric progression distribution
std::vector<Indext> faceIds = {1, 2, 3, 4};
std::vector<NMEntity> geoFaces = { ents2[0] };
param.
_type = SpacingType::Geometric;
std::vector<Indext> edgeIds = { 8, 9 };
double _endLen
Ending spacing length.
Definition BlockMacros.hpp:54
Based on block initialization, first associate faces, then set Geometric distribution result:
Bell curve distribution
std::vector<Indext> faceIds = {1, 2, 3, 4};
std::vector<NMEntity> geoFaces = { ents2[0] };
param.
_type = SpacingType::BellCurve;
std::vector<Indext> edgeIds = { 8, 9 };
Based on block initialization, first associate faces, then set BellCurve distribution result:
Auto CFD distribution
std::vector<Indext> faceIds = {1, 2, 3, 4};
std::vector<NMEntity> geoFaces = { ents2[0] };
param.
_type = SpacingType::AutoCFD;
std::vector<Indext> edgeIds = { 8, 9 };
double _minLength
Minimum spacing.
Definition BlockMacros.hpp:61
double _maxLength
Maximum spacing.
Definition BlockMacros.hpp:60
double _distortionAngle
Distortion angle (degrees)
Definition BlockMacros.hpp:62
double _growthRate
Growth rate.
Definition BlockMacros.hpp:59
Based on block initialization, first associate faces, then set AutoCFD distribution result (for curves):
Note: For edges with no significant curvature change, uniform distribution is used.
Revert edge distribution
std::vector<Indext> faceIds = {1, 2, 3, 4};
std::vector<NMEntity> geoFaces = { ents2[0] };
param.
_type = SpacingType::Number;
edgeIds = { 0, 1 };
param.
_type = SpacingType::Length;
edgeIds = { 0, 1 };
AMCAX_API bool RevertEdgesDistribution(const std::vector< Indext > &eids, bool parallel=false)
Reverts edges to their original distribution.
Based on block initialization, first associate faces, then set Number distribution, then set Length distribution, finally revert edge distribution result:
Discretize all block faces
param.
_type = SpacingType::Length;
edgeIds = {0, 1, 2, 3};
{
std::cout << "Discrete all faces." << std::endl;
}
AMCAX_API bool DiscreteHyperFaces()
Discretizes all hyper faces into mesh elements.
Based on edge-to-edge matching, first set edge distribution, then discretize all block faces result:
Discretize block faces
param.
_type = SpacingType::Length;
edgeIds = {0, 1, 2, 3};
faceIds = { 21 };
{
std::cout << "Discrete face : " ;
for(auto id : faceIds)
{
std::cout << id << " ";
}
std::cout << std::endl;
}
AMCAX_API bool DiscreteFace(const std::vector< Indext > &fids)
Discretizes specified faces.
Based on edge-to-edge matching, first set edge distribution, then discretize block faces result:
Discretize all blocks
param.
_type = SpacingType::Length;
edgeIds = {0, 1, 2, 3};
if(blockapi.DiscreteHyperBlocks())
{
std::cout << "Discrete all blocks." << std::endl;
}
Based on edge-to-edge matching, first set edge distribution, then discretize all blocks result:
Discretize blocks
param.
_type = SpacingType::Length;
edgeIds = {0, 1, 2, 3};
blockIds = { 0 };
{
std::cout << "Discrete block : " ;
for(auto id : blockIds)
{
std::cout << id << " ";
}
std::cout << std::endl;
}
AMCAX_API bool DiscreteBlock(const std::vector< Indext > &hids)
Discretizes specified blocks.
Based on edge-to-edge matching, first set edge distribution, then discretize blocks result:
Smooth faces
smoothParam.faceIds = {21};
smoothParam._optimizerType = SmoothType::LAPLACIAN;
smoothParam._maxIteration = 20;
smoothParam._relaxationFactor = 0.3;
AMCAX_API bool SmoothFaces(SmoothParam ¶m)
Smooths faces according to specified parameters.
Control parameters for mesh smooth.
Definition BlockMacros.hpp:85
Based on discretized block faces, face smoothing result (green lines: before smoothing, blue lines: after smoothing):
Note: Since block face boundaries need constraints, smoothing only optimizes discrete points inside the mesh face, so boundary discrete points don't change.
Smooth blocks
smoothParam._blockIds = {0, 1, 2};
smoothParam._optimizerType = SoothType::ENERGY_BASED;
smoothParam._maxIteration = 15;
smoothParam._relaxationFactor = 0.3f;
AMCAX_API bool SmoothBlocks(SmoothParam ¶m)
Smooths blocks according to specified parameters.
Based on discretized all blocks, block smoothing result:
Note: Since block boundaries need constraints, smoothing only optimizes discrete points inside the mesh block, so boundary discrete points don't change.
Get vertex count
std::cout << "Mesh vertex count: " << vertexCount << std::endl;
AMCAX_API Indext GetVertexCount()
Gets the total number of vertices.
Get edge count
std::cout << "Mesh edge count: " << edgeCount << std::endl;
AMCAX_API Indext GetEdgeCount()
Gets the total number of edges.
Get face count
std::cout << "Mesh face count: " << faceCount << std::endl;
AMCAX_API Indext GetFaceCount()
Gets the total number of faces.
Get block count
std::cout << "Mesh block count: " << blockCount << std::endl;
AMCAX_API Indext GetBlockCount()
Gets the total number of blocks.
Get edge vertices
std::vector<Indext> vertexIds;
std::cout << "Edge " << 10 << " connected vertices: ";
for (auto vid : vertexIds)
{
std::cout << vid << " ";
}
std::cout << std::endl;
AMCAX_API void GetEdgeVertexs(Indext eid, std::vector< Indext > &vids)
Gets vertices of an edge.
Get face vertices
std::vector<Indext> vertexIds;
std::cout << "Face " << 5 << " contains " << vertexIds.size() << " vertices" << std::endl;
AMCAX_API void GetFaceVertexs(Indext fid, std::vector< Indext > &vids)
Gets vertices of a face.
Get block vertices
std::vector<Indext> vertexIds;
std::cout << "Block " << 3 << " contains " << vertexIds.size() << " vertices" << std::endl;
AMCAX_API void GetBlockVertexs(Indext hid, std::vector< Indext > &vids)
Gets vertices of a block.
Get face edges
std::vector<Indext> edgeIds;
std::cout << "Face " << 8 << " consists of " << edgeIds.size() << " edges" << std::endl;
AMCAX_API void GetFaceEdges(Indext fid, std::vector< Indext > &eids)
Gets edges of a face.
Get block edges
std::vector<Indext> edgeIds;
std::cout << "Block " << 2 " contains " << edgeIds.size() << " edges" << std::endl;
AMCAX_API void GetBlockEdges(Indext hid, std::vector< Indext > &eids)
Gets edges of a block.
Get block faces
std::vector<Indext> faceIds;
std::cout << "Block " << 1 << " contains " << faceIds.size() << " faces" << std::endl;
AMCAX_API void GetBlockFaces(Indext hid, std::vector< Indext > &fids)
Gets faces of a block.
Get vertex geometric representation
std::cout << "Vertex position: (" << vertexPos.x() << ", " << vertexPos.y() << ", " << vertexPos.z() << ")" << std::endl;
AMCAX_API void GetVertexRepresentation(Indext vid, NMPoint3 &pos)
Gets the geometric position of a vertex.
Get edge geometric representation
std::vector<NMPoint3> edgePoints;
std::cout << "Edge contains " << edgePoints.size() << " geometric points" << std::endl;
AMCAX_API void GetEdgeRepresentation(Indext eid, std::vector< NMPoint3 > &edgesPnts)
Gets the geometric representation of an edge.
Get face geometric representation
std::vector<NMPoint3> meshPoints;
std::vector<std::array<Indext, 3>> triangles;
std::cout << "Face contains " << meshPoints.size() << " points and " << triangles.size() << " triangles" << std::endl;
AMCAX_API void GetFaceRepresentation(Indext fid, std::vector< NMPoint3 > &meshPnts, std::vector< std::array< Indext, 3 > > &meshfvs)
Gets the geometric representation of a face.
Get all mesh nodes
std::vector<NMPoint3> allNodes;
std::cout << "Mesh contains " << allNodes.size() << " nodes in total" << std::endl;
AMCAX_API void GetAllMeshNodes(std::vector< NMPoint3 > &meshPnts)
Gets all mesh nodes.
Get edge mesh
std::vector<std::array<Indext, 2>> lineElements;
std::cout << "Edge contains " << lineElements.size() << " line elements" << std::endl;
AMCAX_API void GetEdgeMesh(Indext eid, std::vector< std::array< Indext, 2 > > &mlines)
Gets mesh connectivity for an edge.
Get face quadrilateral mesh
std::vector<std::array<Indext, 4>> quadElements;
std::cout << "Face contains " << quadElements.size() << " quadrilateral elements" << std::endl;
AMCAX_API void GetFaceMesh(Indext fid, std::vector< std::array< Indext, 4 > > &mquads)
Gets mesh connectivity for a face.
Get block hexahedral mesh
std::vector<std::array<Indext, 8>> hexElements;
std::cout << "Block contains " << hexElements.size() << " hexahedral elements" << std::endl;
AMCAX_API void GetBlockMesh(Indext hid, std::vector< std::array< Indext, 8 > > &mhexs)
Gets mesh connectivity for a block.
Complete Example
The following is a complete example demonstrating how to import a geometric model, initialize mesh blocks, edit mesh blocks, associate geometry, discretize mesh blocks, and smooth the mesh. The specific code is as follows:
int main()
{
const std::string filedir = "./data/7.brep";
std::vector<NMEntity> ents0, ents1, ents2;
std::vector<Indext> vertexIds;
std::vector<Indext> edgeIds;
std::vector<Indext> faceIds;
std::vector<Indext> blockIds;
std::vector<Indext> sourceEdges;
std::vector<Indext> targetEdges;
std::vector<NMEntity> NMEnts;
bool success;
double matchFactor = 0.0;
NMVector3 moveVector = { 0., .0, .0 };
blockIds = { 0 };
faceIds = { 0, 5 };
double offset = 0.5;
blockapi.
OSplit(blockIds, faceIds, offset);
faceIds = { 0, 2, 5, 8 };
NMEnts = { ents2[0] };
sourceEdges = { 20 };
targetEdges = { 0 };
matchFactor = 0.5;
sourceEdges = { 23 };
targetEdges = { 4 };
matchFactor = 0.5;
sourceEdges = { 25 };
targetEdges = { 7 };
matchFactor = 0.5;
sourceEdges = { 21 };
targetEdges = { 1 };
matchFactor = 0.5;
sourceEdges = { 28 };
targetEdges = { 12 };
matchFactor = 0.5;
sourceEdges = { 30 };
targetEdges = { 15 };
matchFactor = 0.5;
sourceEdges = { 31 };
targetEdges = { 17 };
matchFactor = 0.5;
sourceEdges = { 29 };
targetEdges = { 13 };
matchFactor = 0.5;
param.
_type = SpacingType::Length;
edgeIds = { 0, 1, 2, 3 };
{
std::cout << "Discrete all blocks." << std::endl;
}
smoothParam._blockIds = { 0 };
smoothParam._optimizerType = SmoothType::ENERGY_BASED;
smoothParam._maxIteration = 5;
smoothParam._relaxationFactor = 0.3;
return 0;
}
AMCAX_API bool DiscreteHyperBlock()
Discretizes the entire hyper block.
Click here example06 to get the full source code of the complete example. Everyone can download it as needed.