Author Topic: {Challenge}Get same zone boundary index set from the Matrix  (Read 17240 times)

0 Members and 1 Guest are viewing this topic.

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: {Challenge}Get same zone boundary index set from the Matrix
« Reply #30 on: September 28, 2012, 09:44:16 AM »
strange that this topic no one else is reading...  :-(

chlh_jd

  • Guest
Re: {Challenge}Get same zone boundary index set from the Matrix
« Reply #31 on: September 28, 2012, 10:14:41 AM »
In the List which create by Bmp2lst , Value smaller Colour darker .
The vectorization procedure usually priority deal with dark areas .
I think the most important change is close multiple colors - a big change...
Agree , I've Cold two days, tomorrow continue to modify .
Thank you a lot .
strange that this topic no one else is reading...  :-(
I've search all the swamp , Little helps .
Perhaps this time all busy  :-) In China , we are celebrating the National Day and Mid-Autumn Festival .
Or I put a wrong title . :-(
« Last Edit: September 28, 2012, 10:18:38 AM by chlh_jd »

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: {Challenge}Get same zone boundary index set from the Matrix
« Reply #32 on: September 28, 2012, 11:49:03 AM »
strange that this topic no one else is reading...  :-(
I'm reading but too busy to participate.
Nice work, maybe next week I'll have some free time.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

dgorsman

  • Water Moccasin
  • Posts: 2437
Re: {Challenge}Get same zone boundary index set from the Matrix
« Reply #33 on: September 28, 2012, 12:14:01 PM »
The test image is a little... questionable... for work.   :police:
If you are going to fly by the seat of your pants, expect friction burns.

try {GreatPower;}
   catch (notResponsible)
      {NextTime(PlanAhead);}
   finally
      {MasterBasics;}

chlh_jd

  • Guest
Re: {Challenge}Get same zone boundary index set from the Matrix
« Reply #34 on: September 28, 2012, 12:47:48 PM »
I think the most important change is close multiple colors - a big change...
Before translate Bmp RGB List into Gray Matrix :
Code: [Select]
     Set background RBG colours  ----> Filter RGB  List  ----> Set forward colours ---->Merge nearly color
     Then go to the step you suggest , drop or add setion .

Is this way better ?
 

chlh_jd

  • Guest
Re: {Challenge}Get same zone boundary index set from the Matrix
« Reply #35 on: September 29, 2012, 11:03:04 AM »
Hi all , I've change all codes which easy to test . See the Vector4.lsp
Code: [Select]
(princ "T Bmp2lst CmdGroup : \n
          T1----Create Bmp from the Imagelist's txt file , Insert basepoint '(0 0) .
          T2----Delete Not Want , you also can use the Erase Command .
          T3----Set Background or BackWard Colors
          T4----Set Forward Colors
          T5----Translate Bmp to Gray Matrix .
          T6----Create Component Lines from GrayMatrix .
          T7----Deal Component Lines (Its core is like Pedit Command Spline deal),
                before do it you also can use AutoCAD other Command deal such as Erase/Strentch/Move .
          This CmdGroup will create 3 System Varialbes :
              *Vector_GrayMatrix*
              *Vector_file_path*
              *Vector_Backward_Colors*
              *Vector_Forward_Colors*
              *Vector_Bmp_X*
              *Vector_Bmp_Y*
          ****Warnning****:   
          ****Please Test in New dwg and not open other dwgs , Because it may take Fatal error then
              cause the AutoCAD collapse or interrupt exit****   
          ")

chlh_jd

  • Guest
Re: {Challenge}Get same zone boundary index set from the Matrix
« Reply #36 on: September 29, 2012, 11:36:08 AM »
I am sorry , The Vecto_tmp.txt file's Coordinates are not the routine want , It must be  tansposed , Perhaps my dear HighFlyBird  think the image_list must be rebuild .
To Test on the dwg , I change T5 command .
Code: [Select]
(defun c:t5(/ ss x y)   
  (princ (strcat "\nCurrent forward colors table is :" (vl-princ-to-string *Vector_Forward_Colors*) "."))
  (princ (strcat "\nCurrent backward colors table is :" (vl-princ-to-string *Vector_Backward_Colors*) "."))
  (or *Vector_Bmp_X* (setq *Vector_Bmp_X* 287));_Just for Test
  (or *Vector_Bmp_Y* (setq *Vector_Bmp_Y* 427));_Just for Test
  (setq ss (ssget "X" (list (cons 0 "LWPOLYLINE") (cons 8 "Image2PL")
(cons -4 "<AND") (cons -4 ">=") (cons 10 (list -1 -1)) (cons -4 "<=") (cons 10 (list (1+ *Vector_Bmp_X*) (1+ *Vector_Bmp_Y*))) (cons -4 "AND>"))))
  (if ss
    (progn
      (setq *Vector_GrayMatrix* ([0] (1+ (fix *Vector_Bmp_Y*)) (1+ (fix *Vector_Bmp_X*))))
      (ssapply ss (lambda (en / ent c p)
    (setq ent (entget en)  
  c (dxf 420 ent)
  p (dxf 10 ent))
    (if (and c (not (member c *Vector_Backward_Colors*)))
      (progn
(if (member c *Vector_Forward_Colors*)
   (setq c 6)
   (setq c (vector:True->grayaci c)
c (- 255 c))
  )
(setq *Vector_GrayMatrix* (ch-lst c (list (fix (cadr p))(fix (car p))) *Vector_GrayMatrix*)))
      )
    )
       )
      )
    (princ "\nPlease Select Bmp_PLs based on (0 0) , Don't Select the refer objects !")
  )
  (if *gsls_debug*
    (progn
  (setq y -1.)
  (foreach a *Vector_GrayMatrix*
    (setq x -1.
      y (1+ y)
      )
    (foreach b a
      (setq x (1+ x))
      (if (/= b 0)
      (entupd (entmakex
(list
  (cons 0 "LWPOLYLINE")
  (cons 100 "AcDbEntity")
  (cons 100 "AcDbPolyline")
  (cons 90 2)
  (cons 43 1.0)
  (cons 8 "GrayBmp")
  (cons 62 (min (max 0 (fix (- 255 b))) 255))
  (cons 10 (list x y))
  (cons 10 (list (1+ x) y))
  )
))
      )))
  ))
  (princ)
  )
To deal some better , I change the T7 command
Code: [Select]
(defun c:t7 (/ f1 f2 tor ss)
  (defun f1  (en / ent l Noclosed ps pe e)
    (setq ent    (entget en)
  l    (ss-assoc 10 ent)
  Noclosed (zerop (rem (dxf 70 ent) 2)))
    (repeat 8
      (setq ps (car l)
    pe (last l))
      (setq l (mapcar (function (lambda (a b)
  (midpt a b)))
      l
      (cdr l)))
      (if Noclosed
(setq l (append (cons ps l) (list pe)))
(setq l (cons (midpt ps pe) l))))
    (setq e (entmakex
      (append
(list (cons 0 "LWPOLYLINE")
      (cons 100 "AcDbEntity")
      (cons 100 "AcDbPolyline")
      (cons 90 (length l))
      (assoc 8 ent)
      (assoc 70 ent)
      )
(mapcar (function (lambda (x) (cons 10 x))) l)
)
      ))
    (if (< (vla-get-length (vlax-ename->vla-object e)) 8)
      (entdel e))
    (entdel en)
    (princ)
    )
  (defun f2  (en / ent l l0 ps pe e Noclosed)
    (setq ent    (entget en)
  l    (ss-assoc 10 ent)
  Noclosed (zerop (rem (dxf 70 ent) 2)))
    (setq ps (car l)
  pe (last l)
  l  (cdr l)
  l0 (list ps))
    (while l
      (if (> (distance ps (car l)) 1)
(setq l0 (cons (car l) l0)
      ps (car l0)))
      (setq l (cdr l)))
    (if (and l0 (> (distance pe (car l0)) 1))
      (setq l (cons pe l0))
      (setq l l0)
      )
    (setq l0 (list (car l))
  l  (cdr l))
    (if (not Noclosed)
      (setq l (append l l0)))
    (while (cadr l)
      (setq a (car l0)
    b (car l)
    c (cadr l)
    l (cdr l))
      (if (not (equal (abs (- (angle b a) (angle b c))) pi tor))
(setq l0 (cons b l0)))
      )
    (setq l l0)
    (if l
      (progn
(setq
  e (entmakex
      (append
(list (cons 0 "LWPOLYLINE")
      (cons 100 "AcDbEntity")
      (cons 100 "AcDbPolyline")
      (cons 90 (length l))
      (assoc 8 ent)
      (assoc 70 ent)
      )
(mapcar (function (lambda (x) (cons 10 x))) l)
)
      ))
(if (< (vla-get-length (vlax-ename->vla-object e)) 8)
  (entdel e))))
    (entdel en)
    (princ)
    ) 
  ;;
  (while (or (not tor) (> tor 2e-1))
    (initget 4)
    (setq tor (getreal "\nType in a radian for Rarefying polylines [0.01~0.2]<0.08>:"))
    (or tor (setq tor 0.08)))
  (foreach z (list 6 5 4 3 2 1);_This ...
    (setq ss (ssget "X" (list (cons 0 "LINE") (cons 8 (rtos z 2 1)))))
    (command "_.pedit" "m" ss "" "Y" "J" "2." "");_Only Test in ACAD2011 , Other Vesion you must edited by yourself .
    (setq ss (ssget "X" (list (cons 0 "LWPOLYLINE") (cons 8 (rtos z 2 1))
      (cons -4 "<AND") (cons -4 ">=") (cons 10 (list -1 -1))
      (cons -4 "<=") (cons 10 (list (1+ *Vector_Bmp_X*) (1+ *Vector_Bmp_Y*)))
      (cons -4 "AND>"))))
    (if ss
      (ssapply ss f1))
    (setq ss (ssget "X" (list (cons 0 "LWPOLYLINE") (cons 8 (rtos z 2 1))
      (cons -4 "<AND") (cons -4 ">=") (cons 10 (list -1 -1))
      (cons -4 "<=") (cons 10 (list (1+ *Vector_Bmp_X*) (1+ *Vector_Bmp_Y*)))
      (cons -4 "AND>"))))
    (if ss
      (ssapply ss f2))
    )
  (princ "\nBitmap transfer vector has been completed .")
  (princ "\nAny Suggest you can post on : http://www.theswamp.org/index.php?topic=42846.0 ")
  (princ)
  )
« Last Edit: September 29, 2012, 11:45:03 AM by chlh_jd »

chlh_jd

  • Guest
Re: {Challenge}Get same zone boundary index set from the Matrix
« Reply #37 on: September 29, 2012, 12:05:13 PM »
New Version change some
 1. vector:True->grayaci
 2. use depth 4.5 3.5 2.5 1.5
 

chlh_jd

  • Guest
Re: {Challenge}Get same zone boundary index set from the Matrix
« Reply #38 on: September 29, 2012, 01:32:23 PM »
Brain broken , Need more help  :-(
Pherhaps more about Vector Algorithm , Some date later try to write Evgeniy's Big change .

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: {Challenge}Get same zone boundary index set from the Matrix
« Reply #39 on: September 29, 2012, 03:41:14 PM »
Brain broken , Need more help  :-(
Pherhaps more about Vector Algorithm , Some date later try to write Evgeniy's Big change .

I'm sorry!
I find it hard to spend a lot of time on this research.
Probably the right approach - finding the most intense (curved) space.

qjchen

  • Bull Frog
  • Posts: 285
  • Best wishes to all
Re: {Challenge}Get same zone boundary index set from the Matrix
« Reply #40 on: September 29, 2012, 11:24:36 PM »
strange that this topic no one else is reading...  :-(
To chlh_jd, it is a very interesting topic~

To Evgeniy, I am reading :)

Your method is very good, to change them into elevation and then you can get the result, very clever.

Last time, I also thinking in this program, but I think it is too hard for me.

There are two topics about BMP 2 CAD

Daniel: http://www.theswamp.org/index.php?topic=22296.0
qjchen: http://www.theswamp.org/index.php?topic=28071.msg336615#msg336615

I think it can be converted into vector.

Now you have given us the direction, so maybe when I have time, I will try to test it in .NET.

Oh, Last time I draw some 3dmesh in  http://www.theswamp.org/index.php?topic=41630.msg467499#msg467499

and Seant tell me some cool things about NURBS, http://www.theswamp.org/index.php?topic=36560.0

He have done the similar and cool works.
« Last Edit: September 30, 2012, 03:33:26 AM by qjchen »
http://qjchen.mjtd.com
My blog http://chenqj.blogspot.com (Chinese, can be translate into English)

chlh_jd

  • Guest
Re: {Challenge}Get same zone boundary index set from the Matrix
« Reply #41 on: October 01, 2012, 03:37:06 AM »
I'm sorry!
I find it hard to spend a lot of time on this research.
Probably the right approach - finding the most intense (curved) space.
Not at all , You are always welcome ! :-)
To chlh_jd, it is a very interesting topic~
...
Key of times , you are always present  ,  Very learned !

Thank you a lot Evgeniy , QJChen .

chlh_jd

  • Guest
Re: {Challenge}Get same zone boundary index set from the Matrix
« Reply #42 on: October 01, 2012, 09:43:54 AM »
Some soft Vector result , It seem that no better than we do  :-D
Can we go on next step : deal the result from command T7 ...
Perhaps : Evgeniy said "finding the most intense (curved) space."
« Last Edit: October 01, 2012, 09:51:56 AM by chlh_jd »

chlh_jd

  • Guest
Re: {Challenge}Get same zone boundary index set from the Matrix
« Reply #43 on: October 01, 2012, 04:06:21 PM »
New version , it seems improve little .
Now, I believe , if continue , the result is at hand .
When I got the result , I'll post the codes in this topic , but when can not be determined .
Has been too much off-topic ,  a lot of thank you Evgeniy , thank you again .
« Last Edit: October 01, 2012, 04:21:32 PM by chlh_jd »

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: {Challenge}Get same zone boundary index set from the Matrix
« Reply #44 on: October 05, 2012, 07:35:07 AM »
Code - Auto/Visual Lisp: [Select]
  1. (eea-geodesic-contours-TheSwamp l '(1.33 2.66))
  2. (defun eea-geodesic-contours-TheSwamp (l lst-z / X Y)
  3.   ;; by ElpanovEvgeniy
  4.   ;;(eea-geodesic-contours-TheSwamp l '(0.5 1.5 2.5))
  5.   ;; last edit 26.09.2012
  6.   ;; last edit 05.10.2012
  7.   (defun min-max (a b c) (list (min a b c) (max a b c)))
  8.   (defun fix-z (p z) (list (car p) (cadr p) z))
  9.   (setq y -1.
  10.         l (apply (function append)
  11.                  (mapcar (function
  12.                            (lambda (a b)
  13.                              (setq x -1.
  14.                                    y (1+ y)
  15.                              )
  16.                              (apply (function append)
  17.                                     (mapcar (function
  18.                                               (lambda (a b c d / z)
  19.                                                 (setq x (1+ x)
  20.                                                       z (/ (+ a b c d) 4.)
  21.                                                 )
  22.                                                 (list (list (min-max a b z) (list x y a) (list (1+ x) y b) (list (+ x 0.5) (+ y 0.5) z))
  23.                                                       (list (min-max a c z) (list x y a) (list x (1+ y) c) (list (+ x 0.5) (+ y 0.5) z))
  24.                                                       (list (min-max b d z) (list (1+ x) y b) (list (1+ x) (1+ y) d) (list (+ x 0.5) (+ y 0.5) z))
  25.                                                       (list (min-max c d z) (list x (1+ y) c) (list (1+ x) (1+ y) d) (list (+ x 0.5) (+ y 0.5) z))
  26.                                                 )
  27.                                               )
  28.                                             )
  29.                                             a
  30.                                             (cdr a)
  31.                                             b
  32.                                             (cdr b)
  33.                                     )
  34.                              )
  35.                            )
  36.                          )
  37.                          l
  38.                          (cdr l)
  39.                  )
  40.           )
  41.   )
  42.   (foreach z lst-z
  43.     (foreach tr l
  44.       (if (and (<= (caar tr) z (cadar tr))
  45.                (< 1 (-(cadar tr)(caar tr)))
  46.                (cdr (setq tr (vl-remove nil
  47.                                         (list (inters (nth 1 tr) (nth 2 tr) (fix-z (nth 1 tr) z) (fix-z (nth 2 tr) z))
  48.                                               (inters (nth 2 tr) (nth 3 tr) (fix-z (nth 2 tr) z) (fix-z (nth 3 tr) z))
  49.                                               (inters (nth 1 tr) (nth 3 tr) (fix-z (nth 1 tr) z) (fix-z (nth 3 tr) z))
  50.                                         )
  51.                              )
  52.                     )
  53.                )
  54.           )
  55.         (entmakex (list '(0 . "line")
  56.                         (cons 8 (rtos z 2 1))
  57.                         (cons 10 (car tr))
  58.                         (cons 11 (cadr tr))
  59.                   )
  60.         )
  61.       )
  62.     )
  63.   )
  64.   (princ)
  65. )