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

How to set up local development environment to fix bug's and create PR to contribute in xbim repositories. #464

Open CCT-Mukund-Thakare opened 7 months ago

CCT-Mukund-Thakare commented 7 months ago

Hello Team,

I am looking for reference documentation or guidance to set up local development environment xbimGeometry repositories. I have cloned most of the repositories like XbimGeometry, XbimEssentials, XbimWindowsUI on my local machine and have started debugging it.

But I am finding it hard to related and understand all this repositories with each other. I can see multiple solutions\projects in XbimGeometry --Xbim.Geometry.Engine.Interop.Tests --Xbim.Geometry.Engine.Interop --Xbim.Geometry.Engine --Xbim.Geometry.Portable --Xbim.Geometry.Regression --Xbim.ModelGeometry.Scene

XbimEssentials --Xbim.Common --Xbim.IO.Esent --Xbim.IO.MemoryModel --Xbim.Ifc --Xbim.Ifc2*3 --Xbim.Ifc4 --Xbim.Tessellator

I am finding it hard to understand the purpose of each project. Suppose I fix a bug in Xbim.Geometry.Engine solution how would I test it ? How can I visualize it that it is being fixed ?

The document or readme would really help in this case to do local environment setup and understand these projects.

any kind of help\comments\suggestions are appreciated.

Thank you !!

andyward commented 7 months ago

HI @CCT-Mukund-Thakare, yes you're right a doc would help. I'll make a few notes quickly here and hopefully we can revisit with a md doc:

Understanding the Projects / purposes

So high level, xbimEssentials is the core of xbim Toolkit. It's reads and writes IFC schema files in a variety of formats. It also provides some fundamental data structures for representing the Geometry and visual aspects of models (and a Tesselator to turn geometry into a mesh), but doesn't implement any geometry itself.

xbimGeometry is a separate repo that depends on Essentials, which translates the many IFC logical representations and their conventions into pure geometry, and incorporates a boolean library (OpenCascade) for fundamental shape operations. @Ibrahim5aad did a nice overview post of the fundamentals on LinkedIn

For an overview of the wider Toolkit dependencies see this (slightly out of date) section of the Readme

In a bit more detail, what the assemblies do XbimEssentials

XbimGeometry

Working with XbimGeometry - Debugging etc

Typically we target the develop branch (v5.1) but in the short term I recommend using feature/netcore (v6) as the base branch - as this will shortly become develop and any fix won't need back-porting to v6. It's also a lot easier / quicker to debug with.

Assumption: you can already build and test the XbimGeometry solution. See the Readme for pre-requisites.

To some extent your approach depends on how deep you are going but this is my typical workflow when I have to go into Geometry:

  1. Establish a minimal reproduction of the issue by stripping down an IFC to the minimal required elements. Start by identifying the Ifcproduct(s) that cause the issue. Usually the logs will help you here. To create a mininal IFC test file, I recommend using the 'Ifc Stripping' feature in XbimXplorer for this. Note you don't need to be able to visualise the model to strip out a product. Here's I'm stripping a single product (FlowTerminal #120371) out of an 18MB MEP model to create a 100k test sample. image
image image image image
  1. Ensure all tests pass to start with
  2. Create a unit test exercising the code with that minimal file For example
  3. Debug from the unit test, and determine a fix, ensuring no regressions in the unit tests

(If there's a major change we'd also run the Xbim Regression test suite)

How to visualise

A couple of different approaches:

  1. Use model.SaveAsWexBim(wexBimBinaryWriter) to output a tessellated wexbim file, and load into the xbimWebUI viewer. This is probably the quickest way to view a scene, and means you don't need to create Nuget packages
  2. Manually package the Xbim.ModelGeometry.Scene and Xbim.Geometry.Engine.Interop projects into a nupkg nuget file (dotnet pack etc or just use the IDE), host these in a local / private nuget repo, and integrate into XbimWindowsUI - or your own service.
  3. Lastly for more advanced cases you can save individual objects to a Brep text format using WriteBrep() on a GeometryEngine instance and tools such as OpenCascade's CAD Assistant will render that file for you. e.g.
image

Hope that's a good starting point.