Out of my curiosity, here is a variant that draws mesh triangles (surfaces) only in Dynamo
nearly 96,000 surfaces to display, my laptop suffered a bit ![]()
"""
original author Ramiz Mohareb modify by Cyril Poupin
25.03.2022
enramiz@yahoo.com
"""
import clr
import sys
import re
import System
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference('Python.Included')
import Python.Included as pyInc
path_py3_lib = pyInc.Installer.EmbeddedPythonHome
sys.path.append(path_py3_lib + r'\Lib\site-packages')
import random
import numpy as np
import numpy as np
import open3d as o3d
import matplotlib.pyplot as plt
def computePoint(a):
if np.isnan(a[0]):
return None
else:
return Point.ByCoordinates(a[0], a[1], a[2])
def computeTriangleSurface(a, DS_ptarr):
lstPt = [DS_ptarr[a[i]] for i in range(3)]
if all(isinstance(x, Point) for x in lstPt):
try:
return Surface.ByPerimeterPoints(lstPt)
except:
return None
else:
return None
filepath=IN[0]
pcd = o3d.io.read_point_cloud(filepath)
distances = pcd.compute_nearest_neighbor_distance()
avg_dist = np.mean(distances)
radius = 1.5 * avg_dist
#computing the mehs
bpa_mesh = o3d.geometry.TriangleMesh.create_from_point_cloud_ball_pivoting(pcd,o3d.utility.DoubleVector([radius, radius*2]))
#dec_mesh1 = bpa_mesh.filter_smooth_simple(number_of_iterations=1)
dec_mesh1 = bpa_mesh.filter_smooth_taubin(number_of_iterations=10)
#dec_mesh1 = bpa_mesh.simplify_quadric_decimation(100000)
dec_mesh1.remove_degenerate_triangles()
dec_mesh1.remove_duplicated_triangles()
dec_mesh1.remove_duplicated_vertices()
dec_mesh1.remove_non_manifold_edges()
arr_vertices = np.array(dec_mesh1.vertices)
arr_triangles = np.array(dec_mesh1.triangles)
DS_ptarr = np.apply_along_axis(computePoint, 1, arr_vertices)
DS_surface_arr = np.apply_along_axis(computeTriangleSurface, 1, arr_triangles, DS_ptarr)
#
OUT = DS_surface_arr
download and rename nefertiti_HQ2.txt to nefertiti_HQ2.ply
nefertiti_HQ2.txt (6.2 MB)
