Author Topic: find all possible triangles  (Read 2927 times)

0 Members and 1 Guest are viewing this topic.

domenicomaria

  • Bull Frog
  • Posts: 434
Re: find all possible triangles
« Reply #15 on: December 27, 2022, 01:37:51 PM »
Marco
I have a health problem
And I'm in the hospital

And I can't study your code and give you an answer

Further on, I hope I can.

Thank you

Ciao

ribarm

  • Gator
  • Posts: 2876
  • Marko Ribar, architect
Re: find all possible triangles
« Reply #16 on: December 27, 2022, 03:18:40 PM »
Sorry for health Domenico...
I believe that something hides behind this code, but it doesn't modify copied polylines... Don't know how to fix it...

[EDIT : Fixed buggs...]

Code - Auto/Visual Lisp: [Select]
  1. ;;; analyze of irregular polygon - problem of finding shape of irregular polygon based on input data refering all measured distances between all point pairs ;;;
  2. ;;; dedicated topic : http://www.theswamp.org/index.php?topic=57402.0 ;;;
  3.  
  4. (defun c:decomposition+composition ( / *error* tttt uniquetrl comb trianglst LM:popup makelw mid
  5.                                        lw lwn lwx pl dx dd plcomb trl p3 tr k wcs ti
  6.                                    )
  7.  
  8.   (defun *error* ( m )
  9.     (if wcs
  10.       (if ucsf
  11.         (exe (list "_.UCS" "_P"))
  12.       )
  13.     )
  14.     (while (= 8 (logand 8 (getvar (quote undoctl))))
  15.       (if (not (exe (list "_.UNDO" "_E")))
  16.         (if doc
  17.           (vla-endundomark doc)
  18.         )
  19.       )
  20.     )
  21.     (if initvalueslst
  22.       (mapcar (function apply_cadr->car) initvalueslst)
  23.     )
  24.     (foreach fun (list (quote tttt) (quote vl-load) (quote exe) (quote cmdfun) (quote cmderr) (quote catch_cont) (quote apply_cadr->car) (quote ftoa))
  25.       (setq fun nil)
  26.     )
  27.     (if doc
  28.       (vla-regen doc acactiveviewport)
  29.     )
  30.     (if m
  31.       (prompt m)
  32.     )
  33.     (princ)
  34.   )
  35.  
  36.   (defun tttt ( wcs / sysvarpreset sysvarlst sysvarvals ) ;;; wcs (T/nil) ;;; cad, doc, alo, spc - global variables (Visual Lisp main VLA-OBJECT pointers) ;;; vl-load exe cmdfun cmderr catch_cont apply_cadr->car ftoa - library sub functions common for standard template initialization ;;;
  37.  
  38.     (defun vl-load nil
  39.       (or cad
  40.           (setq cad (vlax-get-acad-object))
  41.           (progn
  42.             (vl-load-com)
  43.             (setq cad (vlax-get-acad-object))
  44.           )
  45.         )
  46.       )
  47.       (or doc (setq doc (vla-get-activedocument cad)))
  48.       (or alo (setq alo (vla-get-activelayout doc)))
  49.       (or spc (setq spc (vla-get-block alo)))
  50.     )
  51.  
  52.     ;;; sometimes not needed to use/initialize AxiveX Visual Lisp extensions - (comment/uncomment) following line ;;;
  53.     (or (and cad doc alo spc) (vl-load))
  54.  
  55.     (defun exe ( tokenslist )
  56.       ( (lambda ( tokenslist / ctch )
  57.           (if (vl-catch-all-error-p (setq ctch (cmdfun tokenslist t)))
  58.             (progn
  59.               (cmderr tokenslist)
  60.               (catch_cont ctch)
  61.             )
  62.             (progn
  63.               (while (< 0 (getvar (quote cmdactive)))
  64.                 (vl-cmdf "")
  65.               )
  66.               t
  67.             )
  68.           )
  69.         )
  70.         tokenslist
  71.       )
  72.     )
  73.  
  74.     (defun cmdfun ( tokenslist flag / ctch ) ;;; tokenslist - command parameters list of strings ;;; flag - if "t" specified, upon successful execution returns t, otherwise if "nil" specified, return is always nil no matter what outcome of function execution is - it should be successful anyway if specified tokenslist was hardcoded correctly... ;;;
  75.       (if command-s
  76.         (if flag
  77.           (if (not (vl-catch-all-error-p (setq ctch (vl-catch-all-apply (function command-s) tokenslist))))
  78.             flag
  79.             ctch
  80.           )
  81.           (if (vl-catch-all-error-p (setq ctch (vl-catch-all-apply (function command-s) tokenslist)))
  82.             ctch
  83.           )
  84.         )
  85.         (if flag
  86.           (if (not (vl-catch-all-error-p (setq ctch (vl-catch-all-apply (function vl-cmdf) tokenslist))))
  87.             flag
  88.             ctch
  89.           )
  90.           (if (vl-catch-all-error-p (setq ctch (vl-catch-all-apply (function command) tokenslist)))
  91.             ctch
  92.           )
  93.         )
  94.       )
  95.     )
  96.  
  97.     (defun cmderr ( tokenslist ) ;;; tokenslist - list of tokens representing command syntax at which used (cmdfun) failed with successful execution ;;;
  98.       (prompt (strcat "\ncommand execution failure... error at used command tokenslist : " (vl-prin1-to-string tokenslist)))
  99.     )
  100.  
  101.     (defun catch_cont ( ctch / gr )
  102.       (prompt "\nleft mouse click to continue or enter to generate catch error - ESC to break...")
  103.       (while
  104.         (and
  105.           (vl-catch-all-error-p (or ctch (setq ctch (vl-catch-all-apply (function /) (list 1 0)))))
  106.           (setq gr (grread))
  107.           (/= (car gr) 3)
  108.           (not (equal gr (list 2 13)))
  109.         )
  110.       )
  111.       (if (vl-catch-all-error-p ctch)
  112.         ctch
  113.       )
  114.     )
  115.  
  116.     (defun apply_cadr->car ( sysvarvaluepair / ctch )
  117.       (setq ctch (vl-catch-all-apply (function setvar) sysvarvaluepair))
  118.       (if (vl-catch-all-error-p ctch)
  119.         (progn
  120.           (prompt (strcat "\ncatched error on setting system variable : " (vl-prin1-to-string (vl-symbol-name (car sysvarvaluepair))) " with value : " (vl-prin1-to-string (cadr sysvarvaluepair))))
  121.           (catch_cont ctch)
  122.         )
  123.       )
  124.     )
  125.  
  126.     (defun ftoa ( n / m a s b )
  127.       (if (numberp n)
  128.         (progn
  129.           (setq m (fix ((if (< n 0) - +) n 1e-8)))
  130.           (setq a (abs (- n m)))
  131.           (setq m (itoa m))
  132.           (setq s "")
  133.           (while (and (not (equal a 0.0 1e-6)) (setq b (fix (* a 10.0))))
  134.             (setq s (strcat s (itoa b)))
  135.             (setq a (- (* a 10.0) b))
  136.           )
  137.           (if (= (type n) (quote int))
  138.             m
  139.             (if (= s "")
  140.               m
  141.               (if (and (= m "0") (< n 0))
  142.                 (strcat "-" m "." s)
  143.                 (strcat m "." s)
  144.               )
  145.             )
  146.           )
  147.         )
  148.       )
  149.     )
  150.  
  151.     (setq sysvarpreset
  152.       (list
  153.         (list (quote cmdecho) 0)
  154.         (list (quote 3dosmode) 0)
  155.         (list (quote osmode) 0)
  156.         (list (quote unitmode) 0)
  157.         (list (quote cmddia) 0)
  158.         (list (quote ucsvp) 0)
  159.         (list (quote ucsortho) 0)
  160.         (list (quote projmode) 0)
  161.         (list (quote orbitautotarget) 0)
  162.         (list (quote insunits) 0)
  163.         (list (quote hpseparate) 0)
  164.         (list (quote hpgaptol) 0)
  165.         (list (quote halogap) 0)
  166.         (list (quote edgemode) 0)
  167.         (list (quote pickdrag) 0)
  168.         (list (quote qtextmode) 0)
  169.         (list (quote dragsnap) 0)
  170.         (list (quote angdir) 0)
  171.         (list (quote aunits) 0)
  172.         (list (quote limcheck) 0)
  173.         (list (quote gridmode) 0)
  174.         (list (quote nomutt) 0)
  175.         (list (quote apbox) 0)
  176.         (list (quote attdia) 0)
  177.         (list (quote blipmode) 0)
  178.         (list (quote copymode) 0)
  179.         (list (quote circlerad) 0.0)
  180.         (list (quote filletrad) 0.0)
  181.         (list (quote filedia) 1)
  182.         (list (quote autosnap) 1)
  183.         (list (quote objectisolationmode) 1)
  184.         (list (quote highlight) 1)
  185.         (list (quote lispinit) 1)
  186.         (list (quote layerpmode) 1)
  187.         (list (quote fillmode) 1)
  188.         (list (quote dragmodeinterrupt) 1)
  189.         (list (quote dispsilh) 1)
  190.         (list (quote fielddisplay) 1)
  191.         (list (quote deletetool) 1)
  192.         (list (quote delobj) 1)
  193.         (list (quote dblclkedit) 1)
  194.         (list (quote attreq) 1)
  195.         (list (quote explmode) 1)
  196.         (list (quote frameselection) 1)
  197.         (list (quote ltgapselection) 1)
  198.         (list (quote pickfirst) 1)
  199.         (list (quote plinegen) 1)
  200.         (list (quote plinetype) 1)
  201.         (list (quote peditaccept) 1)
  202.         (list (quote solidcheck) 1)
  203.         (list (quote visretain) 1)
  204.         (list (quote regenmode) 1)
  205.         (list (quote celtscale) 1.0)
  206.         (list (quote ltscale) 1.0)
  207.         (list (quote osnapcoord) 2)
  208.         (list (quote grips) 2)
  209.         (list (quote dragmode) 2)
  210.         (list (quote lunits) 2)
  211.         (list (quote pickstyle) 3)
  212.         (list (quote navvcubedisplay) 3)
  213.         (list (quote pickauto) 3)
  214.         (list (quote draworderctl) 3)
  215.         (list (quote expert) 5)
  216.         (list (quote auprec) 6)
  217.         (list (quote luprec) 6)
  218.         (list (quote pickbox) 6)
  219.         (list (quote aperture) 6)
  220.         (list (quote osoptions) 7)
  221.         (list (quote dimzin) 8)
  222.         (list (quote pdmode) 35)
  223.         (list (quote pdsize) -1.5)
  224.         (list (quote celweight) -1)
  225.         (list (quote cecolor) "BYLAYER")
  226.         (list (quote celtype) "ByLayer")
  227.         (list (quote clayer) "0")
  228.       )
  229.     )
  230.     (setq sysvarlst (mapcar (function car) sysvarpreset))
  231.     (setq sysvarvals (mapcar (function cadr) sysvarpreset))
  232.     (setq sysvarvals
  233.       (vl-remove nil
  234.         (mapcar
  235.           (function (lambda ( x )
  236.             (if (getvar x) (nth (vl-position x sysvarlst) sysvarvals))
  237.           ))
  238.           sysvarlst
  239.         )
  240.       )
  241.     )
  242.     (setq sysvarlst
  243.       (vl-remove-if-not
  244.         (function (lambda ( x )
  245.           (getvar x)
  246.         ))
  247.         sysvarlst
  248.       )
  249.     )
  250.     (setq initvalueslst
  251.       (apply (function mapcar)
  252.         (cons (function list)
  253.           (list
  254.             sysvarlst
  255.             (mapcar (function getvar) sysvarlst)
  256.           )
  257.         )
  258.       )
  259.     )
  260.       (cons (function setvar)
  261.         (list
  262.           sysvarlst
  263.           sysvarvals
  264.         )
  265.       )
  266.     )
  267.     (while (= 8 (logand 8 (getvar (quote undoctl))))
  268.       (if (not (exe (list "_.UNDO" "_E")))
  269.         (if doc
  270.           (vla-endundomark doc)
  271.         )
  272.       )
  273.     )
  274.     (if (not (exe (list "_.UNDO" "_M")))
  275.       (if doc
  276.         (vla-startundomark doc)
  277.       )
  278.     )
  279.     (if wcs
  280.       (if (= 0 (getvar (quote worlducs)))
  281.         (progn
  282.           (exe (list "_.UCS" "_W"))
  283.           (setq ucsf t)
  284.         )
  285.       )
  286.     )
  287.     wcs
  288.   )
  289.  
  290.   (defun uniquetrl ( trl )
  291.     (if trl
  292.       (cons (car trl)
  293.         (uniquetrl
  294.           (vl-remove-if
  295.             (function (lambda ( x )
  296.               (vl-every
  297.                 (function (lambda ( y )
  298.                   (vl-some
  299.                     (function (lambda ( z ) (equal y z 1e-6)))
  300.                     (car trl)
  301.                   )
  302.                 ))
  303.                 x
  304.               )
  305.             ))
  306.             (cdr trl)
  307.           )
  308.         )
  309.       )
  310.     )
  311.   )
  312.  
  313.   (defun comb ( lst / ll r )
  314.     (setq ll lst)
  315.     (foreach i1 lst
  316.       (setq lst (cdr lst))
  317.       (foreach i2 lst
  318.         (setq r
  319.           (cons
  320.             (list
  321.               i1
  322.               i2
  323.               (distance i1 i2)
  324.             )
  325.             r
  326.           )
  327.         )
  328.       )
  329.     )
  330.     r
  331.   )
  332.  
  333.   (defun trianglst ( plcomb / ll trl r )
  334.     (setq ll plcomb)
  335.     (foreach edge plcomb
  336.       (setq plcomb (cdr plcomb))
  337.       (foreach next plcomb
  338.         (if
  339.           (or
  340.             (= (car edge) (car next))
  341.             (= (car edge) (cadr next))
  342.             (= (cadr edge) (car next))
  343.             (= (cadr edge) (cadr next))
  344.           )
  345.           (setq trl
  346.             (cons (list edge next) trl)
  347.           )
  348.         )
  349.       )
  350.     )
  351.     (setq plcomb ll)
  352.     (foreach 2edges trl
  353.       (foreach edge plcomb
  354.         (if
  355.           (and
  356.             (or
  357.               (and
  358.                 (vl-position (car edge) (car 2edges))
  359.                 (vl-position (cadr edge) (cadr 2edges))
  360.               )
  361.               (and
  362.                 (vl-position (car edge) (cadr 2edges))
  363.                 (vl-position (cadr edge) (car 2edges))
  364.               )
  365.             )
  366.             (not (vl-position edge 2edges))
  367.           )
  368.           (setq r
  369.             (cons
  370.               (append 2edges (list edge))
  371.               r
  372.             )
  373.           )
  374.         )
  375.       )
  376.     )
  377.     r
  378.   )
  379.  
  380.   ;; Popup  -  Lee Mac
  381.   ;; A wrapper for the WSH popup method to display a message box prompting the user.
  382.   ;; ttl - [str] Text to be displayed in the pop-up title bar
  383.   ;; msg - [str] Text content of the message box
  384.   ;; bit - [int] Bit-coded integer indicating icon & button appearance
  385.   ;; Returns: [int] Integer indicating the button pressed to exit
  386.  
  387.   (defun LM:popup ( ttl msg bit / wsh rtn )
  388.     (if (setq wsh (vlax-create-object "wscript.shell"))
  389.       (progn
  390.         (setq rtn
  391.           (vl-catch-all-apply (function vlax-invoke-method)
  392.             (list wsh (quote popup) msg 0 ttl bit)
  393.           )
  394.         )
  395.         (vlax-release-object wsh)
  396.         (if (not (vl-catch-all-error-p rtn)) rtn)
  397.       )
  398.     )
  399.   )
  400.  
  401.   (defun makelw ( pl ocs elev )
  402.     (entmake
  403.       (append
  404.         (list
  405.           (cons 0 "LWPOLYLINE")
  406.           (cons 100 "AcDbEntity")
  407.           (cons 100 "AcDbPolyline")
  408.           (cons 90 (length pl))
  409.           (cons 70 (1+ (* 128 (getvar (quote plinegen)))))
  410.           (cons 38 elev)
  411.         )
  412.         (mapcar (function (lambda ( p ) (cons 10 p))) pl)
  413.         (list (cons 210 ocs))
  414.       )
  415.     )
  416.   )
  417.  
  418.   (defun mid ( p1 p2 )
  419.     (mapcar (function (lambda ( a b ) (/ (+ a b) 2.0))) p1 p2)
  420.   )
  421.  
  422.   (setq wcs (tttt t)) ;;; INITIALIZATION OF PRESET SUB FUNCTIONS AND SYSTEM VARIABLE SETTINGS ;;;
  423.   (if
  424.     (or
  425.       (not (setq lw (car (entsel "\nPick closed polygonal LWPOLYLINE..."))))
  426.       (and
  427.         lw
  428.         (= (cdr (assoc 0 (setq lwx (entget lw)))) "LWPOLYLINE")
  429.         (= 1 (logand 1 (cdr (assoc 70 lwx))))
  430.         (vl-every (function zerop)
  431.           (mapcar (function cdr)
  432.             (vl-remove-if
  433.               (function (lambda ( x )
  434.                 (/= (car x) 42)
  435.               ))
  436.               lwx
  437.             )
  438.           )
  439.         )
  440.       )
  441.     )
  442.     (progn
  443.       (setq ti (car (_vl-times)))
  444.       (prompt "\nSource LWPOLYLINE length : ") (prompt (ftoa (vla-get-length (vlax-ename->vla-object lw))))
  445.       (setq ocs (cdr (assoc 210 lwx)))
  446.       (setq elev (cdr (assoc 38 lwx)))
  447.       (exe (list "_.UCS" "_ZA" "_non" (list 0.0 0.0 0.0) "_non" ocs))
  448.       (exe (list "_.UCS" "_M" "_non" (list 0.0 0.0 elev)))
  449.       (setq pl
  450.         (mapcar (function cdr)
  451.           (vl-remove-if
  452.             (function (lambda ( x )
  453.               (/= (car x) 10)
  454.             ))
  455.             lwx
  456.           )
  457.         )
  458.       )
  459.       (setq dx (- (apply (function max) (mapcar (function car) pl)) (apply (function min) (mapcar (function car) pl))))
  460.       (setq plcomb (comb pl))
  461.       (setq trl (uniquetrl (trianglst plcomb))) ;;; trl=(((n11 n12 d11) (n12 n13 d12) (n13 n11 d13)) ((n21 n22 d21) (n22 n23 d22) (n23 n21 d23)) ((n31 n32 d31) (n32 n33 d32) (n33 n31 d33)) ... ) ;;;
  462.       ;;; (princ trl) ;;;
  463.       ;;; ... we are here with triangles ... ;;;
  464.       ;;; To tackle the problem, we should think of 3D/2D (spacial) triangular dimensional determination in some kind of point additional order : 3 points - triangle = 3; 4 pts = 3 points - triangle + 3 additional edges from each point of triangle to 4th point = 6 ::: formulation : n*(n-1)/2 ::: 4*(4-1)/2=6 ; 5 pts ::: 5*(5-1)/2=10 ; ... ;;;
  465.       ;;; Order goes like this : 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ... ;;;
  466.       (setq k 0)
  467.       (if (> (cdr (assoc 90 lwx)) 3)
  468.         (repeat (length trl)
  469.           (exe (list "_.COPY" (ssadd lw) "" "_non" (list 0.0 0.0 0.0) "_non" (list (setq dd (* dx (setq k (1+ k)))) 0.0 0.0)))
  470.           (setq lwx (entget (entupd (setq lwn (entlast)))))
  471.           (setq pl
  472.             (mapcar (function cdr)
  473.               (vl-remove-if
  474.                 (function (lambda ( x )
  475.                   (/= (car x) 10)
  476.                 ))
  477.                 lwx
  478.               )
  479.             )
  480.           )
  481.           (setq tr (nth (1- k) trl))
  482.           (setq tr
  483.             (list
  484.               (list (list (+ dd (nth 0 (nth 0 (nth 0 tr)))) (nth 1 (nth 0 (nth 0 tr)))) (list (+ dd (nth 0 (nth 1 (nth 0 tr)))) (nth 1 (nth 1 (nth 0 tr)))) (nth 2 (nth 0 tr)))
  485.               (list (list (+ dd (nth 0 (nth 0 (nth 1 tr)))) (nth 1 (nth 0 (nth 1 tr)))) (list (+ dd (nth 0 (nth 1 (nth 1 tr)))) (nth 1 (nth 1 (nth 1 tr)))) (nth 2 (nth 1 tr)))
  486.               (list (list (+ dd (nth 0 (nth 0 (nth 2 tr)))) (nth 1 (nth 0 (nth 2 tr)))) (list (+ dd (nth 0 (nth 1 (nth 2 tr)))) (nth 1 (nth 1 (nth 2 tr)))) (nth 2 (nth 2 tr)))
  487.             )
  488.           )
  489.           (cond
  490.             ( (not (equal (mapcar (function +) (list 0.0 0.0) (vlax-curve-getclosestpointto lwn (mid (nth 0 (nth 0 tr)) (nth 1 (nth 0 tr))))) (mid (nth 0 (nth 0 tr)) (nth 1 (nth 0 tr))) 1e-6))
  491.               (setq li (entmakex (list (cons 0 "LINE") (cons 10 (nth 0 (nth 0 tr))) (cons 11 (nth 1 (nth 0 tr))))))
  492.               (setq p3 (mapcar (function +) (vlax-curve-getclosestpointto li (nth 0 (nth 2 tr)) t) (mapcar (function -) (vlax-curve-getclosestpointto li (nth 0 (nth 2 tr)) t) (nth 0 (nth 2 tr)))))
  493.               (setq pl (mapcar (function (lambda ( x ) (if (equal (nth 0 (nth 2 tr)) x 1e-6) (list (car p3) (cadr p3)) x))) pl))
  494.               (makelw pl ocs elev)
  495.             )
  496.             ( (not (equal (mapcar (function +) (list 0.0 0.0) (vlax-curve-getclosestpointto lwn (mid (nth 0 (nth 1 tr)) (nth 1 (nth 1 tr))))) (mid (nth 0 (nth 1 tr)) (nth 1 (nth 1 tr))) 1e-6))
  497.               (setq li (entmakex (list (cons 0 "LINE") (cons 10 (nth 0 (nth 1 tr))) (cons 11 (nth 1 (nth 1 tr))))))
  498.               (setq p3 (mapcar (function +) (vlax-curve-getclosestpointto li (nth 0 (nth 0 tr)) t) (mapcar (function -) (vlax-curve-getclosestpointto li (nth 0 (nth 0 tr)) t) (nth 0 (nth 0 tr)))))
  499.               (setq pl (mapcar (function (lambda ( x ) (if (equal (nth 0 (nth 0 tr)) x 1e-6) (list (car p3) (cadr p3)) x))) pl))
  500.               (makelw pl ocs elev)
  501.             )
  502.             ( (not (equal (mapcar (function +) (list 0.0 0.0) (vlax-curve-getclosestpointto lwn (mid (nth 0 (nth 2 tr)) (nth 1 (nth 2 tr))))) (mid (nth 0 (nth 2 tr)) (nth 1 (nth 2 tr))) 1e-6))
  503.               (setq li (entmakex (list (cons 0 "LINE") (cons 10 (nth 0 (nth 2 tr))) (cons 11 (nth 1 (nth 2 tr))))))
  504.               (setq p3 (mapcar (function +) (vlax-curve-getclosestpointto li (nth 0 (nth 1 tr)) t) (mapcar (function -) (vlax-curve-getclosestpointto li (nth 0 (nth 1 tr)) t) (nth 0 (nth 1 tr)))))
  505.               (setq pl (mapcar (function (lambda ( x ) (if (equal (nth 0 (nth 1 tr)) x 1e-6) (list (car p3) (cadr p3)) x))) pl))
  506.               (makelw pl ocs elev)
  507.             )
  508.           )
  509.           (if (and li (not (vlax-erased-p li)))
  510.             (entdel li)
  511.           )
  512.           (if (and lwn (not (vlax-erased-p lwn)))
  513.             (entdel lwn)
  514.           )
  515.         )
  516.       )
  517.       (repeat 2
  518.         (exe (list "_.UCS" "_P"))
  519.       )
  520.       (prompt "\nElapsed time : ") (prompt (ftoa (- (car (_vl-times)) ti))) (prompt " milliseconds...")
  521.       (prompt "\nFor UNDO - type \"UNDO\" - \"Back\" option...")
  522.     )
  523.     (progn
  524.       (prompt "\nMissed..., or picked wrong entity type, or picked LWPOLYLINE not closed, or picked LWPOLYLINE not polygonal - has arced segments...")
  525.       (if (= 4 (LM:popup "DECOMPOSITION+COMPOSITION - IRREGULAR POLYGON" "Choose option : " 53))
  526.         (c:decomposition+composition)
  527.       )
  528.     )
  529.   )
  530.   (*error* nil)
  531. )
  532.  

