compas-dev / compas_cgal

COMPAS package for working with CGAL.
https://compas.dev/compas_cgal
GNU Lesser General Public License v3.0
23 stars 5 forks source link

Examples not up-to-date #9

Closed HagegeR closed 3 years ago

HagegeR commented 3 years ago

Describe the bug Any example on this repository which have import from compas_viewers can't work because of the refactor that have been done. the new examples should use compas_plotters.meshplotter apparently, I've tried to make the example work as expected but I didn't get there apparently, I'm still giving you the script that is close to the fix (to the best of my knowledge)

from compas.geometry import Box
from compas.geometry import Sphere
from compas.datastructures import Mesh

from compas_plotters.meshplotter import MeshPlotter

from compas_cgal.booleans import boolean_union
from compas_cgal.meshing import remesh

# ==============================================================================
# Make a box and a sphere
# ==============================================================================

box = Box.from_width_height_depth(2, 2, 2)
box = Mesh.from_shape(box)
box.quads_to_triangles()

A = box.to_vertices_and_faces()

sphere = Sphere(Point(1, 1, 1), 1)
sphere = Mesh.from_shape(sphere, u=30, v=30)
sphere.quads_to_triangles()

B = sphere.to_vertices_and_faces()

# ==============================================================================
# Remesh the sphere
# ==============================================================================

B = remesh(B, 0.3, 10)

# ==============================================================================
# Compute the boolean mesh
# ==============================================================================

V, F = boolean_union(A, B)

mesh = Mesh.from_vertices_and_faces(V, F)

# ==============================================================================
# Visualize
# ==============================================================================

plotter = MeshPlotter(mesh, color='#cccccc')
plotter.draw_edges()
plotter.draw_faces()

def onpick(event):
    index = event.ind[0]
    for i, text in enumerate(plotter.axes.texts):
        if i == index:
            text.set_visible(True)
        else:
            text.set_visible(False)
    plotter.update()

plotter.register_listener(onpick)
plotter.show()

To Reproduce

  1. install COMPAS and compas_cgal
  2. try to run the Example
  3. fail on import of compas_viewers

Expected behavior A working example set which helps developer use this great cgal bindings.

Desktop (please complete the following information):

tomvanmele commented 3 years ago

hi there,

you are right, the examples were outdated. thanks for reporting...

i have updated to the new viewer, which is available at https://github.com/compas-dev/compas_view2

the viewer is not yet conda-installable (should be available later this week) but if you follow the getting started instructions in the viewer docs (https://compas.dev/compas_view2/latest/gettingstarted.html) you should have no problem installing with pip

let me know if you still have problems.

it is best to make a new environment for all of this because the old and the new viewer have conflicting dependencies...

HagegeR commented 3 years ago

Hi, thanks for your help, looking forward to the updated version being integrated into conda!

I'll make a new environment and report back ASAP 👍

tomvanmele commented 3 years ago

@HagegeR this working now?

HagegeR commented 3 years ago

well the viewer is not integrated as a package so it's difficult to run for me, but when I delete the visualization part it runs

tomvanmele commented 3 years ago

okay thanks for checking. will close this then...

HagegeR commented 3 years ago

I've tested the 0.1.2 version, with the new viewer, after installing manually freetype-py, typing_extensions, and nptyping (since the packages was not with those apparently in win-64) it worked! thanks!

tomvanmele commented 3 years ago

ha thanks for reporting back. will add those to the release...