public void LoadGeometricRepresentation(List <DtObject> elements) { try { foreach (var elem in elements) { if (elem.Id != Guid.Empty) { _controller.IntBase.ApiCore.DtObjects.GetObjectGeometryAsThreeJs(elem.Id); } if (elem.Id == Guid.Empty) { elem.Id = Guid.NewGuid(); } var data = elem.AttributeGroups["geometry"]["picture"].ToString(); if (data != null) { var bytePolyeder = Convert.FromBase64String(data); var NULLcompress = Convert.ToInt32(elem.AttributeGroups["geometry"]["compress"]); var compress = (byte)(NULLcompress == null ? 1 : NULLcompress); CBaseElementPolyeder poly = null; try { if (Convert.ToInt32(elem.AttributeGroups["geometry"]["type"]) == 7) { poly = CsgGeometry.Create(bytePolyeder, compress); } else { poly = DeserializeVarbinaryMax.DeserializePolyeder(bytePolyeder, compress); if (poly.face.Count == 0 && poly.edge.Count > 0) { poly = Tubes.CreateTube(poly); } } } catch (Exception) { } var stringMatrix = elem.AttributeGroups["geometry"]["matrix"].ToString(); if (!string.IsNullOrEmpty(stringMatrix) && poly != null) { /* * var mat = new CMatrix(Convert.FromBase64String(stringMatrix)); * poly.MultiplyWithMatrix(mat.Values); */ } var col = elem.AttributeGroups["geometry"]["color"]; // try // { // elem.Material = col != null // ? Color.FromArgb((int) Convert.ToUInt32(col)) // : Color.Transparent; // } // catch (Exception) // { // baseElem.Material = col != null ? Color.FromArgb(Convert.ToInt32(col)) : Color.Transparent; // } // // if (col == null || baseElem.Material == Color.FromArgb(255, 128, 128, 128)) // { // if (poly != null) // { // baseElem.Material = poly.IsSpecialColorDefined() // ? Color.FromArgb((int) poly.GetSpecialColor()) // : Color.FromArgb(255, 128, 128, 128); // } // else // baseElem.Material = Color.FromArgb(255, 128, 128, 128); // } // // if (poly != null) // { // poly.ID = baseElem.Id; // baseElem.Polyeder = poly; // poly.Radius = null; // poly.Bendingrolle = null; // } // else // { // Debug.Print( // $"Invalid geometry for {((GenericElement) baseElem).TypeName} with ID {baseElem.Id}!"); // } } // elem.LoadState |= ElementLoadState.GeometryLoaded; } } catch (OperationCanceledException) { } }