GithubHelp home page GithubHelp logo

Comments (7)

martin1cerny avatar martin1cerny commented on July 19, 2024

Have a look at source code for IfcStore.SaveAsWexBim() function. That uses triangulated geometry to create data for a web presentation.

from xbimgeometry.

jv112602 avatar jv112602 commented on July 19, 2024

I had the same issue and used some code I posted in https://github.com/xBimTeam/XbimGeometry/issues/34
if you need more just let me know but I was able to get all the vertices and faces with that technique

Jay

from xbimgeometry.

ani-rudh avatar ani-rudh commented on July 19, 2024

Hi Jay,

Yes please. I infact tried your method first from the code in issue 34.

This is what I am doing..

var context = new Xbim3DModelContext(model);
              context.CreateContext();
             

              var item = model.Instances.FirstOrDefault<IIfcWall>();
              var productshape = context.ShapeInstancesOf((IIfcProduct)item);
                  
              var _productShape = productshape.Where(s => s.RepresentationType != XbimGeometryRepresentationType.OpeningsAndAdditionsExcluded).ToList();

              XbimShapeTriangulation mesh = null;
              foreach (var shapeInstance in _productShape)
              {
                  var geometry = context.ShapeGeometry(shapeInstance.ShapeGeometryLabel);
                  Console.WriteLine(geometry.Format);
                  Console.WriteLine(context.ShapeGeometry(shapeInstance.ShapeGeometryLabel));
                  var ms = new MemoryStream(((IXbimShapeGeometryData)geometry).ShapeData);
                  var br = new BinaryReader(ms);
                  mesh = br.ReadShapeTriangulation();
                  mesh = mesh.Transform(((XbimShapeInstance)shapeInstance).Transformation);
                  Console.WriteLine (mesh.Faces.Count());

                  
              }

I get 6 faces returned on the wall. The wall is a simple cubiod. From what I understand, after triangulation, each face is split to 2 triangles, which implies that the triangulate shape will have 12 faces on a cuboid instead of 6.

I want to extract the data of each geometry in such a way that i have reference to TriangleIndices, Vertices of the triangle and Face indices for all the faces of the geometry.

If you are familiar with Unity, these are the inputs to compile a mesh. I need to recreate the IFC file in Unity with the hierarchy intact.

I await your suggestions if there is a better way to do this.

On a side note, I have tried the read() method in XbimWindowsUI/Xbim.Presentation/MeshGeometry3DExtensions.cs, which I couldn't manage as well.

Thanks in advance Jay!

from xbimgeometry.

martin1cerny avatar martin1cerny commented on July 19, 2024

If you tried little bit more you would find that every of these faces has triangles as normals and indices inside.

var triangleCount = mesh.Faces.Aggregate(face => face.TriangleCount);

from xbimgeometry.

ani-rudh avatar ani-rudh commented on July 19, 2024

from xbimgeometry.

jv112602 avatar jv112602 commented on July 19, 2024

I tried your same cube example and got the following:

  • 6 faces which are all the sides of the cube
  • inside each cube side (face) you have 2 triangles
  • then there are 6 indices inside each cube face representing the 6 indices for the sides of the 2 triangles
  • I think you can group the indices into 3's and you have your triangle indices ?
    triangle 1 has indices[0, indices[1], indices[2]
    triangle 2 has indices[3, indices[4], indices[5]

make sense ?

jay

from xbimgeometry.

ani-rudh avatar ani-rudh commented on July 19, 2024

from xbimgeometry.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.