Skip to content

Allow for IfcSurfaceStyleShading.Transparency (IFC4+)#2055

Open
cvillagrasa wants to merge 1 commit into
ThatOpen:mainfrom
cvillagrasa:shading-transparency
Open

Allow for IfcSurfaceStyleShading.Transparency (IFC4+)#2055
cvillagrasa wants to merge 1 commit into
ThatOpen:mainfrom
cvillagrasa:shading-transparency

Conversation

@cvillagrasa

Copy link
Copy Markdown

Now, a surface style expressed as a plain IfcSurfaceStyleShading with a Transparency value always renders fully opaque, with GetFlatMesh reporting alpha 1.0. But an IfcSurfaceStyleRendering works:

    #13=IFCCOLOURRGB($,1.,0.,0.);
    #14=IFCSURFACESTYLESHADING(#13,0.8);   -> alpha comes out 1.0, expected 0.2
    #16=IFCSURFACESTYLERENDERING(#13,0.8,$,$,$,$,$,$,.NOTDEFINED.);   -> alpha 0.2, correct

It seems to come from IfcGeometryLoader::GetColor, which reads Transparency only in the IFCSURFACESTYLERENDERING case. The IFCSURFACESTYLESHADING case reads only attribute 0 (SurfaceColour) and recurses into IFCCOLOURRGB, which hardcodes alpha 1. That matches IFC2X3, where IfcSurfaceStyleShading had no Transparency, but in IFC4 and IFC4X3 the attribute was moved up from Rendering to Shading (with Rendering inheriting it).

This PR enables IfcSurfaceStyleShading.Transparency to also have an effect.

tests/functional/ShadingTransparency.spec.ts covers three cases with inline models: IFC4 plain Shading with Transparency 0.8 gives mesh alpha 0.2, IFC4 Rendering with Transparency 0.8 gives alpha 0.2 (passes before and after), and IFC2X3 single-argument Shading stays at alpha 1.0 with no parse error.

GetColor only read Transparency for IfcSurfaceStyleRendering; a plain
IfcSurfaceStyleShading always came out opaque because only its
SurfaceColour was read and IfcColourRgb hardcodes alpha 1. Since IFC4,
Transparency belongs to IfcSurfaceStyleShading (Rendering inherits it)
and sits at argument index 1 in every schema, so the Rendering case
handles both entities: merge the two cases. IFC2X3 Shading has a single
argument and safely yields a non-REAL token at offset 1, keeping the
colour opaque.

Adds a spec with inline IFC4 and IFC2X3 models covering Shading with
transparency, Rendering with transparency and IFC2X3 plain Shading.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant