xBimTeam / XbimWebUI

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

Is their any mechanism xBimTeam developed to create tree from .xbim ,.ifc or .wexbim file? #59

Closed BIMDevelopement closed 8 years ago

martin1cerny commented 8 years ago

What kind of tree do you mean? IFC is not a hierarchical structure so you can create many different tree structures out of it. You can have a look in XbimWindowsUI project to see one of the common tree representations of the data (project->site->building->building storey-> space-> element). You can get this structure just by accessing appropriate fields on these objects.

Also this question should be asked in different project because as you might have realized XbimWebUI doesn't contain any C# code (except for a few helper utilities which are not related to IFC or anything to do with BIM).

BIMDevelopement commented 8 years ago

Yes Martin , I would like same tree representations as you mentioned . Actually , I am not aware about all project . So I put question here. Thanx for replied . I will look in XbimWindowsUI project for that.

martin1cerny commented 8 years ago

You might want to check these: https://github.com/xBimTeam/XbimEssentials/tree/master/Xbim.IO/ViewModels

These are in Xbim.IO for now but will presumably move to more appropriate place in Xbim.Presentation or similar.

BIMDevelopement commented 8 years ago

okay .I will check .. Thanx

ani-rudh commented 7 years ago

You might want to check these: https://github.com/xBimTeam/XbimEssentials/tree/master/Xbim.IO/ViewModels

These are in Xbim.IO for now but will presumably move to more appropriate place in Xbim.Presentation or similar.

The link is not valid anymore.

I am looking to load a .ifc file and relpicate the tree structure (hierarchy) in a game engine for developing Virtual Reality apps for AEC projects.

My interest is to load an IFC file in Unity and rebuild the whole model with exact geometry in Unity. Please point me to right direction to get started. I am a total newbie to xBIM and IFC in general.

The process I want to implement is somewhat like this:

  1. load IFC files using xBIM.
  2. Parse through the tree structure and replicate that in Unity (need geometric information and parent-child relation ship of each node in the IFC file)
  3. For each IFC ENTITY (visible geometry), extract the transforms, triangulated mesh data and materials.
  4. Use the info from step 3 to create meshes in Unity for further processing.
martin1cerny commented 7 years ago

All the operations you have described as well as the view models are implemented in XbimWindowsUI in the sample application XbimXplorer. You should check that to see how to visualize IFC data using xBIM.

ani-rudh commented 7 years ago

Thaks martin, will do that. Will update if I find anything useful and new !

Ajes1337 commented 7 years ago

I have been struggling for days, how to get Vertices, Triangles and Material out of an IFC file with Xbim (in XbimWindowsUI).. I have the Vertices and Triangles.. but are pulling my hair out now, just to figure out how I get a material color or a valid Material.

Anyone know a 'simple' way to get the material?

Here is my code that get Vertices and Triangles:

since I cant seem to use this inbuild 'insert code' here is pastbin: https://pastebin.com/VfmG4rfN

private static byte[] ReadIfcFileAjesStyle(string ifcFilename) {
    List<Vector3[]> vecs = new List<Vector3[]>();
    List<int[]> trises = new List<int[]>();
    List<string> types = new List<string>();
    using (var model2 = IfcStore.Open(ifcFilename)) {
        if (model2.GeometryStore.IsEmpty) {
            Console.WriteLine("model.GeometryStore.IsEmpty");
            var context = new Xbim3DModelContext(model2);
            context.CreateContext();//skal køre for at virke..
        }
        XbimModelPositioningCollection modelPositions = new XbimModelPositioningCollection();
        short userDefinedId = 0;
        model2.UserDefinedId = userDefinedId;
        modelPositions.AddModel(model2.ReferencingModel);
        if (model2.IsFederation) {
            foreach (IReferencedModel refModel in model2.ReferencedModels) {
                refModel.Model.UserDefinedId = ++userDefinedId;
                IfcStore v = refModel.Model as IfcStore;
                if (v != null)
                    modelPositions.AddModel(v.ReferencingModel);
            }
        }
        XbimRect3D modelBounds = modelPositions.GetEnvelopeInMeters();
        XbimPoint3D p = modelBounds.Centroid();
        XbimVector3D modelTranslation = new XbimVector3D(-p.X, -p.Y, -p.Z);
        double oneMeter = model2.ModelFactors.OneMetre;
        XbimMatrix3D translation = XbimMatrix3D.CreateTranslation(modelTranslation * oneMeter);
        XbimMatrix3D scaling = XbimMatrix3D.CreateScale(1 / oneMeter);
        XbimMatrix3D transform = translation * scaling;
        WpfMaterial mat = new WpfMaterial();
        Color SelectionColor = Colors.Blue;
        mat.CreateMaterial(new XbimColour("Selection", SelectionColor.ScR, SelectionColor.ScG, SelectionColor.ScB, SelectionColor.ScA));
        Console.WriteLine("model.Instances amount: " + model2.Instances.Count);
        bool runOnce = false;
        foreach (IPersistEntity entityThe in model2.Instances) {
            WpfMeshGeometry3D m = WpfMeshGeometry3D.GetGeometry(entityThe, transform, mat);
            string nameOfType = entityThe.GetType().ToString();
            List<Vector3> vecsHere = new List<Vector3>();
            foreach (Point3D point in m.Mesh.Positions) {
                vecsHere.Add(new Vector3(point));
            }
            vecs.Add(vecsHere.ToArray());
            trises.Add(m.Mesh.TriangleIndices.ToArray());
            types.Add(nameOfType);
        }
    }
    byte[] data = SerializerMeshPack.SerializeMeshPack(vecs, trises, types);
    return data;
}
CBenghi commented 7 years ago

@Ajes1337,

I've opened a new issue in WindowsUI where your question belongs. This issue was already closed.

See the thread at: https://github.com/xBimTeam/XbimWindowsUI/issues/63

Best, Claudio