zeffii / mesh_tiny_cad

a tiny set of unmissable CAD functions ( VTX, XALL ...) for Blender

Home Page:http://zeffii.github.io/mesh_tiny_cad/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Extend Multiple Towards

zeffii opened this issue · comments

Desired functionality:

  • Select an edge: (call this Edge Prime)
    • it becomes dotted as to suggest it will be used for the destination.
  • Any subsequent clicked edge will be extended towards Edge Prime , if they are calculated to intersect.

If no welding is performed for Extended edges onto Edge Prime then this is doable and nice exercise if i'm bored some time.

Imgur

pseudo code

force edge mode
- first selected, becomes Edge_Prime
    - draw dots over Edge_Prime
- subsequent clicked edges are checked if they extend towards Edge_Prime
    - if yes, this edge is Edge_RX
        - get location of intersection on Edge_Prime
        if intersection is on Edge_Prime
            - call intersection IntX
            - figure out which vertex of Edge_RX is closest to IntX call it Vlast
            - extend from Vlast to IntX

or.....

''' Extend Multiple'''

mode 0 extend towards (this creates a new edge)
mode 1 moves the closest vertex to the projected intersection.

force edge mode
- first selected, becomes Edge_Prime
    - draw dots over Edge_Prime
- subsequent clicked edges are checked if they extend towards Edge_Prime
    - if yes, this edge is Edge_RX
        - get location of intersection on Edge_Prime
        if intersection is on Edge_Prime
            - call intersection IntX
            - figure out which vertex of Edge_RX is closest to IntX call it Vlast

            if mode==0
                - extend from Vlast to IntX
            else:
                - move Vlast to IntX
"""
''' Extend Multiple'''

mode 0 extend towards (this creates a new edge)
mode 1 moves the closest vertex to the projected intersection.

force edge mode
- first selected, becomes Edge_Prime
    - draw dots over Edge_Prime
- subsequent clicked edges are checked if they extend towards Edge_Prime
    - if yes, this edge is Edge_RX
        - get location of intersection on Edge_Prime
        if intersection is on Edge_Prime
            - call intersection IntX
            - which vertex of Edge_RX is closest to idx.
                - call that point Vlast

            if mode==0
                - extend from Vlast to idx
            else:
                - move Vlast to idx
"""


def does_edge_intersect(edge_rx, edge_prime):
    # return point
    pass

def is_point_on_edge(point, edge_prime):
    # this might be an intersection on the mathematical concept of a line
    # that's no good. I want it to really be a point on the edge.
    pass

def closest_idx_to_intersection(point, edge_rx):
    # returns idx , integer
    pass

def draw_edge_prime(self, context, edge_prime):
    pass

def add_vertex(point):
    # add new vertex, and new edge, edge = [idx, vc]
    pass

def move_vertex(idx, point):
    pass


def checkEdge(edge_rx):
    point = does_edge_intersect(edge_rx, edge_prime)
    if point:
        if not is_point_on_edge(point, edge_prime):
            continue
        idx = closest_idx_to_intersection(point, edge_rx)
        if mode == 0:
            add_vertex(point)
        elif mode == 1:
            move_vertex(idx, point)

some design decisions..

Do I code edge detection to deal with hovering of individual edges? or use the edge selection feature as built-in.

I think, i'll store all selected edges in a list,

  • launch operator
    • start new empty edge_list
    • store already selected edges in a restore_list
    • force un-selection of all edges if len(restore_list) > 0
  • let User select edges, store them in edges_list
  • draw edges[0] using dotted gl_line
  • draw edges[1:] using a different indicator
    • only add edges to list if they intersect
    • draw extention towards intersection for each edge
  • when hitting enter,
    • perform addition to the geometry
    • remove all items from edge list
    • clear drawing ( end operator )
    • if len(restore_list) > 0 then reselect them

https://gist.github.com/anonymous/9476761 is a caricature of what I need.seems to be OK now drawing different linetypes
Imgur

Imgur damn straight.
https://gist.github.com/zeffii/9527311

it's not pretty, nor optimal code. but adding the final 'create geometry' part is now easier.

next steps are

  • add geometry on 'PERIOD' press
  • curb num calls to draw_callback_px
  • restructure code where possible to reuse already obtained verts/edges..