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
255 stars 128 forks source link

Some objects (walls, slabs) are not being displayed and a possible solution #497

Open santiagoIT opened 1 month ago

santiagoIT commented 1 month ago

If you open the IFC file with XBimExplorer (compiling the master branch) you will notice that the walls are not being displayed:

image

I doubt this is the proper solution, but it might give a hint as to what might be wrong. But if the code changes listed are applied, then the walls do display: image

Btw, XbimXplorer version 4 does display the walls. So this is some sort of regression.

Let me know how to proceed. If this should be the proper solution, I can make a pull request, otherwise please give me some hints as to where the problem might be. I spent a lot of time, trying to figure this out, so any help/advice is appreciated.

This is in XbimGeometryCreator.cpp. Just added code to support XBimSolidSets.

void XbimGeometryCreator::WriteTriangulation(BinaryWriter^ bw, IXbimGeometryObject^ shape, double tolerance, double deflection, double angle)
{

    XbimOccShape^ xShape = dynamic_cast<XbimOccShape^>(shape);
    if (xShape != nullptr)
    {
        xShape->WriteTriangulation(bw, tolerance, deflection, angle);
        return;
    }

    /// START
    /// NEW CODE -> workaround for the problem of the walls not being displayed
    XbimSolidSet^ xSolidSet = dynamic_cast<XbimSolidSet^>(shape);
    if (xSolidSet != nullptr)
    {
        // create an XBimCompound out of the XBimSolidSet
        TopoDS_Compound compound;
        BRep_Builder b;
        b.MakeCompound(compound);

        for each (IXbimSolid^ solid in xSolidSet)
        {
            if (!solid->IsValid)
            {
                continue;
            }

            XbimSolid^ solid2 = dynamic_cast<XbimSolid^>(solid);
            if (solid2 != nullptr) {
                b.Add(compound, solid2);
                //GC::KeepAlive(solid);
                XbimCompound^ compound2 = gcnew XbimCompound(compound, true, tolerance);
                compound2->WriteTriangulation(bw, tolerance, deflection, angle);
            }
        }
    }
    /// END
    /// NEW CODE
}

Thank you! xBim-Issue.zip