Skip to content

Commit 881e5d1

Browse files
committed
blackification
1 parent e761cd8 commit 881e5d1

9 files changed

Lines changed: 61 additions & 28 deletions
170 KB
Binary file not shown.

examples/core_export_step_ap203.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030

3131
# initialize the STEP exporter
3232
step_writer = STEPControl_Writer()
33+
dd = step_writer.WS().TransferWriter().FinderProcess()
34+
print(dd)
35+
3336
Interface_Static_SetCVal("write.step.schema", "AP203")
3437

3538
# transfer shapes and write file

examples/core_load_iges.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from OCC.Display.SimpleGui import init_display
2121
from OCC.Extend.DataExchange import read_iges_file
2222

23-
shapes = read_iges_file("../assets/models/surf114.igs")
23+
shapes = read_iges_file("../../pythonocc-core/test/test_io/example_45_faces.iges")
2424

2525
display, start_display, add_menu, add_function_to_menu = init_display()
2626
display.DisplayShape(shapes, update=True)

examples/core_meshDS_numpy.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@ def getMesh(X=100, Y=100):
1616
x = np.linspace(-5, 5, X)
1717
y = np.linspace(-5, 5, Y)
1818
xx, yy = np.meshgrid(x, y, sparse=False)
19-
z = (np.sin(xx**2 + yy**2) / (xx**2 + yy**2))
19+
z = np.sin(xx ** 2 + yy ** 2) / (xx ** 2 + yy ** 2)
2020
xyz = np.column_stack((xx.flatten(), yy.flatten(), z.flatten()))
2121
tri = Delaunay(xyz[:, :2])
2222
return xyz, tri.simplices
2323

24-
#get some mesh data
24+
25+
# get some mesh data
2526
vertices, faces = getMesh()
2627

2728
# Create the datasource. Data is taken directly from the numpy arrays. both have to be contiguous.
@@ -34,7 +35,7 @@ def getMesh(X=100, Y=100):
3435
# Create a new presentation builder and add it to the visualizer
3536
prs_builder = MeshVS_MeshPrsBuilder(mesh_vs)
3637

37-
#mesh_vs.SetDisplayMode(AIS_DisplayMode.AIS_Shaded)
38+
# mesh_vs.SetDisplayMode(AIS_DisplayMode.AIS_Shaded)
3839
mesh_vs.AddBuilder(prs_builder, True)
3940

4041
# Create the display and add visualization

examples/core_meshDS_numpy_face_colors.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,14 @@
99
from scipy.spatial import Delaunay
1010
from matplotlib import cm
1111
from OCC.Core.MeshDS import MeshDS_DataSource
12-
from OCC.Core.MeshVS import MeshVS_DMF_OCCMask, MeshVS_Mesh, MeshVS_ElementalColorPrsBuilder, MeshVS_DA_ShowEdges, MeshVS_DMF_ElementalColorDataPrs, MeshVS_DataMapOfIntegerColor
12+
from OCC.Core.MeshVS import (
13+
MeshVS_DMF_OCCMask,
14+
MeshVS_Mesh,
15+
MeshVS_ElementalColorPrsBuilder,
16+
MeshVS_DA_ShowEdges,
17+
MeshVS_DMF_ElementalColorDataPrs,
18+
MeshVS_DataMapOfIntegerColor,
19+
)
1320
from OCC.Display.SimpleGui import init_display
1421
from OCC.Core.Quantity import Quantity_Color, Quantity_TOC_RGB
1522

@@ -19,12 +26,13 @@ def getMesh(X=100, Y=100):
1926
x = np.linspace(-5, 5, X)
2027
y = np.linspace(-5, 5, Y)
2128
xx, yy = np.meshgrid(x, y, sparse=False)
22-
z = (np.sin(xx**2 + yy**2) / (xx**2 + yy**2))
29+
z = np.sin(xx ** 2 + yy ** 2) / (xx ** 2 + yy ** 2)
2330
xyz = np.column_stack((xx.flatten(), yy.flatten(), z.flatten()))
2431
tri = Delaunay(xyz[:, :2])
2532
return xyz, tri.simplices
2633

27-
#get some mesh data
34+
35+
# get some mesh data
2836
vertices, faces = getMesh()
2937

