Author Topic: Triangulation (re-visited)  (Read 316989 times)

0 Members and 1 Guest are viewing this topic.

rw2691

  • Newt
  • Posts: 133
Re: Triangulation (re-visited)
« Reply #630 on: May 01, 2016, 10:37:00 AM »
ymg,

Attached is a JPG of the TIN using your recent BOUND code. It did not leave any tit's touching the boundary, but it did leave the detached TIN's beyond the boundary.

Rick
Hippocrates (400BC), "Life is short, craft long, opportunity fleeting, experiment treacherous, judgment difficult."

rw2691

  • Newt
  • Posts: 133
Re: Triangulation (re-visited)
« Reply #631 on: May 01, 2016, 10:57:45 AM »
YMG,

This is another that I did from the same drawing. It has the tit's that touch the boundary. The only thing that I did differently was to move the boundary off, and then move the boundary back, then also including a larger selection of points.

Rick
Hippocrates (400BC), "Life is short, craft long, opportunity fleeting, experiment treacherous, judgment difficult."

rw2691

  • Newt
  • Posts: 133
Re: Triangulation (re-visited)
« Reply #632 on: May 01, 2016, 11:08:52 AM »
YMG,

I just undid everything in the drawing to the first Boundary. Then I selected the larger set of points for the TIN. It gave the identical set tits and orphans. So moving the boundary off, and then back, had not changed anything. These results are also the same as when I use your former Centroid code.

None of this happens with the OCD code as I have modified it... providing that you include the modification that I made to the BOUND code, which copies and offsets *BOUNDEN* as *LIMITEN*.

Rick
Hippocrates (400BC), "Life is short, craft long, opportunity fleeting, experiment treacherous, judgment difficult."

rw2691

  • Newt
  • Posts: 133
Re: Triangulation (re-visited)
« Reply #633 on: May 01, 2016, 11:27:27 AM »
ymg,

Here is the same drawing, but with using the AUGI:OCD code.

Rick
Hippocrates (400BC), "Life is short, craft long, opportunity fleeting, experiment treacherous, judgment difficult."

rw2691

  • Newt
  • Posts: 133
Re: Triangulation (re-visited)
« Reply #634 on: May 02, 2016, 10:28:19 AM »
YMG,

I have now implemented AUGI:OCD into the TIN code. It is working well.

Upon doing so I decided to review the tests that I had made. There is something that might need to be considered. I am using State Plane coordinates, which are very large. So when I use PRINC to print the LISTPOL results it returns (1.47777e+006  433888.0  0.0) as a typical coordinate. Maybe it is a fault of PRINC, but the actual coordinates for that point are "1477771.31901  433888.37054  654.73". Their difference is a severe reduction of precision. In fact, I would think that it wouldn't work at all.

Likewise when I use the PROPERTIES function it reports X=1477771.32  Y=433888.37  Z=654.73 for that same point. Which is also a reduction to precision, but probably acceptable.

But when I pick that point with a utility function that have for posting coordinates, it prints the data to five decimal places. So I know that ACAD is capable of handling large coordinates with high precision.

So maybe the above discrepancies are just a PRINC problem.

Rick
Hippocrates (400BC), "Life is short, craft long, opportunity fleeting, experiment treacherous, judgment difficult."

squirreldip

  • Newt
  • Posts: 114
Re: Triangulation (re-visited)
« Reply #635 on: May 02, 2016, 01:01:47 PM »
I understand and agree with the network not making any difference for surveyed surfaces - but having small offsets of 1mm or less is common for design surfaces.

I've updated the code slightly to use a 2D distance command and revised the TIN:SECTIONPOINTTOPOINT to remove duplicates based on the offset/elevation rather than the raw points.

I can live with this as a limitation but has there been any answer to why the remove duplicates doesn't work?  The data that Rick gave definitely falls within 0.001 or 0.003 fuzz.

ymg

  • Guest
Re: Triangulation (re-visited)
« Reply #636 on: May 04, 2016, 10:57:22 AM »
@ Rick,

Please post the drawing that you used in your test.

Using large coordinates will cause problems with the vlax-curve function.
Might also be a problem with the iscw_p function.

@ Robert,

As far as I know, remove duplicates works if your point list is sorted.

ymg
« Last Edit: May 04, 2016, 11:32:32 AM by ymg »

rw2691

  • Newt
  • Posts: 133
Re: Triangulation (re-visited)
« Reply #637 on: May 04, 2016, 03:56:53 PM »
YMG,

The drawing is attached. It is an ACAD 2004 format. I work with different layers than your code operates with. The point data for topography is in ".TOP-*", and the Surface layers are ".SRF-*". This drawing is compiled by using my AUGI:OCD code. Since I recently deleted all of my test files, I had to construct this one for you. It has a Boundary Line, but I did not include the break lines. I didn't think they were necessary for the demonstration. But maybe they will be... let me know.

If large coordinates actually turns out to be the issue, AUGI:OCD can handle them. This drawing is State Plane coordinates. It is actually very small in comparison to UTM coordinates, which is becoming more popular because it covers multiple States at a time. A fair number of practitioners are currently working across wide regions of the country, and they like having a single database for coordinates.

The following are my edits to the AUGI:OCD code to integrate with C:TIN, and then my edits to C:TIN to work with AUGI:OCD.

AUGI:OCD ...
Code: [Select]
; Required Express tools
; OutSide Contour Delete
; Found at http://forums.augi.com/showthread.php?t=55056
; modified by RW2691 (aka. Rick)
(defun AUGI:OCD (TIN-LIMIT / ss ssall e1 lst ent tp tr)   ;;  Global: tl 3dfl
(vl-load-com)
  (if TIN-LIMIT
    (progn ; 1
      (setq lst (ACET-GEOM-OBJECT-POINT-LIST TIN-LIMIT 1e-3))
      (ACET-SS-ZOOM-EXTENTS (ACET-LIST-TO-SS (list TIN-LIMIT)))
      (command "_.Zoom" "0.95x")                 
      (if (and (setq ss (ssget "_WP" lst '((0 . "3DFACE")))) ;; select TINs inside polygon
               (setq ssall (ssget "_X" (list (cons 0 "3DFACE")))) ;; select all TINs in drawing
               )
          (progn ; 2
          (setq lst (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))) ;; lst is save-group
          (foreach e1 lst (ssdel e1 ssall))  ;; removes save-group from entity list
         
          (repeat (setq i (sslength ssall))   ;; repeat to update tl and 3dfl
                  (setq  en (ssname ssall (setq i (1- i)))
                        ent (entget en)
                         tp (list (cdr (assoc 11 ent))  ;; translate to point
                                  (cdr (assoc 12 ent))
                                  (cdr (assoc 13 ent))
                                  )
                         tr (list (vl-position (car tp) pl)  ;; query point info ;; pl was tl was lst
                                  (vl-position (cadr tp) pl)
                                  (vl-position (caddr tp) pl)
                                  )
                         tl (vl-remove tr tl)  ;; erase TIN-Set from TIN list
                       3dfl (vl-remove en 3dfl)  ;; erase TIN-object from 3DFACE list
                       ) ; end setq
                  ) ;; end repeat
         
          (ACET-SS-ENTDEL ssall)  ;; deletes all remaining entities
          ) ; end progn 2
        ) ; end if
      ) ; end progn 1
    )
  ) ;; end AUGI:OCD

C:TIN ...
Code: [Select]
                      (acet-ui-progress) ;; ends acet-ui-progress bar
                      (if *LIMITEN* (AUGI:OCD *LIMITEN*))  ;; erase extraneous TIN's by LIMITEN patch-insert
           
;;************* start LIMITEN patch-cut
                      ;; Erasing Triangles in Holes of Triangulation, and those     ;
                      ;;         outside of the boundary. Adjusting Triangle List.  ;
                      ;; Notes: This is a fast hack where we select 3Dfaces with a  ;
                      ;;        Crossing Polygon then Computes their Centroid and   ;
                      ;;        remove those whose centroid is inside the poly.     ;
                      ;;        (But the centroid could be outside the poly)        ;
                      ;;        Will change it eventually to offset the polyline    ;
                      ;;        to the outside by a few millimeters, and make the   ;
                      ;;        Selection by Window Polygon.                        ;             
                      ; (vl-cmdf "._ZOOM" "_E")
                      ; (if *bounden*  ;; created by BND function
                          ; (setq bp (distinct (mapcar '(lambda (a) (list (car a) (cadr a))) (listpol *bounden*))))
                          ; )
                      ; (foreach wp wpl
                            ; (setq ss (ssget "_CP" wp '((0 . "3DFACE"))))
                            ; (repeat (setq i (sslength ss))  ;; i is repeat i times
                                    ; (setq  en (ssname ss (setq i (1- i)))
                                          ; ent (entget en)
                                           ; tp (list (cdr (assoc 11 ent))
                                                    ; (cdr (assoc 12 ent))
                                                    ; (cdr (assoc 13 ent))
                                                    ; )
                                           ; ct (centroid tp) ;; get centroid
                                           ; in (ptinpoly_p ct (cons (last wp) wp))
                                           ; )
                                    ; (if (or (and in (not (equal wp bp)))
                                            ; (and (not in) (equal wp bp))
                                            ; )   
                                        ; (setq tr (list (vl-position  (car   tp) pl)
                                                       ; (vl-position  (cadr  tp) pl)
                                                       ; (vl-position  (caddr tp) pl)
                                                       ; )
                                              ; tl (vl-remove tr tl)
                                            ; 3dfl (vl-remove en 3dfl) 
                                              ; ** (entdel en)
                                             ; ) ; end setq
                                        ; ) ; end if                     
                                    ; ) ;; end repeat
                         ;    ) ;; end foreach
;;************* close LIMITEN patch-cut
           
                      ;; Processing Boundary                   
                      (vl-cmdf "._ZOOM" "_P")

Rick
« Last Edit: May 04, 2016, 04:01:59 PM by rw2691 »
Hippocrates (400BC), "Life is short, craft long, opportunity fleeting, experiment treacherous, judgment difficult."

ymg

  • Guest
Re: Triangulation (re-visited)
« Reply #638 on: May 04, 2016, 05:05:51 PM »
Rick,

I just did a test and I believe we are talking two different things.

The boundary of the triangulation is something that encloses all the
point that are to be triangulated.  Triangles that are removed are the
one outside of that boundary.  In other word you supply tin only
the points inside or on the boundary and all the outside triangle
gets trimmed.

I believe you triangulated all the points shown on your drawing
and wanted to trim the triangulated zone with the closed breakline
shown on your drawing.

In such a case OCD or any othe Cookie Cutter routine can  and should
be used.

But you end up triangulating and contouring a zone for no reason.

ymg
« Last Edit: May 04, 2016, 05:08:59 PM by ymg »

rw2691

  • Newt
  • Posts: 133
Re: Triangulation (re-visited)
« Reply #639 on: May 05, 2016, 07:30:18 AM »
YMG,

Yes... I plot the field points (which always include exterior traverse points), draw the breaklines and boundary, then window the points of interest for the TIN. In the process of windowing, some of the exterior and unwanted points are included in the selection.

Consequently, a TIN is built on all points chosen, but then it removes all those TIN's that lay outside the boundary. They were accidental and unwanted.

The result is that you only have TIN's that are within the boundary limits, and you haven't needed to be very picky about selecting its points... simply square-window the area.

I don't quite understand the method that you have described, and I guess you have never understood my objective as well. For myself, the purpose of a boundary is to allow a relaxed and quick selection.

I should have had a clue when, some time back, you said that you always draw your boundary after having done the contours. Where as, I was proposing that the boundary be drawn before building the TIN. I also thought it was odd that you were bothered by my referring to them as Bogus TIN's. Maybe the word "boundary" should not have been used. It is a TIN and Contours Limit-Line.

Rick

« Last Edit: May 05, 2016, 07:45:05 AM by rw2691 »
Hippocrates (400BC), "Life is short, craft long, opportunity fleeting, experiment treacherous, judgment difficult."

rw2691

  • Newt
  • Posts: 133
Re: Triangulation (re-visited)
« Reply #640 on: May 05, 2016, 07:51:33 AM »
YMG,

I realize that I forgot to repost my alteration to BOUND. It is essential...

Code: [Select]
(mk_3dp plst)             
              (setq *bounden* (entlast))
             
              ;; *bounden* (3dPloyline) is used as a TIN limit and a BREAKLINE
              ;; *limiten* (2dPloyline) is created to facilitate deletion of extraneous TIN's
              ;; *limiten* is built at an outside offset of 0.005 to *bounden*
              (mk_lwp plst)  ;(mk_2dp plst)
              (setq tmpen (entlast))
              (setq ofspt (list (- 0 999999) (- 0 999999) 0))   ;; a negative 1 million feet past 0,0,0.
              (command "_offset" 0.005 tmpen ofspt "")   ;; 0.005             
              (setq *limiten* (entlast))             
              (entdel tmpen)
             
              (redraw)
              ) ;; end progn

The above creates the outer offset entity that is named *Limiten*.

Rick
Hippocrates (400BC), "Life is short, craft long, opportunity fleeting, experiment treacherous, judgment difficult."

ymg

  • Guest
Re: Triangulation (re-visited)
« Reply #641 on: May 05, 2016, 05:55:07 PM »
Rick,

To select only the points that should be in the triangulation,
you can enter "cp" at the Select Objects: prompts and trace
the a rough outline of the triangulated zone excluding the
points you do not want to includes.

Another way, would be to make a simple modification to triang,
where when selecting  a single polyline, the program would then
select automatically all the entities inside.

If the selection set as a length greater than one selection is interpreted
as usual and the selection inside that polyline would be bypassed.

ymg
« Last Edit: May 05, 2016, 06:17:57 PM by ymg »

ymg

  • Guest
Re: Triangulation (re-visited)
« Reply #642 on: May 06, 2016, 06:42:58 AM »
Rick,

If you replace the following code at the beginning of Triang,
You will be able to select a single entity, either an LWpolyline
or a 3DPOLYLINE and the triangulation will be limited to what
is inside.

If the single entity selected is a 3DPOLYLINE, it becomes the
boundary.  Otherwise the triangulation has no boundary but
the selection is limited to what is inside.

Code - Auto/Visual Lisp: [Select]
  1.  
  2. (setq ss nil ssb nil ssw nil
  3.          flt '((0 . "POINT,INSERT,LWPOLYLINE,POLYLINE,LINE"))
  4. )
  5. (if (setq proceed (setup "tins"))
  6.       (progn
  7.          (setq ss (ssget flt))
  8.          (if (and (= (sslength ss) 1)
  9.                   (setq en  (ssname ss 0))
  10.                   (setq ent (entget en))
  11.                   (setq typ (cdr (assoc 0 ent)))    
  12.                   (or (= typ "LWPOLYLINE")
  13.                       (= typ "POLYLINE")
  14.                   )
  15.               )    
  16.             (progn
  17.                (vl-cmdf "_ZOOM" "_O" en "")
  18.                (setq pol (distinct (listpol en))
  19.                      ss (ssget "_CP" pol flt)
  20.                )
  21.                (vl-cmdf "_ZOOM" "_P")
  22.                (if (= "AcDb3dPolyline" (cdr (assoc 100 (cdr (member '(100 . "AcDbEntity") ent)))))
  23.                   (setq *bounden* en) ; 3d polyline, becomes boundary         ;
  24.                   (ssdel en ss)        ; 2d polyline, remove it from selection ;
  25.                )
  26.             )
  27.            
  28.          )
  29.       )  
  30.    )
  31.  
« Last Edit: May 08, 2016, 07:04:11 AM by ymg »

rw2691

  • Newt
  • Posts: 133
Re: Triangulation (re-visited)
« Reply #643 on: May 06, 2016, 09:35:18 AM »
YMG,

I implemented your patch. It provided a very nice way to build the TIN.

I assumed that I was supposed to disable the AUGI:OCD, and to also leave the former code that OCD replaced disabled, because I thought that only what was inside the Boundary was going to acquired.

The result was as follows... although it was limited to the boundary, it still created external TIN's by linking boundary points to boundary points.

It is nevertheless an improvement, but I would have to reactivate the OCD code to clean out the external TIN's.

BTW, there was some orphaned code by this line:  (setq typ (cdr (assoc 0 ent)))      ent (entget en)
I deleted the "ent (entget en)" at its end before I ran the test.

Rick
« Last Edit: May 06, 2016, 09:44:22 AM by rw2691 »
Hippocrates (400BC), "Life is short, craft long, opportunity fleeting, experiment treacherous, judgment difficult."

rw2691

  • Newt
  • Posts: 133
Re: Triangulation (re-visited)
« Reply #644 on: May 06, 2016, 09:51:38 AM »
YMG,

I just tried it with a 2D LWpolyline and it did not work because it refused the poly as a selection.

Rick
Hippocrates (400BC), "Life is short, craft long, opportunity fleeting, experiment treacherous, judgment difficult."