opensourceBIM / bimvie.ws

Javascript client for Building Information Modelling, using open standards like IFC, BCF and BIMSie. Using Bootstrap, BIM Surfer, etc..
GNU Affero General Public License v3.0
171 stars 87 forks source link

How ifcOids array get datas from node ? and how node get object ids ? #54

Closed digitalportico closed 8 years ago

digitalportico commented 8 years ago

While analyzing bimvie.ws source code , we confused on how node get object ids ?

this.internalToggleEye = function(node, mode) { var nodeList = node.list(); console.log("console: nodelist"); console.log(nodeList); var groupNode = node.findFirstParentWithAttr("groupId"); if (groupNode.groupId != -1) { var hiddenTypes = Settings.getDefaultHiddenTypes(); var ifcOids = []; nodeList.forEach(function(subNode){ if (subNode.type.startsWith("Ifc") && typeof subNode.id === "number") { var explicit = node.id == subNode.id || (node.type != null && node.type == subNode.type); if (hiddenTypes[subNode.type] == null || explicit || mode != 0) { ifcOids.push(subNode.id); } } }); console.log("console: ifcOids"); console.log(ifcOids); parent.setObjectVisibility(groupNode.groupId, ifcOids, mode); nodeList.forEach(function(n){ var explicit = node.id == n.id || (node.type != null && node.type == n.type); if (hiddenTypes[n.type] == null || explicit || mode != 0) { n.eye.attr("mode", mode); if (mode == 0) { n.eye.removeClass("eyeclosed").removeClass("eyehalfopen").addClass("eyeopen"); } else if (mode == 1) { n.eye.removeClass("eyeopen").removeClass("eyeclosed").addClass("eyehalfopen"); } else if (mode == 2) { n.eye.removeClass("eyehalfopen").removeClass("eyeopen").addClass("eyeclosed"); } } }); } };

rubendel commented 8 years ago

Please use proper code escaping.

Can you be more specific on what you are confused about? node.list will recursively get a flat list based on all the children of a tree node. For all those nodes, after a little bit of filtering the oid's are being put in ifcOids

digitalportico commented 8 years ago

i need separate ifcOids array. Is there any way to get it , other than using nodes ? I mean , get all oids as array directly from model or from project ?

rubendel commented 8 years ago

Sure just iterate through all objects and get their oids and put them in an array.

Something like this (untested)

var oids = [];
model.objects.forEach(function(object){
  oids.push(object.oid);
});