Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Artist refactoring #1175

Merged
merged 69 commits into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from 43 commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
9f51daf
notes about context
tomvanmele Aug 16, 2023
7b5189a
type stuff
tomvanmele Aug 18, 2023
113d8e5
example files
tomvanmele Aug 18, 2023
edf81f5
descriptor module
tomvanmele Aug 18, 2023
9526b7b
colordict
tomvanmele Aug 18, 2023
ebf3fe0
removed to descriptor
tomvanmele Aug 18, 2023
1dbb918
remove unneeded artists
tomvanmele Aug 18, 2023
881f3e8
update color dict attribute
tomvanmele Aug 18, 2023
d9bea85
fix bug in line endpoint
tomvanmele Aug 18, 2023
e5c880e
add append and insert
tomvanmele Aug 18, 2023
529dc65
fix bug in cylinder circle
tomvanmele Aug 18, 2023
ebb4dd8
rebase on geometry artist
tomvanmele Aug 18, 2023
9bd1190
update rhino artists
tomvanmele Aug 18, 2023
e373482
use native rhino box
tomvanmele Aug 18, 2023
25236fe
use native rhino cone
tomvanmele Aug 18, 2023
062e85d
use native rhino cylinder
tomvanmele Aug 18, 2023
956e0e6
native capsule
tomvanmele Aug 19, 2023
393bee0
native sphere
tomvanmele Aug 19, 2023
e34ac07
capsule as brep pipe
tomvanmele Aug 19, 2023
4916f90
sphere example
tomvanmele Aug 19, 2023
05b9db5
torus as brep
tomvanmele Aug 19, 2023
d3d7210
clean up conversions
tomvanmele Aug 22, 2023
3879e2b
object attributes helper
tomvanmele Aug 22, 2023
9ed1aa7
direct drawing of native geometry
tomvanmele Aug 22, 2023
56dc846
basic example files for testing
tomvanmele Aug 22, 2023
a992fe6
log
tomvanmele Aug 23, 2023
6e4cc94
lots of stuff
tomvanmele Sep 6, 2023
977b252
updated GH artists to use new conversion functions
tomvanmele Sep 6, 2023
ee7602b
added rhino mesh user data to compas mesh attributes
tomvanmele Sep 14, 2023
bb48185
remove plotter
tomvanmele Sep 14, 2023
9519f94
update blender conversions
tomvanmele Sep 14, 2023
b3b1abc
base attribute descriptor
tomvanmele Sep 14, 2023
a3ac99a
unregister blender nurbs plugin
tomvanmele Sep 14, 2023
8b268fb
ignore files in temp
tomvanmele Sep 14, 2023
1db8dcf
blender nurbs curve plugin
tomvanmele Sep 14, 2023
6581ca4
plane is constructed on the fly based on frame
tomvanmele Sep 14, 2023
7984648
upgrade rhino artists
tomvanmele Sep 14, 2023
54b9b35
register item and add transformation
tomvanmele Sep 14, 2023
0ffbf0a
simplify base data structure artists
tomvanmele Sep 14, 2023
80672b0
type stuff
tomvanmele Sep 14, 2023
1a93263
blender artist upgrade part 1
tomvanmele Sep 14, 2023
6c0ee02
some logging :)
tomvanmele Sep 14, 2023
02ecda4
remove plotters from setup
tomvanmele Sep 14, 2023
002dd45
Update src/compas/artists/descriptors/colordict.py
tomvanmele Sep 15, 2023
adb0adf
no longer needed
tomvanmele Sep 17, 2023
e52a9bb
remove comment
tomvanmele Sep 17, 2023
66f85d1
default of correct type
tomvanmele Sep 17, 2023
44ff68c
add kwargs
tomvanmele Sep 17, 2023
266b1fb
remove unused
tomvanmele Sep 17, 2023
39c351e
more conversions
tomvanmele Sep 17, 2023
685e3d5
type and remove comments
tomvanmele Sep 17, 2023
7cf077d
use wcs origin
tomvanmele Sep 17, 2023
fab631a
transformation is reversed
tomvanmele Sep 17, 2023
c6132d7
type stuff
tomvanmele Sep 17, 2023
08e61fd
upgraded blender artists
tomvanmele Sep 17, 2023
dce464e
pointcloud as singular mesh
tomvanmele Sep 18, 2023
21ec06b
pointcloud artists
tomvanmele Sep 18, 2023
ce73710
updated volmesh artist
tomvanmele Sep 18, 2023
2419428
artist cleanup
tomvanmele Sep 18, 2023
8bbfdd2
more cleanup
tomvanmele Sep 18, 2023
11f13f5
lint
tomvanmele Sep 18, 2023
6caba8a
update docstrings of base artists
tomvanmele Sep 18, 2023
5fe516f
fix plotter tests
tomvanmele Sep 18, 2023
2bb415b
docstring and type info
tomvanmele Sep 18, 2023
31e661d
assign default value to torus discretisation in blender
tomvanmele Sep 18, 2023
3a6aa51
color none as default
tomvanmele Sep 18, 2023
c304994
show_wire and shade_smooth options
tomvanmele Sep 18, 2023
2cd05fa
set item
tomvanmele Sep 18, 2023
7491e06
add collection
tomvanmele Sep 18, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,5 @@ src/compas_ghpython/components/**/*.ghuser
dev