3038
# generate face values
@@ -33,7 +41,7 @@ def getMesh(X=100, Y=100):
3341
z_min = np.min(vertices[:, 2])
3442
z_ptp = np.ptp(vertices[:, 2])
3543

36-
face_colors = [cmap((value - z_min)/z_ptp)[:3] for value in face_values]
44+
face_colors = [cmap((value - z_min) / z_ptp)[:3] for value in face_values]
3745

3846
# Create the datasource. Data is taken directly from the numpy arrays. both have to be contiguous and Nx3 (double), Mx3 (int).
3947
mesh_ds = MeshDS_DataSource(vertices, faces)
@@ -43,12 +51,14 @@ def getMesh(X=100, Y=100):
4351
mesh_vs.SetDataSource(mesh_ds)
4452

4553
# create nodal builder and assign to the mesh
46-
element_builder = MeshVS_ElementalColorPrsBuilder(mesh_vs, MeshVS_DMF_ElementalColorDataPrs | MeshVS_DMF_OCCMask)
54+
element_builder = MeshVS_ElementalColorPrsBuilder(
55+
mesh_vs, MeshVS_DMF_ElementalColorDataPrs | MeshVS_DMF_OCCMask
56+
)
4757

4858
# set normalized color intensity to node
4959
for nFace in range(faces.shape[0]):
5060
color = Quantity_Color(*face_colors[nFace], Quantity_TOC_RGB)
51-
element_builder.SetColor1(nFace+1, color) #element indices are 1 based
61+
element_builder.SetColor1(nFace + 1, color) # element indices are 1 based
5262

5363
# Add the builder to the visualizer
5464
mesh_vs.AddBuilder(element_builder, True)

examples/core_meshDS_numpy_material.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,25 @@
1414
Quantity_Color,
1515
)
1616

17-
from OCC.Core.Graphic3d import Graphic3d_MaterialAspect, Graphic3d_PBRMaterial, Graphic3d_NOM_STEEL
17+
from OCC.Core.Graphic3d import (
18+
Graphic3d_MaterialAspect,
19+
Graphic3d_PBRMaterial,
20+
Graphic3d_NOM_STEEL,
21+
)
1822

1923

2024
def getMesh(X=100, Y=100):
2125
# generate some mesh data.
2226
x = np.linspace(-5, 5, X)
2327
y = np.linspace(-5, 5, Y)
2428
xx, yy = np.meshgrid(x, y, sparse=False)
25-
z = (np.sin(xx**2 + yy**2) / (xx**2 + yy**2))
29+
z = np.sin(xx ** 2 + yy ** 2) / (xx ** 2 + yy ** 2)
2630
xyz = np.column_stack((xx.flatten(), yy.flatten(), z.flatten()))
2731
tri = Delaunay(xyz[:, :2])
2832
return xyz, tri.simplices
2933

30-
#get some mesh data
34+
35+
# get some mesh data
3136
vertices, faces = getMesh()
3237

3338
mesh_ds = MeshDS_DataSource(vertices, faces)

