Hi All,
i would like to share how to create topography from point cloud by use dynamo. The idea itself is amazing.
first: if you need to get all point related to the topography you need to see the point cloud from the bottom
what you see now is the topography
second: use Open 3d pakedge to “Hidden point removal”
http://www.open3d.org/docs/release/tutorial/geometry/pointcloud.html#Visualize-point-cloud
"""
Create by Ramiz Mohareb
16-09-2022
enramiz@yahoo.com
this code use Open 3d Pack. http://www.open3d.org/
Packages required:
Open3d
numpy
"""
import clr
import sys
import re
import System
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
reDir = System.IO.DirectoryInfo(re.__file__)
path_py3_lib = reDir.Parent.Parent.FullName
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
import copy
filepath=IN[0]
point_cloud= np.loadtxt(filepath,skiprows=1)
#Format to open3d usable objects
pcd = o3d.geometry.PointCloud()
pcd.points = o3d.utility.Vector3dVector(point_cloud[:,:3])
#pcd.colors = o3d.utility.Vector3dVector(point_cloud[:,3:6]/255)
#pcd.normals = o3d.utility.Vector3dVector(point_cloud[:,3:6])
diameter = np.linalg.norm(
np.asarray(pcd.get_max_bound()) - np.asarray(pcd.get_min_bound()))
#diameter=10
print("Define parameters used for hidden_point_removal")
camera = [80, 0, -100]
radius = diameter * 100
radius=5000
print("Get all points that are visible from given view point")
_, pt_map = pcd.hidden_point_removal(camera, radius)
print("Visualize result")
pcd1 = pcd.select_by_index(pt_map)
o3d.visualization.draw_geometries([pcd1])
#pcd1 = copy.deepcopy(pcd1).translate((3572599.151, 5363571.883, 487.976))
#pcd = o3d.io.read_point_cloud("../../test_data/my_points.txt", format='xyz')
#OUT =o3d.io.write_point_cloud(IN[1]+'/Kienlesbergradweg_Ulm_Teil-Ost_D_DGM.pts', pcd1)
#
OUT=radius
#OUT = np.asarray(pcd1.points).tolist()