NOTES

src/compas_blender/conversions/__temp/
51 changes: 51 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,35 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Added `polyhedron_to_rhino` to `compas_rhino.conversions`.
* Added `from_mesh` plugin to `compas_rhino.geometry.RhinoBrep`.
* Added `compas.geometry.Plane.worldYZ` and `compas.geometry.Plane.worldZX`.
* Added `compas_rhino.conversions.brep_to_compas_box`.
* Added `compas_rhino.conversions.brep_to_compas_cone`.
* Added `compas_rhino.conversions.brep_to_compas_cylinder`.
* Added `compas_rhino.conversions.brep_to_compas_sphere`.
* Added `compas_rhino.conversions.brep_to_rhino`.
* Added `compas_rhino.conversions.capsule_to_rhino_brep`.
* Added `compas_rhino.conversions.cone_to_rhino_brep`.
* Added `compas_rhino.conversions.curve_to_rhino`.
* Added `compas_rhino.conversions.cylinder_to_rhino_brep`.
* Added `compas_rhino.conversions.extrusion_to_compas_box`.
* Added `compas_rhino.conversions.extrusion_to_rhino_cylinder`.
* Added `compas_rhino.conversions.extrusion_to_rhino_torus`.
* Added `compas_rhino.conversions.polyline_to_rhino_curve`.
* Added `compas_rhino.conversions.surface_to_compas`.
* Added `compas_rhino.conversions.surface_to_compas_mesh`.
* Added `compas_rhino.conversions.surface_to_compas_quadmesh`.
* Added `compas_rhino.conversions.surface_to_rhino`.
* Added `compas_rhino.conversions.torus_to_rhino_brep`.
* Added `compas_rhino.artists._helpers.attributes`.
* Added `compas_rhino.artists._helpers.ngon`.
* Added `compas.geometry.find_span`.
* Added `compas.geometry.construct_knotvector`.
* Added `compas.geometry.knotvector_to_knots_and_mults`.
* Added `compas.geometry.knots_and_mults_to_knotvector`.
* Added `compas.geometry.compute_basisfuncs`.
* Added `compas.geometry.compute_basisfuncsderivs`.
* Added `compas.geometry.DefaultNurbsCurve` as try-last, Python-only plugin for `compas.geometry.NurbsCurve`.
* Added `compas.geometry.DefaultNurbsSurface` as try-last, Python-only plugin for `compas.geometry.NurbsSurface`.
* Added color count to constructor functions of `compas.colors.ColorMap`.

### Changed

