Back to index

salome-smesh  6.5.0
Functions | Variables
ex29_refine Namespace Reference

Functions

def node
def triangle
def SplitTrianglesIn4
def refine

Variables

string path = "/tmp/ex29_%s_"
string name = "Carre"
float x0 = 0.0
float x1 = 1.0
float x2 = 1.0
float x3 = 0.0
tuple P0 = geompy.MakeVertex(x0, y0, z0)
tuple P1 = geompy.MakeVertex(x1, y1, z1)
tuple P2 = geompy.MakeVertex(x2, y2, z2)
tuple P3 = geompy.MakeVertex(x3, y3, z3)
tuple square = geompy.MakeQuad4Vertices(P0, P1, P2, P3)
tuple MyMesh = smesh.Mesh(square)
tuple algo2D = MyMesh.Triangle()
int NbCells1 = 110
int NbCells2 = 4
int NbCells3 = 4
int NbCells4 = 4

Function Documentation

def ex29_refine.node (   m,
  f,
  n1,
  n2,
  lnv 
)

Definition at line 41 of file ex29_refine.py.

00041 
00042 def node(m, f, n1, n2, lnv):
00043     x1, y1, z1 = m.GetNodeXYZ(n1)
00044     x2, y2, z2 = m.GetNodeXYZ(n2)
00045 
00046     x = (x1 + x2) / 2.0
00047     y = (y1 + y2) / 2.0
00048     z = (z1 + z2) / 2.0
00049 
00050     i = m.AddNode(x, y, z)
00051 
00052     in1 = m.GetShapeID(n1)
00053     in2 = m.GetShapeID(n2)
00054 
00055     if (in1==f) or (in2==f):
00056         m.SetNodeOnFace(i, f, 0, 0)
00057 
00058     else:
00059         e1 = m.AddEdge([ n1, i  ])
00060         e2 = m.AddEdge([ i , n2 ])
00061 
00062         if n1 in lnv:
00063             e = in2
00064         else:
00065             e = in1
00066 
00067         m.SetMeshElementOnShape(e1, e)
00068         m.SetMeshElementOnShape(e2, e)
00069         m.SetNodeOnEdge(i, e, 0)
00070 
00071     return i
00072 
00073 # Add a triangle and associate to the CAD face
00074 # --------------------------------------------

Here is the caller graph for this function:

def ex29_refine.refine (   m,
  p1,
  p2,
  n,
  k,
  name 
)

Definition at line 135 of file ex29_refine.py.

00135 
00136 def refine(m, p1, p2, n, k, name):
00137     s = m.GetShape()
00138 
00139     g = geompy.CreateGroup(s, geompy.ShapeType["EDGE"])
00140     e = geompy.GetEdge(s, p1, p2)
00141     i = geompy.GetSubShapeID(s, e)
00142     geompy.AddObject(g, i)
00143     m.Group(g, name)
00144 
00145     a = m.Segment(e)
00146     a.NumberOfSegments(n, k)
00147 
00148 # Mesh the square
00149 # ---------------

Here is the caller graph for this function:

Definition at line 82 of file ex29_refine.py.

00082 
00083 def SplitTrianglesIn4(m):
00084     # Get all triangles
00085     triangles = m.GetElementsByType(smesh.FACE)
00086 
00087     # Remove all edges
00088     m.RemoveElements(m.GetElementsByType(smesh.EDGE))
00089 
00090     # Get the list of nodes (ids) associated with the CAD vertices
00091     shape = m.GetShape()
00092     lnv = []
00093     for v in geompy.SubShapeAll(shape, geompy.ShapeType["VERTEX"]):
00094         lnv = lnv + m.GetSubMeshNodesId(v, True)
00095 
00096     # Split every triangle
00097     for t in triangles:
00098         noeud_1, noeud_2, noeud_3 = m.GetElemNodes(t)
00099 
00100         face = m.GetShapeIDForElem(t)
00101 
00102         noeud_12 = node(m, face, noeud_1, noeud_2, lnv)
00103         noeud_23 = node(m, face, noeud_2, noeud_3, lnv)
00104         noeud_13 = node(m, face, noeud_1, noeud_3, lnv)
00105 
00106         triangle(m, face, noeud_1 , noeud_12, noeud_13)
00107         triangle(m, face, noeud_2 , noeud_23, noeud_12)
00108         triangle(m, face, noeud_3 , noeud_13, noeud_23)
00109         triangle(m, face, noeud_12, noeud_23, noeud_13)
00110 
00111     # Remove all initial triangles
00112     m.RemoveElements(triangles)
00113 
00114     # Merge all identical nodes
00115     m.MergeNodes(m.FindCoincidentNodes(0.0001))
00116 
00117 # Build a CAD square
00118 # ------------------

Here is the call graph for this function:

def ex29_refine.triangle (   m,
  f,
  n1,
  n2,
  n3 
)

Definition at line 75 of file ex29_refine.py.

00075 
00076 def triangle(m, f, n1, n2, n3):
00077     i = m.AddFace([ n1, n2, n3 ])
00078     m.SetMeshElementOnShape(i, f)
00079 
00080 # Split all triangles in 4 triangles
00081 # ----------------------------------

Here is the caller graph for this function:


Variable Documentation

tuple ex29_refine.algo2D = MyMesh.Triangle()

Definition at line 157 of file ex29_refine.py.

Definition at line 150 of file ex29_refine.py.

string ex29_refine.name = "Carre"

Definition at line 36 of file ex29_refine.py.

Definition at line 189 of file ex29_refine.py.

Definition at line 197 of file ex29_refine.py.

Definition at line 207 of file ex29_refine.py.

Definition at line 217 of file ex29_refine.py.

tuple ex29_refine.P0 = geompy.MakeVertex(x0, y0, z0)

Definition at line 124 of file ex29_refine.py.

tuple ex29_refine.P1 = geompy.MakeVertex(x1, y1, z1)

Definition at line 125 of file ex29_refine.py.

tuple ex29_refine.P2 = geompy.MakeVertex(x2, y2, z2)

Definition at line 126 of file ex29_refine.py.

tuple ex29_refine.P3 = geompy.MakeVertex(x3, y3, z3)

Definition at line 127 of file ex29_refine.py.

string ex29_refine.path = "/tmp/ex29_%s_"

Definition at line 33 of file ex29_refine.py.

tuple ex29_refine.square = geompy.MakeQuad4Vertices(P0, P1, P2, P3)

Definition at line 129 of file ex29_refine.py.

float ex29_refine.x0 = 0.0

Definition at line 119 of file ex29_refine.py.

float ex29_refine.x1 = 1.0

Definition at line 120 of file ex29_refine.py.

float ex29_refine.x2 = 1.0

Definition at line 121 of file ex29_refine.py.

float ex29_refine.x3 = 0.0

Definition at line 122 of file ex29_refine.py.