Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement