Skip to content

Commit 9e78b56

Browse files
committed
update to string wrapper changes
1 parent 30684ac commit 9e78b56

File tree

5 files changed

+68
-19
lines changed

5 files changed

+68
-19
lines changed

examples/core_export_gltf_single_shape.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
##along with pythonOCC. If not, see <http://www.gnu.org/licenses/>.
1717

1818
from OCC.Core.TDocStd import TDocStd_Document
19-
from OCC.Core.TCollection import TCollection_ExtendedString, TCollection_AsciiString
19+
from OCC.Core.TCollection import TCollection_AsciiString
2020
from OCC.Core.XCAFDoc import (
2121
XCAFDoc_DocumentTool_ShapeTool,
2222
XCAFDoc_DocumentTool_LayerTool,
@@ -34,7 +34,7 @@
3434
shp = BRepPrimAPI_MakeSphere(60.0).Shape()
3535

3636
# create a document
37-
doc = TDocStd_Document(TCollection_ExtendedString("pythonocc-doc"))
37+
doc = TDocStd_Document("pythonocc-doc")
3838
shape_tool = XCAFDoc_DocumentTool_ShapeTool(doc.Main())
3939
layer_tool = XCAFDoc_DocumentTool_LayerTool(doc.Main())
4040

@@ -60,7 +60,7 @@
6060
# Binary export
6161
#
6262
binary = True
63-
binary_rwgltf_writer = RWGltf_CafWriter(TCollection_AsciiString("box.glb"), binary)
63+
binary_rwgltf_writer = RWGltf_CafWriter("box.glb", binary)
6464
binary_rwgltf_writer.SetTransformationFormat(a_format)
6565
binary_rwgltf_writer.SetForcedUVExport(force_uv_export)
6666
pr = Message_ProgressRange() # this is required
@@ -70,7 +70,7 @@
7070
# Ascii export
7171
#
7272
binary = False
73-
ascii_rwgltf_writer = RWGltf_CafWriter(TCollection_AsciiString("box.gla"), binary)
73+
ascii_rwgltf_writer = RWGltf_CafWriter("box.gla", binary)
7474
ascii_rwgltf_writer.SetTransformationFormat(a_format)
7575
ascii_rwgltf_writer.SetForcedUVExport(force_uv_export)
7676
pr = Message_ProgressRange() # this is required

examples/core_export_ply_single_shape.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
shp = BRepPrimAPI_MakeSphere(60.0).Shape()
3535

3636
# create a document
37-
doc = TDocStd_Document(TCollection_ExtendedString("pythonocc-doc"))
37+
doc = TDocStd_Document("pythonocc-doc")
3838
shape_tool = XCAFDoc_DocumentTool_ShapeTool(doc.Main())
3939
layer_tool = XCAFDoc_DocumentTool_LayerTool(doc.Main())
4040

@@ -53,6 +53,6 @@
5353
TCollection_AsciiString("Authors"), TCollection_AsciiString("pythonocc")
5454
)
5555

56-
rwply_writer = RWPly_CafWriter(TCollection_AsciiString("sphere.ply"))
56+
rwply_writer = RWPly_CafWriter("sphere.ply")
5757
pr = Message_ProgressRange()
5858
rwply_writer.Perform(doc, a_file_info, pr)

examples/core_load_step_ap203_ocaf.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,6 @@
1515
##You should have received a copy of the GNU Lesser General Public License
1616
##along with pythonOCC. If not, see <http://www.gnu.org/licenses/>.
1717

