-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
first attempt at surface reconstruction
- Loading branch information
1 parent
ad77313
commit 54b9d75
Showing
11 changed files
with
1,647 additions
and
35 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import math | ||
from pathlib import Path | ||
from compas.datastructures import Mesh | ||
from compas.geometry import Pointcloud | ||
from compas.geometry import Rotation, Scale | ||
from compas_view2.app import App | ||
from compas_cgal.reconstruction import poisson_surface_reconstruction | ||
|
||
HERE = Path(__file__).parent | ||
DATA = HERE / ".." / ".." / "data" | ||
FILE = DATA / "oni.xyz" | ||
|
||
points = [] | ||
normals = [] | ||
with open(FILE, "r") as f: | ||
for line in f: | ||
x, y, z, nx, ny, nz = line.strip().split() | ||
points.append([float(x), float(y), float(z)]) | ||
normals.append([float(nx), float(ny), float(nz)]) | ||
|
||
V, F = poisson_surface_reconstruction(points, normals) | ||
mesh = Mesh.from_vertices_and_faces(V, F) | ||
|
||
R = Rotation.from_axis_and_angle([1, 0, 0], math.radians(90)) | ||
S = Scale.from_factors([5, 5, 5]) | ||
T = R * S | ||
|
||
cloud = Pointcloud(V) | ||
cloud.transform(T) | ||
mesh.transform(T) | ||
|
||
viewer = App(width=1600, height=900) | ||
viewer.view.camera.position = [-5, -5, 1.5] | ||
viewer.view.camera.look_at([0, 0, 1.5]) | ||
|
||
viewer.add(mesh) | ||
viewer.add(cloud) | ||
|
||
viewer.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
******************************************************************************** | ||
Poisson Surface Reconstruction | ||
******************************************************************************** | ||
|
||
.. figure:: /_images/cgal_reconstruction.png | ||
:figclass: figure | ||
:class: figure-img img-fluid | ||
|
||
|
||
.. literalinclude:: reconstruction.py | ||
:language: python |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from __future__ import annotations | ||
import numpy as np | ||
from compas_cgal._cgal import reconstruction | ||
|
||
|
||
def poisson_surface_reconstruction(points, normals): | ||
P = np.asarray(points, dtype=np.float64) | ||
N = np.asarray(normals, dtype=np.float64) | ||
return reconstruction.poisson_surface_reconstruction(P, N) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters