diff --git a/softwrap2/__init__.py b/softwrap2/__init__.py new file mode 100644 index 0000000..b8fb790 --- /dev/null +++ b/softwrap2/__init__.py @@ -0,0 +1,1208 @@ +# Copyright (C) 2021 Jean Da Costa machado. +# Jean3dimensional@gmail.com +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +import bpy +import bmesh +import gc +import random +import time +from math import atan2, ceil +from . import softwrap_core2 as core +from . draw_3d import DrawCallback +from bpy_extras.view3d_utils import region_2d_to_origin_3d, region_2d_to_vector_3d, location_3d_to_region_2d +from mathutils.geometry import intersect_line_plane +from mathutils import Vector, Matrix +from collections import namedtuple, defaultdict +import bpy.app.handlers as handlers + + +bl_info = {'name': 'Softwrap 2', + 'description': 'Transfer topology from one model to another using a softbody simulation', + 'author': 'Jean Da Costa Machado', + 'version': ('2.1.2-alpha-for-blender3.1 -- a928357391',), # ship:-v + 'blender': (3, 1, 0), + 'doc_url': 'https://jeacom25b.github.io/Softwrap-Manual/', + 'tracker_url': 'https://jeacom25b.github.io/Softwrap-Manual/', + 'category': 'Mesh', + 'location': '3D view > properties (N-panel) > Softwrap 2'} + +all_classes = [] + +running_op = None + +SW_SHAPE_KEY_NAME = 'SoftWrap_Shape_key' + + +def register_cls(cls): + all_classes.append(cls) + return cls + + +class PerfTimer: + timer_data = defaultdict(list) + timer_tmp = {} + + def start(self, key='time'): + self.timer_tmp[key] = time.time() + + def stop(self, key='time', max_samples=30): + self.timer_data[key].append(time.time() - self.timer_tmp[key]) + + def __str__(self): + return '' + + +def register_panel_draw(label=None, parent_cls=None, poll=lambda s, c: True): + def decorator(draw_fnc): + nonlocal label, parent_cls, poll + if not label or callable(label): + label = ' '.join(x.capitalize() for x in draw_fnc.__name__.split('_')) + namespace = { + 'bl_label': label, + 'bl_space_type': 'VIEW_3D', + 'bl_region_type': 'UI', + 'bl_category': 'Softwrap 2', + 'poll': classmethod(poll), + 'draw': draw_fnc + } + if parent_cls: + namespace['bl_parent_id'] = parent_cls.__name__ + + return register_cls(type(f'VIEW3D_PT_softwrap2_{draw_fnc.__name__}', + (bpy.types.Panel,), + namespace)) + if callable(label): # actually draw_fnc + return decorator(label) + return decorator + + +def smoothstep(f, fmin=0, fmax=1): + f = max(0, min(1, (f - fmin) / (fmax - fmin))) + return f * f * (3 - 2 * f) + + +def lerp(a, b, f): + return (b - a) * f + a + + +def intersect_point_2d_rectangle(px, py, rx, ry, width, height): + if px <= rx: + return False + if py <= ry: + return False + if px - rx >= width: + return False + if py - ry >= height: + return False + + return True + + +def areas_under_mouse(context, event): + mx, my = event.mouse_x, event.mouse_y + areas = [] + for area in context.screen.areas: + regions = [] + + if intersect_point_2d_rectangle(mx, my, area.x, area.y, area.width, area.height): + for region in area.regions: + if intersect_point_2d_rectangle(mx, my, region.x, region.y, region.width, region.height): + regions.append(region) + + areas.append((area, regions)) + + return areas + + +def get_mouse_ray(context, event, mat=Matrix.Identity(4)): + region = context.region + r3d = context.space_data.region_3d + co = event.mouse_region_x, event.mouse_region_y + origin = mat @ region_2d_to_origin_3d(region, r3d, co) + vec = region_2d_to_vector_3d(region, r3d, co) + vec.rotate(mat) + return origin, vec + + +def mouse_raycast(obj, context, event): + mat = obj.matrix_world.inverted() + origin, vec = get_mouse_ray(context, event, mat) + return obj.ray_cast(origin, vec) + + +def global_to_screen(co, context): + region = context.region + r3d = context.space_data.region_3d + return location_3d_to_region_2d(region, r3d, co) + + +def vertex_group_to_list(obj, vg_name): + vg = obj.vertex_groups.get(vg_name, None) + if not vg: + return None + data = [] + for i in range(len(obj.data.vertices)): + try: + data.append(vg.weight(i)) + except RuntimeError: + data.append(0) + return data + + +def core_mesh_from_bm(bm): + bm.verts.ensure_lookup_table() + verts = [tuple(v.co) for v in bm.verts] + + def triangles(face): + for i in range(len(face.verts) - 2): + yield face.verts[0].index, face.verts[i + 1].index, face.verts[i + 2].index + + faces = [tri for f in bm.faces for tri in triangles(f)] + return core.Mesh(verts, faces) + + +def deduplicate_links(items): + if not items: + return items + return list(tuple(x) for x in set(frozenset(a) for a in items) if len(x) == 2) + + +def loop_pairs(elems): + n = len(elems) + half_n = n // 2 + + for i in range(half_n + n % 2): + yield (elems[i], elems[(i + half_n) % n]) + + +def sort_vert_link_edges(vert): + u = vert.normal.orthogonal().normalized() + v = vert.normal.cross(u) + o = vert.co + + def angle(edge): + vec = vert.co - edge.other_vert(vert).co + return atan2(vec.dot(u), vec.dot(v)) + + return sorted(vert.link_edges, key=angle) + + +def sort_vert_link_loops(vert): + u = vert.normal.orthogonal().normalized() + v = vert.normal.cross(u) + o = vert.co + + loops = vert.link_loops + + def angle(loop): + vec = loop.vert.co - loop.link_loop_next.vert.co + return atan2(vec.dot(u), vec.dot(v)) + + return sorted(loops, key=angle) + + +def structural_springs_indexes(bm): + springs = list(tuple(v.index for v in edge.verts) for edge in bm.edges) + return springs + + +def somoothing_springs_indexes(bm): + return [tuple(v.index for v in edge.verts) for edge in bm.edges if edge.verts[0].is_boundary == edge.verts[1].is_boundary] + + +def shear_spring_indexes(bm): + return [(v.index for v in pair) for face in bm.faces for pair in loop_pairs(face.verts)] + + +def bending_spring_indexes(bm, distance=1): + distance = max(distance, 1) + + springs = {} + length_correlations = set() + links_by_edge = defaultdict(list) + + for vert in bm.verts: + for loop in vert.link_loops: + edge = loop.edge + links_by_edge[edge].append([]) + for _ in range(distance): + loop = loop.link_loop_next + for _ in range(len(loop.vert.link_edges) // 2 - 1): + loop = loop.link_loop_radial_next.link_loop_next + + other = loop.vert + if vert.index == other.index: + continue + + spr = frozenset((vert.index, other.index)) + if spr not in springs: + springs[spr] = 1 + links_by_edge[edge][-1].append(len(springs) - 1) + + for edge in bm.edges: + for spring_chain in links_by_edge[edge]: + for i in range(len(spring_chain) - 1): + length_correlations.add(frozenset((spring_chain[i], spring_chain[i + 1]))) + + return list(springs.keys()) # , list(length_correlations) + + +def ternary_links_indexes(bm): + links = [] + for vert in bm.verts: + for ea, eb in loop_pairs(sort_vert_link_edges(vert)): + va = ea.other_vert(vert) + vb = eb.other_vert(vert) + link = vert.index, va.index, vb.index + if not len(frozenset(link)) < 3: + links.append(link) + return links + + +def quaternary_link_indexes(bm): + links = [] + for face in bm.faces: + if len(face.verts) == 4: + indexes = *(v.index for v in face.verts), + links.append((indexes[0], indexes[1], indexes[3], indexes[2])) + links.append((indexes[0], indexes[3], indexes[1], indexes[2])) + links.append((indexes[0], indexes[2], indexes[1], indexes[3])) + + for vert in bm.verts: + for e1, e2 in loop_pairs(sort_vert_link_edges(vert)): + if e1.is_manifold and e2.is_manifold: + links.append((vert.index, e1.other_vert(vert).index, vert.index, e2.other_vert(vert).index)) + + return links + + +def iter_float_factor(value, max_val, power_fac=1, size=1): + value = (value / size) ** power_fac * size + i = 0 + while value > 0: + yield i, min(value, max_val) + value -= max_val + i += 1 + + +@register_cls +class SoftwrapSettings(bpy.types.PropertyGroup): + def stop_engine(self, context): + if running_op: + running_op.stop(context) + + def set_wire(self, context): + if self.source_ob: + self.wire = self.source_ob.show_wire + + def source_ob_update(self, context): + if self.source_ob and not self.source_ob.type == 'MESH': + self.source_ob = None + self.stop_engine(context) + self.set_wire(context) + + def target_ob_update(self, context): + if self.target_ob and not self.target_ob.type == 'MESH': + self.target_ob = None + self.stop_engine(context) + + def wire_update(self, context): + if self.source_ob: + self.source_ob.show_wire = self.wire + self.source_ob.show_all_edges = self.wire + + def snapping_group_update(self, context): + if running_op: + running_op.snapping_mask_update(context) + + def simulation_group_update(self, context): + if running_op: + running_op.simulation_mask_update(context) + + def mesh_poll(self, ob): + return ob.type == 'MESH' and ob.name in bpy.context.scene.objects + + source_ob: bpy.props.PointerProperty( + name='source mesh', type=bpy.types.Object, update=source_ob_update, poll=mesh_poll, + description='The mesh that is going to be deformed into a new shape using the target mesh as reference') + + target_ob: bpy.props.PointerProperty( + name='target mesh', type=bpy.types.Object, update=target_ob_update, poll=mesh_poll, + description='The mesh that is going to be used as reference, (tipcally a sculpt or a 3d scan)') + + snapping_group: bpy.props.StringProperty( + name='Snapping Group', update=snapping_group_update, + description='vertex group to mask what vertices are involved on the snapping') + + snapping_group_invert: bpy.props.BoolProperty( + name='Invert Snapping Group', + description='Inverts the vertex group influence',) + + simulation_group: bpy.props.StringProperty( + name='Simulation Group', update=simulation_group_update, + description='vertex group to mask what vertices should be simulated,') + + simulation_group_invert: bpy.props.BoolProperty( + name='Invert Simulation Group', + description='Inverts the vertex group influence',) + + wire: bpy.props.BoolProperty( + name='Wire', update=wire_update, + description='Toggle wireframe display on the source mesh') + + mirror: bpy.props.BoolVectorProperty( + name='Mirror', size=3, default=(False, False, False), + description='Enforce symmetry acrons an axis.') + + min_scaling: bpy.props.FloatProperty( + name='Min Scaling', default=0.3, + description='Minimun allowed rest length for edges') + + max_scaling: bpy.props.FloatProperty( + name='Max Scaling', default=3, + description='Maximun allowed rest length for edges') + + scale_plasticity: bpy.props.FloatProperty( + name='Scale Plasticity', min=0, max=1, default=0.1, + description='Amount of semi-permanent deformation per frame') + + scale_restoration: bpy.props.FloatProperty( + name='Scale Restoration', min=0, max=1, default=0.05, + description='Amount of restoration to the semi-parmanent deformation per frame') + + smooth: bpy.props.FloatProperty( + name='Smooth', min=0, soft_max=5, default=0, + description='Amount of somothing applied to the mesh per frame (nonlinear)\n' + 'Note: has the side effect of swrinking the mesh,') + + quad_smoothing: bpy.props.FloatProperty( + name='Quad Smooth', min=0, soft_max=10, default=0, + description='Amount of force applied per frame to restore the shape of quads (nonlinear)\n' + 'Note: has the side effect of swrinking the mesh,') + + topologic_smooth: bpy.props.FloatProperty( + name='Topologic Smooth', min=0, soft_max=5, default=2, + description='Amount of topology-aware smoothing applied to the mesh per frame, (nonlinear)\n' + 'Note: Less aggressive than smooth, ideal for removing kinks in edge loops caused by by pins') + + structural_stiffness: bpy.props.FloatProperty( + name='Structural Stiffness', min=0, soft_max=10, default=2, + description='Stiffness of the direct links between vertices') + + bending_stiffness: bpy.props.FloatProperty( + name='Bending Stiffness', min=0, soft_max=10, default=2, + description='Stiffness of the links across multiple edges') + + shear_stiffness: bpy.props.FloatProperty( + name='Shear Stiffness', min=0, soft_max=10, default=2, + description='Stiffness of the links across face diagonals') + + bending_distance: bpy.props.IntProperty( + name='Bending Distance', min=0, default=3, + description='Maximun distance (by edges) for bending springs to be created') + + damping: bpy.props.FloatProperty( + name='Damping', min=0, max=1, default=0.25, + description='Dampen the simulation to increase stability') + + simulation_steps: bpy.props.IntProperty( + name='Simulation Steps', min=0, default=2, + description='Number of simulation steps per frame') + + snapping_quality: bpy.props.IntProperty( + name='Snapping Quality', min=1, max=20, default=10, + description='How of often to update the snapping direction from the source mesh to the target mesh') + + snapping_force: bpy.props.FloatProperty( + name='Snapping Strength', min=0, max=1, default=0, + description='Strength of the snapping, how much it pulls the source mesh towards the target mesh') + + snapping_mode: bpy.props.EnumProperty( + name='Snap Mode', default='SURFACE', + items = [('SURFACE', 'Surface', 'Surface'), + ('OUTSIDE', 'Outside', 'Outside'), + ('INSIDE', 'Inside', 'Inside')], + description='Controls which side of the target mesh affects the snapping.') + + project_pins: bpy.props.BoolProperty( + name='Project Pins', default=True, + description='Virtually snap pins to the surface of the target mesh based on snapping force.\n') + + pin_force: bpy.props.FloatProperty( + name='Pin Force', min=0, max=1, default=1, + description='How strongly pins pull on the mesh') + + mouse_grab_size: bpy.props.IntProperty( + name='Mouse Grab Size', min=1, default=3, + description='Size of the area grabbed by the mouse') + + pause: bpy.props.BoolProperty( + name='Pause (Space)', default=False, + description='Temporarily halt the simulation') + + interact_mouse: bpy.props.BoolProperty( + name='Interaction (Shift + Space)', default=True, + description='Enable interception of mouse events for pin creation and grabbing') + + mouse_button: bpy.props.EnumProperty( + name='Interact With', default='LEFTMOUSE', + items=[('LEFTMOUSE', 'Left Mouse', 'Left Mouse'), ('RIGHTMOUSE', 'Right Mouse', 'Right Mouse')], + description='Which mouse button to use for interacting with the simulation ') + + +def get_settings(context): + return bpy.context.scene.softwrap2 + + +S = type('SettingsProbe', (), { + '__getattr__': lambda s, k: getattr(get_settings(bpy.context), k), + '__setattr__': lambda s, k, v: setattr(get_settings(bpy.context), k, v), + '__call__': lambda s: get_settings(bpy.context) +})() + + +@register_panel_draw +def softwrap_2(self, context): + pass + + +@register_panel_draw(parent_cls=softwrap_2) +def interaction(self, context): + layout = self.layout + if running_op: + if S.interact_mouse: + mouse_side = S.mouse_button.replace('_', ' ').lower() + layout.label(text=f'[shift + {mouse_side}] to add a pin') + else: + layout.label(text=f'Mouse interaction disabled') + + col = layout.column(align=True) + col.prop(S(), 'interact_mouse', toggle=True) + col.prop(S(), 'pause', toggle=True) + row = col.row(align=True) + row.prop(S(), 'mouse_button', expand=True) + col.separator() + + layout.prop(S(), 'mouse_grab_size') + + +@register_panel_draw(parent_cls=softwrap_2) +def initialization(self, context): + layout = self.layout + col = layout.column(align=True) + row = col.row(align=True) + row.scale_y = 2 + if running_op: + running_anim = ['*---', '-*--', + '--*-', '---*', + '--*-', '-*--'][int(time.time() * 5) % 5] + row.operator('object.start_softwrap', text=f'Stop {running_anim}', icon='CANCEL') + row.prop(S(), 'pause', icon='PAUSE') + else: + row.operator('object.start_softwrap', text='Start', icon='PLAY') + + row = col.row(align=True) + row.operator('object.apply_softwrap') + row.operator('object.reset_softwrap') + row.operator('object.pins_remove_softwrap') + + if S.source_ob: + layout.label(text='Display') + row = layout.row(align=True) + row.prop(S(), 'wire', toggle=True) + row.prop(S().source_ob, 'show_in_front', toggle=True) + layout.separator() + + col = layout.column(align=True) + col.label(text='Source Mesh:') + col.prop(S(), 'source_ob', text='') + col.separator() + + col.label(text='Target Mesh:') + col.prop(S(), 'target_ob', text='') + layout.separator() + + col = layout.column() + col.active = not running_op + col.prop(S(), 'bending_distance') + + +@register_panel_draw(parent_cls=softwrap_2) +def dynamics(self, context): + pass + + +@register_panel_draw(parent_cls=dynamics) +def symmetry(self, context): + layout = self.layout + row = layout.row(align=True) + row.label(text='Mirror') + for i, axis in enumerate('XYZ'): + row.prop(S(), 'mirror', text=axis, index=i, toggle=True) + + if running_op: + for axis, enable, error, scale, dim in zip('XYZ', S.mirror, running_op.symmetry_map.error, S.source_ob.scale, S.source_ob.dimensions): + if enable and error / (dim / scale) > 0.05: + layout.label(text=f'Warning: source mesh may not be symmetrical at axis {axis}', icon='ERROR') + layout.label(text=f' Error: {round(error / (dim / scale) , 6)}') + + +@register_panel_draw(parent_cls=dynamics) +def Stiffness(self, context): + layout = self.layout + col = layout.column(align=True) + col.prop(S(), 'structural_stiffness', slider=True) + col.prop(S(), 'shear_stiffness', slider=True) + col.prop(S(), 'bending_stiffness', slider=True) + layout.prop(S(), 'damping', slider=True) + + +@register_panel_draw(parent_cls=dynamics) +def smoothing(self, context): + layout = self.layout + layout.prop(S(), 'smooth', slider=True) + layout.prop(S(), 'quad_smoothing', slider=True) + layout.prop(S(), 'topologic_smooth', slider=True) + layout.separator() + + +@register_panel_draw(parent_cls=dynamics) +def snapping(self, context): + layout = self.layout + layout.prop(S(), 'snapping_force', slider=True) + layout.prop(S(), 'snapping_mode') + + layout.separator() + + if S.source_ob: + layout.label(text='Snapping Group') + row = layout.row(align=True) + row.prop_search(S(), 'snapping_group', S.source_ob, 'vertex_groups', text='') + row.prop(S(), 'snapping_group_invert', text='', icon='ARROW_LEFTRIGHT') + + layout.label(text='Simulation Group') + row = layout.row(align=True) + row.prop_search(S(), 'simulation_group', S.source_ob, 'vertex_groups', text='') + row.prop(S(), 'simulation_group_invert', text='', icon='ARROW_LEFTRIGHT') + + layout.label(text='Pins:') + layout.prop(S(), 'project_pins') + layout.prop(S(), 'pin_force', slider=True) + + +@register_panel_draw(parent_cls=dynamics) +def plasticity(self, context): + layout = self.layout + row = layout.row(align=True) + row.prop(S(), 'min_scaling') + row.prop(S(), 'max_scaling') + + row = layout.row(align=True) + row.prop(S(), 'scale_plasticity') + row.prop(S(), 'scale_restoration') + + +@register_panel_draw(parent_cls=softwrap_2) +def performance(self, context): + layout = self.layout + layout.prop(S(), 'simulation_steps') + layout.prop(S(), 'snapping_quality', slider=True) + + +PinCacheData = namedtuple('PinCacheData', 'engine_pin type scale factor world_pos', defaults=(None,) * 5) + + +@register_cls +class OBJECT_OT_start_softwrap(bpy.types.Operator): + bl_idname = 'object.start_softwrap' + bl_label = 'Test springs' + bl_options = {'REGISTER', 'UNDO'} + bl_description = 'Run the softwrap softbody engine' + + _timer = None + + source_mesh = None + target_mesh = None + + bvh = None + engine = None + structural_springs = None + shear_springs = None + bending_springs = None + + symmetry_map = None + + mouse_pin_pos = None + mouse_pin_delta = None + mouse_pin = None + + pin_cache = None + + simulation_mask = None + snapping_mask = None + + draw3d = None + + last_mode = None + + perf_timer = None + + @classmethod + def poll(self, context): + + if S.target_ob and not S.target_ob.type == 'MESH': + return False + return S.source_ob and S.source_ob.type == 'MESH' + + def invoke(self, context, event): + + global running_op + if running_op: + running_op.stop(context) + return {'CANCELLED'} + + S.source_ob.data.update() + bm = bmesh.new() + bm.from_mesh(S.source_ob.data) + + self.source_mesh = core_mesh_from_bm(bm) + + if S.target_ob: + tbm = bmesh.new() + tbm.from_mesh(S.target_ob.data) + bmesh.ops.transform(tbm, matrix=S.target_ob.matrix_world, space=Matrix.Identity(4), verts=tbm.verts) + bmesh.ops.transform(tbm, matrix=S.source_ob.matrix_world.inverted(), space=Matrix.Identity(4), verts=tbm.verts) + self.target_mesh = core_mesh_from_bm(tbm) + self.bvh = core.BVH(self.target_mesh) + + self.engine = core.SpringEngine(self.source_mesh, self.bvh) + + # import pdb + # pdb.set_trace() + self.structural_springs = self.engine.create_spring_group(structural_springs_indexes(bm)) + self.shear_springs = self.engine.create_spring_group(shear_spring_indexes(bm)) + self.bending_springs = self.engine.create_spring_group(bending_spring_indexes(bm, S.bending_distance)) + + self.symmetry_map = self.engine.create_symmetry_map() + + self.ternary_links = self.engine.create_ternary_links(ternary_links_indexes(bm)) + self.ternary_links.displacements_update() + + self.quaternary_links = self.engine.create_quaternary_links(quaternary_link_indexes(bm)) + self.quaternary_links.lengths_update() + + running_op = self + + self.snapping_mask_update(context) + self.simulation_mask_update(context) + + self.pin_cache = {} + self.draw3d = DrawCallback() + self.draw3d.point_size = 8 + self.draw3d.line_width = 3 + self.draw3d.setup_handler() + + context.window_manager.modal_handler_add(self) + self._timer = context.window_manager.event_timer_add(1 / 60, window=context.window) + self.perf_timer = PerfTimer() # completelly unrelated to self._timer + return {'RUNNING_MODAL'} + + def mouse_pin_set(self, context, event, create_empty=False): + + closest_distance = float('inf') + closest_empty = None + for pin_obj in S.source_ob.get('sw_pins', []): + pin_2d = global_to_screen(pin_obj.location, context) + if not pin_2d: + continue # behind camera + mouse_2d = Vector((event.mouse_region_x, event.mouse_region_y)) + dist = (pin_2d - mouse_2d).length + if dist < closest_distance: + closest_empty = pin_obj + closest_distance = dist + + if closest_empty and closest_distance < 30: + bpy.ops.object.select_all(action='DESELECT') + closest_empty.select_set(True) + context.view_layer.objects.active = closest_empty + return True + + result, location, normal, index = mouse_raycast(S.source_ob, context, event) + + if not result: + return False + + if not S.source_ob.modifiers: + index = min(S.source_ob.data.polygons[index].vertices, + key=lambda i: (self.get_shape(context).data[i].co - location).length) + + else: + index, v_location = self.source_mesh.closest_vert(location) + + if not create_empty: + self.mouse_pin_pos = S.source_ob.matrix_world @ location + self.mouse_pin_delta = self.mouse_pin_pos - S.source_ob.matrix_world @ self.get_shape(context).data[index].co + self.mouse_pin = core.SpringEnginePin(self.structural_springs, index, S.mouse_grab_size) + + else: + empty = bpy.data.objects.new(S.source_ob.name + '_pin', None) + + empty.empty_display_type = 'SPHERE' + radius_disp = self.structural_springs[index].avg_radius + empty.empty_display_size = radius_disp * 2 * sum(S.source_ob.scale) / 3 + empty.show_in_front = True + + empty.location = S.source_ob.matrix_world @ self.get_shape(context).data[index].co + + empty['vert_idx'] = index + bpy.context.collection.objects.link(empty) + pins = list(S.source_ob.get('sw_pins', [])) + pins.append(empty) + S.source_ob['sw_pins'] = pins + bpy.ops.object.select_all(action='DESELECT') + empty.select_set(True) + bpy.context.view_layer.objects.active = empty + bpy.ops.ed.undo_push(message='Add Pin') + + return True + + def mouse_pin_update(self, context, event): + o, dir = get_mouse_ray(context, event) + plane = context.space_data.region_3d.view_rotation @ Vector((0, 0, 1)) + self.mouse_pin_pos = intersect_line_plane(o, o + dir, self.mouse_pin_pos, plane) + + def mouse_pin_clear(self, context, event): + self.mouse_pin_pos = None + self.mouse_pin = None + self.mouse_pin_delta = None + + def empty_pin_scale(self, empty): + return max((sum(empty.scale) / 3) * 4, 1.000001) + + def pin_cache_update(self, context, event): + mat = S.source_ob.matrix_world + mat_inv = S.source_ob.matrix_world.inverted() + + S.source_ob['sw_pins'] = [ + empty for empty in S.source_ob.get('sw_pins', ()) + if empty and empty.name in context.scene.objects + ] + + new_cache = {} + seen_vert_idxs = set() + + def new_pin_reuse_cache(index, pin_type, scale, factor, location, n_rings): + previous_cache = self.pin_cache.get(index, PinCacheData(None)) + previous_pin = previous_cache.engine_pin + + if previous_pin and previous_pin.n_rings == n_rings: + new_cache[index] = PinCacheData(engine_pin=previous_pin, + type=pin_type, + scale=scale, + factor=factor, + world_pos=location) + else: + pin = core.SpringEnginePin(self.structural_springs, index, n_rings) + new_cache[index] = PinCacheData(engine_pin=pin, + type=pin_type, + scale=scale, + factor=factor, + world_pos=location) + + for empty in S.source_ob.get('sw_pins', ()): + index = empty['vert_idx'] + + if empty == context.active_object and empty.select_get(view_layer=context.view_layer): + pin_type = 'ACTIVE_PIN' + else: + pin_type = 'OBJ_PIN' + + vec = mat_inv @ empty.location + vec -= Vector(self.engine.get_verts([index])[0]) + + scale = self.empty_pin_scale(empty) + n_rings = int(scale) + + new_pin_reuse_cache(index, pin_type, scale, 1, empty.location, n_rings) + + if self.mouse_pin_pos: + self.mouse_pin_update(context, event) + pin_type = 'MOUSE_PIN' + index = self.mouse_pin.start_index + new_cache[index] = PinCacheData(engine_pin=self.mouse_pin, + type=pin_type, + scale=self.mouse_pin.n_rings + 1, + factor=1, + world_pos=self.mouse_pin_pos - self.mouse_pin_delta) + + for axis in range(3): + if S.mirror[axis]: + for idx, pin_data in list(new_cache.items()): + mirr_idx = self.symmetry_map[idx][axis] + if mirr_idx == idx: + continue + location = mat_inv @ pin_data.world_pos + location[axis] *= -1 + location = mat @ location + pin_type = 'MIRROR_' + pin_data.type + + new_pin_reuse_cache(mirr_idx, + pin_type, + pin_data.scale, + pin_data.factor, + location, + pin_data.engine_pin.n_rings) + + self.pin_cache = new_cache + + def pin_cache_apply(self, context, event, factor=1, mouse_factor=1): + + mat_inv = S.source_ob.matrix_world.inverted() + + for index, pin_data in self.pin_cache.items(): + vert_loc = Vector(self.engine.get_verts([index])[0]) + local_pos = mat_inv @ pin_data.world_pos + if self.bvh and S.project_pins and S.snapping_force > 0 and not pin_data.type == 'MOUSE_PIN': + f = S.snapping_force + if self.snapping_mask: + f *= 1 - self.snapping_mask[index] + local_pos = lerp(local_pos, Vector(self.bvh.find_nearest(local_pos)[0]), f) + vec = local_pos - vert_loc + if pin_data.type == 'MOUSE_PIN': + f = mouse_factor + else: + f = factor + pin_data.engine_pin.move(*(vec * pin_data.factor * f), pin_data.scale) + + def draw_pins(self, context, event): + + red = Vector((1, 0, 0, 0.5)) + green = Vector((0, 0.9, 0, 0.5)) + blue = Vector((0, 0, 0.5, 0.5)) + cyan = Vector((0, 0.2, 0.8, 0.5)) + purple = (cyan + red) / 2 + + self.draw3d.clear_data() + + for index, pin_data in self.pin_cache.items(): + + vert_loc = S.source_ob.matrix_world @ Vector(self.engine.get_verts([index])[0]) + + if pin_data.type.startswith('MIRROR_'): + self.draw3d.add_line(vert_loc, pin_data.world_pos, purple, cyan) + self.draw3d.add_point(vert_loc, purple) + self.draw3d.add_point(pin_data.world_pos, cyan) + else: + self.draw3d.add_line(vert_loc, pin_data.world_pos, purple, red) + self.draw3d.add_point(vert_loc, purple) + self.draw3d.add_point(pin_data.world_pos, red) + + if pin_data.type in {'ACTIVE_PIN', 'MOUSE_PIN'}: + + for i, ring in enumerate(pin_data.engine_pin): + indexes = list(ring) + locations = self.engine.get_verts(indexes) + f = 1 - max((pin_data.scale - i - 1) / (pin_data.scale - 1), 0) + color = lerp(red, green, smoothstep(f, 0, 0.7) ** 3) + color = lerp(color, blue, smoothstep(f, 0.7, 1)) + color.w = (1 - f) ** 0.2 + for loc in locations: + loc = S.source_ob.matrix_world @ Vector(loc) + self.draw3d.add_point(loc, color) + + self.draw3d.update_batch() + + def snapping_mask_update(self, context): + vg_data = vertex_group_to_list(S.source_ob, S.snapping_group) + self.snapping_mask = self.engine.create_mask(vg_data) + + def simulation_mask_update(self, context): + vg_data = vertex_group_to_list(S.source_ob, S.simulation_group) + self.simulation_mask = self.engine.create_mask(vg_data) + + def reset_simulation(self, context): + vdata = [0] * len(self.engine) + S.source_ob.data.vertices.foreach_get('co', vdata) + self.engine.from_list(vdata) + self.engine.kinetic_step(0) + self.structural_springs.lengths_update() + self.shear_springs.lengths_update() + self.bending_springs.lengths_update() + self.ternary_links.displacements_update() + self.quaternary_links.lengths_update() + + def load_shape_to_engine(self, context): + vdata = [0] * len(self.engine) + self.get_shape(context).data.foreach_get('co', vdata) + self.engine.from_list(vdata) + self.engine.kinetic_step(0) + + def get_shape(self, context): + sk = S.source_ob.data.shape_keys + if sk and SW_SHAPE_KEY_NAME in sk.key_blocks: + return sk.key_blocks[SW_SHAPE_KEY_NAME] + else: + if not sk or len(sk.key_blocks) == 0: + S.source_ob.shape_key_add(name='Basis') + shape = S.source_ob.shape_key_add(name=SW_SHAPE_KEY_NAME) + shape.value = 1 + return shape + + error = None + + def modal(self, context, event): + global running_op + if self.error: + print('operator runned twice') + return {'FINISHED'} + + try: + return self.modal_impl(context, event) + except Exception as e: + self.error = e + self.stop(context) + raise e + + def stop(self, context): + self.draw3d.remove_handler() + bpy.context.window_manager.event_timer_remove(self._timer) + global running_op + running_op = None + + def modal_impl(self, context, event): + global running_op + + if not running_op or event.type == 'ESC'\ + or not S.source_ob\ + or not len(S.source_ob.data.vertices) * 3 == len(self.engine): + + self.stop(context) + return {'FINISHED'} + + if not S.source_ob.mode == 'OBJECT': + self.get_shape(context).mute = True + else: + self.get_shape(context).mute = False + + if not self.last_mode == 'OBJECT' and S.source_ob.mode == 'OBJECT': + self.reset_simulation(context) + self.load_shape_to_engine(context) + self.simulation_mask_update(context) + self.snapping_mask_update(context) + + self.last_mode = S.source_ob.mode + + if event.type == 'SPACE' and event.value == 'PRESS' and not event.ctrl and S.source_ob.mode == 'OBJECT': + if event.shift: + S.interact_mouse = not S.interact_mouse + else: + S.pause = not S.pause + context.area.tag_redraw() + return {'RUNNING_MODAL'} + + if event.type == 'TIMER': + + if not S.pause and S.source_ob.mode == 'OBJECT': + + with self.simulation_mask.masked_context(invert=S.simulation_group_invert): + + for _ in range(S.simulation_steps): + + for i, f in iter_float_factor(S.quad_smoothing, 1, 3, 10): + self.quaternary_links.smooth(f) + + for i, f in iter_float_factor(S.shear_stiffness, 1, 3, 10): + if i > 0: + self.shear_springs.stiff_spring_force(f) + else: + self.shear_springs.soft_spring_force(f, deform_update=S.scale_plasticity, + deform_restore=S.scale_restoration, + min_deform=S.min_scaling, + max_deform=S.max_scaling) + + for i, f in iter_float_factor(S.bending_stiffness, 1, 3, 10): + if i > 0: + self.bending_springs.stiff_spring_force(f) + else: + self.bending_springs.soft_spring_force(f, deform_update=S.scale_plasticity, + deform_restore=S.scale_restoration, + min_deform=S.min_scaling, + max_deform=S.max_scaling) + + for i, f in iter_float_factor(S.structural_stiffness, 1, 3, 10): + if i > 0: + self.structural_springs.stiff_spring_force(f) + else: + self.structural_springs.soft_spring_force(f, deform_update=S.scale_plasticity, + deform_restore=S.scale_restoration, + min_deform=S.min_scaling, + max_deform=S.max_scaling) + + self.engine.kinetic_step(1 - S.damping) + + for i, f in iter_float_factor(S.smooth, 0.5, 3, 5): + self.structural_springs.smooth(f) + + for i, f in iter_float_factor(S.topologic_smooth, 0.5, 3, 5): + self.ternary_links.displacement_force(f) + + self.engine.update_mesh_normals(1) + + f = S.pin_force ** 4 + for i in range(3): + self.pin_cache_update(context, event) + self.pin_cache_apply(context, event, factor=((i + 1) / 3) * f, mouse_factor=1) + + with self.snapping_mask.masked_context(invert=S.snapping_group_invert): + if self.bvh and S.snapping_force > 0: + self.engine.snap_to_bvh(S.snapping_force ** 3, 20 - S.snapping_quality + 1, snapping_mode = S.snapping_mode) + + self.symmetry_map.mirror(*S.mirror) + + self.get_shape(context).data.foreach_set('co', self.engine) + S.source_ob.data.update() + + self.draw_pins(context, event) + + else: + self.pin_cache_update(context, event) + self.draw_pins(context, event) + + return {'PASS_THROUGH'} if not self.mouse_pin_pos else {'RUNNING_MODAL'} + + if event.type == S.mouse_button and event.value == 'PRESS' and S.interact_mouse: + + areas = areas_under_mouse(context, event) + bad_region = False + + for area, regions in areas: + if area.type == 'VIEW_3D': + r_types = set(r.type for r in regions) + if {'UI', 'HEADER', 'TOOLS'} & r_types: + bad_region = True + + if not bad_region and self.mouse_pin_set(context, event, create_empty=event.shift): + return {'RUNNING_MODAL'} + + elif event.type == S.mouse_button and event.value == 'RELEASE': + self.mouse_pin_clear(context, event) + return {'PASS_THROUGH'} + + return {'PASS_THROUGH'} + + +@register_cls +class OBJECT_OT_apply_softwrap(bpy.types.Operator): + bl_idname = 'object.apply_softwrap' + bl_label = 'Apply' + bl_options = {'REGISTER', 'UNDO'} + bl_description = 'Apply the deformation and exit simulation if running' + + @classmethod + def poll(self, context): + return get_settings(context).source_ob + + def execute(self, context): + + shapes = S.source_ob.data.shape_keys + bpy.ops.object.pins_remove_softwrap() + + if shapes and SW_SHAPE_KEY_NAME in shapes.key_blocks: + data = [0] * (len(S.source_ob.data.vertices) * 3) + shapes.key_blocks[SW_SHAPE_KEY_NAME].data.foreach_get('co', data) + S.source_ob.shape_key_remove(shapes.key_blocks[SW_SHAPE_KEY_NAME]) + + if S.source_ob.data.shape_keys: + if len(shapes.key_blocks) == 1: + S.source_ob.shape_key_remove(shapes.key_blocks[0]) + S.source_ob.data.vertices.foreach_set('co', data) + else: + shapes.key_blocks[0].data.foreach_set('co', data) + else: + S.source_ob.data.vertices.foreach_set('co', data) + else: + return {'CANCELLED'} + + if running_op: + running_op.reset_simulation(context) + + return {'FINISHED'} + + +@register_cls +class OBJECT_OT_reset_softwrap(bpy.types.Operator): + bl_idname = 'object.reset_softwrap' + bl_label = 'Reset' + bl_options = {'REGISTER', 'UNDO'} + bl_description = 'Reset the deformation' + + @classmethod + def poll(self, context): + return get_settings(context).source_ob + + def execute(self, context): + + if running_op: + running_op.reset_simulation(context) + + shapes = S.source_ob.data.shape_keys + if shapes and SW_SHAPE_KEY_NAME in shapes.key_blocks: + S.source_ob.shape_key_remove(shapes.key_blocks[SW_SHAPE_KEY_NAME]) + if S.source_ob.data.shape_keys and len(shapes.key_blocks) == 1: + S.source_ob.shape_key_remove(shapes.key_blocks[0]) + return {'FINISHED'} + return {'CANCELLED'} + + +@register_cls +class OBJECT_OT_remove_pins_softwrap(bpy.types.Operator): + bl_idname = 'object.pins_remove_softwrap' + bl_label = 'Delete Pins' + bl_options = {'REGISTER', 'UNDO'} + bl_description = 'Delete all pins assigned to this mesh' + + @classmethod + def poll(self, context): + return get_settings(context).source_ob + + def execute(self, context): + + for pin_obj in S.source_ob.get('sw_pins', []): + bpy.data.objects.remove(pin_obj) + + S.source_ob['sw_pins'] = [] + del S.source_ob['sw_pins'] + return {'FINISHED'} + + +@handlers.persistent +def load_pre_handler(scene): + S().stop_engine(bpy.context) + DrawCallback.remove_all_handlers() + + +def register(): + handlers.load_pre.append(load_pre_handler) + for cls in all_classes: + bpy.utils.register_class(cls) + + bpy.types.Scene.softwrap2 = bpy.props.PointerProperty(type=SoftwrapSettings) + + +def unregister(): + handlers.load_pre.remove(load_pre_handler) + for cls in all_classes: + bpy.utils.unregister_class(cls) + + del bpy.types.Scene.softwrap2 diff --git a/softwrap2/core/core2.cpp b/softwrap2/core/core2.cpp new file mode 100644 index 0000000..cb7f341 --- /dev/null +++ b/softwrap2/core/core2.cpp @@ -0,0 +1,37453 @@ +/* Postprocessed to add #line directives */ +/* Generated by Cython 0.29.28 */ + +/* BEGIN: Cython Metadata +{ + "distutils": { + "depends": [], + "extra_compile_args": [ + "/O2", + "/openmp", + "/fp:fast" + ], + "extra_link_args": [ + "/openmp" + ], + "include_dirs": [ + "core" + ], + "language": "c++", + "name": "softwrap_core2", + "sources": [ + "core/core2.pyx" + ] + }, + "module_name": "softwrap_core2" +} +END: Cython Metadata */ + +#ifndef PY_SSIZE_T_CLEAN +#define PY_SSIZE_T_CLEAN +#endif /* PY_SSIZE_T_CLEAN */ +#include "Python.h" +#ifndef Py_PYTHON_H + #error Python headers needed to compile C extensions, please install development version of Python. +#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000) + #error Cython requires Python 2.6+ or Python 3.3+. +#else +#define CYTHON_ABI "0_29_28" +#define CYTHON_HEX_VERSION 0x001D1CF0 +#define CYTHON_FUTURE_DIVISION 1 +#include +#ifndef offsetof + #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) +#endif +#if !defined(WIN32) && !defined(MS_WINDOWS) + #ifndef __stdcall + #define __stdcall + #endif + #ifndef __cdecl + #define __cdecl + #endif + #ifndef __fastcall + #define __fastcall + #endif +#endif +#ifndef DL_IMPORT + #define DL_IMPORT(t) t +#endif +#ifndef DL_EXPORT + #define DL_EXPORT(t) t +#endif +#define __PYX_COMMA , +#ifndef HAVE_LONG_LONG + #if PY_VERSION_HEX >= 0x02070000 + #define HAVE_LONG_LONG + #endif +#endif +#ifndef PY_LONG_LONG + #define PY_LONG_LONG LONG_LONG +#endif +#ifndef Py_HUGE_VAL + #define Py_HUGE_VAL HUGE_VAL +#endif +#ifdef PYPY_VERSION + #define CYTHON_COMPILING_IN_PYPY 1 + #define CYTHON_COMPILING_IN_PYSTON 0 + #define CYTHON_COMPILING_IN_CPYTHON 0 + #undef CYTHON_USE_TYPE_SLOTS + #define CYTHON_USE_TYPE_SLOTS 0 + #undef CYTHON_USE_PYTYPE_LOOKUP + #define CYTHON_USE_PYTYPE_LOOKUP 0 + #if PY_VERSION_HEX < 0x03050000 + #undef CYTHON_USE_ASYNC_SLOTS + #define CYTHON_USE_ASYNC_SLOTS 0 + #elif !defined(CYTHON_USE_ASYNC_SLOTS) + #define CYTHON_USE_ASYNC_SLOTS 1 + #endif + #undef CYTHON_USE_PYLIST_INTERNALS + #define CYTHON_USE_PYLIST_INTERNALS 0 + #undef CYTHON_USE_UNICODE_INTERNALS + #define CYTHON_USE_UNICODE_INTERNALS 0 + #undef CYTHON_USE_UNICODE_WRITER + #define CYTHON_USE_UNICODE_WRITER 0 + #undef CYTHON_USE_PYLONG_INTERNALS + #define CYTHON_USE_PYLONG_INTERNALS 0 + #undef CYTHON_AVOID_BORROWED_REFS + #define CYTHON_AVOID_BORROWED_REFS 1 + #undef CYTHON_ASSUME_SAFE_MACROS + #define CYTHON_ASSUME_SAFE_MACROS 0 + #undef CYTHON_UNPACK_METHODS + #define CYTHON_UNPACK_METHODS 0 + #undef CYTHON_FAST_THREAD_STATE + #define CYTHON_FAST_THREAD_STATE 0 + #undef CYTHON_FAST_PYCALL + #define CYTHON_FAST_PYCALL 0 + #undef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT 0 + #undef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE 0 + #undef CYTHON_USE_DICT_VERSIONS + #define CYTHON_USE_DICT_VERSIONS 0 + #undef CYTHON_USE_EXC_INFO_STACK + #define CYTHON_USE_EXC_INFO_STACK 0 +#elif defined(PYSTON_VERSION) + #define CYTHON_COMPILING_IN_PYPY 0 + #define CYTHON_COMPILING_IN_PYSTON 1 + #define CYTHON_COMPILING_IN_CPYTHON 0 + #ifndef CYTHON_USE_TYPE_SLOTS + #define CYTHON_USE_TYPE_SLOTS 1 + #endif + #undef CYTHON_USE_PYTYPE_LOOKUP + #define CYTHON_USE_PYTYPE_LOOKUP 0 + #undef CYTHON_USE_ASYNC_SLOTS + #define CYTHON_USE_ASYNC_SLOTS 0 + #undef CYTHON_USE_PYLIST_INTERNALS + #define CYTHON_USE_PYLIST_INTERNALS 0 + #ifndef CYTHON_USE_UNICODE_INTERNALS + #define CYTHON_USE_UNICODE_INTERNALS 1 + #endif + #undef CYTHON_USE_UNICODE_WRITER + #define CYTHON_USE_UNICODE_WRITER 0 + #undef CYTHON_USE_PYLONG_INTERNALS + #define CYTHON_USE_PYLONG_INTERNALS 0 + #ifndef CYTHON_AVOID_BORROWED_REFS + #define CYTHON_AVOID_BORROWED_REFS 0 + #endif + #ifndef CYTHON_ASSUME_SAFE_MACROS + #define CYTHON_ASSUME_SAFE_MACROS 1 + #endif + #ifndef CYTHON_UNPACK_METHODS + #define CYTHON_UNPACK_METHODS 1 + #endif + #undef CYTHON_FAST_THREAD_STATE + #define CYTHON_FAST_THREAD_STATE 0 + #undef CYTHON_FAST_PYCALL + #define CYTHON_FAST_PYCALL 0 + #undef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT 0 + #undef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE 0 + #undef CYTHON_USE_DICT_VERSIONS + #define CYTHON_USE_DICT_VERSIONS 0 + #undef CYTHON_USE_EXC_INFO_STACK + #define CYTHON_USE_EXC_INFO_STACK 0 +#else + #define CYTHON_COMPILING_IN_PYPY 0 + #define CYTHON_COMPILING_IN_PYSTON 0 + #define CYTHON_COMPILING_IN_CPYTHON 1 + #ifndef CYTHON_USE_TYPE_SLOTS + #define CYTHON_USE_TYPE_SLOTS 1 + #endif + #if PY_VERSION_HEX < 0x02070000 + #undef CYTHON_USE_PYTYPE_LOOKUP + #define CYTHON_USE_PYTYPE_LOOKUP 0 + #elif !defined(CYTHON_USE_PYTYPE_LOOKUP) + #define CYTHON_USE_PYTYPE_LOOKUP 1 + #endif + #if PY_MAJOR_VERSION < 3 + #undef CYTHON_USE_ASYNC_SLOTS + #define CYTHON_USE_ASYNC_SLOTS 0 + #elif !defined(CYTHON_USE_ASYNC_SLOTS) + #define CYTHON_USE_ASYNC_SLOTS 1 + #endif + #if PY_VERSION_HEX < 0x02070000 + #undef CYTHON_USE_PYLONG_INTERNALS + #define CYTHON_USE_PYLONG_INTERNALS 0 + #elif !defined(CYTHON_USE_PYLONG_INTERNALS) + #define CYTHON_USE_PYLONG_INTERNALS 1 + #endif + #ifndef CYTHON_USE_PYLIST_INTERNALS + #define CYTHON_USE_PYLIST_INTERNALS 1 + #endif + #ifndef CYTHON_USE_UNICODE_INTERNALS + #define CYTHON_USE_UNICODE_INTERNALS 1 + #endif + #if PY_VERSION_HEX < 0x030300F0 || PY_VERSION_HEX >= 0x030B00A2 + #undef CYTHON_USE_UNICODE_WRITER + #define CYTHON_USE_UNICODE_WRITER 0 + #elif !defined(CYTHON_USE_UNICODE_WRITER) + #define CYTHON_USE_UNICODE_WRITER 1 + #endif + #ifndef CYTHON_AVOID_BORROWED_REFS + #define CYTHON_AVOID_BORROWED_REFS 0 + #endif + #ifndef CYTHON_ASSUME_SAFE_MACROS + #define CYTHON_ASSUME_SAFE_MACROS 1 + #endif + #ifndef CYTHON_UNPACK_METHODS + #define CYTHON_UNPACK_METHODS 1 + #endif + #if PY_VERSION_HEX >= 0x030B00A4 + #undef CYTHON_FAST_THREAD_STATE + #define CYTHON_FAST_THREAD_STATE 0 + #elif !defined(CYTHON_FAST_THREAD_STATE) + #define CYTHON_FAST_THREAD_STATE 1 + #endif + #ifndef CYTHON_FAST_PYCALL + #define CYTHON_FAST_PYCALL (PY_VERSION_HEX < 0x030B00A1) + #endif + #ifndef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000) + #endif + #ifndef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1) + #endif + #ifndef CYTHON_USE_DICT_VERSIONS + #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX >= 0x030600B1) + #endif + #if PY_VERSION_HEX >= 0x030B00A4 + #undef CYTHON_USE_EXC_INFO_STACK + #define CYTHON_USE_EXC_INFO_STACK 0 + #elif !defined(CYTHON_USE_EXC_INFO_STACK) + #define CYTHON_USE_EXC_INFO_STACK (PY_VERSION_HEX >= 0x030700A3) + #endif +#endif +#if !defined(CYTHON_FAST_PYCCALL) +#define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1) +#endif +#if CYTHON_USE_PYLONG_INTERNALS + #if PY_MAJOR_VERSION < 3 + #include "longintrepr.h" + #endif + #undef SHIFT + #undef BASE + #undef MASK + #ifdef SIZEOF_VOID_P + enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) }; + #endif +#endif +#ifndef __has_attribute + #define __has_attribute(x) 0 +#endif +#ifndef __has_cpp_attribute + #define __has_cpp_attribute(x) 0 +#endif +#ifndef CYTHON_RESTRICT + #if defined(__GNUC__) + #define CYTHON_RESTRICT __restrict__ + #elif defined(_MSC_VER) && _MSC_VER >= 1400 + #define CYTHON_RESTRICT __restrict + #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + #define CYTHON_RESTRICT restrict + #else + #define CYTHON_RESTRICT + #endif +#endif +#ifndef CYTHON_UNUSED +# if defined(__GNUC__) +# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) +# define CYTHON_UNUSED __attribute__ ((__unused__)) +# else +# define CYTHON_UNUSED +# endif +# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER)) +# define CYTHON_UNUSED __attribute__ ((__unused__)) +# else +# define CYTHON_UNUSED +# endif +#endif +#ifndef CYTHON_MAYBE_UNUSED_VAR +# if defined(__cplusplus) + template void CYTHON_MAYBE_UNUSED_VAR( const T& ) { } +# else +# define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x) +# endif +#endif +#ifndef CYTHON_NCP_UNUSED +# if CYTHON_COMPILING_IN_CPYTHON +# define CYTHON_NCP_UNUSED +# else +# define CYTHON_NCP_UNUSED CYTHON_UNUSED +# endif +#endif +#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None) +#ifdef _MSC_VER + #ifndef _MSC_STDINT_H_ + #if _MSC_VER < 1300 + typedef unsigned char uint8_t; + typedef unsigned int uint32_t; + #else + typedef unsigned __int8 uint8_t; + typedef unsigned __int32 uint32_t; + #endif + #endif +#else + #include +#endif +#ifndef CYTHON_FALLTHROUGH + #if defined(__cplusplus) && __cplusplus >= 201103L + #if __has_cpp_attribute(fallthrough) + #define CYTHON_FALLTHROUGH [[fallthrough]] + #elif __has_cpp_attribute(clang::fallthrough) + #define CYTHON_FALLTHROUGH [[clang::fallthrough]] + #elif __has_cpp_attribute(gnu::fallthrough) + #define CYTHON_FALLTHROUGH [[gnu::fallthrough]] + #endif + #endif + #ifndef CYTHON_FALLTHROUGH + #if __has_attribute(fallthrough) + #define CYTHON_FALLTHROUGH __attribute__((fallthrough)) + #else + #define CYTHON_FALLTHROUGH + #endif + #endif + #if defined(__clang__ ) && defined(__apple_build_version__) + #if __apple_build_version__ < 7000000 + #undef CYTHON_FALLTHROUGH + #define CYTHON_FALLTHROUGH + #endif + #endif +#endif + +#ifndef __cplusplus + #error "Cython files generated with the C++ option must be compiled with a C++ compiler." +#endif +#ifndef CYTHON_INLINE + #if defined(__clang__) + #define CYTHON_INLINE __inline__ __attribute__ ((__unused__)) + #else + #define CYTHON_INLINE inline + #endif +#endif +template +void __Pyx_call_destructor(T& x) { + x.~T(); +} +template +class __Pyx_FakeReference { + public: + __Pyx_FakeReference() : ptr(NULL) { } + __Pyx_FakeReference(const T& ref) : ptr(const_cast(&ref)) { } + T *operator->() { return ptr; } + T *operator&() { return ptr; } + operator T&() { return *ptr; } + template bool operator ==(U other) { return *ptr == other; } + template bool operator !=(U other) { return *ptr != other; } + private: + T *ptr; +}; + +#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag) + #define Py_OptimizeFlag 0 +#endif +#define __PYX_BUILD_PY_SSIZE_T "n" +#define CYTHON_FORMAT_SSIZE_T "z" +#if PY_MAJOR_VERSION < 3 + #define __Pyx_BUILTIN_MODULE_NAME "__builtin__" + #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ + PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) + #define __Pyx_DefaultClassType PyClass_Type +#else + #define __Pyx_BUILTIN_MODULE_NAME "builtins" + #define __Pyx_DefaultClassType PyType_Type +#if PY_VERSION_HEX >= 0x030B00A1 + static CYTHON_INLINE PyCodeObject* __Pyx_PyCode_New(int a, int k, int l, int s, int f, + PyObject *code, PyObject *c, PyObject* n, PyObject *v, + PyObject *fv, PyObject *cell, PyObject* fn, + PyObject *name, int fline, PyObject *lnos) { + PyObject *kwds=NULL, *argcount=NULL, *posonlyargcount=NULL, *kwonlyargcount=NULL; + PyObject *nlocals=NULL, *stacksize=NULL, *flags=NULL, *replace=NULL, *call_result=NULL, *empty=NULL; + const char *fn_cstr=NULL; + const char *name_cstr=NULL; + PyCodeObject* co=NULL; + PyObject *type, *value, *traceback; + PyErr_Fetch(&type, &value, &traceback); + if (!(kwds=PyDict_New())) goto end; + if (!(argcount=PyLong_FromLong(a))) goto end; + if (PyDict_SetItemString(kwds, "co_argcount", argcount) != 0) goto end; + if (!(posonlyargcount=PyLong_FromLong(0))) goto end; + if (PyDict_SetItemString(kwds, "co_posonlyargcount", posonlyargcount) != 0) goto end; + if (!(kwonlyargcount=PyLong_FromLong(k))) goto end; + if (PyDict_SetItemString(kwds, "co_kwonlyargcount", kwonlyargcount) != 0) goto end; + if (!(nlocals=PyLong_FromLong(l))) goto end; + if (PyDict_SetItemString(kwds, "co_nlocals", nlocals) != 0) goto end; + if (!(stacksize=PyLong_FromLong(s))) goto end; + if (PyDict_SetItemString(kwds, "co_stacksize", stacksize) != 0) goto end; + if (!(flags=PyLong_FromLong(f))) goto end; + if (PyDict_SetItemString(kwds, "co_flags", flags) != 0) goto end; + if (PyDict_SetItemString(kwds, "co_code", code) != 0) goto end; + if (PyDict_SetItemString(kwds, "co_consts", c) != 0) goto end; + if (PyDict_SetItemString(kwds, "co_names", n) != 0) goto end; + if (PyDict_SetItemString(kwds, "co_varnames", v) != 0) goto end; + if (PyDict_SetItemString(kwds, "co_freevars", fv) != 0) goto end; + if (PyDict_SetItemString(kwds, "co_cellvars", cell) != 0) goto end; + if (PyDict_SetItemString(kwds, "co_linetable", lnos) != 0) goto end; + if (!(fn_cstr=PyUnicode_AsUTF8AndSize(fn, NULL))) goto end; + if (!(name_cstr=PyUnicode_AsUTF8AndSize(name, NULL))) goto end; + if (!(co = PyCode_NewEmpty(fn_cstr, name_cstr, fline))) goto end; + if (!(replace = PyObject_GetAttrString((PyObject*)co, "replace"))) goto cleanup_code_too; + if (!(empty = PyTuple_New(0))) goto cleanup_code_too; // unfortunately __pyx_empty_tuple isn't available here + if (!(call_result = PyObject_Call(replace, empty, kwds))) goto cleanup_code_too; + Py_XDECREF((PyObject*)co); + co = (PyCodeObject*)call_result; + call_result = NULL; + if (0) { + cleanup_code_too: + Py_XDECREF((PyObject*)co); + co = NULL; + } + end: + Py_XDECREF(kwds); + Py_XDECREF(argcount); + Py_XDECREF(posonlyargcount); + Py_XDECREF(kwonlyargcount); + Py_XDECREF(nlocals); + Py_XDECREF(stacksize); + Py_XDECREF(replace); + Py_XDECREF(call_result); + Py_XDECREF(empty); + if (type) { + PyErr_Restore(type, value, traceback); + } + return co; + } +#else + #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ + PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) +#endif + #define __Pyx_DefaultClassType PyType_Type +#endif +#ifndef Py_TPFLAGS_CHECKTYPES + #define Py_TPFLAGS_CHECKTYPES 0 +#endif +#ifndef Py_TPFLAGS_HAVE_INDEX + #define Py_TPFLAGS_HAVE_INDEX 0 +#endif +#ifndef Py_TPFLAGS_HAVE_NEWBUFFER + #define Py_TPFLAGS_HAVE_NEWBUFFER 0 +#endif +#ifndef Py_TPFLAGS_HAVE_FINALIZE + #define Py_TPFLAGS_HAVE_FINALIZE 0 +#endif +#ifndef METH_STACKLESS + #define METH_STACKLESS 0 +#endif +#if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL) + #ifndef METH_FASTCALL + #define METH_FASTCALL 0x80 + #endif + typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs); + typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args, + Py_ssize_t nargs, PyObject *kwnames); +#else + #define __Pyx_PyCFunctionFast _PyCFunctionFast + #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords +#endif +#if CYTHON_FAST_PYCCALL +#define __Pyx_PyFastCFunction_Check(func)\ + ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS))))) +#else +#define __Pyx_PyFastCFunction_Check(func) 0 +#endif +#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc) + #define PyObject_Malloc(s) PyMem_Malloc(s) + #define PyObject_Free(p) PyMem_Free(p) + #define PyObject_Realloc(p) PyMem_Realloc(p) +#endif +#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030400A1 + #define PyMem_RawMalloc(n) PyMem_Malloc(n) + #define PyMem_RawRealloc(p, n) PyMem_Realloc(p, n) + #define PyMem_RawFree(p) PyMem_Free(p) +#endif +#if CYTHON_COMPILING_IN_PYSTON + #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co) + #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno) +#else + #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0) + #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno) +#endif +#if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000 + #define __Pyx_PyThreadState_Current PyThreadState_GET() +#elif PY_VERSION_HEX >= 0x03060000 + #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet() +#elif PY_VERSION_HEX >= 0x03000000 + #define __Pyx_PyThreadState_Current PyThreadState_GET() +#else + #define __Pyx_PyThreadState_Current _PyThreadState_Current +#endif +#if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT) +#include "pythread.h" +#define Py_tss_NEEDS_INIT 0 +typedef int Py_tss_t; +static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) { + *key = PyThread_create_key(); + return 0; +} +static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) { + Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t)); + *key = Py_tss_NEEDS_INIT; + return key; +} +static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) { + PyObject_Free(key); +} +static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) { + return *key != Py_tss_NEEDS_INIT; +} +static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) { + PyThread_delete_key(*key); + *key = Py_tss_NEEDS_INIT; +} +static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) { + return PyThread_set_key_value(*key, value); +} +static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) { + return PyThread_get_key_value(*key); +} +#endif +#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized) +#define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n)) +#else +#define __Pyx_PyDict_NewPresized(n) PyDict_New() +#endif +#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION + #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) +#else + #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) +#endif +#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS +#define __Pyx_PyDict_GetItemStr(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash) +#else +#define __Pyx_PyDict_GetItemStr(dict, name) PyDict_GetItem(dict, name) +#endif +#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) + #define CYTHON_PEP393_ENABLED 1 + #if defined(PyUnicode_IS_READY) + #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\ + 0 : _PyUnicode_Ready((PyObject *)(op))) + #else + #define __Pyx_PyUnicode_READY(op) (0) + #endif + #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u) + #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i) + #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u) + #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u) + #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u) + #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i) + #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch) + #if defined(PyUnicode_IS_READY) && defined(PyUnicode_GET_SIZE) + #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03090000 + #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : ((PyCompactUnicodeObject *)(u))->wstr_length)) + #else + #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u))) + #endif + #else + #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_LENGTH(u)) + #endif +#else + #define CYTHON_PEP393_ENABLED 0 + #define PyUnicode_1BYTE_KIND 1 + #define PyUnicode_2BYTE_KIND 2 + #define PyUnicode_4BYTE_KIND 4 + #define __Pyx_PyUnicode_READY(op) (0) + #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u) + #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i])) + #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111) + #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE)) + #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u)) + #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i])) + #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch) + #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u)) +#endif +#if CYTHON_COMPILING_IN_PYPY + #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b) + #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b) +#else + #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b) + #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\ + PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b)) +#endif +#if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains) + #define PyUnicode_Contains(u, s) PySequence_Contains(u, s) +#endif +#if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check) + #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type) +#endif +#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format) + #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt) +#endif +#define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyString_Check(b) && !PyString_CheckExact(b)))) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b)) +#define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b)) +#if PY_MAJOR_VERSION >= 3 + #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b) +#else + #define __Pyx_PyString_Format(a, b) PyString_Format(a, b) +#endif +#if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII) + #define PyObject_ASCII(o) PyObject_Repr(o) +#endif +#if PY_MAJOR_VERSION >= 3 + #define PyBaseString_Type PyUnicode_Type + #define PyStringObject PyUnicodeObject + #define PyString_Type PyUnicode_Type + #define PyString_Check PyUnicode_Check + #define PyString_CheckExact PyUnicode_CheckExact +#ifndef PyObject_Unicode + #define PyObject_Unicode PyObject_Str +#endif +#endif +#if PY_MAJOR_VERSION >= 3 + #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj) + #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj) +#else + #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj)) + #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj)) +#endif +#ifndef PySet_CheckExact + #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) +#endif +#if PY_VERSION_HEX >= 0x030900A4 + #define __Pyx_SET_REFCNT(obj, refcnt) Py_SET_REFCNT(obj, refcnt) + #define __Pyx_SET_SIZE(obj, size) Py_SET_SIZE(obj, size) +#else + #define __Pyx_SET_REFCNT(obj, refcnt) Py_REFCNT(obj) = (refcnt) + #define __Pyx_SET_SIZE(obj, size) Py_SIZE(obj) = (size) +#endif +#if CYTHON_ASSUME_SAFE_MACROS + #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq) +#else + #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq) +#endif +#if PY_MAJOR_VERSION >= 3 + #define PyIntObject PyLongObject + #define PyInt_Type PyLong_Type + #define PyInt_Check(op) PyLong_Check(op) + #define PyInt_CheckExact(op) PyLong_CheckExact(op) + #define PyInt_FromString PyLong_FromString + #define PyInt_FromUnicode PyLong_FromUnicode + #define PyInt_FromLong PyLong_FromLong + #define PyInt_FromSize_t PyLong_FromSize_t + #define PyInt_FromSsize_t PyLong_FromSsize_t + #define PyInt_AsLong PyLong_AsLong + #define PyInt_AS_LONG PyLong_AS_LONG + #define PyInt_AsSsize_t PyLong_AsSsize_t + #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask + #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask + #define PyNumber_Int PyNumber_Long +#endif +#if PY_MAJOR_VERSION >= 3 + #define PyBoolObject PyLongObject +#endif +#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY + #ifndef PyUnicode_InternFromString + #define PyUnicode_InternFromString(s) PyUnicode_FromString(s) + #endif +#endif +#if PY_VERSION_HEX < 0x030200A4 + typedef long Py_hash_t; + #define __Pyx_PyInt_FromHash_t PyInt_FromLong + #define __Pyx_PyInt_AsHash_t __Pyx_PyIndex_AsHash_t +#else + #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t + #define __Pyx_PyInt_AsHash_t __Pyx_PyIndex_AsSsize_t +#endif +#if PY_MAJOR_VERSION >= 3 + #define __Pyx_PyMethod_New(func, self, klass) ((self) ? ((void)(klass), PyMethod_New(func, self)) : __Pyx_NewRef(func)) +#else + #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass) +#endif +#if CYTHON_USE_ASYNC_SLOTS + #if PY_VERSION_HEX >= 0x030500B1 + #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods + #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async) + #else + #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved)) + #endif +#else + #define __Pyx_PyType_AsAsync(obj) NULL +#endif +#ifndef __Pyx_PyAsyncMethodsStruct + typedef struct { + unaryfunc am_await; + unaryfunc am_aiter; + unaryfunc am_anext; + } __Pyx_PyAsyncMethodsStruct; +#endif + +#if defined(WIN32) || defined(MS_WINDOWS) + #define _USE_MATH_DEFINES +#endif +#include +#ifdef NAN +#define __PYX_NAN() ((float) NAN) +#else +static CYTHON_INLINE float __PYX_NAN() { + float value; + memset(&value, 0xFF, sizeof(value)); + return value; +} +#endif +#if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL) +#define __Pyx_truncl trunc +#else +#define __Pyx_truncl truncl +#endif + +#define __PYX_MARK_ERR_POS(f_index, lineno) \ + { __pyx_filename = __pyx_f[f_index]; (void)__pyx_filename; __pyx_lineno = lineno; (void)__pyx_lineno; __pyx_clineno = __LINE__; (void)__pyx_clineno; } +#define __PYX_ERR(f_index, lineno, Ln_error) \ + { __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; } + +#ifndef __PYX_EXTERN_C + #ifdef __cplusplus + #define __PYX_EXTERN_C extern "C" + #else + #define __PYX_EXTERN_C extern + #endif +#endif + +#define __PYX_HAVE__softwrap_core2 +#define __PYX_HAVE_API__softwrap_core2 +/* Early includes */ +#include +#include +#include +#include +#include + + template + CYTHON_INLINE T1 nmax(T1 a, T2 b) {return a > b ? a : (T1)b;} + + template + CYTHON_INLINE T1 nmin(T1 a, T2 b) {return a < b ? a : (T1)b;} + + template + CYTHON_INLINE T1 nabs(T1 a) {return a < 0 ? -a : a;} + + template + CYTHON_INLINE T1 nlerp(T1 a, T2 b, T3 t) {return a + (b - a) * t;} + + template + CYTHON_INLINE T1 nclamp(T1 a, T2 min, T3 max) {return nmax(nmin(a, max), min);} + + + + + #define EPS 0.00001f + struct vec3 { + float v[3]; + + vec3 (float a[3]) { + v[0] = a[0]; + v[1] = a[1]; + v[2] = a[2]; + } + + vec3 (float x, float y, float z) { + v[0] = x; + v[1] = y; + v[2] = z; + } + + vec3 (float f) { + v[0] = f; + v[1] = f; + v[2] = f; + } + + vec3() = default; + + #define VEC_OP(op)\ + CYTHON_INLINE vec3 operator op (vec3 other) {\ + return vec3(v[0] op other.v[0], v[1] op other.v[1], v[2] op other.v[2]);\ + } + + VEC_OP(+) + VEC_OP(-) + VEC_OP(*) + VEC_OP(/) + VEC_OP(+=) + VEC_OP(-=) + VEC_OP(*=) + VEC_OP(/=) + + #undef VEC_OP + #define VEC_OP(op)\ + CYTHON_INLINE vec3 operator op (float other) {\ + return vec3(v[0] op other, v[1] op other, v[2] op other);\ + } + + VEC_OP(+) + VEC_OP(-) + VEC_OP(*) + VEC_OP(/) + VEC_OP(+=) + VEC_OP(-=) + VEC_OP(*=) + VEC_OP(/=) + VEC_OP(=) + + #undef VEC_OP + CYTHON_INLINE float& x() { return v[0];} + CYTHON_INLINE float& y() { return v[1];} + CYTHON_INLINE float& z() { return v[2];} + CYTHON_INLINE float sum() {return v[0] + v[1] + v[2];} + CYTHON_INLINE float dot(vec3 other) {return v[0] * other.v[0] + v[1] * other.v[1] + v[2] * other.v[2];} + CYTHON_INLINE float len() {return sqrtf(this->dot(*this));} + CYTHON_INLINE float len_sqr() {return this->dot(*this);} + CYTHON_INLINE void normalize() { + float f = this->len(); + if (f == 0) { + return; + } + f = 1 / f; + *this *= f; + } + CYTHON_INLINE vec3 normalized() { + float f = this->len(); + if (f == 0) { + return *this; + } + f = 1 / f; + return *this * f; + } + CYTHON_INLINE vec3 project(vec3 other) {return other * (this->dot(other) / other.dot(other));} + CYTHON_INLINE vec3 project_unit(vec3 other) {return other * this->dot(other);} + CYTHON_INLINE vec3 cross(vec3 other) { + return vec3(v[1] * other.v[2] - v[2] * other.v[1], + v[2] * other.v[0] - v[0] * other.v[2], + v[0] * other.v[1] - v[1] * other.v[0]); + } + + CYTHON_INLINE vec3 max_aa(vec3 other) { + return vec3(nmax(v[0], other.v[0]), nmax(v[1], other.v[1]), nmax(v[2], other.v[2])); + } + CYTHON_INLINE vec3 min_aa(vec3 other) { + return vec3(nmin(v[0], other.v[0]), nmin(v[1], other.v[1]), nmin(v[2], other.v[2])); + } + CYTHON_INLINE vec3 lerp(vec3 other, float fac) { + return *this + (other - *this) * fac; + } + CYTHON_INLINE vec3 clamp(float min, float max) { + float d = this->dot(*this); + if (d == 0) { + return *this; + } + else if (d < min * min) { + return *this * (1 / sqrtf(d) * min); + } + else if (d > max * max) { + return *this * (1 / sqrtf(d) * max); + } + return *this; + } + }; + + + CYTHON_INLINE vec3 project_point_triangle(vec3& a, vec3& b, vec3& c, vec3& n, vec3& p){ + vec3 edge_v = b - a; + vec3 pv = p - a; + vec3 n1 = edge_v.cross(pv); + + if (n1.dot(n) < 0){ + return edge_v * nclamp(edge_v.dot(pv) / (edge_v.dot(edge_v) + EPS), 0, 1) + a; + } + + edge_v = c - b; + pv = p - b; + n1 = edge_v.cross(pv); + + if (n1.dot(n) < 0){ + return edge_v * nclamp(edge_v.dot(pv) / (edge_v.dot(edge_v) + EPS), 0, 1) + b; + } + + edge_v = a - c; + pv = p - c; + n1 = edge_v.cross(pv); + + if (n1.dot(n) < 0){ + return edge_v * nclamp(edge_v.dot(pv) / (edge_v.dot(edge_v) + EPS), 0, 1) + c; + } + + return p - pv.project_unit(n); + } + + CYTHON_INLINE vec3 project_point_plane(vec3& p, vec3& pp, vec3& pn){ + vec3 v = (p - pp).project_unit(pn); + return p - v; + } + + + #include + + union BvhNode; + struct BvhNodeBox; + struct BvhNodeLeaf; + + struct BvhNodeBox { + int split_axis; + float split_pos; + vec3 min, max; + BvhNode* nodes[2]; + + // BvhNodeBox() { + // split_axis = -1; + // min = vec3(INFINITY); + // max = vec3(-INFINITY); + // } + // CYTHON_INLINE void expand(BvhNodeBox other) { + // min = min.min_aa(other.min); + // max = max.max_aa(other.max); + // } + CYTHON_INLINE void expand(vec3 other) { + min = min.min_aa(other); + max = max.max_aa(other); + } + CYTHON_INLINE int major_axis(){ + int axis = 0; + float curr_le, le = 0; + + for (int i=0; i<3; i++){ + curr_le = max.v[i] - min.v[i]; + if (curr_le > le){ + axis = i; + le = curr_le; + } + } + return axis; + } + CYTHON_INLINE vec3 box_center(){ + return (max + min) * 0.5; + } + CYTHON_INLINE float box_center_axis(int axis){ + return (max.v[axis] + min.v[axis]) * 0.5f; + } + CYTHON_INLINE float box_distance_sqr(vec3 p){ + return (p - max.min_aa(min.max_aa(p))).len_sqr(); + } + CYTHON_INLINE void set_split_axis(int axis){ + this->split_axis = ~axis; + } + CYTHON_INLINE int get_split_axis(){ + return ~this->split_axis; + } + CYTHON_INLINE int is_leaf() { + return split_axis >= 0; + } + }; + + struct BvhNodeLeaf { + int index; + // BvhNodeLeaf (int _index) { + // index = _index; + // } + }; + + union BvhNode{ + BvhNodeBox box; + BvhNodeLeaf leaf; + CYTHON_INLINE int is_leaf() { + return leaf.index >= 0; + } + }; + + struct BvhNearestResult { + vec3 point; + float distance; + int tri_index; + }; + + + struct HalfLink { + int a; + float original_length; + float scale; + }; + + struct HalfLinkArr { + int n; + HalfLink half_links[]; + }; + + + struct TernaryLink { + int a, b; + int side; + float avg_dist; + }; + + struct TernaryLinkArr { + int n; + TernaryLink arr[]; + }; + +#ifdef _OPENMP +#include +#endif /* _OPENMP */ + +#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS) +#define CYTHON_WITHOUT_ASSERTIONS +#endif + +typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding; + const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; + +#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0 +#define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 0 +#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT (PY_MAJOR_VERSION >= 3 && __PYX_DEFAULT_STRING_ENCODING_IS_UTF8) +#define __PYX_DEFAULT_STRING_ENCODING "" +#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString +#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize +#define __Pyx_uchar_cast(c) ((unsigned char)c) +#define __Pyx_long_cast(x) ((long)x) +#define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\ + (sizeof(type) < sizeof(Py_ssize_t)) ||\ + (sizeof(type) > sizeof(Py_ssize_t) &&\ + likely(v < (type)PY_SSIZE_T_MAX ||\ + v == (type)PY_SSIZE_T_MAX) &&\ + (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\ + v == (type)PY_SSIZE_T_MIN))) ||\ + (sizeof(type) == sizeof(Py_ssize_t) &&\ + (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\ + v == (type)PY_SSIZE_T_MAX))) ) +static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) { + return (size_t) i < (size_t) limit; +} +#if defined (__cplusplus) && __cplusplus >= 201103L + #include + #define __Pyx_sst_abs(value) std::abs(value) +#elif SIZEOF_INT >= SIZEOF_SIZE_T + #define __Pyx_sst_abs(value) abs(value) +#elif SIZEOF_LONG >= SIZEOF_SIZE_T + #define __Pyx_sst_abs(value) labs(value) +#elif defined (_MSC_VER) + #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value)) +#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + #define __Pyx_sst_abs(value) llabs(value) +#elif defined (__GNUC__) + #define __Pyx_sst_abs(value) __builtin_llabs(value) +#else + #define __Pyx_sst_abs(value) ((value<0) ? -value : value) +#endif +static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*); +static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length); +#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s)) +#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l) +#define __Pyx_PyBytes_FromString PyBytes_FromString +#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize +static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); +#if PY_MAJOR_VERSION < 3 + #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString + #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize +#else + #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString + #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize +#endif +#define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s)) +#define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s)) +#define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s)) +#define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s)) +#define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s)) +#define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s) +#define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s) +#define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s) +#define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s) +#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s) +static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) { + const Py_UNICODE *u_end = u; + while (*u_end++) ; + return (size_t)(u_end - u - 1); +} +#define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u)) +#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode +#define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode +#define __Pyx_NewRef(obj) (Py_INCREF(obj), obj) +#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None) +static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b); +static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); +static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*); +static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x); +#define __Pyx_PySequence_Tuple(obj)\ + (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj)) +static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); +static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); +static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject*); +#if CYTHON_ASSUME_SAFE_MACROS +#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x)) +#else +#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x) +#endif +#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x)) +#if PY_MAJOR_VERSION >= 3 +#define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x)) +#else +#define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x)) +#endif +#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x)) +#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII +static int __Pyx_sys_getdefaultencoding_not_ascii; +static int __Pyx_init_sys_getdefaultencoding_params(void) { + PyObject* sys; + PyObject* default_encoding = NULL; + PyObject* ascii_chars_u = NULL; + PyObject* ascii_chars_b = NULL; + const char* default_encoding_c; + sys = PyImport_ImportModule("sys"); + if (!sys) goto bad; + default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL); + Py_DECREF(sys); + if (!default_encoding) goto bad; + default_encoding_c = PyBytes_AsString(default_encoding); + if (!default_encoding_c) goto bad; + if (strcmp(default_encoding_c, "ascii") == 0) { + __Pyx_sys_getdefaultencoding_not_ascii = 0; + } else { + char ascii_chars[128]; + int c; + for (c = 0; c < 128; c++) { + ascii_chars[c] = c; + } + __Pyx_sys_getdefaultencoding_not_ascii = 1; + ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL); + if (!ascii_chars_u) goto bad; + ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL); + if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) { + PyErr_Format( + PyExc_ValueError, + "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.", + default_encoding_c); + goto bad; + } + Py_DECREF(ascii_chars_u); + Py_DECREF(ascii_chars_b); + } + Py_DECREF(default_encoding); + return 0; +bad: + Py_XDECREF(default_encoding); + Py_XDECREF(ascii_chars_u); + Py_XDECREF(ascii_chars_b); + return -1; +} +#endif +#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3 +#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL) +#else +#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL) +#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT +static char* __PYX_DEFAULT_STRING_ENCODING; +static int __Pyx_init_sys_getdefaultencoding_params(void) { + PyObject* sys; + PyObject* default_encoding = NULL; + char* default_encoding_c; + sys = PyImport_ImportModule("sys"); + if (!sys) goto bad; + default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL); + Py_DECREF(sys); + if (!default_encoding) goto bad; + default_encoding_c = PyBytes_AsString(default_encoding); + if (!default_encoding_c) goto bad; + __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1); + if (!__PYX_DEFAULT_STRING_ENCODING) goto bad; + strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c); + Py_DECREF(default_encoding); + return 0; +bad: + Py_XDECREF(default_encoding); + return -1; +} +#endif +#endif + + +/* Test for GCC > 2.95 */ +#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))) + #define likely(x) __builtin_expect(!!(x), 1) + #define unlikely(x) __builtin_expect(!!(x), 0) +#else /* !__GNUC__ or GCC < 2.95 */ + #define likely(x) (x) + #define unlikely(x) (x) +#endif /* __GNUC__ */ +static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; } + +static PyObject *__pyx_m = NULL; +static PyObject *__pyx_d; +static PyObject *__pyx_b; +static PyObject *__pyx_cython_runtime = NULL; +static PyObject *__pyx_empty_tuple; +static PyObject *__pyx_empty_bytes; +static PyObject *__pyx_empty_unicode; +static int __pyx_lineno; +static int __pyx_clineno = 0; +static const char * __pyx_cfilenm= __FILE__; +static const char *__pyx_filename; + + +static const char *__pyx_f[] = { + "core\\core2.pyx", + "stringsource", +}; +/* NoFastGil.proto */ +#define __Pyx_PyGILState_Ensure PyGILState_Ensure +#define __Pyx_PyGILState_Release PyGILState_Release +#define __Pyx_FastGIL_Remember() +#define __Pyx_FastGIL_Forget() +#define __Pyx_FastGilFuncInit() + +/* ForceInitThreads.proto */ +#ifndef __PYX_FORCE_INIT_THREADS + #define __PYX_FORCE_INIT_THREADS 0 +#endif + + +/*--- Type declarations ---*/ +struct __pyx_obj_14softwrap_core2_Mesh; +struct __pyx_obj_14softwrap_core2_BVH; +struct __pyx_obj_14softwrap_core2_LinkProbe; +struct __pyx_obj_14softwrap_core2_SpringLinks; +struct __pyx_obj_14softwrap_core2_TernarySmoothingLinks; +struct __pyx_obj_14softwrap_core2_QuaternarySmoothingLinks; +struct __pyx_obj_14softwrap_core2_SpringEnginePin; +struct __pyx_obj_14softwrap_core2__MaskContextManager; +struct __pyx_obj_14softwrap_core2_SpringEngineMask; +struct __pyx_obj_14softwrap_core2_SymmetryMap; +struct __pyx_obj_14softwrap_core2_SpringEngine; +struct __pyx_obj_14softwrap_core2___pyx_scope_struct____iter__; +struct __pyx_obj_14softwrap_core2___pyx_scope_struct_1___getitem__; +struct __pyx_obj_14softwrap_core2___pyx_scope_struct_2_iter_ring; +struct __pyx_obj_14softwrap_core2___pyx_scope_struct_3___iter__; +struct __pyx_obj_14softwrap_core2___pyx_scope_struct_4___getitem__; +struct __pyx_obj_14softwrap_core2___pyx_scope_struct_5_genexpr; +struct __pyx_opt_args_14softwrap_core2_11SpringLinks_soft_spring_force; +struct __pyx_t_14softwrap_core2_QuaternaryLink; +struct __pyx_opt_args_14softwrap_core2_24QuaternarySmoothingLinks_smooth; +struct __pyx_opt_args_14softwrap_core2_16SpringEngineMask_masked_store; +struct __pyx_opt_args_14softwrap_core2_12SpringEngine_random_verts; + +/* "core/core2.pyx":830 + * + * + * cpdef void soft_spring_force(self, float factor, float deform_update=0.3, float deform_restore=0.03, float min_deform=0.3, float max_deform=3.0): # <<<<<<<<<<<<<< + * cdef int i, j, n, a + * cdef HalfLink* half_links + */ + +# line 830 "core/core2.pyx" +struct __pyx_opt_args_14softwrap_core2_11SpringLinks_soft_spring_force { + +# line 830 "core/core2.pyx" + int __pyx_n; + +# line 830 "core/core2.pyx" + float deform_update; + +# line 830 "core/core2.pyx" + float deform_restore; + +# line 830 "core/core2.pyx" + float min_deform; + +# line 830 "core/core2.pyx" + float max_deform; + +# line 830 "core/core2.pyx" +}; + +/* "core/core2.pyx":1012 + * + * + * cdef struct QuaternaryLink: # <<<<<<<<<<<<<< + * int a, b, c, d + * float ratio + */ + +# line 1012 "core/core2.pyx" +struct __pyx_t_14softwrap_core2_QuaternaryLink { + +# line 1012 "core/core2.pyx" + int a; + +# line 1012 "core/core2.pyx" + int b; + +# line 1012 "core/core2.pyx" + int c; + +# line 1012 "core/core2.pyx" + int d; + +# line 1012 "core/core2.pyx" + float ratio; + +# line 1012 "core/core2.pyx" + int side; + +# line 1012 "core/core2.pyx" +}; + +/* "core/core2.pyx":1069 + * lnk.side = ab.dot(cd) > 1 + * + * cpdef void smooth(self, float factor, float max_ratio=3): # <<<<<<<<<<<<<< + * cdef int i + * cdef QuaternaryLink* lnk + */ + +# line 1069 "core/core2.pyx" +struct __pyx_opt_args_14softwrap_core2_24QuaternarySmoothingLinks_smooth { + +# line 1069 "core/core2.pyx" + int __pyx_n; + +# line 1069 "core/core2.pyx" + float max_ratio; + +# line 1069 "core/core2.pyx" +}; + +/* "core/core2.pyx":1279 + * self.engine.m.verts[i] = self.vec_data[i] + * + * cpdef void masked_store(self, float factor=1, bint invert=False): # <<<<<<<<<<<<<< + * if self.mask == NULL: + * return + */ + +# line 1279 "core/core2.pyx" +struct __pyx_opt_args_14softwrap_core2_16SpringEngineMask_masked_store { + +# line 1279 "core/core2.pyx" + int __pyx_n; + +# line 1279 "core/core2.pyx" + float factor; + +# line 1279 "core/core2.pyx" + int invert; + +# line 1279 "core/core2.pyx" +}; + +/* "core/core2.pyx":1530 + * return SpringEngineMask(self, mask) + * + * cpdef void random_verts(self, float factor, unsigned int seed=0x452821E6): # <<<<<<<<<<<<<< + * cdef int i + * cdef unsigned int xorstate = 0x452821E6 + */ + +# line 1530 "core/core2.pyx" +struct __pyx_opt_args_14softwrap_core2_12SpringEngine_random_verts { + +# line 1530 "core/core2.pyx" + int __pyx_n; + +# line 1530 "core/core2.pyx" + unsigned int seed; + +# line 1530 "core/core2.pyx" +}; + +/* "core/core2.pyx":326 + * + * @cython.final + * cdef class Mesh: # <<<<<<<<<<<<<< + * cdef: + * vec3* verts + */ + +# line 326 "core/core2.pyx" +struct __pyx_obj_14softwrap_core2_Mesh { + +# line 326 "core/core2.pyx" + PyObject_HEAD + +# line 326 "core/core2.pyx" + struct __pyx_vtabstruct_14softwrap_core2_Mesh *__pyx_vtab; + +# line 326 "core/core2.pyx" + vec3 *verts; + +# line 326 "core/core2.pyx" + int (*triangles)[3]; + +# line 326 "core/core2.pyx" + vec3 *centroids; + +# line 326 "core/core2.pyx" + vec3 *vert_normals; + +# line 326 "core/core2.pyx" + vec3 *face_normals; + +# line 326 "core/core2.pyx" + int n_verts; + +# line 326 "core/core2.pyx" + int n_triangles; + +# line 326 "core/core2.pyx" +}; + + +/* "core/core2.pyx":554 + * + * @cython.final + * cdef class BVH: # <<<<<<<<<<<<<< + * cdef: + * BvhNodeLeaf* leaves + */ + +# line 554 "core/core2.pyx" +struct __pyx_obj_14softwrap_core2_BVH { + +# line 554 "core/core2.pyx" + PyObject_HEAD + +# line 554 "core/core2.pyx" + struct __pyx_vtabstruct_14softwrap_core2_BVH *__pyx_vtab; + +# line 554 "core/core2.pyx" + BvhNodeLeaf *leaves; + +# line 554 "core/core2.pyx" + BvhNodeBox *boxes; + +# line 554 "core/core2.pyx" + union BvhNode *root; + +# line 554 "core/core2.pyx" + int free_box_idx; + +# line 554 "core/core2.pyx" + int size; + +# line 554 "core/core2.pyx" + struct __pyx_obj_14softwrap_core2_Mesh *mesh; + +# line 554 "core/core2.pyx" +}; + + +/* "core/core2.pyx":712 + * + * @cython.final + * cdef class LinkProbe: # <<<<<<<<<<<<<< + * cdef readonly SpringLinks springs + * cdef HalfLinkArr* halflinks + */ + +# line 712 "core/core2.pyx" +struct __pyx_obj_14softwrap_core2_LinkProbe { + +# line 712 "core/core2.pyx" + PyObject_HEAD + +# line 712 "core/core2.pyx" + struct __pyx_obj_14softwrap_core2_SpringLinks *springs; + +# line 712 "core/core2.pyx" + struct HalfLinkArr *halflinks; + +# line 712 "core/core2.pyx" + int index; + +# line 712 "core/core2.pyx" +}; + + +/* "core/core2.pyx":747 + * return r / (self.halflinks.n + EPS) + * + * cdef class SpringLinks: # <<<<<<<<<<<<<< + * + * cdef readonly SpringEngine engine + */ + +# line 747 "core/core2.pyx" +struct __pyx_obj_14softwrap_core2_SpringLinks { + +# line 747 "core/core2.pyx" + PyObject_HEAD + +# line 747 "core/core2.pyx" + struct __pyx_vtabstruct_14softwrap_core2_SpringLinks *__pyx_vtab; + +# line 747 "core/core2.pyx" + struct __pyx_obj_14softwrap_core2_SpringEngine *engine; + +# line 747 "core/core2.pyx" + int max_links; + +# line 747 "core/core2.pyx" + struct HalfLinkArr **links; + +# line 747 "core/core2.pyx" +}; + + +/* "core/core2.pyx":915 + * + * @cython.final + * cdef class TernarySmoothingLinks: # <<<<<<<<<<<<<< + * cdef readonly SpringEngine engine + * cdef TernaryLinkArr** links + */ + +# line 915 "core/core2.pyx" +struct __pyx_obj_14softwrap_core2_TernarySmoothingLinks { + +# line 915 "core/core2.pyx" + PyObject_HEAD + +# line 915 "core/core2.pyx" + struct __pyx_vtabstruct_14softwrap_core2_TernarySmoothingLinks *__pyx_vtab; + +# line 915 "core/core2.pyx" + struct __pyx_obj_14softwrap_core2_SpringEngine *engine; + +# line 915 "core/core2.pyx" + struct TernaryLinkArr **links; + +# line 915 "core/core2.pyx" +}; + + +/* "core/core2.pyx":1017 + * int side + * + * cdef class QuaternarySmoothingLinks: # <<<<<<<<<<<<<< + * cdef readonly SpringEngine engine + * cdef readonly int n_links + */ + +# line 1017 "core/core2.pyx" +struct __pyx_obj_14softwrap_core2_QuaternarySmoothingLinks { + +# line 1017 "core/core2.pyx" + PyObject_HEAD + +# line 1017 "core/core2.pyx" + struct __pyx_vtabstruct_14softwrap_core2_QuaternarySmoothingLinks *__pyx_vtab; + +# line 1017 "core/core2.pyx" + struct __pyx_obj_14softwrap_core2_SpringEngine *engine; + +# line 1017 "core/core2.pyx" + int n_links; + +# line 1017 "core/core2.pyx" + struct __pyx_t_14softwrap_core2_QuaternaryLink *links; + +# line 1017 "core/core2.pyx" + int *accum_n; + +# line 1017 "core/core2.pyx" +}; + + +/* "core/core2.pyx":1108 + * + * @cython.final + * cdef class SpringEnginePin: # <<<<<<<<<<<<<< + * cdef readonly SpringEngine engine + * cdef readonly int n_rings + */ + +# line 1108 "core/core2.pyx" +struct __pyx_obj_14softwrap_core2_SpringEnginePin { + +# line 1108 "core/core2.pyx" + PyObject_HEAD + +# line 1108 "core/core2.pyx" + struct __pyx_obj_14softwrap_core2_SpringEngine *engine; + +# line 1108 "core/core2.pyx" + int n_rings; + +# line 1108 "core/core2.pyx" + int start_index; + +# line 1108 "core/core2.pyx" + int **rings; + +# line 1108 "core/core2.pyx" +}; + + +/* "core/core2.pyx":1192 + * + * + * cdef class _MaskContextManager: # <<<<<<<<<<<<<< + * cdef SpringEngineMask mask + * cdef float factor + */ + +# line 1192 "core/core2.pyx" +struct __pyx_obj_14softwrap_core2__MaskContextManager { + +# line 1192 "core/core2.pyx" + PyObject_HEAD + +# line 1192 "core/core2.pyx" + struct __pyx_obj_14softwrap_core2_SpringEngineMask *mask; + +# line 1192 "core/core2.pyx" + float factor; + +# line 1192 "core/core2.pyx" + int invert; + +# line 1192 "core/core2.pyx" +}; + + +/* "core/core2.pyx":1210 + * + * + * cdef class SpringEngineMask: # <<<<<<<<<<<<<< + * cdef float* mask + * cdef vec3* vec_data + */ + +# line 1210 "core/core2.pyx" +struct __pyx_obj_14softwrap_core2_SpringEngineMask { + +# line 1210 "core/core2.pyx" + PyObject_HEAD + +# line 1210 "core/core2.pyx" + struct __pyx_vtabstruct_14softwrap_core2_SpringEngineMask *__pyx_vtab; + +# line 1210 "core/core2.pyx" + float *mask; + +# line 1210 "core/core2.pyx" + vec3 *vec_data; + +# line 1210 "core/core2.pyx" + struct __pyx_obj_14softwrap_core2_SpringEngine *engine; + +# line 1210 "core/core2.pyx" +}; + + +/* "core/core2.pyx":1313 + * + * @cython.final + * cdef class SymmetryMap: # <<<<<<<<<<<<<< + * cdef int* symm_map + * cdef SpringEngine engine + */ + +# line 1313 "core/core2.pyx" +struct __pyx_obj_14softwrap_core2_SymmetryMap { + +# line 1313 "core/core2.pyx" + PyObject_HEAD + +# line 1313 "core/core2.pyx" + struct __pyx_vtabstruct_14softwrap_core2_SymmetryMap *__pyx_vtab; + +# line 1313 "core/core2.pyx" + int *symm_map; + +# line 1313 "core/core2.pyx" + struct __pyx_obj_14softwrap_core2_SpringEngine *engine; + +# line 1313 "core/core2.pyx" + float error[3]; + +# line 1313 "core/core2.pyx" +}; + + +/* "core/core2.pyx":1376 + * + * + * cdef class SpringEngine: # <<<<<<<<<<<<<< + * cdef Mesh m + * cdef vec3* prev_verts + */ + +# line 1376 "core/core2.pyx" +struct __pyx_obj_14softwrap_core2_SpringEngine { + +# line 1376 "core/core2.pyx" + PyObject_HEAD + +# line 1376 "core/core2.pyx" + struct __pyx_vtabstruct_14softwrap_core2_SpringEngine *__pyx_vtab; + +# line 1376 "core/core2.pyx" + struct __pyx_obj_14softwrap_core2_Mesh *m; + +# line 1376 "core/core2.pyx" + vec3 *prev_verts; + +# line 1376 "core/core2.pyx" + vec3 *tmp_verts; + +# line 1376 "core/core2.pyx" + struct __pyx_obj_14softwrap_core2_BVH *bvh; + +# line 1376 "core/core2.pyx" + int *bvh_closest_indexes; + +# line 1376 "core/core2.pyx" + unsigned int snap_count; + +# line 1376 "core/core2.pyx" + int n_verts; + +# line 1376 "core/core2.pyx" +}; + + +/* "core/core2.pyx":733 + * return self.halflinks.n + * + * def __iter__(self): # <<<<<<<<<<<<<< + * cdef int i + * for i in range(self.halflinks.n): + */ + +# line 733 "core/core2.pyx" +struct __pyx_obj_14softwrap_core2___pyx_scope_struct____iter__ { + +# line 733 "core/core2.pyx" + PyObject_HEAD + +# line 733 "core/core2.pyx" + int __pyx_v_i; + +# line 733 "core/core2.pyx" + struct __pyx_obj_14softwrap_core2_LinkProbe *__pyx_v_self; + +# line 733 "core/core2.pyx" + int __pyx_t_0; + +# line 733 "core/core2.pyx" + int __pyx_t_1; + +# line 733 "core/core2.pyx" + int __pyx_t_2; + +# line 733 "core/core2.pyx" +}; + + +/* "core/core2.pyx":1157 + * self.rings[i][j + 1] = front[j] + * + * def __getitem__(self, int index): # <<<<<<<<<<<<<< + * if index < 0 or index >= self.n_rings: + * raise IndexError + */ + +# line 1157 "core/core2.pyx" +struct __pyx_obj_14softwrap_core2___pyx_scope_struct_1___getitem__ { + +# line 1157 "core/core2.pyx" + PyObject_HEAD + +# line 1157 "core/core2.pyx" + int __pyx_v_index; + +# line 1157 "core/core2.pyx" + struct __pyx_obj_14softwrap_core2_SpringEnginePin *__pyx_v_self; + +# line 1157 "core/core2.pyx" +}; + + +/* "core/core2.pyx":1161 + * raise IndexError + * + * def iter_ring(): # <<<<<<<<<<<<<< + * cdef int i + * for i in range(self.rings[index][0]): + */ + +# line 1161 "core/core2.pyx" +struct __pyx_obj_14softwrap_core2___pyx_scope_struct_2_iter_ring { + +# line 1161 "core/core2.pyx" + PyObject_HEAD + +# line 1161 "core/core2.pyx" + struct __pyx_obj_14softwrap_core2___pyx_scope_struct_1___getitem__ *__pyx_outer_scope; + +# line 1161 "core/core2.pyx" + int __pyx_v_i; + +# line 1161 "core/core2.pyx" + int __pyx_t_0; + +# line 1161 "core/core2.pyx" + int __pyx_t_1; + +# line 1161 "core/core2.pyx" + int __pyx_t_2; + +# line 1161 "core/core2.pyx" +}; + + +/* "core/core2.pyx":1168 + * return iter_ring() + * + * def __iter__(self): # <<<<<<<<<<<<<< + * cdef int i + * for i in range(self.n_rings): + */ + +# line 1168 "core/core2.pyx" +struct __pyx_obj_14softwrap_core2___pyx_scope_struct_3___iter__ { + +# line 1168 "core/core2.pyx" + PyObject_HEAD + +# line 1168 "core/core2.pyx" + int __pyx_v_i; + +# line 1168 "core/core2.pyx" + struct __pyx_obj_14softwrap_core2_SpringEnginePin *__pyx_v_self; + +# line 1168 "core/core2.pyx" + int __pyx_t_0; + +# line 1168 "core/core2.pyx" + int __pyx_t_1; + +# line 1168 "core/core2.pyx" + int __pyx_t_2; + +# line 1168 "core/core2.pyx" +}; + + +/* "core/core2.pyx":1348 + * self.error[axis] = nmax(dist, self.error[axis]) + * + * def __getitem__(self, int index): # <<<<<<<<<<<<<< + * if index < 0 or index >= self.engine.n_verts: + * raise KeyError + */ + +# line 1348 "core/core2.pyx" +struct __pyx_obj_14softwrap_core2___pyx_scope_struct_4___getitem__ { + +# line 1348 "core/core2.pyx" + PyObject_HEAD + +# line 1348 "core/core2.pyx" + int __pyx_v_index; + +# line 1348 "core/core2.pyx" + struct __pyx_obj_14softwrap_core2_SymmetryMap *__pyx_v_self; + +# line 1348 "core/core2.pyx" +}; + + +/* "core/core2.pyx":1352 + * raise KeyError + * + * return tuple(self.symm_map[index + axis * self.engine.n_verts] for axis in range(3)) # <<<<<<<<<<<<<< + * + * cpdef void mirror(self, bint x, bint y, bint z): + */ + +# line 1352 "core/core2.pyx" +struct __pyx_obj_14softwrap_core2___pyx_scope_struct_5_genexpr { + +# line 1352 "core/core2.pyx" + PyObject_HEAD + +# line 1352 "core/core2.pyx" + struct __pyx_obj_14softwrap_core2___pyx_scope_struct_4___getitem__ *__pyx_outer_scope; + +# line 1352 "core/core2.pyx" + PyObject *__pyx_v_axis; + +# line 1352 "core/core2.pyx" + long __pyx_t_0; + +# line 1352 "core/core2.pyx" +}; + + + +/* "core/core2.pyx":326 + * + * @cython.final + * cdef class Mesh: # <<<<<<<<<<<<<< + * cdef: + * vec3* verts + */ + + +# line 326 "core/core2.pyx" +struct __pyx_vtabstruct_14softwrap_core2_Mesh { + +# line 326 "core/core2.pyx" + vec3 *(*tri_vert_ptr)(struct __pyx_obj_14softwrap_core2_Mesh *, int, int); + +# line 326 "core/core2.pyx" + vec3 (*tri_vert)(struct __pyx_obj_14softwrap_core2_Mesh *, int, int); + +# line 326 "core/core2.pyx" + void (*update_face_normals)(struct __pyx_obj_14softwrap_core2_Mesh *, int __pyx_skip_dispatch); + +# line 326 "core/core2.pyx" + void (*update_vert_normals)(struct __pyx_obj_14softwrap_core2_Mesh *, int __pyx_skip_dispatch); + +# line 326 "core/core2.pyx" + void (*update_centroids)(struct __pyx_obj_14softwrap_core2_Mesh *, int __pyx_skip_dispatch); + +# line 326 "core/core2.pyx" +}; + +# line 326 "core/core2.pyx" +static struct __pyx_vtabstruct_14softwrap_core2_Mesh *__pyx_vtabptr_14softwrap_core2_Mesh; + +# line 326 "core/core2.pyx" +static CYTHON_INLINE vec3 *__pyx_f_14softwrap_core2_4Mesh_tri_vert_ptr(struct __pyx_obj_14softwrap_core2_Mesh *, int, int); + +# line 326 "core/core2.pyx" +static CYTHON_INLINE vec3 __pyx_f_14softwrap_core2_4Mesh_tri_vert(struct __pyx_obj_14softwrap_core2_Mesh *, int, int); + +# line 326 "core/core2.pyx" +static void __pyx_f_14softwrap_core2_4Mesh_update_face_normals(struct __pyx_obj_14softwrap_core2_Mesh *, int __pyx_skip_dispatch); + +# line 326 "core/core2.pyx" +static void __pyx_f_14softwrap_core2_4Mesh_update_vert_normals(struct __pyx_obj_14softwrap_core2_Mesh *, int __pyx_skip_dispatch); + +# line 326 "core/core2.pyx" +static void __pyx_f_14softwrap_core2_4Mesh_update_centroids(struct __pyx_obj_14softwrap_core2_Mesh *, int __pyx_skip_dispatch); + + +/* "core/core2.pyx":554 + * + * @cython.final + * cdef class BVH: # <<<<<<<<<<<<<< + * cdef: + * BvhNodeLeaf* leaves + */ + + +# line 554 "core/core2.pyx" +struct __pyx_vtabstruct_14softwrap_core2_BVH { + +# line 554 "core/core2.pyx" + BvhNodeBox *(*pop_box)(struct __pyx_obj_14softwrap_core2_BVH *); + +# line 554 "core/core2.pyx" + union BvhNode *(*build_tree)(struct __pyx_obj_14softwrap_core2_BVH *, BvhNodeLeaf *, int); + +# line 554 "core/core2.pyx" + struct BvhNearestResult (*_find_nearest)(struct __pyx_obj_14softwrap_core2_BVH *, vec3); + +# line 554 "core/core2.pyx" + void (*find_nearest_recursive)(struct __pyx_obj_14softwrap_core2_BVH *, vec3 *, struct BvhNearestResult *, union BvhNode *); + +# line 554 "core/core2.pyx" +}; + +# line 554 "core/core2.pyx" +static struct __pyx_vtabstruct_14softwrap_core2_BVH *__pyx_vtabptr_14softwrap_core2_BVH; + +# line 554 "core/core2.pyx" +static CYTHON_INLINE BvhNodeBox *__pyx_f_14softwrap_core2_3BVH_pop_box(struct __pyx_obj_14softwrap_core2_BVH *); + +# line 554 "core/core2.pyx" +static union BvhNode *__pyx_f_14softwrap_core2_3BVH_build_tree(struct __pyx_obj_14softwrap_core2_BVH *, BvhNodeLeaf *, int); + +# line 554 "core/core2.pyx" +static CYTHON_INLINE struct BvhNearestResult __pyx_f_14softwrap_core2_3BVH__find_nearest(struct __pyx_obj_14softwrap_core2_BVH *, vec3); + +# line 554 "core/core2.pyx" +static void __pyx_f_14softwrap_core2_3BVH_find_nearest_recursive(struct __pyx_obj_14softwrap_core2_BVH *, vec3 *, struct BvhNearestResult *, union BvhNode *); + + +/* "core/core2.pyx":747 + * return r / (self.halflinks.n + EPS) + * + * cdef class SpringLinks: # <<<<<<<<<<<<<< + * + * cdef readonly SpringEngine engine + */ + + +# line 747 "core/core2.pyx" +struct __pyx_vtabstruct_14softwrap_core2_SpringLinks { + +# line 747 "core/core2.pyx" + void (*lengths_update)(struct __pyx_obj_14softwrap_core2_SpringLinks *, int __pyx_skip_dispatch); + +# line 747 "core/core2.pyx" + void (*smooth)(struct __pyx_obj_14softwrap_core2_SpringLinks *, float, int __pyx_skip_dispatch); + +# line 747 "core/core2.pyx" + void (*soft_spring_force)(struct __pyx_obj_14softwrap_core2_SpringLinks *, float, int __pyx_skip_dispatch, struct __pyx_opt_args_14softwrap_core2_11SpringLinks_soft_spring_force *__pyx_optional_args); + +# line 747 "core/core2.pyx" + void (*stiff_spring_force)(struct __pyx_obj_14softwrap_core2_SpringLinks *, float, int __pyx_skip_dispatch); + +# line 747 "core/core2.pyx" +}; + +# line 747 "core/core2.pyx" +static struct __pyx_vtabstruct_14softwrap_core2_SpringLinks *__pyx_vtabptr_14softwrap_core2_SpringLinks; + + +/* "core/core2.pyx":915 + * + * @cython.final + * cdef class TernarySmoothingLinks: # <<<<<<<<<<<<<< + * cdef readonly SpringEngine engine + * cdef TernaryLinkArr** links + */ + + +# line 915 "core/core2.pyx" +struct __pyx_vtabstruct_14softwrap_core2_TernarySmoothingLinks { + +# line 915 "core/core2.pyx" + void (*displacements_update)(struct __pyx_obj_14softwrap_core2_TernarySmoothingLinks *, int __pyx_skip_dispatch); + +# line 915 "core/core2.pyx" + void (*displacement_force)(struct __pyx_obj_14softwrap_core2_TernarySmoothingLinks *, float, int __pyx_skip_dispatch); + +# line 915 "core/core2.pyx" +}; + +# line 915 "core/core2.pyx" +static struct __pyx_vtabstruct_14softwrap_core2_TernarySmoothingLinks *__pyx_vtabptr_14softwrap_core2_TernarySmoothingLinks; + +# line 915 "core/core2.pyx" +static void __pyx_f_14softwrap_core2_21TernarySmoothingLinks_displacements_update(struct __pyx_obj_14softwrap_core2_TernarySmoothingLinks *, int __pyx_skip_dispatch); + +# line 915 "core/core2.pyx" +static void __pyx_f_14softwrap_core2_21TernarySmoothingLinks_displacement_force(struct __pyx_obj_14softwrap_core2_TernarySmoothingLinks *, float, int __pyx_skip_dispatch); + + +/* "core/core2.pyx":1017 + * int side + * + * cdef class QuaternarySmoothingLinks: # <<<<<<<<<<<<<< + * cdef readonly SpringEngine engine + * cdef readonly int n_links + */ + + +# line 1017 "core/core2.pyx" +struct __pyx_vtabstruct_14softwrap_core2_QuaternarySmoothingLinks { + +# line 1017 "core/core2.pyx" + void (*lengths_update)(struct __pyx_obj_14softwrap_core2_QuaternarySmoothingLinks *, int __pyx_skip_dispatch); + +# line 1017 "core/core2.pyx" + void (*smooth)(struct __pyx_obj_14softwrap_core2_QuaternarySmoothingLinks *, float, int __pyx_skip_dispatch, struct __pyx_opt_args_14softwrap_core2_24QuaternarySmoothingLinks_smooth *__pyx_optional_args); + +# line 1017 "core/core2.pyx" +}; + +# line 1017 "core/core2.pyx" +static struct __pyx_vtabstruct_14softwrap_core2_QuaternarySmoothingLinks *__pyx_vtabptr_14softwrap_core2_QuaternarySmoothingLinks; + + +/* "core/core2.pyx":1210 + * + * + * cdef class SpringEngineMask: # <<<<<<<<<<<<<< + * cdef float* mask + * cdef vec3* vec_data + */ + + +# line 1210 "core/core2.pyx" +struct __pyx_vtabstruct_14softwrap_core2_SpringEngineMask { + +# line 1210 "core/core2.pyx" + PyObject *(*set_force)(struct __pyx_obj_14softwrap_core2_SpringEngineMask *, float, float, float, int __pyx_skip_dispatch); + +# line 1210 "core/core2.pyx" + void (*load)(struct __pyx_obj_14softwrap_core2_SpringEngineMask *, int __pyx_skip_dispatch); + +# line 1210 "core/core2.pyx" + void (*store)(struct __pyx_obj_14softwrap_core2_SpringEngineMask *, int __pyx_skip_dispatch); + +# line 1210 "core/core2.pyx" + void (*masked_store)(struct __pyx_obj_14softwrap_core2_SpringEngineMask *, int __pyx_skip_dispatch, struct __pyx_opt_args_14softwrap_core2_16SpringEngineMask_masked_store *__pyx_optional_args); + +# line 1210 "core/core2.pyx" + PyObject *(*set)(struct __pyx_obj_14softwrap_core2_SpringEngineMask *, PyObject *, int __pyx_skip_dispatch); + +# line 1210 "core/core2.pyx" +}; + +# line 1210 "core/core2.pyx" +static struct __pyx_vtabstruct_14softwrap_core2_SpringEngineMask *__pyx_vtabptr_14softwrap_core2_SpringEngineMask; + + +/* "core/core2.pyx":1313 + * + * @cython.final + * cdef class SymmetryMap: # <<<<<<<<<<<<<< + * cdef int* symm_map + * cdef SpringEngine engine + */ + + +# line 1313 "core/core2.pyx" +struct __pyx_vtabstruct_14softwrap_core2_SymmetryMap { + +# line 1313 "core/core2.pyx" + void (*mirror)(struct __pyx_obj_14softwrap_core2_SymmetryMap *, int, int, int, int __pyx_skip_dispatch); + +# line 1313 "core/core2.pyx" +}; + +# line 1313 "core/core2.pyx" +static struct __pyx_vtabstruct_14softwrap_core2_SymmetryMap *__pyx_vtabptr_14softwrap_core2_SymmetryMap; + +# line 1313 "core/core2.pyx" +static void __pyx_f_14softwrap_core2_11SymmetryMap_mirror(struct __pyx_obj_14softwrap_core2_SymmetryMap *, int, int, int, int __pyx_skip_dispatch); + + +/* "core/core2.pyx":1376 + * + * + * cdef class SpringEngine: # <<<<<<<<<<<<<< + * cdef Mesh m + * cdef vec3* prev_verts + */ + + +# line 1376 "core/core2.pyx" +struct __pyx_vtabstruct_14softwrap_core2_SpringEngine { + +# line 1376 "core/core2.pyx" + void (*set_bvh)(struct __pyx_obj_14softwrap_core2_SpringEngine *, struct __pyx_obj_14softwrap_core2_BVH *, int __pyx_skip_dispatch); + +# line 1376 "core/core2.pyx" + struct __pyx_obj_14softwrap_core2_SpringLinks *(*create_spring_group)(struct __pyx_obj_14softwrap_core2_SpringEngine *, PyObject *, int __pyx_skip_dispatch); + +# line 1376 "core/core2.pyx" + struct __pyx_obj_14softwrap_core2_SymmetryMap *(*create_symmetry_map)(struct __pyx_obj_14softwrap_core2_SpringEngine *, int __pyx_skip_dispatch); + +# line 1376 "core/core2.pyx" + struct __pyx_obj_14softwrap_core2_TernarySmoothingLinks *(*create_ternary_links)(struct __pyx_obj_14softwrap_core2_SpringEngine *, PyObject *, int __pyx_skip_dispatch); + +# line 1376 "core/core2.pyx" + struct __pyx_obj_14softwrap_core2_QuaternarySmoothingLinks *(*create_quaternary_links)(struct __pyx_obj_14softwrap_core2_SpringEngine *, PyObject *, int __pyx_skip_dispatch); + +# line 1376 "core/core2.pyx" + struct __pyx_obj_14softwrap_core2_SpringEngineMask *(*create_mask)(struct __pyx_obj_14softwrap_core2_SpringEngine *, PyObject *, int __pyx_skip_dispatch); + +# line 1376 "core/core2.pyx" + void (*random_verts)(struct __pyx_obj_14softwrap_core2_SpringEngine *, float, int __pyx_skip_dispatch, struct __pyx_opt_args_14softwrap_core2_12SpringEngine_random_verts *__pyx_optional_args); + +# line 1376 "core/core2.pyx" + void (*kinetic_step)(struct __pyx_obj_14softwrap_core2_SpringEngine *, float, int __pyx_skip_dispatch); + +# line 1376 "core/core2.pyx" + void (*update_mesh_normals)(struct __pyx_obj_14softwrap_core2_SpringEngine *, float, int __pyx_skip_dispatch); + +# line 1376 "core/core2.pyx" +}; + +# line 1376 "core/core2.pyx" +static struct __pyx_vtabstruct_14softwrap_core2_SpringEngine *__pyx_vtabptr_14softwrap_core2_SpringEngine; + +/* --- Runtime support code (head) --- */ +/* Refnanny.proto */ +#ifndef CYTHON_REFNANNY + #define CYTHON_REFNANNY 0 +#endif +#if CYTHON_REFNANNY + typedef struct { + void (*INCREF)(void*, PyObject*, int); + void (*DECREF)(void*, PyObject*, int); + void (*GOTREF)(void*, PyObject*, int); + void (*GIVEREF)(void*, PyObject*, int); + void* (*SetupContext)(const char*, int, const char*); + void (*FinishContext)(void**); + } __Pyx_RefNannyAPIStruct; + static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL; + static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); + #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL; +#ifdef WITH_THREAD + #define __Pyx_RefNannySetupContext(name, acquire_gil)\ + if (acquire_gil) {\ + PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\ + __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\ + PyGILState_Release(__pyx_gilstate_save);\ + } else {\ + __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\ + } +#else + #define __Pyx_RefNannySetupContext(name, acquire_gil)\ + __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__) +#endif + #define __Pyx_RefNannyFinishContext()\ + __Pyx_RefNanny->FinishContext(&__pyx_refnanny) + #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0) + #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0) + #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0) + #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0) +#else + #define __Pyx_RefNannyDeclarations + #define __Pyx_RefNannySetupContext(name, acquire_gil) + #define __Pyx_RefNannyFinishContext() + #define __Pyx_INCREF(r) Py_INCREF(r) + #define __Pyx_DECREF(r) Py_DECREF(r) + #define __Pyx_GOTREF(r) + #define __Pyx_GIVEREF(r) + #define __Pyx_XINCREF(r) Py_XINCREF(r) + #define __Pyx_XDECREF(r) Py_XDECREF(r) + #define __Pyx_XGOTREF(r) + #define __Pyx_XGIVEREF(r) +#endif +#define __Pyx_XDECREF_SET(r, v) do {\ + PyObject *tmp = (PyObject *) r;\ + r = v; __Pyx_XDECREF(tmp);\ + } while (0) +#define __Pyx_DECREF_SET(r, v) do {\ + PyObject *tmp = (PyObject *) r;\ + r = v; __Pyx_DECREF(tmp);\ + } while (0) +#define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0) +#define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0) + +/* PyObjectGetAttrStr.proto */ +#if CYTHON_USE_TYPE_SLOTS +static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name); +#else +#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n) +#endif + +/* GetBuiltinName.proto */ +static PyObject *__Pyx_GetBuiltinName(PyObject *name); + +/* PyThreadStateGet.proto */ +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate; +#define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current; +#define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type +#else +#define __Pyx_PyThreadState_declare +#define __Pyx_PyThreadState_assign +#define __Pyx_PyErr_Occurred() PyErr_Occurred() +#endif + +/* PyErrFetchRestore.proto */ +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL) +#define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb) +#define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb) +#define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb) +#define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb) +static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); +static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); +#if CYTHON_COMPILING_IN_CPYTHON +#define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL)) +#else +#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) +#endif +#else +#define __Pyx_PyErr_Clear() PyErr_Clear() +#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) +#define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb) +#define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb) +#define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb) +#define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb) +#define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb) +#define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb) +#endif + +/* WriteUnraisableException.proto */ +static void __Pyx_WriteUnraisable(const char *name, int clineno, + int lineno, const char *filename, + int full_traceback, int nogil); + +/* Import.proto */ +static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level); + +/* PyFunctionFastCall.proto */ +#if CYTHON_FAST_PYCALL +#define __Pyx_PyFunction_FastCall(func, args, nargs)\ + __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL) +#if 1 || PY_VERSION_HEX < 0x030600B1 +static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs); +#else +#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs) +#endif +#define __Pyx_BUILD_ASSERT_EXPR(cond)\ + (sizeof(char [1 - 2*!(cond)]) - 1) +#ifndef Py_MEMBER_SIZE +#define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member) +#endif +#if CYTHON_FAST_PYCALL + static size_t __pyx_pyframe_localsplus_offset = 0; + #include "frameobject.h" + #define __Pxy_PyFrame_Initialize_Offsets()\ + ((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\ + (void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus))) + #define __Pyx_PyFrame_GetLocalsplus(frame)\ + (assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset)) +#endif // CYTHON_FAST_PYCALL +#endif + +/* PyObjectCall.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw); +#else +#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw) +#endif + +/* PyObjectCallMethO.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg); +#endif + +/* PyObjectCallNoArg.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func); +#else +#define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL) +#endif + +/* PyCFunctionFastCall.proto */ +#if CYTHON_FAST_PYCCALL +static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs); +#else +#define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL) +#endif + +/* PyObjectCallOneArg.proto */ +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg); + +/* IterFinish.proto */ +static CYTHON_INLINE int __Pyx_IterFinish(void); + +/* PyObjectGetMethod.proto */ +static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method); + +/* PyObjectCallMethod0.proto */ +static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name); + +/* RaiseNeedMoreValuesToUnpack.proto */ +static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index); + +/* RaiseTooManyValuesToUnpack.proto */ +static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected); + +/* UnpackItemEndCheck.proto */ +static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected); + +/* RaiseNoneIterError.proto */ +static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void); + +/* UnpackTupleError.proto */ +static void __Pyx_UnpackTupleError(PyObject *, Py_ssize_t index); + +/* UnpackTuple2.proto */ +#define __Pyx_unpack_tuple2(tuple, value1, value2, is_tuple, has_known_size, decref_tuple)\ + (likely(is_tuple || PyTuple_Check(tuple)) ?\ + (likely(has_known_size || PyTuple_GET_SIZE(tuple) == 2) ?\ + __Pyx_unpack_tuple2_exact(tuple, value1, value2, decref_tuple) :\ + (__Pyx_UnpackTupleError(tuple, 2), -1)) :\ + __Pyx_unpack_tuple2_generic(tuple, value1, value2, has_known_size, decref_tuple)) +static CYTHON_INLINE int __Pyx_unpack_tuple2_exact( + PyObject* tuple, PyObject** value1, PyObject** value2, int decref_tuple); +static int __Pyx_unpack_tuple2_generic( + PyObject* tuple, PyObject** value1, PyObject** value2, int has_known_size, int decref_tuple); + +/* dict_iter.proto */ +static CYTHON_INLINE PyObject* __Pyx_dict_iterator(PyObject* dict, int is_dict, PyObject* method_name, + Py_ssize_t* p_orig_length, int* p_is_dict); +static CYTHON_INLINE int __Pyx_dict_iter_next(PyObject* dict_or_iter, Py_ssize_t orig_length, Py_ssize_t* ppos, + PyObject** pkey, PyObject** pvalue, PyObject** pitem, int is_dict); + +/* PyObjectFormatSimple.proto */ +#if CYTHON_COMPILING_IN_PYPY + #define __Pyx_PyObject_FormatSimple(s, f) (\ + likely(PyUnicode_CheckExact(s)) ? (Py_INCREF(s), s) :\ + PyObject_Format(s, f)) +#elif PY_MAJOR_VERSION < 3 + #define __Pyx_PyObject_FormatSimple(s, f) (\ + likely(PyUnicode_CheckExact(s)) ? (Py_INCREF(s), s) :\ + likely(PyString_CheckExact(s)) ? PyUnicode_FromEncodedObject(s, NULL, "strict") :\ + PyObject_Format(s, f)) +#elif CYTHON_USE_TYPE_SLOTS + #define __Pyx_PyObject_FormatSimple(s, f) (\ + likely(PyUnicode_CheckExact(s)) ? (Py_INCREF(s), s) :\ + likely(PyLong_CheckExact(s)) ? PyLong_Type.tp_str(s) :\ + likely(PyFloat_CheckExact(s)) ? PyFloat_Type.tp_str(s) :\ + PyObject_Format(s, f)) +#else + #define __Pyx_PyObject_FormatSimple(s, f) (\ + likely(PyUnicode_CheckExact(s)) ? (Py_INCREF(s), s) :\ + PyObject_Format(s, f)) +#endif + +/* IncludeStringH.proto */ +#include + +/* JoinPyUnicode.proto */ +static PyObject* __Pyx_PyUnicode_Join(PyObject* value_tuple, Py_ssize_t value_count, Py_ssize_t result_ulength, + Py_UCS4 max_char); + +/* SetItemInt.proto */ +#define __Pyx_SetItemInt(o, i, v, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ + (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ + __Pyx_SetItemInt_Fast(o, (Py_ssize_t)i, v, is_list, wraparound, boundscheck) :\ + (is_list ? (PyErr_SetString(PyExc_IndexError, "list assignment index out of range"), -1) :\ + __Pyx_SetItemInt_Generic(o, to_py_func(i), v))) +static int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v); +static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v, + int is_list, int wraparound, int boundscheck); + +/* RaiseException.proto */ +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); + +/* RaiseArgTupleInvalid.proto */ +static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, + Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); + +/* RaiseDoubleKeywords.proto */ +static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); + +/* ParseKeywords.proto */ +static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\ + PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\ + const char* function_name); + +/* GetItemInt.proto */ +#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ + (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ + __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\ + (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\ + __Pyx_GetItemInt_Generic(o, to_py_func(i)))) +#define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ + (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ + __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\ + (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL)) +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, + int wraparound, int boundscheck); +#define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ + (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ + __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\ + (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL)) +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, + int wraparound, int boundscheck); +static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j); +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, + int is_list, int wraparound, int boundscheck); + +/* ArgTypeTest.proto */ +#define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\ + ((likely((Py_TYPE(obj) == type) | (none_allowed && (obj == Py_None)))) ? 1 :\ + __Pyx__ArgTypeTest(obj, type, name, exact)) +static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact); + +/* ListCompAppend.proto */ +#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS +static CYTHON_INLINE int __Pyx_ListComp_Append(PyObject* list, PyObject* x) { + PyListObject* L = (PyListObject*) list; + Py_ssize_t len = Py_SIZE(list); + if (likely(L->allocated > len)) { + Py_INCREF(x); + PyList_SET_ITEM(list, len, x); + __Pyx_SET_SIZE(list, len + 1); + return 0; + } + return PyList_Append(list, x); +} +#else +#define __Pyx_ListComp_Append(L,x) PyList_Append(L,x) +#endif + +/* ListAppend.proto */ +#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS +static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) { + PyListObject* L = (PyListObject*) list; + Py_ssize_t len = Py_SIZE(list); + if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) { + Py_INCREF(x); + PyList_SET_ITEM(list, len, x); + __Pyx_SET_SIZE(list, len + 1); + return 0; + } + return PyList_Append(list, x); +} +#else +#define __Pyx_PyList_Append(L,x) PyList_Append(L,x) +#endif + +/* PyObjectCall2Args.proto */ +static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2); + +/* PyObjectCallMethod1.proto */ +static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg); + +/* append.proto */ +static CYTHON_INLINE int __Pyx_PyObject_Append(PyObject* L, PyObject* x); + +/* PyDictVersioning.proto */ +#if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS +#define __PYX_DICT_VERSION_INIT ((PY_UINT64_T) -1) +#define __PYX_GET_DICT_VERSION(dict) (((PyDictObject*)(dict))->ma_version_tag) +#define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\ + (version_var) = __PYX_GET_DICT_VERSION(dict);\ + (cache_var) = (value); +#define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\ + static PY_UINT64_T __pyx_dict_version = 0;\ + static PyObject *__pyx_dict_cached_value = NULL;\ + if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\ + (VAR) = __pyx_dict_cached_value;\ + } else {\ + (VAR) = __pyx_dict_cached_value = (LOOKUP);\ + __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\ + }\ +} +static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj); +static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj); +static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version); +#else +#define __PYX_GET_DICT_VERSION(dict) (0) +#define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var) +#define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) (VAR) = (LOOKUP); +#endif + +/* ExtTypeTest.proto */ +static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); + +/* pyfrozenset_new.proto */ +static CYTHON_INLINE PyObject* __Pyx_PyFrozenSet_New(PyObject* it); + +/* PySetContains.proto */ +static CYTHON_INLINE int __Pyx_PySet_ContainsTF(PyObject* key, PyObject* set, int eq); + +/* None.proto */ +static CYTHON_INLINE void __Pyx_RaiseClosureNameError(const char *varname); + +/* FetchCommonType.proto */ +static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type); + +/* CythonFunctionShared.proto */ +#define __Pyx_CyFunction_USED 1 +#define __Pyx_CYFUNCTION_STATICMETHOD 0x01 +#define __Pyx_CYFUNCTION_CLASSMETHOD 0x02 +#define __Pyx_CYFUNCTION_CCLASS 0x04 +#define __Pyx_CyFunction_GetClosure(f)\ + (((__pyx_CyFunctionObject *) (f))->func_closure) +#define __Pyx_CyFunction_GetClassObj(f)\ + (((__pyx_CyFunctionObject *) (f))->func_classobj) +#define __Pyx_CyFunction_Defaults(type, f)\ + ((type *)(((__pyx_CyFunctionObject *) (f))->defaults)) +#define __Pyx_CyFunction_SetDefaultsGetter(f, g)\ + ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g) +typedef struct { + PyCFunctionObject func; +#if PY_VERSION_HEX < 0x030500A0 + PyObject *func_weakreflist; +#endif + PyObject *func_dict; + PyObject *func_name; + PyObject *func_qualname; + PyObject *func_doc; + PyObject *func_globals; + PyObject *func_code; + PyObject *func_closure; + PyObject *func_classobj; + void *defaults; + int defaults_pyobjects; + size_t defaults_size; // used by FusedFunction for copying defaults + int flags; + PyObject *defaults_tuple; + PyObject *defaults_kwdict; + PyObject *(*defaults_getter)(PyObject *); + PyObject *func_annotations; +} __pyx_CyFunctionObject; +static PyTypeObject *__pyx_CyFunctionType = 0; +#define __Pyx_CyFunction_Check(obj) (__Pyx_TypeCheck(obj, __pyx_CyFunctionType)) +static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject* op, PyMethodDef *ml, + int flags, PyObject* qualname, + PyObject *self, + PyObject *module, PyObject *globals, + PyObject* code); +static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *m, + size_t size, + int pyobjects); +static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m, + PyObject *tuple); +static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m, + PyObject *dict); +static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m, + PyObject *dict); +static int __pyx_CyFunction_init(void); + +/* CythonFunction.proto */ +static PyObject *__Pyx_CyFunction_New(PyMethodDef *ml, + int flags, PyObject* qualname, + PyObject *closure, + PyObject *module, PyObject *globals, + PyObject* code); + +/* DictGetItem.proto */ +#if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY +static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key); +#define __Pyx_PyObject_Dict_GetItem(obj, name)\ + (likely(PyDict_CheckExact(obj)) ?\ + __Pyx_PyDict_GetItem(obj, name) : PyObject_GetItem(obj, name)) +#else +#define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key) +#define __Pyx_PyObject_Dict_GetItem(obj, name) PyObject_GetItem(obj, name) +#endif + +/* GetTopmostException.proto */ +#if CYTHON_USE_EXC_INFO_STACK +static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate); +#endif + +/* SaveResetException.proto */ +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb) +static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); +#define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb) +static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); +#else +#define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb) +#define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb) +#endif + +/* PyErrExceptionMatches.proto */ +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err) +static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err); +#else +#define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err) +#endif + +/* PyObject_GenericGetAttrNoDict.proto */ +#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000 +static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name); +#else +#define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr +#endif + +/* SetVTable.proto */ +static int __Pyx_SetVtable(PyObject *dict, void *vtable); + +/* PyObjectGetAttrStrNoError.proto */ +static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name); + +/* SetupReduce.proto */ +static int __Pyx_setup_reduce(PyObject* type_obj); + +/* PyObject_GenericGetAttr.proto */ +#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000 +static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name); +#else +#define __Pyx_PyObject_GenericGetAttr PyObject_GenericGetAttr +#endif + +/* GetModuleGlobalName.proto */ +#if CYTHON_USE_DICT_VERSIONS +#define __Pyx_GetModuleGlobalName(var, name) {\ + static PY_UINT64_T __pyx_dict_version = 0;\ + static PyObject *__pyx_dict_cached_value = NULL;\ + (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_d))) ?\ + (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\ + __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\ +} +#define __Pyx_GetModuleGlobalNameUncached(var, name) {\ + PY_UINT64_T __pyx_dict_version;\ + PyObject *__pyx_dict_cached_value;\ + (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\ +} +static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value); +#else +#define __Pyx_GetModuleGlobalName(var, name) (var) = __Pyx__GetModuleGlobalName(name) +#define __Pyx_GetModuleGlobalNameUncached(var, name) (var) = __Pyx__GetModuleGlobalName(name) +static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name); +#endif + +/* CLineInTraceback.proto */ +#ifdef CYTHON_CLINE_IN_TRACEBACK +#define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0) +#else +static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line); +#endif + +/* CodeObjectCache.proto */ +typedef struct { + PyCodeObject* code_object; + int code_line; +} __Pyx_CodeObjectCacheEntry; +struct __Pyx_CodeObjectCache { + int count; + int max_count; + __Pyx_CodeObjectCacheEntry* entries; +}; +static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL}; +static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line); +static PyCodeObject *__pyx_find_code_object(int code_line); +static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object); + +/* AddTraceback.proto */ +static void __Pyx_AddTraceback(const char *funcname, int c_line, + int py_line, const char *filename); + +/* GCCDiagnostics.proto */ +#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) +#define __Pyx_HAS_GCC_DIAGNOSTIC +#endif + +/* CIntFromPy.proto */ +static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *); + +/* CIntFromPy.proto */ +static CYTHON_INLINE unsigned int __Pyx_PyInt_As_unsigned_int(PyObject *); + +/* CIntToPy.proto */ +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value); + +/* CIntToPy.proto */ +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value); + +/* CIntToPy.proto */ +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_int(unsigned int value); + +/* CIntFromPy.proto */ +static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *); + +/* CIntFromPy.proto */ +static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *); + +/* FastTypeChecks.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type) +static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b); +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type); +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2); +#else +#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) +#define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type) +#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2)) +#endif +#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception) + +/* SwapException.proto */ +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_ExceptionSwap(type, value, tb) __Pyx__ExceptionSwap(__pyx_tstate, type, value, tb) +static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); +#else +static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb); +#endif + +/* CoroutineBase.proto */ +typedef PyObject *(*__pyx_coroutine_body_t)(PyObject *, PyThreadState *, PyObject *); +#if CYTHON_USE_EXC_INFO_STACK +#define __Pyx_ExcInfoStruct _PyErr_StackItem +#else +typedef struct { + PyObject *exc_type; + PyObject *exc_value; + PyObject *exc_traceback; +} __Pyx_ExcInfoStruct; +#endif +typedef struct { + PyObject_HEAD + __pyx_coroutine_body_t body; + PyObject *closure; + __Pyx_ExcInfoStruct gi_exc_state; + PyObject *gi_weakreflist; + PyObject *classobj; + PyObject *yieldfrom; + PyObject *gi_name; + PyObject *gi_qualname; + PyObject *gi_modulename; + PyObject *gi_code; + PyObject *gi_frame; + int resume_label; + char is_running; +} __pyx_CoroutineObject; +static __pyx_CoroutineObject *__Pyx__Coroutine_New( + PyTypeObject *type, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure, + PyObject *name, PyObject *qualname, PyObject *module_name); +static __pyx_CoroutineObject *__Pyx__Coroutine_NewInit( + __pyx_CoroutineObject *gen, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure, + PyObject *name, PyObject *qualname, PyObject *module_name); +static CYTHON_INLINE void __Pyx_Coroutine_ExceptionClear(__Pyx_ExcInfoStruct *self); +static int __Pyx_Coroutine_clear(PyObject *self); +static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value); +static PyObject *__Pyx_Coroutine_Close(PyObject *self); +static PyObject *__Pyx_Coroutine_Throw(PyObject *gen, PyObject *args); +#if CYTHON_USE_EXC_INFO_STACK +#define __Pyx_Coroutine_SwapException(self) +#define __Pyx_Coroutine_ResetAndClearException(self) __Pyx_Coroutine_ExceptionClear(&(self)->gi_exc_state) +#else +#define __Pyx_Coroutine_SwapException(self) {\ + __Pyx_ExceptionSwap(&(self)->gi_exc_state.exc_type, &(self)->gi_exc_state.exc_value, &(self)->gi_exc_state.exc_traceback);\ + __Pyx_Coroutine_ResetFrameBackpointer(&(self)->gi_exc_state);\ + } +#define __Pyx_Coroutine_ResetAndClearException(self) {\ + __Pyx_ExceptionReset((self)->gi_exc_state.exc_type, (self)->gi_exc_state.exc_value, (self)->gi_exc_state.exc_traceback);\ + (self)->gi_exc_state.exc_type = (self)->gi_exc_state.exc_value = (self)->gi_exc_state.exc_traceback = NULL;\ + } +#endif +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_PyGen_FetchStopIterationValue(pvalue)\ + __Pyx_PyGen__FetchStopIterationValue(__pyx_tstate, pvalue) +#else +#define __Pyx_PyGen_FetchStopIterationValue(pvalue)\ + __Pyx_PyGen__FetchStopIterationValue(__Pyx_PyThreadState_Current, pvalue) +#endif +static int __Pyx_PyGen__FetchStopIterationValue(PyThreadState *tstate, PyObject **pvalue); +static CYTHON_INLINE void __Pyx_Coroutine_ResetFrameBackpointer(__Pyx_ExcInfoStruct *exc_state); + +/* PatchModuleWithCoroutine.proto */ +static PyObject* __Pyx_Coroutine_patch_module(PyObject* module, const char* py_code); + +/* PatchGeneratorABC.proto */ +static int __Pyx_patch_abc(void); + +/* Generator.proto */ +#define __Pyx_Generator_USED +static PyTypeObject *__pyx_GeneratorType = 0; +#define __Pyx_Generator_CheckExact(obj) (Py_TYPE(obj) == __pyx_GeneratorType) +#define __Pyx_Generator_New(body, code, closure, name, qualname, module_name)\ + __Pyx__Coroutine_New(__pyx_GeneratorType, body, code, closure, name, qualname, module_name) +static PyObject *__Pyx_Generator_Next(PyObject *self); +static int __pyx_Generator_init(void); + +/* CheckBinaryVersion.proto */ +static int __Pyx_check_binary_version(void); + +/* InitStrings.proto */ +static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); + +static CYTHON_INLINE vec3 *__pyx_f_14softwrap_core2_4Mesh_tri_vert_ptr(struct __pyx_obj_14softwrap_core2_Mesh *__pyx_v_self, int __pyx_v_tri, int __pyx_v_tri_i); /* proto*/ +static CYTHON_INLINE vec3 __pyx_f_14softwrap_core2_4Mesh_tri_vert(struct __pyx_obj_14softwrap_core2_Mesh *__pyx_v_self, int __pyx_v_tri, int __pyx_v_tri_i); /* proto*/ +static void __pyx_f_14softwrap_core2_4Mesh_update_face_normals(struct __pyx_obj_14softwrap_core2_Mesh *__pyx_v_self, CYTHON_UNUSED int __pyx_skip_dispatch); /* proto*/ +static void __pyx_f_14softwrap_core2_4Mesh_update_vert_normals(struct __pyx_obj_14softwrap_core2_Mesh *__pyx_v_self, CYTHON_UNUSED int __pyx_skip_dispatch); /* proto*/ +static void __pyx_f_14softwrap_core2_4Mesh_update_centroids(struct __pyx_obj_14softwrap_core2_Mesh *__pyx_v_self, CYTHON_UNUSED int __pyx_skip_dispatch); /* proto*/ +static CYTHON_INLINE BvhNodeBox *__pyx_f_14softwrap_core2_3BVH_pop_box(struct __pyx_obj_14softwrap_core2_BVH *__pyx_v_self); /* proto*/ +static union BvhNode *__pyx_f_14softwrap_core2_3BVH_build_tree(struct __pyx_obj_14softwrap_core2_BVH *__pyx_v_self, BvhNodeLeaf *__pyx_v_leaves, int __pyx_v_size); /* proto*/ +static CYTHON_INLINE struct BvhNearestResult __pyx_f_14softwrap_core2_3BVH__find_nearest(struct __pyx_obj_14softwrap_core2_BVH *__pyx_v_self, vec3 __pyx_v_p); /* proto*/ +static void __pyx_f_14softwrap_core2_3BVH_find_nearest_recursive(struct __pyx_obj_14softwrap_core2_BVH *__pyx_v_self, vec3 *__pyx_v_p, struct BvhNearestResult *__pyx_v_out, union BvhNode *__pyx_v_node); /* proto*/ +static void __pyx_f_14softwrap_core2_11SpringLinks_lengths_update(struct __pyx_obj_14softwrap_core2_SpringLinks *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/ +static void __pyx_f_14softwrap_core2_11SpringLinks_smooth(struct __pyx_obj_14softwrap_core2_SpringLinks *__pyx_v_self, float __pyx_v_factor, int __pyx_skip_dispatch); /* proto*/ +static void __pyx_f_14softwrap_core2_11SpringLinks_soft_spring_force(struct __pyx_obj_14softwrap_core2_SpringLinks *__pyx_v_self, float __pyx_v_factor, int __pyx_skip_dispatch, struct __pyx_opt_args_14softwrap_core2_11SpringLinks_soft_spring_force *__pyx_optional_args); /* proto*/ +static void __pyx_f_14softwrap_core2_11SpringLinks_stiff_spring_force(struct __pyx_obj_14softwrap_core2_SpringLinks *__pyx_v_self, float __pyx_v_factor, int __pyx_skip_dispatch); /* proto*/ +static void __pyx_f_14softwrap_core2_21TernarySmoothingLinks_displacements_update(struct __pyx_obj_14softwrap_core2_TernarySmoothingLinks *__pyx_v_self, CYTHON_UNUSED int __pyx_skip_dispatch); /* proto*/ +static void __pyx_f_14softwrap_core2_21TernarySmoothingLinks_displacement_force(struct __pyx_obj_14softwrap_core2_TernarySmoothingLinks *__pyx_v_self, float __pyx_v_factor, CYTHON_UNUSED int __pyx_skip_dispatch); /* proto*/ +static void __pyx_f_14softwrap_core2_24QuaternarySmoothingLinks_lengths_update(struct __pyx_obj_14softwrap_core2_QuaternarySmoothingLinks *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/ +static void __pyx_f_14softwrap_core2_24QuaternarySmoothingLinks_smooth(struct __pyx_obj_14softwrap_core2_QuaternarySmoothingLinks *__pyx_v_self, float __pyx_v_factor, int __pyx_skip_dispatch, struct __pyx_opt_args_14softwrap_core2_24QuaternarySmoothingLinks_smooth *__pyx_optional_args); /* proto*/ +static PyObject *__pyx_f_14softwrap_core2_16SpringEngineMask_set_force(struct __pyx_obj_14softwrap_core2_SpringEngineMask *__pyx_v_self, float __pyx_v_x, float __pyx_v_y, float __pyx_v_z, int __pyx_skip_dispatch); /* proto*/ +static void __pyx_f_14softwrap_core2_16SpringEngineMask_load(struct __pyx_obj_14softwrap_core2_SpringEngineMask *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/ +static void __pyx_f_14softwrap_core2_16SpringEngineMask_store(struct __pyx_obj_14softwrap_core2_SpringEngineMask *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/ +static void __pyx_f_14softwrap_core2_16SpringEngineMask_masked_store(struct __pyx_obj_14softwrap_core2_SpringEngineMask *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_14softwrap_core2_16SpringEngineMask_masked_store *__pyx_optional_args); /* proto*/ +static PyObject *__pyx_f_14softwrap_core2_16SpringEngineMask_set(struct __pyx_obj_14softwrap_core2_SpringEngineMask *__pyx_v_self, PyObject *__pyx_v_vec_data, int __pyx_skip_dispatch); /* proto*/ +static void __pyx_f_14softwrap_core2_11SymmetryMap_mirror(struct __pyx_obj_14softwrap_core2_SymmetryMap *__pyx_v_self, int __pyx_v_x, int __pyx_v_y, int __pyx_v_z, CYTHON_UNUSED int __pyx_skip_dispatch); /* proto*/ +static void __pyx_f_14softwrap_core2_12SpringEngine_set_bvh(struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_self, struct __pyx_obj_14softwrap_core2_BVH *__pyx_v_bvh, int __pyx_skip_dispatch); /* proto*/ +static struct __pyx_obj_14softwrap_core2_SpringLinks *__pyx_f_14softwrap_core2_12SpringEngine_create_spring_group(struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_self, PyObject *__pyx_v_links, int __pyx_skip_dispatch); /* proto*/ +static struct __pyx_obj_14softwrap_core2_SymmetryMap *__pyx_f_14softwrap_core2_12SpringEngine_create_symmetry_map(struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/ +static struct __pyx_obj_14softwrap_core2_TernarySmoothingLinks *__pyx_f_14softwrap_core2_12SpringEngine_create_ternary_links(struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_self, PyObject *__pyx_v_links, int __pyx_skip_dispatch); /* proto*/ +static struct __pyx_obj_14softwrap_core2_QuaternarySmoothingLinks *__pyx_f_14softwrap_core2_12SpringEngine_create_quaternary_links(struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_self, PyObject *__pyx_v_links, int __pyx_skip_dispatch); /* proto*/ +static struct __pyx_obj_14softwrap_core2_SpringEngineMask *__pyx_f_14softwrap_core2_12SpringEngine_create_mask(struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_self, PyObject *__pyx_v_mask, int __pyx_skip_dispatch); /* proto*/ +static void __pyx_f_14softwrap_core2_12SpringEngine_random_verts(struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_self, float __pyx_v_factor, int __pyx_skip_dispatch, struct __pyx_opt_args_14softwrap_core2_12SpringEngine_random_verts *__pyx_optional_args); /* proto*/ +static void __pyx_f_14softwrap_core2_12SpringEngine_kinetic_step(struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_self, float __pyx_v_damping, int __pyx_skip_dispatch); /* proto*/ +static void __pyx_f_14softwrap_core2_12SpringEngine_update_mesh_normals(struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_self, float __pyx_v_factor, int __pyx_skip_dispatch); /* proto*/ + +/* Module declarations from 'libc.math' */ + +/* Module declarations from 'libc.limits' */ + +/* Module declarations from 'libc.string' */ + +/* Module declarations from 'libc.stdlib' */ + +/* Module declarations from 'libc.stdint' */ + +/* Module declarations from 'cython' */ + +/* Module declarations from 'softwrap_core2' */ +static PyTypeObject *__pyx_ptype_14softwrap_core2_Mesh = 0; +static PyTypeObject *__pyx_ptype_14softwrap_core2_BVH = 0; +static PyTypeObject *__pyx_ptype_14softwrap_core2_LinkProbe = 0; +static PyTypeObject *__pyx_ptype_14softwrap_core2_SpringLinks = 0; +static PyTypeObject *__pyx_ptype_14softwrap_core2_TernarySmoothingLinks = 0; +static PyTypeObject *__pyx_ptype_14softwrap_core2_QuaternarySmoothingLinks = 0; +static PyTypeObject *__pyx_ptype_14softwrap_core2_SpringEnginePin = 0; +static PyTypeObject *__pyx_ptype_14softwrap_core2__MaskContextManager = 0; +static PyTypeObject *__pyx_ptype_14softwrap_core2_SpringEngineMask = 0; +static PyTypeObject *__pyx_ptype_14softwrap_core2_SymmetryMap = 0; +static PyTypeObject *__pyx_ptype_14softwrap_core2_SpringEngine = 0; +static PyTypeObject *__pyx_ptype_14softwrap_core2___pyx_scope_struct____iter__ = 0; +static PyTypeObject *__pyx_ptype_14softwrap_core2___pyx_scope_struct_1___getitem__ = 0; +static PyTypeObject *__pyx_ptype_14softwrap_core2___pyx_scope_struct_2_iter_ring = 0; +static PyTypeObject *__pyx_ptype_14softwrap_core2___pyx_scope_struct_3___iter__ = 0; +static PyTypeObject *__pyx_ptype_14softwrap_core2___pyx_scope_struct_4___getitem__ = 0; +static PyTypeObject *__pyx_ptype_14softwrap_core2___pyx_scope_struct_5_genexpr = 0; +static PyObject *__pyx_v_14softwrap_core2_not_freed_pointers = 0; +static void *__pyx_f_14softwrap_core2_maelloc(size_t, int); /*proto*/ +static void *__pyx_f_14softwrap_core2_caelloc(size_t, size_t, int); /*proto*/ +static void __pyx_f_14softwrap_core2_fraeee(void *); /*proto*/ +static PyObject *__pyx_f_14softwrap_core2_vec3arr_to_list(vec3 *, int); /*proto*/ +static CYTHON_INLINE unsigned int __pyx_f_14softwrap_core2_xorshift(unsigned int *); /*proto*/ +static CYTHON_INLINE float __pyx_f_14softwrap_core2_uint2neg1pos1f(unsigned int); /*proto*/ +static float __pyx_f_14softwrap_core2_xorshiftf(unsigned int *); /*proto*/ +static PyObject *__pyx_f_14softwrap_core2_index_check(int, int, int __pyx_skip_dispatch); /*proto*/ +static int __Pyx_carray_from_py_float(PyObject *, float *, Py_ssize_t); /*proto*/ +static int __Pyx_carray_from_py_int(PyObject *, int *, Py_ssize_t); /*proto*/ +static CYTHON_INLINE PyObject *__Pyx_carray_to_py_float(float *, Py_ssize_t); /*proto*/ +static CYTHON_INLINE PyObject *__Pyx_carray_to_tuple_float(float *, Py_ssize_t); /*proto*/ +#define __Pyx_MODULE_NAME "softwrap_core2" +extern int __pyx_module_is_main_softwrap_core2; +int __pyx_module_is_main_softwrap_core2 = 0; + +/* Implementation of 'softwrap_core2' */ +static PyObject *__pyx_builtin_MemoryError; +static PyObject *__pyx_builtin_print; +static PyObject *__pyx_builtin_hex; +static PyObject *__pyx_builtin_range; +static PyObject *__pyx_builtin_IndexError; +static PyObject *__pyx_builtin_ValueError; +static PyObject *__pyx_builtin_TypeError; +static PyObject *__pyx_builtin_enumerate; +static PyObject *__pyx_builtin_KeyError; +static PyObject *__pyx_builtin_RuntimeError; +static PyObject *__pyx_builtin_OverflowError; +static const char __pyx_k_i[] = "i"; +static const char __pyx_k_m[] = "m"; +static const char __pyx_k_x[] = "x"; +static const char __pyx_k_y[] = "y"; +static const char __pyx_k_z[] = "z"; +static const char __pyx_k__2[] = "\n -------------------------------------------------------------"; +static const char __pyx_k_gc[] = "gc"; +static const char __pyx_k_BVH[] = "BVH"; +static const char __pyx_k_bvh[] = "bvh"; +static const char __pyx_k_hex[] = "hex"; +static const char __pyx_k_idx[] = "idx"; +static const char __pyx_k_ptr[] = " ptr: "; +static const char __pyx_k_set[] = "set"; +static const char __pyx_k_Mesh[] = "Mesh"; +static const char __pyx_k_args[] = "args"; +static const char __pyx_k_iter[] = "__iter__"; +static const char __pyx_k_line[] = "line"; +static const char __pyx_k_load[] = "load"; +static const char __pyx_k_main[] = "__main__"; +static const char __pyx_k_mask[] = "mask"; +static const char __pyx_k_mesh[] = "mesh"; +static const char __pyx_k_name[] = "__name__"; +static const char __pyx_k_seed[] = "seed"; +static const char __pyx_k_send[] = "send"; +static const char __pyx_k_size[] = "size"; +static const char __pyx_k_test[] = "__test__"; +static const char __pyx_k_type[] = "type"; +static const char __pyx_k_close[] = "close"; +static const char __pyx_k_index[] = "index"; +static const char __pyx_k_items[] = "items"; +static const char __pyx_k_links[] = "links"; +static const char __pyx_k_print[] = "print"; +static const char __pyx_k_ptr_2[] = "ptr"; +static const char __pyx_k_range[] = "range"; +static const char __pyx_k_scale[] = "scale"; +static const char __pyx_k_store[] = "store"; +static const char __pyx_k_throw[] = "throw"; +static const char __pyx_k_value[] = "value"; +static const char __pyx_k_verts[] = "verts"; +static const char __pyx_k_INSIDE[] = "INSIDE"; +static const char __pyx_k_append[] = "append"; +static const char __pyx_k_atexit[] = "atexit"; +static const char __pyx_k_engine[] = "engine"; +static const char __pyx_k_factor[] = "factor"; +static const char __pyx_k_import[] = "__import__"; +static const char __pyx_k_invert[] = "invert"; +static const char __pyx_k_reduce[] = "__reduce__"; +static const char __pyx_k_smooth[] = "smooth"; +static const char __pyx_k_OUTSIDE[] = "OUTSIDE"; +static const char __pyx_k_SURFACE[] = "SURFACE"; +static const char __pyx_k_collect[] = "collect"; +static const char __pyx_k_genexpr[] = "genexpr"; +static const char __pyx_k_indexes[] = "indexes"; +static const char __pyx_k_n_rings[] = "n_rings"; +static const char __pyx_k_set_bvh[] = "set_bvh"; +static const char __pyx_k_springs[] = "springs"; +static const char __pyx_k_KeyError[] = "KeyError"; +static const char __pyx_k_getstate[] = "__getstate__"; +static const char __pyx_k_register[] = "register"; +static const char __pyx_k_setstate[] = "__setstate__"; +static const char __pyx_k_LinkProbe[] = "LinkProbe"; +static const char __pyx_k_TypeError[] = "TypeError"; +static const char __pyx_k_core2_pyx[] = ", core2.pyx:"; +static const char __pyx_k_enumerate[] = "enumerate"; +static const char __pyx_k_iter_ring[] = "iter_ring"; +static const char __pyx_k_locations[] = "locations"; +static const char __pyx_k_max_ratio[] = "max_ratio"; +static const char __pyx_k_reduce_ex[] = "__reduce_ex__"; +static const char __pyx_k_set_force[] = "set_force"; +static const char __pyx_k_traceback[] = "traceback"; +static const char __pyx_k_triangles[] = "triangles"; +static const char __pyx_k_IndexError[] = "IndexError"; +static const char __pyx_k_ValueError[] = "ValueError"; +static const char __pyx_k_leak_check[] = "leak_check"; +static const char __pyx_k_max_deform[] = "max_deform"; +static const char __pyx_k_min_deform[] = "min_deform"; +static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__"; +static const char __pyx_k_MemoryError[] = "MemoryError"; +static const char __pyx_k_SpringLinks[] = "SpringLinks"; +static const char __pyx_k_SymmetryMap[] = "SymmetryMap"; +static const char __pyx_k_create_mask[] = "create_mask"; +static const char __pyx_k_start_index[] = "start_index"; +static const char __pyx_k_RuntimeError[] = "RuntimeError"; +static const char __pyx_k_SpringEngine[] = "SpringEngine"; +static const char __pyx_k_kinetic_step[] = "kinetic_step"; +static const char __pyx_k_masked_store[] = "masked_store"; +static const char __pyx_k_random_verts[] = "random_verts"; +static const char __pyx_k_OverflowError[] = "OverflowError"; +static const char __pyx_k_cycle_quality[] = "cycle_quality"; +static const char __pyx_k_deform_update[] = "deform_update"; +static const char __pyx_k_reduce_cython[] = "__reduce_cython__"; +static const char __pyx_k_snapping_mode[] = "snapping_mode"; +static const char __pyx_k_core_core2_pyx[] = "core\\core2.pyx"; +static const char __pyx_k_deform_restore[] = "deform_restore"; +static const char __pyx_k_lengths_update[] = "lengths_update"; +static const char __pyx_k_list_too_small[] = "list too small"; +static const char __pyx_k_softwrap_core2[] = "softwrap_core2"; +static const char __pyx_k_SpringEnginePin[] = "SpringEnginePin"; +static const char __pyx_k_setstate_cython[] = "__setstate_cython__"; +static const char __pyx_k_LinkProbe___iter[] = "LinkProbe.__iter__"; +static const char __pyx_k_No_bvh_avaliable[] = "No bvh avaliable"; +static const char __pyx_k_SpringEngineMask[] = "SpringEngineMask"; +static const char __pyx_k_soft_spring_force[] = "soft_spring_force"; +static const char __pyx_k_MaskContextManager[] = "_MaskContextManager"; +static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback"; +static const char __pyx_k_stiff_spring_force[] = "stiff_spring_force"; +static const char __pyx_k_create_spring_group[] = "create_spring_group"; +static const char __pyx_k_create_symmetry_map[] = "create_symmetry_map"; +static const char __pyx_k_invalid_start_index[] = "invalid start_index"; +static const char __pyx_k_update_mesh_normals[] = "update_mesh_normals"; +static const char __pyx_k_create_ternary_links[] = "create_ternary_links"; +static const char __pyx_k_Invalid_or_empty_mesh[] = "Invalid or empty mesh"; +static const char __pyx_k_TernarySmoothingLinks[] = "TernarySmoothingLinks"; +static const char __pyx_k_SpringEnginePin___iter[] = "SpringEnginePin.__iter__"; +static const char __pyx_k_create_quaternary_links[] = "create_quaternary_links"; +static const char __pyx_k_QuaternarySmoothingLinks[] = "QuaternarySmoothingLinks"; +static const char __pyx_k_getitem___locals_genexpr[] = "__getitem__..genexpr"; +static const char __pyx_k_getitem___locals_iter_ring[] = "__getitem__..iter_ring"; +static const char __pyx_k_Oops_Softwrap2_memory_leak_dete[] = "\n ------------ Oops Softwrap2 memory leak detected ------------ \n pointers not freed:"; +static const char __pyx_k_indexes_array_is_not_the_same_si[] = "indexes array is not the same size as locations array"; +static const char __pyx_k_mask_must_have_the_same_number_o[] = "mask must have the same number of elements as engine verts"; +static const char __pyx_k_no_default___reduce___due_to_non[] = "no default __reduce__ due to non-trivial __cinit__"; +static const char __pyx_k_self_bvh_closest_indexes_self_pr[] = "self.bvh_closest_indexes,self.prev_verts,self.tmp_verts cannot be converted to a Python object for pickling"; +static const char __pyx_k_self_centroids_self_face_normals[] = "self.centroids,self.face_normals,self.triangles,self.vert_normals,self.verts cannot be converted to a Python object for pickling"; +static const char __pyx_k_vec_data_must_have_the_same_numb[] = "vec_data must have the same number of elements as engine verts times 3"; +static PyObject *__pyx_n_s_BVH; +static PyObject *__pyx_n_u_INSIDE; +static PyObject *__pyx_n_s_IndexError; +static PyObject *__pyx_kp_u_Invalid_or_empty_mesh; +static PyObject *__pyx_n_s_KeyError; +static PyObject *__pyx_n_s_LinkProbe; +static PyObject *__pyx_n_s_LinkProbe___iter; +static PyObject *__pyx_n_s_MaskContextManager; +static PyObject *__pyx_n_s_MemoryError; +static PyObject *__pyx_n_s_Mesh; +static PyObject *__pyx_kp_u_No_bvh_avaliable; +static PyObject *__pyx_n_u_OUTSIDE; +static PyObject *__pyx_kp_u_Oops_Softwrap2_memory_leak_dete; +static PyObject *__pyx_n_s_OverflowError; +static PyObject *__pyx_n_s_QuaternarySmoothingLinks; +static PyObject *__pyx_n_s_RuntimeError; +static PyObject *__pyx_n_u_SURFACE; +static PyObject *__pyx_n_s_SpringEngine; +static PyObject *__pyx_n_s_SpringEngineMask; +static PyObject *__pyx_n_s_SpringEnginePin; +static PyObject *__pyx_n_s_SpringEnginePin___iter; +static PyObject *__pyx_n_s_SpringLinks; +static PyObject *__pyx_n_s_SymmetryMap; +static PyObject *__pyx_n_s_TernarySmoothingLinks; +static PyObject *__pyx_n_s_TypeError; +static PyObject *__pyx_n_s_ValueError; +static PyObject *__pyx_kp_u__2; +static PyObject *__pyx_n_s_append; +static PyObject *__pyx_n_s_args; +static PyObject *__pyx_n_s_atexit; +static PyObject *__pyx_n_s_bvh; +static PyObject *__pyx_n_s_cline_in_traceback; +static PyObject *__pyx_n_s_close; +static PyObject *__pyx_n_s_collect; +static PyObject *__pyx_kp_u_core2_pyx; +static PyObject *__pyx_kp_s_core_core2_pyx; +static PyObject *__pyx_n_s_create_mask; +static PyObject *__pyx_n_s_create_quaternary_links; +static PyObject *__pyx_n_s_create_spring_group; +static PyObject *__pyx_n_s_create_symmetry_map; +static PyObject *__pyx_n_s_create_ternary_links; +static PyObject *__pyx_n_s_cycle_quality; +static PyObject *__pyx_n_s_deform_restore; +static PyObject *__pyx_n_s_deform_update; +static PyObject *__pyx_n_s_engine; +static PyObject *__pyx_n_s_enumerate; +static PyObject *__pyx_n_s_factor; +static PyObject *__pyx_n_s_gc; +static PyObject *__pyx_n_s_genexpr; +static PyObject *__pyx_n_s_getitem___locals_genexpr; +static PyObject *__pyx_n_s_getitem___locals_iter_ring; +static PyObject *__pyx_n_s_getstate; +static PyObject *__pyx_n_s_hex; +static PyObject *__pyx_n_s_i; +static PyObject *__pyx_n_s_idx; +static PyObject *__pyx_n_s_import; +static PyObject *__pyx_n_s_index; +static PyObject *__pyx_n_s_indexes; +static PyObject *__pyx_kp_u_indexes_array_is_not_the_same_si; +static PyObject *__pyx_kp_u_invalid_start_index; +static PyObject *__pyx_n_s_invert; +static PyObject *__pyx_n_s_items; +static PyObject *__pyx_n_s_iter; +static PyObject *__pyx_n_s_iter_ring; +static PyObject *__pyx_n_s_kinetic_step; +static PyObject *__pyx_n_s_leak_check; +static PyObject *__pyx_n_s_lengths_update; +static PyObject *__pyx_n_s_line; +static PyObject *__pyx_n_s_links; +static PyObject *__pyx_kp_u_list_too_small; +static PyObject *__pyx_n_s_load; +static PyObject *__pyx_n_s_locations; +static PyObject *__pyx_n_s_m; +static PyObject *__pyx_n_s_main; +static PyObject *__pyx_n_s_mask; +static PyObject *__pyx_kp_u_mask_must_have_the_same_number_o; +static PyObject *__pyx_n_s_masked_store; +static PyObject *__pyx_n_s_max_deform; +static PyObject *__pyx_n_s_max_ratio; +static PyObject *__pyx_n_s_mesh; +static PyObject *__pyx_n_s_min_deform; +static PyObject *__pyx_n_s_n_rings; +static PyObject *__pyx_n_s_name; +static PyObject *__pyx_kp_s_no_default___reduce___due_to_non; +static PyObject *__pyx_n_s_print; +static PyObject *__pyx_kp_u_ptr; +static PyObject *__pyx_n_s_ptr_2; +static PyObject *__pyx_n_s_pyx_vtable; +static PyObject *__pyx_n_s_random_verts; +static PyObject *__pyx_n_s_range; +static PyObject *__pyx_n_s_reduce; +static PyObject *__pyx_n_s_reduce_cython; +static PyObject *__pyx_n_s_reduce_ex; +static PyObject *__pyx_n_s_register; +static PyObject *__pyx_n_s_scale; +static PyObject *__pyx_n_s_seed; +static PyObject *__pyx_kp_s_self_bvh_closest_indexes_self_pr; +static PyObject *__pyx_kp_s_self_centroids_self_face_normals; +static PyObject *__pyx_n_s_send; +static PyObject *__pyx_n_s_set; +static PyObject *__pyx_n_s_set_bvh; +static PyObject *__pyx_n_s_set_force; +static PyObject *__pyx_n_s_setstate; +static PyObject *__pyx_n_s_setstate_cython; +static PyObject *__pyx_n_s_size; +static PyObject *__pyx_n_s_smooth; +static PyObject *__pyx_n_s_snapping_mode; +static PyObject *__pyx_n_s_soft_spring_force; +static PyObject *__pyx_n_s_softwrap_core2; +static PyObject *__pyx_n_s_springs; +static PyObject *__pyx_n_s_start_index; +static PyObject *__pyx_n_s_stiff_spring_force; +static PyObject *__pyx_n_s_store; +static PyObject *__pyx_n_s_test; +static PyObject *__pyx_n_s_throw; +static PyObject *__pyx_n_s_traceback; +static PyObject *__pyx_n_s_triangles; +static PyObject *__pyx_n_s_type; +static PyObject *__pyx_n_s_update_mesh_normals; +static PyObject *__pyx_n_s_value; +static PyObject *__pyx_kp_u_vec_data_must_have_the_same_numb; +static PyObject *__pyx_n_s_verts; +static PyObject *__pyx_n_s_x; +static PyObject *__pyx_n_s_y; +static PyObject *__pyx_n_s_z; +static PyObject *__pyx_pf_14softwrap_core2_leak_check(CYTHON_UNUSED PyObject *__pyx_self); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_2index_check(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_idx, int __pyx_v_size); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_4Mesh_get_vert_normals(struct __pyx_obj_14softwrap_core2_Mesh *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_4Mesh_2get_face_normals(struct __pyx_obj_14softwrap_core2_Mesh *__pyx_v_self); /* proto */ +static int __pyx_pf_14softwrap_core2_4Mesh_4__init__(struct __pyx_obj_14softwrap_core2_Mesh *__pyx_v_self, PyObject *__pyx_v_verts, PyObject *__pyx_v_triangles); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_4Mesh_6update_face_normals(struct __pyx_obj_14softwrap_core2_Mesh *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_4Mesh_8update_vert_normals(struct __pyx_obj_14softwrap_core2_Mesh *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_4Mesh_10update_centroids(struct __pyx_obj_14softwrap_core2_Mesh *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_4Mesh_12closest_vert(struct __pyx_obj_14softwrap_core2_Mesh *__pyx_v_self, PyObject *__pyx_v_pos); /* proto */ +static void __pyx_pf_14softwrap_core2_4Mesh_14__dealloc__(struct __pyx_obj_14softwrap_core2_Mesh *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_4Mesh_16__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_14softwrap_core2_Mesh *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_4Mesh_18__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_14softwrap_core2_Mesh *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */ +static int __pyx_pf_14softwrap_core2_3BVH___cinit__(struct __pyx_obj_14softwrap_core2_BVH *__pyx_v_self, struct __pyx_obj_14softwrap_core2_Mesh *__pyx_v_mesh); /* proto */ +static void __pyx_pf_14softwrap_core2_3BVH_2__dealloc__(struct __pyx_obj_14softwrap_core2_BVH *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_3BVH_4find_nearest(struct __pyx_obj_14softwrap_core2_BVH *__pyx_v_self, PyObject *__pyx_v__p); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_3BVH_6__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_14softwrap_core2_BVH *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_3BVH_8__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_14softwrap_core2_BVH *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */ +static int __pyx_pf_14softwrap_core2_9LinkProbe___cinit__(struct __pyx_obj_14softwrap_core2_LinkProbe *__pyx_v_self, struct __pyx_obj_14softwrap_core2_SpringLinks *__pyx_v_springs, int __pyx_v_index); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_9LinkProbe_2__getitem__(struct __pyx_obj_14softwrap_core2_LinkProbe *__pyx_v_self, int __pyx_v_link_index); /* proto */ +static Py_ssize_t __pyx_pf_14softwrap_core2_9LinkProbe_4__len__(struct __pyx_obj_14softwrap_core2_LinkProbe *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_9LinkProbe_6__iter__(struct __pyx_obj_14softwrap_core2_LinkProbe *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_9LinkProbe_10avg_radius___get__(struct __pyx_obj_14softwrap_core2_LinkProbe *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_9LinkProbe_7springs___get__(struct __pyx_obj_14softwrap_core2_LinkProbe *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_9LinkProbe_5index___get__(struct __pyx_obj_14softwrap_core2_LinkProbe *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_9LinkProbe_9__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_14softwrap_core2_LinkProbe *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_9LinkProbe_11__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_14softwrap_core2_LinkProbe *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */ +static int __pyx_pf_14softwrap_core2_11SpringLinks___cinit__(struct __pyx_obj_14softwrap_core2_SpringLinks *__pyx_v_self, struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_engine, PyObject *__pyx_v_links); /* proto */ +static void __pyx_pf_14softwrap_core2_11SpringLinks_2__dealloc__(struct __pyx_obj_14softwrap_core2_SpringLinks *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_11SpringLinks_4__getitem__(struct __pyx_obj_14softwrap_core2_SpringLinks *__pyx_v_self, int __pyx_v_key); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_11SpringLinks_6lengths_update(struct __pyx_obj_14softwrap_core2_SpringLinks *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_11SpringLinks_8smooth(struct __pyx_obj_14softwrap_core2_SpringLinks *__pyx_v_self, float __pyx_v_factor); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_11SpringLinks_10soft_spring_force(struct __pyx_obj_14softwrap_core2_SpringLinks *__pyx_v_self, float __pyx_v_factor, float __pyx_v_deform_update, float __pyx_v_deform_restore, float __pyx_v_min_deform, float __pyx_v_max_deform); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_11SpringLinks_12stiff_spring_force(struct __pyx_obj_14softwrap_core2_SpringLinks *__pyx_v_self, float __pyx_v_factor); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_11SpringLinks_6engine___get__(struct __pyx_obj_14softwrap_core2_SpringLinks *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_11SpringLinks_14__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_14softwrap_core2_SpringLinks *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_11SpringLinks_16__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_14softwrap_core2_SpringLinks *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */ +static int __pyx_pf_14softwrap_core2_21TernarySmoothingLinks___cinit__(struct __pyx_obj_14softwrap_core2_TernarySmoothingLinks *__pyx_v_self, struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_engine, PyObject *__pyx_v_links); /* proto */ +static void __pyx_pf_14softwrap_core2_21TernarySmoothingLinks_2__dealloc__(struct __pyx_obj_14softwrap_core2_TernarySmoothingLinks *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_21TernarySmoothingLinks_4displacements_update(struct __pyx_obj_14softwrap_core2_TernarySmoothingLinks *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_21TernarySmoothingLinks_6displacement_force(struct __pyx_obj_14softwrap_core2_TernarySmoothingLinks *__pyx_v_self, float __pyx_v_factor); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_21TernarySmoothingLinks_6engine___get__(struct __pyx_obj_14softwrap_core2_TernarySmoothingLinks *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_21TernarySmoothingLinks_8__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_14softwrap_core2_TernarySmoothingLinks *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_21TernarySmoothingLinks_10__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_14softwrap_core2_TernarySmoothingLinks *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */ +static int __pyx_pf_14softwrap_core2_24QuaternarySmoothingLinks___cinit__(struct __pyx_obj_14softwrap_core2_QuaternarySmoothingLinks *__pyx_v_self, struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_engine, PyObject *__pyx_v_links); /* proto */ +static void __pyx_pf_14softwrap_core2_24QuaternarySmoothingLinks_2__dealloc__(struct __pyx_obj_14softwrap_core2_QuaternarySmoothingLinks *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_24QuaternarySmoothingLinks_4lengths_update(struct __pyx_obj_14softwrap_core2_QuaternarySmoothingLinks *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_24QuaternarySmoothingLinks_6smooth(struct __pyx_obj_14softwrap_core2_QuaternarySmoothingLinks *__pyx_v_self, float __pyx_v_factor, float __pyx_v_max_ratio); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_24QuaternarySmoothingLinks_6engine___get__(struct __pyx_obj_14softwrap_core2_QuaternarySmoothingLinks *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_24QuaternarySmoothingLinks_7n_links___get__(struct __pyx_obj_14softwrap_core2_QuaternarySmoothingLinks *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_24QuaternarySmoothingLinks_8__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_14softwrap_core2_QuaternarySmoothingLinks *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_24QuaternarySmoothingLinks_10__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_14softwrap_core2_QuaternarySmoothingLinks *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */ +static int __pyx_pf_14softwrap_core2_15SpringEnginePin___cinit__(struct __pyx_obj_14softwrap_core2_SpringEnginePin *__pyx_v_self, struct __pyx_obj_14softwrap_core2_SpringLinks *__pyx_v_links, int __pyx_v_start_index, int __pyx_v_n_rings); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_15SpringEnginePin_11__getitem___iter_ring(PyObject *__pyx_self); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_15SpringEnginePin_2__getitem__(struct __pyx_obj_14softwrap_core2_SpringEnginePin *__pyx_v_self, int __pyx_v_index); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_15SpringEnginePin_4__iter__(struct __pyx_obj_14softwrap_core2_SpringEnginePin *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_15SpringEnginePin_7move(struct __pyx_obj_14softwrap_core2_SpringEnginePin *__pyx_v_self, float __pyx_v_x, float __pyx_v_y, float __pyx_v_z, float __pyx_v_scale); /* proto */ +static void __pyx_pf_14softwrap_core2_15SpringEnginePin_9__dealloc__(struct __pyx_obj_14softwrap_core2_SpringEnginePin *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_15SpringEnginePin_6engine___get__(struct __pyx_obj_14softwrap_core2_SpringEnginePin *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_15SpringEnginePin_7n_rings___get__(struct __pyx_obj_14softwrap_core2_SpringEnginePin *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_15SpringEnginePin_11start_index___get__(struct __pyx_obj_14softwrap_core2_SpringEnginePin *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_15SpringEnginePin_11__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_14softwrap_core2_SpringEnginePin *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_15SpringEnginePin_13__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_14softwrap_core2_SpringEnginePin *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */ +static int __pyx_pf_14softwrap_core2_19_MaskContextManager___cinit__(struct __pyx_obj_14softwrap_core2__MaskContextManager *__pyx_v_self, struct __pyx_obj_14softwrap_core2_SpringEngineMask *__pyx_v_mask, float __pyx_v_factor, int __pyx_v_invert); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_19_MaskContextManager_2__enter__(struct __pyx_obj_14softwrap_core2__MaskContextManager *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_19_MaskContextManager_4__exit__(struct __pyx_obj_14softwrap_core2__MaskContextManager *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_type, CYTHON_UNUSED PyObject *__pyx_v_value, CYTHON_UNUSED PyObject *__pyx_v_traceback); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_19_MaskContextManager_6__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_14softwrap_core2__MaskContextManager *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_19_MaskContextManager_8__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_14softwrap_core2__MaskContextManager *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */ +static int __pyx_pf_14softwrap_core2_16SpringEngineMask___cinit__(struct __pyx_obj_14softwrap_core2_SpringEngineMask *__pyx_v_self, struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_engine, PyObject *__pyx_v_mask); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_16SpringEngineMask_2__getitem__(struct __pyx_obj_14softwrap_core2_SpringEngineMask *__pyx_v_self, int __pyx_v_index); /* proto */ +static int __pyx_pf_14softwrap_core2_16SpringEngineMask_4__setitem__(struct __pyx_obj_14softwrap_core2_SpringEngineMask *__pyx_v_self, int __pyx_v_index, PyObject *__pyx_v_value); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_16SpringEngineMask_6set_force(struct __pyx_obj_14softwrap_core2_SpringEngineMask *__pyx_v_self, float __pyx_v_x, float __pyx_v_y, float __pyx_v_z); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_16SpringEngineMask_8load(struct __pyx_obj_14softwrap_core2_SpringEngineMask *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_16SpringEngineMask_10store(struct __pyx_obj_14softwrap_core2_SpringEngineMask *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_16SpringEngineMask_12masked_store(struct __pyx_obj_14softwrap_core2_SpringEngineMask *__pyx_v_self, float __pyx_v_factor, int __pyx_v_invert); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_16SpringEngineMask_14set(struct __pyx_obj_14softwrap_core2_SpringEngineMask *__pyx_v_self, PyObject *__pyx_v_vec_data); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_16SpringEngineMask_16masked_context(struct __pyx_obj_14softwrap_core2_SpringEngineMask *__pyx_v_self, float __pyx_v_factor, int __pyx_v_invert); /* proto */ +static void __pyx_pf_14softwrap_core2_16SpringEngineMask_18__dealloc__(struct __pyx_obj_14softwrap_core2_SpringEngineMask *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_16SpringEngineMask_20__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_14softwrap_core2_SpringEngineMask *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_16SpringEngineMask_22__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_14softwrap_core2_SpringEngineMask *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */ +static int __pyx_pf_14softwrap_core2_11SymmetryMap___cinit__(struct __pyx_obj_14softwrap_core2_SymmetryMap *__pyx_v_self, struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_engine); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_11SymmetryMap_11__getitem___genexpr(PyObject *__pyx_self); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_11SymmetryMap_2__getitem__(struct __pyx_obj_14softwrap_core2_SymmetryMap *__pyx_v_self, int __pyx_v_index); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_11SymmetryMap_4mirror(struct __pyx_obj_14softwrap_core2_SymmetryMap *__pyx_v_self, int __pyx_v_x, int __pyx_v_y, int __pyx_v_z); /* proto */ +static void __pyx_pf_14softwrap_core2_11SymmetryMap_6__dealloc__(struct __pyx_obj_14softwrap_core2_SymmetryMap *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_11SymmetryMap_5error___get__(struct __pyx_obj_14softwrap_core2_SymmetryMap *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_11SymmetryMap_8__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_14softwrap_core2_SymmetryMap *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_11SymmetryMap_10__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_14softwrap_core2_SymmetryMap *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */ +static int __pyx_pf_14softwrap_core2_12SpringEngine___init__(struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_self, struct __pyx_obj_14softwrap_core2_Mesh *__pyx_v_m, struct __pyx_obj_14softwrap_core2_BVH *__pyx_v_bvh); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_12SpringEngine_2set_bvh(struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_self, struct __pyx_obj_14softwrap_core2_BVH *__pyx_v_bvh); /* proto */ +static void __pyx_pf_14softwrap_core2_12SpringEngine_4__dealloc__(struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_self); /* proto */ +static Py_ssize_t __pyx_pf_14softwrap_core2_12SpringEngine_6__len__(struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_12SpringEngine_8__getitem__(struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_self, int __pyx_v_key); /* proto */ +static int __pyx_pf_14softwrap_core2_12SpringEngine_10__setitem__(struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_self, int __pyx_v_key, float __pyx_v_v); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_12SpringEngine_12from_list(struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_self, PyObject *__pyx_v_items); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_12SpringEngine_14set_verts(struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_self, PyObject *__pyx_v_indexes, PyObject *__pyx_v_locations); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_12SpringEngine_16get_verts(struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_self, PyObject *__pyx_v_indexes); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_12SpringEngine_18move_verts(struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_self, PyObject *__pyx_v_indexes, float __pyx_v_x, float __pyx_v_y, float __pyx_v_z); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_12SpringEngine_20snap_to_bvh(struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_self, float __pyx_v_factor, int __pyx_v_cycle_quality, PyObject *__pyx_v_snapping_mode); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_12SpringEngine_22create_spring_group(struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_self, PyObject *__pyx_v_links); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_12SpringEngine_24create_symmetry_map(struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_12SpringEngine_26create_ternary_links(struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_self, PyObject *__pyx_v_links); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_12SpringEngine_28create_quaternary_links(struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_self, PyObject *__pyx_v_links); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_12SpringEngine_30create_mask(struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_self, PyObject *__pyx_v_mask); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_12SpringEngine_32random_verts(struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_self, float __pyx_v_factor, unsigned int __pyx_v_seed); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_12SpringEngine_34kinetic_step(struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_self, float __pyx_v_damping); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_12SpringEngine_36update_mesh_normals(struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_self, float __pyx_v_factor); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_12SpringEngine_38__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_14softwrap_core2_12SpringEngine_40__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */ +static PyObject *__pyx_tp_new_14softwrap_core2_Mesh(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new_14softwrap_core2_BVH(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new_14softwrap_core2_LinkProbe(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new_14softwrap_core2_SpringLinks(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new_14softwrap_core2_TernarySmoothingLinks(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new_14softwrap_core2_QuaternarySmoothingLinks(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new_14softwrap_core2_SpringEnginePin(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new_14softwrap_core2__MaskContextManager(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new_14softwrap_core2_SpringEngineMask(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new_14softwrap_core2_SymmetryMap(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new_14softwrap_core2_SpringEngine(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new_14softwrap_core2___pyx_scope_struct____iter__(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new_14softwrap_core2___pyx_scope_struct_1___getitem__(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new_14softwrap_core2___pyx_scope_struct_2_iter_ring(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new_14softwrap_core2___pyx_scope_struct_3___iter__(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new_14softwrap_core2___pyx_scope_struct_4___getitem__(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new_14softwrap_core2___pyx_scope_struct_5_genexpr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_float_0_0; +static PyObject *__pyx_int_1; +static PyObject *__pyx_int_2; +static PyObject *__pyx_int_4; +static PyObject *__pyx_tuple_; +static PyObject *__pyx_tuple__3; +static PyObject *__pyx_tuple__4; +static PyObject *__pyx_tuple__5; +static PyObject *__pyx_tuple__6; +static PyObject *__pyx_tuple__7; +static PyObject *__pyx_tuple__8; +static PyObject *__pyx_tuple__9; +static PyObject *__pyx_tuple__10; +static PyObject *__pyx_tuple__11; +static PyObject *__pyx_tuple__12; +static PyObject *__pyx_tuple__13; +static PyObject *__pyx_tuple__14; +static PyObject *__pyx_tuple__15; +static PyObject *__pyx_tuple__16; +static PyObject *__pyx_tuple__17; +static PyObject *__pyx_tuple__18; +static PyObject *__pyx_tuple__20; +static PyObject *__pyx_tuple__21; +static PyObject *__pyx_tuple__22; +static PyObject *__pyx_tuple__23; +static PyObject *__pyx_tuple__24; +static PyObject *__pyx_tuple__25; +static PyObject *__pyx_tuple__26; +static PyObject *__pyx_tuple__27; +static PyObject *__pyx_tuple__28; +static PyObject *__pyx_tuple__29; +static PyObject *__pyx_tuple__30; +static PyObject *__pyx_tuple__31; +static PyObject *__pyx_tuple__32; +static PyObject *__pyx_tuple__33; +static PyObject *__pyx_tuple__34; +static PyObject *__pyx_tuple__35; +static PyObject *__pyx_codeobj__19; +static PyObject *__pyx_codeobj__36; +/* Late includes */ + +/* "core/core2.pyx":265 + * int __LINE__ + * + * cdef void* maelloc(size_t size, int id) except NULL: # <<<<<<<<<<<<<< + * cdef void* ptr = malloc(size) + * if ptr == NULL: + */ + + +# line 265 "core/core2.pyx" +static void *__pyx_f_14softwrap_core2_maelloc(size_t __pyx_v_size, int __pyx_v_id) { + +# line 265 "core/core2.pyx" + void *__pyx_v_ptr; + +# line 265 "core/core2.pyx" + void *__pyx_r; + +# line 265 "core/core2.pyx" + __Pyx_RefNannyDeclarations + +# line 265 "core/core2.pyx" + int __pyx_t_1; + +# line 265 "core/core2.pyx" + PyObject *__pyx_t_2 = NULL; + +# line 265 "core/core2.pyx" + PyObject *__pyx_t_3 = NULL; + +# line 265 "core/core2.pyx" + int __pyx_lineno = 0; + +# line 265 "core/core2.pyx" + const char *__pyx_filename = NULL; + +# line 265 "core/core2.pyx" + int __pyx_clineno = 0; + +# line 265 "core/core2.pyx" + __Pyx_RefNannySetupContext("maelloc", 0); + + /* "core/core2.pyx":266 + * + * cdef void* maelloc(size_t size, int id) except NULL: + * cdef void* ptr = malloc(size) # <<<<<<<<<<<<<< + * if ptr == NULL: + * raise MemoryError + */ + +# line 266 "core/core2.pyx" + __pyx_v_ptr = malloc(__pyx_v_size); + + /* "core/core2.pyx":267 + * cdef void* maelloc(size_t size, int id) except NULL: + * cdef void* ptr = malloc(size) + * if ptr == NULL: # <<<<<<<<<<<<<< + * raise MemoryError + * not_freed_pointers[ptr] = id + */ + +# line 267 "core/core2.pyx" + __pyx_t_1 = ((__pyx_v_ptr == NULL) != 0); + +# line 267 "core/core2.pyx" + if (unlikely(__pyx_t_1)) { + + /* "core/core2.pyx":268 + * cdef void* ptr = malloc(size) + * if ptr == NULL: + * raise MemoryError # <<<<<<<<<<<<<< + * not_freed_pointers[ptr] = id + * return ptr + */ + +# line 268 "core/core2.pyx" + PyErr_NoMemory(); __PYX_ERR(0, 268, __pyx_L1_error) + + /* "core/core2.pyx":267 + * cdef void* maelloc(size_t size, int id) except NULL: + * cdef void* ptr = malloc(size) + * if ptr == NULL: # <<<<<<<<<<<<<< + * raise MemoryError + * not_freed_pointers[ptr] = id + */ + +# line 267 "core/core2.pyx" + } + + /* "core/core2.pyx":269 + * if ptr == NULL: + * raise MemoryError + * not_freed_pointers[ptr] = id # <<<<<<<<<<<<<< + * return ptr + * + */ + +# line 269 "core/core2.pyx" + __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_id); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 269, __pyx_L1_error) + +# line 269 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_2); + +# line 269 "core/core2.pyx" + if (unlikely(__pyx_v_14softwrap_core2_not_freed_pointers == Py_None)) { + +# line 269 "core/core2.pyx" + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + +# line 269 "core/core2.pyx" + __PYX_ERR(0, 269, __pyx_L1_error) + +# line 269 "core/core2.pyx" + } + +# line 269 "core/core2.pyx" + __pyx_t_3 = __Pyx_PyInt_FromSize_t(((uintptr_t)__pyx_v_ptr)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 269, __pyx_L1_error) + +# line 269 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_3); + +# line 269 "core/core2.pyx" + if (unlikely(PyDict_SetItem(__pyx_v_14softwrap_core2_not_freed_pointers, __pyx_t_3, __pyx_t_2) < 0)) __PYX_ERR(0, 269, __pyx_L1_error) + +# line 269 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + +# line 269 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "core/core2.pyx":270 + * raise MemoryError + * not_freed_pointers[ptr] = id + * return ptr # <<<<<<<<<<<<<< + * + * cdef void* caelloc(size_t n, size_t size, int id) except NULL: + */ + +# line 270 "core/core2.pyx" + __pyx_r = __pyx_v_ptr; + +# line 270 "core/core2.pyx" + goto __pyx_L0; + + /* "core/core2.pyx":265 + * int __LINE__ + * + * cdef void* maelloc(size_t size, int id) except NULL: # <<<<<<<<<<<<<< + * cdef void* ptr = malloc(size) + * if ptr == NULL: + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("softwrap_core2.maelloc", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":272 + * return ptr + * + * cdef void* caelloc(size_t n, size_t size, int id) except NULL: # <<<<<<<<<<<<<< + * cdef void* ptr = calloc(n, size) + * if ptr == NULL: + */ + + +# line 272 "core/core2.pyx" +static void *__pyx_f_14softwrap_core2_caelloc(size_t __pyx_v_n, size_t __pyx_v_size, int __pyx_v_id) { + +# line 272 "core/core2.pyx" + void *__pyx_v_ptr; + +# line 272 "core/core2.pyx" + void *__pyx_r; + +# line 272 "core/core2.pyx" + __Pyx_RefNannyDeclarations + +# line 272 "core/core2.pyx" + int __pyx_t_1; + +# line 272 "core/core2.pyx" + PyObject *__pyx_t_2 = NULL; + +# line 272 "core/core2.pyx" + PyObject *__pyx_t_3 = NULL; + +# line 272 "core/core2.pyx" + int __pyx_lineno = 0; + +# line 272 "core/core2.pyx" + const char *__pyx_filename = NULL; + +# line 272 "core/core2.pyx" + int __pyx_clineno = 0; + +# line 272 "core/core2.pyx" + __Pyx_RefNannySetupContext("caelloc", 0); + + /* "core/core2.pyx":273 + * + * cdef void* caelloc(size_t n, size_t size, int id) except NULL: + * cdef void* ptr = calloc(n, size) # <<<<<<<<<<<<<< + * if ptr == NULL: + * raise MemoryError + */ + +# line 273 "core/core2.pyx" + __pyx_v_ptr = calloc(__pyx_v_n, __pyx_v_size); + + /* "core/core2.pyx":274 + * cdef void* caelloc(size_t n, size_t size, int id) except NULL: + * cdef void* ptr = calloc(n, size) + * if ptr == NULL: # <<<<<<<<<<<<<< + * raise MemoryError + * not_freed_pointers[ptr] = id + */ + +# line 274 "core/core2.pyx" + __pyx_t_1 = ((__pyx_v_ptr == NULL) != 0); + +# line 274 "core/core2.pyx" + if (unlikely(__pyx_t_1)) { + + /* "core/core2.pyx":275 + * cdef void* ptr = calloc(n, size) + * if ptr == NULL: + * raise MemoryError # <<<<<<<<<<<<<< + * not_freed_pointers[ptr] = id + * return ptr + */ + +# line 275 "core/core2.pyx" + PyErr_NoMemory(); __PYX_ERR(0, 275, __pyx_L1_error) + + /* "core/core2.pyx":274 + * cdef void* caelloc(size_t n, size_t size, int id) except NULL: + * cdef void* ptr = calloc(n, size) + * if ptr == NULL: # <<<<<<<<<<<<<< + * raise MemoryError + * not_freed_pointers[ptr] = id + */ + +# line 274 "core/core2.pyx" + } + + /* "core/core2.pyx":276 + * if ptr == NULL: + * raise MemoryError + * not_freed_pointers[ptr] = id # <<<<<<<<<<<<<< + * return ptr + * + */ + +# line 276 "core/core2.pyx" + __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_id); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 276, __pyx_L1_error) + +# line 276 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_2); + +# line 276 "core/core2.pyx" + if (unlikely(__pyx_v_14softwrap_core2_not_freed_pointers == Py_None)) { + +# line 276 "core/core2.pyx" + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + +# line 276 "core/core2.pyx" + __PYX_ERR(0, 276, __pyx_L1_error) + +# line 276 "core/core2.pyx" + } + +# line 276 "core/core2.pyx" + __pyx_t_3 = __Pyx_PyInt_FromSize_t(((uintptr_t)__pyx_v_ptr)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 276, __pyx_L1_error) + +# line 276 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_3); + +# line 276 "core/core2.pyx" + if (unlikely(PyDict_SetItem(__pyx_v_14softwrap_core2_not_freed_pointers, __pyx_t_3, __pyx_t_2) < 0)) __PYX_ERR(0, 276, __pyx_L1_error) + +# line 276 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + +# line 276 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "core/core2.pyx":277 + * raise MemoryError + * not_freed_pointers[ptr] = id + * return ptr # <<<<<<<<<<<<<< + * + * cdef void fraeee(void* ptr): + */ + +# line 277 "core/core2.pyx" + __pyx_r = __pyx_v_ptr; + +# line 277 "core/core2.pyx" + goto __pyx_L0; + + /* "core/core2.pyx":272 + * return ptr + * + * cdef void* caelloc(size_t n, size_t size, int id) except NULL: # <<<<<<<<<<<<<< + * cdef void* ptr = calloc(n, size) + * if ptr == NULL: + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("softwrap_core2.caelloc", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":279 + * return ptr + * + * cdef void fraeee(void* ptr): # <<<<<<<<<<<<<< + * if ptr is not NULL: + * del not_freed_pointers[ ptr] + */ + + +# line 279 "core/core2.pyx" +static void __pyx_f_14softwrap_core2_fraeee(void *__pyx_v_ptr) { + +# line 279 "core/core2.pyx" + __Pyx_RefNannyDeclarations + +# line 279 "core/core2.pyx" + int __pyx_t_1; + +# line 279 "core/core2.pyx" + PyObject *__pyx_t_2 = NULL; + +# line 279 "core/core2.pyx" + int __pyx_lineno = 0; + +# line 279 "core/core2.pyx" + const char *__pyx_filename = NULL; + +# line 279 "core/core2.pyx" + int __pyx_clineno = 0; + +# line 279 "core/core2.pyx" + __Pyx_RefNannySetupContext("fraeee", 0); + + /* "core/core2.pyx":280 + * + * cdef void fraeee(void* ptr): + * if ptr is not NULL: # <<<<<<<<<<<<<< + * del not_freed_pointers[ ptr] + * free(ptr) + */ + +# line 280 "core/core2.pyx" + __pyx_t_1 = ((__pyx_v_ptr != NULL) != 0); + +# line 280 "core/core2.pyx" + if (__pyx_t_1) { + + /* "core/core2.pyx":281 + * cdef void fraeee(void* ptr): + * if ptr is not NULL: + * del not_freed_pointers[ ptr] # <<<<<<<<<<<<<< + * free(ptr) + * + */ + +# line 281 "core/core2.pyx" + if (unlikely(__pyx_v_14softwrap_core2_not_freed_pointers == Py_None)) { + +# line 281 "core/core2.pyx" + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + +# line 281 "core/core2.pyx" + __PYX_ERR(0, 281, __pyx_L1_error) + +# line 281 "core/core2.pyx" + } + +# line 281 "core/core2.pyx" + __pyx_t_2 = __Pyx_PyInt_FromSize_t(((uintptr_t)__pyx_v_ptr)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 281, __pyx_L1_error) + +# line 281 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_2); + +# line 281 "core/core2.pyx" + if (unlikely(PyDict_DelItem(__pyx_v_14softwrap_core2_not_freed_pointers, __pyx_t_2) < 0)) __PYX_ERR(0, 281, __pyx_L1_error) + +# line 281 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "core/core2.pyx":280 + * + * cdef void fraeee(void* ptr): + * if ptr is not NULL: # <<<<<<<<<<<<<< + * del not_freed_pointers[ ptr] + * free(ptr) + */ + +# line 280 "core/core2.pyx" + } + + /* "core/core2.pyx":282 + * if ptr is not NULL: + * del not_freed_pointers[ ptr] + * free(ptr) # <<<<<<<<<<<<<< + * + * + */ + +# line 282 "core/core2.pyx" + free(__pyx_v_ptr); + + /* "core/core2.pyx":279 + * return ptr + * + * cdef void fraeee(void* ptr): # <<<<<<<<<<<<<< + * if ptr is not NULL: + * del not_freed_pointers[ ptr] + */ + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_WriteUnraisable("softwrap_core2.fraeee", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); + __pyx_L0:; + __Pyx_RefNannyFinishContext(); +} + +/* "core/core2.pyx":285 + * + * + * def leak_check(): # <<<<<<<<<<<<<< + * import gc + * gc.collect() + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_1leak_check(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyMethodDef __pyx_mdef_14softwrap_core2_1leak_check = {"leak_check", (PyCFunction)__pyx_pw_14softwrap_core2_1leak_check, METH_NOARGS, 0}; +static PyObject *__pyx_pw_14softwrap_core2_1leak_check(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("leak_check (wrapper)", 0); + __pyx_r = __pyx_pf_14softwrap_core2_leak_check(__pyx_self); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_leak_check(CYTHON_UNUSED PyObject *__pyx_self) { + PyObject *__pyx_v_gc = NULL; + PyObject *__pyx_v_ptr = NULL; + PyObject *__pyx_v_line = NULL; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_t_4; + Py_ssize_t __pyx_t_5; + Py_ssize_t __pyx_t_6; + int __pyx_t_7; + int __pyx_t_8; + Py_ssize_t __pyx_t_9; + Py_UCS4 __pyx_t_10; + PyObject *__pyx_t_11 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("leak_check", 0); + + /* "core/core2.pyx":286 + * + * def leak_check(): + * import gc # <<<<<<<<<<<<<< + * gc.collect() + * + */ + +# line 286 "core/core2.pyx" + __pyx_t_1 = __Pyx_Import(__pyx_n_s_gc, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 286, __pyx_L1_error) + +# line 286 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_1); + +# line 286 "core/core2.pyx" + __pyx_v_gc = __pyx_t_1; + +# line 286 "core/core2.pyx" + __pyx_t_1 = 0; + + /* "core/core2.pyx":287 + * def leak_check(): + * import gc + * gc.collect() # <<<<<<<<<<<<<< + * + * if not_freed_pointers: + */ + +# line 287 "core/core2.pyx" + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_gc, __pyx_n_s_collect); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 287, __pyx_L1_error) + +# line 287 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_2); + +# line 287 "core/core2.pyx" + __pyx_t_3 = NULL; + +# line 287 "core/core2.pyx" + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { + +# line 287 "core/core2.pyx" + __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); + +# line 287 "core/core2.pyx" + if (likely(__pyx_t_3)) { + +# line 287 "core/core2.pyx" + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); + +# line 287 "core/core2.pyx" + __Pyx_INCREF(__pyx_t_3); + +# line 287 "core/core2.pyx" + __Pyx_INCREF(function); + +# line 287 "core/core2.pyx" + __Pyx_DECREF_SET(__pyx_t_2, function); + +# line 287 "core/core2.pyx" + } + +# line 287 "core/core2.pyx" + } + +# line 287 "core/core2.pyx" + __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2); + +# line 287 "core/core2.pyx" + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + +# line 287 "core/core2.pyx" + if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 287, __pyx_L1_error) + +# line 287 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_1); + +# line 287 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + +# line 287 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "core/core2.pyx":289 + * gc.collect() + * + * if not_freed_pointers: # <<<<<<<<<<<<<< + * print('\n ------------ Oops Softwrap2 memory leak detected ------------ \n pointers not freed:') + * for ptr, line in not_freed_pointers.items(): + */ + +# line 289 "core/core2.pyx" + __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_14softwrap_core2_not_freed_pointers); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 289, __pyx_L1_error) + +# line 289 "core/core2.pyx" + if (__pyx_t_4) { + + /* "core/core2.pyx":290 + * + * if not_freed_pointers: + * print('\n ------------ Oops Softwrap2 memory leak detected ------------ \n pointers not freed:') # <<<<<<<<<<<<<< + * for ptr, line in not_freed_pointers.items(): + * print(f' ptr: {hex(ptr)}, core2.pyx:{line}') + */ + +# line 290 "core/core2.pyx" + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_print, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 290, __pyx_L1_error) + +# line 290 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_1); + +# line 290 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "core/core2.pyx":291 + * if not_freed_pointers: + * print('\n ------------ Oops Softwrap2 memory leak detected ------------ \n pointers not freed:') + * for ptr, line in not_freed_pointers.items(): # <<<<<<<<<<<<<< + * print(f' ptr: {hex(ptr)}, core2.pyx:{line}') + * print('\n -------------------------------------------------------------') + */ + +# line 291 "core/core2.pyx" + __pyx_t_5 = 0; + +# line 291 "core/core2.pyx" + if (unlikely(__pyx_v_14softwrap_core2_not_freed_pointers == Py_None)) { + +# line 291 "core/core2.pyx" + PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "items"); + +# line 291 "core/core2.pyx" + __PYX_ERR(0, 291, __pyx_L1_error) + +# line 291 "core/core2.pyx" + } + +# line 291 "core/core2.pyx" + __pyx_t_2 = __Pyx_dict_iterator(__pyx_v_14softwrap_core2_not_freed_pointers, 1, __pyx_n_s_items, (&__pyx_t_6), (&__pyx_t_7)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 291, __pyx_L1_error) + +# line 291 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_2); + +# line 291 "core/core2.pyx" + __Pyx_XDECREF(__pyx_t_1); + +# line 291 "core/core2.pyx" + __pyx_t_1 = __pyx_t_2; + +# line 291 "core/core2.pyx" + __pyx_t_2 = 0; + +# line 291 "core/core2.pyx" + while (1) { + +# line 291 "core/core2.pyx" + __pyx_t_8 = __Pyx_dict_iter_next(__pyx_t_1, __pyx_t_6, &__pyx_t_5, &__pyx_t_2, &__pyx_t_3, NULL, __pyx_t_7); + +# line 291 "core/core2.pyx" + if (unlikely(__pyx_t_8 == 0)) break; + +# line 291 "core/core2.pyx" + if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(0, 291, __pyx_L1_error) + +# line 291 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_2); + +# line 291 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_3); + +# line 291 "core/core2.pyx" + __Pyx_XDECREF_SET(__pyx_v_ptr, __pyx_t_2); + +# line 291 "core/core2.pyx" + __pyx_t_2 = 0; + +# line 291 "core/core2.pyx" + __Pyx_XDECREF_SET(__pyx_v_line, __pyx_t_3); + +# line 291 "core/core2.pyx" + __pyx_t_3 = 0; + + /* "core/core2.pyx":292 + * print('\n ------------ Oops Softwrap2 memory leak detected ------------ \n pointers not freed:') + * for ptr, line in not_freed_pointers.items(): + * print(f' ptr: {hex(ptr)}, core2.pyx:{line}') # <<<<<<<<<<<<<< + * print('\n -------------------------------------------------------------') + * + */ + +# line 292 "core/core2.pyx" + __pyx_t_3 = PyTuple_New(4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 292, __pyx_L1_error) + +# line 292 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_3); + +# line 292 "core/core2.pyx" + __pyx_t_9 = 0; + +# line 292 "core/core2.pyx" + __pyx_t_10 = 127; + +# line 292 "core/core2.pyx" + __Pyx_INCREF(__pyx_kp_u_ptr); + +# line 292 "core/core2.pyx" + __pyx_t_9 += 9; + +# line 292 "core/core2.pyx" + __Pyx_GIVEREF(__pyx_kp_u_ptr); + +# line 292 "core/core2.pyx" + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_kp_u_ptr); + +# line 292 "core/core2.pyx" + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_hex, __pyx_v_ptr); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 292, __pyx_L1_error) + +# line 292 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_2); + +# line 292 "core/core2.pyx" + __pyx_t_11 = __Pyx_PyObject_FormatSimple(__pyx_t_2, __pyx_empty_unicode); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 292, __pyx_L1_error) + +# line 292 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_11); + +# line 292 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + +# line 292 "core/core2.pyx" + __pyx_t_10 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_11) > __pyx_t_10) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_11) : __pyx_t_10; + +# line 292 "core/core2.pyx" + __pyx_t_9 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_11); + +# line 292 "core/core2.pyx" + __Pyx_GIVEREF(__pyx_t_11); + +# line 292 "core/core2.pyx" + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_11); + +# line 292 "core/core2.pyx" + __pyx_t_11 = 0; + +# line 292 "core/core2.pyx" + __Pyx_INCREF(__pyx_kp_u_core2_pyx); + +# line 292 "core/core2.pyx" + __pyx_t_9 += 12; + +# line 292 "core/core2.pyx" + __Pyx_GIVEREF(__pyx_kp_u_core2_pyx); + +# line 292 "core/core2.pyx" + PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_kp_u_core2_pyx); + +# line 292 "core/core2.pyx" + __pyx_t_11 = __Pyx_PyObject_FormatSimple(__pyx_v_line, __pyx_empty_unicode); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 292, __pyx_L1_error) + +# line 292 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_11); + +# line 292 "core/core2.pyx" + __pyx_t_10 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_11) > __pyx_t_10) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_11) : __pyx_t_10; + +# line 292 "core/core2.pyx" + __pyx_t_9 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_11); + +# line 292 "core/core2.pyx" + __Pyx_GIVEREF(__pyx_t_11); + +# line 292 "core/core2.pyx" + PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_t_11); + +# line 292 "core/core2.pyx" + __pyx_t_11 = 0; + +# line 292 "core/core2.pyx" + __pyx_t_11 = __Pyx_PyUnicode_Join(__pyx_t_3, 4, __pyx_t_9, __pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 292, __pyx_L1_error) + +# line 292 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_11); + +# line 292 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + +# line 292 "core/core2.pyx" + __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_print, __pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 292, __pyx_L1_error) + +# line 292 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_3); + +# line 292 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + +# line 292 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + +# line 292 "core/core2.pyx" + } + +# line 292 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "core/core2.pyx":293 + * for ptr, line in not_freed_pointers.items(): + * print(f' ptr: {hex(ptr)}, core2.pyx:{line}') + * print('\n -------------------------------------------------------------') # <<<<<<<<<<<<<< + * + * + */ + +# line 293 "core/core2.pyx" + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_print, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 293, __pyx_L1_error) + +# line 293 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_1); + +# line 293 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "core/core2.pyx":289 + * gc.collect() + * + * if not_freed_pointers: # <<<<<<<<<<<<<< + * print('\n ------------ Oops Softwrap2 memory leak detected ------------ \n pointers not freed:') + * for ptr, line in not_freed_pointers.items(): + */ + +# line 289 "core/core2.pyx" + } + + /* "core/core2.pyx":285 + * + * + * def leak_check(): # <<<<<<<<<<<<<< + * import gc + * gc.collect() + */ + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_11); + __Pyx_AddTraceback("softwrap_core2.leak_check", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_gc); + __Pyx_XDECREF(__pyx_v_ptr); + __Pyx_XDECREF(__pyx_v_line); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":299 + * + * + * cdef list vec3arr_to_list(vec3* arr, int size): # <<<<<<<<<<<<<< + * cdef list l = [None] * size + * cdef int i + */ + + +# line 299 "core/core2.pyx" +static PyObject *__pyx_f_14softwrap_core2_vec3arr_to_list(vec3 *__pyx_v_arr, int __pyx_v_size) { + +# line 299 "core/core2.pyx" + PyObject *__pyx_v_l = 0; + +# line 299 "core/core2.pyx" + int __pyx_v_i; + +# line 299 "core/core2.pyx" + PyObject *__pyx_r = NULL; + +# line 299 "core/core2.pyx" + __Pyx_RefNannyDeclarations + +# line 299 "core/core2.pyx" + PyObject *__pyx_t_1 = NULL; + +# line 299 "core/core2.pyx" + int __pyx_t_2; + +# line 299 "core/core2.pyx" + int __pyx_t_3; + +# line 299 "core/core2.pyx" + int __pyx_t_4; + +# line 299 "core/core2.pyx" + PyObject *__pyx_t_5 = NULL; + +# line 299 "core/core2.pyx" + PyObject *__pyx_t_6 = NULL; + +# line 299 "core/core2.pyx" + PyObject *__pyx_t_7 = NULL; + +# line 299 "core/core2.pyx" + int __pyx_lineno = 0; + +# line 299 "core/core2.pyx" + const char *__pyx_filename = NULL; + +# line 299 "core/core2.pyx" + int __pyx_clineno = 0; + +# line 299 "core/core2.pyx" + __Pyx_RefNannySetupContext("vec3arr_to_list", 0); + + /* "core/core2.pyx":300 + * + * cdef list vec3arr_to_list(vec3* arr, int size): + * cdef list l = [None] * size # <<<<<<<<<<<<<< + * cdef int i + * for i in range(size): + */ + +# line 300 "core/core2.pyx" + __pyx_t_1 = PyList_New(1 * ((__pyx_v_size<0) ? 0:__pyx_v_size)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 300, __pyx_L1_error) + +# line 300 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_1); + +# line 300 "core/core2.pyx" + { Py_ssize_t __pyx_temp; + +# line 300 "core/core2.pyx" + for (__pyx_temp=0; __pyx_temp < __pyx_v_size; __pyx_temp++) { + +# line 300 "core/core2.pyx" + __Pyx_INCREF(Py_None); + +# line 300 "core/core2.pyx" + __Pyx_GIVEREF(Py_None); + +# line 300 "core/core2.pyx" + PyList_SET_ITEM(__pyx_t_1, __pyx_temp, Py_None); + +# line 300 "core/core2.pyx" + } + +# line 300 "core/core2.pyx" + } + +# line 300 "core/core2.pyx" + __pyx_v_l = ((PyObject*)__pyx_t_1); + +# line 300 "core/core2.pyx" + __pyx_t_1 = 0; + + /* "core/core2.pyx":302 + * cdef list l = [None] * size + * cdef int i + * for i in range(size): # <<<<<<<<<<<<<< + * l[i] = (arr[i].v[0], arr[i].v[1], arr[i].v[2]) + * + */ + +# line 302 "core/core2.pyx" + __pyx_t_2 = __pyx_v_size; + +# line 302 "core/core2.pyx" + __pyx_t_3 = __pyx_t_2; + +# line 302 "core/core2.pyx" + for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { + +# line 302 "core/core2.pyx" + __pyx_v_i = __pyx_t_4; + + /* "core/core2.pyx":303 + * cdef int i + * for i in range(size): + * l[i] = (arr[i].v[0], arr[i].v[1], arr[i].v[2]) # <<<<<<<<<<<<<< + * + * return l + */ + +# line 303 "core/core2.pyx" + __pyx_t_1 = PyFloat_FromDouble(((__pyx_v_arr[__pyx_v_i]).v[0])); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 303, __pyx_L1_error) + +# line 303 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_1); + +# line 303 "core/core2.pyx" + __pyx_t_5 = PyFloat_FromDouble(((__pyx_v_arr[__pyx_v_i]).v[1])); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 303, __pyx_L1_error) + +# line 303 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_5); + +# line 303 "core/core2.pyx" + __pyx_t_6 = PyFloat_FromDouble(((__pyx_v_arr[__pyx_v_i]).v[2])); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 303, __pyx_L1_error) + +# line 303 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_6); + +# line 303 "core/core2.pyx" + __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 303, __pyx_L1_error) + +# line 303 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_7); + +# line 303 "core/core2.pyx" + __Pyx_GIVEREF(__pyx_t_1); + +# line 303 "core/core2.pyx" + PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1); + +# line 303 "core/core2.pyx" + __Pyx_GIVEREF(__pyx_t_5); + +# line 303 "core/core2.pyx" + PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_5); + +# line 303 "core/core2.pyx" + __Pyx_GIVEREF(__pyx_t_6); + +# line 303 "core/core2.pyx" + PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_6); + +# line 303 "core/core2.pyx" + __pyx_t_1 = 0; + +# line 303 "core/core2.pyx" + __pyx_t_5 = 0; + +# line 303 "core/core2.pyx" + __pyx_t_6 = 0; + +# line 303 "core/core2.pyx" + if (unlikely(__Pyx_SetItemInt(__pyx_v_l, __pyx_v_i, __pyx_t_7, int, 1, __Pyx_PyInt_From_int, 1, 1, 0) < 0)) __PYX_ERR(0, 303, __pyx_L1_error) + +# line 303 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + +# line 303 "core/core2.pyx" + } + + /* "core/core2.pyx":305 + * l[i] = (arr[i].v[0], arr[i].v[1], arr[i].v[2]) + * + * return l # <<<<<<<<<<<<<< + * + * + */ + +# line 305 "core/core2.pyx" + __Pyx_XDECREF(__pyx_r); + +# line 305 "core/core2.pyx" + __Pyx_INCREF(__pyx_v_l); + +# line 305 "core/core2.pyx" + __pyx_r = __pyx_v_l; + +# line 305 "core/core2.pyx" + goto __pyx_L0; + + /* "core/core2.pyx":299 + * + * + * cdef list vec3arr_to_list(vec3* arr, int size): # <<<<<<<<<<<<<< + * cdef list l = [None] * size + * cdef int i + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_AddTraceback("softwrap_core2.vec3arr_to_list", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_l); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":308 + * + * + * cdef inline unsigned int xorshift(unsigned int* seed) nogil: # <<<<<<<<<<<<<< + * seed[0] ^= seed[0] << 11 + * seed[0] ^= seed[0] >> 17 + */ + + +# line 308 "core/core2.pyx" +static CYTHON_INLINE unsigned int __pyx_f_14softwrap_core2_xorshift(unsigned int *__pyx_v_seed) { + +# line 308 "core/core2.pyx" + unsigned int __pyx_r; + +# line 308 "core/core2.pyx" + long __pyx_t_1; + + /* "core/core2.pyx":309 + * + * cdef inline unsigned int xorshift(unsigned int* seed) nogil: + * seed[0] ^= seed[0] << 11 # <<<<<<<<<<<<<< + * seed[0] ^= seed[0] >> 17 + * seed[0] ^= seed[0] << 9 + */ + +# line 309 "core/core2.pyx" + __pyx_t_1 = 0; + +# line 309 "core/core2.pyx" + (__pyx_v_seed[__pyx_t_1]) = ((__pyx_v_seed[__pyx_t_1]) ^ ((__pyx_v_seed[0]) << 11)); + + /* "core/core2.pyx":310 + * cdef inline unsigned int xorshift(unsigned int* seed) nogil: + * seed[0] ^= seed[0] << 11 + * seed[0] ^= seed[0] >> 17 # <<<<<<<<<<<<<< + * seed[0] ^= seed[0] << 9 + * return seed[0] + */ + +# line 310 "core/core2.pyx" + __pyx_t_1 = 0; + +# line 310 "core/core2.pyx" + (__pyx_v_seed[__pyx_t_1]) = ((__pyx_v_seed[__pyx_t_1]) ^ ((__pyx_v_seed[0]) >> 17)); + + /* "core/core2.pyx":311 + * seed[0] ^= seed[0] << 11 + * seed[0] ^= seed[0] >> 17 + * seed[0] ^= seed[0] << 9 # <<<<<<<<<<<<<< + * return seed[0] + * + */ + +# line 311 "core/core2.pyx" + __pyx_t_1 = 0; + +# line 311 "core/core2.pyx" + (__pyx_v_seed[__pyx_t_1]) = ((__pyx_v_seed[__pyx_t_1]) ^ ((__pyx_v_seed[0]) << 9)); + + /* "core/core2.pyx":312 + * seed[0] ^= seed[0] >> 17 + * seed[0] ^= seed[0] << 9 + * return seed[0] # <<<<<<<<<<<<<< + * + * cdef inline float uint2neg1pos1f(unsigned int v) nogil: + */ + +# line 312 "core/core2.pyx" + __pyx_r = (__pyx_v_seed[0]); + +# line 312 "core/core2.pyx" + goto __pyx_L0; + + /* "core/core2.pyx":308 + * + * + * cdef inline unsigned int xorshift(unsigned int* seed) nogil: # <<<<<<<<<<<<<< + * seed[0] ^= seed[0] << 11 + * seed[0] ^= seed[0] >> 17 + */ + + /* function exit code */ + __pyx_L0:; + return __pyx_r; +} + +/* "core/core2.pyx":314 + * return seed[0] + * + * cdef inline float uint2neg1pos1f(unsigned int v) nogil: # <<<<<<<<<<<<<< + * return v / ( 0xffffffff >> 1) - 1.0 + * + */ + + +# line 314 "core/core2.pyx" +static CYTHON_INLINE float __pyx_f_14softwrap_core2_uint2neg1pos1f(unsigned int __pyx_v_v) { + +# line 314 "core/core2.pyx" + float __pyx_r; + + /* "core/core2.pyx":315 + * + * cdef inline float uint2neg1pos1f(unsigned int v) nogil: + * return v / ( 0xffffffff >> 1) - 1.0 # <<<<<<<<<<<<<< + * + * cdef float xorshiftf(unsigned int* seed) nogil: + */ + +# line 315 "core/core2.pyx" + __pyx_r = ((((float)__pyx_v_v) / ((float)(((unsigned int)0xffffffff) >> 1))) - ((float)1.0)); + +# line 315 "core/core2.pyx" + goto __pyx_L0; + + /* "core/core2.pyx":314 + * return seed[0] + * + * cdef inline float uint2neg1pos1f(unsigned int v) nogil: # <<<<<<<<<<<<<< + * return v / ( 0xffffffff >> 1) - 1.0 + * + */ + + /* function exit code */ + __pyx_L0:; + return __pyx_r; +} + +/* "core/core2.pyx":317 + * return v / ( 0xffffffff >> 1) - 1.0 + * + * cdef float xorshiftf(unsigned int* seed) nogil: # <<<<<<<<<<<<<< + * return uint2neg1pos1f(xorshift(seed)) + * + */ + + +# line 317 "core/core2.pyx" +static float __pyx_f_14softwrap_core2_xorshiftf(unsigned int *__pyx_v_seed) { + +# line 317 "core/core2.pyx" + float __pyx_r; + + /* "core/core2.pyx":318 + * + * cdef float xorshiftf(unsigned int* seed) nogil: + * return uint2neg1pos1f(xorshift(seed)) # <<<<<<<<<<<<<< + * + * + */ + +# line 318 "core/core2.pyx" + __pyx_r = __pyx_f_14softwrap_core2_uint2neg1pos1f(__pyx_f_14softwrap_core2_xorshift(__pyx_v_seed)); + +# line 318 "core/core2.pyx" + goto __pyx_L0; + + /* "core/core2.pyx":317 + * return v / ( 0xffffffff >> 1) - 1.0 + * + * cdef float xorshiftf(unsigned int* seed) nogil: # <<<<<<<<<<<<<< + * return uint2neg1pos1f(xorshift(seed)) + * + */ + + /* function exit code */ + __pyx_L0:; + return __pyx_r; +} + +/* "core/core2.pyx":321 + * + * + * cpdef index_check(int idx, int size): # <<<<<<<<<<<<<< + * if idx < 0 or idx >= size: + * raise IndexError(idx) + */ + +static PyObject *__pyx_pw_14softwrap_core2_3index_check(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_f_14softwrap_core2_index_check(int __pyx_v_idx, int __pyx_v_size, CYTHON_UNUSED int __pyx_skip_dispatch) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("index_check", 0); + + /* "core/core2.pyx":322 + * + * cpdef index_check(int idx, int size): + * if idx < 0 or idx >= size: # <<<<<<<<<<<<<< + * raise IndexError(idx) + * + */ + +# line 322 "core/core2.pyx" + __pyx_t_2 = ((__pyx_v_idx < 0) != 0); + +# line 322 "core/core2.pyx" + if (!__pyx_t_2) { + +# line 322 "core/core2.pyx" + } else { + +# line 322 "core/core2.pyx" + __pyx_t_1 = __pyx_t_2; + +# line 322 "core/core2.pyx" + goto __pyx_L4_bool_binop_done; + +# line 322 "core/core2.pyx" + } + +# line 322 "core/core2.pyx" + __pyx_t_2 = ((__pyx_v_idx >= __pyx_v_size) != 0); + +# line 322 "core/core2.pyx" + __pyx_t_1 = __pyx_t_2; + +# line 322 "core/core2.pyx" + __pyx_L4_bool_binop_done:; + +# line 322 "core/core2.pyx" + if (unlikely(__pyx_t_1)) { + + /* "core/core2.pyx":323 + * cpdef index_check(int idx, int size): + * if idx < 0 or idx >= size: + * raise IndexError(idx) # <<<<<<<<<<<<<< + * + * @cython.final + */ + +# line 323 "core/core2.pyx" + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_idx); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 323, __pyx_L1_error) + +# line 323 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_3); + +# line 323 "core/core2.pyx" + __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_IndexError, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 323, __pyx_L1_error) + +# line 323 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_4); + +# line 323 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + +# line 323 "core/core2.pyx" + __Pyx_Raise(__pyx_t_4, 0, 0, 0); + +# line 323 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + +# line 323 "core/core2.pyx" + __PYX_ERR(0, 323, __pyx_L1_error) + + /* "core/core2.pyx":322 + * + * cpdef index_check(int idx, int size): + * if idx < 0 or idx >= size: # <<<<<<<<<<<<<< + * raise IndexError(idx) + * + */ + +# line 322 "core/core2.pyx" + } + + /* "core/core2.pyx":321 + * + * + * cpdef index_check(int idx, int size): # <<<<<<<<<<<<<< + * if idx < 0 or idx >= size: + * raise IndexError(idx) + */ + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("softwrap_core2.index_check", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_3index_check(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_3index_check(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + int __pyx_v_idx; + int __pyx_v_size; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("index_check (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_idx,&__pyx_n_s_size,0}; + PyObject* values[2] = {0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + CYTHON_FALLTHROUGH; + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + CYTHON_FALLTHROUGH; + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_idx)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + CYTHON_FALLTHROUGH; + case 1: + if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_size)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("index_check", 1, 2, 2, 1); __PYX_ERR(0, 321, __pyx_L3_error) + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "index_check") < 0)) __PYX_ERR(0, 321, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + } + __pyx_v_idx = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_idx == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 321, __pyx_L3_error) + __pyx_v_size = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_size == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 321, __pyx_L3_error) + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("index_check", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 321, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("softwrap_core2.index_check", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_14softwrap_core2_2index_check(__pyx_self, __pyx_v_idx, __pyx_v_size); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_2index_check(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_idx, int __pyx_v_size) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("index_check", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_f_14softwrap_core2_index_check(__pyx_v_idx, __pyx_v_size, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 321, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("softwrap_core2.index_check", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":336 + * int n_triangles + * + * def get_vert_normals(self): # <<<<<<<<<<<<<< + * return vec3arr_to_list(self.vert_normals, self.n_verts) + * + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_4Mesh_1get_vert_normals(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_4Mesh_1get_vert_normals(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("get_vert_normals (wrapper)", 0); + __pyx_r = __pyx_pf_14softwrap_core2_4Mesh_get_vert_normals(((struct __pyx_obj_14softwrap_core2_Mesh *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_4Mesh_get_vert_normals(struct __pyx_obj_14softwrap_core2_Mesh *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("get_vert_normals", 0); + + /* "core/core2.pyx":337 + * + * def get_vert_normals(self): + * return vec3arr_to_list(self.vert_normals, self.n_verts) # <<<<<<<<<<<<<< + * + * def get_face_normals(self): + */ + +# line 337 "core/core2.pyx" + __Pyx_XDECREF(__pyx_r); + +# line 337 "core/core2.pyx" + __pyx_t_1 = __pyx_f_14softwrap_core2_vec3arr_to_list(__pyx_v_self->vert_normals, __pyx_v_self->n_verts); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 337, __pyx_L1_error) + +# line 337 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_1); + +# line 337 "core/core2.pyx" + __pyx_r = __pyx_t_1; + +# line 337 "core/core2.pyx" + __pyx_t_1 = 0; + +# line 337 "core/core2.pyx" + goto __pyx_L0; + + /* "core/core2.pyx":336 + * int n_triangles + * + * def get_vert_normals(self): # <<<<<<<<<<<<<< + * return vec3arr_to_list(self.vert_normals, self.n_verts) + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("softwrap_core2.Mesh.get_vert_normals", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":339 + * return vec3arr_to_list(self.vert_normals, self.n_verts) + * + * def get_face_normals(self): # <<<<<<<<<<<<<< + * return vec3arr_to_list(self.face_normals, self.n_triangles) + * + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_4Mesh_3get_face_normals(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_4Mesh_3get_face_normals(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("get_face_normals (wrapper)", 0); + __pyx_r = __pyx_pf_14softwrap_core2_4Mesh_2get_face_normals(((struct __pyx_obj_14softwrap_core2_Mesh *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_4Mesh_2get_face_normals(struct __pyx_obj_14softwrap_core2_Mesh *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("get_face_normals", 0); + + /* "core/core2.pyx":340 + * + * def get_face_normals(self): + * return vec3arr_to_list(self.face_normals, self.n_triangles) # <<<<<<<<<<<<<< + * + * def __init__(self, verts, triangles): + */ + +# line 340 "core/core2.pyx" + __Pyx_XDECREF(__pyx_r); + +# line 340 "core/core2.pyx" + __pyx_t_1 = __pyx_f_14softwrap_core2_vec3arr_to_list(__pyx_v_self->face_normals, __pyx_v_self->n_triangles); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 340, __pyx_L1_error) + +# line 340 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_1); + +# line 340 "core/core2.pyx" + __pyx_r = __pyx_t_1; + +# line 340 "core/core2.pyx" + __pyx_t_1 = 0; + +# line 340 "core/core2.pyx" + goto __pyx_L0; + + /* "core/core2.pyx":339 + * return vec3arr_to_list(self.vert_normals, self.n_verts) + * + * def get_face_normals(self): # <<<<<<<<<<<<<< + * return vec3arr_to_list(self.face_normals, self.n_triangles) + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("softwrap_core2.Mesh.get_face_normals", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":342 + * return vec3arr_to_list(self.face_normals, self.n_triangles) + * + * def __init__(self, verts, triangles): # <<<<<<<<<<<<<< + * self.n_verts = len(verts) + * self.n_triangles = len(triangles) + */ + +/* Python wrapper */ +static int __pyx_pw_14softwrap_core2_4Mesh_5__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pw_14softwrap_core2_4Mesh_5__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_verts = 0; + PyObject *__pyx_v_triangles = 0; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_verts,&__pyx_n_s_triangles,0}; + PyObject* values[2] = {0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + CYTHON_FALLTHROUGH; + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + CYTHON_FALLTHROUGH; + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_verts)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + CYTHON_FALLTHROUGH; + case 1: + if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_triangles)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, 1); __PYX_ERR(0, 342, __pyx_L3_error) + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 342, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + } + __pyx_v_verts = values[0]; + __pyx_v_triangles = values[1]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 342, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("softwrap_core2.Mesh.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_14softwrap_core2_4Mesh_4__init__(((struct __pyx_obj_14softwrap_core2_Mesh *)__pyx_v_self), __pyx_v_verts, __pyx_v_triangles); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_14softwrap_core2_4Mesh_4__init__(struct __pyx_obj_14softwrap_core2_Mesh *__pyx_v_self, PyObject *__pyx_v_verts, PyObject *__pyx_v_triangles) { + int __pyx_v_i; + int __pyx_r; + __Pyx_RefNannyDeclarations + Py_ssize_t __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + PyObject *__pyx_t_4 = NULL; + void *__pyx_t_5; + int __pyx_t_6; + int __pyx_t_7; + int __pyx_t_8; + float __pyx_t_9[3]; + int __pyx_t_10[3]; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__init__", 0); + + /* "core/core2.pyx":343 + * + * def __init__(self, verts, triangles): + * self.n_verts = len(verts) # <<<<<<<<<<<<<< + * self.n_triangles = len(triangles) + * + */ + +# line 343 "core/core2.pyx" + __pyx_t_1 = PyObject_Length(__pyx_v_verts); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 343, __pyx_L1_error) + +# line 343 "core/core2.pyx" + __pyx_v_self->n_verts = __pyx_t_1; + + /* "core/core2.pyx":344 + * def __init__(self, verts, triangles): + * self.n_verts = len(verts) + * self.n_triangles = len(triangles) # <<<<<<<<<<<<<< + * + * if len(verts) < 3 or len(triangles) < 1: + */ + +# line 344 "core/core2.pyx" + __pyx_t_1 = PyObject_Length(__pyx_v_triangles); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 344, __pyx_L1_error) + +# line 344 "core/core2.pyx" + __pyx_v_self->n_triangles = __pyx_t_1; + + /* "core/core2.pyx":346 + * self.n_triangles = len(triangles) + * + * if len(verts) < 3 or len(triangles) < 1: # <<<<<<<<<<<<<< + * raise ValueError('Invalid or empty mesh') + * + */ + +# line 346 "core/core2.pyx" + __pyx_t_1 = PyObject_Length(__pyx_v_verts); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 346, __pyx_L1_error) + +# line 346 "core/core2.pyx" + __pyx_t_3 = ((__pyx_t_1 < 3) != 0); + +# line 346 "core/core2.pyx" + if (!__pyx_t_3) { + +# line 346 "core/core2.pyx" + } else { + +# line 346 "core/core2.pyx" + __pyx_t_2 = __pyx_t_3; + +# line 346 "core/core2.pyx" + goto __pyx_L4_bool_binop_done; + +# line 346 "core/core2.pyx" + } + +# line 346 "core/core2.pyx" + __pyx_t_1 = PyObject_Length(__pyx_v_triangles); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 346, __pyx_L1_error) + +# line 346 "core/core2.pyx" + __pyx_t_3 = ((__pyx_t_1 < 1) != 0); + +# line 346 "core/core2.pyx" + __pyx_t_2 = __pyx_t_3; + +# line 346 "core/core2.pyx" + __pyx_L4_bool_binop_done:; + +# line 346 "core/core2.pyx" + if (unlikely(__pyx_t_2)) { + + /* "core/core2.pyx":347 + * + * if len(verts) < 3 or len(triangles) < 1: + * raise ValueError('Invalid or empty mesh') # <<<<<<<<<<<<<< + * + * self.verts = maelloc(sizeof(vec3) * self.n_verts, __LINE__) + */ + +# line 347 "core/core2.pyx" + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 347, __pyx_L1_error) + +# line 347 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_4); + +# line 347 "core/core2.pyx" + __Pyx_Raise(__pyx_t_4, 0, 0, 0); + +# line 347 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + +# line 347 "core/core2.pyx" + __PYX_ERR(0, 347, __pyx_L1_error) + + /* "core/core2.pyx":346 + * self.n_triangles = len(triangles) + * + * if len(verts) < 3 or len(triangles) < 1: # <<<<<<<<<<<<<< + * raise ValueError('Invalid or empty mesh') + * + */ + +# line 346 "core/core2.pyx" + } + + /* "core/core2.pyx":349 + * raise ValueError('Invalid or empty mesh') + * + * self.verts = maelloc(sizeof(vec3) * self.n_verts, __LINE__) # <<<<<<<<<<<<<< + * self.triangles = maelloc(sizeof(int[3]) * self.n_triangles, __LINE__) + * + */ + +# line 349 "core/core2.pyx" + __pyx_t_5 = __pyx_f_14softwrap_core2_maelloc(((sizeof(vec3)) * __pyx_v_self->n_verts), __LINE__); if (unlikely(__pyx_t_5 == ((void *)NULL))) __PYX_ERR(0, 349, __pyx_L1_error) + +# line 349 "core/core2.pyx" + __pyx_v_self->verts = ((vec3 *)__pyx_t_5); + + /* "core/core2.pyx":350 + * + * self.verts = maelloc(sizeof(vec3) * self.n_verts, __LINE__) + * self.triangles = maelloc(sizeof(int[3]) * self.n_triangles, __LINE__) # <<<<<<<<<<<<<< + * + * cdef int i + */ + +# line 350 "core/core2.pyx" + __pyx_t_5 = __pyx_f_14softwrap_core2_maelloc(((sizeof(int [3])) * __pyx_v_self->n_triangles), __LINE__); if (unlikely(__pyx_t_5 == ((void *)NULL))) __PYX_ERR(0, 350, __pyx_L1_error) + +# line 350 "core/core2.pyx" + __pyx_v_self->triangles = ((int (*)[3])__pyx_t_5); + + /* "core/core2.pyx":353 + * + * cdef int i + * for i in range(self.n_verts): # <<<<<<<<<<<<<< + * self.verts[i].v = verts[i] + * + */ + +# line 353 "core/core2.pyx" + __pyx_t_6 = __pyx_v_self->n_verts; + +# line 353 "core/core2.pyx" + __pyx_t_7 = __pyx_t_6; + +# line 353 "core/core2.pyx" + for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_7; __pyx_t_8+=1) { + +# line 353 "core/core2.pyx" + __pyx_v_i = __pyx_t_8; + + /* "core/core2.pyx":354 + * cdef int i + * for i in range(self.n_verts): + * self.verts[i].v = verts[i] # <<<<<<<<<<<<<< + * + * for i in range(self.n_triangles): + */ + +# line 354 "core/core2.pyx" + __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_verts, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 0, 1, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 354, __pyx_L1_error) + +# line 354 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_4); + +# line 354 "core/core2.pyx" + if (unlikely(__Pyx_carray_from_py_float(__pyx_t_4, __pyx_t_9, 3) < 0)) __PYX_ERR(0, 354, __pyx_L1_error) + +# line 354 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + +# line 354 "core/core2.pyx" + memcpy(&((__pyx_v_self->verts[__pyx_v_i]).v[0]), __pyx_t_9, sizeof((__pyx_v_self->verts[__pyx_v_i]).v[0]) * (3)); + +# line 354 "core/core2.pyx" + } + + /* "core/core2.pyx":356 + * self.verts[i].v = verts[i] + * + * for i in range(self.n_triangles): # <<<<<<<<<<<<<< + * self.triangles[i] = triangles[i] + * + */ + +# line 356 "core/core2.pyx" + __pyx_t_6 = __pyx_v_self->n_triangles; + +# line 356 "core/core2.pyx" + __pyx_t_7 = __pyx_t_6; + +# line 356 "core/core2.pyx" + for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_7; __pyx_t_8+=1) { + +# line 356 "core/core2.pyx" + __pyx_v_i = __pyx_t_8; + + /* "core/core2.pyx":357 + * + * for i in range(self.n_triangles): + * self.triangles[i] = triangles[i] # <<<<<<<<<<<<<< + * + * cdef inline vec3*tri_vert_ptr(self, int tri, int tri_i) nogil: + */ + +# line 357 "core/core2.pyx" + __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_triangles, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 0, 1, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 357, __pyx_L1_error) + +# line 357 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_4); + +# line 357 "core/core2.pyx" + if (unlikely(__Pyx_carray_from_py_int(__pyx_t_4, __pyx_t_10, 3) < 0)) __PYX_ERR(0, 357, __pyx_L1_error) + +# line 357 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + +# line 357 "core/core2.pyx" + memcpy(&((__pyx_v_self->triangles[__pyx_v_i])[0]), __pyx_t_10, sizeof((__pyx_v_self->triangles[__pyx_v_i])[0]) * (3)); + +# line 357 "core/core2.pyx" + } + + /* "core/core2.pyx":342 + * return vec3arr_to_list(self.face_normals, self.n_triangles) + * + * def __init__(self, verts, triangles): # <<<<<<<<<<<<<< + * self.n_verts = len(verts) + * self.n_triangles = len(triangles) + */ + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("softwrap_core2.Mesh.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":359 + * self.triangles[i] = triangles[i] + * + * cdef inline vec3*tri_vert_ptr(self, int tri, int tri_i) nogil: # <<<<<<<<<<<<<< + * return & self.verts[self.triangles[tri][tri_i]] + * + */ + + +# line 359 "core/core2.pyx" +static CYTHON_INLINE vec3 *__pyx_f_14softwrap_core2_4Mesh_tri_vert_ptr(struct __pyx_obj_14softwrap_core2_Mesh *__pyx_v_self, int __pyx_v_tri, int __pyx_v_tri_i) { + +# line 359 "core/core2.pyx" + vec3 *__pyx_r; + + /* "core/core2.pyx":360 + * + * cdef inline vec3*tri_vert_ptr(self, int tri, int tri_i) nogil: + * return & self.verts[self.triangles[tri][tri_i]] # <<<<<<<<<<<<<< + * + * cdef inline vec3 tri_vert(self, int tri, int tri_i) nogil: + */ + +# line 360 "core/core2.pyx" + __pyx_r = (&(__pyx_v_self->verts[((__pyx_v_self->triangles[__pyx_v_tri])[__pyx_v_tri_i])])); + +# line 360 "core/core2.pyx" + goto __pyx_L0; + + /* "core/core2.pyx":359 + * self.triangles[i] = triangles[i] + * + * cdef inline vec3*tri_vert_ptr(self, int tri, int tri_i) nogil: # <<<<<<<<<<<<<< + * return & self.verts[self.triangles[tri][tri_i]] + * + */ + + /* function exit code */ + __pyx_L0:; + return __pyx_r; +} + +/* "core/core2.pyx":362 + * return & self.verts[self.triangles[tri][tri_i]] + * + * cdef inline vec3 tri_vert(self, int tri, int tri_i) nogil: # <<<<<<<<<<<<<< + * return self.verts[self.triangles[tri][tri_i]] + * + */ + + +# line 362 "core/core2.pyx" +static CYTHON_INLINE vec3 __pyx_f_14softwrap_core2_4Mesh_tri_vert(struct __pyx_obj_14softwrap_core2_Mesh *__pyx_v_self, int __pyx_v_tri, int __pyx_v_tri_i) { + +# line 362 "core/core2.pyx" + vec3 __pyx_r; + + /* "core/core2.pyx":363 + * + * cdef inline vec3 tri_vert(self, int tri, int tri_i) nogil: + * return self.verts[self.triangles[tri][tri_i]] # <<<<<<<<<<<<<< + * + * cpdef void update_face_normals(self): + */ + +# line 363 "core/core2.pyx" + __pyx_r = (__pyx_v_self->verts[((__pyx_v_self->triangles[__pyx_v_tri])[__pyx_v_tri_i])]); + +# line 363 "core/core2.pyx" + goto __pyx_L0; + + /* "core/core2.pyx":362 + * return & self.verts[self.triangles[tri][tri_i]] + * + * cdef inline vec3 tri_vert(self, int tri, int tri_i) nogil: # <<<<<<<<<<<<<< + * return self.verts[self.triangles[tri][tri_i]] + * + */ + + /* function exit code */ + __pyx_L0:; + return __pyx_r; +} + +/* "core/core2.pyx":365 + * return self.verts[self.triangles[tri][tri_i]] + * + * cpdef void update_face_normals(self): # <<<<<<<<<<<<<< + * if not self.face_normals: + * self.face_normals = caelloc(self.n_triangles, sizeof(vec3), __LINE__) + */ + +static PyObject *__pyx_pw_14softwrap_core2_4Mesh_7update_face_normals(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static void __pyx_f_14softwrap_core2_4Mesh_update_face_normals(struct __pyx_obj_14softwrap_core2_Mesh *__pyx_v_self, CYTHON_UNUSED int __pyx_skip_dispatch) { + int __pyx_v_i; + vec3 *__pyx_v_a; + vec3 *__pyx_v_b; + vec3 *__pyx_v_c; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + void *__pyx_t_2; + int __pyx_t_3; + int __pyx_t_4; + int __pyx_t_5; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("update_face_normals", 0); + + /* "core/core2.pyx":366 + * + * cpdef void update_face_normals(self): + * if not self.face_normals: # <<<<<<<<<<<<<< + * self.face_normals = caelloc(self.n_triangles, sizeof(vec3), __LINE__) + * + */ + +# line 366 "core/core2.pyx" + __pyx_t_1 = ((!(__pyx_v_self->face_normals != 0)) != 0); + +# line 366 "core/core2.pyx" + if (__pyx_t_1) { + + /* "core/core2.pyx":367 + * cpdef void update_face_normals(self): + * if not self.face_normals: + * self.face_normals = caelloc(self.n_triangles, sizeof(vec3), __LINE__) # <<<<<<<<<<<<<< + * + * cdef int i + */ + +# line 367 "core/core2.pyx" + __pyx_t_2 = __pyx_f_14softwrap_core2_caelloc(__pyx_v_self->n_triangles, (sizeof(vec3)), __LINE__); if (unlikely(__pyx_t_2 == ((void *)NULL))) __PYX_ERR(0, 367, __pyx_L1_error) + +# line 367 "core/core2.pyx" + __pyx_v_self->face_normals = ((vec3 *)__pyx_t_2); + + /* "core/core2.pyx":366 + * + * cpdef void update_face_normals(self): + * if not self.face_normals: # <<<<<<<<<<<<<< + * self.face_normals = caelloc(self.n_triangles, sizeof(vec3), __LINE__) + * + */ + +# line 366 "core/core2.pyx" + } + + /* "core/core2.pyx":374 + * cdef vec3* b + * cdef vec3* c + * with nogil: # <<<<<<<<<<<<<< + * for i in prange(self.n_triangles): + * a = self.tri_vert_ptr(i, 0) + */ + +# line 374 "core/core2.pyx" + { + +# line 374 "core/core2.pyx" + #ifdef WITH_THREAD + +# line 374 "core/core2.pyx" + PyThreadState *_save; + +# line 374 "core/core2.pyx" + Py_UNBLOCK_THREADS + +# line 374 "core/core2.pyx" + __Pyx_FastGIL_Remember(); + +# line 374 "core/core2.pyx" + #endif + /*try:*/ { + + /* "core/core2.pyx":375 + * cdef vec3* c + * with nogil: + * for i in prange(self.n_triangles): # <<<<<<<<<<<<<< + * a = self.tri_vert_ptr(i, 0) + * b = self.tri_vert_ptr(i, 1) + */ + +# line 375 "core/core2.pyx" + __pyx_t_3 = __pyx_v_self->n_triangles; + +# line 375 "core/core2.pyx" + if ((1 == 0)) abort(); + +# line 375 "core/core2.pyx" + { + +# line 375 "core/core2.pyx" + #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))))) + +# line 375 "core/core2.pyx" + #undef likely + +# line 375 "core/core2.pyx" + #undef unlikely + #define likely(x) (x) + #define unlikely(x) (x) + +# line 375 "core/core2.pyx" + #endif + +# line 375 "core/core2.pyx" + __pyx_t_5 = (__pyx_t_3 - 0 + 1 - 1/abs(1)) / 1; + +# line 375 "core/core2.pyx" + if (__pyx_t_5 > 0) + +# line 375 "core/core2.pyx" + { + +# line 375 "core/core2.pyx" + #ifdef _OPENMP + +# line 375 "core/core2.pyx" + #pragma omp parallel + #endif /* _OPENMP */ + { + #ifdef _OPENMP + #pragma omp for lastprivate(__pyx_v_a) lastprivate(__pyx_v_b) lastprivate(__pyx_v_c) firstprivate(__pyx_v_i) lastprivate(__pyx_v_i) + #endif /* _OPENMP */ + for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_5; __pyx_t_4++){ + { + __pyx_v_i = (int)(0 + 1 * __pyx_t_4); + /* Initialize private variables to invalid values */ + __pyx_v_a = ((vec3 *)1); + __pyx_v_b = ((vec3 *)1); + __pyx_v_c = ((vec3 *)1); + + /* "core/core2.pyx":376 + * with nogil: + * for i in prange(self.n_triangles): + * a = self.tri_vert_ptr(i, 0) # <<<<<<<<<<<<<< + * b = self.tri_vert_ptr(i, 1) + * c = self.tri_vert_ptr(i, 2) + */ + +# line 376 "core/core2.pyx" + __pyx_v_a = __pyx_f_14softwrap_core2_4Mesh_tri_vert_ptr(__pyx_v_self, __pyx_v_i, 0); + + /* "core/core2.pyx":377 + * for i in prange(self.n_triangles): + * a = self.tri_vert_ptr(i, 0) + * b = self.tri_vert_ptr(i, 1) # <<<<<<<<<<<<<< + * c = self.tri_vert_ptr(i, 2) + * self.face_normals[i] = (b[0] - a[0]).cross(c[0] - a[0]).normalized() + */ + +# line 377 "core/core2.pyx" + __pyx_v_b = __pyx_f_14softwrap_core2_4Mesh_tri_vert_ptr(__pyx_v_self, __pyx_v_i, 1); + + /* "core/core2.pyx":378 + * a = self.tri_vert_ptr(i, 0) + * b = self.tri_vert_ptr(i, 1) + * c = self.tri_vert_ptr(i, 2) # <<<<<<<<<<<<<< + * self.face_normals[i] = (b[0] - a[0]).cross(c[0] - a[0]).normalized() + * + */ + +# line 378 "core/core2.pyx" + __pyx_v_c = __pyx_f_14softwrap_core2_4Mesh_tri_vert_ptr(__pyx_v_self, __pyx_v_i, 2); + + /* "core/core2.pyx":379 + * b = self.tri_vert_ptr(i, 1) + * c = self.tri_vert_ptr(i, 2) + * self.face_normals[i] = (b[0] - a[0]).cross(c[0] - a[0]).normalized() # <<<<<<<<<<<<<< + * + * cpdef void update_vert_normals(self): + */ + +# line 379 "core/core2.pyx" + (__pyx_v_self->face_normals[__pyx_v_i]) = ((__pyx_v_b[0]) - (__pyx_v_a[0])).cross(((__pyx_v_c[0]) - (__pyx_v_a[0]))).normalized(); + +# line 379 "core/core2.pyx" + } + +# line 379 "core/core2.pyx" + } + +# line 379 "core/core2.pyx" + } + +# line 379 "core/core2.pyx" + } + +# line 379 "core/core2.pyx" + } + +# line 379 "core/core2.pyx" + #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))))) + +# line 379 "core/core2.pyx" + #undef likely + +# line 379 "core/core2.pyx" + #undef unlikely + #define likely(x) __builtin_expect(!!(x), 1) + #define unlikely(x) __builtin_expect(!!(x), 0) + +# line 379 "core/core2.pyx" + #endif + +# line 379 "core/core2.pyx" + } + + /* "core/core2.pyx":374 + * cdef vec3* b + * cdef vec3* c + * with nogil: # <<<<<<<<<<<<<< + * for i in prange(self.n_triangles): + * a = self.tri_vert_ptr(i, 0) + */ + /*finally:*/ { + /*normal exit:*/{ + #ifdef WITH_THREAD + __Pyx_FastGIL_Forget(); + Py_BLOCK_THREADS + #endif + goto __pyx_L6; + } + __pyx_L6:; + } + } + + /* "core/core2.pyx":365 + * return self.verts[self.triangles[tri][tri_i]] + * + * cpdef void update_face_normals(self): # <<<<<<<<<<<<<< + * if not self.face_normals: + * self.face_normals = caelloc(self.n_triangles, sizeof(vec3), __LINE__) + */ + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_WriteUnraisable("softwrap_core2.Mesh.update_face_normals", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); + __pyx_L0:; + __Pyx_RefNannyFinishContext(); +} + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_4Mesh_7update_face_normals(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_4Mesh_7update_face_normals(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("update_face_normals (wrapper)", 0); + __pyx_r = __pyx_pf_14softwrap_core2_4Mesh_6update_face_normals(((struct __pyx_obj_14softwrap_core2_Mesh *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_4Mesh_6update_face_normals(struct __pyx_obj_14softwrap_core2_Mesh *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("update_face_normals", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_void_to_None(__pyx_f_14softwrap_core2_4Mesh_update_face_normals(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 365, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("softwrap_core2.Mesh.update_face_normals", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":381 + * self.face_normals[i] = (b[0] - a[0]).cross(c[0] - a[0]).normalized() + * + * cpdef void update_vert_normals(self): # <<<<<<<<<<<<<< + * if not self.vert_normals: + * self.vert_normals = caelloc(self.n_verts, sizeof(vec3), __LINE__) + */ + +static PyObject *__pyx_pw_14softwrap_core2_4Mesh_9update_vert_normals(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static void __pyx_f_14softwrap_core2_4Mesh_update_vert_normals(struct __pyx_obj_14softwrap_core2_Mesh *__pyx_v_self, CYTHON_UNUSED int __pyx_skip_dispatch) { + int __pyx_v_i; + int __pyx_v_j; + int *__pyx_v_tri; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + void *__pyx_t_2; + int __pyx_t_3; + int __pyx_t_4; + int __pyx_t_5; + int __pyx_t_6; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("update_vert_normals", 0); + + /* "core/core2.pyx":382 + * + * cpdef void update_vert_normals(self): + * if not self.vert_normals: # <<<<<<<<<<<<<< + * self.vert_normals = caelloc(self.n_verts, sizeof(vec3), __LINE__) + * + */ + +# line 382 "core/core2.pyx" + __pyx_t_1 = ((!(__pyx_v_self->vert_normals != 0)) != 0); + +# line 382 "core/core2.pyx" + if (__pyx_t_1) { + + /* "core/core2.pyx":383 + * cpdef void update_vert_normals(self): + * if not self.vert_normals: + * self.vert_normals = caelloc(self.n_verts, sizeof(vec3), __LINE__) # <<<<<<<<<<<<<< + * + * cdef int i, j + */ + +# line 383 "core/core2.pyx" + __pyx_t_2 = __pyx_f_14softwrap_core2_caelloc(__pyx_v_self->n_verts, (sizeof(vec3)), __LINE__); if (unlikely(__pyx_t_2 == ((void *)NULL))) __PYX_ERR(0, 383, __pyx_L1_error) + +# line 383 "core/core2.pyx" + __pyx_v_self->vert_normals = ((vec3 *)__pyx_t_2); + + /* "core/core2.pyx":382 + * + * cpdef void update_vert_normals(self): + * if not self.vert_normals: # <<<<<<<<<<<<<< + * self.vert_normals = caelloc(self.n_verts, sizeof(vec3), __LINE__) + * + */ + +# line 382 "core/core2.pyx" + } + + /* "core/core2.pyx":389 + * cdef int * tri + * + * with nogil: # <<<<<<<<<<<<<< + * for i in prange(self.n_verts): + * self.vert_normals[i] = vec3(0) + */ + +# line 389 "core/core2.pyx" + { + +# line 389 "core/core2.pyx" + #ifdef WITH_THREAD + +# line 389 "core/core2.pyx" + PyThreadState *_save; + +# line 389 "core/core2.pyx" + Py_UNBLOCK_THREADS + +# line 389 "core/core2.pyx" + __Pyx_FastGIL_Remember(); + +# line 389 "core/core2.pyx" + #endif + /*try:*/ { + + /* "core/core2.pyx":390 + * + * with nogil: + * for i in prange(self.n_verts): # <<<<<<<<<<<<<< + * self.vert_normals[i] = vec3(0) + * + */ + +# line 390 "core/core2.pyx" + __pyx_t_3 = __pyx_v_self->n_verts; + +# line 390 "core/core2.pyx" + if ((1 == 0)) abort(); + +# line 390 "core/core2.pyx" + { + +# line 390 "core/core2.pyx" + #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))))) + +# line 390 "core/core2.pyx" + #undef likely + +# line 390 "core/core2.pyx" + #undef unlikely + #define likely(x) (x) + #define unlikely(x) (x) + +# line 390 "core/core2.pyx" + #endif + +# line 390 "core/core2.pyx" + __pyx_t_5 = (__pyx_t_3 - 0 + 1 - 1/abs(1)) / 1; + +# line 390 "core/core2.pyx" + if (__pyx_t_5 > 0) + +# line 390 "core/core2.pyx" + { + +# line 390 "core/core2.pyx" + #ifdef _OPENMP + +# line 390 "core/core2.pyx" + #pragma omp parallel + #endif /* _OPENMP */ + { + #ifdef _OPENMP + #pragma omp for firstprivate(__pyx_v_i) lastprivate(__pyx_v_i) + #endif /* _OPENMP */ + for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_5; __pyx_t_4++){ + { + __pyx_v_i = (int)(0 + 1 * __pyx_t_4); + + /* "core/core2.pyx":391 + * with nogil: + * for i in prange(self.n_verts): + * self.vert_normals[i] = vec3(0) # <<<<<<<<<<<<<< + * + * for i in range(self.n_triangles): + */ + +# line 391 "core/core2.pyx" + (__pyx_v_self->vert_normals[__pyx_v_i]) = vec3(0.0); + +# line 391 "core/core2.pyx" + } + +# line 391 "core/core2.pyx" + } + +# line 391 "core/core2.pyx" + } + +# line 391 "core/core2.pyx" + } + +# line 391 "core/core2.pyx" + } + +# line 391 "core/core2.pyx" + #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))))) + +# line 391 "core/core2.pyx" + #undef likely + +# line 391 "core/core2.pyx" + #undef unlikely + #define likely(x) __builtin_expect(!!(x), 1) + #define unlikely(x) __builtin_expect(!!(x), 0) + +# line 391 "core/core2.pyx" + #endif + + /* "core/core2.pyx":393 + * self.vert_normals[i] = vec3(0) + * + * for i in range(self.n_triangles): # <<<<<<<<<<<<<< + * tri = self.triangles[i] + * for j in range(3): + */ + +# line 393 "core/core2.pyx" + __pyx_t_5 = __pyx_v_self->n_triangles; + +# line 393 "core/core2.pyx" + __pyx_t_4 = __pyx_t_5; + +# line 393 "core/core2.pyx" + for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_4; __pyx_t_3+=1) { + +# line 393 "core/core2.pyx" + __pyx_v_i = __pyx_t_3; + + /* "core/core2.pyx":394 + * + * for i in range(self.n_triangles): + * tri = self.triangles[i] # <<<<<<<<<<<<<< + * for j in range(3): + * self.vert_normals[tri[j]] += self.face_normals[i] + */ + +# line 394 "core/core2.pyx" + __pyx_v_tri = ((int *)(__pyx_v_self->triangles[__pyx_v_i])); + + /* "core/core2.pyx":395 + * for i in range(self.n_triangles): + * tri = self.triangles[i] + * for j in range(3): # <<<<<<<<<<<<<< + * self.vert_normals[tri[j]] += self.face_normals[i] + * + */ + +# line 395 "core/core2.pyx" + for (__pyx_t_6 = 0; __pyx_t_6 < 3; __pyx_t_6+=1) { + +# line 395 "core/core2.pyx" + __pyx_v_j = __pyx_t_6; + + /* "core/core2.pyx":396 + * tri = self.triangles[i] + * for j in range(3): + * self.vert_normals[tri[j]] += self.face_normals[i] # <<<<<<<<<<<<<< + * + * for i in prange(self.n_verts): + */ + +# line 396 "core/core2.pyx" + (__pyx_v_self->vert_normals[(__pyx_v_tri[__pyx_v_j])]) += (__pyx_v_self->face_normals[__pyx_v_i]); + +# line 396 "core/core2.pyx" + } + +# line 396 "core/core2.pyx" + } + + /* "core/core2.pyx":398 + * self.vert_normals[tri[j]] += self.face_normals[i] + * + * for i in prange(self.n_verts): # <<<<<<<<<<<<<< + * self.vert_normals[i].normalize() + * + */ + +# line 398 "core/core2.pyx" + __pyx_t_5 = __pyx_v_self->n_verts; + +# line 398 "core/core2.pyx" + if ((1 == 0)) abort(); + +# line 398 "core/core2.pyx" + { + +# line 398 "core/core2.pyx" + #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))))) + +# line 398 "core/core2.pyx" + #undef likely + +# line 398 "core/core2.pyx" + #undef unlikely + #define likely(x) (x) + #define unlikely(x) (x) + +# line 398 "core/core2.pyx" + #endif + +# line 398 "core/core2.pyx" + __pyx_t_3 = (__pyx_t_5 - 0 + 1 - 1/abs(1)) / 1; + +# line 398 "core/core2.pyx" + if (__pyx_t_3 > 0) + +# line 398 "core/core2.pyx" + { + +# line 398 "core/core2.pyx" + #ifdef _OPENMP + +# line 398 "core/core2.pyx" + #pragma omp parallel + #endif /* _OPENMP */ + { + #ifdef _OPENMP + #pragma omp for firstprivate(__pyx_v_i) lastprivate(__pyx_v_i) + #endif /* _OPENMP */ + for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4++){ + { + __pyx_v_i = (int)(0 + 1 * __pyx_t_4); + + /* "core/core2.pyx":399 + * + * for i in prange(self.n_verts): + * self.vert_normals[i].normalize() # <<<<<<<<<<<<<< + * + * cpdef void update_centroids(self): + */ + +# line 399 "core/core2.pyx" + (__pyx_v_self->vert_normals[__pyx_v_i]).normalize(); + +# line 399 "core/core2.pyx" + } + +# line 399 "core/core2.pyx" + } + +# line 399 "core/core2.pyx" + } + +# line 399 "core/core2.pyx" + } + +# line 399 "core/core2.pyx" + } + +# line 399 "core/core2.pyx" + #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))))) + +# line 399 "core/core2.pyx" + #undef likely + +# line 399 "core/core2.pyx" + #undef unlikely + #define likely(x) __builtin_expect(!!(x), 1) + #define unlikely(x) __builtin_expect(!!(x), 0) + +# line 399 "core/core2.pyx" + #endif + +# line 399 "core/core2.pyx" + } + + /* "core/core2.pyx":389 + * cdef int * tri + * + * with nogil: # <<<<<<<<<<<<<< + * for i in prange(self.n_verts): + * self.vert_normals[i] = vec3(0) + */ + /*finally:*/ { + /*normal exit:*/{ + #ifdef WITH_THREAD + __Pyx_FastGIL_Forget(); + Py_BLOCK_THREADS + #endif + goto __pyx_L6; + } + __pyx_L6:; + } + } + + /* "core/core2.pyx":381 + * self.face_normals[i] = (b[0] - a[0]).cross(c[0] - a[0]).normalized() + * + * cpdef void update_vert_normals(self): # <<<<<<<<<<<<<< + * if not self.vert_normals: + * self.vert_normals = caelloc(self.n_verts, sizeof(vec3), __LINE__) + */ + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_WriteUnraisable("softwrap_core2.Mesh.update_vert_normals", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); + __pyx_L0:; + __Pyx_RefNannyFinishContext(); +} + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_4Mesh_9update_vert_normals(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_4Mesh_9update_vert_normals(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("update_vert_normals (wrapper)", 0); + __pyx_r = __pyx_pf_14softwrap_core2_4Mesh_8update_vert_normals(((struct __pyx_obj_14softwrap_core2_Mesh *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_4Mesh_8update_vert_normals(struct __pyx_obj_14softwrap_core2_Mesh *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("update_vert_normals", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_void_to_None(__pyx_f_14softwrap_core2_4Mesh_update_vert_normals(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 381, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("softwrap_core2.Mesh.update_vert_normals", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":401 + * self.vert_normals[i].normalize() + * + * cpdef void update_centroids(self): # <<<<<<<<<<<<<< + * if not self.centroids: + * self.centroids = maelloc(sizeof(vec3) * self.n_triangles, __LINE__) + */ + +static PyObject *__pyx_pw_14softwrap_core2_4Mesh_11update_centroids(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static void __pyx_f_14softwrap_core2_4Mesh_update_centroids(struct __pyx_obj_14softwrap_core2_Mesh *__pyx_v_self, CYTHON_UNUSED int __pyx_skip_dispatch) { + int __pyx_v_i; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + void *__pyx_t_2; + int __pyx_t_3; + int __pyx_t_4; + int __pyx_t_5; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("update_centroids", 0); + + /* "core/core2.pyx":402 + * + * cpdef void update_centroids(self): + * if not self.centroids: # <<<<<<<<<<<<<< + * self.centroids = maelloc(sizeof(vec3) * self.n_triangles, __LINE__) + * + */ + +# line 402 "core/core2.pyx" + __pyx_t_1 = ((!(__pyx_v_self->centroids != 0)) != 0); + +# line 402 "core/core2.pyx" + if (__pyx_t_1) { + + /* "core/core2.pyx":403 + * cpdef void update_centroids(self): + * if not self.centroids: + * self.centroids = maelloc(sizeof(vec3) * self.n_triangles, __LINE__) # <<<<<<<<<<<<<< + * + * cdef int i + */ + +# line 403 "core/core2.pyx" + __pyx_t_2 = __pyx_f_14softwrap_core2_maelloc(((sizeof(vec3)) * __pyx_v_self->n_triangles), __LINE__); if (unlikely(__pyx_t_2 == ((void *)NULL))) __PYX_ERR(0, 403, __pyx_L1_error) + +# line 403 "core/core2.pyx" + __pyx_v_self->centroids = ((vec3 *)__pyx_t_2); + + /* "core/core2.pyx":402 + * + * cpdef void update_centroids(self): + * if not self.centroids: # <<<<<<<<<<<<<< + * self.centroids = maelloc(sizeof(vec3) * self.n_triangles, __LINE__) + * + */ + +# line 402 "core/core2.pyx" + } + + /* "core/core2.pyx":406 + * + * cdef int i + * for i in prange(self.n_triangles, nogil=True): # <<<<<<<<<<<<<< + * self.centroids[i] = (self.tri_vert(i, 0) + self.tri_vert(i, 1) + self.tri_vert(i, 2)) / 3 + * + */ + +# line 406 "core/core2.pyx" + { + +# line 406 "core/core2.pyx" + #ifdef WITH_THREAD + +# line 406 "core/core2.pyx" + PyThreadState *_save; + +# line 406 "core/core2.pyx" + Py_UNBLOCK_THREADS + +# line 406 "core/core2.pyx" + __Pyx_FastGIL_Remember(); + +# line 406 "core/core2.pyx" + #endif + /*try:*/ { + __pyx_t_3 = __pyx_v_self->n_triangles; + if ((1 == 0)) abort(); + { + #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))))) + #undef likely + #undef unlikely + #define likely(x) (x) + #define unlikely(x) (x) + #endif + __pyx_t_5 = (__pyx_t_3 - 0 + 1 - 1/abs(1)) / 1; + if (__pyx_t_5 > 0) + { + #ifdef _OPENMP + #pragma omp parallel + #endif /* _OPENMP */ + { + #ifdef _OPENMP + #pragma omp for firstprivate(__pyx_v_i) lastprivate(__pyx_v_i) + #endif /* _OPENMP */ + for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_5; __pyx_t_4++){ + { + __pyx_v_i = (int)(0 + 1 * __pyx_t_4); + + /* "core/core2.pyx":407 + * cdef int i + * for i in prange(self.n_triangles, nogil=True): + * self.centroids[i] = (self.tri_vert(i, 0) + self.tri_vert(i, 1) + self.tri_vert(i, 2)) / 3 # <<<<<<<<<<<<<< + * + * + */ + +# line 407 "core/core2.pyx" + (__pyx_v_self->centroids[__pyx_v_i]) = (((__pyx_f_14softwrap_core2_4Mesh_tri_vert(__pyx_v_self, __pyx_v_i, 0) + __pyx_f_14softwrap_core2_4Mesh_tri_vert(__pyx_v_self, __pyx_v_i, 1)) + __pyx_f_14softwrap_core2_4Mesh_tri_vert(__pyx_v_self, __pyx_v_i, 2)) / 3.0); + +# line 407 "core/core2.pyx" + } + +# line 407 "core/core2.pyx" + } + +# line 407 "core/core2.pyx" + } + +# line 407 "core/core2.pyx" + } + +# line 407 "core/core2.pyx" + } + +# line 407 "core/core2.pyx" + #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))))) + +# line 407 "core/core2.pyx" + #undef likely + +# line 407 "core/core2.pyx" + #undef unlikely + #define likely(x) __builtin_expect(!!(x), 1) + #define unlikely(x) __builtin_expect(!!(x), 0) + +# line 407 "core/core2.pyx" + #endif + +# line 407 "core/core2.pyx" + } + + /* "core/core2.pyx":406 + * + * cdef int i + * for i in prange(self.n_triangles, nogil=True): # <<<<<<<<<<<<<< + * self.centroids[i] = (self.tri_vert(i, 0) + self.tri_vert(i, 1) + self.tri_vert(i, 2)) / 3 + * + */ + /*finally:*/ { + /*normal exit:*/{ + #ifdef WITH_THREAD + __Pyx_FastGIL_Forget(); + Py_BLOCK_THREADS + #endif + goto __pyx_L6; + } + __pyx_L6:; + } + } + + /* "core/core2.pyx":401 + * self.vert_normals[i].normalize() + * + * cpdef void update_centroids(self): # <<<<<<<<<<<<<< + * if not self.centroids: + * self.centroids = maelloc(sizeof(vec3) * self.n_triangles, __LINE__) + */ + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_WriteUnraisable("softwrap_core2.Mesh.update_centroids", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); + __pyx_L0:; + __Pyx_RefNannyFinishContext(); +} + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_4Mesh_11update_centroids(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_4Mesh_11update_centroids(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("update_centroids (wrapper)", 0); + __pyx_r = __pyx_pf_14softwrap_core2_4Mesh_10update_centroids(((struct __pyx_obj_14softwrap_core2_Mesh *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_4Mesh_10update_centroids(struct __pyx_obj_14softwrap_core2_Mesh *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("update_centroids", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_void_to_None(__pyx_f_14softwrap_core2_4Mesh_update_centroids(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 401, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("softwrap_core2.Mesh.update_centroids", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":410 + * + * + * def closest_vert(self, pos): # <<<<<<<<<<<<<< + * cdef vec3 p + * cdef float tmp_dist, dist = INFINITY + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_4Mesh_13closest_vert(PyObject *__pyx_v_self, PyObject *__pyx_v_pos); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_4Mesh_13closest_vert(PyObject *__pyx_v_self, PyObject *__pyx_v_pos) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("closest_vert (wrapper)", 0); + __pyx_r = __pyx_pf_14softwrap_core2_4Mesh_12closest_vert(((struct __pyx_obj_14softwrap_core2_Mesh *)__pyx_v_self), ((PyObject *)__pyx_v_pos)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_4Mesh_12closest_vert(struct __pyx_obj_14softwrap_core2_Mesh *__pyx_v_self, PyObject *__pyx_v_pos) { + vec3 __pyx_v_p; + float __pyx_v_tmp_dist; + float __pyx_v_dist; + int __pyx_v_i; + int __pyx_v_idx; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + float __pyx_t_1[3]; + int __pyx_t_2; + int __pyx_t_3; + int __pyx_t_4; + int __pyx_t_5; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("closest_vert", 0); + + /* "core/core2.pyx":412 + * def closest_vert(self, pos): + * cdef vec3 p + * cdef float tmp_dist, dist = INFINITY # <<<<<<<<<<<<<< + * cdef int i=0, idx = -1 + * + */ + +# line 412 "core/core2.pyx" + __pyx_v_dist = INFINITY; + + /* "core/core2.pyx":413 + * cdef vec3 p + * cdef float tmp_dist, dist = INFINITY + * cdef int i=0, idx = -1 # <<<<<<<<<<<<<< + * + * p.v = pos + */ + +# line 413 "core/core2.pyx" + __pyx_v_i = 0; + +# line 413 "core/core2.pyx" + __pyx_v_idx = -1; + + /* "core/core2.pyx":415 + * cdef int i=0, idx = -1 + * + * p.v = pos # <<<<<<<<<<<<<< + * + * for i in range(self.n_verts): + */ + +# line 415 "core/core2.pyx" + if (unlikely(__Pyx_carray_from_py_float(__pyx_v_pos, __pyx_t_1, 3) < 0)) __PYX_ERR(0, 415, __pyx_L1_error) + +# line 415 "core/core2.pyx" + memcpy(&(__pyx_v_p.v[0]), __pyx_t_1, sizeof(__pyx_v_p.v[0]) * (3)); + + /* "core/core2.pyx":417 + * p.v = pos + * + * for i in range(self.n_verts): # <<<<<<<<<<<<<< + * tmp_dist = (self.verts[i] - p).len_sqr() + * if tmp_dist < dist: + */ + +# line 417 "core/core2.pyx" + __pyx_t_2 = __pyx_v_self->n_verts; + +# line 417 "core/core2.pyx" + __pyx_t_3 = __pyx_t_2; + +# line 417 "core/core2.pyx" + for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { + +# line 417 "core/core2.pyx" + __pyx_v_i = __pyx_t_4; + + /* "core/core2.pyx":418 + * + * for i in range(self.n_verts): + * tmp_dist = (self.verts[i] - p).len_sqr() # <<<<<<<<<<<<<< + * if tmp_dist < dist: + * dist = tmp_dist + */ + +# line 418 "core/core2.pyx" + __pyx_v_tmp_dist = ((__pyx_v_self->verts[__pyx_v_i]) - __pyx_v_p).len_sqr(); + + /* "core/core2.pyx":419 + * for i in range(self.n_verts): + * tmp_dist = (self.verts[i] - p).len_sqr() + * if tmp_dist < dist: # <<<<<<<<<<<<<< + * dist = tmp_dist + * idx = i + */ + +# line 419 "core/core2.pyx" + __pyx_t_5 = ((__pyx_v_tmp_dist < __pyx_v_dist) != 0); + +# line 419 "core/core2.pyx" + if (__pyx_t_5) { + + /* "core/core2.pyx":420 + * tmp_dist = (self.verts[i] - p).len_sqr() + * if tmp_dist < dist: + * dist = tmp_dist # <<<<<<<<<<<<<< + * idx = i + * + */ + +# line 420 "core/core2.pyx" + __pyx_v_dist = __pyx_v_tmp_dist; + + /* "core/core2.pyx":421 + * if tmp_dist < dist: + * dist = tmp_dist + * idx = i # <<<<<<<<<<<<<< + * + * return idx, self.verts[idx].v + */ + +# line 421 "core/core2.pyx" + __pyx_v_idx = __pyx_v_i; + + /* "core/core2.pyx":419 + * for i in range(self.n_verts): + * tmp_dist = (self.verts[i] - p).len_sqr() + * if tmp_dist < dist: # <<<<<<<<<<<<<< + * dist = tmp_dist + * idx = i + */ + +# line 419 "core/core2.pyx" + } + +# line 419 "core/core2.pyx" + } + + /* "core/core2.pyx":423 + * idx = i + * + * return idx, self.verts[idx].v # <<<<<<<<<<<<<< + * + * + */ + +# line 423 "core/core2.pyx" + __Pyx_XDECREF(__pyx_r); + +# line 423 "core/core2.pyx" + __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_idx); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 423, __pyx_L1_error) + +# line 423 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_6); + +# line 423 "core/core2.pyx" + __pyx_t_7 = __Pyx_carray_to_py_float((__pyx_v_self->verts[__pyx_v_idx]).v, 3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 423, __pyx_L1_error) + +# line 423 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_7); + +# line 423 "core/core2.pyx" + __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 423, __pyx_L1_error) + +# line 423 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_8); + +# line 423 "core/core2.pyx" + __Pyx_GIVEREF(__pyx_t_6); + +# line 423 "core/core2.pyx" + PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); + +# line 423 "core/core2.pyx" + __Pyx_GIVEREF(__pyx_t_7); + +# line 423 "core/core2.pyx" + PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_7); + +# line 423 "core/core2.pyx" + __pyx_t_6 = 0; + +# line 423 "core/core2.pyx" + __pyx_t_7 = 0; + +# line 423 "core/core2.pyx" + __pyx_r = __pyx_t_8; + +# line 423 "core/core2.pyx" + __pyx_t_8 = 0; + +# line 423 "core/core2.pyx" + goto __pyx_L0; + + /* "core/core2.pyx":410 + * + * + * def closest_vert(self, pos): # <<<<<<<<<<<<<< + * cdef vec3 p + * cdef float tmp_dist, dist = INFINITY + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_AddTraceback("softwrap_core2.Mesh.closest_vert", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":426 + * + * + * def __dealloc__(self): # <<<<<<<<<<<<<< + * fraeee(self.verts) + * fraeee(self.triangles) + */ + +/* Python wrapper */ +static void __pyx_pw_14softwrap_core2_4Mesh_15__dealloc__(PyObject *__pyx_v_self); /*proto*/ +static void __pyx_pw_14softwrap_core2_4Mesh_15__dealloc__(PyObject *__pyx_v_self) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0); + __pyx_pf_14softwrap_core2_4Mesh_14__dealloc__(((struct __pyx_obj_14softwrap_core2_Mesh *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); +} + +static void __pyx_pf_14softwrap_core2_4Mesh_14__dealloc__(struct __pyx_obj_14softwrap_core2_Mesh *__pyx_v_self) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__dealloc__", 0); + + /* "core/core2.pyx":427 + * + * def __dealloc__(self): + * fraeee(self.verts) # <<<<<<<<<<<<<< + * fraeee(self.triangles) + * fraeee(self.centroids) + */ + +# line 427 "core/core2.pyx" + __pyx_f_14softwrap_core2_fraeee(__pyx_v_self->verts); + + /* "core/core2.pyx":428 + * def __dealloc__(self): + * fraeee(self.verts) + * fraeee(self.triangles) # <<<<<<<<<<<<<< + * fraeee(self.centroids) + * fraeee(self.face_normals) + */ + +# line 428 "core/core2.pyx" + __pyx_f_14softwrap_core2_fraeee(__pyx_v_self->triangles); + + /* "core/core2.pyx":429 + * fraeee(self.verts) + * fraeee(self.triangles) + * fraeee(self.centroids) # <<<<<<<<<<<<<< + * fraeee(self.face_normals) + * fraeee(self.vert_normals) + */ + +# line 429 "core/core2.pyx" + __pyx_f_14softwrap_core2_fraeee(__pyx_v_self->centroids); + + /* "core/core2.pyx":430 + * fraeee(self.triangles) + * fraeee(self.centroids) + * fraeee(self.face_normals) # <<<<<<<<<<<<<< + * fraeee(self.vert_normals) + * + */ + +# line 430 "core/core2.pyx" + __pyx_f_14softwrap_core2_fraeee(__pyx_v_self->face_normals); + + /* "core/core2.pyx":431 + * fraeee(self.centroids) + * fraeee(self.face_normals) + * fraeee(self.vert_normals) # <<<<<<<<<<<<<< + * + * + */ + +# line 431 "core/core2.pyx" + __pyx_f_14softwrap_core2_fraeee(__pyx_v_self->vert_normals); + + /* "core/core2.pyx":426 + * + * + * def __dealloc__(self): # <<<<<<<<<<<<<< + * fraeee(self.verts) + * fraeee(self.triangles) + */ + + /* function exit code */ + __Pyx_RefNannyFinishContext(); +} + +/* "(tree fragment)":1 + * def __reduce_cython__(self): # <<<<<<<<<<<<<< + * raise TypeError("self.centroids,self.face_normals,self.triangles,self.vert_normals,self.verts cannot be converted to a Python object for pickling") + * def __setstate_cython__(self, __pyx_state): + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_4Mesh_17__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_4Mesh_17__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0); + __pyx_r = __pyx_pf_14softwrap_core2_4Mesh_16__reduce_cython__(((struct __pyx_obj_14softwrap_core2_Mesh *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_4Mesh_16__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_14softwrap_core2_Mesh *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__reduce_cython__", 0); + + /* "(tree fragment)":2 + * def __reduce_cython__(self): + * raise TypeError("self.centroids,self.face_normals,self.triangles,self.vert_normals,self.verts cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<< + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("self.centroids,self.face_normals,self.triangles,self.vert_normals,self.verts cannot be converted to a Python object for pickling") + */ + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __PYX_ERR(1, 2, __pyx_L1_error) + + /* "(tree fragment)":1 + * def __reduce_cython__(self): # <<<<<<<<<<<<<< + * raise TypeError("self.centroids,self.face_normals,self.triangles,self.vert_normals,self.verts cannot be converted to a Python object for pickling") + * def __setstate_cython__(self, __pyx_state): + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("softwrap_core2.Mesh.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "(tree fragment)":3 + * def __reduce_cython__(self): + * raise TypeError("self.centroids,self.face_normals,self.triangles,self.vert_normals,self.verts cannot be converted to a Python object for pickling") + * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< + * raise TypeError("self.centroids,self.face_normals,self.triangles,self.vert_normals,self.verts cannot be converted to a Python object for pickling") + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_4Mesh_19__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_4Mesh_19__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0); + __pyx_r = __pyx_pf_14softwrap_core2_4Mesh_18__setstate_cython__(((struct __pyx_obj_14softwrap_core2_Mesh *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_4Mesh_18__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_14softwrap_core2_Mesh *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__setstate_cython__", 0); + + /* "(tree fragment)":4 + * raise TypeError("self.centroids,self.face_normals,self.triangles,self.vert_normals,self.verts cannot be converted to a Python object for pickling") + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("self.centroids,self.face_normals,self.triangles,self.vert_normals,self.verts cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<< + */ + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __PYX_ERR(1, 4, __pyx_L1_error) + + /* "(tree fragment)":3 + * def __reduce_cython__(self): + * raise TypeError("self.centroids,self.face_normals,self.triangles,self.vert_normals,self.verts cannot be converted to a Python object for pickling") + * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< + * raise TypeError("self.centroids,self.face_normals,self.triangles,self.vert_normals,self.verts cannot be converted to a Python object for pickling") + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("softwrap_core2.Mesh.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":564 + * Mesh mesh + * + * def __cinit__(self, Mesh mesh): # <<<<<<<<<<<<<< + * self.mesh = mesh + * if mesh == None: + */ + +/* Python wrapper */ +static int __pyx_pw_14softwrap_core2_3BVH_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pw_14softwrap_core2_3BVH_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + struct __pyx_obj_14softwrap_core2_Mesh *__pyx_v_mesh = 0; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_mesh,0}; + PyObject* values[1] = {0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + CYTHON_FALLTHROUGH; + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_mesh)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(0, 564, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 1) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + } + __pyx_v_mesh = ((struct __pyx_obj_14softwrap_core2_Mesh *)values[0]); + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 564, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("softwrap_core2.BVH.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_mesh), __pyx_ptype_14softwrap_core2_Mesh, 1, "mesh", 0))) __PYX_ERR(0, 564, __pyx_L1_error) + __pyx_r = __pyx_pf_14softwrap_core2_3BVH___cinit__(((struct __pyx_obj_14softwrap_core2_BVH *)__pyx_v_self), __pyx_v_mesh); + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_14softwrap_core2_3BVH___cinit__(struct __pyx_obj_14softwrap_core2_BVH *__pyx_v_self, struct __pyx_obj_14softwrap_core2_Mesh *__pyx_v_mesh) { + int __pyx_v_i; + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_t_2; + int __pyx_t_3; + void *__pyx_t_4; + int __pyx_t_5; + int __pyx_t_6; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__cinit__", 0); + + /* "core/core2.pyx":565 + * + * def __cinit__(self, Mesh mesh): + * self.mesh = mesh # <<<<<<<<<<<<<< + * if mesh == None: + * raise ValueError + */ + +# line 565 "core/core2.pyx" + __Pyx_INCREF(((PyObject *)__pyx_v_mesh)); + +# line 565 "core/core2.pyx" + __Pyx_GIVEREF(((PyObject *)__pyx_v_mesh)); + +# line 565 "core/core2.pyx" + __Pyx_GOTREF(__pyx_v_self->mesh); + +# line 565 "core/core2.pyx" + __Pyx_DECREF(((PyObject *)__pyx_v_self->mesh)); + +# line 565 "core/core2.pyx" + __pyx_v_self->mesh = __pyx_v_mesh; + + /* "core/core2.pyx":566 + * def __cinit__(self, Mesh mesh): + * self.mesh = mesh + * if mesh == None: # <<<<<<<<<<<<<< + * raise ValueError + * + */ + +# line 566 "core/core2.pyx" + __pyx_t_1 = PyObject_RichCompare(((PyObject *)__pyx_v_mesh), Py_None, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 566, __pyx_L1_error) + +# line 566 "core/core2.pyx" + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 566, __pyx_L1_error) + +# line 566 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + +# line 566 "core/core2.pyx" + if (unlikely(__pyx_t_2)) { + + /* "core/core2.pyx":567 + * self.mesh = mesh + * if mesh == None: + * raise ValueError # <<<<<<<<<<<<<< + * + * self.size = mesh.n_triangles + */ + +# line 567 "core/core2.pyx" + __Pyx_Raise(__pyx_builtin_ValueError, 0, 0, 0); + +# line 567 "core/core2.pyx" + __PYX_ERR(0, 567, __pyx_L1_error) + + /* "core/core2.pyx":566 + * def __cinit__(self, Mesh mesh): + * self.mesh = mesh + * if mesh == None: # <<<<<<<<<<<<<< + * raise ValueError + * + */ + +# line 566 "core/core2.pyx" + } + + /* "core/core2.pyx":569 + * raise ValueError + * + * self.size = mesh.n_triangles # <<<<<<<<<<<<<< + * self.leaves = maelloc(sizeof(BvhNodeLeaf) * self.size, __LINE__) + * self.boxes = maelloc(sizeof(BvhNodeBox) * self.size, __LINE__) + */ + +# line 569 "core/core2.pyx" + __pyx_t_3 = __pyx_v_mesh->n_triangles; + +# line 569 "core/core2.pyx" + __pyx_v_self->size = __pyx_t_3; + + /* "core/core2.pyx":570 + * + * self.size = mesh.n_triangles + * self.leaves = maelloc(sizeof(BvhNodeLeaf) * self.size, __LINE__) # <<<<<<<<<<<<<< + * self.boxes = maelloc(sizeof(BvhNodeBox) * self.size, __LINE__) + * self.free_box_idx = self.size + */ + +# line 570 "core/core2.pyx" + __pyx_t_4 = __pyx_f_14softwrap_core2_maelloc(((sizeof(BvhNodeLeaf)) * __pyx_v_self->size), __LINE__); if (unlikely(__pyx_t_4 == ((void *)NULL))) __PYX_ERR(0, 570, __pyx_L1_error) + +# line 570 "core/core2.pyx" + __pyx_v_self->leaves = ((BvhNodeLeaf *)__pyx_t_4); + + /* "core/core2.pyx":571 + * self.size = mesh.n_triangles + * self.leaves = maelloc(sizeof(BvhNodeLeaf) * self.size, __LINE__) + * self.boxes = maelloc(sizeof(BvhNodeBox) * self.size, __LINE__) # <<<<<<<<<<<<<< + * self.free_box_idx = self.size + * + */ + +# line 571 "core/core2.pyx" + __pyx_t_4 = __pyx_f_14softwrap_core2_maelloc(((sizeof(BvhNodeBox)) * __pyx_v_self->size), __LINE__); if (unlikely(__pyx_t_4 == ((void *)NULL))) __PYX_ERR(0, 571, __pyx_L1_error) + +# line 571 "core/core2.pyx" + __pyx_v_self->boxes = ((BvhNodeBox *)__pyx_t_4); + + /* "core/core2.pyx":572 + * self.leaves = maelloc(sizeof(BvhNodeLeaf) * self.size, __LINE__) + * self.boxes = maelloc(sizeof(BvhNodeBox) * self.size, __LINE__) + * self.free_box_idx = self.size # <<<<<<<<<<<<<< + * + * cdef int i + */ + +# line 572 "core/core2.pyx" + __pyx_t_3 = __pyx_v_self->size; + +# line 572 "core/core2.pyx" + __pyx_v_self->free_box_idx = __pyx_t_3; + + /* "core/core2.pyx":575 + * + * cdef int i + * with nogil: # <<<<<<<<<<<<<< + * for i in prange(self.size): + * self.leaves[i].index = i + */ + +# line 575 "core/core2.pyx" + { + +# line 575 "core/core2.pyx" + #ifdef WITH_THREAD + +# line 575 "core/core2.pyx" + PyThreadState *_save; + +# line 575 "core/core2.pyx" + Py_UNBLOCK_THREADS + +# line 575 "core/core2.pyx" + __Pyx_FastGIL_Remember(); + +# line 575 "core/core2.pyx" + #endif + /*try:*/ { + + /* "core/core2.pyx":576 + * cdef int i + * with nogil: + * for i in prange(self.size): # <<<<<<<<<<<<<< + * self.leaves[i].index = i + * self.boxes[i].split_axis = -1; + */ + +# line 576 "core/core2.pyx" + __pyx_t_3 = __pyx_v_self->size; + +# line 576 "core/core2.pyx" + if ((1 == 0)) abort(); + +# line 576 "core/core2.pyx" + { + +# line 576 "core/core2.pyx" + #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))))) + +# line 576 "core/core2.pyx" + #undef likely + +# line 576 "core/core2.pyx" + #undef unlikely + #define likely(x) (x) + #define unlikely(x) (x) + +# line 576 "core/core2.pyx" + #endif + +# line 576 "core/core2.pyx" + __pyx_t_6 = (__pyx_t_3 - 0 + 1 - 1/abs(1)) / 1; + +# line 576 "core/core2.pyx" + if (__pyx_t_6 > 0) + +# line 576 "core/core2.pyx" + { + +# line 576 "core/core2.pyx" + #ifdef _OPENMP + +# line 576 "core/core2.pyx" + #pragma omp parallel + #endif /* _OPENMP */ + { + #ifdef _OPENMP + #pragma omp for firstprivate(__pyx_v_i) lastprivate(__pyx_v_i) + #endif /* _OPENMP */ + for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_6; __pyx_t_5++){ + { + __pyx_v_i = (int)(0 + 1 * __pyx_t_5); + + /* "core/core2.pyx":577 + * with nogil: + * for i in prange(self.size): + * self.leaves[i].index = i # <<<<<<<<<<<<<< + * self.boxes[i].split_axis = -1; + * self.boxes[i].min = vec3(INFINITY); + */ + +# line 577 "core/core2.pyx" + (__pyx_v_self->leaves[__pyx_v_i]).index = __pyx_v_i; + + /* "core/core2.pyx":578 + * for i in prange(self.size): + * self.leaves[i].index = i + * self.boxes[i].split_axis = -1; # <<<<<<<<<<<<<< + * self.boxes[i].min = vec3(INFINITY); + * self.boxes[i].max = vec3(-INFINITY); + */ + +# line 578 "core/core2.pyx" + (__pyx_v_self->boxes[__pyx_v_i]).split_axis = -1; + + /* "core/core2.pyx":579 + * self.leaves[i].index = i + * self.boxes[i].split_axis = -1; + * self.boxes[i].min = vec3(INFINITY); # <<<<<<<<<<<<<< + * self.boxes[i].max = vec3(-INFINITY); + * + */ + +# line 579 "core/core2.pyx" + (__pyx_v_self->boxes[__pyx_v_i]).min = vec3(INFINITY); + + /* "core/core2.pyx":580 + * self.boxes[i].split_axis = -1; + * self.boxes[i].min = vec3(INFINITY); + * self.boxes[i].max = vec3(-INFINITY); # <<<<<<<<<<<<<< + * + * self.mesh.update_centroids() + */ + +# line 580 "core/core2.pyx" + (__pyx_v_self->boxes[__pyx_v_i]).max = vec3((-INFINITY)); + +# line 580 "core/core2.pyx" + } + +# line 580 "core/core2.pyx" + } + +# line 580 "core/core2.pyx" + } + +# line 580 "core/core2.pyx" + } + +# line 580 "core/core2.pyx" + } + +# line 580 "core/core2.pyx" + #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))))) + +# line 580 "core/core2.pyx" + #undef likely + +# line 580 "core/core2.pyx" + #undef unlikely + #define likely(x) __builtin_expect(!!(x), 1) + #define unlikely(x) __builtin_expect(!!(x), 0) + +# line 580 "core/core2.pyx" + #endif + +# line 580 "core/core2.pyx" + } + + /* "core/core2.pyx":575 + * + * cdef int i + * with nogil: # <<<<<<<<<<<<<< + * for i in prange(self.size): + * self.leaves[i].index = i + */ + /*finally:*/ { + /*normal exit:*/{ + #ifdef WITH_THREAD + __Pyx_FastGIL_Forget(); + Py_BLOCK_THREADS + #endif + goto __pyx_L6; + } + __pyx_L6:; + } + } + + /* "core/core2.pyx":582 + * self.boxes[i].max = vec3(-INFINITY); + * + * self.mesh.update_centroids() # <<<<<<<<<<<<<< + * self.mesh.update_face_normals() + * self.root = self.build_tree(self.leaves, self.size) + */ + +# line 582 "core/core2.pyx" + __pyx_f_14softwrap_core2_4Mesh_update_centroids(__pyx_v_self->mesh, 0); + + /* "core/core2.pyx":583 + * + * self.mesh.update_centroids() + * self.mesh.update_face_normals() # <<<<<<<<<<<<<< + * self.root = self.build_tree(self.leaves, self.size) + * + */ + +# line 583 "core/core2.pyx" + __pyx_f_14softwrap_core2_4Mesh_update_face_normals(__pyx_v_self->mesh, 0); + + /* "core/core2.pyx":584 + * self.mesh.update_centroids() + * self.mesh.update_face_normals() + * self.root = self.build_tree(self.leaves, self.size) # <<<<<<<<<<<<<< + * + * def __dealloc__(self): + */ + +# line 584 "core/core2.pyx" + __pyx_v_self->root = __pyx_f_14softwrap_core2_3BVH_build_tree(__pyx_v_self, __pyx_v_self->leaves, __pyx_v_self->size); + + /* "core/core2.pyx":564 + * Mesh mesh + * + * def __cinit__(self, Mesh mesh): # <<<<<<<<<<<<<< + * self.mesh = mesh + * if mesh == None: + */ + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("softwrap_core2.BVH.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":586 + * self.root = self.build_tree(self.leaves, self.size) + * + * def __dealloc__(self): # <<<<<<<<<<<<<< + * fraeee(self.leaves) + * fraeee(self.boxes) + */ + +/* Python wrapper */ +static void __pyx_pw_14softwrap_core2_3BVH_3__dealloc__(PyObject *__pyx_v_self); /*proto*/ +static void __pyx_pw_14softwrap_core2_3BVH_3__dealloc__(PyObject *__pyx_v_self) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0); + __pyx_pf_14softwrap_core2_3BVH_2__dealloc__(((struct __pyx_obj_14softwrap_core2_BVH *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); +} + +static void __pyx_pf_14softwrap_core2_3BVH_2__dealloc__(struct __pyx_obj_14softwrap_core2_BVH *__pyx_v_self) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__dealloc__", 0); + + /* "core/core2.pyx":587 + * + * def __dealloc__(self): + * fraeee(self.leaves) # <<<<<<<<<<<<<< + * fraeee(self.boxes) + * + */ + +# line 587 "core/core2.pyx" + __pyx_f_14softwrap_core2_fraeee(__pyx_v_self->leaves); + + /* "core/core2.pyx":588 + * def __dealloc__(self): + * fraeee(self.leaves) + * fraeee(self.boxes) # <<<<<<<<<<<<<< + * + * cdef inline BvhNodeBox* pop_box(self) nogil: + */ + +# line 588 "core/core2.pyx" + __pyx_f_14softwrap_core2_fraeee(__pyx_v_self->boxes); + + /* "core/core2.pyx":586 + * self.root = self.build_tree(self.leaves, self.size) + * + * def __dealloc__(self): # <<<<<<<<<<<<<< + * fraeee(self.leaves) + * fraeee(self.boxes) + */ + + /* function exit code */ + __Pyx_RefNannyFinishContext(); +} + +/* "core/core2.pyx":590 + * fraeee(self.boxes) + * + * cdef inline BvhNodeBox* pop_box(self) nogil: # <<<<<<<<<<<<<< + * self.free_box_idx -= 1 + * # if self.free_box_idx < 0: + */ + + +# line 590 "core/core2.pyx" +static CYTHON_INLINE BvhNodeBox *__pyx_f_14softwrap_core2_3BVH_pop_box(struct __pyx_obj_14softwrap_core2_BVH *__pyx_v_self) { + +# line 590 "core/core2.pyx" + BvhNodeBox *__pyx_r; + + /* "core/core2.pyx":591 + * + * cdef inline BvhNodeBox* pop_box(self) nogil: + * self.free_box_idx -= 1 # <<<<<<<<<<<<<< + * # if self.free_box_idx < 0: + * # raise RuntimeError('Ran out of boxes') + */ + +# line 591 "core/core2.pyx" + __pyx_v_self->free_box_idx = (__pyx_v_self->free_box_idx - 1); + + /* "core/core2.pyx":595 + * # raise RuntimeError('Ran out of boxes') + * + * return & self.boxes[self.free_box_idx] # <<<<<<<<<<<<<< + * + * cdef BvhNode* build_tree(self, BvhNodeLeaf* leaves, int size) nogil: + */ + +# line 595 "core/core2.pyx" + __pyx_r = (&(__pyx_v_self->boxes[__pyx_v_self->free_box_idx])); + +# line 595 "core/core2.pyx" + goto __pyx_L0; + + /* "core/core2.pyx":590 + * fraeee(self.boxes) + * + * cdef inline BvhNodeBox* pop_box(self) nogil: # <<<<<<<<<<<<<< + * self.free_box_idx -= 1 + * # if self.free_box_idx < 0: + */ + + /* function exit code */ + __pyx_L0:; + return __pyx_r; +} + +/* "core/core2.pyx":597 + * return & self.boxes[self.free_box_idx] + * + * cdef BvhNode* build_tree(self, BvhNodeLeaf* leaves, int size) nogil: # <<<<<<<<<<<<<< + * cdef int i, j + * + */ + + +# line 597 "core/core2.pyx" +static union BvhNode *__pyx_f_14softwrap_core2_3BVH_build_tree(struct __pyx_obj_14softwrap_core2_BVH *__pyx_v_self, BvhNodeLeaf *__pyx_v_leaves, int __pyx_v_size) { + +# line 597 "core/core2.pyx" + int __pyx_v_i; + +# line 597 "core/core2.pyx" + int __pyx_v_j; + +# line 597 "core/core2.pyx" + BvhNodeBox *__pyx_v_box; + +# line 597 "core/core2.pyx" + vec3 __pyx_v_median; + +# line 597 "core/core2.pyx" + int __pyx_v_axis; + +# line 597 "core/core2.pyx" + union BvhNode *__pyx_r; + +# line 597 "core/core2.pyx" + int __pyx_t_1; + +# line 597 "core/core2.pyx" + int __pyx_t_2; + +# line 597 "core/core2.pyx" + int __pyx_t_3; + +# line 597 "core/core2.pyx" + int __pyx_t_4; + +# line 597 "core/core2.pyx" + int __pyx_t_5; + +# line 597 "core/core2.pyx" + int __pyx_t_6; + +# line 597 "core/core2.pyx" + int __pyx_t_7; + + /* "core/core2.pyx":600 + * cdef int i, j + * + * if size == 1: # <<<<<<<<<<<<<< + * return leaves + * + */ + +# line 600 "core/core2.pyx" + __pyx_t_1 = ((__pyx_v_size == 1) != 0); + +# line 600 "core/core2.pyx" + if (__pyx_t_1) { + + /* "core/core2.pyx":601 + * + * if size == 1: + * return leaves # <<<<<<<<<<<<<< + * + * cdef BvhNodeBox * box = self.pop_box() + */ + +# line 601 "core/core2.pyx" + __pyx_r = ((union BvhNode *)__pyx_v_leaves); + +# line 601 "core/core2.pyx" + goto __pyx_L0; + + /* "core/core2.pyx":600 + * cdef int i, j + * + * if size == 1: # <<<<<<<<<<<<<< + * return leaves + * + */ + +# line 600 "core/core2.pyx" + } + + /* "core/core2.pyx":603 + * return leaves + * + * cdef BvhNodeBox * box = self.pop_box() # <<<<<<<<<<<<<< + * + * for i in range(size): + */ + +# line 603 "core/core2.pyx" + __pyx_v_box = __pyx_f_14softwrap_core2_3BVH_pop_box(__pyx_v_self); + + /* "core/core2.pyx":605 + * cdef BvhNodeBox * box = self.pop_box() + * + * for i in range(size): # <<<<<<<<<<<<<< + * for j in range(3): + * box.expand(self.mesh.tri_vert(leaves[i].index, j)) + */ + +# line 605 "core/core2.pyx" + __pyx_t_2 = __pyx_v_size; + +# line 605 "core/core2.pyx" + __pyx_t_3 = __pyx_t_2; + +# line 605 "core/core2.pyx" + for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { + +# line 605 "core/core2.pyx" + __pyx_v_i = __pyx_t_4; + + /* "core/core2.pyx":606 + * + * for i in range(size): + * for j in range(3): # <<<<<<<<<<<<<< + * box.expand(self.mesh.tri_vert(leaves[i].index, j)) + * + */ + +# line 606 "core/core2.pyx" + for (__pyx_t_5 = 0; __pyx_t_5 < 3; __pyx_t_5+=1) { + +# line 606 "core/core2.pyx" + __pyx_v_j = __pyx_t_5; + + /* "core/core2.pyx":607 + * for i in range(size): + * for j in range(3): + * box.expand(self.mesh.tri_vert(leaves[i].index, j)) # <<<<<<<<<<<<<< + * + * cdef vec3 median = (box.max + box.min) * 0.5 + */ + +# line 607 "core/core2.pyx" + __pyx_v_box->expand(__pyx_f_14softwrap_core2_4Mesh_tri_vert(__pyx_v_self->mesh, (__pyx_v_leaves[__pyx_v_i]).index, __pyx_v_j)); + +# line 607 "core/core2.pyx" + } + +# line 607 "core/core2.pyx" + } + + /* "core/core2.pyx":609 + * box.expand(self.mesh.tri_vert(leaves[i].index, j)) + * + * cdef vec3 median = (box.max + box.min) * 0.5 # <<<<<<<<<<<<<< + * + * cdef int axis = box.major_axis() + */ + +# line 609 "core/core2.pyx" + __pyx_v_median = ((__pyx_v_box->max + __pyx_v_box->min) * 0.5); + + /* "core/core2.pyx":611 + * cdef vec3 median = (box.max + box.min) * 0.5 + * + * cdef int axis = box.major_axis() # <<<<<<<<<<<<<< + * box.set_split_axis(axis) + * box.split_pos = median.v[axis] + */ + +# line 611 "core/core2.pyx" + __pyx_v_axis = __pyx_v_box->major_axis(); + + /* "core/core2.pyx":612 + * + * cdef int axis = box.major_axis() + * box.set_split_axis(axis) # <<<<<<<<<<<<<< + * box.split_pos = median.v[axis] + * + */ + +# line 612 "core/core2.pyx" + __pyx_v_box->set_split_axis(__pyx_v_axis); + + /* "core/core2.pyx":613 + * cdef int axis = box.major_axis() + * box.set_split_axis(axis) + * box.split_pos = median.v[axis] # <<<<<<<<<<<<<< + * + * j = 0 + */ + +# line 613 "core/core2.pyx" + __pyx_v_box->split_pos = (__pyx_v_median.v[__pyx_v_axis]); + + /* "core/core2.pyx":615 + * box.split_pos = median.v[axis] + * + * j = 0 # <<<<<<<<<<<<<< + * for i in range(size): + * if self.mesh.centroids[leaves[i].index].v[axis] < median.v[axis]: + */ + +# line 615 "core/core2.pyx" + __pyx_v_j = 0; + + /* "core/core2.pyx":616 + * + * j = 0 + * for i in range(size): # <<<<<<<<<<<<<< + * if self.mesh.centroids[leaves[i].index].v[axis] < median.v[axis]: + * leaves[i].index, leaves[j].index = leaves[j].index, leaves[i].index + */ + +# line 616 "core/core2.pyx" + __pyx_t_2 = __pyx_v_size; + +# line 616 "core/core2.pyx" + __pyx_t_3 = __pyx_t_2; + +# line 616 "core/core2.pyx" + for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { + +# line 616 "core/core2.pyx" + __pyx_v_i = __pyx_t_4; + + /* "core/core2.pyx":617 + * j = 0 + * for i in range(size): + * if self.mesh.centroids[leaves[i].index].v[axis] < median.v[axis]: # <<<<<<<<<<<<<< + * leaves[i].index, leaves[j].index = leaves[j].index, leaves[i].index + * j += 1 + */ + +# line 617 "core/core2.pyx" + __pyx_t_1 = ((((__pyx_v_self->mesh->centroids[(__pyx_v_leaves[__pyx_v_i]).index]).v[__pyx_v_axis]) < (__pyx_v_median.v[__pyx_v_axis])) != 0); + +# line 617 "core/core2.pyx" + if (__pyx_t_1) { + + /* "core/core2.pyx":618 + * for i in range(size): + * if self.mesh.centroids[leaves[i].index].v[axis] < median.v[axis]: + * leaves[i].index, leaves[j].index = leaves[j].index, leaves[i].index # <<<<<<<<<<<<<< + * j += 1 + * + */ + +# line 618 "core/core2.pyx" + __pyx_t_5 = (__pyx_v_leaves[__pyx_v_j]).index; + +# line 618 "core/core2.pyx" + __pyx_t_6 = (__pyx_v_leaves[__pyx_v_i]).index; + +# line 618 "core/core2.pyx" + (__pyx_v_leaves[__pyx_v_i]).index = __pyx_t_5; + +# line 618 "core/core2.pyx" + (__pyx_v_leaves[__pyx_v_j]).index = __pyx_t_6; + + /* "core/core2.pyx":619 + * if self.mesh.centroids[leaves[i].index].v[axis] < median.v[axis]: + * leaves[i].index, leaves[j].index = leaves[j].index, leaves[i].index + * j += 1 # <<<<<<<<<<<<<< + * + * if j == 0 or j == size: + */ + +# line 619 "core/core2.pyx" + __pyx_v_j = (__pyx_v_j + 1); + + /* "core/core2.pyx":617 + * j = 0 + * for i in range(size): + * if self.mesh.centroids[leaves[i].index].v[axis] < median.v[axis]: # <<<<<<<<<<<<<< + * leaves[i].index, leaves[j].index = leaves[j].index, leaves[i].index + * j += 1 + */ + +# line 617 "core/core2.pyx" + } + +# line 617 "core/core2.pyx" + } + + /* "core/core2.pyx":621 + * j += 1 + * + * if j == 0 or j == size: # <<<<<<<<<<<<<< + * j = size // 2 + * + */ + +# line 621 "core/core2.pyx" + __pyx_t_7 = ((__pyx_v_j == 0) != 0); + +# line 621 "core/core2.pyx" + if (!__pyx_t_7) { + +# line 621 "core/core2.pyx" + } else { + +# line 621 "core/core2.pyx" + __pyx_t_1 = __pyx_t_7; + +# line 621 "core/core2.pyx" + goto __pyx_L12_bool_binop_done; + +# line 621 "core/core2.pyx" + } + +# line 621 "core/core2.pyx" + __pyx_t_7 = ((__pyx_v_j == __pyx_v_size) != 0); + +# line 621 "core/core2.pyx" + __pyx_t_1 = __pyx_t_7; + +# line 621 "core/core2.pyx" + __pyx_L12_bool_binop_done:; + +# line 621 "core/core2.pyx" + if (__pyx_t_1) { + + /* "core/core2.pyx":622 + * + * if j == 0 or j == size: + * j = size // 2 # <<<<<<<<<<<<<< + * + * box.nodes[0] = self.build_tree(leaves, j) + */ + +# line 622 "core/core2.pyx" + __pyx_v_j = (__pyx_v_size / 2); + + /* "core/core2.pyx":621 + * j += 1 + * + * if j == 0 or j == size: # <<<<<<<<<<<<<< + * j = size // 2 + * + */ + +# line 621 "core/core2.pyx" + } + + /* "core/core2.pyx":624 + * j = size // 2 + * + * box.nodes[0] = self.build_tree(leaves, j) # <<<<<<<<<<<<<< + * box.nodes[1] = self.build_tree(&leaves[j], size - j) + * return box + */ + +# line 624 "core/core2.pyx" + (__pyx_v_box->nodes[0]) = __pyx_f_14softwrap_core2_3BVH_build_tree(__pyx_v_self, __pyx_v_leaves, __pyx_v_j); + + /* "core/core2.pyx":625 + * + * box.nodes[0] = self.build_tree(leaves, j) + * box.nodes[1] = self.build_tree(&leaves[j], size - j) # <<<<<<<<<<<<<< + * return box + * + */ + +# line 625 "core/core2.pyx" + (__pyx_v_box->nodes[1]) = __pyx_f_14softwrap_core2_3BVH_build_tree(__pyx_v_self, (&(__pyx_v_leaves[__pyx_v_j])), (__pyx_v_size - __pyx_v_j)); + + /* "core/core2.pyx":626 + * box.nodes[0] = self.build_tree(leaves, j) + * box.nodes[1] = self.build_tree(&leaves[j], size - j) + * return box # <<<<<<<<<<<<<< + * + * def find_nearest(self, _p): + */ + +# line 626 "core/core2.pyx" + __pyx_r = ((union BvhNode *)__pyx_v_box); + +# line 626 "core/core2.pyx" + goto __pyx_L0; + + /* "core/core2.pyx":597 + * return & self.boxes[self.free_box_idx] + * + * cdef BvhNode* build_tree(self, BvhNodeLeaf* leaves, int size) nogil: # <<<<<<<<<<<<<< + * cdef int i, j + * + */ + + /* function exit code */ + __pyx_L0:; + return __pyx_r; +} + +/* "core/core2.pyx":628 + * return box + * + * def find_nearest(self, _p): # <<<<<<<<<<<<<< + * cdef vec3 p + * p.v = _p + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_3BVH_5find_nearest(PyObject *__pyx_v_self, PyObject *__pyx_v__p); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_3BVH_5find_nearest(PyObject *__pyx_v_self, PyObject *__pyx_v__p) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("find_nearest (wrapper)", 0); + __pyx_r = __pyx_pf_14softwrap_core2_3BVH_4find_nearest(((struct __pyx_obj_14softwrap_core2_BVH *)__pyx_v_self), ((PyObject *)__pyx_v__p)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_3BVH_4find_nearest(struct __pyx_obj_14softwrap_core2_BVH *__pyx_v_self, PyObject *__pyx_v__p) { + vec3 __pyx_v_p; + struct BvhNearestResult __pyx_v_result; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + float __pyx_t_1[3]; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("find_nearest", 0); + + /* "core/core2.pyx":630 + * def find_nearest(self, _p): + * cdef vec3 p + * p.v = _p # <<<<<<<<<<<<<< + * cdef BvhNearestResult result = self._find_nearest(p) + * return (result.point.v, result.tri_index, result.distance) + */ + +# line 630 "core/core2.pyx" + if (unlikely(__Pyx_carray_from_py_float(__pyx_v__p, __pyx_t_1, 3) < 0)) __PYX_ERR(0, 630, __pyx_L1_error) + +# line 630 "core/core2.pyx" + memcpy(&(__pyx_v_p.v[0]), __pyx_t_1, sizeof(__pyx_v_p.v[0]) * (3)); + + /* "core/core2.pyx":631 + * cdef vec3 p + * p.v = _p + * cdef BvhNearestResult result = self._find_nearest(p) # <<<<<<<<<<<<<< + * return (result.point.v, result.tri_index, result.distance) + * + */ + +# line 631 "core/core2.pyx" + __pyx_v_result = __pyx_f_14softwrap_core2_3BVH__find_nearest(__pyx_v_self, __pyx_v_p); + + /* "core/core2.pyx":632 + * p.v = _p + * cdef BvhNearestResult result = self._find_nearest(p) + * return (result.point.v, result.tri_index, result.distance) # <<<<<<<<<<<<<< + * + * cdef inline BvhNearestResult _find_nearest(self, vec3 p) nogil: + */ + +# line 632 "core/core2.pyx" + __Pyx_XDECREF(__pyx_r); + +# line 632 "core/core2.pyx" + __pyx_t_2 = __Pyx_carray_to_py_float(__pyx_v_result.point.v, 3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 632, __pyx_L1_error) + +# line 632 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_2); + +# line 632 "core/core2.pyx" + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_result.tri_index); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 632, __pyx_L1_error) + +# line 632 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_3); + +# line 632 "core/core2.pyx" + __pyx_t_4 = PyFloat_FromDouble(__pyx_v_result.distance); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 632, __pyx_L1_error) + +# line 632 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_4); + +# line 632 "core/core2.pyx" + __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 632, __pyx_L1_error) + +# line 632 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_5); + +# line 632 "core/core2.pyx" + __Pyx_GIVEREF(__pyx_t_2); + +# line 632 "core/core2.pyx" + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2); + +# line 632 "core/core2.pyx" + __Pyx_GIVEREF(__pyx_t_3); + +# line 632 "core/core2.pyx" + PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_3); + +# line 632 "core/core2.pyx" + __Pyx_GIVEREF(__pyx_t_4); + +# line 632 "core/core2.pyx" + PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_4); + +# line 632 "core/core2.pyx" + __pyx_t_2 = 0; + +# line 632 "core/core2.pyx" + __pyx_t_3 = 0; + +# line 632 "core/core2.pyx" + __pyx_t_4 = 0; + +# line 632 "core/core2.pyx" + __pyx_r = __pyx_t_5; + +# line 632 "core/core2.pyx" + __pyx_t_5 = 0; + +# line 632 "core/core2.pyx" + goto __pyx_L0; + + /* "core/core2.pyx":628 + * return box + * + * def find_nearest(self, _p): # <<<<<<<<<<<<<< + * cdef vec3 p + * p.v = _p + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("softwrap_core2.BVH.find_nearest", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":634 + * return (result.point.v, result.tri_index, result.distance) + * + * cdef inline BvhNearestResult _find_nearest(self, vec3 p) nogil: # <<<<<<<<<<<<<< + * cdef BvhNearestResult result + * result.distance = INFINITY + */ + + +# line 634 "core/core2.pyx" +static CYTHON_INLINE struct BvhNearestResult __pyx_f_14softwrap_core2_3BVH__find_nearest(struct __pyx_obj_14softwrap_core2_BVH *__pyx_v_self, vec3 __pyx_v_p) { + +# line 634 "core/core2.pyx" + struct BvhNearestResult __pyx_v_result; + +# line 634 "core/core2.pyx" + struct BvhNearestResult __pyx_r; + + /* "core/core2.pyx":636 + * cdef inline BvhNearestResult _find_nearest(self, vec3 p) nogil: + * cdef BvhNearestResult result + * result.distance = INFINITY # <<<<<<<<<<<<<< + * self.find_nearest_recursive( & p, & result, self.root) + * return result + */ + +# line 636 "core/core2.pyx" + __pyx_v_result.distance = INFINITY; + + /* "core/core2.pyx":637 + * cdef BvhNearestResult result + * result.distance = INFINITY + * self.find_nearest_recursive( & p, & result, self.root) # <<<<<<<<<<<<<< + * return result + * + */ + +# line 637 "core/core2.pyx" + __pyx_f_14softwrap_core2_3BVH_find_nearest_recursive(__pyx_v_self, (&__pyx_v_p), (&__pyx_v_result), __pyx_v_self->root); + + /* "core/core2.pyx":638 + * result.distance = INFINITY + * self.find_nearest_recursive( & p, & result, self.root) + * return result # <<<<<<<<<<<<<< + * + * cdef void find_nearest_recursive(self, vec3* p, BvhNearestResult* out, BvhNode* node) nogil: + */ + +# line 638 "core/core2.pyx" + __pyx_r = __pyx_v_result; + +# line 638 "core/core2.pyx" + goto __pyx_L0; + + /* "core/core2.pyx":634 + * return (result.point.v, result.tri_index, result.distance) + * + * cdef inline BvhNearestResult _find_nearest(self, vec3 p) nogil: # <<<<<<<<<<<<<< + * cdef BvhNearestResult result + * result.distance = INFINITY + */ + + /* function exit code */ + __pyx_L0:; + return __pyx_r; +} + +/* "core/core2.pyx":640 + * return result + * + * cdef void find_nearest_recursive(self, vec3* p, BvhNearestResult* out, BvhNode* node) nogil: # <<<<<<<<<<<<<< + * cdef vec3 closest + * cdef int i, axis + */ + + +# line 640 "core/core2.pyx" +static void __pyx_f_14softwrap_core2_3BVH_find_nearest_recursive(struct __pyx_obj_14softwrap_core2_BVH *__pyx_v_self, vec3 *__pyx_v_p, struct BvhNearestResult *__pyx_v_out, union BvhNode *__pyx_v_node) { + +# line 640 "core/core2.pyx" + vec3 __pyx_v_closest; + +# line 640 "core/core2.pyx" + int __pyx_v_i; + +# line 640 "core/core2.pyx" + int __pyx_v_axis; + +# line 640 "core/core2.pyx" + float __pyx_v_dist; + +# line 640 "core/core2.pyx" + int __pyx_t_1; + +# line 640 "core/core2.pyx" + int __pyx_t_2; + + /* "core/core2.pyx":644 + * cdef int i, axis + * cdef float dist + * if node.is_leaf(): # <<<<<<<<<<<<<< + * i = (< BvhNodeLeaf*>node).index + * closest = project_point_triangle(self.mesh.tri_vert_ptr(i, 0)[0], + */ + +# line 644 "core/core2.pyx" + __pyx_t_1 = (__pyx_v_node->is_leaf() != 0); + +# line 644 "core/core2.pyx" + if (__pyx_t_1) { + + /* "core/core2.pyx":645 + * cdef float dist + * if node.is_leaf(): + * i = (< BvhNodeLeaf*>node).index # <<<<<<<<<<<<<< + * closest = project_point_triangle(self.mesh.tri_vert_ptr(i, 0)[0], + * self.mesh.tri_vert_ptr(i, 1)[0], + */ + +# line 645 "core/core2.pyx" + __pyx_t_2 = ((BvhNodeLeaf *)__pyx_v_node)->index; + +# line 645 "core/core2.pyx" + __pyx_v_i = __pyx_t_2; + + /* "core/core2.pyx":646 + * if node.is_leaf(): + * i = (< BvhNodeLeaf*>node).index + * closest = project_point_triangle(self.mesh.tri_vert_ptr(i, 0)[0], # <<<<<<<<<<<<<< + * self.mesh.tri_vert_ptr(i, 1)[0], + * self.mesh.tri_vert_ptr(i, 2)[0], + */ + +# line 646 "core/core2.pyx" + __pyx_v_closest = project_point_triangle((__pyx_f_14softwrap_core2_4Mesh_tri_vert_ptr(__pyx_v_self->mesh, __pyx_v_i, 0)[0]), (__pyx_f_14softwrap_core2_4Mesh_tri_vert_ptr(__pyx_v_self->mesh, __pyx_v_i, 1)[0]), (__pyx_f_14softwrap_core2_4Mesh_tri_vert_ptr(__pyx_v_self->mesh, __pyx_v_i, 2)[0]), (__pyx_v_self->mesh->face_normals[__pyx_v_i]), (__pyx_v_p[0])); + + /* "core/core2.pyx":652 + * p[0]) + * + * dist = (closest - p[0]).len_sqr() # <<<<<<<<<<<<<< + * if dist < out.distance: + * out.point = closest + */ + +# line 652 "core/core2.pyx" + __pyx_v_dist = (__pyx_v_closest - (__pyx_v_p[0])).len_sqr(); + + /* "core/core2.pyx":653 + * + * dist = (closest - p[0]).len_sqr() + * if dist < out.distance: # <<<<<<<<<<<<<< + * out.point = closest + * out.tri_index = i + */ + +# line 653 "core/core2.pyx" + __pyx_t_1 = ((__pyx_v_dist < __pyx_v_out->distance) != 0); + +# line 653 "core/core2.pyx" + if (__pyx_t_1) { + + /* "core/core2.pyx":654 + * dist = (closest - p[0]).len_sqr() + * if dist < out.distance: + * out.point = closest # <<<<<<<<<<<<<< + * out.tri_index = i + * out.distance = dist + */ + +# line 654 "core/core2.pyx" + __pyx_v_out->point = __pyx_v_closest; + + /* "core/core2.pyx":655 + * if dist < out.distance: + * out.point = closest + * out.tri_index = i # <<<<<<<<<<<<<< + * out.distance = dist + * + */ + +# line 655 "core/core2.pyx" + __pyx_v_out->tri_index = __pyx_v_i; + + /* "core/core2.pyx":656 + * out.point = closest + * out.tri_index = i + * out.distance = dist # <<<<<<<<<<<<<< + * + * else: + */ + +# line 656 "core/core2.pyx" + __pyx_v_out->distance = __pyx_v_dist; + + /* "core/core2.pyx":653 + * + * dist = (closest - p[0]).len_sqr() + * if dist < out.distance: # <<<<<<<<<<<<<< + * out.point = closest + * out.tri_index = i + */ + +# line 653 "core/core2.pyx" + } + + /* "core/core2.pyx":644 + * cdef int i, axis + * cdef float dist + * if node.is_leaf(): # <<<<<<<<<<<<<< + * i = (< BvhNodeLeaf*>node).index + * closest = project_point_triangle(self.mesh.tri_vert_ptr(i, 0)[0], + */ + +# line 644 "core/core2.pyx" + goto __pyx_L3; + +# line 644 "core/core2.pyx" + } + + /* "core/core2.pyx":659 + * + * else: + * dist = node.box.box_distance_sqr(p[0]) # <<<<<<<<<<<<<< + * if dist < out.distance: + * # if not node.box.nodes[0].is_leaf(): + */ + /*else*/ { + __pyx_v_dist = __pyx_v_node->box.box_distance_sqr((__pyx_v_p[0])); + + /* "core/core2.pyx":660 + * else: + * dist = node.box.box_distance_sqr(p[0]) + * if dist < out.distance: # <<<<<<<<<<<<<< + * # if not node.box.nodes[0].is_leaf(): + * # self.find_nearest_recursive(p, out, node.box.nodes[0]) + */ + +# line 660 "core/core2.pyx" + __pyx_t_1 = ((__pyx_v_dist < __pyx_v_out->distance) != 0); + +# line 660 "core/core2.pyx" + if (__pyx_t_1) { + + /* "core/core2.pyx":675 + * # self.find_nearest_recursive(p, out, node.box.nodes[1]) + * # return + * axis = node.box.get_split_axis() # <<<<<<<<<<<<<< + * if node.box.split_pos > p.v[axis]: + * self.find_nearest_recursive(p, out, node.box.nodes[0]) + */ + +# line 675 "core/core2.pyx" + __pyx_v_axis = __pyx_v_node->box.get_split_axis(); + + /* "core/core2.pyx":676 + * # return + * axis = node.box.get_split_axis() + * if node.box.split_pos > p.v[axis]: # <<<<<<<<<<<<<< + * self.find_nearest_recursive(p, out, node.box.nodes[0]) + * self.find_nearest_recursive(p, out, node.box.nodes[1]) + */ + +# line 676 "core/core2.pyx" + __pyx_t_1 = ((__pyx_v_node->box.split_pos > (__pyx_v_p->v[__pyx_v_axis])) != 0); + +# line 676 "core/core2.pyx" + if (__pyx_t_1) { + + /* "core/core2.pyx":677 + * axis = node.box.get_split_axis() + * if node.box.split_pos > p.v[axis]: + * self.find_nearest_recursive(p, out, node.box.nodes[0]) # <<<<<<<<<<<<<< + * self.find_nearest_recursive(p, out, node.box.nodes[1]) + * return + */ + +# line 677 "core/core2.pyx" + __pyx_f_14softwrap_core2_3BVH_find_nearest_recursive(__pyx_v_self, __pyx_v_p, __pyx_v_out, (__pyx_v_node->box.nodes[0])); + + /* "core/core2.pyx":678 + * if node.box.split_pos > p.v[axis]: + * self.find_nearest_recursive(p, out, node.box.nodes[0]) + * self.find_nearest_recursive(p, out, node.box.nodes[1]) # <<<<<<<<<<<<<< + * return + * self.find_nearest_recursive(p, out, node.box.nodes[1]) + */ + +# line 678 "core/core2.pyx" + __pyx_f_14softwrap_core2_3BVH_find_nearest_recursive(__pyx_v_self, __pyx_v_p, __pyx_v_out, (__pyx_v_node->box.nodes[1])); + + /* "core/core2.pyx":679 + * self.find_nearest_recursive(p, out, node.box.nodes[0]) + * self.find_nearest_recursive(p, out, node.box.nodes[1]) + * return # <<<<<<<<<<<<<< + * self.find_nearest_recursive(p, out, node.box.nodes[1]) + * self.find_nearest_recursive(p, out, node.box.nodes[0]) + */ + +# line 679 "core/core2.pyx" + goto __pyx_L0; + + /* "core/core2.pyx":676 + * # return + * axis = node.box.get_split_axis() + * if node.box.split_pos > p.v[axis]: # <<<<<<<<<<<<<< + * self.find_nearest_recursive(p, out, node.box.nodes[0]) + * self.find_nearest_recursive(p, out, node.box.nodes[1]) + */ + +# line 676 "core/core2.pyx" + } + + /* "core/core2.pyx":680 + * self.find_nearest_recursive(p, out, node.box.nodes[1]) + * return + * self.find_nearest_recursive(p, out, node.box.nodes[1]) # <<<<<<<<<<<<<< + * self.find_nearest_recursive(p, out, node.box.nodes[0]) + * + */ + +# line 680 "core/core2.pyx" + __pyx_f_14softwrap_core2_3BVH_find_nearest_recursive(__pyx_v_self, __pyx_v_p, __pyx_v_out, (__pyx_v_node->box.nodes[1])); + + /* "core/core2.pyx":681 + * return + * self.find_nearest_recursive(p, out, node.box.nodes[1]) + * self.find_nearest_recursive(p, out, node.box.nodes[0]) # <<<<<<<<<<<<<< + * + * + */ + +# line 681 "core/core2.pyx" + __pyx_f_14softwrap_core2_3BVH_find_nearest_recursive(__pyx_v_self, __pyx_v_p, __pyx_v_out, (__pyx_v_node->box.nodes[0])); + + /* "core/core2.pyx":660 + * else: + * dist = node.box.box_distance_sqr(p[0]) + * if dist < out.distance: # <<<<<<<<<<<<<< + * # if not node.box.nodes[0].is_leaf(): + * # self.find_nearest_recursive(p, out, node.box.nodes[0]) + */ + +# line 660 "core/core2.pyx" + } + +# line 660 "core/core2.pyx" + } + +# line 660 "core/core2.pyx" + __pyx_L3:; + + /* "core/core2.pyx":640 + * return result + * + * cdef void find_nearest_recursive(self, vec3* p, BvhNearestResult* out, BvhNode* node) nogil: # <<<<<<<<<<<<<< + * cdef vec3 closest + * cdef int i, axis + */ + + /* function exit code */ + __pyx_L0:; +} + +/* "(tree fragment)":1 + * def __reduce_cython__(self): # <<<<<<<<<<<<<< + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_3BVH_7__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_3BVH_7__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0); + __pyx_r = __pyx_pf_14softwrap_core2_3BVH_6__reduce_cython__(((struct __pyx_obj_14softwrap_core2_BVH *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_3BVH_6__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_14softwrap_core2_BVH *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__reduce_cython__", 0); + + /* "(tree fragment)":2 + * def __reduce_cython__(self): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + */ + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __PYX_ERR(1, 2, __pyx_L1_error) + + /* "(tree fragment)":1 + * def __reduce_cython__(self): # <<<<<<<<<<<<<< + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("softwrap_core2.BVH.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "(tree fragment)":3 + * def __reduce_cython__(self): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_3BVH_9__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_3BVH_9__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0); + __pyx_r = __pyx_pf_14softwrap_core2_3BVH_8__setstate_cython__(((struct __pyx_obj_14softwrap_core2_BVH *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_3BVH_8__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_14softwrap_core2_BVH *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__setstate_cython__", 0); + + /* "(tree fragment)":4 + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< + */ + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __PYX_ERR(1, 4, __pyx_L1_error) + + /* "(tree fragment)":3 + * def __reduce_cython__(self): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("softwrap_core2.BVH.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":717 + * cdef readonly int index + * + * def __cinit__(self, SpringLinks springs, int index): # <<<<<<<<<<<<<< + * self.springs = springs + * if index < 0 or index >= springs.engine.n_verts: + */ + +/* Python wrapper */ +static int __pyx_pw_14softwrap_core2_9LinkProbe_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pw_14softwrap_core2_9LinkProbe_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + struct __pyx_obj_14softwrap_core2_SpringLinks *__pyx_v_springs = 0; + int __pyx_v_index; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_springs,&__pyx_n_s_index,0}; + PyObject* values[2] = {0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + CYTHON_FALLTHROUGH; + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + CYTHON_FALLTHROUGH; + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_springs)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + CYTHON_FALLTHROUGH; + case 1: + if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_index)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 2, 2, 1); __PYX_ERR(0, 717, __pyx_L3_error) + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(0, 717, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + } + __pyx_v_springs = ((struct __pyx_obj_14softwrap_core2_SpringLinks *)values[0]); + __pyx_v_index = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_index == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 717, __pyx_L3_error) + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 717, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("softwrap_core2.LinkProbe.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_springs), __pyx_ptype_14softwrap_core2_SpringLinks, 1, "springs", 0))) __PYX_ERR(0, 717, __pyx_L1_error) + __pyx_r = __pyx_pf_14softwrap_core2_9LinkProbe___cinit__(((struct __pyx_obj_14softwrap_core2_LinkProbe *)__pyx_v_self), __pyx_v_springs, __pyx_v_index); + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_14softwrap_core2_9LinkProbe___cinit__(struct __pyx_obj_14softwrap_core2_LinkProbe *__pyx_v_self, struct __pyx_obj_14softwrap_core2_SpringLinks *__pyx_v_springs, int __pyx_v_index) { + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__cinit__", 0); + + /* "core/core2.pyx":718 + * + * def __cinit__(self, SpringLinks springs, int index): + * self.springs = springs # <<<<<<<<<<<<<< + * if index < 0 or index >= springs.engine.n_verts: + * raise IndexError + */ + +# line 718 "core/core2.pyx" + __Pyx_INCREF(((PyObject *)__pyx_v_springs)); + +# line 718 "core/core2.pyx" + __Pyx_GIVEREF(((PyObject *)__pyx_v_springs)); + +# line 718 "core/core2.pyx" + __Pyx_GOTREF(__pyx_v_self->springs); + +# line 718 "core/core2.pyx" + __Pyx_DECREF(((PyObject *)__pyx_v_self->springs)); + +# line 718 "core/core2.pyx" + __pyx_v_self->springs = __pyx_v_springs; + + /* "core/core2.pyx":719 + * def __cinit__(self, SpringLinks springs, int index): + * self.springs = springs + * if index < 0 or index >= springs.engine.n_verts: # <<<<<<<<<<<<<< + * raise IndexError + * + */ + +# line 719 "core/core2.pyx" + __pyx_t_2 = ((__pyx_v_index < 0) != 0); + +# line 719 "core/core2.pyx" + if (!__pyx_t_2) { + +# line 719 "core/core2.pyx" + } else { + +# line 719 "core/core2.pyx" + __pyx_t_1 = __pyx_t_2; + +# line 719 "core/core2.pyx" + goto __pyx_L4_bool_binop_done; + +# line 719 "core/core2.pyx" + } + +# line 719 "core/core2.pyx" + __pyx_t_2 = ((__pyx_v_index >= __pyx_v_springs->engine->n_verts) != 0); + +# line 719 "core/core2.pyx" + __pyx_t_1 = __pyx_t_2; + +# line 719 "core/core2.pyx" + __pyx_L4_bool_binop_done:; + +# line 719 "core/core2.pyx" + if (unlikely(__pyx_t_1)) { + + /* "core/core2.pyx":720 + * self.springs = springs + * if index < 0 or index >= springs.engine.n_verts: + * raise IndexError # <<<<<<<<<<<<<< + * + * self.index = index + */ + +# line 720 "core/core2.pyx" + __Pyx_Raise(__pyx_builtin_IndexError, 0, 0, 0); + +# line 720 "core/core2.pyx" + __PYX_ERR(0, 720, __pyx_L1_error) + + /* "core/core2.pyx":719 + * def __cinit__(self, SpringLinks springs, int index): + * self.springs = springs + * if index < 0 or index >= springs.engine.n_verts: # <<<<<<<<<<<<<< + * raise IndexError + * + */ + +# line 719 "core/core2.pyx" + } + + /* "core/core2.pyx":722 + * raise IndexError + * + * self.index = index # <<<<<<<<<<<<<< + * self.halflinks = springs.links[index] + * + */ + +# line 722 "core/core2.pyx" + __pyx_v_self->index = __pyx_v_index; + + /* "core/core2.pyx":723 + * + * self.index = index + * self.halflinks = springs.links[index] # <<<<<<<<<<<<<< + * + * def __getitem__(self, int link_index): + */ + +# line 723 "core/core2.pyx" + __pyx_v_self->halflinks = (__pyx_v_springs->links[__pyx_v_index]); + + /* "core/core2.pyx":717 + * cdef readonly int index + * + * def __cinit__(self, SpringLinks springs, int index): # <<<<<<<<<<<<<< + * self.springs = springs + * if index < 0 or index >= springs.engine.n_verts: + */ + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_AddTraceback("softwrap_core2.LinkProbe.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":725 + * self.halflinks = springs.links[index] + * + * def __getitem__(self, int link_index): # <<<<<<<<<<<<<< + * if link_index < 0 or link_index >= self.halflinks.n: + * raise IndexError + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_9LinkProbe_3__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_link_index); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_9LinkProbe_3__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_link_index) { + int __pyx_v_link_index; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0); + assert(__pyx_arg_link_index); { + __pyx_v_link_index = __Pyx_PyInt_As_int(__pyx_arg_link_index); if (unlikely((__pyx_v_link_index == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 725, __pyx_L3_error) + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("softwrap_core2.LinkProbe.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_14softwrap_core2_9LinkProbe_2__getitem__(((struct __pyx_obj_14softwrap_core2_LinkProbe *)__pyx_v_self), ((int)__pyx_v_link_index)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_9LinkProbe_2__getitem__(struct __pyx_obj_14softwrap_core2_LinkProbe *__pyx_v_self, int __pyx_v_link_index) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__getitem__", 0); + + /* "core/core2.pyx":726 + * + * def __getitem__(self, int link_index): + * if link_index < 0 or link_index >= self.halflinks.n: # <<<<<<<<<<<<<< + * raise IndexError + * return self.halflinks.half_links[link_index].a + */ + +# line 726 "core/core2.pyx" + __pyx_t_2 = ((__pyx_v_link_index < 0) != 0); + +# line 726 "core/core2.pyx" + if (!__pyx_t_2) { + +# line 726 "core/core2.pyx" + } else { + +# line 726 "core/core2.pyx" + __pyx_t_1 = __pyx_t_2; + +# line 726 "core/core2.pyx" + goto __pyx_L4_bool_binop_done; + +# line 726 "core/core2.pyx" + } + +# line 726 "core/core2.pyx" + __pyx_t_2 = ((__pyx_v_link_index >= __pyx_v_self->halflinks->n) != 0); + +# line 726 "core/core2.pyx" + __pyx_t_1 = __pyx_t_2; + +# line 726 "core/core2.pyx" + __pyx_L4_bool_binop_done:; + +# line 726 "core/core2.pyx" + if (unlikely(__pyx_t_1)) { + + /* "core/core2.pyx":727 + * def __getitem__(self, int link_index): + * if link_index < 0 or link_index >= self.halflinks.n: + * raise IndexError # <<<<<<<<<<<<<< + * return self.halflinks.half_links[link_index].a + * + */ + +# line 727 "core/core2.pyx" + __Pyx_Raise(__pyx_builtin_IndexError, 0, 0, 0); + +# line 727 "core/core2.pyx" + __PYX_ERR(0, 727, __pyx_L1_error) + + /* "core/core2.pyx":726 + * + * def __getitem__(self, int link_index): + * if link_index < 0 or link_index >= self.halflinks.n: # <<<<<<<<<<<<<< + * raise IndexError + * return self.halflinks.half_links[link_index].a + */ + +# line 726 "core/core2.pyx" + } + + /* "core/core2.pyx":728 + * if link_index < 0 or link_index >= self.halflinks.n: + * raise IndexError + * return self.halflinks.half_links[link_index].a # <<<<<<<<<<<<<< + * + * def __len__(self): + */ + +# line 728 "core/core2.pyx" + __Pyx_XDECREF(__pyx_r); + +# line 728 "core/core2.pyx" + __pyx_t_3 = __Pyx_PyInt_From_int((__pyx_v_self->halflinks->half_links[__pyx_v_link_index]).a); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 728, __pyx_L1_error) + +# line 728 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_3); + +# line 728 "core/core2.pyx" + __pyx_r = __pyx_t_3; + +# line 728 "core/core2.pyx" + __pyx_t_3 = 0; + +# line 728 "core/core2.pyx" + goto __pyx_L0; + + /* "core/core2.pyx":725 + * self.halflinks = springs.links[index] + * + * def __getitem__(self, int link_index): # <<<<<<<<<<<<<< + * if link_index < 0 or link_index >= self.halflinks.n: + * raise IndexError + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("softwrap_core2.LinkProbe.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":730 + * return self.halflinks.half_links[link_index].a + * + * def __len__(self): # <<<<<<<<<<<<<< + * return self.halflinks.n + * + */ + +/* Python wrapper */ +static Py_ssize_t __pyx_pw_14softwrap_core2_9LinkProbe_5__len__(PyObject *__pyx_v_self); /*proto*/ +static Py_ssize_t __pyx_pw_14softwrap_core2_9LinkProbe_5__len__(PyObject *__pyx_v_self) { + Py_ssize_t __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__len__ (wrapper)", 0); + __pyx_r = __pyx_pf_14softwrap_core2_9LinkProbe_4__len__(((struct __pyx_obj_14softwrap_core2_LinkProbe *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static Py_ssize_t __pyx_pf_14softwrap_core2_9LinkProbe_4__len__(struct __pyx_obj_14softwrap_core2_LinkProbe *__pyx_v_self) { + Py_ssize_t __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__len__", 0); + + /* "core/core2.pyx":731 + * + * def __len__(self): + * return self.halflinks.n # <<<<<<<<<<<<<< + * + * def __iter__(self): + */ + +# line 731 "core/core2.pyx" + __pyx_r = __pyx_v_self->halflinks->n; + +# line 731 "core/core2.pyx" + goto __pyx_L0; + + /* "core/core2.pyx":730 + * return self.halflinks.half_links[link_index].a + * + * def __len__(self): # <<<<<<<<<<<<<< + * return self.halflinks.n + * + */ + + /* function exit code */ + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} +static PyObject *__pyx_gb_14softwrap_core2_9LinkProbe_8generator(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */ + +/* "core/core2.pyx":733 + * return self.halflinks.n + * + * def __iter__(self): # <<<<<<<<<<<<<< + * cdef int i + * for i in range(self.halflinks.n): + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_9LinkProbe_7__iter__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_9LinkProbe_7__iter__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0); + __pyx_r = __pyx_pf_14softwrap_core2_9LinkProbe_6__iter__(((struct __pyx_obj_14softwrap_core2_LinkProbe *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_9LinkProbe_6__iter__(struct __pyx_obj_14softwrap_core2_LinkProbe *__pyx_v_self) { + struct __pyx_obj_14softwrap_core2___pyx_scope_struct____iter__ *__pyx_cur_scope; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__iter__", 0); + __pyx_cur_scope = (struct __pyx_obj_14softwrap_core2___pyx_scope_struct____iter__ *)__pyx_tp_new_14softwrap_core2___pyx_scope_struct____iter__(__pyx_ptype_14softwrap_core2___pyx_scope_struct____iter__, __pyx_empty_tuple, NULL); + if (unlikely(!__pyx_cur_scope)) { + __pyx_cur_scope = ((struct __pyx_obj_14softwrap_core2___pyx_scope_struct____iter__ *)Py_None); + __Pyx_INCREF(Py_None); + __PYX_ERR(0, 733, __pyx_L1_error) + } else { + __Pyx_GOTREF(__pyx_cur_scope); + } + __pyx_cur_scope->__pyx_v_self = __pyx_v_self; + __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self); + __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self); + { + __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_14softwrap_core2_9LinkProbe_8generator, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_iter, __pyx_n_s_LinkProbe___iter, __pyx_n_s_softwrap_core2); if (unlikely(!gen)) __PYX_ERR(0, 733, __pyx_L1_error) + __Pyx_DECREF(__pyx_cur_scope); + __Pyx_RefNannyFinishContext(); + return (PyObject *) gen; + } + + /* function exit code */ + __pyx_L1_error:; + __Pyx_AddTraceback("softwrap_core2.LinkProbe.__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __Pyx_DECREF(((PyObject *)__pyx_cur_scope)); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_gb_14softwrap_core2_9LinkProbe_8generator(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */ +{ + struct __pyx_obj_14softwrap_core2___pyx_scope_struct____iter__ *__pyx_cur_scope = ((struct __pyx_obj_14softwrap_core2___pyx_scope_struct____iter__ *)__pyx_generator->closure); + PyObject *__pyx_r = NULL; + int __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + PyObject *__pyx_t_4 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__iter__", 0); + switch (__pyx_generator->resume_label) { + case 0: goto __pyx_L3_first_run; + case 1: goto __pyx_L6_resume_from_yield; + default: /* CPython raises the right error here */ + __Pyx_RefNannyFinishContext(); + return NULL; + } + __pyx_L3_first_run:; + if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 733, __pyx_L1_error) + + /* "core/core2.pyx":735 + * def __iter__(self): + * cdef int i + * for i in range(self.halflinks.n): # <<<<<<<<<<<<<< + * yield self.halflinks.half_links[i].a + * + */ + +# line 735 "core/core2.pyx" + __pyx_t_1 = __pyx_cur_scope->__pyx_v_self->halflinks->n; + +# line 735 "core/core2.pyx" + __pyx_t_2 = __pyx_t_1; + +# line 735 "core/core2.pyx" + for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) { + +# line 735 "core/core2.pyx" + __pyx_cur_scope->__pyx_v_i = __pyx_t_3; + + /* "core/core2.pyx":736 + * cdef int i + * for i in range(self.halflinks.n): + * yield self.halflinks.half_links[i].a # <<<<<<<<<<<<<< + * + * @property + */ + +# line 736 "core/core2.pyx" + __pyx_t_4 = __Pyx_PyInt_From_int((__pyx_cur_scope->__pyx_v_self->halflinks->half_links[__pyx_cur_scope->__pyx_v_i]).a); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 736, __pyx_L1_error) + +# line 736 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_4); + +# line 736 "core/core2.pyx" + __pyx_r = __pyx_t_4; + +# line 736 "core/core2.pyx" + __pyx_t_4 = 0; + +# line 736 "core/core2.pyx" + __pyx_cur_scope->__pyx_t_0 = __pyx_t_1; + +# line 736 "core/core2.pyx" + __pyx_cur_scope->__pyx_t_1 = __pyx_t_2; + +# line 736 "core/core2.pyx" + __pyx_cur_scope->__pyx_t_2 = __pyx_t_3; + +# line 736 "core/core2.pyx" + __Pyx_XGIVEREF(__pyx_r); + +# line 736 "core/core2.pyx" + __Pyx_RefNannyFinishContext(); + +# line 736 "core/core2.pyx" + __Pyx_Coroutine_ResetAndClearException(__pyx_generator); + /* return from generator, yielding value */ + __pyx_generator->resume_label = 1; + return __pyx_r; + __pyx_L6_resume_from_yield:; + __pyx_t_1 = __pyx_cur_scope->__pyx_t_0; + __pyx_t_2 = __pyx_cur_scope->__pyx_t_1; + __pyx_t_3 = __pyx_cur_scope->__pyx_t_2; + if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 736, __pyx_L1_error) + } + CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope); + + /* "core/core2.pyx":733 + * return self.halflinks.n + * + * def __iter__(self): # <<<<<<<<<<<<<< + * cdef int i + * for i in range(self.halflinks.n): + */ + + /* function exit code */ + PyErr_SetNone(PyExc_StopIteration); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_L0:; + __Pyx_XDECREF(__pyx_r); __pyx_r = 0; + #if !CYTHON_USE_EXC_INFO_STACK + __Pyx_Coroutine_ResetAndClearException(__pyx_generator); + #endif + __pyx_generator->resume_label = -1; + __Pyx_Coroutine_clear((PyObject*)__pyx_generator); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":739 + * + * @property + * def avg_radius(self): # <<<<<<<<<<<<<< + * cdef int i + * cdef float r = 0 + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_9LinkProbe_10avg_radius_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_9LinkProbe_10avg_radius_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_14softwrap_core2_9LinkProbe_10avg_radius___get__(((struct __pyx_obj_14softwrap_core2_LinkProbe *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_9LinkProbe_10avg_radius___get__(struct __pyx_obj_14softwrap_core2_LinkProbe *__pyx_v_self) { + int __pyx_v_i; + float __pyx_v_r; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + PyObject *__pyx_t_4 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__get__", 0); + + /* "core/core2.pyx":741 + * def avg_radius(self): + * cdef int i + * cdef float r = 0 # <<<<<<<<<<<<<< + * for i in range(self.halflinks.n): + * r += self.halflinks.half_links[i].original_length + */ + +# line 741 "core/core2.pyx" + __pyx_v_r = 0.0; + + /* "core/core2.pyx":742 + * cdef int i + * cdef float r = 0 + * for i in range(self.halflinks.n): # <<<<<<<<<<<<<< + * r += self.halflinks.half_links[i].original_length + * + */ + +# line 742 "core/core2.pyx" + __pyx_t_1 = __pyx_v_self->halflinks->n; + +# line 742 "core/core2.pyx" + __pyx_t_2 = __pyx_t_1; + +# line 742 "core/core2.pyx" + for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) { + +# line 742 "core/core2.pyx" + __pyx_v_i = __pyx_t_3; + + /* "core/core2.pyx":743 + * cdef float r = 0 + * for i in range(self.halflinks.n): + * r += self.halflinks.half_links[i].original_length # <<<<<<<<<<<<<< + * + * return r / (self.halflinks.n + EPS) + */ + +# line 743 "core/core2.pyx" + __pyx_v_r = (__pyx_v_r + (__pyx_v_self->halflinks->half_links[__pyx_v_i]).original_length); + +# line 743 "core/core2.pyx" + } + + /* "core/core2.pyx":745 + * r += self.halflinks.half_links[i].original_length + * + * return r / (self.halflinks.n + EPS) # <<<<<<<<<<<<<< + * + * cdef class SpringLinks: + */ + +# line 745 "core/core2.pyx" + __Pyx_XDECREF(__pyx_r); + +# line 745 "core/core2.pyx" + __pyx_t_4 = PyFloat_FromDouble((__pyx_v_r / (__pyx_v_self->halflinks->n + EPS))); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 745, __pyx_L1_error) + +# line 745 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_4); + +# line 745 "core/core2.pyx" + __pyx_r = __pyx_t_4; + +# line 745 "core/core2.pyx" + __pyx_t_4 = 0; + +# line 745 "core/core2.pyx" + goto __pyx_L0; + + /* "core/core2.pyx":739 + * + * @property + * def avg_radius(self): # <<<<<<<<<<<<<< + * cdef int i + * cdef float r = 0 + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("softwrap_core2.LinkProbe.avg_radius.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":713 + * @cython.final + * cdef class LinkProbe: + * cdef readonly SpringLinks springs # <<<<<<<<<<<<<< + * cdef HalfLinkArr* halflinks + * cdef readonly int index + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_9LinkProbe_7springs_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_9LinkProbe_7springs_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_14softwrap_core2_9LinkProbe_7springs___get__(((struct __pyx_obj_14softwrap_core2_LinkProbe *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_9LinkProbe_7springs___get__(struct __pyx_obj_14softwrap_core2_LinkProbe *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_self->springs)); + __pyx_r = ((PyObject *)__pyx_v_self->springs); + goto __pyx_L0; + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":715 + * cdef readonly SpringLinks springs + * cdef HalfLinkArr* halflinks + * cdef readonly int index # <<<<<<<<<<<<<< + * + * def __cinit__(self, SpringLinks springs, int index): + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_9LinkProbe_5index_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_9LinkProbe_5index_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_14softwrap_core2_9LinkProbe_5index___get__(((struct __pyx_obj_14softwrap_core2_LinkProbe *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_9LinkProbe_5index___get__(struct __pyx_obj_14softwrap_core2_LinkProbe *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->index); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 715, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("softwrap_core2.LinkProbe.index.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "(tree fragment)":1 + * def __reduce_cython__(self): # <<<<<<<<<<<<<< + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_9LinkProbe_10__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_9LinkProbe_10__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0); + __pyx_r = __pyx_pf_14softwrap_core2_9LinkProbe_9__reduce_cython__(((struct __pyx_obj_14softwrap_core2_LinkProbe *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_9LinkProbe_9__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_14softwrap_core2_LinkProbe *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__reduce_cython__", 0); + + /* "(tree fragment)":2 + * def __reduce_cython__(self): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + */ + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __PYX_ERR(1, 2, __pyx_L1_error) + + /* "(tree fragment)":1 + * def __reduce_cython__(self): # <<<<<<<<<<<<<< + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("softwrap_core2.LinkProbe.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "(tree fragment)":3 + * def __reduce_cython__(self): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_9LinkProbe_12__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_9LinkProbe_12__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0); + __pyx_r = __pyx_pf_14softwrap_core2_9LinkProbe_11__setstate_cython__(((struct __pyx_obj_14softwrap_core2_LinkProbe *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_9LinkProbe_11__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_14softwrap_core2_LinkProbe *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__setstate_cython__", 0); + + /* "(tree fragment)":4 + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< + */ + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__10, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __PYX_ERR(1, 4, __pyx_L1_error) + + /* "(tree fragment)":3 + * def __reduce_cython__(self): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("softwrap_core2.LinkProbe.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":754 + * + * @cython.boundscheck(True) + * def __cinit__(self, SpringEngine engine, list links): # <<<<<<<<<<<<<< + * self.engine = engine + * self.links = maelloc(sizeof(HalfLink**) * self.engine.n_verts, __LINE__) + */ + +/* Python wrapper */ +static int __pyx_pw_14softwrap_core2_11SpringLinks_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pw_14softwrap_core2_11SpringLinks_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_engine = 0; + PyObject *__pyx_v_links = 0; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_engine,&__pyx_n_s_links,0}; + PyObject* values[2] = {0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + CYTHON_FALLTHROUGH; + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + CYTHON_FALLTHROUGH; + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_engine)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + CYTHON_FALLTHROUGH; + case 1: + if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_links)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 2, 2, 1); __PYX_ERR(0, 754, __pyx_L3_error) + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(0, 754, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + } + __pyx_v_engine = ((struct __pyx_obj_14softwrap_core2_SpringEngine *)values[0]); + __pyx_v_links = ((PyObject*)values[1]); + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 754, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("softwrap_core2.SpringLinks.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_engine), __pyx_ptype_14softwrap_core2_SpringEngine, 1, "engine", 0))) __PYX_ERR(0, 754, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_links), (&PyList_Type), 1, "links", 1))) __PYX_ERR(0, 754, __pyx_L1_error) + __pyx_r = __pyx_pf_14softwrap_core2_11SpringLinks___cinit__(((struct __pyx_obj_14softwrap_core2_SpringLinks *)__pyx_v_self), __pyx_v_engine, __pyx_v_links); + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_14softwrap_core2_11SpringLinks___cinit__(struct __pyx_obj_14softwrap_core2_SpringLinks *__pyx_v_self, struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_engine, PyObject *__pyx_v_links) { + int __pyx_v_a; + int __pyx_v_b; + int __pyx_v_i; + int __pyx_v_j; + int __pyx_v_n; + PyObject *__pyx_v_arranged_links = 0; + PyObject *__pyx_v_half_lst = 0; + CYTHON_UNUSED int __pyx_7genexpr__pyx_v_i; + int __pyx_r; + __Pyx_RefNannyDeclarations + void *__pyx_t_1; + Py_ssize_t __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + int __pyx_t_4; + int __pyx_t_5; + int __pyx_t_6; + PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8 = NULL; + PyObject *__pyx_t_9 = NULL; + PyObject *__pyx_t_10 = NULL; + PyObject *(*__pyx_t_11)(PyObject *); + int __pyx_t_12; + int __pyx_t_13; + int __pyx_t_14; + int __pyx_t_15; + int __pyx_t_16; + int __pyx_t_17; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__cinit__", 0); + + /* "core/core2.pyx":755 + * @cython.boundscheck(True) + * def __cinit__(self, SpringEngine engine, list links): + * self.engine = engine # <<<<<<<<<<<<<< + * self.links = maelloc(sizeof(HalfLink**) * self.engine.n_verts, __LINE__) + * self.links[0] = maelloc(sizeof(HalfLinkArr) * self.engine.n_verts + sizeof(HalfLink) * 2 * len(links), __LINE__) + */ + +# line 755 "core/core2.pyx" + __Pyx_INCREF(((PyObject *)__pyx_v_engine)); + +# line 755 "core/core2.pyx" + __Pyx_GIVEREF(((PyObject *)__pyx_v_engine)); + +# line 755 "core/core2.pyx" + __Pyx_GOTREF(__pyx_v_self->engine); + +# line 755 "core/core2.pyx" + __Pyx_DECREF(((PyObject *)__pyx_v_self->engine)); + +# line 755 "core/core2.pyx" + __pyx_v_self->engine = __pyx_v_engine; + + /* "core/core2.pyx":756 + * def __cinit__(self, SpringEngine engine, list links): + * self.engine = engine + * self.links = maelloc(sizeof(HalfLink**) * self.engine.n_verts, __LINE__) # <<<<<<<<<<<<<< + * self.links[0] = maelloc(sizeof(HalfLinkArr) * self.engine.n_verts + sizeof(HalfLink) * 2 * len(links), __LINE__) + * + */ + +# line 756 "core/core2.pyx" + __pyx_t_1 = __pyx_f_14softwrap_core2_maelloc(((sizeof(struct HalfLink **)) * __pyx_v_self->engine->n_verts), __LINE__); if (unlikely(__pyx_t_1 == ((void *)NULL))) __PYX_ERR(0, 756, __pyx_L1_error) + +# line 756 "core/core2.pyx" + __pyx_v_self->links = ((struct HalfLinkArr **)__pyx_t_1); + + /* "core/core2.pyx":757 + * self.engine = engine + * self.links = maelloc(sizeof(HalfLink**) * self.engine.n_verts, __LINE__) + * self.links[0] = maelloc(sizeof(HalfLinkArr) * self.engine.n_verts + sizeof(HalfLink) * 2 * len(links), __LINE__) # <<<<<<<<<<<<<< + * + * cdef int a, b, i, j, n + */ + +# line 757 "core/core2.pyx" + if (unlikely(__pyx_v_links == Py_None)) { + +# line 757 "core/core2.pyx" + PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); + +# line 757 "core/core2.pyx" + __PYX_ERR(0, 757, __pyx_L1_error) + +# line 757 "core/core2.pyx" + } + +# line 757 "core/core2.pyx" + __pyx_t_2 = PyList_GET_SIZE(__pyx_v_links); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 757, __pyx_L1_error) + +# line 757 "core/core2.pyx" + __pyx_t_1 = __pyx_f_14softwrap_core2_maelloc((((sizeof(struct HalfLinkArr)) * __pyx_v_self->engine->n_verts) + (((sizeof(struct HalfLink)) * 2) * __pyx_t_2)), __LINE__); if (unlikely(__pyx_t_1 == ((void *)NULL))) __PYX_ERR(0, 757, __pyx_L1_error) + +# line 757 "core/core2.pyx" + (__pyx_v_self->links[0]) = ((struct HalfLinkArr *)__pyx_t_1); + + /* "core/core2.pyx":761 + * cdef int a, b, i, j, n + * + * cdef list arranged_links = [[] for i in range(engine.n_verts)] # <<<<<<<<<<<<<< + * + * for a, b in links: + */ + { /* enter inner scope */ + __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 761, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = __pyx_v_engine->n_verts; + __pyx_t_5 = __pyx_t_4; + for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) { + __pyx_7genexpr__pyx_v_i = __pyx_t_6; + __pyx_t_7 = PyList_New(0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 761, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_7))) __PYX_ERR(0, 761, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + } + } /* exit inner scope */ + __pyx_v_arranged_links = ((PyObject*)__pyx_t_3); + __pyx_t_3 = 0; + + /* "core/core2.pyx":763 + * cdef list arranged_links = [[] for i in range(engine.n_verts)] + * + * for a, b in links: # <<<<<<<<<<<<<< + * arranged_links[a].append(b) + * arranged_links[b].append(a) + */ + +# line 763 "core/core2.pyx" + if (unlikely(__pyx_v_links == Py_None)) { + +# line 763 "core/core2.pyx" + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); + +# line 763 "core/core2.pyx" + __PYX_ERR(0, 763, __pyx_L1_error) + +# line 763 "core/core2.pyx" + } + +# line 763 "core/core2.pyx" + __pyx_t_3 = __pyx_v_links; __Pyx_INCREF(__pyx_t_3); __pyx_t_2 = 0; + +# line 763 "core/core2.pyx" + for (;;) { + +# line 763 "core/core2.pyx" + if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_3)) break; + +# line 763 "core/core2.pyx" + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + +# line 763 "core/core2.pyx" + __pyx_t_7 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_2); __Pyx_INCREF(__pyx_t_7); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 763, __pyx_L1_error) + +# line 763 "core/core2.pyx" + #else + +# line 763 "core/core2.pyx" + __pyx_t_7 = PySequence_ITEM(__pyx_t_3, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 763, __pyx_L1_error) + +# line 763 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_7); + +# line 763 "core/core2.pyx" + #endif + +# line 763 "core/core2.pyx" + if ((likely(PyTuple_CheckExact(__pyx_t_7))) || (PyList_CheckExact(__pyx_t_7))) { + +# line 763 "core/core2.pyx" + PyObject* sequence = __pyx_t_7; + +# line 763 "core/core2.pyx" + Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); + +# line 763 "core/core2.pyx" + if (unlikely(size != 2)) { + +# line 763 "core/core2.pyx" + if (size > 2) __Pyx_RaiseTooManyValuesError(2); + +# line 763 "core/core2.pyx" + else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); + +# line 763 "core/core2.pyx" + __PYX_ERR(0, 763, __pyx_L1_error) + +# line 763 "core/core2.pyx" + } + +# line 763 "core/core2.pyx" + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + +# line 763 "core/core2.pyx" + if (likely(PyTuple_CheckExact(sequence))) { + +# line 763 "core/core2.pyx" + __pyx_t_8 = PyTuple_GET_ITEM(sequence, 0); + +# line 763 "core/core2.pyx" + __pyx_t_9 = PyTuple_GET_ITEM(sequence, 1); + +# line 763 "core/core2.pyx" + } else { + +# line 763 "core/core2.pyx" + __pyx_t_8 = PyList_GET_ITEM(sequence, 0); + +# line 763 "core/core2.pyx" + __pyx_t_9 = PyList_GET_ITEM(sequence, 1); + +# line 763 "core/core2.pyx" + } + +# line 763 "core/core2.pyx" + __Pyx_INCREF(__pyx_t_8); + +# line 763 "core/core2.pyx" + __Pyx_INCREF(__pyx_t_9); + +# line 763 "core/core2.pyx" + #else + +# line 763 "core/core2.pyx" + __pyx_t_8 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 763, __pyx_L1_error) + +# line 763 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_8); + +# line 763 "core/core2.pyx" + __pyx_t_9 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 763, __pyx_L1_error) + +# line 763 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_9); + +# line 763 "core/core2.pyx" + #endif + +# line 763 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + +# line 763 "core/core2.pyx" + } else { + +# line 763 "core/core2.pyx" + Py_ssize_t index = -1; + +# line 763 "core/core2.pyx" + __pyx_t_10 = PyObject_GetIter(__pyx_t_7); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 763, __pyx_L1_error) + +# line 763 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_10); + +# line 763 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + +# line 763 "core/core2.pyx" + __pyx_t_11 = Py_TYPE(__pyx_t_10)->tp_iternext; + +# line 763 "core/core2.pyx" + index = 0; __pyx_t_8 = __pyx_t_11(__pyx_t_10); if (unlikely(!__pyx_t_8)) goto __pyx_L7_unpacking_failed; + +# line 763 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_8); + +# line 763 "core/core2.pyx" + index = 1; __pyx_t_9 = __pyx_t_11(__pyx_t_10); if (unlikely(!__pyx_t_9)) goto __pyx_L7_unpacking_failed; + +# line 763 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_9); + +# line 763 "core/core2.pyx" + if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_10), 2) < 0) __PYX_ERR(0, 763, __pyx_L1_error) + +# line 763 "core/core2.pyx" + __pyx_t_11 = NULL; + +# line 763 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + +# line 763 "core/core2.pyx" + goto __pyx_L8_unpacking_done; + +# line 763 "core/core2.pyx" + __pyx_L7_unpacking_failed:; + +# line 763 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + +# line 763 "core/core2.pyx" + __pyx_t_11 = NULL; + +# line 763 "core/core2.pyx" + if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); + +# line 763 "core/core2.pyx" + __PYX_ERR(0, 763, __pyx_L1_error) + +# line 763 "core/core2.pyx" + __pyx_L8_unpacking_done:; + +# line 763 "core/core2.pyx" + } + +# line 763 "core/core2.pyx" + __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_t_8); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 763, __pyx_L1_error) + +# line 763 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + +# line 763 "core/core2.pyx" + __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_9); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 763, __pyx_L1_error) + +# line 763 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + +# line 763 "core/core2.pyx" + __pyx_v_a = __pyx_t_4; + +# line 763 "core/core2.pyx" + __pyx_v_b = __pyx_t_5; + + /* "core/core2.pyx":764 + * + * for a, b in links: + * arranged_links[a].append(b) # <<<<<<<<<<<<<< + * arranged_links[b].append(a) + * + */ + +# line 764 "core/core2.pyx" + __pyx_t_7 = __Pyx_GetItemInt_List(__pyx_v_arranged_links, __pyx_v_a, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 764, __pyx_L1_error) + +# line 764 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_7); + +# line 764 "core/core2.pyx" + __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_b); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 764, __pyx_L1_error) + +# line 764 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_9); + +# line 764 "core/core2.pyx" + __pyx_t_12 = __Pyx_PyObject_Append(__pyx_t_7, __pyx_t_9); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(0, 764, __pyx_L1_error) + +# line 764 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + +# line 764 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + + /* "core/core2.pyx":765 + * for a, b in links: + * arranged_links[a].append(b) + * arranged_links[b].append(a) # <<<<<<<<<<<<<< + * + * cdef list half_lst + */ + +# line 765 "core/core2.pyx" + __pyx_t_9 = __Pyx_GetItemInt_List(__pyx_v_arranged_links, __pyx_v_b, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 765, __pyx_L1_error) + +# line 765 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_9); + +# line 765 "core/core2.pyx" + __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_a); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 765, __pyx_L1_error) + +# line 765 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_7); + +# line 765 "core/core2.pyx" + __pyx_t_12 = __Pyx_PyObject_Append(__pyx_t_9, __pyx_t_7); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(0, 765, __pyx_L1_error) + +# line 765 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + +# line 765 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + + /* "core/core2.pyx":763 + * cdef list arranged_links = [[] for i in range(engine.n_verts)] + * + * for a, b in links: # <<<<<<<<<<<<<< + * arranged_links[a].append(b) + * arranged_links[b].append(a) + */ + +# line 763 "core/core2.pyx" + } + +# line 763 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + + /* "core/core2.pyx":769 + * cdef list half_lst + * + * for i in range(engine.n_verts): # <<<<<<<<<<<<<< + * half_lst = arranged_links[i] + * n = len(half_lst) + */ + +# line 769 "core/core2.pyx" + __pyx_t_5 = __pyx_v_engine->n_verts; + +# line 769 "core/core2.pyx" + __pyx_t_4 = __pyx_t_5; + +# line 769 "core/core2.pyx" + for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_4; __pyx_t_6+=1) { + +# line 769 "core/core2.pyx" + __pyx_v_i = __pyx_t_6; + + /* "core/core2.pyx":770 + * + * for i in range(engine.n_verts): + * half_lst = arranged_links[i] # <<<<<<<<<<<<<< + * n = len(half_lst) + * + */ + +# line 770 "core/core2.pyx" + __pyx_t_3 = __Pyx_GetItemInt_List(__pyx_v_arranged_links, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 770, __pyx_L1_error) + +# line 770 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_3); + +# line 770 "core/core2.pyx" + if (!(likely(PyList_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(0, 770, __pyx_L1_error) + +# line 770 "core/core2.pyx" + __Pyx_XDECREF_SET(__pyx_v_half_lst, ((PyObject*)__pyx_t_3)); + +# line 770 "core/core2.pyx" + __pyx_t_3 = 0; + + /* "core/core2.pyx":771 + * for i in range(engine.n_verts): + * half_lst = arranged_links[i] + * n = len(half_lst) # <<<<<<<<<<<<<< + * + * if i > 0: + */ + +# line 771 "core/core2.pyx" + if (unlikely(__pyx_v_half_lst == Py_None)) { + +# line 771 "core/core2.pyx" + PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); + +# line 771 "core/core2.pyx" + __PYX_ERR(0, 771, __pyx_L1_error) + +# line 771 "core/core2.pyx" + } + +# line 771 "core/core2.pyx" + __pyx_t_2 = PyList_GET_SIZE(__pyx_v_half_lst); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 771, __pyx_L1_error) + +# line 771 "core/core2.pyx" + __pyx_v_n = __pyx_t_2; + + /* "core/core2.pyx":773 + * n = len(half_lst) + * + * if i > 0: # <<<<<<<<<<<<<< + * self.links[i] = ((self.links[i - 1]) + sizeof(HalfLinkArr) + sizeof(HalfLink) * self.links[i - 1].n) + * + */ + +# line 773 "core/core2.pyx" + __pyx_t_13 = ((__pyx_v_i > 0) != 0); + +# line 773 "core/core2.pyx" + if (__pyx_t_13) { + + /* "core/core2.pyx":774 + * + * if i > 0: + * self.links[i] = ((self.links[i - 1]) + sizeof(HalfLinkArr) + sizeof(HalfLink) * self.links[i - 1].n) # <<<<<<<<<<<<<< + * + * self.links[i].n = n + */ + +# line 774 "core/core2.pyx" + (__pyx_v_self->links[__pyx_v_i]) = ((struct HalfLinkArr *)((((char *)(__pyx_v_self->links[(__pyx_v_i - 1)])) + (sizeof(struct HalfLinkArr))) + ((sizeof(struct HalfLink)) * (__pyx_v_self->links[(__pyx_v_i - 1)])->n))); + + /* "core/core2.pyx":773 + * n = len(half_lst) + * + * if i > 0: # <<<<<<<<<<<<<< + * self.links[i] = ((self.links[i - 1]) + sizeof(HalfLinkArr) + sizeof(HalfLink) * self.links[i - 1].n) + * + */ + +# line 773 "core/core2.pyx" + } + + /* "core/core2.pyx":776 + * self.links[i] = ((self.links[i - 1]) + sizeof(HalfLinkArr) + sizeof(HalfLink) * self.links[i - 1].n) + * + * self.links[i].n = n # <<<<<<<<<<<<<< + * + * for j in range(n): + */ + +# line 776 "core/core2.pyx" + (__pyx_v_self->links[__pyx_v_i])->n = __pyx_v_n; + + /* "core/core2.pyx":778 + * self.links[i].n = n + * + * for j in range(n): # <<<<<<<<<<<<<< + * a = half_lst[j] + * self.links[i].half_links[j].a = a + */ + +# line 778 "core/core2.pyx" + __pyx_t_14 = __pyx_v_n; + +# line 778 "core/core2.pyx" + __pyx_t_15 = __pyx_t_14; + +# line 778 "core/core2.pyx" + for (__pyx_t_16 = 0; __pyx_t_16 < __pyx_t_15; __pyx_t_16+=1) { + +# line 778 "core/core2.pyx" + __pyx_v_j = __pyx_t_16; + + /* "core/core2.pyx":779 + * + * for j in range(n): + * a = half_lst[j] # <<<<<<<<<<<<<< + * self.links[i].half_links[j].a = a + * + */ + +# line 779 "core/core2.pyx" + if (unlikely(__pyx_v_half_lst == Py_None)) { + +# line 779 "core/core2.pyx" + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + +# line 779 "core/core2.pyx" + __PYX_ERR(0, 779, __pyx_L1_error) + +# line 779 "core/core2.pyx" + } + +# line 779 "core/core2.pyx" + __pyx_t_3 = __Pyx_GetItemInt_List(__pyx_v_half_lst, __pyx_v_j, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 779, __pyx_L1_error) + +# line 779 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_3); + +# line 779 "core/core2.pyx" + __pyx_t_17 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_17 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 779, __pyx_L1_error) + +# line 779 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + +# line 779 "core/core2.pyx" + __pyx_v_a = __pyx_t_17; + + /* "core/core2.pyx":780 + * for j in range(n): + * a = half_lst[j] + * self.links[i].half_links[j].a = a # <<<<<<<<<<<<<< + * + * self.lengths_update() + */ + +# line 780 "core/core2.pyx" + ((__pyx_v_self->links[__pyx_v_i])->half_links[__pyx_v_j]).a = __pyx_v_a; + +# line 780 "core/core2.pyx" + } + +# line 780 "core/core2.pyx" + } + + /* "core/core2.pyx":782 + * self.links[i].half_links[j].a = a + * + * self.lengths_update() # <<<<<<<<<<<<<< + * + * def __dealloc__(self): + */ + +# line 782 "core/core2.pyx" + ((struct __pyx_vtabstruct_14softwrap_core2_SpringLinks *)__pyx_v_self->__pyx_vtab)->lengths_update(__pyx_v_self, 0); + + /* "core/core2.pyx":754 + * + * @cython.boundscheck(True) + * def __cinit__(self, SpringEngine engine, list links): # <<<<<<<<<<<<<< + * self.engine = engine + * self.links = maelloc(sizeof(HalfLink**) * self.engine.n_verts, __LINE__) + */ + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_XDECREF(__pyx_t_9); + __Pyx_XDECREF(__pyx_t_10); + __Pyx_AddTraceback("softwrap_core2.SpringLinks.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_arranged_links); + __Pyx_XDECREF(__pyx_v_half_lst); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":784 + * self.lengths_update() + * + * def __dealloc__(self): # <<<<<<<<<<<<<< + * fraeee(self.links[0]) + * fraeee(self.links) + */ + +/* Python wrapper */ +static void __pyx_pw_14softwrap_core2_11SpringLinks_3__dealloc__(PyObject *__pyx_v_self); /*proto*/ +static void __pyx_pw_14softwrap_core2_11SpringLinks_3__dealloc__(PyObject *__pyx_v_self) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0); + __pyx_pf_14softwrap_core2_11SpringLinks_2__dealloc__(((struct __pyx_obj_14softwrap_core2_SpringLinks *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); +} + +static void __pyx_pf_14softwrap_core2_11SpringLinks_2__dealloc__(struct __pyx_obj_14softwrap_core2_SpringLinks *__pyx_v_self) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__dealloc__", 0); + + /* "core/core2.pyx":785 + * + * def __dealloc__(self): + * fraeee(self.links[0]) # <<<<<<<<<<<<<< + * fraeee(self.links) + * + */ + +# line 785 "core/core2.pyx" + __pyx_f_14softwrap_core2_fraeee((__pyx_v_self->links[0])); + + /* "core/core2.pyx":786 + * def __dealloc__(self): + * fraeee(self.links[0]) + * fraeee(self.links) # <<<<<<<<<<<<<< + * + * def __getitem__(self, int key): + */ + +# line 786 "core/core2.pyx" + __pyx_f_14softwrap_core2_fraeee(__pyx_v_self->links); + + /* "core/core2.pyx":784 + * self.lengths_update() + * + * def __dealloc__(self): # <<<<<<<<<<<<<< + * fraeee(self.links[0]) + * fraeee(self.links) + */ + + /* function exit code */ + __Pyx_RefNannyFinishContext(); +} + +/* "core/core2.pyx":788 + * fraeee(self.links) + * + * def __getitem__(self, int key): # <<<<<<<<<<<<<< + * if key < 0 or key >= self.engine.n_verts: + * raise IndexError + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_11SpringLinks_5__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_key); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_11SpringLinks_5__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_key) { + int __pyx_v_key; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0); + assert(__pyx_arg_key); { + __pyx_v_key = __Pyx_PyInt_As_int(__pyx_arg_key); if (unlikely((__pyx_v_key == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 788, __pyx_L3_error) + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("softwrap_core2.SpringLinks.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_14softwrap_core2_11SpringLinks_4__getitem__(((struct __pyx_obj_14softwrap_core2_SpringLinks *)__pyx_v_self), ((int)__pyx_v_key)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_11SpringLinks_4__getitem__(struct __pyx_obj_14softwrap_core2_SpringLinks *__pyx_v_self, int __pyx_v_key) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__getitem__", 0); + + /* "core/core2.pyx":789 + * + * def __getitem__(self, int key): + * if key < 0 or key >= self.engine.n_verts: # <<<<<<<<<<<<<< + * raise IndexError + * + */ + +# line 789 "core/core2.pyx" + __pyx_t_2 = ((__pyx_v_key < 0) != 0); + +# line 789 "core/core2.pyx" + if (!__pyx_t_2) { + +# line 789 "core/core2.pyx" + } else { + +# line 789 "core/core2.pyx" + __pyx_t_1 = __pyx_t_2; + +# line 789 "core/core2.pyx" + goto __pyx_L4_bool_binop_done; + +# line 789 "core/core2.pyx" + } + +# line 789 "core/core2.pyx" + __pyx_t_2 = ((__pyx_v_key >= __pyx_v_self->engine->n_verts) != 0); + +# line 789 "core/core2.pyx" + __pyx_t_1 = __pyx_t_2; + +# line 789 "core/core2.pyx" + __pyx_L4_bool_binop_done:; + +# line 789 "core/core2.pyx" + if (unlikely(__pyx_t_1)) { + + /* "core/core2.pyx":790 + * def __getitem__(self, int key): + * if key < 0 or key >= self.engine.n_verts: + * raise IndexError # <<<<<<<<<<<<<< + * + * return LinkProbe(self, key) + */ + +# line 790 "core/core2.pyx" + __Pyx_Raise(__pyx_builtin_IndexError, 0, 0, 0); + +# line 790 "core/core2.pyx" + __PYX_ERR(0, 790, __pyx_L1_error) + + /* "core/core2.pyx":789 + * + * def __getitem__(self, int key): + * if key < 0 or key >= self.engine.n_verts: # <<<<<<<<<<<<<< + * raise IndexError + * + */ + +# line 789 "core/core2.pyx" + } + + /* "core/core2.pyx":792 + * raise IndexError + * + * return LinkProbe(self, key) # <<<<<<<<<<<<<< + * + * cpdef void lengths_update(self): + */ + +# line 792 "core/core2.pyx" + __Pyx_XDECREF(__pyx_r); + +# line 792 "core/core2.pyx" + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_key); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 792, __pyx_L1_error) + +# line 792 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_3); + +# line 792 "core/core2.pyx" + __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 792, __pyx_L1_error) + +# line 792 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_4); + +# line 792 "core/core2.pyx" + __Pyx_INCREF(((PyObject *)__pyx_v_self)); + +# line 792 "core/core2.pyx" + __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); + +# line 792 "core/core2.pyx" + PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_self)); + +# line 792 "core/core2.pyx" + __Pyx_GIVEREF(__pyx_t_3); + +# line 792 "core/core2.pyx" + PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3); + +# line 792 "core/core2.pyx" + __pyx_t_3 = 0; + +# line 792 "core/core2.pyx" + __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_14softwrap_core2_LinkProbe), __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 792, __pyx_L1_error) + +# line 792 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_3); + +# line 792 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + +# line 792 "core/core2.pyx" + __pyx_r = __pyx_t_3; + +# line 792 "core/core2.pyx" + __pyx_t_3 = 0; + +# line 792 "core/core2.pyx" + goto __pyx_L0; + + /* "core/core2.pyx":788 + * fraeee(self.links) + * + * def __getitem__(self, int key): # <<<<<<<<<<<<<< + * if key < 0 or key >= self.engine.n_verts: + * raise IndexError + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("softwrap_core2.SpringLinks.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":794 + * return LinkProbe(self, key) + * + * cpdef void lengths_update(self): # <<<<<<<<<<<<<< + * cdef int i, j, a + * + */ + +static PyObject *__pyx_pw_14softwrap_core2_11SpringLinks_7lengths_update(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static void __pyx_f_14softwrap_core2_11SpringLinks_lengths_update(struct __pyx_obj_14softwrap_core2_SpringLinks *__pyx_v_self, int __pyx_skip_dispatch) { + int __pyx_v_i; + int __pyx_v_j; + int __pyx_v_a; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + int __pyx_t_5; + int __pyx_t_6; + int __pyx_t_7; + int __pyx_t_8; + int __pyx_t_9; + int __pyx_t_10; + int __pyx_t_11; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("lengths_update", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) { + #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS + static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; + if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) { + PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); + #endif + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_lengths_update); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 794, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_14softwrap_core2_11SpringLinks_7lengths_update)) { + __Pyx_INCREF(__pyx_t_1); + __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { + __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); + if (likely(__pyx_t_4)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); + __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_3, function); + } + } + __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 794, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS + __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); + __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self)); + if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) { + __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; + } + #endif + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS + } + #endif + } + + /* "core/core2.pyx":797 + * cdef int i, j, a + * + * for i in range(self.engine.n_verts): # <<<<<<<<<<<<<< + * for j in range(self.links[i].n): + * a = self.links[i].half_links[j].a + */ + +# line 797 "core/core2.pyx" + __pyx_t_5 = __pyx_v_self->engine->n_verts; + +# line 797 "core/core2.pyx" + __pyx_t_6 = __pyx_t_5; + +# line 797 "core/core2.pyx" + for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) { + +# line 797 "core/core2.pyx" + __pyx_v_i = __pyx_t_7; + + /* "core/core2.pyx":798 + * + * for i in range(self.engine.n_verts): + * for j in range(self.links[i].n): # <<<<<<<<<<<<<< + * a = self.links[i].half_links[j].a + * self.links[i].half_links[j].original_length = (self.engine.m.verts[i] - self.engine.m.verts[a]).len() + */ + +# line 798 "core/core2.pyx" + __pyx_t_8 = (__pyx_v_self->links[__pyx_v_i])->n; + +# line 798 "core/core2.pyx" + __pyx_t_9 = __pyx_t_8; + +# line 798 "core/core2.pyx" + for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) { + +# line 798 "core/core2.pyx" + __pyx_v_j = __pyx_t_10; + + /* "core/core2.pyx":799 + * for i in range(self.engine.n_verts): + * for j in range(self.links[i].n): + * a = self.links[i].half_links[j].a # <<<<<<<<<<<<<< + * self.links[i].half_links[j].original_length = (self.engine.m.verts[i] - self.engine.m.verts[a]).len() + * self.links[i].half_links[j].scale = 1 + */ + +# line 799 "core/core2.pyx" + __pyx_t_11 = ((__pyx_v_self->links[__pyx_v_i])->half_links[__pyx_v_j]).a; + +# line 799 "core/core2.pyx" + __pyx_v_a = __pyx_t_11; + + /* "core/core2.pyx":800 + * for j in range(self.links[i].n): + * a = self.links[i].half_links[j].a + * self.links[i].half_links[j].original_length = (self.engine.m.verts[i] - self.engine.m.verts[a]).len() # <<<<<<<<<<<<<< + * self.links[i].half_links[j].scale = 1 + * + */ + +# line 800 "core/core2.pyx" + ((__pyx_v_self->links[__pyx_v_i])->half_links[__pyx_v_j]).original_length = ((__pyx_v_self->engine->m->verts[__pyx_v_i]) - (__pyx_v_self->engine->m->verts[__pyx_v_a])).len(); + + /* "core/core2.pyx":801 + * a = self.links[i].half_links[j].a + * self.links[i].half_links[j].original_length = (self.engine.m.verts[i] - self.engine.m.verts[a]).len() + * self.links[i].half_links[j].scale = 1 # <<<<<<<<<<<<<< + * + * cpdef void smooth(self, float factor): + */ + +# line 801 "core/core2.pyx" + ((__pyx_v_self->links[__pyx_v_i])->half_links[__pyx_v_j]).scale = 1.0; + +# line 801 "core/core2.pyx" + } + +# line 801 "core/core2.pyx" + } + + /* "core/core2.pyx":794 + * return LinkProbe(self, key) + * + * cpdef void lengths_update(self): # <<<<<<<<<<<<<< + * cdef int i, j, a + * + */ + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_WriteUnraisable("softwrap_core2.SpringLinks.lengths_update", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); + __pyx_L0:; + __Pyx_RefNannyFinishContext(); +} + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_11SpringLinks_7lengths_update(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_11SpringLinks_7lengths_update(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("lengths_update (wrapper)", 0); + __pyx_r = __pyx_pf_14softwrap_core2_11SpringLinks_6lengths_update(((struct __pyx_obj_14softwrap_core2_SpringLinks *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_11SpringLinks_6lengths_update(struct __pyx_obj_14softwrap_core2_SpringLinks *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("lengths_update", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_void_to_None(__pyx_f_14softwrap_core2_11SpringLinks_lengths_update(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 794, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("softwrap_core2.SpringLinks.lengths_update", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":803 + * self.links[i].half_links[j].scale = 1 + * + * cpdef void smooth(self, float factor): # <<<<<<<<<<<<<< + * cdef int i, j, n + * cdef HalfLink* half_links + */ + +static PyObject *__pyx_pw_14softwrap_core2_11SpringLinks_9smooth(PyObject *__pyx_v_self, PyObject *__pyx_arg_factor); /*proto*/ +static void __pyx_f_14softwrap_core2_11SpringLinks_smooth(struct __pyx_obj_14softwrap_core2_SpringLinks *__pyx_v_self, float __pyx_v_factor, int __pyx_skip_dispatch) { + int __pyx_v_i; + int __pyx_v_j; + int __pyx_v_n; + struct HalfLink *__pyx_v_half_links; + vec3 __pyx_v_avg; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + int __pyx_t_6; + int __pyx_t_7; + int __pyx_t_8; + int __pyx_t_9; + struct HalfLink *__pyx_t_10; + int __pyx_t_11; + int __pyx_t_12; + int __pyx_t_13; + vec3 *__pyx_t_14; + vec3 *__pyx_t_15; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("smooth", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) { + #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS + static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; + if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) { + PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); + #endif + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_smooth); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 803, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_14softwrap_core2_11SpringLinks_9smooth)) { + __pyx_t_3 = PyFloat_FromDouble(__pyx_v_factor); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 803, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_t_1); + __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_4, function); + } + } + __pyx_t_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); + __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 803, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS + __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); + __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self)); + if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) { + __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; + } + #endif + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS + } + #endif + } + + /* "core/core2.pyx":808 + * cdef vec3 avg + * + * with nogil: # <<<<<<<<<<<<<< + * for i in prange(self.engine.n_verts): + * n = self.links[i].n + */ + +# line 808 "core/core2.pyx" + { + +# line 808 "core/core2.pyx" + #ifdef WITH_THREAD + +# line 808 "core/core2.pyx" + PyThreadState *_save; + +# line 808 "core/core2.pyx" + Py_UNBLOCK_THREADS + +# line 808 "core/core2.pyx" + __Pyx_FastGIL_Remember(); + +# line 808 "core/core2.pyx" + #endif + /*try:*/ { + + /* "core/core2.pyx":809 + * + * with nogil: + * for i in prange(self.engine.n_verts): # <<<<<<<<<<<<<< + * n = self.links[i].n + * + */ + +# line 809 "core/core2.pyx" + __pyx_t_6 = __pyx_v_self->engine->n_verts; + +# line 809 "core/core2.pyx" + if ((1 == 0)) abort(); + +# line 809 "core/core2.pyx" + { + +# line 809 "core/core2.pyx" + #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))))) + +# line 809 "core/core2.pyx" + #undef likely + +# line 809 "core/core2.pyx" + #undef unlikely + #define likely(x) (x) + #define unlikely(x) (x) + +# line 809 "core/core2.pyx" + #endif + +# line 809 "core/core2.pyx" + __pyx_t_8 = (__pyx_t_6 - 0 + 1 - 1/abs(1)) / 1; + +# line 809 "core/core2.pyx" + if (__pyx_t_8 > 0) + +# line 809 "core/core2.pyx" + { + +# line 809 "core/core2.pyx" + #ifdef _OPENMP + +# line 809 "core/core2.pyx" + #pragma omp parallel private(__pyx_t_10, __pyx_t_11, __pyx_t_12, __pyx_t_13, __pyx_t_9) + #endif /* _OPENMP */ + { + #ifdef _OPENMP + #pragma omp for lastprivate(__pyx_v_avg) lastprivate(__pyx_v_half_links) firstprivate(__pyx_v_i) lastprivate(__pyx_v_i) lastprivate(__pyx_v_j) lastprivate(__pyx_v_n) + #endif /* _OPENMP */ + for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_8; __pyx_t_7++){ + { + __pyx_v_i = (int)(0 + 1 * __pyx_t_7); + /* Initialize private variables to invalid values */ + __pyx_v_half_links = ((struct HalfLink *)1); + __pyx_v_j = ((int)0xbad0bad0); + __pyx_v_n = ((int)0xbad0bad0); + + /* "core/core2.pyx":810 + * with nogil: + * for i in prange(self.engine.n_verts): + * n = self.links[i].n # <<<<<<<<<<<<<< + * + * half_links = self.links[i].half_links + */ + +# line 810 "core/core2.pyx" + __pyx_t_9 = (__pyx_v_self->links[__pyx_v_i])->n; + +# line 810 "core/core2.pyx" + __pyx_v_n = __pyx_t_9; + + /* "core/core2.pyx":812 + * n = self.links[i].n + * + * half_links = self.links[i].half_links # <<<<<<<<<<<<<< + * + * if n == 0: + */ + +# line 812 "core/core2.pyx" + __pyx_t_10 = (__pyx_v_self->links[__pyx_v_i])->half_links; + +# line 812 "core/core2.pyx" + __pyx_v_half_links = __pyx_t_10; + + /* "core/core2.pyx":814 + * half_links = self.links[i].half_links + * + * if n == 0: # <<<<<<<<<<<<<< + * avg = self.engine.m.verts[i] + * continue + */ + +# line 814 "core/core2.pyx" + __pyx_t_11 = ((__pyx_v_n == 0) != 0); + +# line 814 "core/core2.pyx" + if (__pyx_t_11) { + + /* "core/core2.pyx":815 + * + * if n == 0: + * avg = self.engine.m.verts[i] # <<<<<<<<<<<<<< + * continue + * + */ + +# line 815 "core/core2.pyx" + __pyx_v_avg = (__pyx_v_self->engine->m->verts[__pyx_v_i]); + + /* "core/core2.pyx":816 + * if n == 0: + * avg = self.engine.m.verts[i] + * continue # <<<<<<<<<<<<<< + * + * avg = vec3(0) + */ + +# line 816 "core/core2.pyx" + goto __pyx_L6_continue; + + /* "core/core2.pyx":814 + * half_links = self.links[i].half_links + * + * if n == 0: # <<<<<<<<<<<<<< + * avg = self.engine.m.verts[i] + * continue + */ + +# line 814 "core/core2.pyx" + } + + /* "core/core2.pyx":818 + * continue + * + * avg = vec3(0) # <<<<<<<<<<<<<< + * + * for j in range(n): + */ + +# line 818 "core/core2.pyx" + __pyx_v_avg = vec3(0.0); + + /* "core/core2.pyx":820 + * avg = vec3(0) + * + * for j in range(n): # <<<<<<<<<<<<<< + * avg = avg + self.engine.m.verts[half_links[j].a] + * + */ + +# line 820 "core/core2.pyx" + __pyx_t_9 = __pyx_v_n; + +# line 820 "core/core2.pyx" + __pyx_t_12 = __pyx_t_9; + +# line 820 "core/core2.pyx" + for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_12; __pyx_t_13+=1) { + +# line 820 "core/core2.pyx" + __pyx_v_j = __pyx_t_13; + + /* "core/core2.pyx":821 + * + * for j in range(n): + * avg = avg + self.engine.m.verts[half_links[j].a] # <<<<<<<<<<<<<< + * + * avg = avg * 1.0 / n + */ + +# line 821 "core/core2.pyx" + __pyx_v_avg = (__pyx_v_avg + (__pyx_v_self->engine->m->verts[(__pyx_v_half_links[__pyx_v_j]).a])); + +# line 821 "core/core2.pyx" + } + + /* "core/core2.pyx":823 + * avg = avg + self.engine.m.verts[half_links[j].a] + * + * avg = avg * 1.0 / n # <<<<<<<<<<<<<< + * + * self.engine.tmp_verts[i] = self.engine.m.verts[i].lerp(avg, factor) + */ + +# line 823 "core/core2.pyx" + __pyx_v_avg = ((__pyx_v_avg * ((float)1.0)) / __pyx_v_n); + + /* "core/core2.pyx":825 + * avg = avg * 1.0 / n + * + * self.engine.tmp_verts[i] = self.engine.m.verts[i].lerp(avg, factor) # <<<<<<<<<<<<<< + * + * self.engine.m.verts, self.engine.tmp_verts = self.engine.tmp_verts, self.engine.m.verts + */ + +# line 825 "core/core2.pyx" + (__pyx_v_self->engine->tmp_verts[__pyx_v_i]) = (__pyx_v_self->engine->m->verts[__pyx_v_i]).lerp(__pyx_v_avg, __pyx_v_factor); + +# line 825 "core/core2.pyx" + goto __pyx_L14; + +# line 825 "core/core2.pyx" + __pyx_L6_continue:; + +# line 825 "core/core2.pyx" + goto __pyx_L14; + +# line 825 "core/core2.pyx" + __pyx_L14:; + +# line 825 "core/core2.pyx" + } + +# line 825 "core/core2.pyx" + } + +# line 825 "core/core2.pyx" + } + +# line 825 "core/core2.pyx" + } + +# line 825 "core/core2.pyx" + } + +# line 825 "core/core2.pyx" + #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))))) + +# line 825 "core/core2.pyx" + #undef likely + +# line 825 "core/core2.pyx" + #undef unlikely + #define likely(x) __builtin_expect(!!(x), 1) + #define unlikely(x) __builtin_expect(!!(x), 0) + +# line 825 "core/core2.pyx" + #endif + +# line 825 "core/core2.pyx" + } + + /* "core/core2.pyx":808 + * cdef vec3 avg + * + * with nogil: # <<<<<<<<<<<<<< + * for i in prange(self.engine.n_verts): + * n = self.links[i].n + */ + /*finally:*/ { + /*normal exit:*/{ + #ifdef WITH_THREAD + __Pyx_FastGIL_Forget(); + Py_BLOCK_THREADS + #endif + goto __pyx_L5; + } + __pyx_L5:; + } + } + + /* "core/core2.pyx":827 + * self.engine.tmp_verts[i] = self.engine.m.verts[i].lerp(avg, factor) + * + * self.engine.m.verts, self.engine.tmp_verts = self.engine.tmp_verts, self.engine.m.verts # <<<<<<<<<<<<<< + * + * + */ + +# line 827 "core/core2.pyx" + __pyx_t_14 = __pyx_v_self->engine->tmp_verts; + +# line 827 "core/core2.pyx" + __pyx_t_15 = __pyx_v_self->engine->m->verts; + +# line 827 "core/core2.pyx" + __pyx_v_self->engine->m->verts = __pyx_t_14; + +# line 827 "core/core2.pyx" + __pyx_v_self->engine->tmp_verts = __pyx_t_15; + + /* "core/core2.pyx":803 + * self.links[i].half_links[j].scale = 1 + * + * cpdef void smooth(self, float factor): # <<<<<<<<<<<<<< + * cdef int i, j, n + * cdef HalfLink* half_links + */ + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_WriteUnraisable("softwrap_core2.SpringLinks.smooth", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); + __pyx_L0:; + __Pyx_RefNannyFinishContext(); +} + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_11SpringLinks_9smooth(PyObject *__pyx_v_self, PyObject *__pyx_arg_factor); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_11SpringLinks_9smooth(PyObject *__pyx_v_self, PyObject *__pyx_arg_factor) { + float __pyx_v_factor; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("smooth (wrapper)", 0); + assert(__pyx_arg_factor); { + __pyx_v_factor = __pyx_PyFloat_AsFloat(__pyx_arg_factor); if (unlikely((__pyx_v_factor == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 803, __pyx_L3_error) + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("softwrap_core2.SpringLinks.smooth", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_14softwrap_core2_11SpringLinks_8smooth(((struct __pyx_obj_14softwrap_core2_SpringLinks *)__pyx_v_self), ((float)__pyx_v_factor)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_11SpringLinks_8smooth(struct __pyx_obj_14softwrap_core2_SpringLinks *__pyx_v_self, float __pyx_v_factor) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("smooth", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_void_to_None(__pyx_f_14softwrap_core2_11SpringLinks_smooth(__pyx_v_self, __pyx_v_factor, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 803, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("softwrap_core2.SpringLinks.smooth", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":830 + * + * + * cpdef void soft_spring_force(self, float factor, float deform_update=0.3, float deform_restore=0.03, float min_deform=0.3, float max_deform=3.0): # <<<<<<<<<<<<<< + * cdef int i, j, n, a + * cdef HalfLink* half_links + */ + +static PyObject *__pyx_pw_14softwrap_core2_11SpringLinks_11soft_spring_force(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static void __pyx_f_14softwrap_core2_11SpringLinks_soft_spring_force(struct __pyx_obj_14softwrap_core2_SpringLinks *__pyx_v_self, float __pyx_v_factor, int __pyx_skip_dispatch, struct __pyx_opt_args_14softwrap_core2_11SpringLinks_soft_spring_force *__pyx_optional_args) { + float __pyx_v_deform_update = ((float)0.3); + float __pyx_v_deform_restore = ((float)0.03); + float __pyx_v_min_deform = ((float)0.3); + float __pyx_v_max_deform = ((float)3.0); + int __pyx_v_i; + int __pyx_v_j; + int __pyx_v_n; + int __pyx_v_a; + struct HalfLink *__pyx_v_half_links; + vec3 __pyx_v_delta; + float __pyx_v_curr_length; + float __pyx_v_diff; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8 = NULL; + PyObject *__pyx_t_9 = NULL; + int __pyx_t_10; + PyObject *__pyx_t_11 = NULL; + int __pyx_t_12; + int __pyx_t_13; + int __pyx_t_14; + struct HalfLink *__pyx_t_15; + int __pyx_t_16; + int __pyx_t_17; + int __pyx_t_18; + vec3 *__pyx_t_19; + vec3 *__pyx_t_20; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("soft_spring_force", 0); + if (__pyx_optional_args) { + if (__pyx_optional_args->__pyx_n > 0) { + __pyx_v_deform_update = __pyx_optional_args->deform_update; + if (__pyx_optional_args->__pyx_n > 1) { + __pyx_v_deform_restore = __pyx_optional_args->deform_restore; + if (__pyx_optional_args->__pyx_n > 2) { + __pyx_v_min_deform = __pyx_optional_args->min_deform; + if (__pyx_optional_args->__pyx_n > 3) { + __pyx_v_max_deform = __pyx_optional_args->max_deform; + } + } + } + } + } + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) { + #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS + static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; + if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) { + PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); + #endif + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_soft_spring_force); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 830, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_14softwrap_core2_11SpringLinks_11soft_spring_force)) { + __pyx_t_3 = PyFloat_FromDouble(__pyx_v_factor); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 830, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyFloat_FromDouble(__pyx_v_deform_update); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 830, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = PyFloat_FromDouble(__pyx_v_deform_restore); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 830, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_6 = PyFloat_FromDouble(__pyx_v_min_deform); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 830, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_7 = PyFloat_FromDouble(__pyx_v_max_deform); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 830, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_INCREF(__pyx_t_1); + __pyx_t_8 = __pyx_t_1; __pyx_t_9 = NULL; + __pyx_t_10 = 0; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) { + __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8); + if (likely(__pyx_t_9)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); + __Pyx_INCREF(__pyx_t_9); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_8, function); + __pyx_t_10 = 1; + } + } + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_8)) { + PyObject *__pyx_temp[6] = {__pyx_t_9, __pyx_t_3, __pyx_t_4, __pyx_t_5, __pyx_t_6, __pyx_t_7}; + __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_10, 5+__pyx_t_10); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 830, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) { + PyObject *__pyx_temp[6] = {__pyx_t_9, __pyx_t_3, __pyx_t_4, __pyx_t_5, __pyx_t_6, __pyx_t_7}; + __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_10, 5+__pyx_t_10); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 830, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + } else + #endif + { + __pyx_t_11 = PyTuple_New(5+__pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 830, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); + if (__pyx_t_9) { + __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_9); __pyx_t_9 = NULL; + } + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_10, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_10, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_11, 2+__pyx_t_10, __pyx_t_5); + __Pyx_GIVEREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_11, 3+__pyx_t_10, __pyx_t_6); + __Pyx_GIVEREF(__pyx_t_7); + PyTuple_SET_ITEM(__pyx_t_11, 4+__pyx_t_10, __pyx_t_7); + __pyx_t_3 = 0; + __pyx_t_4 = 0; + __pyx_t_5 = 0; + __pyx_t_6 = 0; + __pyx_t_7 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_11, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 830, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + } + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS + __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); + __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self)); + if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) { + __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; + } + #endif + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS + } + #endif + } + + /* "core/core2.pyx":836 + * cdef float curr_length, diff + * + * with nogil: # <<<<<<<<<<<<<< + * for i in prange(self.engine.n_verts): + * n = self.links[i].n + */ + +# line 836 "core/core2.pyx" + { + +# line 836 "core/core2.pyx" + #ifdef WITH_THREAD + +# line 836 "core/core2.pyx" + PyThreadState *_save; + +# line 836 "core/core2.pyx" + Py_UNBLOCK_THREADS + +# line 836 "core/core2.pyx" + __Pyx_FastGIL_Remember(); + +# line 836 "core/core2.pyx" + #endif + /*try:*/ { + + /* "core/core2.pyx":837 + * + * with nogil: + * for i in prange(self.engine.n_verts): # <<<<<<<<<<<<<< + * n = self.links[i].n + * + */ + +# line 837 "core/core2.pyx" + __pyx_t_10 = __pyx_v_self->engine->n_verts; + +# line 837 "core/core2.pyx" + if ((1 == 0)) abort(); + +# line 837 "core/core2.pyx" + { + +# line 837 "core/core2.pyx" + #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))))) + +# line 837 "core/core2.pyx" + #undef likely + +# line 837 "core/core2.pyx" + #undef unlikely + #define likely(x) (x) + #define unlikely(x) (x) + +# line 837 "core/core2.pyx" + #endif + +# line 837 "core/core2.pyx" + __pyx_t_13 = (__pyx_t_10 - 0 + 1 - 1/abs(1)) / 1; + +# line 837 "core/core2.pyx" + if (__pyx_t_13 > 0) + +# line 837 "core/core2.pyx" + { + +# line 837 "core/core2.pyx" + #ifdef _OPENMP + +# line 837 "core/core2.pyx" + #pragma omp parallel private(__pyx_t_14, __pyx_t_15, __pyx_t_16, __pyx_t_17, __pyx_t_18) + #endif /* _OPENMP */ + { + #ifdef _OPENMP + #pragma omp for lastprivate(__pyx_v_a) lastprivate(__pyx_v_curr_length) lastprivate(__pyx_v_delta) lastprivate(__pyx_v_diff) lastprivate(__pyx_v_half_links) firstprivate(__pyx_v_i) lastprivate(__pyx_v_i) lastprivate(__pyx_v_j) lastprivate(__pyx_v_n) + #endif /* _OPENMP */ + for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_13; __pyx_t_12++){ + { + __pyx_v_i = (int)(0 + 1 * __pyx_t_12); + /* Initialize private variables to invalid values */ + __pyx_v_a = ((int)0xbad0bad0); + __pyx_v_curr_length = ((float)__PYX_NAN()); + __pyx_v_diff = ((float)__PYX_NAN()); + __pyx_v_half_links = ((struct HalfLink *)1); + __pyx_v_j = ((int)0xbad0bad0); + __pyx_v_n = ((int)0xbad0bad0); + + /* "core/core2.pyx":838 + * with nogil: + * for i in prange(self.engine.n_verts): + * n = self.links[i].n # <<<<<<<<<<<<<< + * + * half_links = self.links[i].half_links + */ + +# line 838 "core/core2.pyx" + __pyx_t_14 = (__pyx_v_self->links[__pyx_v_i])->n; + +# line 838 "core/core2.pyx" + __pyx_v_n = __pyx_t_14; + + /* "core/core2.pyx":840 + * n = self.links[i].n + * + * half_links = self.links[i].half_links # <<<<<<<<<<<<<< + * + * self.engine.tmp_verts[i] = vec3(0) + */ + +# line 840 "core/core2.pyx" + __pyx_t_15 = (__pyx_v_self->links[__pyx_v_i])->half_links; + +# line 840 "core/core2.pyx" + __pyx_v_half_links = __pyx_t_15; + + /* "core/core2.pyx":842 + * half_links = self.links[i].half_links + * + * self.engine.tmp_verts[i] = vec3(0) # <<<<<<<<<<<<<< + * + * for j in range(n): + */ + +# line 842 "core/core2.pyx" + (__pyx_v_self->engine->tmp_verts[__pyx_v_i]) = vec3(0.0); + + /* "core/core2.pyx":844 + * self.engine.tmp_verts[i] = vec3(0) + * + * for j in range(n): # <<<<<<<<<<<<<< + * a = half_links[j].a + * + */ + +# line 844 "core/core2.pyx" + __pyx_t_14 = __pyx_v_n; + +# line 844 "core/core2.pyx" + __pyx_t_16 = __pyx_t_14; + +# line 844 "core/core2.pyx" + for (__pyx_t_17 = 0; __pyx_t_17 < __pyx_t_16; __pyx_t_17+=1) { + +# line 844 "core/core2.pyx" + __pyx_v_j = __pyx_t_17; + + /* "core/core2.pyx":845 + * + * for j in range(n): + * a = half_links[j].a # <<<<<<<<<<<<<< + * + * delta = self.engine.m.verts[i] - self.engine.m.verts[a] + */ + +# line 845 "core/core2.pyx" + __pyx_t_18 = (__pyx_v_half_links[__pyx_v_j]).a; + +# line 845 "core/core2.pyx" + __pyx_v_a = __pyx_t_18; + + /* "core/core2.pyx":847 + * a = half_links[j].a + * + * delta = self.engine.m.verts[i] - self.engine.m.verts[a] # <<<<<<<<<<<<<< + * curr_length = nmax(delta.len(), EPS) + * diff = ((half_links[j].original_length * half_links[j].scale - curr_length) / curr_length) + */ + +# line 847 "core/core2.pyx" + __pyx_v_delta = ((__pyx_v_self->engine->m->verts[__pyx_v_i]) - (__pyx_v_self->engine->m->verts[__pyx_v_a])); + + /* "core/core2.pyx":848 + * + * delta = self.engine.m.verts[i] - self.engine.m.verts[a] + * curr_length = nmax(delta.len(), EPS) # <<<<<<<<<<<<<< + * diff = ((half_links[j].original_length * half_links[j].scale - curr_length) / curr_length) + * self.engine.tmp_verts[i] += delta * diff + */ + +# line 848 "core/core2.pyx" + __pyx_v_curr_length = nmax(__pyx_v_delta.len(), EPS); + + /* "core/core2.pyx":849 + * delta = self.engine.m.verts[i] - self.engine.m.verts[a] + * curr_length = nmax(delta.len(), EPS) + * diff = ((half_links[j].original_length * half_links[j].scale - curr_length) / curr_length) # <<<<<<<<<<<<<< + * self.engine.tmp_verts[i] += delta * diff + * half_links[j].scale = nlerp(half_links[j].scale, nclamp(curr_length / half_links[j].original_length, min_deform, max_deform), deform_update) + */ + +# line 849 "core/core2.pyx" + __pyx_v_diff = ((((__pyx_v_half_links[__pyx_v_j]).original_length * (__pyx_v_half_links[__pyx_v_j]).scale) - __pyx_v_curr_length) / __pyx_v_curr_length); + + /* "core/core2.pyx":850 + * curr_length = nmax(delta.len(), EPS) + * diff = ((half_links[j].original_length * half_links[j].scale - curr_length) / curr_length) + * self.engine.tmp_verts[i] += delta * diff # <<<<<<<<<<<<<< + * half_links[j].scale = nlerp(half_links[j].scale, nclamp(curr_length / half_links[j].original_length, min_deform, max_deform), deform_update) + * half_links[j].scale = nlerp(half_links[j].scale, 1, deform_restore) + */ + +# line 850 "core/core2.pyx" + (__pyx_v_self->engine->tmp_verts[__pyx_v_i]) += (__pyx_v_delta * __pyx_v_diff); + + /* "core/core2.pyx":851 + * diff = ((half_links[j].original_length * half_links[j].scale - curr_length) / curr_length) + * self.engine.tmp_verts[i] += delta * diff + * half_links[j].scale = nlerp(half_links[j].scale, nclamp(curr_length / half_links[j].original_length, min_deform, max_deform), deform_update) # <<<<<<<<<<<<<< + * half_links[j].scale = nlerp(half_links[j].scale, 1, deform_restore) + * + */ + +# line 851 "core/core2.pyx" + (__pyx_v_half_links[__pyx_v_j]).scale = nlerp((__pyx_v_half_links[__pyx_v_j]).scale, nclamp((__pyx_v_curr_length / (__pyx_v_half_links[__pyx_v_j]).original_length), __pyx_v_min_deform, __pyx_v_max_deform), __pyx_v_deform_update); + + /* "core/core2.pyx":852 + * self.engine.tmp_verts[i] += delta * diff + * half_links[j].scale = nlerp(half_links[j].scale, nclamp(curr_length / half_links[j].original_length, min_deform, max_deform), deform_update) + * half_links[j].scale = nlerp(half_links[j].scale, 1, deform_restore) # <<<<<<<<<<<<<< + * + * self.engine.tmp_verts[i] *= 1.0 / (n + EPS) * factor + */ + +# line 852 "core/core2.pyx" + (__pyx_v_half_links[__pyx_v_j]).scale = nlerp((__pyx_v_half_links[__pyx_v_j]).scale, 1, __pyx_v_deform_restore); + +# line 852 "core/core2.pyx" + } + + /* "core/core2.pyx":854 + * half_links[j].scale = nlerp(half_links[j].scale, 1, deform_restore) + * + * self.engine.tmp_verts[i] *= 1.0 / (n + EPS) * factor # <<<<<<<<<<<<<< + * self.engine.tmp_verts[i] += self.engine.m.verts[i] + * + */ + +# line 854 "core/core2.pyx" + (__pyx_v_self->engine->tmp_verts[__pyx_v_i]) *= ((((float)1.0) / (__pyx_v_n + EPS)) * __pyx_v_factor); + + /* "core/core2.pyx":855 + * + * self.engine.tmp_verts[i] *= 1.0 / (n + EPS) * factor + * self.engine.tmp_verts[i] += self.engine.m.verts[i] # <<<<<<<<<<<<<< + * + * self.engine.m.verts, self.engine.tmp_verts = self.engine.tmp_verts, self.engine.m.verts + */ + +# line 855 "core/core2.pyx" + (__pyx_v_self->engine->tmp_verts[__pyx_v_i]) += (__pyx_v_self->engine->m->verts[__pyx_v_i]); + +# line 855 "core/core2.pyx" + } + +# line 855 "core/core2.pyx" + } + +# line 855 "core/core2.pyx" + } + +# line 855 "core/core2.pyx" + } + +# line 855 "core/core2.pyx" + } + +# line 855 "core/core2.pyx" + #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))))) + +# line 855 "core/core2.pyx" + #undef likely + +# line 855 "core/core2.pyx" + #undef unlikely + #define likely(x) __builtin_expect(!!(x), 1) + #define unlikely(x) __builtin_expect(!!(x), 0) + +# line 855 "core/core2.pyx" + #endif + +# line 855 "core/core2.pyx" + } + + /* "core/core2.pyx":836 + * cdef float curr_length, diff + * + * with nogil: # <<<<<<<<<<<<<< + * for i in prange(self.engine.n_verts): + * n = self.links[i].n + */ + /*finally:*/ { + /*normal exit:*/{ + #ifdef WITH_THREAD + __Pyx_FastGIL_Forget(); + Py_BLOCK_THREADS + #endif + goto __pyx_L5; + } + __pyx_L5:; + } + } + + /* "core/core2.pyx":857 + * self.engine.tmp_verts[i] += self.engine.m.verts[i] + * + * self.engine.m.verts, self.engine.tmp_verts = self.engine.tmp_verts, self.engine.m.verts # <<<<<<<<<<<<<< + * + * cpdef void stiff_spring_force(self, float factor): + */ + +# line 857 "core/core2.pyx" + __pyx_t_19 = __pyx_v_self->engine->tmp_verts; + +# line 857 "core/core2.pyx" + __pyx_t_20 = __pyx_v_self->engine->m->verts; + +# line 857 "core/core2.pyx" + __pyx_v_self->engine->m->verts = __pyx_t_19; + +# line 857 "core/core2.pyx" + __pyx_v_self->engine->tmp_verts = __pyx_t_20; + + /* "core/core2.pyx":830 + * + * + * cpdef void soft_spring_force(self, float factor, float deform_update=0.3, float deform_restore=0.03, float min_deform=0.3, float max_deform=3.0): # <<<<<<<<<<<<<< + * cdef int i, j, n, a + * cdef HalfLink* half_links + */ + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_XDECREF(__pyx_t_9); + __Pyx_XDECREF(__pyx_t_11); + __Pyx_WriteUnraisable("softwrap_core2.SpringLinks.soft_spring_force", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); + __pyx_L0:; + __Pyx_RefNannyFinishContext(); +} + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_11SpringLinks_11soft_spring_force(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_11SpringLinks_11soft_spring_force(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + float __pyx_v_factor; + float __pyx_v_deform_update; + float __pyx_v_deform_restore; + float __pyx_v_min_deform; + float __pyx_v_max_deform; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("soft_spring_force (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_factor,&__pyx_n_s_deform_update,&__pyx_n_s_deform_restore,&__pyx_n_s_min_deform,&__pyx_n_s_max_deform,0}; + PyObject* values[5] = {0,0,0,0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); + CYTHON_FALLTHROUGH; + case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + CYTHON_FALLTHROUGH; + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + CYTHON_FALLTHROUGH; + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + CYTHON_FALLTHROUGH; + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + CYTHON_FALLTHROUGH; + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_factor)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + CYTHON_FALLTHROUGH; + case 1: + if (kw_args > 0) { + PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_deform_update); + if (value) { values[1] = value; kw_args--; } + } + CYTHON_FALLTHROUGH; + case 2: + if (kw_args > 0) { + PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_deform_restore); + if (value) { values[2] = value; kw_args--; } + } + CYTHON_FALLTHROUGH; + case 3: + if (kw_args > 0) { + PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_min_deform); + if (value) { values[3] = value; kw_args--; } + } + CYTHON_FALLTHROUGH; + case 4: + if (kw_args > 0) { + PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_max_deform); + if (value) { values[4] = value; kw_args--; } + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "soft_spring_force") < 0)) __PYX_ERR(0, 830, __pyx_L3_error) + } + } else { + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); + CYTHON_FALLTHROUGH; + case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + CYTHON_FALLTHROUGH; + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + CYTHON_FALLTHROUGH; + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + CYTHON_FALLTHROUGH; + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + break; + default: goto __pyx_L5_argtuple_error; + } + } + __pyx_v_factor = __pyx_PyFloat_AsFloat(values[0]); if (unlikely((__pyx_v_factor == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 830, __pyx_L3_error) + if (values[1]) { + __pyx_v_deform_update = __pyx_PyFloat_AsFloat(values[1]); if (unlikely((__pyx_v_deform_update == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 830, __pyx_L3_error) + } else { + __pyx_v_deform_update = ((float)0.3); + } + if (values[2]) { + __pyx_v_deform_restore = __pyx_PyFloat_AsFloat(values[2]); if (unlikely((__pyx_v_deform_restore == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 830, __pyx_L3_error) + } else { + __pyx_v_deform_restore = ((float)0.03); + } + if (values[3]) { + __pyx_v_min_deform = __pyx_PyFloat_AsFloat(values[3]); if (unlikely((__pyx_v_min_deform == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 830, __pyx_L3_error) + } else { + __pyx_v_min_deform = ((float)0.3); + } + if (values[4]) { + __pyx_v_max_deform = __pyx_PyFloat_AsFloat(values[4]); if (unlikely((__pyx_v_max_deform == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 830, __pyx_L3_error) + } else { + __pyx_v_max_deform = ((float)3.0); + } + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("soft_spring_force", 0, 1, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 830, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("softwrap_core2.SpringLinks.soft_spring_force", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_14softwrap_core2_11SpringLinks_10soft_spring_force(((struct __pyx_obj_14softwrap_core2_SpringLinks *)__pyx_v_self), __pyx_v_factor, __pyx_v_deform_update, __pyx_v_deform_restore, __pyx_v_min_deform, __pyx_v_max_deform); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_11SpringLinks_10soft_spring_force(struct __pyx_obj_14softwrap_core2_SpringLinks *__pyx_v_self, float __pyx_v_factor, float __pyx_v_deform_update, float __pyx_v_deform_restore, float __pyx_v_min_deform, float __pyx_v_max_deform) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + struct __pyx_opt_args_14softwrap_core2_11SpringLinks_soft_spring_force __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("soft_spring_force", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1.__pyx_n = 4; + __pyx_t_1.deform_update = __pyx_v_deform_update; + __pyx_t_1.deform_restore = __pyx_v_deform_restore; + __pyx_t_1.min_deform = __pyx_v_min_deform; + __pyx_t_1.max_deform = __pyx_v_max_deform; + __pyx_vtabptr_14softwrap_core2_SpringLinks->soft_spring_force(__pyx_v_self, __pyx_v_factor, 1, &__pyx_t_1); + __pyx_t_2 = __Pyx_void_to_None(NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 830, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("softwrap_core2.SpringLinks.soft_spring_force", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":859 + * self.engine.m.verts, self.engine.tmp_verts = self.engine.tmp_verts, self.engine.m.verts + * + * cpdef void stiff_spring_force(self, float factor): # <<<<<<<<<<<<<< + * cdef int i, j, n, a + * cdef HalfLink* half_links + */ + +static PyObject *__pyx_pw_14softwrap_core2_11SpringLinks_13stiff_spring_force(PyObject *__pyx_v_self, PyObject *__pyx_arg_factor); /*proto*/ +static void __pyx_f_14softwrap_core2_11SpringLinks_stiff_spring_force(struct __pyx_obj_14softwrap_core2_SpringLinks *__pyx_v_self, float __pyx_v_factor, int __pyx_skip_dispatch) { + int __pyx_v_i; + int __pyx_v_j; + int __pyx_v_n; + int __pyx_v_a; + struct HalfLink *__pyx_v_half_links; + vec3 __pyx_v_delta; + float __pyx_v_curr_length; + float __pyx_v_diff; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + int __pyx_t_6; + int __pyx_t_7; + int __pyx_t_8; + int __pyx_t_9; + struct HalfLink *__pyx_t_10; + int __pyx_t_11; + int __pyx_t_12; + int __pyx_t_13; + vec3 *__pyx_t_14; + vec3 *__pyx_t_15; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("stiff_spring_force", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) { + #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS + static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; + if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) { + PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); + #endif + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_stiff_spring_force); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 859, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_14softwrap_core2_11SpringLinks_13stiff_spring_force)) { + __pyx_t_3 = PyFloat_FromDouble(__pyx_v_factor); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 859, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_t_1); + __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_4, function); + } + } + __pyx_t_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); + __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 859, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS + __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); + __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self)); + if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) { + __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; + } + #endif + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS + } + #endif + } + + /* "core/core2.pyx":864 + * cdef vec3 delta + * cdef float curr_length, diff + * with nogil: # <<<<<<<<<<<<<< + * for i in prange(self.engine.n_verts): + * n = self.links[i].n + */ + +# line 864 "core/core2.pyx" + { + +# line 864 "core/core2.pyx" + #ifdef WITH_THREAD + +# line 864 "core/core2.pyx" + PyThreadState *_save; + +# line 864 "core/core2.pyx" + Py_UNBLOCK_THREADS + +# line 864 "core/core2.pyx" + __Pyx_FastGIL_Remember(); + +# line 864 "core/core2.pyx" + #endif + /*try:*/ { + + /* "core/core2.pyx":865 + * cdef float curr_length, diff + * with nogil: + * for i in prange(self.engine.n_verts): # <<<<<<<<<<<<<< + * n = self.links[i].n + * + */ + +# line 865 "core/core2.pyx" + __pyx_t_6 = __pyx_v_self->engine->n_verts; + +# line 865 "core/core2.pyx" + if ((1 == 0)) abort(); + +# line 865 "core/core2.pyx" + { + +# line 865 "core/core2.pyx" + #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))))) + +# line 865 "core/core2.pyx" + #undef likely + +# line 865 "core/core2.pyx" + #undef unlikely + #define likely(x) (x) + #define unlikely(x) (x) + +# line 865 "core/core2.pyx" + #endif + +# line 865 "core/core2.pyx" + __pyx_t_8 = (__pyx_t_6 - 0 + 1 - 1/abs(1)) / 1; + +# line 865 "core/core2.pyx" + if (__pyx_t_8 > 0) + +# line 865 "core/core2.pyx" + { + +# line 865 "core/core2.pyx" + #ifdef _OPENMP + +# line 865 "core/core2.pyx" + #pragma omp parallel private(__pyx_t_10, __pyx_t_11, __pyx_t_12, __pyx_t_13, __pyx_t_9) + #endif /* _OPENMP */ + { + #ifdef _OPENMP + #pragma omp for lastprivate(__pyx_v_a) lastprivate(__pyx_v_curr_length) lastprivate(__pyx_v_delta) lastprivate(__pyx_v_diff) lastprivate(__pyx_v_half_links) firstprivate(__pyx_v_i) lastprivate(__pyx_v_i) lastprivate(__pyx_v_j) lastprivate(__pyx_v_n) + #endif /* _OPENMP */ + for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_8; __pyx_t_7++){ + { + __pyx_v_i = (int)(0 + 1 * __pyx_t_7); + /* Initialize private variables to invalid values */ + __pyx_v_a = ((int)0xbad0bad0); + __pyx_v_curr_length = ((float)__PYX_NAN()); + __pyx_v_diff = ((float)__PYX_NAN()); + __pyx_v_half_links = ((struct HalfLink *)1); + __pyx_v_j = ((int)0xbad0bad0); + __pyx_v_n = ((int)0xbad0bad0); + + /* "core/core2.pyx":866 + * with nogil: + * for i in prange(self.engine.n_verts): + * n = self.links[i].n # <<<<<<<<<<<<<< + * + * half_links = self.links[i].half_links + */ + +# line 866 "core/core2.pyx" + __pyx_t_9 = (__pyx_v_self->links[__pyx_v_i])->n; + +# line 866 "core/core2.pyx" + __pyx_v_n = __pyx_t_9; + + /* "core/core2.pyx":868 + * n = self.links[i].n + * + * half_links = self.links[i].half_links # <<<<<<<<<<<<<< + * + * self.engine.tmp_verts[i] = vec3(0) + */ + +# line 868 "core/core2.pyx" + __pyx_t_10 = (__pyx_v_self->links[__pyx_v_i])->half_links; + +# line 868 "core/core2.pyx" + __pyx_v_half_links = __pyx_t_10; + + /* "core/core2.pyx":870 + * half_links = self.links[i].half_links + * + * self.engine.tmp_verts[i] = vec3(0) # <<<<<<<<<<<<<< + * + * for j in range(n): + */ + +# line 870 "core/core2.pyx" + (__pyx_v_self->engine->tmp_verts[__pyx_v_i]) = vec3(0.0); + + /* "core/core2.pyx":872 + * self.engine.tmp_verts[i] = vec3(0) + * + * for j in range(n): # <<<<<<<<<<<<<< + * a = half_links[j].a + * + */ + +# line 872 "core/core2.pyx" + __pyx_t_9 = __pyx_v_n; + +# line 872 "core/core2.pyx" + __pyx_t_11 = __pyx_t_9; + +# line 872 "core/core2.pyx" + for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) { + +# line 872 "core/core2.pyx" + __pyx_v_j = __pyx_t_12; + + /* "core/core2.pyx":873 + * + * for j in range(n): + * a = half_links[j].a # <<<<<<<<<<<<<< + * + * delta = self.engine.m.verts[i] - self.engine.m.verts[a] + */ + +# line 873 "core/core2.pyx" + __pyx_t_13 = (__pyx_v_half_links[__pyx_v_j]).a; + +# line 873 "core/core2.pyx" + __pyx_v_a = __pyx_t_13; + + /* "core/core2.pyx":875 + * a = half_links[j].a + * + * delta = self.engine.m.verts[i] - self.engine.m.verts[a] # <<<<<<<<<<<<<< + * curr_length = delta.len() + * + */ + +# line 875 "core/core2.pyx" + __pyx_v_delta = ((__pyx_v_self->engine->m->verts[__pyx_v_i]) - (__pyx_v_self->engine->m->verts[__pyx_v_a])); + + /* "core/core2.pyx":876 + * + * delta = self.engine.m.verts[i] - self.engine.m.verts[a] + * curr_length = delta.len() # <<<<<<<<<<<<<< + * + * diff = (half_links[j].original_length * half_links[j].scale) / curr_length + */ + +# line 876 "core/core2.pyx" + __pyx_v_curr_length = __pyx_v_delta.len(); + + /* "core/core2.pyx":878 + * curr_length = delta.len() + * + * diff = (half_links[j].original_length * half_links[j].scale) / curr_length # <<<<<<<<<<<<<< + * + * diff = nlerp(1.0, diff, factor) + */ + +# line 878 "core/core2.pyx" + __pyx_v_diff = (((__pyx_v_half_links[__pyx_v_j]).original_length * (__pyx_v_half_links[__pyx_v_j]).scale) / __pyx_v_curr_length); + + /* "core/core2.pyx":880 + * diff = (half_links[j].original_length * half_links[j].scale) / curr_length + * + * diff = nlerp(1.0, diff, factor) # <<<<<<<<<<<<<< + * + * delta = delta * diff + */ + +# line 880 "core/core2.pyx" + __pyx_v_diff = nlerp(((float)1.0), __pyx_v_diff, __pyx_v_factor); + + /* "core/core2.pyx":882 + * diff = nlerp(1.0, diff, factor) + * + * delta = delta * diff # <<<<<<<<<<<<<< + * self.engine.tmp_verts[i] += delta + self.engine.m.verts[a] + * + */ + +# line 882 "core/core2.pyx" + __pyx_v_delta = (__pyx_v_delta * __pyx_v_diff); + + /* "core/core2.pyx":883 + * + * delta = delta * diff + * self.engine.tmp_verts[i] += delta + self.engine.m.verts[a] # <<<<<<<<<<<<<< + * + * + */ + +# line 883 "core/core2.pyx" + (__pyx_v_self->engine->tmp_verts[__pyx_v_i]) += (__pyx_v_delta + (__pyx_v_self->engine->m->verts[__pyx_v_a])); + +# line 883 "core/core2.pyx" + } + + /* "core/core2.pyx":886 + * + * + * self.engine.tmp_verts[i] *= 1.0 / nmax(n, 1) # <<<<<<<<<<<<<< + * + * self.engine.m.verts, self.engine.tmp_verts = self.engine.tmp_verts, self.engine.m.verts + */ + +# line 886 "core/core2.pyx" + (__pyx_v_self->engine->tmp_verts[__pyx_v_i]) *= (((float)1.0) / ((float)nmax(__pyx_v_n, 1))); + +# line 886 "core/core2.pyx" + } + +# line 886 "core/core2.pyx" + } + +# line 886 "core/core2.pyx" + } + +# line 886 "core/core2.pyx" + } + +# line 886 "core/core2.pyx" + } + +# line 886 "core/core2.pyx" + #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))))) + +# line 886 "core/core2.pyx" + #undef likely + +# line 886 "core/core2.pyx" + #undef unlikely + #define likely(x) __builtin_expect(!!(x), 1) + #define unlikely(x) __builtin_expect(!!(x), 0) + +# line 886 "core/core2.pyx" + #endif + +# line 886 "core/core2.pyx" + } + + /* "core/core2.pyx":864 + * cdef vec3 delta + * cdef float curr_length, diff + * with nogil: # <<<<<<<<<<<<<< + * for i in prange(self.engine.n_verts): + * n = self.links[i].n + */ + /*finally:*/ { + /*normal exit:*/{ + #ifdef WITH_THREAD + __Pyx_FastGIL_Forget(); + Py_BLOCK_THREADS + #endif + goto __pyx_L5; + } + __pyx_L5:; + } + } + + /* "core/core2.pyx":888 + * self.engine.tmp_verts[i] *= 1.0 / nmax(n, 1) + * + * self.engine.m.verts, self.engine.tmp_verts = self.engine.tmp_verts, self.engine.m.verts # <<<<<<<<<<<<<< + * + * + */ + +# line 888 "core/core2.pyx" + __pyx_t_14 = __pyx_v_self->engine->tmp_verts; + +# line 888 "core/core2.pyx" + __pyx_t_15 = __pyx_v_self->engine->m->verts; + +# line 888 "core/core2.pyx" + __pyx_v_self->engine->m->verts = __pyx_t_14; + +# line 888 "core/core2.pyx" + __pyx_v_self->engine->tmp_verts = __pyx_t_15; + + /* "core/core2.pyx":859 + * self.engine.m.verts, self.engine.tmp_verts = self.engine.tmp_verts, self.engine.m.verts + * + * cpdef void stiff_spring_force(self, float factor): # <<<<<<<<<<<<<< + * cdef int i, j, n, a + * cdef HalfLink* half_links + */ + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_WriteUnraisable("softwrap_core2.SpringLinks.stiff_spring_force", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); + __pyx_L0:; + __Pyx_RefNannyFinishContext(); +} + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_11SpringLinks_13stiff_spring_force(PyObject *__pyx_v_self, PyObject *__pyx_arg_factor); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_11SpringLinks_13stiff_spring_force(PyObject *__pyx_v_self, PyObject *__pyx_arg_factor) { + float __pyx_v_factor; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("stiff_spring_force (wrapper)", 0); + assert(__pyx_arg_factor); { + __pyx_v_factor = __pyx_PyFloat_AsFloat(__pyx_arg_factor); if (unlikely((__pyx_v_factor == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 859, __pyx_L3_error) + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("softwrap_core2.SpringLinks.stiff_spring_force", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_14softwrap_core2_11SpringLinks_12stiff_spring_force(((struct __pyx_obj_14softwrap_core2_SpringLinks *)__pyx_v_self), ((float)__pyx_v_factor)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_11SpringLinks_12stiff_spring_force(struct __pyx_obj_14softwrap_core2_SpringLinks *__pyx_v_self, float __pyx_v_factor) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("stiff_spring_force", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_void_to_None(__pyx_f_14softwrap_core2_11SpringLinks_stiff_spring_force(__pyx_v_self, __pyx_v_factor, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 859, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("softwrap_core2.SpringLinks.stiff_spring_force", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":749 + * cdef class SpringLinks: + * + * cdef readonly SpringEngine engine # <<<<<<<<<<<<<< + * cdef int max_links + * cdef HalfLinkArr** links + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_11SpringLinks_6engine_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_11SpringLinks_6engine_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_14softwrap_core2_11SpringLinks_6engine___get__(((struct __pyx_obj_14softwrap_core2_SpringLinks *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_11SpringLinks_6engine___get__(struct __pyx_obj_14softwrap_core2_SpringLinks *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_self->engine)); + __pyx_r = ((PyObject *)__pyx_v_self->engine); + goto __pyx_L0; + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "(tree fragment)":1 + * def __reduce_cython__(self): # <<<<<<<<<<<<<< + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_11SpringLinks_15__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_11SpringLinks_15__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0); + __pyx_r = __pyx_pf_14softwrap_core2_11SpringLinks_14__reduce_cython__(((struct __pyx_obj_14softwrap_core2_SpringLinks *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_11SpringLinks_14__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_14softwrap_core2_SpringLinks *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__reduce_cython__", 0); + + /* "(tree fragment)":2 + * def __reduce_cython__(self): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + */ + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__11, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __PYX_ERR(1, 2, __pyx_L1_error) + + /* "(tree fragment)":1 + * def __reduce_cython__(self): # <<<<<<<<<<<<<< + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("softwrap_core2.SpringLinks.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "(tree fragment)":3 + * def __reduce_cython__(self): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_11SpringLinks_17__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_11SpringLinks_17__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0); + __pyx_r = __pyx_pf_14softwrap_core2_11SpringLinks_16__setstate_cython__(((struct __pyx_obj_14softwrap_core2_SpringLinks *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_11SpringLinks_16__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_14softwrap_core2_SpringLinks *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__setstate_cython__", 0); + + /* "(tree fragment)":4 + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< + */ + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__12, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __PYX_ERR(1, 4, __pyx_L1_error) + + /* "(tree fragment)":3 + * def __reduce_cython__(self): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("softwrap_core2.SpringLinks.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":920 + * + * @cython.boundscheck(True) + * def __cinit__(self, SpringEngine engine, list links): # <<<<<<<<<<<<<< + * self.engine = engine + * + */ + +/* Python wrapper */ +static int __pyx_pw_14softwrap_core2_21TernarySmoothingLinks_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pw_14softwrap_core2_21TernarySmoothingLinks_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_engine = 0; + PyObject *__pyx_v_links = 0; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_engine,&__pyx_n_s_links,0}; + PyObject* values[2] = {0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + CYTHON_FALLTHROUGH; + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + CYTHON_FALLTHROUGH; + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_engine)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + CYTHON_FALLTHROUGH; + case 1: + if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_links)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 2, 2, 1); __PYX_ERR(0, 920, __pyx_L3_error) + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(0, 920, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + } + __pyx_v_engine = ((struct __pyx_obj_14softwrap_core2_SpringEngine *)values[0]); + __pyx_v_links = ((PyObject*)values[1]); + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 920, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("softwrap_core2.TernarySmoothingLinks.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_engine), __pyx_ptype_14softwrap_core2_SpringEngine, 1, "engine", 0))) __PYX_ERR(0, 920, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_links), (&PyList_Type), 1, "links", 1))) __PYX_ERR(0, 920, __pyx_L1_error) + __pyx_r = __pyx_pf_14softwrap_core2_21TernarySmoothingLinks___cinit__(((struct __pyx_obj_14softwrap_core2_TernarySmoothingLinks *)__pyx_v_self), __pyx_v_engine, __pyx_v_links); + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_14softwrap_core2_21TernarySmoothingLinks___cinit__(struct __pyx_obj_14softwrap_core2_TernarySmoothingLinks *__pyx_v_self, struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_engine, PyObject *__pyx_v_links) { + PyObject *__pyx_v_arranged_links = 0; + int __pyx_v_c; + int __pyx_v_a; + int __pyx_v_b; + int __pyx_v_i; + int __pyx_v_j; + int __pyx_v_n; + PyObject *__pyx_v_links_lst = 0; + CYTHON_UNUSED int __pyx_8genexpr1__pyx_v_i; + int __pyx_r; + __Pyx_RefNannyDeclarations + void *__pyx_t_1; + Py_ssize_t __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + int __pyx_t_4; + int __pyx_t_5; + int __pyx_t_6; + PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8 = NULL; + PyObject *__pyx_t_9 = NULL; + PyObject *__pyx_t_10 = NULL; + PyObject *__pyx_t_11 = NULL; + PyObject *(*__pyx_t_12)(PyObject *); + int __pyx_t_13; + int __pyx_t_14; + int __pyx_t_15; + int __pyx_t_16; + int __pyx_t_17; + int __pyx_t_18; + int __pyx_t_19; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__cinit__", 0); + + /* "core/core2.pyx":921 + * @cython.boundscheck(True) + * def __cinit__(self, SpringEngine engine, list links): + * self.engine = engine # <<<<<<<<<<<<<< + * + * self.links = maelloc(sizeof(TernaryLinkArr**) * engine.n_verts, __LINE__) + */ + +# line 921 "core/core2.pyx" + __Pyx_INCREF(((PyObject *)__pyx_v_engine)); + +# line 921 "core/core2.pyx" + __Pyx_GIVEREF(((PyObject *)__pyx_v_engine)); + +# line 921 "core/core2.pyx" + __Pyx_GOTREF(__pyx_v_self->engine); + +# line 921 "core/core2.pyx" + __Pyx_DECREF(((PyObject *)__pyx_v_self->engine)); + +# line 921 "core/core2.pyx" + __pyx_v_self->engine = __pyx_v_engine; + + /* "core/core2.pyx":923 + * self.engine = engine + * + * self.links = maelloc(sizeof(TernaryLinkArr**) * engine.n_verts, __LINE__) # <<<<<<<<<<<<<< + * self.links[0] = maelloc(sizeof(TernaryLinkArr) * engine.n_verts + sizeof(TernaryLink) * len(links), __LINE__) + * + */ + +# line 923 "core/core2.pyx" + __pyx_t_1 = __pyx_f_14softwrap_core2_maelloc(((sizeof(struct TernaryLinkArr **)) * __pyx_v_engine->n_verts), __LINE__); if (unlikely(__pyx_t_1 == ((void *)NULL))) __PYX_ERR(0, 923, __pyx_L1_error) + +# line 923 "core/core2.pyx" + __pyx_v_self->links = ((struct TernaryLinkArr **)__pyx_t_1); + + /* "core/core2.pyx":924 + * + * self.links = maelloc(sizeof(TernaryLinkArr**) * engine.n_verts, __LINE__) + * self.links[0] = maelloc(sizeof(TernaryLinkArr) * engine.n_verts + sizeof(TernaryLink) * len(links), __LINE__) # <<<<<<<<<<<<<< + * + * cdef list arranged_links = [[] for i in range(engine.n_verts)] + */ + +# line 924 "core/core2.pyx" + if (unlikely(__pyx_v_links == Py_None)) { + +# line 924 "core/core2.pyx" + PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); + +# line 924 "core/core2.pyx" + __PYX_ERR(0, 924, __pyx_L1_error) + +# line 924 "core/core2.pyx" + } + +# line 924 "core/core2.pyx" + __pyx_t_2 = PyList_GET_SIZE(__pyx_v_links); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 924, __pyx_L1_error) + +# line 924 "core/core2.pyx" + __pyx_t_1 = __pyx_f_14softwrap_core2_maelloc((((sizeof(struct TernaryLinkArr)) * __pyx_v_engine->n_verts) + ((sizeof(struct TernaryLink)) * __pyx_t_2)), __LINE__); if (unlikely(__pyx_t_1 == ((void *)NULL))) __PYX_ERR(0, 924, __pyx_L1_error) + +# line 924 "core/core2.pyx" + (__pyx_v_self->links[0]) = ((struct TernaryLinkArr *)__pyx_t_1); + + /* "core/core2.pyx":926 + * self.links[0] = maelloc(sizeof(TernaryLinkArr) * engine.n_verts + sizeof(TernaryLink) * len(links), __LINE__) + * + * cdef list arranged_links = [[] for i in range(engine.n_verts)] # <<<<<<<<<<<<<< + * + * cdef int c, a, b, i, j, n + */ + { /* enter inner scope */ + __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 926, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = __pyx_v_engine->n_verts; + __pyx_t_5 = __pyx_t_4; + for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) { + __pyx_8genexpr1__pyx_v_i = __pyx_t_6; + __pyx_t_7 = PyList_New(0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 926, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_7))) __PYX_ERR(0, 926, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + } + } /* exit inner scope */ + __pyx_v_arranged_links = ((PyObject*)__pyx_t_3); + __pyx_t_3 = 0; + + /* "core/core2.pyx":930 + * cdef int c, a, b, i, j, n + * + * for c, a, b in links: # <<<<<<<<<<<<<< + * arranged_links[c].append((a, b)) + * + */ + +# line 930 "core/core2.pyx" + if (unlikely(__pyx_v_links == Py_None)) { + +# line 930 "core/core2.pyx" + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); + +# line 930 "core/core2.pyx" + __PYX_ERR(0, 930, __pyx_L1_error) + +# line 930 "core/core2.pyx" + } + +# line 930 "core/core2.pyx" + __pyx_t_3 = __pyx_v_links; __Pyx_INCREF(__pyx_t_3); __pyx_t_2 = 0; + +# line 930 "core/core2.pyx" + for (;;) { + +# line 930 "core/core2.pyx" + if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_3)) break; + +# line 930 "core/core2.pyx" + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + +# line 930 "core/core2.pyx" + __pyx_t_7 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_2); __Pyx_INCREF(__pyx_t_7); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 930, __pyx_L1_error) + +# line 930 "core/core2.pyx" + #else + +# line 930 "core/core2.pyx" + __pyx_t_7 = PySequence_ITEM(__pyx_t_3, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 930, __pyx_L1_error) + +# line 930 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_7); + +# line 930 "core/core2.pyx" + #endif + +# line 930 "core/core2.pyx" + if ((likely(PyTuple_CheckExact(__pyx_t_7))) || (PyList_CheckExact(__pyx_t_7))) { + +# line 930 "core/core2.pyx" + PyObject* sequence = __pyx_t_7; + +# line 930 "core/core2.pyx" + Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); + +# line 930 "core/core2.pyx" + if (unlikely(size != 3)) { + +# line 930 "core/core2.pyx" + if (size > 3) __Pyx_RaiseTooManyValuesError(3); + +# line 930 "core/core2.pyx" + else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); + +# line 930 "core/core2.pyx" + __PYX_ERR(0, 930, __pyx_L1_error) + +# line 930 "core/core2.pyx" + } + +# line 930 "core/core2.pyx" + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + +# line 930 "core/core2.pyx" + if (likely(PyTuple_CheckExact(sequence))) { + +# line 930 "core/core2.pyx" + __pyx_t_8 = PyTuple_GET_ITEM(sequence, 0); + +# line 930 "core/core2.pyx" + __pyx_t_9 = PyTuple_GET_ITEM(sequence, 1); + +# line 930 "core/core2.pyx" + __pyx_t_10 = PyTuple_GET_ITEM(sequence, 2); + +# line 930 "core/core2.pyx" + } else { + +# line 930 "core/core2.pyx" + __pyx_t_8 = PyList_GET_ITEM(sequence, 0); + +# line 930 "core/core2.pyx" + __pyx_t_9 = PyList_GET_ITEM(sequence, 1); + +# line 930 "core/core2.pyx" + __pyx_t_10 = PyList_GET_ITEM(sequence, 2); + +# line 930 "core/core2.pyx" + } + +# line 930 "core/core2.pyx" + __Pyx_INCREF(__pyx_t_8); + +# line 930 "core/core2.pyx" + __Pyx_INCREF(__pyx_t_9); + +# line 930 "core/core2.pyx" + __Pyx_INCREF(__pyx_t_10); + +# line 930 "core/core2.pyx" + #else + +# line 930 "core/core2.pyx" + __pyx_t_8 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 930, __pyx_L1_error) + +# line 930 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_8); + +# line 930 "core/core2.pyx" + __pyx_t_9 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 930, __pyx_L1_error) + +# line 930 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_9); + +# line 930 "core/core2.pyx" + __pyx_t_10 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 930, __pyx_L1_error) + +# line 930 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_10); + +# line 930 "core/core2.pyx" + #endif + +# line 930 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + +# line 930 "core/core2.pyx" + } else { + +# line 930 "core/core2.pyx" + Py_ssize_t index = -1; + +# line 930 "core/core2.pyx" + __pyx_t_11 = PyObject_GetIter(__pyx_t_7); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 930, __pyx_L1_error) + +# line 930 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_11); + +# line 930 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + +# line 930 "core/core2.pyx" + __pyx_t_12 = Py_TYPE(__pyx_t_11)->tp_iternext; + +# line 930 "core/core2.pyx" + index = 0; __pyx_t_8 = __pyx_t_12(__pyx_t_11); if (unlikely(!__pyx_t_8)) goto __pyx_L7_unpacking_failed; + +# line 930 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_8); + +# line 930 "core/core2.pyx" + index = 1; __pyx_t_9 = __pyx_t_12(__pyx_t_11); if (unlikely(!__pyx_t_9)) goto __pyx_L7_unpacking_failed; + +# line 930 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_9); + +# line 930 "core/core2.pyx" + index = 2; __pyx_t_10 = __pyx_t_12(__pyx_t_11); if (unlikely(!__pyx_t_10)) goto __pyx_L7_unpacking_failed; + +# line 930 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_10); + +# line 930 "core/core2.pyx" + if (__Pyx_IternextUnpackEndCheck(__pyx_t_12(__pyx_t_11), 3) < 0) __PYX_ERR(0, 930, __pyx_L1_error) + +# line 930 "core/core2.pyx" + __pyx_t_12 = NULL; + +# line 930 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + +# line 930 "core/core2.pyx" + goto __pyx_L8_unpacking_done; + +# line 930 "core/core2.pyx" + __pyx_L7_unpacking_failed:; + +# line 930 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + +# line 930 "core/core2.pyx" + __pyx_t_12 = NULL; + +# line 930 "core/core2.pyx" + if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); + +# line 930 "core/core2.pyx" + __PYX_ERR(0, 930, __pyx_L1_error) + +# line 930 "core/core2.pyx" + __pyx_L8_unpacking_done:; + +# line 930 "core/core2.pyx" + } + +# line 930 "core/core2.pyx" + __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_t_8); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 930, __pyx_L1_error) + +# line 930 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + +# line 930 "core/core2.pyx" + __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_9); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 930, __pyx_L1_error) + +# line 930 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + +# line 930 "core/core2.pyx" + __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_10); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 930, __pyx_L1_error) + +# line 930 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + +# line 930 "core/core2.pyx" + __pyx_v_c = __pyx_t_4; + +# line 930 "core/core2.pyx" + __pyx_v_a = __pyx_t_5; + +# line 930 "core/core2.pyx" + __pyx_v_b = __pyx_t_6; + + /* "core/core2.pyx":931 + * + * for c, a, b in links: + * arranged_links[c].append((a, b)) # <<<<<<<<<<<<<< + * + * cdef list links_lst + */ + +# line 931 "core/core2.pyx" + __pyx_t_7 = __Pyx_GetItemInt_List(__pyx_v_arranged_links, __pyx_v_c, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 931, __pyx_L1_error) + +# line 931 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_7); + +# line 931 "core/core2.pyx" + __pyx_t_10 = __Pyx_PyInt_From_int(__pyx_v_a); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 931, __pyx_L1_error) + +# line 931 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_10); + +# line 931 "core/core2.pyx" + __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_b); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 931, __pyx_L1_error) + +# line 931 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_9); + +# line 931 "core/core2.pyx" + __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 931, __pyx_L1_error) + +# line 931 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_8); + +# line 931 "core/core2.pyx" + __Pyx_GIVEREF(__pyx_t_10); + +# line 931 "core/core2.pyx" + PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_10); + +# line 931 "core/core2.pyx" + __Pyx_GIVEREF(__pyx_t_9); + +# line 931 "core/core2.pyx" + PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_9); + +# line 931 "core/core2.pyx" + __pyx_t_10 = 0; + +# line 931 "core/core2.pyx" + __pyx_t_9 = 0; + +# line 931 "core/core2.pyx" + __pyx_t_13 = __Pyx_PyObject_Append(__pyx_t_7, __pyx_t_8); if (unlikely(__pyx_t_13 == ((int)-1))) __PYX_ERR(0, 931, __pyx_L1_error) + +# line 931 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + +# line 931 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + + /* "core/core2.pyx":930 + * cdef int c, a, b, i, j, n + * + * for c, a, b in links: # <<<<<<<<<<<<<< + * arranged_links[c].append((a, b)) + * + */ + +# line 930 "core/core2.pyx" + } + +# line 930 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + + /* "core/core2.pyx":936 + * cdef vec3 avg, d + * + * for i in range(engine.n_verts): # <<<<<<<<<<<<<< + * links_lst = arranged_links[i] + * if i > 0: + */ + +# line 936 "core/core2.pyx" + __pyx_t_6 = __pyx_v_engine->n_verts; + +# line 936 "core/core2.pyx" + __pyx_t_5 = __pyx_t_6; + +# line 936 "core/core2.pyx" + for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_5; __pyx_t_4+=1) { + +# line 936 "core/core2.pyx" + __pyx_v_i = __pyx_t_4; + + /* "core/core2.pyx":937 + * + * for i in range(engine.n_verts): + * links_lst = arranged_links[i] # <<<<<<<<<<<<<< + * if i > 0: + * self.links[i] = ((self.links[i - 1]) + sizeof(TernaryLinkArr) + sizeof(TernaryLink) * self.links[i - 1].n) + */ + +# line 937 "core/core2.pyx" + __pyx_t_3 = __Pyx_GetItemInt_List(__pyx_v_arranged_links, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 937, __pyx_L1_error) + +# line 937 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_3); + +# line 937 "core/core2.pyx" + if (!(likely(PyList_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(0, 937, __pyx_L1_error) + +# line 937 "core/core2.pyx" + __Pyx_XDECREF_SET(__pyx_v_links_lst, ((PyObject*)__pyx_t_3)); + +# line 937 "core/core2.pyx" + __pyx_t_3 = 0; + + /* "core/core2.pyx":938 + * for i in range(engine.n_verts): + * links_lst = arranged_links[i] + * if i > 0: # <<<<<<<<<<<<<< + * self.links[i] = ((self.links[i - 1]) + sizeof(TernaryLinkArr) + sizeof(TernaryLink) * self.links[i - 1].n) + * + */ + +# line 938 "core/core2.pyx" + __pyx_t_14 = ((__pyx_v_i > 0) != 0); + +# line 938 "core/core2.pyx" + if (__pyx_t_14) { + + /* "core/core2.pyx":939 + * links_lst = arranged_links[i] + * if i > 0: + * self.links[i] = ((self.links[i - 1]) + sizeof(TernaryLinkArr) + sizeof(TernaryLink) * self.links[i - 1].n) # <<<<<<<<<<<<<< + * + * n = len(links_lst) + */ + +# line 939 "core/core2.pyx" + (__pyx_v_self->links[__pyx_v_i]) = ((struct TernaryLinkArr *)((((char *)(__pyx_v_self->links[(__pyx_v_i - 1)])) + (sizeof(struct TernaryLinkArr))) + ((sizeof(struct TernaryLink)) * (__pyx_v_self->links[(__pyx_v_i - 1)])->n))); + + /* "core/core2.pyx":938 + * for i in range(engine.n_verts): + * links_lst = arranged_links[i] + * if i > 0: # <<<<<<<<<<<<<< + * self.links[i] = ((self.links[i - 1]) + sizeof(TernaryLinkArr) + sizeof(TernaryLink) * self.links[i - 1].n) + * + */ + +# line 938 "core/core2.pyx" + } + + /* "core/core2.pyx":941 + * self.links[i] = ((self.links[i - 1]) + sizeof(TernaryLinkArr) + sizeof(TernaryLink) * self.links[i - 1].n) + * + * n = len(links_lst) # <<<<<<<<<<<<<< + * self.links[i].n = n + * + */ + +# line 941 "core/core2.pyx" + if (unlikely(__pyx_v_links_lst == Py_None)) { + +# line 941 "core/core2.pyx" + PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); + +# line 941 "core/core2.pyx" + __PYX_ERR(0, 941, __pyx_L1_error) + +# line 941 "core/core2.pyx" + } + +# line 941 "core/core2.pyx" + __pyx_t_2 = PyList_GET_SIZE(__pyx_v_links_lst); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 941, __pyx_L1_error) + +# line 941 "core/core2.pyx" + __pyx_v_n = __pyx_t_2; + + /* "core/core2.pyx":942 + * + * n = len(links_lst) + * self.links[i].n = n # <<<<<<<<<<<<<< + * + * for j in range(n): + */ + +# line 942 "core/core2.pyx" + (__pyx_v_self->links[__pyx_v_i])->n = __pyx_v_n; + + /* "core/core2.pyx":944 + * self.links[i].n = n + * + * for j in range(n): # <<<<<<<<<<<<<< + * a, b = links_lst[j] + * self.links[i].arr[j].a = a + */ + +# line 944 "core/core2.pyx" + __pyx_t_15 = __pyx_v_n; + +# line 944 "core/core2.pyx" + __pyx_t_16 = __pyx_t_15; + +# line 944 "core/core2.pyx" + for (__pyx_t_17 = 0; __pyx_t_17 < __pyx_t_16; __pyx_t_17+=1) { + +# line 944 "core/core2.pyx" + __pyx_v_j = __pyx_t_17; + + /* "core/core2.pyx":945 + * + * for j in range(n): + * a, b = links_lst[j] # <<<<<<<<<<<<<< + * self.links[i].arr[j].a = a + * self.links[i].arr[j].b = b + */ + +# line 945 "core/core2.pyx" + if (unlikely(__pyx_v_links_lst == Py_None)) { + +# line 945 "core/core2.pyx" + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + +# line 945 "core/core2.pyx" + __PYX_ERR(0, 945, __pyx_L1_error) + +# line 945 "core/core2.pyx" + } + +# line 945 "core/core2.pyx" + __pyx_t_3 = __Pyx_GetItemInt_List(__pyx_v_links_lst, __pyx_v_j, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 945, __pyx_L1_error) + +# line 945 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_3); + +# line 945 "core/core2.pyx" + if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) { + +# line 945 "core/core2.pyx" + PyObject* sequence = __pyx_t_3; + +# line 945 "core/core2.pyx" + Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); + +# line 945 "core/core2.pyx" + if (unlikely(size != 2)) { + +# line 945 "core/core2.pyx" + if (size > 2) __Pyx_RaiseTooManyValuesError(2); + +# line 945 "core/core2.pyx" + else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); + +# line 945 "core/core2.pyx" + __PYX_ERR(0, 945, __pyx_L1_error) + +# line 945 "core/core2.pyx" + } + +# line 945 "core/core2.pyx" + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + +# line 945 "core/core2.pyx" + if (likely(PyTuple_CheckExact(sequence))) { + +# line 945 "core/core2.pyx" + __pyx_t_8 = PyTuple_GET_ITEM(sequence, 0); + +# line 945 "core/core2.pyx" + __pyx_t_7 = PyTuple_GET_ITEM(sequence, 1); + +# line 945 "core/core2.pyx" + } else { + +# line 945 "core/core2.pyx" + __pyx_t_8 = PyList_GET_ITEM(sequence, 0); + +# line 945 "core/core2.pyx" + __pyx_t_7 = PyList_GET_ITEM(sequence, 1); + +# line 945 "core/core2.pyx" + } + +# line 945 "core/core2.pyx" + __Pyx_INCREF(__pyx_t_8); + +# line 945 "core/core2.pyx" + __Pyx_INCREF(__pyx_t_7); + +# line 945 "core/core2.pyx" + #else + +# line 945 "core/core2.pyx" + __pyx_t_8 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 945, __pyx_L1_error) + +# line 945 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_8); + +# line 945 "core/core2.pyx" + __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 945, __pyx_L1_error) + +# line 945 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_7); + +# line 945 "core/core2.pyx" + #endif + +# line 945 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + +# line 945 "core/core2.pyx" + } else { + +# line 945 "core/core2.pyx" + Py_ssize_t index = -1; + +# line 945 "core/core2.pyx" + __pyx_t_9 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 945, __pyx_L1_error) + +# line 945 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_9); + +# line 945 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + +# line 945 "core/core2.pyx" + __pyx_t_12 = Py_TYPE(__pyx_t_9)->tp_iternext; + +# line 945 "core/core2.pyx" + index = 0; __pyx_t_8 = __pyx_t_12(__pyx_t_9); if (unlikely(!__pyx_t_8)) goto __pyx_L14_unpacking_failed; + +# line 945 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_8); + +# line 945 "core/core2.pyx" + index = 1; __pyx_t_7 = __pyx_t_12(__pyx_t_9); if (unlikely(!__pyx_t_7)) goto __pyx_L14_unpacking_failed; + +# line 945 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_7); + +# line 945 "core/core2.pyx" + if (__Pyx_IternextUnpackEndCheck(__pyx_t_12(__pyx_t_9), 2) < 0) __PYX_ERR(0, 945, __pyx_L1_error) + +# line 945 "core/core2.pyx" + __pyx_t_12 = NULL; + +# line 945 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + +# line 945 "core/core2.pyx" + goto __pyx_L15_unpacking_done; + +# line 945 "core/core2.pyx" + __pyx_L14_unpacking_failed:; + +# line 945 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + +# line 945 "core/core2.pyx" + __pyx_t_12 = NULL; + +# line 945 "core/core2.pyx" + if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); + +# line 945 "core/core2.pyx" + __PYX_ERR(0, 945, __pyx_L1_error) + +# line 945 "core/core2.pyx" + __pyx_L15_unpacking_done:; + +# line 945 "core/core2.pyx" + } + +# line 945 "core/core2.pyx" + __pyx_t_18 = __Pyx_PyInt_As_int(__pyx_t_8); if (unlikely((__pyx_t_18 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 945, __pyx_L1_error) + +# line 945 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + +# line 945 "core/core2.pyx" + __pyx_t_19 = __Pyx_PyInt_As_int(__pyx_t_7); if (unlikely((__pyx_t_19 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 945, __pyx_L1_error) + +# line 945 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + +# line 945 "core/core2.pyx" + __pyx_v_a = __pyx_t_18; + +# line 945 "core/core2.pyx" + __pyx_v_b = __pyx_t_19; + + /* "core/core2.pyx":946 + * for j in range(n): + * a, b = links_lst[j] + * self.links[i].arr[j].a = a # <<<<<<<<<<<<<< + * self.links[i].arr[j].b = b + * + */ + +# line 946 "core/core2.pyx" + ((__pyx_v_self->links[__pyx_v_i])->arr[__pyx_v_j]).a = __pyx_v_a; + + /* "core/core2.pyx":947 + * a, b = links_lst[j] + * self.links[i].arr[j].a = a + * self.links[i].arr[j].b = b # <<<<<<<<<<<<<< + * + * + */ + +# line 947 "core/core2.pyx" + ((__pyx_v_self->links[__pyx_v_i])->arr[__pyx_v_j]).b = __pyx_v_b; + +# line 947 "core/core2.pyx" + } + +# line 947 "core/core2.pyx" + } + + /* "core/core2.pyx":920 + * + * @cython.boundscheck(True) + * def __cinit__(self, SpringEngine engine, list links): # <<<<<<<<<<<<<< + * self.engine = engine + * + */ + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_XDECREF(__pyx_t_9); + __Pyx_XDECREF(__pyx_t_10); + __Pyx_XDECREF(__pyx_t_11); + __Pyx_AddTraceback("softwrap_core2.TernarySmoothingLinks.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_arranged_links); + __Pyx_XDECREF(__pyx_v_links_lst); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":950 + * + * + * def __dealloc__(self): # <<<<<<<<<<<<<< + * fraeee(self.links[0]) + * fraeee(self.links) + */ + +/* Python wrapper */ +static void __pyx_pw_14softwrap_core2_21TernarySmoothingLinks_3__dealloc__(PyObject *__pyx_v_self); /*proto*/ +static void __pyx_pw_14softwrap_core2_21TernarySmoothingLinks_3__dealloc__(PyObject *__pyx_v_self) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0); + __pyx_pf_14softwrap_core2_21TernarySmoothingLinks_2__dealloc__(((struct __pyx_obj_14softwrap_core2_TernarySmoothingLinks *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); +} + +static void __pyx_pf_14softwrap_core2_21TernarySmoothingLinks_2__dealloc__(struct __pyx_obj_14softwrap_core2_TernarySmoothingLinks *__pyx_v_self) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__dealloc__", 0); + + /* "core/core2.pyx":951 + * + * def __dealloc__(self): + * fraeee(self.links[0]) # <<<<<<<<<<<<<< + * fraeee(self.links) + * + */ + +# line 951 "core/core2.pyx" + __pyx_f_14softwrap_core2_fraeee((__pyx_v_self->links[0])); + + /* "core/core2.pyx":952 + * def __dealloc__(self): + * fraeee(self.links[0]) + * fraeee(self.links) # <<<<<<<<<<<<<< + * + * cpdef void displacements_update(self): + */ + +# line 952 "core/core2.pyx" + __pyx_f_14softwrap_core2_fraeee(__pyx_v_self->links); + + /* "core/core2.pyx":950 + * + * + * def __dealloc__(self): # <<<<<<<<<<<<<< + * fraeee(self.links[0]) + * fraeee(self.links) + */ + + /* function exit code */ + __Pyx_RefNannyFinishContext(); +} + +/* "core/core2.pyx":954 + * fraeee(self.links) + * + * cpdef void displacements_update(self): # <<<<<<<<<<<<<< + * cdef int i, j, a, b + * cdef vec3 avg, d + */ + +static PyObject *__pyx_pw_14softwrap_core2_21TernarySmoothingLinks_5displacements_update(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static void __pyx_f_14softwrap_core2_21TernarySmoothingLinks_displacements_update(struct __pyx_obj_14softwrap_core2_TernarySmoothingLinks *__pyx_v_self, CYTHON_UNUSED int __pyx_skip_dispatch) { + int __pyx_v_i; + int __pyx_v_j; + int __pyx_v_a; + int __pyx_v_b; + vec3 __pyx_v_avg; + vec3 __pyx_v_d; + struct TernaryLinkArr *__pyx_v_arr; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + int __pyx_t_4; + int __pyx_t_5; + int __pyx_t_6; + int __pyx_t_7; + __Pyx_RefNannySetupContext("displacements_update", 0); + + /* "core/core2.pyx":959 + * cdef TernaryLinkArr* arr + * + * self.engine.m.update_face_normals() # <<<<<<<<<<<<<< + * self.engine.m.update_vert_normals() + * + */ + +# line 959 "core/core2.pyx" + __pyx_f_14softwrap_core2_4Mesh_update_face_normals(__pyx_v_self->engine->m, 0); + + /* "core/core2.pyx":960 + * + * self.engine.m.update_face_normals() + * self.engine.m.update_vert_normals() # <<<<<<<<<<<<<< + * + * for i in range(self.engine.n_verts): + */ + +# line 960 "core/core2.pyx" + __pyx_f_14softwrap_core2_4Mesh_update_vert_normals(__pyx_v_self->engine->m, 0); + + /* "core/core2.pyx":962 + * self.engine.m.update_vert_normals() + * + * for i in range(self.engine.n_verts): # <<<<<<<<<<<<<< + * arr = self.links[i] + * + */ + +# line 962 "core/core2.pyx" + __pyx_t_1 = __pyx_v_self->engine->n_verts; + +# line 962 "core/core2.pyx" + __pyx_t_2 = __pyx_t_1; + +# line 962 "core/core2.pyx" + for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) { + +# line 962 "core/core2.pyx" + __pyx_v_i = __pyx_t_3; + + /* "core/core2.pyx":963 + * + * for i in range(self.engine.n_verts): + * arr = self.links[i] # <<<<<<<<<<<<<< + * + * for j in range(arr.n): + */ + +# line 963 "core/core2.pyx" + __pyx_v_arr = (__pyx_v_self->links[__pyx_v_i]); + + /* "core/core2.pyx":965 + * arr = self.links[i] + * + * for j in range(arr.n): # <<<<<<<<<<<<<< + * a = arr.arr[j].a + * b = arr.arr[j].b + */ + +# line 965 "core/core2.pyx" + __pyx_t_4 = __pyx_v_arr->n; + +# line 965 "core/core2.pyx" + __pyx_t_5 = __pyx_t_4; + +# line 965 "core/core2.pyx" + for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) { + +# line 965 "core/core2.pyx" + __pyx_v_j = __pyx_t_6; + + /* "core/core2.pyx":966 + * + * for j in range(arr.n): + * a = arr.arr[j].a # <<<<<<<<<<<<<< + * b = arr.arr[j].b + * avg = (self.engine.m.verts[a] + self.engine.m.verts[b]) * 0.5 + */ + +# line 966 "core/core2.pyx" + __pyx_t_7 = (__pyx_v_arr->arr[__pyx_v_j]).a; + +# line 966 "core/core2.pyx" + __pyx_v_a = __pyx_t_7; + + /* "core/core2.pyx":967 + * for j in range(arr.n): + * a = arr.arr[j].a + * b = arr.arr[j].b # <<<<<<<<<<<<<< + * avg = (self.engine.m.verts[a] + self.engine.m.verts[b]) * 0.5 + * d = (self.engine.m.verts[i] - avg) + */ + +# line 967 "core/core2.pyx" + __pyx_t_7 = (__pyx_v_arr->arr[__pyx_v_j]).b; + +# line 967 "core/core2.pyx" + __pyx_v_b = __pyx_t_7; + + /* "core/core2.pyx":968 + * a = arr.arr[j].a + * b = arr.arr[j].b + * avg = (self.engine.m.verts[a] + self.engine.m.verts[b]) * 0.5 # <<<<<<<<<<<<<< + * d = (self.engine.m.verts[i] - avg) + * arr.arr[j].side = d.dot(self.engine.m.vert_normals[i]) > 0 + */ + +# line 968 "core/core2.pyx" + __pyx_v_avg = (((__pyx_v_self->engine->m->verts[__pyx_v_a]) + (__pyx_v_self->engine->m->verts[__pyx_v_b])) * 0.5); + + /* "core/core2.pyx":969 + * b = arr.arr[j].b + * avg = (self.engine.m.verts[a] + self.engine.m.verts[b]) * 0.5 + * d = (self.engine.m.verts[i] - avg) # <<<<<<<<<<<<<< + * arr.arr[j].side = d.dot(self.engine.m.vert_normals[i]) > 0 + * arr.arr[j].avg_dist = d.len() / ((self.engine.m.verts[a] - self.engine.m.verts[b]).len() + EPS) + */ + +# line 969 "core/core2.pyx" + __pyx_v_d = ((__pyx_v_self->engine->m->verts[__pyx_v_i]) - __pyx_v_avg); + + /* "core/core2.pyx":970 + * avg = (self.engine.m.verts[a] + self.engine.m.verts[b]) * 0.5 + * d = (self.engine.m.verts[i] - avg) + * arr.arr[j].side = d.dot(self.engine.m.vert_normals[i]) > 0 # <<<<<<<<<<<<<< + * arr.arr[j].avg_dist = d.len() / ((self.engine.m.verts[a] - self.engine.m.verts[b]).len() + EPS) + * + */ + +# line 970 "core/core2.pyx" + (__pyx_v_arr->arr[__pyx_v_j]).side = (__pyx_v_d.dot((__pyx_v_self->engine->m->vert_normals[__pyx_v_i])) > 0.0); + + /* "core/core2.pyx":971 + * d = (self.engine.m.verts[i] - avg) + * arr.arr[j].side = d.dot(self.engine.m.vert_normals[i]) > 0 + * arr.arr[j].avg_dist = d.len() / ((self.engine.m.verts[a] - self.engine.m.verts[b]).len() + EPS) # <<<<<<<<<<<<<< + * + * cpdef void displacement_force(self, float factor): + */ + +# line 971 "core/core2.pyx" + (__pyx_v_arr->arr[__pyx_v_j]).avg_dist = (__pyx_v_d.len() / (((__pyx_v_self->engine->m->verts[__pyx_v_a]) - (__pyx_v_self->engine->m->verts[__pyx_v_b])).len() + EPS)); + +# line 971 "core/core2.pyx" + } + +# line 971 "core/core2.pyx" + } + + /* "core/core2.pyx":954 + * fraeee(self.links) + * + * cpdef void displacements_update(self): # <<<<<<<<<<<<<< + * cdef int i, j, a, b + * cdef vec3 avg, d + */ + + /* function exit code */ + __Pyx_RefNannyFinishContext(); +} + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_21TernarySmoothingLinks_5displacements_update(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_21TernarySmoothingLinks_5displacements_update(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("displacements_update (wrapper)", 0); + __pyx_r = __pyx_pf_14softwrap_core2_21TernarySmoothingLinks_4displacements_update(((struct __pyx_obj_14softwrap_core2_TernarySmoothingLinks *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_21TernarySmoothingLinks_4displacements_update(struct __pyx_obj_14softwrap_core2_TernarySmoothingLinks *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("displacements_update", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_void_to_None(__pyx_f_14softwrap_core2_21TernarySmoothingLinks_displacements_update(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 954, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("softwrap_core2.TernarySmoothingLinks.displacements_update", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":973 + * arr.arr[j].avg_dist = d.len() / ((self.engine.m.verts[a] - self.engine.m.verts[b]).len() + EPS) + * + * cpdef void displacement_force(self, float factor): # <<<<<<<<<<<<<< + * cdef int i, j, a, b + * cdef vec3 avg, d + */ + +static PyObject *__pyx_pw_14softwrap_core2_21TernarySmoothingLinks_7displacement_force(PyObject *__pyx_v_self, PyObject *__pyx_arg_factor); /*proto*/ +static void __pyx_f_14softwrap_core2_21TernarySmoothingLinks_displacement_force(struct __pyx_obj_14softwrap_core2_TernarySmoothingLinks *__pyx_v_self, float __pyx_v_factor, CYTHON_UNUSED int __pyx_skip_dispatch) { + int __pyx_v_i; + int __pyx_v_j; + int __pyx_v_a; + int __pyx_v_b; + vec3 __pyx_v_avg; + vec3 __pyx_v_d; + struct TernaryLinkArr *__pyx_v_arr; + float __pyx_v_l; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + int __pyx_t_4; + int __pyx_t_5; + int __pyx_t_6; + int __pyx_t_7; + int __pyx_t_8; + __Pyx_RefNannySetupContext("displacement_force", 0); + + /* "core/core2.pyx":980 + * cdef float l + * + * with nogil: # <<<<<<<<<<<<<< + * for i in prange(self.engine.n_verts): + * arr = self.links[i] + */ + +# line 980 "core/core2.pyx" + { + +# line 980 "core/core2.pyx" + #ifdef WITH_THREAD + +# line 980 "core/core2.pyx" + PyThreadState *_save; + +# line 980 "core/core2.pyx" + Py_UNBLOCK_THREADS + +# line 980 "core/core2.pyx" + __Pyx_FastGIL_Remember(); + +# line 980 "core/core2.pyx" + #endif + /*try:*/ { + + /* "core/core2.pyx":981 + * + * with nogil: + * for i in prange(self.engine.n_verts): # <<<<<<<<<<<<<< + * arr = self.links[i] + * if arr.n == 0: + */ + +# line 981 "core/core2.pyx" + __pyx_t_1 = __pyx_v_self->engine->n_verts; + +# line 981 "core/core2.pyx" + if ((1 == 0)) abort(); + +# line 981 "core/core2.pyx" + { + +# line 981 "core/core2.pyx" + #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))))) + +# line 981 "core/core2.pyx" + #undef likely + +# line 981 "core/core2.pyx" + #undef unlikely + #define likely(x) (x) + #define unlikely(x) (x) + +# line 981 "core/core2.pyx" + #endif + +# line 981 "core/core2.pyx" + __pyx_t_3 = (__pyx_t_1 - 0 + 1 - 1/abs(1)) / 1; + +# line 981 "core/core2.pyx" + if (__pyx_t_3 > 0) + +# line 981 "core/core2.pyx" + { + +# line 981 "core/core2.pyx" + #ifdef _OPENMP + +# line 981 "core/core2.pyx" + #pragma omp parallel private(__pyx_t_4, __pyx_t_5, __pyx_t_6, __pyx_t_7, __pyx_t_8) + #endif /* _OPENMP */ + { + #ifdef _OPENMP + #pragma omp for lastprivate(__pyx_v_a) lastprivate(__pyx_v_arr) lastprivate(__pyx_v_avg) lastprivate(__pyx_v_b) lastprivate(__pyx_v_d) firstprivate(__pyx_v_i) lastprivate(__pyx_v_i) lastprivate(__pyx_v_j) lastprivate(__pyx_v_l) + #endif /* _OPENMP */ + for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_3; __pyx_t_2++){ + { + __pyx_v_i = (int)(0 + 1 * __pyx_t_2); + /* Initialize private variables to invalid values */ + __pyx_v_a = ((int)0xbad0bad0); + __pyx_v_arr = ((struct TernaryLinkArr *)1); + __pyx_v_b = ((int)0xbad0bad0); + __pyx_v_j = ((int)0xbad0bad0); + __pyx_v_l = ((float)__PYX_NAN()); + + /* "core/core2.pyx":982 + * with nogil: + * for i in prange(self.engine.n_verts): + * arr = self.links[i] # <<<<<<<<<<<<<< + * if arr.n == 0: + * continue + */ + +# line 982 "core/core2.pyx" + __pyx_v_arr = (__pyx_v_self->links[__pyx_v_i]); + + /* "core/core2.pyx":983 + * for i in prange(self.engine.n_verts): + * arr = self.links[i] + * if arr.n == 0: # <<<<<<<<<<<<<< + * continue + * + */ + +# line 983 "core/core2.pyx" + __pyx_t_4 = ((__pyx_v_arr->n == 0) != 0); + +# line 983 "core/core2.pyx" + if (__pyx_t_4) { + + /* "core/core2.pyx":984 + * arr = self.links[i] + * if arr.n == 0: + * continue # <<<<<<<<<<<<<< + * + * self.engine.tmp_verts[i] = vec3(0) + */ + +# line 984 "core/core2.pyx" + goto __pyx_L6_continue; + + /* "core/core2.pyx":983 + * for i in prange(self.engine.n_verts): + * arr = self.links[i] + * if arr.n == 0: # <<<<<<<<<<<<<< + * continue + * + */ + +# line 983 "core/core2.pyx" + } + + /* "core/core2.pyx":986 + * continue + * + * self.engine.tmp_verts[i] = vec3(0) # <<<<<<<<<<<<<< + * + * for j in range(arr.n): + */ + +# line 986 "core/core2.pyx" + (__pyx_v_self->engine->tmp_verts[__pyx_v_i]) = vec3(0.0); + + /* "core/core2.pyx":988 + * self.engine.tmp_verts[i] = vec3(0) + * + * for j in range(arr.n): # <<<<<<<<<<<<<< + * a = arr.arr[j].a + * b = arr.arr[j].b + */ + +# line 988 "core/core2.pyx" + __pyx_t_5 = __pyx_v_arr->n; + +# line 988 "core/core2.pyx" + __pyx_t_6 = __pyx_t_5; + +# line 988 "core/core2.pyx" + for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) { + +# line 988 "core/core2.pyx" + __pyx_v_j = __pyx_t_7; + + /* "core/core2.pyx":989 + * + * for j in range(arr.n): + * a = arr.arr[j].a # <<<<<<<<<<<<<< + * b = arr.arr[j].b + * + */ + +# line 989 "core/core2.pyx" + __pyx_t_8 = (__pyx_v_arr->arr[__pyx_v_j]).a; + +# line 989 "core/core2.pyx" + __pyx_v_a = __pyx_t_8; + + /* "core/core2.pyx":990 + * for j in range(arr.n): + * a = arr.arr[j].a + * b = arr.arr[j].b # <<<<<<<<<<<<<< + * + * avg = (self.engine.m.verts[a] + self.engine.m.verts[b]) * 0.5 + */ + +# line 990 "core/core2.pyx" + __pyx_t_8 = (__pyx_v_arr->arr[__pyx_v_j]).b; + +# line 990 "core/core2.pyx" + __pyx_v_b = __pyx_t_8; + + /* "core/core2.pyx":992 + * b = arr.arr[j].b + * + * avg = (self.engine.m.verts[a] + self.engine.m.verts[b]) * 0.5 # <<<<<<<<<<<<<< + * d = (self.engine.m.verts[i] - avg) + * if not (d.dot(self.engine.m.vert_normals[i]) > 0) == arr.arr[j].side: + */ + +# line 992 "core/core2.pyx" + __pyx_v_avg = (((__pyx_v_self->engine->m->verts[__pyx_v_a]) + (__pyx_v_self->engine->m->verts[__pyx_v_b])) * 0.5); + + /* "core/core2.pyx":993 + * + * avg = (self.engine.m.verts[a] + self.engine.m.verts[b]) * 0.5 + * d = (self.engine.m.verts[i] - avg) # <<<<<<<<<<<<<< + * if not (d.dot(self.engine.m.vert_normals[i]) > 0) == arr.arr[j].side: + * d = d - d.project_unit(self.engine.m.vert_normals[i]) * 2 + */ + +# line 993 "core/core2.pyx" + __pyx_v_d = ((__pyx_v_self->engine->m->verts[__pyx_v_i]) - __pyx_v_avg); + + /* "core/core2.pyx":994 + * avg = (self.engine.m.verts[a] + self.engine.m.verts[b]) * 0.5 + * d = (self.engine.m.verts[i] - avg) + * if not (d.dot(self.engine.m.vert_normals[i]) > 0) == arr.arr[j].side: # <<<<<<<<<<<<<< + * d = d - d.project_unit(self.engine.m.vert_normals[i]) * 2 + * l = d.len() + */ + +# line 994 "core/core2.pyx" + __pyx_t_4 = ((!(((__pyx_v_d.dot((__pyx_v_self->engine->m->vert_normals[__pyx_v_i])) > 0.0) == (__pyx_v_arr->arr[__pyx_v_j]).side) != 0)) != 0); + +# line 994 "core/core2.pyx" + if (__pyx_t_4) { + + /* "core/core2.pyx":995 + * d = (self.engine.m.verts[i] - avg) + * if not (d.dot(self.engine.m.vert_normals[i]) > 0) == arr.arr[j].side: + * d = d - d.project_unit(self.engine.m.vert_normals[i]) * 2 # <<<<<<<<<<<<<< + * l = d.len() + * if l > EPS: + */ + +# line 995 "core/core2.pyx" + __pyx_v_d = (__pyx_v_d - (__pyx_v_d.project_unit((__pyx_v_self->engine->m->vert_normals[__pyx_v_i])) * 2.0)); + + /* "core/core2.pyx":994 + * avg = (self.engine.m.verts[a] + self.engine.m.verts[b]) * 0.5 + * d = (self.engine.m.verts[i] - avg) + * if not (d.dot(self.engine.m.vert_normals[i]) > 0) == arr.arr[j].side: # <<<<<<<<<<<<<< + * d = d - d.project_unit(self.engine.m.vert_normals[i]) * 2 + * l = d.len() + */ + +# line 994 "core/core2.pyx" + } + + /* "core/core2.pyx":996 + * if not (d.dot(self.engine.m.vert_normals[i]) > 0) == arr.arr[j].side: + * d = d - d.project_unit(self.engine.m.vert_normals[i]) * 2 + * l = d.len() # <<<<<<<<<<<<<< + * if l > EPS: + * l = 1 / l + */ + +# line 996 "core/core2.pyx" + __pyx_v_l = __pyx_v_d.len(); + + /* "core/core2.pyx":997 + * d = d - d.project_unit(self.engine.m.vert_normals[i]) * 2 + * l = d.len() + * if l > EPS: # <<<<<<<<<<<<<< + * l = 1 / l + * d = d * l * arr.arr[j].avg_dist * (self.engine.m.verts[a] - self.engine.m.verts[b]).len() + */ + +# line 997 "core/core2.pyx" + __pyx_t_4 = ((__pyx_v_l > EPS) != 0); + +# line 997 "core/core2.pyx" + if (__pyx_t_4) { + + /* "core/core2.pyx":998 + * l = d.len() + * if l > EPS: + * l = 1 / l # <<<<<<<<<<<<<< + * d = d * l * arr.arr[j].avg_dist * (self.engine.m.verts[a] - self.engine.m.verts[b]).len() + * + */ + +# line 998 "core/core2.pyx" + __pyx_v_l = (1.0 / __pyx_v_l); + + /* "core/core2.pyx":997 + * d = d - d.project_unit(self.engine.m.vert_normals[i]) * 2 + * l = d.len() + * if l > EPS: # <<<<<<<<<<<<<< + * l = 1 / l + * d = d * l * arr.arr[j].avg_dist * (self.engine.m.verts[a] - self.engine.m.verts[b]).len() + */ + +# line 997 "core/core2.pyx" + } + + /* "core/core2.pyx":999 + * if l > EPS: + * l = 1 / l + * d = d * l * arr.arr[j].avg_dist * (self.engine.m.verts[a] - self.engine.m.verts[b]).len() # <<<<<<<<<<<<<< + * + * self.engine.tmp_verts[i] += avg + d + */ + +# line 999 "core/core2.pyx" + __pyx_v_d = (((__pyx_v_d * __pyx_v_l) * (__pyx_v_arr->arr[__pyx_v_j]).avg_dist) * ((__pyx_v_self->engine->m->verts[__pyx_v_a]) - (__pyx_v_self->engine->m->verts[__pyx_v_b])).len()); + + /* "core/core2.pyx":1001 + * d = d * l * arr.arr[j].avg_dist * (self.engine.m.verts[a] - self.engine.m.verts[b]).len() + * + * self.engine.tmp_verts[i] += avg + d # <<<<<<<<<<<<<< + * + * self.engine.tmp_verts[i] *= 1.0 / arr.n + */ + +# line 1001 "core/core2.pyx" + (__pyx_v_self->engine->tmp_verts[__pyx_v_i]) += (__pyx_v_avg + __pyx_v_d); + +# line 1001 "core/core2.pyx" + } + + /* "core/core2.pyx":1003 + * self.engine.tmp_verts[i] += avg + d + * + * self.engine.tmp_verts[i] *= 1.0 / arr.n # <<<<<<<<<<<<<< + * + * for i in prange(self.engine.n_verts): + */ + +# line 1003 "core/core2.pyx" + (__pyx_v_self->engine->tmp_verts[__pyx_v_i]) *= (((float)1.0) / ((float)__pyx_v_arr->n)); + +# line 1003 "core/core2.pyx" + goto __pyx_L16; + +# line 1003 "core/core2.pyx" + __pyx_L6_continue:; + +# line 1003 "core/core2.pyx" + goto __pyx_L16; + +# line 1003 "core/core2.pyx" + __pyx_L16:; + +# line 1003 "core/core2.pyx" + } + +# line 1003 "core/core2.pyx" + } + +# line 1003 "core/core2.pyx" + } + +# line 1003 "core/core2.pyx" + } + +# line 1003 "core/core2.pyx" + } + +# line 1003 "core/core2.pyx" + #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))))) + +# line 1003 "core/core2.pyx" + #undef likely + +# line 1003 "core/core2.pyx" + #undef unlikely + #define likely(x) __builtin_expect(!!(x), 1) + #define unlikely(x) __builtin_expect(!!(x), 0) + +# line 1003 "core/core2.pyx" + #endif + + /* "core/core2.pyx":1005 + * self.engine.tmp_verts[i] *= 1.0 / arr.n + * + * for i in prange(self.engine.n_verts): # <<<<<<<<<<<<<< + * if self.links[i].n == 0: + * continue + */ + +# line 1005 "core/core2.pyx" + __pyx_t_3 = __pyx_v_self->engine->n_verts; + +# line 1005 "core/core2.pyx" + if ((1 == 0)) abort(); + +# line 1005 "core/core2.pyx" + { + +# line 1005 "core/core2.pyx" + #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))))) + +# line 1005 "core/core2.pyx" + #undef likely + +# line 1005 "core/core2.pyx" + #undef unlikely + #define likely(x) (x) + #define unlikely(x) (x) + +# line 1005 "core/core2.pyx" + #endif + +# line 1005 "core/core2.pyx" + __pyx_t_1 = (__pyx_t_3 - 0 + 1 - 1/abs(1)) / 1; + +# line 1005 "core/core2.pyx" + if (__pyx_t_1 > 0) + +# line 1005 "core/core2.pyx" + { + +# line 1005 "core/core2.pyx" + #ifdef _OPENMP + +# line 1005 "core/core2.pyx" + #pragma omp parallel private(__pyx_t_4) + #endif /* _OPENMP */ + { + #ifdef _OPENMP + #pragma omp for firstprivate(__pyx_v_i) lastprivate(__pyx_v_i) + #endif /* _OPENMP */ + for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2++){ + { + __pyx_v_i = (int)(0 + 1 * __pyx_t_2); + + /* "core/core2.pyx":1006 + * + * for i in prange(self.engine.n_verts): + * if self.links[i].n == 0: # <<<<<<<<<<<<<< + * continue + * + */ + +# line 1006 "core/core2.pyx" + __pyx_t_4 = (((__pyx_v_self->links[__pyx_v_i])->n == 0) != 0); + +# line 1006 "core/core2.pyx" + if (__pyx_t_4) { + + /* "core/core2.pyx":1007 + * for i in prange(self.engine.n_verts): + * if self.links[i].n == 0: + * continue # <<<<<<<<<<<<<< + * + * self.engine.m.verts[i] = self.engine.m.verts[i].lerp(self.engine.tmp_verts[i], factor) + */ + +# line 1007 "core/core2.pyx" + goto __pyx_L17_continue; + + /* "core/core2.pyx":1006 + * + * for i in prange(self.engine.n_verts): + * if self.links[i].n == 0: # <<<<<<<<<<<<<< + * continue + * + */ + +# line 1006 "core/core2.pyx" + } + + /* "core/core2.pyx":1009 + * continue + * + * self.engine.m.verts[i] = self.engine.m.verts[i].lerp(self.engine.tmp_verts[i], factor) # <<<<<<<<<<<<<< + * + * + */ + +# line 1009 "core/core2.pyx" + (__pyx_v_self->engine->m->verts[__pyx_v_i]) = (__pyx_v_self->engine->m->verts[__pyx_v_i]).lerp((__pyx_v_self->engine->tmp_verts[__pyx_v_i]), __pyx_v_factor); + +# line 1009 "core/core2.pyx" + goto __pyx_L23; + +# line 1009 "core/core2.pyx" + __pyx_L17_continue:; + +# line 1009 "core/core2.pyx" + goto __pyx_L23; + +# line 1009 "core/core2.pyx" + __pyx_L23:; + +# line 1009 "core/core2.pyx" + } + +# line 1009 "core/core2.pyx" + } + +# line 1009 "core/core2.pyx" + } + +# line 1009 "core/core2.pyx" + } + +# line 1009 "core/core2.pyx" + } + +# line 1009 "core/core2.pyx" + #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))))) + +# line 1009 "core/core2.pyx" + #undef likely + +# line 1009 "core/core2.pyx" + #undef unlikely + #define likely(x) __builtin_expect(!!(x), 1) + #define unlikely(x) __builtin_expect(!!(x), 0) + +# line 1009 "core/core2.pyx" + #endif + +# line 1009 "core/core2.pyx" + } + + /* "core/core2.pyx":980 + * cdef float l + * + * with nogil: # <<<<<<<<<<<<<< + * for i in prange(self.engine.n_verts): + * arr = self.links[i] + */ + /*finally:*/ { + /*normal exit:*/{ + #ifdef WITH_THREAD + __Pyx_FastGIL_Forget(); + Py_BLOCK_THREADS + #endif + goto __pyx_L5; + } + __pyx_L5:; + } + } + + /* "core/core2.pyx":973 + * arr.arr[j].avg_dist = d.len() / ((self.engine.m.verts[a] - self.engine.m.verts[b]).len() + EPS) + * + * cpdef void displacement_force(self, float factor): # <<<<<<<<<<<<<< + * cdef int i, j, a, b + * cdef vec3 avg, d + */ + + /* function exit code */ + __Pyx_RefNannyFinishContext(); +} + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_21TernarySmoothingLinks_7displacement_force(PyObject *__pyx_v_self, PyObject *__pyx_arg_factor); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_21TernarySmoothingLinks_7displacement_force(PyObject *__pyx_v_self, PyObject *__pyx_arg_factor) { + float __pyx_v_factor; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("displacement_force (wrapper)", 0); + assert(__pyx_arg_factor); { + __pyx_v_factor = __pyx_PyFloat_AsFloat(__pyx_arg_factor); if (unlikely((__pyx_v_factor == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 973, __pyx_L3_error) + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("softwrap_core2.TernarySmoothingLinks.displacement_force", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_14softwrap_core2_21TernarySmoothingLinks_6displacement_force(((struct __pyx_obj_14softwrap_core2_TernarySmoothingLinks *)__pyx_v_self), ((float)__pyx_v_factor)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_21TernarySmoothingLinks_6displacement_force(struct __pyx_obj_14softwrap_core2_TernarySmoothingLinks *__pyx_v_self, float __pyx_v_factor) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("displacement_force", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_void_to_None(__pyx_f_14softwrap_core2_21TernarySmoothingLinks_displacement_force(__pyx_v_self, __pyx_v_factor, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 973, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("softwrap_core2.TernarySmoothingLinks.displacement_force", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":916 + * @cython.final + * cdef class TernarySmoothingLinks: + * cdef readonly SpringEngine engine # <<<<<<<<<<<<<< + * cdef TernaryLinkArr** links + * + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_21TernarySmoothingLinks_6engine_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_21TernarySmoothingLinks_6engine_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_14softwrap_core2_21TernarySmoothingLinks_6engine___get__(((struct __pyx_obj_14softwrap_core2_TernarySmoothingLinks *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_21TernarySmoothingLinks_6engine___get__(struct __pyx_obj_14softwrap_core2_TernarySmoothingLinks *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_self->engine)); + __pyx_r = ((PyObject *)__pyx_v_self->engine); + goto __pyx_L0; + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "(tree fragment)":1 + * def __reduce_cython__(self): # <<<<<<<<<<<<<< + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_21TernarySmoothingLinks_9__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_21TernarySmoothingLinks_9__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0); + __pyx_r = __pyx_pf_14softwrap_core2_21TernarySmoothingLinks_8__reduce_cython__(((struct __pyx_obj_14softwrap_core2_TernarySmoothingLinks *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_21TernarySmoothingLinks_8__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_14softwrap_core2_TernarySmoothingLinks *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__reduce_cython__", 0); + + /* "(tree fragment)":2 + * def __reduce_cython__(self): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + */ + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__13, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __PYX_ERR(1, 2, __pyx_L1_error) + + /* "(tree fragment)":1 + * def __reduce_cython__(self): # <<<<<<<<<<<<<< + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("softwrap_core2.TernarySmoothingLinks.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "(tree fragment)":3 + * def __reduce_cython__(self): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_21TernarySmoothingLinks_11__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_21TernarySmoothingLinks_11__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0); + __pyx_r = __pyx_pf_14softwrap_core2_21TernarySmoothingLinks_10__setstate_cython__(((struct __pyx_obj_14softwrap_core2_TernarySmoothingLinks *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_21TernarySmoothingLinks_10__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_14softwrap_core2_TernarySmoothingLinks *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__setstate_cython__", 0); + + /* "(tree fragment)":4 + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< + */ + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__14, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __PYX_ERR(1, 4, __pyx_L1_error) + + /* "(tree fragment)":3 + * def __reduce_cython__(self): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("softwrap_core2.TernarySmoothingLinks.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":1024 + * + * @cython.boundscheck(True) + * def __cinit__(self, SpringEngine engine, list links): # <<<<<<<<<<<<<< + * self.engine = engine + * self.n_links = len(links) + */ + +/* Python wrapper */ +static int __pyx_pw_14softwrap_core2_24QuaternarySmoothingLinks_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pw_14softwrap_core2_24QuaternarySmoothingLinks_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_engine = 0; + PyObject *__pyx_v_links = 0; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_engine,&__pyx_n_s_links,0}; + PyObject* values[2] = {0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + CYTHON_FALLTHROUGH; + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + CYTHON_FALLTHROUGH; + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_engine)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + CYTHON_FALLTHROUGH; + case 1: + if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_links)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 2, 2, 1); __PYX_ERR(0, 1024, __pyx_L3_error) + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(0, 1024, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + } + __pyx_v_engine = ((struct __pyx_obj_14softwrap_core2_SpringEngine *)values[0]); + __pyx_v_links = ((PyObject*)values[1]); + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1024, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("softwrap_core2.QuaternarySmoothingLinks.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_engine), __pyx_ptype_14softwrap_core2_SpringEngine, 1, "engine", 0))) __PYX_ERR(0, 1024, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_links), (&PyList_Type), 1, "links", 1))) __PYX_ERR(0, 1024, __pyx_L1_error) + __pyx_r = __pyx_pf_14softwrap_core2_24QuaternarySmoothingLinks___cinit__(((struct __pyx_obj_14softwrap_core2_QuaternarySmoothingLinks *)__pyx_v_self), __pyx_v_engine, __pyx_v_links); + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_14softwrap_core2_24QuaternarySmoothingLinks___cinit__(struct __pyx_obj_14softwrap_core2_QuaternarySmoothingLinks *__pyx_v_self, struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_engine, PyObject *__pyx_v_links) { + struct __pyx_t_14softwrap_core2_QuaternaryLink *__pyx_v_lnk; + int __pyx_v_i; + int __pyx_r; + __Pyx_RefNannyDeclarations + Py_ssize_t __pyx_t_1; + void *__pyx_t_2; + int __pyx_t_3; + int __pyx_t_4; + int __pyx_t_5; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8 = NULL; + PyObject *__pyx_t_9 = NULL; + PyObject *__pyx_t_10 = NULL; + PyObject *__pyx_t_11 = NULL; + PyObject *(*__pyx_t_12)(PyObject *); + int __pyx_t_13; + int __pyx_t_14; + int __pyx_t_15; + int __pyx_t_16; + int __pyx_t_17; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__cinit__", 0); + + /* "core/core2.pyx":1025 + * @cython.boundscheck(True) + * def __cinit__(self, SpringEngine engine, list links): + * self.engine = engine # <<<<<<<<<<<<<< + * self.n_links = len(links) + * self.links = maelloc(sizeof(QuaternaryLink) * self.n_links, __LINE__) + */ + +# line 1025 "core/core2.pyx" + __Pyx_INCREF(((PyObject *)__pyx_v_engine)); + +# line 1025 "core/core2.pyx" + __Pyx_GIVEREF(((PyObject *)__pyx_v_engine)); + +# line 1025 "core/core2.pyx" + __Pyx_GOTREF(__pyx_v_self->engine); + +# line 1025 "core/core2.pyx" + __Pyx_DECREF(((PyObject *)__pyx_v_self->engine)); + +# line 1025 "core/core2.pyx" + __pyx_v_self->engine = __pyx_v_engine; + + /* "core/core2.pyx":1026 + * def __cinit__(self, SpringEngine engine, list links): + * self.engine = engine + * self.n_links = len(links) # <<<<<<<<<<<<<< + * self.links = maelloc(sizeof(QuaternaryLink) * self.n_links, __LINE__) + * self.accum_n = caelloc(engine.n_verts, sizeof(int), __LINE__) + */ + +# line 1026 "core/core2.pyx" + if (unlikely(__pyx_v_links == Py_None)) { + +# line 1026 "core/core2.pyx" + PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); + +# line 1026 "core/core2.pyx" + __PYX_ERR(0, 1026, __pyx_L1_error) + +# line 1026 "core/core2.pyx" + } + +# line 1026 "core/core2.pyx" + __pyx_t_1 = PyList_GET_SIZE(__pyx_v_links); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1026, __pyx_L1_error) + +# line 1026 "core/core2.pyx" + __pyx_v_self->n_links = __pyx_t_1; + + /* "core/core2.pyx":1027 + * self.engine = engine + * self.n_links = len(links) + * self.links = maelloc(sizeof(QuaternaryLink) * self.n_links, __LINE__) # <<<<<<<<<<<<<< + * self.accum_n = caelloc(engine.n_verts, sizeof(int), __LINE__) + * + */ + +# line 1027 "core/core2.pyx" + __pyx_t_2 = __pyx_f_14softwrap_core2_maelloc(((sizeof(struct __pyx_t_14softwrap_core2_QuaternaryLink)) * __pyx_v_self->n_links), __LINE__); if (unlikely(__pyx_t_2 == ((void *)NULL))) __PYX_ERR(0, 1027, __pyx_L1_error) + +# line 1027 "core/core2.pyx" + __pyx_v_self->links = ((struct __pyx_t_14softwrap_core2_QuaternaryLink *)__pyx_t_2); + + /* "core/core2.pyx":1028 + * self.n_links = len(links) + * self.links = maelloc(sizeof(QuaternaryLink) * self.n_links, __LINE__) + * self.accum_n = caelloc(engine.n_verts, sizeof(int), __LINE__) # <<<<<<<<<<<<<< + * + * cdef QuaternaryLink* lnk + */ + +# line 1028 "core/core2.pyx" + __pyx_t_2 = __pyx_f_14softwrap_core2_caelloc(__pyx_v_engine->n_verts, (sizeof(int)), __LINE__); if (unlikely(__pyx_t_2 == ((void *)NULL))) __PYX_ERR(0, 1028, __pyx_L1_error) + +# line 1028 "core/core2.pyx" + __pyx_v_self->accum_n = ((int *)__pyx_t_2); + + /* "core/core2.pyx":1033 + * cdef int i + * + * for i in range(self.n_links): # <<<<<<<<<<<<<< + * lnk = self.links + i + * lnk.a, lnk.b, lnk.c, lnk.d = links[i] + */ + +# line 1033 "core/core2.pyx" + __pyx_t_3 = __pyx_v_self->n_links; + +# line 1033 "core/core2.pyx" + __pyx_t_4 = __pyx_t_3; + +# line 1033 "core/core2.pyx" + for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) { + +# line 1033 "core/core2.pyx" + __pyx_v_i = __pyx_t_5; + + /* "core/core2.pyx":1034 + * + * for i in range(self.n_links): + * lnk = self.links + i # <<<<<<<<<<<<<< + * lnk.a, lnk.b, lnk.c, lnk.d = links[i] + * index_check(lnk.a, engine.n_verts) + */ + +# line 1034 "core/core2.pyx" + __pyx_v_lnk = (__pyx_v_self->links + __pyx_v_i); + + /* "core/core2.pyx":1035 + * for i in range(self.n_links): + * lnk = self.links + i + * lnk.a, lnk.b, lnk.c, lnk.d = links[i] # <<<<<<<<<<<<<< + * index_check(lnk.a, engine.n_verts) + * index_check(lnk.b, engine.n_verts) + */ + +# line 1035 "core/core2.pyx" + if (unlikely(__pyx_v_links == Py_None)) { + +# line 1035 "core/core2.pyx" + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + +# line 1035 "core/core2.pyx" + __PYX_ERR(0, 1035, __pyx_L1_error) + +# line 1035 "core/core2.pyx" + } + +# line 1035 "core/core2.pyx" + __pyx_t_6 = __Pyx_GetItemInt_List(__pyx_v_links, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1035, __pyx_L1_error) + +# line 1035 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_6); + +# line 1035 "core/core2.pyx" + if ((likely(PyTuple_CheckExact(__pyx_t_6))) || (PyList_CheckExact(__pyx_t_6))) { + +# line 1035 "core/core2.pyx" + PyObject* sequence = __pyx_t_6; + +# line 1035 "core/core2.pyx" + Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); + +# line 1035 "core/core2.pyx" + if (unlikely(size != 4)) { + +# line 1035 "core/core2.pyx" + if (size > 4) __Pyx_RaiseTooManyValuesError(4); + +# line 1035 "core/core2.pyx" + else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); + +# line 1035 "core/core2.pyx" + __PYX_ERR(0, 1035, __pyx_L1_error) + +# line 1035 "core/core2.pyx" + } + +# line 1035 "core/core2.pyx" + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + +# line 1035 "core/core2.pyx" + if (likely(PyTuple_CheckExact(sequence))) { + +# line 1035 "core/core2.pyx" + __pyx_t_7 = PyTuple_GET_ITEM(sequence, 0); + +# line 1035 "core/core2.pyx" + __pyx_t_8 = PyTuple_GET_ITEM(sequence, 1); + +# line 1035 "core/core2.pyx" + __pyx_t_9 = PyTuple_GET_ITEM(sequence, 2); + +# line 1035 "core/core2.pyx" + __pyx_t_10 = PyTuple_GET_ITEM(sequence, 3); + +# line 1035 "core/core2.pyx" + } else { + +# line 1035 "core/core2.pyx" + __pyx_t_7 = PyList_GET_ITEM(sequence, 0); + +# line 1035 "core/core2.pyx" + __pyx_t_8 = PyList_GET_ITEM(sequence, 1); + +# line 1035 "core/core2.pyx" + __pyx_t_9 = PyList_GET_ITEM(sequence, 2); + +# line 1035 "core/core2.pyx" + __pyx_t_10 = PyList_GET_ITEM(sequence, 3); + +# line 1035 "core/core2.pyx" + } + +# line 1035 "core/core2.pyx" + __Pyx_INCREF(__pyx_t_7); + +# line 1035 "core/core2.pyx" + __Pyx_INCREF(__pyx_t_8); + +# line 1035 "core/core2.pyx" + __Pyx_INCREF(__pyx_t_9); + +# line 1035 "core/core2.pyx" + __Pyx_INCREF(__pyx_t_10); + +# line 1035 "core/core2.pyx" + #else + +# line 1035 "core/core2.pyx" + { + +# line 1035 "core/core2.pyx" + Py_ssize_t i; + +# line 1035 "core/core2.pyx" + PyObject** temps[4] = {&__pyx_t_7,&__pyx_t_8,&__pyx_t_9,&__pyx_t_10}; + +# line 1035 "core/core2.pyx" + for (i=0; i < 4; i++) { + +# line 1035 "core/core2.pyx" + PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 1035, __pyx_L1_error) + +# line 1035 "core/core2.pyx" + __Pyx_GOTREF(item); + +# line 1035 "core/core2.pyx" + *(temps[i]) = item; + +# line 1035 "core/core2.pyx" + } + +# line 1035 "core/core2.pyx" + } + +# line 1035 "core/core2.pyx" + #endif + +# line 1035 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + +# line 1035 "core/core2.pyx" + } else { + +# line 1035 "core/core2.pyx" + Py_ssize_t index = -1; + +# line 1035 "core/core2.pyx" + PyObject** temps[4] = {&__pyx_t_7,&__pyx_t_8,&__pyx_t_9,&__pyx_t_10}; + +# line 1035 "core/core2.pyx" + __pyx_t_11 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1035, __pyx_L1_error) + +# line 1035 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_11); + +# line 1035 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + +# line 1035 "core/core2.pyx" + __pyx_t_12 = Py_TYPE(__pyx_t_11)->tp_iternext; + +# line 1035 "core/core2.pyx" + for (index=0; index < 4; index++) { + +# line 1035 "core/core2.pyx" + PyObject* item = __pyx_t_12(__pyx_t_11); if (unlikely(!item)) goto __pyx_L5_unpacking_failed; + +# line 1035 "core/core2.pyx" + __Pyx_GOTREF(item); + +# line 1035 "core/core2.pyx" + *(temps[index]) = item; + +# line 1035 "core/core2.pyx" + } + +# line 1035 "core/core2.pyx" + if (__Pyx_IternextUnpackEndCheck(__pyx_t_12(__pyx_t_11), 4) < 0) __PYX_ERR(0, 1035, __pyx_L1_error) + +# line 1035 "core/core2.pyx" + __pyx_t_12 = NULL; + +# line 1035 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + +# line 1035 "core/core2.pyx" + goto __pyx_L6_unpacking_done; + +# line 1035 "core/core2.pyx" + __pyx_L5_unpacking_failed:; + +# line 1035 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + +# line 1035 "core/core2.pyx" + __pyx_t_12 = NULL; + +# line 1035 "core/core2.pyx" + if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); + +# line 1035 "core/core2.pyx" + __PYX_ERR(0, 1035, __pyx_L1_error) + +# line 1035 "core/core2.pyx" + __pyx_L6_unpacking_done:; + +# line 1035 "core/core2.pyx" + } + +# line 1035 "core/core2.pyx" + __pyx_t_13 = __Pyx_PyInt_As_int(__pyx_t_7); if (unlikely((__pyx_t_13 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1035, __pyx_L1_error) + +# line 1035 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + +# line 1035 "core/core2.pyx" + __pyx_t_14 = __Pyx_PyInt_As_int(__pyx_t_8); if (unlikely((__pyx_t_14 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1035, __pyx_L1_error) + +# line 1035 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + +# line 1035 "core/core2.pyx" + __pyx_t_15 = __Pyx_PyInt_As_int(__pyx_t_9); if (unlikely((__pyx_t_15 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1035, __pyx_L1_error) + +# line 1035 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + +# line 1035 "core/core2.pyx" + __pyx_t_16 = __Pyx_PyInt_As_int(__pyx_t_10); if (unlikely((__pyx_t_16 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1035, __pyx_L1_error) + +# line 1035 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + +# line 1035 "core/core2.pyx" + __pyx_v_lnk->a = __pyx_t_13; + +# line 1035 "core/core2.pyx" + __pyx_v_lnk->b = __pyx_t_14; + +# line 1035 "core/core2.pyx" + __pyx_v_lnk->c = __pyx_t_15; + +# line 1035 "core/core2.pyx" + __pyx_v_lnk->d = __pyx_t_16; + + /* "core/core2.pyx":1036 + * lnk = self.links + i + * lnk.a, lnk.b, lnk.c, lnk.d = links[i] + * index_check(lnk.a, engine.n_verts) # <<<<<<<<<<<<<< + * index_check(lnk.b, engine.n_verts) + * index_check(lnk.c, engine.n_verts) + */ + +# line 1036 "core/core2.pyx" + __pyx_t_6 = __pyx_f_14softwrap_core2_index_check(__pyx_v_lnk->a, __pyx_v_engine->n_verts, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1036, __pyx_L1_error) + +# line 1036 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_6); + +# line 1036 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + + /* "core/core2.pyx":1037 + * lnk.a, lnk.b, lnk.c, lnk.d = links[i] + * index_check(lnk.a, engine.n_verts) + * index_check(lnk.b, engine.n_verts) # <<<<<<<<<<<<<< + * index_check(lnk.c, engine.n_verts) + * index_check(lnk.d, engine.n_verts) + */ + +# line 1037 "core/core2.pyx" + __pyx_t_6 = __pyx_f_14softwrap_core2_index_check(__pyx_v_lnk->b, __pyx_v_engine->n_verts, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1037, __pyx_L1_error) + +# line 1037 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_6); + +# line 1037 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + + /* "core/core2.pyx":1038 + * index_check(lnk.a, engine.n_verts) + * index_check(lnk.b, engine.n_verts) + * index_check(lnk.c, engine.n_verts) # <<<<<<<<<<<<<< + * index_check(lnk.d, engine.n_verts) + * self.accum_n[lnk.a] += 1 + */ + +# line 1038 "core/core2.pyx" + __pyx_t_6 = __pyx_f_14softwrap_core2_index_check(__pyx_v_lnk->c, __pyx_v_engine->n_verts, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1038, __pyx_L1_error) + +# line 1038 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_6); + +# line 1038 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + + /* "core/core2.pyx":1039 + * index_check(lnk.b, engine.n_verts) + * index_check(lnk.c, engine.n_verts) + * index_check(lnk.d, engine.n_verts) # <<<<<<<<<<<<<< + * self.accum_n[lnk.a] += 1 + * self.accum_n[lnk.b] += 1 + */ + +# line 1039 "core/core2.pyx" + __pyx_t_6 = __pyx_f_14softwrap_core2_index_check(__pyx_v_lnk->d, __pyx_v_engine->n_verts, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1039, __pyx_L1_error) + +# line 1039 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_6); + +# line 1039 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + + /* "core/core2.pyx":1040 + * index_check(lnk.c, engine.n_verts) + * index_check(lnk.d, engine.n_verts) + * self.accum_n[lnk.a] += 1 # <<<<<<<<<<<<<< + * self.accum_n[lnk.b] += 1 + * self.accum_n[lnk.c] += 1 + */ + +# line 1040 "core/core2.pyx" + __pyx_t_16 = __pyx_v_lnk->a; + +# line 1040 "core/core2.pyx" + (__pyx_v_self->accum_n[__pyx_t_16]) = ((__pyx_v_self->accum_n[__pyx_t_16]) + 1); + + /* "core/core2.pyx":1041 + * index_check(lnk.d, engine.n_verts) + * self.accum_n[lnk.a] += 1 + * self.accum_n[lnk.b] += 1 # <<<<<<<<<<<<<< + * self.accum_n[lnk.c] += 1 + * self.accum_n[lnk.d] += 1 + */ + +# line 1041 "core/core2.pyx" + __pyx_t_16 = __pyx_v_lnk->b; + +# line 1041 "core/core2.pyx" + (__pyx_v_self->accum_n[__pyx_t_16]) = ((__pyx_v_self->accum_n[__pyx_t_16]) + 1); + + /* "core/core2.pyx":1042 + * self.accum_n[lnk.a] += 1 + * self.accum_n[lnk.b] += 1 + * self.accum_n[lnk.c] += 1 # <<<<<<<<<<<<<< + * self.accum_n[lnk.d] += 1 + * + */ + +# line 1042 "core/core2.pyx" + __pyx_t_16 = __pyx_v_lnk->c; + +# line 1042 "core/core2.pyx" + (__pyx_v_self->accum_n[__pyx_t_16]) = ((__pyx_v_self->accum_n[__pyx_t_16]) + 1); + + /* "core/core2.pyx":1043 + * self.accum_n[lnk.b] += 1 + * self.accum_n[lnk.c] += 1 + * self.accum_n[lnk.d] += 1 # <<<<<<<<<<<<<< + * + * for i in range(engine.n_verts): + */ + +# line 1043 "core/core2.pyx" + __pyx_t_16 = __pyx_v_lnk->d; + +# line 1043 "core/core2.pyx" + (__pyx_v_self->accum_n[__pyx_t_16]) = ((__pyx_v_self->accum_n[__pyx_t_16]) + 1); + +# line 1043 "core/core2.pyx" + } + + /* "core/core2.pyx":1045 + * self.accum_n[lnk.d] += 1 + * + * for i in range(engine.n_verts): # <<<<<<<<<<<<<< + * if self.accum_n[i] == 0: + * self.accum_n[i] = 1 + */ + +# line 1045 "core/core2.pyx" + __pyx_t_3 = __pyx_v_engine->n_verts; + +# line 1045 "core/core2.pyx" + __pyx_t_4 = __pyx_t_3; + +# line 1045 "core/core2.pyx" + for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) { + +# line 1045 "core/core2.pyx" + __pyx_v_i = __pyx_t_5; + + /* "core/core2.pyx":1046 + * + * for i in range(engine.n_verts): + * if self.accum_n[i] == 0: # <<<<<<<<<<<<<< + * self.accum_n[i] = 1 + * + */ + +# line 1046 "core/core2.pyx" + __pyx_t_17 = (((__pyx_v_self->accum_n[__pyx_v_i]) == 0) != 0); + +# line 1046 "core/core2.pyx" + if (__pyx_t_17) { + + /* "core/core2.pyx":1047 + * for i in range(engine.n_verts): + * if self.accum_n[i] == 0: + * self.accum_n[i] = 1 # <<<<<<<<<<<<<< + * + * self.lengths_update() + */ + +# line 1047 "core/core2.pyx" + (__pyx_v_self->accum_n[__pyx_v_i]) = 1; + + /* "core/core2.pyx":1046 + * + * for i in range(engine.n_verts): + * if self.accum_n[i] == 0: # <<<<<<<<<<<<<< + * self.accum_n[i] = 1 + * + */ + +# line 1046 "core/core2.pyx" + } + +# line 1046 "core/core2.pyx" + } + + /* "core/core2.pyx":1049 + * self.accum_n[i] = 1 + * + * self.lengths_update() # <<<<<<<<<<<<<< + * + * def __dealloc__(self): + */ + +# line 1049 "core/core2.pyx" + ((struct __pyx_vtabstruct_14softwrap_core2_QuaternarySmoothingLinks *)__pyx_v_self->__pyx_vtab)->lengths_update(__pyx_v_self, 0); + + /* "core/core2.pyx":1024 + * + * @cython.boundscheck(True) + * def __cinit__(self, SpringEngine engine, list links): # <<<<<<<<<<<<<< + * self.engine = engine + * self.n_links = len(links) + */ + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_XDECREF(__pyx_t_9); + __Pyx_XDECREF(__pyx_t_10); + __Pyx_XDECREF(__pyx_t_11); + __Pyx_AddTraceback("softwrap_core2.QuaternarySmoothingLinks.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":1051 + * self.lengths_update() + * + * def __dealloc__(self): # <<<<<<<<<<<<<< + * fraeee(self.links) + * fraeee(self.accum_n) + */ + +/* Python wrapper */ +static void __pyx_pw_14softwrap_core2_24QuaternarySmoothingLinks_3__dealloc__(PyObject *__pyx_v_self); /*proto*/ +static void __pyx_pw_14softwrap_core2_24QuaternarySmoothingLinks_3__dealloc__(PyObject *__pyx_v_self) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0); + __pyx_pf_14softwrap_core2_24QuaternarySmoothingLinks_2__dealloc__(((struct __pyx_obj_14softwrap_core2_QuaternarySmoothingLinks *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); +} + +static void __pyx_pf_14softwrap_core2_24QuaternarySmoothingLinks_2__dealloc__(struct __pyx_obj_14softwrap_core2_QuaternarySmoothingLinks *__pyx_v_self) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__dealloc__", 0); + + /* "core/core2.pyx":1052 + * + * def __dealloc__(self): + * fraeee(self.links) # <<<<<<<<<<<<<< + * fraeee(self.accum_n) + * + */ + +# line 1052 "core/core2.pyx" + __pyx_f_14softwrap_core2_fraeee(__pyx_v_self->links); + + /* "core/core2.pyx":1053 + * def __dealloc__(self): + * fraeee(self.links) + * fraeee(self.accum_n) # <<<<<<<<<<<<<< + * + * cpdef void lengths_update(self): + */ + +# line 1053 "core/core2.pyx" + __pyx_f_14softwrap_core2_fraeee(__pyx_v_self->accum_n); + + /* "core/core2.pyx":1051 + * self.lengths_update() + * + * def __dealloc__(self): # <<<<<<<<<<<<<< + * fraeee(self.links) + * fraeee(self.accum_n) + */ + + /* function exit code */ + __Pyx_RefNannyFinishContext(); +} + +/* "core/core2.pyx":1055 + * fraeee(self.accum_n) + * + * cpdef void lengths_update(self): # <<<<<<<<<<<<<< + * + * cdef int i + */ + +static PyObject *__pyx_pw_14softwrap_core2_24QuaternarySmoothingLinks_5lengths_update(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static void __pyx_f_14softwrap_core2_24QuaternarySmoothingLinks_lengths_update(struct __pyx_obj_14softwrap_core2_QuaternarySmoothingLinks *__pyx_v_self, int __pyx_skip_dispatch) { + int __pyx_v_i; + struct __pyx_t_14softwrap_core2_QuaternaryLink *__pyx_v_lnk; + vec3 __pyx_v_ab; + vec3 __pyx_v_cd; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + int __pyx_t_5; + int __pyx_t_6; + int __pyx_t_7; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("lengths_update", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) { + #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS + static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; + if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) { + PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); + #endif + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_lengths_update); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1055, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_14softwrap_core2_24QuaternarySmoothingLinks_5lengths_update)) { + __Pyx_INCREF(__pyx_t_1); + __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { + __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); + if (likely(__pyx_t_4)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); + __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_3, function); + } + } + __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1055, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS + __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); + __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self)); + if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) { + __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; + } + #endif + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS + } + #endif + } + + /* "core/core2.pyx":1061 + * cdef vec3 ab, cd + * + * for i in range(self.n_links): # <<<<<<<<<<<<<< + * lnk = self.links + i + * ab = (self.engine.m.verts[lnk.a] - self.engine.m.verts[lnk.b]) + */ + +# line 1061 "core/core2.pyx" + __pyx_t_5 = __pyx_v_self->n_links; + +# line 1061 "core/core2.pyx" + __pyx_t_6 = __pyx_t_5; + +# line 1061 "core/core2.pyx" + for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) { + +# line 1061 "core/core2.pyx" + __pyx_v_i = __pyx_t_7; + + /* "core/core2.pyx":1062 + * + * for i in range(self.n_links): + * lnk = self.links + i # <<<<<<<<<<<<<< + * ab = (self.engine.m.verts[lnk.a] - self.engine.m.verts[lnk.b]) + * cd = (self.engine.m.verts[lnk.c] - self.engine.m.verts[lnk.d]) + */ + +# line 1062 "core/core2.pyx" + __pyx_v_lnk = (__pyx_v_self->links + __pyx_v_i); + + /* "core/core2.pyx":1063 + * for i in range(self.n_links): + * lnk = self.links + i + * ab = (self.engine.m.verts[lnk.a] - self.engine.m.verts[lnk.b]) # <<<<<<<<<<<<<< + * cd = (self.engine.m.verts[lnk.c] - self.engine.m.verts[lnk.d]) + * + */ + +# line 1063 "core/core2.pyx" + __pyx_v_ab = ((__pyx_v_self->engine->m->verts[__pyx_v_lnk->a]) - (__pyx_v_self->engine->m->verts[__pyx_v_lnk->b])); + + /* "core/core2.pyx":1064 + * lnk = self.links + i + * ab = (self.engine.m.verts[lnk.a] - self.engine.m.verts[lnk.b]) + * cd = (self.engine.m.verts[lnk.c] - self.engine.m.verts[lnk.d]) # <<<<<<<<<<<<<< + * + * lnk.ratio = ab.len() / cd.len() + */ + +# line 1064 "core/core2.pyx" + __pyx_v_cd = ((__pyx_v_self->engine->m->verts[__pyx_v_lnk->c]) - (__pyx_v_self->engine->m->verts[__pyx_v_lnk->d])); + + /* "core/core2.pyx":1066 + * cd = (self.engine.m.verts[lnk.c] - self.engine.m.verts[lnk.d]) + * + * lnk.ratio = ab.len() / cd.len() # <<<<<<<<<<<<<< + * lnk.side = ab.dot(cd) > 1 + * + */ + +# line 1066 "core/core2.pyx" + __pyx_v_lnk->ratio = (__pyx_v_ab.len() / __pyx_v_cd.len()); + + /* "core/core2.pyx":1067 + * + * lnk.ratio = ab.len() / cd.len() + * lnk.side = ab.dot(cd) > 1 # <<<<<<<<<<<<<< + * + * cpdef void smooth(self, float factor, float max_ratio=3): + */ + +# line 1067 "core/core2.pyx" + __pyx_v_lnk->side = (__pyx_v_ab.dot(__pyx_v_cd) > 1.0); + +# line 1067 "core/core2.pyx" + } + + /* "core/core2.pyx":1055 + * fraeee(self.accum_n) + * + * cpdef void lengths_update(self): # <<<<<<<<<<<<<< + * + * cdef int i + */ + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_WriteUnraisable("softwrap_core2.QuaternarySmoothingLinks.lengths_update", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); + __pyx_L0:; + __Pyx_RefNannyFinishContext(); +} + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_24QuaternarySmoothingLinks_5lengths_update(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_24QuaternarySmoothingLinks_5lengths_update(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("lengths_update (wrapper)", 0); + __pyx_r = __pyx_pf_14softwrap_core2_24QuaternarySmoothingLinks_4lengths_update(((struct __pyx_obj_14softwrap_core2_QuaternarySmoothingLinks *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_24QuaternarySmoothingLinks_4lengths_update(struct __pyx_obj_14softwrap_core2_QuaternarySmoothingLinks *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("lengths_update", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_void_to_None(__pyx_f_14softwrap_core2_24QuaternarySmoothingLinks_lengths_update(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1055, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("softwrap_core2.QuaternarySmoothingLinks.lengths_update", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":1069 + * lnk.side = ab.dot(cd) > 1 + * + * cpdef void smooth(self, float factor, float max_ratio=3): # <<<<<<<<<<<<<< + * cdef int i + * cdef QuaternaryLink* lnk + */ + +static PyObject *__pyx_pw_14softwrap_core2_24QuaternarySmoothingLinks_7smooth(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static void __pyx_f_14softwrap_core2_24QuaternarySmoothingLinks_smooth(struct __pyx_obj_14softwrap_core2_QuaternarySmoothingLinks *__pyx_v_self, float __pyx_v_factor, int __pyx_skip_dispatch, struct __pyx_opt_args_14softwrap_core2_24QuaternarySmoothingLinks_smooth *__pyx_optional_args) { + float __pyx_v_max_ratio = ((float)3.0); + int __pyx_v_i; + struct __pyx_t_14softwrap_core2_QuaternaryLink *__pyx_v_lnk; + vec3 __pyx_v_ab; + vec3 __pyx_v_cd; + float __pyx_v_lab; + float __pyx_v_lcd; + float __pyx_v_rlab; + float __pyx_v_rlcd; + float __pyx_v_min_ratio; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + int __pyx_t_7; + PyObject *__pyx_t_8 = NULL; + int __pyx_t_9; + int __pyx_t_10; + int __pyx_t_11; + int __pyx_t_12; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("smooth", 0); + if (__pyx_optional_args) { + if (__pyx_optional_args->__pyx_n > 0) { + __pyx_v_max_ratio = __pyx_optional_args->max_ratio; + } + } + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) { + #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS + static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; + if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) { + PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); + #endif + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_smooth); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1069, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_14softwrap_core2_24QuaternarySmoothingLinks_7smooth)) { + __pyx_t_3 = PyFloat_FromDouble(__pyx_v_factor); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1069, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyFloat_FromDouble(__pyx_v_max_ratio); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1069, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_INCREF(__pyx_t_1); + __pyx_t_5 = __pyx_t_1; __pyx_t_6 = NULL; + __pyx_t_7 = 0; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { + __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5); + if (likely(__pyx_t_6)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); + __Pyx_INCREF(__pyx_t_6); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_5, function); + __pyx_t_7 = 1; + } + } + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_5)) { + PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_3, __pyx_t_4}; + __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1069, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { + PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_3, __pyx_t_4}; + __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1069, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } else + #endif + { + __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1069, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + if (__pyx_t_6) { + __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL; + } + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_4); + __pyx_t_3 = 0; + __pyx_t_4 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1069, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + } + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS + __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); + __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self)); + if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) { + __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; + } + #endif + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS + } + #endif + } + + /* "core/core2.pyx":1074 + * cdef vec3 ab, cd + * cdef float lab, lcd, rlab, rlcd + * cdef float min_ratio = 1.0 / max_ratio # <<<<<<<<<<<<<< + * + * for i in range(self.engine.n_verts): + */ + +# line 1074 "core/core2.pyx" + __pyx_v_min_ratio = (((float)1.0) / __pyx_v_max_ratio); + + /* "core/core2.pyx":1076 + * cdef float min_ratio = 1.0 / max_ratio + * + * for i in range(self.engine.n_verts): # <<<<<<<<<<<<<< + * self.engine.tmp_verts[i] = vec3(0) + * + */ + +# line 1076 "core/core2.pyx" + __pyx_t_7 = __pyx_v_self->engine->n_verts; + +# line 1076 "core/core2.pyx" + __pyx_t_9 = __pyx_t_7; + +# line 1076 "core/core2.pyx" + for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) { + +# line 1076 "core/core2.pyx" + __pyx_v_i = __pyx_t_10; + + /* "core/core2.pyx":1077 + * + * for i in range(self.engine.n_verts): + * self.engine.tmp_verts[i] = vec3(0) # <<<<<<<<<<<<<< + * + * for i in range(self.n_links): + */ + +# line 1077 "core/core2.pyx" + (__pyx_v_self->engine->tmp_verts[__pyx_v_i]) = vec3(0.0); + +# line 1077 "core/core2.pyx" + } + + /* "core/core2.pyx":1079 + * self.engine.tmp_verts[i] = vec3(0) + * + * for i in range(self.n_links): # <<<<<<<<<<<<<< + * lnk = self.links + i + * if lnk.ratio < min_ratio or lnk.ratio > max_ratio: + */ + +# line 1079 "core/core2.pyx" + __pyx_t_7 = __pyx_v_self->n_links; + +# line 1079 "core/core2.pyx" + __pyx_t_9 = __pyx_t_7; + +# line 1079 "core/core2.pyx" + for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) { + +# line 1079 "core/core2.pyx" + __pyx_v_i = __pyx_t_10; + + /* "core/core2.pyx":1080 + * + * for i in range(self.n_links): + * lnk = self.links + i # <<<<<<<<<<<<<< + * if lnk.ratio < min_ratio or lnk.ratio > max_ratio: + * continue + */ + +# line 1080 "core/core2.pyx" + __pyx_v_lnk = (__pyx_v_self->links + __pyx_v_i); + + /* "core/core2.pyx":1081 + * for i in range(self.n_links): + * lnk = self.links + i + * if lnk.ratio < min_ratio or lnk.ratio > max_ratio: # <<<<<<<<<<<<<< + * continue + * + */ + +# line 1081 "core/core2.pyx" + __pyx_t_12 = ((__pyx_v_lnk->ratio < __pyx_v_min_ratio) != 0); + +# line 1081 "core/core2.pyx" + if (!__pyx_t_12) { + +# line 1081 "core/core2.pyx" + } else { + +# line 1081 "core/core2.pyx" + __pyx_t_11 = __pyx_t_12; + +# line 1081 "core/core2.pyx" + goto __pyx_L8_bool_binop_done; + +# line 1081 "core/core2.pyx" + } + +# line 1081 "core/core2.pyx" + __pyx_t_12 = ((__pyx_v_lnk->ratio > __pyx_v_max_ratio) != 0); + +# line 1081 "core/core2.pyx" + __pyx_t_11 = __pyx_t_12; + +# line 1081 "core/core2.pyx" + __pyx_L8_bool_binop_done:; + +# line 1081 "core/core2.pyx" + if (__pyx_t_11) { + + /* "core/core2.pyx":1082 + * lnk = self.links + i + * if lnk.ratio < min_ratio or lnk.ratio > max_ratio: + * continue # <<<<<<<<<<<<<< + * + * ab = (self.engine.m.verts[lnk.a] - self.engine.m.verts[lnk.b]) + */ + +# line 1082 "core/core2.pyx" + goto __pyx_L5_continue; + + /* "core/core2.pyx":1081 + * for i in range(self.n_links): + * lnk = self.links + i + * if lnk.ratio < min_ratio or lnk.ratio > max_ratio: # <<<<<<<<<<<<<< + * continue + * + */ + +# line 1081 "core/core2.pyx" + } + + /* "core/core2.pyx":1084 + * continue + * + * ab = (self.engine.m.verts[lnk.a] - self.engine.m.verts[lnk.b]) # <<<<<<<<<<<<<< + * cd = (self.engine.m.verts[lnk.c] - self.engine.m.verts[lnk.d]) + * + */ + +# line 1084 "core/core2.pyx" + __pyx_v_ab = ((__pyx_v_self->engine->m->verts[__pyx_v_lnk->a]) - (__pyx_v_self->engine->m->verts[__pyx_v_lnk->b])); + + /* "core/core2.pyx":1085 + * + * ab = (self.engine.m.verts[lnk.a] - self.engine.m.verts[lnk.b]) + * cd = (self.engine.m.verts[lnk.c] - self.engine.m.verts[lnk.d]) # <<<<<<<<<<<<<< + * + * + */ + +# line 1085 "core/core2.pyx" + __pyx_v_cd = ((__pyx_v_self->engine->m->verts[__pyx_v_lnk->c]) - (__pyx_v_self->engine->m->verts[__pyx_v_lnk->d])); + + /* "core/core2.pyx":1088 + * + * + * rlab = ab.len() # <<<<<<<<<<<<<< + * rlcd = cd.len() + * + */ + +# line 1088 "core/core2.pyx" + __pyx_v_rlab = __pyx_v_ab.len(); + + /* "core/core2.pyx":1089 + * + * rlab = ab.len() + * rlcd = cd.len() # <<<<<<<<<<<<<< + * + * lab = rlcd * lnk.ratio + */ + +# line 1089 "core/core2.pyx" + __pyx_v_rlcd = __pyx_v_cd.len(); + + /* "core/core2.pyx":1091 + * rlcd = cd.len() + * + * lab = rlcd * lnk.ratio # <<<<<<<<<<<<<< + * lcd = rlab / lnk.ratio + * + */ + +# line 1091 "core/core2.pyx" + __pyx_v_lab = (__pyx_v_rlcd * __pyx_v_lnk->ratio); + + /* "core/core2.pyx":1092 + * + * lab = rlcd * lnk.ratio + * lcd = rlab / lnk.ratio # <<<<<<<<<<<<<< + * + * ab -= ab / rlab * lab + */ + +# line 1092 "core/core2.pyx" + __pyx_v_lcd = (__pyx_v_rlab / __pyx_v_lnk->ratio); + + /* "core/core2.pyx":1094 + * lcd = rlab / lnk.ratio + * + * ab -= ab / rlab * lab # <<<<<<<<<<<<<< + * cd -= cd / rlcd * lcd + * + */ + +# line 1094 "core/core2.pyx" + __pyx_v_ab -= ((__pyx_v_ab / __pyx_v_rlab) * __pyx_v_lab); + + /* "core/core2.pyx":1095 + * + * ab -= ab / rlab * lab + * cd -= cd / rlcd * lcd # <<<<<<<<<<<<<< + * + * self.engine.tmp_verts[lnk.a] -= ab + */ + +# line 1095 "core/core2.pyx" + __pyx_v_cd -= ((__pyx_v_cd / __pyx_v_rlcd) * __pyx_v_lcd); + + /* "core/core2.pyx":1097 + * cd -= cd / rlcd * lcd + * + * self.engine.tmp_verts[lnk.a] -= ab # <<<<<<<<<<<<<< + * self.engine.tmp_verts[lnk.b] += ab + * + */ + +# line 1097 "core/core2.pyx" + (__pyx_v_self->engine->tmp_verts[__pyx_v_lnk->a]) -= __pyx_v_ab; + + /* "core/core2.pyx":1098 + * + * self.engine.tmp_verts[lnk.a] -= ab + * self.engine.tmp_verts[lnk.b] += ab # <<<<<<<<<<<<<< + * + * self.engine.tmp_verts[lnk.c] -= cd + */ + +# line 1098 "core/core2.pyx" + (__pyx_v_self->engine->tmp_verts[__pyx_v_lnk->b]) += __pyx_v_ab; + + /* "core/core2.pyx":1100 + * self.engine.tmp_verts[lnk.b] += ab + * + * self.engine.tmp_verts[lnk.c] -= cd # <<<<<<<<<<<<<< + * self.engine.tmp_verts[lnk.d] += cd + * + */ + +# line 1100 "core/core2.pyx" + (__pyx_v_self->engine->tmp_verts[__pyx_v_lnk->c]) -= __pyx_v_cd; + + /* "core/core2.pyx":1101 + * + * self.engine.tmp_verts[lnk.c] -= cd + * self.engine.tmp_verts[lnk.d] += cd # <<<<<<<<<<<<<< + * + * for i in range(self.engine.n_verts): + */ + +# line 1101 "core/core2.pyx" + (__pyx_v_self->engine->tmp_verts[__pyx_v_lnk->d]) += __pyx_v_cd; + +# line 1101 "core/core2.pyx" + __pyx_L5_continue:; + +# line 1101 "core/core2.pyx" + } + + /* "core/core2.pyx":1103 + * self.engine.tmp_verts[lnk.d] += cd + * + * for i in range(self.engine.n_verts): # <<<<<<<<<<<<<< + * self.engine.m.verts[i] += self.engine.tmp_verts[i] * factor / self.accum_n[i] + * + */ + +# line 1103 "core/core2.pyx" + __pyx_t_7 = __pyx_v_self->engine->n_verts; + +# line 1103 "core/core2.pyx" + __pyx_t_9 = __pyx_t_7; + +# line 1103 "core/core2.pyx" + for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) { + +# line 1103 "core/core2.pyx" + __pyx_v_i = __pyx_t_10; + + /* "core/core2.pyx":1104 + * + * for i in range(self.engine.n_verts): + * self.engine.m.verts[i] += self.engine.tmp_verts[i] * factor / self.accum_n[i] # <<<<<<<<<<<<<< + * + * + */ + +# line 1104 "core/core2.pyx" + (__pyx_v_self->engine->m->verts[__pyx_v_i]) += (((__pyx_v_self->engine->tmp_verts[__pyx_v_i]) * __pyx_v_factor) / (__pyx_v_self->accum_n[__pyx_v_i])); + +# line 1104 "core/core2.pyx" + } + + /* "core/core2.pyx":1069 + * lnk.side = ab.dot(cd) > 1 + * + * cpdef void smooth(self, float factor, float max_ratio=3): # <<<<<<<<<<<<<< + * cdef int i + * cdef QuaternaryLink* lnk + */ + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_WriteUnraisable("softwrap_core2.QuaternarySmoothingLinks.smooth", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); + __pyx_L0:; + __Pyx_RefNannyFinishContext(); +} + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_24QuaternarySmoothingLinks_7smooth(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_24QuaternarySmoothingLinks_7smooth(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + float __pyx_v_factor; + float __pyx_v_max_ratio; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("smooth (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_factor,&__pyx_n_s_max_ratio,0}; + PyObject* values[2] = {0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + CYTHON_FALLTHROUGH; + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + CYTHON_FALLTHROUGH; + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_factor)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + CYTHON_FALLTHROUGH; + case 1: + if (kw_args > 0) { + PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_max_ratio); + if (value) { values[1] = value; kw_args--; } + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "smooth") < 0)) __PYX_ERR(0, 1069, __pyx_L3_error) + } + } else { + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + CYTHON_FALLTHROUGH; + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + break; + default: goto __pyx_L5_argtuple_error; + } + } + __pyx_v_factor = __pyx_PyFloat_AsFloat(values[0]); if (unlikely((__pyx_v_factor == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 1069, __pyx_L3_error) + if (values[1]) { + __pyx_v_max_ratio = __pyx_PyFloat_AsFloat(values[1]); if (unlikely((__pyx_v_max_ratio == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 1069, __pyx_L3_error) + } else { + __pyx_v_max_ratio = ((float)3.0); + } + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("smooth", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1069, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("softwrap_core2.QuaternarySmoothingLinks.smooth", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_14softwrap_core2_24QuaternarySmoothingLinks_6smooth(((struct __pyx_obj_14softwrap_core2_QuaternarySmoothingLinks *)__pyx_v_self), __pyx_v_factor, __pyx_v_max_ratio); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_24QuaternarySmoothingLinks_6smooth(struct __pyx_obj_14softwrap_core2_QuaternarySmoothingLinks *__pyx_v_self, float __pyx_v_factor, float __pyx_v_max_ratio) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + struct __pyx_opt_args_14softwrap_core2_24QuaternarySmoothingLinks_smooth __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("smooth", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1.__pyx_n = 1; + __pyx_t_1.max_ratio = __pyx_v_max_ratio; + __pyx_vtabptr_14softwrap_core2_QuaternarySmoothingLinks->smooth(__pyx_v_self, __pyx_v_factor, 1, &__pyx_t_1); + __pyx_t_2 = __Pyx_void_to_None(NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1069, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("softwrap_core2.QuaternarySmoothingLinks.smooth", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":1018 + * + * cdef class QuaternarySmoothingLinks: + * cdef readonly SpringEngine engine # <<<<<<<<<<<<<< + * cdef readonly int n_links + * cdef QuaternaryLink* links + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_24QuaternarySmoothingLinks_6engine_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_24QuaternarySmoothingLinks_6engine_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_14softwrap_core2_24QuaternarySmoothingLinks_6engine___get__(((struct __pyx_obj_14softwrap_core2_QuaternarySmoothingLinks *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_24QuaternarySmoothingLinks_6engine___get__(struct __pyx_obj_14softwrap_core2_QuaternarySmoothingLinks *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_self->engine)); + __pyx_r = ((PyObject *)__pyx_v_self->engine); + goto __pyx_L0; + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":1019 + * cdef class QuaternarySmoothingLinks: + * cdef readonly SpringEngine engine + * cdef readonly int n_links # <<<<<<<<<<<<<< + * cdef QuaternaryLink* links + * cdef int* accum_n + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_24QuaternarySmoothingLinks_7n_links_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_24QuaternarySmoothingLinks_7n_links_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_14softwrap_core2_24QuaternarySmoothingLinks_7n_links___get__(((struct __pyx_obj_14softwrap_core2_QuaternarySmoothingLinks *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_24QuaternarySmoothingLinks_7n_links___get__(struct __pyx_obj_14softwrap_core2_QuaternarySmoothingLinks *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->n_links); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1019, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("softwrap_core2.QuaternarySmoothingLinks.n_links.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "(tree fragment)":1 + * def __reduce_cython__(self): # <<<<<<<<<<<<<< + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_24QuaternarySmoothingLinks_9__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_24QuaternarySmoothingLinks_9__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0); + __pyx_r = __pyx_pf_14softwrap_core2_24QuaternarySmoothingLinks_8__reduce_cython__(((struct __pyx_obj_14softwrap_core2_QuaternarySmoothingLinks *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_24QuaternarySmoothingLinks_8__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_14softwrap_core2_QuaternarySmoothingLinks *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__reduce_cython__", 0); + + /* "(tree fragment)":2 + * def __reduce_cython__(self): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + */ + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__15, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __PYX_ERR(1, 2, __pyx_L1_error) + + /* "(tree fragment)":1 + * def __reduce_cython__(self): # <<<<<<<<<<<<<< + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("softwrap_core2.QuaternarySmoothingLinks.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "(tree fragment)":3 + * def __reduce_cython__(self): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_24QuaternarySmoothingLinks_11__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_24QuaternarySmoothingLinks_11__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0); + __pyx_r = __pyx_pf_14softwrap_core2_24QuaternarySmoothingLinks_10__setstate_cython__(((struct __pyx_obj_14softwrap_core2_QuaternarySmoothingLinks *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_24QuaternarySmoothingLinks_10__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_14softwrap_core2_QuaternarySmoothingLinks *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__setstate_cython__", 0); + + /* "(tree fragment)":4 + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< + */ + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__16, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __PYX_ERR(1, 4, __pyx_L1_error) + + /* "(tree fragment)":3 + * def __reduce_cython__(self): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("softwrap_core2.QuaternarySmoothingLinks.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":1115 + * + * + * def __cinit__(self, SpringLinks links, int start_index, int n_rings): # <<<<<<<<<<<<<< + * n_rings = nmax(n_rings, 1) + * self.engine = links.engine + */ + +/* Python wrapper */ +static int __pyx_pw_14softwrap_core2_15SpringEnginePin_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pw_14softwrap_core2_15SpringEnginePin_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + struct __pyx_obj_14softwrap_core2_SpringLinks *__pyx_v_links = 0; + int __pyx_v_start_index; + int __pyx_v_n_rings; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_links,&__pyx_n_s_start_index,&__pyx_n_s_n_rings,0}; + PyObject* values[3] = {0,0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + CYTHON_FALLTHROUGH; + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + CYTHON_FALLTHROUGH; + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + CYTHON_FALLTHROUGH; + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_links)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + CYTHON_FALLTHROUGH; + case 1: + if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_start_index)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 3, 3, 1); __PYX_ERR(0, 1115, __pyx_L3_error) + } + CYTHON_FALLTHROUGH; + case 2: + if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_n_rings)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 3, 3, 2); __PYX_ERR(0, 1115, __pyx_L3_error) + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(0, 1115, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + } + __pyx_v_links = ((struct __pyx_obj_14softwrap_core2_SpringLinks *)values[0]); + __pyx_v_start_index = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_start_index == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1115, __pyx_L3_error) + __pyx_v_n_rings = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_n_rings == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1115, __pyx_L3_error) + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1115, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("softwrap_core2.SpringEnginePin.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_links), __pyx_ptype_14softwrap_core2_SpringLinks, 1, "links", 0))) __PYX_ERR(0, 1115, __pyx_L1_error) + __pyx_r = __pyx_pf_14softwrap_core2_15SpringEnginePin___cinit__(((struct __pyx_obj_14softwrap_core2_SpringEnginePin *)__pyx_v_self), __pyx_v_links, __pyx_v_start_index, __pyx_v_n_rings); + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_14softwrap_core2_15SpringEnginePin___cinit__(struct __pyx_obj_14softwrap_core2_SpringEnginePin *__pyx_v_self, struct __pyx_obj_14softwrap_core2_SpringLinks *__pyx_v_links, int __pyx_v_start_index, int __pyx_v_n_rings) { + PyObject *__pyx_v_rings = 0; + PyObject *__pyx_v_seen = 0; + PyObject *__pyx_v_new_front = 0; + struct __pyx_obj_14softwrap_core2_LinkProbe *__pyx_v_probe = 0; + int __pyx_v_i; + int __pyx_v_vert_idx; + PyObject *__pyx_v_new_idx = NULL; + PyObject *__pyx_v_front = 0; + int __pyx_v_j; + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_t_2; + int __pyx_t_3; + PyObject *__pyx_t_4 = NULL; + long __pyx_t_5; + long __pyx_t_6; + int __pyx_t_7; + Py_ssize_t __pyx_t_8; + PyObject *(*__pyx_t_9)(PyObject *); + int __pyx_t_10; + Py_ssize_t __pyx_t_11; + PyObject *(*__pyx_t_12)(PyObject *); + PyObject *__pyx_t_13 = NULL; + int __pyx_t_14; + void *__pyx_t_15; + int __pyx_t_16; + int __pyx_t_17; + int __pyx_t_18; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__cinit__", 0); + + /* "core/core2.pyx":1116 + * + * def __cinit__(self, SpringLinks links, int start_index, int n_rings): + * n_rings = nmax(n_rings, 1) # <<<<<<<<<<<<<< + * self.engine = links.engine + * + */ + +# line 1116 "core/core2.pyx" + __pyx_v_n_rings = nmax(__pyx_v_n_rings, 1); + + /* "core/core2.pyx":1117 + * def __cinit__(self, SpringLinks links, int start_index, int n_rings): + * n_rings = nmax(n_rings, 1) + * self.engine = links.engine # <<<<<<<<<<<<<< + * + * if start_index < 0 or start_index >= self.engine.n_verts: + */ + +# line 1117 "core/core2.pyx" + __pyx_t_1 = ((PyObject *)__pyx_v_links->engine); + +# line 1117 "core/core2.pyx" + __Pyx_INCREF(__pyx_t_1); + +# line 1117 "core/core2.pyx" + __Pyx_GIVEREF(__pyx_t_1); + +# line 1117 "core/core2.pyx" + __Pyx_GOTREF(__pyx_v_self->engine); + +# line 1117 "core/core2.pyx" + __Pyx_DECREF(((PyObject *)__pyx_v_self->engine)); + +# line 1117 "core/core2.pyx" + __pyx_v_self->engine = ((struct __pyx_obj_14softwrap_core2_SpringEngine *)__pyx_t_1); + +# line 1117 "core/core2.pyx" + __pyx_t_1 = 0; + + /* "core/core2.pyx":1119 + * self.engine = links.engine + * + * if start_index < 0 or start_index >= self.engine.n_verts: # <<<<<<<<<<<<<< + * raise ValueError('invalid start_index') + * + */ + +# line 1119 "core/core2.pyx" + __pyx_t_3 = ((__pyx_v_start_index < 0) != 0); + +# line 1119 "core/core2.pyx" + if (!__pyx_t_3) { + +# line 1119 "core/core2.pyx" + } else { + +# line 1119 "core/core2.pyx" + __pyx_t_2 = __pyx_t_3; + +# line 1119 "core/core2.pyx" + goto __pyx_L4_bool_binop_done; + +# line 1119 "core/core2.pyx" + } + +# line 1119 "core/core2.pyx" + __pyx_t_3 = ((__pyx_v_start_index >= __pyx_v_self->engine->n_verts) != 0); + +# line 1119 "core/core2.pyx" + __pyx_t_2 = __pyx_t_3; + +# line 1119 "core/core2.pyx" + __pyx_L4_bool_binop_done:; + +# line 1119 "core/core2.pyx" + if (unlikely(__pyx_t_2)) { + + /* "core/core2.pyx":1120 + * + * if start_index < 0 or start_index >= self.engine.n_verts: + * raise ValueError('invalid start_index') # <<<<<<<<<<<<<< + * + * self.start_index = start_index + */ + +# line 1120 "core/core2.pyx" + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__17, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1120, __pyx_L1_error) + +# line 1120 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_1); + +# line 1120 "core/core2.pyx" + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + +# line 1120 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + +# line 1120 "core/core2.pyx" + __PYX_ERR(0, 1120, __pyx_L1_error) + + /* "core/core2.pyx":1119 + * self.engine = links.engine + * + * if start_index < 0 or start_index >= self.engine.n_verts: # <<<<<<<<<<<<<< + * raise ValueError('invalid start_index') + * + */ + +# line 1119 "core/core2.pyx" + } + + /* "core/core2.pyx":1122 + * raise ValueError('invalid start_index') + * + * self.start_index = start_index # <<<<<<<<<<<<<< + * + * cdef list rings = [[start_index]] + */ + +# line 1122 "core/core2.pyx" + __pyx_v_self->start_index = __pyx_v_start_index; + + /* "core/core2.pyx":1124 + * self.start_index = start_index + * + * cdef list rings = [[start_index]] # <<<<<<<<<<<<<< + * cdef set seen = set((start_index,)) + * cdef list new_front + */ + +# line 1124 "core/core2.pyx" + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_start_index); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1124, __pyx_L1_error) + +# line 1124 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_1); + +# line 1124 "core/core2.pyx" + __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1124, __pyx_L1_error) + +# line 1124 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_4); + +# line 1124 "core/core2.pyx" + __Pyx_GIVEREF(__pyx_t_1); + +# line 1124 "core/core2.pyx" + PyList_SET_ITEM(__pyx_t_4, 0, __pyx_t_1); + +# line 1124 "core/core2.pyx" + __pyx_t_1 = 0; + +# line 1124 "core/core2.pyx" + __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1124, __pyx_L1_error) + +# line 1124 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_1); + +# line 1124 "core/core2.pyx" + __Pyx_GIVEREF(__pyx_t_4); + +# line 1124 "core/core2.pyx" + PyList_SET_ITEM(__pyx_t_1, 0, __pyx_t_4); + +# line 1124 "core/core2.pyx" + __pyx_t_4 = 0; + +# line 1124 "core/core2.pyx" + __pyx_v_rings = ((PyObject*)__pyx_t_1); + +# line 1124 "core/core2.pyx" + __pyx_t_1 = 0; + + /* "core/core2.pyx":1125 + * + * cdef list rings = [[start_index]] + * cdef set seen = set((start_index,)) # <<<<<<<<<<<<<< + * cdef list new_front + * cdef LinkProbe probe + */ + +# line 1125 "core/core2.pyx" + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_start_index); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1125, __pyx_L1_error) + +# line 1125 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_1); + +# line 1125 "core/core2.pyx" + __pyx_t_4 = PySet_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1125, __pyx_L1_error) + +# line 1125 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_4); + +# line 1125 "core/core2.pyx" + if (PySet_Add(__pyx_t_4, __pyx_t_1) < 0) __PYX_ERR(0, 1125, __pyx_L1_error) + +# line 1125 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + +# line 1125 "core/core2.pyx" + __pyx_v_seen = ((PyObject*)__pyx_t_4); + +# line 1125 "core/core2.pyx" + __pyx_t_4 = 0; + + /* "core/core2.pyx":1131 + * cdef int i + * cdef int vert_idx + * for i in range(n_rings - 1): # <<<<<<<<<<<<<< + * new_front = [] + * for vert_idx in rings[-1]: + */ + +# line 1131 "core/core2.pyx" + __pyx_t_5 = (__pyx_v_n_rings - 1); + +# line 1131 "core/core2.pyx" + __pyx_t_6 = __pyx_t_5; + +# line 1131 "core/core2.pyx" + for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) { + +# line 1131 "core/core2.pyx" + __pyx_v_i = __pyx_t_7; + + /* "core/core2.pyx":1132 + * cdef int vert_idx + * for i in range(n_rings - 1): + * new_front = [] # <<<<<<<<<<<<<< + * for vert_idx in rings[-1]: + * probe = links[vert_idx] + */ + +# line 1132 "core/core2.pyx" + __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1132, __pyx_L1_error) + +# line 1132 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_4); + +# line 1132 "core/core2.pyx" + __Pyx_XDECREF_SET(__pyx_v_new_front, ((PyObject*)__pyx_t_4)); + +# line 1132 "core/core2.pyx" + __pyx_t_4 = 0; + + /* "core/core2.pyx":1133 + * for i in range(n_rings - 1): + * new_front = [] + * for vert_idx in rings[-1]: # <<<<<<<<<<<<<< + * probe = links[vert_idx] + * for new_idx in probe: + */ + +# line 1133 "core/core2.pyx" + __pyx_t_4 = __Pyx_GetItemInt_List(__pyx_v_rings, -1L, long, 1, __Pyx_PyInt_From_long, 1, 1, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1133, __pyx_L1_error) + +# line 1133 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_4); + +# line 1133 "core/core2.pyx" + if (likely(PyList_CheckExact(__pyx_t_4)) || PyTuple_CheckExact(__pyx_t_4)) { + +# line 1133 "core/core2.pyx" + __pyx_t_1 = __pyx_t_4; __Pyx_INCREF(__pyx_t_1); __pyx_t_8 = 0; + +# line 1133 "core/core2.pyx" + __pyx_t_9 = NULL; + +# line 1133 "core/core2.pyx" + } else { + +# line 1133 "core/core2.pyx" + __pyx_t_8 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1133, __pyx_L1_error) + +# line 1133 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_1); + +# line 1133 "core/core2.pyx" + __pyx_t_9 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1133, __pyx_L1_error) + +# line 1133 "core/core2.pyx" + } + +# line 1133 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + +# line 1133 "core/core2.pyx" + for (;;) { + +# line 1133 "core/core2.pyx" + if (likely(!__pyx_t_9)) { + +# line 1133 "core/core2.pyx" + if (likely(PyList_CheckExact(__pyx_t_1))) { + +# line 1133 "core/core2.pyx" + if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_1)) break; + +# line 1133 "core/core2.pyx" + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + +# line 1133 "core/core2.pyx" + __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_8); __Pyx_INCREF(__pyx_t_4); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 1133, __pyx_L1_error) + +# line 1133 "core/core2.pyx" + #else + +# line 1133 "core/core2.pyx" + __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1133, __pyx_L1_error) + +# line 1133 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_4); + +# line 1133 "core/core2.pyx" + #endif + +# line 1133 "core/core2.pyx" + } else { + +# line 1133 "core/core2.pyx" + if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_1)) break; + +# line 1133 "core/core2.pyx" + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + +# line 1133 "core/core2.pyx" + __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_8); __Pyx_INCREF(__pyx_t_4); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 1133, __pyx_L1_error) + +# line 1133 "core/core2.pyx" + #else + +# line 1133 "core/core2.pyx" + __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1133, __pyx_L1_error) + +# line 1133 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_4); + +# line 1133 "core/core2.pyx" + #endif + +# line 1133 "core/core2.pyx" + } + +# line 1133 "core/core2.pyx" + } else { + +# line 1133 "core/core2.pyx" + __pyx_t_4 = __pyx_t_9(__pyx_t_1); + +# line 1133 "core/core2.pyx" + if (unlikely(!__pyx_t_4)) { + +# line 1133 "core/core2.pyx" + PyObject* exc_type = PyErr_Occurred(); + +# line 1133 "core/core2.pyx" + if (exc_type) { + +# line 1133 "core/core2.pyx" + if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); + +# line 1133 "core/core2.pyx" + else __PYX_ERR(0, 1133, __pyx_L1_error) + +# line 1133 "core/core2.pyx" + } + +# line 1133 "core/core2.pyx" + break; + +# line 1133 "core/core2.pyx" + } + +# line 1133 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_4); + +# line 1133 "core/core2.pyx" + } + +# line 1133 "core/core2.pyx" + __pyx_t_10 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1133, __pyx_L1_error) + +# line 1133 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + +# line 1133 "core/core2.pyx" + __pyx_v_vert_idx = __pyx_t_10; + + /* "core/core2.pyx":1134 + * new_front = [] + * for vert_idx in rings[-1]: + * probe = links[vert_idx] # <<<<<<<<<<<<<< + * for new_idx in probe: + * if new_idx not in seen: + */ + +# line 1134 "core/core2.pyx" + __pyx_t_4 = __Pyx_GetItemInt(((PyObject *)__pyx_v_links), __pyx_v_vert_idx, int, 1, __Pyx_PyInt_From_int, 0, 1, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1134, __pyx_L1_error) + +# line 1134 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_4); + +# line 1134 "core/core2.pyx" + if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_14softwrap_core2_LinkProbe))))) __PYX_ERR(0, 1134, __pyx_L1_error) + +# line 1134 "core/core2.pyx" + __Pyx_XDECREF_SET(__pyx_v_probe, ((struct __pyx_obj_14softwrap_core2_LinkProbe *)__pyx_t_4)); + +# line 1134 "core/core2.pyx" + __pyx_t_4 = 0; + + /* "core/core2.pyx":1135 + * for vert_idx in rings[-1]: + * probe = links[vert_idx] + * for new_idx in probe: # <<<<<<<<<<<<<< + * if new_idx not in seen: + * seen.add(new_idx) + */ + +# line 1135 "core/core2.pyx" + if (likely(PyList_CheckExact(((PyObject *)__pyx_v_probe))) || PyTuple_CheckExact(((PyObject *)__pyx_v_probe))) { + +# line 1135 "core/core2.pyx" + __pyx_t_4 = ((PyObject *)__pyx_v_probe); __Pyx_INCREF(__pyx_t_4); __pyx_t_11 = 0; + +# line 1135 "core/core2.pyx" + __pyx_t_12 = NULL; + +# line 1135 "core/core2.pyx" + } else { + +# line 1135 "core/core2.pyx" + __pyx_t_11 = -1; __pyx_t_4 = PyObject_GetIter(((PyObject *)__pyx_v_probe)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1135, __pyx_L1_error) + +# line 1135 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_4); + +# line 1135 "core/core2.pyx" + __pyx_t_12 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1135, __pyx_L1_error) + +# line 1135 "core/core2.pyx" + } + +# line 1135 "core/core2.pyx" + for (;;) { + +# line 1135 "core/core2.pyx" + if (likely(!__pyx_t_12)) { + +# line 1135 "core/core2.pyx" + if (likely(PyList_CheckExact(__pyx_t_4))) { + +# line 1135 "core/core2.pyx" + if (__pyx_t_11 >= PyList_GET_SIZE(__pyx_t_4)) break; + +# line 1135 "core/core2.pyx" + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + +# line 1135 "core/core2.pyx" + __pyx_t_13 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_11); __Pyx_INCREF(__pyx_t_13); __pyx_t_11++; if (unlikely(0 < 0)) __PYX_ERR(0, 1135, __pyx_L1_error) + +# line 1135 "core/core2.pyx" + #else + +# line 1135 "core/core2.pyx" + __pyx_t_13 = PySequence_ITEM(__pyx_t_4, __pyx_t_11); __pyx_t_11++; if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1135, __pyx_L1_error) + +# line 1135 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_13); + +# line 1135 "core/core2.pyx" + #endif + +# line 1135 "core/core2.pyx" + } else { + +# line 1135 "core/core2.pyx" + if (__pyx_t_11 >= PyTuple_GET_SIZE(__pyx_t_4)) break; + +# line 1135 "core/core2.pyx" + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + +# line 1135 "core/core2.pyx" + __pyx_t_13 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_11); __Pyx_INCREF(__pyx_t_13); __pyx_t_11++; if (unlikely(0 < 0)) __PYX_ERR(0, 1135, __pyx_L1_error) + +# line 1135 "core/core2.pyx" + #else + +# line 1135 "core/core2.pyx" + __pyx_t_13 = PySequence_ITEM(__pyx_t_4, __pyx_t_11); __pyx_t_11++; if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1135, __pyx_L1_error) + +# line 1135 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_13); + +# line 1135 "core/core2.pyx" + #endif + +# line 1135 "core/core2.pyx" + } + +# line 1135 "core/core2.pyx" + } else { + +# line 1135 "core/core2.pyx" + __pyx_t_13 = __pyx_t_12(__pyx_t_4); + +# line 1135 "core/core2.pyx" + if (unlikely(!__pyx_t_13)) { + +# line 1135 "core/core2.pyx" + PyObject* exc_type = PyErr_Occurred(); + +# line 1135 "core/core2.pyx" + if (exc_type) { + +# line 1135 "core/core2.pyx" + if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); + +# line 1135 "core/core2.pyx" + else __PYX_ERR(0, 1135, __pyx_L1_error) + +# line 1135 "core/core2.pyx" + } + +# line 1135 "core/core2.pyx" + break; + +# line 1135 "core/core2.pyx" + } + +# line 1135 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_13); + +# line 1135 "core/core2.pyx" + } + +# line 1135 "core/core2.pyx" + __Pyx_XDECREF_SET(__pyx_v_new_idx, __pyx_t_13); + +# line 1135 "core/core2.pyx" + __pyx_t_13 = 0; + + /* "core/core2.pyx":1136 + * probe = links[vert_idx] + * for new_idx in probe: + * if new_idx not in seen: # <<<<<<<<<<<<<< + * seen.add(new_idx) + * new_front.append(new_idx) + */ + +# line 1136 "core/core2.pyx" + __pyx_t_2 = (__Pyx_PySet_ContainsTF(__pyx_v_new_idx, __pyx_v_seen, Py_NE)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1136, __pyx_L1_error) + +# line 1136 "core/core2.pyx" + __pyx_t_3 = (__pyx_t_2 != 0); + +# line 1136 "core/core2.pyx" + if (__pyx_t_3) { + + /* "core/core2.pyx":1137 + * for new_idx in probe: + * if new_idx not in seen: + * seen.add(new_idx) # <<<<<<<<<<<<<< + * new_front.append(new_idx) + * rings.append(new_front) + */ + +# line 1137 "core/core2.pyx" + __pyx_t_14 = PySet_Add(__pyx_v_seen, __pyx_v_new_idx); if (unlikely(__pyx_t_14 == ((int)-1))) __PYX_ERR(0, 1137, __pyx_L1_error) + + /* "core/core2.pyx":1138 + * if new_idx not in seen: + * seen.add(new_idx) + * new_front.append(new_idx) # <<<<<<<<<<<<<< + * rings.append(new_front) + * + */ + +# line 1138 "core/core2.pyx" + __pyx_t_14 = __Pyx_PyList_Append(__pyx_v_new_front, __pyx_v_new_idx); if (unlikely(__pyx_t_14 == ((int)-1))) __PYX_ERR(0, 1138, __pyx_L1_error) + + /* "core/core2.pyx":1136 + * probe = links[vert_idx] + * for new_idx in probe: + * if new_idx not in seen: # <<<<<<<<<<<<<< + * seen.add(new_idx) + * new_front.append(new_idx) + */ + +# line 1136 "core/core2.pyx" + } + + /* "core/core2.pyx":1135 + * for vert_idx in rings[-1]: + * probe = links[vert_idx] + * for new_idx in probe: # <<<<<<<<<<<<<< + * if new_idx not in seen: + * seen.add(new_idx) + */ + +# line 1135 "core/core2.pyx" + } + +# line 1135 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + + /* "core/core2.pyx":1133 + * for i in range(n_rings - 1): + * new_front = [] + * for vert_idx in rings[-1]: # <<<<<<<<<<<<<< + * probe = links[vert_idx] + * for new_idx in probe: + */ + +# line 1133 "core/core2.pyx" + } + +# line 1133 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "core/core2.pyx":1139 + * seen.add(new_idx) + * new_front.append(new_idx) + * rings.append(new_front) # <<<<<<<<<<<<<< + * + * self.n_rings = n_rings + */ + +# line 1139 "core/core2.pyx" + __pyx_t_14 = __Pyx_PyList_Append(__pyx_v_rings, __pyx_v_new_front); if (unlikely(__pyx_t_14 == ((int)-1))) __PYX_ERR(0, 1139, __pyx_L1_error) + +# line 1139 "core/core2.pyx" + } + + /* "core/core2.pyx":1141 + * rings.append(new_front) + * + * self.n_rings = n_rings # <<<<<<<<<<<<<< + * self.rings = maelloc(sizeof(int**) * self.n_rings, __LINE__) + * + */ + +# line 1141 "core/core2.pyx" + __pyx_v_self->n_rings = __pyx_v_n_rings; + + /* "core/core2.pyx":1142 + * + * self.n_rings = n_rings + * self.rings = maelloc(sizeof(int**) * self.n_rings, __LINE__) # <<<<<<<<<<<<<< + * + * for i in range(self.n_rings): + */ + +# line 1142 "core/core2.pyx" + __pyx_t_15 = __pyx_f_14softwrap_core2_maelloc(((sizeof(int **)) * __pyx_v_self->n_rings), __LINE__); if (unlikely(__pyx_t_15 == ((void *)NULL))) __PYX_ERR(0, 1142, __pyx_L1_error) + +# line 1142 "core/core2.pyx" + __pyx_v_self->rings = ((int **)__pyx_t_15); + + /* "core/core2.pyx":1144 + * self.rings = maelloc(sizeof(int**) * self.n_rings, __LINE__) + * + * for i in range(self.n_rings): # <<<<<<<<<<<<<< + * self.rings[i] = NULL + * + */ + +# line 1144 "core/core2.pyx" + __pyx_t_7 = __pyx_v_self->n_rings; + +# line 1144 "core/core2.pyx" + __pyx_t_10 = __pyx_t_7; + +# line 1144 "core/core2.pyx" + for (__pyx_t_16 = 0; __pyx_t_16 < __pyx_t_10; __pyx_t_16+=1) { + +# line 1144 "core/core2.pyx" + __pyx_v_i = __pyx_t_16; + + /* "core/core2.pyx":1145 + * + * for i in range(self.n_rings): + * self.rings[i] = NULL # <<<<<<<<<<<<<< + * + * cdef list front + */ + +# line 1145 "core/core2.pyx" + (__pyx_v_self->rings[__pyx_v_i]) = NULL; + +# line 1145 "core/core2.pyx" + } + + /* "core/core2.pyx":1150 + * cdef int j + * + * for i, front in enumerate(rings): # <<<<<<<<<<<<<< + * self.rings[i] = maelloc(sizeof(int*) * (len(front) + 1), __LINE__) + * self.rings[i][0] = len(front) + */ + +# line 1150 "core/core2.pyx" + __pyx_t_7 = 0; + +# line 1150 "core/core2.pyx" + __pyx_t_1 = __pyx_v_rings; __Pyx_INCREF(__pyx_t_1); __pyx_t_8 = 0; + +# line 1150 "core/core2.pyx" + for (;;) { + +# line 1150 "core/core2.pyx" + if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_1)) break; + +# line 1150 "core/core2.pyx" + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + +# line 1150 "core/core2.pyx" + __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_8); __Pyx_INCREF(__pyx_t_4); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 1150, __pyx_L1_error) + +# line 1150 "core/core2.pyx" + #else + +# line 1150 "core/core2.pyx" + __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1150, __pyx_L1_error) + +# line 1150 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_4); + +# line 1150 "core/core2.pyx" + #endif + +# line 1150 "core/core2.pyx" + if (!(likely(PyList_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_4)->tp_name), 0))) __PYX_ERR(0, 1150, __pyx_L1_error) + +# line 1150 "core/core2.pyx" + __Pyx_XDECREF_SET(__pyx_v_front, ((PyObject*)__pyx_t_4)); + +# line 1150 "core/core2.pyx" + __pyx_t_4 = 0; + +# line 1150 "core/core2.pyx" + __pyx_v_i = __pyx_t_7; + +# line 1150 "core/core2.pyx" + __pyx_t_7 = (__pyx_t_7 + 1); + + /* "core/core2.pyx":1151 + * + * for i, front in enumerate(rings): + * self.rings[i] = maelloc(sizeof(int*) * (len(front) + 1), __LINE__) # <<<<<<<<<<<<<< + * self.rings[i][0] = len(front) + * + */ + +# line 1151 "core/core2.pyx" + if (unlikely(__pyx_v_front == Py_None)) { + +# line 1151 "core/core2.pyx" + PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); + +# line 1151 "core/core2.pyx" + __PYX_ERR(0, 1151, __pyx_L1_error) + +# line 1151 "core/core2.pyx" + } + +# line 1151 "core/core2.pyx" + __pyx_t_11 = PyList_GET_SIZE(__pyx_v_front); if (unlikely(__pyx_t_11 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1151, __pyx_L1_error) + +# line 1151 "core/core2.pyx" + __pyx_t_15 = __pyx_f_14softwrap_core2_maelloc(((sizeof(int *)) * (__pyx_t_11 + 1)), __LINE__); if (unlikely(__pyx_t_15 == ((void *)NULL))) __PYX_ERR(0, 1151, __pyx_L1_error) + +# line 1151 "core/core2.pyx" + (__pyx_v_self->rings[__pyx_v_i]) = ((int *)__pyx_t_15); + + /* "core/core2.pyx":1152 + * for i, front in enumerate(rings): + * self.rings[i] = maelloc(sizeof(int*) * (len(front) + 1), __LINE__) + * self.rings[i][0] = len(front) # <<<<<<<<<<<<<< + * + * for j in range(self.rings[i][0]): + */ + +# line 1152 "core/core2.pyx" + if (unlikely(__pyx_v_front == Py_None)) { + +# line 1152 "core/core2.pyx" + PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); + +# line 1152 "core/core2.pyx" + __PYX_ERR(0, 1152, __pyx_L1_error) + +# line 1152 "core/core2.pyx" + } + +# line 1152 "core/core2.pyx" + __pyx_t_11 = PyList_GET_SIZE(__pyx_v_front); if (unlikely(__pyx_t_11 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1152, __pyx_L1_error) + +# line 1152 "core/core2.pyx" + ((__pyx_v_self->rings[__pyx_v_i])[0]) = __pyx_t_11; + + /* "core/core2.pyx":1154 + * self.rings[i][0] = len(front) + * + * for j in range(self.rings[i][0]): # <<<<<<<<<<<<<< + * self.rings[i][j + 1] = front[j] + * + */ + +# line 1154 "core/core2.pyx" + __pyx_t_10 = ((__pyx_v_self->rings[__pyx_v_i])[0]); + +# line 1154 "core/core2.pyx" + __pyx_t_16 = __pyx_t_10; + +# line 1154 "core/core2.pyx" + for (__pyx_t_17 = 0; __pyx_t_17 < __pyx_t_16; __pyx_t_17+=1) { + +# line 1154 "core/core2.pyx" + __pyx_v_j = __pyx_t_17; + + /* "core/core2.pyx":1155 + * + * for j in range(self.rings[i][0]): + * self.rings[i][j + 1] = front[j] # <<<<<<<<<<<<<< + * + * def __getitem__(self, int index): + */ + +# line 1155 "core/core2.pyx" + if (unlikely(__pyx_v_front == Py_None)) { + +# line 1155 "core/core2.pyx" + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + +# line 1155 "core/core2.pyx" + __PYX_ERR(0, 1155, __pyx_L1_error) + +# line 1155 "core/core2.pyx" + } + +# line 1155 "core/core2.pyx" + __pyx_t_4 = __Pyx_GetItemInt_List(__pyx_v_front, __pyx_v_j, int, 1, __Pyx_PyInt_From_int, 1, 1, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1155, __pyx_L1_error) + +# line 1155 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_4); + +# line 1155 "core/core2.pyx" + __pyx_t_18 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_18 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1155, __pyx_L1_error) + +# line 1155 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + +# line 1155 "core/core2.pyx" + ((__pyx_v_self->rings[__pyx_v_i])[(__pyx_v_j + 1)]) = __pyx_t_18; + +# line 1155 "core/core2.pyx" + } + + /* "core/core2.pyx":1150 + * cdef int j + * + * for i, front in enumerate(rings): # <<<<<<<<<<<<<< + * self.rings[i] = maelloc(sizeof(int*) * (len(front) + 1), __LINE__) + * self.rings[i][0] = len(front) + */ + +# line 1150 "core/core2.pyx" + } + +# line 1150 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "core/core2.pyx":1115 + * + * + * def __cinit__(self, SpringLinks links, int start_index, int n_rings): # <<<<<<<<<<<<<< + * n_rings = nmax(n_rings, 1) + * self.engine = links.engine + */ + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_13); + __Pyx_AddTraceback("softwrap_core2.SpringEnginePin.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_rings); + __Pyx_XDECREF(__pyx_v_seen); + __Pyx_XDECREF(__pyx_v_new_front); + __Pyx_XDECREF((PyObject *)__pyx_v_probe); + __Pyx_XDECREF(__pyx_v_new_idx); + __Pyx_XDECREF(__pyx_v_front); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":1157 + * self.rings[i][j + 1] = front[j] + * + * def __getitem__(self, int index): # <<<<<<<<<<<<<< + * if index < 0 or index >= self.n_rings: + * raise IndexError + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_15SpringEnginePin_3__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_index); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_15SpringEnginePin_3__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_index) { + int __pyx_v_index; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0); + assert(__pyx_arg_index); { + __pyx_v_index = __Pyx_PyInt_As_int(__pyx_arg_index); if (unlikely((__pyx_v_index == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1157, __pyx_L3_error) + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("softwrap_core2.SpringEnginePin.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_14softwrap_core2_15SpringEnginePin_2__getitem__(((struct __pyx_obj_14softwrap_core2_SpringEnginePin *)__pyx_v_self), ((int)__pyx_v_index)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} +static PyObject *__pyx_gb_14softwrap_core2_15SpringEnginePin_11__getitem___2generator2(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */ + +/* "core/core2.pyx":1161 + * raise IndexError + * + * def iter_ring(): # <<<<<<<<<<<<<< + * cdef int i + * for i in range(self.rings[index][0]): + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_15SpringEnginePin_11__getitem___1iter_ring(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyMethodDef __pyx_mdef_14softwrap_core2_15SpringEnginePin_11__getitem___1iter_ring = {"iter_ring", (PyCFunction)__pyx_pw_14softwrap_core2_15SpringEnginePin_11__getitem___1iter_ring, METH_NOARGS, 0}; +static PyObject *__pyx_pw_14softwrap_core2_15SpringEnginePin_11__getitem___1iter_ring(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("iter_ring (wrapper)", 0); + __pyx_r = __pyx_pf_14softwrap_core2_15SpringEnginePin_11__getitem___iter_ring(__pyx_self); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_15SpringEnginePin_11__getitem___iter_ring(PyObject *__pyx_self) { + struct __pyx_obj_14softwrap_core2___pyx_scope_struct_2_iter_ring *__pyx_cur_scope; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("iter_ring", 0); + __pyx_cur_scope = (struct __pyx_obj_14softwrap_core2___pyx_scope_struct_2_iter_ring *)__pyx_tp_new_14softwrap_core2___pyx_scope_struct_2_iter_ring(__pyx_ptype_14softwrap_core2___pyx_scope_struct_2_iter_ring, __pyx_empty_tuple, NULL); + if (unlikely(!__pyx_cur_scope)) { + __pyx_cur_scope = ((struct __pyx_obj_14softwrap_core2___pyx_scope_struct_2_iter_ring *)Py_None); + __Pyx_INCREF(Py_None); + __PYX_ERR(0, 1161, __pyx_L1_error) + } else { + __Pyx_GOTREF(__pyx_cur_scope); + } + __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_14softwrap_core2___pyx_scope_struct_1___getitem__ *) __Pyx_CyFunction_GetClosure(__pyx_self); + __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_outer_scope)); + __Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope); + { + __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_14softwrap_core2_15SpringEnginePin_11__getitem___2generator2, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_iter_ring, __pyx_n_s_getitem___locals_iter_ring, __pyx_n_s_softwrap_core2); if (unlikely(!gen)) __PYX_ERR(0, 1161, __pyx_L1_error) + __Pyx_DECREF(__pyx_cur_scope); + __Pyx_RefNannyFinishContext(); + return (PyObject *) gen; + } + + /* function exit code */ + __pyx_L1_error:; + __Pyx_AddTraceback("softwrap_core2.SpringEnginePin.__getitem__.iter_ring", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __Pyx_DECREF(((PyObject *)__pyx_cur_scope)); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_gb_14softwrap_core2_15SpringEnginePin_11__getitem___2generator2(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */ +{ + struct __pyx_obj_14softwrap_core2___pyx_scope_struct_2_iter_ring *__pyx_cur_scope = ((struct __pyx_obj_14softwrap_core2___pyx_scope_struct_2_iter_ring *)__pyx_generator->closure); + PyObject *__pyx_r = NULL; + int __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + PyObject *__pyx_t_4 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("iter_ring", 0); + switch (__pyx_generator->resume_label) { + case 0: goto __pyx_L3_first_run; + case 1: goto __pyx_L6_resume_from_yield; + default: /* CPython raises the right error here */ + __Pyx_RefNannyFinishContext(); + return NULL; + } + __pyx_L3_first_run:; + if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1161, __pyx_L1_error) + + /* "core/core2.pyx":1163 + * def iter_ring(): + * cdef int i + * for i in range(self.rings[index][0]): # <<<<<<<<<<<<<< + * yield self.rings[index][i + 1] + * + */ + +# line 1163 "core/core2.pyx" + if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1163, __pyx_L1_error) } + +# line 1163 "core/core2.pyx" + __pyx_t_1 = ((__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self->rings[__pyx_cur_scope->__pyx_outer_scope->__pyx_v_index])[0]); + +# line 1163 "core/core2.pyx" + __pyx_t_2 = __pyx_t_1; + +# line 1163 "core/core2.pyx" + for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) { + +# line 1163 "core/core2.pyx" + __pyx_cur_scope->__pyx_v_i = __pyx_t_3; + + /* "core/core2.pyx":1164 + * cdef int i + * for i in range(self.rings[index][0]): + * yield self.rings[index][i + 1] # <<<<<<<<<<<<<< + * + * return iter_ring() + */ + +# line 1164 "core/core2.pyx" + if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1164, __pyx_L1_error) } + +# line 1164 "core/core2.pyx" + __pyx_t_4 = __Pyx_PyInt_From_int(((__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self->rings[__pyx_cur_scope->__pyx_outer_scope->__pyx_v_index])[(__pyx_cur_scope->__pyx_v_i + 1)])); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1164, __pyx_L1_error) + +# line 1164 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_4); + +# line 1164 "core/core2.pyx" + __pyx_r = __pyx_t_4; + +# line 1164 "core/core2.pyx" + __pyx_t_4 = 0; + +# line 1164 "core/core2.pyx" + __pyx_cur_scope->__pyx_t_0 = __pyx_t_1; + +# line 1164 "core/core2.pyx" + __pyx_cur_scope->__pyx_t_1 = __pyx_t_2; + +# line 1164 "core/core2.pyx" + __pyx_cur_scope->__pyx_t_2 = __pyx_t_3; + +# line 1164 "core/core2.pyx" + __Pyx_XGIVEREF(__pyx_r); + +# line 1164 "core/core2.pyx" + __Pyx_RefNannyFinishContext(); + +# line 1164 "core/core2.pyx" + __Pyx_Coroutine_ResetAndClearException(__pyx_generator); + /* return from generator, yielding value */ + __pyx_generator->resume_label = 1; + return __pyx_r; + __pyx_L6_resume_from_yield:; + __pyx_t_1 = __pyx_cur_scope->__pyx_t_0; + __pyx_t_2 = __pyx_cur_scope->__pyx_t_1; + __pyx_t_3 = __pyx_cur_scope->__pyx_t_2; + if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1164, __pyx_L1_error) + } + CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope); + + /* "core/core2.pyx":1161 + * raise IndexError + * + * def iter_ring(): # <<<<<<<<<<<<<< + * cdef int i + * for i in range(self.rings[index][0]): + */ + + /* function exit code */ + PyErr_SetNone(PyExc_StopIteration); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("iter_ring", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_L0:; + __Pyx_XDECREF(__pyx_r); __pyx_r = 0; + #if !CYTHON_USE_EXC_INFO_STACK + __Pyx_Coroutine_ResetAndClearException(__pyx_generator); + #endif + __pyx_generator->resume_label = -1; + __Pyx_Coroutine_clear((PyObject*)__pyx_generator); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":1157 + * self.rings[i][j + 1] = front[j] + * + * def __getitem__(self, int index): # <<<<<<<<<<<<<< + * if index < 0 or index >= self.n_rings: + * raise IndexError + */ + + +# line 1157 "core/core2.pyx" +static PyObject *__pyx_pf_14softwrap_core2_15SpringEnginePin_2__getitem__(struct __pyx_obj_14softwrap_core2_SpringEnginePin *__pyx_v_self, int __pyx_v_index) { + +# line 1157 "core/core2.pyx" + struct __pyx_obj_14softwrap_core2___pyx_scope_struct_1___getitem__ *__pyx_cur_scope; + +# line 1157 "core/core2.pyx" + PyObject *__pyx_v_iter_ring = 0; + +# line 1157 "core/core2.pyx" + PyObject *__pyx_gb_14softwrap_core2_15SpringEnginePin_11__getitem___2generator2 = 0; + +# line 1157 "core/core2.pyx" + PyObject *__pyx_r = NULL; + +# line 1157 "core/core2.pyx" + __Pyx_RefNannyDeclarations + +# line 1157 "core/core2.pyx" + int __pyx_t_1; + +# line 1157 "core/core2.pyx" + int __pyx_t_2; + +# line 1157 "core/core2.pyx" + PyObject *__pyx_t_3 = NULL; + +# line 1157 "core/core2.pyx" + int __pyx_lineno = 0; + +# line 1157 "core/core2.pyx" + const char *__pyx_filename = NULL; + +# line 1157 "core/core2.pyx" + int __pyx_clineno = 0; + +# line 1157 "core/core2.pyx" + __Pyx_RefNannySetupContext("__getitem__", 0); + +# line 1157 "core/core2.pyx" + __pyx_cur_scope = (struct __pyx_obj_14softwrap_core2___pyx_scope_struct_1___getitem__ *)__pyx_tp_new_14softwrap_core2___pyx_scope_struct_1___getitem__(__pyx_ptype_14softwrap_core2___pyx_scope_struct_1___getitem__, __pyx_empty_tuple, NULL); + +# line 1157 "core/core2.pyx" + if (unlikely(!__pyx_cur_scope)) { + +# line 1157 "core/core2.pyx" + __pyx_cur_scope = ((struct __pyx_obj_14softwrap_core2___pyx_scope_struct_1___getitem__ *)Py_None); + +# line 1157 "core/core2.pyx" + __Pyx_INCREF(Py_None); + +# line 1157 "core/core2.pyx" + __PYX_ERR(0, 1157, __pyx_L1_error) + +# line 1157 "core/core2.pyx" + } else { + +# line 1157 "core/core2.pyx" + __Pyx_GOTREF(__pyx_cur_scope); + +# line 1157 "core/core2.pyx" + } + +# line 1157 "core/core2.pyx" + __pyx_cur_scope->__pyx_v_self = __pyx_v_self; + +# line 1157 "core/core2.pyx" + __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self); + +# line 1157 "core/core2.pyx" + __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self); + +# line 1157 "core/core2.pyx" + __pyx_cur_scope->__pyx_v_index = __pyx_v_index; + + /* "core/core2.pyx":1158 + * + * def __getitem__(self, int index): + * if index < 0 or index >= self.n_rings: # <<<<<<<<<<<<<< + * raise IndexError + * + */ + +# line 1158 "core/core2.pyx" + __pyx_t_2 = ((__pyx_cur_scope->__pyx_v_index < 0) != 0); + +# line 1158 "core/core2.pyx" + if (!__pyx_t_2) { + +# line 1158 "core/core2.pyx" + } else { + +# line 1158 "core/core2.pyx" + __pyx_t_1 = __pyx_t_2; + +# line 1158 "core/core2.pyx" + goto __pyx_L4_bool_binop_done; + +# line 1158 "core/core2.pyx" + } + +# line 1158 "core/core2.pyx" + __pyx_t_2 = ((__pyx_cur_scope->__pyx_v_index >= __pyx_cur_scope->__pyx_v_self->n_rings) != 0); + +# line 1158 "core/core2.pyx" + __pyx_t_1 = __pyx_t_2; + +# line 1158 "core/core2.pyx" + __pyx_L4_bool_binop_done:; + +# line 1158 "core/core2.pyx" + if (unlikely(__pyx_t_1)) { + + /* "core/core2.pyx":1159 + * def __getitem__(self, int index): + * if index < 0 or index >= self.n_rings: + * raise IndexError # <<<<<<<<<<<<<< + * + * def iter_ring(): + */ + +# line 1159 "core/core2.pyx" + __Pyx_Raise(__pyx_builtin_IndexError, 0, 0, 0); + +# line 1159 "core/core2.pyx" + __PYX_ERR(0, 1159, __pyx_L1_error) + + /* "core/core2.pyx":1158 + * + * def __getitem__(self, int index): + * if index < 0 or index >= self.n_rings: # <<<<<<<<<<<<<< + * raise IndexError + * + */ + +# line 1158 "core/core2.pyx" + } + + /* "core/core2.pyx":1161 + * raise IndexError + * + * def iter_ring(): # <<<<<<<<<<<<<< + * cdef int i + * for i in range(self.rings[index][0]): + */ + +# line 1161 "core/core2.pyx" + __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_14softwrap_core2_15SpringEnginePin_11__getitem___1iter_ring, 0, __pyx_n_s_getitem___locals_iter_ring, ((PyObject*)__pyx_cur_scope), __pyx_n_s_softwrap_core2, __pyx_d, ((PyObject *)__pyx_codeobj__19)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1161, __pyx_L1_error) + +# line 1161 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_3); + +# line 1161 "core/core2.pyx" + __pyx_v_iter_ring = __pyx_t_3; + +# line 1161 "core/core2.pyx" + __pyx_t_3 = 0; + + /* "core/core2.pyx":1166 + * yield self.rings[index][i + 1] + * + * return iter_ring() # <<<<<<<<<<<<<< + * + * def __iter__(self): + */ + +# line 1166 "core/core2.pyx" + __Pyx_XDECREF(__pyx_r); + +# line 1166 "core/core2.pyx" + __pyx_t_3 = __pyx_pf_14softwrap_core2_15SpringEnginePin_11__getitem___iter_ring(__pyx_v_iter_ring); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1166, __pyx_L1_error) + +# line 1166 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_3); + +# line 1166 "core/core2.pyx" + __pyx_r = __pyx_t_3; + +# line 1166 "core/core2.pyx" + __pyx_t_3 = 0; + +# line 1166 "core/core2.pyx" + goto __pyx_L0; + + /* "core/core2.pyx":1157 + * self.rings[i][j + 1] = front[j] + * + * def __getitem__(self, int index): # <<<<<<<<<<<<<< + * if index < 0 or index >= self.n_rings: + * raise IndexError + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("softwrap_core2.SpringEnginePin.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_iter_ring); + __Pyx_XDECREF(__pyx_gb_14softwrap_core2_15SpringEnginePin_11__getitem___2generator2); + __Pyx_DECREF(((PyObject *)__pyx_cur_scope)); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} +static PyObject *__pyx_gb_14softwrap_core2_15SpringEnginePin_6generator1(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */ + +/* "core/core2.pyx":1168 + * return iter_ring() + * + * def __iter__(self): # <<<<<<<<<<<<<< + * cdef int i + * for i in range(self.n_rings): + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_15SpringEnginePin_5__iter__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_15SpringEnginePin_5__iter__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0); + __pyx_r = __pyx_pf_14softwrap_core2_15SpringEnginePin_4__iter__(((struct __pyx_obj_14softwrap_core2_SpringEnginePin *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_15SpringEnginePin_4__iter__(struct __pyx_obj_14softwrap_core2_SpringEnginePin *__pyx_v_self) { + struct __pyx_obj_14softwrap_core2___pyx_scope_struct_3___iter__ *__pyx_cur_scope; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__iter__", 0); + __pyx_cur_scope = (struct __pyx_obj_14softwrap_core2___pyx_scope_struct_3___iter__ *)__pyx_tp_new_14softwrap_core2___pyx_scope_struct_3___iter__(__pyx_ptype_14softwrap_core2___pyx_scope_struct_3___iter__, __pyx_empty_tuple, NULL); + if (unlikely(!__pyx_cur_scope)) { + __pyx_cur_scope = ((struct __pyx_obj_14softwrap_core2___pyx_scope_struct_3___iter__ *)Py_None); + __Pyx_INCREF(Py_None); + __PYX_ERR(0, 1168, __pyx_L1_error) + } else { + __Pyx_GOTREF(__pyx_cur_scope); + } + __pyx_cur_scope->__pyx_v_self = __pyx_v_self; + __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self); + __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self); + { + __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_14softwrap_core2_15SpringEnginePin_6generator1, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_iter, __pyx_n_s_SpringEnginePin___iter, __pyx_n_s_softwrap_core2); if (unlikely(!gen)) __PYX_ERR(0, 1168, __pyx_L1_error) + __Pyx_DECREF(__pyx_cur_scope); + __Pyx_RefNannyFinishContext(); + return (PyObject *) gen; + } + + /* function exit code */ + __pyx_L1_error:; + __Pyx_AddTraceback("softwrap_core2.SpringEnginePin.__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __Pyx_DECREF(((PyObject *)__pyx_cur_scope)); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_gb_14softwrap_core2_15SpringEnginePin_6generator1(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */ +{ + struct __pyx_obj_14softwrap_core2___pyx_scope_struct_3___iter__ *__pyx_cur_scope = ((struct __pyx_obj_14softwrap_core2___pyx_scope_struct_3___iter__ *)__pyx_generator->closure); + PyObject *__pyx_r = NULL; + int __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + PyObject *__pyx_t_4 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__iter__", 0); + switch (__pyx_generator->resume_label) { + case 0: goto __pyx_L3_first_run; + case 1: goto __pyx_L6_resume_from_yield; + default: /* CPython raises the right error here */ + __Pyx_RefNannyFinishContext(); + return NULL; + } + __pyx_L3_first_run:; + if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1168, __pyx_L1_error) + + /* "core/core2.pyx":1170 + * def __iter__(self): + * cdef int i + * for i in range(self.n_rings): # <<<<<<<<<<<<<< + * yield self[i] + * + */ + +# line 1170 "core/core2.pyx" + __pyx_t_1 = __pyx_cur_scope->__pyx_v_self->n_rings; + +# line 1170 "core/core2.pyx" + __pyx_t_2 = __pyx_t_1; + +# line 1170 "core/core2.pyx" + for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) { + +# line 1170 "core/core2.pyx" + __pyx_cur_scope->__pyx_v_i = __pyx_t_3; + + /* "core/core2.pyx":1171 + * cdef int i + * for i in range(self.n_rings): + * yield self[i] # <<<<<<<<<<<<<< + * + * def move(self, float x, float y, float z, float scale): + */ + +# line 1171 "core/core2.pyx" + __pyx_t_4 = __Pyx_GetItemInt(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_cur_scope->__pyx_v_i, int, 1, __Pyx_PyInt_From_int, 0, 1, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1171, __pyx_L1_error) + +# line 1171 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_4); + +# line 1171 "core/core2.pyx" + __pyx_r = __pyx_t_4; + +# line 1171 "core/core2.pyx" + __pyx_t_4 = 0; + +# line 1171 "core/core2.pyx" + __pyx_cur_scope->__pyx_t_0 = __pyx_t_1; + +# line 1171 "core/core2.pyx" + __pyx_cur_scope->__pyx_t_1 = __pyx_t_2; + +# line 1171 "core/core2.pyx" + __pyx_cur_scope->__pyx_t_2 = __pyx_t_3; + +# line 1171 "core/core2.pyx" + __Pyx_XGIVEREF(__pyx_r); + +# line 1171 "core/core2.pyx" + __Pyx_RefNannyFinishContext(); + +# line 1171 "core/core2.pyx" + __Pyx_Coroutine_ResetAndClearException(__pyx_generator); + /* return from generator, yielding value */ + __pyx_generator->resume_label = 1; + return __pyx_r; + __pyx_L6_resume_from_yield:; + __pyx_t_1 = __pyx_cur_scope->__pyx_t_0; + __pyx_t_2 = __pyx_cur_scope->__pyx_t_1; + __pyx_t_3 = __pyx_cur_scope->__pyx_t_2; + if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1171, __pyx_L1_error) + } + CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope); + + /* "core/core2.pyx":1168 + * return iter_ring() + * + * def __iter__(self): # <<<<<<<<<<<<<< + * cdef int i + * for i in range(self.n_rings): + */ + + /* function exit code */ + PyErr_SetNone(PyExc_StopIteration); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_L0:; + __Pyx_XDECREF(__pyx_r); __pyx_r = 0; + #if !CYTHON_USE_EXC_INFO_STACK + __Pyx_Coroutine_ResetAndClearException(__pyx_generator); + #endif + __pyx_generator->resume_label = -1; + __Pyx_Coroutine_clear((PyObject*)__pyx_generator); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":1173 + * yield self[i] + * + * def move(self, float x, float y, float z, float scale): # <<<<<<<<<<<<<< + * cdef vec3 vec = vec3(x, y, z) + * cdef vec3 ring_vec + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_15SpringEnginePin_8move(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_15SpringEnginePin_8move(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + float __pyx_v_x; + float __pyx_v_y; + float __pyx_v_z; + float __pyx_v_scale; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("move (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,&__pyx_n_s_y,&__pyx_n_s_z,&__pyx_n_s_scale,0}; + PyObject* values[4] = {0,0,0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + CYTHON_FALLTHROUGH; + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + CYTHON_FALLTHROUGH; + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + CYTHON_FALLTHROUGH; + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + CYTHON_FALLTHROUGH; + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + CYTHON_FALLTHROUGH; + case 1: + if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_y)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("move", 1, 4, 4, 1); __PYX_ERR(0, 1173, __pyx_L3_error) + } + CYTHON_FALLTHROUGH; + case 2: + if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_z)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("move", 1, 4, 4, 2); __PYX_ERR(0, 1173, __pyx_L3_error) + } + CYTHON_FALLTHROUGH; + case 3: + if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_scale)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("move", 1, 4, 4, 3); __PYX_ERR(0, 1173, __pyx_L3_error) + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "move") < 0)) __PYX_ERR(0, 1173, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 4) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + } + __pyx_v_x = __pyx_PyFloat_AsFloat(values[0]); if (unlikely((__pyx_v_x == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 1173, __pyx_L3_error) + __pyx_v_y = __pyx_PyFloat_AsFloat(values[1]); if (unlikely((__pyx_v_y == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 1173, __pyx_L3_error) + __pyx_v_z = __pyx_PyFloat_AsFloat(values[2]); if (unlikely((__pyx_v_z == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 1173, __pyx_L3_error) + __pyx_v_scale = __pyx_PyFloat_AsFloat(values[3]); if (unlikely((__pyx_v_scale == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 1173, __pyx_L3_error) + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("move", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1173, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("softwrap_core2.SpringEnginePin.move", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_14softwrap_core2_15SpringEnginePin_7move(((struct __pyx_obj_14softwrap_core2_SpringEnginePin *)__pyx_v_self), __pyx_v_x, __pyx_v_y, __pyx_v_z, __pyx_v_scale); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_15SpringEnginePin_7move(struct __pyx_obj_14softwrap_core2_SpringEnginePin *__pyx_v_self, float __pyx_v_x, float __pyx_v_y, float __pyx_v_z, float __pyx_v_scale) { + vec3 __pyx_v_vec; + vec3 __pyx_v_ring_vec; + int __pyx_v_i; + int __pyx_v_j; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + int __pyx_t_4; + int __pyx_t_5; + int __pyx_t_6; + __Pyx_RefNannySetupContext("move", 0); + + /* "core/core2.pyx":1174 + * + * def move(self, float x, float y, float z, float scale): + * cdef vec3 vec = vec3(x, y, z) # <<<<<<<<<<<<<< + * cdef vec3 ring_vec + * + */ + +# line 1174 "core/core2.pyx" + __pyx_v_vec = vec3(__pyx_v_x, __pyx_v_y, __pyx_v_z); + + /* "core/core2.pyx":1178 + * + * cdef int i, j + * for i in range(self.n_rings): # <<<<<<<<<<<<<< + * ring_vec = vec * nclamp((scale - i - 1) / (scale - 1), 0, 1) + * for j in range(self.rings[i][0]): + */ + +# line 1178 "core/core2.pyx" + __pyx_t_1 = __pyx_v_self->n_rings; + +# line 1178 "core/core2.pyx" + __pyx_t_2 = __pyx_t_1; + +# line 1178 "core/core2.pyx" + for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) { + +# line 1178 "core/core2.pyx" + __pyx_v_i = __pyx_t_3; + + /* "core/core2.pyx":1179 + * cdef int i, j + * for i in range(self.n_rings): + * ring_vec = vec * nclamp((scale - i - 1) / (scale - 1), 0, 1) # <<<<<<<<<<<<<< + * for j in range(self.rings[i][0]): + * self.engine.m.verts[self.rings[i][j + 1]] += ring_vec + */ + +# line 1179 "core/core2.pyx" + __pyx_v_ring_vec = (__pyx_v_vec * nclamp((((__pyx_v_scale - __pyx_v_i) - ((float)1)) / (__pyx_v_scale - ((float)1))), ((float)0), ((float)1))); + + /* "core/core2.pyx":1180 + * for i in range(self.n_rings): + * ring_vec = vec * nclamp((scale - i - 1) / (scale - 1), 0, 1) + * for j in range(self.rings[i][0]): # <<<<<<<<<<<<<< + * self.engine.m.verts[self.rings[i][j + 1]] += ring_vec + * # self.engine.prev_verts[self.rings[i][j + 1]] += ring_vec + */ + +# line 1180 "core/core2.pyx" + __pyx_t_4 = ((__pyx_v_self->rings[__pyx_v_i])[0]); + +# line 1180 "core/core2.pyx" + __pyx_t_5 = __pyx_t_4; + +# line 1180 "core/core2.pyx" + for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) { + +# line 1180 "core/core2.pyx" + __pyx_v_j = __pyx_t_6; + + /* "core/core2.pyx":1181 + * ring_vec = vec * nclamp((scale - i - 1) / (scale - 1), 0, 1) + * for j in range(self.rings[i][0]): + * self.engine.m.verts[self.rings[i][j + 1]] += ring_vec # <<<<<<<<<<<<<< + * # self.engine.prev_verts[self.rings[i][j + 1]] += ring_vec + * + */ + +# line 1181 "core/core2.pyx" + (__pyx_v_self->engine->m->verts[((__pyx_v_self->rings[__pyx_v_i])[(__pyx_v_j + 1)])]) += __pyx_v_ring_vec; + +# line 1181 "core/core2.pyx" + } + +# line 1181 "core/core2.pyx" + } + + /* "core/core2.pyx":1173 + * yield self[i] + * + * def move(self, float x, float y, float z, float scale): # <<<<<<<<<<<<<< + * cdef vec3 vec = vec3(x, y, z) + * cdef vec3 ring_vec + */ + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":1185 + * + * + * def __dealloc__(self): # <<<<<<<<<<<<<< + * cdef int i + * for i in range(self.n_rings): + */ + +/* Python wrapper */ +static void __pyx_pw_14softwrap_core2_15SpringEnginePin_10__dealloc__(PyObject *__pyx_v_self); /*proto*/ +static void __pyx_pw_14softwrap_core2_15SpringEnginePin_10__dealloc__(PyObject *__pyx_v_self) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0); + __pyx_pf_14softwrap_core2_15SpringEnginePin_9__dealloc__(((struct __pyx_obj_14softwrap_core2_SpringEnginePin *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); +} + +static void __pyx_pf_14softwrap_core2_15SpringEnginePin_9__dealloc__(struct __pyx_obj_14softwrap_core2_SpringEnginePin *__pyx_v_self) { + int __pyx_v_i; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + __Pyx_RefNannySetupContext("__dealloc__", 0); + + /* "core/core2.pyx":1187 + * def __dealloc__(self): + * cdef int i + * for i in range(self.n_rings): # <<<<<<<<<<<<<< + * fraeee(self.rings[i]) + * fraeee(self.rings) + */ + +# line 1187 "core/core2.pyx" + __pyx_t_1 = __pyx_v_self->n_rings; + +# line 1187 "core/core2.pyx" + __pyx_t_2 = __pyx_t_1; + +# line 1187 "core/core2.pyx" + for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) { + +# line 1187 "core/core2.pyx" + __pyx_v_i = __pyx_t_3; + + /* "core/core2.pyx":1188 + * cdef int i + * for i in range(self.n_rings): + * fraeee(self.rings[i]) # <<<<<<<<<<<<<< + * fraeee(self.rings) + * + */ + +# line 1188 "core/core2.pyx" + __pyx_f_14softwrap_core2_fraeee((__pyx_v_self->rings[__pyx_v_i])); + +# line 1188 "core/core2.pyx" + } + + /* "core/core2.pyx":1189 + * for i in range(self.n_rings): + * fraeee(self.rings[i]) + * fraeee(self.rings) # <<<<<<<<<<<<<< + * + * + */ + +# line 1189 "core/core2.pyx" + __pyx_f_14softwrap_core2_fraeee(__pyx_v_self->rings); + + /* "core/core2.pyx":1185 + * + * + * def __dealloc__(self): # <<<<<<<<<<<<<< + * cdef int i + * for i in range(self.n_rings): + */ + + /* function exit code */ + __Pyx_RefNannyFinishContext(); +} + +/* "core/core2.pyx":1109 + * @cython.final + * cdef class SpringEnginePin: + * cdef readonly SpringEngine engine # <<<<<<<<<<<<<< + * cdef readonly int n_rings + * cdef readonly int start_index + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_15SpringEnginePin_6engine_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_15SpringEnginePin_6engine_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_14softwrap_core2_15SpringEnginePin_6engine___get__(((struct __pyx_obj_14softwrap_core2_SpringEnginePin *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_15SpringEnginePin_6engine___get__(struct __pyx_obj_14softwrap_core2_SpringEnginePin *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_self->engine)); + __pyx_r = ((PyObject *)__pyx_v_self->engine); + goto __pyx_L0; + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":1110 + * cdef class SpringEnginePin: + * cdef readonly SpringEngine engine + * cdef readonly int n_rings # <<<<<<<<<<<<<< + * cdef readonly int start_index + * cdef int** rings + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_15SpringEnginePin_7n_rings_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_15SpringEnginePin_7n_rings_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_14softwrap_core2_15SpringEnginePin_7n_rings___get__(((struct __pyx_obj_14softwrap_core2_SpringEnginePin *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_15SpringEnginePin_7n_rings___get__(struct __pyx_obj_14softwrap_core2_SpringEnginePin *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->n_rings); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1110, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("softwrap_core2.SpringEnginePin.n_rings.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":1111 + * cdef readonly SpringEngine engine + * cdef readonly int n_rings + * cdef readonly int start_index # <<<<<<<<<<<<<< + * cdef int** rings + * + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_15SpringEnginePin_11start_index_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_15SpringEnginePin_11start_index_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_14softwrap_core2_15SpringEnginePin_11start_index___get__(((struct __pyx_obj_14softwrap_core2_SpringEnginePin *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_15SpringEnginePin_11start_index___get__(struct __pyx_obj_14softwrap_core2_SpringEnginePin *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->start_index); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1111, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("softwrap_core2.SpringEnginePin.start_index.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "(tree fragment)":1 + * def __reduce_cython__(self): # <<<<<<<<<<<<<< + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_15SpringEnginePin_12__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_15SpringEnginePin_12__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0); + __pyx_r = __pyx_pf_14softwrap_core2_15SpringEnginePin_11__reduce_cython__(((struct __pyx_obj_14softwrap_core2_SpringEnginePin *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_15SpringEnginePin_11__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_14softwrap_core2_SpringEnginePin *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__reduce_cython__", 0); + + /* "(tree fragment)":2 + * def __reduce_cython__(self): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + */ + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__20, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __PYX_ERR(1, 2, __pyx_L1_error) + + /* "(tree fragment)":1 + * def __reduce_cython__(self): # <<<<<<<<<<<<<< + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("softwrap_core2.SpringEnginePin.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "(tree fragment)":3 + * def __reduce_cython__(self): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_15SpringEnginePin_14__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_15SpringEnginePin_14__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0); + __pyx_r = __pyx_pf_14softwrap_core2_15SpringEnginePin_13__setstate_cython__(((struct __pyx_obj_14softwrap_core2_SpringEnginePin *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_15SpringEnginePin_13__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_14softwrap_core2_SpringEnginePin *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__setstate_cython__", 0); + + /* "(tree fragment)":4 + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< + */ + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__21, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __PYX_ERR(1, 4, __pyx_L1_error) + + /* "(tree fragment)":3 + * def __reduce_cython__(self): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("softwrap_core2.SpringEnginePin.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":1197 + * cdef bint invert + * + * def __cinit__(self, SpringEngineMask mask, float factor, bint invert): # <<<<<<<<<<<<<< + * self.mask = mask + * self.factor = factor + */ + +/* Python wrapper */ +static int __pyx_pw_14softwrap_core2_19_MaskContextManager_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pw_14softwrap_core2_19_MaskContextManager_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + struct __pyx_obj_14softwrap_core2_SpringEngineMask *__pyx_v_mask = 0; + float __pyx_v_factor; + int __pyx_v_invert; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_mask,&__pyx_n_s_factor,&__pyx_n_s_invert,0}; + PyObject* values[3] = {0,0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + CYTHON_FALLTHROUGH; + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + CYTHON_FALLTHROUGH; + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + CYTHON_FALLTHROUGH; + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_mask)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + CYTHON_FALLTHROUGH; + case 1: + if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_factor)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 3, 3, 1); __PYX_ERR(0, 1197, __pyx_L3_error) + } + CYTHON_FALLTHROUGH; + case 2: + if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_invert)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 3, 3, 2); __PYX_ERR(0, 1197, __pyx_L3_error) + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(0, 1197, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + } + __pyx_v_mask = ((struct __pyx_obj_14softwrap_core2_SpringEngineMask *)values[0]); + __pyx_v_factor = __pyx_PyFloat_AsFloat(values[1]); if (unlikely((__pyx_v_factor == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 1197, __pyx_L3_error) + __pyx_v_invert = __Pyx_PyObject_IsTrue(values[2]); if (unlikely((__pyx_v_invert == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1197, __pyx_L3_error) + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1197, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("softwrap_core2._MaskContextManager.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_mask), __pyx_ptype_14softwrap_core2_SpringEngineMask, 1, "mask", 0))) __PYX_ERR(0, 1197, __pyx_L1_error) + __pyx_r = __pyx_pf_14softwrap_core2_19_MaskContextManager___cinit__(((struct __pyx_obj_14softwrap_core2__MaskContextManager *)__pyx_v_self), __pyx_v_mask, __pyx_v_factor, __pyx_v_invert); + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_14softwrap_core2_19_MaskContextManager___cinit__(struct __pyx_obj_14softwrap_core2__MaskContextManager *__pyx_v_self, struct __pyx_obj_14softwrap_core2_SpringEngineMask *__pyx_v_mask, float __pyx_v_factor, int __pyx_v_invert) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__cinit__", 0); + + /* "core/core2.pyx":1198 + * + * def __cinit__(self, SpringEngineMask mask, float factor, bint invert): + * self.mask = mask # <<<<<<<<<<<<<< + * self.factor = factor + * self.invert = invert + */ + +# line 1198 "core/core2.pyx" + __Pyx_INCREF(((PyObject *)__pyx_v_mask)); + +# line 1198 "core/core2.pyx" + __Pyx_GIVEREF(((PyObject *)__pyx_v_mask)); + +# line 1198 "core/core2.pyx" + __Pyx_GOTREF(__pyx_v_self->mask); + +# line 1198 "core/core2.pyx" + __Pyx_DECREF(((PyObject *)__pyx_v_self->mask)); + +# line 1198 "core/core2.pyx" + __pyx_v_self->mask = __pyx_v_mask; + + /* "core/core2.pyx":1199 + * def __cinit__(self, SpringEngineMask mask, float factor, bint invert): + * self.mask = mask + * self.factor = factor # <<<<<<<<<<<<<< + * self.invert = invert + * + */ + +# line 1199 "core/core2.pyx" + __pyx_v_self->factor = __pyx_v_factor; + + /* "core/core2.pyx":1200 + * self.mask = mask + * self.factor = factor + * self.invert = invert # <<<<<<<<<<<<<< + * + * def __enter__(self): + */ + +# line 1200 "core/core2.pyx" + __pyx_v_self->invert = __pyx_v_invert; + + /* "core/core2.pyx":1197 + * cdef bint invert + * + * def __cinit__(self, SpringEngineMask mask, float factor, bint invert): # <<<<<<<<<<<<<< + * self.mask = mask + * self.factor = factor + */ + + /* function exit code */ + __pyx_r = 0; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":1202 + * self.invert = invert + * + * def __enter__(self): # <<<<<<<<<<<<<< + * self.mask.load() + * + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_19_MaskContextManager_3__enter__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_19_MaskContextManager_3__enter__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__enter__ (wrapper)", 0); + __pyx_r = __pyx_pf_14softwrap_core2_19_MaskContextManager_2__enter__(((struct __pyx_obj_14softwrap_core2__MaskContextManager *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_19_MaskContextManager_2__enter__(struct __pyx_obj_14softwrap_core2__MaskContextManager *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__enter__", 0); + + /* "core/core2.pyx":1203 + * + * def __enter__(self): + * self.mask.load() # <<<<<<<<<<<<<< + * + * def __exit__(self, type, value, traceback): + */ + +# line 1203 "core/core2.pyx" + ((struct __pyx_vtabstruct_14softwrap_core2_SpringEngineMask *)__pyx_v_self->mask->__pyx_vtab)->load(__pyx_v_self->mask, 0); + + /* "core/core2.pyx":1202 + * self.invert = invert + * + * def __enter__(self): # <<<<<<<<<<<<<< + * self.mask.load() + * + */ + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":1205 + * self.mask.load() + * + * def __exit__(self, type, value, traceback): # <<<<<<<<<<<<<< + * self.mask.masked_store(self.factor, self.invert) + * + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_19_MaskContextManager_5__exit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_19_MaskContextManager_5__exit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + CYTHON_UNUSED PyObject *__pyx_v_type = 0; + CYTHON_UNUSED PyObject *__pyx_v_value = 0; + CYTHON_UNUSED PyObject *__pyx_v_traceback = 0; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__exit__ (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_type,&__pyx_n_s_value,&__pyx_n_s_traceback,0}; + PyObject* values[3] = {0,0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + CYTHON_FALLTHROUGH; + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + CYTHON_FALLTHROUGH; + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + CYTHON_FALLTHROUGH; + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_type)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + CYTHON_FALLTHROUGH; + case 1: + if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_value)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__exit__", 1, 3, 3, 1); __PYX_ERR(0, 1205, __pyx_L3_error) + } + CYTHON_FALLTHROUGH; + case 2: + if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_traceback)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__exit__", 1, 3, 3, 2); __PYX_ERR(0, 1205, __pyx_L3_error) + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__exit__") < 0)) __PYX_ERR(0, 1205, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + } + __pyx_v_type = values[0]; + __pyx_v_value = values[1]; + __pyx_v_traceback = values[2]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("__exit__", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1205, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("softwrap_core2._MaskContextManager.__exit__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_14softwrap_core2_19_MaskContextManager_4__exit__(((struct __pyx_obj_14softwrap_core2__MaskContextManager *)__pyx_v_self), __pyx_v_type, __pyx_v_value, __pyx_v_traceback); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_19_MaskContextManager_4__exit__(struct __pyx_obj_14softwrap_core2__MaskContextManager *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_type, CYTHON_UNUSED PyObject *__pyx_v_value, CYTHON_UNUSED PyObject *__pyx_v_traceback) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + struct __pyx_opt_args_14softwrap_core2_16SpringEngineMask_masked_store __pyx_t_1; + __Pyx_RefNannySetupContext("__exit__", 0); + + /* "core/core2.pyx":1206 + * + * def __exit__(self, type, value, traceback): + * self.mask.masked_store(self.factor, self.invert) # <<<<<<<<<<<<<< + * + * + */ + +# line 1206 "core/core2.pyx" + __pyx_t_1.__pyx_n = 2; + +# line 1206 "core/core2.pyx" + __pyx_t_1.factor = __pyx_v_self->factor; + +# line 1206 "core/core2.pyx" + __pyx_t_1.invert = __pyx_v_self->invert; + +# line 1206 "core/core2.pyx" + ((struct __pyx_vtabstruct_14softwrap_core2_SpringEngineMask *)__pyx_v_self->mask->__pyx_vtab)->masked_store(__pyx_v_self->mask, 0, &__pyx_t_1); + + /* "core/core2.pyx":1205 + * self.mask.load() + * + * def __exit__(self, type, value, traceback): # <<<<<<<<<<<<<< + * self.mask.masked_store(self.factor, self.invert) + * + */ + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "(tree fragment)":1 + * def __reduce_cython__(self): # <<<<<<<<<<<<<< + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_19_MaskContextManager_7__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_19_MaskContextManager_7__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0); + __pyx_r = __pyx_pf_14softwrap_core2_19_MaskContextManager_6__reduce_cython__(((struct __pyx_obj_14softwrap_core2__MaskContextManager *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_19_MaskContextManager_6__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_14softwrap_core2__MaskContextManager *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__reduce_cython__", 0); + + /* "(tree fragment)":2 + * def __reduce_cython__(self): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + */ + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__22, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __PYX_ERR(1, 2, __pyx_L1_error) + + /* "(tree fragment)":1 + * def __reduce_cython__(self): # <<<<<<<<<<<<<< + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("softwrap_core2._MaskContextManager.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "(tree fragment)":3 + * def __reduce_cython__(self): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_19_MaskContextManager_9__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_19_MaskContextManager_9__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0); + __pyx_r = __pyx_pf_14softwrap_core2_19_MaskContextManager_8__setstate_cython__(((struct __pyx_obj_14softwrap_core2__MaskContextManager *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_19_MaskContextManager_8__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_14softwrap_core2__MaskContextManager *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__setstate_cython__", 0); + + /* "(tree fragment)":4 + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< + */ + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__23, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __PYX_ERR(1, 4, __pyx_L1_error) + + /* "(tree fragment)":3 + * def __reduce_cython__(self): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("softwrap_core2._MaskContextManager.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":1216 + * cdef SpringEngine engine + * + * def __cinit__(self, SpringEngine engine, list mask): # <<<<<<<<<<<<<< + * self.engine = engine + * + */ + +/* Python wrapper */ +static int __pyx_pw_14softwrap_core2_16SpringEngineMask_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pw_14softwrap_core2_16SpringEngineMask_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_engine = 0; + PyObject *__pyx_v_mask = 0; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_engine,&__pyx_n_s_mask,0}; + PyObject* values[2] = {0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + CYTHON_FALLTHROUGH; + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + CYTHON_FALLTHROUGH; + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_engine)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + CYTHON_FALLTHROUGH; + case 1: + if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_mask)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 2, 2, 1); __PYX_ERR(0, 1216, __pyx_L3_error) + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(0, 1216, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + } + __pyx_v_engine = ((struct __pyx_obj_14softwrap_core2_SpringEngine *)values[0]); + __pyx_v_mask = ((PyObject*)values[1]); + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1216, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("softwrap_core2.SpringEngineMask.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_engine), __pyx_ptype_14softwrap_core2_SpringEngine, 1, "engine", 0))) __PYX_ERR(0, 1216, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_mask), (&PyList_Type), 1, "mask", 1))) __PYX_ERR(0, 1216, __pyx_L1_error) + __pyx_r = __pyx_pf_14softwrap_core2_16SpringEngineMask___cinit__(((struct __pyx_obj_14softwrap_core2_SpringEngineMask *)__pyx_v_self), __pyx_v_engine, __pyx_v_mask); + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_14softwrap_core2_16SpringEngineMask___cinit__(struct __pyx_obj_14softwrap_core2_SpringEngineMask *__pyx_v_self, struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_engine, PyObject *__pyx_v_mask) { + int __pyx_v_i; + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + Py_ssize_t __pyx_t_3; + PyObject *__pyx_t_4 = NULL; + void *__pyx_t_5; + int __pyx_t_6; + int __pyx_t_7; + int __pyx_t_8; + float __pyx_t_9; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__cinit__", 0); + + /* "core/core2.pyx":1217 + * + * def __cinit__(self, SpringEngine engine, list mask): + * self.engine = engine # <<<<<<<<<<<<<< + * + * if not mask: + */ + +# line 1217 "core/core2.pyx" + __Pyx_INCREF(((PyObject *)__pyx_v_engine)); + +# line 1217 "core/core2.pyx" + __Pyx_GIVEREF(((PyObject *)__pyx_v_engine)); + +# line 1217 "core/core2.pyx" + __Pyx_GOTREF(__pyx_v_self->engine); + +# line 1217 "core/core2.pyx" + __Pyx_DECREF(((PyObject *)__pyx_v_self->engine)); + +# line 1217 "core/core2.pyx" + __pyx_v_self->engine = __pyx_v_engine; + + /* "core/core2.pyx":1219 + * self.engine = engine + * + * if not mask: # <<<<<<<<<<<<<< + * self.mask = NULL + * self.vec_data = NULL + */ + +# line 1219 "core/core2.pyx" + __pyx_t_1 = (__pyx_v_mask != Py_None)&&(PyList_GET_SIZE(__pyx_v_mask) != 0); + +# line 1219 "core/core2.pyx" + __pyx_t_2 = ((!__pyx_t_1) != 0); + +# line 1219 "core/core2.pyx" + if (__pyx_t_2) { + + /* "core/core2.pyx":1220 + * + * if not mask: + * self.mask = NULL # <<<<<<<<<<<<<< + * self.vec_data = NULL + * return + */ + +# line 1220 "core/core2.pyx" + __pyx_v_self->mask = NULL; + + /* "core/core2.pyx":1221 + * if not mask: + * self.mask = NULL + * self.vec_data = NULL # <<<<<<<<<<<<<< + * return + * + */ + +# line 1221 "core/core2.pyx" + __pyx_v_self->vec_data = NULL; + + /* "core/core2.pyx":1222 + * self.mask = NULL + * self.vec_data = NULL + * return # <<<<<<<<<<<<<< + * + * elif not len(mask) == engine.n_verts: + */ + +# line 1222 "core/core2.pyx" + __pyx_r = 0; + +# line 1222 "core/core2.pyx" + goto __pyx_L0; + + /* "core/core2.pyx":1219 + * self.engine = engine + * + * if not mask: # <<<<<<<<<<<<<< + * self.mask = NULL + * self.vec_data = NULL + */ + +# line 1219 "core/core2.pyx" + } + + /* "core/core2.pyx":1224 + * return + * + * elif not len(mask) == engine.n_verts: # <<<<<<<<<<<<<< + * raise ValueError('mask must have the same number of elements as engine verts') + * + */ + +# line 1224 "core/core2.pyx" + if (unlikely(__pyx_v_mask == Py_None)) { + +# line 1224 "core/core2.pyx" + PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); + +# line 1224 "core/core2.pyx" + __PYX_ERR(0, 1224, __pyx_L1_error) + +# line 1224 "core/core2.pyx" + } + +# line 1224 "core/core2.pyx" + __pyx_t_3 = PyList_GET_SIZE(__pyx_v_mask); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1224, __pyx_L1_error) + +# line 1224 "core/core2.pyx" + __pyx_t_2 = ((!((__pyx_t_3 == __pyx_v_engine->n_verts) != 0)) != 0); + +# line 1224 "core/core2.pyx" + if (unlikely(__pyx_t_2)) { + + /* "core/core2.pyx":1225 + * + * elif not len(mask) == engine.n_verts: + * raise ValueError('mask must have the same number of elements as engine verts') # <<<<<<<<<<<<<< + * + * self.mask = maelloc(sizeof(float) * self.engine.n_verts, __LINE__) + */ + +# line 1225 "core/core2.pyx" + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__24, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1225, __pyx_L1_error) + +# line 1225 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_4); + +# line 1225 "core/core2.pyx" + __Pyx_Raise(__pyx_t_4, 0, 0, 0); + +# line 1225 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + +# line 1225 "core/core2.pyx" + __PYX_ERR(0, 1225, __pyx_L1_error) + + /* "core/core2.pyx":1224 + * return + * + * elif not len(mask) == engine.n_verts: # <<<<<<<<<<<<<< + * raise ValueError('mask must have the same number of elements as engine verts') + * + */ + +# line 1224 "core/core2.pyx" + } + + /* "core/core2.pyx":1227 + * raise ValueError('mask must have the same number of elements as engine verts') + * + * self.mask = maelloc(sizeof(float) * self.engine.n_verts, __LINE__) # <<<<<<<<<<<<<< + * self.vec_data = maelloc(sizeof(vec3) * self.engine.n_verts, __LINE__) + * + */ + +# line 1227 "core/core2.pyx" + __pyx_t_5 = __pyx_f_14softwrap_core2_maelloc(((sizeof(float)) * __pyx_v_self->engine->n_verts), __LINE__); if (unlikely(__pyx_t_5 == ((void *)NULL))) __PYX_ERR(0, 1227, __pyx_L1_error) + +# line 1227 "core/core2.pyx" + __pyx_v_self->mask = ((float *)__pyx_t_5); + + /* "core/core2.pyx":1228 + * + * self.mask = maelloc(sizeof(float) * self.engine.n_verts, __LINE__) + * self.vec_data = maelloc(sizeof(vec3) * self.engine.n_verts, __LINE__) # <<<<<<<<<<<<<< + * + * cdef int i + */ + +# line 1228 "core/core2.pyx" + __pyx_t_5 = __pyx_f_14softwrap_core2_maelloc(((sizeof(vec3)) * __pyx_v_self->engine->n_verts), __LINE__); if (unlikely(__pyx_t_5 == ((void *)NULL))) __PYX_ERR(0, 1228, __pyx_L1_error) + +# line 1228 "core/core2.pyx" + __pyx_v_self->vec_data = ((vec3 *)__pyx_t_5); + + /* "core/core2.pyx":1231 + * + * cdef int i + * for i in range(self.engine.n_verts): # <<<<<<<<<<<<<< + * self.mask[i] = mask[i] + * + */ + +# line 1231 "core/core2.pyx" + __pyx_t_6 = __pyx_v_self->engine->n_verts; + +# line 1231 "core/core2.pyx" + __pyx_t_7 = __pyx_t_6; + +# line 1231 "core/core2.pyx" + for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_7; __pyx_t_8+=1) { + +# line 1231 "core/core2.pyx" + __pyx_v_i = __pyx_t_8; + + /* "core/core2.pyx":1232 + * cdef int i + * for i in range(self.engine.n_verts): + * self.mask[i] = mask[i] # <<<<<<<<<<<<<< + * + * def __getitem__(self, int index): + */ + +# line 1232 "core/core2.pyx" + if (unlikely(__pyx_v_mask == Py_None)) { + +# line 1232 "core/core2.pyx" + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + +# line 1232 "core/core2.pyx" + __PYX_ERR(0, 1232, __pyx_L1_error) + +# line 1232 "core/core2.pyx" + } + +# line 1232 "core/core2.pyx" + __pyx_t_4 = __Pyx_GetItemInt_List(__pyx_v_mask, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 1, 1, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1232, __pyx_L1_error) + +# line 1232 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_4); + +# line 1232 "core/core2.pyx" + __pyx_t_9 = __pyx_PyFloat_AsFloat(__pyx_t_4); if (unlikely((__pyx_t_9 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 1232, __pyx_L1_error) + +# line 1232 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + +# line 1232 "core/core2.pyx" + (__pyx_v_self->mask[__pyx_v_i]) = __pyx_t_9; + +# line 1232 "core/core2.pyx" + } + + /* "core/core2.pyx":1216 + * cdef SpringEngine engine + * + * def __cinit__(self, SpringEngine engine, list mask): # <<<<<<<<<<<<<< + * self.engine = engine + * + */ + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("softwrap_core2.SpringEngineMask.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":1234 + * self.mask[i] = mask[i] + * + * def __getitem__(self, int index): # <<<<<<<<<<<<<< + * if self.mask == NULL: + * return 0.0 + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_16SpringEngineMask_3__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_index); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_16SpringEngineMask_3__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_index) { + int __pyx_v_index; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0); + assert(__pyx_arg_index); { + __pyx_v_index = __Pyx_PyInt_As_int(__pyx_arg_index); if (unlikely((__pyx_v_index == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1234, __pyx_L3_error) + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("softwrap_core2.SpringEngineMask.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_14softwrap_core2_16SpringEngineMask_2__getitem__(((struct __pyx_obj_14softwrap_core2_SpringEngineMask *)__pyx_v_self), ((int)__pyx_v_index)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_16SpringEngineMask_2__getitem__(struct __pyx_obj_14softwrap_core2_SpringEngineMask *__pyx_v_self, int __pyx_v_index) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__getitem__", 0); + + /* "core/core2.pyx":1235 + * + * def __getitem__(self, int index): + * if self.mask == NULL: # <<<<<<<<<<<<<< + * return 0.0 + * + */ + +# line 1235 "core/core2.pyx" + __pyx_t_1 = ((__pyx_v_self->mask == NULL) != 0); + +# line 1235 "core/core2.pyx" + if (__pyx_t_1) { + + /* "core/core2.pyx":1236 + * def __getitem__(self, int index): + * if self.mask == NULL: + * return 0.0 # <<<<<<<<<<<<<< + * + * index_check(index, self.engine.n_verts) + */ + +# line 1236 "core/core2.pyx" + __Pyx_XDECREF(__pyx_r); + +# line 1236 "core/core2.pyx" + __Pyx_INCREF(__pyx_float_0_0); + +# line 1236 "core/core2.pyx" + __pyx_r = __pyx_float_0_0; + +# line 1236 "core/core2.pyx" + goto __pyx_L0; + + /* "core/core2.pyx":1235 + * + * def __getitem__(self, int index): + * if self.mask == NULL: # <<<<<<<<<<<<<< + * return 0.0 + * + */ + +# line 1235 "core/core2.pyx" + } + + /* "core/core2.pyx":1238 + * return 0.0 + * + * index_check(index, self.engine.n_verts) # <<<<<<<<<<<<<< + * return self.mask[index] + * + */ + +# line 1238 "core/core2.pyx" + __pyx_t_2 = __pyx_f_14softwrap_core2_index_check(__pyx_v_index, __pyx_v_self->engine->n_verts, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1238, __pyx_L1_error) + +# line 1238 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_2); + +# line 1238 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "core/core2.pyx":1239 + * + * index_check(index, self.engine.n_verts) + * return self.mask[index] # <<<<<<<<<<<<<< + * + * def __setitem__(self, int index, value): + */ + +# line 1239 "core/core2.pyx" + __Pyx_XDECREF(__pyx_r); + +# line 1239 "core/core2.pyx" + __pyx_t_2 = PyFloat_FromDouble((__pyx_v_self->mask[__pyx_v_index])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1239, __pyx_L1_error) + +# line 1239 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_2); + +# line 1239 "core/core2.pyx" + __pyx_r = __pyx_t_2; + +# line 1239 "core/core2.pyx" + __pyx_t_2 = 0; + +# line 1239 "core/core2.pyx" + goto __pyx_L0; + + /* "core/core2.pyx":1234 + * self.mask[i] = mask[i] + * + * def __getitem__(self, int index): # <<<<<<<<<<<<<< + * if self.mask == NULL: + * return 0.0 + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("softwrap_core2.SpringEngineMask.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":1241 + * return self.mask[index] + * + * def __setitem__(self, int index, value): # <<<<<<<<<<<<<< + * if self.mask == NULL: + * return + */ + +/* Python wrapper */ +static int __pyx_pw_14softwrap_core2_16SpringEngineMask_5__setitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_index, PyObject *__pyx_v_value); /*proto*/ +static int __pyx_pw_14softwrap_core2_16SpringEngineMask_5__setitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_index, PyObject *__pyx_v_value) { + int __pyx_v_index; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__setitem__ (wrapper)", 0); + assert(__pyx_arg_index); { + __pyx_v_index = __Pyx_PyInt_As_int(__pyx_arg_index); if (unlikely((__pyx_v_index == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1241, __pyx_L3_error) + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("softwrap_core2.SpringEngineMask.__setitem__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_14softwrap_core2_16SpringEngineMask_4__setitem__(((struct __pyx_obj_14softwrap_core2_SpringEngineMask *)__pyx_v_self), ((int)__pyx_v_index), ((PyObject *)__pyx_v_value)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_14softwrap_core2_16SpringEngineMask_4__setitem__(struct __pyx_obj_14softwrap_core2_SpringEngineMask *__pyx_v_self, int __pyx_v_index, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + float __pyx_t_3; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__setitem__", 0); + + /* "core/core2.pyx":1242 + * + * def __setitem__(self, int index, value): + * if self.mask == NULL: # <<<<<<<<<<<<<< + * return + * + */ + +# line 1242 "core/core2.pyx" + __pyx_t_1 = ((__pyx_v_self->mask == NULL) != 0); + +# line 1242 "core/core2.pyx" + if (__pyx_t_1) { + + /* "core/core2.pyx":1243 + * def __setitem__(self, int index, value): + * if self.mask == NULL: + * return # <<<<<<<<<<<<<< + * + * index_check(index, self.engine.n_verts) + */ + +# line 1243 "core/core2.pyx" + __pyx_r = 0; + +# line 1243 "core/core2.pyx" + goto __pyx_L0; + + /* "core/core2.pyx":1242 + * + * def __setitem__(self, int index, value): + * if self.mask == NULL: # <<<<<<<<<<<<<< + * return + * + */ + +# line 1242 "core/core2.pyx" + } + + /* "core/core2.pyx":1245 + * return + * + * index_check(index, self.engine.n_verts) # <<<<<<<<<<<<<< + * self.mask[index] = value + * + */ + +# line 1245 "core/core2.pyx" + __pyx_t_2 = __pyx_f_14softwrap_core2_index_check(__pyx_v_index, __pyx_v_self->engine->n_verts, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1245, __pyx_L1_error) + +# line 1245 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_2); + +# line 1245 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "core/core2.pyx":1246 + * + * index_check(index, self.engine.n_verts) + * self.mask[index] = value # <<<<<<<<<<<<<< + * + * cpdef set_force(self, float x, float y, float z): + */ + +# line 1246 "core/core2.pyx" + __pyx_t_3 = __pyx_PyFloat_AsFloat(__pyx_v_value); if (unlikely((__pyx_t_3 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 1246, __pyx_L1_error) + +# line 1246 "core/core2.pyx" + (__pyx_v_self->mask[__pyx_v_index]) = __pyx_t_3; + + /* "core/core2.pyx":1241 + * return self.mask[index] + * + * def __setitem__(self, int index, value): # <<<<<<<<<<<<<< + * if self.mask == NULL: + * return + */ + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("softwrap_core2.SpringEngineMask.__setitem__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":1248 + * self.mask[index] = value + * + * cpdef set_force(self, float x, float y, float z): # <<<<<<<<<<<<<< + * if self.mask == NULL: + * return + */ + +static PyObject *__pyx_pw_14softwrap_core2_16SpringEngineMask_7set_force(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_f_14softwrap_core2_16SpringEngineMask_set_force(struct __pyx_obj_14softwrap_core2_SpringEngineMask *__pyx_v_self, float __pyx_v_x, float __pyx_v_y, float __pyx_v_z, int __pyx_skip_dispatch) { + int __pyx_v_i; + vec3 __pyx_v_d; + vec3 __pyx_v_v; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + int __pyx_t_8; + PyObject *__pyx_t_9 = NULL; + int __pyx_t_10; + int __pyx_t_11; + int __pyx_t_12; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("set_force", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) { + #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS + static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; + if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) { + PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); + #endif + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_set_force); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1248, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_14softwrap_core2_16SpringEngineMask_7set_force)) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_3 = PyFloat_FromDouble(__pyx_v_x); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1248, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyFloat_FromDouble(__pyx_v_y); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1248, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = PyFloat_FromDouble(__pyx_v_z); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1248, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_INCREF(__pyx_t_1); + __pyx_t_6 = __pyx_t_1; __pyx_t_7 = NULL; + __pyx_t_8 = 0; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) { + __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6); + if (likely(__pyx_t_7)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); + __Pyx_INCREF(__pyx_t_7); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_6, function); + __pyx_t_8 = 1; + } + } + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_6)) { + PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_t_3, __pyx_t_4, __pyx_t_5}; + __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1248, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) { + PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_t_3, __pyx_t_4, __pyx_t_5}; + __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1248, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + } else + #endif + { + __pyx_t_9 = PyTuple_New(3+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1248, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + if (__pyx_t_7) { + __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL; + } + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_9, 2+__pyx_t_8, __pyx_t_5); + __pyx_t_3 = 0; + __pyx_t_4 = 0; + __pyx_t_5 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_9, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1248, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + } + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS + __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); + __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self)); + if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) { + __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; + } + #endif + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS + } + #endif + } + + /* "core/core2.pyx":1249 + * + * cpdef set_force(self, float x, float y, float z): + * if self.mask == NULL: # <<<<<<<<<<<<<< + * return + * + */ + +# line 1249 "core/core2.pyx" + __pyx_t_10 = ((__pyx_v_self->mask == NULL) != 0); + +# line 1249 "core/core2.pyx" + if (__pyx_t_10) { + + /* "core/core2.pyx":1250 + * cpdef set_force(self, float x, float y, float z): + * if self.mask == NULL: + * return # <<<<<<<<<<<<<< + * + * cdef int i + */ + +# line 1250 "core/core2.pyx" + __Pyx_XDECREF(__pyx_r); + +# line 1250 "core/core2.pyx" + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + +# line 1250 "core/core2.pyx" + goto __pyx_L0; + + /* "core/core2.pyx":1249 + * + * cpdef set_force(self, float x, float y, float z): + * if self.mask == NULL: # <<<<<<<<<<<<<< + * return + * + */ + +# line 1249 "core/core2.pyx" + } + + /* "core/core2.pyx":1254 + * cdef int i + * cdef vec3 d, v + * v = vec3(x, y, z) # <<<<<<<<<<<<<< + * with nogil: + * for i in prange(self.engine.n_verts): + */ + +# line 1254 "core/core2.pyx" + __pyx_v_v = vec3(__pyx_v_x, __pyx_v_y, __pyx_v_z); + + /* "core/core2.pyx":1255 + * cdef vec3 d, v + * v = vec3(x, y, z) + * with nogil: # <<<<<<<<<<<<<< + * for i in prange(self.engine.n_verts): + * d = self.engine.m.verts[i] - self.engine.prev_verts[i] + */ + +# line 1255 "core/core2.pyx" + { + +# line 1255 "core/core2.pyx" + #ifdef WITH_THREAD + +# line 1255 "core/core2.pyx" + PyThreadState *_save; + +# line 1255 "core/core2.pyx" + Py_UNBLOCK_THREADS + +# line 1255 "core/core2.pyx" + __Pyx_FastGIL_Remember(); + +# line 1255 "core/core2.pyx" + #endif + /*try:*/ { + + /* "core/core2.pyx":1256 + * v = vec3(x, y, z) + * with nogil: + * for i in prange(self.engine.n_verts): # <<<<<<<<<<<<<< + * d = self.engine.m.verts[i] - self.engine.prev_verts[i] + * d = d.lerp(v, self.mask[i]) + */ + +# line 1256 "core/core2.pyx" + __pyx_t_8 = __pyx_v_self->engine->n_verts; + +# line 1256 "core/core2.pyx" + if ((1 == 0)) abort(); + +# line 1256 "core/core2.pyx" + { + +# line 1256 "core/core2.pyx" + #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))))) + +# line 1256 "core/core2.pyx" + #undef likely + +# line 1256 "core/core2.pyx" + #undef unlikely + #define likely(x) (x) + #define unlikely(x) (x) + +# line 1256 "core/core2.pyx" + #endif + +# line 1256 "core/core2.pyx" + __pyx_t_12 = (__pyx_t_8 - 0 + 1 - 1/abs(1)) / 1; + +# line 1256 "core/core2.pyx" + if (__pyx_t_12 > 0) + +# line 1256 "core/core2.pyx" + { + +# line 1256 "core/core2.pyx" + #ifdef _OPENMP + +# line 1256 "core/core2.pyx" + #pragma omp parallel + #endif /* _OPENMP */ + { + #ifdef _OPENMP + #pragma omp for lastprivate(__pyx_v_d) firstprivate(__pyx_v_i) lastprivate(__pyx_v_i) + #endif /* _OPENMP */ + for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_12; __pyx_t_11++){ + { + __pyx_v_i = (int)(0 + 1 * __pyx_t_11); + + /* "core/core2.pyx":1257 + * with nogil: + * for i in prange(self.engine.n_verts): + * d = self.engine.m.verts[i] - self.engine.prev_verts[i] # <<<<<<<<<<<<<< + * d = d.lerp(v, self.mask[i]) + * self.engine.m.verts[i] = self.engine.prev_verts[i] + d + */ + +# line 1257 "core/core2.pyx" + __pyx_v_d = ((__pyx_v_self->engine->m->verts[__pyx_v_i]) - (__pyx_v_self->engine->prev_verts[__pyx_v_i])); + + /* "core/core2.pyx":1258 + * for i in prange(self.engine.n_verts): + * d = self.engine.m.verts[i] - self.engine.prev_verts[i] + * d = d.lerp(v, self.mask[i]) # <<<<<<<<<<<<<< + * self.engine.m.verts[i] = self.engine.prev_verts[i] + d + * + */ + +# line 1258 "core/core2.pyx" + __pyx_v_d = __pyx_v_d.lerp(__pyx_v_v, (__pyx_v_self->mask[__pyx_v_i])); + + /* "core/core2.pyx":1259 + * d = self.engine.m.verts[i] - self.engine.prev_verts[i] + * d = d.lerp(v, self.mask[i]) + * self.engine.m.verts[i] = self.engine.prev_verts[i] + d # <<<<<<<<<<<<<< + * + * cpdef void load(self): + */ + +# line 1259 "core/core2.pyx" + (__pyx_v_self->engine->m->verts[__pyx_v_i]) = ((__pyx_v_self->engine->prev_verts[__pyx_v_i]) + __pyx_v_d); + +# line 1259 "core/core2.pyx" + } + +# line 1259 "core/core2.pyx" + } + +# line 1259 "core/core2.pyx" + } + +# line 1259 "core/core2.pyx" + } + +# line 1259 "core/core2.pyx" + } + +# line 1259 "core/core2.pyx" + #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))))) + +# line 1259 "core/core2.pyx" + #undef likely + +# line 1259 "core/core2.pyx" + #undef unlikely + #define likely(x) __builtin_expect(!!(x), 1) + #define unlikely(x) __builtin_expect(!!(x), 0) + +# line 1259 "core/core2.pyx" + #endif + +# line 1259 "core/core2.pyx" + } + + /* "core/core2.pyx":1255 + * cdef vec3 d, v + * v = vec3(x, y, z) + * with nogil: # <<<<<<<<<<<<<< + * for i in prange(self.engine.n_verts): + * d = self.engine.m.verts[i] - self.engine.prev_verts[i] + */ + /*finally:*/ { + /*normal exit:*/{ + #ifdef WITH_THREAD + __Pyx_FastGIL_Forget(); + Py_BLOCK_THREADS + #endif + goto __pyx_L6; + } + __pyx_L6:; + } + } + + /* "core/core2.pyx":1248 + * self.mask[index] = value + * + * cpdef set_force(self, float x, float y, float z): # <<<<<<<<<<<<<< + * if self.mask == NULL: + * return + */ + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_9); + __Pyx_AddTraceback("softwrap_core2.SpringEngineMask.set_force", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_16SpringEngineMask_7set_force(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_16SpringEngineMask_7set_force(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + float __pyx_v_x; + float __pyx_v_y; + float __pyx_v_z; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("set_force (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,&__pyx_n_s_y,&__pyx_n_s_z,0}; + PyObject* values[3] = {0,0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + CYTHON_FALLTHROUGH; + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + CYTHON_FALLTHROUGH; + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + CYTHON_FALLTHROUGH; + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + CYTHON_FALLTHROUGH; + case 1: + if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_y)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("set_force", 1, 3, 3, 1); __PYX_ERR(0, 1248, __pyx_L3_error) + } + CYTHON_FALLTHROUGH; + case 2: + if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_z)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("set_force", 1, 3, 3, 2); __PYX_ERR(0, 1248, __pyx_L3_error) + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "set_force") < 0)) __PYX_ERR(0, 1248, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + } + __pyx_v_x = __pyx_PyFloat_AsFloat(values[0]); if (unlikely((__pyx_v_x == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 1248, __pyx_L3_error) + __pyx_v_y = __pyx_PyFloat_AsFloat(values[1]); if (unlikely((__pyx_v_y == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 1248, __pyx_L3_error) + __pyx_v_z = __pyx_PyFloat_AsFloat(values[2]); if (unlikely((__pyx_v_z == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 1248, __pyx_L3_error) + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("set_force", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1248, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("softwrap_core2.SpringEngineMask.set_force", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_14softwrap_core2_16SpringEngineMask_6set_force(((struct __pyx_obj_14softwrap_core2_SpringEngineMask *)__pyx_v_self), __pyx_v_x, __pyx_v_y, __pyx_v_z); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_16SpringEngineMask_6set_force(struct __pyx_obj_14softwrap_core2_SpringEngineMask *__pyx_v_self, float __pyx_v_x, float __pyx_v_y, float __pyx_v_z) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("set_force", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_f_14softwrap_core2_16SpringEngineMask_set_force(__pyx_v_self, __pyx_v_x, __pyx_v_y, __pyx_v_z, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1248, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("softwrap_core2.SpringEngineMask.set_force", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":1261 + * self.engine.m.verts[i] = self.engine.prev_verts[i] + d + * + * cpdef void load(self): # <<<<<<<<<<<<<< + * if self.mask == NULL: + * return + */ + +static PyObject *__pyx_pw_14softwrap_core2_16SpringEngineMask_9load(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static void __pyx_f_14softwrap_core2_16SpringEngineMask_load(struct __pyx_obj_14softwrap_core2_SpringEngineMask *__pyx_v_self, int __pyx_skip_dispatch) { + int __pyx_v_i; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + int __pyx_t_5; + int __pyx_t_6; + int __pyx_t_7; + int __pyx_t_8; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("load", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) { + #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS + static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; + if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) { + PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); + #endif + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_load); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1261, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_14softwrap_core2_16SpringEngineMask_9load)) { + __Pyx_INCREF(__pyx_t_1); + __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { + __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); + if (likely(__pyx_t_4)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); + __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_3, function); + } + } + __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1261, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS + __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); + __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self)); + if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) { + __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; + } + #endif + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS + } + #endif + } + + /* "core/core2.pyx":1262 + * + * cpdef void load(self): + * if self.mask == NULL: # <<<<<<<<<<<<<< + * return + * + */ + +# line 1262 "core/core2.pyx" + __pyx_t_5 = ((__pyx_v_self->mask == NULL) != 0); + +# line 1262 "core/core2.pyx" + if (__pyx_t_5) { + + /* "core/core2.pyx":1263 + * cpdef void load(self): + * if self.mask == NULL: + * return # <<<<<<<<<<<<<< + * + * cdef int i + */ + +# line 1263 "core/core2.pyx" + goto __pyx_L0; + + /* "core/core2.pyx":1262 + * + * cpdef void load(self): + * if self.mask == NULL: # <<<<<<<<<<<<<< + * return + * + */ + +# line 1262 "core/core2.pyx" + } + + /* "core/core2.pyx":1266 + * + * cdef int i + * with nogil: # <<<<<<<<<<<<<< + * for i in prange(self.engine.n_verts): + * self.vec_data[i] = self.engine.m.verts[i] + */ + +# line 1266 "core/core2.pyx" + { + +# line 1266 "core/core2.pyx" + #ifdef WITH_THREAD + +# line 1266 "core/core2.pyx" + PyThreadState *_save; + +# line 1266 "core/core2.pyx" + Py_UNBLOCK_THREADS + +# line 1266 "core/core2.pyx" + __Pyx_FastGIL_Remember(); + +# line 1266 "core/core2.pyx" + #endif + /*try:*/ { + + /* "core/core2.pyx":1267 + * cdef int i + * with nogil: + * for i in prange(self.engine.n_verts): # <<<<<<<<<<<<<< + * self.vec_data[i] = self.engine.m.verts[i] + * + */ + +# line 1267 "core/core2.pyx" + __pyx_t_6 = __pyx_v_self->engine->n_verts; + +# line 1267 "core/core2.pyx" + if ((1 == 0)) abort(); + +# line 1267 "core/core2.pyx" + { + +# line 1267 "core/core2.pyx" + #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))))) + +# line 1267 "core/core2.pyx" + #undef likely + +# line 1267 "core/core2.pyx" + #undef unlikely + #define likely(x) (x) + #define unlikely(x) (x) + +# line 1267 "core/core2.pyx" + #endif + +# line 1267 "core/core2.pyx" + __pyx_t_8 = (__pyx_t_6 - 0 + 1 - 1/abs(1)) / 1; + +# line 1267 "core/core2.pyx" + if (__pyx_t_8 > 0) + +# line 1267 "core/core2.pyx" + { + +# line 1267 "core/core2.pyx" + #ifdef _OPENMP + +# line 1267 "core/core2.pyx" + #pragma omp parallel + #endif /* _OPENMP */ + { + #ifdef _OPENMP + #pragma omp for firstprivate(__pyx_v_i) lastprivate(__pyx_v_i) + #endif /* _OPENMP */ + for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_8; __pyx_t_7++){ + { + __pyx_v_i = (int)(0 + 1 * __pyx_t_7); + + /* "core/core2.pyx":1268 + * with nogil: + * for i in prange(self.engine.n_verts): + * self.vec_data[i] = self.engine.m.verts[i] # <<<<<<<<<<<<<< + * + * cpdef void store(self): + */ + +# line 1268 "core/core2.pyx" + (__pyx_v_self->vec_data[__pyx_v_i]) = (__pyx_v_self->engine->m->verts[__pyx_v_i]); + +# line 1268 "core/core2.pyx" + } + +# line 1268 "core/core2.pyx" + } + +# line 1268 "core/core2.pyx" + } + +# line 1268 "core/core2.pyx" + } + +# line 1268 "core/core2.pyx" + } + +# line 1268 "core/core2.pyx" + #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))))) + +# line 1268 "core/core2.pyx" + #undef likely + +# line 1268 "core/core2.pyx" + #undef unlikely + #define likely(x) __builtin_expect(!!(x), 1) + #define unlikely(x) __builtin_expect(!!(x), 0) + +# line 1268 "core/core2.pyx" + #endif + +# line 1268 "core/core2.pyx" + } + + /* "core/core2.pyx":1266 + * + * cdef int i + * with nogil: # <<<<<<<<<<<<<< + * for i in prange(self.engine.n_verts): + * self.vec_data[i] = self.engine.m.verts[i] + */ + /*finally:*/ { + /*normal exit:*/{ + #ifdef WITH_THREAD + __Pyx_FastGIL_Forget(); + Py_BLOCK_THREADS + #endif + goto __pyx_L6; + } + __pyx_L6:; + } + } + + /* "core/core2.pyx":1261 + * self.engine.m.verts[i] = self.engine.prev_verts[i] + d + * + * cpdef void load(self): # <<<<<<<<<<<<<< + * if self.mask == NULL: + * return + */ + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_WriteUnraisable("softwrap_core2.SpringEngineMask.load", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); + __pyx_L0:; + __Pyx_RefNannyFinishContext(); +} + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_16SpringEngineMask_9load(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_16SpringEngineMask_9load(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("load (wrapper)", 0); + __pyx_r = __pyx_pf_14softwrap_core2_16SpringEngineMask_8load(((struct __pyx_obj_14softwrap_core2_SpringEngineMask *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_16SpringEngineMask_8load(struct __pyx_obj_14softwrap_core2_SpringEngineMask *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("load", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_void_to_None(__pyx_f_14softwrap_core2_16SpringEngineMask_load(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1261, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("softwrap_core2.SpringEngineMask.load", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":1270 + * self.vec_data[i] = self.engine.m.verts[i] + * + * cpdef void store(self): # <<<<<<<<<<<<<< + * if self.mask == NULL: + * return + */ + +static PyObject *__pyx_pw_14softwrap_core2_16SpringEngineMask_11store(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static void __pyx_f_14softwrap_core2_16SpringEngineMask_store(struct __pyx_obj_14softwrap_core2_SpringEngineMask *__pyx_v_self, int __pyx_skip_dispatch) { + int __pyx_v_i; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + int __pyx_t_5; + int __pyx_t_6; + int __pyx_t_7; + int __pyx_t_8; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("store", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) { + #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS + static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; + if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) { + PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); + #endif + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_store); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1270, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_14softwrap_core2_16SpringEngineMask_11store)) { + __Pyx_INCREF(__pyx_t_1); + __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { + __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); + if (likely(__pyx_t_4)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); + __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_3, function); + } + } + __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1270, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS + __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); + __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self)); + if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) { + __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; + } + #endif + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS + } + #endif + } + + /* "core/core2.pyx":1271 + * + * cpdef void store(self): + * if self.mask == NULL: # <<<<<<<<<<<<<< + * return + * + */ + +# line 1271 "core/core2.pyx" + __pyx_t_5 = ((__pyx_v_self->mask == NULL) != 0); + +# line 1271 "core/core2.pyx" + if (__pyx_t_5) { + + /* "core/core2.pyx":1272 + * cpdef void store(self): + * if self.mask == NULL: + * return # <<<<<<<<<<<<<< + * + * cdef int i + */ + +# line 1272 "core/core2.pyx" + goto __pyx_L0; + + /* "core/core2.pyx":1271 + * + * cpdef void store(self): + * if self.mask == NULL: # <<<<<<<<<<<<<< + * return + * + */ + +# line 1271 "core/core2.pyx" + } + + /* "core/core2.pyx":1275 + * + * cdef int i + * with nogil: # <<<<<<<<<<<<<< + * for i in prange(self.engine.n_verts): + * self.engine.m.verts[i] = self.vec_data[i] + */ + +# line 1275 "core/core2.pyx" + { + +# line 1275 "core/core2.pyx" + #ifdef WITH_THREAD + +# line 1275 "core/core2.pyx" + PyThreadState *_save; + +# line 1275 "core/core2.pyx" + Py_UNBLOCK_THREADS + +# line 1275 "core/core2.pyx" + __Pyx_FastGIL_Remember(); + +# line 1275 "core/core2.pyx" + #endif + /*try:*/ { + + /* "core/core2.pyx":1276 + * cdef int i + * with nogil: + * for i in prange(self.engine.n_verts): # <<<<<<<<<<<<<< + * self.engine.m.verts[i] = self.vec_data[i] + * + */ + +# line 1276 "core/core2.pyx" + __pyx_t_6 = __pyx_v_self->engine->n_verts; + +# line 1276 "core/core2.pyx" + if ((1 == 0)) abort(); + +# line 1276 "core/core2.pyx" + { + +# line 1276 "core/core2.pyx" + #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))))) + +# line 1276 "core/core2.pyx" + #undef likely + +# line 1276 "core/core2.pyx" + #undef unlikely + #define likely(x) (x) + #define unlikely(x) (x) + +# line 1276 "core/core2.pyx" + #endif + +# line 1276 "core/core2.pyx" + __pyx_t_8 = (__pyx_t_6 - 0 + 1 - 1/abs(1)) / 1; + +# line 1276 "core/core2.pyx" + if (__pyx_t_8 > 0) + +# line 1276 "core/core2.pyx" + { + +# line 1276 "core/core2.pyx" + #ifdef _OPENMP + +# line 1276 "core/core2.pyx" + #pragma omp parallel + #endif /* _OPENMP */ + { + #ifdef _OPENMP + #pragma omp for firstprivate(__pyx_v_i) lastprivate(__pyx_v_i) + #endif /* _OPENMP */ + for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_8; __pyx_t_7++){ + { + __pyx_v_i = (int)(0 + 1 * __pyx_t_7); + + /* "core/core2.pyx":1277 + * with nogil: + * for i in prange(self.engine.n_verts): + * self.engine.m.verts[i] = self.vec_data[i] # <<<<<<<<<<<<<< + * + * cpdef void masked_store(self, float factor=1, bint invert=False): + */ + +# line 1277 "core/core2.pyx" + (__pyx_v_self->engine->m->verts[__pyx_v_i]) = (__pyx_v_self->vec_data[__pyx_v_i]); + +# line 1277 "core/core2.pyx" + } + +# line 1277 "core/core2.pyx" + } + +# line 1277 "core/core2.pyx" + } + +# line 1277 "core/core2.pyx" + } + +# line 1277 "core/core2.pyx" + } + +# line 1277 "core/core2.pyx" + #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))))) + +# line 1277 "core/core2.pyx" + #undef likely + +# line 1277 "core/core2.pyx" + #undef unlikely + #define likely(x) __builtin_expect(!!(x), 1) + #define unlikely(x) __builtin_expect(!!(x), 0) + +# line 1277 "core/core2.pyx" + #endif + +# line 1277 "core/core2.pyx" + } + + /* "core/core2.pyx":1275 + * + * cdef int i + * with nogil: # <<<<<<<<<<<<<< + * for i in prange(self.engine.n_verts): + * self.engine.m.verts[i] = self.vec_data[i] + */ + /*finally:*/ { + /*normal exit:*/{ + #ifdef WITH_THREAD + __Pyx_FastGIL_Forget(); + Py_BLOCK_THREADS + #endif + goto __pyx_L6; + } + __pyx_L6:; + } + } + + /* "core/core2.pyx":1270 + * self.vec_data[i] = self.engine.m.verts[i] + * + * cpdef void store(self): # <<<<<<<<<<<<<< + * if self.mask == NULL: + * return + */ + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_WriteUnraisable("softwrap_core2.SpringEngineMask.store", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); + __pyx_L0:; + __Pyx_RefNannyFinishContext(); +} + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_16SpringEngineMask_11store(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_16SpringEngineMask_11store(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("store (wrapper)", 0); + __pyx_r = __pyx_pf_14softwrap_core2_16SpringEngineMask_10store(((struct __pyx_obj_14softwrap_core2_SpringEngineMask *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_16SpringEngineMask_10store(struct __pyx_obj_14softwrap_core2_SpringEngineMask *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("store", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_void_to_None(__pyx_f_14softwrap_core2_16SpringEngineMask_store(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1270, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("softwrap_core2.SpringEngineMask.store", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":1279 + * self.engine.m.verts[i] = self.vec_data[i] + * + * cpdef void masked_store(self, float factor=1, bint invert=False): # <<<<<<<<<<<<<< + * if self.mask == NULL: + * return + */ + +static PyObject *__pyx_pw_14softwrap_core2_16SpringEngineMask_13masked_store(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static void __pyx_f_14softwrap_core2_16SpringEngineMask_masked_store(struct __pyx_obj_14softwrap_core2_SpringEngineMask *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_14softwrap_core2_16SpringEngineMask_masked_store *__pyx_optional_args) { + float __pyx_v_factor = ((float)1.0); + int __pyx_v_invert = ((int)0); + int __pyx_v_i; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + int __pyx_t_7; + PyObject *__pyx_t_8 = NULL; + int __pyx_t_9; + int __pyx_t_10; + int __pyx_t_11; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("masked_store", 0); + if (__pyx_optional_args) { + if (__pyx_optional_args->__pyx_n > 0) { + __pyx_v_factor = __pyx_optional_args->factor; + if (__pyx_optional_args->__pyx_n > 1) { + __pyx_v_invert = __pyx_optional_args->invert; + } + } + } + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) { + #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS + static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; + if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) { + PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); + #endif + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_masked_store); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1279, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_14softwrap_core2_16SpringEngineMask_13masked_store)) { + __pyx_t_3 = PyFloat_FromDouble(__pyx_v_factor); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1279, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_v_invert); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1279, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_INCREF(__pyx_t_1); + __pyx_t_5 = __pyx_t_1; __pyx_t_6 = NULL; + __pyx_t_7 = 0; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { + __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5); + if (likely(__pyx_t_6)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); + __Pyx_INCREF(__pyx_t_6); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_5, function); + __pyx_t_7 = 1; + } + } + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_5)) { + PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_3, __pyx_t_4}; + __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1279, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { + PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_3, __pyx_t_4}; + __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1279, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } else + #endif + { + __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1279, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + if (__pyx_t_6) { + __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL; + } + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_4); + __pyx_t_3 = 0; + __pyx_t_4 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1279, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + } + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS + __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); + __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self)); + if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) { + __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; + } + #endif + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS + } + #endif + } + + /* "core/core2.pyx":1280 + * + * cpdef void masked_store(self, float factor=1, bint invert=False): + * if self.mask == NULL: # <<<<<<<<<<<<<< + * return + * + */ + +# line 1280 "core/core2.pyx" + __pyx_t_9 = ((__pyx_v_self->mask == NULL) != 0); + +# line 1280 "core/core2.pyx" + if (__pyx_t_9) { + + /* "core/core2.pyx":1281 + * cpdef void masked_store(self, float factor=1, bint invert=False): + * if self.mask == NULL: + * return # <<<<<<<<<<<<<< + * + * cdef int i + */ + +# line 1281 "core/core2.pyx" + goto __pyx_L0; + + /* "core/core2.pyx":1280 + * + * cpdef void masked_store(self, float factor=1, bint invert=False): + * if self.mask == NULL: # <<<<<<<<<<<<<< + * return + * + */ + +# line 1280 "core/core2.pyx" + } + + /* "core/core2.pyx":1284 + * + * cdef int i + * with nogil: # <<<<<<<<<<<<<< + * if invert: + * for i in prange(self.engine.n_verts): + */ + +# line 1284 "core/core2.pyx" + { + +# line 1284 "core/core2.pyx" + #ifdef WITH_THREAD + +# line 1284 "core/core2.pyx" + PyThreadState *_save; + +# line 1284 "core/core2.pyx" + Py_UNBLOCK_THREADS + +# line 1284 "core/core2.pyx" + __Pyx_FastGIL_Remember(); + +# line 1284 "core/core2.pyx" + #endif + /*try:*/ { + + /* "core/core2.pyx":1285 + * cdef int i + * with nogil: + * if invert: # <<<<<<<<<<<<<< + * for i in prange(self.engine.n_verts): + * self.engine.m.verts[i] = self.engine.m.verts[i].lerp(self.vec_data[i], (1.0 - self.mask[i]) * factor) + */ + +# line 1285 "core/core2.pyx" + __pyx_t_9 = (__pyx_v_invert != 0); + +# line 1285 "core/core2.pyx" + if (__pyx_t_9) { + + /* "core/core2.pyx":1286 + * with nogil: + * if invert: + * for i in prange(self.engine.n_verts): # <<<<<<<<<<<<<< + * self.engine.m.verts[i] = self.engine.m.verts[i].lerp(self.vec_data[i], (1.0 - self.mask[i]) * factor) + * else: + */ + +# line 1286 "core/core2.pyx" + __pyx_t_7 = __pyx_v_self->engine->n_verts; + +# line 1286 "core/core2.pyx" + if ((1 == 0)) abort(); + +# line 1286 "core/core2.pyx" + { + +# line 1286 "core/core2.pyx" + #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))))) + +# line 1286 "core/core2.pyx" + #undef likely + +# line 1286 "core/core2.pyx" + #undef unlikely + #define likely(x) (x) + #define unlikely(x) (x) + +# line 1286 "core/core2.pyx" + #endif + +# line 1286 "core/core2.pyx" + __pyx_t_11 = (__pyx_t_7 - 0 + 1 - 1/abs(1)) / 1; + +# line 1286 "core/core2.pyx" + if (__pyx_t_11 > 0) + +# line 1286 "core/core2.pyx" + { + +# line 1286 "core/core2.pyx" + #ifdef _OPENMP + +# line 1286 "core/core2.pyx" + #pragma omp parallel + #endif /* _OPENMP */ + { + #ifdef _OPENMP + #pragma omp for firstprivate(__pyx_v_i) lastprivate(__pyx_v_i) + #endif /* _OPENMP */ + for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_11; __pyx_t_10++){ + { + __pyx_v_i = (int)(0 + 1 * __pyx_t_10); + + /* "core/core2.pyx":1287 + * if invert: + * for i in prange(self.engine.n_verts): + * self.engine.m.verts[i] = self.engine.m.verts[i].lerp(self.vec_data[i], (1.0 - self.mask[i]) * factor) # <<<<<<<<<<<<<< + * else: + * for i in prange(self.engine.n_verts): + */ + +# line 1287 "core/core2.pyx" + (__pyx_v_self->engine->m->verts[__pyx_v_i]) = (__pyx_v_self->engine->m->verts[__pyx_v_i]).lerp((__pyx_v_self->vec_data[__pyx_v_i]), ((((float)1.0) - (__pyx_v_self->mask[__pyx_v_i])) * __pyx_v_factor)); + +# line 1287 "core/core2.pyx" + } + +# line 1287 "core/core2.pyx" + } + +# line 1287 "core/core2.pyx" + } + +# line 1287 "core/core2.pyx" + } + +# line 1287 "core/core2.pyx" + } + +# line 1287 "core/core2.pyx" + #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))))) + +# line 1287 "core/core2.pyx" + #undef likely + +# line 1287 "core/core2.pyx" + #undef unlikely + #define likely(x) __builtin_expect(!!(x), 1) + #define unlikely(x) __builtin_expect(!!(x), 0) + +# line 1287 "core/core2.pyx" + #endif + + /* "core/core2.pyx":1285 + * cdef int i + * with nogil: + * if invert: # <<<<<<<<<<<<<< + * for i in prange(self.engine.n_verts): + * self.engine.m.verts[i] = self.engine.m.verts[i].lerp(self.vec_data[i], (1.0 - self.mask[i]) * factor) + */ + +# line 1285 "core/core2.pyx" + goto __pyx_L7; + +# line 1285 "core/core2.pyx" + } + + /* "core/core2.pyx":1289 + * self.engine.m.verts[i] = self.engine.m.verts[i].lerp(self.vec_data[i], (1.0 - self.mask[i]) * factor) + * else: + * for i in prange(self.engine.n_verts): # <<<<<<<<<<<<<< + * self.engine.m.verts[i] = self.engine.m.verts[i].lerp(self.vec_data[i], self.mask[i] * factor) + * + */ + /*else*/ { + __pyx_t_11 = __pyx_v_self->engine->n_verts; + if ((1 == 0)) abort(); + { + #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))))) + #undef likely + #undef unlikely + #define likely(x) (x) + #define unlikely(x) (x) + #endif + __pyx_t_7 = (__pyx_t_11 - 0 + 1 - 1/abs(1)) / 1; + if (__pyx_t_7 > 0) + { + #ifdef _OPENMP + #pragma omp parallel + #endif /* _OPENMP */ + { + #ifdef _OPENMP + #pragma omp for firstprivate(__pyx_v_i) lastprivate(__pyx_v_i) + #endif /* _OPENMP */ + for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_7; __pyx_t_10++){ + { + __pyx_v_i = (int)(0 + 1 * __pyx_t_10); + + /* "core/core2.pyx":1290 + * else: + * for i in prange(self.engine.n_verts): + * self.engine.m.verts[i] = self.engine.m.verts[i].lerp(self.vec_data[i], self.mask[i] * factor) # <<<<<<<<<<<<<< + * + * cpdef set(self, list vec_data): + */ + +# line 1290 "core/core2.pyx" + (__pyx_v_self->engine->m->verts[__pyx_v_i]) = (__pyx_v_self->engine->m->verts[__pyx_v_i]).lerp((__pyx_v_self->vec_data[__pyx_v_i]), ((__pyx_v_self->mask[__pyx_v_i]) * __pyx_v_factor)); + +# line 1290 "core/core2.pyx" + } + +# line 1290 "core/core2.pyx" + } + +# line 1290 "core/core2.pyx" + } + +# line 1290 "core/core2.pyx" + } + +# line 1290 "core/core2.pyx" + } + +# line 1290 "core/core2.pyx" + #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))))) + +# line 1290 "core/core2.pyx" + #undef likely + +# line 1290 "core/core2.pyx" + #undef unlikely + #define likely(x) __builtin_expect(!!(x), 1) + #define unlikely(x) __builtin_expect(!!(x), 0) + +# line 1290 "core/core2.pyx" + #endif + +# line 1290 "core/core2.pyx" + } + +# line 1290 "core/core2.pyx" + __pyx_L7:; + +# line 1290 "core/core2.pyx" + } + + /* "core/core2.pyx":1284 + * + * cdef int i + * with nogil: # <<<<<<<<<<<<<< + * if invert: + * for i in prange(self.engine.n_verts): + */ + /*finally:*/ { + /*normal exit:*/{ + #ifdef WITH_THREAD + __Pyx_FastGIL_Forget(); + Py_BLOCK_THREADS + #endif + goto __pyx_L6; + } + __pyx_L6:; + } + } + + /* "core/core2.pyx":1279 + * self.engine.m.verts[i] = self.vec_data[i] + * + * cpdef void masked_store(self, float factor=1, bint invert=False): # <<<<<<<<<<<<<< + * if self.mask == NULL: + * return + */ + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_WriteUnraisable("softwrap_core2.SpringEngineMask.masked_store", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); + __pyx_L0:; + __Pyx_RefNannyFinishContext(); +} + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_16SpringEngineMask_13masked_store(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_16SpringEngineMask_13masked_store(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + float __pyx_v_factor; + int __pyx_v_invert; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("masked_store (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_factor,&__pyx_n_s_invert,0}; + PyObject* values[2] = {0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + CYTHON_FALLTHROUGH; + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + CYTHON_FALLTHROUGH; + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (kw_args > 0) { + PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_factor); + if (value) { values[0] = value; kw_args--; } + } + CYTHON_FALLTHROUGH; + case 1: + if (kw_args > 0) { + PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_invert); + if (value) { values[1] = value; kw_args--; } + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "masked_store") < 0)) __PYX_ERR(0, 1279, __pyx_L3_error) + } + } else { + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + CYTHON_FALLTHROUGH; + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + CYTHON_FALLTHROUGH; + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + } + if (values[0]) { + __pyx_v_factor = __pyx_PyFloat_AsFloat(values[0]); if (unlikely((__pyx_v_factor == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 1279, __pyx_L3_error) + } else { + __pyx_v_factor = ((float)1.0); + } + if (values[1]) { + __pyx_v_invert = __Pyx_PyObject_IsTrue(values[1]); if (unlikely((__pyx_v_invert == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1279, __pyx_L3_error) + } else { + __pyx_v_invert = ((int)0); + } + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("masked_store", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1279, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("softwrap_core2.SpringEngineMask.masked_store", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_14softwrap_core2_16SpringEngineMask_12masked_store(((struct __pyx_obj_14softwrap_core2_SpringEngineMask *)__pyx_v_self), __pyx_v_factor, __pyx_v_invert); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_16SpringEngineMask_12masked_store(struct __pyx_obj_14softwrap_core2_SpringEngineMask *__pyx_v_self, float __pyx_v_factor, int __pyx_v_invert) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + struct __pyx_opt_args_14softwrap_core2_16SpringEngineMask_masked_store __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("masked_store", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1.__pyx_n = 2; + __pyx_t_1.factor = __pyx_v_factor; + __pyx_t_1.invert = __pyx_v_invert; + __pyx_vtabptr_14softwrap_core2_SpringEngineMask->masked_store(__pyx_v_self, 1, &__pyx_t_1); + __pyx_t_2 = __Pyx_void_to_None(NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1279, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("softwrap_core2.SpringEngineMask.masked_store", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":1292 + * self.engine.m.verts[i] = self.engine.m.verts[i].lerp(self.vec_data[i], self.mask[i] * factor) + * + * cpdef set(self, list vec_data): # <<<<<<<<<<<<<< + * if self.mask == NULL: + * return + */ + +static PyObject *__pyx_pw_14softwrap_core2_16SpringEngineMask_15set(PyObject *__pyx_v_self, PyObject *__pyx_v_vec_data); /*proto*/ +static PyObject *__pyx_f_14softwrap_core2_16SpringEngineMask_set(struct __pyx_obj_14softwrap_core2_SpringEngineMask *__pyx_v_self, PyObject *__pyx_v_vec_data, int __pyx_skip_dispatch) { + int __pyx_v_i; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + int __pyx_t_5; + Py_ssize_t __pyx_t_6; + long __pyx_t_7; + long __pyx_t_8; + int __pyx_t_9; + float __pyx_t_10; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("set", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) { + #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS + static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; + if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) { + PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); + #endif + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_set); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1292, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_14softwrap_core2_16SpringEngineMask_15set)) { + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_t_1); + __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { + __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); + if (likely(__pyx_t_4)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); + __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_3, function); + } + } + __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_vec_data) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_vec_data); + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1292, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS + __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); + __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self)); + if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) { + __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; + } + #endif + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS + } + #endif + } + + /* "core/core2.pyx":1293 + * + * cpdef set(self, list vec_data): + * if self.mask == NULL: # <<<<<<<<<<<<<< + * return + * + */ + +# line 1293 "core/core2.pyx" + __pyx_t_5 = ((__pyx_v_self->mask == NULL) != 0); + +# line 1293 "core/core2.pyx" + if (__pyx_t_5) { + + /* "core/core2.pyx":1294 + * cpdef set(self, list vec_data): + * if self.mask == NULL: + * return # <<<<<<<<<<<<<< + * + * cdef int i + */ + +# line 1294 "core/core2.pyx" + __Pyx_XDECREF(__pyx_r); + +# line 1294 "core/core2.pyx" + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + +# line 1294 "core/core2.pyx" + goto __pyx_L0; + + /* "core/core2.pyx":1293 + * + * cpdef set(self, list vec_data): + * if self.mask == NULL: # <<<<<<<<<<<<<< + * return + * + */ + +# line 1293 "core/core2.pyx" + } + + /* "core/core2.pyx":1297 + * + * cdef int i + * if not len(vec_data) == self.engine.n_verts * 3: # <<<<<<<<<<<<<< + * raise ValueError('vec_data must have the same number of elements as engine verts times 3') + * + */ + +# line 1297 "core/core2.pyx" + if (unlikely(__pyx_v_vec_data == Py_None)) { + +# line 1297 "core/core2.pyx" + PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); + +# line 1297 "core/core2.pyx" + __PYX_ERR(0, 1297, __pyx_L1_error) + +# line 1297 "core/core2.pyx" + } + +# line 1297 "core/core2.pyx" + __pyx_t_6 = PyList_GET_SIZE(__pyx_v_vec_data); if (unlikely(__pyx_t_6 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1297, __pyx_L1_error) + +# line 1297 "core/core2.pyx" + __pyx_t_5 = ((!((__pyx_t_6 == (__pyx_v_self->engine->n_verts * 3)) != 0)) != 0); + +# line 1297 "core/core2.pyx" + if (unlikely(__pyx_t_5)) { + + /* "core/core2.pyx":1298 + * cdef int i + * if not len(vec_data) == self.engine.n_verts * 3: + * raise ValueError('vec_data must have the same number of elements as engine verts times 3') # <<<<<<<<<<<<<< + * + * for i in range(self.engine.n_verts * 3): + */ + +# line 1298 "core/core2.pyx" + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__25, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1298, __pyx_L1_error) + +# line 1298 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_1); + +# line 1298 "core/core2.pyx" + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + +# line 1298 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + +# line 1298 "core/core2.pyx" + __PYX_ERR(0, 1298, __pyx_L1_error) + + /* "core/core2.pyx":1297 + * + * cdef int i + * if not len(vec_data) == self.engine.n_verts * 3: # <<<<<<<<<<<<<< + * raise ValueError('vec_data must have the same number of elements as engine verts times 3') + * + */ + +# line 1297 "core/core2.pyx" + } + + /* "core/core2.pyx":1300 + * raise ValueError('vec_data must have the same number of elements as engine verts times 3') + * + * for i in range(self.engine.n_verts * 3): # <<<<<<<<<<<<<< + * self.vec_data[i // 3].v[i % 3] = vec_data[i] + * + */ + +# line 1300 "core/core2.pyx" + __pyx_t_7 = (__pyx_v_self->engine->n_verts * 3); + +# line 1300 "core/core2.pyx" + __pyx_t_8 = __pyx_t_7; + +# line 1300 "core/core2.pyx" + for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_8; __pyx_t_9+=1) { + +# line 1300 "core/core2.pyx" + __pyx_v_i = __pyx_t_9; + + /* "core/core2.pyx":1301 + * + * for i in range(self.engine.n_verts * 3): + * self.vec_data[i // 3].v[i % 3] = vec_data[i] # <<<<<<<<<<<<<< + * + * def masked_context(self, float factor=1, bint invert=False): + */ + +# line 1301 "core/core2.pyx" + if (unlikely(__pyx_v_vec_data == Py_None)) { + +# line 1301 "core/core2.pyx" + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + +# line 1301 "core/core2.pyx" + __PYX_ERR(0, 1301, __pyx_L1_error) + +# line 1301 "core/core2.pyx" + } + +# line 1301 "core/core2.pyx" + __pyx_t_1 = __Pyx_GetItemInt_List(__pyx_v_vec_data, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 1, 1, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1301, __pyx_L1_error) + +# line 1301 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_1); + +# line 1301 "core/core2.pyx" + __pyx_t_10 = __pyx_PyFloat_AsFloat(__pyx_t_1); if (unlikely((__pyx_t_10 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 1301, __pyx_L1_error) + +# line 1301 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + +# line 1301 "core/core2.pyx" + ((__pyx_v_self->vec_data[(__pyx_v_i / 3)]).v[(__pyx_v_i % 3)]) = __pyx_t_10; + +# line 1301 "core/core2.pyx" + } + + /* "core/core2.pyx":1292 + * self.engine.m.verts[i] = self.engine.m.verts[i].lerp(self.vec_data[i], self.mask[i] * factor) + * + * cpdef set(self, list vec_data): # <<<<<<<<<<<<<< + * if self.mask == NULL: + * return + */ + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("softwrap_core2.SpringEngineMask.set", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_16SpringEngineMask_15set(PyObject *__pyx_v_self, PyObject *__pyx_v_vec_data); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_16SpringEngineMask_15set(PyObject *__pyx_v_self, PyObject *__pyx_v_vec_data) { + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("set (wrapper)", 0); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_vec_data), (&PyList_Type), 1, "vec_data", 1))) __PYX_ERR(0, 1292, __pyx_L1_error) + __pyx_r = __pyx_pf_14softwrap_core2_16SpringEngineMask_14set(((struct __pyx_obj_14softwrap_core2_SpringEngineMask *)__pyx_v_self), ((PyObject*)__pyx_v_vec_data)); + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_16SpringEngineMask_14set(struct __pyx_obj_14softwrap_core2_SpringEngineMask *__pyx_v_self, PyObject *__pyx_v_vec_data) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("set", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_f_14softwrap_core2_16SpringEngineMask_set(__pyx_v_self, __pyx_v_vec_data, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1292, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("softwrap_core2.SpringEngineMask.set", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":1303 + * self.vec_data[i // 3].v[i % 3] = vec_data[i] + * + * def masked_context(self, float factor=1, bint invert=False): # <<<<<<<<<<<<<< + * return _MaskContextManager(self, factor, invert) + * + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_16SpringEngineMask_17masked_context(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_16SpringEngineMask_17masked_context(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + float __pyx_v_factor; + int __pyx_v_invert; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("masked_context (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_factor,&__pyx_n_s_invert,0}; + PyObject* values[2] = {0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + CYTHON_FALLTHROUGH; + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + CYTHON_FALLTHROUGH; + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (kw_args > 0) { + PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_factor); + if (value) { values[0] = value; kw_args--; } + } + CYTHON_FALLTHROUGH; + case 1: + if (kw_args > 0) { + PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_invert); + if (value) { values[1] = value; kw_args--; } + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "masked_context") < 0)) __PYX_ERR(0, 1303, __pyx_L3_error) + } + } else { + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + CYTHON_FALLTHROUGH; + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + CYTHON_FALLTHROUGH; + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + } + if (values[0]) { + __pyx_v_factor = __pyx_PyFloat_AsFloat(values[0]); if (unlikely((__pyx_v_factor == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 1303, __pyx_L3_error) + } else { + __pyx_v_factor = ((float)1.0); + } + if (values[1]) { + __pyx_v_invert = __Pyx_PyObject_IsTrue(values[1]); if (unlikely((__pyx_v_invert == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1303, __pyx_L3_error) + } else { + __pyx_v_invert = ((int)0); + } + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("masked_context", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1303, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("softwrap_core2.SpringEngineMask.masked_context", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_14softwrap_core2_16SpringEngineMask_16masked_context(((struct __pyx_obj_14softwrap_core2_SpringEngineMask *)__pyx_v_self), __pyx_v_factor, __pyx_v_invert); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_16SpringEngineMask_16masked_context(struct __pyx_obj_14softwrap_core2_SpringEngineMask *__pyx_v_self, float __pyx_v_factor, int __pyx_v_invert) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("masked_context", 0); + + /* "core/core2.pyx":1304 + * + * def masked_context(self, float factor=1, bint invert=False): + * return _MaskContextManager(self, factor, invert) # <<<<<<<<<<<<<< + * + * def __dealloc__(self): + */ + +# line 1304 "core/core2.pyx" + __Pyx_XDECREF(__pyx_r); + +# line 1304 "core/core2.pyx" + __pyx_t_1 = PyFloat_FromDouble(__pyx_v_factor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1304, __pyx_L1_error) + +# line 1304 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_1); + +# line 1304 "core/core2.pyx" + __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_invert); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1304, __pyx_L1_error) + +# line 1304 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_2); + +# line 1304 "core/core2.pyx" + __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1304, __pyx_L1_error) + +# line 1304 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_3); + +# line 1304 "core/core2.pyx" + __Pyx_INCREF(((PyObject *)__pyx_v_self)); + +# line 1304 "core/core2.pyx" + __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); + +# line 1304 "core/core2.pyx" + PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_self)); + +# line 1304 "core/core2.pyx" + __Pyx_GIVEREF(__pyx_t_1); + +# line 1304 "core/core2.pyx" + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1); + +# line 1304 "core/core2.pyx" + __Pyx_GIVEREF(__pyx_t_2); + +# line 1304 "core/core2.pyx" + PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2); + +# line 1304 "core/core2.pyx" + __pyx_t_1 = 0; + +# line 1304 "core/core2.pyx" + __pyx_t_2 = 0; + +# line 1304 "core/core2.pyx" + __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_14softwrap_core2__MaskContextManager), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1304, __pyx_L1_error) + +# line 1304 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_2); + +# line 1304 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + +# line 1304 "core/core2.pyx" + __pyx_r = __pyx_t_2; + +# line 1304 "core/core2.pyx" + __pyx_t_2 = 0; + +# line 1304 "core/core2.pyx" + goto __pyx_L0; + + /* "core/core2.pyx":1303 + * self.vec_data[i // 3].v[i % 3] = vec_data[i] + * + * def masked_context(self, float factor=1, bint invert=False): # <<<<<<<<<<<<<< + * return _MaskContextManager(self, factor, invert) + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("softwrap_core2.SpringEngineMask.masked_context", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":1306 + * return _MaskContextManager(self, factor, invert) + * + * def __dealloc__(self): # <<<<<<<<<<<<<< + * fraeee(self.vec_data) + * fraeee(self.mask) + */ + +/* Python wrapper */ +static void __pyx_pw_14softwrap_core2_16SpringEngineMask_19__dealloc__(PyObject *__pyx_v_self); /*proto*/ +static void __pyx_pw_14softwrap_core2_16SpringEngineMask_19__dealloc__(PyObject *__pyx_v_self) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0); + __pyx_pf_14softwrap_core2_16SpringEngineMask_18__dealloc__(((struct __pyx_obj_14softwrap_core2_SpringEngineMask *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); +} + +static void __pyx_pf_14softwrap_core2_16SpringEngineMask_18__dealloc__(struct __pyx_obj_14softwrap_core2_SpringEngineMask *__pyx_v_self) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__dealloc__", 0); + + /* "core/core2.pyx":1307 + * + * def __dealloc__(self): + * fraeee(self.vec_data) # <<<<<<<<<<<<<< + * fraeee(self.mask) + * + */ + +# line 1307 "core/core2.pyx" + __pyx_f_14softwrap_core2_fraeee(__pyx_v_self->vec_data); + + /* "core/core2.pyx":1308 + * def __dealloc__(self): + * fraeee(self.vec_data) + * fraeee(self.mask) # <<<<<<<<<<<<<< + * + * + */ + +# line 1308 "core/core2.pyx" + __pyx_f_14softwrap_core2_fraeee(__pyx_v_self->mask); + + /* "core/core2.pyx":1306 + * return _MaskContextManager(self, factor, invert) + * + * def __dealloc__(self): # <<<<<<<<<<<<<< + * fraeee(self.vec_data) + * fraeee(self.mask) + */ + + /* function exit code */ + __Pyx_RefNannyFinishContext(); +} + +/* "(tree fragment)":1 + * def __reduce_cython__(self): # <<<<<<<<<<<<<< + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_16SpringEngineMask_21__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_16SpringEngineMask_21__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0); + __pyx_r = __pyx_pf_14softwrap_core2_16SpringEngineMask_20__reduce_cython__(((struct __pyx_obj_14softwrap_core2_SpringEngineMask *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_16SpringEngineMask_20__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_14softwrap_core2_SpringEngineMask *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__reduce_cython__", 0); + + /* "(tree fragment)":2 + * def __reduce_cython__(self): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + */ + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__26, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __PYX_ERR(1, 2, __pyx_L1_error) + + /* "(tree fragment)":1 + * def __reduce_cython__(self): # <<<<<<<<<<<<<< + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("softwrap_core2.SpringEngineMask.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "(tree fragment)":3 + * def __reduce_cython__(self): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_16SpringEngineMask_23__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_16SpringEngineMask_23__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0); + __pyx_r = __pyx_pf_14softwrap_core2_16SpringEngineMask_22__setstate_cython__(((struct __pyx_obj_14softwrap_core2_SpringEngineMask *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_16SpringEngineMask_22__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_14softwrap_core2_SpringEngineMask *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__setstate_cython__", 0); + + /* "(tree fragment)":4 + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< + */ + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__27, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __PYX_ERR(1, 4, __pyx_L1_error) + + /* "(tree fragment)":3 + * def __reduce_cython__(self): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("softwrap_core2.SpringEngineMask.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":1318 + * cdef readonly float[3] error + * + * def __cinit__(self, SpringEngine engine): # <<<<<<<<<<<<<< + * if engine == None: + * raise ValueError + */ + +/* Python wrapper */ +static int __pyx_pw_14softwrap_core2_11SymmetryMap_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pw_14softwrap_core2_11SymmetryMap_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_engine = 0; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_engine,0}; + PyObject* values[1] = {0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + CYTHON_FALLTHROUGH; + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_engine)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(0, 1318, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 1) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + } + __pyx_v_engine = ((struct __pyx_obj_14softwrap_core2_SpringEngine *)values[0]); + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1318, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("softwrap_core2.SymmetryMap.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_engine), __pyx_ptype_14softwrap_core2_SpringEngine, 1, "engine", 0))) __PYX_ERR(0, 1318, __pyx_L1_error) + __pyx_r = __pyx_pf_14softwrap_core2_11SymmetryMap___cinit__(((struct __pyx_obj_14softwrap_core2_SymmetryMap *)__pyx_v_self), __pyx_v_engine); + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_14softwrap_core2_11SymmetryMap___cinit__(struct __pyx_obj_14softwrap_core2_SymmetryMap *__pyx_v_self, struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_engine) { + struct __pyx_obj_14softwrap_core2_BVH *__pyx_v_bvh = 0; + int __pyx_v_i; + int __pyx_v_j; + int __pyx_v_axis; + int __pyx_v_v_index; + struct BvhNearestResult __pyx_v_result; + vec3 __pyx_v_v; + double __pyx_v_dist; + double __pyx_v_tmp_dist; + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_t_2; + void *__pyx_t_3; + float *__pyx_t_4; + float __pyx_t_5; + float __pyx_t_6; + float __pyx_t_7; + int __pyx_t_8; + int __pyx_t_9; + int __pyx_t_10; + int __pyx_t_11; + int __pyx_t_12; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__cinit__", 0); + + /* "core/core2.pyx":1319 + * + * def __cinit__(self, SpringEngine engine): + * if engine == None: # <<<<<<<<<<<<<< + * raise ValueError + * cdef BVH bvh = BVH(engine.m) + */ + +# line 1319 "core/core2.pyx" + __pyx_t_1 = PyObject_RichCompare(((PyObject *)__pyx_v_engine), Py_None, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1319, __pyx_L1_error) + +# line 1319 "core/core2.pyx" + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 1319, __pyx_L1_error) + +# line 1319 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + +# line 1319 "core/core2.pyx" + if (unlikely(__pyx_t_2)) { + + /* "core/core2.pyx":1320 + * def __cinit__(self, SpringEngine engine): + * if engine == None: + * raise ValueError # <<<<<<<<<<<<<< + * cdef BVH bvh = BVH(engine.m) + * self.engine = engine + */ + +# line 1320 "core/core2.pyx" + __Pyx_Raise(__pyx_builtin_ValueError, 0, 0, 0); + +# line 1320 "core/core2.pyx" + __PYX_ERR(0, 1320, __pyx_L1_error) + + /* "core/core2.pyx":1319 + * + * def __cinit__(self, SpringEngine engine): + * if engine == None: # <<<<<<<<<<<<<< + * raise ValueError + * cdef BVH bvh = BVH(engine.m) + */ + +# line 1319 "core/core2.pyx" + } + + /* "core/core2.pyx":1321 + * if engine == None: + * raise ValueError + * cdef BVH bvh = BVH(engine.m) # <<<<<<<<<<<<<< + * self.engine = engine + * self.symm_map = maelloc(sizeof(int) * engine.n_verts * 3, __LINE__) + */ + +# line 1321 "core/core2.pyx" + __pyx_t_1 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_14softwrap_core2_BVH), ((PyObject *)__pyx_v_engine->m)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1321, __pyx_L1_error) + +# line 1321 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_1); + +# line 1321 "core/core2.pyx" + __pyx_v_bvh = ((struct __pyx_obj_14softwrap_core2_BVH *)__pyx_t_1); + +# line 1321 "core/core2.pyx" + __pyx_t_1 = 0; + + /* "core/core2.pyx":1322 + * raise ValueError + * cdef BVH bvh = BVH(engine.m) + * self.engine = engine # <<<<<<<<<<<<<< + * self.symm_map = maelloc(sizeof(int) * engine.n_verts * 3, __LINE__) + * + */ + +# line 1322 "core/core2.pyx" + __Pyx_INCREF(((PyObject *)__pyx_v_engine)); + +# line 1322 "core/core2.pyx" + __Pyx_GIVEREF(((PyObject *)__pyx_v_engine)); + +# line 1322 "core/core2.pyx" + __Pyx_GOTREF(__pyx_v_self->engine); + +# line 1322 "core/core2.pyx" + __Pyx_DECREF(((PyObject *)__pyx_v_self->engine)); + +# line 1322 "core/core2.pyx" + __pyx_v_self->engine = __pyx_v_engine; + + /* "core/core2.pyx":1323 + * cdef BVH bvh = BVH(engine.m) + * self.engine = engine + * self.symm_map = maelloc(sizeof(int) * engine.n_verts * 3, __LINE__) # <<<<<<<<<<<<<< + * + * cdef int i, j, axis, v_index + */ + +# line 1323 "core/core2.pyx" + __pyx_t_3 = __pyx_f_14softwrap_core2_maelloc((((sizeof(int)) * __pyx_v_engine->n_verts) * 3), __LINE__); if (unlikely(__pyx_t_3 == ((void *)NULL))) __PYX_ERR(0, 1323, __pyx_L1_error) + +# line 1323 "core/core2.pyx" + __pyx_v_self->symm_map = ((int *)__pyx_t_3); + + /* "core/core2.pyx":1330 + * cdef double dist, tmp_dist + * + * self.error = (0, 0, 0) # <<<<<<<<<<<<<< + * + * with nogil: + */ + +# line 1330 "core/core2.pyx" + __pyx_t_4 = __pyx_v_self->error; + +# line 1330 "core/core2.pyx" + __pyx_t_5 = 0.0; + +# line 1330 "core/core2.pyx" + __pyx_t_6 = 0.0; + +# line 1330 "core/core2.pyx" + __pyx_t_7 = 0.0; + +# line 1330 "core/core2.pyx" + (__pyx_t_4[0]) = __pyx_t_5; + +# line 1330 "core/core2.pyx" + (__pyx_t_4[1]) = __pyx_t_6; + +# line 1330 "core/core2.pyx" + (__pyx_t_4[2]) = __pyx_t_7; + + /* "core/core2.pyx":1332 + * self.error = (0, 0, 0) + * + * with nogil: # <<<<<<<<<<<<<< + * for i in prange(self.engine.n_verts): + * for axis in range(3): + */ + +# line 1332 "core/core2.pyx" + { + +# line 1332 "core/core2.pyx" + #ifdef WITH_THREAD + +# line 1332 "core/core2.pyx" + PyThreadState *_save; + +# line 1332 "core/core2.pyx" + Py_UNBLOCK_THREADS + +# line 1332 "core/core2.pyx" + __Pyx_FastGIL_Remember(); + +# line 1332 "core/core2.pyx" + #endif + /*try:*/ { + + /* "core/core2.pyx":1333 + * + * with nogil: + * for i in prange(self.engine.n_verts): # <<<<<<<<<<<<<< + * for axis in range(3): + * dist = INFINITY + */ + +# line 1333 "core/core2.pyx" + __pyx_t_8 = __pyx_v_self->engine->n_verts; + +# line 1333 "core/core2.pyx" + if ((1 == 0)) abort(); + +# line 1333 "core/core2.pyx" + { + +# line 1333 "core/core2.pyx" + #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))))) + +# line 1333 "core/core2.pyx" + #undef likely + +# line 1333 "core/core2.pyx" + #undef unlikely + #define likely(x) (x) + #define unlikely(x) (x) + +# line 1333 "core/core2.pyx" + #endif + +# line 1333 "core/core2.pyx" + __pyx_t_10 = (__pyx_t_8 - 0 + 1 - 1/abs(1)) / 1; + +# line 1333 "core/core2.pyx" + if (__pyx_t_10 > 0) + +# line 1333 "core/core2.pyx" + { + +# line 1333 "core/core2.pyx" + #ifdef _OPENMP + +# line 1333 "core/core2.pyx" + #pragma omp parallel private(__pyx_t_11, __pyx_t_12, __pyx_t_2) + #endif /* _OPENMP */ + { + #ifdef _OPENMP + #pragma omp for lastprivate(__pyx_v_axis) lastprivate(__pyx_v_dist) firstprivate(__pyx_v_i) lastprivate(__pyx_v_i) lastprivate(__pyx_v_j) lastprivate(__pyx_v_result) lastprivate(__pyx_v_tmp_dist) lastprivate(__pyx_v_v) lastprivate(__pyx_v_v_index) + #endif /* _OPENMP */ + for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_10; __pyx_t_9++){ + { + __pyx_v_i = (int)(0 + 1 * __pyx_t_9); + /* Initialize private variables to invalid values */ + __pyx_v_axis = ((int)0xbad0bad0); + __pyx_v_dist = ((double)__PYX_NAN()); + __pyx_v_j = ((int)0xbad0bad0); + __pyx_v_tmp_dist = ((double)__PYX_NAN()); + __pyx_v_v_index = ((int)0xbad0bad0); + + /* "core/core2.pyx":1334 + * with nogil: + * for i in prange(self.engine.n_verts): + * for axis in range(3): # <<<<<<<<<<<<<< + * dist = INFINITY + * v = self.engine.m.verts[i] + */ + +# line 1334 "core/core2.pyx" + for (__pyx_t_11 = 0; __pyx_t_11 < 3; __pyx_t_11+=1) { + +# line 1334 "core/core2.pyx" + __pyx_v_axis = __pyx_t_11; + + /* "core/core2.pyx":1335 + * for i in prange(self.engine.n_verts): + * for axis in range(3): + * dist = INFINITY # <<<<<<<<<<<<<< + * v = self.engine.m.verts[i] + * v.v[axis] = -v.v[axis] + */ + +# line 1335 "core/core2.pyx" + __pyx_v_dist = INFINITY; + + /* "core/core2.pyx":1336 + * for axis in range(3): + * dist = INFINITY + * v = self.engine.m.verts[i] # <<<<<<<<<<<<<< + * v.v[axis] = -v.v[axis] + * + */ + +# line 1336 "core/core2.pyx" + __pyx_v_v = (__pyx_v_self->engine->m->verts[__pyx_v_i]); + + /* "core/core2.pyx":1337 + * dist = INFINITY + * v = self.engine.m.verts[i] + * v.v[axis] = -v.v[axis] # <<<<<<<<<<<<<< + * + * result = bvh._find_nearest(v) + */ + +# line 1337 "core/core2.pyx" + (__pyx_v_v.v[__pyx_v_axis]) = (-(__pyx_v_v.v[__pyx_v_axis])); + + /* "core/core2.pyx":1339 + * v.v[axis] = -v.v[axis] + * + * result = bvh._find_nearest(v) # <<<<<<<<<<<<<< + * for j in range(3): + * v_index = self.engine.m.triangles[result.tri_index][j] + */ + +# line 1339 "core/core2.pyx" + __pyx_v_result = __pyx_f_14softwrap_core2_3BVH__find_nearest(__pyx_v_bvh, __pyx_v_v); + + /* "core/core2.pyx":1340 + * + * result = bvh._find_nearest(v) + * for j in range(3): # <<<<<<<<<<<<<< + * v_index = self.engine.m.triangles[result.tri_index][j] + * tmp_dist = (self.engine.m.verts[v_index] - v).len() + */ + +# line 1340 "core/core2.pyx" + for (__pyx_t_12 = 0; __pyx_t_12 < 3; __pyx_t_12+=1) { + +# line 1340 "core/core2.pyx" + __pyx_v_j = __pyx_t_12; + + /* "core/core2.pyx":1341 + * result = bvh._find_nearest(v) + * for j in range(3): + * v_index = self.engine.m.triangles[result.tri_index][j] # <<<<<<<<<<<<<< + * tmp_dist = (self.engine.m.verts[v_index] - v).len() + * if tmp_dist < dist: + */ + +# line 1341 "core/core2.pyx" + __pyx_v_v_index = ((__pyx_v_self->engine->m->triangles[__pyx_v_result.tri_index])[__pyx_v_j]); + + /* "core/core2.pyx":1342 + * for j in range(3): + * v_index = self.engine.m.triangles[result.tri_index][j] + * tmp_dist = (self.engine.m.verts[v_index] - v).len() # <<<<<<<<<<<<<< + * if tmp_dist < dist: + * dist = tmp_dist + */ + +# line 1342 "core/core2.pyx" + __pyx_v_tmp_dist = ((__pyx_v_self->engine->m->verts[__pyx_v_v_index]) - __pyx_v_v).len(); + + /* "core/core2.pyx":1343 + * v_index = self.engine.m.triangles[result.tri_index][j] + * tmp_dist = (self.engine.m.verts[v_index] - v).len() + * if tmp_dist < dist: # <<<<<<<<<<<<<< + * dist = tmp_dist + * self.symm_map[i + self.engine.m.n_verts * axis] = v_index + */ + +# line 1343 "core/core2.pyx" + __pyx_t_2 = ((__pyx_v_tmp_dist < __pyx_v_dist) != 0); + +# line 1343 "core/core2.pyx" + if (__pyx_t_2) { + + /* "core/core2.pyx":1344 + * tmp_dist = (self.engine.m.verts[v_index] - v).len() + * if tmp_dist < dist: + * dist = tmp_dist # <<<<<<<<<<<<<< + * self.symm_map[i + self.engine.m.n_verts * axis] = v_index + * self.error[axis] = nmax(dist, self.error[axis]) + */ + +# line 1344 "core/core2.pyx" + __pyx_v_dist = __pyx_v_tmp_dist; + + /* "core/core2.pyx":1345 + * if tmp_dist < dist: + * dist = tmp_dist + * self.symm_map[i + self.engine.m.n_verts * axis] = v_index # <<<<<<<<<<<<<< + * self.error[axis] = nmax(dist, self.error[axis]) + * + */ + +# line 1345 "core/core2.pyx" + (__pyx_v_self->symm_map[(__pyx_v_i + (__pyx_v_self->engine->m->n_verts * __pyx_v_axis))]) = __pyx_v_v_index; + + /* "core/core2.pyx":1343 + * v_index = self.engine.m.triangles[result.tri_index][j] + * tmp_dist = (self.engine.m.verts[v_index] - v).len() + * if tmp_dist < dist: # <<<<<<<<<<<<<< + * dist = tmp_dist + * self.symm_map[i + self.engine.m.n_verts * axis] = v_index + */ + +# line 1343 "core/core2.pyx" + } + +# line 1343 "core/core2.pyx" + } + + /* "core/core2.pyx":1346 + * dist = tmp_dist + * self.symm_map[i + self.engine.m.n_verts * axis] = v_index + * self.error[axis] = nmax(dist, self.error[axis]) # <<<<<<<<<<<<<< + * + * def __getitem__(self, int index): + */ + +# line 1346 "core/core2.pyx" + (__pyx_v_self->error[__pyx_v_axis]) = nmax(__pyx_v_dist, (__pyx_v_self->error[__pyx_v_axis])); + +# line 1346 "core/core2.pyx" + } + +# line 1346 "core/core2.pyx" + } + +# line 1346 "core/core2.pyx" + } + +# line 1346 "core/core2.pyx" + } + +# line 1346 "core/core2.pyx" + } + +# line 1346 "core/core2.pyx" + } + +# line 1346 "core/core2.pyx" + #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))))) + +# line 1346 "core/core2.pyx" + #undef likely + +# line 1346 "core/core2.pyx" + #undef unlikely + #define likely(x) __builtin_expect(!!(x), 1) + #define unlikely(x) __builtin_expect(!!(x), 0) + +# line 1346 "core/core2.pyx" + #endif + +# line 1346 "core/core2.pyx" + } + + /* "core/core2.pyx":1332 + * self.error = (0, 0, 0) + * + * with nogil: # <<<<<<<<<<<<<< + * for i in prange(self.engine.n_verts): + * for axis in range(3): + */ + /*finally:*/ { + /*normal exit:*/{ + #ifdef WITH_THREAD + __Pyx_FastGIL_Forget(); + Py_BLOCK_THREADS + #endif + goto __pyx_L6; + } + __pyx_L6:; + } + } + + /* "core/core2.pyx":1318 + * cdef readonly float[3] error + * + * def __cinit__(self, SpringEngine engine): # <<<<<<<<<<<<<< + * if engine == None: + * raise ValueError + */ + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("softwrap_core2.SymmetryMap.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_XDECREF((PyObject *)__pyx_v_bvh); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":1348 + * self.error[axis] = nmax(dist, self.error[axis]) + * + * def __getitem__(self, int index): # <<<<<<<<<<<<<< + * if index < 0 or index >= self.engine.n_verts: + * raise KeyError + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_11SymmetryMap_3__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_index); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_11SymmetryMap_3__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_index) { + int __pyx_v_index; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0); + assert(__pyx_arg_index); { + __pyx_v_index = __Pyx_PyInt_As_int(__pyx_arg_index); if (unlikely((__pyx_v_index == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1348, __pyx_L3_error) + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("softwrap_core2.SymmetryMap.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_14softwrap_core2_11SymmetryMap_2__getitem__(((struct __pyx_obj_14softwrap_core2_SymmetryMap *)__pyx_v_self), ((int)__pyx_v_index)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} +static PyObject *__pyx_gb_14softwrap_core2_11SymmetryMap_11__getitem___2generator3(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */ + +/* "core/core2.pyx":1352 + * raise KeyError + * + * return tuple(self.symm_map[index + axis * self.engine.n_verts] for axis in range(3)) # <<<<<<<<<<<<<< + * + * cpdef void mirror(self, bint x, bint y, bint z): + */ + + +# line 1352 "core/core2.pyx" +static PyObject *__pyx_pf_14softwrap_core2_11SymmetryMap_11__getitem___genexpr(PyObject *__pyx_self) { + +# line 1352 "core/core2.pyx" + struct __pyx_obj_14softwrap_core2___pyx_scope_struct_5_genexpr *__pyx_cur_scope; + +# line 1352 "core/core2.pyx" + PyObject *__pyx_r = NULL; + +# line 1352 "core/core2.pyx" + __Pyx_RefNannyDeclarations + +# line 1352 "core/core2.pyx" + int __pyx_lineno = 0; + +# line 1352 "core/core2.pyx" + const char *__pyx_filename = NULL; + +# line 1352 "core/core2.pyx" + int __pyx_clineno = 0; + +# line 1352 "core/core2.pyx" + __Pyx_RefNannySetupContext("genexpr", 0); + +# line 1352 "core/core2.pyx" + __pyx_cur_scope = (struct __pyx_obj_14softwrap_core2___pyx_scope_struct_5_genexpr *)__pyx_tp_new_14softwrap_core2___pyx_scope_struct_5_genexpr(__pyx_ptype_14softwrap_core2___pyx_scope_struct_5_genexpr, __pyx_empty_tuple, NULL); + +# line 1352 "core/core2.pyx" + if (unlikely(!__pyx_cur_scope)) { + +# line 1352 "core/core2.pyx" + __pyx_cur_scope = ((struct __pyx_obj_14softwrap_core2___pyx_scope_struct_5_genexpr *)Py_None); + +# line 1352 "core/core2.pyx" + __Pyx_INCREF(Py_None); + +# line 1352 "core/core2.pyx" + __PYX_ERR(0, 1352, __pyx_L1_error) + +# line 1352 "core/core2.pyx" + } else { + +# line 1352 "core/core2.pyx" + __Pyx_GOTREF(__pyx_cur_scope); + +# line 1352 "core/core2.pyx" + } + +# line 1352 "core/core2.pyx" + __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_14softwrap_core2___pyx_scope_struct_4___getitem__ *) __pyx_self; + +# line 1352 "core/core2.pyx" + __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_outer_scope)); + +# line 1352 "core/core2.pyx" + __Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope); + +# line 1352 "core/core2.pyx" + { + +# line 1352 "core/core2.pyx" + __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_14softwrap_core2_11SymmetryMap_11__getitem___2generator3, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_getitem___locals_genexpr, __pyx_n_s_softwrap_core2); if (unlikely(!gen)) __PYX_ERR(0, 1352, __pyx_L1_error) + +# line 1352 "core/core2.pyx" + __Pyx_DECREF(__pyx_cur_scope); + +# line 1352 "core/core2.pyx" + __Pyx_RefNannyFinishContext(); + +# line 1352 "core/core2.pyx" + return (PyObject *) gen; + +# line 1352 "core/core2.pyx" + } + + /* function exit code */ + __pyx_L1_error:; + __Pyx_AddTraceback("softwrap_core2.SymmetryMap.__getitem__.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __Pyx_DECREF(((PyObject *)__pyx_cur_scope)); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_gb_14softwrap_core2_11SymmetryMap_11__getitem___2generator3(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */ +{ + struct __pyx_obj_14softwrap_core2___pyx_scope_struct_5_genexpr *__pyx_cur_scope = ((struct __pyx_obj_14softwrap_core2___pyx_scope_struct_5_genexpr *)__pyx_generator->closure); + PyObject *__pyx_r = NULL; + long __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + Py_ssize_t __pyx_t_5; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("genexpr", 0); + switch (__pyx_generator->resume_label) { + case 0: goto __pyx_L3_first_run; + case 1: goto __pyx_L6_resume_from_yield; + default: /* CPython raises the right error here */ + __Pyx_RefNannyFinishContext(); + return NULL; + } + __pyx_L3_first_run:; + if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1352, __pyx_L1_error) + for (__pyx_t_1 = 0; __pyx_t_1 < 3; __pyx_t_1+=1) { + __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1352, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_axis); + __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_axis, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __pyx_t_2 = 0; + if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1352, __pyx_L1_error) } + __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_index); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1352, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1352, __pyx_L1_error) } + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self->engine->n_verts); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1352, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyNumber_Multiply(__pyx_cur_scope->__pyx_v_axis, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1352, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyNumber_Add(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1352, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1352, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyInt_From_int((__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self->symm_map[__pyx_t_5])); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1352, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_r = __pyx_t_3; + __pyx_t_3 = 0; + __pyx_cur_scope->__pyx_t_0 = __pyx_t_1; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + __Pyx_Coroutine_ResetAndClearException(__pyx_generator); + /* return from generator, yielding value */ + __pyx_generator->resume_label = 1; + return __pyx_r; + __pyx_L6_resume_from_yield:; + __pyx_t_1 = __pyx_cur_scope->__pyx_t_0; + if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1352, __pyx_L1_error) + } + CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope); + + /* function exit code */ + PyErr_SetNone(PyExc_StopIteration); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_L0:; + __Pyx_XDECREF(__pyx_r); __pyx_r = 0; + #if !CYTHON_USE_EXC_INFO_STACK + __Pyx_Coroutine_ResetAndClearException(__pyx_generator); + #endif + __pyx_generator->resume_label = -1; + __Pyx_Coroutine_clear((PyObject*)__pyx_generator); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":1348 + * self.error[axis] = nmax(dist, self.error[axis]) + * + * def __getitem__(self, int index): # <<<<<<<<<<<<<< + * if index < 0 or index >= self.engine.n_verts: + * raise KeyError + */ + + +# line 1348 "core/core2.pyx" +static PyObject *__pyx_pf_14softwrap_core2_11SymmetryMap_2__getitem__(struct __pyx_obj_14softwrap_core2_SymmetryMap *__pyx_v_self, int __pyx_v_index) { + +# line 1348 "core/core2.pyx" + struct __pyx_obj_14softwrap_core2___pyx_scope_struct_4___getitem__ *__pyx_cur_scope; + +# line 1348 "core/core2.pyx" + PyObject *__pyx_gb_14softwrap_core2_11SymmetryMap_11__getitem___2generator3 = 0; + +# line 1348 "core/core2.pyx" + PyObject *__pyx_r = NULL; + +# line 1348 "core/core2.pyx" + __Pyx_RefNannyDeclarations + +# line 1348 "core/core2.pyx" + int __pyx_t_1; + +# line 1348 "core/core2.pyx" + int __pyx_t_2; + +# line 1348 "core/core2.pyx" + PyObject *__pyx_t_3 = NULL; + +# line 1348 "core/core2.pyx" + PyObject *__pyx_t_4 = NULL; + +# line 1348 "core/core2.pyx" + int __pyx_lineno = 0; + +# line 1348 "core/core2.pyx" + const char *__pyx_filename = NULL; + +# line 1348 "core/core2.pyx" + int __pyx_clineno = 0; + +# line 1348 "core/core2.pyx" + __Pyx_RefNannySetupContext("__getitem__", 0); + +# line 1348 "core/core2.pyx" + __pyx_cur_scope = (struct __pyx_obj_14softwrap_core2___pyx_scope_struct_4___getitem__ *)__pyx_tp_new_14softwrap_core2___pyx_scope_struct_4___getitem__(__pyx_ptype_14softwrap_core2___pyx_scope_struct_4___getitem__, __pyx_empty_tuple, NULL); + +# line 1348 "core/core2.pyx" + if (unlikely(!__pyx_cur_scope)) { + +# line 1348 "core/core2.pyx" + __pyx_cur_scope = ((struct __pyx_obj_14softwrap_core2___pyx_scope_struct_4___getitem__ *)Py_None); + +# line 1348 "core/core2.pyx" + __Pyx_INCREF(Py_None); + +# line 1348 "core/core2.pyx" + __PYX_ERR(0, 1348, __pyx_L1_error) + +# line 1348 "core/core2.pyx" + } else { + +# line 1348 "core/core2.pyx" + __Pyx_GOTREF(__pyx_cur_scope); + +# line 1348 "core/core2.pyx" + } + +# line 1348 "core/core2.pyx" + __pyx_cur_scope->__pyx_v_self = __pyx_v_self; + +# line 1348 "core/core2.pyx" + __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self); + +# line 1348 "core/core2.pyx" + __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self); + +# line 1348 "core/core2.pyx" + __pyx_cur_scope->__pyx_v_index = __pyx_v_index; + + /* "core/core2.pyx":1349 + * + * def __getitem__(self, int index): + * if index < 0 or index >= self.engine.n_verts: # <<<<<<<<<<<<<< + * raise KeyError + * + */ + +# line 1349 "core/core2.pyx" + __pyx_t_2 = ((__pyx_cur_scope->__pyx_v_index < 0) != 0); + +# line 1349 "core/core2.pyx" + if (!__pyx_t_2) { + +# line 1349 "core/core2.pyx" + } else { + +# line 1349 "core/core2.pyx" + __pyx_t_1 = __pyx_t_2; + +# line 1349 "core/core2.pyx" + goto __pyx_L4_bool_binop_done; + +# line 1349 "core/core2.pyx" + } + +# line 1349 "core/core2.pyx" + __pyx_t_2 = ((__pyx_cur_scope->__pyx_v_index >= __pyx_cur_scope->__pyx_v_self->engine->n_verts) != 0); + +# line 1349 "core/core2.pyx" + __pyx_t_1 = __pyx_t_2; + +# line 1349 "core/core2.pyx" + __pyx_L4_bool_binop_done:; + +# line 1349 "core/core2.pyx" + if (unlikely(__pyx_t_1)) { + + /* "core/core2.pyx":1350 + * def __getitem__(self, int index): + * if index < 0 or index >= self.engine.n_verts: + * raise KeyError # <<<<<<<<<<<<<< + * + * return tuple(self.symm_map[index + axis * self.engine.n_verts] for axis in range(3)) + */ + +# line 1350 "core/core2.pyx" + __Pyx_Raise(__pyx_builtin_KeyError, 0, 0, 0); + +# line 1350 "core/core2.pyx" + __PYX_ERR(0, 1350, __pyx_L1_error) + + /* "core/core2.pyx":1349 + * + * def __getitem__(self, int index): + * if index < 0 or index >= self.engine.n_verts: # <<<<<<<<<<<<<< + * raise KeyError + * + */ + +# line 1349 "core/core2.pyx" + } + + /* "core/core2.pyx":1352 + * raise KeyError + * + * return tuple(self.symm_map[index + axis * self.engine.n_verts] for axis in range(3)) # <<<<<<<<<<<<<< + * + * cpdef void mirror(self, bint x, bint y, bint z): + */ + +# line 1352 "core/core2.pyx" + __Pyx_XDECREF(__pyx_r); + +# line 1352 "core/core2.pyx" + __pyx_t_3 = __pyx_pf_14softwrap_core2_11SymmetryMap_11__getitem___genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1352, __pyx_L1_error) + +# line 1352 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_3); + +# line 1352 "core/core2.pyx" + __pyx_t_4 = __Pyx_PySequence_Tuple(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1352, __pyx_L1_error) + +# line 1352 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_4); + +# line 1352 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + +# line 1352 "core/core2.pyx" + __pyx_r = __pyx_t_4; + +# line 1352 "core/core2.pyx" + __pyx_t_4 = 0; + +# line 1352 "core/core2.pyx" + goto __pyx_L0; + + /* "core/core2.pyx":1348 + * self.error[axis] = nmax(dist, self.error[axis]) + * + * def __getitem__(self, int index): # <<<<<<<<<<<<<< + * if index < 0 or index >= self.engine.n_verts: + * raise KeyError + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("softwrap_core2.SymmetryMap.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF(__pyx_gb_14softwrap_core2_11SymmetryMap_11__getitem___2generator3); + __Pyx_DECREF(((PyObject *)__pyx_cur_scope)); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":1354 + * return tuple(self.symm_map[index + axis * self.engine.n_verts] for axis in range(3)) + * + * cpdef void mirror(self, bint x, bint y, bint z): # <<<<<<<<<<<<<< + * cdef int i, j, axis, v_index + * cdef int[3] mirror = (x, y, z) + */ + +static PyObject *__pyx_pw_14softwrap_core2_11SymmetryMap_5mirror(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static void __pyx_f_14softwrap_core2_11SymmetryMap_mirror(struct __pyx_obj_14softwrap_core2_SymmetryMap *__pyx_v_self, int __pyx_v_x, int __pyx_v_y, int __pyx_v_z, CYTHON_UNUSED int __pyx_skip_dispatch) { + int __pyx_v_i; + int __pyx_v_axis; + int __pyx_v_v_index; + int __pyx_v_mirror[3]; + vec3 __pyx_v_v; + __Pyx_RefNannyDeclarations + int *__pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + int __pyx_t_4; + int __pyx_t_5; + int __pyx_t_6; + int __pyx_t_7; + int __pyx_t_8; + vec3 *__pyx_t_9; + vec3 *__pyx_t_10; + __Pyx_RefNannySetupContext("mirror", 0); + + /* "core/core2.pyx":1356 + * cpdef void mirror(self, bint x, bint y, bint z): + * cdef int i, j, axis, v_index + * cdef int[3] mirror = (x, y, z) # <<<<<<<<<<<<<< + * cdef vec3 v + * + */ + +# line 1356 "core/core2.pyx" + __pyx_t_1 = __pyx_v_mirror; + +# line 1356 "core/core2.pyx" + __pyx_t_2 = __pyx_v_x; + +# line 1356 "core/core2.pyx" + __pyx_t_3 = __pyx_v_y; + +# line 1356 "core/core2.pyx" + __pyx_t_4 = __pyx_v_z; + +# line 1356 "core/core2.pyx" + (__pyx_t_1[0]) = __pyx_t_2; + +# line 1356 "core/core2.pyx" + (__pyx_t_1[1]) = __pyx_t_3; + +# line 1356 "core/core2.pyx" + (__pyx_t_1[2]) = __pyx_t_4; + + /* "core/core2.pyx":1359 + * cdef vec3 v + * + * with nogil: # <<<<<<<<<<<<<< + * for axis in range(3): + * if not mirror[axis]: + */ + +# line 1359 "core/core2.pyx" + { + +# line 1359 "core/core2.pyx" + #ifdef WITH_THREAD + +# line 1359 "core/core2.pyx" + PyThreadState *_save; + +# line 1359 "core/core2.pyx" + Py_UNBLOCK_THREADS + +# line 1359 "core/core2.pyx" + __Pyx_FastGIL_Remember(); + +# line 1359 "core/core2.pyx" + #endif + /*try:*/ { + + /* "core/core2.pyx":1360 + * + * with nogil: + * for axis in range(3): # <<<<<<<<<<<<<< + * if not mirror[axis]: + * continue + */ + +# line 1360 "core/core2.pyx" + for (__pyx_t_5 = 0; __pyx_t_5 < 3; __pyx_t_5+=1) { + +# line 1360 "core/core2.pyx" + __pyx_v_axis = __pyx_t_5; + + /* "core/core2.pyx":1361 + * with nogil: + * for axis in range(3): + * if not mirror[axis]: # <<<<<<<<<<<<<< + * continue + * + */ + +# line 1361 "core/core2.pyx" + __pyx_t_4 = ((!((__pyx_v_mirror[__pyx_v_axis]) != 0)) != 0); + +# line 1361 "core/core2.pyx" + if (__pyx_t_4) { + + /* "core/core2.pyx":1362 + * for axis in range(3): + * if not mirror[axis]: + * continue # <<<<<<<<<<<<<< + * + * for i in prange(self.engine.n_verts): + */ + +# line 1362 "core/core2.pyx" + goto __pyx_L6_continue; + + /* "core/core2.pyx":1361 + * with nogil: + * for axis in range(3): + * if not mirror[axis]: # <<<<<<<<<<<<<< + * continue + * + */ + +# line 1361 "core/core2.pyx" + } + + /* "core/core2.pyx":1364 + * continue + * + * for i in prange(self.engine.n_verts): # <<<<<<<<<<<<<< + * v_index = self.symm_map[i + axis * self.engine.m.n_verts] + * v = self.engine.m.verts[v_index] + */ + +# line 1364 "core/core2.pyx" + __pyx_t_6 = __pyx_v_self->engine->n_verts; + +# line 1364 "core/core2.pyx" + if ((1 == 0)) abort(); + +# line 1364 "core/core2.pyx" + { + +# line 1364 "core/core2.pyx" + #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))))) + +# line 1364 "core/core2.pyx" + #undef likely + +# line 1364 "core/core2.pyx" + #undef unlikely + #define likely(x) (x) + #define unlikely(x) (x) + +# line 1364 "core/core2.pyx" + #endif + +# line 1364 "core/core2.pyx" + __pyx_t_8 = (__pyx_t_6 - 0 + 1 - 1/abs(1)) / 1; + +# line 1364 "core/core2.pyx" + if (__pyx_t_8 > 0) + +# line 1364 "core/core2.pyx" + { + +# line 1364 "core/core2.pyx" + #ifdef _OPENMP + +# line 1364 "core/core2.pyx" + #pragma omp parallel + #endif /* _OPENMP */ + { + #ifdef _OPENMP + #pragma omp for firstprivate(__pyx_v_i) lastprivate(__pyx_v_i) lastprivate(__pyx_v_v) lastprivate(__pyx_v_v_index) + #endif /* _OPENMP */ + for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_8; __pyx_t_7++){ + { + __pyx_v_i = (int)(0 + 1 * __pyx_t_7); + /* Initialize private variables to invalid values */ + __pyx_v_v_index = ((int)0xbad0bad0); + + /* "core/core2.pyx":1365 + * + * for i in prange(self.engine.n_verts): + * v_index = self.symm_map[i + axis * self.engine.m.n_verts] # <<<<<<<<<<<<<< + * v = self.engine.m.verts[v_index] + * v.v[axis] = -v.v[axis] + */ + +# line 1365 "core/core2.pyx" + __pyx_v_v_index = (__pyx_v_self->symm_map[(__pyx_v_i + (__pyx_v_axis * __pyx_v_self->engine->m->n_verts))]); + + /* "core/core2.pyx":1366 + * for i in prange(self.engine.n_verts): + * v_index = self.symm_map[i + axis * self.engine.m.n_verts] + * v = self.engine.m.verts[v_index] # <<<<<<<<<<<<<< + * v.v[axis] = -v.v[axis] + * self.engine.tmp_verts[i] = (self.engine.m.verts[i] + v) * 0.5 + */ + +# line 1366 "core/core2.pyx" + __pyx_v_v = (__pyx_v_self->engine->m->verts[__pyx_v_v_index]); + + /* "core/core2.pyx":1367 + * v_index = self.symm_map[i + axis * self.engine.m.n_verts] + * v = self.engine.m.verts[v_index] + * v.v[axis] = -v.v[axis] # <<<<<<<<<<<<<< + * self.engine.tmp_verts[i] = (self.engine.m.verts[i] + v) * 0.5 + * + */ + +# line 1367 "core/core2.pyx" + (__pyx_v_v.v[__pyx_v_axis]) = (-(__pyx_v_v.v[__pyx_v_axis])); + + /* "core/core2.pyx":1368 + * v = self.engine.m.verts[v_index] + * v.v[axis] = -v.v[axis] + * self.engine.tmp_verts[i] = (self.engine.m.verts[i] + v) * 0.5 # <<<<<<<<<<<<<< + * + * self.engine.tmp_verts, self.engine.m.verts = self.engine.m.verts, self.engine.tmp_verts + */ + +# line 1368 "core/core2.pyx" + (__pyx_v_self->engine->tmp_verts[__pyx_v_i]) = (((__pyx_v_self->engine->m->verts[__pyx_v_i]) + __pyx_v_v) * 0.5); + +# line 1368 "core/core2.pyx" + } + +# line 1368 "core/core2.pyx" + } + +# line 1368 "core/core2.pyx" + } + +# line 1368 "core/core2.pyx" + } + +# line 1368 "core/core2.pyx" + } + +# line 1368 "core/core2.pyx" + #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))))) + +# line 1368 "core/core2.pyx" + #undef likely + +# line 1368 "core/core2.pyx" + #undef unlikely + #define likely(x) __builtin_expect(!!(x), 1) + #define unlikely(x) __builtin_expect(!!(x), 0) + +# line 1368 "core/core2.pyx" + #endif + + /* "core/core2.pyx":1370 + * self.engine.tmp_verts[i] = (self.engine.m.verts[i] + v) * 0.5 + * + * self.engine.tmp_verts, self.engine.m.verts = self.engine.m.verts, self.engine.tmp_verts # <<<<<<<<<<<<<< + * + * def __dealloc__(self): + */ + +# line 1370 "core/core2.pyx" + __pyx_t_9 = __pyx_v_self->engine->m->verts; + +# line 1370 "core/core2.pyx" + __pyx_t_10 = __pyx_v_self->engine->tmp_verts; + +# line 1370 "core/core2.pyx" + __pyx_v_self->engine->tmp_verts = __pyx_t_9; + +# line 1370 "core/core2.pyx" + __pyx_v_self->engine->m->verts = __pyx_t_10; + +# line 1370 "core/core2.pyx" + __pyx_L6_continue:; + +# line 1370 "core/core2.pyx" + } + +# line 1370 "core/core2.pyx" + } + + /* "core/core2.pyx":1359 + * cdef vec3 v + * + * with nogil: # <<<<<<<<<<<<<< + * for axis in range(3): + * if not mirror[axis]: + */ + /*finally:*/ { + /*normal exit:*/{ + #ifdef WITH_THREAD + __Pyx_FastGIL_Forget(); + Py_BLOCK_THREADS + #endif + goto __pyx_L5; + } + __pyx_L5:; + } + } + + /* "core/core2.pyx":1354 + * return tuple(self.symm_map[index + axis * self.engine.n_verts] for axis in range(3)) + * + * cpdef void mirror(self, bint x, bint y, bint z): # <<<<<<<<<<<<<< + * cdef int i, j, axis, v_index + * cdef int[3] mirror = (x, y, z) + */ + + /* function exit code */ + __Pyx_RefNannyFinishContext(); +} + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_11SymmetryMap_5mirror(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_11SymmetryMap_5mirror(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + int __pyx_v_x; + int __pyx_v_y; + int __pyx_v_z; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("mirror (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,&__pyx_n_s_y,&__pyx_n_s_z,0}; + PyObject* values[3] = {0,0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + CYTHON_FALLTHROUGH; + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + CYTHON_FALLTHROUGH; + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + CYTHON_FALLTHROUGH; + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + CYTHON_FALLTHROUGH; + case 1: + if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_y)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("mirror", 1, 3, 3, 1); __PYX_ERR(0, 1354, __pyx_L3_error) + } + CYTHON_FALLTHROUGH; + case 2: + if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_z)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("mirror", 1, 3, 3, 2); __PYX_ERR(0, 1354, __pyx_L3_error) + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "mirror") < 0)) __PYX_ERR(0, 1354, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + } + __pyx_v_x = __Pyx_PyObject_IsTrue(values[0]); if (unlikely((__pyx_v_x == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1354, __pyx_L3_error) + __pyx_v_y = __Pyx_PyObject_IsTrue(values[1]); if (unlikely((__pyx_v_y == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1354, __pyx_L3_error) + __pyx_v_z = __Pyx_PyObject_IsTrue(values[2]); if (unlikely((__pyx_v_z == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1354, __pyx_L3_error) + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("mirror", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1354, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("softwrap_core2.SymmetryMap.mirror", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_14softwrap_core2_11SymmetryMap_4mirror(((struct __pyx_obj_14softwrap_core2_SymmetryMap *)__pyx_v_self), __pyx_v_x, __pyx_v_y, __pyx_v_z); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_11SymmetryMap_4mirror(struct __pyx_obj_14softwrap_core2_SymmetryMap *__pyx_v_self, int __pyx_v_x, int __pyx_v_y, int __pyx_v_z) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("mirror", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_void_to_None(__pyx_f_14softwrap_core2_11SymmetryMap_mirror(__pyx_v_self, __pyx_v_x, __pyx_v_y, __pyx_v_z, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1354, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("softwrap_core2.SymmetryMap.mirror", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":1372 + * self.engine.tmp_verts, self.engine.m.verts = self.engine.m.verts, self.engine.tmp_verts + * + * def __dealloc__(self): # <<<<<<<<<<<<<< + * fraeee(self.symm_map) + * + */ + +/* Python wrapper */ +static void __pyx_pw_14softwrap_core2_11SymmetryMap_7__dealloc__(PyObject *__pyx_v_self); /*proto*/ +static void __pyx_pw_14softwrap_core2_11SymmetryMap_7__dealloc__(PyObject *__pyx_v_self) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0); + __pyx_pf_14softwrap_core2_11SymmetryMap_6__dealloc__(((struct __pyx_obj_14softwrap_core2_SymmetryMap *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); +} + +static void __pyx_pf_14softwrap_core2_11SymmetryMap_6__dealloc__(struct __pyx_obj_14softwrap_core2_SymmetryMap *__pyx_v_self) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__dealloc__", 0); + + /* "core/core2.pyx":1373 + * + * def __dealloc__(self): + * fraeee(self.symm_map) # <<<<<<<<<<<<<< + * + * + */ + +# line 1373 "core/core2.pyx" + __pyx_f_14softwrap_core2_fraeee(__pyx_v_self->symm_map); + + /* "core/core2.pyx":1372 + * self.engine.tmp_verts, self.engine.m.verts = self.engine.m.verts, self.engine.tmp_verts + * + * def __dealloc__(self): # <<<<<<<<<<<<<< + * fraeee(self.symm_map) + * + */ + + /* function exit code */ + __Pyx_RefNannyFinishContext(); +} + +/* "core/core2.pyx":1316 + * cdef int* symm_map + * cdef SpringEngine engine + * cdef readonly float[3] error # <<<<<<<<<<<<<< + * + * def __cinit__(self, SpringEngine engine): + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_11SymmetryMap_5error_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_11SymmetryMap_5error_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_14softwrap_core2_11SymmetryMap_5error___get__(((struct __pyx_obj_14softwrap_core2_SymmetryMap *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_11SymmetryMap_5error___get__(struct __pyx_obj_14softwrap_core2_SymmetryMap *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_carray_to_py_float(__pyx_v_self->error, 3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1316, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("softwrap_core2.SymmetryMap.error.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "(tree fragment)":1 + * def __reduce_cython__(self): # <<<<<<<<<<<<<< + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_11SymmetryMap_9__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_11SymmetryMap_9__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0); + __pyx_r = __pyx_pf_14softwrap_core2_11SymmetryMap_8__reduce_cython__(((struct __pyx_obj_14softwrap_core2_SymmetryMap *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_11SymmetryMap_8__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_14softwrap_core2_SymmetryMap *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__reduce_cython__", 0); + + /* "(tree fragment)":2 + * def __reduce_cython__(self): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + */ + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__28, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __PYX_ERR(1, 2, __pyx_L1_error) + + /* "(tree fragment)":1 + * def __reduce_cython__(self): # <<<<<<<<<<<<<< + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("softwrap_core2.SymmetryMap.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "(tree fragment)":3 + * def __reduce_cython__(self): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_11SymmetryMap_11__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_11SymmetryMap_11__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0); + __pyx_r = __pyx_pf_14softwrap_core2_11SymmetryMap_10__setstate_cython__(((struct __pyx_obj_14softwrap_core2_SymmetryMap *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_11SymmetryMap_10__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_14softwrap_core2_SymmetryMap *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__setstate_cython__", 0); + + /* "(tree fragment)":4 + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< + */ + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__29, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __PYX_ERR(1, 4, __pyx_L1_error) + + /* "(tree fragment)":3 + * def __reduce_cython__(self): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("softwrap_core2.SymmetryMap.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":1386 + * cdef int n_verts + * + * def __init__(self, Mesh m, BVH bvh=None): # <<<<<<<<<<<<<< + * self.m = m + * self.n_verts = m.n_verts + */ + +/* Python wrapper */ +static int __pyx_pw_14softwrap_core2_12SpringEngine_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pw_14softwrap_core2_12SpringEngine_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + struct __pyx_obj_14softwrap_core2_Mesh *__pyx_v_m = 0; + struct __pyx_obj_14softwrap_core2_BVH *__pyx_v_bvh = 0; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_m,&__pyx_n_s_bvh,0}; + PyObject* values[2] = {0,0}; + values[1] = (PyObject *)((struct __pyx_obj_14softwrap_core2_BVH *)Py_None); + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + CYTHON_FALLTHROUGH; + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + CYTHON_FALLTHROUGH; + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_m)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + CYTHON_FALLTHROUGH; + case 1: + if (kw_args > 0) { + PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_bvh); + if (value) { values[1] = value; kw_args--; } + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 1386, __pyx_L3_error) + } + } else { + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + CYTHON_FALLTHROUGH; + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + break; + default: goto __pyx_L5_argtuple_error; + } + } + __pyx_v_m = ((struct __pyx_obj_14softwrap_core2_Mesh *)values[0]); + __pyx_v_bvh = ((struct __pyx_obj_14softwrap_core2_BVH *)values[1]); + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1386, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("softwrap_core2.SpringEngine.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_m), __pyx_ptype_14softwrap_core2_Mesh, 1, "m", 0))) __PYX_ERR(0, 1386, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_bvh), __pyx_ptype_14softwrap_core2_BVH, 1, "bvh", 0))) __PYX_ERR(0, 1386, __pyx_L1_error) + __pyx_r = __pyx_pf_14softwrap_core2_12SpringEngine___init__(((struct __pyx_obj_14softwrap_core2_SpringEngine *)__pyx_v_self), __pyx_v_m, __pyx_v_bvh); + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_14softwrap_core2_12SpringEngine___init__(struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_self, struct __pyx_obj_14softwrap_core2_Mesh *__pyx_v_m, struct __pyx_obj_14softwrap_core2_BVH *__pyx_v_bvh) { + int __pyx_v_i; + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + void *__pyx_t_2; + int __pyx_t_3; + int __pyx_t_4; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__init__", 0); + + /* "core/core2.pyx":1387 + * + * def __init__(self, Mesh m, BVH bvh=None): + * self.m = m # <<<<<<<<<<<<<< + * self.n_verts = m.n_verts + * self.snap_count = 0 + */ + +# line 1387 "core/core2.pyx" + __Pyx_INCREF(((PyObject *)__pyx_v_m)); + +# line 1387 "core/core2.pyx" + __Pyx_GIVEREF(((PyObject *)__pyx_v_m)); + +# line 1387 "core/core2.pyx" + __Pyx_GOTREF(__pyx_v_self->m); + +# line 1387 "core/core2.pyx" + __Pyx_DECREF(((PyObject *)__pyx_v_self->m)); + +# line 1387 "core/core2.pyx" + __pyx_v_self->m = __pyx_v_m; + + /* "core/core2.pyx":1388 + * def __init__(self, Mesh m, BVH bvh=None): + * self.m = m + * self.n_verts = m.n_verts # <<<<<<<<<<<<<< + * self.snap_count = 0 + * self.prev_verts = maelloc(sizeof(vec3) * self.n_verts, __LINE__) + */ + +# line 1388 "core/core2.pyx" + __pyx_t_1 = __pyx_v_m->n_verts; + +# line 1388 "core/core2.pyx" + __pyx_v_self->n_verts = __pyx_t_1; + + /* "core/core2.pyx":1389 + * self.m = m + * self.n_verts = m.n_verts + * self.snap_count = 0 # <<<<<<<<<<<<<< + * self.prev_verts = maelloc(sizeof(vec3) * self.n_verts, __LINE__) + * self.tmp_verts = maelloc(sizeof(vec3) * self.n_verts, __LINE__) + */ + +# line 1389 "core/core2.pyx" + __pyx_v_self->snap_count = 0; + + /* "core/core2.pyx":1390 + * self.n_verts = m.n_verts + * self.snap_count = 0 + * self.prev_verts = maelloc(sizeof(vec3) * self.n_verts, __LINE__) # <<<<<<<<<<<<<< + * self.tmp_verts = maelloc(sizeof(vec3) * self.n_verts, __LINE__) + * self.bvh_closest_indexes = maelloc(sizeof(vec3) * self.n_verts, __LINE__) + */ + +# line 1390 "core/core2.pyx" + __pyx_t_2 = __pyx_f_14softwrap_core2_maelloc(((sizeof(vec3)) * __pyx_v_self->n_verts), __LINE__); if (unlikely(__pyx_t_2 == ((void *)NULL))) __PYX_ERR(0, 1390, __pyx_L1_error) + +# line 1390 "core/core2.pyx" + __pyx_v_self->prev_verts = ((vec3 *)__pyx_t_2); + + /* "core/core2.pyx":1391 + * self.snap_count = 0 + * self.prev_verts = maelloc(sizeof(vec3) * self.n_verts, __LINE__) + * self.tmp_verts = maelloc(sizeof(vec3) * self.n_verts, __LINE__) # <<<<<<<<<<<<<< + * self.bvh_closest_indexes = maelloc(sizeof(vec3) * self.n_verts, __LINE__) + * cdef int i + */ + +# line 1391 "core/core2.pyx" + __pyx_t_2 = __pyx_f_14softwrap_core2_maelloc(((sizeof(vec3)) * __pyx_v_self->n_verts), __LINE__); if (unlikely(__pyx_t_2 == ((void *)NULL))) __PYX_ERR(0, 1391, __pyx_L1_error) + +# line 1391 "core/core2.pyx" + __pyx_v_self->tmp_verts = ((vec3 *)__pyx_t_2); + + /* "core/core2.pyx":1392 + * self.prev_verts = maelloc(sizeof(vec3) * self.n_verts, __LINE__) + * self.tmp_verts = maelloc(sizeof(vec3) * self.n_verts, __LINE__) + * self.bvh_closest_indexes = maelloc(sizeof(vec3) * self.n_verts, __LINE__) # <<<<<<<<<<<<<< + * cdef int i + * for i in range(self.n_verts): + */ + +# line 1392 "core/core2.pyx" + __pyx_t_2 = __pyx_f_14softwrap_core2_maelloc(((sizeof(vec3)) * __pyx_v_self->n_verts), __LINE__); if (unlikely(__pyx_t_2 == ((void *)NULL))) __PYX_ERR(0, 1392, __pyx_L1_error) + +# line 1392 "core/core2.pyx" + __pyx_v_self->bvh_closest_indexes = ((int *)__pyx_t_2); + + /* "core/core2.pyx":1394 + * self.bvh_closest_indexes = maelloc(sizeof(vec3) * self.n_verts, __LINE__) + * cdef int i + * for i in range(self.n_verts): # <<<<<<<<<<<<<< + * self.prev_verts[i] = self.m.verts[i] + * + */ + +# line 1394 "core/core2.pyx" + __pyx_t_1 = __pyx_v_self->n_verts; + +# line 1394 "core/core2.pyx" + __pyx_t_3 = __pyx_t_1; + +# line 1394 "core/core2.pyx" + for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { + +# line 1394 "core/core2.pyx" + __pyx_v_i = __pyx_t_4; + + /* "core/core2.pyx":1395 + * cdef int i + * for i in range(self.n_verts): + * self.prev_verts[i] = self.m.verts[i] # <<<<<<<<<<<<<< + * + * self.set_bvh(bvh) + */ + +# line 1395 "core/core2.pyx" + (__pyx_v_self->prev_verts[__pyx_v_i]) = (__pyx_v_self->m->verts[__pyx_v_i]); + +# line 1395 "core/core2.pyx" + } + + /* "core/core2.pyx":1397 + * self.prev_verts[i] = self.m.verts[i] + * + * self.set_bvh(bvh) # <<<<<<<<<<<<<< + * + * cpdef void set_bvh(self, BVH bvh): + */ + +# line 1397 "core/core2.pyx" + ((struct __pyx_vtabstruct_14softwrap_core2_SpringEngine *)__pyx_v_self->__pyx_vtab)->set_bvh(__pyx_v_self, __pyx_v_bvh, 0); + + /* "core/core2.pyx":1386 + * cdef int n_verts + * + * def __init__(self, Mesh m, BVH bvh=None): # <<<<<<<<<<<<<< + * self.m = m + * self.n_verts = m.n_verts + */ + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_AddTraceback("softwrap_core2.SpringEngine.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":1399 + * self.set_bvh(bvh) + * + * cpdef void set_bvh(self, BVH bvh): # <<<<<<<<<<<<<< + * self.bvh = bvh + * + */ + +static PyObject *__pyx_pw_14softwrap_core2_12SpringEngine_3set_bvh(PyObject *__pyx_v_self, PyObject *__pyx_v_bvh); /*proto*/ +static void __pyx_f_14softwrap_core2_12SpringEngine_set_bvh(struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_self, struct __pyx_obj_14softwrap_core2_BVH *__pyx_v_bvh, int __pyx_skip_dispatch) { + int __pyx_v_i; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + int __pyx_t_5; + int __pyx_t_6; + int __pyx_t_7; + int __pyx_t_8; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("set_bvh", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) { + #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS + static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; + if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) { + PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); + #endif + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_set_bvh); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1399, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_14softwrap_core2_12SpringEngine_3set_bvh)) { + __Pyx_INCREF(__pyx_t_1); + __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { + __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); + if (likely(__pyx_t_4)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); + __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_3, function); + } + } + __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, ((PyObject *)__pyx_v_bvh)) : __Pyx_PyObject_CallOneArg(__pyx_t_3, ((PyObject *)__pyx_v_bvh)); + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1399, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS + __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); + __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self)); + if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) { + __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; + } + #endif + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS + } + #endif + } + + /* "core/core2.pyx":1400 + * + * cpdef void set_bvh(self, BVH bvh): + * self.bvh = bvh # <<<<<<<<<<<<<< + * + * cdef int i + */ + +# line 1400 "core/core2.pyx" + __Pyx_INCREF(((PyObject *)__pyx_v_bvh)); + +# line 1400 "core/core2.pyx" + __Pyx_GIVEREF(((PyObject *)__pyx_v_bvh)); + +# line 1400 "core/core2.pyx" + __Pyx_GOTREF(__pyx_v_self->bvh); + +# line 1400 "core/core2.pyx" + __Pyx_DECREF(((PyObject *)__pyx_v_self->bvh)); + +# line 1400 "core/core2.pyx" + __pyx_v_self->bvh = __pyx_v_bvh; + + /* "core/core2.pyx":1403 + * + * cdef int i + * if bvh: # <<<<<<<<<<<<<< + * with nogil: + * for i in prange(self.n_verts): + */ + +# line 1403 "core/core2.pyx" + __pyx_t_5 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_bvh)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 1403, __pyx_L1_error) + +# line 1403 "core/core2.pyx" + if (__pyx_t_5) { + + /* "core/core2.pyx":1404 + * cdef int i + * if bvh: + * with nogil: # <<<<<<<<<<<<<< + * for i in prange(self.n_verts): + * self.bvh_closest_indexes[i] = -1 + */ + +# line 1404 "core/core2.pyx" + { + +# line 1404 "core/core2.pyx" + #ifdef WITH_THREAD + +# line 1404 "core/core2.pyx" + PyThreadState *_save; + +# line 1404 "core/core2.pyx" + Py_UNBLOCK_THREADS + +# line 1404 "core/core2.pyx" + __Pyx_FastGIL_Remember(); + +# line 1404 "core/core2.pyx" + #endif + /*try:*/ { + + /* "core/core2.pyx":1405 + * if bvh: + * with nogil: + * for i in prange(self.n_verts): # <<<<<<<<<<<<<< + * self.bvh_closest_indexes[i] = -1 + * + */ + +# line 1405 "core/core2.pyx" + __pyx_t_6 = __pyx_v_self->n_verts; + +# line 1405 "core/core2.pyx" + if ((1 == 0)) abort(); + +# line 1405 "core/core2.pyx" + { + +# line 1405 "core/core2.pyx" + #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))))) + +# line 1405 "core/core2.pyx" + #undef likely + +# line 1405 "core/core2.pyx" + #undef unlikely + #define likely(x) (x) + #define unlikely(x) (x) + +# line 1405 "core/core2.pyx" + #endif + +# line 1405 "core/core2.pyx" + __pyx_t_8 = (__pyx_t_6 - 0 + 1 - 1/abs(1)) / 1; + +# line 1405 "core/core2.pyx" + if (__pyx_t_8 > 0) + +# line 1405 "core/core2.pyx" + { + +# line 1405 "core/core2.pyx" + #ifdef _OPENMP + +# line 1405 "core/core2.pyx" + #pragma omp parallel + #endif /* _OPENMP */ + { + #ifdef _OPENMP + #pragma omp for firstprivate(__pyx_v_i) lastprivate(__pyx_v_i) + #endif /* _OPENMP */ + for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_8; __pyx_t_7++){ + { + __pyx_v_i = (int)(0 + 1 * __pyx_t_7); + + /* "core/core2.pyx":1406 + * with nogil: + * for i in prange(self.n_verts): + * self.bvh_closest_indexes[i] = -1 # <<<<<<<<<<<<<< + * + * def __dealloc__(self): + */ + +# line 1406 "core/core2.pyx" + (__pyx_v_self->bvh_closest_indexes[__pyx_v_i]) = -1; + +# line 1406 "core/core2.pyx" + } + +# line 1406 "core/core2.pyx" + } + +# line 1406 "core/core2.pyx" + } + +# line 1406 "core/core2.pyx" + } + +# line 1406 "core/core2.pyx" + } + +# line 1406 "core/core2.pyx" + #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))))) + +# line 1406 "core/core2.pyx" + #undef likely + +# line 1406 "core/core2.pyx" + #undef unlikely + #define likely(x) __builtin_expect(!!(x), 1) + #define unlikely(x) __builtin_expect(!!(x), 0) + +# line 1406 "core/core2.pyx" + #endif + +# line 1406 "core/core2.pyx" + } + + /* "core/core2.pyx":1404 + * cdef int i + * if bvh: + * with nogil: # <<<<<<<<<<<<<< + * for i in prange(self.n_verts): + * self.bvh_closest_indexes[i] = -1 + */ + /*finally:*/ { + /*normal exit:*/{ + #ifdef WITH_THREAD + __Pyx_FastGIL_Forget(); + Py_BLOCK_THREADS + #endif + goto __pyx_L6; + } + __pyx_L6:; + } + } + + /* "core/core2.pyx":1403 + * + * cdef int i + * if bvh: # <<<<<<<<<<<<<< + * with nogil: + * for i in prange(self.n_verts): + */ + +# line 1403 "core/core2.pyx" + } + + /* "core/core2.pyx":1399 + * self.set_bvh(bvh) + * + * cpdef void set_bvh(self, BVH bvh): # <<<<<<<<<<<<<< + * self.bvh = bvh + * + */ + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_WriteUnraisable("softwrap_core2.SpringEngine.set_bvh", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); + __pyx_L0:; + __Pyx_RefNannyFinishContext(); +} + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_12SpringEngine_3set_bvh(PyObject *__pyx_v_self, PyObject *__pyx_v_bvh); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_12SpringEngine_3set_bvh(PyObject *__pyx_v_self, PyObject *__pyx_v_bvh) { + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("set_bvh (wrapper)", 0); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_bvh), __pyx_ptype_14softwrap_core2_BVH, 1, "bvh", 0))) __PYX_ERR(0, 1399, __pyx_L1_error) + __pyx_r = __pyx_pf_14softwrap_core2_12SpringEngine_2set_bvh(((struct __pyx_obj_14softwrap_core2_SpringEngine *)__pyx_v_self), ((struct __pyx_obj_14softwrap_core2_BVH *)__pyx_v_bvh)); + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_12SpringEngine_2set_bvh(struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_self, struct __pyx_obj_14softwrap_core2_BVH *__pyx_v_bvh) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("set_bvh", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_void_to_None(__pyx_f_14softwrap_core2_12SpringEngine_set_bvh(__pyx_v_self, __pyx_v_bvh, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1399, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("softwrap_core2.SpringEngine.set_bvh", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":1408 + * self.bvh_closest_indexes[i] = -1 + * + * def __dealloc__(self): # <<<<<<<<<<<<<< + * fraeee(self.prev_verts) + * fraeee(self.tmp_verts) + */ + +/* Python wrapper */ +static void __pyx_pw_14softwrap_core2_12SpringEngine_5__dealloc__(PyObject *__pyx_v_self); /*proto*/ +static void __pyx_pw_14softwrap_core2_12SpringEngine_5__dealloc__(PyObject *__pyx_v_self) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0); + __pyx_pf_14softwrap_core2_12SpringEngine_4__dealloc__(((struct __pyx_obj_14softwrap_core2_SpringEngine *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); +} + +static void __pyx_pf_14softwrap_core2_12SpringEngine_4__dealloc__(struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_self) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__dealloc__", 0); + + /* "core/core2.pyx":1409 + * + * def __dealloc__(self): + * fraeee(self.prev_verts) # <<<<<<<<<<<<<< + * fraeee(self.tmp_verts) + * fraeee(self.bvh_closest_indexes) + */ + +# line 1409 "core/core2.pyx" + __pyx_f_14softwrap_core2_fraeee(__pyx_v_self->prev_verts); + + /* "core/core2.pyx":1410 + * def __dealloc__(self): + * fraeee(self.prev_verts) + * fraeee(self.tmp_verts) # <<<<<<<<<<<<<< + * fraeee(self.bvh_closest_indexes) + * + */ + +# line 1410 "core/core2.pyx" + __pyx_f_14softwrap_core2_fraeee(__pyx_v_self->tmp_verts); + + /* "core/core2.pyx":1411 + * fraeee(self.prev_verts) + * fraeee(self.tmp_verts) + * fraeee(self.bvh_closest_indexes) # <<<<<<<<<<<<<< + * + * def __len__(self): + */ + +# line 1411 "core/core2.pyx" + __pyx_f_14softwrap_core2_fraeee(__pyx_v_self->bvh_closest_indexes); + + /* "core/core2.pyx":1408 + * self.bvh_closest_indexes[i] = -1 + * + * def __dealloc__(self): # <<<<<<<<<<<<<< + * fraeee(self.prev_verts) + * fraeee(self.tmp_verts) + */ + + /* function exit code */ + __Pyx_RefNannyFinishContext(); +} + +/* "core/core2.pyx":1413 + * fraeee(self.bvh_closest_indexes) + * + * def __len__(self): # <<<<<<<<<<<<<< + * return self.n_verts * 3 + * + */ + +/* Python wrapper */ +static Py_ssize_t __pyx_pw_14softwrap_core2_12SpringEngine_7__len__(PyObject *__pyx_v_self); /*proto*/ +static Py_ssize_t __pyx_pw_14softwrap_core2_12SpringEngine_7__len__(PyObject *__pyx_v_self) { + Py_ssize_t __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__len__ (wrapper)", 0); + __pyx_r = __pyx_pf_14softwrap_core2_12SpringEngine_6__len__(((struct __pyx_obj_14softwrap_core2_SpringEngine *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static Py_ssize_t __pyx_pf_14softwrap_core2_12SpringEngine_6__len__(struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_self) { + Py_ssize_t __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__len__", 0); + + /* "core/core2.pyx":1414 + * + * def __len__(self): + * return self.n_verts * 3 # <<<<<<<<<<<<<< + * + * def __getitem__(self, int key): + */ + +# line 1414 "core/core2.pyx" + __pyx_r = (__pyx_v_self->n_verts * 3); + +# line 1414 "core/core2.pyx" + goto __pyx_L0; + + /* "core/core2.pyx":1413 + * fraeee(self.bvh_closest_indexes) + * + * def __len__(self): # <<<<<<<<<<<<<< + * return self.n_verts * 3 + * + */ + + /* function exit code */ + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":1416 + * return self.n_verts * 3 + * + * def __getitem__(self, int key): # <<<<<<<<<<<<<< + * return self.m.verts[key // 3].v[key % 3] + * + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_12SpringEngine_9__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_key); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_12SpringEngine_9__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_key) { + int __pyx_v_key; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0); + assert(__pyx_arg_key); { + __pyx_v_key = __Pyx_PyInt_As_int(__pyx_arg_key); if (unlikely((__pyx_v_key == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1416, __pyx_L3_error) + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("softwrap_core2.SpringEngine.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_14softwrap_core2_12SpringEngine_8__getitem__(((struct __pyx_obj_14softwrap_core2_SpringEngine *)__pyx_v_self), ((int)__pyx_v_key)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_12SpringEngine_8__getitem__(struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_self, int __pyx_v_key) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__getitem__", 0); + + /* "core/core2.pyx":1417 + * + * def __getitem__(self, int key): + * return self.m.verts[key // 3].v[key % 3] # <<<<<<<<<<<<<< + * + * def __setitem__(self, int key, float v): + */ + +# line 1417 "core/core2.pyx" + __Pyx_XDECREF(__pyx_r); + +# line 1417 "core/core2.pyx" + __pyx_t_1 = PyFloat_FromDouble(((__pyx_v_self->m->verts[(__pyx_v_key / 3)]).v[(__pyx_v_key % 3)])); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1417, __pyx_L1_error) + +# line 1417 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_1); + +# line 1417 "core/core2.pyx" + __pyx_r = __pyx_t_1; + +# line 1417 "core/core2.pyx" + __pyx_t_1 = 0; + +# line 1417 "core/core2.pyx" + goto __pyx_L0; + + /* "core/core2.pyx":1416 + * return self.n_verts * 3 + * + * def __getitem__(self, int key): # <<<<<<<<<<<<<< + * return self.m.verts[key // 3].v[key % 3] + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("softwrap_core2.SpringEngine.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":1419 + * return self.m.verts[key // 3].v[key % 3] + * + * def __setitem__(self, int key, float v): # <<<<<<<<<<<<<< + * self.m.verts[key // 3].v[key % 3] = v + * self.prev_verts[key // 3].v[key % 3] = v + */ + +/* Python wrapper */ +static int __pyx_pw_14softwrap_core2_12SpringEngine_11__setitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_key, PyObject *__pyx_arg_v); /*proto*/ +static int __pyx_pw_14softwrap_core2_12SpringEngine_11__setitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_key, PyObject *__pyx_arg_v) { + int __pyx_v_key; + float __pyx_v_v; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__setitem__ (wrapper)", 0); + assert(__pyx_arg_key); { + __pyx_v_key = __Pyx_PyInt_As_int(__pyx_arg_key); if (unlikely((__pyx_v_key == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1419, __pyx_L3_error) + } + assert(__pyx_arg_v); { + __pyx_v_v = __pyx_PyFloat_AsFloat(__pyx_arg_v); if (unlikely((__pyx_v_v == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 1419, __pyx_L3_error) + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("softwrap_core2.SpringEngine.__setitem__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_14softwrap_core2_12SpringEngine_10__setitem__(((struct __pyx_obj_14softwrap_core2_SpringEngine *)__pyx_v_self), ((int)__pyx_v_key), ((float)__pyx_v_v)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_14softwrap_core2_12SpringEngine_10__setitem__(struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_self, int __pyx_v_key, float __pyx_v_v) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__setitem__", 0); + + /* "core/core2.pyx":1420 + * + * def __setitem__(self, int key, float v): + * self.m.verts[key // 3].v[key % 3] = v # <<<<<<<<<<<<<< + * self.prev_verts[key // 3].v[key % 3] = v + * + */ + +# line 1420 "core/core2.pyx" + ((__pyx_v_self->m->verts[(__pyx_v_key / 3)]).v[(__pyx_v_key % 3)]) = __pyx_v_v; + + /* "core/core2.pyx":1421 + * def __setitem__(self, int key, float v): + * self.m.verts[key // 3].v[key % 3] = v + * self.prev_verts[key // 3].v[key % 3] = v # <<<<<<<<<<<<<< + * + * def from_list(self, list items): + */ + +# line 1421 "core/core2.pyx" + ((__pyx_v_self->prev_verts[(__pyx_v_key / 3)]).v[(__pyx_v_key % 3)]) = __pyx_v_v; + + /* "core/core2.pyx":1419 + * return self.m.verts[key // 3].v[key % 3] + * + * def __setitem__(self, int key, float v): # <<<<<<<<<<<<<< + * self.m.verts[key // 3].v[key % 3] = v + * self.prev_verts[key // 3].v[key % 3] = v + */ + + /* function exit code */ + __pyx_r = 0; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":1423 + * self.prev_verts[key // 3].v[key % 3] = v + * + * def from_list(self, list items): # <<<<<<<<<<<<<< + * if not len(items) >= self.n_verts * 3: + * raise ValueError('list too small') + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_12SpringEngine_13from_list(PyObject *__pyx_v_self, PyObject *__pyx_v_items); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_12SpringEngine_13from_list(PyObject *__pyx_v_self, PyObject *__pyx_v_items) { + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("from_list (wrapper)", 0); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_items), (&PyList_Type), 1, "items", 1))) __PYX_ERR(0, 1423, __pyx_L1_error) + __pyx_r = __pyx_pf_14softwrap_core2_12SpringEngine_12from_list(((struct __pyx_obj_14softwrap_core2_SpringEngine *)__pyx_v_self), ((PyObject*)__pyx_v_items)); + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_12SpringEngine_12from_list(struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_self, PyObject *__pyx_v_items) { + int __pyx_v_i; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + Py_ssize_t __pyx_t_1; + int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + long __pyx_t_4; + long __pyx_t_5; + int __pyx_t_6; + float __pyx_t_7; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("from_list", 0); + + /* "core/core2.pyx":1424 + * + * def from_list(self, list items): + * if not len(items) >= self.n_verts * 3: # <<<<<<<<<<<<<< + * raise ValueError('list too small') + * + */ + +# line 1424 "core/core2.pyx" + if (unlikely(__pyx_v_items == Py_None)) { + +# line 1424 "core/core2.pyx" + PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); + +# line 1424 "core/core2.pyx" + __PYX_ERR(0, 1424, __pyx_L1_error) + +# line 1424 "core/core2.pyx" + } + +# line 1424 "core/core2.pyx" + __pyx_t_1 = PyList_GET_SIZE(__pyx_v_items); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1424, __pyx_L1_error) + +# line 1424 "core/core2.pyx" + __pyx_t_2 = ((!((__pyx_t_1 >= (__pyx_v_self->n_verts * 3)) != 0)) != 0); + +# line 1424 "core/core2.pyx" + if (unlikely(__pyx_t_2)) { + + /* "core/core2.pyx":1425 + * def from_list(self, list items): + * if not len(items) >= self.n_verts * 3: + * raise ValueError('list too small') # <<<<<<<<<<<<<< + * + * cdef int i + */ + +# line 1425 "core/core2.pyx" + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__30, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1425, __pyx_L1_error) + +# line 1425 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_3); + +# line 1425 "core/core2.pyx" + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + +# line 1425 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + +# line 1425 "core/core2.pyx" + __PYX_ERR(0, 1425, __pyx_L1_error) + + /* "core/core2.pyx":1424 + * + * def from_list(self, list items): + * if not len(items) >= self.n_verts * 3: # <<<<<<<<<<<<<< + * raise ValueError('list too small') + * + */ + +# line 1424 "core/core2.pyx" + } + + /* "core/core2.pyx":1428 + * + * cdef int i + * for i in range(self.n_verts * 3): # <<<<<<<<<<<<<< + * self.m.verts[i // 3].v[i % 3] = items[i] + * self.prev_verts[i // 3].v[i % 3] = items[i] + */ + +# line 1428 "core/core2.pyx" + __pyx_t_4 = (__pyx_v_self->n_verts * 3); + +# line 1428 "core/core2.pyx" + __pyx_t_5 = __pyx_t_4; + +# line 1428 "core/core2.pyx" + for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) { + +# line 1428 "core/core2.pyx" + __pyx_v_i = __pyx_t_6; + + /* "core/core2.pyx":1429 + * cdef int i + * for i in range(self.n_verts * 3): + * self.m.verts[i // 3].v[i % 3] = items[i] # <<<<<<<<<<<<<< + * self.prev_verts[i // 3].v[i % 3] = items[i] + * + */ + +# line 1429 "core/core2.pyx" + if (unlikely(__pyx_v_items == Py_None)) { + +# line 1429 "core/core2.pyx" + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + +# line 1429 "core/core2.pyx" + __PYX_ERR(0, 1429, __pyx_L1_error) + +# line 1429 "core/core2.pyx" + } + +# line 1429 "core/core2.pyx" + __pyx_t_3 = __Pyx_GetItemInt_List(__pyx_v_items, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 1, 1, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1429, __pyx_L1_error) + +# line 1429 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_3); + +# line 1429 "core/core2.pyx" + __pyx_t_7 = __pyx_PyFloat_AsFloat(__pyx_t_3); if (unlikely((__pyx_t_7 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 1429, __pyx_L1_error) + +# line 1429 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + +# line 1429 "core/core2.pyx" + ((__pyx_v_self->m->verts[(__pyx_v_i / 3)]).v[(__pyx_v_i % 3)]) = __pyx_t_7; + + /* "core/core2.pyx":1430 + * for i in range(self.n_verts * 3): + * self.m.verts[i // 3].v[i % 3] = items[i] + * self.prev_verts[i // 3].v[i % 3] = items[i] # <<<<<<<<<<<<<< + * + * def set_verts(self, list indexes, list locations): + */ + +# line 1430 "core/core2.pyx" + if (unlikely(__pyx_v_items == Py_None)) { + +# line 1430 "core/core2.pyx" + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + +# line 1430 "core/core2.pyx" + __PYX_ERR(0, 1430, __pyx_L1_error) + +# line 1430 "core/core2.pyx" + } + +# line 1430 "core/core2.pyx" + __pyx_t_3 = __Pyx_GetItemInt_List(__pyx_v_items, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 1, 1, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1430, __pyx_L1_error) + +# line 1430 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_3); + +# line 1430 "core/core2.pyx" + __pyx_t_7 = __pyx_PyFloat_AsFloat(__pyx_t_3); if (unlikely((__pyx_t_7 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 1430, __pyx_L1_error) + +# line 1430 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + +# line 1430 "core/core2.pyx" + ((__pyx_v_self->prev_verts[(__pyx_v_i / 3)]).v[(__pyx_v_i % 3)]) = __pyx_t_7; + +# line 1430 "core/core2.pyx" + } + + /* "core/core2.pyx":1423 + * self.prev_verts[key // 3].v[key % 3] = v + * + * def from_list(self, list items): # <<<<<<<<<<<<<< + * if not len(items) >= self.n_verts * 3: + * raise ValueError('list too small') + */ + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("softwrap_core2.SpringEngine.from_list", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":1432 + * self.prev_verts[i // 3].v[i % 3] = items[i] + * + * def set_verts(self, list indexes, list locations): # <<<<<<<<<<<<<< + * cdef int i, index + * cdef float x, y, z + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_12SpringEngine_15set_verts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_12SpringEngine_15set_verts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_indexes = 0; + PyObject *__pyx_v_locations = 0; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("set_verts (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_indexes,&__pyx_n_s_locations,0}; + PyObject* values[2] = {0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + CYTHON_FALLTHROUGH; + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + CYTHON_FALLTHROUGH; + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_indexes)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + CYTHON_FALLTHROUGH; + case 1: + if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_locations)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("set_verts", 1, 2, 2, 1); __PYX_ERR(0, 1432, __pyx_L3_error) + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "set_verts") < 0)) __PYX_ERR(0, 1432, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + } + __pyx_v_indexes = ((PyObject*)values[0]); + __pyx_v_locations = ((PyObject*)values[1]); + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("set_verts", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1432, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("softwrap_core2.SpringEngine.set_verts", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_indexes), (&PyList_Type), 1, "indexes", 1))) __PYX_ERR(0, 1432, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_locations), (&PyList_Type), 1, "locations", 1))) __PYX_ERR(0, 1432, __pyx_L1_error) + __pyx_r = __pyx_pf_14softwrap_core2_12SpringEngine_14set_verts(((struct __pyx_obj_14softwrap_core2_SpringEngine *)__pyx_v_self), __pyx_v_indexes, __pyx_v_locations); + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_12SpringEngine_14set_verts(struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_self, PyObject *__pyx_v_indexes, PyObject *__pyx_v_locations) { + int __pyx_v_i; + int __pyx_v_index; + float __pyx_v_x; + float __pyx_v_y; + float __pyx_v_z; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + Py_ssize_t __pyx_t_1; + Py_ssize_t __pyx_t_2; + int __pyx_t_3; + PyObject *__pyx_t_4 = NULL; + int __pyx_t_5; + int __pyx_t_6; + PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8 = NULL; + PyObject *__pyx_t_9 = NULL; + PyObject *__pyx_t_10 = NULL; + PyObject *(*__pyx_t_11)(PyObject *); + float __pyx_t_12; + float __pyx_t_13; + float __pyx_t_14; + vec3 __pyx_t_15; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("set_verts", 0); + + /* "core/core2.pyx":1435 + * cdef int i, index + * cdef float x, y, z + * if not len(indexes) == len(locations): # <<<<<<<<<<<<<< + * raise ValueError('indexes array is not the same size as locations array') + * + */ + +# line 1435 "core/core2.pyx" + if (unlikely(__pyx_v_indexes == Py_None)) { + +# line 1435 "core/core2.pyx" + PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); + +# line 1435 "core/core2.pyx" + __PYX_ERR(0, 1435, __pyx_L1_error) + +# line 1435 "core/core2.pyx" + } + +# line 1435 "core/core2.pyx" + __pyx_t_1 = PyList_GET_SIZE(__pyx_v_indexes); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1435, __pyx_L1_error) + +# line 1435 "core/core2.pyx" + if (unlikely(__pyx_v_locations == Py_None)) { + +# line 1435 "core/core2.pyx" + PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); + +# line 1435 "core/core2.pyx" + __PYX_ERR(0, 1435, __pyx_L1_error) + +# line 1435 "core/core2.pyx" + } + +# line 1435 "core/core2.pyx" + __pyx_t_2 = PyList_GET_SIZE(__pyx_v_locations); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1435, __pyx_L1_error) + +# line 1435 "core/core2.pyx" + __pyx_t_3 = ((!((__pyx_t_1 == __pyx_t_2) != 0)) != 0); + +# line 1435 "core/core2.pyx" + if (unlikely(__pyx_t_3)) { + + /* "core/core2.pyx":1436 + * cdef float x, y, z + * if not len(indexes) == len(locations): + * raise ValueError('indexes array is not the same size as locations array') # <<<<<<<<<<<<<< + * + * for i in range(len(indexes)): + */ + +# line 1436 "core/core2.pyx" + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__31, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1436, __pyx_L1_error) + +# line 1436 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_4); + +# line 1436 "core/core2.pyx" + __Pyx_Raise(__pyx_t_4, 0, 0, 0); + +# line 1436 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + +# line 1436 "core/core2.pyx" + __PYX_ERR(0, 1436, __pyx_L1_error) + + /* "core/core2.pyx":1435 + * cdef int i, index + * cdef float x, y, z + * if not len(indexes) == len(locations): # <<<<<<<<<<<<<< + * raise ValueError('indexes array is not the same size as locations array') + * + */ + +# line 1435 "core/core2.pyx" + } + + /* "core/core2.pyx":1438 + * raise ValueError('indexes array is not the same size as locations array') + * + * for i in range(len(indexes)): # <<<<<<<<<<<<<< + * index = indexes[i] + * x, y, z = locations[i] + */ + +# line 1438 "core/core2.pyx" + if (unlikely(__pyx_v_indexes == Py_None)) { + +# line 1438 "core/core2.pyx" + PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); + +# line 1438 "core/core2.pyx" + __PYX_ERR(0, 1438, __pyx_L1_error) + +# line 1438 "core/core2.pyx" + } + +# line 1438 "core/core2.pyx" + __pyx_t_2 = PyList_GET_SIZE(__pyx_v_indexes); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1438, __pyx_L1_error) + +# line 1438 "core/core2.pyx" + __pyx_t_1 = __pyx_t_2; + +# line 1438 "core/core2.pyx" + for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_1; __pyx_t_5+=1) { + +# line 1438 "core/core2.pyx" + __pyx_v_i = __pyx_t_5; + + /* "core/core2.pyx":1439 + * + * for i in range(len(indexes)): + * index = indexes[i] # <<<<<<<<<<<<<< + * x, y, z = locations[i] + * self.prev_verts[index] = self.m.verts[index] = vec3(x, y, z) + */ + +# line 1439 "core/core2.pyx" + if (unlikely(__pyx_v_indexes == Py_None)) { + +# line 1439 "core/core2.pyx" + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + +# line 1439 "core/core2.pyx" + __PYX_ERR(0, 1439, __pyx_L1_error) + +# line 1439 "core/core2.pyx" + } + +# line 1439 "core/core2.pyx" + __pyx_t_4 = __Pyx_GetItemInt_List(__pyx_v_indexes, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 1, 1, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1439, __pyx_L1_error) + +# line 1439 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_4); + +# line 1439 "core/core2.pyx" + __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1439, __pyx_L1_error) + +# line 1439 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + +# line 1439 "core/core2.pyx" + __pyx_v_index = __pyx_t_6; + + /* "core/core2.pyx":1440 + * for i in range(len(indexes)): + * index = indexes[i] + * x, y, z = locations[i] # <<<<<<<<<<<<<< + * self.prev_verts[index] = self.m.verts[index] = vec3(x, y, z) + * + */ + +# line 1440 "core/core2.pyx" + if (unlikely(__pyx_v_locations == Py_None)) { + +# line 1440 "core/core2.pyx" + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + +# line 1440 "core/core2.pyx" + __PYX_ERR(0, 1440, __pyx_L1_error) + +# line 1440 "core/core2.pyx" + } + +# line 1440 "core/core2.pyx" + __pyx_t_4 = __Pyx_GetItemInt_List(__pyx_v_locations, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 1, 1, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1440, __pyx_L1_error) + +# line 1440 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_4); + +# line 1440 "core/core2.pyx" + if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) { + +# line 1440 "core/core2.pyx" + PyObject* sequence = __pyx_t_4; + +# line 1440 "core/core2.pyx" + Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); + +# line 1440 "core/core2.pyx" + if (unlikely(size != 3)) { + +# line 1440 "core/core2.pyx" + if (size > 3) __Pyx_RaiseTooManyValuesError(3); + +# line 1440 "core/core2.pyx" + else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); + +# line 1440 "core/core2.pyx" + __PYX_ERR(0, 1440, __pyx_L1_error) + +# line 1440 "core/core2.pyx" + } + +# line 1440 "core/core2.pyx" + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + +# line 1440 "core/core2.pyx" + if (likely(PyTuple_CheckExact(sequence))) { + +# line 1440 "core/core2.pyx" + __pyx_t_7 = PyTuple_GET_ITEM(sequence, 0); + +# line 1440 "core/core2.pyx" + __pyx_t_8 = PyTuple_GET_ITEM(sequence, 1); + +# line 1440 "core/core2.pyx" + __pyx_t_9 = PyTuple_GET_ITEM(sequence, 2); + +# line 1440 "core/core2.pyx" + } else { + +# line 1440 "core/core2.pyx" + __pyx_t_7 = PyList_GET_ITEM(sequence, 0); + +# line 1440 "core/core2.pyx" + __pyx_t_8 = PyList_GET_ITEM(sequence, 1); + +# line 1440 "core/core2.pyx" + __pyx_t_9 = PyList_GET_ITEM(sequence, 2); + +# line 1440 "core/core2.pyx" + } + +# line 1440 "core/core2.pyx" + __Pyx_INCREF(__pyx_t_7); + +# line 1440 "core/core2.pyx" + __Pyx_INCREF(__pyx_t_8); + +# line 1440 "core/core2.pyx" + __Pyx_INCREF(__pyx_t_9); + +# line 1440 "core/core2.pyx" + #else + +# line 1440 "core/core2.pyx" + __pyx_t_7 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1440, __pyx_L1_error) + +# line 1440 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_7); + +# line 1440 "core/core2.pyx" + __pyx_t_8 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1440, __pyx_L1_error) + +# line 1440 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_8); + +# line 1440 "core/core2.pyx" + __pyx_t_9 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1440, __pyx_L1_error) + +# line 1440 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_9); + +# line 1440 "core/core2.pyx" + #endif + +# line 1440 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + +# line 1440 "core/core2.pyx" + } else { + +# line 1440 "core/core2.pyx" + Py_ssize_t index = -1; + +# line 1440 "core/core2.pyx" + __pyx_t_10 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1440, __pyx_L1_error) + +# line 1440 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_10); + +# line 1440 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + +# line 1440 "core/core2.pyx" + __pyx_t_11 = Py_TYPE(__pyx_t_10)->tp_iternext; + +# line 1440 "core/core2.pyx" + index = 0; __pyx_t_7 = __pyx_t_11(__pyx_t_10); if (unlikely(!__pyx_t_7)) goto __pyx_L6_unpacking_failed; + +# line 1440 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_7); + +# line 1440 "core/core2.pyx" + index = 1; __pyx_t_8 = __pyx_t_11(__pyx_t_10); if (unlikely(!__pyx_t_8)) goto __pyx_L6_unpacking_failed; + +# line 1440 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_8); + +# line 1440 "core/core2.pyx" + index = 2; __pyx_t_9 = __pyx_t_11(__pyx_t_10); if (unlikely(!__pyx_t_9)) goto __pyx_L6_unpacking_failed; + +# line 1440 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_9); + +# line 1440 "core/core2.pyx" + if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_10), 3) < 0) __PYX_ERR(0, 1440, __pyx_L1_error) + +# line 1440 "core/core2.pyx" + __pyx_t_11 = NULL; + +# line 1440 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + +# line 1440 "core/core2.pyx" + goto __pyx_L7_unpacking_done; + +# line 1440 "core/core2.pyx" + __pyx_L6_unpacking_failed:; + +# line 1440 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + +# line 1440 "core/core2.pyx" + __pyx_t_11 = NULL; + +# line 1440 "core/core2.pyx" + if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); + +# line 1440 "core/core2.pyx" + __PYX_ERR(0, 1440, __pyx_L1_error) + +# line 1440 "core/core2.pyx" + __pyx_L7_unpacking_done:; + +# line 1440 "core/core2.pyx" + } + +# line 1440 "core/core2.pyx" + __pyx_t_12 = __pyx_PyFloat_AsFloat(__pyx_t_7); if (unlikely((__pyx_t_12 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 1440, __pyx_L1_error) + +# line 1440 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + +# line 1440 "core/core2.pyx" + __pyx_t_13 = __pyx_PyFloat_AsFloat(__pyx_t_8); if (unlikely((__pyx_t_13 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 1440, __pyx_L1_error) + +# line 1440 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + +# line 1440 "core/core2.pyx" + __pyx_t_14 = __pyx_PyFloat_AsFloat(__pyx_t_9); if (unlikely((__pyx_t_14 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 1440, __pyx_L1_error) + +# line 1440 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + +# line 1440 "core/core2.pyx" + __pyx_v_x = __pyx_t_12; + +# line 1440 "core/core2.pyx" + __pyx_v_y = __pyx_t_13; + +# line 1440 "core/core2.pyx" + __pyx_v_z = __pyx_t_14; + + /* "core/core2.pyx":1441 + * index = indexes[i] + * x, y, z = locations[i] + * self.prev_verts[index] = self.m.verts[index] = vec3(x, y, z) # <<<<<<<<<<<<<< + * + * def get_verts(self, list indexes): + */ + +# line 1441 "core/core2.pyx" + __pyx_t_15 = vec3(__pyx_v_x, __pyx_v_y, __pyx_v_z); + +# line 1441 "core/core2.pyx" + (__pyx_v_self->prev_verts[__pyx_v_index]) = __pyx_t_15; + +# line 1441 "core/core2.pyx" + (__pyx_v_self->m->verts[__pyx_v_index]) = __pyx_t_15; + +# line 1441 "core/core2.pyx" + } + + /* "core/core2.pyx":1432 + * self.prev_verts[i // 3].v[i % 3] = items[i] + * + * def set_verts(self, list indexes, list locations): # <<<<<<<<<<<<<< + * cdef int i, index + * cdef float x, y, z + */ + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_XDECREF(__pyx_t_9); + __Pyx_XDECREF(__pyx_t_10); + __Pyx_AddTraceback("softwrap_core2.SpringEngine.set_verts", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":1443 + * self.prev_verts[index] = self.m.verts[index] = vec3(x, y, z) + * + * def get_verts(self, list indexes): # <<<<<<<<<<<<<< + * cdef int i, index + * cdef list ret = [] + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_12SpringEngine_17get_verts(PyObject *__pyx_v_self, PyObject *__pyx_v_indexes); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_12SpringEngine_17get_verts(PyObject *__pyx_v_self, PyObject *__pyx_v_indexes) { + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("get_verts (wrapper)", 0); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_indexes), (&PyList_Type), 1, "indexes", 1))) __PYX_ERR(0, 1443, __pyx_L1_error) + __pyx_r = __pyx_pf_14softwrap_core2_12SpringEngine_16get_verts(((struct __pyx_obj_14softwrap_core2_SpringEngine *)__pyx_v_self), ((PyObject*)__pyx_v_indexes)); + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_12SpringEngine_16get_verts(struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_self, PyObject *__pyx_v_indexes) { + int __pyx_v_i; + int __pyx_v_index; + PyObject *__pyx_v_ret = 0; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + Py_ssize_t __pyx_t_2; + Py_ssize_t __pyx_t_3; + int __pyx_t_4; + int __pyx_t_5; + int __pyx_t_6; + int __pyx_t_7; + int __pyx_t_8; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("get_verts", 0); + + /* "core/core2.pyx":1445 + * def get_verts(self, list indexes): + * cdef int i, index + * cdef list ret = [] # <<<<<<<<<<<<<< + * for i in range(len(indexes)): + * index = indexes[i] + */ + +# line 1445 "core/core2.pyx" + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1445, __pyx_L1_error) + +# line 1445 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_1); + +# line 1445 "core/core2.pyx" + __pyx_v_ret = ((PyObject*)__pyx_t_1); + +# line 1445 "core/core2.pyx" + __pyx_t_1 = 0; + + /* "core/core2.pyx":1446 + * cdef int i, index + * cdef list ret = [] + * for i in range(len(indexes)): # <<<<<<<<<<<<<< + * index = indexes[i] + * if index < 0 or index >= self.n_verts: + */ + +# line 1446 "core/core2.pyx" + if (unlikely(__pyx_v_indexes == Py_None)) { + +# line 1446 "core/core2.pyx" + PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); + +# line 1446 "core/core2.pyx" + __PYX_ERR(0, 1446, __pyx_L1_error) + +# line 1446 "core/core2.pyx" + } + +# line 1446 "core/core2.pyx" + __pyx_t_2 = PyList_GET_SIZE(__pyx_v_indexes); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1446, __pyx_L1_error) + +# line 1446 "core/core2.pyx" + __pyx_t_3 = __pyx_t_2; + +# line 1446 "core/core2.pyx" + for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { + +# line 1446 "core/core2.pyx" + __pyx_v_i = __pyx_t_4; + + /* "core/core2.pyx":1447 + * cdef list ret = [] + * for i in range(len(indexes)): + * index = indexes[i] # <<<<<<<<<<<<<< + * if index < 0 or index >= self.n_verts: + * raise IndexError + */ + +# line 1447 "core/core2.pyx" + if (unlikely(__pyx_v_indexes == Py_None)) { + +# line 1447 "core/core2.pyx" + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + +# line 1447 "core/core2.pyx" + __PYX_ERR(0, 1447, __pyx_L1_error) + +# line 1447 "core/core2.pyx" + } + +# line 1447 "core/core2.pyx" + __pyx_t_1 = __Pyx_GetItemInt_List(__pyx_v_indexes, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 1, 1, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1447, __pyx_L1_error) + +# line 1447 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_1); + +# line 1447 "core/core2.pyx" + __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1447, __pyx_L1_error) + +# line 1447 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + +# line 1447 "core/core2.pyx" + __pyx_v_index = __pyx_t_5; + + /* "core/core2.pyx":1448 + * for i in range(len(indexes)): + * index = indexes[i] + * if index < 0 or index >= self.n_verts: # <<<<<<<<<<<<<< + * raise IndexError + * ret.append(self.m.verts[index].v) + */ + +# line 1448 "core/core2.pyx" + __pyx_t_7 = ((__pyx_v_index < 0) != 0); + +# line 1448 "core/core2.pyx" + if (!__pyx_t_7) { + +# line 1448 "core/core2.pyx" + } else { + +# line 1448 "core/core2.pyx" + __pyx_t_6 = __pyx_t_7; + +# line 1448 "core/core2.pyx" + goto __pyx_L6_bool_binop_done; + +# line 1448 "core/core2.pyx" + } + +# line 1448 "core/core2.pyx" + __pyx_t_7 = ((__pyx_v_index >= __pyx_v_self->n_verts) != 0); + +# line 1448 "core/core2.pyx" + __pyx_t_6 = __pyx_t_7; + +# line 1448 "core/core2.pyx" + __pyx_L6_bool_binop_done:; + +# line 1448 "core/core2.pyx" + if (unlikely(__pyx_t_6)) { + + /* "core/core2.pyx":1449 + * index = indexes[i] + * if index < 0 or index >= self.n_verts: + * raise IndexError # <<<<<<<<<<<<<< + * ret.append(self.m.verts[index].v) + * return ret + */ + +# line 1449 "core/core2.pyx" + __Pyx_Raise(__pyx_builtin_IndexError, 0, 0, 0); + +# line 1449 "core/core2.pyx" + __PYX_ERR(0, 1449, __pyx_L1_error) + + /* "core/core2.pyx":1448 + * for i in range(len(indexes)): + * index = indexes[i] + * if index < 0 or index >= self.n_verts: # <<<<<<<<<<<<<< + * raise IndexError + * ret.append(self.m.verts[index].v) + */ + +# line 1448 "core/core2.pyx" + } + + /* "core/core2.pyx":1450 + * if index < 0 or index >= self.n_verts: + * raise IndexError + * ret.append(self.m.verts[index].v) # <<<<<<<<<<<<<< + * return ret + * + */ + +# line 1450 "core/core2.pyx" + __pyx_t_1 = __Pyx_carray_to_py_float((__pyx_v_self->m->verts[__pyx_v_index]).v, 3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1450, __pyx_L1_error) + +# line 1450 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_1); + +# line 1450 "core/core2.pyx" + __pyx_t_8 = __Pyx_PyList_Append(__pyx_v_ret, __pyx_t_1); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 1450, __pyx_L1_error) + +# line 1450 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + +# line 1450 "core/core2.pyx" + } + + /* "core/core2.pyx":1451 + * raise IndexError + * ret.append(self.m.verts[index].v) + * return ret # <<<<<<<<<<<<<< + * + * def move_verts(self, list indexes, float x, float y, float z): + */ + +# line 1451 "core/core2.pyx" + __Pyx_XDECREF(__pyx_r); + +# line 1451 "core/core2.pyx" + __Pyx_INCREF(__pyx_v_ret); + +# line 1451 "core/core2.pyx" + __pyx_r = __pyx_v_ret; + +# line 1451 "core/core2.pyx" + goto __pyx_L0; + + /* "core/core2.pyx":1443 + * self.prev_verts[index] = self.m.verts[index] = vec3(x, y, z) + * + * def get_verts(self, list indexes): # <<<<<<<<<<<<<< + * cdef int i, index + * cdef list ret = [] + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("softwrap_core2.SpringEngine.get_verts", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_ret); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":1453 + * return ret + * + * def move_verts(self, list indexes, float x, float y, float z): # <<<<<<<<<<<<<< + * cdef vec3 delta = vec3(x, y, z) + * cdef int i, index + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_12SpringEngine_19move_verts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_12SpringEngine_19move_verts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_indexes = 0; + float __pyx_v_x; + float __pyx_v_y; + float __pyx_v_z; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("move_verts (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_indexes,&__pyx_n_s_x,&__pyx_n_s_y,&__pyx_n_s_z,0}; + PyObject* values[4] = {0,0,0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + CYTHON_FALLTHROUGH; + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + CYTHON_FALLTHROUGH; + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + CYTHON_FALLTHROUGH; + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + CYTHON_FALLTHROUGH; + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_indexes)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + CYTHON_FALLTHROUGH; + case 1: + if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("move_verts", 1, 4, 4, 1); __PYX_ERR(0, 1453, __pyx_L3_error) + } + CYTHON_FALLTHROUGH; + case 2: + if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_y)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("move_verts", 1, 4, 4, 2); __PYX_ERR(0, 1453, __pyx_L3_error) + } + CYTHON_FALLTHROUGH; + case 3: + if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_z)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("move_verts", 1, 4, 4, 3); __PYX_ERR(0, 1453, __pyx_L3_error) + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "move_verts") < 0)) __PYX_ERR(0, 1453, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 4) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + } + __pyx_v_indexes = ((PyObject*)values[0]); + __pyx_v_x = __pyx_PyFloat_AsFloat(values[1]); if (unlikely((__pyx_v_x == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 1453, __pyx_L3_error) + __pyx_v_y = __pyx_PyFloat_AsFloat(values[2]); if (unlikely((__pyx_v_y == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 1453, __pyx_L3_error) + __pyx_v_z = __pyx_PyFloat_AsFloat(values[3]); if (unlikely((__pyx_v_z == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 1453, __pyx_L3_error) + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("move_verts", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1453, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("softwrap_core2.SpringEngine.move_verts", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_indexes), (&PyList_Type), 1, "indexes", 1))) __PYX_ERR(0, 1453, __pyx_L1_error) + __pyx_r = __pyx_pf_14softwrap_core2_12SpringEngine_18move_verts(((struct __pyx_obj_14softwrap_core2_SpringEngine *)__pyx_v_self), __pyx_v_indexes, __pyx_v_x, __pyx_v_y, __pyx_v_z); + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_12SpringEngine_18move_verts(struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_self, PyObject *__pyx_v_indexes, float __pyx_v_x, float __pyx_v_y, float __pyx_v_z) { + vec3 __pyx_v_delta; + int __pyx_v_i; + int __pyx_v_index; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + Py_ssize_t __pyx_t_1; + Py_ssize_t __pyx_t_2; + int __pyx_t_3; + PyObject *__pyx_t_4 = NULL; + int __pyx_t_5; + int __pyx_t_6; + int __pyx_t_7; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("move_verts", 0); + + /* "core/core2.pyx":1454 + * + * def move_verts(self, list indexes, float x, float y, float z): + * cdef vec3 delta = vec3(x, y, z) # <<<<<<<<<<<<<< + * cdef int i, index + * for i in range(len(indexes)): + */ + +# line 1454 "core/core2.pyx" + __pyx_v_delta = vec3(__pyx_v_x, __pyx_v_y, __pyx_v_z); + + /* "core/core2.pyx":1456 + * cdef vec3 delta = vec3(x, y, z) + * cdef int i, index + * for i in range(len(indexes)): # <<<<<<<<<<<<<< + * index = indexes[i] + * if index < 0 or index >= self.n_verts: + */ + +# line 1456 "core/core2.pyx" + if (unlikely(__pyx_v_indexes == Py_None)) { + +# line 1456 "core/core2.pyx" + PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); + +# line 1456 "core/core2.pyx" + __PYX_ERR(0, 1456, __pyx_L1_error) + +# line 1456 "core/core2.pyx" + } + +# line 1456 "core/core2.pyx" + __pyx_t_1 = PyList_GET_SIZE(__pyx_v_indexes); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1456, __pyx_L1_error) + +# line 1456 "core/core2.pyx" + __pyx_t_2 = __pyx_t_1; + +# line 1456 "core/core2.pyx" + for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) { + +# line 1456 "core/core2.pyx" + __pyx_v_i = __pyx_t_3; + + /* "core/core2.pyx":1457 + * cdef int i, index + * for i in range(len(indexes)): + * index = indexes[i] # <<<<<<<<<<<<<< + * if index < 0 or index >= self.n_verts: + * raise IndexError + */ + +# line 1457 "core/core2.pyx" + if (unlikely(__pyx_v_indexes == Py_None)) { + +# line 1457 "core/core2.pyx" + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + +# line 1457 "core/core2.pyx" + __PYX_ERR(0, 1457, __pyx_L1_error) + +# line 1457 "core/core2.pyx" + } + +# line 1457 "core/core2.pyx" + __pyx_t_4 = __Pyx_GetItemInt_List(__pyx_v_indexes, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 1, 1, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1457, __pyx_L1_error) + +# line 1457 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_4); + +# line 1457 "core/core2.pyx" + __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1457, __pyx_L1_error) + +# line 1457 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + +# line 1457 "core/core2.pyx" + __pyx_v_index = __pyx_t_5; + + /* "core/core2.pyx":1458 + * for i in range(len(indexes)): + * index = indexes[i] + * if index < 0 or index >= self.n_verts: # <<<<<<<<<<<<<< + * raise IndexError + * self.m.verts[index] += delta + */ + +# line 1458 "core/core2.pyx" + __pyx_t_7 = ((__pyx_v_index < 0) != 0); + +# line 1458 "core/core2.pyx" + if (!__pyx_t_7) { + +# line 1458 "core/core2.pyx" + } else { + +# line 1458 "core/core2.pyx" + __pyx_t_6 = __pyx_t_7; + +# line 1458 "core/core2.pyx" + goto __pyx_L6_bool_binop_done; + +# line 1458 "core/core2.pyx" + } + +# line 1458 "core/core2.pyx" + __pyx_t_7 = ((__pyx_v_index >= __pyx_v_self->n_verts) != 0); + +# line 1458 "core/core2.pyx" + __pyx_t_6 = __pyx_t_7; + +# line 1458 "core/core2.pyx" + __pyx_L6_bool_binop_done:; + +# line 1458 "core/core2.pyx" + if (unlikely(__pyx_t_6)) { + + /* "core/core2.pyx":1459 + * index = indexes[i] + * if index < 0 or index >= self.n_verts: + * raise IndexError # <<<<<<<<<<<<<< + * self.m.verts[index] += delta + * self.prev_verts[index] += delta + */ + +# line 1459 "core/core2.pyx" + __Pyx_Raise(__pyx_builtin_IndexError, 0, 0, 0); + +# line 1459 "core/core2.pyx" + __PYX_ERR(0, 1459, __pyx_L1_error) + + /* "core/core2.pyx":1458 + * for i in range(len(indexes)): + * index = indexes[i] + * if index < 0 or index >= self.n_verts: # <<<<<<<<<<<<<< + * raise IndexError + * self.m.verts[index] += delta + */ + +# line 1458 "core/core2.pyx" + } + + /* "core/core2.pyx":1460 + * if index < 0 or index >= self.n_verts: + * raise IndexError + * self.m.verts[index] += delta # <<<<<<<<<<<<<< + * self.prev_verts[index] += delta + * + */ + +# line 1460 "core/core2.pyx" + (__pyx_v_self->m->verts[__pyx_v_index]) += __pyx_v_delta; + + /* "core/core2.pyx":1461 + * raise IndexError + * self.m.verts[index] += delta + * self.prev_verts[index] += delta # <<<<<<<<<<<<<< + * + * def snap_to_bvh(self, float factor=1, int cycle_quality=10, str snapping_mode='SURFACE'): + */ + +# line 1461 "core/core2.pyx" + (__pyx_v_self->prev_verts[__pyx_v_index]) += __pyx_v_delta; + +# line 1461 "core/core2.pyx" + } + + /* "core/core2.pyx":1453 + * return ret + * + * def move_verts(self, list indexes, float x, float y, float z): # <<<<<<<<<<<<<< + * cdef vec3 delta = vec3(x, y, z) + * cdef int i, index + */ + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("softwrap_core2.SpringEngine.move_verts", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":1463 + * self.prev_verts[index] += delta + * + * def snap_to_bvh(self, float factor=1, int cycle_quality=10, str snapping_mode='SURFACE'): # <<<<<<<<<<<<<< + * cdef int snapping_mode_ = {'SURFACE': 1, + * 'OUTSIDE': 2, + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_12SpringEngine_21snap_to_bvh(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_12SpringEngine_21snap_to_bvh(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + float __pyx_v_factor; + int __pyx_v_cycle_quality; + PyObject *__pyx_v_snapping_mode = 0; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("snap_to_bvh (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_factor,&__pyx_n_s_cycle_quality,&__pyx_n_s_snapping_mode,0}; + PyObject* values[3] = {0,0,0}; + values[2] = ((PyObject*)__pyx_n_u_SURFACE); + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + CYTHON_FALLTHROUGH; + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + CYTHON_FALLTHROUGH; + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + CYTHON_FALLTHROUGH; + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (kw_args > 0) { + PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_factor); + if (value) { values[0] = value; kw_args--; } + } + CYTHON_FALLTHROUGH; + case 1: + if (kw_args > 0) { + PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_cycle_quality); + if (value) { values[1] = value; kw_args--; } + } + CYTHON_FALLTHROUGH; + case 2: + if (kw_args > 0) { + PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_snapping_mode); + if (value) { values[2] = value; kw_args--; } + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "snap_to_bvh") < 0)) __PYX_ERR(0, 1463, __pyx_L3_error) + } + } else { + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + CYTHON_FALLTHROUGH; + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + CYTHON_FALLTHROUGH; + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + CYTHON_FALLTHROUGH; + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + } + if (values[0]) { + __pyx_v_factor = __pyx_PyFloat_AsFloat(values[0]); if (unlikely((__pyx_v_factor == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 1463, __pyx_L3_error) + } else { + __pyx_v_factor = ((float)1.0); + } + if (values[1]) { + __pyx_v_cycle_quality = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_cycle_quality == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1463, __pyx_L3_error) + } else { + __pyx_v_cycle_quality = ((int)10); + } + __pyx_v_snapping_mode = ((PyObject*)values[2]); + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("snap_to_bvh", 0, 0, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1463, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("softwrap_core2.SpringEngine.snap_to_bvh", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_snapping_mode), (&PyUnicode_Type), 1, "snapping_mode", 1))) __PYX_ERR(0, 1463, __pyx_L1_error) + __pyx_r = __pyx_pf_14softwrap_core2_12SpringEngine_20snap_to_bvh(((struct __pyx_obj_14softwrap_core2_SpringEngine *)__pyx_v_self), __pyx_v_factor, __pyx_v_cycle_quality, __pyx_v_snapping_mode); + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_12SpringEngine_20snap_to_bvh(struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_self, float __pyx_v_factor, int __pyx_v_cycle_quality, PyObject *__pyx_v_snapping_mode) { + int __pyx_v_snapping_mode_; + struct BvhNearestResult __pyx_v_result; + int __pyx_v_i; + vec3 __pyx_v_v; + float __pyx_v_snapping; + unsigned int __pyx_v_cycle; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + int __pyx_t_4; + int __pyx_t_5; + int __pyx_t_6; + int __pyx_t_7; + int __pyx_t_8; + vec3 __pyx_t_9; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("snap_to_bvh", 0); + + /* "core/core2.pyx":1464 + * + * def snap_to_bvh(self, float factor=1, int cycle_quality=10, str snapping_mode='SURFACE'): + * cdef int snapping_mode_ = {'SURFACE': 1, # <<<<<<<<<<<<<< + * 'OUTSIDE': 2, + * 'INSIDE': 4}[snapping_mode] + */ + +# line 1464 "core/core2.pyx" + __pyx_t_1 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1464, __pyx_L1_error) + +# line 1464 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_1); + +# line 1464 "core/core2.pyx" + if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_SURFACE, __pyx_int_1) < 0) __PYX_ERR(0, 1464, __pyx_L1_error) + +# line 1464 "core/core2.pyx" + if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_OUTSIDE, __pyx_int_2) < 0) __PYX_ERR(0, 1464, __pyx_L1_error) + +# line 1464 "core/core2.pyx" + if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_INSIDE, __pyx_int_4) < 0) __PYX_ERR(0, 1464, __pyx_L1_error) + + /* "core/core2.pyx":1466 + * cdef int snapping_mode_ = {'SURFACE': 1, + * 'OUTSIDE': 2, + * 'INSIDE': 4}[snapping_mode] # <<<<<<<<<<<<<< + * + * if not self.bvh: + */ + +# line 1466 "core/core2.pyx" + __pyx_t_2 = __Pyx_PyDict_GetItem(__pyx_t_1, __pyx_v_snapping_mode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1466, __pyx_L1_error) + +# line 1466 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_2); + +# line 1466 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + +# line 1466 "core/core2.pyx" + __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1466, __pyx_L1_error) + +# line 1466 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + +# line 1466 "core/core2.pyx" + __pyx_v_snapping_mode_ = __pyx_t_3; + + /* "core/core2.pyx":1468 + * 'INSIDE': 4}[snapping_mode] + * + * if not self.bvh: # <<<<<<<<<<<<<< + * raise RuntimeError('No bvh avaliable') + * + */ + +# line 1468 "core/core2.pyx" + __pyx_t_4 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_self->bvh)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 1468, __pyx_L1_error) + +# line 1468 "core/core2.pyx" + __pyx_t_5 = ((!__pyx_t_4) != 0); + +# line 1468 "core/core2.pyx" + if (unlikely(__pyx_t_5)) { + + /* "core/core2.pyx":1469 + * + * if not self.bvh: + * raise RuntimeError('No bvh avaliable') # <<<<<<<<<<<<<< + * + * cycle_quality = nabs(cycle_quality) + */ + +# line 1469 "core/core2.pyx" + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__32, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1469, __pyx_L1_error) + +# line 1469 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_2); + +# line 1469 "core/core2.pyx" + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + +# line 1469 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + +# line 1469 "core/core2.pyx" + __PYX_ERR(0, 1469, __pyx_L1_error) + + /* "core/core2.pyx":1468 + * 'INSIDE': 4}[snapping_mode] + * + * if not self.bvh: # <<<<<<<<<<<<<< + * raise RuntimeError('No bvh avaliable') + * + */ + +# line 1468 "core/core2.pyx" + } + + /* "core/core2.pyx":1471 + * raise RuntimeError('No bvh avaliable') + * + * cycle_quality = nabs(cycle_quality) # <<<<<<<<<<<<<< + * self.snap_count += 1 + * + */ + +# line 1471 "core/core2.pyx" + __pyx_v_cycle_quality = nabs(__pyx_v_cycle_quality); + + /* "core/core2.pyx":1472 + * + * cycle_quality = nabs(cycle_quality) + * self.snap_count += 1 # <<<<<<<<<<<<<< + * + * cdef BvhNearestResult result + */ + +# line 1472 "core/core2.pyx" + __pyx_v_self->snap_count = (__pyx_v_self->snap_count + 1); + + /* "core/core2.pyx":1480 + * cdef unsigned int cycle + * + * with nogil: # <<<<<<<<<<<<<< + * for i in prange(self.n_verts): + * cycle = (i ^ 0x243F6A88) * 0x243F6A88 + */ + +# line 1480 "core/core2.pyx" + { + +# line 1480 "core/core2.pyx" + #ifdef WITH_THREAD + +# line 1480 "core/core2.pyx" + PyThreadState *_save; + +# line 1480 "core/core2.pyx" + Py_UNBLOCK_THREADS + +# line 1480 "core/core2.pyx" + __Pyx_FastGIL_Remember(); + +# line 1480 "core/core2.pyx" + #endif + /*try:*/ { + + /* "core/core2.pyx":1481 + * + * with nogil: + * for i in prange(self.n_verts): # <<<<<<<<<<<<<< + * cycle = (i ^ 0x243F6A88) * 0x243F6A88 + * cycle = cycle ^ cycle >> 5 + */ + +# line 1481 "core/core2.pyx" + __pyx_t_3 = __pyx_v_self->n_verts; + +# line 1481 "core/core2.pyx" + if ((1 == 0)) abort(); + +# line 1481 "core/core2.pyx" + { + +# line 1481 "core/core2.pyx" + #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))))) + +# line 1481 "core/core2.pyx" + #undef likely + +# line 1481 "core/core2.pyx" + #undef unlikely + #define likely(x) (x) + #define unlikely(x) (x) + +# line 1481 "core/core2.pyx" + #endif + +# line 1481 "core/core2.pyx" + __pyx_t_7 = (__pyx_t_3 - 0 + 1 - 1/abs(1)) / 1; + +# line 1481 "core/core2.pyx" + if (__pyx_t_7 > 0) + +# line 1481 "core/core2.pyx" + { + +# line 1481 "core/core2.pyx" + #ifdef _OPENMP + +# line 1481 "core/core2.pyx" + #pragma omp parallel private(__pyx_t_4, __pyx_t_5, __pyx_t_8, __pyx_t_9) + #endif /* _OPENMP */ + { + #ifdef _OPENMP + #pragma omp for lastprivate(__pyx_v_cycle) firstprivate(__pyx_v_i) lastprivate(__pyx_v_i) lastprivate(__pyx_v_result) lastprivate(__pyx_v_snapping) lastprivate(__pyx_v_v) + #endif /* _OPENMP */ + for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_7; __pyx_t_6++){ + { + __pyx_v_i = (int)(0 + 1 * __pyx_t_6); + /* Initialize private variables to invalid values */ + __pyx_v_cycle = ((unsigned int)0xbad0bad0); + __pyx_v_snapping = ((float)__PYX_NAN()); + + /* "core/core2.pyx":1482 + * with nogil: + * for i in prange(self.n_verts): + * cycle = (i ^ 0x243F6A88) * 0x243F6A88 # <<<<<<<<<<<<<< + * cycle = cycle ^ cycle >> 5 + * cycle = cycle + self.snap_count + */ + +# line 1482 "core/core2.pyx" + __pyx_v_cycle = ((((unsigned int)__pyx_v_i) ^ ((unsigned int)0x243F6A88)) * ((unsigned int)0x243F6A88)); + + /* "core/core2.pyx":1483 + * for i in prange(self.n_verts): + * cycle = (i ^ 0x243F6A88) * 0x243F6A88 + * cycle = cycle ^ cycle >> 5 # <<<<<<<<<<<<<< + * cycle = cycle + self.snap_count + * + */ + +# line 1483 "core/core2.pyx" + __pyx_v_cycle = (__pyx_v_cycle ^ (__pyx_v_cycle >> 5)); + + /* "core/core2.pyx":1484 + * cycle = (i ^ 0x243F6A88) * 0x243F6A88 + * cycle = cycle ^ cycle >> 5 + * cycle = cycle + self.snap_count # <<<<<<<<<<<<<< + * + * if cycle % cycle_quality > 0 and self.bvh_closest_indexes[i] >= 0: + */ + +# line 1484 "core/core2.pyx" + __pyx_v_cycle = (__pyx_v_cycle + __pyx_v_self->snap_count); + + /* "core/core2.pyx":1486 + * cycle = cycle + self.snap_count + * + * if cycle % cycle_quality > 0 and self.bvh_closest_indexes[i] >= 0: # <<<<<<<<<<<<<< + * result.tri_index = self.bvh_closest_indexes[i] + * result.point = project_point_plane( + */ + +# line 1486 "core/core2.pyx" + __pyx_t_4 = (((__pyx_v_cycle % __pyx_v_cycle_quality) > 0) != 0); + +# line 1486 "core/core2.pyx" + if (__pyx_t_4) { + +# line 1486 "core/core2.pyx" + } else { + +# line 1486 "core/core2.pyx" + __pyx_t_5 = __pyx_t_4; + +# line 1486 "core/core2.pyx" + goto __pyx_L12_bool_binop_done; + +# line 1486 "core/core2.pyx" + } + +# line 1486 "core/core2.pyx" + __pyx_t_4 = (((__pyx_v_self->bvh_closest_indexes[__pyx_v_i]) >= 0) != 0); + +# line 1486 "core/core2.pyx" + __pyx_t_5 = __pyx_t_4; + +# line 1486 "core/core2.pyx" + __pyx_L12_bool_binop_done:; + +# line 1486 "core/core2.pyx" + if (__pyx_t_5) { + + /* "core/core2.pyx":1487 + * + * if cycle % cycle_quality > 0 and self.bvh_closest_indexes[i] >= 0: + * result.tri_index = self.bvh_closest_indexes[i] # <<<<<<<<<<<<<< + * result.point = project_point_plane( + * self.m.verts[i], + */ + +# line 1487 "core/core2.pyx" + __pyx_v_result.tri_index = (__pyx_v_self->bvh_closest_indexes[__pyx_v_i]); + + /* "core/core2.pyx":1488 + * if cycle % cycle_quality > 0 and self.bvh_closest_indexes[i] >= 0: + * result.tri_index = self.bvh_closest_indexes[i] + * result.point = project_point_plane( # <<<<<<<<<<<<<< + * self.m.verts[i], + * self.bvh.mesh.verts[self.bvh.mesh.triangles[result.tri_index][0]], + */ + +# line 1488 "core/core2.pyx" + __pyx_v_result.point = project_point_plane((__pyx_v_self->m->verts[__pyx_v_i]), (__pyx_v_self->bvh->mesh->verts[((__pyx_v_self->bvh->mesh->triangles[__pyx_v_result.tri_index])[0])]), (__pyx_v_self->bvh->mesh->face_normals[__pyx_v_result.tri_index])); + + /* "core/core2.pyx":1486 + * cycle = cycle + self.snap_count + * + * if cycle % cycle_quality > 0 and self.bvh_closest_indexes[i] >= 0: # <<<<<<<<<<<<<< + * result.tri_index = self.bvh_closest_indexes[i] + * result.point = project_point_plane( + */ + +# line 1486 "core/core2.pyx" + goto __pyx_L11; + +# line 1486 "core/core2.pyx" + } + + /* "core/core2.pyx":1494 + * ) + * else: + * result = self.bvh._find_nearest(self.m.verts[i]) # <<<<<<<<<<<<<< + * self.bvh_closest_indexes[i] = result.tri_index + * + */ + /*else*/ { + __pyx_v_result = __pyx_f_14softwrap_core2_3BVH__find_nearest(__pyx_v_self->bvh, (__pyx_v_self->m->verts[__pyx_v_i])); + + /* "core/core2.pyx":1495 + * else: + * result = self.bvh._find_nearest(self.m.verts[i]) + * self.bvh_closest_indexes[i] = result.tri_index # <<<<<<<<<<<<<< + * + * v = result.point - self.m.verts[i] + */ + +# line 1495 "core/core2.pyx" + __pyx_t_8 = __pyx_v_result.tri_index; + +# line 1495 "core/core2.pyx" + (__pyx_v_self->bvh_closest_indexes[__pyx_v_i]) = __pyx_t_8; + +# line 1495 "core/core2.pyx" + } + +# line 1495 "core/core2.pyx" + __pyx_L11:; + + /* "core/core2.pyx":1497 + * self.bvh_closest_indexes[i] = result.tri_index + * + * v = result.point - self.m.verts[i] # <<<<<<<<<<<<<< + * + * if snapping_mode_ & 1: + */ + +# line 1497 "core/core2.pyx" + __pyx_v_v = (__pyx_v_result.point - (__pyx_v_self->m->verts[__pyx_v_i])); + + /* "core/core2.pyx":1499 + * v = result.point - self.m.verts[i] + * + * if snapping_mode_ & 1: # <<<<<<<<<<<<<< + * if v.dot(self.bvh.mesh.face_normals[result.tri_index]) > 0: + * if v.dot(self.m.vert_normals[i]) < 0: + */ + +# line 1499 "core/core2.pyx" + __pyx_t_5 = ((__pyx_v_snapping_mode_ & 1) != 0); + +# line 1499 "core/core2.pyx" + if (__pyx_t_5) { + + /* "core/core2.pyx":1500 + * + * if snapping_mode_ & 1: + * if v.dot(self.bvh.mesh.face_normals[result.tri_index]) > 0: # <<<<<<<<<<<<<< + * if v.dot(self.m.vert_normals[i]) < 0: + * v = self.m.vert_normals[i] * v.len() + v * 0.5 + */ + +# line 1500 "core/core2.pyx" + __pyx_t_5 = ((__pyx_v_v.dot((__pyx_v_self->bvh->mesh->face_normals[__pyx_v_result.tri_index])) > 0.0) != 0); + +# line 1500 "core/core2.pyx" + if (__pyx_t_5) { + + /* "core/core2.pyx":1501 + * if snapping_mode_ & 1: + * if v.dot(self.bvh.mesh.face_normals[result.tri_index]) > 0: + * if v.dot(self.m.vert_normals[i]) < 0: # <<<<<<<<<<<<<< + * v = self.m.vert_normals[i] * v.len() + v * 0.5 + * + */ + +# line 1501 "core/core2.pyx" + __pyx_t_5 = ((__pyx_v_v.dot((__pyx_v_self->m->vert_normals[__pyx_v_i])) < 0.0) != 0); + +# line 1501 "core/core2.pyx" + if (__pyx_t_5) { + + /* "core/core2.pyx":1502 + * if v.dot(self.bvh.mesh.face_normals[result.tri_index]) > 0: + * if v.dot(self.m.vert_normals[i]) < 0: + * v = self.m.vert_normals[i] * v.len() + v * 0.5 # <<<<<<<<<<<<<< + * + * + */ + +# line 1502 "core/core2.pyx" + __pyx_v_v = (((__pyx_v_self->m->vert_normals[__pyx_v_i]) * __pyx_v_v.len()) + (__pyx_v_v * 0.5)); + + /* "core/core2.pyx":1501 + * if snapping_mode_ & 1: + * if v.dot(self.bvh.mesh.face_normals[result.tri_index]) > 0: + * if v.dot(self.m.vert_normals[i]) < 0: # <<<<<<<<<<<<<< + * v = self.m.vert_normals[i] * v.len() + v * 0.5 + * + */ + +# line 1501 "core/core2.pyx" + } + + /* "core/core2.pyx":1500 + * + * if snapping_mode_ & 1: + * if v.dot(self.bvh.mesh.face_normals[result.tri_index]) > 0: # <<<<<<<<<<<<<< + * if v.dot(self.m.vert_normals[i]) < 0: + * v = self.m.vert_normals[i] * v.len() + v * 0.5 + */ + +# line 1500 "core/core2.pyx" + } + + /* "core/core2.pyx":1505 + * + * + * snapping = self.m.vert_normals[i].dot(self.bvh.mesh.face_normals[result.tri_index]) # <<<<<<<<<<<<<< + * snapping = snapping * snapping + * + */ + +# line 1505 "core/core2.pyx" + __pyx_v_snapping = (__pyx_v_self->m->vert_normals[__pyx_v_i]).dot((__pyx_v_self->bvh->mesh->face_normals[__pyx_v_result.tri_index])); + + /* "core/core2.pyx":1506 + * + * snapping = self.m.vert_normals[i].dot(self.bvh.mesh.face_normals[result.tri_index]) + * snapping = snapping * snapping # <<<<<<<<<<<<<< + * + * v = v * factor * snapping + */ + +# line 1506 "core/core2.pyx" + __pyx_v_snapping = (__pyx_v_snapping * __pyx_v_snapping); + + /* "core/core2.pyx":1508 + * snapping = snapping * snapping + * + * v = v * factor * snapping # <<<<<<<<<<<<<< + * self.m.verts[i] += v + * + */ + +# line 1508 "core/core2.pyx" + __pyx_v_v = ((__pyx_v_v * __pyx_v_factor) * __pyx_v_snapping); + + /* "core/core2.pyx":1509 + * + * v = v * factor * snapping + * self.m.verts[i] += v # <<<<<<<<<<<<<< + * + * elif snapping_mode_ & (2 | 4): + */ + +# line 1509 "core/core2.pyx" + (__pyx_v_self->m->verts[__pyx_v_i]) += __pyx_v_v; + + /* "core/core2.pyx":1499 + * v = result.point - self.m.verts[i] + * + * if snapping_mode_ & 1: # <<<<<<<<<<<<<< + * if v.dot(self.bvh.mesh.face_normals[result.tri_index]) > 0: + * if v.dot(self.m.vert_normals[i]) < 0: + */ + +# line 1499 "core/core2.pyx" + goto __pyx_L14; + +# line 1499 "core/core2.pyx" + } + + /* "core/core2.pyx":1511 + * self.m.verts[i] += v + * + * elif snapping_mode_ & (2 | 4): # <<<<<<<<<<<<<< + * if (v.dot(self.bvh.mesh.face_normals[result.tri_index]) > 0) ^ (snapping_mode_ & 4 > 0): + * v = self.m.verts[i] = result.point + */ + +# line 1511 "core/core2.pyx" + __pyx_t_5 = ((__pyx_v_snapping_mode_ & 6) != 0); + +# line 1511 "core/core2.pyx" + if (__pyx_t_5) { + + /* "core/core2.pyx":1512 + * + * elif snapping_mode_ & (2 | 4): + * if (v.dot(self.bvh.mesh.face_normals[result.tri_index]) > 0) ^ (snapping_mode_ & 4 > 0): # <<<<<<<<<<<<<< + * v = self.m.verts[i] = result.point + * + */ + +# line 1512 "core/core2.pyx" + __pyx_t_5 = (((__pyx_v_v.dot((__pyx_v_self->bvh->mesh->face_normals[__pyx_v_result.tri_index])) > 0.0) ^ ((__pyx_v_snapping_mode_ & 4) > 0)) != 0); + +# line 1512 "core/core2.pyx" + if (__pyx_t_5) { + + /* "core/core2.pyx":1513 + * elif snapping_mode_ & (2 | 4): + * if (v.dot(self.bvh.mesh.face_normals[result.tri_index]) > 0) ^ (snapping_mode_ & 4 > 0): + * v = self.m.verts[i] = result.point # <<<<<<<<<<<<<< + * + * cpdef SpringLinks create_spring_group(self, list links): + */ + +# line 1513 "core/core2.pyx" + __pyx_t_9 = __pyx_v_result.point; + +# line 1513 "core/core2.pyx" + __pyx_v_v = __pyx_t_9; + +# line 1513 "core/core2.pyx" + (__pyx_v_self->m->verts[__pyx_v_i]) = __pyx_t_9; + + /* "core/core2.pyx":1512 + * + * elif snapping_mode_ & (2 | 4): + * if (v.dot(self.bvh.mesh.face_normals[result.tri_index]) > 0) ^ (snapping_mode_ & 4 > 0): # <<<<<<<<<<<<<< + * v = self.m.verts[i] = result.point + * + */ + +# line 1512 "core/core2.pyx" + } + + /* "core/core2.pyx":1511 + * self.m.verts[i] += v + * + * elif snapping_mode_ & (2 | 4): # <<<<<<<<<<<<<< + * if (v.dot(self.bvh.mesh.face_normals[result.tri_index]) > 0) ^ (snapping_mode_ & 4 > 0): + * v = self.m.verts[i] = result.point + */ + +# line 1511 "core/core2.pyx" + } + +# line 1511 "core/core2.pyx" + __pyx_L14:; + +# line 1511 "core/core2.pyx" + } + +# line 1511 "core/core2.pyx" + } + +# line 1511 "core/core2.pyx" + } + +# line 1511 "core/core2.pyx" + } + +# line 1511 "core/core2.pyx" + } + +# line 1511 "core/core2.pyx" + #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))))) + +# line 1511 "core/core2.pyx" + #undef likely + +# line 1511 "core/core2.pyx" + #undef unlikely + #define likely(x) __builtin_expect(!!(x), 1) + #define unlikely(x) __builtin_expect(!!(x), 0) + +# line 1511 "core/core2.pyx" + #endif + +# line 1511 "core/core2.pyx" + } + + /* "core/core2.pyx":1480 + * cdef unsigned int cycle + * + * with nogil: # <<<<<<<<<<<<<< + * for i in prange(self.n_verts): + * cycle = (i ^ 0x243F6A88) * 0x243F6A88 + */ + /*finally:*/ { + /*normal exit:*/{ + #ifdef WITH_THREAD + __Pyx_FastGIL_Forget(); + Py_BLOCK_THREADS + #endif + goto __pyx_L6; + } + __pyx_L6:; + } + } + + /* "core/core2.pyx":1463 + * self.prev_verts[index] += delta + * + * def snap_to_bvh(self, float factor=1, int cycle_quality=10, str snapping_mode='SURFACE'): # <<<<<<<<<<<<<< + * cdef int snapping_mode_ = {'SURFACE': 1, + * 'OUTSIDE': 2, + */ + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("softwrap_core2.SpringEngine.snap_to_bvh", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":1515 + * v = self.m.verts[i] = result.point + * + * cpdef SpringLinks create_spring_group(self, list links): # <<<<<<<<<<<<<< + * return SpringLinks(self, links) + * + */ + +static PyObject *__pyx_pw_14softwrap_core2_12SpringEngine_23create_spring_group(PyObject *__pyx_v_self, PyObject *__pyx_v_links); /*proto*/ +static struct __pyx_obj_14softwrap_core2_SpringLinks *__pyx_f_14softwrap_core2_12SpringEngine_create_spring_group(struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_self, PyObject *__pyx_v_links, int __pyx_skip_dispatch) { + struct __pyx_obj_14softwrap_core2_SpringLinks *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("create_spring_group", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) { + #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS + static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; + if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) { + PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); + #endif + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_create_spring_group); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1515, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_14softwrap_core2_12SpringEngine_23create_spring_group)) { + __Pyx_XDECREF(((PyObject *)__pyx_r)); + __Pyx_INCREF(__pyx_t_1); + __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { + __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); + if (likely(__pyx_t_4)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); + __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_3, function); + } + } + __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_links) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_links); + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1515, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_14softwrap_core2_SpringLinks))))) __PYX_ERR(0, 1515, __pyx_L1_error) + __pyx_r = ((struct __pyx_obj_14softwrap_core2_SpringLinks *)__pyx_t_2); + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS + __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); + __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self)); + if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) { + __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; + } + #endif + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS + } + #endif + } + + /* "core/core2.pyx":1516 + * + * cpdef SpringLinks create_spring_group(self, list links): + * return SpringLinks(self, links) # <<<<<<<<<<<<<< + * + * cpdef SymmetryMap create_symmetry_map(self): + */ + +# line 1516 "core/core2.pyx" + __Pyx_XDECREF(((PyObject *)__pyx_r)); + +# line 1516 "core/core2.pyx" + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1516, __pyx_L1_error) + +# line 1516 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_1); + +# line 1516 "core/core2.pyx" + __Pyx_INCREF(((PyObject *)__pyx_v_self)); + +# line 1516 "core/core2.pyx" + __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); + +# line 1516 "core/core2.pyx" + PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self)); + +# line 1516 "core/core2.pyx" + __Pyx_INCREF(__pyx_v_links); + +# line 1516 "core/core2.pyx" + __Pyx_GIVEREF(__pyx_v_links); + +# line 1516 "core/core2.pyx" + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_links); + +# line 1516 "core/core2.pyx" + __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_14softwrap_core2_SpringLinks), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1516, __pyx_L1_error) + +# line 1516 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_2); + +# line 1516 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + +# line 1516 "core/core2.pyx" + __pyx_r = ((struct __pyx_obj_14softwrap_core2_SpringLinks *)__pyx_t_2); + +# line 1516 "core/core2.pyx" + __pyx_t_2 = 0; + +# line 1516 "core/core2.pyx" + goto __pyx_L0; + + /* "core/core2.pyx":1515 + * v = self.m.verts[i] = result.point + * + * cpdef SpringLinks create_spring_group(self, list links): # <<<<<<<<<<<<<< + * return SpringLinks(self, links) + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("softwrap_core2.SpringEngine.create_spring_group", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF((PyObject *)__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_12SpringEngine_23create_spring_group(PyObject *__pyx_v_self, PyObject *__pyx_v_links); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_12SpringEngine_23create_spring_group(PyObject *__pyx_v_self, PyObject *__pyx_v_links) { + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("create_spring_group (wrapper)", 0); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_links), (&PyList_Type), 1, "links", 1))) __PYX_ERR(0, 1515, __pyx_L1_error) + __pyx_r = __pyx_pf_14softwrap_core2_12SpringEngine_22create_spring_group(((struct __pyx_obj_14softwrap_core2_SpringEngine *)__pyx_v_self), ((PyObject*)__pyx_v_links)); + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_12SpringEngine_22create_spring_group(struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_self, PyObject *__pyx_v_links) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("create_spring_group", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = ((PyObject *)__pyx_f_14softwrap_core2_12SpringEngine_create_spring_group(__pyx_v_self, __pyx_v_links, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1515, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("softwrap_core2.SpringEngine.create_spring_group", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":1518 + * return SpringLinks(self, links) + * + * cpdef SymmetryMap create_symmetry_map(self): # <<<<<<<<<<<<<< + * return SymmetryMap(self) + * + */ + +static PyObject *__pyx_pw_14softwrap_core2_12SpringEngine_25create_symmetry_map(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static struct __pyx_obj_14softwrap_core2_SymmetryMap *__pyx_f_14softwrap_core2_12SpringEngine_create_symmetry_map(struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_self, int __pyx_skip_dispatch) { + struct __pyx_obj_14softwrap_core2_SymmetryMap *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("create_symmetry_map", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) { + #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS + static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; + if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) { + PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); + #endif + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_create_symmetry_map); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1518, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_14softwrap_core2_12SpringEngine_25create_symmetry_map)) { + __Pyx_XDECREF(((PyObject *)__pyx_r)); + __Pyx_INCREF(__pyx_t_1); + __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { + __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); + if (likely(__pyx_t_4)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); + __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_3, function); + } + } + __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1518, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_14softwrap_core2_SymmetryMap))))) __PYX_ERR(0, 1518, __pyx_L1_error) + __pyx_r = ((struct __pyx_obj_14softwrap_core2_SymmetryMap *)__pyx_t_2); + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS + __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); + __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self)); + if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) { + __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; + } + #endif + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS + } + #endif + } + + /* "core/core2.pyx":1519 + * + * cpdef SymmetryMap create_symmetry_map(self): + * return SymmetryMap(self) # <<<<<<<<<<<<<< + * + * cpdef TernarySmoothingLinks create_ternary_links(self, list links): + */ + +# line 1519 "core/core2.pyx" + __Pyx_XDECREF(((PyObject *)__pyx_r)); + +# line 1519 "core/core2.pyx" + __pyx_t_1 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_14softwrap_core2_SymmetryMap), ((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1519, __pyx_L1_error) + +# line 1519 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_1); + +# line 1519 "core/core2.pyx" + __pyx_r = ((struct __pyx_obj_14softwrap_core2_SymmetryMap *)__pyx_t_1); + +# line 1519 "core/core2.pyx" + __pyx_t_1 = 0; + +# line 1519 "core/core2.pyx" + goto __pyx_L0; + + /* "core/core2.pyx":1518 + * return SpringLinks(self, links) + * + * cpdef SymmetryMap create_symmetry_map(self): # <<<<<<<<<<<<<< + * return SymmetryMap(self) + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("softwrap_core2.SpringEngine.create_symmetry_map", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF((PyObject *)__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_12SpringEngine_25create_symmetry_map(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_12SpringEngine_25create_symmetry_map(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("create_symmetry_map (wrapper)", 0); + __pyx_r = __pyx_pf_14softwrap_core2_12SpringEngine_24create_symmetry_map(((struct __pyx_obj_14softwrap_core2_SpringEngine *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_12SpringEngine_24create_symmetry_map(struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("create_symmetry_map", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = ((PyObject *)__pyx_f_14softwrap_core2_12SpringEngine_create_symmetry_map(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1518, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("softwrap_core2.SpringEngine.create_symmetry_map", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":1521 + * return SymmetryMap(self) + * + * cpdef TernarySmoothingLinks create_ternary_links(self, list links): # <<<<<<<<<<<<<< + * return TernarySmoothingLinks(self, links) + * + */ + +static PyObject *__pyx_pw_14softwrap_core2_12SpringEngine_27create_ternary_links(PyObject *__pyx_v_self, PyObject *__pyx_v_links); /*proto*/ +static struct __pyx_obj_14softwrap_core2_TernarySmoothingLinks *__pyx_f_14softwrap_core2_12SpringEngine_create_ternary_links(struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_self, PyObject *__pyx_v_links, int __pyx_skip_dispatch) { + struct __pyx_obj_14softwrap_core2_TernarySmoothingLinks *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("create_ternary_links", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) { + #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS + static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; + if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) { + PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); + #endif + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_create_ternary_links); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1521, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_14softwrap_core2_12SpringEngine_27create_ternary_links)) { + __Pyx_XDECREF(((PyObject *)__pyx_r)); + __Pyx_INCREF(__pyx_t_1); + __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { + __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); + if (likely(__pyx_t_4)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); + __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_3, function); + } + } + __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_links) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_links); + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1521, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_14softwrap_core2_TernarySmoothingLinks))))) __PYX_ERR(0, 1521, __pyx_L1_error) + __pyx_r = ((struct __pyx_obj_14softwrap_core2_TernarySmoothingLinks *)__pyx_t_2); + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS + __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); + __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self)); + if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) { + __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; + } + #endif + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS + } + #endif + } + + /* "core/core2.pyx":1522 + * + * cpdef TernarySmoothingLinks create_ternary_links(self, list links): + * return TernarySmoothingLinks(self, links) # <<<<<<<<<<<<<< + * + * cpdef QuaternarySmoothingLinks create_quaternary_links(self, list links): + */ + +# line 1522 "core/core2.pyx" + __Pyx_XDECREF(((PyObject *)__pyx_r)); + +# line 1522 "core/core2.pyx" + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1522, __pyx_L1_error) + +# line 1522 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_1); + +# line 1522 "core/core2.pyx" + __Pyx_INCREF(((PyObject *)__pyx_v_self)); + +# line 1522 "core/core2.pyx" + __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); + +# line 1522 "core/core2.pyx" + PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self)); + +# line 1522 "core/core2.pyx" + __Pyx_INCREF(__pyx_v_links); + +# line 1522 "core/core2.pyx" + __Pyx_GIVEREF(__pyx_v_links); + +# line 1522 "core/core2.pyx" + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_links); + +# line 1522 "core/core2.pyx" + __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_14softwrap_core2_TernarySmoothingLinks), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1522, __pyx_L1_error) + +# line 1522 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_2); + +# line 1522 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + +# line 1522 "core/core2.pyx" + __pyx_r = ((struct __pyx_obj_14softwrap_core2_TernarySmoothingLinks *)__pyx_t_2); + +# line 1522 "core/core2.pyx" + __pyx_t_2 = 0; + +# line 1522 "core/core2.pyx" + goto __pyx_L0; + + /* "core/core2.pyx":1521 + * return SymmetryMap(self) + * + * cpdef TernarySmoothingLinks create_ternary_links(self, list links): # <<<<<<<<<<<<<< + * return TernarySmoothingLinks(self, links) + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("softwrap_core2.SpringEngine.create_ternary_links", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF((PyObject *)__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_12SpringEngine_27create_ternary_links(PyObject *__pyx_v_self, PyObject *__pyx_v_links); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_12SpringEngine_27create_ternary_links(PyObject *__pyx_v_self, PyObject *__pyx_v_links) { + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("create_ternary_links (wrapper)", 0); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_links), (&PyList_Type), 1, "links", 1))) __PYX_ERR(0, 1521, __pyx_L1_error) + __pyx_r = __pyx_pf_14softwrap_core2_12SpringEngine_26create_ternary_links(((struct __pyx_obj_14softwrap_core2_SpringEngine *)__pyx_v_self), ((PyObject*)__pyx_v_links)); + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_12SpringEngine_26create_ternary_links(struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_self, PyObject *__pyx_v_links) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("create_ternary_links", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = ((PyObject *)__pyx_f_14softwrap_core2_12SpringEngine_create_ternary_links(__pyx_v_self, __pyx_v_links, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1521, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("softwrap_core2.SpringEngine.create_ternary_links", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":1524 + * return TernarySmoothingLinks(self, links) + * + * cpdef QuaternarySmoothingLinks create_quaternary_links(self, list links): # <<<<<<<<<<<<<< + * return QuaternarySmoothingLinks(self, links) + * + */ + +static PyObject *__pyx_pw_14softwrap_core2_12SpringEngine_29create_quaternary_links(PyObject *__pyx_v_self, PyObject *__pyx_v_links); /*proto*/ +static struct __pyx_obj_14softwrap_core2_QuaternarySmoothingLinks *__pyx_f_14softwrap_core2_12SpringEngine_create_quaternary_links(struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_self, PyObject *__pyx_v_links, int __pyx_skip_dispatch) { + struct __pyx_obj_14softwrap_core2_QuaternarySmoothingLinks *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("create_quaternary_links", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) { + #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS + static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; + if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) { + PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); + #endif + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_create_quaternary_links); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1524, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_14softwrap_core2_12SpringEngine_29create_quaternary_links)) { + __Pyx_XDECREF(((PyObject *)__pyx_r)); + __Pyx_INCREF(__pyx_t_1); + __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { + __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); + if (likely(__pyx_t_4)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); + __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_3, function); + } + } + __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_links) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_links); + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1524, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_14softwrap_core2_QuaternarySmoothingLinks))))) __PYX_ERR(0, 1524, __pyx_L1_error) + __pyx_r = ((struct __pyx_obj_14softwrap_core2_QuaternarySmoothingLinks *)__pyx_t_2); + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS + __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); + __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self)); + if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) { + __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; + } + #endif + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS + } + #endif + } + + /* "core/core2.pyx":1525 + * + * cpdef QuaternarySmoothingLinks create_quaternary_links(self, list links): + * return QuaternarySmoothingLinks(self, links) # <<<<<<<<<<<<<< + * + * cpdef SpringEngineMask create_mask(self, mask): + */ + +# line 1525 "core/core2.pyx" + __Pyx_XDECREF(((PyObject *)__pyx_r)); + +# line 1525 "core/core2.pyx" + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1525, __pyx_L1_error) + +# line 1525 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_1); + +# line 1525 "core/core2.pyx" + __Pyx_INCREF(((PyObject *)__pyx_v_self)); + +# line 1525 "core/core2.pyx" + __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); + +# line 1525 "core/core2.pyx" + PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self)); + +# line 1525 "core/core2.pyx" + __Pyx_INCREF(__pyx_v_links); + +# line 1525 "core/core2.pyx" + __Pyx_GIVEREF(__pyx_v_links); + +# line 1525 "core/core2.pyx" + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_links); + +# line 1525 "core/core2.pyx" + __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_14softwrap_core2_QuaternarySmoothingLinks), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1525, __pyx_L1_error) + +# line 1525 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_2); + +# line 1525 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + +# line 1525 "core/core2.pyx" + __pyx_r = ((struct __pyx_obj_14softwrap_core2_QuaternarySmoothingLinks *)__pyx_t_2); + +# line 1525 "core/core2.pyx" + __pyx_t_2 = 0; + +# line 1525 "core/core2.pyx" + goto __pyx_L0; + + /* "core/core2.pyx":1524 + * return TernarySmoothingLinks(self, links) + * + * cpdef QuaternarySmoothingLinks create_quaternary_links(self, list links): # <<<<<<<<<<<<<< + * return QuaternarySmoothingLinks(self, links) + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("softwrap_core2.SpringEngine.create_quaternary_links", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF((PyObject *)__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_12SpringEngine_29create_quaternary_links(PyObject *__pyx_v_self, PyObject *__pyx_v_links); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_12SpringEngine_29create_quaternary_links(PyObject *__pyx_v_self, PyObject *__pyx_v_links) { + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("create_quaternary_links (wrapper)", 0); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_links), (&PyList_Type), 1, "links", 1))) __PYX_ERR(0, 1524, __pyx_L1_error) + __pyx_r = __pyx_pf_14softwrap_core2_12SpringEngine_28create_quaternary_links(((struct __pyx_obj_14softwrap_core2_SpringEngine *)__pyx_v_self), ((PyObject*)__pyx_v_links)); + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_12SpringEngine_28create_quaternary_links(struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_self, PyObject *__pyx_v_links) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("create_quaternary_links", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = ((PyObject *)__pyx_f_14softwrap_core2_12SpringEngine_create_quaternary_links(__pyx_v_self, __pyx_v_links, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1524, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("softwrap_core2.SpringEngine.create_quaternary_links", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":1527 + * return QuaternarySmoothingLinks(self, links) + * + * cpdef SpringEngineMask create_mask(self, mask): # <<<<<<<<<<<<<< + * return SpringEngineMask(self, mask) + * + */ + +static PyObject *__pyx_pw_14softwrap_core2_12SpringEngine_31create_mask(PyObject *__pyx_v_self, PyObject *__pyx_v_mask); /*proto*/ +static struct __pyx_obj_14softwrap_core2_SpringEngineMask *__pyx_f_14softwrap_core2_12SpringEngine_create_mask(struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_self, PyObject *__pyx_v_mask, int __pyx_skip_dispatch) { + struct __pyx_obj_14softwrap_core2_SpringEngineMask *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("create_mask", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) { + #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS + static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; + if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) { + PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); + #endif + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_create_mask); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1527, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_14softwrap_core2_12SpringEngine_31create_mask)) { + __Pyx_XDECREF(((PyObject *)__pyx_r)); + __Pyx_INCREF(__pyx_t_1); + __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { + __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); + if (likely(__pyx_t_4)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); + __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_3, function); + } + } + __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_mask) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_mask); + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1527, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_14softwrap_core2_SpringEngineMask))))) __PYX_ERR(0, 1527, __pyx_L1_error) + __pyx_r = ((struct __pyx_obj_14softwrap_core2_SpringEngineMask *)__pyx_t_2); + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS + __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); + __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self)); + if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) { + __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; + } + #endif + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS + } + #endif + } + + /* "core/core2.pyx":1528 + * + * cpdef SpringEngineMask create_mask(self, mask): + * return SpringEngineMask(self, mask) # <<<<<<<<<<<<<< + * + * cpdef void random_verts(self, float factor, unsigned int seed=0x452821E6): + */ + +# line 1528 "core/core2.pyx" + __Pyx_XDECREF(((PyObject *)__pyx_r)); + +# line 1528 "core/core2.pyx" + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1528, __pyx_L1_error) + +# line 1528 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_1); + +# line 1528 "core/core2.pyx" + __Pyx_INCREF(((PyObject *)__pyx_v_self)); + +# line 1528 "core/core2.pyx" + __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); + +# line 1528 "core/core2.pyx" + PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self)); + +# line 1528 "core/core2.pyx" + __Pyx_INCREF(__pyx_v_mask); + +# line 1528 "core/core2.pyx" + __Pyx_GIVEREF(__pyx_v_mask); + +# line 1528 "core/core2.pyx" + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_mask); + +# line 1528 "core/core2.pyx" + __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_14softwrap_core2_SpringEngineMask), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1528, __pyx_L1_error) + +# line 1528 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_2); + +# line 1528 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + +# line 1528 "core/core2.pyx" + __pyx_r = ((struct __pyx_obj_14softwrap_core2_SpringEngineMask *)__pyx_t_2); + +# line 1528 "core/core2.pyx" + __pyx_t_2 = 0; + +# line 1528 "core/core2.pyx" + goto __pyx_L0; + + /* "core/core2.pyx":1527 + * return QuaternarySmoothingLinks(self, links) + * + * cpdef SpringEngineMask create_mask(self, mask): # <<<<<<<<<<<<<< + * return SpringEngineMask(self, mask) + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("softwrap_core2.SpringEngine.create_mask", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF((PyObject *)__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_12SpringEngine_31create_mask(PyObject *__pyx_v_self, PyObject *__pyx_v_mask); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_12SpringEngine_31create_mask(PyObject *__pyx_v_self, PyObject *__pyx_v_mask) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("create_mask (wrapper)", 0); + __pyx_r = __pyx_pf_14softwrap_core2_12SpringEngine_30create_mask(((struct __pyx_obj_14softwrap_core2_SpringEngine *)__pyx_v_self), ((PyObject *)__pyx_v_mask)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_12SpringEngine_30create_mask(struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_self, PyObject *__pyx_v_mask) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("create_mask", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = ((PyObject *)__pyx_f_14softwrap_core2_12SpringEngine_create_mask(__pyx_v_self, __pyx_v_mask, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1527, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("softwrap_core2.SpringEngine.create_mask", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":1530 + * return SpringEngineMask(self, mask) + * + * cpdef void random_verts(self, float factor, unsigned int seed=0x452821E6): # <<<<<<<<<<<<<< + * cdef int i + * cdef unsigned int xorstate = 0x452821E6 + */ + +static PyObject *__pyx_pw_14softwrap_core2_12SpringEngine_33random_verts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static void __pyx_f_14softwrap_core2_12SpringEngine_random_verts(struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_self, float __pyx_v_factor, int __pyx_skip_dispatch, struct __pyx_opt_args_14softwrap_core2_12SpringEngine_random_verts *__pyx_optional_args) { + unsigned int __pyx_v_seed = ((unsigned int)0x452821E6); + int __pyx_v_i; + unsigned int __pyx_v_xorstate; + vec3 __pyx_v_v; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + int __pyx_t_7; + PyObject *__pyx_t_8 = NULL; + int __pyx_t_9; + int __pyx_t_10; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("random_verts", 0); + if (__pyx_optional_args) { + if (__pyx_optional_args->__pyx_n > 0) { + __pyx_v_seed = __pyx_optional_args->seed; + } + } + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) { + #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS + static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; + if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) { + PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); + #endif + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_random_verts); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1530, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_14softwrap_core2_12SpringEngine_33random_verts)) { + __pyx_t_3 = PyFloat_FromDouble(__pyx_v_factor); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1530, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = __Pyx_PyInt_From_unsigned_int(__pyx_v_seed); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1530, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_INCREF(__pyx_t_1); + __pyx_t_5 = __pyx_t_1; __pyx_t_6 = NULL; + __pyx_t_7 = 0; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { + __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5); + if (likely(__pyx_t_6)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); + __Pyx_INCREF(__pyx_t_6); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_5, function); + __pyx_t_7 = 1; + } + } + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_5)) { + PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_3, __pyx_t_4}; + __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1530, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { + PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_3, __pyx_t_4}; + __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1530, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } else + #endif + { + __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1530, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + if (__pyx_t_6) { + __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL; + } + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_4); + __pyx_t_3 = 0; + __pyx_t_4 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1530, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + } + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS + __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); + __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self)); + if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) { + __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; + } + #endif + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS + } + #endif + } + + /* "core/core2.pyx":1532 + * cpdef void random_verts(self, float factor, unsigned int seed=0x452821E6): + * cdef int i + * cdef unsigned int xorstate = 0x452821E6 # <<<<<<<<<<<<<< + * cdef vec3 v + * with nogil: + */ + +# line 1532 "core/core2.pyx" + __pyx_v_xorstate = 0x452821E6; + + /* "core/core2.pyx":1534 + * cdef unsigned int xorstate = 0x452821E6 + * cdef vec3 v + * with nogil: # <<<<<<<<<<<<<< + * for i in prange(self.n_verts): + * v = vec3(xorshiftf(&xorstate), xorshiftf(&xorstate), xorshiftf(&xorstate)) * factor + */ + +# line 1534 "core/core2.pyx" + { + +# line 1534 "core/core2.pyx" + #ifdef WITH_THREAD + +# line 1534 "core/core2.pyx" + PyThreadState *_save; + +# line 1534 "core/core2.pyx" + Py_UNBLOCK_THREADS + +# line 1534 "core/core2.pyx" + __Pyx_FastGIL_Remember(); + +# line 1534 "core/core2.pyx" + #endif + /*try:*/ { + + /* "core/core2.pyx":1535 + * cdef vec3 v + * with nogil: + * for i in prange(self.n_verts): # <<<<<<<<<<<<<< + * v = vec3(xorshiftf(&xorstate), xorshiftf(&xorstate), xorshiftf(&xorstate)) * factor + * self.m.verts[i] += v + */ + +# line 1535 "core/core2.pyx" + __pyx_t_7 = __pyx_v_self->n_verts; + +# line 1535 "core/core2.pyx" + if ((1 == 0)) abort(); + +# line 1535 "core/core2.pyx" + { + +# line 1535 "core/core2.pyx" + #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))))) + +# line 1535 "core/core2.pyx" + #undef likely + +# line 1535 "core/core2.pyx" + #undef unlikely + #define likely(x) (x) + #define unlikely(x) (x) + +# line 1535 "core/core2.pyx" + #endif + +# line 1535 "core/core2.pyx" + __pyx_t_10 = (__pyx_t_7 - 0 + 1 - 1/abs(1)) / 1; + +# line 1535 "core/core2.pyx" + if (__pyx_t_10 > 0) + +# line 1535 "core/core2.pyx" + { + +# line 1535 "core/core2.pyx" + #ifdef _OPENMP + +# line 1535 "core/core2.pyx" + #pragma omp parallel + #endif /* _OPENMP */ + { + #ifdef _OPENMP + #pragma omp for firstprivate(__pyx_v_i) lastprivate(__pyx_v_i) lastprivate(__pyx_v_v) + #endif /* _OPENMP */ + for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_10; __pyx_t_9++){ + { + __pyx_v_i = (int)(0 + 1 * __pyx_t_9); + + /* "core/core2.pyx":1536 + * with nogil: + * for i in prange(self.n_verts): + * v = vec3(xorshiftf(&xorstate), xorshiftf(&xorstate), xorshiftf(&xorstate)) * factor # <<<<<<<<<<<<<< + * self.m.verts[i] += v + * self.prev_verts[i] += v + */ + +# line 1536 "core/core2.pyx" + __pyx_v_v = (vec3(__pyx_f_14softwrap_core2_xorshiftf((&__pyx_v_xorstate)), __pyx_f_14softwrap_core2_xorshiftf((&__pyx_v_xorstate)), __pyx_f_14softwrap_core2_xorshiftf((&__pyx_v_xorstate))) * __pyx_v_factor); + + /* "core/core2.pyx":1537 + * for i in prange(self.n_verts): + * v = vec3(xorshiftf(&xorstate), xorshiftf(&xorstate), xorshiftf(&xorstate)) * factor + * self.m.verts[i] += v # <<<<<<<<<<<<<< + * self.prev_verts[i] += v + * + */ + +# line 1537 "core/core2.pyx" + (__pyx_v_self->m->verts[__pyx_v_i]) += __pyx_v_v; + + /* "core/core2.pyx":1538 + * v = vec3(xorshiftf(&xorstate), xorshiftf(&xorstate), xorshiftf(&xorstate)) * factor + * self.m.verts[i] += v + * self.prev_verts[i] += v # <<<<<<<<<<<<<< + * + * cpdef void kinetic_step(self, float damping): + */ + +# line 1538 "core/core2.pyx" + (__pyx_v_self->prev_verts[__pyx_v_i]) += __pyx_v_v; + +# line 1538 "core/core2.pyx" + } + +# line 1538 "core/core2.pyx" + } + +# line 1538 "core/core2.pyx" + } + +# line 1538 "core/core2.pyx" + } + +# line 1538 "core/core2.pyx" + } + +# line 1538 "core/core2.pyx" + #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))))) + +# line 1538 "core/core2.pyx" + #undef likely + +# line 1538 "core/core2.pyx" + #undef unlikely + #define likely(x) __builtin_expect(!!(x), 1) + #define unlikely(x) __builtin_expect(!!(x), 0) + +# line 1538 "core/core2.pyx" + #endif + +# line 1538 "core/core2.pyx" + } + + /* "core/core2.pyx":1534 + * cdef unsigned int xorstate = 0x452821E6 + * cdef vec3 v + * with nogil: # <<<<<<<<<<<<<< + * for i in prange(self.n_verts): + * v = vec3(xorshiftf(&xorstate), xorshiftf(&xorstate), xorshiftf(&xorstate)) * factor + */ + /*finally:*/ { + /*normal exit:*/{ + #ifdef WITH_THREAD + __Pyx_FastGIL_Forget(); + Py_BLOCK_THREADS + #endif + goto __pyx_L5; + } + __pyx_L5:; + } + } + + /* "core/core2.pyx":1530 + * return SpringEngineMask(self, mask) + * + * cpdef void random_verts(self, float factor, unsigned int seed=0x452821E6): # <<<<<<<<<<<<<< + * cdef int i + * cdef unsigned int xorstate = 0x452821E6 + */ + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_WriteUnraisable("softwrap_core2.SpringEngine.random_verts", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); + __pyx_L0:; + __Pyx_RefNannyFinishContext(); +} + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_12SpringEngine_33random_verts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_12SpringEngine_33random_verts(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + float __pyx_v_factor; + unsigned int __pyx_v_seed; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("random_verts (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_factor,&__pyx_n_s_seed,0}; + PyObject* values[2] = {0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + CYTHON_FALLTHROUGH; + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + CYTHON_FALLTHROUGH; + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_factor)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + CYTHON_FALLTHROUGH; + case 1: + if (kw_args > 0) { + PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_seed); + if (value) { values[1] = value; kw_args--; } + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "random_verts") < 0)) __PYX_ERR(0, 1530, __pyx_L3_error) + } + } else { + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + CYTHON_FALLTHROUGH; + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + break; + default: goto __pyx_L5_argtuple_error; + } + } + __pyx_v_factor = __pyx_PyFloat_AsFloat(values[0]); if (unlikely((__pyx_v_factor == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 1530, __pyx_L3_error) + if (values[1]) { + __pyx_v_seed = __Pyx_PyInt_As_unsigned_int(values[1]); if (unlikely((__pyx_v_seed == (unsigned int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1530, __pyx_L3_error) + } else { + __pyx_v_seed = ((unsigned int)0x452821E6); + } + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("random_verts", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 1530, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("softwrap_core2.SpringEngine.random_verts", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_14softwrap_core2_12SpringEngine_32random_verts(((struct __pyx_obj_14softwrap_core2_SpringEngine *)__pyx_v_self), __pyx_v_factor, __pyx_v_seed); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_12SpringEngine_32random_verts(struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_self, float __pyx_v_factor, unsigned int __pyx_v_seed) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + struct __pyx_opt_args_14softwrap_core2_12SpringEngine_random_verts __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("random_verts", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1.__pyx_n = 1; + __pyx_t_1.seed = __pyx_v_seed; + __pyx_vtabptr_14softwrap_core2_SpringEngine->random_verts(__pyx_v_self, __pyx_v_factor, 1, &__pyx_t_1); + __pyx_t_2 = __Pyx_void_to_None(NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1530, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("softwrap_core2.SpringEngine.random_verts", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":1540 + * self.prev_verts[i] += v + * + * cpdef void kinetic_step(self, float damping): # <<<<<<<<<<<<<< + * cdef int i + * + */ + +static PyObject *__pyx_pw_14softwrap_core2_12SpringEngine_35kinetic_step(PyObject *__pyx_v_self, PyObject *__pyx_arg_damping); /*proto*/ +static void __pyx_f_14softwrap_core2_12SpringEngine_kinetic_step(struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_self, float __pyx_v_damping, int __pyx_skip_dispatch) { + int __pyx_v_i; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + int __pyx_t_6; + int __pyx_t_7; + int __pyx_t_8; + vec3 *__pyx_t_9; + vec3 *__pyx_t_10; + vec3 *__pyx_t_11; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("kinetic_step", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) { + #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS + static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; + if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) { + PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); + #endif + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_kinetic_step); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1540, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_14softwrap_core2_12SpringEngine_35kinetic_step)) { + __pyx_t_3 = PyFloat_FromDouble(__pyx_v_damping); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1540, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_t_1); + __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_4, function); + } + } + __pyx_t_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); + __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1540, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS + __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); + __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self)); + if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) { + __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; + } + #endif + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS + } + #endif + } + + /* "core/core2.pyx":1543 + * cdef int i + * + * with nogil: # <<<<<<<<<<<<<< + * for i in prange(self.n_verts): + * self.tmp_verts[i] = (self.m.verts[i] - self.prev_verts[i]) * damping + self.m.verts[i] + */ + +# line 1543 "core/core2.pyx" + { + +# line 1543 "core/core2.pyx" + #ifdef WITH_THREAD + +# line 1543 "core/core2.pyx" + PyThreadState *_save; + +# line 1543 "core/core2.pyx" + Py_UNBLOCK_THREADS + +# line 1543 "core/core2.pyx" + __Pyx_FastGIL_Remember(); + +# line 1543 "core/core2.pyx" + #endif + /*try:*/ { + + /* "core/core2.pyx":1544 + * + * with nogil: + * for i in prange(self.n_verts): # <<<<<<<<<<<<<< + * self.tmp_verts[i] = (self.m.verts[i] - self.prev_verts[i]) * damping + self.m.verts[i] + * + */ + +# line 1544 "core/core2.pyx" + __pyx_t_6 = __pyx_v_self->n_verts; + +# line 1544 "core/core2.pyx" + if ((1 == 0)) abort(); + +# line 1544 "core/core2.pyx" + { + +# line 1544 "core/core2.pyx" + #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))))) + +# line 1544 "core/core2.pyx" + #undef likely + +# line 1544 "core/core2.pyx" + #undef unlikely + #define likely(x) (x) + #define unlikely(x) (x) + +# line 1544 "core/core2.pyx" + #endif + +# line 1544 "core/core2.pyx" + __pyx_t_8 = (__pyx_t_6 - 0 + 1 - 1/abs(1)) / 1; + +# line 1544 "core/core2.pyx" + if (__pyx_t_8 > 0) + +# line 1544 "core/core2.pyx" + { + +# line 1544 "core/core2.pyx" + #ifdef _OPENMP + +# line 1544 "core/core2.pyx" + #pragma omp parallel + #endif /* _OPENMP */ + { + #ifdef _OPENMP + #pragma omp for firstprivate(__pyx_v_i) lastprivate(__pyx_v_i) + #endif /* _OPENMP */ + for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_8; __pyx_t_7++){ + { + __pyx_v_i = (int)(0 + 1 * __pyx_t_7); + + /* "core/core2.pyx":1545 + * with nogil: + * for i in prange(self.n_verts): + * self.tmp_verts[i] = (self.m.verts[i] - self.prev_verts[i]) * damping + self.m.verts[i] # <<<<<<<<<<<<<< + * + * self.prev_verts, self.m.verts, self.tmp_verts = self.m.verts, self.tmp_verts, self.prev_verts + */ + +# line 1545 "core/core2.pyx" + (__pyx_v_self->tmp_verts[__pyx_v_i]) = ((((__pyx_v_self->m->verts[__pyx_v_i]) - (__pyx_v_self->prev_verts[__pyx_v_i])) * __pyx_v_damping) + (__pyx_v_self->m->verts[__pyx_v_i])); + +# line 1545 "core/core2.pyx" + } + +# line 1545 "core/core2.pyx" + } + +# line 1545 "core/core2.pyx" + } + +# line 1545 "core/core2.pyx" + } + +# line 1545 "core/core2.pyx" + } + +# line 1545 "core/core2.pyx" + #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))))) + +# line 1545 "core/core2.pyx" + #undef likely + +# line 1545 "core/core2.pyx" + #undef unlikely + #define likely(x) __builtin_expect(!!(x), 1) + #define unlikely(x) __builtin_expect(!!(x), 0) + +# line 1545 "core/core2.pyx" + #endif + +# line 1545 "core/core2.pyx" + } + + /* "core/core2.pyx":1543 + * cdef int i + * + * with nogil: # <<<<<<<<<<<<<< + * for i in prange(self.n_verts): + * self.tmp_verts[i] = (self.m.verts[i] - self.prev_verts[i]) * damping + self.m.verts[i] + */ + /*finally:*/ { + /*normal exit:*/{ + #ifdef WITH_THREAD + __Pyx_FastGIL_Forget(); + Py_BLOCK_THREADS + #endif + goto __pyx_L5; + } + __pyx_L5:; + } + } + + /* "core/core2.pyx":1547 + * self.tmp_verts[i] = (self.m.verts[i] - self.prev_verts[i]) * damping + self.m.verts[i] + * + * self.prev_verts, self.m.verts, self.tmp_verts = self.m.verts, self.tmp_verts, self.prev_verts # <<<<<<<<<<<<<< + * + * cpdef void update_mesh_normals(self, float factor): + */ + +# line 1547 "core/core2.pyx" + __pyx_t_9 = __pyx_v_self->m->verts; + +# line 1547 "core/core2.pyx" + __pyx_t_10 = __pyx_v_self->tmp_verts; + +# line 1547 "core/core2.pyx" + __pyx_t_11 = __pyx_v_self->prev_verts; + +# line 1547 "core/core2.pyx" + __pyx_v_self->prev_verts = __pyx_t_9; + +# line 1547 "core/core2.pyx" + __pyx_v_self->m->verts = __pyx_t_10; + +# line 1547 "core/core2.pyx" + __pyx_v_self->tmp_verts = __pyx_t_11; + + /* "core/core2.pyx":1540 + * self.prev_verts[i] += v + * + * cpdef void kinetic_step(self, float damping): # <<<<<<<<<<<<<< + * cdef int i + * + */ + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_WriteUnraisable("softwrap_core2.SpringEngine.kinetic_step", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); + __pyx_L0:; + __Pyx_RefNannyFinishContext(); +} + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_12SpringEngine_35kinetic_step(PyObject *__pyx_v_self, PyObject *__pyx_arg_damping); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_12SpringEngine_35kinetic_step(PyObject *__pyx_v_self, PyObject *__pyx_arg_damping) { + float __pyx_v_damping; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("kinetic_step (wrapper)", 0); + assert(__pyx_arg_damping); { + __pyx_v_damping = __pyx_PyFloat_AsFloat(__pyx_arg_damping); if (unlikely((__pyx_v_damping == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 1540, __pyx_L3_error) + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("softwrap_core2.SpringEngine.kinetic_step", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_14softwrap_core2_12SpringEngine_34kinetic_step(((struct __pyx_obj_14softwrap_core2_SpringEngine *)__pyx_v_self), ((float)__pyx_v_damping)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_12SpringEngine_34kinetic_step(struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_self, float __pyx_v_damping) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("kinetic_step", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_void_to_None(__pyx_f_14softwrap_core2_12SpringEngine_kinetic_step(__pyx_v_self, __pyx_v_damping, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1540, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("softwrap_core2.SpringEngine.kinetic_step", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "core/core2.pyx":1549 + * self.prev_verts, self.m.verts, self.tmp_verts = self.m.verts, self.tmp_verts, self.prev_verts + * + * cpdef void update_mesh_normals(self, float factor): # <<<<<<<<<<<<<< + * self.tmp_verts, self.m.vert_normals = self.m.vert_normals, self.tmp_verts + * + */ + +static PyObject *__pyx_pw_14softwrap_core2_12SpringEngine_37update_mesh_normals(PyObject *__pyx_v_self, PyObject *__pyx_arg_factor); /*proto*/ +static void __pyx_f_14softwrap_core2_12SpringEngine_update_mesh_normals(struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_self, float __pyx_v_factor, int __pyx_skip_dispatch) { + int __pyx_v_i; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + vec3 *__pyx_t_6; + vec3 *__pyx_t_7; + int __pyx_t_8; + int __pyx_t_9; + int __pyx_t_10; + int __pyx_t_11; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("update_mesh_normals", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) { + #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS + static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; + if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) { + PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); + #endif + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_update_mesh_normals); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1549, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_14softwrap_core2_12SpringEngine_37update_mesh_normals)) { + __pyx_t_3 = PyFloat_FromDouble(__pyx_v_factor); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1549, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_t_1); + __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_4, function); + } + } + __pyx_t_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); + __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1549, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS + __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); + __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self)); + if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) { + __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; + } + #endif + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS + } + #endif + } + + /* "core/core2.pyx":1550 + * + * cpdef void update_mesh_normals(self, float factor): + * self.tmp_verts, self.m.vert_normals = self.m.vert_normals, self.tmp_verts # <<<<<<<<<<<<<< + * + * self.m.update_face_normals() + */ + +# line 1550 "core/core2.pyx" + __pyx_t_6 = __pyx_v_self->m->vert_normals; + +# line 1550 "core/core2.pyx" + __pyx_t_7 = __pyx_v_self->tmp_verts; + +# line 1550 "core/core2.pyx" + __pyx_v_self->tmp_verts = __pyx_t_6; + +# line 1550 "core/core2.pyx" + __pyx_v_self->m->vert_normals = __pyx_t_7; + + /* "core/core2.pyx":1552 + * self.tmp_verts, self.m.vert_normals = self.m.vert_normals, self.tmp_verts + * + * self.m.update_face_normals() # <<<<<<<<<<<<<< + * self.m.update_vert_normals() + * + */ + +# line 1552 "core/core2.pyx" + __pyx_f_14softwrap_core2_4Mesh_update_face_normals(__pyx_v_self->m, 0); + + /* "core/core2.pyx":1553 + * + * self.m.update_face_normals() + * self.m.update_vert_normals() # <<<<<<<<<<<<<< + * + * cdef int i + */ + +# line 1553 "core/core2.pyx" + __pyx_f_14softwrap_core2_4Mesh_update_vert_normals(__pyx_v_self->m, 0); + + /* "core/core2.pyx":1556 + * + * cdef int i + * if factor < 1: # <<<<<<<<<<<<<< + * with nogil: + * for i in prange(self.n_verts): + */ + +# line 1556 "core/core2.pyx" + __pyx_t_8 = ((__pyx_v_factor < 1.0) != 0); + +# line 1556 "core/core2.pyx" + if (__pyx_t_8) { + + /* "core/core2.pyx":1557 + * cdef int i + * if factor < 1: + * with nogil: # <<<<<<<<<<<<<< + * for i in prange(self.n_verts): + * self.m.vert_normals[i] = self.tmp_verts[i].lerp(self.m.vert_normals[i], factor) + */ + +# line 1557 "core/core2.pyx" + { + +# line 1557 "core/core2.pyx" + #ifdef WITH_THREAD + +# line 1557 "core/core2.pyx" + PyThreadState *_save; + +# line 1557 "core/core2.pyx" + Py_UNBLOCK_THREADS + +# line 1557 "core/core2.pyx" + __Pyx_FastGIL_Remember(); + +# line 1557 "core/core2.pyx" + #endif + /*try:*/ { + + /* "core/core2.pyx":1558 + * if factor < 1: + * with nogil: + * for i in prange(self.n_verts): # <<<<<<<<<<<<<< + * self.m.vert_normals[i] = self.tmp_verts[i].lerp(self.m.vert_normals[i], factor) + */ + +# line 1558 "core/core2.pyx" + __pyx_t_9 = __pyx_v_self->n_verts; + +# line 1558 "core/core2.pyx" + if ((1 == 0)) abort(); + +# line 1558 "core/core2.pyx" + { + +# line 1558 "core/core2.pyx" + #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))))) + +# line 1558 "core/core2.pyx" + #undef likely + +# line 1558 "core/core2.pyx" + #undef unlikely + #define likely(x) (x) + #define unlikely(x) (x) + +# line 1558 "core/core2.pyx" + #endif + +# line 1558 "core/core2.pyx" + __pyx_t_11 = (__pyx_t_9 - 0 + 1 - 1/abs(1)) / 1; + +# line 1558 "core/core2.pyx" + if (__pyx_t_11 > 0) + +# line 1558 "core/core2.pyx" + { + +# line 1558 "core/core2.pyx" + #ifdef _OPENMP + +# line 1558 "core/core2.pyx" + #pragma omp parallel + #endif /* _OPENMP */ + { + #ifdef _OPENMP + #pragma omp for firstprivate(__pyx_v_i) lastprivate(__pyx_v_i) + #endif /* _OPENMP */ + for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_11; __pyx_t_10++){ + { + __pyx_v_i = (int)(0 + 1 * __pyx_t_10); + + /* "core/core2.pyx":1559 + * with nogil: + * for i in prange(self.n_verts): + * self.m.vert_normals[i] = self.tmp_verts[i].lerp(self.m.vert_normals[i], factor) # <<<<<<<<<<<<<< + */ + +# line 1559 "core/core2.pyx" + (__pyx_v_self->m->vert_normals[__pyx_v_i]) = (__pyx_v_self->tmp_verts[__pyx_v_i]).lerp((__pyx_v_self->m->vert_normals[__pyx_v_i]), __pyx_v_factor); + +# line 1559 "core/core2.pyx" + } + +# line 1559 "core/core2.pyx" + } + +# line 1559 "core/core2.pyx" + } + +# line 1559 "core/core2.pyx" + } + +# line 1559 "core/core2.pyx" + } + +# line 1559 "core/core2.pyx" + #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))))) + +# line 1559 "core/core2.pyx" + #undef likely + +# line 1559 "core/core2.pyx" + #undef unlikely + #define likely(x) __builtin_expect(!!(x), 1) + #define unlikely(x) __builtin_expect(!!(x), 0) + +# line 1559 "core/core2.pyx" + #endif + +# line 1559 "core/core2.pyx" + } + + /* "core/core2.pyx":1557 + * cdef int i + * if factor < 1: + * with nogil: # <<<<<<<<<<<<<< + * for i in prange(self.n_verts): + * self.m.vert_normals[i] = self.tmp_verts[i].lerp(self.m.vert_normals[i], factor) + */ + /*finally:*/ { + /*normal exit:*/{ + #ifdef WITH_THREAD + __Pyx_FastGIL_Forget(); + Py_BLOCK_THREADS + #endif + goto __pyx_L6; + } + __pyx_L6:; + } + } + + /* "core/core2.pyx":1556 + * + * cdef int i + * if factor < 1: # <<<<<<<<<<<<<< + * with nogil: + * for i in prange(self.n_verts): + */ + +# line 1556 "core/core2.pyx" + } + + /* "core/core2.pyx":1549 + * self.prev_verts, self.m.verts, self.tmp_verts = self.m.verts, self.tmp_verts, self.prev_verts + * + * cpdef void update_mesh_normals(self, float factor): # <<<<<<<<<<<<<< + * self.tmp_verts, self.m.vert_normals = self.m.vert_normals, self.tmp_verts + * + */ + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_WriteUnraisable("softwrap_core2.SpringEngine.update_mesh_normals", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); + __pyx_L0:; + __Pyx_RefNannyFinishContext(); +} + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_12SpringEngine_37update_mesh_normals(PyObject *__pyx_v_self, PyObject *__pyx_arg_factor); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_12SpringEngine_37update_mesh_normals(PyObject *__pyx_v_self, PyObject *__pyx_arg_factor) { + float __pyx_v_factor; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("update_mesh_normals (wrapper)", 0); + assert(__pyx_arg_factor); { + __pyx_v_factor = __pyx_PyFloat_AsFloat(__pyx_arg_factor); if (unlikely((__pyx_v_factor == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 1549, __pyx_L3_error) + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("softwrap_core2.SpringEngine.update_mesh_normals", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_14softwrap_core2_12SpringEngine_36update_mesh_normals(((struct __pyx_obj_14softwrap_core2_SpringEngine *)__pyx_v_self), ((float)__pyx_v_factor)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_12SpringEngine_36update_mesh_normals(struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_self, float __pyx_v_factor) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("update_mesh_normals", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_void_to_None(__pyx_f_14softwrap_core2_12SpringEngine_update_mesh_normals(__pyx_v_self, __pyx_v_factor, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1549, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("softwrap_core2.SpringEngine.update_mesh_normals", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "(tree fragment)":1 + * def __reduce_cython__(self): # <<<<<<<<<<<<<< + * raise TypeError("self.bvh_closest_indexes,self.prev_verts,self.tmp_verts cannot be converted to a Python object for pickling") + * def __setstate_cython__(self, __pyx_state): + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_12SpringEngine_39__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_12SpringEngine_39__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0); + __pyx_r = __pyx_pf_14softwrap_core2_12SpringEngine_38__reduce_cython__(((struct __pyx_obj_14softwrap_core2_SpringEngine *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_12SpringEngine_38__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__reduce_cython__", 0); + + /* "(tree fragment)":2 + * def __reduce_cython__(self): + * raise TypeError("self.bvh_closest_indexes,self.prev_verts,self.tmp_verts cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<< + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("self.bvh_closest_indexes,self.prev_verts,self.tmp_verts cannot be converted to a Python object for pickling") + */ + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__33, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __PYX_ERR(1, 2, __pyx_L1_error) + + /* "(tree fragment)":1 + * def __reduce_cython__(self): # <<<<<<<<<<<<<< + * raise TypeError("self.bvh_closest_indexes,self.prev_verts,self.tmp_verts cannot be converted to a Python object for pickling") + * def __setstate_cython__(self, __pyx_state): + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("softwrap_core2.SpringEngine.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "(tree fragment)":3 + * def __reduce_cython__(self): + * raise TypeError("self.bvh_closest_indexes,self.prev_verts,self.tmp_verts cannot be converted to a Python object for pickling") + * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< + * raise TypeError("self.bvh_closest_indexes,self.prev_verts,self.tmp_verts cannot be converted to a Python object for pickling") + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_14softwrap_core2_12SpringEngine_41__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/ +static PyObject *__pyx_pw_14softwrap_core2_12SpringEngine_41__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0); + __pyx_r = __pyx_pf_14softwrap_core2_12SpringEngine_40__setstate_cython__(((struct __pyx_obj_14softwrap_core2_SpringEngine *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_14softwrap_core2_12SpringEngine_40__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_14softwrap_core2_SpringEngine *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__setstate_cython__", 0); + + /* "(tree fragment)":4 + * raise TypeError("self.bvh_closest_indexes,self.prev_verts,self.tmp_verts cannot be converted to a Python object for pickling") + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("self.bvh_closest_indexes,self.prev_verts,self.tmp_verts cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<< + */ + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__34, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __PYX_ERR(1, 4, __pyx_L1_error) + + /* "(tree fragment)":3 + * def __reduce_cython__(self): + * raise TypeError("self.bvh_closest_indexes,self.prev_verts,self.tmp_verts cannot be converted to a Python object for pickling") + * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< + * raise TypeError("self.bvh_closest_indexes,self.prev_verts,self.tmp_verts cannot be converted to a Python object for pickling") + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("softwrap_core2.SpringEngine.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "carray.from_py":77 + * + * @cname("__Pyx_carray_from_py_float") + * cdef int __Pyx_carray_from_py_float(object o, base_type *v, Py_ssize_t length) except -1: # <<<<<<<<<<<<<< + * cdef Py_ssize_t i = length + * try: + */ + +static int __Pyx_carray_from_py_float(PyObject *__pyx_v_o, float *__pyx_v_v, Py_ssize_t __pyx_v_length) { + Py_ssize_t __pyx_v_i; + PyObject *__pyx_v_item = NULL; + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + Py_ssize_t __pyx_t_4; + int __pyx_t_5; + int __pyx_t_6; + PyObject *__pyx_t_7 = NULL; + Py_ssize_t __pyx_t_8; + PyObject *(*__pyx_t_9)(PyObject *); + PyObject *__pyx_t_10 = NULL; + float __pyx_t_11; + char const *__pyx_t_12; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__Pyx_carray_from_py_float", 0); + + /* "carray.from_py":78 + * @cname("__Pyx_carray_from_py_float") + * cdef int __Pyx_carray_from_py_float(object o, base_type *v, Py_ssize_t length) except -1: + * cdef Py_ssize_t i = length # <<<<<<<<<<<<<< + * try: + * i = len(o) + */ + __pyx_v_i = __pyx_v_length; + + /* "carray.from_py":79 + * cdef int __Pyx_carray_from_py_float(object o, base_type *v, Py_ssize_t length) except -1: + * cdef Py_ssize_t i = length + * try: # <<<<<<<<<<<<<< + * i = len(o) + * except (TypeError, OverflowError): + */ + { + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3); + __Pyx_XGOTREF(__pyx_t_1); + __Pyx_XGOTREF(__pyx_t_2); + __Pyx_XGOTREF(__pyx_t_3); + /*try:*/ { + + /* "carray.from_py":80 + * cdef Py_ssize_t i = length + * try: + * i = len(o) # <<<<<<<<<<<<<< + * except (TypeError, OverflowError): + * pass + */ + __pyx_t_4 = PyObject_Length(__pyx_v_o); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(1, 80, __pyx_L3_error) + __pyx_v_i = __pyx_t_4; + + /* "carray.from_py":79 + * cdef int __Pyx_carray_from_py_float(object o, base_type *v, Py_ssize_t length) except -1: + * cdef Py_ssize_t i = length + * try: # <<<<<<<<<<<<<< + * i = len(o) + * except (TypeError, OverflowError): + */ + } + __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + goto __pyx_L8_try_end; + __pyx_L3_error:; + + /* "carray.from_py":81 + * try: + * i = len(o) + * except (TypeError, OverflowError): # <<<<<<<<<<<<<< + * pass + * if i == length: + */ + __pyx_t_5 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_TypeError) || __Pyx_PyErr_ExceptionMatches(__pyx_builtin_OverflowError); + if (__pyx_t_5) { + __Pyx_ErrRestore(0,0,0); + goto __pyx_L4_exception_handled; + } + goto __pyx_L5_except_error; + __pyx_L5_except_error:; + + /* "carray.from_py":79 + * cdef int __Pyx_carray_from_py_float(object o, base_type *v, Py_ssize_t length) except -1: + * cdef Py_ssize_t i = length + * try: # <<<<<<<<<<<<<< + * i = len(o) + * except (TypeError, OverflowError): + */ + __Pyx_XGIVEREF(__pyx_t_1); + __Pyx_XGIVEREF(__pyx_t_2); + __Pyx_XGIVEREF(__pyx_t_3); + __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); + goto __pyx_L1_error; + __pyx_L4_exception_handled:; + __Pyx_XGIVEREF(__pyx_t_1); + __Pyx_XGIVEREF(__pyx_t_2); + __Pyx_XGIVEREF(__pyx_t_3); + __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); + __pyx_L8_try_end:; + } + + /* "carray.from_py":83 + * except (TypeError, OverflowError): + * pass + * if i == length: # <<<<<<<<<<<<<< + * for i, item in enumerate(o): + * if i >= length: + */ + __pyx_t_6 = ((__pyx_v_i == __pyx_v_length) != 0); + if (__pyx_t_6) { + + /* "carray.from_py":84 + * pass + * if i == length: + * for i, item in enumerate(o): # <<<<<<<<<<<<<< + * if i >= length: + * break + */ + __pyx_t_4 = 0; + if (likely(PyList_CheckExact(__pyx_v_o)) || PyTuple_CheckExact(__pyx_v_o)) { + __pyx_t_7 = __pyx_v_o; __Pyx_INCREF(__pyx_t_7); __pyx_t_8 = 0; + __pyx_t_9 = NULL; + } else { + __pyx_t_8 = -1; __pyx_t_7 = PyObject_GetIter(__pyx_v_o); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 84, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_9 = Py_TYPE(__pyx_t_7)->tp_iternext; if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 84, __pyx_L1_error) + } + for (;;) { + if (likely(!__pyx_t_9)) { + if (likely(PyList_CheckExact(__pyx_t_7))) { + if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_7)) break; + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_10 = PyList_GET_ITEM(__pyx_t_7, __pyx_t_8); __Pyx_INCREF(__pyx_t_10); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(1, 84, __pyx_L1_error) + #else + __pyx_t_10 = PySequence_ITEM(__pyx_t_7, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 84, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + #endif + } else { + if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_7)) break; + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_10 = PyTuple_GET_ITEM(__pyx_t_7, __pyx_t_8); __Pyx_INCREF(__pyx_t_10); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(1, 84, __pyx_L1_error) + #else + __pyx_t_10 = PySequence_ITEM(__pyx_t_7, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 84, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + #endif + } + } else { + __pyx_t_10 = __pyx_t_9(__pyx_t_7); + if (unlikely(!__pyx_t_10)) { + PyObject* exc_type = PyErr_Occurred(); + if (exc_type) { + if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); + else __PYX_ERR(1, 84, __pyx_L1_error) + } + break; + } + __Pyx_GOTREF(__pyx_t_10); + } + __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_10); + __pyx_t_10 = 0; + __pyx_v_i = __pyx_t_4; + __pyx_t_4 = (__pyx_t_4 + 1); + + /* "carray.from_py":85 + * if i == length: + * for i, item in enumerate(o): + * if i >= length: # <<<<<<<<<<<<<< + * break + * v[i] = item + */ + __pyx_t_6 = ((__pyx_v_i >= __pyx_v_length) != 0); + if (__pyx_t_6) { + + /* "carray.from_py":86 + * for i, item in enumerate(o): + * if i >= length: + * break # <<<<<<<<<<<<<< + * v[i] = item + * else: + */ + goto __pyx_L11_break; + + /* "carray.from_py":85 + * if i == length: + * for i, item in enumerate(o): + * if i >= length: # <<<<<<<<<<<<<< + * break + * v[i] = item + */ + } + + /* "carray.from_py":87 + * if i >= length: + * break + * v[i] = item # <<<<<<<<<<<<<< + * else: + * i += 1 # convert index to length + */ + __pyx_t_11 = __pyx_PyFloat_AsFloat(__pyx_v_item); if (unlikely((__pyx_t_11 == (float)-1) && PyErr_Occurred())) __PYX_ERR(1, 87, __pyx_L1_error) + (__pyx_v_v[__pyx_v_i]) = __pyx_t_11; + + /* "carray.from_py":84 + * pass + * if i == length: + * for i, item in enumerate(o): # <<<<<<<<<<<<<< + * if i >= length: + * break + */ + } + /*else*/ { + + /* "carray.from_py":89 + * v[i] = item + * else: + * i += 1 # convert index to length # <<<<<<<<<<<<<< + * if i == length: + * return 0 + */ + __pyx_v_i = (__pyx_v_i + 1); + + /* "carray.from_py":90 + * else: + * i += 1 # convert index to length + * if i == length: # <<<<<<<<<<<<<< + * return 0 + * + */ + __pyx_t_6 = ((__pyx_v_i == __pyx_v_length) != 0); + if (__pyx_t_6) { + + /* "carray.from_py":91 + * i += 1 # convert index to length + * if i == length: + * return 0 # <<<<<<<<<<<<<< + * + * PyErr_Format( + */ + __pyx_r = 0; + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + goto __pyx_L0; + + /* "carray.from_py":90 + * else: + * i += 1 # convert index to length + * if i == length: # <<<<<<<<<<<<<< + * return 0 + * + */ + } + } + + /* "carray.from_py":84 + * pass + * if i == length: + * for i, item in enumerate(o): # <<<<<<<<<<<<<< + * if i >= length: + * break + */ + __pyx_L11_break:; + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + + /* "carray.from_py":83 + * except (TypeError, OverflowError): + * pass + * if i == length: # <<<<<<<<<<<<<< + * for i, item in enumerate(o): + * if i >= length: + */ + } + + /* "carray.from_py":96 + * IndexError, + * ("too many values found during array assignment, expected %zd" + * if i >= length else # <<<<<<<<<<<<<< + * "not enough values found during array assignment, expected %zd, got %zd"), + * length, i) + */ + if (((__pyx_v_i >= __pyx_v_length) != 0)) { + __pyx_t_12 = ((char const *)"too many values found during array assignment, expected %zd"); + } else { + __pyx_t_12 = ((char const *)"not enough values found during array assignment, expected %zd, got %zd"); + } + + /* "carray.from_py":93 + * return 0 + * + * PyErr_Format( # <<<<<<<<<<<<<< + * IndexError, + * ("too many values found during array assignment, expected %zd" + */ + __pyx_t_7 = PyErr_Format(__pyx_builtin_IndexError, __pyx_t_12, __pyx_v_length, __pyx_v_i); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 93, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + + /* "carray.from_py":77 + * + * @cname("__Pyx_carray_from_py_float") + * cdef int __Pyx_carray_from_py_float(object o, base_type *v, Py_ssize_t length) except -1: # <<<<<<<<<<<<<< + * cdef Py_ssize_t i = length + * try: + */ + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_10); + __Pyx_AddTraceback("carray.from_py.__Pyx_carray_from_py_float", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_item); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __Pyx_carray_from_py_int(PyObject *__pyx_v_o, int *__pyx_v_v, Py_ssize_t __pyx_v_length) { + Py_ssize_t __pyx_v_i; + PyObject *__pyx_v_item = NULL; + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + Py_ssize_t __pyx_t_4; + int __pyx_t_5; + int __pyx_t_6; + PyObject *__pyx_t_7 = NULL; + Py_ssize_t __pyx_t_8; + PyObject *(*__pyx_t_9)(PyObject *); + PyObject *__pyx_t_10 = NULL; + char const *__pyx_t_11; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__Pyx_carray_from_py_int", 0); + + /* "carray.from_py":78 + * @cname("__Pyx_carray_from_py_int") + * cdef int __Pyx_carray_from_py_int(object o, base_type *v, Py_ssize_t length) except -1: + * cdef Py_ssize_t i = length # <<<<<<<<<<<<<< + * try: + * i = len(o) + */ + __pyx_v_i = __pyx_v_length; + + /* "carray.from_py":79 + * cdef int __Pyx_carray_from_py_int(object o, base_type *v, Py_ssize_t length) except -1: + * cdef Py_ssize_t i = length + * try: # <<<<<<<<<<<<<< + * i = len(o) + * except (TypeError, OverflowError): + */ + { + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3); + __Pyx_XGOTREF(__pyx_t_1); + __Pyx_XGOTREF(__pyx_t_2); + __Pyx_XGOTREF(__pyx_t_3); + /*try:*/ { + + /* "carray.from_py":80 + * cdef Py_ssize_t i = length + * try: + * i = len(o) # <<<<<<<<<<<<<< + * except (TypeError, OverflowError): + * pass + */ + __pyx_t_4 = PyObject_Length(__pyx_v_o); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(1, 80, __pyx_L3_error) + __pyx_v_i = __pyx_t_4; + + /* "carray.from_py":79 + * cdef int __Pyx_carray_from_py_int(object o, base_type *v, Py_ssize_t length) except -1: + * cdef Py_ssize_t i = length + * try: # <<<<<<<<<<<<<< + * i = len(o) + * except (TypeError, OverflowError): + */ + } + __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + goto __pyx_L8_try_end; + __pyx_L3_error:; + + /* "carray.from_py":81 + * try: + * i = len(o) + * except (TypeError, OverflowError): # <<<<<<<<<<<<<< + * pass + * if i == length: + */ + __pyx_t_5 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_TypeError) || __Pyx_PyErr_ExceptionMatches(__pyx_builtin_OverflowError); + if (__pyx_t_5) { + __Pyx_ErrRestore(0,0,0); + goto __pyx_L4_exception_handled; + } + goto __pyx_L5_except_error; + __pyx_L5_except_error:; + + /* "carray.from_py":79 + * cdef int __Pyx_carray_from_py_int(object o, base_type *v, Py_ssize_t length) except -1: + * cdef Py_ssize_t i = length + * try: # <<<<<<<<<<<<<< + * i = len(o) + * except (TypeError, OverflowError): + */ + __Pyx_XGIVEREF(__pyx_t_1); + __Pyx_XGIVEREF(__pyx_t_2); + __Pyx_XGIVEREF(__pyx_t_3); + __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); + goto __pyx_L1_error; + __pyx_L4_exception_handled:; + __Pyx_XGIVEREF(__pyx_t_1); + __Pyx_XGIVEREF(__pyx_t_2); + __Pyx_XGIVEREF(__pyx_t_3); + __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); + __pyx_L8_try_end:; + } + + /* "carray.from_py":83 + * except (TypeError, OverflowError): + * pass + * if i == length: # <<<<<<<<<<<<<< + * for i, item in enumerate(o): + * if i >= length: + */ + __pyx_t_6 = ((__pyx_v_i == __pyx_v_length) != 0); + if (__pyx_t_6) { + + /* "carray.from_py":84 + * pass + * if i == length: + * for i, item in enumerate(o): # <<<<<<<<<<<<<< + * if i >= length: + * break + */ + __pyx_t_4 = 0; + if (likely(PyList_CheckExact(__pyx_v_o)) || PyTuple_CheckExact(__pyx_v_o)) { + __pyx_t_7 = __pyx_v_o; __Pyx_INCREF(__pyx_t_7); __pyx_t_8 = 0; + __pyx_t_9 = NULL; + } else { + __pyx_t_8 = -1; __pyx_t_7 = PyObject_GetIter(__pyx_v_o); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 84, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_9 = Py_TYPE(__pyx_t_7)->tp_iternext; if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 84, __pyx_L1_error) + } + for (;;) { + if (likely(!__pyx_t_9)) { + if (likely(PyList_CheckExact(__pyx_t_7))) { + if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_7)) break; + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_10 = PyList_GET_ITEM(__pyx_t_7, __pyx_t_8); __Pyx_INCREF(__pyx_t_10); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(1, 84, __pyx_L1_error) + #else + __pyx_t_10 = PySequence_ITEM(__pyx_t_7, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 84, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + #endif + } else { + if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_7)) break; + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_10 = PyTuple_GET_ITEM(__pyx_t_7, __pyx_t_8); __Pyx_INCREF(__pyx_t_10); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(1, 84, __pyx_L1_error) + #else + __pyx_t_10 = PySequence_ITEM(__pyx_t_7, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 84, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + #endif + } + } else { + __pyx_t_10 = __pyx_t_9(__pyx_t_7); + if (unlikely(!__pyx_t_10)) { + PyObject* exc_type = PyErr_Occurred(); + if (exc_type) { + if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); + else __PYX_ERR(1, 84, __pyx_L1_error) + } + break; + } + __Pyx_GOTREF(__pyx_t_10); + } + __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_10); + __pyx_t_10 = 0; + __pyx_v_i = __pyx_t_4; + __pyx_t_4 = (__pyx_t_4 + 1); + + /* "carray.from_py":85 + * if i == length: + * for i, item in enumerate(o): + * if i >= length: # <<<<<<<<<<<<<< + * break + * v[i] = item + */ + __pyx_t_6 = ((__pyx_v_i >= __pyx_v_length) != 0); + if (__pyx_t_6) { + + /* "carray.from_py":86 + * for i, item in enumerate(o): + * if i >= length: + * break # <<<<<<<<<<<<<< + * v[i] = item + * else: + */ + goto __pyx_L11_break; + + /* "carray.from_py":85 + * if i == length: + * for i, item in enumerate(o): + * if i >= length: # <<<<<<<<<<<<<< + * break + * v[i] = item + */ + } + + /* "carray.from_py":87 + * if i >= length: + * break + * v[i] = item # <<<<<<<<<<<<<< + * else: + * i += 1 # convert index to length + */ + __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_v_item); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 87, __pyx_L1_error) + (__pyx_v_v[__pyx_v_i]) = __pyx_t_5; + + /* "carray.from_py":84 + * pass + * if i == length: + * for i, item in enumerate(o): # <<<<<<<<<<<<<< + * if i >= length: + * break + */ + } + /*else*/ { + + /* "carray.from_py":89 + * v[i] = item + * else: + * i += 1 # convert index to length # <<<<<<<<<<<<<< + * if i == length: + * return 0 + */ + __pyx_v_i = (__pyx_v_i + 1); + + /* "carray.from_py":90 + * else: + * i += 1 # convert index to length + * if i == length: # <<<<<<<<<<<<<< + * return 0 + * + */ + __pyx_t_6 = ((__pyx_v_i == __pyx_v_length) != 0); + if (__pyx_t_6) { + + /* "carray.from_py":91 + * i += 1 # convert index to length + * if i == length: + * return 0 # <<<<<<<<<<<<<< + * + * PyErr_Format( + */ + __pyx_r = 0; + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + goto __pyx_L0; + + /* "carray.from_py":90 + * else: + * i += 1 # convert index to length + * if i == length: # <<<<<<<<<<<<<< + * return 0 + * + */ + } + } + + /* "carray.from_py":84 + * pass + * if i == length: + * for i, item in enumerate(o): # <<<<<<<<<<<<<< + * if i >= length: + * break + */ + __pyx_L11_break:; + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + + /* "carray.from_py":83 + * except (TypeError, OverflowError): + * pass + * if i == length: # <<<<<<<<<<<<<< + * for i, item in enumerate(o): + * if i >= length: + */ + } + + /* "carray.from_py":96 + * IndexError, + * ("too many values found during array assignment, expected %zd" + * if i >= length else # <<<<<<<<<<<<<< + * "not enough values found during array assignment, expected %zd, got %zd"), + * length, i) + */ + if (((__pyx_v_i >= __pyx_v_length) != 0)) { + __pyx_t_11 = ((char const *)"too many values found during array assignment, expected %zd"); + } else { + __pyx_t_11 = ((char const *)"not enough values found during array assignment, expected %zd, got %zd"); + } + + /* "carray.from_py":93 + * return 0 + * + * PyErr_Format( # <<<<<<<<<<<<<< + * IndexError, + * ("too many values found during array assignment, expected %zd" + */ + __pyx_t_7 = PyErr_Format(__pyx_builtin_IndexError, __pyx_t_11, __pyx_v_length, __pyx_v_i); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 93, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + + /* "carray.from_py":77 + * + * @cname("__Pyx_carray_from_py_int") + * cdef int __Pyx_carray_from_py_int(object o, base_type *v, Py_ssize_t length) except -1: # <<<<<<<<<<<<<< + * cdef Py_ssize_t i = length + * try: + */ + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_10); + __Pyx_AddTraceback("carray.from_py.__Pyx_carray_from_py_int", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_item); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "carray.to_py":112 + * + * @cname("__Pyx_carray_to_py_float") + * cdef inline list __Pyx_carray_to_py_float(base_type *v, Py_ssize_t length): # <<<<<<<<<<<<<< + * cdef size_t i + * cdef object value + */ + +static CYTHON_INLINE PyObject *__Pyx_carray_to_py_float(float *__pyx_v_v, Py_ssize_t __pyx_v_length) { + size_t __pyx_v_i; + PyObject *__pyx_v_value = 0; + PyObject *__pyx_v_l = NULL; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + size_t __pyx_t_2; + size_t __pyx_t_3; + size_t __pyx_t_4; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__Pyx_carray_to_py_float", 0); + + /* "carray.to_py":115 + * cdef size_t i + * cdef object value + * l = PyList_New(length) # <<<<<<<<<<<<<< + * for i in range(length): + * value = v[i] + */ + __pyx_t_1 = PyList_New(__pyx_v_length); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 115, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_v_l = ((PyObject*)__pyx_t_1); + __pyx_t_1 = 0; + + /* "carray.to_py":116 + * cdef object value + * l = PyList_New(length) + * for i in range(length): # <<<<<<<<<<<<<< + * value = v[i] + * Py_INCREF(value) + */ + __pyx_t_2 = ((size_t)__pyx_v_length); + __pyx_t_3 = __pyx_t_2; + for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { + __pyx_v_i = __pyx_t_4; + + /* "carray.to_py":117 + * l = PyList_New(length) + * for i in range(length): + * value = v[i] # <<<<<<<<<<<<<< + * Py_INCREF(value) + * PyList_SET_ITEM(l, i, value) + */ + __pyx_t_1 = PyFloat_FromDouble((__pyx_v_v[__pyx_v_i])); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 117, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_XDECREF_SET(__pyx_v_value, __pyx_t_1); + __pyx_t_1 = 0; + + /* "carray.to_py":118 + * for i in range(length): + * value = v[i] + * Py_INCREF(value) # <<<<<<<<<<<<<< + * PyList_SET_ITEM(l, i, value) + * return l + */ + Py_INCREF(__pyx_v_value); + + /* "carray.to_py":119 + * value = v[i] + * Py_INCREF(value) + * PyList_SET_ITEM(l, i, value) # <<<<<<<<<<<<<< + * return l + * + */ + PyList_SET_ITEM(__pyx_v_l, __pyx_v_i, __pyx_v_value); + } + + /* "carray.to_py":120 + * Py_INCREF(value) + * PyList_SET_ITEM(l, i, value) + * return l # <<<<<<<<<<<<<< + * + * + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_l); + __pyx_r = __pyx_v_l; + goto __pyx_L0; + + /* "carray.to_py":112 + * + * @cname("__Pyx_carray_to_py_float") + * cdef inline list __Pyx_carray_to_py_float(base_type *v, Py_ssize_t length): # <<<<<<<<<<<<<< + * cdef size_t i + * cdef object value + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("carray.to_py.__Pyx_carray_to_py_float", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_value); + __Pyx_XDECREF(__pyx_v_l); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "carray.to_py":124 + * + * @cname("__Pyx_carray_to_tuple_float") + * cdef inline tuple __Pyx_carray_to_tuple_float(base_type *v, Py_ssize_t length): # <<<<<<<<<<<<<< + * cdef size_t i + * cdef object value + */ + +static CYTHON_INLINE PyObject *__Pyx_carray_to_tuple_float(float *__pyx_v_v, Py_ssize_t __pyx_v_length) { + size_t __pyx_v_i; + PyObject *__pyx_v_value = 0; + PyObject *__pyx_v_t = NULL; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + size_t __pyx_t_2; + size_t __pyx_t_3; + size_t __pyx_t_4; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__Pyx_carray_to_tuple_float", 0); + + /* "carray.to_py":127 + * cdef size_t i + * cdef object value + * t = PyTuple_New(length) # <<<<<<<<<<<<<< + * for i in range(length): + * value = v[i] + */ + __pyx_t_1 = PyTuple_New(__pyx_v_length); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 127, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_v_t = ((PyObject*)__pyx_t_1); + __pyx_t_1 = 0; + + /* "carray.to_py":128 + * cdef object value + * t = PyTuple_New(length) + * for i in range(length): # <<<<<<<<<<<<<< + * value = v[i] + * Py_INCREF(value) + */ + __pyx_t_2 = ((size_t)__pyx_v_length); + __pyx_t_3 = __pyx_t_2; + for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { + __pyx_v_i = __pyx_t_4; + + /* "carray.to_py":129 + * t = PyTuple_New(length) + * for i in range(length): + * value = v[i] # <<<<<<<<<<<<<< + * Py_INCREF(value) + * PyTuple_SET_ITEM(t, i, value) + */ + __pyx_t_1 = PyFloat_FromDouble((__pyx_v_v[__pyx_v_i])); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 129, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_XDECREF_SET(__pyx_v_value, __pyx_t_1); + __pyx_t_1 = 0; + + /* "carray.to_py":130 + * for i in range(length): + * value = v[i] + * Py_INCREF(value) # <<<<<<<<<<<<<< + * PyTuple_SET_ITEM(t, i, value) + * return t + */ + Py_INCREF(__pyx_v_value); + + /* "carray.to_py":131 + * value = v[i] + * Py_INCREF(value) + * PyTuple_SET_ITEM(t, i, value) # <<<<<<<<<<<<<< + * return t + */ + PyTuple_SET_ITEM(__pyx_v_t, __pyx_v_i, __pyx_v_value); + } + + /* "carray.to_py":132 + * Py_INCREF(value) + * PyTuple_SET_ITEM(t, i, value) + * return t # <<<<<<<<<<<<<< + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_t); + __pyx_r = __pyx_v_t; + goto __pyx_L0; + + /* "carray.to_py":124 + * + * @cname("__Pyx_carray_to_tuple_float") + * cdef inline tuple __Pyx_carray_to_tuple_float(base_type *v, Py_ssize_t length): # <<<<<<<<<<<<<< + * cdef size_t i + * cdef object value + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("carray.to_py.__Pyx_carray_to_tuple_float", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_value); + __Pyx_XDECREF(__pyx_v_t); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} +static struct __pyx_vtabstruct_14softwrap_core2_Mesh __pyx_vtable_14softwrap_core2_Mesh; + +static PyObject *__pyx_tp_new_14softwrap_core2_Mesh(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { + struct __pyx_obj_14softwrap_core2_Mesh *p; + PyObject *o; + o = (*t->tp_alloc)(t, 0); + if (unlikely(!o)) return 0; + p = ((struct __pyx_obj_14softwrap_core2_Mesh *)o); + p->__pyx_vtab = __pyx_vtabptr_14softwrap_core2_Mesh; + return o; +} + +static void __pyx_tp_dealloc_14softwrap_core2_Mesh(PyObject *o) { + { + PyObject *etype, *eval, *etb; + PyErr_Fetch(&etype, &eval, &etb); + __Pyx_SET_REFCNT(o, Py_REFCNT(o) + 1); + __pyx_pw_14softwrap_core2_4Mesh_15__dealloc__(o); + __Pyx_SET_REFCNT(o, Py_REFCNT(o) - 1); + PyErr_Restore(etype, eval, etb); + } + (*Py_TYPE(o)->tp_free)(o); +} + +static PyMethodDef __pyx_methods_14softwrap_core2_Mesh[] = { + {"get_vert_normals", (PyCFunction)__pyx_pw_14softwrap_core2_4Mesh_1get_vert_normals, METH_NOARGS, 0}, + {"get_face_normals", (PyCFunction)__pyx_pw_14softwrap_core2_4Mesh_3get_face_normals, METH_NOARGS, 0}, + {"update_face_normals", (PyCFunction)__pyx_pw_14softwrap_core2_4Mesh_7update_face_normals, METH_NOARGS, 0}, + {"update_vert_normals", (PyCFunction)__pyx_pw_14softwrap_core2_4Mesh_9update_vert_normals, METH_NOARGS, 0}, + {"update_centroids", (PyCFunction)__pyx_pw_14softwrap_core2_4Mesh_11update_centroids, METH_NOARGS, 0}, + {"closest_vert", (PyCFunction)__pyx_pw_14softwrap_core2_4Mesh_13closest_vert, METH_O, 0}, + {"__reduce_cython__", (PyCFunction)__pyx_pw_14softwrap_core2_4Mesh_17__reduce_cython__, METH_NOARGS, 0}, + {"__setstate_cython__", (PyCFunction)__pyx_pw_14softwrap_core2_4Mesh_19__setstate_cython__, METH_O, 0}, + {0, 0, 0, 0} +}; + +static PyTypeObject __pyx_type_14softwrap_core2_Mesh = { + PyVarObject_HEAD_INIT(0, 0) + "softwrap_core2.Mesh", /*tp_name*/ + sizeof(struct __pyx_obj_14softwrap_core2_Mesh), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_14softwrap_core2_Mesh, /*tp_dealloc*/ + #if PY_VERSION_HEX < 0x030800b4 + 0, /*tp_print*/ + #endif + #if PY_VERSION_HEX >= 0x030800b4 + 0, /*tp_vectorcall_offset*/ + #endif + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #endif + #if PY_MAJOR_VERSION >= 3 + 0, /*tp_as_async*/ + #endif + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/ + 0, /*tp_doc*/ + 0, /*tp_traverse*/ + 0, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_14softwrap_core2_Mesh, /*tp_methods*/ + 0, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + __pyx_pw_14softwrap_core2_4Mesh_5__init__, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_14softwrap_core2_Mesh, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + 0, /*tp_version_tag*/ + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif + #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800) + 0, /*tp_vectorcall*/ + #endif + #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000 + 0, /*tp_print*/ + #endif + #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 + 0, /*tp_pypy_flags*/ + #endif +}; +static struct __pyx_vtabstruct_14softwrap_core2_BVH __pyx_vtable_14softwrap_core2_BVH; + +static PyObject *__pyx_tp_new_14softwrap_core2_BVH(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_obj_14softwrap_core2_BVH *p; + PyObject *o; + o = (*t->tp_alloc)(t, 0); + if (unlikely(!o)) return 0; + p = ((struct __pyx_obj_14softwrap_core2_BVH *)o); + p->__pyx_vtab = __pyx_vtabptr_14softwrap_core2_BVH; + p->mesh = ((struct __pyx_obj_14softwrap_core2_Mesh *)Py_None); Py_INCREF(Py_None); + if (unlikely(__pyx_pw_14softwrap_core2_3BVH_1__cinit__(o, a, k) < 0)) goto bad; + return o; + bad: + Py_DECREF(o); o = 0; + return NULL; +} + +static void __pyx_tp_dealloc_14softwrap_core2_BVH(PyObject *o) { + struct __pyx_obj_14softwrap_core2_BVH *p = (struct __pyx_obj_14softwrap_core2_BVH *)o; + PyObject_GC_UnTrack(o); + { + PyObject *etype, *eval, *etb; + PyErr_Fetch(&etype, &eval, &etb); + __Pyx_SET_REFCNT(o, Py_REFCNT(o) + 1); + __pyx_pw_14softwrap_core2_3BVH_3__dealloc__(o); + __Pyx_SET_REFCNT(o, Py_REFCNT(o) - 1); + PyErr_Restore(etype, eval, etb); + } + Py_CLEAR(p->mesh); + (*Py_TYPE(o)->tp_free)(o); +} + +static int __pyx_tp_traverse_14softwrap_core2_BVH(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_14softwrap_core2_BVH *p = (struct __pyx_obj_14softwrap_core2_BVH *)o; + if (p->mesh) { + e = (*v)(((PyObject *)p->mesh), a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_14softwrap_core2_BVH(PyObject *o) { + PyObject* tmp; + struct __pyx_obj_14softwrap_core2_BVH *p = (struct __pyx_obj_14softwrap_core2_BVH *)o; + tmp = ((PyObject*)p->mesh); + p->mesh = ((struct __pyx_obj_14softwrap_core2_Mesh *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} + +static PyMethodDef __pyx_methods_14softwrap_core2_BVH[] = { + {"find_nearest", (PyCFunction)__pyx_pw_14softwrap_core2_3BVH_5find_nearest, METH_O, 0}, + {"__reduce_cython__", (PyCFunction)__pyx_pw_14softwrap_core2_3BVH_7__reduce_cython__, METH_NOARGS, 0}, + {"__setstate_cython__", (PyCFunction)__pyx_pw_14softwrap_core2_3BVH_9__setstate_cython__, METH_O, 0}, + {0, 0, 0, 0} +}; + +static PyTypeObject __pyx_type_14softwrap_core2_BVH = { + PyVarObject_HEAD_INIT(0, 0) + "softwrap_core2.BVH", /*tp_name*/ + sizeof(struct __pyx_obj_14softwrap_core2_BVH), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_14softwrap_core2_BVH, /*tp_dealloc*/ + #if PY_VERSION_HEX < 0x030800b4 + 0, /*tp_print*/ + #endif + #if PY_VERSION_HEX >= 0x030800b4 + 0, /*tp_vectorcall_offset*/ + #endif + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #endif + #if PY_MAJOR_VERSION >= 3 + 0, /*tp_as_async*/ + #endif + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_14softwrap_core2_BVH, /*tp_traverse*/ + __pyx_tp_clear_14softwrap_core2_BVH, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_14softwrap_core2_BVH, /*tp_methods*/ + 0, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_14softwrap_core2_BVH, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + 0, /*tp_version_tag*/ + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif + #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800) + 0, /*tp_vectorcall*/ + #endif + #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000 + 0, /*tp_print*/ + #endif + #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 + 0, /*tp_pypy_flags*/ + #endif +}; + +static PyObject *__pyx_tp_new_14softwrap_core2_LinkProbe(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_obj_14softwrap_core2_LinkProbe *p; + PyObject *o; + o = (*t->tp_alloc)(t, 0); + if (unlikely(!o)) return 0; + p = ((struct __pyx_obj_14softwrap_core2_LinkProbe *)o); + p->springs = ((struct __pyx_obj_14softwrap_core2_SpringLinks *)Py_None); Py_INCREF(Py_None); + if (unlikely(__pyx_pw_14softwrap_core2_9LinkProbe_1__cinit__(o, a, k) < 0)) goto bad; + return o; + bad: + Py_DECREF(o); o = 0; + return NULL; +} + +static void __pyx_tp_dealloc_14softwrap_core2_LinkProbe(PyObject *o) { + struct __pyx_obj_14softwrap_core2_LinkProbe *p = (struct __pyx_obj_14softwrap_core2_LinkProbe *)o; + PyObject_GC_UnTrack(o); + Py_CLEAR(p->springs); + (*Py_TYPE(o)->tp_free)(o); +} + +static int __pyx_tp_traverse_14softwrap_core2_LinkProbe(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_14softwrap_core2_LinkProbe *p = (struct __pyx_obj_14softwrap_core2_LinkProbe *)o; + if (p->springs) { + e = (*v)(((PyObject *)p->springs), a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_14softwrap_core2_LinkProbe(PyObject *o) { + PyObject* tmp; + struct __pyx_obj_14softwrap_core2_LinkProbe *p = (struct __pyx_obj_14softwrap_core2_LinkProbe *)o; + tmp = ((PyObject*)p->springs); + p->springs = ((struct __pyx_obj_14softwrap_core2_SpringLinks *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} +static PyObject *__pyx_sq_item_14softwrap_core2_LinkProbe(PyObject *o, Py_ssize_t i) { + PyObject *r; + PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0; + r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x); + Py_DECREF(x); + return r; +} + +static PyObject *__pyx_getprop_14softwrap_core2_9LinkProbe_avg_radius(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_14softwrap_core2_9LinkProbe_10avg_radius_1__get__(o); +} + +static PyObject *__pyx_getprop_14softwrap_core2_9LinkProbe_springs(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_14softwrap_core2_9LinkProbe_7springs_1__get__(o); +} + +static PyObject *__pyx_getprop_14softwrap_core2_9LinkProbe_index(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_14softwrap_core2_9LinkProbe_5index_1__get__(o); +} + +static PyMethodDef __pyx_methods_14softwrap_core2_LinkProbe[] = { + {"__reduce_cython__", (PyCFunction)__pyx_pw_14softwrap_core2_9LinkProbe_10__reduce_cython__, METH_NOARGS, 0}, + {"__setstate_cython__", (PyCFunction)__pyx_pw_14softwrap_core2_9LinkProbe_12__setstate_cython__, METH_O, 0}, + {0, 0, 0, 0} +}; + +static struct PyGetSetDef __pyx_getsets_14softwrap_core2_LinkProbe[] = { + {(char *)"avg_radius", __pyx_getprop_14softwrap_core2_9LinkProbe_avg_radius, 0, (char *)0, 0}, + {(char *)"springs", __pyx_getprop_14softwrap_core2_9LinkProbe_springs, 0, (char *)0, 0}, + {(char *)"index", __pyx_getprop_14softwrap_core2_9LinkProbe_index, 0, (char *)0, 0}, + {0, 0, 0, 0, 0} +}; + +static PySequenceMethods __pyx_tp_as_sequence_LinkProbe = { + __pyx_pw_14softwrap_core2_9LinkProbe_5__len__, /*sq_length*/ + 0, /*sq_concat*/ + 0, /*sq_repeat*/ + __pyx_sq_item_14softwrap_core2_LinkProbe, /*sq_item*/ + 0, /*sq_slice*/ + 0, /*sq_ass_item*/ + 0, /*sq_ass_slice*/ + 0, /*sq_contains*/ + 0, /*sq_inplace_concat*/ + 0, /*sq_inplace_repeat*/ +}; + +static PyMappingMethods __pyx_tp_as_mapping_LinkProbe = { + __pyx_pw_14softwrap_core2_9LinkProbe_5__len__, /*mp_length*/ + __pyx_pw_14softwrap_core2_9LinkProbe_3__getitem__, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyTypeObject __pyx_type_14softwrap_core2_LinkProbe = { + PyVarObject_HEAD_INIT(0, 0) + "softwrap_core2.LinkProbe", /*tp_name*/ + sizeof(struct __pyx_obj_14softwrap_core2_LinkProbe), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_14softwrap_core2_LinkProbe, /*tp_dealloc*/ + #if PY_VERSION_HEX < 0x030800b4 + 0, /*tp_print*/ + #endif + #if PY_VERSION_HEX >= 0x030800b4 + 0, /*tp_vectorcall_offset*/ + #endif + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #endif + #if PY_MAJOR_VERSION >= 3 + 0, /*tp_as_async*/ + #endif + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + &__pyx_tp_as_sequence_LinkProbe, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_LinkProbe, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_14softwrap_core2_LinkProbe, /*tp_traverse*/ + __pyx_tp_clear_14softwrap_core2_LinkProbe, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + __pyx_pw_14softwrap_core2_9LinkProbe_7__iter__, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_14softwrap_core2_LinkProbe, /*tp_methods*/ + 0, /*tp_members*/ + __pyx_getsets_14softwrap_core2_LinkProbe, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_14softwrap_core2_LinkProbe, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + 0, /*tp_version_tag*/ + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif + #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800) + 0, /*tp_vectorcall*/ + #endif + #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000 + 0, /*tp_print*/ + #endif + #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 + 0, /*tp_pypy_flags*/ + #endif +}; +static struct __pyx_vtabstruct_14softwrap_core2_SpringLinks __pyx_vtable_14softwrap_core2_SpringLinks; + +static PyObject *__pyx_tp_new_14softwrap_core2_SpringLinks(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_obj_14softwrap_core2_SpringLinks *p; + PyObject *o; + if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) { + o = (*t->tp_alloc)(t, 0); + } else { + o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0); + } + if (unlikely(!o)) return 0; + p = ((struct __pyx_obj_14softwrap_core2_SpringLinks *)o); + p->__pyx_vtab = __pyx_vtabptr_14softwrap_core2_SpringLinks; + p->engine = ((struct __pyx_obj_14softwrap_core2_SpringEngine *)Py_None); Py_INCREF(Py_None); + if (unlikely(__pyx_pw_14softwrap_core2_11SpringLinks_1__cinit__(o, a, k) < 0)) goto bad; + return o; + bad: + Py_DECREF(o); o = 0; + return NULL; +} + +static void __pyx_tp_dealloc_14softwrap_core2_SpringLinks(PyObject *o) { + struct __pyx_obj_14softwrap_core2_SpringLinks *p = (struct __pyx_obj_14softwrap_core2_SpringLinks *)o; + #if CYTHON_USE_TP_FINALIZE + if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { + if (PyObject_CallFinalizerFromDealloc(o)) return; + } + #endif + PyObject_GC_UnTrack(o); + { + PyObject *etype, *eval, *etb; + PyErr_Fetch(&etype, &eval, &etb); + __Pyx_SET_REFCNT(o, Py_REFCNT(o) + 1); + __pyx_pw_14softwrap_core2_11SpringLinks_3__dealloc__(o); + __Pyx_SET_REFCNT(o, Py_REFCNT(o) - 1); + PyErr_Restore(etype, eval, etb); + } + Py_CLEAR(p->engine); + (*Py_TYPE(o)->tp_free)(o); +} + +static int __pyx_tp_traverse_14softwrap_core2_SpringLinks(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_14softwrap_core2_SpringLinks *p = (struct __pyx_obj_14softwrap_core2_SpringLinks *)o; + if (p->engine) { + e = (*v)(((PyObject *)p->engine), a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_14softwrap_core2_SpringLinks(PyObject *o) { + PyObject* tmp; + struct __pyx_obj_14softwrap_core2_SpringLinks *p = (struct __pyx_obj_14softwrap_core2_SpringLinks *)o; + tmp = ((PyObject*)p->engine); + p->engine = ((struct __pyx_obj_14softwrap_core2_SpringEngine *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} +static PyObject *__pyx_sq_item_14softwrap_core2_SpringLinks(PyObject *o, Py_ssize_t i) { + PyObject *r; + PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0; + r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x); + Py_DECREF(x); + return r; +} + +static PyObject *__pyx_getprop_14softwrap_core2_11SpringLinks_engine(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_14softwrap_core2_11SpringLinks_6engine_1__get__(o); +} + +static PyMethodDef __pyx_methods_14softwrap_core2_SpringLinks[] = { + {"lengths_update", (PyCFunction)__pyx_pw_14softwrap_core2_11SpringLinks_7lengths_update, METH_NOARGS, 0}, + {"smooth", (PyCFunction)__pyx_pw_14softwrap_core2_11SpringLinks_9smooth, METH_O, 0}, + {"soft_spring_force", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_14softwrap_core2_11SpringLinks_11soft_spring_force, METH_VARARGS|METH_KEYWORDS, 0}, + {"stiff_spring_force", (PyCFunction)__pyx_pw_14softwrap_core2_11SpringLinks_13stiff_spring_force, METH_O, 0}, + {"__reduce_cython__", (PyCFunction)__pyx_pw_14softwrap_core2_11SpringLinks_15__reduce_cython__, METH_NOARGS, 0}, + {"__setstate_cython__", (PyCFunction)__pyx_pw_14softwrap_core2_11SpringLinks_17__setstate_cython__, METH_O, 0}, + {0, 0, 0, 0} +}; + +static struct PyGetSetDef __pyx_getsets_14softwrap_core2_SpringLinks[] = { + {(char *)"engine", __pyx_getprop_14softwrap_core2_11SpringLinks_engine, 0, (char *)0, 0}, + {0, 0, 0, 0, 0} +}; + +static PySequenceMethods __pyx_tp_as_sequence_SpringLinks = { + 0, /*sq_length*/ + 0, /*sq_concat*/ + 0, /*sq_repeat*/ + __pyx_sq_item_14softwrap_core2_SpringLinks, /*sq_item*/ + 0, /*sq_slice*/ + 0, /*sq_ass_item*/ + 0, /*sq_ass_slice*/ + 0, /*sq_contains*/ + 0, /*sq_inplace_concat*/ + 0, /*sq_inplace_repeat*/ +}; + +static PyMappingMethods __pyx_tp_as_mapping_SpringLinks = { + 0, /*mp_length*/ + __pyx_pw_14softwrap_core2_11SpringLinks_5__getitem__, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyTypeObject __pyx_type_14softwrap_core2_SpringLinks = { + PyVarObject_HEAD_INIT(0, 0) + "softwrap_core2.SpringLinks", /*tp_name*/ + sizeof(struct __pyx_obj_14softwrap_core2_SpringLinks), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_14softwrap_core2_SpringLinks, /*tp_dealloc*/ + #if PY_VERSION_HEX < 0x030800b4 + 0, /*tp_print*/ + #endif + #if PY_VERSION_HEX >= 0x030800b4 + 0, /*tp_vectorcall_offset*/ + #endif + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #endif + #if PY_MAJOR_VERSION >= 3 + 0, /*tp_as_async*/ + #endif + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + &__pyx_tp_as_sequence_SpringLinks, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_SpringLinks, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_14softwrap_core2_SpringLinks, /*tp_traverse*/ + __pyx_tp_clear_14softwrap_core2_SpringLinks, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_14softwrap_core2_SpringLinks, /*tp_methods*/ + 0, /*tp_members*/ + __pyx_getsets_14softwrap_core2_SpringLinks, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_14softwrap_core2_SpringLinks, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + 0, /*tp_version_tag*/ + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif + #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800) + 0, /*tp_vectorcall*/ + #endif + #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000 + 0, /*tp_print*/ + #endif + #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 + 0, /*tp_pypy_flags*/ + #endif +}; +static struct __pyx_vtabstruct_14softwrap_core2_TernarySmoothingLinks __pyx_vtable_14softwrap_core2_TernarySmoothingLinks; + +static PyObject *__pyx_tp_new_14softwrap_core2_TernarySmoothingLinks(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_obj_14softwrap_core2_TernarySmoothingLinks *p; + PyObject *o; + o = (*t->tp_alloc)(t, 0); + if (unlikely(!o)) return 0; + p = ((struct __pyx_obj_14softwrap_core2_TernarySmoothingLinks *)o); + p->__pyx_vtab = __pyx_vtabptr_14softwrap_core2_TernarySmoothingLinks; + p->engine = ((struct __pyx_obj_14softwrap_core2_SpringEngine *)Py_None); Py_INCREF(Py_None); + if (unlikely(__pyx_pw_14softwrap_core2_21TernarySmoothingLinks_1__cinit__(o, a, k) < 0)) goto bad; + return o; + bad: + Py_DECREF(o); o = 0; + return NULL; +} + +static void __pyx_tp_dealloc_14softwrap_core2_TernarySmoothingLinks(PyObject *o) { + struct __pyx_obj_14softwrap_core2_TernarySmoothingLinks *p = (struct __pyx_obj_14softwrap_core2_TernarySmoothingLinks *)o; + PyObject_GC_UnTrack(o); + { + PyObject *etype, *eval, *etb; + PyErr_Fetch(&etype, &eval, &etb); + __Pyx_SET_REFCNT(o, Py_REFCNT(o) + 1); + __pyx_pw_14softwrap_core2_21TernarySmoothingLinks_3__dealloc__(o); + __Pyx_SET_REFCNT(o, Py_REFCNT(o) - 1); + PyErr_Restore(etype, eval, etb); + } + Py_CLEAR(p->engine); + (*Py_TYPE(o)->tp_free)(o); +} + +static int __pyx_tp_traverse_14softwrap_core2_TernarySmoothingLinks(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_14softwrap_core2_TernarySmoothingLinks *p = (struct __pyx_obj_14softwrap_core2_TernarySmoothingLinks *)o; + if (p->engine) { + e = (*v)(((PyObject *)p->engine), a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_14softwrap_core2_TernarySmoothingLinks(PyObject *o) { + PyObject* tmp; + struct __pyx_obj_14softwrap_core2_TernarySmoothingLinks *p = (struct __pyx_obj_14softwrap_core2_TernarySmoothingLinks *)o; + tmp = ((PyObject*)p->engine); + p->engine = ((struct __pyx_obj_14softwrap_core2_SpringEngine *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} + +static PyObject *__pyx_getprop_14softwrap_core2_21TernarySmoothingLinks_engine(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_14softwrap_core2_21TernarySmoothingLinks_6engine_1__get__(o); +} + +static PyMethodDef __pyx_methods_14softwrap_core2_TernarySmoothingLinks[] = { + {"displacements_update", (PyCFunction)__pyx_pw_14softwrap_core2_21TernarySmoothingLinks_5displacements_update, METH_NOARGS, 0}, + {"displacement_force", (PyCFunction)__pyx_pw_14softwrap_core2_21TernarySmoothingLinks_7displacement_force, METH_O, 0}, + {"__reduce_cython__", (PyCFunction)__pyx_pw_14softwrap_core2_21TernarySmoothingLinks_9__reduce_cython__, METH_NOARGS, 0}, + {"__setstate_cython__", (PyCFunction)__pyx_pw_14softwrap_core2_21TernarySmoothingLinks_11__setstate_cython__, METH_O, 0}, + {0, 0, 0, 0} +}; + +static struct PyGetSetDef __pyx_getsets_14softwrap_core2_TernarySmoothingLinks[] = { + {(char *)"engine", __pyx_getprop_14softwrap_core2_21TernarySmoothingLinks_engine, 0, (char *)0, 0}, + {0, 0, 0, 0, 0} +}; + +static PyTypeObject __pyx_type_14softwrap_core2_TernarySmoothingLinks = { + PyVarObject_HEAD_INIT(0, 0) + "softwrap_core2.TernarySmoothingLinks", /*tp_name*/ + sizeof(struct __pyx_obj_14softwrap_core2_TernarySmoothingLinks), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_14softwrap_core2_TernarySmoothingLinks, /*tp_dealloc*/ + #if PY_VERSION_HEX < 0x030800b4 + 0, /*tp_print*/ + #endif + #if PY_VERSION_HEX >= 0x030800b4 + 0, /*tp_vectorcall_offset*/ + #endif + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #endif + #if PY_MAJOR_VERSION >= 3 + 0, /*tp_as_async*/ + #endif + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_14softwrap_core2_TernarySmoothingLinks, /*tp_traverse*/ + __pyx_tp_clear_14softwrap_core2_TernarySmoothingLinks, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_14softwrap_core2_TernarySmoothingLinks, /*tp_methods*/ + 0, /*tp_members*/ + __pyx_getsets_14softwrap_core2_TernarySmoothingLinks, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_14softwrap_core2_TernarySmoothingLinks, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + 0, /*tp_version_tag*/ + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif + #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800) + 0, /*tp_vectorcall*/ + #endif + #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000 + 0, /*tp_print*/ + #endif + #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 + 0, /*tp_pypy_flags*/ + #endif +}; +static struct __pyx_vtabstruct_14softwrap_core2_QuaternarySmoothingLinks __pyx_vtable_14softwrap_core2_QuaternarySmoothingLinks; + +static PyObject *__pyx_tp_new_14softwrap_core2_QuaternarySmoothingLinks(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_obj_14softwrap_core2_QuaternarySmoothingLinks *p; + PyObject *o; + if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) { + o = (*t->tp_alloc)(t, 0); + } else { + o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0); + } + if (unlikely(!o)) return 0; + p = ((struct __pyx_obj_14softwrap_core2_QuaternarySmoothingLinks *)o); + p->__pyx_vtab = __pyx_vtabptr_14softwrap_core2_QuaternarySmoothingLinks; + p->engine = ((struct __pyx_obj_14softwrap_core2_SpringEngine *)Py_None); Py_INCREF(Py_None); + if (unlikely(__pyx_pw_14softwrap_core2_24QuaternarySmoothingLinks_1__cinit__(o, a, k) < 0)) goto bad; + return o; + bad: + Py_DECREF(o); o = 0; + return NULL; +} + +static void __pyx_tp_dealloc_14softwrap_core2_QuaternarySmoothingLinks(PyObject *o) { + struct __pyx_obj_14softwrap_core2_QuaternarySmoothingLinks *p = (struct __pyx_obj_14softwrap_core2_QuaternarySmoothingLinks *)o; + #if CYTHON_USE_TP_FINALIZE + if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { + if (PyObject_CallFinalizerFromDealloc(o)) return; + } + #endif + PyObject_GC_UnTrack(o); + { + PyObject *etype, *eval, *etb; + PyErr_Fetch(&etype, &eval, &etb); + __Pyx_SET_REFCNT(o, Py_REFCNT(o) + 1); + __pyx_pw_14softwrap_core2_24QuaternarySmoothingLinks_3__dealloc__(o); + __Pyx_SET_REFCNT(o, Py_REFCNT(o) - 1); + PyErr_Restore(etype, eval, etb); + } + Py_CLEAR(p->engine); + (*Py_TYPE(o)->tp_free)(o); +} + +static int __pyx_tp_traverse_14softwrap_core2_QuaternarySmoothingLinks(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_14softwrap_core2_QuaternarySmoothingLinks *p = (struct __pyx_obj_14softwrap_core2_QuaternarySmoothingLinks *)o; + if (p->engine) { + e = (*v)(((PyObject *)p->engine), a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_14softwrap_core2_QuaternarySmoothingLinks(PyObject *o) { + PyObject* tmp; + struct __pyx_obj_14softwrap_core2_QuaternarySmoothingLinks *p = (struct __pyx_obj_14softwrap_core2_QuaternarySmoothingLinks *)o; + tmp = ((PyObject*)p->engine); + p->engine = ((struct __pyx_obj_14softwrap_core2_SpringEngine *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} + +static PyObject *__pyx_getprop_14softwrap_core2_24QuaternarySmoothingLinks_engine(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_14softwrap_core2_24QuaternarySmoothingLinks_6engine_1__get__(o); +} + +static PyObject *__pyx_getprop_14softwrap_core2_24QuaternarySmoothingLinks_n_links(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_14softwrap_core2_24QuaternarySmoothingLinks_7n_links_1__get__(o); +} + +static PyMethodDef __pyx_methods_14softwrap_core2_QuaternarySmoothingLinks[] = { + {"lengths_update", (PyCFunction)__pyx_pw_14softwrap_core2_24QuaternarySmoothingLinks_5lengths_update, METH_NOARGS, 0}, + {"smooth", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_14softwrap_core2_24QuaternarySmoothingLinks_7smooth, METH_VARARGS|METH_KEYWORDS, 0}, + {"__reduce_cython__", (PyCFunction)__pyx_pw_14softwrap_core2_24QuaternarySmoothingLinks_9__reduce_cython__, METH_NOARGS, 0}, + {"__setstate_cython__", (PyCFunction)__pyx_pw_14softwrap_core2_24QuaternarySmoothingLinks_11__setstate_cython__, METH_O, 0}, + {0, 0, 0, 0} +}; + +static struct PyGetSetDef __pyx_getsets_14softwrap_core2_QuaternarySmoothingLinks[] = { + {(char *)"engine", __pyx_getprop_14softwrap_core2_24QuaternarySmoothingLinks_engine, 0, (char *)0, 0}, + {(char *)"n_links", __pyx_getprop_14softwrap_core2_24QuaternarySmoothingLinks_n_links, 0, (char *)0, 0}, + {0, 0, 0, 0, 0} +}; + +static PyTypeObject __pyx_type_14softwrap_core2_QuaternarySmoothingLinks = { + PyVarObject_HEAD_INIT(0, 0) + "softwrap_core2.QuaternarySmoothingLinks", /*tp_name*/ + sizeof(struct __pyx_obj_14softwrap_core2_QuaternarySmoothingLinks), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_14softwrap_core2_QuaternarySmoothingLinks, /*tp_dealloc*/ + #if PY_VERSION_HEX < 0x030800b4 + 0, /*tp_print*/ + #endif + #if PY_VERSION_HEX >= 0x030800b4 + 0, /*tp_vectorcall_offset*/ + #endif + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #endif + #if PY_MAJOR_VERSION >= 3 + 0, /*tp_as_async*/ + #endif + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_14softwrap_core2_QuaternarySmoothingLinks, /*tp_traverse*/ + __pyx_tp_clear_14softwrap_core2_QuaternarySmoothingLinks, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_14softwrap_core2_QuaternarySmoothingLinks, /*tp_methods*/ + 0, /*tp_members*/ + __pyx_getsets_14softwrap_core2_QuaternarySmoothingLinks, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_14softwrap_core2_QuaternarySmoothingLinks, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + 0, /*tp_version_tag*/ + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif + #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800) + 0, /*tp_vectorcall*/ + #endif + #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000 + 0, /*tp_print*/ + #endif + #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 + 0, /*tp_pypy_flags*/ + #endif +}; + +static PyObject *__pyx_tp_new_14softwrap_core2_SpringEnginePin(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_obj_14softwrap_core2_SpringEnginePin *p; + PyObject *o; + o = (*t->tp_alloc)(t, 0); + if (unlikely(!o)) return 0; + p = ((struct __pyx_obj_14softwrap_core2_SpringEnginePin *)o); + p->engine = ((struct __pyx_obj_14softwrap_core2_SpringEngine *)Py_None); Py_INCREF(Py_None); + if (unlikely(__pyx_pw_14softwrap_core2_15SpringEnginePin_1__cinit__(o, a, k) < 0)) goto bad; + return o; + bad: + Py_DECREF(o); o = 0; + return NULL; +} + +static void __pyx_tp_dealloc_14softwrap_core2_SpringEnginePin(PyObject *o) { + struct __pyx_obj_14softwrap_core2_SpringEnginePin *p = (struct __pyx_obj_14softwrap_core2_SpringEnginePin *)o; + PyObject_GC_UnTrack(o); + { + PyObject *etype, *eval, *etb; + PyErr_Fetch(&etype, &eval, &etb); + __Pyx_SET_REFCNT(o, Py_REFCNT(o) + 1); + __pyx_pw_14softwrap_core2_15SpringEnginePin_10__dealloc__(o); + __Pyx_SET_REFCNT(o, Py_REFCNT(o) - 1); + PyErr_Restore(etype, eval, etb); + } + Py_CLEAR(p->engine); + (*Py_TYPE(o)->tp_free)(o); +} + +static int __pyx_tp_traverse_14softwrap_core2_SpringEnginePin(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_14softwrap_core2_SpringEnginePin *p = (struct __pyx_obj_14softwrap_core2_SpringEnginePin *)o; + if (p->engine) { + e = (*v)(((PyObject *)p->engine), a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_14softwrap_core2_SpringEnginePin(PyObject *o) { + PyObject* tmp; + struct __pyx_obj_14softwrap_core2_SpringEnginePin *p = (struct __pyx_obj_14softwrap_core2_SpringEnginePin *)o; + tmp = ((PyObject*)p->engine); + p->engine = ((struct __pyx_obj_14softwrap_core2_SpringEngine *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} +static PyObject *__pyx_sq_item_14softwrap_core2_SpringEnginePin(PyObject *o, Py_ssize_t i) { + PyObject *r; + PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0; + r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x); + Py_DECREF(x); + return r; +} + +static PyObject *__pyx_getprop_14softwrap_core2_15SpringEnginePin_engine(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_14softwrap_core2_15SpringEnginePin_6engine_1__get__(o); +} + +static PyObject *__pyx_getprop_14softwrap_core2_15SpringEnginePin_n_rings(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_14softwrap_core2_15SpringEnginePin_7n_rings_1__get__(o); +} + +static PyObject *__pyx_getprop_14softwrap_core2_15SpringEnginePin_start_index(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_14softwrap_core2_15SpringEnginePin_11start_index_1__get__(o); +} + +static PyMethodDef __pyx_methods_14softwrap_core2_SpringEnginePin[] = { + {"move", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_14softwrap_core2_15SpringEnginePin_8move, METH_VARARGS|METH_KEYWORDS, 0}, + {"__reduce_cython__", (PyCFunction)__pyx_pw_14softwrap_core2_15SpringEnginePin_12__reduce_cython__, METH_NOARGS, 0}, + {"__setstate_cython__", (PyCFunction)__pyx_pw_14softwrap_core2_15SpringEnginePin_14__setstate_cython__, METH_O, 0}, + {0, 0, 0, 0} +}; + +static struct PyGetSetDef __pyx_getsets_14softwrap_core2_SpringEnginePin[] = { + {(char *)"engine", __pyx_getprop_14softwrap_core2_15SpringEnginePin_engine, 0, (char *)0, 0}, + {(char *)"n_rings", __pyx_getprop_14softwrap_core2_15SpringEnginePin_n_rings, 0, (char *)0, 0}, + {(char *)"start_index", __pyx_getprop_14softwrap_core2_15SpringEnginePin_start_index, 0, (char *)0, 0}, + {0, 0, 0, 0, 0} +}; + +static PySequenceMethods __pyx_tp_as_sequence_SpringEnginePin = { + 0, /*sq_length*/ + 0, /*sq_concat*/ + 0, /*sq_repeat*/ + __pyx_sq_item_14softwrap_core2_SpringEnginePin, /*sq_item*/ + 0, /*sq_slice*/ + 0, /*sq_ass_item*/ + 0, /*sq_ass_slice*/ + 0, /*sq_contains*/ + 0, /*sq_inplace_concat*/ + 0, /*sq_inplace_repeat*/ +}; + +static PyMappingMethods __pyx_tp_as_mapping_SpringEnginePin = { + 0, /*mp_length*/ + __pyx_pw_14softwrap_core2_15SpringEnginePin_3__getitem__, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyTypeObject __pyx_type_14softwrap_core2_SpringEnginePin = { + PyVarObject_HEAD_INIT(0, 0) + "softwrap_core2.SpringEnginePin", /*tp_name*/ + sizeof(struct __pyx_obj_14softwrap_core2_SpringEnginePin), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_14softwrap_core2_SpringEnginePin, /*tp_dealloc*/ + #if PY_VERSION_HEX < 0x030800b4 + 0, /*tp_print*/ + #endif + #if PY_VERSION_HEX >= 0x030800b4 + 0, /*tp_vectorcall_offset*/ + #endif + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #endif + #if PY_MAJOR_VERSION >= 3 + 0, /*tp_as_async*/ + #endif + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + &__pyx_tp_as_sequence_SpringEnginePin, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_SpringEnginePin, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_14softwrap_core2_SpringEnginePin, /*tp_traverse*/ + __pyx_tp_clear_14softwrap_core2_SpringEnginePin, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + __pyx_pw_14softwrap_core2_15SpringEnginePin_5__iter__, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_14softwrap_core2_SpringEnginePin, /*tp_methods*/ + 0, /*tp_members*/ + __pyx_getsets_14softwrap_core2_SpringEnginePin, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_14softwrap_core2_SpringEnginePin, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + 0, /*tp_version_tag*/ + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif + #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800) + 0, /*tp_vectorcall*/ + #endif + #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000 + 0, /*tp_print*/ + #endif + #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 + 0, /*tp_pypy_flags*/ + #endif +}; + +static PyObject *__pyx_tp_new_14softwrap_core2__MaskContextManager(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_obj_14softwrap_core2__MaskContextManager *p; + PyObject *o; + if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) { + o = (*t->tp_alloc)(t, 0); + } else { + o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0); + } + if (unlikely(!o)) return 0; + p = ((struct __pyx_obj_14softwrap_core2__MaskContextManager *)o); + p->mask = ((struct __pyx_obj_14softwrap_core2_SpringEngineMask *)Py_None); Py_INCREF(Py_None); + if (unlikely(__pyx_pw_14softwrap_core2_19_MaskContextManager_1__cinit__(o, a, k) < 0)) goto bad; + return o; + bad: + Py_DECREF(o); o = 0; + return NULL; +} + +static void __pyx_tp_dealloc_14softwrap_core2__MaskContextManager(PyObject *o) { + struct __pyx_obj_14softwrap_core2__MaskContextManager *p = (struct __pyx_obj_14softwrap_core2__MaskContextManager *)o; + #if CYTHON_USE_TP_FINALIZE + if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { + if (PyObject_CallFinalizerFromDealloc(o)) return; + } + #endif + PyObject_GC_UnTrack(o); + Py_CLEAR(p->mask); + (*Py_TYPE(o)->tp_free)(o); +} + +static int __pyx_tp_traverse_14softwrap_core2__MaskContextManager(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_14softwrap_core2__MaskContextManager *p = (struct __pyx_obj_14softwrap_core2__MaskContextManager *)o; + if (p->mask) { + e = (*v)(((PyObject *)p->mask), a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_14softwrap_core2__MaskContextManager(PyObject *o) { + PyObject* tmp; + struct __pyx_obj_14softwrap_core2__MaskContextManager *p = (struct __pyx_obj_14softwrap_core2__MaskContextManager *)o; + tmp = ((PyObject*)p->mask); + p->mask = ((struct __pyx_obj_14softwrap_core2_SpringEngineMask *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} + +static PyMethodDef __pyx_methods_14softwrap_core2__MaskContextManager[] = { + {"__enter__", (PyCFunction)__pyx_pw_14softwrap_core2_19_MaskContextManager_3__enter__, METH_NOARGS, 0}, + {"__exit__", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_14softwrap_core2_19_MaskContextManager_5__exit__, METH_VARARGS|METH_KEYWORDS, 0}, + {"__reduce_cython__", (PyCFunction)__pyx_pw_14softwrap_core2_19_MaskContextManager_7__reduce_cython__, METH_NOARGS, 0}, + {"__setstate_cython__", (PyCFunction)__pyx_pw_14softwrap_core2_19_MaskContextManager_9__setstate_cython__, METH_O, 0}, + {0, 0, 0, 0} +}; + +static PyTypeObject __pyx_type_14softwrap_core2__MaskContextManager = { + PyVarObject_HEAD_INIT(0, 0) + "softwrap_core2._MaskContextManager", /*tp_name*/ + sizeof(struct __pyx_obj_14softwrap_core2__MaskContextManager), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_14softwrap_core2__MaskContextManager, /*tp_dealloc*/ + #if PY_VERSION_HEX < 0x030800b4 + 0, /*tp_print*/ + #endif + #if PY_VERSION_HEX >= 0x030800b4 + 0, /*tp_vectorcall_offset*/ + #endif + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #endif + #if PY_MAJOR_VERSION >= 3 + 0, /*tp_as_async*/ + #endif + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_14softwrap_core2__MaskContextManager, /*tp_traverse*/ + __pyx_tp_clear_14softwrap_core2__MaskContextManager, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_14softwrap_core2__MaskContextManager, /*tp_methods*/ + 0, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_14softwrap_core2__MaskContextManager, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + 0, /*tp_version_tag*/ + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif + #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800) + 0, /*tp_vectorcall*/ + #endif + #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000 + 0, /*tp_print*/ + #endif + #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 + 0, /*tp_pypy_flags*/ + #endif +}; +static struct __pyx_vtabstruct_14softwrap_core2_SpringEngineMask __pyx_vtable_14softwrap_core2_SpringEngineMask; + +static PyObject *__pyx_tp_new_14softwrap_core2_SpringEngineMask(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_obj_14softwrap_core2_SpringEngineMask *p; + PyObject *o; + if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) { + o = (*t->tp_alloc)(t, 0); + } else { + o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0); + } + if (unlikely(!o)) return 0; + p = ((struct __pyx_obj_14softwrap_core2_SpringEngineMask *)o); + p->__pyx_vtab = __pyx_vtabptr_14softwrap_core2_SpringEngineMask; + p->engine = ((struct __pyx_obj_14softwrap_core2_SpringEngine *)Py_None); Py_INCREF(Py_None); + if (unlikely(__pyx_pw_14softwrap_core2_16SpringEngineMask_1__cinit__(o, a, k) < 0)) goto bad; + return o; + bad: + Py_DECREF(o); o = 0; + return NULL; +} + +static void __pyx_tp_dealloc_14softwrap_core2_SpringEngineMask(PyObject *o) { + struct __pyx_obj_14softwrap_core2_SpringEngineMask *p = (struct __pyx_obj_14softwrap_core2_SpringEngineMask *)o; + #if CYTHON_USE_TP_FINALIZE + if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { + if (PyObject_CallFinalizerFromDealloc(o)) return; + } + #endif + PyObject_GC_UnTrack(o); + { + PyObject *etype, *eval, *etb; + PyErr_Fetch(&etype, &eval, &etb); + __Pyx_SET_REFCNT(o, Py_REFCNT(o) + 1); + __pyx_pw_14softwrap_core2_16SpringEngineMask_19__dealloc__(o); + __Pyx_SET_REFCNT(o, Py_REFCNT(o) - 1); + PyErr_Restore(etype, eval, etb); + } + Py_CLEAR(p->engine); + (*Py_TYPE(o)->tp_free)(o); +} + +static int __pyx_tp_traverse_14softwrap_core2_SpringEngineMask(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_14softwrap_core2_SpringEngineMask *p = (struct __pyx_obj_14softwrap_core2_SpringEngineMask *)o; + if (p->engine) { + e = (*v)(((PyObject *)p->engine), a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_14softwrap_core2_SpringEngineMask(PyObject *o) { + PyObject* tmp; + struct __pyx_obj_14softwrap_core2_SpringEngineMask *p = (struct __pyx_obj_14softwrap_core2_SpringEngineMask *)o; + tmp = ((PyObject*)p->engine); + p->engine = ((struct __pyx_obj_14softwrap_core2_SpringEngine *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} +static PyObject *__pyx_sq_item_14softwrap_core2_SpringEngineMask(PyObject *o, Py_ssize_t i) { + PyObject *r; + PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0; + r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x); + Py_DECREF(x); + return r; +} + +static int __pyx_mp_ass_subscript_14softwrap_core2_SpringEngineMask(PyObject *o, PyObject *i, PyObject *v) { + if (v) { + return __pyx_pw_14softwrap_core2_16SpringEngineMask_5__setitem__(o, i, v); + } + else { + PyErr_Format(PyExc_NotImplementedError, + "Subscript deletion not supported by %.200s", Py_TYPE(o)->tp_name); + return -1; + } +} + +static PyMethodDef __pyx_methods_14softwrap_core2_SpringEngineMask[] = { + {"set_force", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_14softwrap_core2_16SpringEngineMask_7set_force, METH_VARARGS|METH_KEYWORDS, 0}, + {"load", (PyCFunction)__pyx_pw_14softwrap_core2_16SpringEngineMask_9load, METH_NOARGS, 0}, + {"store", (PyCFunction)__pyx_pw_14softwrap_core2_16SpringEngineMask_11store, METH_NOARGS, 0}, + {"masked_store", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_14softwrap_core2_16SpringEngineMask_13masked_store, METH_VARARGS|METH_KEYWORDS, 0}, + {"set", (PyCFunction)__pyx_pw_14softwrap_core2_16SpringEngineMask_15set, METH_O, 0}, + {"masked_context", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_14softwrap_core2_16SpringEngineMask_17masked_context, METH_VARARGS|METH_KEYWORDS, 0}, + {"__reduce_cython__", (PyCFunction)__pyx_pw_14softwrap_core2_16SpringEngineMask_21__reduce_cython__, METH_NOARGS, 0}, + {"__setstate_cython__", (PyCFunction)__pyx_pw_14softwrap_core2_16SpringEngineMask_23__setstate_cython__, METH_O, 0}, + {0, 0, 0, 0} +}; + +static PySequenceMethods __pyx_tp_as_sequence_SpringEngineMask = { + 0, /*sq_length*/ + 0, /*sq_concat*/ + 0, /*sq_repeat*/ + __pyx_sq_item_14softwrap_core2_SpringEngineMask, /*sq_item*/ + 0, /*sq_slice*/ + 0, /*sq_ass_item*/ + 0, /*sq_ass_slice*/ + 0, /*sq_contains*/ + 0, /*sq_inplace_concat*/ + 0, /*sq_inplace_repeat*/ +}; + +static PyMappingMethods __pyx_tp_as_mapping_SpringEngineMask = { + 0, /*mp_length*/ + __pyx_pw_14softwrap_core2_16SpringEngineMask_3__getitem__, /*mp_subscript*/ + __pyx_mp_ass_subscript_14softwrap_core2_SpringEngineMask, /*mp_ass_subscript*/ +}; + +static PyTypeObject __pyx_type_14softwrap_core2_SpringEngineMask = { + PyVarObject_HEAD_INIT(0, 0) + "softwrap_core2.SpringEngineMask", /*tp_name*/ + sizeof(struct __pyx_obj_14softwrap_core2_SpringEngineMask), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_14softwrap_core2_SpringEngineMask, /*tp_dealloc*/ + #if PY_VERSION_HEX < 0x030800b4 + 0, /*tp_print*/ + #endif + #if PY_VERSION_HEX >= 0x030800b4 + 0, /*tp_vectorcall_offset*/ + #endif + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #endif + #if PY_MAJOR_VERSION >= 3 + 0, /*tp_as_async*/ + #endif + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + &__pyx_tp_as_sequence_SpringEngineMask, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_SpringEngineMask, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_14softwrap_core2_SpringEngineMask, /*tp_traverse*/ + __pyx_tp_clear_14softwrap_core2_SpringEngineMask, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_14softwrap_core2_SpringEngineMask, /*tp_methods*/ + 0, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_14softwrap_core2_SpringEngineMask, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + 0, /*tp_version_tag*/ + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif + #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800) + 0, /*tp_vectorcall*/ + #endif + #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000 + 0, /*tp_print*/ + #endif + #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 + 0, /*tp_pypy_flags*/ + #endif +}; +static struct __pyx_vtabstruct_14softwrap_core2_SymmetryMap __pyx_vtable_14softwrap_core2_SymmetryMap; + +static PyObject *__pyx_tp_new_14softwrap_core2_SymmetryMap(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_obj_14softwrap_core2_SymmetryMap *p; + PyObject *o; + o = (*t->tp_alloc)(t, 0); + if (unlikely(!o)) return 0; + p = ((struct __pyx_obj_14softwrap_core2_SymmetryMap *)o); + p->__pyx_vtab = __pyx_vtabptr_14softwrap_core2_SymmetryMap; + p->engine = ((struct __pyx_obj_14softwrap_core2_SpringEngine *)Py_None); Py_INCREF(Py_None); + if (unlikely(__pyx_pw_14softwrap_core2_11SymmetryMap_1__cinit__(o, a, k) < 0)) goto bad; + return o; + bad: + Py_DECREF(o); o = 0; + return NULL; +} + +static void __pyx_tp_dealloc_14softwrap_core2_SymmetryMap(PyObject *o) { + struct __pyx_obj_14softwrap_core2_SymmetryMap *p = (struct __pyx_obj_14softwrap_core2_SymmetryMap *)o; + PyObject_GC_UnTrack(o); + { + PyObject *etype, *eval, *etb; + PyErr_Fetch(&etype, &eval, &etb); + __Pyx_SET_REFCNT(o, Py_REFCNT(o) + 1); + __pyx_pw_14softwrap_core2_11SymmetryMap_7__dealloc__(o); + __Pyx_SET_REFCNT(o, Py_REFCNT(o) - 1); + PyErr_Restore(etype, eval, etb); + } + Py_CLEAR(p->engine); + (*Py_TYPE(o)->tp_free)(o); +} + +static int __pyx_tp_traverse_14softwrap_core2_SymmetryMap(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_14softwrap_core2_SymmetryMap *p = (struct __pyx_obj_14softwrap_core2_SymmetryMap *)o; + if (p->engine) { + e = (*v)(((PyObject *)p->engine), a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_14softwrap_core2_SymmetryMap(PyObject *o) { + PyObject* tmp; + struct __pyx_obj_14softwrap_core2_SymmetryMap *p = (struct __pyx_obj_14softwrap_core2_SymmetryMap *)o; + tmp = ((PyObject*)p->engine); + p->engine = ((struct __pyx_obj_14softwrap_core2_SpringEngine *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} +static PyObject *__pyx_sq_item_14softwrap_core2_SymmetryMap(PyObject *o, Py_ssize_t i) { + PyObject *r; + PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0; + r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x); + Py_DECREF(x); + return r; +} + +static PyObject *__pyx_getprop_14softwrap_core2_11SymmetryMap_error(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_14softwrap_core2_11SymmetryMap_5error_1__get__(o); +} + +static PyMethodDef __pyx_methods_14softwrap_core2_SymmetryMap[] = { + {"mirror", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_14softwrap_core2_11SymmetryMap_5mirror, METH_VARARGS|METH_KEYWORDS, 0}, + {"__reduce_cython__", (PyCFunction)__pyx_pw_14softwrap_core2_11SymmetryMap_9__reduce_cython__, METH_NOARGS, 0}, + {"__setstate_cython__", (PyCFunction)__pyx_pw_14softwrap_core2_11SymmetryMap_11__setstate_cython__, METH_O, 0}, + {0, 0, 0, 0} +}; + +static struct PyGetSetDef __pyx_getsets_14softwrap_core2_SymmetryMap[] = { + {(char *)"error", __pyx_getprop_14softwrap_core2_11SymmetryMap_error, 0, (char *)0, 0}, + {0, 0, 0, 0, 0} +}; + +static PySequenceMethods __pyx_tp_as_sequence_SymmetryMap = { + 0, /*sq_length*/ + 0, /*sq_concat*/ + 0, /*sq_repeat*/ + __pyx_sq_item_14softwrap_core2_SymmetryMap, /*sq_item*/ + 0, /*sq_slice*/ + 0, /*sq_ass_item*/ + 0, /*sq_ass_slice*/ + 0, /*sq_contains*/ + 0, /*sq_inplace_concat*/ + 0, /*sq_inplace_repeat*/ +}; + +static PyMappingMethods __pyx_tp_as_mapping_SymmetryMap = { + 0, /*mp_length*/ + __pyx_pw_14softwrap_core2_11SymmetryMap_3__getitem__, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyTypeObject __pyx_type_14softwrap_core2_SymmetryMap = { + PyVarObject_HEAD_INIT(0, 0) + "softwrap_core2.SymmetryMap", /*tp_name*/ + sizeof(struct __pyx_obj_14softwrap_core2_SymmetryMap), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_14softwrap_core2_SymmetryMap, /*tp_dealloc*/ + #if PY_VERSION_HEX < 0x030800b4 + 0, /*tp_print*/ + #endif + #if PY_VERSION_HEX >= 0x030800b4 + 0, /*tp_vectorcall_offset*/ + #endif + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #endif + #if PY_MAJOR_VERSION >= 3 + 0, /*tp_as_async*/ + #endif + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + &__pyx_tp_as_sequence_SymmetryMap, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_SymmetryMap, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_14softwrap_core2_SymmetryMap, /*tp_traverse*/ + __pyx_tp_clear_14softwrap_core2_SymmetryMap, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_14softwrap_core2_SymmetryMap, /*tp_methods*/ + 0, /*tp_members*/ + __pyx_getsets_14softwrap_core2_SymmetryMap, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_14softwrap_core2_SymmetryMap, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + 0, /*tp_version_tag*/ + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif + #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800) + 0, /*tp_vectorcall*/ + #endif + #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000 + 0, /*tp_print*/ + #endif + #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 + 0, /*tp_pypy_flags*/ + #endif +}; +static struct __pyx_vtabstruct_14softwrap_core2_SpringEngine __pyx_vtable_14softwrap_core2_SpringEngine; + +static PyObject *__pyx_tp_new_14softwrap_core2_SpringEngine(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { + struct __pyx_obj_14softwrap_core2_SpringEngine *p; + PyObject *o; + if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) { + o = (*t->tp_alloc)(t, 0); + } else { + o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0); + } + if (unlikely(!o)) return 0; + p = ((struct __pyx_obj_14softwrap_core2_SpringEngine *)o); + p->__pyx_vtab = __pyx_vtabptr_14softwrap_core2_SpringEngine; + p->m = ((struct __pyx_obj_14softwrap_core2_Mesh *)Py_None); Py_INCREF(Py_None); + p->bvh = ((struct __pyx_obj_14softwrap_core2_BVH *)Py_None); Py_INCREF(Py_None); + return o; +} + +static void __pyx_tp_dealloc_14softwrap_core2_SpringEngine(PyObject *o) { + struct __pyx_obj_14softwrap_core2_SpringEngine *p = (struct __pyx_obj_14softwrap_core2_SpringEngine *)o; + #if CYTHON_USE_TP_FINALIZE + if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { + if (PyObject_CallFinalizerFromDealloc(o)) return; + } + #endif + PyObject_GC_UnTrack(o); + { + PyObject *etype, *eval, *etb; + PyErr_Fetch(&etype, &eval, &etb); + __Pyx_SET_REFCNT(o, Py_REFCNT(o) + 1); + __pyx_pw_14softwrap_core2_12SpringEngine_5__dealloc__(o); + __Pyx_SET_REFCNT(o, Py_REFCNT(o) - 1); + PyErr_Restore(etype, eval, etb); + } + Py_CLEAR(p->m); + Py_CLEAR(p->bvh); + (*Py_TYPE(o)->tp_free)(o); +} + +static int __pyx_tp_traverse_14softwrap_core2_SpringEngine(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_14softwrap_core2_SpringEngine *p = (struct __pyx_obj_14softwrap_core2_SpringEngine *)o; + if (p->m) { + e = (*v)(((PyObject *)p->m), a); if (e) return e; + } + if (p->bvh) { + e = (*v)(((PyObject *)p->bvh), a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_14softwrap_core2_SpringEngine(PyObject *o) { + PyObject* tmp; + struct __pyx_obj_14softwrap_core2_SpringEngine *p = (struct __pyx_obj_14softwrap_core2_SpringEngine *)o; + tmp = ((PyObject*)p->m); + p->m = ((struct __pyx_obj_14softwrap_core2_Mesh *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->bvh); + p->bvh = ((struct __pyx_obj_14softwrap_core2_BVH *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} +static PyObject *__pyx_sq_item_14softwrap_core2_SpringEngine(PyObject *o, Py_ssize_t i) { + PyObject *r; + PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0; + r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x); + Py_DECREF(x); + return r; +} + +static int __pyx_mp_ass_subscript_14softwrap_core2_SpringEngine(PyObject *o, PyObject *i, PyObject *v) { + if (v) { + return __pyx_pw_14softwrap_core2_12SpringEngine_11__setitem__(o, i, v); + } + else { + PyErr_Format(PyExc_NotImplementedError, + "Subscript deletion not supported by %.200s", Py_TYPE(o)->tp_name); + return -1; + } +} + +static PyMethodDef __pyx_methods_14softwrap_core2_SpringEngine[] = { + {"set_bvh", (PyCFunction)__pyx_pw_14softwrap_core2_12SpringEngine_3set_bvh, METH_O, 0}, + {"from_list", (PyCFunction)__pyx_pw_14softwrap_core2_12SpringEngine_13from_list, METH_O, 0}, + {"set_verts", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_14softwrap_core2_12SpringEngine_15set_verts, METH_VARARGS|METH_KEYWORDS, 0}, + {"get_verts", (PyCFunction)__pyx_pw_14softwrap_core2_12SpringEngine_17get_verts, METH_O, 0}, + {"move_verts", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_14softwrap_core2_12SpringEngine_19move_verts, METH_VARARGS|METH_KEYWORDS, 0}, + {"snap_to_bvh", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_14softwrap_core2_12SpringEngine_21snap_to_bvh, METH_VARARGS|METH_KEYWORDS, 0}, + {"create_spring_group", (PyCFunction)__pyx_pw_14softwrap_core2_12SpringEngine_23create_spring_group, METH_O, 0}, + {"create_symmetry_map", (PyCFunction)__pyx_pw_14softwrap_core2_12SpringEngine_25create_symmetry_map, METH_NOARGS, 0}, + {"create_ternary_links", (PyCFunction)__pyx_pw_14softwrap_core2_12SpringEngine_27create_ternary_links, METH_O, 0}, + {"create_quaternary_links", (PyCFunction)__pyx_pw_14softwrap_core2_12SpringEngine_29create_quaternary_links, METH_O, 0}, + {"create_mask", (PyCFunction)__pyx_pw_14softwrap_core2_12SpringEngine_31create_mask, METH_O, 0}, + {"random_verts", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_14softwrap_core2_12SpringEngine_33random_verts, METH_VARARGS|METH_KEYWORDS, 0}, + {"kinetic_step", (PyCFunction)__pyx_pw_14softwrap_core2_12SpringEngine_35kinetic_step, METH_O, 0}, + {"update_mesh_normals", (PyCFunction)__pyx_pw_14softwrap_core2_12SpringEngine_37update_mesh_normals, METH_O, 0}, + {"__reduce_cython__", (PyCFunction)__pyx_pw_14softwrap_core2_12SpringEngine_39__reduce_cython__, METH_NOARGS, 0}, + {"__setstate_cython__", (PyCFunction)__pyx_pw_14softwrap_core2_12SpringEngine_41__setstate_cython__, METH_O, 0}, + {0, 0, 0, 0} +}; + +static PySequenceMethods __pyx_tp_as_sequence_SpringEngine = { + __pyx_pw_14softwrap_core2_12SpringEngine_7__len__, /*sq_length*/ + 0, /*sq_concat*/ + 0, /*sq_repeat*/ + __pyx_sq_item_14softwrap_core2_SpringEngine, /*sq_item*/ + 0, /*sq_slice*/ + 0, /*sq_ass_item*/ + 0, /*sq_ass_slice*/ + 0, /*sq_contains*/ + 0, /*sq_inplace_concat*/ + 0, /*sq_inplace_repeat*/ +}; + +static PyMappingMethods __pyx_tp_as_mapping_SpringEngine = { + __pyx_pw_14softwrap_core2_12SpringEngine_7__len__, /*mp_length*/ + __pyx_pw_14softwrap_core2_12SpringEngine_9__getitem__, /*mp_subscript*/ + __pyx_mp_ass_subscript_14softwrap_core2_SpringEngine, /*mp_ass_subscript*/ +}; + +static PyTypeObject __pyx_type_14softwrap_core2_SpringEngine = { + PyVarObject_HEAD_INIT(0, 0) + "softwrap_core2.SpringEngine", /*tp_name*/ + sizeof(struct __pyx_obj_14softwrap_core2_SpringEngine), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_14softwrap_core2_SpringEngine, /*tp_dealloc*/ + #if PY_VERSION_HEX < 0x030800b4 + 0, /*tp_print*/ + #endif + #if PY_VERSION_HEX >= 0x030800b4 + 0, /*tp_vectorcall_offset*/ + #endif + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #endif + #if PY_MAJOR_VERSION >= 3 + 0, /*tp_as_async*/ + #endif + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + &__pyx_tp_as_sequence_SpringEngine, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_SpringEngine, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_14softwrap_core2_SpringEngine, /*tp_traverse*/ + __pyx_tp_clear_14softwrap_core2_SpringEngine, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_14softwrap_core2_SpringEngine, /*tp_methods*/ + 0, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + __pyx_pw_14softwrap_core2_12SpringEngine_1__init__, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_14softwrap_core2_SpringEngine, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + 0, /*tp_version_tag*/ + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif + #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800) + 0, /*tp_vectorcall*/ + #endif + #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000 + 0, /*tp_print*/ + #endif + #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 + 0, /*tp_pypy_flags*/ + #endif +}; + +static struct __pyx_obj_14softwrap_core2___pyx_scope_struct____iter__ *__pyx_freelist_14softwrap_core2___pyx_scope_struct____iter__[8]; +static int __pyx_freecount_14softwrap_core2___pyx_scope_struct____iter__ = 0; + +static PyObject *__pyx_tp_new_14softwrap_core2___pyx_scope_struct____iter__(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { + PyObject *o; + if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_14softwrap_core2___pyx_scope_struct____iter__ > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_14softwrap_core2___pyx_scope_struct____iter__)))) { + o = (PyObject*)__pyx_freelist_14softwrap_core2___pyx_scope_struct____iter__[--__pyx_freecount_14softwrap_core2___pyx_scope_struct____iter__]; + memset(o, 0, sizeof(struct __pyx_obj_14softwrap_core2___pyx_scope_struct____iter__)); + (void) PyObject_INIT(o, t); + PyObject_GC_Track(o); + } else { + o = (*t->tp_alloc)(t, 0); + if (unlikely(!o)) return 0; + } + return o; +} + +static void __pyx_tp_dealloc_14softwrap_core2___pyx_scope_struct____iter__(PyObject *o) { + struct __pyx_obj_14softwrap_core2___pyx_scope_struct____iter__ *p = (struct __pyx_obj_14softwrap_core2___pyx_scope_struct____iter__ *)o; + PyObject_GC_UnTrack(o); + Py_CLEAR(p->__pyx_v_self); + if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_14softwrap_core2___pyx_scope_struct____iter__ < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_14softwrap_core2___pyx_scope_struct____iter__)))) { + __pyx_freelist_14softwrap_core2___pyx_scope_struct____iter__[__pyx_freecount_14softwrap_core2___pyx_scope_struct____iter__++] = ((struct __pyx_obj_14softwrap_core2___pyx_scope_struct____iter__ *)o); + } else { + (*Py_TYPE(o)->tp_free)(o); + } +} + +static int __pyx_tp_traverse_14softwrap_core2___pyx_scope_struct____iter__(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_14softwrap_core2___pyx_scope_struct____iter__ *p = (struct __pyx_obj_14softwrap_core2___pyx_scope_struct____iter__ *)o; + if (p->__pyx_v_self) { + e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e; + } + return 0; +} + +static PyTypeObject __pyx_type_14softwrap_core2___pyx_scope_struct____iter__ = { + PyVarObject_HEAD_INIT(0, 0) + "softwrap_core2.__pyx_scope_struct____iter__", /*tp_name*/ + sizeof(struct __pyx_obj_14softwrap_core2___pyx_scope_struct____iter__), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_14softwrap_core2___pyx_scope_struct____iter__, /*tp_dealloc*/ + #if PY_VERSION_HEX < 0x030800b4 + 0, /*tp_print*/ + #endif + #if PY_VERSION_HEX >= 0x030800b4 + 0, /*tp_vectorcall_offset*/ + #endif + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #endif + #if PY_MAJOR_VERSION >= 3 + 0, /*tp_as_async*/ + #endif + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_14softwrap_core2___pyx_scope_struct____iter__, /*tp_traverse*/ + 0, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + 0, /*tp_methods*/ + 0, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_14softwrap_core2___pyx_scope_struct____iter__, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + 0, /*tp_version_tag*/ + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif + #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800) + 0, /*tp_vectorcall*/ + #endif + #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000 + 0, /*tp_print*/ + #endif + #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 + 0, /*tp_pypy_flags*/ + #endif +}; + +static struct __pyx_obj_14softwrap_core2___pyx_scope_struct_1___getitem__ *__pyx_freelist_14softwrap_core2___pyx_scope_struct_1___getitem__[8]; +static int __pyx_freecount_14softwrap_core2___pyx_scope_struct_1___getitem__ = 0; + +static PyObject *__pyx_tp_new_14softwrap_core2___pyx_scope_struct_1___getitem__(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { + PyObject *o; + if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_14softwrap_core2___pyx_scope_struct_1___getitem__ > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_14softwrap_core2___pyx_scope_struct_1___getitem__)))) { + o = (PyObject*)__pyx_freelist_14softwrap_core2___pyx_scope_struct_1___getitem__[--__pyx_freecount_14softwrap_core2___pyx_scope_struct_1___getitem__]; + memset(o, 0, sizeof(struct __pyx_obj_14softwrap_core2___pyx_scope_struct_1___getitem__)); + (void) PyObject_INIT(o, t); + PyObject_GC_Track(o); + } else { + o = (*t->tp_alloc)(t, 0); + if (unlikely(!o)) return 0; + } + return o; +} + +static void __pyx_tp_dealloc_14softwrap_core2___pyx_scope_struct_1___getitem__(PyObject *o) { + struct __pyx_obj_14softwrap_core2___pyx_scope_struct_1___getitem__ *p = (struct __pyx_obj_14softwrap_core2___pyx_scope_struct_1___getitem__ *)o; + PyObject_GC_UnTrack(o); + Py_CLEAR(p->__pyx_v_self); + if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_14softwrap_core2___pyx_scope_struct_1___getitem__ < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_14softwrap_core2___pyx_scope_struct_1___getitem__)))) { + __pyx_freelist_14softwrap_core2___pyx_scope_struct_1___getitem__[__pyx_freecount_14softwrap_core2___pyx_scope_struct_1___getitem__++] = ((struct __pyx_obj_14softwrap_core2___pyx_scope_struct_1___getitem__ *)o); + } else { + (*Py_TYPE(o)->tp_free)(o); + } +} + +static int __pyx_tp_traverse_14softwrap_core2___pyx_scope_struct_1___getitem__(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_14softwrap_core2___pyx_scope_struct_1___getitem__ *p = (struct __pyx_obj_14softwrap_core2___pyx_scope_struct_1___getitem__ *)o; + if (p->__pyx_v_self) { + e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_14softwrap_core2___pyx_scope_struct_1___getitem__(PyObject *o) { + PyObject* tmp; + struct __pyx_obj_14softwrap_core2___pyx_scope_struct_1___getitem__ *p = (struct __pyx_obj_14softwrap_core2___pyx_scope_struct_1___getitem__ *)o; + tmp = ((PyObject*)p->__pyx_v_self); + p->__pyx_v_self = ((struct __pyx_obj_14softwrap_core2_SpringEnginePin *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} + +static PyTypeObject __pyx_type_14softwrap_core2___pyx_scope_struct_1___getitem__ = { + PyVarObject_HEAD_INIT(0, 0) + "softwrap_core2.__pyx_scope_struct_1___getitem__", /*tp_name*/ + sizeof(struct __pyx_obj_14softwrap_core2___pyx_scope_struct_1___getitem__), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_14softwrap_core2___pyx_scope_struct_1___getitem__, /*tp_dealloc*/ + #if PY_VERSION_HEX < 0x030800b4 + 0, /*tp_print*/ + #endif + #if PY_VERSION_HEX >= 0x030800b4 + 0, /*tp_vectorcall_offset*/ + #endif + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #endif + #if PY_MAJOR_VERSION >= 3 + 0, /*tp_as_async*/ + #endif + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_14softwrap_core2___pyx_scope_struct_1___getitem__, /*tp_traverse*/ + __pyx_tp_clear_14softwrap_core2___pyx_scope_struct_1___getitem__, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + 0, /*tp_methods*/ + 0, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_14softwrap_core2___pyx_scope_struct_1___getitem__, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + 0, /*tp_version_tag*/ + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif + #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800) + 0, /*tp_vectorcall*/ + #endif + #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000 + 0, /*tp_print*/ + #endif + #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 + 0, /*tp_pypy_flags*/ + #endif +}; + +static struct __pyx_obj_14softwrap_core2___pyx_scope_struct_2_iter_ring *__pyx_freelist_14softwrap_core2___pyx_scope_struct_2_iter_ring[8]; +static int __pyx_freecount_14softwrap_core2___pyx_scope_struct_2_iter_ring = 0; + +static PyObject *__pyx_tp_new_14softwrap_core2___pyx_scope_struct_2_iter_ring(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { + PyObject *o; + if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_14softwrap_core2___pyx_scope_struct_2_iter_ring > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_14softwrap_core2___pyx_scope_struct_2_iter_ring)))) { + o = (PyObject*)__pyx_freelist_14softwrap_core2___pyx_scope_struct_2_iter_ring[--__pyx_freecount_14softwrap_core2___pyx_scope_struct_2_iter_ring]; + memset(o, 0, sizeof(struct __pyx_obj_14softwrap_core2___pyx_scope_struct_2_iter_ring)); + (void) PyObject_INIT(o, t); + PyObject_GC_Track(o); + } else { + o = (*t->tp_alloc)(t, 0); + if (unlikely(!o)) return 0; + } + return o; +} + +static void __pyx_tp_dealloc_14softwrap_core2___pyx_scope_struct_2_iter_ring(PyObject *o) { + struct __pyx_obj_14softwrap_core2___pyx_scope_struct_2_iter_ring *p = (struct __pyx_obj_14softwrap_core2___pyx_scope_struct_2_iter_ring *)o; + PyObject_GC_UnTrack(o); + Py_CLEAR(p->__pyx_outer_scope); + if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_14softwrap_core2___pyx_scope_struct_2_iter_ring < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_14softwrap_core2___pyx_scope_struct_2_iter_ring)))) { + __pyx_freelist_14softwrap_core2___pyx_scope_struct_2_iter_ring[__pyx_freecount_14softwrap_core2___pyx_scope_struct_2_iter_ring++] = ((struct __pyx_obj_14softwrap_core2___pyx_scope_struct_2_iter_ring *)o); + } else { + (*Py_TYPE(o)->tp_free)(o); + } +} + +static int __pyx_tp_traverse_14softwrap_core2___pyx_scope_struct_2_iter_ring(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_14softwrap_core2___pyx_scope_struct_2_iter_ring *p = (struct __pyx_obj_14softwrap_core2___pyx_scope_struct_2_iter_ring *)o; + if (p->__pyx_outer_scope) { + e = (*v)(((PyObject *)p->__pyx_outer_scope), a); if (e) return e; + } + return 0; +} + +static PyTypeObject __pyx_type_14softwrap_core2___pyx_scope_struct_2_iter_ring = { + PyVarObject_HEAD_INIT(0, 0) + "softwrap_core2.__pyx_scope_struct_2_iter_ring", /*tp_name*/ + sizeof(struct __pyx_obj_14softwrap_core2___pyx_scope_struct_2_iter_ring), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_14softwrap_core2___pyx_scope_struct_2_iter_ring, /*tp_dealloc*/ + #if PY_VERSION_HEX < 0x030800b4 + 0, /*tp_print*/ + #endif + #if PY_VERSION_HEX >= 0x030800b4 + 0, /*tp_vectorcall_offset*/ + #endif + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #endif + #if PY_MAJOR_VERSION >= 3 + 0, /*tp_as_async*/ + #endif + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_14softwrap_core2___pyx_scope_struct_2_iter_ring, /*tp_traverse*/ + 0, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + 0, /*tp_methods*/ + 0, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_14softwrap_core2___pyx_scope_struct_2_iter_ring, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + 0, /*tp_version_tag*/ + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif + #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800) + 0, /*tp_vectorcall*/ + #endif + #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000 + 0, /*tp_print*/ + #endif + #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 + 0, /*tp_pypy_flags*/ + #endif +}; + +static struct __pyx_obj_14softwrap_core2___pyx_scope_struct_3___iter__ *__pyx_freelist_14softwrap_core2___pyx_scope_struct_3___iter__[8]; +static int __pyx_freecount_14softwrap_core2___pyx_scope_struct_3___iter__ = 0; + +static PyObject *__pyx_tp_new_14softwrap_core2___pyx_scope_struct_3___iter__(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { + PyObject *o; + if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_14softwrap_core2___pyx_scope_struct_3___iter__ > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_14softwrap_core2___pyx_scope_struct_3___iter__)))) { + o = (PyObject*)__pyx_freelist_14softwrap_core2___pyx_scope_struct_3___iter__[--__pyx_freecount_14softwrap_core2___pyx_scope_struct_3___iter__]; + memset(o, 0, sizeof(struct __pyx_obj_14softwrap_core2___pyx_scope_struct_3___iter__)); + (void) PyObject_INIT(o, t); + PyObject_GC_Track(o); + } else { + o = (*t->tp_alloc)(t, 0); + if (unlikely(!o)) return 0; + } + return o; +} + +static void __pyx_tp_dealloc_14softwrap_core2___pyx_scope_struct_3___iter__(PyObject *o) { + struct __pyx_obj_14softwrap_core2___pyx_scope_struct_3___iter__ *p = (struct __pyx_obj_14softwrap_core2___pyx_scope_struct_3___iter__ *)o; + PyObject_GC_UnTrack(o); + Py_CLEAR(p->__pyx_v_self); + if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_14softwrap_core2___pyx_scope_struct_3___iter__ < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_14softwrap_core2___pyx_scope_struct_3___iter__)))) { + __pyx_freelist_14softwrap_core2___pyx_scope_struct_3___iter__[__pyx_freecount_14softwrap_core2___pyx_scope_struct_3___iter__++] = ((struct __pyx_obj_14softwrap_core2___pyx_scope_struct_3___iter__ *)o); + } else { + (*Py_TYPE(o)->tp_free)(o); + } +} + +static int __pyx_tp_traverse_14softwrap_core2___pyx_scope_struct_3___iter__(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_14softwrap_core2___pyx_scope_struct_3___iter__ *p = (struct __pyx_obj_14softwrap_core2___pyx_scope_struct_3___iter__ *)o; + if (p->__pyx_v_self) { + e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e; + } + return 0; +} + +static PyTypeObject __pyx_type_14softwrap_core2___pyx_scope_struct_3___iter__ = { + PyVarObject_HEAD_INIT(0, 0) + "softwrap_core2.__pyx_scope_struct_3___iter__", /*tp_name*/ + sizeof(struct __pyx_obj_14softwrap_core2___pyx_scope_struct_3___iter__), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_14softwrap_core2___pyx_scope_struct_3___iter__, /*tp_dealloc*/ + #if PY_VERSION_HEX < 0x030800b4 + 0, /*tp_print*/ + #endif + #if PY_VERSION_HEX >= 0x030800b4 + 0, /*tp_vectorcall_offset*/ + #endif + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #endif + #if PY_MAJOR_VERSION >= 3 + 0, /*tp_as_async*/ + #endif + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_14softwrap_core2___pyx_scope_struct_3___iter__, /*tp_traverse*/ + 0, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + 0, /*tp_methods*/ + 0, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_14softwrap_core2___pyx_scope_struct_3___iter__, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + 0, /*tp_version_tag*/ + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif + #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800) + 0, /*tp_vectorcall*/ + #endif + #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000 + 0, /*tp_print*/ + #endif + #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 + 0, /*tp_pypy_flags*/ + #endif +}; + +static struct __pyx_obj_14softwrap_core2___pyx_scope_struct_4___getitem__ *__pyx_freelist_14softwrap_core2___pyx_scope_struct_4___getitem__[8]; +static int __pyx_freecount_14softwrap_core2___pyx_scope_struct_4___getitem__ = 0; + +static PyObject *__pyx_tp_new_14softwrap_core2___pyx_scope_struct_4___getitem__(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { + PyObject *o; + if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_14softwrap_core2___pyx_scope_struct_4___getitem__ > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_14softwrap_core2___pyx_scope_struct_4___getitem__)))) { + o = (PyObject*)__pyx_freelist_14softwrap_core2___pyx_scope_struct_4___getitem__[--__pyx_freecount_14softwrap_core2___pyx_scope_struct_4___getitem__]; + memset(o, 0, sizeof(struct __pyx_obj_14softwrap_core2___pyx_scope_struct_4___getitem__)); + (void) PyObject_INIT(o, t); + PyObject_GC_Track(o); + } else { + o = (*t->tp_alloc)(t, 0); + if (unlikely(!o)) return 0; + } + return o; +} + +static void __pyx_tp_dealloc_14softwrap_core2___pyx_scope_struct_4___getitem__(PyObject *o) { + struct __pyx_obj_14softwrap_core2___pyx_scope_struct_4___getitem__ *p = (struct __pyx_obj_14softwrap_core2___pyx_scope_struct_4___getitem__ *)o; + PyObject_GC_UnTrack(o); + Py_CLEAR(p->__pyx_v_self); + if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_14softwrap_core2___pyx_scope_struct_4___getitem__ < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_14softwrap_core2___pyx_scope_struct_4___getitem__)))) { + __pyx_freelist_14softwrap_core2___pyx_scope_struct_4___getitem__[__pyx_freecount_14softwrap_core2___pyx_scope_struct_4___getitem__++] = ((struct __pyx_obj_14softwrap_core2___pyx_scope_struct_4___getitem__ *)o); + } else { + (*Py_TYPE(o)->tp_free)(o); + } +} + +static int __pyx_tp_traverse_14softwrap_core2___pyx_scope_struct_4___getitem__(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_14softwrap_core2___pyx_scope_struct_4___getitem__ *p = (struct __pyx_obj_14softwrap_core2___pyx_scope_struct_4___getitem__ *)o; + if (p->__pyx_v_self) { + e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_14softwrap_core2___pyx_scope_struct_4___getitem__(PyObject *o) { + PyObject* tmp; + struct __pyx_obj_14softwrap_core2___pyx_scope_struct_4___getitem__ *p = (struct __pyx_obj_14softwrap_core2___pyx_scope_struct_4___getitem__ *)o; + tmp = ((PyObject*)p->__pyx_v_self); + p->__pyx_v_self = ((struct __pyx_obj_14softwrap_core2_SymmetryMap *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} + +static PyTypeObject __pyx_type_14softwrap_core2___pyx_scope_struct_4___getitem__ = { + PyVarObject_HEAD_INIT(0, 0) + "softwrap_core2.__pyx_scope_struct_4___getitem__", /*tp_name*/ + sizeof(struct __pyx_obj_14softwrap_core2___pyx_scope_struct_4___getitem__), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_14softwrap_core2___pyx_scope_struct_4___getitem__, /*tp_dealloc*/ + #if PY_VERSION_HEX < 0x030800b4 + 0, /*tp_print*/ + #endif + #if PY_VERSION_HEX >= 0x030800b4 + 0, /*tp_vectorcall_offset*/ + #endif + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #endif + #if PY_MAJOR_VERSION >= 3 + 0, /*tp_as_async*/ + #endif + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_14softwrap_core2___pyx_scope_struct_4___getitem__, /*tp_traverse*/ + __pyx_tp_clear_14softwrap_core2___pyx_scope_struct_4___getitem__, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + 0, /*tp_methods*/ + 0, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_14softwrap_core2___pyx_scope_struct_4___getitem__, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + 0, /*tp_version_tag*/ + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif + #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800) + 0, /*tp_vectorcall*/ + #endif + #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000 + 0, /*tp_print*/ + #endif + #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 + 0, /*tp_pypy_flags*/ + #endif +}; + +static struct __pyx_obj_14softwrap_core2___pyx_scope_struct_5_genexpr *__pyx_freelist_14softwrap_core2___pyx_scope_struct_5_genexpr[8]; +static int __pyx_freecount_14softwrap_core2___pyx_scope_struct_5_genexpr = 0; + +static PyObject *__pyx_tp_new_14softwrap_core2___pyx_scope_struct_5_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { + PyObject *o; + if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_14softwrap_core2___pyx_scope_struct_5_genexpr > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_14softwrap_core2___pyx_scope_struct_5_genexpr)))) { + o = (PyObject*)__pyx_freelist_14softwrap_core2___pyx_scope_struct_5_genexpr[--__pyx_freecount_14softwrap_core2___pyx_scope_struct_5_genexpr]; + memset(o, 0, sizeof(struct __pyx_obj_14softwrap_core2___pyx_scope_struct_5_genexpr)); + (void) PyObject_INIT(o, t); + PyObject_GC_Track(o); + } else { + o = (*t->tp_alloc)(t, 0); + if (unlikely(!o)) return 0; + } + return o; +} + +static void __pyx_tp_dealloc_14softwrap_core2___pyx_scope_struct_5_genexpr(PyObject *o) { + struct __pyx_obj_14softwrap_core2___pyx_scope_struct_5_genexpr *p = (struct __pyx_obj_14softwrap_core2___pyx_scope_struct_5_genexpr *)o; + PyObject_GC_UnTrack(o); + Py_CLEAR(p->__pyx_outer_scope); + Py_CLEAR(p->__pyx_v_axis); + if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_14softwrap_core2___pyx_scope_struct_5_genexpr < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_14softwrap_core2___pyx_scope_struct_5_genexpr)))) { + __pyx_freelist_14softwrap_core2___pyx_scope_struct_5_genexpr[__pyx_freecount_14softwrap_core2___pyx_scope_struct_5_genexpr++] = ((struct __pyx_obj_14softwrap_core2___pyx_scope_struct_5_genexpr *)o); + } else { + (*Py_TYPE(o)->tp_free)(o); + } +} + +static int __pyx_tp_traverse_14softwrap_core2___pyx_scope_struct_5_genexpr(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_14softwrap_core2___pyx_scope_struct_5_genexpr *p = (struct __pyx_obj_14softwrap_core2___pyx_scope_struct_5_genexpr *)o; + if (p->__pyx_outer_scope) { + e = (*v)(((PyObject *)p->__pyx_outer_scope), a); if (e) return e; + } + if (p->__pyx_v_axis) { + e = (*v)(p->__pyx_v_axis, a); if (e) return e; + } + return 0; +} + +static PyTypeObject __pyx_type_14softwrap_core2___pyx_scope_struct_5_genexpr = { + PyVarObject_HEAD_INIT(0, 0) + "softwrap_core2.__pyx_scope_struct_5_genexpr", /*tp_name*/ + sizeof(struct __pyx_obj_14softwrap_core2___pyx_scope_struct_5_genexpr), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_14softwrap_core2___pyx_scope_struct_5_genexpr, /*tp_dealloc*/ + #if PY_VERSION_HEX < 0x030800b4 + 0, /*tp_print*/ + #endif + #if PY_VERSION_HEX >= 0x030800b4 + 0, /*tp_vectorcall_offset*/ + #endif + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #endif + #if PY_MAJOR_VERSION >= 3 + 0, /*tp_as_async*/ + #endif + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_14softwrap_core2___pyx_scope_struct_5_genexpr, /*tp_traverse*/ + 0, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + 0, /*tp_methods*/ + 0, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_14softwrap_core2___pyx_scope_struct_5_genexpr, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + 0, /*tp_version_tag*/ + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif + #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800) + 0, /*tp_vectorcall*/ + #endif + #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000 + 0, /*tp_print*/ + #endif + #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 + 0, /*tp_pypy_flags*/ + #endif +}; + +static PyMethodDef __pyx_methods[] = { + {"index_check", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_14softwrap_core2_3index_check, METH_VARARGS|METH_KEYWORDS, 0}, + {0, 0, 0, 0} +}; + +#if PY_MAJOR_VERSION >= 3 +#if CYTHON_PEP489_MULTI_PHASE_INIT +static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/ +static int __pyx_pymod_exec_softwrap_core2(PyObject* module); /*proto*/ +static PyModuleDef_Slot __pyx_moduledef_slots[] = { + {Py_mod_create, (void*)__pyx_pymod_create}, + {Py_mod_exec, (void*)__pyx_pymod_exec_softwrap_core2}, + {0, NULL} +}; +#endif + +static struct PyModuleDef __pyx_moduledef = { + PyModuleDef_HEAD_INIT, + "softwrap_core2", + 0, /* m_doc */ + #if CYTHON_PEP489_MULTI_PHASE_INIT + 0, /* m_size */ + #else + -1, /* m_size */ + #endif + __pyx_methods /* m_methods */, + #if CYTHON_PEP489_MULTI_PHASE_INIT + __pyx_moduledef_slots, /* m_slots */ + #else + NULL, /* m_reload */ + #endif + NULL, /* m_traverse */ + NULL, /* m_clear */ + NULL /* m_free */ +}; +#endif +#ifndef CYTHON_SMALL_CODE +#if defined(__clang__) + #define CYTHON_SMALL_CODE +#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) + #define CYTHON_SMALL_CODE __attribute__((cold)) +#else + #define CYTHON_SMALL_CODE +#endif +#endif + +static __Pyx_StringTabEntry __pyx_string_tab[] = { + {&__pyx_n_s_BVH, __pyx_k_BVH, sizeof(__pyx_k_BVH), 0, 0, 1, 1}, + {&__pyx_n_u_INSIDE, __pyx_k_INSIDE, sizeof(__pyx_k_INSIDE), 0, 1, 0, 1}, + {&__pyx_n_s_IndexError, __pyx_k_IndexError, sizeof(__pyx_k_IndexError), 0, 0, 1, 1}, + {&__pyx_kp_u_Invalid_or_empty_mesh, __pyx_k_Invalid_or_empty_mesh, sizeof(__pyx_k_Invalid_or_empty_mesh), 0, 1, 0, 0}, + {&__pyx_n_s_KeyError, __pyx_k_KeyError, sizeof(__pyx_k_KeyError), 0, 0, 1, 1}, + {&__pyx_n_s_LinkProbe, __pyx_k_LinkProbe, sizeof(__pyx_k_LinkProbe), 0, 0, 1, 1}, + {&__pyx_n_s_LinkProbe___iter, __pyx_k_LinkProbe___iter, sizeof(__pyx_k_LinkProbe___iter), 0, 0, 1, 1}, + {&__pyx_n_s_MaskContextManager, __pyx_k_MaskContextManager, sizeof(__pyx_k_MaskContextManager), 0, 0, 1, 1}, + {&__pyx_n_s_MemoryError, __pyx_k_MemoryError, sizeof(__pyx_k_MemoryError), 0, 0, 1, 1}, + {&__pyx_n_s_Mesh, __pyx_k_Mesh, sizeof(__pyx_k_Mesh), 0, 0, 1, 1}, + {&__pyx_kp_u_No_bvh_avaliable, __pyx_k_No_bvh_avaliable, sizeof(__pyx_k_No_bvh_avaliable), 0, 1, 0, 0}, + {&__pyx_n_u_OUTSIDE, __pyx_k_OUTSIDE, sizeof(__pyx_k_OUTSIDE), 0, 1, 0, 1}, + {&__pyx_kp_u_Oops_Softwrap2_memory_leak_dete, __pyx_k_Oops_Softwrap2_memory_leak_dete, sizeof(__pyx_k_Oops_Softwrap2_memory_leak_dete), 0, 1, 0, 0}, + {&__pyx_n_s_OverflowError, __pyx_k_OverflowError, sizeof(__pyx_k_OverflowError), 0, 0, 1, 1}, + {&__pyx_n_s_QuaternarySmoothingLinks, __pyx_k_QuaternarySmoothingLinks, sizeof(__pyx_k_QuaternarySmoothingLinks), 0, 0, 1, 1}, + {&__pyx_n_s_RuntimeError, __pyx_k_RuntimeError, sizeof(__pyx_k_RuntimeError), 0, 0, 1, 1}, + {&__pyx_n_u_SURFACE, __pyx_k_SURFACE, sizeof(__pyx_k_SURFACE), 0, 1, 0, 1}, + {&__pyx_n_s_SpringEngine, __pyx_k_SpringEngine, sizeof(__pyx_k_SpringEngine), 0, 0, 1, 1}, + {&__pyx_n_s_SpringEngineMask, __pyx_k_SpringEngineMask, sizeof(__pyx_k_SpringEngineMask), 0, 0, 1, 1}, + {&__pyx_n_s_SpringEnginePin, __pyx_k_SpringEnginePin, sizeof(__pyx_k_SpringEnginePin), 0, 0, 1, 1}, + {&__pyx_n_s_SpringEnginePin___iter, __pyx_k_SpringEnginePin___iter, sizeof(__pyx_k_SpringEnginePin___iter), 0, 0, 1, 1}, + {&__pyx_n_s_SpringLinks, __pyx_k_SpringLinks, sizeof(__pyx_k_SpringLinks), 0, 0, 1, 1}, + {&__pyx_n_s_SymmetryMap, __pyx_k_SymmetryMap, sizeof(__pyx_k_SymmetryMap), 0, 0, 1, 1}, + {&__pyx_n_s_TernarySmoothingLinks, __pyx_k_TernarySmoothingLinks, sizeof(__pyx_k_TernarySmoothingLinks), 0, 0, 1, 1}, + {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1}, + {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1}, + {&__pyx_kp_u__2, __pyx_k__2, sizeof(__pyx_k__2), 0, 1, 0, 0}, + {&__pyx_n_s_append, __pyx_k_append, sizeof(__pyx_k_append), 0, 0, 1, 1}, + {&__pyx_n_s_args, __pyx_k_args, sizeof(__pyx_k_args), 0, 0, 1, 1}, + {&__pyx_n_s_atexit, __pyx_k_atexit, sizeof(__pyx_k_atexit), 0, 0, 1, 1}, + {&__pyx_n_s_bvh, __pyx_k_bvh, sizeof(__pyx_k_bvh), 0, 0, 1, 1}, + {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1}, + {&__pyx_n_s_close, __pyx_k_close, sizeof(__pyx_k_close), 0, 0, 1, 1}, + {&__pyx_n_s_collect, __pyx_k_collect, sizeof(__pyx_k_collect), 0, 0, 1, 1}, + {&__pyx_kp_u_core2_pyx, __pyx_k_core2_pyx, sizeof(__pyx_k_core2_pyx), 0, 1, 0, 0}, + {&__pyx_kp_s_core_core2_pyx, __pyx_k_core_core2_pyx, sizeof(__pyx_k_core_core2_pyx), 0, 0, 1, 0}, + {&__pyx_n_s_create_mask, __pyx_k_create_mask, sizeof(__pyx_k_create_mask), 0, 0, 1, 1}, + {&__pyx_n_s_create_quaternary_links, __pyx_k_create_quaternary_links, sizeof(__pyx_k_create_quaternary_links), 0, 0, 1, 1}, + {&__pyx_n_s_create_spring_group, __pyx_k_create_spring_group, sizeof(__pyx_k_create_spring_group), 0, 0, 1, 1}, + {&__pyx_n_s_create_symmetry_map, __pyx_k_create_symmetry_map, sizeof(__pyx_k_create_symmetry_map), 0, 0, 1, 1}, + {&__pyx_n_s_create_ternary_links, __pyx_k_create_ternary_links, sizeof(__pyx_k_create_ternary_links), 0, 0, 1, 1}, + {&__pyx_n_s_cycle_quality, __pyx_k_cycle_quality, sizeof(__pyx_k_cycle_quality), 0, 0, 1, 1}, + {&__pyx_n_s_deform_restore, __pyx_k_deform_restore, sizeof(__pyx_k_deform_restore), 0, 0, 1, 1}, + {&__pyx_n_s_deform_update, __pyx_k_deform_update, sizeof(__pyx_k_deform_update), 0, 0, 1, 1}, + {&__pyx_n_s_engine, __pyx_k_engine, sizeof(__pyx_k_engine), 0, 0, 1, 1}, + {&__pyx_n_s_enumerate, __pyx_k_enumerate, sizeof(__pyx_k_enumerate), 0, 0, 1, 1}, + {&__pyx_n_s_factor, __pyx_k_factor, sizeof(__pyx_k_factor), 0, 0, 1, 1}, + {&__pyx_n_s_gc, __pyx_k_gc, sizeof(__pyx_k_gc), 0, 0, 1, 1}, + {&__pyx_n_s_genexpr, __pyx_k_genexpr, sizeof(__pyx_k_genexpr), 0, 0, 1, 1}, + {&__pyx_n_s_getitem___locals_genexpr, __pyx_k_getitem___locals_genexpr, sizeof(__pyx_k_getitem___locals_genexpr), 0, 0, 1, 1}, + {&__pyx_n_s_getitem___locals_iter_ring, __pyx_k_getitem___locals_iter_ring, sizeof(__pyx_k_getitem___locals_iter_ring), 0, 0, 1, 1}, + {&__pyx_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 0, 0, 1, 1}, + {&__pyx_n_s_hex, __pyx_k_hex, sizeof(__pyx_k_hex), 0, 0, 1, 1}, + {&__pyx_n_s_i, __pyx_k_i, sizeof(__pyx_k_i), 0, 0, 1, 1}, + {&__pyx_n_s_idx, __pyx_k_idx, sizeof(__pyx_k_idx), 0, 0, 1, 1}, + {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1}, + {&__pyx_n_s_index, __pyx_k_index, sizeof(__pyx_k_index), 0, 0, 1, 1}, + {&__pyx_n_s_indexes, __pyx_k_indexes, sizeof(__pyx_k_indexes), 0, 0, 1, 1}, + {&__pyx_kp_u_indexes_array_is_not_the_same_si, __pyx_k_indexes_array_is_not_the_same_si, sizeof(__pyx_k_indexes_array_is_not_the_same_si), 0, 1, 0, 0}, + {&__pyx_kp_u_invalid_start_index, __pyx_k_invalid_start_index, sizeof(__pyx_k_invalid_start_index), 0, 1, 0, 0}, + {&__pyx_n_s_invert, __pyx_k_invert, sizeof(__pyx_k_invert), 0, 0, 1, 1}, + {&__pyx_n_s_items, __pyx_k_items, sizeof(__pyx_k_items), 0, 0, 1, 1}, + {&__pyx_n_s_iter, __pyx_k_iter, sizeof(__pyx_k_iter), 0, 0, 1, 1}, + {&__pyx_n_s_iter_ring, __pyx_k_iter_ring, sizeof(__pyx_k_iter_ring), 0, 0, 1, 1}, + {&__pyx_n_s_kinetic_step, __pyx_k_kinetic_step, sizeof(__pyx_k_kinetic_step), 0, 0, 1, 1}, + {&__pyx_n_s_leak_check, __pyx_k_leak_check, sizeof(__pyx_k_leak_check), 0, 0, 1, 1}, + {&__pyx_n_s_lengths_update, __pyx_k_lengths_update, sizeof(__pyx_k_lengths_update), 0, 0, 1, 1}, + {&__pyx_n_s_line, __pyx_k_line, sizeof(__pyx_k_line), 0, 0, 1, 1}, + {&__pyx_n_s_links, __pyx_k_links, sizeof(__pyx_k_links), 0, 0, 1, 1}, + {&__pyx_kp_u_list_too_small, __pyx_k_list_too_small, sizeof(__pyx_k_list_too_small), 0, 1, 0, 0}, + {&__pyx_n_s_load, __pyx_k_load, sizeof(__pyx_k_load), 0, 0, 1, 1}, + {&__pyx_n_s_locations, __pyx_k_locations, sizeof(__pyx_k_locations), 0, 0, 1, 1}, + {&__pyx_n_s_m, __pyx_k_m, sizeof(__pyx_k_m), 0, 0, 1, 1}, + {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1}, + {&__pyx_n_s_mask, __pyx_k_mask, sizeof(__pyx_k_mask), 0, 0, 1, 1}, + {&__pyx_kp_u_mask_must_have_the_same_number_o, __pyx_k_mask_must_have_the_same_number_o, sizeof(__pyx_k_mask_must_have_the_same_number_o), 0, 1, 0, 0}, + {&__pyx_n_s_masked_store, __pyx_k_masked_store, sizeof(__pyx_k_masked_store), 0, 0, 1, 1}, + {&__pyx_n_s_max_deform, __pyx_k_max_deform, sizeof(__pyx_k_max_deform), 0, 0, 1, 1}, + {&__pyx_n_s_max_ratio, __pyx_k_max_ratio, sizeof(__pyx_k_max_ratio), 0, 0, 1, 1}, + {&__pyx_n_s_mesh, __pyx_k_mesh, sizeof(__pyx_k_mesh), 0, 0, 1, 1}, + {&__pyx_n_s_min_deform, __pyx_k_min_deform, sizeof(__pyx_k_min_deform), 0, 0, 1, 1}, + {&__pyx_n_s_n_rings, __pyx_k_n_rings, sizeof(__pyx_k_n_rings), 0, 0, 1, 1}, + {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1}, + {&__pyx_kp_s_no_default___reduce___due_to_non, __pyx_k_no_default___reduce___due_to_non, sizeof(__pyx_k_no_default___reduce___due_to_non), 0, 0, 1, 0}, + {&__pyx_n_s_print, __pyx_k_print, sizeof(__pyx_k_print), 0, 0, 1, 1}, + {&__pyx_kp_u_ptr, __pyx_k_ptr, sizeof(__pyx_k_ptr), 0, 1, 0, 0}, + {&__pyx_n_s_ptr_2, __pyx_k_ptr_2, sizeof(__pyx_k_ptr_2), 0, 0, 1, 1}, + {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1}, + {&__pyx_n_s_random_verts, __pyx_k_random_verts, sizeof(__pyx_k_random_verts), 0, 0, 1, 1}, + {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1}, + {&__pyx_n_s_reduce, __pyx_k_reduce, sizeof(__pyx_k_reduce), 0, 0, 1, 1}, + {&__pyx_n_s_reduce_cython, __pyx_k_reduce_cython, sizeof(__pyx_k_reduce_cython), 0, 0, 1, 1}, + {&__pyx_n_s_reduce_ex, __pyx_k_reduce_ex, sizeof(__pyx_k_reduce_ex), 0, 0, 1, 1}, + {&__pyx_n_s_register, __pyx_k_register, sizeof(__pyx_k_register), 0, 0, 1, 1}, + {&__pyx_n_s_scale, __pyx_k_scale, sizeof(__pyx_k_scale), 0, 0, 1, 1}, + {&__pyx_n_s_seed, __pyx_k_seed, sizeof(__pyx_k_seed), 0, 0, 1, 1}, + {&__pyx_kp_s_self_bvh_closest_indexes_self_pr, __pyx_k_self_bvh_closest_indexes_self_pr, sizeof(__pyx_k_self_bvh_closest_indexes_self_pr), 0, 0, 1, 0}, + {&__pyx_kp_s_self_centroids_self_face_normals, __pyx_k_self_centroids_self_face_normals, sizeof(__pyx_k_self_centroids_self_face_normals), 0, 0, 1, 0}, + {&__pyx_n_s_send, __pyx_k_send, sizeof(__pyx_k_send), 0, 0, 1, 1}, + {&__pyx_n_s_set, __pyx_k_set, sizeof(__pyx_k_set), 0, 0, 1, 1}, + {&__pyx_n_s_set_bvh, __pyx_k_set_bvh, sizeof(__pyx_k_set_bvh), 0, 0, 1, 1}, + {&__pyx_n_s_set_force, __pyx_k_set_force, sizeof(__pyx_k_set_force), 0, 0, 1, 1}, + {&__pyx_n_s_setstate, __pyx_k_setstate, sizeof(__pyx_k_setstate), 0, 0, 1, 1}, + {&__pyx_n_s_setstate_cython, __pyx_k_setstate_cython, sizeof(__pyx_k_setstate_cython), 0, 0, 1, 1}, + {&__pyx_n_s_size, __pyx_k_size, sizeof(__pyx_k_size), 0, 0, 1, 1}, + {&__pyx_n_s_smooth, __pyx_k_smooth, sizeof(__pyx_k_smooth), 0, 0, 1, 1}, + {&__pyx_n_s_snapping_mode, __pyx_k_snapping_mode, sizeof(__pyx_k_snapping_mode), 0, 0, 1, 1}, + {&__pyx_n_s_soft_spring_force, __pyx_k_soft_spring_force, sizeof(__pyx_k_soft_spring_force), 0, 0, 1, 1}, + {&__pyx_n_s_softwrap_core2, __pyx_k_softwrap_core2, sizeof(__pyx_k_softwrap_core2), 0, 0, 1, 1}, + {&__pyx_n_s_springs, __pyx_k_springs, sizeof(__pyx_k_springs), 0, 0, 1, 1}, + {&__pyx_n_s_start_index, __pyx_k_start_index, sizeof(__pyx_k_start_index), 0, 0, 1, 1}, + {&__pyx_n_s_stiff_spring_force, __pyx_k_stiff_spring_force, sizeof(__pyx_k_stiff_spring_force), 0, 0, 1, 1}, + {&__pyx_n_s_store, __pyx_k_store, sizeof(__pyx_k_store), 0, 0, 1, 1}, + {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1}, + {&__pyx_n_s_throw, __pyx_k_throw, sizeof(__pyx_k_throw), 0, 0, 1, 1}, + {&__pyx_n_s_traceback, __pyx_k_traceback, sizeof(__pyx_k_traceback), 0, 0, 1, 1}, + {&__pyx_n_s_triangles, __pyx_k_triangles, sizeof(__pyx_k_triangles), 0, 0, 1, 1}, + {&__pyx_n_s_type, __pyx_k_type, sizeof(__pyx_k_type), 0, 0, 1, 1}, + {&__pyx_n_s_update_mesh_normals, __pyx_k_update_mesh_normals, sizeof(__pyx_k_update_mesh_normals), 0, 0, 1, 1}, + {&__pyx_n_s_value, __pyx_k_value, sizeof(__pyx_k_value), 0, 0, 1, 1}, + {&__pyx_kp_u_vec_data_must_have_the_same_numb, __pyx_k_vec_data_must_have_the_same_numb, sizeof(__pyx_k_vec_data_must_have_the_same_numb), 0, 1, 0, 0}, + {&__pyx_n_s_verts, __pyx_k_verts, sizeof(__pyx_k_verts), 0, 0, 1, 1}, + {&__pyx_n_s_x, __pyx_k_x, sizeof(__pyx_k_x), 0, 0, 1, 1}, + {&__pyx_n_s_y, __pyx_k_y, sizeof(__pyx_k_y), 0, 0, 1, 1}, + {&__pyx_n_s_z, __pyx_k_z, sizeof(__pyx_k_z), 0, 0, 1, 1}, + {0, 0, 0, 0, 0, 0, 0} +}; +static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) { + __pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s_MemoryError); if (!__pyx_builtin_MemoryError) __PYX_ERR(0, 268, __pyx_L1_error) + __pyx_builtin_print = __Pyx_GetBuiltinName(__pyx_n_s_print); if (!__pyx_builtin_print) __PYX_ERR(0, 290, __pyx_L1_error) + __pyx_builtin_hex = __Pyx_GetBuiltinName(__pyx_n_s_hex); if (!__pyx_builtin_hex) __PYX_ERR(0, 292, __pyx_L1_error) + __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 302, __pyx_L1_error) + __pyx_builtin_IndexError = __Pyx_GetBuiltinName(__pyx_n_s_IndexError); if (!__pyx_builtin_IndexError) __PYX_ERR(0, 323, __pyx_L1_error) + __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(0, 347, __pyx_L1_error) + __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(1, 2, __pyx_L1_error) + __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s_enumerate); if (!__pyx_builtin_enumerate) __PYX_ERR(0, 1150, __pyx_L1_error) + __pyx_builtin_KeyError = __Pyx_GetBuiltinName(__pyx_n_s_KeyError); if (!__pyx_builtin_KeyError) __PYX_ERR(0, 1350, __pyx_L1_error) + __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s_RuntimeError); if (!__pyx_builtin_RuntimeError) __PYX_ERR(0, 1469, __pyx_L1_error) + __pyx_builtin_OverflowError = __Pyx_GetBuiltinName(__pyx_n_s_OverflowError); if (!__pyx_builtin_OverflowError) __PYX_ERR(1, 81, __pyx_L1_error) + return 0; + __pyx_L1_error:; + return -1; +} + +static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); + + /* "core/core2.pyx":290 + * + * if not_freed_pointers: + * print('\n ------------ Oops Softwrap2 memory leak detected ------------ \n pointers not freed:') # <<<<<<<<<<<<<< + * for ptr, line in not_freed_pointers.items(): + * print(f' ptr: {hex(ptr)}, core2.pyx:{line}') + */ + +# line 290 "core/core2.pyx" + __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_u_Oops_Softwrap2_memory_leak_dete); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 290, __pyx_L1_error) + +# line 290 "core/core2.pyx" + __Pyx_GOTREF(__pyx_tuple_); + +# line 290 "core/core2.pyx" + __Pyx_GIVEREF(__pyx_tuple_); + + /* "core/core2.pyx":293 + * for ptr, line in not_freed_pointers.items(): + * print(f' ptr: {hex(ptr)}, core2.pyx:{line}') + * print('\n -------------------------------------------------------------') # <<<<<<<<<<<<<< + * + * + */ + +# line 293 "core/core2.pyx" + __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_u__2); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 293, __pyx_L1_error) + +# line 293 "core/core2.pyx" + __Pyx_GOTREF(__pyx_tuple__3); + +# line 293 "core/core2.pyx" + __Pyx_GIVEREF(__pyx_tuple__3); + + /* "core/core2.pyx":347 + * + * if len(verts) < 3 or len(triangles) < 1: + * raise ValueError('Invalid or empty mesh') # <<<<<<<<<<<<<< + * + * self.verts = maelloc(sizeof(vec3) * self.n_verts, __LINE__) + */ + +# line 347 "core/core2.pyx" + __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_u_Invalid_or_empty_mesh); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 347, __pyx_L1_error) + +# line 347 "core/core2.pyx" + __Pyx_GOTREF(__pyx_tuple__4); + +# line 347 "core/core2.pyx" + __Pyx_GIVEREF(__pyx_tuple__4); + + /* "(tree fragment)":2 + * def __reduce_cython__(self): + * raise TypeError("self.centroids,self.face_normals,self.triangles,self.vert_normals,self.verts cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<< + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("self.centroids,self.face_normals,self.triangles,self.vert_normals,self.verts cannot be converted to a Python object for pickling") + */ + __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_s_self_centroids_self_face_normals); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(1, 2, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__5); + __Pyx_GIVEREF(__pyx_tuple__5); + + /* "(tree fragment)":4 + * raise TypeError("self.centroids,self.face_normals,self.triangles,self.vert_normals,self.verts cannot be converted to a Python object for pickling") + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("self.centroids,self.face_normals,self.triangles,self.vert_normals,self.verts cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<< + */ + __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_s_self_centroids_self_face_normals); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(1, 4, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__6); + __Pyx_GIVEREF(__pyx_tuple__6); + + /* "(tree fragment)":2 + * def __reduce_cython__(self): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + */ + __pyx_tuple__7 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(1, 2, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__7); + __Pyx_GIVEREF(__pyx_tuple__7); + + /* "(tree fragment)":4 + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< + */ + __pyx_tuple__8 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(1, 4, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__8); + __Pyx_GIVEREF(__pyx_tuple__8); + + /* "(tree fragment)":2 + * def __reduce_cython__(self): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + */ + __pyx_tuple__9 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(1, 2, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__9); + __Pyx_GIVEREF(__pyx_tuple__9); + + /* "(tree fragment)":4 + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< + */ + __pyx_tuple__10 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(1, 4, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__10); + __Pyx_GIVEREF(__pyx_tuple__10); + + /* "(tree fragment)":2 + * def __reduce_cython__(self): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + */ + __pyx_tuple__11 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(1, 2, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__11); + __Pyx_GIVEREF(__pyx_tuple__11); + + /* "(tree fragment)":4 + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< + */ + __pyx_tuple__12 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(1, 4, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__12); + __Pyx_GIVEREF(__pyx_tuple__12); + + /* "(tree fragment)":2 + * def __reduce_cython__(self): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + */ + __pyx_tuple__13 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(1, 2, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__13); + __Pyx_GIVEREF(__pyx_tuple__13); + + /* "(tree fragment)":4 + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< + */ + __pyx_tuple__14 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(1, 4, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__14); + __Pyx_GIVEREF(__pyx_tuple__14); + + /* "(tree fragment)":2 + * def __reduce_cython__(self): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + */ + __pyx_tuple__15 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(1, 2, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__15); + __Pyx_GIVEREF(__pyx_tuple__15); + + /* "(tree fragment)":4 + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< + */ + __pyx_tuple__16 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__16)) __PYX_ERR(1, 4, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__16); + __Pyx_GIVEREF(__pyx_tuple__16); + + /* "core/core2.pyx":1120 + * + * if start_index < 0 or start_index >= self.engine.n_verts: + * raise ValueError('invalid start_index') # <<<<<<<<<<<<<< + * + * self.start_index = start_index + */ + +# line 1120 "core/core2.pyx" + __pyx_tuple__17 = PyTuple_Pack(1, __pyx_kp_u_invalid_start_index); if (unlikely(!__pyx_tuple__17)) __PYX_ERR(0, 1120, __pyx_L1_error) + +# line 1120 "core/core2.pyx" + __Pyx_GOTREF(__pyx_tuple__17); + +# line 1120 "core/core2.pyx" + __Pyx_GIVEREF(__pyx_tuple__17); + + /* "core/core2.pyx":1161 + * raise IndexError + * + * def iter_ring(): # <<<<<<<<<<<<<< + * cdef int i + * for i in range(self.rings[index][0]): + */ + +# line 1161 "core/core2.pyx" + __pyx_tuple__18 = PyTuple_Pack(1, __pyx_n_s_i); if (unlikely(!__pyx_tuple__18)) __PYX_ERR(0, 1161, __pyx_L1_error) + +# line 1161 "core/core2.pyx" + __Pyx_GOTREF(__pyx_tuple__18); + +# line 1161 "core/core2.pyx" + __Pyx_GIVEREF(__pyx_tuple__18); + +# line 1161 "core/core2.pyx" + __pyx_codeobj__19 = (PyObject*)__Pyx_PyCode_New(0, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__18, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_core_core2_pyx, __pyx_n_s_iter_ring, 1161, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__19)) __PYX_ERR(0, 1161, __pyx_L1_error) + + /* "(tree fragment)":2 + * def __reduce_cython__(self): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + */ + __pyx_tuple__20 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__20)) __PYX_ERR(1, 2, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__20); + __Pyx_GIVEREF(__pyx_tuple__20); + + /* "(tree fragment)":4 + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< + */ + __pyx_tuple__21 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__21)) __PYX_ERR(1, 4, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__21); + __Pyx_GIVEREF(__pyx_tuple__21); + + /* "(tree fragment)":2 + * def __reduce_cython__(self): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + */ + __pyx_tuple__22 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__22)) __PYX_ERR(1, 2, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__22); + __Pyx_GIVEREF(__pyx_tuple__22); + + /* "(tree fragment)":4 + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< + */ + __pyx_tuple__23 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__23)) __PYX_ERR(1, 4, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__23); + __Pyx_GIVEREF(__pyx_tuple__23); + + /* "core/core2.pyx":1225 + * + * elif not len(mask) == engine.n_verts: + * raise ValueError('mask must have the same number of elements as engine verts') # <<<<<<<<<<<<<< + * + * self.mask = maelloc(sizeof(float) * self.engine.n_verts, __LINE__) + */ + +# line 1225 "core/core2.pyx" + __pyx_tuple__24 = PyTuple_Pack(1, __pyx_kp_u_mask_must_have_the_same_number_o); if (unlikely(!__pyx_tuple__24)) __PYX_ERR(0, 1225, __pyx_L1_error) + +# line 1225 "core/core2.pyx" + __Pyx_GOTREF(__pyx_tuple__24); + +# line 1225 "core/core2.pyx" + __Pyx_GIVEREF(__pyx_tuple__24); + + /* "core/core2.pyx":1298 + * cdef int i + * if not len(vec_data) == self.engine.n_verts * 3: + * raise ValueError('vec_data must have the same number of elements as engine verts times 3') # <<<<<<<<<<<<<< + * + * for i in range(self.engine.n_verts * 3): + */ + +# line 1298 "core/core2.pyx" + __pyx_tuple__25 = PyTuple_Pack(1, __pyx_kp_u_vec_data_must_have_the_same_numb); if (unlikely(!__pyx_tuple__25)) __PYX_ERR(0, 1298, __pyx_L1_error) + +# line 1298 "core/core2.pyx" + __Pyx_GOTREF(__pyx_tuple__25); + +# line 1298 "core/core2.pyx" + __Pyx_GIVEREF(__pyx_tuple__25); + + /* "(tree fragment)":2 + * def __reduce_cython__(self): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + */ + __pyx_tuple__26 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__26)) __PYX_ERR(1, 2, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__26); + __Pyx_GIVEREF(__pyx_tuple__26); + + /* "(tree fragment)":4 + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< + */ + __pyx_tuple__27 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__27)) __PYX_ERR(1, 4, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__27); + __Pyx_GIVEREF(__pyx_tuple__27); + + /* "(tree fragment)":2 + * def __reduce_cython__(self): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + */ + __pyx_tuple__28 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__28)) __PYX_ERR(1, 2, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__28); + __Pyx_GIVEREF(__pyx_tuple__28); + + /* "(tree fragment)":4 + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< + */ + __pyx_tuple__29 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__29)) __PYX_ERR(1, 4, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__29); + __Pyx_GIVEREF(__pyx_tuple__29); + + /* "core/core2.pyx":1425 + * def from_list(self, list items): + * if not len(items) >= self.n_verts * 3: + * raise ValueError('list too small') # <<<<<<<<<<<<<< + * + * cdef int i + */ + +# line 1425 "core/core2.pyx" + __pyx_tuple__30 = PyTuple_Pack(1, __pyx_kp_u_list_too_small); if (unlikely(!__pyx_tuple__30)) __PYX_ERR(0, 1425, __pyx_L1_error) + +# line 1425 "core/core2.pyx" + __Pyx_GOTREF(__pyx_tuple__30); + +# line 1425 "core/core2.pyx" + __Pyx_GIVEREF(__pyx_tuple__30); + + /* "core/core2.pyx":1436 + * cdef float x, y, z + * if not len(indexes) == len(locations): + * raise ValueError('indexes array is not the same size as locations array') # <<<<<<<<<<<<<< + * + * for i in range(len(indexes)): + */ + +# line 1436 "core/core2.pyx" + __pyx_tuple__31 = PyTuple_Pack(1, __pyx_kp_u_indexes_array_is_not_the_same_si); if (unlikely(!__pyx_tuple__31)) __PYX_ERR(0, 1436, __pyx_L1_error) + +# line 1436 "core/core2.pyx" + __Pyx_GOTREF(__pyx_tuple__31); + +# line 1436 "core/core2.pyx" + __Pyx_GIVEREF(__pyx_tuple__31); + + /* "core/core2.pyx":1469 + * + * if not self.bvh: + * raise RuntimeError('No bvh avaliable') # <<<<<<<<<<<<<< + * + * cycle_quality = nabs(cycle_quality) + */ + +# line 1469 "core/core2.pyx" + __pyx_tuple__32 = PyTuple_Pack(1, __pyx_kp_u_No_bvh_avaliable); if (unlikely(!__pyx_tuple__32)) __PYX_ERR(0, 1469, __pyx_L1_error) + +# line 1469 "core/core2.pyx" + __Pyx_GOTREF(__pyx_tuple__32); + +# line 1469 "core/core2.pyx" + __Pyx_GIVEREF(__pyx_tuple__32); + + /* "(tree fragment)":2 + * def __reduce_cython__(self): + * raise TypeError("self.bvh_closest_indexes,self.prev_verts,self.tmp_verts cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<< + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("self.bvh_closest_indexes,self.prev_verts,self.tmp_verts cannot be converted to a Python object for pickling") + */ + __pyx_tuple__33 = PyTuple_Pack(1, __pyx_kp_s_self_bvh_closest_indexes_self_pr); if (unlikely(!__pyx_tuple__33)) __PYX_ERR(1, 2, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__33); + __Pyx_GIVEREF(__pyx_tuple__33); + + /* "(tree fragment)":4 + * raise TypeError("self.bvh_closest_indexes,self.prev_verts,self.tmp_verts cannot be converted to a Python object for pickling") + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("self.bvh_closest_indexes,self.prev_verts,self.tmp_verts cannot be converted to a Python object for pickling") # <<<<<<<<<<<<<< + */ + __pyx_tuple__34 = PyTuple_Pack(1, __pyx_kp_s_self_bvh_closest_indexes_self_pr); if (unlikely(!__pyx_tuple__34)) __PYX_ERR(1, 4, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__34); + __Pyx_GIVEREF(__pyx_tuple__34); + + /* "core/core2.pyx":285 + * + * + * def leak_check(): # <<<<<<<<<<<<<< + * import gc + * gc.collect() + */ + +# line 285 "core/core2.pyx" + __pyx_tuple__35 = PyTuple_Pack(3, __pyx_n_s_gc, __pyx_n_s_ptr_2, __pyx_n_s_line); if (unlikely(!__pyx_tuple__35)) __PYX_ERR(0, 285, __pyx_L1_error) + +# line 285 "core/core2.pyx" + __Pyx_GOTREF(__pyx_tuple__35); + +# line 285 "core/core2.pyx" + __Pyx_GIVEREF(__pyx_tuple__35); + +# line 285 "core/core2.pyx" + __pyx_codeobj__36 = (PyObject*)__Pyx_PyCode_New(0, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__35, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_core_core2_pyx, __pyx_n_s_leak_check, 285, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__36)) __PYX_ERR(0, 285, __pyx_L1_error) + +# line 285 "core/core2.pyx" + __Pyx_RefNannyFinishContext(); + +# line 285 "core/core2.pyx" + return 0; + +# line 285 "core/core2.pyx" + __pyx_L1_error:; + +# line 285 "core/core2.pyx" + __Pyx_RefNannyFinishContext(); + +# line 285 "core/core2.pyx" + return -1; + +# line 285 "core/core2.pyx" +} + + +# line 285 "core/core2.pyx" +static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) { + /* InitThreads.init */ + #if defined(WITH_THREAD) && PY_VERSION_HEX < 0x030700F0 +PyEval_InitThreads(); +#endif + +if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1, __pyx_L1_error) + + if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error); + __pyx_float_0_0 = PyFloat_FromDouble(0.0); if (unlikely(!__pyx_float_0_0)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_int_4 = PyInt_FromLong(4); if (unlikely(!__pyx_int_4)) __PYX_ERR(0, 1, __pyx_L1_error) + return 0; + __pyx_L1_error:; + return -1; +} + +static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/ +static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/ +static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/ +static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/ +static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/ +static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/ +static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/ + +static int __Pyx_modinit_global_init_code(void) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0); + /*--- Global init code ---*/ + __pyx_v_14softwrap_core2_not_freed_pointers = ((PyObject*)Py_None); Py_INCREF(Py_None); + __Pyx_RefNannyFinishContext(); + return 0; +} + +static int __Pyx_modinit_variable_export_code(void) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0); + /*--- Variable export code ---*/ + __Pyx_RefNannyFinishContext(); + return 0; +} + +static int __Pyx_modinit_function_export_code(void) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0); + /*--- Function export code ---*/ + __Pyx_RefNannyFinishContext(); + return 0; +} + +static int __Pyx_modinit_type_init_code(void) { + __Pyx_RefNannyDeclarations + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0); + /*--- Type init code ---*/ + __pyx_vtabptr_14softwrap_core2_Mesh = &__pyx_vtable_14softwrap_core2_Mesh; + __pyx_vtable_14softwrap_core2_Mesh.tri_vert_ptr = (vec3 *(*)(struct __pyx_obj_14softwrap_core2_Mesh *, int, int))__pyx_f_14softwrap_core2_4Mesh_tri_vert_ptr; + __pyx_vtable_14softwrap_core2_Mesh.tri_vert = (vec3 (*)(struct __pyx_obj_14softwrap_core2_Mesh *, int, int))__pyx_f_14softwrap_core2_4Mesh_tri_vert; + __pyx_vtable_14softwrap_core2_Mesh.update_face_normals = (void (*)(struct __pyx_obj_14softwrap_core2_Mesh *, int __pyx_skip_dispatch))__pyx_f_14softwrap_core2_4Mesh_update_face_normals; + __pyx_vtable_14softwrap_core2_Mesh.update_vert_normals = (void (*)(struct __pyx_obj_14softwrap_core2_Mesh *, int __pyx_skip_dispatch))__pyx_f_14softwrap_core2_4Mesh_update_vert_normals; + __pyx_vtable_14softwrap_core2_Mesh.update_centroids = (void (*)(struct __pyx_obj_14softwrap_core2_Mesh *, int __pyx_skip_dispatch))__pyx_f_14softwrap_core2_4Mesh_update_centroids; + if (PyType_Ready(&__pyx_type_14softwrap_core2_Mesh) < 0) __PYX_ERR(0, 326, __pyx_L1_error) + #if PY_VERSION_HEX < 0x030800B1 + __pyx_type_14softwrap_core2_Mesh.tp_print = 0; + #endif + if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_14softwrap_core2_Mesh.tp_dictoffset && __pyx_type_14softwrap_core2_Mesh.tp_getattro == PyObject_GenericGetAttr)) { + __pyx_type_14softwrap_core2_Mesh.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict; + } + if (__Pyx_SetVtable(__pyx_type_14softwrap_core2_Mesh.tp_dict, __pyx_vtabptr_14softwrap_core2_Mesh) < 0) __PYX_ERR(0, 326, __pyx_L1_error) + if (PyObject_SetAttr(__pyx_m, __pyx_n_s_Mesh, (PyObject *)&__pyx_type_14softwrap_core2_Mesh) < 0) __PYX_ERR(0, 326, __pyx_L1_error) + if (__Pyx_setup_reduce((PyObject*)&__pyx_type_14softwrap_core2_Mesh) < 0) __PYX_ERR(0, 326, __pyx_L1_error) + __pyx_ptype_14softwrap_core2_Mesh = &__pyx_type_14softwrap_core2_Mesh; + __pyx_vtabptr_14softwrap_core2_BVH = &__pyx_vtable_14softwrap_core2_BVH; + __pyx_vtable_14softwrap_core2_BVH.pop_box = (BvhNodeBox *(*)(struct __pyx_obj_14softwrap_core2_BVH *))__pyx_f_14softwrap_core2_3BVH_pop_box; + __pyx_vtable_14softwrap_core2_BVH.build_tree = (union BvhNode *(*)(struct __pyx_obj_14softwrap_core2_BVH *, BvhNodeLeaf *, int))__pyx_f_14softwrap_core2_3BVH_build_tree; + __pyx_vtable_14softwrap_core2_BVH._find_nearest = (struct BvhNearestResult (*)(struct __pyx_obj_14softwrap_core2_BVH *, vec3))__pyx_f_14softwrap_core2_3BVH__find_nearest; + __pyx_vtable_14softwrap_core2_BVH.find_nearest_recursive = (void (*)(struct __pyx_obj_14softwrap_core2_BVH *, vec3 *, struct BvhNearestResult *, union BvhNode *))__pyx_f_14softwrap_core2_3BVH_find_nearest_recursive; + if (PyType_Ready(&__pyx_type_14softwrap_core2_BVH) < 0) __PYX_ERR(0, 554, __pyx_L1_error) + #if PY_VERSION_HEX < 0x030800B1 + __pyx_type_14softwrap_core2_BVH.tp_print = 0; + #endif + if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_14softwrap_core2_BVH.tp_dictoffset && __pyx_type_14softwrap_core2_BVH.tp_getattro == PyObject_GenericGetAttr)) { + __pyx_type_14softwrap_core2_BVH.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict; + } + if (__Pyx_SetVtable(__pyx_type_14softwrap_core2_BVH.tp_dict, __pyx_vtabptr_14softwrap_core2_BVH) < 0) __PYX_ERR(0, 554, __pyx_L1_error) + if (PyObject_SetAttr(__pyx_m, __pyx_n_s_BVH, (PyObject *)&__pyx_type_14softwrap_core2_BVH) < 0) __PYX_ERR(0, 554, __pyx_L1_error) + if (__Pyx_setup_reduce((PyObject*)&__pyx_type_14softwrap_core2_BVH) < 0) __PYX_ERR(0, 554, __pyx_L1_error) + __pyx_ptype_14softwrap_core2_BVH = &__pyx_type_14softwrap_core2_BVH; + if (PyType_Ready(&__pyx_type_14softwrap_core2_LinkProbe) < 0) __PYX_ERR(0, 712, __pyx_L1_error) + #if PY_VERSION_HEX < 0x030800B1 + __pyx_type_14softwrap_core2_LinkProbe.tp_print = 0; + #endif + if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_14softwrap_core2_LinkProbe.tp_dictoffset && __pyx_type_14softwrap_core2_LinkProbe.tp_getattro == PyObject_GenericGetAttr)) { + __pyx_type_14softwrap_core2_LinkProbe.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict; + } + if (PyObject_SetAttr(__pyx_m, __pyx_n_s_LinkProbe, (PyObject *)&__pyx_type_14softwrap_core2_LinkProbe) < 0) __PYX_ERR(0, 712, __pyx_L1_error) + if (__Pyx_setup_reduce((PyObject*)&__pyx_type_14softwrap_core2_LinkProbe) < 0) __PYX_ERR(0, 712, __pyx_L1_error) + __pyx_ptype_14softwrap_core2_LinkProbe = &__pyx_type_14softwrap_core2_LinkProbe; + __pyx_vtabptr_14softwrap_core2_SpringLinks = &__pyx_vtable_14softwrap_core2_SpringLinks; + __pyx_vtable_14softwrap_core2_SpringLinks.lengths_update = (void (*)(struct __pyx_obj_14softwrap_core2_SpringLinks *, int __pyx_skip_dispatch))__pyx_f_14softwrap_core2_11SpringLinks_lengths_update; + __pyx_vtable_14softwrap_core2_SpringLinks.smooth = (void (*)(struct __pyx_obj_14softwrap_core2_SpringLinks *, float, int __pyx_skip_dispatch))__pyx_f_14softwrap_core2_11SpringLinks_smooth; + __pyx_vtable_14softwrap_core2_SpringLinks.soft_spring_force = (void (*)(struct __pyx_obj_14softwrap_core2_SpringLinks *, float, int __pyx_skip_dispatch, struct __pyx_opt_args_14softwrap_core2_11SpringLinks_soft_spring_force *__pyx_optional_args))__pyx_f_14softwrap_core2_11SpringLinks_soft_spring_force; + __pyx_vtable_14softwrap_core2_SpringLinks.stiff_spring_force = (void (*)(struct __pyx_obj_14softwrap_core2_SpringLinks *, float, int __pyx_skip_dispatch))__pyx_f_14softwrap_core2_11SpringLinks_stiff_spring_force; + if (PyType_Ready(&__pyx_type_14softwrap_core2_SpringLinks) < 0) __PYX_ERR(0, 747, __pyx_L1_error) + #if PY_VERSION_HEX < 0x030800B1 + __pyx_type_14softwrap_core2_SpringLinks.tp_print = 0; + #endif + if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_14softwrap_core2_SpringLinks.tp_dictoffset && __pyx_type_14softwrap_core2_SpringLinks.tp_getattro == PyObject_GenericGetAttr)) { + __pyx_type_14softwrap_core2_SpringLinks.tp_getattro = __Pyx_PyObject_GenericGetAttr; + } + if (__Pyx_SetVtable(__pyx_type_14softwrap_core2_SpringLinks.tp_dict, __pyx_vtabptr_14softwrap_core2_SpringLinks) < 0) __PYX_ERR(0, 747, __pyx_L1_error) + if (PyObject_SetAttr(__pyx_m, __pyx_n_s_SpringLinks, (PyObject *)&__pyx_type_14softwrap_core2_SpringLinks) < 0) __PYX_ERR(0, 747, __pyx_L1_error) + if (__Pyx_setup_reduce((PyObject*)&__pyx_type_14softwrap_core2_SpringLinks) < 0) __PYX_ERR(0, 747, __pyx_L1_error) + __pyx_ptype_14softwrap_core2_SpringLinks = &__pyx_type_14softwrap_core2_SpringLinks; + __pyx_vtabptr_14softwrap_core2_TernarySmoothingLinks = &__pyx_vtable_14softwrap_core2_TernarySmoothingLinks; + __pyx_vtable_14softwrap_core2_TernarySmoothingLinks.displacements_update = (void (*)(struct __pyx_obj_14softwrap_core2_TernarySmoothingLinks *, int __pyx_skip_dispatch))__pyx_f_14softwrap_core2_21TernarySmoothingLinks_displacements_update; + __pyx_vtable_14softwrap_core2_TernarySmoothingLinks.displacement_force = (void (*)(struct __pyx_obj_14softwrap_core2_TernarySmoothingLinks *, float, int __pyx_skip_dispatch))__pyx_f_14softwrap_core2_21TernarySmoothingLinks_displacement_force; + if (PyType_Ready(&__pyx_type_14softwrap_core2_TernarySmoothingLinks) < 0) __PYX_ERR(0, 915, __pyx_L1_error) + #if PY_VERSION_HEX < 0x030800B1 + __pyx_type_14softwrap_core2_TernarySmoothingLinks.tp_print = 0; + #endif + if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_14softwrap_core2_TernarySmoothingLinks.tp_dictoffset && __pyx_type_14softwrap_core2_TernarySmoothingLinks.tp_getattro == PyObject_GenericGetAttr)) { + __pyx_type_14softwrap_core2_TernarySmoothingLinks.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict; + } + if (__Pyx_SetVtable(__pyx_type_14softwrap_core2_TernarySmoothingLinks.tp_dict, __pyx_vtabptr_14softwrap_core2_TernarySmoothingLinks) < 0) __PYX_ERR(0, 915, __pyx_L1_error) + if (PyObject_SetAttr(__pyx_m, __pyx_n_s_TernarySmoothingLinks, (PyObject *)&__pyx_type_14softwrap_core2_TernarySmoothingLinks) < 0) __PYX_ERR(0, 915, __pyx_L1_error) + if (__Pyx_setup_reduce((PyObject*)&__pyx_type_14softwrap_core2_TernarySmoothingLinks) < 0) __PYX_ERR(0, 915, __pyx_L1_error) + __pyx_ptype_14softwrap_core2_TernarySmoothingLinks = &__pyx_type_14softwrap_core2_TernarySmoothingLinks; + __pyx_vtabptr_14softwrap_core2_QuaternarySmoothingLinks = &__pyx_vtable_14softwrap_core2_QuaternarySmoothingLinks; + __pyx_vtable_14softwrap_core2_QuaternarySmoothingLinks.lengths_update = (void (*)(struct __pyx_obj_14softwrap_core2_QuaternarySmoothingLinks *, int __pyx_skip_dispatch))__pyx_f_14softwrap_core2_24QuaternarySmoothingLinks_lengths_update; + __pyx_vtable_14softwrap_core2_QuaternarySmoothingLinks.smooth = (void (*)(struct __pyx_obj_14softwrap_core2_QuaternarySmoothingLinks *, float, int __pyx_skip_dispatch, struct __pyx_opt_args_14softwrap_core2_24QuaternarySmoothingLinks_smooth *__pyx_optional_args))__pyx_f_14softwrap_core2_24QuaternarySmoothingLinks_smooth; + if (PyType_Ready(&__pyx_type_14softwrap_core2_QuaternarySmoothingLinks) < 0) __PYX_ERR(0, 1017, __pyx_L1_error) + #if PY_VERSION_HEX < 0x030800B1 + __pyx_type_14softwrap_core2_QuaternarySmoothingLinks.tp_print = 0; + #endif + if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_14softwrap_core2_QuaternarySmoothingLinks.tp_dictoffset && __pyx_type_14softwrap_core2_QuaternarySmoothingLinks.tp_getattro == PyObject_GenericGetAttr)) { + __pyx_type_14softwrap_core2_QuaternarySmoothingLinks.tp_getattro = __Pyx_PyObject_GenericGetAttr; + } + if (__Pyx_SetVtable(__pyx_type_14softwrap_core2_QuaternarySmoothingLinks.tp_dict, __pyx_vtabptr_14softwrap_core2_QuaternarySmoothingLinks) < 0) __PYX_ERR(0, 1017, __pyx_L1_error) + if (PyObject_SetAttr(__pyx_m, __pyx_n_s_QuaternarySmoothingLinks, (PyObject *)&__pyx_type_14softwrap_core2_QuaternarySmoothingLinks) < 0) __PYX_ERR(0, 1017, __pyx_L1_error) + if (__Pyx_setup_reduce((PyObject*)&__pyx_type_14softwrap_core2_QuaternarySmoothingLinks) < 0) __PYX_ERR(0, 1017, __pyx_L1_error) + __pyx_ptype_14softwrap_core2_QuaternarySmoothingLinks = &__pyx_type_14softwrap_core2_QuaternarySmoothingLinks; + if (PyType_Ready(&__pyx_type_14softwrap_core2_SpringEnginePin) < 0) __PYX_ERR(0, 1108, __pyx_L1_error) + #if PY_VERSION_HEX < 0x030800B1 + __pyx_type_14softwrap_core2_SpringEnginePin.tp_print = 0; + #endif + if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_14softwrap_core2_SpringEnginePin.tp_dictoffset && __pyx_type_14softwrap_core2_SpringEnginePin.tp_getattro == PyObject_GenericGetAttr)) { + __pyx_type_14softwrap_core2_SpringEnginePin.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict; + } + if (PyObject_SetAttr(__pyx_m, __pyx_n_s_SpringEnginePin, (PyObject *)&__pyx_type_14softwrap_core2_SpringEnginePin) < 0) __PYX_ERR(0, 1108, __pyx_L1_error) + if (__Pyx_setup_reduce((PyObject*)&__pyx_type_14softwrap_core2_SpringEnginePin) < 0) __PYX_ERR(0, 1108, __pyx_L1_error) + __pyx_ptype_14softwrap_core2_SpringEnginePin = &__pyx_type_14softwrap_core2_SpringEnginePin; + if (PyType_Ready(&__pyx_type_14softwrap_core2__MaskContextManager) < 0) __PYX_ERR(0, 1192, __pyx_L1_error) + #if PY_VERSION_HEX < 0x030800B1 + __pyx_type_14softwrap_core2__MaskContextManager.tp_print = 0; + #endif + if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_14softwrap_core2__MaskContextManager.tp_dictoffset && __pyx_type_14softwrap_core2__MaskContextManager.tp_getattro == PyObject_GenericGetAttr)) { + __pyx_type_14softwrap_core2__MaskContextManager.tp_getattro = __Pyx_PyObject_GenericGetAttr; + } + if (PyObject_SetAttr(__pyx_m, __pyx_n_s_MaskContextManager, (PyObject *)&__pyx_type_14softwrap_core2__MaskContextManager) < 0) __PYX_ERR(0, 1192, __pyx_L1_error) + if (__Pyx_setup_reduce((PyObject*)&__pyx_type_14softwrap_core2__MaskContextManager) < 0) __PYX_ERR(0, 1192, __pyx_L1_error) + __pyx_ptype_14softwrap_core2__MaskContextManager = &__pyx_type_14softwrap_core2__MaskContextManager; + __pyx_vtabptr_14softwrap_core2_SpringEngineMask = &__pyx_vtable_14softwrap_core2_SpringEngineMask; + __pyx_vtable_14softwrap_core2_SpringEngineMask.set_force = (PyObject *(*)(struct __pyx_obj_14softwrap_core2_SpringEngineMask *, float, float, float, int __pyx_skip_dispatch))__pyx_f_14softwrap_core2_16SpringEngineMask_set_force; + __pyx_vtable_14softwrap_core2_SpringEngineMask.load = (void (*)(struct __pyx_obj_14softwrap_core2_SpringEngineMask *, int __pyx_skip_dispatch))__pyx_f_14softwrap_core2_16SpringEngineMask_load; + __pyx_vtable_14softwrap_core2_SpringEngineMask.store = (void (*)(struct __pyx_obj_14softwrap_core2_SpringEngineMask *, int __pyx_skip_dispatch))__pyx_f_14softwrap_core2_16SpringEngineMask_store; + __pyx_vtable_14softwrap_core2_SpringEngineMask.masked_store = (void (*)(struct __pyx_obj_14softwrap_core2_SpringEngineMask *, int __pyx_skip_dispatch, struct __pyx_opt_args_14softwrap_core2_16SpringEngineMask_masked_store *__pyx_optional_args))__pyx_f_14softwrap_core2_16SpringEngineMask_masked_store; + __pyx_vtable_14softwrap_core2_SpringEngineMask.set = (PyObject *(*)(struct __pyx_obj_14softwrap_core2_SpringEngineMask *, PyObject *, int __pyx_skip_dispatch))__pyx_f_14softwrap_core2_16SpringEngineMask_set; + if (PyType_Ready(&__pyx_type_14softwrap_core2_SpringEngineMask) < 0) __PYX_ERR(0, 1210, __pyx_L1_error) + #if PY_VERSION_HEX < 0x030800B1 + __pyx_type_14softwrap_core2_SpringEngineMask.tp_print = 0; + #endif + if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_14softwrap_core2_SpringEngineMask.tp_dictoffset && __pyx_type_14softwrap_core2_SpringEngineMask.tp_getattro == PyObject_GenericGetAttr)) { + __pyx_type_14softwrap_core2_SpringEngineMask.tp_getattro = __Pyx_PyObject_GenericGetAttr; + } + if (__Pyx_SetVtable(__pyx_type_14softwrap_core2_SpringEngineMask.tp_dict, __pyx_vtabptr_14softwrap_core2_SpringEngineMask) < 0) __PYX_ERR(0, 1210, __pyx_L1_error) + if (PyObject_SetAttr(__pyx_m, __pyx_n_s_SpringEngineMask, (PyObject *)&__pyx_type_14softwrap_core2_SpringEngineMask) < 0) __PYX_ERR(0, 1210, __pyx_L1_error) + if (__Pyx_setup_reduce((PyObject*)&__pyx_type_14softwrap_core2_SpringEngineMask) < 0) __PYX_ERR(0, 1210, __pyx_L1_error) + __pyx_ptype_14softwrap_core2_SpringEngineMask = &__pyx_type_14softwrap_core2_SpringEngineMask; + __pyx_vtabptr_14softwrap_core2_SymmetryMap = &__pyx_vtable_14softwrap_core2_SymmetryMap; + __pyx_vtable_14softwrap_core2_SymmetryMap.mirror = (void (*)(struct __pyx_obj_14softwrap_core2_SymmetryMap *, int, int, int, int __pyx_skip_dispatch))__pyx_f_14softwrap_core2_11SymmetryMap_mirror; + if (PyType_Ready(&__pyx_type_14softwrap_core2_SymmetryMap) < 0) __PYX_ERR(0, 1313, __pyx_L1_error) + #if PY_VERSION_HEX < 0x030800B1 + __pyx_type_14softwrap_core2_SymmetryMap.tp_print = 0; + #endif + if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_14softwrap_core2_SymmetryMap.tp_dictoffset && __pyx_type_14softwrap_core2_SymmetryMap.tp_getattro == PyObject_GenericGetAttr)) { + __pyx_type_14softwrap_core2_SymmetryMap.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict; + } + if (__Pyx_SetVtable(__pyx_type_14softwrap_core2_SymmetryMap.tp_dict, __pyx_vtabptr_14softwrap_core2_SymmetryMap) < 0) __PYX_ERR(0, 1313, __pyx_L1_error) + if (PyObject_SetAttr(__pyx_m, __pyx_n_s_SymmetryMap, (PyObject *)&__pyx_type_14softwrap_core2_SymmetryMap) < 0) __PYX_ERR(0, 1313, __pyx_L1_error) + if (__Pyx_setup_reduce((PyObject*)&__pyx_type_14softwrap_core2_SymmetryMap) < 0) __PYX_ERR(0, 1313, __pyx_L1_error) + __pyx_ptype_14softwrap_core2_SymmetryMap = &__pyx_type_14softwrap_core2_SymmetryMap; + __pyx_vtabptr_14softwrap_core2_SpringEngine = &__pyx_vtable_14softwrap_core2_SpringEngine; + __pyx_vtable_14softwrap_core2_SpringEngine.set_bvh = (void (*)(struct __pyx_obj_14softwrap_core2_SpringEngine *, struct __pyx_obj_14softwrap_core2_BVH *, int __pyx_skip_dispatch))__pyx_f_14softwrap_core2_12SpringEngine_set_bvh; + __pyx_vtable_14softwrap_core2_SpringEngine.create_spring_group = (struct __pyx_obj_14softwrap_core2_SpringLinks *(*)(struct __pyx_obj_14softwrap_core2_SpringEngine *, PyObject *, int __pyx_skip_dispatch))__pyx_f_14softwrap_core2_12SpringEngine_create_spring_group; + __pyx_vtable_14softwrap_core2_SpringEngine.create_symmetry_map = (struct __pyx_obj_14softwrap_core2_SymmetryMap *(*)(struct __pyx_obj_14softwrap_core2_SpringEngine *, int __pyx_skip_dispatch))__pyx_f_14softwrap_core2_12SpringEngine_create_symmetry_map; + __pyx_vtable_14softwrap_core2_SpringEngine.create_ternary_links = (struct __pyx_obj_14softwrap_core2_TernarySmoothingLinks *(*)(struct __pyx_obj_14softwrap_core2_SpringEngine *, PyObject *, int __pyx_skip_dispatch))__pyx_f_14softwrap_core2_12SpringEngine_create_ternary_links; + __pyx_vtable_14softwrap_core2_SpringEngine.create_quaternary_links = (struct __pyx_obj_14softwrap_core2_QuaternarySmoothingLinks *(*)(struct __pyx_obj_14softwrap_core2_SpringEngine *, PyObject *, int __pyx_skip_dispatch))__pyx_f_14softwrap_core2_12SpringEngine_create_quaternary_links; + __pyx_vtable_14softwrap_core2_SpringEngine.create_mask = (struct __pyx_obj_14softwrap_core2_SpringEngineMask *(*)(struct __pyx_obj_14softwrap_core2_SpringEngine *, PyObject *, int __pyx_skip_dispatch))__pyx_f_14softwrap_core2_12SpringEngine_create_mask; + __pyx_vtable_14softwrap_core2_SpringEngine.random_verts = (void (*)(struct __pyx_obj_14softwrap_core2_SpringEngine *, float, int __pyx_skip_dispatch, struct __pyx_opt_args_14softwrap_core2_12SpringEngine_random_verts *__pyx_optional_args))__pyx_f_14softwrap_core2_12SpringEngine_random_verts; + __pyx_vtable_14softwrap_core2_SpringEngine.kinetic_step = (void (*)(struct __pyx_obj_14softwrap_core2_SpringEngine *, float, int __pyx_skip_dispatch))__pyx_f_14softwrap_core2_12SpringEngine_kinetic_step; + __pyx_vtable_14softwrap_core2_SpringEngine.update_mesh_normals = (void (*)(struct __pyx_obj_14softwrap_core2_SpringEngine *, float, int __pyx_skip_dispatch))__pyx_f_14softwrap_core2_12SpringEngine_update_mesh_normals; + if (PyType_Ready(&__pyx_type_14softwrap_core2_SpringEngine) < 0) __PYX_ERR(0, 1376, __pyx_L1_error) + #if PY_VERSION_HEX < 0x030800B1 + __pyx_type_14softwrap_core2_SpringEngine.tp_print = 0; + #endif + if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_14softwrap_core2_SpringEngine.tp_dictoffset && __pyx_type_14softwrap_core2_SpringEngine.tp_getattro == PyObject_GenericGetAttr)) { + __pyx_type_14softwrap_core2_SpringEngine.tp_getattro = __Pyx_PyObject_GenericGetAttr; + } + if (__Pyx_SetVtable(__pyx_type_14softwrap_core2_SpringEngine.tp_dict, __pyx_vtabptr_14softwrap_core2_SpringEngine) < 0) __PYX_ERR(0, 1376, __pyx_L1_error) + if (PyObject_SetAttr(__pyx_m, __pyx_n_s_SpringEngine, (PyObject *)&__pyx_type_14softwrap_core2_SpringEngine) < 0) __PYX_ERR(0, 1376, __pyx_L1_error) + if (__Pyx_setup_reduce((PyObject*)&__pyx_type_14softwrap_core2_SpringEngine) < 0) __PYX_ERR(0, 1376, __pyx_L1_error) + __pyx_ptype_14softwrap_core2_SpringEngine = &__pyx_type_14softwrap_core2_SpringEngine; + if (PyType_Ready(&__pyx_type_14softwrap_core2___pyx_scope_struct____iter__) < 0) __PYX_ERR(0, 733, __pyx_L1_error) + #if PY_VERSION_HEX < 0x030800B1 + __pyx_type_14softwrap_core2___pyx_scope_struct____iter__.tp_print = 0; + #endif + if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_14softwrap_core2___pyx_scope_struct____iter__.tp_dictoffset && __pyx_type_14softwrap_core2___pyx_scope_struct____iter__.tp_getattro == PyObject_GenericGetAttr)) { + __pyx_type_14softwrap_core2___pyx_scope_struct____iter__.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict; + } + __pyx_ptype_14softwrap_core2___pyx_scope_struct____iter__ = &__pyx_type_14softwrap_core2___pyx_scope_struct____iter__; + if (PyType_Ready(&__pyx_type_14softwrap_core2___pyx_scope_struct_1___getitem__) < 0) __PYX_ERR(0, 1157, __pyx_L1_error) + #if PY_VERSION_HEX < 0x030800B1 + __pyx_type_14softwrap_core2___pyx_scope_struct_1___getitem__.tp_print = 0; + #endif + if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_14softwrap_core2___pyx_scope_struct_1___getitem__.tp_dictoffset && __pyx_type_14softwrap_core2___pyx_scope_struct_1___getitem__.tp_getattro == PyObject_GenericGetAttr)) { + __pyx_type_14softwrap_core2___pyx_scope_struct_1___getitem__.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict; + } + __pyx_ptype_14softwrap_core2___pyx_scope_struct_1___getitem__ = &__pyx_type_14softwrap_core2___pyx_scope_struct_1___getitem__; + if (PyType_Ready(&__pyx_type_14softwrap_core2___pyx_scope_struct_2_iter_ring) < 0) __PYX_ERR(0, 1161, __pyx_L1_error) + #if PY_VERSION_HEX < 0x030800B1 + __pyx_type_14softwrap_core2___pyx_scope_struct_2_iter_ring.tp_print = 0; + #endif + if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_14softwrap_core2___pyx_scope_struct_2_iter_ring.tp_dictoffset && __pyx_type_14softwrap_core2___pyx_scope_struct_2_iter_ring.tp_getattro == PyObject_GenericGetAttr)) { + __pyx_type_14softwrap_core2___pyx_scope_struct_2_iter_ring.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict; + } + __pyx_ptype_14softwrap_core2___pyx_scope_struct_2_iter_ring = &__pyx_type_14softwrap_core2___pyx_scope_struct_2_iter_ring; + if (PyType_Ready(&__pyx_type_14softwrap_core2___pyx_scope_struct_3___iter__) < 0) __PYX_ERR(0, 1168, __pyx_L1_error) + #if PY_VERSION_HEX < 0x030800B1 + __pyx_type_14softwrap_core2___pyx_scope_struct_3___iter__.tp_print = 0; + #endif + if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_14softwrap_core2___pyx_scope_struct_3___iter__.tp_dictoffset && __pyx_type_14softwrap_core2___pyx_scope_struct_3___iter__.tp_getattro == PyObject_GenericGetAttr)) { + __pyx_type_14softwrap_core2___pyx_scope_struct_3___iter__.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict; + } + __pyx_ptype_14softwrap_core2___pyx_scope_struct_3___iter__ = &__pyx_type_14softwrap_core2___pyx_scope_struct_3___iter__; + if (PyType_Ready(&__pyx_type_14softwrap_core2___pyx_scope_struct_4___getitem__) < 0) __PYX_ERR(0, 1348, __pyx_L1_error) + #if PY_VERSION_HEX < 0x030800B1 + __pyx_type_14softwrap_core2___pyx_scope_struct_4___getitem__.tp_print = 0; + #endif + if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_14softwrap_core2___pyx_scope_struct_4___getitem__.tp_dictoffset && __pyx_type_14softwrap_core2___pyx_scope_struct_4___getitem__.tp_getattro == PyObject_GenericGetAttr)) { + __pyx_type_14softwrap_core2___pyx_scope_struct_4___getitem__.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict; + } + __pyx_ptype_14softwrap_core2___pyx_scope_struct_4___getitem__ = &__pyx_type_14softwrap_core2___pyx_scope_struct_4___getitem__; + if (PyType_Ready(&__pyx_type_14softwrap_core2___pyx_scope_struct_5_genexpr) < 0) __PYX_ERR(0, 1352, __pyx_L1_error) + #if PY_VERSION_HEX < 0x030800B1 + __pyx_type_14softwrap_core2___pyx_scope_struct_5_genexpr.tp_print = 0; + #endif + if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_14softwrap_core2___pyx_scope_struct_5_genexpr.tp_dictoffset && __pyx_type_14softwrap_core2___pyx_scope_struct_5_genexpr.tp_getattro == PyObject_GenericGetAttr)) { + __pyx_type_14softwrap_core2___pyx_scope_struct_5_genexpr.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict; + } + __pyx_ptype_14softwrap_core2___pyx_scope_struct_5_genexpr = &__pyx_type_14softwrap_core2___pyx_scope_struct_5_genexpr; + __Pyx_RefNannyFinishContext(); + return 0; + __pyx_L1_error:; + __Pyx_RefNannyFinishContext(); + return -1; +} + +static int __Pyx_modinit_type_import_code(void) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0); + /*--- Type import code ---*/ + __Pyx_RefNannyFinishContext(); + return 0; +} + +static int __Pyx_modinit_variable_import_code(void) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0); + /*--- Variable import code ---*/ + __Pyx_RefNannyFinishContext(); + return 0; +} + +static int __Pyx_modinit_function_import_code(void) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0); + /*--- Function import code ---*/ + __Pyx_RefNannyFinishContext(); + return 0; +} + + +#ifndef CYTHON_NO_PYINIT_EXPORT +#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC +#elif PY_MAJOR_VERSION < 3 +#ifdef __cplusplus +#define __Pyx_PyMODINIT_FUNC extern "C" void +#else +#define __Pyx_PyMODINIT_FUNC void +#endif +#else +#ifdef __cplusplus +#define __Pyx_PyMODINIT_FUNC extern "C" PyObject * +#else +#define __Pyx_PyMODINIT_FUNC PyObject * +#endif +#endif + + +#if PY_MAJOR_VERSION < 3 +__Pyx_PyMODINIT_FUNC initsoftwrap_core2(void) CYTHON_SMALL_CODE; /*proto*/ +__Pyx_PyMODINIT_FUNC initsoftwrap_core2(void) +#else +__Pyx_PyMODINIT_FUNC PyInit_softwrap_core2(void) CYTHON_SMALL_CODE; /*proto*/ +__Pyx_PyMODINIT_FUNC PyInit_softwrap_core2(void) +#if CYTHON_PEP489_MULTI_PHASE_INIT +{ + return PyModuleDef_Init(&__pyx_moduledef); +} +static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) { + #if PY_VERSION_HEX >= 0x030700A1 + static PY_INT64_T main_interpreter_id = -1; + PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp); + if (main_interpreter_id == -1) { + main_interpreter_id = current_id; + return (unlikely(current_id == -1)) ? -1 : 0; + } else if (unlikely(main_interpreter_id != current_id)) + #else + static PyInterpreterState *main_interpreter = NULL; + PyInterpreterState *current_interpreter = PyThreadState_Get()->interp; + if (!main_interpreter) { + main_interpreter = current_interpreter; + } else if (unlikely(main_interpreter != current_interpreter)) + #endif + { + PyErr_SetString( + PyExc_ImportError, + "Interpreter change detected - this module can only be loaded into one interpreter per process."); + return -1; + } + return 0; +} +static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name, int allow_none) { + PyObject *value = PyObject_GetAttrString(spec, from_name); + int result = 0; + if (likely(value)) { + if (allow_none || value != Py_None) { + result = PyDict_SetItemString(moddict, to_name, value); + } + Py_DECREF(value); + } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) { + PyErr_Clear(); + } else { + result = -1; + } + return result; +} +static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) { + PyObject *module = NULL, *moddict, *modname; + if (__Pyx_check_single_interpreter()) + return NULL; + if (__pyx_m) + return __Pyx_NewRef(__pyx_m); + modname = PyObject_GetAttrString(spec, "name"); + if (unlikely(!modname)) goto bad; + module = PyModule_NewObject(modname); + Py_DECREF(modname); + if (unlikely(!module)) goto bad; + moddict = PyModule_GetDict(module); + if (unlikely(!moddict)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad; + return module; +bad: + Py_XDECREF(module); + return NULL; +} + + +static CYTHON_SMALL_CODE int __pyx_pymod_exec_softwrap_core2(PyObject *__pyx_pyinit_module) +#endif +#endif +{ + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannyDeclarations + #if CYTHON_PEP489_MULTI_PHASE_INIT + if (__pyx_m) { + if (__pyx_m == __pyx_pyinit_module) return 0; + PyErr_SetString(PyExc_RuntimeError, "Module 'softwrap_core2' has already been imported. Re-initialisation is not supported."); + return -1; + } + #elif PY_MAJOR_VERSION >= 3 + if (__pyx_m) return __Pyx_NewRef(__pyx_m); + #endif + #if CYTHON_REFNANNY +__Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); +if (!__Pyx_RefNanny) { + PyErr_Clear(); + __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny"); + if (!__Pyx_RefNanny) + Py_FatalError("failed to import 'refnanny' module"); +} +#endif + __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_softwrap_core2(void)", 0); + if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #ifdef __Pxy_PyFrame_Initialize_Offsets + __Pxy_PyFrame_Initialize_Offsets(); + #endif + __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error) + #ifdef __Pyx_CyFunction_USED + if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + #ifdef __Pyx_FusedFunction_USED + if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + #ifdef __Pyx_Coroutine_USED + if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + #ifdef __Pyx_Generator_USED + if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + #ifdef __Pyx_AsyncGen_USED + if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + #ifdef __Pyx_StopAsyncIteration_USED + if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + /*--- Library function declarations ---*/ + /*--- Threads initialization code ---*/ + #if defined(WITH_THREAD) && PY_VERSION_HEX < 0x030700F0 && defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS + PyEval_InitThreads(); + #endif + /*--- Module creation code ---*/ + #if CYTHON_PEP489_MULTI_PHASE_INIT + __pyx_m = __pyx_pyinit_module; + Py_INCREF(__pyx_m); + #else + #if PY_MAJOR_VERSION < 3 + __pyx_m = Py_InitModule4("softwrap_core2", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); + #else + __pyx_m = PyModule_Create(&__pyx_moduledef); + #endif + if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error) + Py_INCREF(__pyx_d); + __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error) + Py_INCREF(__pyx_b); + __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error) + Py_INCREF(__pyx_cython_runtime); + if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error); + /*--- Initialize various global constants etc. ---*/ + if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) + if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + if (__pyx_module_is_main_softwrap_core2) { + if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name, __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error) + } + #if PY_MAJOR_VERSION >= 3 + { + PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error) + if (!PyDict_GetItemString(modules, "softwrap_core2")) { + if (unlikely(PyDict_SetItemString(modules, "softwrap_core2", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error) + } + } + #endif + /*--- Builtin init code ---*/ + if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + /*--- Constants init code ---*/ + if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + /*--- Global type/function init code ---*/ + (void)__Pyx_modinit_global_init_code(); + (void)__Pyx_modinit_variable_export_code(); + (void)__Pyx_modinit_function_export_code(); + if (unlikely(__Pyx_modinit_type_init_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error) + (void)__Pyx_modinit_type_import_code(); + (void)__Pyx_modinit_variable_import_code(); + (void)__Pyx_modinit_function_import_code(); + /*--- Execution code ---*/ + #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) + if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + + /* "core/core2.pyx":20 + * # along with this program. If not, see . + * + * import atexit # <<<<<<<<<<<<<< + * from libc.math cimport INFINITY + * from libc.limits cimport UINT_MAX + */ + +# line 20 "core/core2.pyx" + __pyx_t_1 = __Pyx_Import(__pyx_n_s_atexit, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 20, __pyx_L1_error) + +# line 20 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_1); + +# line 20 "core/core2.pyx" + if (PyDict_SetItem(__pyx_d, __pyx_n_s_atexit, __pyx_t_1) < 0) __PYX_ERR(0, 20, __pyx_L1_error) + +# line 20 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "core/core2.pyx":259 + * + * + * cdef dict not_freed_pointers = {} # <<<<<<<<<<<<<< + * + * cdef extern from *: + */ + +# line 259 "core/core2.pyx" + __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 259, __pyx_L1_error) + +# line 259 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_1); + +# line 259 "core/core2.pyx" + __Pyx_XGOTREF(__pyx_v_14softwrap_core2_not_freed_pointers); + +# line 259 "core/core2.pyx" + __Pyx_DECREF_SET(__pyx_v_14softwrap_core2_not_freed_pointers, ((PyObject*)__pyx_t_1)); + +# line 259 "core/core2.pyx" + __Pyx_GIVEREF(__pyx_t_1); + +# line 259 "core/core2.pyx" + __pyx_t_1 = 0; + + /* "core/core2.pyx":285 + * + * + * def leak_check(): # <<<<<<<<<<<<<< + * import gc + * gc.collect() + */ + +# line 285 "core/core2.pyx" + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_14softwrap_core2_1leak_check, NULL, __pyx_n_s_softwrap_core2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 285, __pyx_L1_error) + +# line 285 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_1); + +# line 285 "core/core2.pyx" + if (PyDict_SetItem(__pyx_d, __pyx_n_s_leak_check, __pyx_t_1) < 0) __PYX_ERR(0, 285, __pyx_L1_error) + +# line 285 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "core/core2.pyx":296 + * + * + * atexit.register(leak_check) # <<<<<<<<<<<<<< + * + * + */ + +# line 296 "core/core2.pyx" + __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_atexit); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 296, __pyx_L1_error) + +# line 296 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_1); + +# line 296 "core/core2.pyx" + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_register); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 296, __pyx_L1_error) + +# line 296 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_2); + +# line 296 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + +# line 296 "core/core2.pyx" + __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_leak_check); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 296, __pyx_L1_error) + +# line 296 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_1); + +# line 296 "core/core2.pyx" + __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 296, __pyx_L1_error) + +# line 296 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_3); + +# line 296 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + +# line 296 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + +# line 296 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + + /* "core/core2.pyx":1 + * # distutils: language=c++ # <<<<<<<<<<<<<< + * # cython: cdivision=True + * # cython: language_level=3 + */ + +# line 1 "core/core2.pyx" + __pyx_t_3 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1, __pyx_L1_error) + +# line 1 "core/core2.pyx" + __Pyx_GOTREF(__pyx_t_3); + +# line 1 "core/core2.pyx" + if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_3) < 0) __PYX_ERR(0, 1, __pyx_L1_error) + +# line 1 "core/core2.pyx" + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + + /* "carray.to_py":124 + * + * @cname("__Pyx_carray_to_tuple_float") + * cdef inline tuple __Pyx_carray_to_tuple_float(base_type *v, Py_ssize_t length): # <<<<<<<<<<<<<< + * cdef size_t i + * cdef object value + */ + + /*--- Wrapped vars code ---*/ + + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + if (__pyx_m) { + if (__pyx_d) { + __Pyx_AddTraceback("init softwrap_core2", __pyx_clineno, __pyx_lineno, __pyx_filename); + } + Py_CLEAR(__pyx_m); + } else if (!PyErr_Occurred()) { + PyErr_SetString(PyExc_ImportError, "init softwrap_core2"); + } + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + #if CYTHON_PEP489_MULTI_PHASE_INIT + return (__pyx_m != NULL) ? 0 : -1; + #elif PY_MAJOR_VERSION >= 3 + return __pyx_m; + #else + return; + #endif +} + +/* --- Runtime support code --- */ +/* Refnanny */ +#if CYTHON_REFNANNY +static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { + PyObject *m = NULL, *p = NULL; + void *r = NULL; + m = PyImport_ImportModule(modname); + if (!m) goto end; + p = PyObject_GetAttrString(m, "RefNannyAPI"); + if (!p) goto end; + r = PyLong_AsVoidPtr(p); +end: + Py_XDECREF(p); + Py_XDECREF(m); + return (__Pyx_RefNannyAPIStruct *)r; +} +#endif + +/* PyObjectGetAttrStr */ +#if CYTHON_USE_TYPE_SLOTS +static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) { + PyTypeObject* tp = Py_TYPE(obj); + if (likely(tp->tp_getattro)) + return tp->tp_getattro(obj, attr_name); +#if PY_MAJOR_VERSION < 3 + if (likely(tp->tp_getattr)) + return tp->tp_getattr(obj, PyString_AS_STRING(attr_name)); +#endif + return PyObject_GetAttr(obj, attr_name); +} +#endif + +/* GetBuiltinName */ +static PyObject *__Pyx_GetBuiltinName(PyObject *name) { + PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name); + if (unlikely(!result)) { + PyErr_Format(PyExc_NameError, +#if PY_MAJOR_VERSION >= 3 + "name '%U' is not defined", name); +#else + "name '%.200s' is not defined", PyString_AS_STRING(name)); +#endif + } + return result; +} + +/* PyErrFetchRestore */ +#if CYTHON_FAST_THREAD_STATE +static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { + PyObject *tmp_type, *tmp_value, *tmp_tb; + tmp_type = tstate->curexc_type; + tmp_value = tstate->curexc_value; + tmp_tb = tstate->curexc_traceback; + tstate->curexc_type = type; + tstate->curexc_value = value; + tstate->curexc_traceback = tb; + Py_XDECREF(tmp_type); + Py_XDECREF(tmp_value); + Py_XDECREF(tmp_tb); +} +static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { + *type = tstate->curexc_type; + *value = tstate->curexc_value; + *tb = tstate->curexc_traceback; + tstate->curexc_type = 0; + tstate->curexc_value = 0; + tstate->curexc_traceback = 0; +} +#endif + +/* WriteUnraisableException */ +static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno, + CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename, + int full_traceback, CYTHON_UNUSED int nogil) { + PyObject *old_exc, *old_val, *old_tb; + PyObject *ctx; + __Pyx_PyThreadState_declare +#ifdef WITH_THREAD + PyGILState_STATE state; + if (nogil) + state = PyGILState_Ensure(); +#ifdef _MSC_VER + else state = (PyGILState_STATE)-1; +#endif +#endif + __Pyx_PyThreadState_assign + __Pyx_ErrFetch(&old_exc, &old_val, &old_tb); + if (full_traceback) { + Py_XINCREF(old_exc); + Py_XINCREF(old_val); + Py_XINCREF(old_tb); + __Pyx_ErrRestore(old_exc, old_val, old_tb); + PyErr_PrintEx(1); + } + #if PY_MAJOR_VERSION < 3 + ctx = PyString_FromString(name); + #else + ctx = PyUnicode_FromString(name); + #endif + __Pyx_ErrRestore(old_exc, old_val, old_tb); + if (!ctx) { + PyErr_WriteUnraisable(Py_None); + } else { + PyErr_WriteUnraisable(ctx); + Py_DECREF(ctx); + } +#ifdef WITH_THREAD + if (nogil) + PyGILState_Release(state); +#endif +} + +/* Import */ +static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) { + PyObject *empty_list = 0; + PyObject *module = 0; + PyObject *global_dict = 0; + PyObject *empty_dict = 0; + PyObject *list; + #if PY_MAJOR_VERSION < 3 + PyObject *py_import; + py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import); + if (!py_import) + goto bad; + #endif + if (from_list) + list = from_list; + else { + empty_list = PyList_New(0); + if (!empty_list) + goto bad; + list = empty_list; + } + global_dict = PyModule_GetDict(__pyx_m); + if (!global_dict) + goto bad; + empty_dict = PyDict_New(); + if (!empty_dict) + goto bad; + { + #if PY_MAJOR_VERSION >= 3 + if (level == -1) { + if ((1) && (strchr(__Pyx_MODULE_NAME, '.'))) { + module = PyImport_ImportModuleLevelObject( + name, global_dict, empty_dict, list, 1); + if (!module) { + if (!PyErr_ExceptionMatches(PyExc_ImportError)) + goto bad; + PyErr_Clear(); + } + } + level = 0; + } + #endif + if (!module) { + #if PY_MAJOR_VERSION < 3 + PyObject *py_level = PyInt_FromLong(level); + if (!py_level) + goto bad; + module = PyObject_CallFunctionObjArgs(py_import, + name, global_dict, empty_dict, list, py_level, (PyObject *)NULL); + Py_DECREF(py_level); + #else + module = PyImport_ImportModuleLevelObject( + name, global_dict, empty_dict, list, level); + #endif + } + } +bad: + #if PY_MAJOR_VERSION < 3 + Py_XDECREF(py_import); + #endif + Py_XDECREF(empty_list); + Py_XDECREF(empty_dict); + return module; +} + +/* PyFunctionFastCall */ +#if CYTHON_FAST_PYCALL +static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na, + PyObject *globals) { + PyFrameObject *f; + PyThreadState *tstate = __Pyx_PyThreadState_Current; + PyObject **fastlocals; + Py_ssize_t i; + PyObject *result; + assert(globals != NULL); + /* XXX Perhaps we should create a specialized + PyFrame_New() that doesn't take locals, but does + take builtins without sanity checking them. + */ + assert(tstate != NULL); + f = PyFrame_New(tstate, co, globals, NULL); + if (f == NULL) { + return NULL; + } + fastlocals = __Pyx_PyFrame_GetLocalsplus(f); + for (i = 0; i < na; i++) { + Py_INCREF(*args); + fastlocals[i] = *args++; + } + result = PyEval_EvalFrameEx(f,0); + ++tstate->recursion_depth; + Py_DECREF(f); + --tstate->recursion_depth; + return result; +} +#if 1 || PY_VERSION_HEX < 0x030600B1 +static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs) { + PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func); + PyObject *globals = PyFunction_GET_GLOBALS(func); + PyObject *argdefs = PyFunction_GET_DEFAULTS(func); + PyObject *closure; +#if PY_MAJOR_VERSION >= 3 + PyObject *kwdefs; +#endif + PyObject *kwtuple, **k; + PyObject **d; + Py_ssize_t nd; + Py_ssize_t nk; + PyObject *result; + assert(kwargs == NULL || PyDict_Check(kwargs)); + nk = kwargs ? PyDict_Size(kwargs) : 0; + if (Py_EnterRecursiveCall((char*)" while calling a Python object")) { + return NULL; + } + if ( +#if PY_MAJOR_VERSION >= 3 + co->co_kwonlyargcount == 0 && +#endif + likely(kwargs == NULL || nk == 0) && + co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) { + if (argdefs == NULL && co->co_argcount == nargs) { + result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals); + goto done; + } + else if (nargs == 0 && argdefs != NULL + && co->co_argcount == Py_SIZE(argdefs)) { + /* function called with no arguments, but all parameters have + a default value: use default values as arguments .*/ + args = &PyTuple_GET_ITEM(argdefs, 0); + result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals); + goto done; + } + } + if (kwargs != NULL) { + Py_ssize_t pos, i; + kwtuple = PyTuple_New(2 * nk); + if (kwtuple == NULL) { + result = NULL; + goto done; + } + k = &PyTuple_GET_ITEM(kwtuple, 0); + pos = i = 0; + while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) { + Py_INCREF(k[i]); + Py_INCREF(k[i+1]); + i += 2; + } + nk = i / 2; + } + else { + kwtuple = NULL; + k = NULL; + } + closure = PyFunction_GET_CLOSURE(func); +#if PY_MAJOR_VERSION >= 3 + kwdefs = PyFunction_GET_KW_DEFAULTS(func); +#endif + if (argdefs != NULL) { + d = &PyTuple_GET_ITEM(argdefs, 0); + nd = Py_SIZE(argdefs); + } + else { + d = NULL; + nd = 0; + } +#if PY_MAJOR_VERSION >= 3 + result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL, + args, (int)nargs, + k, (int)nk, + d, (int)nd, kwdefs, closure); +#else + result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL, + args, (int)nargs, + k, (int)nk, + d, (int)nd, closure); +#endif + Py_XDECREF(kwtuple); +done: + Py_LeaveRecursiveCall(); + return result; +} +#endif +#endif + +/* PyObjectCall */ +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) { + PyObject *result; + ternaryfunc call = Py_TYPE(func)->tp_call; + if (unlikely(!call)) + return PyObject_Call(func, arg, kw); + if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) + return NULL; + result = (*call)(func, arg, kw); + Py_LeaveRecursiveCall(); + if (unlikely(!result) && unlikely(!PyErr_Occurred())) { + PyErr_SetString( + PyExc_SystemError, + "NULL result without error in PyObject_Call"); + } + return result; +} +#endif + +/* PyObjectCallMethO */ +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) { + PyObject *self, *result; + PyCFunction cfunc; + cfunc = PyCFunction_GET_FUNCTION(func); + self = PyCFunction_GET_SELF(func); + if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) + return NULL; + result = cfunc(self, arg); + Py_LeaveRecursiveCall(); + if (unlikely(!result) && unlikely(!PyErr_Occurred())) { + PyErr_SetString( + PyExc_SystemError, + "NULL result without error in PyObject_Call"); + } + return result; +} +#endif + +/* PyObjectCallNoArg */ +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) { +#if CYTHON_FAST_PYCALL + if (PyFunction_Check(func)) { + return __Pyx_PyFunction_FastCall(func, NULL, 0); + } +#endif +#ifdef __Pyx_CyFunction_USED + if (likely(PyCFunction_Check(func) || __Pyx_CyFunction_Check(func))) +#else + if (likely(PyCFunction_Check(func))) +#endif + { + if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) { + return __Pyx_PyObject_CallMethO(func, NULL); + } + } + return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL); +} +#endif + +/* PyCFunctionFastCall */ +#if CYTHON_FAST_PYCCALL +static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) { + PyCFunctionObject *func = (PyCFunctionObject*)func_obj; + PyCFunction meth = PyCFunction_GET_FUNCTION(func); + PyObject *self = PyCFunction_GET_SELF(func); + int flags = PyCFunction_GET_FLAGS(func); + assert(PyCFunction_Check(func)); + assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS))); + assert(nargs >= 0); + assert(nargs == 0 || args != NULL); + /* _PyCFunction_FastCallDict() must not be called with an exception set, + because it may clear it (directly or indirectly) and so the + caller loses its exception */ + assert(!PyErr_Occurred()); + if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) { + return (*((__Pyx_PyCFunctionFastWithKeywords)(void*)meth)) (self, args, nargs, NULL); + } else { + return (*((__Pyx_PyCFunctionFast)(void*)meth)) (self, args, nargs); + } +} +#endif + +/* PyObjectCallOneArg */ +#if CYTHON_COMPILING_IN_CPYTHON +static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) { + PyObject *result; + PyObject *args = PyTuple_New(1); + if (unlikely(!args)) return NULL; + Py_INCREF(arg); + PyTuple_SET_ITEM(args, 0, arg); + result = __Pyx_PyObject_Call(func, args, NULL); + Py_DECREF(args); + return result; +} +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { +#if CYTHON_FAST_PYCALL + if (PyFunction_Check(func)) { + return __Pyx_PyFunction_FastCall(func, &arg, 1); + } +#endif + if (likely(PyCFunction_Check(func))) { + if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) { + return __Pyx_PyObject_CallMethO(func, arg); +#if CYTHON_FAST_PYCCALL + } else if (__Pyx_PyFastCFunction_Check(func)) { + return __Pyx_PyCFunction_FastCall(func, &arg, 1); +#endif + } + } + return __Pyx__PyObject_CallOneArg(func, arg); +} +#else +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { + PyObject *result; + PyObject *args = PyTuple_Pack(1, arg); + if (unlikely(!args)) return NULL; + result = __Pyx_PyObject_Call(func, args, NULL); + Py_DECREF(args); + return result; +} +#endif + +/* IterFinish */ +static CYTHON_INLINE int __Pyx_IterFinish(void) { +#if CYTHON_FAST_THREAD_STATE + PyThreadState *tstate = __Pyx_PyThreadState_Current; + PyObject* exc_type = tstate->curexc_type; + if (unlikely(exc_type)) { + if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) { + PyObject *exc_value, *exc_tb; + exc_value = tstate->curexc_value; + exc_tb = tstate->curexc_traceback; + tstate->curexc_type = 0; + tstate->curexc_value = 0; + tstate->curexc_traceback = 0; + Py_DECREF(exc_type); + Py_XDECREF(exc_value); + Py_XDECREF(exc_tb); + return 0; + } else { + return -1; + } + } + return 0; +#else + if (unlikely(PyErr_Occurred())) { + if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) { + PyErr_Clear(); + return 0; + } else { + return -1; + } + } + return 0; +#endif +} + +/* PyObjectGetMethod */ +static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method) { + PyObject *attr; +#if CYTHON_UNPACK_METHODS && CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_PYTYPE_LOOKUP + PyTypeObject *tp = Py_TYPE(obj); + PyObject *descr; + descrgetfunc f = NULL; + PyObject **dictptr, *dict; + int meth_found = 0; + assert (*method == NULL); + if (unlikely(tp->tp_getattro != PyObject_GenericGetAttr)) { + attr = __Pyx_PyObject_GetAttrStr(obj, name); + goto try_unpack; + } + if (unlikely(tp->tp_dict == NULL) && unlikely(PyType_Ready(tp) < 0)) { + return 0; + } + descr = _PyType_Lookup(tp, name); + if (likely(descr != NULL)) { + Py_INCREF(descr); +#if PY_MAJOR_VERSION >= 3 + #ifdef __Pyx_CyFunction_USED + if (likely(PyFunction_Check(descr) || (Py_TYPE(descr) == &PyMethodDescr_Type) || __Pyx_CyFunction_Check(descr))) + #else + if (likely(PyFunction_Check(descr) || (Py_TYPE(descr) == &PyMethodDescr_Type))) + #endif +#else + #ifdef __Pyx_CyFunction_USED + if (likely(PyFunction_Check(descr) || __Pyx_CyFunction_Check(descr))) + #else + if (likely(PyFunction_Check(descr))) + #endif +#endif + { + meth_found = 1; + } else { + f = Py_TYPE(descr)->tp_descr_get; + if (f != NULL && PyDescr_IsData(descr)) { + attr = f(descr, obj, (PyObject *)Py_TYPE(obj)); + Py_DECREF(descr); + goto try_unpack; + } + } + } + dictptr = _PyObject_GetDictPtr(obj); + if (dictptr != NULL && (dict = *dictptr) != NULL) { + Py_INCREF(dict); + attr = __Pyx_PyDict_GetItemStr(dict, name); + if (attr != NULL) { + Py_INCREF(attr); + Py_DECREF(dict); + Py_XDECREF(descr); + goto try_unpack; + } + Py_DECREF(dict); + } + if (meth_found) { + *method = descr; + return 1; + } + if (f != NULL) { + attr = f(descr, obj, (PyObject *)Py_TYPE(obj)); + Py_DECREF(descr); + goto try_unpack; + } + if (descr != NULL) { + *method = descr; + return 0; + } + PyErr_Format(PyExc_AttributeError, +#if PY_MAJOR_VERSION >= 3 + "'%.50s' object has no attribute '%U'", + tp->tp_name, name); +#else + "'%.50s' object has no attribute '%.400s'", + tp->tp_name, PyString_AS_STRING(name)); +#endif + return 0; +#else + attr = __Pyx_PyObject_GetAttrStr(obj, name); + goto try_unpack; +#endif +try_unpack: +#if CYTHON_UNPACK_METHODS + if (likely(attr) && PyMethod_Check(attr) && likely(PyMethod_GET_SELF(attr) == obj)) { + PyObject *function = PyMethod_GET_FUNCTION(attr); + Py_INCREF(function); + Py_DECREF(attr); + *method = function; + return 1; + } +#endif + *method = attr; + return 0; +} + +/* PyObjectCallMethod0 */ +static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name) { + PyObject *method = NULL, *result = NULL; + int is_method = __Pyx_PyObject_GetMethod(obj, method_name, &method); + if (likely(is_method)) { + result = __Pyx_PyObject_CallOneArg(method, obj); + Py_DECREF(method); + return result; + } + if (unlikely(!method)) goto bad; + result = __Pyx_PyObject_CallNoArg(method); + Py_DECREF(method); +bad: + return result; +} + +/* RaiseNeedMoreValuesToUnpack */ +static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) { + PyErr_Format(PyExc_ValueError, + "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack", + index, (index == 1) ? "" : "s"); +} + +/* RaiseTooManyValuesToUnpack */ +static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) { + PyErr_Format(PyExc_ValueError, + "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected); +} + +/* UnpackItemEndCheck */ +static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) { + if (unlikely(retval)) { + Py_DECREF(retval); + __Pyx_RaiseTooManyValuesError(expected); + return -1; + } else { + return __Pyx_IterFinish(); + } + return 0; +} + +/* RaiseNoneIterError */ +static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); +} + +/* UnpackTupleError */ +static void __Pyx_UnpackTupleError(PyObject *t, Py_ssize_t index) { + if (t == Py_None) { + __Pyx_RaiseNoneNotIterableError(); + } else if (PyTuple_GET_SIZE(t) < index) { + __Pyx_RaiseNeedMoreValuesError(PyTuple_GET_SIZE(t)); + } else { + __Pyx_RaiseTooManyValuesError(index); + } +} + +/* UnpackTuple2 */ +static CYTHON_INLINE int __Pyx_unpack_tuple2_exact( + PyObject* tuple, PyObject** pvalue1, PyObject** pvalue2, int decref_tuple) { + PyObject *value1 = NULL, *value2 = NULL; +#if CYTHON_COMPILING_IN_PYPY + value1 = PySequence_ITEM(tuple, 0); if (unlikely(!value1)) goto bad; + value2 = PySequence_ITEM(tuple, 1); if (unlikely(!value2)) goto bad; +#else + value1 = PyTuple_GET_ITEM(tuple, 0); Py_INCREF(value1); + value2 = PyTuple_GET_ITEM(tuple, 1); Py_INCREF(value2); +#endif + if (decref_tuple) { + Py_DECREF(tuple); + } + *pvalue1 = value1; + *pvalue2 = value2; + return 0; +#if CYTHON_COMPILING_IN_PYPY +bad: + Py_XDECREF(value1); + Py_XDECREF(value2); + if (decref_tuple) { Py_XDECREF(tuple); } + return -1; +#endif +} +static int __Pyx_unpack_tuple2_generic(PyObject* tuple, PyObject** pvalue1, PyObject** pvalue2, + int has_known_size, int decref_tuple) { + Py_ssize_t index; + PyObject *value1 = NULL, *value2 = NULL, *iter = NULL; + iternextfunc iternext; + iter = PyObject_GetIter(tuple); + if (unlikely(!iter)) goto bad; + if (decref_tuple) { Py_DECREF(tuple); tuple = NULL; } + iternext = Py_TYPE(iter)->tp_iternext; + value1 = iternext(iter); if (unlikely(!value1)) { index = 0; goto unpacking_failed; } + value2 = iternext(iter); if (unlikely(!value2)) { index = 1; goto unpacking_failed; } + if (!has_known_size && unlikely(__Pyx_IternextUnpackEndCheck(iternext(iter), 2))) goto bad; + Py_DECREF(iter); + *pvalue1 = value1; + *pvalue2 = value2; + return 0; +unpacking_failed: + if (!has_known_size && __Pyx_IterFinish() == 0) + __Pyx_RaiseNeedMoreValuesError(index); +bad: + Py_XDECREF(iter); + Py_XDECREF(value1); + Py_XDECREF(value2); + if (decref_tuple) { Py_XDECREF(tuple); } + return -1; +} + +/* dict_iter */ +static CYTHON_INLINE PyObject* __Pyx_dict_iterator(PyObject* iterable, int is_dict, PyObject* method_name, + Py_ssize_t* p_orig_length, int* p_source_is_dict) { + is_dict = is_dict || likely(PyDict_CheckExact(iterable)); + *p_source_is_dict = is_dict; + if (is_dict) { +#if !CYTHON_COMPILING_IN_PYPY + *p_orig_length = PyDict_Size(iterable); + Py_INCREF(iterable); + return iterable; +#elif PY_MAJOR_VERSION >= 3 + static PyObject *py_items = NULL, *py_keys = NULL, *py_values = NULL; + PyObject **pp = NULL; + if (method_name) { + const char *name = PyUnicode_AsUTF8(method_name); + if (strcmp(name, "iteritems") == 0) pp = &py_items; + else if (strcmp(name, "iterkeys") == 0) pp = &py_keys; + else if (strcmp(name, "itervalues") == 0) pp = &py_values; + if (pp) { + if (!*pp) { + *pp = PyUnicode_FromString(name + 4); + if (!*pp) + return NULL; + } + method_name = *pp; + } + } +#endif + } + *p_orig_length = 0; + if (method_name) { + PyObject* iter; + iterable = __Pyx_PyObject_CallMethod0(iterable, method_name); + if (!iterable) + return NULL; +#if !CYTHON_COMPILING_IN_PYPY + if (PyTuple_CheckExact(iterable) || PyList_CheckExact(iterable)) + return iterable; +#endif + iter = PyObject_GetIter(iterable); + Py_DECREF(iterable); + return iter; + } + return PyObject_GetIter(iterable); +} +static CYTHON_INLINE int __Pyx_dict_iter_next( + PyObject* iter_obj, CYTHON_NCP_UNUSED Py_ssize_t orig_length, CYTHON_NCP_UNUSED Py_ssize_t* ppos, + PyObject** pkey, PyObject** pvalue, PyObject** pitem, int source_is_dict) { + PyObject* next_item; +#if !CYTHON_COMPILING_IN_PYPY + if (source_is_dict) { + PyObject *key, *value; + if (unlikely(orig_length != PyDict_Size(iter_obj))) { + PyErr_SetString(PyExc_RuntimeError, "dictionary changed size during iteration"); + return -1; + } + if (unlikely(!PyDict_Next(iter_obj, ppos, &key, &value))) { + return 0; + } + if (pitem) { + PyObject* tuple = PyTuple_New(2); + if (unlikely(!tuple)) { + return -1; + } + Py_INCREF(key); + Py_INCREF(value); + PyTuple_SET_ITEM(tuple, 0, key); + PyTuple_SET_ITEM(tuple, 1, value); + *pitem = tuple; + } else { + if (pkey) { + Py_INCREF(key); + *pkey = key; + } + if (pvalue) { + Py_INCREF(value); + *pvalue = value; + } + } + return 1; + } else if (PyTuple_CheckExact(iter_obj)) { + Py_ssize_t pos = *ppos; + if (unlikely(pos >= PyTuple_GET_SIZE(iter_obj))) return 0; + *ppos = pos + 1; + next_item = PyTuple_GET_ITEM(iter_obj, pos); + Py_INCREF(next_item); + } else if (PyList_CheckExact(iter_obj)) { + Py_ssize_t pos = *ppos; + if (unlikely(pos >= PyList_GET_SIZE(iter_obj))) return 0; + *ppos = pos + 1; + next_item = PyList_GET_ITEM(iter_obj, pos); + Py_INCREF(next_item); + } else +#endif + { + next_item = PyIter_Next(iter_obj); + if (unlikely(!next_item)) { + return __Pyx_IterFinish(); + } + } + if (pitem) { + *pitem = next_item; + } else if (pkey && pvalue) { + if (__Pyx_unpack_tuple2(next_item, pkey, pvalue, source_is_dict, source_is_dict, 1)) + return -1; + } else if (pkey) { + *pkey = next_item; + } else { + *pvalue = next_item; + } + return 1; +} + +/* JoinPyUnicode */ +static PyObject* __Pyx_PyUnicode_Join(PyObject* value_tuple, Py_ssize_t value_count, Py_ssize_t result_ulength, + CYTHON_UNUSED Py_UCS4 max_char) { +#if CYTHON_USE_UNICODE_INTERNALS && CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + PyObject *result_uval; + int result_ukind; + Py_ssize_t i, char_pos; + void *result_udata; +#if CYTHON_PEP393_ENABLED + result_uval = PyUnicode_New(result_ulength, max_char); + if (unlikely(!result_uval)) return NULL; + result_ukind = (max_char <= 255) ? PyUnicode_1BYTE_KIND : (max_char <= 65535) ? PyUnicode_2BYTE_KIND : PyUnicode_4BYTE_KIND; + result_udata = PyUnicode_DATA(result_uval); +#else + result_uval = PyUnicode_FromUnicode(NULL, result_ulength); + if (unlikely(!result_uval)) return NULL; + result_ukind = sizeof(Py_UNICODE); + result_udata = PyUnicode_AS_UNICODE(result_uval); +#endif + char_pos = 0; + for (i=0; i < value_count; i++) { + int ukind; + Py_ssize_t ulength; + void *udata; + PyObject *uval = PyTuple_GET_ITEM(value_tuple, i); + if (unlikely(__Pyx_PyUnicode_READY(uval))) + goto bad; + ulength = __Pyx_PyUnicode_GET_LENGTH(uval); + if (unlikely(!ulength)) + continue; + if (unlikely(char_pos + ulength < 0)) + goto overflow; + ukind = __Pyx_PyUnicode_KIND(uval); + udata = __Pyx_PyUnicode_DATA(uval); + if (!CYTHON_PEP393_ENABLED || ukind == result_ukind) { + memcpy((char *)result_udata + char_pos * result_ukind, udata, (size_t) (ulength * result_ukind)); + } else { + #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030300F0 || defined(_PyUnicode_FastCopyCharacters) + _PyUnicode_FastCopyCharacters(result_uval, char_pos, uval, 0, ulength); + #else + Py_ssize_t j; + for (j=0; j < ulength; j++) { + Py_UCS4 uchar = __Pyx_PyUnicode_READ(ukind, udata, j); + __Pyx_PyUnicode_WRITE(result_ukind, result_udata, char_pos+j, uchar); + } + #endif + } + char_pos += ulength; + } + return result_uval; +overflow: + PyErr_SetString(PyExc_OverflowError, "join() result is too long for a Python string"); +bad: + Py_DECREF(result_uval); + return NULL; +#else + result_ulength++; + value_count++; + return PyUnicode_Join(__pyx_empty_unicode, value_tuple); +#endif +} + +/* SetItemInt */ +static int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v) { + int r; + if (!j) return -1; + r = PyObject_SetItem(o, j, v); + Py_DECREF(j); + return r; +} +static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v, int is_list, + CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) { +#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS + if (is_list || PyList_CheckExact(o)) { + Py_ssize_t n = (!wraparound) ? i : ((likely(i >= 0)) ? i : i + PyList_GET_SIZE(o)); + if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o)))) { + PyObject* old = PyList_GET_ITEM(o, n); + Py_INCREF(v); + PyList_SET_ITEM(o, n, v); + Py_DECREF(old); + return 1; + } + } else { + PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence; + if (likely(m && m->sq_ass_item)) { + if (wraparound && unlikely(i < 0) && likely(m->sq_length)) { + Py_ssize_t l = m->sq_length(o); + if (likely(l >= 0)) { + i += l; + } else { + if (!PyErr_ExceptionMatches(PyExc_OverflowError)) + return -1; + PyErr_Clear(); + } + } + return m->sq_ass_item(o, i, v); + } + } +#else +#if CYTHON_COMPILING_IN_PYPY + if (is_list || (PySequence_Check(o) && !PyDict_Check(o))) +#else + if (is_list || PySequence_Check(o)) +#endif + { + return PySequence_SetItem(o, i, v); + } +#endif + return __Pyx_SetItemInt_Generic(o, PyInt_FromSsize_t(i), v); +} + +/* RaiseException */ +#if PY_MAJOR_VERSION < 3 +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, + CYTHON_UNUSED PyObject *cause) { + __Pyx_PyThreadState_declare + Py_XINCREF(type); + if (!value || value == Py_None) + value = NULL; + else + Py_INCREF(value); + if (!tb || tb == Py_None) + tb = NULL; + else { + Py_INCREF(tb); + if (!PyTraceBack_Check(tb)) { + PyErr_SetString(PyExc_TypeError, + "raise: arg 3 must be a traceback or None"); + goto raise_error; + } + } + if (PyType_Check(type)) { +#if CYTHON_COMPILING_IN_PYPY + if (!value) { + Py_INCREF(Py_None); + value = Py_None; + } +#endif + PyErr_NormalizeException(&type, &value, &tb); + } else { + if (value) { + PyErr_SetString(PyExc_TypeError, + "instance exception may not have a separate value"); + goto raise_error; + } + value = type; + type = (PyObject*) Py_TYPE(type); + Py_INCREF(type); + if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) { + PyErr_SetString(PyExc_TypeError, + "raise: exception class must be a subclass of BaseException"); + goto raise_error; + } + } + __Pyx_PyThreadState_assign + __Pyx_ErrRestore(type, value, tb); + return; +raise_error: + Py_XDECREF(value); + Py_XDECREF(type); + Py_XDECREF(tb); + return; +} +#else +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) { + PyObject* owned_instance = NULL; + if (tb == Py_None) { + tb = 0; + } else if (tb && !PyTraceBack_Check(tb)) { + PyErr_SetString(PyExc_TypeError, + "raise: arg 3 must be a traceback or None"); + goto bad; + } + if (value == Py_None) + value = 0; + if (PyExceptionInstance_Check(type)) { + if (value) { + PyErr_SetString(PyExc_TypeError, + "instance exception may not have a separate value"); + goto bad; + } + value = type; + type = (PyObject*) Py_TYPE(value); + } else if (PyExceptionClass_Check(type)) { + PyObject *instance_class = NULL; + if (value && PyExceptionInstance_Check(value)) { + instance_class = (PyObject*) Py_TYPE(value); + if (instance_class != type) { + int is_subclass = PyObject_IsSubclass(instance_class, type); + if (!is_subclass) { + instance_class = NULL; + } else if (unlikely(is_subclass == -1)) { + goto bad; + } else { + type = instance_class; + } + } + } + if (!instance_class) { + PyObject *args; + if (!value) + args = PyTuple_New(0); + else if (PyTuple_Check(value)) { + Py_INCREF(value); + args = value; + } else + args = PyTuple_Pack(1, value); + if (!args) + goto bad; + owned_instance = PyObject_Call(type, args, NULL); + Py_DECREF(args); + if (!owned_instance) + goto bad; + value = owned_instance; + if (!PyExceptionInstance_Check(value)) { + PyErr_Format(PyExc_TypeError, + "calling %R should have returned an instance of " + "BaseException, not %R", + type, Py_TYPE(value)); + goto bad; + } + } + } else { + PyErr_SetString(PyExc_TypeError, + "raise: exception class must be a subclass of BaseException"); + goto bad; + } + if (cause) { + PyObject *fixed_cause; + if (cause == Py_None) { + fixed_cause = NULL; + } else if (PyExceptionClass_Check(cause)) { + fixed_cause = PyObject_CallObject(cause, NULL); + if (fixed_cause == NULL) + goto bad; + } else if (PyExceptionInstance_Check(cause)) { + fixed_cause = cause; + Py_INCREF(fixed_cause); + } else { + PyErr_SetString(PyExc_TypeError, + "exception causes must derive from " + "BaseException"); + goto bad; + } + PyException_SetCause(value, fixed_cause); + } + PyErr_SetObject(type, value); + if (tb) { +#if CYTHON_COMPILING_IN_PYPY + PyObject *tmp_type, *tmp_value, *tmp_tb; + PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb); + Py_INCREF(tb); + PyErr_Restore(tmp_type, tmp_value, tb); + Py_XDECREF(tmp_tb); +#else + PyThreadState *tstate = __Pyx_PyThreadState_Current; + PyObject* tmp_tb = tstate->curexc_traceback; + if (tb != tmp_tb) { + Py_INCREF(tb); + tstate->curexc_traceback = tb; + Py_XDECREF(tmp_tb); + } +#endif + } +bad: + Py_XDECREF(owned_instance); + return; +} +#endif + +/* RaiseArgTupleInvalid */ +static void __Pyx_RaiseArgtupleInvalid( + const char* func_name, + int exact, + Py_ssize_t num_min, + Py_ssize_t num_max, + Py_ssize_t num_found) +{ + Py_ssize_t num_expected; + const char *more_or_less; + if (num_found < num_min) { + num_expected = num_min; + more_or_less = "at least"; + } else { + num_expected = num_max; + more_or_less = "at most"; + } + if (exact) { + more_or_less = "exactly"; + } + PyErr_Format(PyExc_TypeError, + "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)", + func_name, more_or_less, num_expected, + (num_expected == 1) ? "" : "s", num_found); +} + +/* RaiseDoubleKeywords */ +static void __Pyx_RaiseDoubleKeywordsError( + const char* func_name, + PyObject* kw_name) +{ + PyErr_Format(PyExc_TypeError, + #if PY_MAJOR_VERSION >= 3 + "%s() got multiple values for keyword argument '%U'", func_name, kw_name); + #else + "%s() got multiple values for keyword argument '%s'", func_name, + PyString_AsString(kw_name)); + #endif +} + +/* ParseKeywords */ +static int __Pyx_ParseOptionalKeywords( + PyObject *kwds, + PyObject **argnames[], + PyObject *kwds2, + PyObject *values[], + Py_ssize_t num_pos_args, + const char* function_name) +{ + PyObject *key = 0, *value = 0; + Py_ssize_t pos = 0; + PyObject*** name; + PyObject*** first_kw_arg = argnames + num_pos_args; + while (PyDict_Next(kwds, &pos, &key, &value)) { + name = first_kw_arg; + while (*name && (**name != key)) name++; + if (*name) { + values[name-argnames] = value; + continue; + } + name = first_kw_arg; + #if PY_MAJOR_VERSION < 3 + if (likely(PyString_Check(key))) { + while (*name) { + if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key)) + && _PyString_Eq(**name, key)) { + values[name-argnames] = value; + break; + } + name++; + } + if (*name) continue; + else { + PyObject*** argname = argnames; + while (argname != first_kw_arg) { + if ((**argname == key) || ( + (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key)) + && _PyString_Eq(**argname, key))) { + goto arg_passed_twice; + } + argname++; + } + } + } else + #endif + if (likely(PyUnicode_Check(key))) { + while (*name) { + int cmp = (**name == key) ? 0 : + #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 + (__Pyx_PyUnicode_GET_LENGTH(**name) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 : + #endif + PyUnicode_Compare(**name, key); + if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; + if (cmp == 0) { + values[name-argnames] = value; + break; + } + name++; + } + if (*name) continue; + else { + PyObject*** argname = argnames; + while (argname != first_kw_arg) { + int cmp = (**argname == key) ? 0 : + #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 + (__Pyx_PyUnicode_GET_LENGTH(**argname) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 : + #endif + PyUnicode_Compare(**argname, key); + if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; + if (cmp == 0) goto arg_passed_twice; + argname++; + } + } + } else + goto invalid_keyword_type; + if (kwds2) { + if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad; + } else { + goto invalid_keyword; + } + } + return 0; +arg_passed_twice: + __Pyx_RaiseDoubleKeywordsError(function_name, key); + goto bad; +invalid_keyword_type: + PyErr_Format(PyExc_TypeError, + "%.200s() keywords must be strings", function_name); + goto bad; +invalid_keyword: + PyErr_Format(PyExc_TypeError, + #if PY_MAJOR_VERSION < 3 + "%.200s() got an unexpected keyword argument '%.200s'", + function_name, PyString_AsString(key)); + #else + "%s() got an unexpected keyword argument '%U'", + function_name, key); + #endif +bad: + return -1; +} + +/* GetItemInt */ +static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) { + PyObject *r; + if (!j) return NULL; + r = PyObject_GetItem(o, j); + Py_DECREF(j); + return r; +} +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, + CYTHON_NCP_UNUSED int wraparound, + CYTHON_NCP_UNUSED int boundscheck) { +#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + Py_ssize_t wrapped_i = i; + if (wraparound & unlikely(i < 0)) { + wrapped_i += PyList_GET_SIZE(o); + } + if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyList_GET_SIZE(o)))) { + PyObject *r = PyList_GET_ITEM(o, wrapped_i); + Py_INCREF(r); + return r; + } + return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); +#else + return PySequence_GetItem(o, i); +#endif +} +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, + CYTHON_NCP_UNUSED int wraparound, + CYTHON_NCP_UNUSED int boundscheck) { +#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + Py_ssize_t wrapped_i = i; + if (wraparound & unlikely(i < 0)) { + wrapped_i += PyTuple_GET_SIZE(o); + } + if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyTuple_GET_SIZE(o)))) { + PyObject *r = PyTuple_GET_ITEM(o, wrapped_i); + Py_INCREF(r); + return r; + } + return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); +#else + return PySequence_GetItem(o, i); +#endif +} +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list, + CYTHON_NCP_UNUSED int wraparound, + CYTHON_NCP_UNUSED int boundscheck) { +#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS + if (is_list || PyList_CheckExact(o)) { + Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o); + if ((!boundscheck) || (likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o))))) { + PyObject *r = PyList_GET_ITEM(o, n); + Py_INCREF(r); + return r; + } + } + else if (PyTuple_CheckExact(o)) { + Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o); + if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyTuple_GET_SIZE(o)))) { + PyObject *r = PyTuple_GET_ITEM(o, n); + Py_INCREF(r); + return r; + } + } else { + PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence; + if (likely(m && m->sq_item)) { + if (wraparound && unlikely(i < 0) && likely(m->sq_length)) { + Py_ssize_t l = m->sq_length(o); + if (likely(l >= 0)) { + i += l; + } else { + if (!PyErr_ExceptionMatches(PyExc_OverflowError)) + return NULL; + PyErr_Clear(); + } + } + return m->sq_item(o, i); + } + } +#else + if (is_list || PySequence_Check(o)) { + return PySequence_GetItem(o, i); + } +#endif + return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); +} + +/* ArgTypeTest */ +static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact) +{ + if (unlikely(!type)) { + PyErr_SetString(PyExc_SystemError, "Missing type object"); + return 0; + } + else if (exact) { + #if PY_MAJOR_VERSION == 2 + if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1; + #endif + } + else { + if (likely(__Pyx_TypeCheck(obj, type))) return 1; + } + PyErr_Format(PyExc_TypeError, + "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)", + name, type->tp_name, Py_TYPE(obj)->tp_name); + return 0; +} + +/* PyObjectCall2Args */ +static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2) { + PyObject *args, *result = NULL; + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(function)) { + PyObject *args[2] = {arg1, arg2}; + return __Pyx_PyFunction_FastCall(function, args, 2); + } + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(function)) { + PyObject *args[2] = {arg1, arg2}; + return __Pyx_PyCFunction_FastCall(function, args, 2); + } + #endif + args = PyTuple_New(2); + if (unlikely(!args)) goto done; + Py_INCREF(arg1); + PyTuple_SET_ITEM(args, 0, arg1); + Py_INCREF(arg2); + PyTuple_SET_ITEM(args, 1, arg2); + Py_INCREF(function); + result = __Pyx_PyObject_Call(function, args, NULL); + Py_DECREF(args); + Py_DECREF(function); +done: + return result; +} + +/* PyObjectCallMethod1 */ +static PyObject* __Pyx__PyObject_CallMethod1(PyObject* method, PyObject* arg) { + PyObject *result = __Pyx_PyObject_CallOneArg(method, arg); + Py_DECREF(method); + return result; +} +static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg) { + PyObject *method = NULL, *result; + int is_method = __Pyx_PyObject_GetMethod(obj, method_name, &method); + if (likely(is_method)) { + result = __Pyx_PyObject_Call2Args(method, obj, arg); + Py_DECREF(method); + return result; + } + if (unlikely(!method)) return NULL; + return __Pyx__PyObject_CallMethod1(method, arg); +} + +/* append */ +static CYTHON_INLINE int __Pyx_PyObject_Append(PyObject* L, PyObject* x) { + if (likely(PyList_CheckExact(L))) { + if (unlikely(__Pyx_PyList_Append(L, x) < 0)) return -1; + } else { + PyObject* retval = __Pyx_PyObject_CallMethod1(L, __pyx_n_s_append, x); + if (unlikely(!retval)) + return -1; + Py_DECREF(retval); + } + return 0; +} + +/* PyDictVersioning */ +#if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS +static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) { + PyObject *dict = Py_TYPE(obj)->tp_dict; + return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0; +} +static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) { + PyObject **dictptr = NULL; + Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset; + if (offset) { +#if CYTHON_COMPILING_IN_CPYTHON + dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj); +#else + dictptr = _PyObject_GetDictPtr(obj); +#endif + } + return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0; +} +static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) { + PyObject *dict = Py_TYPE(obj)->tp_dict; + if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict))) + return 0; + return obj_dict_version == __Pyx_get_object_dict_version(obj); +} +#endif + +/* ExtTypeTest */ +static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { + if (unlikely(!type)) { + PyErr_SetString(PyExc_SystemError, "Missing type object"); + return 0; + } + if (likely(__Pyx_TypeCheck(obj, type))) + return 1; + PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s", + Py_TYPE(obj)->tp_name, type->tp_name); + return 0; +} + +/* pyfrozenset_new */ +static CYTHON_INLINE PyObject* __Pyx_PyFrozenSet_New(PyObject* it) { + if (it) { + PyObject* result; +#if CYTHON_COMPILING_IN_PYPY + PyObject* args; + args = PyTuple_Pack(1, it); + if (unlikely(!args)) + return NULL; + result = PyObject_Call((PyObject*)&PyFrozenSet_Type, args, NULL); + Py_DECREF(args); + return result; +#else + if (PyFrozenSet_CheckExact(it)) { + Py_INCREF(it); + return it; + } + result = PyFrozenSet_New(it); + if (unlikely(!result)) + return NULL; + if ((PY_VERSION_HEX >= 0x031000A1) || likely(PySet_GET_SIZE(result))) + return result; + Py_DECREF(result); +#endif + } +#if CYTHON_USE_TYPE_SLOTS + return PyFrozenSet_Type.tp_new(&PyFrozenSet_Type, __pyx_empty_tuple, NULL); +#else + return PyObject_Call((PyObject*)&PyFrozenSet_Type, __pyx_empty_tuple, NULL); +#endif +} + +/* PySetContains */ +static int __Pyx_PySet_ContainsUnhashable(PyObject *set, PyObject *key) { + int result = -1; + if (PySet_Check(key) && PyErr_ExceptionMatches(PyExc_TypeError)) { + PyObject *tmpkey; + PyErr_Clear(); + tmpkey = __Pyx_PyFrozenSet_New(key); + if (tmpkey != NULL) { + result = PySet_Contains(set, tmpkey); + Py_DECREF(tmpkey); + } + } + return result; +} +static CYTHON_INLINE int __Pyx_PySet_ContainsTF(PyObject* key, PyObject* set, int eq) { + int result = PySet_Contains(set, key); + if (unlikely(result < 0)) { + result = __Pyx_PySet_ContainsUnhashable(set, key); + } + return unlikely(result < 0) ? result : (result == (eq == Py_EQ)); +} + +/* None */ +static CYTHON_INLINE void __Pyx_RaiseClosureNameError(const char *varname) { + PyErr_Format(PyExc_NameError, "free variable '%s' referenced before assignment in enclosing scope", varname); +} + +/* FetchCommonType */ +static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) { + PyObject* fake_module; + PyTypeObject* cached_type = NULL; + fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI); + if (!fake_module) return NULL; + Py_INCREF(fake_module); + cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name); + if (cached_type) { + if (!PyType_Check((PyObject*)cached_type)) { + PyErr_Format(PyExc_TypeError, + "Shared Cython type %.200s is not a type object", + type->tp_name); + goto bad; + } + if (cached_type->tp_basicsize != type->tp_basicsize) { + PyErr_Format(PyExc_TypeError, + "Shared Cython type %.200s has the wrong size, try recompiling", + type->tp_name); + goto bad; + } + } else { + if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad; + PyErr_Clear(); + if (PyType_Ready(type) < 0) goto bad; + if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0) + goto bad; + Py_INCREF(type); + cached_type = type; + } +done: + Py_DECREF(fake_module); + return cached_type; +bad: + Py_XDECREF(cached_type); + cached_type = NULL; + goto done; +} + +/* CythonFunctionShared */ +#include +static PyObject * +__Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *closure) +{ + if (unlikely(op->func_doc == NULL)) { + if (op->func.m_ml->ml_doc) { +#if PY_MAJOR_VERSION >= 3 + op->func_doc = PyUnicode_FromString(op->func.m_ml->ml_doc); +#else + op->func_doc = PyString_FromString(op->func.m_ml->ml_doc); +#endif + if (unlikely(op->func_doc == NULL)) + return NULL; + } else { + Py_INCREF(Py_None); + return Py_None; + } + } + Py_INCREF(op->func_doc); + return op->func_doc; +} +static int +__Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context) +{ + PyObject *tmp = op->func_doc; + if (value == NULL) { + value = Py_None; + } + Py_INCREF(value); + op->func_doc = value; + Py_XDECREF(tmp); + return 0; +} +static PyObject * +__Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) +{ + if (unlikely(op->func_name == NULL)) { +#if PY_MAJOR_VERSION >= 3 + op->func_name = PyUnicode_InternFromString(op->func.m_ml->ml_name); +#else + op->func_name = PyString_InternFromString(op->func.m_ml->ml_name); +#endif + if (unlikely(op->func_name == NULL)) + return NULL; + } + Py_INCREF(op->func_name); + return op->func_name; +} +static int +__Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context) +{ + PyObject *tmp; +#if PY_MAJOR_VERSION >= 3 + if (unlikely(value == NULL || !PyUnicode_Check(value))) +#else + if (unlikely(value == NULL || !PyString_Check(value))) +#endif + { + PyErr_SetString(PyExc_TypeError, + "__name__ must be set to a string object"); + return -1; + } + tmp = op->func_name; + Py_INCREF(value); + op->func_name = value; + Py_XDECREF(tmp); + return 0; +} +static PyObject * +__Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) +{ + Py_INCREF(op->func_qualname); + return op->func_qualname; +} +static int +__Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context) +{ + PyObject *tmp; +#if PY_MAJOR_VERSION >= 3 + if (unlikely(value == NULL || !PyUnicode_Check(value))) +#else + if (unlikely(value == NULL || !PyString_Check(value))) +#endif + { + PyErr_SetString(PyExc_TypeError, + "__qualname__ must be set to a string object"); + return -1; + } + tmp = op->func_qualname; + Py_INCREF(value); + op->func_qualname = value; + Py_XDECREF(tmp); + return 0; +} +static PyObject * +__Pyx_CyFunction_get_self(__pyx_CyFunctionObject *m, CYTHON_UNUSED void *closure) +{ + PyObject *self; + self = m->func_closure; + if (self == NULL) + self = Py_None; + Py_INCREF(self); + return self; +} +static PyObject * +__Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) +{ + if (unlikely(op->func_dict == NULL)) { + op->func_dict = PyDict_New(); + if (unlikely(op->func_dict == NULL)) + return NULL; + } + Py_INCREF(op->func_dict); + return op->func_dict; +} +static int +__Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context) +{ + PyObject *tmp; + if (unlikely(value == NULL)) { + PyErr_SetString(PyExc_TypeError, + "function's dictionary may not be deleted"); + return -1; + } + if (unlikely(!PyDict_Check(value))) { + PyErr_SetString(PyExc_TypeError, + "setting function's dictionary to a non-dict"); + return -1; + } + tmp = op->func_dict; + Py_INCREF(value); + op->func_dict = value; + Py_XDECREF(tmp); + return 0; +} +static PyObject * +__Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) +{ + Py_INCREF(op->func_globals); + return op->func_globals; +} +static PyObject * +__Pyx_CyFunction_get_closure(CYTHON_UNUSED __pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) +{ + Py_INCREF(Py_None); + return Py_None; +} +static PyObject * +__Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) +{ + PyObject* result = (op->func_code) ? op->func_code : Py_None; + Py_INCREF(result); + return result; +} +static int +__Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) { + int result = 0; + PyObject *res = op->defaults_getter((PyObject *) op); + if (unlikely(!res)) + return -1; + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + op->defaults_tuple = PyTuple_GET_ITEM(res, 0); + Py_INCREF(op->defaults_tuple); + op->defaults_kwdict = PyTuple_GET_ITEM(res, 1); + Py_INCREF(op->defaults_kwdict); + #else + op->defaults_tuple = PySequence_ITEM(res, 0); + if (unlikely(!op->defaults_tuple)) result = -1; + else { + op->defaults_kwdict = PySequence_ITEM(res, 1); + if (unlikely(!op->defaults_kwdict)) result = -1; + } + #endif + Py_DECREF(res); + return result; +} +static int +__Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value, CYTHON_UNUSED void *context) { + PyObject* tmp; + if (!value) { + value = Py_None; + } else if (value != Py_None && !PyTuple_Check(value)) { + PyErr_SetString(PyExc_TypeError, + "__defaults__ must be set to a tuple object"); + return -1; + } + Py_INCREF(value); + tmp = op->defaults_tuple; + op->defaults_tuple = value; + Py_XDECREF(tmp); + return 0; +} +static PyObject * +__Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) { + PyObject* result = op->defaults_tuple; + if (unlikely(!result)) { + if (op->defaults_getter) { + if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL; + result = op->defaults_tuple; + } else { + result = Py_None; + } + } + Py_INCREF(result); + return result; +} +static int +__Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value, CYTHON_UNUSED void *context) { + PyObject* tmp; + if (!value) { + value = Py_None; + } else if (value != Py_None && !PyDict_Check(value)) { + PyErr_SetString(PyExc_TypeError, + "__kwdefaults__ must be set to a dict object"); + return -1; + } + Py_INCREF(value); + tmp = op->defaults_kwdict; + op->defaults_kwdict = value; + Py_XDECREF(tmp); + return 0; +} +static PyObject * +__Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) { + PyObject* result = op->defaults_kwdict; + if (unlikely(!result)) { + if (op->defaults_getter) { + if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL; + result = op->defaults_kwdict; + } else { + result = Py_None; + } + } + Py_INCREF(result); + return result; +} +static int +__Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value, CYTHON_UNUSED void *context) { + PyObject* tmp; + if (!value || value == Py_None) { + value = NULL; + } else if (!PyDict_Check(value)) { + PyErr_SetString(PyExc_TypeError, + "__annotations__ must be set to a dict object"); + return -1; + } + Py_XINCREF(value); + tmp = op->func_annotations; + op->func_annotations = value; + Py_XDECREF(tmp); + return 0; +} +static PyObject * +__Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) { + PyObject* result = op->func_annotations; + if (unlikely(!result)) { + result = PyDict_New(); + if (unlikely(!result)) return NULL; + op->func_annotations = result; + } + Py_INCREF(result); + return result; +} +static PyGetSetDef __pyx_CyFunction_getsets[] = { + {(char *) "func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0}, + {(char *) "__doc__", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0}, + {(char *) "func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0}, + {(char *) "__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0}, + {(char *) "__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0}, + {(char *) "__self__", (getter)__Pyx_CyFunction_get_self, 0, 0, 0}, + {(char *) "func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0}, + {(char *) "__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0}, + {(char *) "func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0}, + {(char *) "__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0}, + {(char *) "func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0}, + {(char *) "__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0}, + {(char *) "func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0}, + {(char *) "__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0}, + {(char *) "func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0}, + {(char *) "__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0}, + {(char *) "__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0}, + {(char *) "__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0}, + {0, 0, 0, 0, 0} +}; +static PyMemberDef __pyx_CyFunction_members[] = { + {(char *) "__module__", T_OBJECT, offsetof(PyCFunctionObject, m_module), PY_WRITE_RESTRICTED, 0}, + {0, 0, 0, 0, 0} +}; +static PyObject * +__Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, CYTHON_UNUSED PyObject *args) +{ +#if PY_MAJOR_VERSION >= 3 + Py_INCREF(m->func_qualname); + return m->func_qualname; +#else + return PyString_FromString(m->func.m_ml->ml_name); +#endif +} +static PyMethodDef __pyx_CyFunction_methods[] = { + {"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0}, + {0, 0, 0, 0} +}; +#if PY_VERSION_HEX < 0x030500A0 +#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func_weakreflist) +#else +#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func.m_weakreflist) +#endif +static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject *op, PyMethodDef *ml, int flags, PyObject* qualname, + PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) { + if (unlikely(op == NULL)) + return NULL; + op->flags = flags; + __Pyx_CyFunction_weakreflist(op) = NULL; + op->func.m_ml = ml; + op->func.m_self = (PyObject *) op; + Py_XINCREF(closure); + op->func_closure = closure; + Py_XINCREF(module); + op->func.m_module = module; + op->func_dict = NULL; + op->func_name = NULL; + Py_INCREF(qualname); + op->func_qualname = qualname; + op->func_doc = NULL; + op->func_classobj = NULL; + op->func_globals = globals; + Py_INCREF(op->func_globals); + Py_XINCREF(code); + op->func_code = code; + op->defaults_pyobjects = 0; + op->defaults_size = 0; + op->defaults = NULL; + op->defaults_tuple = NULL; + op->defaults_kwdict = NULL; + op->defaults_getter = NULL; + op->func_annotations = NULL; + return (PyObject *) op; +} +static int +__Pyx_CyFunction_clear(__pyx_CyFunctionObject *m) +{ + Py_CLEAR(m->func_closure); + Py_CLEAR(m->func.m_module); + Py_CLEAR(m->func_dict); + Py_CLEAR(m->func_name); + Py_CLEAR(m->func_qualname); + Py_CLEAR(m->func_doc); + Py_CLEAR(m->func_globals); + Py_CLEAR(m->func_code); + Py_CLEAR(m->func_classobj); + Py_CLEAR(m->defaults_tuple); + Py_CLEAR(m->defaults_kwdict); + Py_CLEAR(m->func_annotations); + if (m->defaults) { + PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m); + int i; + for (i = 0; i < m->defaults_pyobjects; i++) + Py_XDECREF(pydefaults[i]); + PyObject_Free(m->defaults); + m->defaults = NULL; + } + return 0; +} +static void __Pyx__CyFunction_dealloc(__pyx_CyFunctionObject *m) +{ + if (__Pyx_CyFunction_weakreflist(m) != NULL) + PyObject_ClearWeakRefs((PyObject *) m); + __Pyx_CyFunction_clear(m); + PyObject_GC_Del(m); +} +static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m) +{ + PyObject_GC_UnTrack(m); + __Pyx__CyFunction_dealloc(m); +} +static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg) +{ + Py_VISIT(m->func_closure); + Py_VISIT(m->func.m_module); + Py_VISIT(m->func_dict); + Py_VISIT(m->func_name); + Py_VISIT(m->func_qualname); + Py_VISIT(m->func_doc); + Py_VISIT(m->func_globals); + Py_VISIT(m->func_code); + Py_VISIT(m->func_classobj); + Py_VISIT(m->defaults_tuple); + Py_VISIT(m->defaults_kwdict); + if (m->defaults) { + PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m); + int i; + for (i = 0; i < m->defaults_pyobjects; i++) + Py_VISIT(pydefaults[i]); + } + return 0; +} +static PyObject *__Pyx_CyFunction_descr_get(PyObject *func, PyObject *obj, PyObject *type) +{ +#if PY_MAJOR_VERSION < 3 + __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; + if (m->flags & __Pyx_CYFUNCTION_STATICMETHOD) { + Py_INCREF(func); + return func; + } + if (m->flags & __Pyx_CYFUNCTION_CLASSMETHOD) { + if (type == NULL) + type = (PyObject *)(Py_TYPE(obj)); + return __Pyx_PyMethod_New(func, type, (PyObject *)(Py_TYPE(type))); + } + if (obj == Py_None) + obj = NULL; +#endif + return __Pyx_PyMethod_New(func, obj, type); +} +static PyObject* +__Pyx_CyFunction_repr(__pyx_CyFunctionObject *op) +{ +#if PY_MAJOR_VERSION >= 3 + return PyUnicode_FromFormat("", + op->func_qualname, (void *)op); +#else + return PyString_FromFormat("", + PyString_AsString(op->func_qualname), (void *)op); +#endif +} +static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, PyObject *arg, PyObject *kw) { + PyCFunctionObject* f = (PyCFunctionObject*)func; + PyCFunction meth = f->m_ml->ml_meth; + Py_ssize_t size; + switch (f->m_ml->ml_flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) { + case METH_VARARGS: + if (likely(kw == NULL || PyDict_Size(kw) == 0)) + return (*meth)(self, arg); + break; + case METH_VARARGS | METH_KEYWORDS: + return (*(PyCFunctionWithKeywords)(void*)meth)(self, arg, kw); + case METH_NOARGS: + if (likely(kw == NULL || PyDict_Size(kw) == 0)) { + size = PyTuple_GET_SIZE(arg); + if (likely(size == 0)) + return (*meth)(self, NULL); + PyErr_Format(PyExc_TypeError, + "%.200s() takes no arguments (%" CYTHON_FORMAT_SSIZE_T "d given)", + f->m_ml->ml_name, size); + return NULL; + } + break; + case METH_O: + if (likely(kw == NULL || PyDict_Size(kw) == 0)) { + size = PyTuple_GET_SIZE(arg); + if (likely(size == 1)) { + PyObject *result, *arg0; + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + arg0 = PyTuple_GET_ITEM(arg, 0); + #else + arg0 = PySequence_ITEM(arg, 0); if (unlikely(!arg0)) return NULL; + #endif + result = (*meth)(self, arg0); + #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS) + Py_DECREF(arg0); + #endif + return result; + } + PyErr_Format(PyExc_TypeError, + "%.200s() takes exactly one argument (%" CYTHON_FORMAT_SSIZE_T "d given)", + f->m_ml->ml_name, size); + return NULL; + } + break; + default: + PyErr_SetString(PyExc_SystemError, "Bad call flags in " + "__Pyx_CyFunction_Call. METH_OLDARGS is no " + "longer supported!"); + return NULL; + } + PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments", + f->m_ml->ml_name); + return NULL; +} +static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) { + return __Pyx_CyFunction_CallMethod(func, ((PyCFunctionObject*)func)->m_self, arg, kw); +} +static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, PyObject *kw) { + PyObject *result; + __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func; + if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) { + Py_ssize_t argc; + PyObject *new_args; + PyObject *self; + argc = PyTuple_GET_SIZE(args); + new_args = PyTuple_GetSlice(args, 1, argc); + if (unlikely(!new_args)) + return NULL; + self = PyTuple_GetItem(args, 0); + if (unlikely(!self)) { + Py_DECREF(new_args); + return NULL; + } + result = __Pyx_CyFunction_CallMethod(func, self, new_args, kw); + Py_DECREF(new_args); + } else { + result = __Pyx_CyFunction_Call(func, args, kw); + } + return result; +} +static PyTypeObject __pyx_CyFunctionType_type = { + PyVarObject_HEAD_INIT(0, 0) + "cython_function_or_method", + sizeof(__pyx_CyFunctionObject), + 0, + (destructor) __Pyx_CyFunction_dealloc, + 0, + 0, + 0, +#if PY_MAJOR_VERSION < 3 + 0, +#else + 0, +#endif + (reprfunc) __Pyx_CyFunction_repr, + 0, + 0, + 0, + 0, + __Pyx_CyFunction_CallAsMethod, + 0, + 0, + 0, + 0, + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, + 0, + (traverseproc) __Pyx_CyFunction_traverse, + (inquiry) __Pyx_CyFunction_clear, + 0, +#if PY_VERSION_HEX < 0x030500A0 + offsetof(__pyx_CyFunctionObject, func_weakreflist), +#else + offsetof(PyCFunctionObject, m_weakreflist), +#endif + 0, + 0, + __pyx_CyFunction_methods, + __pyx_CyFunction_members, + __pyx_CyFunction_getsets, + 0, + 0, + __Pyx_CyFunction_descr_get, + 0, + offsetof(__pyx_CyFunctionObject, func_dict), + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, +#if PY_VERSION_HEX >= 0x030400a1 + 0, +#endif +#if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800) + 0, +#endif +#if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000 + 0, +#endif +#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 + 0, +#endif +}; +static int __pyx_CyFunction_init(void) { + __pyx_CyFunctionType = __Pyx_FetchCommonType(&__pyx_CyFunctionType_type); + if (unlikely(__pyx_CyFunctionType == NULL)) { + return -1; + } + return 0; +} +static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects) { + __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; + m->defaults = PyObject_Malloc(size); + if (unlikely(!m->defaults)) + return PyErr_NoMemory(); + memset(m->defaults, 0, size); + m->defaults_pyobjects = pyobjects; + m->defaults_size = size; + return m->defaults; +} +static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) { + __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; + m->defaults_tuple = tuple; + Py_INCREF(tuple); +} +static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) { + __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; + m->defaults_kwdict = dict; + Py_INCREF(dict); +} +static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) { + __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; + m->func_annotations = dict; + Py_INCREF(dict); +} + +/* CythonFunction */ +static PyObject *__Pyx_CyFunction_New(PyMethodDef *ml, int flags, PyObject* qualname, + PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) { + PyObject *op = __Pyx_CyFunction_Init( + PyObject_GC_New(__pyx_CyFunctionObject, __pyx_CyFunctionType), + ml, flags, qualname, closure, module, globals, code + ); + if (likely(op)) { + PyObject_GC_Track(op); + } + return op; +} + +/* DictGetItem */ +#if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY +static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) { + PyObject *value; + value = PyDict_GetItemWithError(d, key); + if (unlikely(!value)) { + if (!PyErr_Occurred()) { + if (unlikely(PyTuple_Check(key))) { + PyObject* args = PyTuple_Pack(1, key); + if (likely(args)) { + PyErr_SetObject(PyExc_KeyError, args); + Py_DECREF(args); + } + } else { + PyErr_SetObject(PyExc_KeyError, key); + } + } + return NULL; + } + Py_INCREF(value); + return value; +} +#endif + +/* GetTopmostException */ +#if CYTHON_USE_EXC_INFO_STACK +static _PyErr_StackItem * +__Pyx_PyErr_GetTopmostException(PyThreadState *tstate) +{ + _PyErr_StackItem *exc_info = tstate->exc_info; + while ((exc_info->exc_type == NULL || exc_info->exc_type == Py_None) && + exc_info->previous_item != NULL) + { + exc_info = exc_info->previous_item; + } + return exc_info; +} +#endif + +/* SaveResetException */ +#if CYTHON_FAST_THREAD_STATE +static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { + #if CYTHON_USE_EXC_INFO_STACK + _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate); + *type = exc_info->exc_type; + *value = exc_info->exc_value; + *tb = exc_info->exc_traceback; + #else + *type = tstate->exc_type; + *value = tstate->exc_value; + *tb = tstate->exc_traceback; + #endif + Py_XINCREF(*type); + Py_XINCREF(*value); + Py_XINCREF(*tb); +} +static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { + PyObject *tmp_type, *tmp_value, *tmp_tb; + #if CYTHON_USE_EXC_INFO_STACK + _PyErr_StackItem *exc_info = tstate->exc_info; + tmp_type = exc_info->exc_type; + tmp_value = exc_info->exc_value; + tmp_tb = exc_info->exc_traceback; + exc_info->exc_type = type; + exc_info->exc_value = value; + exc_info->exc_traceback = tb; + #else + tmp_type = tstate->exc_type; + tmp_value = tstate->exc_value; + tmp_tb = tstate->exc_traceback; + tstate->exc_type = type; + tstate->exc_value = value; + tstate->exc_traceback = tb; + #endif + Py_XDECREF(tmp_type); + Py_XDECREF(tmp_value); + Py_XDECREF(tmp_tb); +} +#endif + +/* PyErrExceptionMatches */ +#if CYTHON_FAST_THREAD_STATE +static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) { + Py_ssize_t i, n; + n = PyTuple_GET_SIZE(tuple); +#if PY_MAJOR_VERSION >= 3 + for (i=0; icurexc_type; + if (exc_type == err) return 1; + if (unlikely(!exc_type)) return 0; + if (unlikely(PyTuple_Check(err))) + return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err); + return __Pyx_PyErr_GivenExceptionMatches(exc_type, err); +} +#endif + +/* PyObject_GenericGetAttrNoDict */ +#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000 +static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) { + PyErr_Format(PyExc_AttributeError, +#if PY_MAJOR_VERSION >= 3 + "'%.50s' object has no attribute '%U'", + tp->tp_name, attr_name); +#else + "'%.50s' object has no attribute '%.400s'", + tp->tp_name, PyString_AS_STRING(attr_name)); +#endif + return NULL; +} +static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) { + PyObject *descr; + PyTypeObject *tp = Py_TYPE(obj); + if (unlikely(!PyString_Check(attr_name))) { + return PyObject_GenericGetAttr(obj, attr_name); + } + assert(!tp->tp_dictoffset); + descr = _PyType_Lookup(tp, attr_name); + if (unlikely(!descr)) { + return __Pyx_RaiseGenericGetAttributeError(tp, attr_name); + } + Py_INCREF(descr); + #if PY_MAJOR_VERSION < 3 + if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS))) + #endif + { + descrgetfunc f = Py_TYPE(descr)->tp_descr_get; + if (unlikely(f)) { + PyObject *res = f(descr, obj, (PyObject *)tp); + Py_DECREF(descr); + return res; + } + } + return descr; +} +#endif + +/* SetVTable */ +static int __Pyx_SetVtable(PyObject *dict, void *vtable) { +#if PY_VERSION_HEX >= 0x02070000 + PyObject *ob = PyCapsule_New(vtable, 0, 0); +#else + PyObject *ob = PyCObject_FromVoidPtr(vtable, 0); +#endif + if (!ob) + goto bad; + if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0) + goto bad; + Py_DECREF(ob); + return 0; +bad: + Py_XDECREF(ob); + return -1; +} + +/* PyObjectGetAttrStrNoError */ +static void __Pyx_PyObject_GetAttrStr_ClearAttributeError(void) { + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + if (likely(__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError))) + __Pyx_PyErr_Clear(); +} +static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name) { + PyObject *result; +#if CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_TYPE_SLOTS && PY_VERSION_HEX >= 0x030700B1 + PyTypeObject* tp = Py_TYPE(obj); + if (likely(tp->tp_getattro == PyObject_GenericGetAttr)) { + return _PyObject_GenericGetAttrWithDict(obj, attr_name, NULL, 1); + } +#endif + result = __Pyx_PyObject_GetAttrStr(obj, attr_name); + if (unlikely(!result)) { + __Pyx_PyObject_GetAttrStr_ClearAttributeError(); + } + return result; +} + +/* SetupReduce */ +static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) { + int ret; + PyObject *name_attr; + name_attr = __Pyx_PyObject_GetAttrStr(meth, __pyx_n_s_name); + if (likely(name_attr)) { + ret = PyObject_RichCompareBool(name_attr, name, Py_EQ); + } else { + ret = -1; + } + if (unlikely(ret < 0)) { + PyErr_Clear(); + ret = 0; + } + Py_XDECREF(name_attr); + return ret; +} +static int __Pyx_setup_reduce(PyObject* type_obj) { + int ret = 0; + PyObject *object_reduce = NULL; + PyObject *object_reduce_ex = NULL; + PyObject *reduce = NULL; + PyObject *reduce_ex = NULL; + PyObject *reduce_cython = NULL; + PyObject *setstate = NULL; + PyObject *setstate_cython = NULL; +#if CYTHON_USE_PYTYPE_LOOKUP + if (_PyType_Lookup((PyTypeObject*)type_obj, __pyx_n_s_getstate)) goto __PYX_GOOD; +#else + if (PyObject_HasAttr(type_obj, __pyx_n_s_getstate)) goto __PYX_GOOD; +#endif +#if CYTHON_USE_PYTYPE_LOOKUP + object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD; +#else + object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD; +#endif + reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_ex); if (unlikely(!reduce_ex)) goto __PYX_BAD; + if (reduce_ex == object_reduce_ex) { +#if CYTHON_USE_PYTYPE_LOOKUP + object_reduce = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD; +#else + object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD; +#endif + reduce = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce); if (unlikely(!reduce)) goto __PYX_BAD; + if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) { + reduce_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_reduce_cython); + if (likely(reduce_cython)) { + ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce, reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD; + ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD; + } else if (reduce == object_reduce || PyErr_Occurred()) { + goto __PYX_BAD; + } + setstate = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate); + if (!setstate) PyErr_Clear(); + if (!setstate || __Pyx_setup_reduce_is_named(setstate, __pyx_n_s_setstate_cython)) { + setstate_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_setstate_cython); + if (likely(setstate_cython)) { + ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate, setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD; + ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD; + } else if (!setstate || PyErr_Occurred()) { + goto __PYX_BAD; + } + } + PyType_Modified((PyTypeObject*)type_obj); + } + } + goto __PYX_GOOD; +__PYX_BAD: + if (!PyErr_Occurred()) + PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name); + ret = -1; +__PYX_GOOD: +#if !CYTHON_USE_PYTYPE_LOOKUP + Py_XDECREF(object_reduce); + Py_XDECREF(object_reduce_ex); +#endif + Py_XDECREF(reduce); + Py_XDECREF(reduce_ex); + Py_XDECREF(reduce_cython); + Py_XDECREF(setstate); + Py_XDECREF(setstate_cython); + return ret; +} + +/* PyObject_GenericGetAttr */ +#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000 +static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name) { + if (unlikely(Py_TYPE(obj)->tp_dictoffset)) { + return PyObject_GenericGetAttr(obj, attr_name); + } + return __Pyx_PyObject_GenericGetAttrNoDict(obj, attr_name); +} +#endif + +/* GetModuleGlobalName */ +#if CYTHON_USE_DICT_VERSIONS +static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value) +#else +static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name) +#endif +{ + PyObject *result; +#if !CYTHON_AVOID_BORROWED_REFS +#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 + result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash); + __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version) + if (likely(result)) { + return __Pyx_NewRef(result); + } else if (unlikely(PyErr_Occurred())) { + return NULL; + } +#else + result = PyDict_GetItem(__pyx_d, name); + __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version) + if (likely(result)) { + return __Pyx_NewRef(result); + } +#endif +#else + result = PyObject_GetItem(__pyx_d, name); + __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version) + if (likely(result)) { + return __Pyx_NewRef(result); + } + PyErr_Clear(); +#endif + return __Pyx_GetBuiltinName(name); +} + +/* CLineInTraceback */ +#ifndef CYTHON_CLINE_IN_TRACEBACK +static int __Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState *tstate, int c_line) { + PyObject *use_cline; + PyObject *ptype, *pvalue, *ptraceback; +#if CYTHON_COMPILING_IN_CPYTHON + PyObject **cython_runtime_dict; +#endif + if (unlikely(!__pyx_cython_runtime)) { + return c_line; + } + __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback); +#if CYTHON_COMPILING_IN_CPYTHON + cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime); + if (likely(cython_runtime_dict)) { + __PYX_PY_DICT_LOOKUP_IF_MODIFIED( + use_cline, *cython_runtime_dict, + __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback)) + } else +#endif + { + PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback); + if (use_cline_obj) { + use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True; + Py_DECREF(use_cline_obj); + } else { + PyErr_Clear(); + use_cline = NULL; + } + } + if (!use_cline) { + c_line = 0; + (void) PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False); + } + else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) { + c_line = 0; + } + __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback); + return c_line; +} +#endif + +/* CodeObjectCache */ +static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { + int start = 0, mid = 0, end = count - 1; + if (end >= 0 && code_line > entries[end].code_line) { + return count; + } + while (start < end) { + mid = start + (end - start) / 2; + if (code_line < entries[mid].code_line) { + end = mid; + } else if (code_line > entries[mid].code_line) { + start = mid + 1; + } else { + return mid; + } + } + if (code_line <= entries[mid].code_line) { + return mid; + } else { + return mid + 1; + } +} +static PyCodeObject *__pyx_find_code_object(int code_line) { + PyCodeObject* code_object; + int pos; + if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) { + return NULL; + } + pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); + if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) { + return NULL; + } + code_object = __pyx_code_cache.entries[pos].code_object; + Py_INCREF(code_object); + return code_object; +} +static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) { + int pos, i; + __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries; + if (unlikely(!code_line)) { + return; + } + if (unlikely(!entries)) { + entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry)); + if (likely(entries)) { + __pyx_code_cache.entries = entries; + __pyx_code_cache.max_count = 64; + __pyx_code_cache.count = 1; + entries[0].code_line = code_line; + entries[0].code_object = code_object; + Py_INCREF(code_object); + } + return; + } + pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); + if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) { + PyCodeObject* tmp = entries[pos].code_object; + entries[pos].code_object = code_object; + Py_DECREF(tmp); + return; + } + if (__pyx_code_cache.count == __pyx_code_cache.max_count) { + int new_max = __pyx_code_cache.max_count + 64; + entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc( + __pyx_code_cache.entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry)); + if (unlikely(!entries)) { + return; + } + __pyx_code_cache.entries = entries; + __pyx_code_cache.max_count = new_max; + } + for (i=__pyx_code_cache.count; i>pos; i--) { + entries[i] = entries[i-1]; + } + entries[pos].code_line = code_line; + entries[pos].code_object = code_object; + __pyx_code_cache.count++; + Py_INCREF(code_object); +} + +/* AddTraceback */ +#include "compile.h" +#include "frameobject.h" +#include "traceback.h" +static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( + const char *funcname, int c_line, + int py_line, const char *filename) { + PyCodeObject *py_code = NULL; + PyObject *py_funcname = NULL; + #if PY_MAJOR_VERSION < 3 + PyObject *py_srcfile = NULL; + py_srcfile = PyString_FromString(filename); + if (!py_srcfile) goto bad; + #endif + if (c_line) { + #if PY_MAJOR_VERSION < 3 + py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); + if (!py_funcname) goto bad; + #else + py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); + if (!py_funcname) goto bad; + funcname = PyUnicode_AsUTF8(py_funcname); + if (!funcname) goto bad; + #endif + } + else { + #if PY_MAJOR_VERSION < 3 + py_funcname = PyString_FromString(funcname); + if (!py_funcname) goto bad; + #endif + } + #if PY_MAJOR_VERSION < 3 + py_code = __Pyx_PyCode_New( + 0, + 0, + 0, + 0, + 0, + __pyx_empty_bytes, /*PyObject *code,*/ + __pyx_empty_tuple, /*PyObject *consts,*/ + __pyx_empty_tuple, /*PyObject *names,*/ + __pyx_empty_tuple, /*PyObject *varnames,*/ + __pyx_empty_tuple, /*PyObject *freevars,*/ + __pyx_empty_tuple, /*PyObject *cellvars,*/ + py_srcfile, /*PyObject *filename,*/ + py_funcname, /*PyObject *name,*/ + py_line, + __pyx_empty_bytes /*PyObject *lnotab*/ + ); + Py_DECREF(py_srcfile); + #else + py_code = PyCode_NewEmpty(filename, funcname, py_line); + #endif + Py_XDECREF(py_funcname); // XDECREF since it's only set on Py3 if cline + return py_code; +bad: + Py_XDECREF(py_funcname); + #if PY_MAJOR_VERSION < 3 + Py_XDECREF(py_srcfile); + #endif + return NULL; +} +static void __Pyx_AddTraceback(const char *funcname, int c_line, + int py_line, const char *filename) { + PyCodeObject *py_code = 0; + PyFrameObject *py_frame = 0; + PyThreadState *tstate = __Pyx_PyThreadState_Current; + if (c_line) { + c_line = __Pyx_CLineForTraceback(tstate, c_line); + } + py_code = __pyx_find_code_object(c_line ? -c_line : py_line); + if (!py_code) { + py_code = __Pyx_CreateCodeObjectForTraceback( + funcname, c_line, py_line, filename); + if (!py_code) goto bad; + __pyx_insert_code_object(c_line ? -c_line : py_line, py_code); + } + py_frame = PyFrame_New( + tstate, /*PyThreadState *tstate,*/ + py_code, /*PyCodeObject *code,*/ + __pyx_d, /*PyObject *globals,*/ + 0 /*PyObject *locals*/ + ); + if (!py_frame) goto bad; + __Pyx_PyFrame_SetLineNumber(py_frame, py_line); + PyTraceBack_Here(py_frame); +bad: + Py_XDECREF(py_code); + Py_XDECREF(py_frame); +} + +/* CIntFromPyVerify */ +#define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\ + __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0) +#define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\ + __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1) +#define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\ + {\ + func_type value = func_value;\ + if (sizeof(target_type) < sizeof(func_type)) {\ + if (unlikely(value != (func_type) (target_type) value)) {\ + func_type zero = 0;\ + if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\ + return (target_type) -1;\ + if (is_unsigned && unlikely(value < zero))\ + goto raise_neg_overflow;\ + else\ + goto raise_overflow;\ + }\ + }\ + return (target_type) value;\ + } + +/* CIntFromPy */ +static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { +#ifdef __Pyx_HAS_GCC_DIAGNOSTIC +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" +#endif + const int neg_one = (int) -1, const_zero = (int) 0; +#ifdef __Pyx_HAS_GCC_DIAGNOSTIC +#pragma GCC diagnostic pop +#endif + const int is_unsigned = neg_one > const_zero; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x))) { + if (sizeof(int) < sizeof(long)) { + __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x)) + } else { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + goto raise_neg_overflow; + } + return (int) val; + } + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { +#if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)x)->ob_digit; + switch (Py_SIZE(x)) { + case 0: return (int) 0; + case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0]) + case 2: + if (8 * sizeof(int) > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) { + return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); + } + } + break; + case 3: + if (8 * sizeof(int) > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) { + return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); + } + } + break; + case 4: + if (8 * sizeof(int) > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) { + return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); + } + } + break; + } +#endif +#if CYTHON_COMPILING_IN_CPYTHON + if (unlikely(Py_SIZE(x) < 0)) { + goto raise_neg_overflow; + } +#else + { + int result = PyObject_RichCompareBool(x, Py_False, Py_LT); + if (unlikely(result < 0)) + return (int) -1; + if (unlikely(result == 1)) + goto raise_neg_overflow; + } +#endif + if (sizeof(int) <= sizeof(unsigned long)) { + __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x)) +#ifdef HAVE_LONG_LONG + } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) +#endif + } + } else { +#if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)x)->ob_digit; + switch (Py_SIZE(x)) { + case 0: return (int) 0; + case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0])) + case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0]) + case -2: + if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { + return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + } + } + break; + case 2: + if (8 * sizeof(int) > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { + return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + } + } + break; + case -3: + if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { + return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + } + } + break; + case 3: + if (8 * sizeof(int) > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { + return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + } + } + break; + case -4: + if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { + return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + } + } + break; + case 4: + if (8 * sizeof(int) > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { + return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + } + } + break; + } +#endif + if (sizeof(int) <= sizeof(long)) { + __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x)) +#ifdef HAVE_LONG_LONG + } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x)) +#endif + } + } + { +#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) + PyErr_SetString(PyExc_RuntimeError, + "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); +#else + int val; + PyObject *v = __Pyx_PyNumber_IntOrLong(x); + #if PY_MAJOR_VERSION < 3 + if (likely(v) && !PyLong_Check(v)) { + PyObject *tmp = v; + v = PyNumber_Long(tmp); + Py_DECREF(tmp); + } + #endif + if (likely(v)) { + int one = 1; int is_little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&val; + int ret = _PyLong_AsByteArray((PyLongObject *)v, + bytes, sizeof(val), + is_little, !is_unsigned); + Py_DECREF(v); + if (likely(!ret)) + return val; + } +#endif + return (int) -1; + } + } else { + int val; + PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); + if (!tmp) return (int) -1; + val = __Pyx_PyInt_As_int(tmp); + Py_DECREF(tmp); + return val; + } +raise_overflow: + PyErr_SetString(PyExc_OverflowError, + "value too large to convert to int"); + return (int) -1; +raise_neg_overflow: + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to int"); + return (int) -1; +} + +/* CIntFromPy */ +static CYTHON_INLINE unsigned int __Pyx_PyInt_As_unsigned_int(PyObject *x) { +#ifdef __Pyx_HAS_GCC_DIAGNOSTIC +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" +#endif + const unsigned int neg_one = (unsigned int) -1, const_zero = (unsigned int) 0; +#ifdef __Pyx_HAS_GCC_DIAGNOSTIC +#pragma GCC diagnostic pop +#endif + const int is_unsigned = neg_one > const_zero; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x))) { + if (sizeof(unsigned int) < sizeof(long)) { + __PYX_VERIFY_RETURN_INT(unsigned int, long, PyInt_AS_LONG(x)) + } else { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + goto raise_neg_overflow; + } + return (unsigned int) val; + } + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { +#if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)x)->ob_digit; + switch (Py_SIZE(x)) { + case 0: return (unsigned int) 0; + case 1: __PYX_VERIFY_RETURN_INT(unsigned int, digit, digits[0]) + case 2: + if (8 * sizeof(unsigned int) > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(unsigned int) >= 2 * PyLong_SHIFT) { + return (unsigned int) (((((unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])); + } + } + break; + case 3: + if (8 * sizeof(unsigned int) > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(unsigned int) >= 3 * PyLong_SHIFT) { + return (unsigned int) (((((((unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])); + } + } + break; + case 4: + if (8 * sizeof(unsigned int) > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(unsigned int) >= 4 * PyLong_SHIFT) { + return (unsigned int) (((((((((unsigned int)digits[3]) << PyLong_SHIFT) | (unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])); + } + } + break; + } +#endif +#if CYTHON_COMPILING_IN_CPYTHON + if (unlikely(Py_SIZE(x) < 0)) { + goto raise_neg_overflow; + } +#else + { + int result = PyObject_RichCompareBool(x, Py_False, Py_LT); + if (unlikely(result < 0)) + return (unsigned int) -1; + if (unlikely(result == 1)) + goto raise_neg_overflow; + } +#endif + if (sizeof(unsigned int) <= sizeof(unsigned long)) { + __PYX_VERIFY_RETURN_INT_EXC(unsigned int, unsigned long, PyLong_AsUnsignedLong(x)) +#ifdef HAVE_LONG_LONG + } else if (sizeof(unsigned int) <= sizeof(unsigned PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC(unsigned int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) +#endif + } + } else { +#if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)x)->ob_digit; + switch (Py_SIZE(x)) { + case 0: return (unsigned int) 0; + case -1: __PYX_VERIFY_RETURN_INT(unsigned int, sdigit, (sdigit) (-(sdigit)digits[0])) + case 1: __PYX_VERIFY_RETURN_INT(unsigned int, digit, +digits[0]) + case -2: + if (8 * sizeof(unsigned int) - 1 > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(unsigned int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(unsigned int) - 1 > 2 * PyLong_SHIFT) { + return (unsigned int) (((unsigned int)-1)*(((((unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]))); + } + } + break; + case 2: + if (8 * sizeof(unsigned int) > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(unsigned int) - 1 > 2 * PyLong_SHIFT) { + return (unsigned int) ((((((unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]))); + } + } + break; + case -3: + if (8 * sizeof(unsigned int) - 1 > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(unsigned int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(unsigned int) - 1 > 3 * PyLong_SHIFT) { + return (unsigned int) (((unsigned int)-1)*(((((((unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]))); + } + } + break; + case 3: + if (8 * sizeof(unsigned int) > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(unsigned int) - 1 > 3 * PyLong_SHIFT) { + return (unsigned int) ((((((((unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]))); + } + } + break; + case -4: + if (8 * sizeof(unsigned int) - 1 > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(unsigned int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(unsigned int) - 1 > 4 * PyLong_SHIFT) { + return (unsigned int) (((unsigned int)-1)*(((((((((unsigned int)digits[3]) << PyLong_SHIFT) | (unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]))); + } + } + break; + case 4: + if (8 * sizeof(unsigned int) > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(unsigned int) - 1 > 4 * PyLong_SHIFT) { + return (unsigned int) ((((((((((unsigned int)digits[3]) << PyLong_SHIFT) | (unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]))); + } + } + break; + } +#endif + if (sizeof(unsigned int) <= sizeof(long)) { + __PYX_VERIFY_RETURN_INT_EXC(unsigned int, long, PyLong_AsLong(x)) +#ifdef HAVE_LONG_LONG + } else if (sizeof(unsigned int) <= sizeof(PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC(unsigned int, PY_LONG_LONG, PyLong_AsLongLong(x)) +#endif + } + } + { +#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) + PyErr_SetString(PyExc_RuntimeError, + "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); +#else + unsigned int val; + PyObject *v = __Pyx_PyNumber_IntOrLong(x); + #if PY_MAJOR_VERSION < 3 + if (likely(v) && !PyLong_Check(v)) { + PyObject *tmp = v; + v = PyNumber_Long(tmp); + Py_DECREF(tmp); + } + #endif + if (likely(v)) { + int one = 1; int is_little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&val; + int ret = _PyLong_AsByteArray((PyLongObject *)v, + bytes, sizeof(val), + is_little, !is_unsigned); + Py_DECREF(v); + if (likely(!ret)) + return val; + } +#endif + return (unsigned int) -1; + } + } else { + unsigned int val; + PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); + if (!tmp) return (unsigned int) -1; + val = __Pyx_PyInt_As_unsigned_int(tmp); + Py_DECREF(tmp); + return val; + } +raise_overflow: + PyErr_SetString(PyExc_OverflowError, + "value too large to convert to unsigned int"); + return (unsigned int) -1; +raise_neg_overflow: + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to unsigned int"); + return (unsigned int) -1; +} + +/* CIntToPy */ +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) { +#ifdef __Pyx_HAS_GCC_DIAGNOSTIC +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" +#endif + const int neg_one = (int) -1, const_zero = (int) 0; +#ifdef __Pyx_HAS_GCC_DIAGNOSTIC +#pragma GCC diagnostic pop +#endif + const int is_unsigned = neg_one > const_zero; + if (is_unsigned) { + if (sizeof(int) < sizeof(long)) { + return PyInt_FromLong((long) value); + } else if (sizeof(int) <= sizeof(unsigned long)) { + return PyLong_FromUnsignedLong((unsigned long) value); +#ifdef HAVE_LONG_LONG + } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { + return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); +#endif + } + } else { + if (sizeof(int) <= sizeof(long)) { + return PyInt_FromLong((long) value); +#ifdef HAVE_LONG_LONG + } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { + return PyLong_FromLongLong((PY_LONG_LONG) value); +#endif + } + } + { + int one = 1; int little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&value; + return _PyLong_FromByteArray(bytes, sizeof(int), + little, !is_unsigned); + } +} + +/* CIntToPy */ +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { +#ifdef __Pyx_HAS_GCC_DIAGNOSTIC +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" +#endif + const long neg_one = (long) -1, const_zero = (long) 0; +#ifdef __Pyx_HAS_GCC_DIAGNOSTIC +#pragma GCC diagnostic pop +#endif + const int is_unsigned = neg_one > const_zero; + if (is_unsigned) { + if (sizeof(long) < sizeof(long)) { + return PyInt_FromLong((long) value); + } else if (sizeof(long) <= sizeof(unsigned long)) { + return PyLong_FromUnsignedLong((unsigned long) value); +#ifdef HAVE_LONG_LONG + } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { + return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); +#endif + } + } else { + if (sizeof(long) <= sizeof(long)) { + return PyInt_FromLong((long) value); +#ifdef HAVE_LONG_LONG + } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { + return PyLong_FromLongLong((PY_LONG_LONG) value); +#endif + } + } + { + int one = 1; int little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&value; + return _PyLong_FromByteArray(bytes, sizeof(long), + little, !is_unsigned); + } +} + +/* CIntToPy */ +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_int(unsigned int value) { +#ifdef __Pyx_HAS_GCC_DIAGNOSTIC +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" +#endif + const unsigned int neg_one = (unsigned int) -1, const_zero = (unsigned int) 0; +#ifdef __Pyx_HAS_GCC_DIAGNOSTIC +#pragma GCC diagnostic pop +#endif + const int is_unsigned = neg_one > const_zero; + if (is_unsigned) { + if (sizeof(unsigned int) < sizeof(long)) { + return PyInt_FromLong((long) value); + } else if (sizeof(unsigned int) <= sizeof(unsigned long)) { + return PyLong_FromUnsignedLong((unsigned long) value); +#ifdef HAVE_LONG_LONG + } else if (sizeof(unsigned int) <= sizeof(unsigned PY_LONG_LONG)) { + return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); +#endif + } + } else { + if (sizeof(unsigned int) <= sizeof(long)) { + return PyInt_FromLong((long) value); +#ifdef HAVE_LONG_LONG + } else if (sizeof(unsigned int) <= sizeof(PY_LONG_LONG)) { + return PyLong_FromLongLong((PY_LONG_LONG) value); +#endif + } + } + { + int one = 1; int little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&value; + return _PyLong_FromByteArray(bytes, sizeof(unsigned int), + little, !is_unsigned); + } +} + +/* CIntFromPy */ +static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *x) { +#ifdef __Pyx_HAS_GCC_DIAGNOSTIC +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" +#endif + const size_t neg_one = (size_t) -1, const_zero = (size_t) 0; +#ifdef __Pyx_HAS_GCC_DIAGNOSTIC +#pragma GCC diagnostic pop +#endif + const int is_unsigned = neg_one > const_zero; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x))) { + if (sizeof(size_t) < sizeof(long)) { + __PYX_VERIFY_RETURN_INT(size_t, long, PyInt_AS_LONG(x)) + } else { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + goto raise_neg_overflow; + } + return (size_t) val; + } + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { +#if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)x)->ob_digit; + switch (Py_SIZE(x)) { + case 0: return (size_t) 0; + case 1: __PYX_VERIFY_RETURN_INT(size_t, digit, digits[0]) + case 2: + if (8 * sizeof(size_t) > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(size_t) >= 2 * PyLong_SHIFT) { + return (size_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); + } + } + break; + case 3: + if (8 * sizeof(size_t) > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(size_t) >= 3 * PyLong_SHIFT) { + return (size_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); + } + } + break; + case 4: + if (8 * sizeof(size_t) > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(size_t) >= 4 * PyLong_SHIFT) { + return (size_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); + } + } + break; + } +#endif +#if CYTHON_COMPILING_IN_CPYTHON + if (unlikely(Py_SIZE(x) < 0)) { + goto raise_neg_overflow; + } +#else + { + int result = PyObject_RichCompareBool(x, Py_False, Py_LT); + if (unlikely(result < 0)) + return (size_t) -1; + if (unlikely(result == 1)) + goto raise_neg_overflow; + } +#endif + if (sizeof(size_t) <= sizeof(unsigned long)) { + __PYX_VERIFY_RETURN_INT_EXC(size_t, unsigned long, PyLong_AsUnsignedLong(x)) +#ifdef HAVE_LONG_LONG + } else if (sizeof(size_t) <= sizeof(unsigned PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC(size_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) +#endif + } + } else { +#if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)x)->ob_digit; + switch (Py_SIZE(x)) { + case 0: return (size_t) 0; + case -1: __PYX_VERIFY_RETURN_INT(size_t, sdigit, (sdigit) (-(sdigit)digits[0])) + case 1: __PYX_VERIFY_RETURN_INT(size_t, digit, +digits[0]) + case -2: + if (8 * sizeof(size_t) - 1 > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) { + return (size_t) (((size_t)-1)*(((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]))); + } + } + break; + case 2: + if (8 * sizeof(size_t) > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) { + return (size_t) ((((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]))); + } + } + break; + case -3: + if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) { + return (size_t) (((size_t)-1)*(((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]))); + } + } + break; + case 3: + if (8 * sizeof(size_t) > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) { + return (size_t) ((((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]))); + } + } + break; + case -4: + if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(size_t) - 1 > 4 * PyLong_SHIFT) { + return (size_t) (((size_t)-1)*(((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]))); + } + } + break; + case 4: + if (8 * sizeof(size_t) > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(size_t) - 1 > 4 * PyLong_SHIFT) { + return (size_t) ((((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]))); + } + } + break; + } +#endif + if (sizeof(size_t) <= sizeof(long)) { + __PYX_VERIFY_RETURN_INT_EXC(size_t, long, PyLong_AsLong(x)) +#ifdef HAVE_LONG_LONG + } else if (sizeof(size_t) <= sizeof(PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC(size_t, PY_LONG_LONG, PyLong_AsLongLong(x)) +#endif + } + } + { +#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) + PyErr_SetString(PyExc_RuntimeError, + "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); +#else + size_t val; + PyObject *v = __Pyx_PyNumber_IntOrLong(x); + #if PY_MAJOR_VERSION < 3 + if (likely(v) && !PyLong_Check(v)) { + PyObject *tmp = v; + v = PyNumber_Long(tmp); + Py_DECREF(tmp); + } + #endif + if (likely(v)) { + int one = 1; int is_little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&val; + int ret = _PyLong_AsByteArray((PyLongObject *)v, + bytes, sizeof(val), + is_little, !is_unsigned); + Py_DECREF(v); + if (likely(!ret)) + return val; + } +#endif + return (size_t) -1; + } + } else { + size_t val; + PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); + if (!tmp) return (size_t) -1; + val = __Pyx_PyInt_As_size_t(tmp); + Py_DECREF(tmp); + return val; + } +raise_overflow: + PyErr_SetString(PyExc_OverflowError, + "value too large to convert to size_t"); + return (size_t) -1; +raise_neg_overflow: + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to size_t"); + return (size_t) -1; +} + +/* CIntFromPy */ +static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { +#ifdef __Pyx_HAS_GCC_DIAGNOSTIC +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" +#endif + const long neg_one = (long) -1, const_zero = (long) 0; +#ifdef __Pyx_HAS_GCC_DIAGNOSTIC +#pragma GCC diagnostic pop +#endif + const int is_unsigned = neg_one > const_zero; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x))) { + if (sizeof(long) < sizeof(long)) { + __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x)) + } else { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + goto raise_neg_overflow; + } + return (long) val; + } + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { +#if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)x)->ob_digit; + switch (Py_SIZE(x)) { + case 0: return (long) 0; + case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0]) + case 2: + if (8 * sizeof(long) > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) { + return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); + } + } + break; + case 3: + if (8 * sizeof(long) > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) { + return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); + } + } + break; + case 4: + if (8 * sizeof(long) > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) { + return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); + } + } + break; + } +#endif +#if CYTHON_COMPILING_IN_CPYTHON + if (unlikely(Py_SIZE(x) < 0)) { + goto raise_neg_overflow; + } +#else + { + int result = PyObject_RichCompareBool(x, Py_False, Py_LT); + if (unlikely(result < 0)) + return (long) -1; + if (unlikely(result == 1)) + goto raise_neg_overflow; + } +#endif + if (sizeof(long) <= sizeof(unsigned long)) { + __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x)) +#ifdef HAVE_LONG_LONG + } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) +#endif + } + } else { +#if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)x)->ob_digit; + switch (Py_SIZE(x)) { + case 0: return (long) 0; + case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0])) + case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0]) + case -2: + if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { + return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); + } + } + break; + case 2: + if (8 * sizeof(long) > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { + return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); + } + } + break; + case -3: + if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { + return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); + } + } + break; + case 3: + if (8 * sizeof(long) > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { + return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); + } + } + break; + case -4: + if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { + return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); + } + } + break; + case 4: + if (8 * sizeof(long) > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { + return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); + } + } + break; + } +#endif + if (sizeof(long) <= sizeof(long)) { + __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x)) +#ifdef HAVE_LONG_LONG + } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x)) +#endif + } + } + { +#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) + PyErr_SetString(PyExc_RuntimeError, + "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); +#else + long val; + PyObject *v = __Pyx_PyNumber_IntOrLong(x); + #if PY_MAJOR_VERSION < 3 + if (likely(v) && !PyLong_Check(v)) { + PyObject *tmp = v; + v = PyNumber_Long(tmp); + Py_DECREF(tmp); + } + #endif + if (likely(v)) { + int one = 1; int is_little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&val; + int ret = _PyLong_AsByteArray((PyLongObject *)v, + bytes, sizeof(val), + is_little, !is_unsigned); + Py_DECREF(v); + if (likely(!ret)) + return val; + } +#endif + return (long) -1; + } + } else { + long val; + PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); + if (!tmp) return (long) -1; + val = __Pyx_PyInt_As_long(tmp); + Py_DECREF(tmp); + return val; + } +raise_overflow: + PyErr_SetString(PyExc_OverflowError, + "value too large to convert to long"); + return (long) -1; +raise_neg_overflow: + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to long"); + return (long) -1; +} + +/* FastTypeChecks */ +#if CYTHON_COMPILING_IN_CPYTHON +static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) { + while (a) { + a = a->tp_base; + if (a == b) + return 1; + } + return b == &PyBaseObject_Type; +} +static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) { + PyObject *mro; + if (a == b) return 1; + mro = a->tp_mro; + if (likely(mro)) { + Py_ssize_t i, n; + n = PyTuple_GET_SIZE(mro); + for (i = 0; i < n; i++) { + if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b) + return 1; + } + return 0; + } + return __Pyx_InBases(a, b); +} +#if PY_MAJOR_VERSION == 2 +static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) { + PyObject *exception, *value, *tb; + int res; + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ErrFetch(&exception, &value, &tb); + res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0; + if (unlikely(res == -1)) { + PyErr_WriteUnraisable(err); + res = 0; + } + if (!res) { + res = PyObject_IsSubclass(err, exc_type2); + if (unlikely(res == -1)) { + PyErr_WriteUnraisable(err); + res = 0; + } + } + __Pyx_ErrRestore(exception, value, tb); + return res; +} +#else +static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) { + int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0; + if (!res) { + res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2); + } + return res; +} +#endif +static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) { + Py_ssize_t i, n; + assert(PyExceptionClass_Check(exc_type)); + n = PyTuple_GET_SIZE(tuple); +#if PY_MAJOR_VERSION >= 3 + for (i=0; iexc_info; + tmp_type = exc_info->exc_type; + tmp_value = exc_info->exc_value; + tmp_tb = exc_info->exc_traceback; + exc_info->exc_type = *type; + exc_info->exc_value = *value; + exc_info->exc_traceback = *tb; + #else + tmp_type = tstate->exc_type; + tmp_value = tstate->exc_value; + tmp_tb = tstate->exc_traceback; + tstate->exc_type = *type; + tstate->exc_value = *value; + tstate->exc_traceback = *tb; + #endif + *type = tmp_type; + *value = tmp_value; + *tb = tmp_tb; +} +#else +static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) { + PyObject *tmp_type, *tmp_value, *tmp_tb; + PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb); + PyErr_SetExcInfo(*type, *value, *tb); + *type = tmp_type; + *value = tmp_value; + *tb = tmp_tb; +} +#endif + +/* CoroutineBase */ +#include +#include +#define __Pyx_Coroutine_Undelegate(gen) Py_CLEAR((gen)->yieldfrom) +static int __Pyx_PyGen__FetchStopIterationValue(CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject **pvalue) { + PyObject *et, *ev, *tb; + PyObject *value = NULL; + __Pyx_ErrFetch(&et, &ev, &tb); + if (!et) { + Py_XDECREF(tb); + Py_XDECREF(ev); + Py_INCREF(Py_None); + *pvalue = Py_None; + return 0; + } + if (likely(et == PyExc_StopIteration)) { + if (!ev) { + Py_INCREF(Py_None); + value = Py_None; + } +#if PY_VERSION_HEX >= 0x030300A0 + else if (Py_TYPE(ev) == (PyTypeObject*)PyExc_StopIteration) { + value = ((PyStopIterationObject *)ev)->value; + Py_INCREF(value); + Py_DECREF(ev); + } +#endif + else if (unlikely(PyTuple_Check(ev))) { + if (PyTuple_GET_SIZE(ev) >= 1) { +#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + value = PyTuple_GET_ITEM(ev, 0); + Py_INCREF(value); +#else + value = PySequence_ITEM(ev, 0); +#endif + } else { + Py_INCREF(Py_None); + value = Py_None; + } + Py_DECREF(ev); + } + else if (!__Pyx_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration)) { + value = ev; + } + if (likely(value)) { + Py_XDECREF(tb); + Py_DECREF(et); + *pvalue = value; + return 0; + } + } else if (!__Pyx_PyErr_GivenExceptionMatches(et, PyExc_StopIteration)) { + __Pyx_ErrRestore(et, ev, tb); + return -1; + } + PyErr_NormalizeException(&et, &ev, &tb); + if (unlikely(!PyObject_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration))) { + __Pyx_ErrRestore(et, ev, tb); + return -1; + } + Py_XDECREF(tb); + Py_DECREF(et); +#if PY_VERSION_HEX >= 0x030300A0 + value = ((PyStopIterationObject *)ev)->value; + Py_INCREF(value); + Py_DECREF(ev); +#else + { + PyObject* args = __Pyx_PyObject_GetAttrStr(ev, __pyx_n_s_args); + Py_DECREF(ev); + if (likely(args)) { + value = PySequence_GetItem(args, 0); + Py_DECREF(args); + } + if (unlikely(!value)) { + __Pyx_ErrRestore(NULL, NULL, NULL); + Py_INCREF(Py_None); + value = Py_None; + } + } +#endif + *pvalue = value; + return 0; +} +static CYTHON_INLINE +void __Pyx_Coroutine_ExceptionClear(__Pyx_ExcInfoStruct *exc_state) { + PyObject *t, *v, *tb; + t = exc_state->exc_type; + v = exc_state->exc_value; + tb = exc_state->exc_traceback; + exc_state->exc_type = NULL; + exc_state->exc_value = NULL; + exc_state->exc_traceback = NULL; + Py_XDECREF(t); + Py_XDECREF(v); + Py_XDECREF(tb); +} +#define __Pyx_Coroutine_AlreadyRunningError(gen) (__Pyx__Coroutine_AlreadyRunningError(gen), (PyObject*)NULL) +static void __Pyx__Coroutine_AlreadyRunningError(CYTHON_UNUSED __pyx_CoroutineObject *gen) { + const char *msg; + if ((0)) { + #ifdef __Pyx_Coroutine_USED + } else if (__Pyx_Coroutine_Check((PyObject*)gen)) { + msg = "coroutine already executing"; + #endif + #ifdef __Pyx_AsyncGen_USED + } else if (__Pyx_AsyncGen_CheckExact((PyObject*)gen)) { + msg = "async generator already executing"; + #endif + } else { + msg = "generator already executing"; + } + PyErr_SetString(PyExc_ValueError, msg); +} +#define __Pyx_Coroutine_NotStartedError(gen) (__Pyx__Coroutine_NotStartedError(gen), (PyObject*)NULL) +static void __Pyx__Coroutine_NotStartedError(CYTHON_UNUSED PyObject *gen) { + const char *msg; + if ((0)) { + #ifdef __Pyx_Coroutine_USED + } else if (__Pyx_Coroutine_Check(gen)) { + msg = "can't send non-None value to a just-started coroutine"; + #endif + #ifdef __Pyx_AsyncGen_USED + } else if (__Pyx_AsyncGen_CheckExact(gen)) { + msg = "can't send non-None value to a just-started async generator"; + #endif + } else { + msg = "can't send non-None value to a just-started generator"; + } + PyErr_SetString(PyExc_TypeError, msg); +} +#define __Pyx_Coroutine_AlreadyTerminatedError(gen, value, closing) (__Pyx__Coroutine_AlreadyTerminatedError(gen, value, closing), (PyObject*)NULL) +static void __Pyx__Coroutine_AlreadyTerminatedError(CYTHON_UNUSED PyObject *gen, PyObject *value, CYTHON_UNUSED int closing) { + #ifdef __Pyx_Coroutine_USED + if (!closing && __Pyx_Coroutine_Check(gen)) { + PyErr_SetString(PyExc_RuntimeError, "cannot reuse already awaited coroutine"); + } else + #endif + if (value) { + #ifdef __Pyx_AsyncGen_USED + if (__Pyx_AsyncGen_CheckExact(gen)) + PyErr_SetNone(__Pyx_PyExc_StopAsyncIteration); + else + #endif + PyErr_SetNone(PyExc_StopIteration); + } +} +static +PyObject *__Pyx_Coroutine_SendEx(__pyx_CoroutineObject *self, PyObject *value, int closing) { + __Pyx_PyThreadState_declare + PyThreadState *tstate; + __Pyx_ExcInfoStruct *exc_state; + PyObject *retval; + assert(!self->is_running); + if (unlikely(self->resume_label == 0)) { + if (unlikely(value && value != Py_None)) { + return __Pyx_Coroutine_NotStartedError((PyObject*)self); + } + } + if (unlikely(self->resume_label == -1)) { + return __Pyx_Coroutine_AlreadyTerminatedError((PyObject*)self, value, closing); + } +#if CYTHON_FAST_THREAD_STATE + __Pyx_PyThreadState_assign + tstate = __pyx_tstate; +#else + tstate = __Pyx_PyThreadState_Current; +#endif + exc_state = &self->gi_exc_state; + if (exc_state->exc_type) { + #if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_PYSTON + #else + if (exc_state->exc_traceback) { + PyTracebackObject *tb = (PyTracebackObject *) exc_state->exc_traceback; + PyFrameObject *f = tb->tb_frame; + assert(f->f_back == NULL); + #if PY_VERSION_HEX >= 0x030B00A1 + f->f_back = PyThreadState_GetFrame(tstate); + #else + Py_XINCREF(tstate->frame); + f->f_back = tstate->frame; + #endif + } + #endif + } +#if CYTHON_USE_EXC_INFO_STACK + exc_state->previous_item = tstate->exc_info; + tstate->exc_info = exc_state; +#else + if (exc_state->exc_type) { + __Pyx_ExceptionSwap(&exc_state->exc_type, &exc_state->exc_value, &exc_state->exc_traceback); + } else { + __Pyx_Coroutine_ExceptionClear(exc_state); + __Pyx_ExceptionSave(&exc_state->exc_type, &exc_state->exc_value, &exc_state->exc_traceback); + } +#endif + self->is_running = 1; + retval = self->body((PyObject *) self, tstate, value); + self->is_running = 0; +#if CYTHON_USE_EXC_INFO_STACK + exc_state = &self->gi_exc_state; + tstate->exc_info = exc_state->previous_item; + exc_state->previous_item = NULL; + __Pyx_Coroutine_ResetFrameBackpointer(exc_state); +#endif + return retval; +} +static CYTHON_INLINE void __Pyx_Coroutine_ResetFrameBackpointer(__Pyx_ExcInfoStruct *exc_state) { + PyObject *exc_tb = exc_state->exc_traceback; + if (likely(exc_tb)) { +#if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_PYSTON +#else + PyTracebackObject *tb = (PyTracebackObject *) exc_tb; + PyFrameObject *f = tb->tb_frame; + Py_CLEAR(f->f_back); +#endif + } +} +static CYTHON_INLINE +PyObject *__Pyx_Coroutine_MethodReturn(CYTHON_UNUSED PyObject* gen, PyObject *retval) { + if (unlikely(!retval)) { + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + if (!__Pyx_PyErr_Occurred()) { + PyObject *exc = PyExc_StopIteration; + #ifdef __Pyx_AsyncGen_USED + if (__Pyx_AsyncGen_CheckExact(gen)) + exc = __Pyx_PyExc_StopAsyncIteration; + #endif + __Pyx_PyErr_SetNone(exc); + } + } + return retval; +} +#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03030000 && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3) +static CYTHON_INLINE +PyObject *__Pyx_PyGen_Send(PyGenObject *gen, PyObject *arg) { +#if PY_VERSION_HEX <= 0x030A00A1 + return _PyGen_Send(gen, arg); +#else + PyObject *result; + if (PyIter_Send((PyObject*)gen, arg ? arg : Py_None, &result) == PYGEN_RETURN) { + if (PyAsyncGen_CheckExact(gen)) { + assert(result == Py_None); + PyErr_SetNone(PyExc_StopAsyncIteration); + } + else if (result == Py_None) { + PyErr_SetNone(PyExc_StopIteration); + } + else { + _PyGen_SetStopIterationValue(result); + } + Py_CLEAR(result); + } + return result; +#endif +} +#endif +static CYTHON_INLINE +PyObject *__Pyx_Coroutine_FinishDelegation(__pyx_CoroutineObject *gen) { + PyObject *ret; + PyObject *val = NULL; + __Pyx_Coroutine_Undelegate(gen); + __Pyx_PyGen__FetchStopIterationValue(__Pyx_PyThreadState_Current, &val); + ret = __Pyx_Coroutine_SendEx(gen, val, 0); + Py_XDECREF(val); + return ret; +} +static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value) { + PyObject *retval; + __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self; + PyObject *yf = gen->yieldfrom; + if (unlikely(gen->is_running)) + return __Pyx_Coroutine_AlreadyRunningError(gen); + if (yf) { + PyObject *ret; + gen->is_running = 1; + #ifdef __Pyx_Generator_USED + if (__Pyx_Generator_CheckExact(yf)) { + ret = __Pyx_Coroutine_Send(yf, value); + } else + #endif + #ifdef __Pyx_Coroutine_USED + if (__Pyx_Coroutine_Check(yf)) { + ret = __Pyx_Coroutine_Send(yf, value); + } else + #endif + #ifdef __Pyx_AsyncGen_USED + if (__pyx_PyAsyncGenASend_CheckExact(yf)) { + ret = __Pyx_async_gen_asend_send(yf, value); + } else + #endif + #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03030000 && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3) + if (PyGen_CheckExact(yf)) { + ret = __Pyx_PyGen_Send((PyGenObject*)yf, value == Py_None ? NULL : value); + } else + #endif + #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03050000 && defined(PyCoro_CheckExact) && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3) + if (PyCoro_CheckExact(yf)) { + ret = __Pyx_PyGen_Send((PyGenObject*)yf, value == Py_None ? NULL : value); + } else + #endif + { + if (value == Py_None) + ret = Py_TYPE(yf)->tp_iternext(yf); + else + ret = __Pyx_PyObject_CallMethod1(yf, __pyx_n_s_send, value); + } + gen->is_running = 0; + if (likely(ret)) { + return ret; + } + retval = __Pyx_Coroutine_FinishDelegation(gen); + } else { + retval = __Pyx_Coroutine_SendEx(gen, value, 0); + } + return __Pyx_Coroutine_MethodReturn(self, retval); +} +static int __Pyx_Coroutine_CloseIter(__pyx_CoroutineObject *gen, PyObject *yf) { + PyObject *retval = NULL; + int err = 0; + #ifdef __Pyx_Generator_USED + if (__Pyx_Generator_CheckExact(yf)) { + retval = __Pyx_Coroutine_Close(yf); + if (!retval) + return -1; + } else + #endif + #ifdef __Pyx_Coroutine_USED + if (__Pyx_Coroutine_Check(yf)) { + retval = __Pyx_Coroutine_Close(yf); + if (!retval) + return -1; + } else + if (__Pyx_CoroutineAwait_CheckExact(yf)) { + retval = __Pyx_CoroutineAwait_Close((__pyx_CoroutineAwaitObject*)yf, NULL); + if (!retval) + return -1; + } else + #endif + #ifdef __Pyx_AsyncGen_USED + if (__pyx_PyAsyncGenASend_CheckExact(yf)) { + retval = __Pyx_async_gen_asend_close(yf, NULL); + } else + if (__pyx_PyAsyncGenAThrow_CheckExact(yf)) { + retval = __Pyx_async_gen_athrow_close(yf, NULL); + } else + #endif + { + PyObject *meth; + gen->is_running = 1; + meth = __Pyx_PyObject_GetAttrStr(yf, __pyx_n_s_close); + if (unlikely(!meth)) { + if (!PyErr_ExceptionMatches(PyExc_AttributeError)) { + PyErr_WriteUnraisable(yf); + } + PyErr_Clear(); + } else { + retval = PyObject_CallFunction(meth, NULL); + Py_DECREF(meth); + if (!retval) + err = -1; + } + gen->is_running = 0; + } + Py_XDECREF(retval); + return err; +} +static PyObject *__Pyx_Generator_Next(PyObject *self) { + __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self; + PyObject *yf = gen->yieldfrom; + if (unlikely(gen->is_running)) + return __Pyx_Coroutine_AlreadyRunningError(gen); + if (yf) { + PyObject *ret; + gen->is_running = 1; + #ifdef __Pyx_Generator_USED + if (__Pyx_Generator_CheckExact(yf)) { + ret = __Pyx_Generator_Next(yf); + } else + #endif + #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03030000 && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3) + if (PyGen_CheckExact(yf)) { + ret = __Pyx_PyGen_Send((PyGenObject*)yf, NULL); + } else + #endif + #ifdef __Pyx_Coroutine_USED + if (__Pyx_Coroutine_Check(yf)) { + ret = __Pyx_Coroutine_Send(yf, Py_None); + } else + #endif + ret = Py_TYPE(yf)->tp_iternext(yf); + gen->is_running = 0; + if (likely(ret)) { + return ret; + } + return __Pyx_Coroutine_FinishDelegation(gen); + } + return __Pyx_Coroutine_SendEx(gen, Py_None, 0); +} +static PyObject *__Pyx_Coroutine_Close_Method(PyObject *self, CYTHON_UNUSED PyObject *arg) { + return __Pyx_Coroutine_Close(self); +} +static PyObject *__Pyx_Coroutine_Close(PyObject *self) { + __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self; + PyObject *retval, *raised_exception; + PyObject *yf = gen->yieldfrom; + int err = 0; + if (unlikely(gen->is_running)) + return __Pyx_Coroutine_AlreadyRunningError(gen); + if (yf) { + Py_INCREF(yf); + err = __Pyx_Coroutine_CloseIter(gen, yf); + __Pyx_Coroutine_Undelegate(gen); + Py_DECREF(yf); + } + if (err == 0) + PyErr_SetNone(PyExc_GeneratorExit); + retval = __Pyx_Coroutine_SendEx(gen, NULL, 1); + if (unlikely(retval)) { + const char *msg; + Py_DECREF(retval); + if ((0)) { + #ifdef __Pyx_Coroutine_USED + } else if (__Pyx_Coroutine_Check(self)) { + msg = "coroutine ignored GeneratorExit"; + #endif + #ifdef __Pyx_AsyncGen_USED + } else if (__Pyx_AsyncGen_CheckExact(self)) { +#if PY_VERSION_HEX < 0x03060000 + msg = "async generator ignored GeneratorExit - might require Python 3.6+ finalisation (PEP 525)"; +#else + msg = "async generator ignored GeneratorExit"; +#endif + #endif + } else { + msg = "generator ignored GeneratorExit"; + } + PyErr_SetString(PyExc_RuntimeError, msg); + return NULL; + } + raised_exception = PyErr_Occurred(); + if (likely(!raised_exception || __Pyx_PyErr_GivenExceptionMatches2(raised_exception, PyExc_GeneratorExit, PyExc_StopIteration))) { + if (raised_exception) PyErr_Clear(); + Py_INCREF(Py_None); + return Py_None; + } + return NULL; +} +static PyObject *__Pyx__Coroutine_Throw(PyObject *self, PyObject *typ, PyObject *val, PyObject *tb, + PyObject *args, int close_on_genexit) { + __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self; + PyObject *yf = gen->yieldfrom; + if (unlikely(gen->is_running)) + return __Pyx_Coroutine_AlreadyRunningError(gen); + if (yf) { + PyObject *ret; + Py_INCREF(yf); + if (__Pyx_PyErr_GivenExceptionMatches(typ, PyExc_GeneratorExit) && close_on_genexit) { + int err = __Pyx_Coroutine_CloseIter(gen, yf); + Py_DECREF(yf); + __Pyx_Coroutine_Undelegate(gen); + if (err < 0) + return __Pyx_Coroutine_MethodReturn(self, __Pyx_Coroutine_SendEx(gen, NULL, 0)); + goto throw_here; + } + gen->is_running = 1; + if (0 + #ifdef __Pyx_Generator_USED + || __Pyx_Generator_CheckExact(yf) + #endif + #ifdef __Pyx_Coroutine_USED + || __Pyx_Coroutine_Check(yf) + #endif + ) { + ret = __Pyx__Coroutine_Throw(yf, typ, val, tb, args, close_on_genexit); + #ifdef __Pyx_Coroutine_USED + } else if (__Pyx_CoroutineAwait_CheckExact(yf)) { + ret = __Pyx__Coroutine_Throw(((__pyx_CoroutineAwaitObject*)yf)->coroutine, typ, val, tb, args, close_on_genexit); + #endif + } else { + PyObject *meth = __Pyx_PyObject_GetAttrStr(yf, __pyx_n_s_throw); + if (unlikely(!meth)) { + Py_DECREF(yf); + if (!PyErr_ExceptionMatches(PyExc_AttributeError)) { + gen->is_running = 0; + return NULL; + } + PyErr_Clear(); + __Pyx_Coroutine_Undelegate(gen); + gen->is_running = 0; + goto throw_here; + } + if (likely(args)) { + ret = PyObject_CallObject(meth, args); + } else { + ret = PyObject_CallFunctionObjArgs(meth, typ, val, tb, NULL); + } + Py_DECREF(meth); + } + gen->is_running = 0; + Py_DECREF(yf); + if (!ret) { + ret = __Pyx_Coroutine_FinishDelegation(gen); + } + return __Pyx_Coroutine_MethodReturn(self, ret); + } +throw_here: + __Pyx_Raise(typ, val, tb, NULL); + return __Pyx_Coroutine_MethodReturn(self, __Pyx_Coroutine_SendEx(gen, NULL, 0)); +} +static PyObject *__Pyx_Coroutine_Throw(PyObject *self, PyObject *args) { + PyObject *typ; + PyObject *val = NULL; + PyObject *tb = NULL; + if (!PyArg_UnpackTuple(args, (char *)"throw", 1, 3, &typ, &val, &tb)) + return NULL; + return __Pyx__Coroutine_Throw(self, typ, val, tb, args, 1); +} +static CYTHON_INLINE int __Pyx_Coroutine_traverse_excstate(__Pyx_ExcInfoStruct *exc_state, visitproc visit, void *arg) { + Py_VISIT(exc_state->exc_type); + Py_VISIT(exc_state->exc_value); + Py_VISIT(exc_state->exc_traceback); + return 0; +} +static int __Pyx_Coroutine_traverse(__pyx_CoroutineObject *gen, visitproc visit, void *arg) { + Py_VISIT(gen->closure); + Py_VISIT(gen->classobj); + Py_VISIT(gen->yieldfrom); + return __Pyx_Coroutine_traverse_excstate(&gen->gi_exc_state, visit, arg); +} +static int __Pyx_Coroutine_clear(PyObject *self) { + __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self; + Py_CLEAR(gen->closure); + Py_CLEAR(gen->classobj); + Py_CLEAR(gen->yieldfrom); + __Pyx_Coroutine_ExceptionClear(&gen->gi_exc_state); +#ifdef __Pyx_AsyncGen_USED + if (__Pyx_AsyncGen_CheckExact(self)) { + Py_CLEAR(((__pyx_PyAsyncGenObject*)gen)->ag_finalizer); + } +#endif + Py_CLEAR(gen->gi_code); + Py_CLEAR(gen->gi_frame); + Py_CLEAR(gen->gi_name); + Py_CLEAR(gen->gi_qualname); + Py_CLEAR(gen->gi_modulename); + return 0; +} +static void __Pyx_Coroutine_dealloc(PyObject *self) { + __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self; + PyObject_GC_UnTrack(gen); + if (gen->gi_weakreflist != NULL) + PyObject_ClearWeakRefs(self); + if (gen->resume_label >= 0) { + PyObject_GC_Track(self); +#if PY_VERSION_HEX >= 0x030400a1 && CYTHON_USE_TP_FINALIZE + if (PyObject_CallFinalizerFromDealloc(self)) +#else + Py_TYPE(gen)->tp_del(self); + if (Py_REFCNT(self) > 0) +#endif + { + return; + } + PyObject_GC_UnTrack(self); + } +#ifdef __Pyx_AsyncGen_USED + if (__Pyx_AsyncGen_CheckExact(self)) { + /* We have to handle this case for asynchronous generators + right here, because this code has to be between UNTRACK + and GC_Del. */ + Py_CLEAR(((__pyx_PyAsyncGenObject*)self)->ag_finalizer); + } +#endif + __Pyx_Coroutine_clear(self); + PyObject_GC_Del(gen); +} +static void __Pyx_Coroutine_del(PyObject *self) { + PyObject *error_type, *error_value, *error_traceback; + __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self; + __Pyx_PyThreadState_declare + if (gen->resume_label < 0) { + return; + } +#if !CYTHON_USE_TP_FINALIZE + assert(self->ob_refcnt == 0); + __Pyx_SET_REFCNT(self, 1); +#endif + __Pyx_PyThreadState_assign + __Pyx_ErrFetch(&error_type, &error_value, &error_traceback); +#ifdef __Pyx_AsyncGen_USED + if (__Pyx_AsyncGen_CheckExact(self)) { + __pyx_PyAsyncGenObject *agen = (__pyx_PyAsyncGenObject*)self; + PyObject *finalizer = agen->ag_finalizer; + if (finalizer && !agen->ag_closed) { + PyObject *res = __Pyx_PyObject_CallOneArg(finalizer, self); + if (unlikely(!res)) { + PyErr_WriteUnraisable(self); + } else { + Py_DECREF(res); + } + __Pyx_ErrRestore(error_type, error_value, error_traceback); + return; + } + } +#endif + if (unlikely(gen->resume_label == 0 && !error_value)) { +#ifdef __Pyx_Coroutine_USED +#ifdef __Pyx_Generator_USED + if (!__Pyx_Generator_CheckExact(self)) +#endif + { + PyObject_GC_UnTrack(self); +#if PY_MAJOR_VERSION >= 3 || defined(PyErr_WarnFormat) + if (unlikely(PyErr_WarnFormat(PyExc_RuntimeWarning, 1, "coroutine '%.50S' was never awaited", gen->gi_qualname) < 0)) + PyErr_WriteUnraisable(self); +#else + {PyObject *msg; + char *cmsg; + #if CYTHON_COMPILING_IN_PYPY + msg = NULL; + cmsg = (char*) "coroutine was never awaited"; + #else + char *cname; + PyObject *qualname; + qualname = gen->gi_qualname; + cname = PyString_AS_STRING(qualname); + msg = PyString_FromFormat("coroutine '%.50s' was never awaited", cname); + if (unlikely(!msg)) { + PyErr_Clear(); + cmsg = (char*) "coroutine was never awaited"; + } else { + cmsg = PyString_AS_STRING(msg); + } + #endif + if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning, cmsg, 1) < 0)) + PyErr_WriteUnraisable(self); + Py_XDECREF(msg);} +#endif + PyObject_GC_Track(self); + } +#endif + } else { + PyObject *res = __Pyx_Coroutine_Close(self); + if (unlikely(!res)) { + if (PyErr_Occurred()) + PyErr_WriteUnraisable(self); + } else { + Py_DECREF(res); + } + } + __Pyx_ErrRestore(error_type, error_value, error_traceback); +#if !CYTHON_USE_TP_FINALIZE + assert(Py_REFCNT(self) > 0); + if (--self->ob_refcnt == 0) { + return; + } + { + Py_ssize_t refcnt = Py_REFCNT(self); + _Py_NewReference(self); + __Pyx_SET_REFCNT(self, refcnt); + } +#if CYTHON_COMPILING_IN_CPYTHON + assert(PyType_IS_GC(Py_TYPE(self)) && + _Py_AS_GC(self)->gc.gc_refs != _PyGC_REFS_UNTRACKED); + _Py_DEC_REFTOTAL; +#endif +#ifdef COUNT_ALLOCS + --Py_TYPE(self)->tp_frees; + --Py_TYPE(self)->tp_allocs; +#endif +#endif +} +static PyObject * +__Pyx_Coroutine_get_name(__pyx_CoroutineObject *self, CYTHON_UNUSED void *context) +{ + PyObject *name = self->gi_name; + if (unlikely(!name)) name = Py_None; + Py_INCREF(name); + return name; +} +static int +__Pyx_Coroutine_set_name(__pyx_CoroutineObject *self, PyObject *value, CYTHON_UNUSED void *context) +{ + PyObject *tmp; +#if PY_MAJOR_VERSION >= 3 + if (unlikely(value == NULL || !PyUnicode_Check(value))) +#else + if (unlikely(value == NULL || !PyString_Check(value))) +#endif + { + PyErr_SetString(PyExc_TypeError, + "__name__ must be set to a string object"); + return -1; + } + tmp = self->gi_name; + Py_INCREF(value); + self->gi_name = value; + Py_XDECREF(tmp); + return 0; +} +static PyObject * +__Pyx_Coroutine_get_qualname(__pyx_CoroutineObject *self, CYTHON_UNUSED void *context) +{ + PyObject *name = self->gi_qualname; + if (unlikely(!name)) name = Py_None; + Py_INCREF(name); + return name; +} +static int +__Pyx_Coroutine_set_qualname(__pyx_CoroutineObject *self, PyObject *value, CYTHON_UNUSED void *context) +{ + PyObject *tmp; +#if PY_MAJOR_VERSION >= 3 + if (unlikely(value == NULL || !PyUnicode_Check(value))) +#else + if (unlikely(value == NULL || !PyString_Check(value))) +#endif + { + PyErr_SetString(PyExc_TypeError, + "__qualname__ must be set to a string object"); + return -1; + } + tmp = self->gi_qualname; + Py_INCREF(value); + self->gi_qualname = value; + Py_XDECREF(tmp); + return 0; +} +static PyObject * +__Pyx_Coroutine_get_frame(__pyx_CoroutineObject *self, CYTHON_UNUSED void *context) +{ + PyObject *frame = self->gi_frame; + if (!frame) { + if (unlikely(!self->gi_code)) { + Py_RETURN_NONE; + } + frame = (PyObject *) PyFrame_New( + PyThreadState_Get(), /*PyThreadState *tstate,*/ + (PyCodeObject*) self->gi_code, /*PyCodeObject *code,*/ + __pyx_d, /*PyObject *globals,*/ + 0 /*PyObject *locals*/ + ); + if (unlikely(!frame)) + return NULL; + self->gi_frame = frame; + } + Py_INCREF(frame); + return frame; +} +static __pyx_CoroutineObject *__Pyx__Coroutine_New( + PyTypeObject* type, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure, + PyObject *name, PyObject *qualname, PyObject *module_name) { + __pyx_CoroutineObject *gen = PyObject_GC_New(__pyx_CoroutineObject, type); + if (unlikely(!gen)) + return NULL; + return __Pyx__Coroutine_NewInit(gen, body, code, closure, name, qualname, module_name); +} +static __pyx_CoroutineObject *__Pyx__Coroutine_NewInit( + __pyx_CoroutineObject *gen, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure, + PyObject *name, PyObject *qualname, PyObject *module_name) { + gen->body = body; + gen->closure = closure; + Py_XINCREF(closure); + gen->is_running = 0; + gen->resume_label = 0; + gen->classobj = NULL; + gen->yieldfrom = NULL; + gen->gi_exc_state.exc_type = NULL; + gen->gi_exc_state.exc_value = NULL; + gen->gi_exc_state.exc_traceback = NULL; +#if CYTHON_USE_EXC_INFO_STACK + gen->gi_exc_state.previous_item = NULL; +#endif + gen->gi_weakreflist = NULL; + Py_XINCREF(qualname); + gen->gi_qualname = qualname; + Py_XINCREF(name); + gen->gi_name = name; + Py_XINCREF(module_name); + gen->gi_modulename = module_name; + Py_XINCREF(code); + gen->gi_code = code; + gen->gi_frame = NULL; + PyObject_GC_Track(gen); + return gen; +} + +/* PatchModuleWithCoroutine */ +static PyObject* __Pyx_Coroutine_patch_module(PyObject* module, const char* py_code) { +#if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) + int result; + PyObject *globals, *result_obj; + globals = PyDict_New(); if (unlikely(!globals)) goto ignore; + result = PyDict_SetItemString(globals, "_cython_coroutine_type", + #ifdef __Pyx_Coroutine_USED + (PyObject*)__pyx_CoroutineType); + #else + Py_None); + #endif + if (unlikely(result < 0)) goto ignore; + result = PyDict_SetItemString(globals, "_cython_generator_type", + #ifdef __Pyx_Generator_USED + (PyObject*)__pyx_GeneratorType); + #else + Py_None); + #endif + if (unlikely(result < 0)) goto ignore; + if (unlikely(PyDict_SetItemString(globals, "_module", module) < 0)) goto ignore; + if (unlikely(PyDict_SetItemString(globals, "__builtins__", __pyx_b) < 0)) goto ignore; + result_obj = PyRun_String(py_code, Py_file_input, globals, globals); + if (unlikely(!result_obj)) goto ignore; + Py_DECREF(result_obj); + Py_DECREF(globals); + return module; +ignore: + Py_XDECREF(globals); + PyErr_WriteUnraisable(module); + if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning, "Cython module failed to patch module with custom type", 1) < 0)) { + Py_DECREF(module); + module = NULL; + } +#else + py_code++; +#endif + return module; +} + +/* PatchGeneratorABC */ +#ifndef CYTHON_REGISTER_ABCS +#define CYTHON_REGISTER_ABCS 1 +#endif +#if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) +static PyObject* __Pyx_patch_abc_module(PyObject *module); +static PyObject* __Pyx_patch_abc_module(PyObject *module) { + module = __Pyx_Coroutine_patch_module( + module, "" +"if _cython_generator_type is not None:\n" +" try: Generator = _module.Generator\n" +" except AttributeError: pass\n" +" else: Generator.register(_cython_generator_type)\n" +"if _cython_coroutine_type is not None:\n" +" try: Coroutine = _module.Coroutine\n" +" except AttributeError: pass\n" +" else: Coroutine.register(_cython_coroutine_type)\n" + ); + return module; +} +#endif +static int __Pyx_patch_abc(void) { +#if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) + static int abc_patched = 0; + if (CYTHON_REGISTER_ABCS && !abc_patched) { + PyObject *module; + module = PyImport_ImportModule((PY_MAJOR_VERSION >= 3) ? "collections.abc" : "collections"); + if (!module) { + PyErr_WriteUnraisable(NULL); + if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning, + ((PY_MAJOR_VERSION >= 3) ? + "Cython module failed to register with collections.abc module" : + "Cython module failed to register with collections module"), 1) < 0)) { + return -1; + } + } else { + module = __Pyx_patch_abc_module(module); + abc_patched = 1; + if (unlikely(!module)) + return -1; + Py_DECREF(module); + } + module = PyImport_ImportModule("backports_abc"); + if (module) { + module = __Pyx_patch_abc_module(module); + Py_XDECREF(module); + } + if (!module) { + PyErr_Clear(); + } + } +#else + if ((0)) __Pyx_Coroutine_patch_module(NULL, NULL); +#endif + return 0; +} + +/* Generator */ +static PyMethodDef __pyx_Generator_methods[] = { + {"send", (PyCFunction) __Pyx_Coroutine_Send, METH_O, + (char*) PyDoc_STR("send(arg) -> send 'arg' into generator,\nreturn next yielded value or raise StopIteration.")}, + {"throw", (PyCFunction) __Pyx_Coroutine_Throw, METH_VARARGS, + (char*) PyDoc_STR("throw(typ[,val[,tb]]) -> raise exception in generator,\nreturn next yielded value or raise StopIteration.")}, + {"close", (PyCFunction) __Pyx_Coroutine_Close_Method, METH_NOARGS, + (char*) PyDoc_STR("close() -> raise GeneratorExit inside generator.")}, + {0, 0, 0, 0} +}; +static PyMemberDef __pyx_Generator_memberlist[] = { + {(char *) "gi_running", T_BOOL, offsetof(__pyx_CoroutineObject, is_running), READONLY, NULL}, + {(char*) "gi_yieldfrom", T_OBJECT, offsetof(__pyx_CoroutineObject, yieldfrom), READONLY, + (char*) PyDoc_STR("object being iterated by 'yield from', or None")}, + {(char*) "gi_code", T_OBJECT, offsetof(__pyx_CoroutineObject, gi_code), READONLY, NULL}, + {0, 0, 0, 0, 0} +}; +static PyGetSetDef __pyx_Generator_getsets[] = { + {(char *) "__name__", (getter)__Pyx_Coroutine_get_name, (setter)__Pyx_Coroutine_set_name, + (char*) PyDoc_STR("name of the generator"), 0}, + {(char *) "__qualname__", (getter)__Pyx_Coroutine_get_qualname, (setter)__Pyx_Coroutine_set_qualname, + (char*) PyDoc_STR("qualified name of the generator"), 0}, + {(char *) "gi_frame", (getter)__Pyx_Coroutine_get_frame, NULL, + (char*) PyDoc_STR("Frame of the generator"), 0}, + {0, 0, 0, 0, 0} +}; +static PyTypeObject __pyx_GeneratorType_type = { + PyVarObject_HEAD_INIT(0, 0) + "generator", + sizeof(__pyx_CoroutineObject), + 0, + (destructor) __Pyx_Coroutine_dealloc, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_HAVE_FINALIZE, + 0, + (traverseproc) __Pyx_Coroutine_traverse, + 0, + 0, + offsetof(__pyx_CoroutineObject, gi_weakreflist), + 0, + (iternextfunc) __Pyx_Generator_Next, + __pyx_Generator_methods, + __pyx_Generator_memberlist, + __pyx_Generator_getsets, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, +#if CYTHON_USE_TP_FINALIZE + 0, +#else + __Pyx_Coroutine_del, +#endif + 0, +#if CYTHON_USE_TP_FINALIZE + __Pyx_Coroutine_del, +#elif PY_VERSION_HEX >= 0x030400a1 + 0, +#endif +#if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800) + 0, +#endif +#if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000 + 0, +#endif +#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 + 0, +#endif +}; +static int __pyx_Generator_init(void) { + __pyx_GeneratorType_type.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict; + __pyx_GeneratorType_type.tp_iter = PyObject_SelfIter; + __pyx_GeneratorType = __Pyx_FetchCommonType(&__pyx_GeneratorType_type); + if (unlikely(!__pyx_GeneratorType)) { + return -1; + } + return 0; +} + +/* CheckBinaryVersion */ +static int __Pyx_check_binary_version(void) { + char ctversion[4], rtversion[4]; + PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION); + PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion()); + if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) { + char message[200]; + PyOS_snprintf(message, sizeof(message), + "compiletime version %s of module '%.100s' " + "does not match runtime version %s", + ctversion, __Pyx_MODULE_NAME, rtversion); + return PyErr_WarnEx(NULL, message, 1); + } + return 0; +} + +/* InitStrings */ +static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { + while (t->p) { + #if PY_MAJOR_VERSION < 3 + if (t->is_unicode) { + *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL); + } else if (t->intern) { + *t->p = PyString_InternFromString(t->s); + } else { + *t->p = PyString_FromStringAndSize(t->s, t->n - 1); + } + #else + if (t->is_unicode | t->is_str) { + if (t->intern) { + *t->p = PyUnicode_InternFromString(t->s); + } else if (t->encoding) { + *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL); + } else { + *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1); + } + } else { + *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1); + } + #endif + if (!*t->p) + return -1; + if (PyObject_Hash(*t->p) == -1) + return -1; + ++t; + } + return 0; +} + +static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) { + return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str)); +} +static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) { + Py_ssize_t ignore; + return __Pyx_PyObject_AsStringAndSize(o, &ignore); +} +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT +#if !CYTHON_PEP393_ENABLED +static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { + char* defenc_c; + PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); + if (!defenc) return NULL; + defenc_c = PyBytes_AS_STRING(defenc); +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII + { + char* end = defenc_c + PyBytes_GET_SIZE(defenc); + char* c; + for (c = defenc_c; c < end; c++) { + if ((unsigned char) (*c) >= 128) { + PyUnicode_AsASCIIString(o); + return NULL; + } + } + } +#endif + *length = PyBytes_GET_SIZE(defenc); + return defenc_c; +} +#else +static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { + if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL; +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII + if (likely(PyUnicode_IS_ASCII(o))) { + *length = PyUnicode_GET_LENGTH(o); + return PyUnicode_AsUTF8(o); + } else { + PyUnicode_AsASCIIString(o); + return NULL; + } +#else + return PyUnicode_AsUTF8AndSize(o, length); +#endif +} +#endif +#endif +static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT + if ( +#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII + __Pyx_sys_getdefaultencoding_not_ascii && +#endif + PyUnicode_Check(o)) { + return __Pyx_PyUnicode_AsStringAndSize(o, length); + } else +#endif +#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE)) + if (PyByteArray_Check(o)) { + *length = PyByteArray_GET_SIZE(o); + return PyByteArray_AS_STRING(o); + } else +#endif + { + char* result; + int r = PyBytes_AsStringAndSize(o, &result, length); + if (unlikely(r < 0)) { + return NULL; + } else { + return result; + } + } +} +static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { + int is_true = x == Py_True; + if (is_true | (x == Py_False) | (x == Py_None)) return is_true; + else return PyObject_IsTrue(x); +} +static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) { + int retval; + if (unlikely(!x)) return -1; + retval = __Pyx_PyObject_IsTrue(x); + Py_DECREF(x); + return retval; +} +static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) { +#if PY_MAJOR_VERSION >= 3 + if (PyLong_Check(result)) { + if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1, + "__int__ returned non-int (type %.200s). " + "The ability to return an instance of a strict subclass of int " + "is deprecated, and may be removed in a future version of Python.", + Py_TYPE(result)->tp_name)) { + Py_DECREF(result); + return NULL; + } + return result; + } +#endif + PyErr_Format(PyExc_TypeError, + "__%.4s__ returned non-%.4s (type %.200s)", + type_name, type_name, Py_TYPE(result)->tp_name); + Py_DECREF(result); + return NULL; +} +static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { +#if CYTHON_USE_TYPE_SLOTS + PyNumberMethods *m; +#endif + const char *name = NULL; + PyObject *res = NULL; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x) || PyLong_Check(x))) +#else + if (likely(PyLong_Check(x))) +#endif + return __Pyx_NewRef(x); +#if CYTHON_USE_TYPE_SLOTS + m = Py_TYPE(x)->tp_as_number; + #if PY_MAJOR_VERSION < 3 + if (m && m->nb_int) { + name = "int"; + res = m->nb_int(x); + } + else if (m && m->nb_long) { + name = "long"; + res = m->nb_long(x); + } + #else + if (likely(m && m->nb_int)) { + name = "int"; + res = m->nb_int(x); + } + #endif +#else + if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) { + res = PyNumber_Int(x); + } +#endif + if (likely(res)) { +#if PY_MAJOR_VERSION < 3 + if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) { +#else + if (unlikely(!PyLong_CheckExact(res))) { +#endif + return __Pyx_PyNumber_IntOrLongWrongResultType(res, name); + } + } + else if (!PyErr_Occurred()) { + PyErr_SetString(PyExc_TypeError, + "an integer is required"); + } + return res; +} +static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { + Py_ssize_t ival; + PyObject *x; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_CheckExact(b))) { + if (sizeof(Py_ssize_t) >= sizeof(long)) + return PyInt_AS_LONG(b); + else + return PyInt_AsSsize_t(b); + } +#endif + if (likely(PyLong_CheckExact(b))) { + #if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)b)->ob_digit; + const Py_ssize_t size = Py_SIZE(b); + if (likely(__Pyx_sst_abs(size) <= 1)) { + ival = likely(size) ? digits[0] : 0; + if (size == -1) ival = -ival; + return ival; + } else { + switch (size) { + case 2: + if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { + return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); + } + break; + case -2: + if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { + return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); + } + break; + case 3: + if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { + return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); + } + break; + case -3: + if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { + return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); + } + break; + case 4: + if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { + return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); + } + break; + case -4: + if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { + return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); + } + break; + } + } + #endif + return PyLong_AsSsize_t(b); + } + x = PyNumber_Index(b); + if (!x) return -1; + ival = PyInt_AsSsize_t(x); + Py_DECREF(x); + return ival; +} +static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject* o) { + if (sizeof(Py_hash_t) == sizeof(Py_ssize_t)) { + return (Py_hash_t) __Pyx_PyIndex_AsSsize_t(o); +#if PY_MAJOR_VERSION < 3 + } else if (likely(PyInt_CheckExact(o))) { + return PyInt_AS_LONG(o); +#endif + } else { + Py_ssize_t ival; + PyObject *x; + x = PyNumber_Index(o); + if (!x) return -1; + ival = PyInt_AsLong(x); + Py_DECREF(x); + return ival; + } +} +static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) { + return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False); +} +static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) { + return PyInt_FromSize_t(ival); +} + + +#endif /* Py_PYTHON_H */ + diff --git a/softwrap2/core/core2.pyx b/softwrap2/core/core2.pyx new file mode 100644 index 0000000..1242d98 --- /dev/null +++ b/softwrap2/core/core2.pyx @@ -0,0 +1,1559 @@ +# distutils: language=c++ +# cython: cdivision=True +# cython: language_level=3 +# cython: boundscheck=False +# cython: nonecheck=False + +# Copyright (C) 2021 Jean Da Costa machado. +# Jean3dimensional@gmail.com +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +import atexit +from libc.math cimport INFINITY +from libc.limits cimport UINT_MAX +from libc.stdlib cimport calloc, malloc, free +from libc.stdint cimport uintptr_t +from libc.string cimport memset +from cython.parallel cimport prange, parallel +cimport cython + + +cdef extern from *: + ''' + template + CYTHON_INLINE T1 nmax(T1 a, T2 b) {return a > b ? a : (T1)b;} + + template + CYTHON_INLINE T1 nmin(T1 a, T2 b) {return a < b ? a : (T1)b;} + + template + CYTHON_INLINE T1 nabs(T1 a) {return a < 0 ? -a : a;} + + template + CYTHON_INLINE T1 nlerp(T1 a, T2 b, T3 t) {return a + (b - a) * t;} + + template + CYTHON_INLINE T1 nclamp(T1 a, T2 min, T3 max) {return nmax(nmin(a, max), min);} + + + ''' + + T1 nmin[T1, T2](T1, T2) nogil + T1 nmax[T1, T2](T1, T2) nogil + T1 nabs[T1](T1) nogil + T1 nlerp[T1, T2, T3](T1, T2, T3) nogil + T1 nclamp[T1, T2, T3](T1, T2, T3) nogil + + +cdef extern from *: + ''' + #define EPS 0.00001f + struct vec3 { + float v[3]; + + vec3 (float a[3]) { + v[0] = a[0]; + v[1] = a[1]; + v[2] = a[2]; + } + + vec3 (float x, float y, float z) { + v[0] = x; + v[1] = y; + v[2] = z; + } + + vec3 (float f) { + v[0] = f; + v[1] = f; + v[2] = f; + } + + vec3() = default; + + #define VEC_OP(op)\\ + CYTHON_INLINE vec3 operator op (vec3 other) {\\ + return vec3(v[0] op other.v[0], v[1] op other.v[1], v[2] op other.v[2]);\\ + } + + VEC_OP(+) + VEC_OP(-) + VEC_OP(*) + VEC_OP(/) + VEC_OP(+=) + VEC_OP(-=) + VEC_OP(*=) + VEC_OP(/=) + + #undef VEC_OP + #define VEC_OP(op)\\ + CYTHON_INLINE vec3 operator op (float other) {\\ + return vec3(v[0] op other, v[1] op other, v[2] op other);\\ + } + + VEC_OP(+) + VEC_OP(-) + VEC_OP(*) + VEC_OP(/) + VEC_OP(+=) + VEC_OP(-=) + VEC_OP(*=) + VEC_OP(/=) + VEC_OP(=) + + #undef VEC_OP + CYTHON_INLINE float& x() { return v[0];} + CYTHON_INLINE float& y() { return v[1];} + CYTHON_INLINE float& z() { return v[2];} + CYTHON_INLINE float sum() {return v[0] + v[1] + v[2];} + CYTHON_INLINE float dot(vec3 other) {return v[0] * other.v[0] + v[1] * other.v[1] + v[2] * other.v[2];} + CYTHON_INLINE float len() {return sqrtf(this->dot(*this));} + CYTHON_INLINE float len_sqr() {return this->dot(*this);} + CYTHON_INLINE void normalize() { + float f = this->len(); + if (f == 0) { + return; + } + f = 1 / f; + *this *= f; + } + CYTHON_INLINE vec3 normalized() { + float f = this->len(); + if (f == 0) { + return *this; + } + f = 1 / f; + return *this * f; + } + CYTHON_INLINE vec3 project(vec3 other) {return other * (this->dot(other) / other.dot(other));} + CYTHON_INLINE vec3 project_unit(vec3 other) {return other * this->dot(other);} + CYTHON_INLINE vec3 cross(vec3 other) { + return vec3(v[1] * other.v[2] - v[2] * other.v[1], + v[2] * other.v[0] - v[0] * other.v[2], + v[0] * other.v[1] - v[1] * other.v[0]); + } + + CYTHON_INLINE vec3 max_aa(vec3 other) { + return vec3(nmax(v[0], other.v[0]), nmax(v[1], other.v[1]), nmax(v[2], other.v[2])); + } + CYTHON_INLINE vec3 min_aa(vec3 other) { + return vec3(nmin(v[0], other.v[0]), nmin(v[1], other.v[1]), nmin(v[2], other.v[2])); + } + CYTHON_INLINE vec3 lerp(vec3 other, float fac) { + return *this + (other - *this) * fac; + } + CYTHON_INLINE vec3 clamp(float min, float max) { + float d = this->dot(*this); + if (d == 0) { + return *this; + } + else if (d < min * min) { + return *this * (1 / sqrtf(d) * min); + } + else if (d > max * max) { + return *this * (1 / sqrtf(d) * max); + } + return *this; + } + }; + ''' + float EPS + float sqrtf(float) nogil + cdef cppclass vec3 nogil: + float v[3] + vec3(float a[3]) nogil + vec3(float, float, float) nogil + vec3(float) nogil + vec3() nogil + vec3 operator + (vec3) nogil + vec3 operator - (vec3) nogil + vec3 operator * (vec3) nogil + vec3 operator / (vec3) nogil + vec3 operator + (float) nogil + vec3 operator - (float) nogil + vec3 operator * (float) nogil + vec3 operator / (float) nogil + vec3 operator = (float) nogil + float & x() nogil + float & y() nogil + float & z() nogil + float sum() nogil + float dot(vec3) nogil + float len() nogil + float len_sqr() nogil + void normalize() nogil + vec3 normalized() nogil + vec3 project(vec3) nogil + vec3 project_unit(vec3) nogil + vec3 cross(vec3) nogil + vec3 max_aa(vec3) nogil + vec3 min_aa(vec3) nogil + vec3 lerp(vec3, float) nogil + vec3 clamp(float, float) nogil + +cdef extern from *: + ''' + CYTHON_INLINE vec3 project_point_triangle(vec3& a, vec3& b, vec3& c, vec3& n, vec3& p){ + vec3 edge_v = b - a; + vec3 pv = p - a; + vec3 n1 = edge_v.cross(pv); + + if (n1.dot(n) < 0){ + return edge_v * nclamp(edge_v.dot(pv) / (edge_v.dot(edge_v) + EPS), 0, 1) + a; + } + + edge_v = c - b; + pv = p - b; + n1 = edge_v.cross(pv); + + if (n1.dot(n) < 0){ + return edge_v * nclamp(edge_v.dot(pv) / (edge_v.dot(edge_v) + EPS), 0, 1) + b; + } + + edge_v = a - c; + pv = p - c; + n1 = edge_v.cross(pv); + + if (n1.dot(n) < 0){ + return edge_v * nclamp(edge_v.dot(pv) / (edge_v.dot(edge_v) + EPS), 0, 1) + c; + } + + return p - pv.project_unit(n); + } + + CYTHON_INLINE vec3 project_point_plane(vec3& p, vec3& pp, vec3& pn){ + vec3 v = (p - pp).project_unit(pn); + return p - v; + } + ''' + vec3 project_point_triangle(vec3 & a, vec3 & b, vec3 & c, vec3 & n, vec3 & p) nogil + vec3 project_point_plane(vec3& p, vec3& pp, vec3& pn) nogil + +# ctypedef fused number: +# char +# signed char +# unsigned char +# int +# signed int +# unsigned int +# short int +# signed short int +# unsigned short int +# long int +# signed long int +# unsigned long int +# float +# double +# long double + + +cdef dict not_freed_pointers = {} + +cdef extern from *: + "" + int __LINE__ + +cdef void* maelloc(size_t size, int id) except NULL: + cdef void* ptr = malloc(size) + if ptr == NULL: + raise MemoryError + not_freed_pointers[ptr] = id + return ptr + +cdef void* caelloc(size_t n, size_t size, int id) except NULL: + cdef void* ptr = calloc(n, size) + if ptr == NULL: + raise MemoryError + not_freed_pointers[ptr] = id + return ptr + +cdef void fraeee(void* ptr): + if ptr is not NULL: + del not_freed_pointers[ ptr] + free(ptr) + + +def leak_check(): + import gc + gc.collect() + + if not_freed_pointers: + print('\n ------------ Oops Softwrap2 memory leak detected ------------ \n pointers not freed:') + for ptr, line in not_freed_pointers.items(): + print(f' ptr: {hex(ptr)}, core2.pyx:{line}') + print('\n -------------------------------------------------------------') + + +atexit.register(leak_check) + + +cdef list vec3arr_to_list(vec3* arr, int size): + cdef list l = [None] * size + cdef int i + for i in range(size): + l[i] = (arr[i].v[0], arr[i].v[1], arr[i].v[2]) + + return l + + +cdef inline unsigned int xorshift(unsigned int* seed) nogil: + seed[0] ^= seed[0] << 11 + seed[0] ^= seed[0] >> 17 + seed[0] ^= seed[0] << 9 + return seed[0] + +cdef inline float uint2neg1pos1f(unsigned int v) nogil: + return v / ( 0xffffffff >> 1) - 1.0 + +cdef float xorshiftf(unsigned int* seed) nogil: + return uint2neg1pos1f(xorshift(seed)) + + +cpdef index_check(int idx, int size): + if idx < 0 or idx >= size: + raise IndexError(idx) + +@cython.final +cdef class Mesh: + cdef: + vec3* verts + int[3]* triangles + vec3* centroids + vec3* vert_normals + vec3* face_normals + int n_verts + int n_triangles + + def get_vert_normals(self): + return vec3arr_to_list(self.vert_normals, self.n_verts) + + def get_face_normals(self): + return vec3arr_to_list(self.face_normals, self.n_triangles) + + def __init__(self, verts, triangles): + self.n_verts = len(verts) + self.n_triangles = len(triangles) + + if len(verts) < 3 or len(triangles) < 1: + raise ValueError('Invalid or empty mesh') + + self.verts = maelloc(sizeof(vec3) * self.n_verts, __LINE__) + self.triangles = maelloc(sizeof(int[3]) * self.n_triangles, __LINE__) + + cdef int i + for i in range(self.n_verts): + self.verts[i].v = verts[i] + + for i in range(self.n_triangles): + self.triangles[i] = triangles[i] + + cdef inline vec3*tri_vert_ptr(self, int tri, int tri_i) nogil: + return & self.verts[self.triangles[tri][tri_i]] + + cdef inline vec3 tri_vert(self, int tri, int tri_i) nogil: + return self.verts[self.triangles[tri][tri_i]] + + cpdef void update_face_normals(self): + if not self.face_normals: + self.face_normals = caelloc(self.n_triangles, sizeof(vec3), __LINE__) + + cdef int i + + cdef vec3* a + cdef vec3* b + cdef vec3* c + with nogil: + for i in prange(self.n_triangles): + a = self.tri_vert_ptr(i, 0) + b = self.tri_vert_ptr(i, 1) + c = self.tri_vert_ptr(i, 2) + self.face_normals[i] = (b[0] - a[0]).cross(c[0] - a[0]).normalized() + + cpdef void update_vert_normals(self): + if not self.vert_normals: + self.vert_normals = caelloc(self.n_verts, sizeof(vec3), __LINE__) + + cdef int i, j + + cdef int * tri + + with nogil: + for i in prange(self.n_verts): + self.vert_normals[i] = vec3(0) + + for i in range(self.n_triangles): + tri = self.triangles[i] + for j in range(3): + self.vert_normals[tri[j]] += self.face_normals[i] + + for i in prange(self.n_verts): + self.vert_normals[i].normalize() + + cpdef void update_centroids(self): + if not self.centroids: + self.centroids = maelloc(sizeof(vec3) * self.n_triangles, __LINE__) + + cdef int i + for i in prange(self.n_triangles, nogil=True): + self.centroids[i] = (self.tri_vert(i, 0) + self.tri_vert(i, 1) + self.tri_vert(i, 2)) / 3 + + + def closest_vert(self, pos): + cdef vec3 p + cdef float tmp_dist, dist = INFINITY + cdef int i=0, idx = -1 + + p.v = pos + + for i in range(self.n_verts): + tmp_dist = (self.verts[i] - p).len_sqr() + if tmp_dist < dist: + dist = tmp_dist + idx = i + + return idx, self.verts[idx].v + + + def __dealloc__(self): + fraeee(self.verts) + fraeee(self.triangles) + fraeee(self.centroids) + fraeee(self.face_normals) + fraeee(self.vert_normals) + + +cdef extern from *: + ''' + #include + + union BvhNode; + struct BvhNodeBox; + struct BvhNodeLeaf; + + struct BvhNodeBox { + int split_axis; + float split_pos; + vec3 min, max; + BvhNode* nodes[2]; + + // BvhNodeBox() { + // split_axis = -1; + // min = vec3(INFINITY); + // max = vec3(-INFINITY); + // } + // CYTHON_INLINE void expand(BvhNodeBox other) { + // min = min.min_aa(other.min); + // max = max.max_aa(other.max); + // } + CYTHON_INLINE void expand(vec3 other) { + min = min.min_aa(other); + max = max.max_aa(other); + } + CYTHON_INLINE int major_axis(){ + int axis = 0; + float curr_le, le = 0; + + for (int i=0; i<3; i++){ + curr_le = max.v[i] - min.v[i]; + if (curr_le > le){ + axis = i; + le = curr_le; + } + } + return axis; + } + CYTHON_INLINE vec3 box_center(){ + return (max + min) * 0.5; + } + CYTHON_INLINE float box_center_axis(int axis){ + return (max.v[axis] + min.v[axis]) * 0.5f; + } + CYTHON_INLINE float box_distance_sqr(vec3 p){ + return (p - max.min_aa(min.max_aa(p))).len_sqr(); + } + CYTHON_INLINE void set_split_axis(int axis){ + this->split_axis = ~axis; + } + CYTHON_INLINE int get_split_axis(){ + return ~this->split_axis; + } + CYTHON_INLINE int is_leaf() { + return split_axis >= 0; + } + }; + + struct BvhNodeLeaf { + int index; + // BvhNodeLeaf (int _index) { + // index = _index; + // } + }; + + union BvhNode{ + BvhNodeBox box; + BvhNodeLeaf leaf; + CYTHON_INLINE int is_leaf() { + return leaf.index >= 0; + } + }; + + struct BvhNearestResult { + vec3 point; + float distance; + int tri_index; + }; + ''' + + cdef cppclass BvhNodeBox: + int split_axis + float split_pos + vec3 min, max + BvhNode * nodes[2] + # BvhNodeBox() nogil + void expand(BvhNodeBox) nogil + void expand(vec3) nogil + int major_axis() nogil + vec3 box_center() nogil + float box_center_axis(int) nogil + int box_distance_sqr(vec3) nogil + void set_split_axis(int) nogil + int get_split_axis() nogil + bint is_leaf() nogil + + cdef cppclass BvhNodeLeaf: + int type, index + # BvhNodeLeaf(int) nogil + + union BvhNode: + BvhNodeBox box + BvhNodeLeaf leaf + bint is_leaf() nogil + + struct BvhNearestResult: + vec3 point + float distance + int tri_index + + +# cdef struct BvhNearestResult: +# vec3 point +# int tri_index +# float distance + + +@cython.final +cdef class BVH: + cdef: + BvhNodeLeaf* leaves + BvhNodeBox* boxes + BvhNode* root + + int free_box_idx + int size + Mesh mesh + + def __cinit__(self, Mesh mesh): + self.mesh = mesh + if mesh == None: + raise ValueError + + self.size = mesh.n_triangles + self.leaves = maelloc(sizeof(BvhNodeLeaf) * self.size, __LINE__) + self.boxes = maelloc(sizeof(BvhNodeBox) * self.size, __LINE__) + self.free_box_idx = self.size + + cdef int i + with nogil: + for i in prange(self.size): + self.leaves[i].index = i + self.boxes[i].split_axis = -1; + self.boxes[i].min = vec3(INFINITY); + self.boxes[i].max = vec3(-INFINITY); + + self.mesh.update_centroids() + self.mesh.update_face_normals() + self.root = self.build_tree(self.leaves, self.size) + + def __dealloc__(self): + fraeee(self.leaves) + fraeee(self.boxes) + + cdef inline BvhNodeBox* pop_box(self) nogil: + self.free_box_idx -= 1 + # if self.free_box_idx < 0: + # raise RuntimeError('Ran out of boxes') + + return & self.boxes[self.free_box_idx] + + cdef BvhNode* build_tree(self, BvhNodeLeaf* leaves, int size) nogil: + cdef int i, j + + if size == 1: + return leaves + + cdef BvhNodeBox * box = self.pop_box() + + for i in range(size): + for j in range(3): + box.expand(self.mesh.tri_vert(leaves[i].index, j)) + + cdef vec3 median = (box.max + box.min) * 0.5 + + cdef int axis = box.major_axis() + box.set_split_axis(axis) + box.split_pos = median.v[axis] + + j = 0 + for i in range(size): + if self.mesh.centroids[leaves[i].index].v[axis] < median.v[axis]: + leaves[i].index, leaves[j].index = leaves[j].index, leaves[i].index + j += 1 + + if j == 0 or j == size: + j = size // 2 + + box.nodes[0] = self.build_tree(leaves, j) + box.nodes[1] = self.build_tree(&leaves[j], size - j) + return box + + def find_nearest(self, _p): + cdef vec3 p + p.v = _p + cdef BvhNearestResult result = self._find_nearest(p) + return (result.point.v, result.tri_index, result.distance) + + cdef inline BvhNearestResult _find_nearest(self, vec3 p) nogil: + cdef BvhNearestResult result + result.distance = INFINITY + self.find_nearest_recursive( & p, & result, self.root) + return result + + cdef void find_nearest_recursive(self, vec3* p, BvhNearestResult* out, BvhNode* node) nogil: + cdef vec3 closest + cdef int i, axis + cdef float dist + if node.is_leaf(): + i = (< BvhNodeLeaf*>node).index + closest = project_point_triangle(self.mesh.tri_vert_ptr(i, 0)[0], + self.mesh.tri_vert_ptr(i, 1)[0], + self.mesh.tri_vert_ptr(i, 2)[0], + self.mesh.face_normals[i], + p[0]) + + dist = (closest - p[0]).len_sqr() + if dist < out.distance: + out.point = closest + out.tri_index = i + out.distance = dist + + else: + dist = node.box.box_distance_sqr(p[0]) + if dist < out.distance: + # if not node.box.nodes[0].is_leaf(): + # self.find_nearest_recursive(p, out, node.box.nodes[0]) + # self.find_nearest_recursive(p, out, node.box.nodes[1]) + # return + # + # if not node.box.nodes[1].is_leaf(): + # self.find_nearest_recursive(p, out, node.box.nodes[1]) + # self.find_nearest_recursive(p, out, node.box.nodes[0]) + # return + # + # if (node.box.nodes[0].box.box_center() - p[0]).len_sqr() < (node.box.nodes[1].box.box_center() - p[0]).len_sqr(): + # self.find_nearest_recursive(p, out, node.box.nodes[0]) + # self.find_nearest_recursive(p, out, node.box.nodes[1]) + # return + axis = node.box.get_split_axis() + if node.box.split_pos > p.v[axis]: + self.find_nearest_recursive(p, out, node.box.nodes[0]) + self.find_nearest_recursive(p, out, node.box.nodes[1]) + return + self.find_nearest_recursive(p, out, node.box.nodes[1]) + self.find_nearest_recursive(p, out, node.box.nodes[0]) + + + + +cdef extern from *: + ''' + struct HalfLink { + int a; + float original_length; + float scale; + }; + + struct HalfLinkArr { + int n; + HalfLink half_links[]; + }; + ''' + + struct HalfLink: + int a + float original_length + float scale + + + struct HalfLinkArr: + int n + HalfLink half_links[0] + + +@cython.final +cdef class LinkProbe: + cdef readonly SpringLinks springs + cdef HalfLinkArr* halflinks + cdef readonly int index + + def __cinit__(self, SpringLinks springs, int index): + self.springs = springs + if index < 0 or index >= springs.engine.n_verts: + raise IndexError + + self.index = index + self.halflinks = springs.links[index] + + def __getitem__(self, int link_index): + if link_index < 0 or link_index >= self.halflinks.n: + raise IndexError + return self.halflinks.half_links[link_index].a + + def __len__(self): + return self.halflinks.n + + def __iter__(self): + cdef int i + for i in range(self.halflinks.n): + yield self.halflinks.half_links[i].a + + @property + def avg_radius(self): + cdef int i + cdef float r = 0 + for i in range(self.halflinks.n): + r += self.halflinks.half_links[i].original_length + + return r / (self.halflinks.n + EPS) + +cdef class SpringLinks: + + cdef readonly SpringEngine engine + cdef int max_links + cdef HalfLinkArr** links + + @cython.boundscheck(True) + def __cinit__(self, SpringEngine engine, list links): + self.engine = engine + self.links = maelloc(sizeof(HalfLink**) * self.engine.n_verts, __LINE__) + self.links[0] = maelloc(sizeof(HalfLinkArr) * self.engine.n_verts + sizeof(HalfLink) * 2 * len(links), __LINE__) + + cdef int a, b, i, j, n + + cdef list arranged_links = [[] for i in range(engine.n_verts)] + + for a, b in links: + arranged_links[a].append(b) + arranged_links[b].append(a) + + cdef list half_lst + + for i in range(engine.n_verts): + half_lst = arranged_links[i] + n = len(half_lst) + + if i > 0: + self.links[i] = ((self.links[i - 1]) + sizeof(HalfLinkArr) + sizeof(HalfLink) * self.links[i - 1].n) + + self.links[i].n = n + + for j in range(n): + a = half_lst[j] + self.links[i].half_links[j].a = a + + self.lengths_update() + + def __dealloc__(self): + fraeee(self.links[0]) + fraeee(self.links) + + def __getitem__(self, int key): + if key < 0 or key >= self.engine.n_verts: + raise IndexError + + return LinkProbe(self, key) + + cpdef void lengths_update(self): + cdef int i, j, a + + for i in range(self.engine.n_verts): + for j in range(self.links[i].n): + a = self.links[i].half_links[j].a + self.links[i].half_links[j].original_length = (self.engine.m.verts[i] - self.engine.m.verts[a]).len() + self.links[i].half_links[j].scale = 1 + + cpdef void smooth(self, float factor): + cdef int i, j, n + cdef HalfLink* half_links + cdef vec3 avg + + with nogil: + for i in prange(self.engine.n_verts): + n = self.links[i].n + + half_links = self.links[i].half_links + + if n == 0: + avg = self.engine.m.verts[i] + continue + + avg = vec3(0) + + for j in range(n): + avg = avg + self.engine.m.verts[half_links[j].a] + + avg = avg * 1.0 / n + + self.engine.tmp_verts[i] = self.engine.m.verts[i].lerp(avg, factor) + + self.engine.m.verts, self.engine.tmp_verts = self.engine.tmp_verts, self.engine.m.verts + + + cpdef void soft_spring_force(self, float factor, float deform_update=0.3, float deform_restore=0.03, float min_deform=0.3, float max_deform=3.0): + cdef int i, j, n, a + cdef HalfLink* half_links + cdef vec3 delta + cdef float curr_length, diff + + with nogil: + for i in prange(self.engine.n_verts): + n = self.links[i].n + + half_links = self.links[i].half_links + + self.engine.tmp_verts[i] = vec3(0) + + for j in range(n): + a = half_links[j].a + + delta = self.engine.m.verts[i] - self.engine.m.verts[a] + curr_length = nmax(delta.len(), EPS) + diff = ((half_links[j].original_length * half_links[j].scale - curr_length) / curr_length) + self.engine.tmp_verts[i] += delta * diff + half_links[j].scale = nlerp(half_links[j].scale, nclamp(curr_length / half_links[j].original_length, min_deform, max_deform), deform_update) + half_links[j].scale = nlerp(half_links[j].scale, 1, deform_restore) + + self.engine.tmp_verts[i] *= 1.0 / (n + EPS) * factor + self.engine.tmp_verts[i] += self.engine.m.verts[i] + + self.engine.m.verts, self.engine.tmp_verts = self.engine.tmp_verts, self.engine.m.verts + + cpdef void stiff_spring_force(self, float factor): + cdef int i, j, n, a + cdef HalfLink* half_links + cdef vec3 delta + cdef float curr_length, diff + with nogil: + for i in prange(self.engine.n_verts): + n = self.links[i].n + + half_links = self.links[i].half_links + + self.engine.tmp_verts[i] = vec3(0) + + for j in range(n): + a = half_links[j].a + + delta = self.engine.m.verts[i] - self.engine.m.verts[a] + curr_length = delta.len() + + diff = (half_links[j].original_length * half_links[j].scale) / curr_length + + diff = nlerp(1.0, diff, factor) + + delta = delta * diff + self.engine.tmp_verts[i] += delta + self.engine.m.verts[a] + + + self.engine.tmp_verts[i] *= 1.0 / nmax(n, 1) + + self.engine.m.verts, self.engine.tmp_verts = self.engine.tmp_verts, self.engine.m.verts + + +cdef extern from *: + ''' + struct TernaryLink { + int a, b; + int side; + float avg_dist; + }; + + struct TernaryLinkArr { + int n; + TernaryLink arr[]; + }; + ''' + + struct TernaryLink: + int a, b + int side + float avg_dist + + struct TernaryLinkArr: + int n + TernaryLink arr[0] + +@cython.final +cdef class TernarySmoothingLinks: + cdef readonly SpringEngine engine + cdef TernaryLinkArr** links + + @cython.boundscheck(True) + def __cinit__(self, SpringEngine engine, list links): + self.engine = engine + + self.links = maelloc(sizeof(TernaryLinkArr**) * engine.n_verts, __LINE__) + self.links[0] = maelloc(sizeof(TernaryLinkArr) * engine.n_verts + sizeof(TernaryLink) * len(links), __LINE__) + + cdef list arranged_links = [[] for i in range(engine.n_verts)] + + cdef int c, a, b, i, j, n + + for c, a, b in links: + arranged_links[c].append((a, b)) + + cdef list links_lst + cdef vec3 avg, d + + for i in range(engine.n_verts): + links_lst = arranged_links[i] + if i > 0: + self.links[i] = ((self.links[i - 1]) + sizeof(TernaryLinkArr) + sizeof(TernaryLink) * self.links[i - 1].n) + + n = len(links_lst) + self.links[i].n = n + + for j in range(n): + a, b = links_lst[j] + self.links[i].arr[j].a = a + self.links[i].arr[j].b = b + + + def __dealloc__(self): + fraeee(self.links[0]) + fraeee(self.links) + + cpdef void displacements_update(self): + cdef int i, j, a, b + cdef vec3 avg, d + cdef TernaryLinkArr* arr + + self.engine.m.update_face_normals() + self.engine.m.update_vert_normals() + + for i in range(self.engine.n_verts): + arr = self.links[i] + + for j in range(arr.n): + a = arr.arr[j].a + b = arr.arr[j].b + avg = (self.engine.m.verts[a] + self.engine.m.verts[b]) * 0.5 + d = (self.engine.m.verts[i] - avg) + arr.arr[j].side = d.dot(self.engine.m.vert_normals[i]) > 0 + arr.arr[j].avg_dist = d.len() / ((self.engine.m.verts[a] - self.engine.m.verts[b]).len() + EPS) + + cpdef void displacement_force(self, float factor): + cdef int i, j, a, b + cdef vec3 avg, d + cdef TernaryLinkArr* arr + + cdef float l + + with nogil: + for i in prange(self.engine.n_verts): + arr = self.links[i] + if arr.n == 0: + continue + + self.engine.tmp_verts[i] = vec3(0) + + for j in range(arr.n): + a = arr.arr[j].a + b = arr.arr[j].b + + avg = (self.engine.m.verts[a] + self.engine.m.verts[b]) * 0.5 + d = (self.engine.m.verts[i] - avg) + if not (d.dot(self.engine.m.vert_normals[i]) > 0) == arr.arr[j].side: + d = d - d.project_unit(self.engine.m.vert_normals[i]) * 2 + l = d.len() + if l > EPS: + l = 1 / l + d = d * l * arr.arr[j].avg_dist * (self.engine.m.verts[a] - self.engine.m.verts[b]).len() + + self.engine.tmp_verts[i] += avg + d + + self.engine.tmp_verts[i] *= 1.0 / arr.n + + for i in prange(self.engine.n_verts): + if self.links[i].n == 0: + continue + + self.engine.m.verts[i] = self.engine.m.verts[i].lerp(self.engine.tmp_verts[i], factor) + + +cdef struct QuaternaryLink: + int a, b, c, d + float ratio + int side + +cdef class QuaternarySmoothingLinks: + cdef readonly SpringEngine engine + cdef readonly int n_links + cdef QuaternaryLink* links + cdef int* accum_n + + @cython.boundscheck(True) + def __cinit__(self, SpringEngine engine, list links): + self.engine = engine + self.n_links = len(links) + self.links = maelloc(sizeof(QuaternaryLink) * self.n_links, __LINE__) + self.accum_n = caelloc(engine.n_verts, sizeof(int), __LINE__) + + cdef QuaternaryLink* lnk + cdef int i + + for i in range(self.n_links): + lnk = self.links + i + lnk.a, lnk.b, lnk.c, lnk.d = links[i] + index_check(lnk.a, engine.n_verts) + index_check(lnk.b, engine.n_verts) + index_check(lnk.c, engine.n_verts) + index_check(lnk.d, engine.n_verts) + self.accum_n[lnk.a] += 1 + self.accum_n[lnk.b] += 1 + self.accum_n[lnk.c] += 1 + self.accum_n[lnk.d] += 1 + + for i in range(engine.n_verts): + if self.accum_n[i] == 0: + self.accum_n[i] = 1 + + self.lengths_update() + + def __dealloc__(self): + fraeee(self.links) + fraeee(self.accum_n) + + cpdef void lengths_update(self): + + cdef int i + cdef QuaternaryLink* lnk + cdef vec3 ab, cd + + for i in range(self.n_links): + lnk = self.links + i + ab = (self.engine.m.verts[lnk.a] - self.engine.m.verts[lnk.b]) + cd = (self.engine.m.verts[lnk.c] - self.engine.m.verts[lnk.d]) + + lnk.ratio = ab.len() / cd.len() + lnk.side = ab.dot(cd) > 1 + + cpdef void smooth(self, float factor, float max_ratio=3): + cdef int i + cdef QuaternaryLink* lnk + cdef vec3 ab, cd + cdef float lab, lcd, rlab, rlcd + cdef float min_ratio = 1.0 / max_ratio + + for i in range(self.engine.n_verts): + self.engine.tmp_verts[i] = vec3(0) + + for i in range(self.n_links): + lnk = self.links + i + if lnk.ratio < min_ratio or lnk.ratio > max_ratio: + continue + + ab = (self.engine.m.verts[lnk.a] - self.engine.m.verts[lnk.b]) + cd = (self.engine.m.verts[lnk.c] - self.engine.m.verts[lnk.d]) + + + rlab = ab.len() + rlcd = cd.len() + + lab = rlcd * lnk.ratio + lcd = rlab / lnk.ratio + + ab -= ab / rlab * lab + cd -= cd / rlcd * lcd + + self.engine.tmp_verts[lnk.a] -= ab + self.engine.tmp_verts[lnk.b] += ab + + self.engine.tmp_verts[lnk.c] -= cd + self.engine.tmp_verts[lnk.d] += cd + + for i in range(self.engine.n_verts): + self.engine.m.verts[i] += self.engine.tmp_verts[i] * factor / self.accum_n[i] + + +@cython.final +cdef class SpringEnginePin: + cdef readonly SpringEngine engine + cdef readonly int n_rings + cdef readonly int start_index + cdef int** rings + + + def __cinit__(self, SpringLinks links, int start_index, int n_rings): + n_rings = nmax(n_rings, 1) + self.engine = links.engine + + if start_index < 0 or start_index >= self.engine.n_verts: + raise ValueError('invalid start_index') + + self.start_index = start_index + + cdef list rings = [[start_index]] + cdef set seen = set((start_index,)) + cdef list new_front + cdef LinkProbe probe + + cdef int i + cdef int vert_idx + for i in range(n_rings - 1): + new_front = [] + for vert_idx in rings[-1]: + probe = links[vert_idx] + for new_idx in probe: + if new_idx not in seen: + seen.add(new_idx) + new_front.append(new_idx) + rings.append(new_front) + + self.n_rings = n_rings + self.rings = maelloc(sizeof(int**) * self.n_rings, __LINE__) + + for i in range(self.n_rings): + self.rings[i] = NULL + + cdef list front + cdef int j + + for i, front in enumerate(rings): + self.rings[i] = maelloc(sizeof(int*) * (len(front) + 1), __LINE__) + self.rings[i][0] = len(front) + + for j in range(self.rings[i][0]): + self.rings[i][j + 1] = front[j] + + def __getitem__(self, int index): + if index < 0 or index >= self.n_rings: + raise IndexError + + def iter_ring(): + cdef int i + for i in range(self.rings[index][0]): + yield self.rings[index][i + 1] + + return iter_ring() + + def __iter__(self): + cdef int i + for i in range(self.n_rings): + yield self[i] + + def move(self, float x, float y, float z, float scale): + cdef vec3 vec = vec3(x, y, z) + cdef vec3 ring_vec + + cdef int i, j + for i in range(self.n_rings): + ring_vec = vec * nclamp((scale - i - 1) / (scale - 1), 0, 1) + for j in range(self.rings[i][0]): + self.engine.m.verts[self.rings[i][j + 1]] += ring_vec + # self.engine.prev_verts[self.rings[i][j + 1]] += ring_vec + + + def __dealloc__(self): + cdef int i + for i in range(self.n_rings): + fraeee(self.rings[i]) + fraeee(self.rings) + + +cdef class _MaskContextManager: + cdef SpringEngineMask mask + cdef float factor + cdef bint invert + + def __cinit__(self, SpringEngineMask mask, float factor, bint invert): + self.mask = mask + self.factor = factor + self.invert = invert + + def __enter__(self): + self.mask.load() + + def __exit__(self, type, value, traceback): + self.mask.masked_store(self.factor, self.invert) + + + +cdef class SpringEngineMask: + cdef float* mask + cdef vec3* vec_data + + cdef SpringEngine engine + + def __cinit__(self, SpringEngine engine, list mask): + self.engine = engine + + if not mask: + self.mask = NULL + self.vec_data = NULL + return + + elif not len(mask) == engine.n_verts: + raise ValueError('mask must have the same number of elements as engine verts') + + self.mask = maelloc(sizeof(float) * self.engine.n_verts, __LINE__) + self.vec_data = maelloc(sizeof(vec3) * self.engine.n_verts, __LINE__) + + cdef int i + for i in range(self.engine.n_verts): + self.mask[i] = mask[i] + + def __getitem__(self, int index): + if self.mask == NULL: + return 0.0 + + index_check(index, self.engine.n_verts) + return self.mask[index] + + def __setitem__(self, int index, value): + if self.mask == NULL: + return + + index_check(index, self.engine.n_verts) + self.mask[index] = value + + cpdef set_force(self, float x, float y, float z): + if self.mask == NULL: + return + + cdef int i + cdef vec3 d, v + v = vec3(x, y, z) + with nogil: + for i in prange(self.engine.n_verts): + d = self.engine.m.verts[i] - self.engine.prev_verts[i] + d = d.lerp(v, self.mask[i]) + self.engine.m.verts[i] = self.engine.prev_verts[i] + d + + cpdef void load(self): + if self.mask == NULL: + return + + cdef int i + with nogil: + for i in prange(self.engine.n_verts): + self.vec_data[i] = self.engine.m.verts[i] + + cpdef void store(self): + if self.mask == NULL: + return + + cdef int i + with nogil: + for i in prange(self.engine.n_verts): + self.engine.m.verts[i] = self.vec_data[i] + + cpdef void masked_store(self, float factor=1, bint invert=False): + if self.mask == NULL: + return + + cdef int i + with nogil: + if invert: + for i in prange(self.engine.n_verts): + self.engine.m.verts[i] = self.engine.m.verts[i].lerp(self.vec_data[i], (1.0 - self.mask[i]) * factor) + else: + for i in prange(self.engine.n_verts): + self.engine.m.verts[i] = self.engine.m.verts[i].lerp(self.vec_data[i], self.mask[i] * factor) + + cpdef set(self, list vec_data): + if self.mask == NULL: + return + + cdef int i + if not len(vec_data) == self.engine.n_verts * 3: + raise ValueError('vec_data must have the same number of elements as engine verts times 3') + + for i in range(self.engine.n_verts * 3): + self.vec_data[i // 3].v[i % 3] = vec_data[i] + + def masked_context(self, float factor=1, bint invert=False): + return _MaskContextManager(self, factor, invert) + + def __dealloc__(self): + fraeee(self.vec_data) + fraeee(self.mask) + + + +@cython.final +cdef class SymmetryMap: + cdef int* symm_map + cdef SpringEngine engine + cdef readonly float[3] error + + def __cinit__(self, SpringEngine engine): + if engine == None: + raise ValueError + cdef BVH bvh = BVH(engine.m) + self.engine = engine + self.symm_map = maelloc(sizeof(int) * engine.n_verts * 3, __LINE__) + + cdef int i, j, axis, v_index + cdef BvhNearestResult result + cdef vec3 v + cdef double dist, tmp_dist + + self.error = (0, 0, 0) + + with nogil: + for i in prange(self.engine.n_verts): + for axis in range(3): + dist = INFINITY + v = self.engine.m.verts[i] + v.v[axis] = -v.v[axis] + + result = bvh._find_nearest(v) + for j in range(3): + v_index = self.engine.m.triangles[result.tri_index][j] + tmp_dist = (self.engine.m.verts[v_index] - v).len() + if tmp_dist < dist: + dist = tmp_dist + self.symm_map[i + self.engine.m.n_verts * axis] = v_index + self.error[axis] = nmax(dist, self.error[axis]) + + def __getitem__(self, int index): + if index < 0 or index >= self.engine.n_verts: + raise KeyError + + return tuple(self.symm_map[index + axis * self.engine.n_verts] for axis in range(3)) + + cpdef void mirror(self, bint x, bint y, bint z): + cdef int i, j, axis, v_index + cdef int[3] mirror = (x, y, z) + cdef vec3 v + + with nogil: + for axis in range(3): + if not mirror[axis]: + continue + + for i in prange(self.engine.n_verts): + v_index = self.symm_map[i + axis * self.engine.m.n_verts] + v = self.engine.m.verts[v_index] + v.v[axis] = -v.v[axis] + self.engine.tmp_verts[i] = (self.engine.m.verts[i] + v) * 0.5 + + self.engine.tmp_verts, self.engine.m.verts = self.engine.m.verts, self.engine.tmp_verts + + def __dealloc__(self): + fraeee(self.symm_map) + + +cdef class SpringEngine: + cdef Mesh m + cdef vec3* prev_verts + cdef vec3* tmp_verts + cdef BVH bvh + cdef int* bvh_closest_indexes + cdef unsigned int snap_count + + cdef int n_verts + + def __init__(self, Mesh m, BVH bvh=None): + self.m = m + self.n_verts = m.n_verts + self.snap_count = 0 + self.prev_verts = maelloc(sizeof(vec3) * self.n_verts, __LINE__) + self.tmp_verts = maelloc(sizeof(vec3) * self.n_verts, __LINE__) + self.bvh_closest_indexes = maelloc(sizeof(vec3) * self.n_verts, __LINE__) + cdef int i + for i in range(self.n_verts): + self.prev_verts[i] = self.m.verts[i] + + self.set_bvh(bvh) + + cpdef void set_bvh(self, BVH bvh): + self.bvh = bvh + + cdef int i + if bvh: + with nogil: + for i in prange(self.n_verts): + self.bvh_closest_indexes[i] = -1 + + def __dealloc__(self): + fraeee(self.prev_verts) + fraeee(self.tmp_verts) + fraeee(self.bvh_closest_indexes) + + def __len__(self): + return self.n_verts * 3 + + def __getitem__(self, int key): + return self.m.verts[key // 3].v[key % 3] + + def __setitem__(self, int key, float v): + self.m.verts[key // 3].v[key % 3] = v + self.prev_verts[key // 3].v[key % 3] = v + + def from_list(self, list items): + if not len(items) >= self.n_verts * 3: + raise ValueError('list too small') + + cdef int i + for i in range(self.n_verts * 3): + self.m.verts[i // 3].v[i % 3] = items[i] + self.prev_verts[i // 3].v[i % 3] = items[i] + + def set_verts(self, list indexes, list locations): + cdef int i, index + cdef float x, y, z + if not len(indexes) == len(locations): + raise ValueError('indexes array is not the same size as locations array') + + for i in range(len(indexes)): + index = indexes[i] + x, y, z = locations[i] + self.prev_verts[index] = self.m.verts[index] = vec3(x, y, z) + + def get_verts(self, list indexes): + cdef int i, index + cdef list ret = [] + for i in range(len(indexes)): + index = indexes[i] + if index < 0 or index >= self.n_verts: + raise IndexError + ret.append(self.m.verts[index].v) + return ret + + def move_verts(self, list indexes, float x, float y, float z): + cdef vec3 delta = vec3(x, y, z) + cdef int i, index + for i in range(len(indexes)): + index = indexes[i] + if index < 0 or index >= self.n_verts: + raise IndexError + self.m.verts[index] += delta + self.prev_verts[index] += delta + + def snap_to_bvh(self, float factor=1, int cycle_quality=10, str snapping_mode='SURFACE'): + cdef int snapping_mode_ = {'SURFACE': 1, + 'OUTSIDE': 2, + 'INSIDE': 4}[snapping_mode] + + if not self.bvh: + raise RuntimeError('No bvh avaliable') + + cycle_quality = nabs(cycle_quality) + self.snap_count += 1 + + cdef BvhNearestResult result + cdef int i + cdef vec3 v + cdef float snapping + cdef unsigned int cycle + + with nogil: + for i in prange(self.n_verts): + cycle = (i ^ 0x243F6A88) * 0x243F6A88 + cycle = cycle ^ cycle >> 5 + cycle = cycle + self.snap_count + + if cycle % cycle_quality > 0 and self.bvh_closest_indexes[i] >= 0: + result.tri_index = self.bvh_closest_indexes[i] + result.point = project_point_plane( + self.m.verts[i], + self.bvh.mesh.verts[self.bvh.mesh.triangles[result.tri_index][0]], + self.bvh.mesh.face_normals[result.tri_index] + ) + else: + result = self.bvh._find_nearest(self.m.verts[i]) + self.bvh_closest_indexes[i] = result.tri_index + + v = result.point - self.m.verts[i] + + if snapping_mode_ & 1: + if v.dot(self.bvh.mesh.face_normals[result.tri_index]) > 0: + if v.dot(self.m.vert_normals[i]) < 0: + v = self.m.vert_normals[i] * v.len() + v * 0.5 + + + snapping = self.m.vert_normals[i].dot(self.bvh.mesh.face_normals[result.tri_index]) + snapping = snapping * snapping + + v = v * factor * snapping + self.m.verts[i] += v + + elif snapping_mode_ & (2 | 4): + if (v.dot(self.bvh.mesh.face_normals[result.tri_index]) > 0) ^ (snapping_mode_ & 4 > 0): + v = self.m.verts[i] = result.point + + cpdef SpringLinks create_spring_group(self, list links): + return SpringLinks(self, links) + + cpdef SymmetryMap create_symmetry_map(self): + return SymmetryMap(self) + + cpdef TernarySmoothingLinks create_ternary_links(self, list links): + return TernarySmoothingLinks(self, links) + + cpdef QuaternarySmoothingLinks create_quaternary_links(self, list links): + return QuaternarySmoothingLinks(self, links) + + cpdef SpringEngineMask create_mask(self, mask): + return SpringEngineMask(self, mask) + + cpdef void random_verts(self, float factor, unsigned int seed=0x452821E6): + cdef int i + cdef unsigned int xorstate = 0x452821E6 + cdef vec3 v + with nogil: + for i in prange(self.n_verts): + v = vec3(xorshiftf(&xorstate), xorshiftf(&xorstate), xorshiftf(&xorstate)) * factor + self.m.verts[i] += v + self.prev_verts[i] += v + + cpdef void kinetic_step(self, float damping): + cdef int i + + with nogil: + for i in prange(self.n_verts): + self.tmp_verts[i] = (self.m.verts[i] - self.prev_verts[i]) * damping + self.m.verts[i] + + self.prev_verts, self.m.verts, self.tmp_verts = self.m.verts, self.tmp_verts, self.prev_verts + + cpdef void update_mesh_normals(self, float factor): + self.tmp_verts, self.m.vert_normals = self.m.vert_normals, self.tmp_verts + + self.m.update_face_normals() + self.m.update_vert_normals() + + cdef int i + if factor < 1: + with nogil: + for i in prange(self.n_verts): + self.m.vert_normals[i] = self.tmp_verts[i].lerp(self.m.vert_normals[i], factor) diff --git a/softwrap2/draw_3d.py b/softwrap2/draw_3d.py new file mode 100644 index 0000000..d2f1a3e --- /dev/null +++ b/softwrap2/draw_3d.py @@ -0,0 +1,239 @@ +# Copyright (C) 2021 Jean Da Costa machado. +# Jean3dimensional@gmail.com +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +''' +This is a utility module for drawing lines in the 3D viewport on Blender 2.8 +using the GPU Api + + +The idea is to get rid of messy draw functions and data that is hard to keep track. +This class works directly like a callable draw handler and keeps track of all the geometry data. +''' + +__all__ = ["DrawCallback"] + +import bpy +import bgl +import gpu +from gpu_extras.batch import batch_for_shader +from mathutils import Matrix, Vector +VERSION = bpy.app.version + +vertex_shader = ''' + +uniform mat4 ModelViewProjectionMatrix; + +#ifdef USE_WORLD_CLIP_PLANES +uniform mat4 ModelMatrix; +#endif + +in vec3 pos; +in vec4 color; + +out vec4 finalColor; + +void main() +{ + gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0); + gl_Position.z -= 0.002; + finalColor = color; + + #ifdef USE_WORLD_CLIP_PLANES + world_clip_planes_calc_clip_distance((ModelMatrix * vec4(pos, 1.0)).xyz); + #endif +} + +''' + + +fragment_shader = """ +in vec4 finalColor; +out vec4 fragColor; + +void main() +{ + fragColor = finalColor; + fragColor = blender_srgb_to_framebuffer_space(fragColor); +} +""" + +point_fragment_shader = """ +in vec4 finalColor; +in vec4 fragCoord; + +out vec4 fragColor; + +void main() +{ + vec2 coord = (gl_PointCoord - vec2(0.5, 0.5)) * 2.0; + float fac = dot(coord, coord); + if (fac > 0.5){ + discard; + } + fragColor = finalColor; + fragColor = blender_srgb_to_framebuffer_space(fragColor); +} + +""" + + +class DrawCallback: + running_draws = set() + + def __init__(self): + + # Useful for rendering in the same space of an object + self.matrix = Matrix().Identity(4) + # X-ray mode, draw through solid objects + self.draw_on_top = False + # Blend mode to choose, set it to one of the blend constants. + self.blend_mode = 'MULTIPLY' + + self.line_width = 1 + self.point_size = 3 + + # Handler Placeholder + self.draw_handler = None + + self.line_coords = [] + self.line_colors = [] + self.point_coords = [] + self.point_colors = [] + self._line_shader = gpu.types.GPUShader(vertex_shader, fragment_shader) + self._point_shader = gpu.types.GPUShader(vertex_shader, point_fragment_shader) + self._line_batch = batch_for_shader(self._line_shader, 'LINES', + {"pos": self.line_coords, "color": self.line_colors}) + self._point_batch = batch_for_shader(self._line_shader, 'POINTS', + {"pos": self.point_coords, "color": self.line_colors}) + + def __call__(self, *args, **kwargs): + # __call__ Makes this object behave like a function. + # So you can add it like a draw handler. + self._draw() + + def setup_handler(self): + # Utility function to easily add it as a draw handler + self.draw_handler = bpy.types.SpaceView3D.draw_handler_add(self, (), "WINDOW", "POST_VIEW") + self.__class__.running_draws.add(self) + + def remove_handler(self): + # Utility function to remove the handler + if not self.draw_handler: + return + bpy.types.SpaceView3D.draw_handler_remove(self.draw_handler, "WINDOW") + self.draw_handler = None + self.__class__.running_draws.remove(self) + + @classmethod + def remove_all_handlers(cls): + for draw in list(cls.running_draws): + draw.remove_handler() + + def update_batch(self): + # This takes the data rebuilds the shader batch. + # Call it every time you clear the data or add new lines, otherwize, + # You wont see changes in the viewport + coords = [self.matrix @ Vector(coord) for coord in self.line_coords] + self._line_batch = batch_for_shader(self._line_shader, 'LINES', {"pos": coords, "color": self.line_colors}) + coords = [self.matrix @ Vector(coord) for coord in self.point_coords] + self._point_batch = batch_for_shader(self._point_shader, 'POINTS', {"pos": coords, "color": self.point_colors}) + + def add_line(self, start, end, color1=(1, 0, 0, 1), color2=None): + # Simple add_line function, support color gradients, + # if only color1 is specified, it will be solid color (color1 on both ends) + # This doesnt render a line, it just adds the vectors and colors to the data + # so after calling update_batch(), it will be converted in a buffer Object + self.line_coords.append(Vector(start)) + self.line_coords.append(Vector(end)) + self.line_colors.append(color1) + if color2 is None: + self.line_colors.append(color1) + else: + self.line_colors.append(color2) + + def add_point(self, location, color=(1, 0, 0, 1)): + self.point_coords.append(location) + self.point_colors.append(color) + + def clear_data(self): + # just clear all the data + self.line_coords = [] + self.line_colors = [] + self.point_coords = [] + self.point_colors = [] + + def _start_drawing(self): + # This handles all the settings of the renderer before starting the draw stuff + if VERSION[1] >= 93: + gpu.state.blend_set('ALPHA') + + # bgl.glDisable(bgl.GL_DEPTH_TEST) + # if self.draw_on_top: + if self.draw_on_top: + gpu.state.depth_test_set('NONE') + + gpu.state.line_width_set(self.line_width) + gpu.state.point_size_set(self.point_size) + + else: + bgl.glEnable(bgl.GL_BLEND) + + if self.draw_on_top: + bgl.glDisable(bgl.GL_DEPTH_TEST) + + bgl.glLineWidth(self.line_width) + bgl.glPointSize(self.point_size) + + def _stop_drawing(self): + + # just reset some OpenGL stuff to not interfere with other drawings in the viewport + # its not absolutely necessary but makes it safer. + if VERSION[1] >= 93: + pass + + else: + bgl.glDisable(bgl.GL_BLEND) + bgl.glLineWidth(1) + bgl.glPointSize(1) + if self.draw_on_top: + bgl.glEnable(bgl.GL_DEPTH_TEST) + + def _draw(self): + # This should be called by __call__, + # just regular routines for rendering in the viewport as a draw_handler + self._start_drawing() + self._line_shader.bind() + self._line_batch.draw(self._line_shader) + self._point_shader.bind() + self._point_batch.draw(self._point_shader) + self._stop_drawing() + + +if __name__ == "__main__": + # Simple example, run it on blender's text editor. + + # create a new instance of the class + draw = DrawCallback() + # add lines to ir + draw.add_line((10, 0, 0), (-10, 0, 0), color1=(1, 0, 0, 1), color2=(0, 0, 1, 1)) + draw.add_line((0, 0, 0), (0, 0, 5), color1=(0, 1, 0, 1), color2=(0, 1, 1, 1)) + # enable X ray mode/see through objects and set Blend mode to Additive + draw.draw_on_top = True + draw.blend_mode = ADDITIVE_BLEND + # set line width to 5 + draw.line_width = 5 + # Important, update batch always when adding + # new lines, otherwize they wont render. + draw.update_batch() + # setup draw handler, optionally, you can call bpy.SpaceView3D.draw_handler_add() + draw.setup_handler() diff --git a/softwrap2/setup.py b/softwrap2/setup.py new file mode 100644 index 0000000..b199f5e --- /dev/null +++ b/softwrap2/setup.py @@ -0,0 +1,111 @@ +# Copyright (C) 2021 Jean Da Costa machado. +# Jean3dimensional@gmail.com +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + + +from setuptools import setup, Extension +from Cython.Build import cythonize +from distutils.util import get_platform +import re +from sys import argv +from os import path + +debug = 'debug' in argv +if debug: + argv.remove('debug') + +platf = get_platform().lower() +print(f'compiling for platform: {platf}') +if 'linux' in platf: + extra_compile_args = ['-ffast-math', '-fopenmp', '-O3'] + (['-g3'] if debug else []) + extra_link_args = ['-fopenmp'] + (['-g3'] if debug else []) + +elif 'win' in platf: + extra_compile_args = ['/O2', '/openmp', '/fp:fast'] + (['/debug'] if debug else []) + extra_link_args = ['/openmp'] + (['/debug'] if debug else []) + +else: # mac + extra_compile_args = ['-ffast-math', '-O3', '-std=c++2a'] + (['-g3'] if debug else []) + extra_link_args = ['-g3'] if debug else [] + + + +def line_directive_add(filestr): + modfied_tag = '/* Postprocessed to add #line directives */' + if filestr.startswith(modfied_tag): + return filestr + + lines = filestr.split('\n') + line_comment_re = re.compile(r"^\s*\/\*\s*\"(.+)\":(\d+)") + define_re = re.compile(r'\s*#\s*define') + + curr_line = None + curr_file = None + in_comment = False + in_define = False + + new_lines = [modfied_tag] + for line in lines: + if "/*" in line: + in_comment = True + curr_file = None + curr_line = None + + match = line_comment_re.match(line) + if match: + filename = match.group(1) + line_num = match.group(2) + if path.isfile(filename): + # curr_file = path.abspath(filename) + curr_file = filename + curr_line = line_num + + if define_re.match(line): + in_define = True + + if not in_comment and not in_define and line.strip(): + if curr_file: + new_lines.append(f'\n# line {curr_line} "{curr_file}"') + + if '*/' in line: + in_comment = False + + if not line.endswith('\\'): + in_define = False + + new_lines.append(line) + + return '\n'.join(new_lines) + '\n' + + +modules = cythonize( + Extension( + 'softwrap_core2', + # ['core/core.pyx'], + ['core/core2.pyx'], + extra_compile_args=extra_compile_args, + extra_link_args=extra_link_args, + include_dirs=["core"] + ) +) + +print('adding #line directives') +with open('core/core2.cpp', 'r+') as f: + new_filestr = line_directive_add(f.read()) + f.seek(0) + f.truncate() + f.write(new_filestr) + +setup( + name='softwrap_core2', + ext_modules=modules +) diff --git a/softwrap2/softwrap_core2.cp310-win_amd64.pyd b/softwrap2/softwrap_core2.cp310-win_amd64.pyd new file mode 100644 index 0000000..0ca9636 Binary files /dev/null and b/softwrap2/softwrap_core2.cp310-win_amd64.pyd differ