Expand Down Expand Up @@ -174,6 +203,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Changed `compas.datastructures.Graph.delete_edge` to delete invalid (u, u) edges and not delete edges in opposite directions (v, u)
* Fixed bug in `compas.datastructures.Mesh.insert_vertex`.
* Fixed bug in `compas.geometry.angle_vectors_signed`.
* Changed `compas.artists.MeshArtist` default colors.

### Removed

Expand Down Expand Up @@ -234,6 +264,27 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Removed classmethod `compas.color.Color.from_data`.
* Removed `validate_data` from `compas.data.validators`.
* Removed `json_validate` from `compas.data.json`.
* Removed `compas_rhino.conversions.Box`.
* Removed `compas_rhino.conversions.Circle`.
* Removed `compas_rhino.conversions.Cone`.
* Removed `compas_rhino.conversions.Curve`.
* Removed `compas_rhino.conversions.Cylinder`.
* Removed `compas_rhino.conversions.Ellipse`.
* Removed `compas_rhino.conversions.Line`.
* Removed `compas_rhino.conversions.Mesh`.
* Removed `compas_rhino.conversions.Plane`.
* Removed `compas_rhino.conversions.Point`.
* Removed `compas_rhino.conversions.Polyline`.
* Removed `compas_rhino.conversions.Vector`.
* Removed `compas_rhino.artists.NetworkArtist.draw_nodelabels`.
* Removed `compas_rhino.artists.NetworkArtist.draw_edgelabels`.
* Removed `compas_rhino.artists.MeshArtist.draw_vertexlabels`.
* Removed `compas_rhino.artists.MeshArtist.draw_edgelabels`.
* Removed `compas_rhino.artists.MeshArtist.draw_facelabels`.
* Removed `compas_rhino.artists.VolMeshArtist.draw_vertexlabels`.
* Removed `compas_rhino.artists.VolMeshArtist.draw_edgelabels`.
* Removed `compas_rhino.artists.VolMeshArtist.draw_facelabels`.
* Removed `compas_rhino.artists.VolMeshArtist.draw_celllabels`.

## [1.17.5] 2023-02-16

Expand Down
11 changes: 11 additions & 0 deletions docs/userguide/tutorials/artists/boxartist.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from compas.geometry import Box
from compas.artists import Artist

Artist.clear()

box = Box.from_corner_corner_height([0, 0, 0], [1, 1, 0], 3)

artist = Artist(box, layer='Test::Child')
artist.draw(color=(0.0, 1.0, 0.0))

Artist.redraw()
11 changes: 11 additions & 0 deletions docs/userguide/tutorials/artists/capsuleartist.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from compas.geometry import Capsule
from compas.artists import Artist

Artist.clear()

capsule = Capsule(radius=1.0, height=7.0)

artist = Artist(capsule)
artist.draw(color=(1.0, 0.0, 0.0))

Artist.redraw()
11 changes: 11 additions & 0 deletions docs/userguide/tutorials/artists/circleartist.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from compas.geometry import Circle
from compas.artists import Artist

Artist.clear()

circle = Circle(radius=3.0)

artist = Artist(circle)
artist.draw(color=(0.0, 0.0, 1.0), show_point=True, show_normal=True)

Artist.redraw()
11 changes: 11 additions & 0 deletions docs/userguide/tutorials/artists/coneartist.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from compas.geometry import Cone
from compas.artists import Artist

Artist.clear()

cone = Cone(radius=1.0, height=7.0)

artist = Artist(cone)
artist.draw(color=(1.0, 0.0, 0.0))

Artist.redraw()
12 changes: 12 additions & 0 deletions docs/userguide/tutorials/artists/curveartist.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from compas.geometry import NurbsCurve
from compas.artists import Artist

Artist.clear()

curve = NurbsCurve.from_points([[0, 0, 0], [3, 3, 6], [6, -3, -3], [9, 0, 0]])

artist = Artist(curve)
artist.color = (0.0, 1.0, 0.0)
artist.draw()

Artist.redraw()
Comment on lines +1 to +12
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

