# MakerBot/Cleaning Up Point Cloud Meshes in Meshlab For 3D Printing
### Purpose

Cleaning up a point cloud mesh of an object in Meshlab so that it can be printed using a 3D printer.

## Deleting Unwanted Background Points

    1. Open the file that was taken from the Kinect in MeshLab. Select Points Output Mesh
    2. Select either the desired points or the unwanted points using the Select Vertices tool. Rotate the mesh to make selecting easier.
    3. If a selection is made around the points you want to keep, then invert the selection using Filter -> Render -> Invert Selection. Press ctrl + delete to delete unwanted points from the mesh.
    4. Use Export as... (.ply) to save progress. Saving it at this point provides a good backup point, and the image is zoomed and centered when re-opened from the new file.

## Rendering the Object
### Option "A"

    5a. Under the Filters tab in the navigation menu choose Sampling -> Poisson-disk Sampling. In the Number of Samples, pick between 60000 and 100000 sample points(sometimes the system crashes.) Remember to check the Base Mesh Subsampling box or you will get an error.
    6a. Once the sampling has completed, a new layer will be added. Open the layers window under View -> Open Layer Dialog and make sure the Poison-disk Samples layer is highlighted.
    7a. Next, go to Filters –> Normals, Curvatures and Orientation -> Compute normals for point sets. In the new window, put a number greater than 15 for the Number of Neighbors.
    8a. Click Apply and manually Close that menu.
    9a. Then, go to Filters —> Points —> Surface Reconstruction Poisson. This will create a new layer called Poisson Mesh. From there you can add surfaces to the Model.
    10a. Finally save the model in a .obj file format to be opened in Maya or Blender.
    Note: Meshlab can export the mesh as a .stl file for 3D printing with the MakerBot. However, further 3D modeling is required to create a base, ground layer, or support platform for the object before a printable code can be generated by the Replicator-G software used by the MakerBot.

### Option B

    5b. Distribute normals using Render -> Show Vertex Normals. This will create normals pointing backwards, so they will need to be recomputed so that the normals are facing forward.
    6b. Recompute normals using Filter > Point Set -> Compute normals for point sets, change number to 16 for the number of neighbors and also check the box for Flip Normals. Change the camera to -1000 so that the sampling program knows that the cloud point data was taken from a large distance, this would give it a better idea where the normals should go.
    7b. Turn on layers from the top menu bar View -> Open Layer Dialog.
    8b. Now create a subset of the point cloud, go to Filters > Sampling > Poisson -Disk sampling, change the Number of Samples to 5000 and check the box for Base Mesh Subsampling. This will create an even sampling distribution of the cloud points, and will give a general surface to work with.
    9b. Click the Poisson-disk Samples layer. Now go to Filters > Point Set > Surface Reconstruction: Poisson, set parameters, 12 for Octree Depth and 7 for Solver Divide, these numbers can be changed depending on the scale of the original point cloud mesh. Make the numbers bigger if the point cloud is big.
    10b. Turn on the Light found within the tool bar and also turn on Smoothing which is next to the light button.
    11b. Now approximate more normals using the point cloud to add more detail. This time distribute points by going to Filter > Re-meshing-simplification and reconstruction > Use sub-division algorithm called LS3 loop. This algorithm will add more detail to the mesh. Sub-sample it three times by setting Iterations = 3 adding more detail
    12b. Use File -> Export as... to save the final version of the mesh which can be printed using a 3d printer.final image