examples/core_meshDS_numpy_node_colors.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@
88
import numpy as np
99
from scipy.spatial import Delaunay
1010
from OCC.Core.MeshDS import MeshDS_DataSource
11-
from OCC.Core.MeshVS import MeshVS_DMF_OCCMask, MeshVS_Mesh, MeshVS_NodalColorPrsBuilder, MeshVS_DA_ShowEdges, MeshVS_DMF_NodalColorDataPrs
11+
from OCC.Core.MeshVS import (
12+
MeshVS_DMF_OCCMask,
13+
MeshVS_Mesh,
14+
MeshVS_NodalColorPrsBuilder,
15+
MeshVS_DA_ShowEdges,
16+
MeshVS_DMF_NodalColorDataPrs,
17+
)
1218
from OCC.Display.SimpleGui import init_display
1319
from OCC.Core.Aspect import Aspect_SequenceOfColor
1420
from OCC.Core.Quantity import (
@@ -28,12 +34,13 @@ def getMesh(X=100, Y=100):
2834
x = np.linspace(-5, 5, X)
2935
y = np.linspace(-5, 5, Y)
3036
xx, yy = np.meshgrid(x, y, sparse=False)
31-
z = (np.sin(xx**2 + yy**2) / (xx**2 + yy**2))
37+
z = np.sin(xx ** 2 + yy ** 2) / (xx ** 2 + yy ** 2)
3238
xyz = np.column_stack((xx.flatten(), yy.flatten(), z.flatten()))
3339
tri = Delaunay(xyz[:, :2])
3440
return xyz, tri.simplices
3541

36-
#get some mesh data
42+
43+
# get some mesh data
3744
vertices, faces = getMesh()
3845

3946
# Create the datasource. Data is taken directly from the numpy arrays. both have to be contiguous and Nx3 (double), Mx3 (int).
@@ -44,7 +51,9 @@ def getMesh(X=100, Y=100):
4451
mesh_vs.SetDataSource(mesh_ds)
4552

4653
# create nodal builder and assign to the mesh
47-
node_builder = MeshVS_NodalColorPrsBuilder(mesh_vs, MeshVS_DMF_NodalColorDataPrs | MeshVS_DMF_OCCMask)
54+
node_builder = MeshVS_NodalColorPrsBuilder(
55+
mesh_vs, MeshVS_DMF_NodalColorDataPrs | MeshVS_DMF_OCCMask
56+
)
4857
node_builder.UseTexture(True)
4958

5059
# prepare color map
@@ -62,7 +71,7 @@ def getMesh(X=100, Y=100):
6271
z_ptp = np.ptp(vertices[:, 2])
6372
for nVert in range(vertices.shape[0]):
6473
color = (vertices[nVert, 2] - z_min) / z_ptp
65-
aScaleMap.Bind(nVert + 1, color) #node indices are 1 based
74+
aScaleMap.Bind(nVert + 1, color) # node indices are 1 based
6675

6776
# pass color map and color scale values to the builder
6877
node_builder.SetColorMap(aColorMap)

examples/core_topology_glue.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def tag_faces(_shape, _color, shape_name):
5454
def tag_edge(_edge, msg, _color=(1, 0, 0)):
5555
"""tag an edge"""
5656
center_pt = get_aligned_boundingbox(_edge)[0]
57-
display.DisplayMessage(center_pt, msg, message_color = _color)
57+
display.DisplayMessage(center_pt, msg, message_color=_color)
5858

5959

6060
def glue_solids(event=None):

run_examples_as_tests.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,35 +24,40 @@
2424
import subprocess
2525
import time
2626

27+
2728
def worker(example_name):
2829
# += operation is not atomic, so we need to get a lock:
2930
print("running %s ..." % example_name, end="")
3031
try:
31-
subprocess.check_output([sys.executable, example_name],
32-
stderr=subprocess.STDOUT,
33-
universal_newlines=True)
32+
subprocess.check_output(
33+
[sys.executable, example_name],
34+
stderr=subprocess.STDOUT,
35+
universal_newlines=True,
36+
)
3437
print("[passed]")
3538
return True
3639
except subprocess.CalledProcessError as cpe:
3740
print("%s" % cpe.output)
3841
print("[failed]")
3942
return False
4043

44+
4145
if __name__ == "__main__":
4246
init_time = time.time()
4347

4448
# find examplessubdir from current file
4549
path = os.path.abspath(__file__)
4650
test_dirname = os.path.dirname(path)
47-
examples_directory = os.path.join(test_dirname, 'examples')
51+
examples_directory = os.path.join(test_dirname, "examples")
4852
os.chdir(examples_directory)
49-
all_examples_file_names = glob.glob('core_*.py')
53+
all_examples_file_names = glob.glob("core_*.py")
5054

5155
# some tests have to be excluded from the automatic
5256
# run. For instance, qt based examples
53-
tests_to_exclude = ['core_display_signal_slots.py',
54-
'core_visualization_overpaint_viewer.py'
55-
]
57+
tests_to_exclude = [
58+
"core_display_signal_slots.py",
59+
"core_visualization_overpaint_viewer.py",
60+
]
5661

5762
# remove examples to excludes
5863
for test_name in tests_to_exclude:
@@ -77,7 +82,7 @@ def worker(example_name):
7782
if failed > 0:
7883
print("%i tests failed" % failed)
7984

80-
print("Total time to run all examples: %fs" %(time.time() - init_time))
85+
print("Total time to run all examples: %fs" % (time.time() - init_time))
8186

8287
# if failed, exit with error
8388
if failed > 0:

0 commit comments

Comments
 (0)