Outline class behaviour

Outline class behaviour

jonathan.taVCBM2
Enthusiast Enthusiast
1,318 Views
7 Replies
Message 1 of 8

Outline class behaviour

jonathan.taVCBM2
Enthusiast
Enthusiast

Hi ,

I have been trying to use the Outline class in order to figure out if a point is inside a certain outline which I build from the  stems from a floor top face .  using the Outline.contains(XYZ pt, double Tolerance).  
I create the outline with the  constructor that uses minimum and maximum points. 

 

It seems to behave like a bounding box rather than how I expected an Outline to behave , when I compile and run the code below (one time with p2 as the Maximum point and the other with p5 ) I get the results as show in the images below. 

Is this the planned behaviour ? it's not what I expected at all , the documentation is sparse.

public void squick()
        {
            XYZ p0, p1, p2, p3, p4, p5, pout , pin;
            p0 = new XYZ(0,0,0);
            p1 = new XYZ(0,80,0);
            p2 = new XYZ(80, 80, 0);
            p3 = new XYZ(80, 50, 0);
            p4 = new XYZ(50, 50, 0);
            p5 = new XYZ(50, 0, 0);
            pout= new XYZ(60,30,0);
            pin = new XYZ(60,60,0);
            Outline outline = new Outline(p0, p5); // alternate p2 and p5 
            string o, i;
            o = outline.Contains(pout, 0.0001) ?  "Inside" : "Outside";
            i = outline.Contains(pin, 0.0001)  ? "Inside" : "Outside";
            string r = $"60,30 is {o} and 60,60 is {i}";
            // should be 60,30 is outside and 60,60 is inside 
            TaskDialog.Show("check", r);
        }



If I use the top right corner (p2  =80,80,0) as the maximum point it shows both points (60,60 and 60,30) as inside, if I use the bottom right corner (p5 =50,0,0) as the maximum point it shows both points as outside. 


jonathantaVCBM2_1-1681907904603.png

 




jonathantaVCBM2_0-1681907719795.png

 



Jonathan Talisman
BIM Developer
Accepted solutions (2)
1,319 Views
7 Replies
Replies (7)
Message 2 of 8

jeremy_tammik
Alumni
Alumni
Accepted solution

I'm sorry to say that I trust no documentation whatsoever. Therefore, I am a great fan of DIY. In the simple case of determining whether a point lies within a simple polygon, I would recommend implementing and using your own algorithm, or maybe somebody else's, but one that you can analyse, understand, control and modify yourself, e.g., this:

 

 

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
Message 3 of 8

jonathan.taVCBM2
Enthusiast
Enthusiast

Hi Jeremy , 

As much as I like DIY, sometimes using API's make sense. I would expect a class name Outline to behave as an outline,  or be deleted or renamed . The documentation says nothing meaningful.
It's a funny coincident that the first Link of the two starts with arriving at Tel Aviv , where I live. 
I will go through your solutions, they reference some obsolete libraries / class (Autodesk.Revit.Geometery and UVArray to name a couple) , if I make something useful/meaningful I will post here. 
Unfortunately I feel like marking your answer as a solution is the right thing to do albeit not quite what I was hoping for .

Kind regards , Jonathan. 

Jonathan Talisman
BIM Developer
Message 4 of 8

jeremy_tammik
Alumni
Alumni

Yes, I would love to just use official published fully documented APIs. Unfortunately, it has often proven unfeasible or ineffective. Chance are often better if they are open source, so all users can contribute. Sorry to hear that the code I shared is out of date. If you either update it yourself or share a couple of nice little use cases for testing, I can update it to share a current version on the blog.

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
Message 5 of 8

RPTHOMAS108
Mentor
Mentor
Accepted solution

Outline Class:

"Outline is a generic object that provides a bounding box/bounding outline. It supports operations to scale and transform. It also supports intersections and contains operations."

 

Apart from the nonsensical use of the term 'generic object' I can see that is possibly a bit vague (the bounding outline bit) however:

 

Outline.AddPoint

"Adds a point to the bounding box, expanding it if the point is outside the existing boundary."

 

So it is a box and when a point is added the box is expanded to contain it (i.e. no mention of convex hull etc). There are two constructors one takes two points (so can only create a box/line/flat rectangle). The other constructor takes another Outline which we know logically must have either been created by two points or expanded with further points into a box. Meaning there is no ability to create anything other than a box/line/rectangle with this class.

 

Additionally you have the method Outline.GetDiagonalLength which also indicates it is a box. Lastly regardless of how many points you add you are always left with the MaximumPoint and MinimumPoint properties that define it. Such point properties would be reporting wrong if the class was defining anything other than a line/rectangle/box.

 

The thing to know about Outline is that it is similar to BoundingBoxXYZ but without the transform. So where they say "supports operations to scale and transform" yes it supports scaling but I don't see any evidence that it supports transformations. 

 

I think that is the key complaint of the Outline class; that it is a low level thing perhaps used internally to decide if an element needs to be drawn on screen. I assumed this is why all the bounding box filters use an Outline rather than a BoundingBoxXYZ.

 

 

Message 6 of 8

mhannonQ65N2
Collaborator
Collaborator

Outline is just an Axis Aligned Bounding Box (aka, an AABB). Testing if something is in an AABB is very fast, hence why Outline is using in filtering rather than BoundingBoxXYZ.

 

I am not sure what you expect to get but when you use your p0 and p5 as the outline's min and max, neither pin nor pout should be inside of it and when you use p0 and p2, both of them should inside of it.

Message 7 of 8

jonathan.taVCBM2
Enthusiast
Enthusiast

Hi @RPTHOMAS108 ,

I must have read this and and ignored it because I was looking for something else, my bad. 

Thanks , Jonathan

Jonathan Talisman
BIM Developer
0 Likes
Message 8 of 8

jonathan.taVCBM2
Enthusiast
Enthusiast

Thanks @mhannonQ65N2 ,

I figured it out, I should have read the doc rather then "looking at it" I guess. 

I still thinks that [1 ]- the name Outline is confusing [2] - there should be an API function to check point in a polygon/polycurve containment, after all there is Room.IsPointInRoom function and Face.IsInside function I am sure these are or could be exposed as a more generic functions.

Since I am checking a floor I am using the Face.IsInside function , I just needed to figure the edges in UV values , luckily there's an Edge EvaluateOnFace method which is handy .

Thanks , Jonathan

 

 
Jonathan Talisman
BIM Developer
0 Likes