|
13 | 13 | from io import StringIO
|
14 | 14 | from . import compatibility, operations, elements, linalg
|
15 | 15 | from . import _exchange as exch
|
| 16 | +from .exceptions import GeomdlException |
16 | 17 | from ._utilities import export
|
17 | 18 |
|
18 | 19 |
|
@@ -896,98 +897,31 @@ def export_vmesh(volume, file_name, **kwargs):
|
896 | 897 |
|
897 | 898 | @export
|
898 | 899 | def import_3dm(file_name, **kwargs):
|
899 |
| - """ Imports Rhinoceros/OpenNURBS .3dm file format. |
| 900 | + """ Imports curves and surfaces from Rhinoceros/OpenNURBS .3dm files. |
900 | 901 |
|
901 |
| - .. note:: |
| 902 | + .. deprecated:: 5.2.2 |
902 | 903 |
|
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. |
904 | 906 |
|
905 | 907 | :param file_name: input file name
|
906 | 908 | :type file_name: str
|
907 | 909 | """
|
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") |
941 | 911 |
|
942 | 912 |
|
943 | 913 | @export
|
944 | 914 | 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. |
946 | 916 |
|
947 |
| - .. note:: |
| 917 | + .. deprecated:: 5.2.2 |
948 | 918 |
|
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. |
950 | 921 |
|
951 | 922 | :param obj: curves/surfaces to be exported
|
952 | 923 | :type obj: abstract.Curve, abstract.Surface, multi.CurveContainer, multi.SurfaceContainer
|
953 | 924 | :param file_name: file name
|
954 | 925 | :type file_name: str
|
955 | 926 | """
|
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