Skip to content

Commit b4bb2a9

Browse files
committed
Add polyline example
1 parent 53d689f commit b4bb2a9

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

docs/examples.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ Scalar Field
2727
.. literalinclude:: ../script_examples/scalar_field.py
2828
:language: Python
2929

30+
Polyline
31+
---------
32+
33+
.. literalinclude:: ../script_examples/polyline.py
34+
:language: Python
3035

3136
Sub sampling
3237
------------

script_examples/polyline.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import pycc
2+
import cccorelib
3+
import numpy as np
4+
5+
CC = pycc.GetInstance()
6+
VERTICES = np.array([
7+
[-0.5, -0.5, 0],
8+
[1, 1, 0],
9+
[2, 2, 0]
10+
])
11+
vertices = pycc.ccPointCloud(VERTICES[:, 0], VERTICES[:, 1], VERTICES[:, 2])
12+
polyline = pycc.ccPolyline(vertices)
13+
polyline.setColor(pycc.Rgb(255, 0, 0)) # set the color to red
14+
polyline.showColors(True)
15+
polyline.setClosed(False)
16+
17+
18+
# This is important, otherwise the polyline would have a size of 0
19+
polyline.addPointIndex(0, 3)
20+
21+
22+
CC.addToDB(polyline)
23+
CC.updateUI()
24+
polyline.getDisplay().display3DLabel("Hello, world", cccorelib.CCVector3(1, 1,0))
25+

0 commit comments

Comments
 (0)