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

0 Members and 3 Guests are viewing this topic.

motee-z

  • Newt
  • Posts: 40
Re: Triangulation (re-visited)
« Reply #390 on: May 03, 2015, 09:05:21 AM »
Hello ymg
thank you for your big efforts to finish this great lisp
but i think the problem is still for draw profile and there is something going not well
the message still divided by zero
here is my sample

ribarm

  • Gator
  • Posts: 3279
  • Marko Ribar, architect
Re: Triangulation (re-visited)
« Reply #391 on: May 03, 2015, 09:18:35 AM »
I don't see a problem with TIN command :

Code: [Select]
Command: (LOAD "C:/Users/RIBAR/Downloads/TriangV0.6.2.9.LSP")
Triangulation V0.6.2.9 loaded...!

Command: TIN
Select objects: Specify opposite corner: 814 found

Select objects:

     TIN - Elapsed time: 1.8870 secs, 5131 3DFACES
     CDT V0.6.2.9 - Elapsed time: 14.9610 secs, 2082 Constraints

Attached is drawing after TIN command...

[EDIT : Oh I see the problem is with PROF command... after TIN]
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

ymg

  • Guest
Re: Triangulation (re-visited)
« Reply #392 on: May 03, 2015, 10:05:46 AM »
Marko and motte-z,

I can see the problem here too.

Will look at it, more closely.

The fence selection seems to be wrong if we use a 3d-polyline
as the linear entity.

Or there is a problem in the getz function

ymg

ribarm

  • Gator
  • Posts: 3279
  • Marko Ribar, architect
Re: Triangulation (re-visited)
« Reply #393 on: May 03, 2015, 10:13:55 AM »
ymg, TriangV0.6.2.6 works as desired but profile is wrong... Tested with LINE entity...

[EDIT : Oh I see DATUM value must be added to distance to be match with value in table]... So it's OK...
« Last Edit: May 03, 2015, 10:18:18 AM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

ymg

  • Guest
Re: Triangulation (re-visited)
« Reply #394 on: May 03, 2015, 10:30:35 AM »
Marko,

I've changed completely the way I calculate the profile.

Used to be Lawson's Walk to get the triangle number.

Now I find the triangle and intersections by exploiting
the return of ssnamex after using the linear entity
as a fence to get the selection set.

Although in version 0.6.2.6 that change was already there.

It is very possible that there is a bug in there.
Will look at it, or maybe you can spot it before me.

I've looked at it too long now, seeing doubles  :-)

ymg

ribarm

  • Gator
  • Posts: 3279
  • Marko Ribar, architect
Re: Triangulation (re-visited)
« Reply #395 on: May 03, 2015, 10:59:41 AM »
Ok ymg, I've spoted where is bug... It's in :

Code - Auto/Visual Lisp: [Select]
  1. (defun get_3dfpts (en / ent p1 p2 p3)
  2.    (setq ent (entget en)
  3.           p1 (cdr (assoc 10 ent))
  4.           p2 (cdr (assoc 11 ent))
  5.           p3 (cdr (assoc 12 ent))
  6.    )
  7.    (if (equal p1 p2)
  8.       (list p2 p3 (cdr (assoc 13 ent)))
  9.       (list p1 p2 p3)
  10.    )
  11. ;|  
  12.    ;; Insuring that Faces are  Listed Counterclockwise                        ;
  13.    
  14.    (setq x (car p1) y (cadr p1))                
  15.    (if (minusp  (- (* (- (car p2) x)(- (cadr p3) y)) (* (- (car p3) x)(- (cadr p2) y))))
  16.       (setq tp (list p1 p3 p2))
  17.       (setq tp (list p1 p2 p3))
  18.    )
  19. |;
  20. )
  21.  

I've commented what's different from V0.6.2.6
It works now by my tests, and I've slightly changed (centroid) to (centgrav) function. I think that it's just slightly more reliable...
I'll attach my revision...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

ymg

  • Guest
Re: Triangulation (re-visited)
« Reply #396 on: May 03, 2015, 11:32:15 AM »
Marko,

I did spot it also.

Need to change function get_3dfpts to this:

Code - Auto/Visual Lisp: [Select]
  1. (defun get_3dfpts (en / ent p1 p2 p3 p4)
  2.    (setq ent (entget en)
  3.           p1 (cdr (assoc 10 ent))
  4.           p2 (cdr (assoc 11 ent))
  5.           p3 (cdr (assoc 12 ent))
  6.    )
  7.    (if (equal p1 p2)
  8.       (setq p1 p2  p2 p3  p3 (cdr (assoc 13 ent)))
  9.    )    
  10.    
  11.    ;; Insuring that Faces are  Listed Counterclockwise                        ;
  12.    
  13.    (setq x (car p1) y (cadr p1))                
  14.    (if (minusp  (- (* (- (car p2) x)(- (cadr p3) y)) (* (- (car p3) x)(- (cadr p2) y))))
  15.       (list p1 p3 p2)
  16.       (list p1 p2 p3)
  17.    )
  18. )
  19.  

ymg


ribarm

  • Gator
  • Posts: 3279
  • Marko Ribar, architect
Re: Triangulation (re-visited)
« Reply #397 on: May 03, 2015, 11:49:47 AM »
Thanks ymg, it works...

M.R.
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

ymg

  • Guest
