Skip to content

Commit a4ae21a

Browse files
committed
Deprecate 3dm import/export in favor of rw3dm 2.0
1 parent 71ac1c0 commit a4ae21a

File tree

1 file changed

+11
-77
lines changed

1 file changed

+11
-77
lines changed

geomdl/exchange.py

Lines changed: 11 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from io import StringIO
1414
from . import compatibility, operations, elements, linalg
1515
from . import _exchange as exch
16+
from .exceptions import GeomdlException
1617
from ._utilities import export
1718

1819

@@ -896,98 +897,31 @@ def export_vmesh(volume, file_name, **kwargs):
896897

897898
@export
898899
def import_3dm(file_name, **kwargs):
899-
""" Imports Rhinoceros/OpenNURBS .3dm file format.
900+
""" Imports curves and surfaces from Rhinoceros/OpenNURBS .3dm files.
900901
901-
.. note::
902+
.. deprecated:: 5.2.2
902903
903-
Requires ``rw3dm`` module: https://github.com/orbingol/rw3dm
904+
``rw3dm`` Python module is replaced by ``on2json``. It can be used to convert .3dm files to geomdl JSON format.
905+
Please refer to https://github.com/orbingol/rw3dm for more details.
904906
905907
:param file_name: input file name
906908
:type file_name: str
907909
"""
908-
try:
909-
from rw3dm import rw3dm
910-
except ImportError:
911-
print("Please install 'rw3dm' module: https://github.com/orbingol/rw3dm")
912-
return
913-
914-
res3dm = []
915-
rw3dm.read(file_name, res3dm, **kwargs)
916-
917-
res = []
918-
for r in res3dm:
919-
if r['shape_type'] == "curve":
920-
tmp = exch.shortcuts.generate_curve(rational=True)
921-
tmp.degree = r['degree']
922-
tmp.ctrlpts = r['control_points']['points']
923-
if 'weights' in r:
924-
tmp.weights = r['control_points']['weights']
925-
tmp.knotvector = [r['knotvector'][0]] + r['knotvector'] + [r['knotvector'][-1]]
926-
res.append(tmp)
927-
if r['shape_type'] == "surface":
928-
tmp = exch.shortcuts.generate_surface(rational=True)
929-
tmp.degree_u = r['degree_u']
930-
tmp.degree_v = r['degree_v']
931-
tmp.ctrlpts_size_u = r['size_u']
932-
tmp.ctrlpts_size_v = r['size_v']
933-
tmp.ctrlpts = r['control_points']['points']
934-
if 'weights' in r:
935-
tmp.weights = r['control_points']['weights']
936-
tmp.knotvector_u = [r['knotvector_u'][0]] + r['knotvector_u'] + [r['knotvector_u'][-1]]
937-
tmp.knotvector_v = [r['knotvector_v'][0]] + r['knotvector_v'] + [r['knotvector_v'][-1]]
938-
res.append(tmp)
939-
940-
return res
910+
raise GeomdlException("This API call has been deprecated. Please refer to https://github.com/orbingol/rw3dm")
941911

942912

943913
@export
944914
def export_3dm(obj, file_name, **kwargs):
945-
""" Exports NURBS curves and surfaces in Rhinoceros/OpenNURBS .3dm format.
915+
""" Exports NURBS curves and surfaces to Rhinoceros/OpenNURBS .3dm files.
946916
947-
.. note::
917+
.. deprecated:: 5.2.2
948918
949-
Requires ``rw3dm`` module: https://github.com/orbingol/rw3dm
919+
``rw3dm`` Python module is replaced by ``json2on``. It can be used to convert geomdl JSON format to .3dm files.
920+
Please refer to https://github.com/orbingol/rw3dm for more details.
950921
951922
:param obj: curves/surfaces to be exported
952923
:type obj: abstract.Curve, abstract.Surface, multi.CurveContainer, multi.SurfaceContainer
953924
:param file_name: file name
954925
:type file_name: str
955926
"""
956-
try:
957-
from rw3dm import rw3dm
958-
except ImportError:
959-
print("Please install 'rw3dm' module: https://github.com/orbingol/rw3dm")
960-
return
961-
962-
res3dm = []
963-
for o in obj:
964-
if o.pdimension == 1:
965-
rd = dict(
966-
shape_type="curve",
967-
degree=o.degree,
968-
knotvector=o.knotvector[1:-1],
969-
control_points=dict(
970-
points=o.ctrlpts
971-
)
972-
)
973-
if o.rational:
974-
rd['control_points']['weights'] = o.weights
975-
res3dm.append(rd)
976-
if o.pdimension == 2:
977-
rd = dict(
978-
shape_type="surface",
979-
degree_u=o.degree_u,
980-
degree_v=o.degree_v,
981-
knotvector_u=o.knotvector_u[1:-1],
982-
knotvector_v=o.knotvector_v[1:-1],
983-
size_u=o.ctrlpts_size_u,
984-
size_v=o.ctrlpts_size_v,
985-
control_points=dict(
986-
points=o.ctrlpts
987-
)
988-
)
989-
if o.rational:
990-
rd['control_points']['weights'] = o.weights
991-
res3dm.append(rd)
992-
993-
rw3dm.write(res3dm, file_name)
927+
raise GeomdlException("This API call has been deprecated. Please refer to https://github.com/orbingol/rw3dm")

0 commit comments

Comments
 (0)