18-
from __future__ import print_function
19-
20-
21-
from OCC.Core.TCollection import TCollection_ExtendedString
22-
2318
from OCC.Core.TDocStd import TDocStd_Document
2419
from OCC.Core.XCAFDoc import (
2520
XCAFDoc_DocumentTool_ShapeTool,
@@ -37,7 +32,7 @@
3732
_shapes = []
3833

3934
# create an handle to a document
40-
doc = TDocStd_Document(TCollection_ExtendedString("pythonocc-doc"))
35+
doc = TDocStd_Document("pythonocc-doc")
4136

4237
# Get root assembly
4338
shape_tool = XCAFDoc_DocumentTool_ShapeTool(doc.Main())
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
##Copyright 2023 Thomas Paviot (tpaviot@gmail.com)
2+
##
3+
##This file is part of pythonOCC.
4+
##
5+
##pythonOCC is free software: you can redistribute it and/or modify
6+
##it under the terms of the GNU Lesser General Public License as published by
7+
##the Free Software Foundation, either version 3 of the License, or
8+
##(at your option) any later version.
9+
##
10+
##pythonOCC is distributed in the hope that it will be useful,
11+
##but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
##MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
##GNU Lesser General Public License for more details.
14+
##
15+
##You should have received a copy of the GNU Lesser General Public License
16+
##along with pythonOCC. If not, see <http://www.gnu.org/licenses/>.
17+
18+
from OCC.Core.TDocStd import TDocStd_Document
19+
from OCC.Core.XCAFDoc import (
20+
XCAFDoc_DocumentTool_MaterialTool,
21+
)
22+
from OCC.Core.STEPCAFControl import STEPCAFControl_Reader
23+
from OCC.Core.IFSelect import IFSelect_RetDone
24+
from OCC.Core.TDF import TDF_LabelSequence
25+
26+
filename = "../assets/models/eight_cyl.stp"
27+
28+
# create an handle to a document
29+
doc = TDocStd_Document("pythonocc-doc")
30+
31+
# Get root assembly
32+
mat_tool = XCAFDoc_DocumentTool_MaterialTool(doc.Main())
33+
34+
step_reader = STEPCAFControl_Reader()
35+
36+
status = step_reader.ReadFile(filename)
37+
if status == IFSelect_RetDone:
38+
step_reader.Transfer(doc)
39+
40+
material_labels = TDF_LabelSequence()
41+
42+
mat_tool.GetMaterialLabels(material_labels)
43+
44+
# materials
45+
for i in range(1, material_labels.Length() + 1):
46+
(
47+
ok,
48+
material_name,
49+
material_description,
50+
material_density,
51+
material_densname,
52+
material_densvaltype,
53+
) = mat_tool.GetMaterial(material_labels.Value(i))
54+
55+
print(f"Material name: {material_name}")
56+
print(f"Material description: {material_description}")
57+
print(f"Material density: {material_density}")
58+
print(f"Material densname: {material_densname}")
59+
print(f"Material_densvaltype: {material_densvaltype}\n")

examples/core_visualization_glsl.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
Graphic3d_TOS_FRAGMENT,
2525
Graphic3d_ShaderObject,
2626
)
27-
from OCC.Core.TCollection import TCollection_AsciiString
2827
from OCC.Display.SimpleGui import init_display
2928

3029
display, start_display, add_menu, add_function_to_menu = init_display()
@@ -50,12 +49,8 @@
5049
"""
5150

5251
# construct the shader, load, compile and attach the GLSL programs
53-
vs_shader = Graphic3d_ShaderObject.CreateFromSource(
54-
Graphic3d_TOS_VERTEX, TCollection_AsciiString(vs)
55-
)
56-
fs_shader = Graphic3d_ShaderObject.CreateFromSource(
57-
Graphic3d_TOS_FRAGMENT, TCollection_AsciiString(fs)
58-
)
52+
vs_shader = Graphic3d_ShaderObject.CreateFromSource(Graphic3d_TOS_VERTEX, vs)
53+
fs_shader = Graphic3d_ShaderObject.CreateFromSource(Graphic3d_TOS_FRAGMENT, fs)
5954
aProgram = Graphic3d_ShaderProgram()
6055
aProgram.AttachShader(fs_shader)
6156
aProgram.AttachShader(vs_shader)

0 commit comments

Comments
 (0)