11 changes: 11 additions & 0 deletions docs/userguide/tutorials/artists/cylinderartist.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from compas.geometry import Cylinder
from compas.artists import Artist

Artist.clear()

cylinder = Cylinder(radius=1.0, height=7.0)

artist = Artist(cylinder)
artist.draw(color=(1.0, 0.0, 0.0))

Artist.redraw()
10 changes: 10 additions & 0 deletions docs/userguide/tutorials/artists/frameartist.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from compas.geometry import Frame
from compas.artists import Artist

Artist.clear()

frame = Frame.worldXY()
artist = Artist(frame)
artist.draw()

Artist.redraw()
20 changes: 20 additions & 0 deletions docs/userguide/tutorials/artists/lineartist.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from math import pi
from compas.geometry import Rotation, Scale
from compas.geometry import Line
from compas.artists import Artist
from compas.colors import Color

Artist.clear()

line = Line([0, 0, 0], [3, 0, 0])
artist = Artist(line)
# artist.color = (1.0, 0.0, 0.0)

step = pi / 10.0
rotation = Rotation.from_axis_and_angle([0, 0, 1], angle=step)

for i in range(11):
artist.draw(color=Color.from_i(i / 10))
line.transform(rotation)

Artist.redraw()
16 changes: 16 additions & 0 deletions docs/userguide/tutorials/artists/meshartist.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from compas.datastructures import Mesh
from compas.artists import Artist
from compas.colors import Color

mesh = Mesh.from_meshgrid(10, 10)

Artist.clear()

artist = Artist(mesh)
artist.draw_vertices()
artist.draw_edges()
artist.draw_faces(color={face: Color.pink() for face in mesh.face_sample(size=17)})
#artist.draw_vertexnormals()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#artist.draw_vertexnormals()

delete?

artist.draw_facenormals()

Artist.redraw()
21 changes: 21 additions & 0 deletions docs/userguide/tutorials/artists/networkartist.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from compas.geometry import Pointcloud
from compas.datastructures import Network
from compas.artists import Artist
from compas.colors import Color

network = Network.from_pointcloud(Pointcloud.from_bounds(8, 5, 3, 53))

node = network.node_sample(size=1)[0]
nbrs = network.neighbors(node)
edges = network.connected_edges(node)

Artist.clear()

artist = Artist(network)
artist.draw(
nodecolor={n: Color.pink() for n in [node] + nbrs},
edgecolor={e: Color.pink() for e in edges},
nodetext='index'
)

Artist.redraw()
17 changes: 17 additions & 0 deletions docs/userguide/tutorials/artists/pointartist.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import compas_rhino

from compas.geometry import Point
from compas.artists import Artist
from compas.colors import Color

compas_rhino.clear()

point = Point(0, 0, 0)
artist = Artist(point)
# artist.color = (0.0, 1.0, 0.0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# artist.color = (0.0, 1.0, 0.0)

delete? or uncomment?


for i in range(11):
point.x = i
artist.draw(color=Color.from_i(i / 10))

compas_rhino.redraw()
13 changes: 13 additions & 0 deletions docs/userguide/tutorials/artists/polygonartist.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from compas.geometry import Polygon
from compas.artists import Artist

Artist.clear()

polygon = Polygon.from_sides_and_radius_xy(8, 7.0)

artist = Artist(polygon)
artist.color = (0.0, 1.0, 0.0)

artist.draw(show_points=True, show_edges=True)

Artist.redraw()
10 changes: 10 additions & 0 deletions docs/userguide/tutorials/artists/polyhedronartist.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from compas.geometry import Polyhedron
from compas.artists import Artist

Artist.clear()

polyhedron = Polyhedron.from_platonicsolid(f=8)
artist = Artist(polyhedron)
artist.draw()

Artist.redraw()
20 changes: 20 additions & 0 deletions docs/userguide/tutorials/artists/polylineartist.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from random import randrange
from compas.geometry import Polyline
from compas.artists import Artist
from compas.colors import Color

Artist.clear()

