XbimGeometry
XbimGeometry copied to clipboard
How to get geometry correctly?
Hello! I try to get geometry, using this code
//Получаем XbimShapeInstances для данного IfcElement
List<XbimShapeInstance> shapeInsts = (from t in m_ShapeInsts // определяем каждый объект из teams как t
where t.IfcProductLabel == EntLabel //фильтрация по критерию
select t).ToList(); // выбираем объект
if (shapeInsts == null || shapeInsts.Count == 0) return;
//Обрабатываем все XbimShapeInstance данного IFCElement
foreach (var instance in shapeInsts)
{
var transfor = instance.Transformation; //Transformation matrix (location point inside)
XbimShapeGeometry geometry =
m_3DMdlContext.ShapeGeometry(instance); //Instance geometry
XbimRect3D box = geometry.BoundingBox; //bounding box you need
byte[] data = ((IXbimShapeGeometryData)geometry).ShapeData;
//Получим сетку треугольников
using (var stream = new MemoryStream(data))
{
using (var reader = new BinaryReader(stream))
{
var mesh = reader.ReadShapeTriangulation();
List<XbimFaceTriangulation> faces = mesh.Faces as
List<XbimFaceTriangulation>;
List<XbimPoint3D> vertices = mesh.Vertices as List<XbimPoint3D>;
}
}
}
But result is not quite correct.

I suppose I have to use transfor matrix. But I don't know how to do it right. Thanks for the answers.
See the code here.
I applied this code
var mesh = reader.ReadShapeTriangulation();
mesh.Transform(transfor);
but result is still the same(
var mesh = reader.ReadShapeTriangulation();
mesh = mesh.Transform(transfor);