AutodeskAILab / Fusion360GalleryDataset

Data, tools, and documentation of the Fusion 360 Gallery Dataset
Other
421 stars 51 forks source link

How to visualize the Brep data ? #76

Closed cuge1995 closed 3 years ago

karldd commented 3 years ago

Which dataset are you interested in visualizing? Reconstruction or Segmentation?

cuge1995 commented 3 years ago

Which dataset are you interested in visualizing? Reconstruction or Segmentation?

The Segmentation

JoeLambourne commented 3 years ago

Hi @cuge1995,

Thank you for your interest in the segmentation dataset. The easiest way to view the segmentation is by visualizing the obj and seg files. Here is a very simple example using trimesh

import argparse
from pathlib import Path
import numpy as np
import trimesh

def view_file(obj_file, seg_file):
    mesh = trimesh.load_mesh(obj_file)

    color_map = np.array([
        [235, 85, 79, 255],  # ExtrudeSide
        [220, 198, 73, 255], # ExtrudeEnd
        [113, 227, 76, 255], # CutSide
        [0, 226, 124, 255],  # CutEnd
        [23, 213, 221, 255], # Fillet
        [92, 99, 222, 255],  # Chamfer
        [176, 57, 223, 255], # RevolveSide
        [238, 61, 178, 255]  # RevolveEnd
    ], dtype=np.uint8)
    tris_to_segments = np.loadtxt(seg_file, dtype=np.uint64)
    facet_colors = color_map[tris_to_segments]

    mesh.visual.face_colors = facet_colors
    mesh.show()

    print("Completed view_segmentation.py")

if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument("--meshes_folder", type=str, required=True, help="Path segmentation meshes folder")
    parser.add_argument("--file_stem", type=str, required=True, help="The name of the file to view (without extension).")
    args = parser.parse_args()

    meshes_folder = Path(args.meshes_folder)
    obj_file = meshes_folder / (args.file_stem + ".obj")
    seg_file = meshes_folder / (args.file_stem + ".seg")
    view_file(obj_file, seg_file)

To view one of the files, for example 52027_790dbc09_10.obj and 52027_790dbc09_10.seg you then run the script like this

python visualization/view_segmentation.py /path/to/SegmentationDataset/s1.0.0/meshes 52027_790dbc09_10

If you would like to look at the B-Rep data in the smt file format, then the best way to do this right now is using Fusion 360. It is free for students and academic use. The Fusion API provides lots of functionality for extracting data from the B-Rep model. The B-Rep faces are returned from the API in the same order as is provided in the s1.0.0/breps/*.seg and s1.0.0/timeline_info/*.json files.

You may also be interested to know we are working on a whole set of tools using Open Cascade to allow you to work with B-Rep data in STEP format and visualize results like the face segmentation. I'm not quite at the stage where I can give you code for this yet, but it is coming soon.

karldd commented 3 years ago

The segmentation viewer can now be found here: https://github.com/AutodeskAILab/Fusion360GalleryDataset/tree/master/tools/segmentation_viewer

CodingNovice7 commented 1 year ago

Which dataset are you interested in visualizing? Reconstruction or Segmentation?

Hi, is it possible to visualize this B-rep data for the Assembly and Assembly-Joint datasets?

karldd commented 1 year ago

There are a number of tools you can use:

CodingNovice7 commented 1 year ago

There are a number of tools you can use:

Thank you for such a timely and accurate response!