Comments (7)
Have a look at source code for IfcStore.SaveAsWexBim()
function. That uses triangulated geometry to create data for a web presentation.
from xbimgeometry.
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.
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.
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.
from xbimgeometry.
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.
from xbimgeometry.
Related Issues (20)
- Resolving native assemblies from UNC file share fails under NetFramework
- Some IXbimSolid elements don't exist when performing boolean operations HOT 4
- How to get color of IfcSpace? HOT 3
- net6.0 support HOT 4
- Cant create valid IfcSurfaceCurveSweptAreaSolid HOT 1
- Getting correct position of the model in world coordinates
- How to set up local development environment to fix bug's and create PR to contribute in xbim repositories. HOT 1
- How to get outer Edges for an IfcEntity using Xbim library ? HOT 8
- Load Ifc File System.AccessViolationException HOT 4
- Big size of result IFC file HOT 3
- XbimShapeInstance.Transformation places instance in world coordinates HOT 1
- Setting model units HOT 3
- Is v6 geometry engine currently much slower than v5?? HOT 2
- System.OutOfMemoryException. Array dimensions exceeded supported range. HOT 5
- GetShellPoints of a component HOT 1
- Failed to load IFC file: failed to load Xbim.Geometry.Engine64.dll HOT 6
- We need to get plot line bounding box distance for all levels. HOT 1
- We need to get shellpoints of any Building elements. HOT 1
- How to get face points of any building element. HOT 1
- ShapeUpgrade_UnifySameDomain causes a freeze HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xbimgeometry.