Re: Triangulation (re-visited)
« Reply #398 on: May 03, 2015, 11:50:23 AM »
Here is the Lisp, with bug in function c:prof corrected.

I need your feedback about layer control.

Should we move the Points Block to the layer "Point name of surface " ?

As it is when they are points instead of blocks I move them.

Also notes that a 3d polyline cannot be used as the linear entity
for the profile.  This capacity will be in next revision.

Profile from Contour Lines is not implemented yet.

I believe there is still a bug in drawing the profile when
we have points with negative elevation.  Will correct also
in next revision.

ymg
« Last Edit: May 03, 2015, 03:50:27 PM by ymg »

motee-z

  • Newt
  • Posts: 40
Re: Triangulation (re-visited)
« Reply #399 on: May 03, 2015, 05:37:42 PM »
Hello ymg
i copied a 3dface generated by last version of triangulation
and with same points i created a 3dface using 3dface command
so the 2 3dface are same if we want to get z value inside
so if apply the function get z value on your 3d face it gave point outside
but if applied on second one i get elevation
what i am asking for. is there is any difference in creating 3dface
why function worke on one and on the second not work
that mean there is defference between 2 3dface
any clarification please
attached here the 2 3dface

ymg

  • Guest
Re: Triangulation (re-visited)
« Reply #400 on: May 04, 2015, 04:20:54 AM »
motee-z,

As it is, the getz funtion actually "Bombed Out"
if the 3dface is completely flat.

So added a test in there to prevent that error.
will be in next revision.

Code - Auto/Visual Lisp: [Select]
  1. ;;                                                                            ;
  2. ;; getz     by ymg                                                            ;
  3. ;;                                                                            ;
  4. ;; Given point p and triangle defined by points t1, t2, t3                    ;
  5. ;; Returns: (x y z) where z is on face of triangle.                           ;
  6. ;;                                                                            ;
  7. ;; Added test to prevent Division by Zero    May 2015                         ;
  8. ;;                                                                            ;
  9.  
  10. (defun getz (p t1 t2 t3 / n1 n2 n3 x x1 x21 x31 y y1 y21 y31 z1 z21 z31)
  11.    (setq  x (car  p)  y  (cadr p)
  12.          x1 (car t1) y1 (cadr t1) z1 (caddr t1)        
  13.         x21 (- (car t2) x1)  y21 (- (cadr t2) y1) z21 (- (caddr t2) z1)
  14.         x31 (- (car t3) x1)  y31 (- (cadr t3) y1) z31 (- (caddr t3) z1)
  15.          n1 (- (* y21 z31) (* z21 y31))
  16.          n2 (- (* z21 x31) (* x21 z31))  
  17.          n3 (- (* x21 y31) (* y21 x31))
  18.    )
  19.    (if (zerop n3)
  20.       (list x y z1)
  21.       (list x y (/ (+ (* (- x1 x) n1) (* (- y1 y) n2) (* z1 n3)) n3))
  22.    )  
  23. )
  24.  

ymg

motee-z

  • Newt
  • Posts: 40
Re: Triangulation (re-visited)
« Reply #401 on: May 04, 2015, 04:37:23 PM »
yes ymg
but the 3d face not flat
and i mean in my question what is the difference between the 2 3dface they are the same dimension same elevation points
 but there are difference i don,t know where

ymg

  • Guest
Re: Triangulation (re-visited)
« Reply #402 on: May 04, 2015, 05:16:10 PM »
motee-z

When I opened your drawing they were not the same.

First one has elevation 1097.52, 1097.52 and 1097.55
The second has 1097.55, 1097.55, 1097.55

Look at the result from entget below:

Quote
Command: (entget (car (entsel)))

Select object: ((-1 . <Entity name: 7ffff61ccf0>) (0 . "3DFACE") (330 . <Entity
name: 7ffff6059f0>) (5 . "1C7") (100 . "AcDbEntity") (67 . 0) (410 . "Model")
(8 . "TIN Natural Ground") (100 . "AcDbFace") (10 18.4842 6.96325 1097.52) (11
18.4842 6.96325 1097.52) (12 15.9999 14.4341 1097.52) (13 13.6163 8.10007
1097.55) (70 . 0))

Command: Specify opposite corner or [Fence/WPolygon/CPolygon]:
Command: (entget (car (entsel)))

Select object: ((-1 . <Entity name: 7ffff61cd80>) (0 . "3DFACE") (330 . <Entity
name: 7ffff6059f0>) (5 . "218") (100 . "AcDbEntity") (67 . 0) (410 . "Model")
(8 . "0") (100 . "AcDbFace") (10 21.4421 6.98593 1097.55) (11 26.31 5.84911
1097.55) (12 23.8257 13.32 1097.55) (13 21.4421 6.98593 1097.55) (70 . 0))


ymg

motee-z

  • Newt
  • Posts: 40
Re: Triangulation (re-visited)
« Reply #403 on: May 04, 2015, 06:16:44 PM »
oh my god you are right ymg
actually i applied polyline command by mistake instead of 3dface command on a gray 3dface 
ok any way if we make another 3dface same head point using 3dface command and move it for comparing there will different 
apologize me for mistake

ymg

  • Guest
Re: Triangulation (re-visited)
« Reply #404 on: May 04, 2015, 06:28:08 PM »
motee-z

No need to apologize, to err is human.

ymg