{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-guides/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":[]},"type":"markdown"},"seo":{"title":"Working With Triangle Mesh Data","description":"Accelerate E&P application development and protect your innovation by consuming our Data and Domain APIs / Platform APIs.","lang":"en-US","meta":[{"name":"robots","content":"noindex"}],"llmstxt":{"hide":false}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"working-with-triangle-mesh-data","__idx":0},"children":["Working With Triangle Mesh Data"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["A triangle mesh data object is used to represent complex surfaces that can be described by a set of adjacent triangles."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Note"]},": you will need to include GocadData in your ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Module Dependencies"]}," list"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"creating-a-trianglemesh-data-object-from-a-file","__idx":1},"children":["Creating a TriangleMesh data object from a file"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The most common file format for triangle mesh data is the Gocad format from Paradigm. Gocad files have extension \".ts\". A Gocad file can be loaded as follows:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"    import com.interactive.intviewerapi.data.IData;\n    import com.interactive.intviewerapi.data.tmesh.ITriangleMeshData;\n    import com.interactive.intviewerapi.util.DialogManager;\n    ...\n        IData gcd = null;\n        try {\n            gcd = IData.factory.createNewInstance(\"/data/GOCAD/SALT.ts\");\n        } catch (Exception ex) {\n            DialogManager.getDefault().showMessageDialog(\"Error loading Gocad file SALT.ts.\",\n                    \"Error Loading Gocad File\", DialogManager.ERROR);\n            return;\n        }\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Since Gocad files can contain various types of data, you need to verify that the type of data returned is indeed a ITriangleMeshData object."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"    if (gcd instanceof ITriangleMeshData) {\n       ...\n    }\n"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"creating-a-trianglemesh-data-object-programmatically","__idx":2},"children":["Creating a TriangleMesh data object programmatically"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"        float vertices[] = {0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1};\n        int indexes[] = {0, 1, 3,\n                         1, 2, 3,\n                         4, 5, 0,\n                         5, 0, 0,\n                         1, 5, 2,\n                         5, 6, 2,\n                         3, 2, 7,\n                         2, 6, 7,\n                         4, 0, 7,\n                         0, 3, 7,\n                         7, 6, 4};\n        ITriangleMeshData cube = new TriangleMeshData(\"cube\", vertices, indexes);\n"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"retrieving-the-vertices-and-indexes-of-a-trianglemesh","__idx":3},"children":["Retrieving the vertices and indexes of a TriangleMesh"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"    ITriangleMeshData data = ...\n    int[] indexes = data.getIndexes();\n    float[] vertices = data.getVertices();\n    System.out.println(\"Number of triangles = \" + (data.getIndexes().length/3));\n"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"smoothing-a-trianglemesh-surface","__idx":4},"children":["Smoothing a TriangleMesh surface"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Utility class TriangleSmoothing provides an implementation of Loop's scheme for smoothing a triangle mesh surface. Each path subdvides the triangles into four sub-triangles."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"    import com.interactive.intviewerapi.data.tmesh.TriangleSmoothing;\n    ...\n    TriangleSmoothing ts = new TriangleSmoothing(2, cube.getVertices(), cube.getIndexes());\n    ITriangleMeshData smoothCube = new TriangleMeshData(\"smooth cube\", ts.getVertices(), ts.getIndexes());\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["before smoothing after smoothing (2 passes)"]}]},"headings":[{"value":"Working With Triangle Mesh Data","id":"working-with-triangle-mesh-data","depth":1},{"value":"Creating a TriangleMesh data object from a file","id":"creating-a-trianglemesh-data-object-from-a-file","depth":3},{"value":"Creating a TriangleMesh data object programmatically","id":"creating-a-trianglemesh-data-object-programmatically","depth":3},{"value":"Retrieving the vertices and indexes of a TriangleMesh","id":"retrieving-the-vertices-and-indexes-of-a-trianglemesh","depth":3},{"value":"Smoothing a TriangleMesh surface","id":"smoothing-a-trianglemesh-surface","depth":3}],"frontmatter":{"title":"Working With Triangle Mesh Data","pageId":"intviewer-apis-for-data/working-with-triangle-mesh-data","seo":{"title":"Working With Triangle Mesh Data"}},"lastModified":"2026-10-22T14:32:05.575Z","pagePropGetterError":{"message":"","name":""}},"slug":"/solutions/intviewer/intviewer-apis-for-data/working-with-triangle-mesh-data","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}