Method for recursive fill the ancestor properties of item - ifc

I dont know if this question is simple or not (or silly)
You have getItem methods to get an object using its Id (expressid) .
I want to get, for example, the ancestor properties ... and calculate properties (m2, m3. etc)
I can do it recursively calling to the ifc parent elements, and then again ., and again ...
Is there any other way ? Is there any dedicated function ?
This also means to learn about the ifc itself, but I dont know if I'm reinventing the wheel ?
Thanks
PD.
Somebody with enough reputation could create a ifc.js tag ....?

IFC.js just reflects the data within the IFC file. That means that the complexity / convolution of the data structures are not due to the library itself, but to the data structure of the IFC schema. Indeed, getting a bit familiar with the schema is a requirement to perform specific operations.
Just for your information, it's quite uncommon to compute the quantity data of elements yourself (surface, volume, etc). What the vast majority of BIM softwares do is read the explicit data of the IFC file (generally expressed as QSets).

It could be interesting to improve the ifc.js libraby to get a structured object of all properties for a construction element by its expressid.
A construction element is a leaf element under ifcRoot in class hierarchy.

Related

Is it possible to design a Class so that its instances only exist as items of a Collection?

I am trying to develop a conceptual model (object-oriented) of GPS-collected data. Usually, common classes are Track, which represents an ordered sequence of Trackpoints, and the class Trackpoint itself, which has properties such as latitude, longitude, elevation, timestamp, speed, accumulated distance, etc.
The fact is: since a Trackpoint instance only "makes sense" as an item of a Track (or a Segment, or a ConnectedSegment, or other possible similar collection types), the question is:
Is it good/common practice to design a class so that it "behaves" better (or exclusively) as member of a collection? And should I design the collection itself to enforce this?
I think most languages provide various collections implementations and they are well optimized. There is not much point in rolling your own implementations.
If you really don't want "TrackPoint" to be visible outside "Track", then, in Java, one can make TrackPoint a private class inside the definition of Trackclass. I guess in other languages too, you can apply similar visibility restrictions. Again, normally one does not need to to this kind of design either.
Design a Track class which has list of TrackPoint as member. It is as simple as that, and is perfectly good OO design.

Graph Traversing algorithms in Semantic web

I am asking about Algorithms that would be useful in Querying the Semantic web DB to get all the related RDFs to an original Object.
i.e If the original Object is the movie "inception", I want an algorithm to build queries to get the RDFs of the cast of the movie, the studio, the country ....etc so that I can build a relationship graph.
The most close example is the answer to this question , Especially this class , I wan similar algorithms or maybe titles to search in order to produce such an algorithm, I am thinking maybe some modifications on graph traversing algorithms can work, but I'm not sure.
NOTE: My project is in ASP.NET. So, it would help to use Exisiting .NET libraries.
You should be able to do a simple breadth-first-search to get all the objects that are a certain distance away from a given node.
You'll need to know something about the schema because some neighboring nodes are more meaningful than others. For example, in Freebase, we have intermediate nodes that link a film to an actor and a role. You need to know to go 2-ply deep to get at the actor and the role because just saying that the film is related to the intermediate nodes is not very interesting.
Did you take a look at "property paths"?
Property Paths give a more succinct way to write parts of basic graph
patterns and also extend matching of triple pattern to arbitrary
length paths. Property paths do not invalidate or change any existing
SPARQL query.
Triple stores and SPARQL engines such as OWLIM and AllegroGraph support them.

Measuring distances among classes in RDF/OWL graphs

Maybe someone could give me a hint. Is it possible to measure the distance between 2 concepts/classes that belong to the same ontology?
For example, let's suppose I have an ontology with the
Astronomy class and the Telescope class. There is a link between both, but it is not a direct link. Astronomy has a parent class called Science, and Telescope has a parent class called Optical Instrument which belongs to its parent called Instrumentation, that is related to a class called Empirical Science that finally belongs to a class called Science.
So there is an indirect link between Telescope and Astronomy, and I want to find out the number of steps needed to reach one class starting from the another one.
Is there an easy SPARQL query that resolves that question? Or are there better ways to do that job? Or is not possible to find that out using Semantic Web paradigm?
Any hint will be very appreciated.
SPARQL provides the ability to search for arbitrary length paths in a graph but no mechanism to tell you the length of that path.
So you can do something like:
SELECT * WHERE { ?s ex:property+ ?o }
The syntax is very much like regex so you can do alternatives, restricted cardinalities etc
In my understanding SPARQL doesn't contain any recursive constructions to be able to measure indirect link of arbitrary length. The best you could do is to prepare set of queries distance_1(a, b), distance_2(a, b)... to check for specific distance between two concepts.
Another alternative is to discover this information using non-SPARQL technology, for example writing graph traversing algorithm in Python with RDFlib.
Since you explicitly mentioned that you are talking about classes and they will be in the same ontology, it is safe to assume that they will be always connected (because ultimately both will be a subclass of "Thing", right?). On the other hand, the path I mentioned in the parentheses (Class1 -> ... -> Thing <- ... <- Class2) is a trivial one, so I assume you want to find... all of the existing paths between two classes, in other words, all of the existing paths between two vertices. Is that true? Or are you looking for the shortest path? Your question is not very clear in that aspect, can you clarify it?
As far as I know there is no simple SPARQL construct that will list all the paths between classes or the shortest path. However some semantic web triple stores come with graph traversal algorithms such as breadth-first-search or depth-first-search, please refer to:
http://www.franz.com/agraph/support/documentation/current/lisp-reference.html#sna
You may also find the source code of the following project very useful:
RelFinder, Interactive Relationship Discovery in RDF Data, http://www.visualdataweb.org/relfinder.php

