xBimTeam / XbimWebUI

Web components for xBIM Toolkit
http://xbimteam.github.io/XbimWebUI/
Other
188 stars 117 forks source link

Problem rendering wexbim exported with Xbim Xplorer #240

Closed dumitrugrl closed 2 years ago

dumitrugrl commented 4 years ago

Hi, I loaded a .ifc file into to Xbim Xplorer and exported it as wexbim in order to load it in the web viewer. While in the windows app it looks ok, on the web it does not render the same.

Is there something with my source file?

I am attaching a screenshot and the two files (ifc and wexbim). image

The version of the xBIM Viewer: 4.0.1902 (latest sources from Github, compiled and executed locally.

testfile01.zip

martin1cerny commented 4 years ago

This is likely caused by tessellated geometry with large coordinates. While the Xplorer is adjusting the view space to the local region wexbim viewer is not doing that in the current version. That results in the data which is above GPU precision.

dumitrugrl commented 4 years ago

Are there some adjustments that can be made in the IFC file?

martin1cerny commented 4 years ago

Yes, you can scan through and reduce all instances of IfcCartesianPoint with X > 1000 by 149000.0 and Y by 213000.0. Code would look like this:

using (var txn = model.BeginTransaction())
{
    foreach (var c in model.Instances.OfType<IIfcCartesianPoint>().ToList())
    {
        if (c.X > 100000)
        {
            c.Coordinates[0] -= 149000;
            c.Coordinates[1] -= 213000;
        }
    }
    txn.Commit();
}

Be aware that this is only suitable for models where the only type or shape representation is an IfcFacetedBrep. That is usually not the case but we see this often with infrastructural models exported from Autodesk Civil 3D (like yours) or Bentley.

dumitrugrl commented 4 years ago

Thank you very much for your help. I will give it a try tomorrow and get back to you with the result. Thank you once again. I really appreciate your help.

dumitrugrl commented 4 years ago

Thank you, Martin. That was indeed the issue. Below a screenshot with the wexbim after indicated adjustments. 2019-08-30_7-56-09

Fortunately, the file in question only had IfcFacetedBrep shape representation.

martin1cerny commented 4 years ago

Another option is to move the wexBIM file as described in https://github.com/xBimTeam/XbimGeometry/issues/213

This would be more generic solution.

image

dumitrugrl commented 4 years ago

I have tested both approaches and while both resolve the tesselation issue, the second method described in https://github.com/xBimTeam/XbimGeometry/issues/213 alters the relative positioning of elements (when using multiple models loaded at once) (each IFC file is part of a larger project and has an absolute position within that project).

Left = 1st approach

2019-08-30_12-06-01

martin1cerny commented 4 years ago

Yes, you would have to use the same displacement for all wexBIM exports which are expected to be viewed together.

dumitrugrl commented 4 years ago

Thank you for the information. In the first step I have collected all regions from all files like so:

IVector3D translation = null;
List<XbimRegion> regions = new List<XbimRegion>();
for (int fi = 0; fi < fileEntries.Length; fi++)
{
   using (var model = IfcStore.Open($"{fileEntries[fi]}"))
   {
       var context = new Xbim3DModelContext(model);
       context.CreateContext();
       using (var store = model.GeometryStore.BeginRead())
       {
          var rgs = store.ContextRegions.SelectMany(r => r).ToList();
          regions.AddRange(rgs);
        }
    }
 }

Then got the largest one by population and computed the translation:

var biggestByPop = regions.OrderByDescending(r => r.Population).FirstOrDefault();
if (biggestByPop != null)
{
   var c = biggestByPop.Centre;
   translation = new XbimVector3D(-c.X, -c.Y, -c.Z);
}

Then passed this IVector3D to the IFCModel2WexBIM and the results seem to be ok. All sub-models appear to have kept their relative position to each other.

Can you tell if my steps are correct?

Should I get the largest region by size maybe?

var biggestBySize = regions.OrderByDescending(r => r.Size.X ).ThenByDescending( r => r.Size.Y).FirstOrDefault();

Thank you!

martin1cerny commented 4 years ago

The logic depends entirely on you. I would use the population as the more important metric. That is where most of your 3D data is.

castronelson commented 4 years ago

please anyone help how to download the xbim.geometry.Engine64.dll ?

dumitrugrl commented 4 years ago

Xbim.Geometry.Engine64.dll.zip

castronelson commented 4 years ago

Dear All,

Thanks for the dll.

We are trying to convert the IFC file to WEXBIM. But we have received the below error after referring the Xbim.Geometry.Engine64.

Please provide if any other samples code available for converting the IFC file to wexbim, converting IFC file to JSON.

Best Regards,

Castro Nelson D

Software Engineer

Email: mailto:castro.nelson@sierratec.com castro.nelson@sierratec.com | Voice: +91-422-711 5566, +91 93632-20483 | Ext. 508

http://www.greenestbuilding.com/

WORLD'S SECOND HIGHEST RANKING GREEN BUILDING

rated by GBCI under LEED NC v2009

                            <https://www.greenestbuilding.com/efacility-building-walkthrough-worlds-second-greenest-building/> 

From: mmmggg [mailto:notifications@github.com] Sent: 10 September 2019 16:33 To: xBimTeam/XbimWebUI XbimWebUI@noreply.github.com Cc: castronelson castro.nelson@sierratec.com; Comment comment@noreply.github.com Subject: Re: [xBimTeam/XbimWebUI] Problem rendering wexbim exported with Xbim Xplorer (#240)

Xbim.Geometry.Engine64.dll.zip https://github.com/xBimTeam/XbimWebUI/files/3595327/Xbim.Geometry.Engine64.dll.zip

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/xBimTeam/XbimWebUI/issues/240?email_source=notifications&email_token=AMUVKXCPFLUXS7ADXEFTQNLQI55F7A5CNFSM4ISBV3UKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6KWMIQ#issuecomment-529884706 , or mute the thread https://github.com/notifications/unsubscribe-auth/AMUVKXAHQISOC5HBKCYJBPLQI55F7ANCNFSM4ISBV3UA .

castronelson commented 4 years ago

Hi, we have received the below error while converting the IFC file to WexBim. An exception of type 'System.IO.FileNotFoundException' occurred in Xbim.Geometry.Engine.Interop.dll but was not handled in user code

Additional information: Could not load file or assembly 'Xbim.Geometry.Engine32' or one of its dependencies. The system cannot find the file specified.

We have used 'Xbim.Geometry.Engine64' dll. Please also provide the related dlls below:

  1. Xbim.Geometry.Engine.Interop.dll
  2. Xbim.ModelGeometry.Scene.dll Thank you.
martin1cerny commented 4 years ago

You should use NuGet package. It will make sure all dlls are copied to the right location to be loaded in runtime.