How to create a more accuracy triangles?

Hi Dears.
I'm beginner of OpenCC.
I saw a meshing animation in showroom section
: creating a sphere, creating a mesh, and "creating more and more accuracy mesh"

I am looking for a sample.
I found a sample , 02_7_TopologyTriangulation.
That show how to make some shape and create triangles from the shape.
(I cannot understand whole code.)

How can I create more accuracy triangles, adding some code
: just call some functins? calculate the first mesh result?

Please, show me a key point,
or very kindly a sample. ^^

Thank you for reading my poor English.
I'm waiting for your reply.

Have a nice day.
BYE.

Thomas Paviot's picture

Hi,

I guess you talk about the Mesh() method of the BRepMesh class. This method takes two parameters: the TopoDS_Shape to mesh and a Standard_Real float number (named d). The more d is small, the more precise is the mesh.

Here is a part of a pythonOCC sample that shows howto mesh a TopoDS_Shape (a sphere actually) with this basic algorithm:

shape = BRepPrimAPI_MakeSphere(gp_Pnt(100,20,20),80).Shape()
MESH_QUALITY = 0.8 # test with 0.5, 0.1, 0.05 etc.
#
# Mesh the shape
#
BRepMesh().Mesh(shape,MESH_QUALITY)
builder = BRep_Builder()
Comp = TopoDS_Compound()
builder.MakeCompound(Comp)

ex = TopExp_Explorer(shape,TopAbs_FACE)
while ex.More():
F = TopoDS().Face(ex.Current())
L = TopLoc_Location()
facing = (BRep_Tool().Triangulation(F,L)).GetObject()
tab = facing.Nodes()
tri = facing.Triangles()
for i in range(1,facing.NbTriangles()+1):
trian = tri.Value(i)
index1, index2, index3 = trian.Get()
for j in range(1,4):
if j==1:
M = index1
N = index2
elif j==2:
N = index3
elif j==3:
M = index2
ME = BRepBuilderAPI_MakeEdge(tab.Value(M),tab.Value(N))
if ME.IsDone():
builder.Add(Comp,ME.Edge())
ex.Next()

# Display
display.EraseAll()
display.DisplayShape(shape)
display.DisplayShape(Comp)

Complete source code of this sample is available here: http://svn.gna.org/viewcvs/pythonocc/trunk/src/samples/Level1/Mesh/simpl...

Regards,

Thomas

iphds's picture

I'm very thank you for your answer.