engine_components icon indicating copy to clipboard operation
engine_components copied to clipboard

Sort levels by height for exploding tool

Open RASRC opened this issue 2 years ago • 7 comments

Describe the bug 📝

I'm having some problems with the explode tool.

It appears to don't work well with levels that have negative elevation (I mean that this levels are positioned below the IFC origin). The elements are displayed in an incorrect position above the origin when you explode the model like in the screen captures. There is something I can do to fix it? Thanks! Cap02 Cap03

Reproduction ▶️

https://github.com/RASRC/FrontEnd_Course.git

Steps to reproduce 🔢

Activating the explode tool in the bottom menu of the app

System Info 💻

openbim-components

Used Package Manager 📦

npm

Error Trace/Logs 📃

No response

Validations ✅

  • [X] Read the docs.
  • [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • [X] Make sure this is a IFC.js components issue and not a framework-specific issue. For example, if it's a THREE.js related bug, it should likely be reported to mrdoob/threejs instead.
  • [X] Check that this is a concrete bug. For Q&A join our Discord Chat Server.
  • [X] The provided reproduction is a minimal reproducible example of the bug.

RASRC avatar Jul 26 '23 10:07 RASRC

Hi @agviegas

I write to ask you if there is a chance to solve this issue for the official release.

Thanks!

RASRC avatar Sep 03 '23 23:09 RASRC

We'll try! Otherwise, we'll fix it after September 20. Cheers!

agviegas avatar Sep 04 '23 12:09 agviegas

Hi @agviegas.

I send you the IFC file. It could be useful if you want to do some tests.

Thanks!

25052023-896-WTC.zip

RASRC avatar Nov 05 '23 14:11 RASRC

Hi @RASRC! I'm just following up this issue. Are still experiencing the same problems when updating to [email protected]?

HoyosJuan avatar Nov 28 '23 17:11 HoyosJuan

Hi @HoyosJuan! Yes I have that version running and the issue is still there. I left the ifc file in a previous message if you want to do some tests. Thanks!

RASRC avatar Dec 01 '23 09:12 RASRC

Hi @HoyosJuan! I'm using the 1.2.0 version of the library now and still have the same issue

RASRC avatar Jan 13 '24 16:01 RASRC

Hi @HoyosJuan! Did you can test the FragmentExploder with the model I attached to the issue? Thanks.

RASRC avatar Mar 25 '24 14:03 RASRC

Hey! After the big refactor of the library, this milestone we are checking and solving issues. We have also updated the exploder. Now, you can classify the model like this:

const classifier = components.get(OBC.Classifier);
await classifier.bySpatialStructure(model);

That won't sort the storeys by default because it's generic to any kind of relationship, but you can easily sort them by getting all the storeys and using its elevation information. Good thing about this approach is that even in those files where the elevation information is somewhere else, a custom sort method can be established for the exploder:

const storeys = await model.getAllPropertiesOfType(WEBIFC.IFCBUILDINGSTOREY);

if (storeys) {
  const storeyList = Object.values(storeys);
  storeyList.sort((a, b) => a.Elevation.value - b.Elevation.value);
  const sortedIds = storeyList.map((item) => item.Name.value);
  const newClassifiedStories: typeof classifier.list.spatialStructures = {};
  for (const id of sortedIds) {
    const classifiedStories = classifier.list.spatialStructures;
    newClassifiedStories[id] = classifiedStories[id];
  }
  classifier.list.spatialStructures = newClassifiedStories;
}

This should be possible from @thatopen/[email protected], which I'm publishing right now. I'm also going to update the docs right away. Let me know if you face any issues with this. Cheers!

agviegas avatar Jun 20 '24 08:06 agviegas