Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 30 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,17 +1,38 @@
# precompiled python
# Python bytecode
*.pyc
__pycache__/
*.py[cod]
*$py.class

# setuptools/pip stuff
# Virtual environments
venv/
env/
ENV/
.venv/

# Build artifacts
build/
dist/
*.egg-info/
*.egg/
.eggs/
*.egg

# IDE
.vscode/
.idea/
*.swp
*.swo
*~

# brlcad output file
*.g
# OS
.DS_Store
Thumbs.db

# editor swap files
.*.sw*
# Testing
.pytest_cache/
.coverage
htmlcov/
.tox/

# intellij pycharm project directory:
.idea
# Distribution
MANIFEST
2 changes: 1 addition & 1 deletion brlcad/ctypes_adaptors.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def plane_from_pointer(t):


def transform_from_pointer(t):
return [t[x] for x in xrange(0, 16)]
return [t[x] for x in range(0, 16)]


def array2d_from_pointer(t, num_rows, num_cols):
Expand Down
4 changes: 2 additions & 2 deletions brlcad/ged.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def execute_command(self, ged_function, *args, **kwargs):
if not (result & libged.GED_MORE):
break
prompt = self._ged_pointer.contents.ged_result_str.contents.vls_str
new_input = raw_input(prompt)
new_input = input(prompt)
args.extend(new_input.split())
if readline:
# this code collapses the multiple history items resulting from
Expand All @@ -155,7 +155,7 @@ def execute_command(self, ged_function, *args, **kwargs):
else:
ged_output = self._ged_pointer.contents.ged_result_str.contents.vls_str
if ged_output:
print ged_output
print(ged_output)
return result

@ged_command
Expand Down
8 changes: 4 additions & 4 deletions brlcad/install/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
import copy
import re
import subprocess
import ctypesgencore
import ctypesgen.options as ctypesgencore_options

from distutils.version import StrictVersion
from ConfigParser import ConfigParser
from configparser import ConfigParser


class SetupException(Exception):
Expand Down Expand Up @@ -246,7 +246,7 @@ def setup_libraries(bindings_path, config, settings, brlcad_info, logger):
"""
Read and expand the library list configured in options.
"""
default_options = ctypesgencore.options.get_default_options()
default_options = ctypesgencore_options.get_default_options()
default_options.include_symbols = None
default_options.exclude_symbols = None
default_options.output_language = "python"
Expand Down Expand Up @@ -293,7 +293,7 @@ def setup_libraries(bindings_path, config, settings, brlcad_info, logger):
options.output = os.path.join(bindings_path, "{0}.py".format(lib_name))
lib_path = find_shared_lib_file([bin_dir, lib_dir], lib_name)
options.libraries = [norm_win_path(lib_path)]
for i in xrange(0, len(lib_headers)):
for i in range(0, len(lib_headers)):
lib_headers[i] = os.path.join(include_dir, "brlcad", lib_headers[i])
if not os.access(lib_headers[i], os.R_OK):
raise SetupException("Missing header file: {0}".format(lib_headers[i]))
Expand Down
25 changes: 16 additions & 9 deletions brlcad/install/post_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@
import os
import json
import logging
import imp
import importlib.util
import shutil

import ctypesgencore
import ctypesgen.parser as ctypesgencore_parser
import ctypesgen.processor as ctypesgencore_processor
import ctypesgen.printer_python as ctypesgencore_printer_python
import ctypesgen

from options import load_ctypesgen_options, load_config
from .options import load_ctypesgen_options, load_config


