xBimTeam / XbimGeometry

XbimGeometry contains the CLR interop libraries and the c++ engine used to compute the 3D geometry of models.
https://xbimteam.github.io/
Other
260 stars 132 forks source link

Can't get correct color #305

Open GVladislavG opened 3 years ago

GVladislavG commented 3 years ago

I try to get color of IFCElements, using this code

                //Получим цвет
                XbimColour color = null;
                int styleId = instance.StyleLabel;
                if (styleId > 0)
                {
                    var ss = (IIfcSurfaceStyle)m_model.Instances[styleId];
                    var texture = XbimTexture.Create(ss);
                    color = texture.ColourMap.FirstOrDefault();
                }                

                if (color == null) color = XbimColour.DefaultColour;

                byte r = (Byte)(color.Red * 255);
                byte g = (Byte)(color.Green * 255);
                byte b = (Byte)(color.Blue * 255);
                byte a = (Byte)(color.Alpha * 255);

But I can't get right color for every element. For example walls are blue in BIM Vision, but they are grey in my application. Where is the problem? BimVision CADLib

martin1cerny commented 3 years ago

Can you share an IFC file with one of these walls?

GVladislavG commented 3 years ago

АР_модель.zip

martin1cerny commented 3 years ago

The blue colour in this case is assigned through the material list and definition representation #487= IFCMATERIALDEFINITIONREPRESENTATION($,$,(#485),#470); Xbim currently only handles single colour for a product, but rendering material layer sets or lists would require per-face colour handling. See #279

GVladislavG commented 3 years ago

So is there any way now to read this material list and to set correct blue color to a wall? Or this type of colors is not supported in current version? Thanks for your answers.

martin1cerny commented 3 years ago

You can read it from IFC directly and enhance the result. We do plan some support in the future, but it is not in the current version.

GVladislavG commented 3 years ago

I have the same problem with colors in IFC4 files. Is it because of the same reason? IFC4.zip

martin1cerny commented 3 years ago

This is a large file, so I'd like to ask you to create a minimal example with just a single IfcProduct.

GVladislavG commented 3 years ago

IFC4(small).zip

GVladislavG commented 3 years ago

And can you show me please a place in XbimEplorer source code, where getting of color happens? XbimEplorer shows incorrect colors but it's better than nothing in my case. Thanks.

martin1cerny commented 3 years ago

Which element has a wrong colour? The best sample file would be the one containing only the element in question. image

GVladislavG commented 3 years ago

Blue color is wrong. It must be brown. Here's two more examples of incorrect colors in XBimExplorer Building-BimVision Building-XBimExplorer RAC-BimVision RAC-XBimExplorer

GVladislavG commented 3 years ago

Roofs have wrong colors in these XBimExplorer visualisations. BimVision shows correct colors. I also share these IFC-files RAC_basic_sample_project.zip IFC4.zip