Imports ccm2math1Lib Imports cm2meshtools = ccm2meshtoolsLib Imports cm2meshtools1d = ccm2meshtools1dLib Imports cm2triamesh = ccm2triameshLib Imports cm2quadmesh = ccm2quadmeshLib ' Very simple VB program to mesh a square with triangles or quadrangles. ' Uses CM2 TriaMesh and CM2 QuadMesh through the COM interface. Module Module1 Sub Main() Dim msg1 As String ' For error messages. Try Dim pos As New DoubleMat Dim indices As New UIntVec Dim connectB As New UIntMat Dim connectM As New UIntMat Dim MT As New cm2meshtools.MeshTools Dim MT1D As New cm2meshtools1d.MeshTools1D Dim mesherT3 As New cm2triamesh.mesher Dim mesherQ4 As New cm2quadmesh.mesher ' Dim dataT3 As New cm2triamesh.data_type Dim dataQ4 As New cm2quadmesh.data_type ' Registration of the DLLs mesherT3.registration("Licensed to DEMO.", "FC5B65DEDF55") ' All cm2triamesh.mesher are now runnable. mesherQ4.registration("Licensed to DEMO.", "7FA4A61046AA") ' All cm2quadmesh.mesher are now runnable. ' Construct the four vertices of the square. pos.push_back2(0.0, 0.0) pos.push_back2(10.0, 0.0) pos.push_back2(10.0, 10.0) pos.push_back2(0.0, 10.0) ' Mesh the four segments (10 elements on each segment). MT1D.mesh_straight1(pos, 0, 1, 10, indices) indices.pop_back() MT1D.mesh_straight1(pos, 1, 2, 10, indices) indices.pop_back() MT1D.mesh_straight1(pos, 2, 3, 10, indices) indices.pop_back() MT1D.mesh_straight1(pos, 3, 0, 10, indices) MT1D.indices_to_connectE2(indices, connectB) ' Do the triangle mesh. dataT3.pos = pos dataT3.connectB = connectB mesherT3.run(dataT3) If dataT3.error_code <> 0 Then msg1 = dataT3.msg1 Throw New Exception("CM2 Exception: " + msg1) End If pos = dataT3.pos connectM = dataT3.connectM dataT3.print_info() ' MEDIT output of the triangle mesh MT.medit_output("T3.mesh", pos, connectM, cm2meshtools.Celement_type.CM2_FACET3) ' Do the quadrangle mesh dataQ4.pos = pos dataQ4.connectB = connectB mesherQ4.run(dataQ4) If dataQ4.error_code <> 0 Then msg1 = dataQ4.msg1 Throw New Exception("CM2 Exception: " + msg1) End If pos = dataQ4.pos connectM = dataQ4.connectM dataQ4.print_info() ' MEDIT output of the quadrangle mesh MT.medit_output("Q4.mesh", pos, connectM, cm2meshtools.Celement_type.CM2_FACEQ4) Catch ex As Exception Console.WriteLine(ex.Message()) End Try End Sub End Module