def setup_logging(level=logging.DEBUG):
Expand Down Expand Up @@ -48,15 +51,15 @@ def generate_wrapper(ctypesgen_options, logger):
"""
# parse
logger.debug("parsing")
descriptions = ctypesgencore.parser.parse(ctypesgen_options.headers, ctypesgen_options)
descriptions = ctypesgencore_parser.parse(ctypesgen_options.headers, ctypesgen_options)

# process
logger.debug("processing")
ctypesgencore.processor.process(descriptions, ctypesgen_options)
ctypesgencore_processor.process(descriptions, ctypesgen_options)

# print
logger.debug("printing")
ctypesgencore.printer_python.WrapperPrinter(ctypesgen_options.output, ctypesgen_options, descriptions)
ctypesgencore_printer_python.WrapperPrinter(ctypesgen_options.output, ctypesgen_options, descriptions)


def cleanup_bindings_dir(bindings_path, cached_bindings_path, logger):
Expand Down Expand Up @@ -97,7 +100,7 @@ def main(library_path, logger=None):
if not logger:
logger = setup_logging()

logger.debug("ctypesgencore version is {0}".format(ctypesgencore.__version__))
logger.debug("ctypesgen version is {0}".format(ctypesgen.__version__))

# this is where the generated files are placed
bindings_path = os.path.join(library_path, "_bindings")
Expand Down Expand Up @@ -172,10 +175,14 @@ def main(library_path, logger=None):

# 2) load the latest generated module
logger.debug("Loading the __init__.py module from {0}".format(bindings_path))
imp.load_source("_bindings", os.path.join(bindings_path, "__init__.py"))
spec = importlib.util.spec_from_file_location("_bindings", os.path.join(bindings_path, "__init__.py"))
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)

logger.debug("Loading the {0} module from {1}.".format(lib_name, ctypesgen_options.output))
latest_module = imp.load_source(lib_name, ctypesgen_options.output)
spec = importlib.util.spec_from_file_location(lib_name, ctypesgen_options.output)
latest_module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(latest_module)
symbols = dir(latest_module)

# 3) store the list of defined names from that module by running dir(loaded_module)
Expand Down
6 changes: 3 additions & 3 deletions brlcad/primitives/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def __init__(self, bot, vertices, index=None, copy=False):
if index==None:
if len(vertices)==3:
self.index=[]
for i in xrange(0, len(self._points)):
for i in range(0, len(self._points)):
self.index.append(bot.vertex_index(self._points[i]))
else:
raise BRLCADException("A face requires 3 vertices")
Expand Down Expand Up @@ -87,7 +87,7 @@ def __init__(self, name, mode=1, orientation=1, flags=0, vertices=None, faces=No
elif not isinstance(faces, list):
curves = list(faces)
self.faces = faces
for i in xrange(0, len(faces)):
for i in range(0, len(faces)):
self.add_face(faces[i])

def __repr__(self):
Expand Down Expand Up @@ -142,7 +142,7 @@ def vertex_index(self, value, copy=False):
value = Vector(value, copy=copy)
if len(value) != 3:
raise ValueError("A traingle needs 3D vertexes, but got: {}".format(value))
for i in xrange(0, vertex_count):
for i in range(0, vertex_count):
if self.vertices[i].is_same(value):
return i
self.vertices.append(value)
Expand Down
6 changes: 3 additions & 3 deletions brlcad/primitives/combination.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,9 @@ def __new__(cls, arg):
else:
arg = [leaf(x) for x in arg]
# if any of the children is of the same class, it will accumulate the new nodes:
for i in xrange(0, len(arg)):
for i in range(0, len(arg)):
if isinstance(arg[i], cls):
for j in xrange(0, len(arg)):
for j in range(0, len(arg)):
if i != j:
arg[i].add_child(arg[j])
return arg[i]
Expand Down Expand Up @@ -232,7 +232,7 @@ def is_same(self, other):
return False
if len(self.children) != len(other.children):
return False
return all([self.children[i].is_same(other.children[i]) for i in xrange(0, len(self.children))])
return all([self.children[i].is_same(other.children[i]) for i in range(0, len(self.children))])

def build_tree(self, subset=None):
if subset and len(subset) == 1:
Expand Down
2 changes: 1 addition & 1 deletion brlcad/primitives/metaball.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class Metaball(Primitive):
def __init__(self, name, threshold=1, method=2, points=(((1, 1, 1), 1, 0), ((0, 0, 1), 2, 0)), copy=False):
Primitive.__init__(self, name=name)
if isinstance(points, list) and not copy:
for i in xrange(0, len(points)):
for i in range(0, len(points)):
points[i] = MetaballCtrlPoint(points[i])
else:
points = [MetaballCtrlPoint(point, copy=copy) for point in points]
Expand Down
4 changes: 2 additions & 2 deletions brlcad/primitives/pipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class Pipe(Primitive):
def __init__(self, name, points=(((0, 0, 0), 0.5, 0.3, 1), ((0, 0, 1), 0.5, 0.3, 1)), copy=False):
Primitive.__init__(self, name=name)
if isinstance(points, list) and not copy:
for i in xrange(0, len(points)):
for i in range(0, len(points)):
points[i] = PipePoint(points[i])
else:
points = [PipePoint(point, copy=copy) for point in points]
Expand Down Expand Up @@ -123,7 +123,7 @@ def append_point(self, point, *args, **kwargs):
def from_wdb(name, data):
points = []
crt_head = data.pipe_segs_head.forw
for i in xrange(0, data.pipe_count):
for i in range(0, data.pipe_count):
crt_point = ctypes.cast(crt_head, ctypes.POINTER(librt.wdb_pipept)).contents
crt_head = crt_point.l.forw
points.append((
Expand Down
22 changes: 11 additions & 11 deletions brlcad/primitives/sketch.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class Curve(collections.MutableSequence):
def __init__(self, sketch, points, reverse=False, copy=False):
self.sketch = sketch
self._points = list(points) if copy or not isinstance(points, list) else points
for i in xrange(0, len(self._points)):
for i in range(0, len(self._points)):
self._points[i] = sketch.vertex_index(self._points[i])
self.reverse = reverse

Expand Down Expand Up @@ -252,7 +252,7 @@ def from_wdb(sketch, data, reverse):
data = librt.cast(data, librt.POINTER(librt.struct_nurb_seg)).contents
point_type = (data.pt_type >> 1) & 0x0f
if bool(data.pt_type & 1):
weights = [data.weights[i] for i in xrange(0, data.c_size)]
weights = [data.weights[i] for i in range(0, data.c_size)]
coordinate_count = 3
else:
weights = None
Expand All @@ -263,11 +263,11 @@ def from_wdb(sketch, data, reverse):
)
result = NURB(
sketch,
points=[data.ctl_points[i] for i in xrange(0, data.c_size)],
points=[data.ctl_points[i] for i in range(0, data.c_size)],
reverse=reverse,
order=data.order,
point_type=point_type,
knot_vector=[data.k.knots[i] for i in xrange(0, data.k.k_size)],
knot_vector=[data.k.knots[i] for i in range(0, data.k.k_size)],
weights=weights
)
return result
Expand Down Expand Up @@ -337,7 +337,7 @@ def from_wdb(sketch, data, reverse):
data = librt.cast(data, librt.POINTER(librt.struct_bezier_seg)).contents
return Bezier(
sketch,
points=[data.ctl_points[i] for i in xrange(0, data.degree + 1)],
points=[data.ctl_points[i] for i in range(0, data.degree + 1)],
reverse=reverse
)

Expand Down Expand Up @@ -382,7 +382,7 @@ def __init__(self, name, base=(0, 0, 0), u_vec=(1, 0, 0), v_vec=(0, 1, 0), verti
elif not isinstance(curves, list):
curves = list(curves)
self.curves = curves
for i in xrange(0, len(curves)):
for i in range(0, len(curves)):
self.add_curve_segment(curves[i], segment_index=i, copy=copy)

def __repr__(self):
Expand All @@ -399,7 +399,7 @@ def vertex_index(self, value, copy=False):
value = Vector(value, copy=copy)
if len(value) != 2:
raise ValueError("Sketches need 2D vertexes, but got: {}".format(value))
for i in xrange(0, vertex_count):
for i in range(0, vertex_count):
if self.vertices[i].is_same(value):
return i
self.vertices.append(value)
Expand Down Expand Up @@ -467,7 +467,7 @@ def build_curves(self):
else:
ci.reverse = None
ci.segment = None
for i in xrange(0, ci.count):
for i in range(0, ci.count):
curve = self.curves[i]
ci.reverse[i] = bool(curve.reverse)
ci.segment[i] = librt.cast(librt.pointer(curve.build_segment()), librt.c_void_p)
Expand All @@ -485,7 +485,7 @@ def has_same_data(self, other):
curve_count = len(self.curves)
if len(other.curves) != curve_count:
return False
return all([self.curves[i].is_same(other.curves[i]) for i in xrange(0, curve_count)])
return all([self.curves[i].is_same(other.curves[i]) for i in range(0, curve_count)])

def line(self, start, end, reverse=False, copy=False):
return Line(self, [start, end], reverse=reverse, copy=copy)
Expand Down Expand Up @@ -517,13 +517,13 @@ def revolve(self, name, revolve_center=None, revolve_axis=None, radius=None, ang
@staticmethod
def from_wdb(name, data):
vertices = []
for i in xrange(0, data.vert_count):
for i in range(0, data.vert_count):
vertices.append(Vector(data.verts[i]))
result = Sketch(
name=name, base=Vector(data.V), u_vec=Vector(data.u_vec), v_vec=Vector(data.v_vec), vertices=vertices
)
curves = data.curve
for i in xrange(0, curves.count):
for i in range(0, curves.count):
curve = curves.segment[i]
magic = librt.cast(curve, librt.POINTER(librt.struct_line_seg)).contents.magic
reverse = bool(curves.reverse[i])
Expand Down
2 changes: 1 addition & 1 deletion brlcad/vmath/vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ def compare_for_sort(self, other):
result = length - len(other)
if result:
return result
for i in xrange(0, length):
for i in range(0, length):
result = self[i] - other[i]
if result:
return result
Expand Down
2 changes: 1 addition & 1 deletion brlcad/wdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def __init__(self, db_file, title=None):
raise BRLCADException("Can't open DB file <{0}>: {1}".format(db_file, e))

def __iter__(self):
for i in xrange(0, libwdb.RT_DBNHASH):
for i in range(0, libwdb.RT_DBNHASH):
dp = self.db_ip.contents.dbi_Head[i]
while dp:
crt_dir = dp.contents
Expand Down
2 changes: 1 addition & 1 deletion examples/wdb_primitives.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,4 +202,4 @@

with WDB("test_wdb.g") as brl_db:
for x in brl_db.ls():
print brl_db.lookup(x)
print(brl_db.lookup(x))
Loading