polyline = Polyline([[0, 0, 0]])

for i, r in enumerate([randrange(1, 20) for _ in range(10)]):
if i % 2 == 0:
polyline.append([r, polyline.points[-1].y, 0])
else:
polyline.append([polyline.points[-1].x, r, 0])

artist = Artist(polyline)
artist.color = (0.0, 0.0, 1.0)
artist.draw()

Artist.redraw()
11 changes: 11 additions & 0 deletions docs/userguide/tutorials/artists/sphereartist.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from compas.geometry import Sphere
from compas.artists import Artist

Artist.clear()

sphere = Sphere(radius=1.0)

artist = Artist(sphere)
artist.draw(color=(1.0, 0.0, 0.0))

Artist.redraw()
11 changes: 11 additions & 0 deletions docs/userguide/tutorials/artists/torusartist.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from compas.geometry import Torus
from compas.artists import Artist

Artist.clear()

torus = Torus(radius_axis=7.0, radius_pipe=2.0)

artist = Artist(torus)
artist.draw(color=(1.0, 0.0, 0.0))

Artist.redraw()
28 changes: 28 additions & 0 deletions docs/userguide/tutorials/artists/vectorartist.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from math import pi
from compas.geometry import Vector
from compas.geometry import Rotation
from compas.artists import Artist
from compas.colors import Color

Artist.clear()

vector = Vector(1, 0, 0)
artist = Artist(vector)
# artist.color = (0.0, 1.0, 0.0)

# for i in range(11):
# artist.draw(
# color=Color.from_i(i / 10),
# point=[i, 0, 0],
# show_point=True
# )

Comment on lines +11 to +19
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same, delete or uncomment?

step = pi / 10.0

for i in range(11):
artist.draw(color=Color.from_i(i / 10))

rotation = Rotation.from_axis_and_angle([0, 0, 1], angle=step)
vector.transform(rotation)

Artist.redraw()
12 changes: 12 additions & 0 deletions docs/userguide/tutorials/artists/volmeshartist.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from compas.datastructures import VolMesh
from compas.artists import Artist
from compas.colors import Color

mesh = VolMesh.from_meshgrid(dx=10, nx=10)

Artist.clear()

artist = Artist(mesh)
artist.draw_cells(color={cell: Color.pink() for cell in mesh.cell_sample(size=83)})

Artist.redraw()
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ def read(*names, **kwargs):
"compas_rhino",
"compas_blender",
"compas_ghpython",
"compas_plotters",
gonzalocasas marked this conversation as resolved.
Show resolved Hide resolved
],
package_dir={"": "src"},
package_data={"compas": ["data/schemas/*.json"]},
Expand Down
2 changes: 2 additions & 0 deletions src/compas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@

__all_plugins__ = [
"compas.geometry.booleans.booleans_shapely",
"compas.geometry.curves.nurbs_",
"compas.geometry.surfaces.nurbs_",
gonzalocasas marked this conversation as resolved.
Show resolved Hide resolved
]


Expand Down
8 changes: 2 additions & 6 deletions src/compas/artists/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@
from .exceptions import DataArtistNotRegistered
from .exceptions import NoArtistContextError
from .artist import Artist
from .curveartist import CurveArtist
from .meshartist import MeshArtist
from .networkartist import NetworkArtist
from .primitiveartist import PrimitiveArtist
from .geometryartist import GeometryArtist
from .robotmodelartist import RobotModelArtist
from .shapeartist import ShapeArtist
from .surfaceartist import SurfaceArtist
from .volmeshartist import VolMeshArtist

from .artist import clear # noqa: F401
Expand All @@ -25,12 +23,10 @@
"DataArtistNotRegistered",
"NoArtistContextError",
"Artist",
"CurveArtist",
"MeshArtist",
"NetworkArtist",
"PrimitiveArtist",
"GeometryArtist",
"RobotModelArtist",
"ShapeArtist",
"SurfaceArtist",
"VolMeshArtist",
]
Loading
Loading