mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2024-12-28 18:30:35 +05:00
0020868: EDF 1251 SMESH: Pattern 3D mapping
Add documentation and sample scripts for 3D pattern mapping
This commit is contained in:
parent
ed467c6060
commit
69e7a358b8
Binary file not shown.
Before Width: | Height: | Size: 5.5 KiB |
BIN
doc/salome/gui/SMESH/images/pattern2d.png
Normal file
BIN
doc/salome/gui/SMESH/images/pattern2d.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 578 B |
@ -11,30 +11,83 @@ located at geometrical vertices. Pattern description is stored in
|
|||||||
\<pattern_name\>.smp file.
|
\<pattern_name\>.smp file.
|
||||||
|
|
||||||
The smp file contains 4 sections:
|
The smp file contains 4 sections:
|
||||||
<ol>
|
|
||||||
<li>The first line holds the number of nodes (N).</li>
|
|
||||||
|
|
||||||
<li>The next N lines describe nodes coordinates. Each line holds 2
|
-# The first line holds the total number of the pattern nodes (N).
|
||||||
coordinates of a node.</li>
|
-# The next N lines describe nodes coordinates. Each line holds 2
|
||||||
|
coordinates of a node for 2D pattern or 3 cordinates for 3D pattern.
|
||||||
<li>A key-points line: indices of nodes to be mapped on geometrical
|
Note, that for 3D pattern only relateive values in range [0;1] are
|
||||||
vertices. An index n refers to a node described on an n-th line of
|
valid for coordinates of the nodes.
|
||||||
section 2. The first node index is zero.</li>
|
-# A key-points line: indices of nodes to be mapped on geometrical
|
||||||
|
vertices (for 2D pattern only). An index n refers to a node described
|
||||||
<li>The rest lines describe nodal connectivity of elements, one line
|
on an n-th line of section 2. The first node index is zero. For 3D
|
||||||
|
pattern key points are not specified.
|
||||||
|
-# The rest lines describe nodal connectivity of elements, one line
|
||||||
for an element. A line holds indices of nodes forming an element. An
|
for an element. A line holds indices of nodes forming an element. An
|
||||||
index n refers to a node described on an n-th line of the section
|
index n refers to a node described on an n-th line of the section
|
||||||
2. The first node index is zero. There must be 3 or 4 indices on a
|
2. The first node index is zero. There must be 3 or 4 indices on a
|
||||||
line: only 2d elements are allowed.</li>
|
line for 2D pattern (only 2d elements are allowed) and 4, 5, 6 or 8
|
||||||
</ol>
|
indices for 3D pattern (only 3d elements are allowed).
|
||||||
|
|
||||||
The 2D pattern must contain at least one element and at least one
|
The 2D pattern must contain at least one element and at least one
|
||||||
key-point. All key-points must lay on boundaries.
|
key-point. All key-points must lay on boundaries.
|
||||||
|
|
||||||
An example of a simple smp file and a preview of a pattern described
|
The 3D pattern must contain at least one element.
|
||||||
in this file:
|
|
||||||
|
|
||||||
\image html image94.gif
|
An example of a simple 2D pattern smp file:
|
||||||
|
|
||||||
|
\code
|
||||||
|
!!! SALOME 2D mesh pattern file
|
||||||
|
!!!
|
||||||
|
!!! Nb of points:
|
||||||
|
9
|
||||||
|
200 0 !- 0
|
||||||
|
100 0 !- 1
|
||||||
|
0 0 !- 2
|
||||||
|
0 -100 !- 3
|
||||||
|
0 -200 !- 4
|
||||||
|
100 -200 !- 5
|
||||||
|
200 -200 !- 6
|
||||||
|
200 -100 !- 7
|
||||||
|
100 -100 !- 8
|
||||||
|
!!! Indices of 4 key-points
|
||||||
|
2 0 4 6
|
||||||
|
!!! Indices of points of 6 elements
|
||||||
|
0 1 8
|
||||||
|
8 5 6 7
|
||||||
|
2 3 8
|
||||||
|
8 3 4 5
|
||||||
|
8 7 0
|
||||||
|
8 1 2
|
||||||
|
\endcode
|
||||||
|
|
||||||
|
The image below provides a preview of above described pattern:
|
||||||
|
|
||||||
|
\image html pattern2d.png
|
||||||
|
|
||||||
|
An example of a simple 3D pattern smp file:
|
||||||
|
|
||||||
|
\code
|
||||||
|
!!! SALOME 3D mesh pattern file
|
||||||
|
!!!
|
||||||
|
!!! Nb of points:
|
||||||
|
9
|
||||||
|
0 0 0 !- 0
|
||||||
|
1 0 0 !- 1
|
||||||
|
0 1 0 !- 2
|
||||||
|
1 1 0 !- 3
|
||||||
|
0 0 1 !- 4
|
||||||
|
1 0 1 !- 5
|
||||||
|
0 1 1 !- 6
|
||||||
|
1 1 1 !- 7
|
||||||
|
0.5 0.5 0.5 !- 8
|
||||||
|
!!! Indices of points of 6 elements:
|
||||||
|
0 1 5 4 8
|
||||||
|
7 5 1 3 8
|
||||||
|
3 2 6 7 8
|
||||||
|
2 0 4 6 8
|
||||||
|
0 2 3 1 8
|
||||||
|
4 5 7 6 8
|
||||||
|
\endcode
|
||||||
|
|
||||||
<br><h2>Application of pattern mapping</h2>
|
<br><h2>Application of pattern mapping</h2>
|
||||||
|
|
||||||
@ -50,86 +103,89 @@ The following dialog box shall appear:
|
|||||||
|
|
||||||
\image html patternmapping1.png
|
\image html patternmapping1.png
|
||||||
|
|
||||||
|
<center><b> 2D Pattern Mapping dialog box</b></center>
|
||||||
|
|
||||||
\image html patternmapping2.png
|
\image html patternmapping2.png
|
||||||
|
|
||||||
|
<center><b> 3D Pattern Mapping dialog box</b></center>
|
||||||
|
|
||||||
To apply a pattern to a geometrical object, you should specify:
|
To apply a pattern to a geometrical object, you should specify:
|
||||||
<ul>
|
|
||||||
<li>a face having the number of vertices equal to the number of
|
-# For 2D pattern
|
||||||
key-points in the pattern; the number of key-points on internal
|
- A face having the number of vertices equal to the number of
|
||||||
boundaries of a pattern must also be equal to the number of vertices
|
key-points in the pattern; the number of key-points on internal
|
||||||
on internal boundaries of a face;</li>
|
boundaries of a pattern must also be equal to the number of vertices
|
||||||
<li>a vertex to which the first key-point should be mapped;</li>
|
on internal boundaries of a face;
|
||||||
<li>reverse or not the order of key-points. (The order of vertices of
|
- A vertex to which the first key-point should be mapped;
|
||||||
a face is counterclockwise looking from outside).</li>
|
- Reverse or not the order of key-points. (The order of vertices of
|
||||||
</ul>
|
a face is counterclockwise looking from outside).
|
||||||
|
-# For 3D pattern
|
||||||
|
- 3D block (Solid) object;
|
||||||
|
- Two vertices that specify the order of nodes in the resulting
|
||||||
|
mesh.
|
||||||
|
|
||||||
Then you either load a .smp pattern file previously created manually
|
Then you either load a .smp pattern file previously created manually
|
||||||
by clicking on the <em>"Load pattern"</em> button, or click on the \b
|
by clicking on the <em>"Load pattern"</em> button, or click on the \b
|
||||||
New button for automatic generation.
|
New button for automatic generation of the pattern.
|
||||||
\n For an automatic generation you just specify a geometrical face
|
|
||||||
having a mesh built on it. Mesh nodes lying on face vertices become
|
For an automatic generation you just specify a geometrical face (for
|
||||||
key-points. Additionally, you may choose the way of getting nodes
|
2D) or solid (for 3d) having a mesh built on it. Mesh nodes lying on
|
||||||
coordinates by <b>projecting nodes on the face</b> instead of using
|
face vertices become key-points of 2D pattern. Additionally, for 2D
|
||||||
|
pattern you may choose the way of getting nodes coordinates by
|
||||||
|
<b>projecting nodes on the face</b> instead of using
|
||||||
"positions on face" generated by mesher (if there is any). Faces
|
"positions on face" generated by mesher (if there is any). Faces
|
||||||
having a seam edge can't be used for automatic pattern creation.
|
having a seam edge can't be used for automatic pattern creation.
|
||||||
|
|
||||||
When creating a pattern from an existing mesh, there are two possible
|
When creating a pattern from an existing mesh, there are two possible
|
||||||
cases:
|
cases:
|
||||||
<ol>
|
|
||||||
<li>A sub-mesh on face is selected. A pattern is created from the 2d
|
- A sub-mesh on face/solid is selected. A pattern is created from the 2d/3d
|
||||||
elements bound to a face by mesher. Node coordinates are either
|
elements bound to a face/solid by mesher. For 2D pattern, node coordinates are either
|
||||||
"positions on face" computed by mesher, or coordinates got by node
|
"positions on face" computed by mesher, or coordinates got by node
|
||||||
projection on a geometrical surface, according to your choice.</li>
|
projection on a geometrical surface, according to the user choice. For
|
||||||
<li>A mesh where the main shape is a face, is selected. A pattern is
|
3D pattern, nodes coordinates correspond to the nodes computed by mesher.
|
||||||
created from all the 2d elements in a mesh. If all mesh elements are
|
- A mesh where the main shape is a face/solid, is selected. A pattern is
|
||||||
build by mesher, the user can select the way of getting nodes
|
created from all the 2d/3d elements in a mesh. In addition, for 2D
|
||||||
coordinates, else all nodes are projected on a face surface.</li>
|
pattern, if all mesh elements are build by mesher, the user can select
|
||||||
</ol>
|
the way of getting nodes coordinates, else all nodes are projected on
|
||||||
|
a face surface.
|
||||||
|
|
||||||
\image html a-patterntype.png
|
\image html a-patterntype.png
|
||||||
|
|
||||||
|
<center><b> 2D Pattern Creation dialog box</b></center>
|
||||||
|
|
||||||
\image html a-patterntype1.png
|
\image html a-patterntype1.png
|
||||||
|
|
||||||
|
<center><b> 3D Pattern Creation dialog box</b></center>
|
||||||
|
|
||||||
<br><h2>Mapping algorithm</h2>
|
<br><h2>Mapping algorithm</h2>
|
||||||
|
|
||||||
The mapping algorithm is as follows:
|
The mapping algorithm for 2D case is as follows:
|
||||||
<ol>
|
|
||||||
<li>Key-points are set in the order that they are encountered when
|
|
||||||
walking along a pattern boundary so that elements are on the left. The
|
|
||||||
first key-point is preserved.
|
|
||||||
</li>
|
|
||||||
|
|
||||||
<li>Find geometrical vertices corresponding to key-points by vertices
|
- Key-points are set in the order that they are encountered when
|
||||||
order in a face boundary; here, "Reverse order of key-points" flag is
|
walking along a pattern boundary so that elements are on the left. The
|
||||||
taken into account.
|
first key-point is preserved.
|
||||||
|
- Find geometrical vertices corresponding to key-points by vertices
|
||||||
|
order in a face boundary; here, "Reverse order of key-points" flag is
|
||||||
|
taken into account. \image html image95.gif
|
||||||
|
- Boundary nodes of a pattern are mapped onto edges of a face: a
|
||||||
|
node located between certain key-points on a pattern boundary is
|
||||||
|
mapped on a geometrical edge limited by corresponding geometrical
|
||||||
|
vertices. Node position on an edge reflects its distance from two
|
||||||
|
key-points. \image html image96.gif
|
||||||
|
- Coordinates of a non-boundary node in a parametric space of a face
|
||||||
|
are defined as following. In a parametric space of a pattern, a node
|
||||||
|
lays at the intersection of two iso-lines, each of which intersects a
|
||||||
|
pattern boundary at least at two points. Knowing mapped positions of
|
||||||
|
boundary nodes, we find where isoline-boundary intersection points are
|
||||||
|
mapped to, and hence we can find mapped isolines direction and then,
|
||||||
|
two node positions on two mapped isolines. The eventual mapped
|
||||||
|
position of a node is found as an average of positions on mapped
|
||||||
|
isolines. \image html image97.gif
|
||||||
|
|
||||||
\image html image95.gif
|
For 3D case the algorithm is similar.
|
||||||
</li>
|
|
||||||
|
|
||||||
<li>Boundary nodes of a pattern are mapped onto edges of a face: a
|
<b>See Also</b> a sample TUI Script of a
|
||||||
node located between certain key-points on a pattern boundary is
|
|
||||||
mapped on a geometrical edge limited by corresponding geometrical
|
|
||||||
vertices. Node position on an edge reflects its distance from two
|
|
||||||
key-points.
|
|
||||||
|
|
||||||
\image html image96.gif
|
|
||||||
</li>
|
|
||||||
|
|
||||||
<li>Coordinates of a non-boundary node in a parametric space of a face
|
|
||||||
are defined as following. In a parametric space of a pattern, a node
|
|
||||||
lays at the intersection of two iso-lines, each of which intersects a
|
|
||||||
pattern boundary at least at two points. Knowing mapped positions of
|
|
||||||
boundary nodes, we find where isoline-boundary intersection points are
|
|
||||||
mapped to, and hence we can find mapped isolines direction and then,
|
|
||||||
two node positions on two mapped isolines. The eventual mapped
|
|
||||||
position of a node is found as an average of positions on mapped
|
|
||||||
isolines.
|
|
||||||
|
|
||||||
\image html image97.gif
|
|
||||||
</li>
|
|
||||||
</ol>
|
|
||||||
|
|
||||||
<br><b>See Also</b> a sample TUI Script of a
|
|
||||||
\ref tui_pattern_mapping "Pattern Mapping" operation.
|
\ref tui_pattern_mapping "Pattern Mapping" operation.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
@ -768,7 +768,6 @@ mesh.RotationSweepObject(GroupRotate, axisXYZ, angle45, 4, 1e-5)
|
|||||||
|
|
||||||
\code
|
\code
|
||||||
import geompy
|
import geompy
|
||||||
|
|
||||||
import smesh
|
import smesh
|
||||||
|
|
||||||
# define the geometry
|
# define the geometry
|
||||||
@ -802,17 +801,100 @@ algo2D.MaxElementArea(240)
|
|||||||
isDone = Mesh_2.Compute()
|
isDone = Mesh_2.Compute()
|
||||||
if not isDone: print 'Mesh Mesh_2 : computation failed'
|
if not isDone: print 'Mesh Mesh_2 : computation failed'
|
||||||
|
|
||||||
# create a pattern
|
# create a 2d pattern
|
||||||
pattern = smesh.GetPattern()
|
pattern = smesh.GetPattern()
|
||||||
|
|
||||||
isDone = pattern.LoadFromFace(Mesh_2.GetMesh(), Face_2, 0)
|
isDone = pattern.LoadFromFace(Mesh_2.GetMesh(), Face_2, 0)
|
||||||
if (isDone != 1): print 'LoadFromFace :', pattern.GetErrorCode()
|
if (isDone != 1): print 'LoadFromFace :', pattern.GetErrorCode()
|
||||||
|
|
||||||
# apply the pattern to a face of the first mesh
|
# apply the pattern to a face of the first mesh
|
||||||
pattern.ApplyToMeshFaces(Mesh_1.GetMesh(), [17], 0, 0)
|
facesToSplit = Mesh_1.GetElementsByType(smesh.SMESH.FACE)
|
||||||
|
print "Splitting %d rectangular face(s) to %d triangles..."%(len(facesToSplit), 2*len(facesToSplit))
|
||||||
|
pattern.ApplyToMeshFaces(Mesh_1.GetMesh(), facesToSplit, 0, 0)
|
||||||
isDone = pattern.MakeMesh(Mesh_1.GetMesh(), 0, 0)
|
isDone = pattern.MakeMesh(Mesh_1.GetMesh(), 0, 0)
|
||||||
if (isDone != 1): print 'MakeMesh :', pattern.GetErrorCode()
|
if (isDone != 1): print 'MakeMesh :', pattern.GetErrorCode()
|
||||||
|
|
||||||
|
# create quadrangle mesh
|
||||||
|
Mesh_3 = smesh.Mesh(Box_1)
|
||||||
|
Mesh_3.Segment().NumberOfSegments(1)
|
||||||
|
Mesh_3.Quadrangle()
|
||||||
|
Mesh_3.Hexahedron()
|
||||||
|
isDone = Mesh_3.Compute()
|
||||||
|
if not isDone: print 'Mesh Mesh_3 : computation failed'
|
||||||
|
|
||||||
|
# create a 3d pattern (hexahedrons)
|
||||||
|
pattern_hexa = smesh.GetPattern()
|
||||||
|
|
||||||
|
smp_hexa = """!!! Nb of points:
|
||||||
|
15
|
||||||
|
0 0 0 !- 0
|
||||||
|
1 0 0 !- 1
|
||||||
|
0 1 0 !- 2
|
||||||
|
1 1 0 !- 3
|
||||||
|
0 0 1 !- 4
|
||||||
|
1 0 1 !- 5
|
||||||
|
0 1 1 !- 6
|
||||||
|
1 1 1 !- 7
|
||||||
|
0.5 0 0.5 !- 8
|
||||||
|
0.5 0 1 !- 9
|
||||||
|
0.5 0.5 0.5 !- 10
|
||||||
|
0.5 0.5 1 !- 11
|
||||||
|
1 0 0.5 !- 12
|
||||||
|
1 0.5 0.5 !- 13
|
||||||
|
1 0.5 1 !- 14
|
||||||
|
!!! Indices of points of 4 elements:
|
||||||
|
8 12 5 9 10 13 14 11
|
||||||
|
0 8 9 4 2 10 11 6
|
||||||
|
2 10 11 6 3 13 14 7
|
||||||
|
0 1 12 8 2 3 13 10"""
|
||||||
|
|
||||||
|
pattern_hexa.LoadFromFile(smp_hexa)
|
||||||
|
|
||||||
|
# apply the pattern to a mesh
|
||||||
|
volsToSplit = Mesh_3.GetElementsByType(smesh.SMESH.VOLUME)
|
||||||
|
print "Splitting %d hexa volume(s) to %d hexas..."%(len(volsToSplit), 4*len(volsToSplit))
|
||||||
|
pattern_hexa.ApplyToHexahedrons(Mesh_3.GetMesh(), volsToSplit,0,3)
|
||||||
|
isDone = pattern_hexa.MakeMesh(Mesh_3.GetMesh(), True, True)
|
||||||
|
if (isDone != 1): print 'MakeMesh :', pattern_hexa.GetErrorCode()
|
||||||
|
|
||||||
|
# create one more quadrangle mesh
|
||||||
|
Mesh_4 = smesh.Mesh(Box_1)
|
||||||
|
Mesh_4.Segment().NumberOfSegments(1)
|
||||||
|
Mesh_4.Quadrangle()
|
||||||
|
Mesh_4.Hexahedron()
|
||||||
|
isDone = Mesh_4.Compute()
|
||||||
|
if not isDone: print 'Mesh Mesh_4 : computation failed'
|
||||||
|
|
||||||
|
# create another 3d pattern (pyramids)
|
||||||
|
pattern_pyra = smesh.GetPattern()
|
||||||
|
|
||||||
|
smp_pyra = """!!! Nb of points:
|
||||||
|
9
|
||||||
|
0 0 0 !- 0
|
||||||
|
1 0 0 !- 1
|
||||||
|
0 1 0 !- 2
|
||||||
|
1 1 0 !- 3
|
||||||
|
0 0 1 !- 4
|
||||||
|
1 0 1 !- 5
|
||||||
|
0 1 1 !- 6
|
||||||
|
1 1 1 !- 7
|
||||||
|
0.5 0.5 0.5 !- 8
|
||||||
|
!!! Indices of points of 6 elements:
|
||||||
|
0 1 5 4 8
|
||||||
|
7 5 1 3 8
|
||||||
|
3 2 6 7 8
|
||||||
|
2 0 4 6 8
|
||||||
|
0 2 3 1 8
|
||||||
|
4 5 7 6 8"""
|
||||||
|
|
||||||
|
pattern_pyra.LoadFromFile(smp_pyra)
|
||||||
|
|
||||||
|
# apply the pattern to a face mesh
|
||||||
|
volsToSplit = Mesh_4.GetElementsByType(smesh.SMESH.VOLUME)
|
||||||
|
print "Splitting %d hexa volume(s) to %d hexas..."%(len(volsToSplit), 6*len(volsToSplit))
|
||||||
|
pattern_pyra.ApplyToHexahedrons(Mesh_4.GetMesh(), volsToSplit,1,0)
|
||||||
|
isDone = pattern_pyra.MakeMesh(Mesh_4.GetMesh(), True, True)
|
||||||
|
if (isDone != 1): print 'MakeMesh :', pattern_pyra.GetErrorCode()
|
||||||
\endcode
|
\endcode
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
Loading…
Reference in New Issue
Block a user