Is Object the preferred Associative Container in AS3?

I've been using Object as a way to have a generic associative array (map/dictionary) since AS3/Flex seems to be very limited in this regard. But I really don't like it coming from a C++/Java/C# background. Is there a better way, some standard class I've not come across... is this even considered good/bad in AS3?
Yes, Actionscript uses Object as a generic associative container and is considered the standard way of doing this.
There is also a Dictionary class available, flash.utils.Dictionary.
The difference is that Dictionary can use any value as a key, including objects, while Object uses string keys. For most uses, Object is preferred as it is faster and covers the majority of use cases.
You can see the details on Object here: http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/Object.html
and Dictionary here: http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/utils/Dictionary.html
and the differences between them here: http://livedocs.adobe.com/flex/3/html/help.html?content=10_Lists_of_data_4.html
I'm afraid there's no native alternative to Object or Dictionary for maps and other structures. As for standard, well, it depends on how one defines standard, but there are a couple of known libraries that you might like to check out if you look for Java style collections.
Like this one:
http://sibirjak.com/blog/collections/as3commons-collections/
Also, you could take a look at this question, that has links to a couple of ds libraries (including the above one).
Collections in Adobe Flex
I wouldn't say using Objects is either good or bad practice. In the general case they are faster than any Actionscript alternative (since they are native), but less featured. Sometimes the provided functionality is good enough. Sometimes, it's a bit bare-bones, so something more structured could help you getting rid of lower level details in your code and focusing in your "domain logic", so to speak.
In the end, all of these libraries implement their data structures through Objects, Dictionaries and Arrays (or Vectors). So, if the native objects are fine for your needs, I'd say go with them. On the other hand, if you find yourself basically re-writting, say, an ad-hoc Set, perhaps, using one of these libs would be a wise choice.

QAbstractItemModel.parent(), why?

I'm a (Py)Qt newbie, porting C# GUI code to Qt for a couple of days now. One question that I keep asking myself is why are QAbstractItemModel subclasses required to supply a parent() method, and why are they required to supply, in the resulting QModelIndex, the row of a child in the parent?
This requirement forces me to add another layer over my tree data (because I don't want to call indexOf(item) in parent(), it wouldn't be very efficient) that remembers row indexes.
I ask this because it's the first time I see a model based view require this. For example, NSOutlineViewDataSource in Cocoa doesn't require this.
Trolltech devs are smart people, so I'm sure there's a good reason for this, I just want to know what reason.
The quick answer is, "they thought it best at the time." The Qt developers are people just like you and me -- they aren't perfect and they do make mistakes. They have learned from that experience and the result is in the works in the form of Itemviews-NG.
In their own words from the link above:
Let’s just say that there is room for improvement, lots of room!
By providing a parent that contains a row and column index, they provide one possible way to implement trees and support navigation. They could just as easily have used a more obvious graph implementation.
The requirement is primarily to support trees. I couldn't tell you the reason, since I'm not a Qt dev... I only use the stuff. However, if you aren't doing trees, you could probably use one of the more-tuned model classes and not have to deal with the overhead of supplying a parent. I believe that both QAbstractListModel and QAbstractTableModel handle the parent portion themselves, leaving you free to just worry about the data you want.
For trees, I suspect that one of the reasons they need the parent is that they try to keep to only asking for the information they need to draw. Without knowing all of the items in a tree (if it wasn't expanded, for example), it becomes much harder to provide an absolute position of a given item in a tree.
As for the quandry of using indexOf(item) in the parent function, have you considered using QModelIndex's internalId or internalPointer? I'm assuming they are available in PyQt... they can be used by your model to track things about the index. You might be able to use that to shortcut the effort of finding the parent's index.

Resources