Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overriding IfcElements render colors on loading file #595

Merged
merged 3 commits into from Feb 17, 2023

Conversation

aozien
Copy link
Collaborator

@aozien aozien commented Feb 12, 2023

The Idea

This is an alternative more of a static approach for colorizing single IfcElements at an early stage of file loading, without having to rely on the ifc-viewer subset functionality.

The viewer.loadIfcUrl now takes an extra parameter where you can specify options for overloading the loaded elements colors.

The view-options is an object that contains

  1. a map of key-value pair for elements and their colors.
  2. a default color to be used for element as a fallback
  3. if both failed, it will use the element's original color.

This PR should be the first step of achieving the 'smart views' like functionality
The second step is to create the view-rules compiler

Eventually those view settings will be the result of compiling the view-rules against the loaded model,

for example having a view-rule

type:Wall set color:red; type:Slab set color:#0000FF;

will first be executed on the model file in the compiler that creates the viewOptions object to be passed to the viewer

image
image

@netlify
Copy link

netlify bot commented Feb 12, 2023

Deploy Preview for bldrs-share ready!

Name Link
🔨 Latest commit ae683d7
🔍 Latest deploy log https://app.netlify.com/sites/bldrs-share/deploys/63e8343879ff930008d85fcc
😎 Deploy Preview https://deploy-preview-595--bldrs-share.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@pablo-mayrgundter
Copy link
Member

Hi @aozien , sorry, missed this again. Are you able to ask for a reveiw? If not I can move you to outside collaborator with triage

@pablo-mayrgundter
Copy link
Member

How are you previewing this with the colors? Would be nice to have a link to preview

@aozien
Copy link
Collaborator Author

aozien commented Feb 14, 2023

Hi @pablo-mayrgundter, no problem there's also another PR open for the multiselect in case you missed it. (Edit: you didn't)

Are you able to ask for a reveiw?

I'm not sure where this option should be, but I'm not seeing it any where.

How are you previewing this with the colors? Would be nice to have a link to preview

The viewer.loadIfcUrl function now accepts an additional parameter of type IfcCustomViewSettings

Where you can define the following when loading the file:
1- a default color to override all elements color with
2- a specific color per express Id

something like this for example:

image

can be achieved with the following settings:

import IfcCustomViewSettings from '../Infrastructure/IfcCustomViewSettings'
import IfcColor from '../Infrastructure/IfcColor'
.
.

 
 const customViewSettings = new IfcCustomViewSettings(new IfcColor(0.7, 0.3, 0.1, 1), {
      396: new IfcColor(0.2, 0.3, 0.4, 0.8),
 })
const loadedModel = await viewer.loadIfcUrl(
ifcURL,
!urlHasCameraParams(), // fitToFrame
(progressEvent) => {
  if (Number.isFinite(progressEvent.loaded)) {
    const loadedBytes = progressEvent.loaded
    // eslint-disable-next-line no-magic-numbers
    const loadedMegs = (loadedBytes / (1024 * 1024)).toFixed(2)
    setLoadingMessage(`${loadingMessageBase}: ${loadedMegs} MB`)
    debug().log(`CadView#loadIfc$onProgress, ${loadedBytes} bytes`)
  }
},
(error) => {
  console.warn('CadView#loadIfc$onError', error)
  // TODO(pablo): error modal.
  setIsLoading(false)
  setAlertMessage(`Could not load file: ${filepath}`)
}, customViewSettings)
    

@pablo-mayrgundter
Copy link
Member

I'm sorry i was taking a while on this this week. I'd like to get you guys in a better previewing situation.. i didn't quite follow how to evaluate this.

However, I do understand the goal here and the code as you have it doesn't touch any main workflow, so fine for now.

I'm going to merge this and see what else I we can get in this week.

We should talk soon. I'll send an invite for a meeting after I get a chance to talk with Adrian.

Cheers!

@pablo-mayrgundter pablo-mayrgundter merged commit 4ec449f into bldrs-ai:main Feb 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Completed
Development

Successfully merging this pull request may close these issues.

None yet

2 participants