M.R.
« Last Edit: December 29, 2022, 10:06:43 AM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

ribarm

  • Gator
  • Posts: 2876
  • Marko Ribar, architect
Re: find all possible triangles
« Reply #17 on: December 29, 2022, 10:08:22 AM »
I've debugged it more further... So I ended with this picture... LSP attached to this post... Thanks for attention...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

ribarm

  • Gator
  • Posts: 2876
  • Marko Ribar, architect
Re: find all possible triangles
« Reply #18 on: January 15, 2023, 12:54:14 PM »
Here is another revision... But it's buggy - maybe you'll get only one or few triangles, but complete structure I doubt you'll get...

M.R.
« Last Edit: January 16, 2023, 10:26:50 AM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

ribarm

  • Gator
  • Posts: 2876
  • Marko Ribar, architect
Re: find all possible triangles
« Reply #19 on: January 16, 2023, 11:33:24 AM »
I've just throwed triangles and tried to compose broken pieces... Evgeniy had once this solved - I think that this was the topic, but not 100% sure... See if you can find something relevant to this issue : https://www.theswamp.org/index.php?topic=44783.0
Only thing was that pieces should not have been rotated, or mirrored - so throwing all still not good approach...

HTH.
M.R.
« Last Edit: January 19, 2023, 03:30:06 PM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

ribarm

  • Gator
  • Posts: 2876
  • Marko Ribar, architect
Re: find all possible triangles
« Reply #20 on: January 17, 2023, 04:57:36 AM »
decomposition+composition-inside-p.lsp gives the most adequate results... So I think that without ANGLES as additional parameter, it is almost impossible to solve this task... I've implemented angles and (jigsaw) sub, so it works the most appropriate - with convex shapes, it should never fail to copy original shape...

[EDIT] This file in attachment yields convex hull of picked polygonal LWPOLYLINE... [/EDIT]
« Last Edit: January 19, 2023, 03:29:48 PM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube