diff --git a/Xbim.Geometry.Engine.Interop/Xbim.Geometry.Engine.Interop.csproj b/Xbim.Geometry.Engine.Interop/Xbim.Geometry.Engine.Interop.csproj index 6d162d834..2dbb95965 100644 --- a/Xbim.Geometry.Engine.Interop/Xbim.Geometry.Engine.Interop.csproj +++ b/Xbim.Geometry.Engine.Interop/Xbim.Geometry.Engine.Interop.csproj @@ -50,7 +50,7 @@ - + diff --git a/Xbim.Geometry.Engine.Interop/XbimCustomAssemblyResolver.cs b/Xbim.Geometry.Engine.Interop/XbimCustomAssemblyResolver.cs index 37338fdd3..261e2a341 100644 --- a/Xbim.Geometry.Engine.Interop/XbimCustomAssemblyResolver.cs +++ b/Xbim.Geometry.Engine.Interop/XbimCustomAssemblyResolver.cs @@ -40,8 +40,8 @@ private static Assembly ProbeForAssembly(string moduleName) { _logger.LogDebug("Getting probing path from executing assembly"); Assembly assembly = Assembly.GetExecutingAssembly(); // The Xbim.Geometry.Engine.Interop assembly - // code base always points to the deployed DLL, which may be different to the executing Location because of Shadow Copying in the AppDomain (e.g. ASP.NET) - var codepath = new Uri(assembly.CodeBase); + // Location always points to the deployed DLL, which may be different to the executing Location because of Shadow Copying in the AppDomain (e.g. ASP.NET) + var codepath = new Uri(assembly.Location); // Unlike Assembly.Location, CodeBase is a URI [file:\\c:\wwwroot\etc\WebApp\bin\Xbim.Geometry.Engine.Interop.dll] appDir = Path.GetDirectoryName(codepath.LocalPath); } diff --git a/Xbim.Geometry.Engine.Interop/XbimGeometryEngine.cs b/Xbim.Geometry.Engine.Interop/XbimGeometryEngine.cs index bc1988e72..7f0ec85cd 100644 --- a/Xbim.Geometry.Engine.Interop/XbimGeometryEngine.cs +++ b/Xbim.Geometry.Engine.Interop/XbimGeometryEngine.cs @@ -34,8 +34,6 @@ public XbimGeometryEngine(ILogger logger) { _logger = logger ?? XbimLogging.CreateLogger(); - // Warn if runtime for Engine is not present, this is not necessary any more as we are net47 - #if DELAY_LOAD var conventions = new XbimArchitectureConventions(); // understands the process we run under @@ -818,6 +816,18 @@ public string ToBrep(IXbimGeometryObject geometryObject) } } + public void WriteBrep(string filename, IXbimGeometryObject geomObj) + { + // no logger is provided so no tracing is started for this function + _engine.WriteBrep(filename, geomObj); + } + + public IXbimGeometryObject ReadBrep(string filename) + { + // no logger is provided so no tracing is started for this function + return _engine.ReadBrep(filename); + } + public IXbimSolidSet CreateSolidSet(IIfcSweptAreaSolid ifcSolid, ILogger logger = null) { using (new Tracer(LogHelper.CurrentFunctionName(), this._logger, ifcSolid)) diff --git a/Xbim.Geometry.Engine/OCC/src/BRepTools/BRepTools_WireExplorer.cxx b/Xbim.Geometry.Engine/OCC/src/BRepTools/BRepTools_WireExplorer.cxx index 1fe412abe..263f8dfa7 100644 --- a/Xbim.Geometry.Engine/OCC/src/BRepTools/BRepTools_WireExplorer.cxx +++ b/Xbim.Geometry.Engine/OCC/src/BRepTools/BRepTools_WireExplorer.cxx @@ -751,6 +751,9 @@ Standard_Real GetNextParamOnPC(const Handle(Geom2d_Curve)& aPC, { Standard_Real result = ( reverse ) ? fP : lP; Standard_Real dP = Abs( lP - fP ) / 1000.; // was / 16.; + // Ensure incrememt is large enough to effect startPar + Standard_Real resolution = Abs(fP / Pow(2, 52)); + dP = Max(dP, resolution); if( reverse ) { Standard_Real startPar = fP; diff --git a/Xbim.Geometry.Engine/OCC/src/ShapeUpgrade/ShapeUpgrade_UnifySameDomain.cxx b/Xbim.Geometry.Engine/OCC/src/ShapeUpgrade/ShapeUpgrade_UnifySameDomain.cxx index 010386c99..613ac1443 100644 --- a/Xbim.Geometry.Engine/OCC/src/ShapeUpgrade/ShapeUpgrade_UnifySameDomain.cxx +++ b/Xbim.Geometry.Engine/OCC/src/ShapeUpgrade/ShapeUpgrade_UnifySameDomain.cxx @@ -315,10 +315,12 @@ static void RelocatePCurvesToNewUorigin(const TopTools_SequenceOfShape& theEdges for (;;) //collect pcurves of a contour { RemoveEdgeFromMap(CurEdge, theVEmap); - theUsedEdges.Add(CurEdge); + Standard_Boolean notUsed = theUsedEdges.Add(CurEdge); + if (!notUsed) + break; TopoDS_Vertex CurVertex = (anOr == TopAbs_FORWARD)? TopExp::LastVertex(CurEdge, Standard_True) : TopExp::FirstVertex(CurEdge, Standard_True); - + const TopTools_ListOfShape& Elist = theVEmap.FindFromKey(CurVertex); if (Elist.IsEmpty()) break; //end of contour in 3d diff --git a/Xbim.Geometry.Engine/XbimFace.cpp b/Xbim.Geometry.Engine/XbimFace.cpp index 3594691ca..b5321ffac 100644 --- a/Xbim.Geometry.Engine/XbimFace.cpp +++ b/Xbim.Geometry.Engine/XbimFace.cpp @@ -1780,38 +1780,33 @@ namespace Xbim //trim 1 and trim 2 will be cartesian points IIfcCartesianPoint^ trim1 = dynamic_cast(Enumerable::FirstOrDefault(tc->Trim1)); IIfcCartesianPoint^ trim2 = dynamic_cast(Enumerable::FirstOrDefault(tc->Trim2)); - gp_Pnt p1 = XbimConvert::GetPoint3d(trim1); - gp_Pnt p2 = XbimConvert::GetPoint3d(trim2); - //there are two solutions A, B - //calc solution A - double radsq = circle->Radius * circle->Radius; - double qX = System::Math::Sqrt(((p2.X() - p1.X()) * (p2.X() - p1.X())) + ((p2.Y() - p1.Y()) * (p2.Y() - p1.Y()))); - double x3 = (p1.X() + p2.X()) / 2; - double centreX = x3 - System::Math::Sqrt(radsq - ((qX / 2) * (qX / 2))) * ((p1.Y() - p2.Y()) / qX); - - double qY = System::Math::Sqrt(((p2.X() - p1.X()) * (p2.X() - p1.X())) + ((p2.Y() - p1.Y()) * (p2.Y() - p1.Y()))); - - double y3 = (p1.Y() + p2.Y()) / 2; - - double centreY = y3 - System::Math::Sqrt(radsq - ((qY / 2) * (qY / 2))) * ((p2.X() - p1.X()) / qY); - - - - ITransaction^ txn = sLin->Model->BeginTransaction("Fix Centre"); - - - IIfcPlacement^ p = dynamic_cast(circle->Position); - - p->Location->Coordinates[0] = centreX; - p->Location->Coordinates[1] = centreY; - p->Location->Coordinates[2] = 0; - - xbasisEdge1 = gcnew XbimEdge(sLin->SweptCurve, logger); - txn->RollBack(); - isFixed = true; + if (trim1 != nullptr && trim2 != nullptr) + { + gp_Pnt p1 = XbimConvert::GetPoint3d(trim1); + gp_Pnt p2 = XbimConvert::GetPoint3d(trim2); + //there are two solutions A, B + //calc solution A + double radsq = circle->Radius * circle->Radius; + double qX = System::Math::Sqrt(((p2.X() - p1.X()) * (p2.X() - p1.X())) + ((p2.Y() - p1.Y()) * (p2.Y() - p1.Y()))); + double x3 = (p1.X() + p2.X()) / 2; + double centreX = x3 - System::Math::Sqrt(radsq - ((qX / 2) * (qX / 2))) * ((p1.Y() - p2.Y()) / qX); + + double qY = System::Math::Sqrt(((p2.X() - p1.X()) * (p2.X() - p1.X())) + ((p2.Y() - p1.Y()) * (p2.Y() - p1.Y()))); + double y3 = (p1.Y() + p2.Y()) / 2; + double centreY = y3 - System::Math::Sqrt(radsq - ((qY / 2) * (qY / 2))) * ((p2.X() - p1.X()) / qY); + + ITransaction^ txn = sLin->Model->BeginTransaction("Fix Centre"); + + IIfcPlacement^ p = dynamic_cast(circle->Position); + p->Location->Coordinates[0] = centreX; + p->Location->Coordinates[1] = centreY; + p->Location->Coordinates[2] = 0; + + xbasisEdge1 = gcnew XbimEdge(sLin->SweptCurve, logger); + txn->RollBack(); + isFixed = true; + } } - - } if (!isFixed) //just build it xbasisEdge1 = gcnew XbimEdge(sLin->SweptCurve, logger); diff --git a/Xbim.Geometry.Engine/XbimGeometryCreator.cpp b/Xbim.Geometry.Engine/XbimGeometryCreator.cpp index 510ed6168..5394bc057 100644 --- a/Xbim.Geometry.Engine/XbimGeometryCreator.cpp +++ b/Xbim.Geometry.Engine/XbimGeometryCreator.cpp @@ -99,7 +99,21 @@ namespace Xbim LoggerExtensions::LogDebug(logger, "GeomEngine: {0} [{1}]", entity->GetType()->Name, msg); } } + + void XbimGeometryCreator::WriteBrep(System::String^ filename, IXbimGeometryObject^ geomObj) + { + throw gcnew System::NotImplementedException(); + // TODO: This is stubbed out until we merge the implementation from unpushed code. + // temp fix for broken build + } + IXbimGeometryObject^ XbimGeometryCreator::ReadBrep(System::String^ filename) + { + throw gcnew System::NotImplementedException(); + // TODO: This is stubbed out until we merge the implementation from unpushed code. + // temp fix for broken build + } + void XbimGeometryCreator::LogError(ILogger^ logger, Object^ entity, System::String^ format, ...array^ arg) { System::String^ msg = System::String::Format(format, arg); @@ -287,6 +301,11 @@ namespace Xbim LogError(logger, geomRep, "Error creating geometry #{2} representation of type {0}, {1}", geomRep->GetType()->Name, err, geomRep->EntityLabel); return XbimGeometryObjectSet::Empty; } + catch (System::Exception^ exc) + { + LogError(logger, geomRep, "Error creating geometry #{2} representation of type {0}, {1}", geomRep->GetType()->Name, exc, geomRep->EntityLabel); + return XbimGeometryObjectSet::Empty; + } //catch () catch (...) { diff --git a/Xbim.Geometry.Engine/XbimGeometryCreator.h b/Xbim.Geometry.Engine/XbimGeometryCreator.h index 1e0aa9696..2b5cded49 100644 --- a/Xbim.Geometry.Engine/XbimGeometryCreator.h +++ b/Xbim.Geometry.Engine/XbimGeometryCreator.h @@ -23,7 +23,7 @@ namespace Xbim public ref class XbimGeometryCreator : IXbimGeometryEngine { - static Assembly^ ResolveHandler(Object^ /*Sender*/, System::ResolveEventArgs^ /*args*/) + static Assembly^ ResolveHandler(Object^ /*Sender*/, System::ResolveEventArgs^ /*args*/) { // Warning: this should check the args for the assembly name! @@ -80,6 +80,9 @@ namespace Xbim static void LogError(ILogger^ logger, Object^ entity, System::String^ format, ... array^ arg); static void LogDebug(ILogger^ logger, Object^ entity, System::String^ format, ... array^ arg); + virtual void WriteBrep(System::String^ filename, IXbimGeometryObject^ geomObj); + virtual IXbimGeometryObject^ ReadBrep(System::String^ filename); + static int BooleanTimeOut; static double FuzzyFactor; static double LinearDeflectionInMM; @@ -90,7 +93,7 @@ namespace Xbim virtual XbimShapeGeometry^ CreateShapeGeometry(IXbimGeometryObject^ geometryObject, double precision, double deflection, ILogger^ logger/*, double angle = 0.5, XbimGeometryType storageType = XbimGeometryType::Polyhedron*/) { - return CreateShapeGeometry(geometryObject, precision, deflection, 0.5, XbimGeometryType::PolyhedronBinary,logger); + return CreateShapeGeometry(geometryObject, precision, deflection, 0.5, XbimGeometryType::PolyhedronBinary, logger); }; virtual XbimShapeGeometry^ CreateShapeGeometry(double oneMillimetre, IXbimGeometryObject^ geometryObject, double precision, ILogger^ logger) @@ -242,9 +245,9 @@ namespace Xbim { return Moved(geometryObject, (IIfcPlacement ^)placement); }; - virtual IXbimGeometryObject ^ Moved(IXbimGeometryObject ^geometryObject, IIfcAxis2Placement2D ^placement) + virtual IXbimGeometryObject^ Moved(IXbimGeometryObject^ geometryObject, IIfcAxis2Placement2D^ placement) { - return Moved(geometryObject, (IIfcPlacement ^)placement); + return Moved(geometryObject, (IIfcPlacement^)placement); }; virtual IXbimGeometryObject ^ Moved(IXbimGeometryObject ^geometryObject, IIfcObjectPlacement ^objectPlacement, ILogger^ logger); virtual IXbimGeometryObject^ FromBrep(System::String^ brepStr); diff --git a/Xbim.Geometry.Engine/XbimSolid.cpp b/Xbim.Geometry.Engine/XbimSolid.cpp index 422f30523..ea1712fa2 100644 --- a/Xbim.Geometry.Engine/XbimSolid.cpp +++ b/Xbim.Geometry.Engine/XbimSolid.cpp @@ -1307,9 +1307,9 @@ namespace Xbim { //BRepTools::Write(revol.Shape(), "d:\\tmp\\rev"); pSolid = new TopoDS_Solid(); + *pSolid = TopoDS::Solid(revol.Shape()); if (repItem->Position != nullptr) - *pSolid = TopoDS::Solid(revol.Shape()); - pSolid->Move(XbimConvert::ToLocation(repItem->Position)); + pSolid->Move(XbimConvert::ToLocation(repItem->Position)); ShapeFix_ShapeTolerance tolFixer; tolFixer.LimitTolerance(*pSolid, repItem->Model->ModelFactors->Precision); } diff --git a/Xbim.Geometry.Engine/XbimSolidSet.cpp b/Xbim.Geometry.Engine/XbimSolidSet.cpp index 165bc0e4f..4cdc48ea1 100644 --- a/Xbim.Geometry.Engine/XbimSolidSet.cpp +++ b/Xbim.Geometry.Engine/XbimSolidSet.cpp @@ -1055,7 +1055,9 @@ namespace Xbim if (dynamic_cast(bOp) && bOp->GetType()->Name->Contains("IfcHalfSpaceSolid") || dynamic_cast(bOp) && bOp->GetType()->Name->Contains("IfcPolygonalBoundedHalfSpace")) { - bodySet = (XbimSolidSet^)bodySet->Cut(s, mf->Precision, logger); + XbimSolidSet^ bodySetCut = (XbimSolidSet^)bodySet->Cut(s, mf->Precision, logger); + if (bodySetCut->IsValid) + bodySet = bodySetCut; } else solidSet->Add(s); diff --git a/Xbim.Geometry.Engine/XbimWire.cpp b/Xbim.Geometry.Engine/XbimWire.cpp index 35c45dc29..5bcc9003f 100644 --- a/Xbim.Geometry.Engine/XbimWire.cpp +++ b/Xbim.Geometry.Engine/XbimWire.cpp @@ -236,27 +236,28 @@ namespace Xbim pWire = new TopoDS_Wire(); if (profile->ProfileType == IfcProfileTypeEnum::AREA && !loop->IsClosed) //need to make sure it is not self intersecting and it is closed area { - // todo: this code is not quite robust, it did not manage to close fairly simple polylines. try { - - double oneMilli = profile->Model->ModelFactors->OneMilliMeter; - TopoDS_Face face = gcnew XbimFace(loop, true, oneMilli, profile->OuterCurve->EntityLabel, logger); - ShapeFix_Wire wireFixer(loop, face, profile->Model->ModelFactors->Precision); - wireFixer.ClosedWireMode() = Standard_True; - wireFixer.FixGaps2dMode() = Standard_True; - wireFixer.FixGaps3dMode() = Standard_True; - wireFixer.ModifyGeometryMode() = Standard_True; - wireFixer.SetMinTolerance(profile->Model->ModelFactors->Precision); - wireFixer.SetPrecision(oneMilli); - wireFixer.SetMaxTolerance(oneMilli * 10); - Standard_Boolean closed = wireFixer.Perform(); - if (closed) - *pWire = wireFixer.Wire(); - else - *pWire = loop; + XbimFace^ xbimFace = gcnew XbimFace(loop, true, oneMilli, profile->OuterCurve->EntityLabel, logger); + if (xbimFace->IsValid) + { + TopoDS_Face face = xbimFace; + ShapeFix_Wire wireFixer(loop, face, profile->Model->ModelFactors->Precision); + wireFixer.ClosedWireMode() = Standard_True; + wireFixer.FixGaps2dMode() = Standard_True; + wireFixer.FixGaps3dMode() = Standard_True; + wireFixer.ModifyGeometryMode() = Standard_True; + wireFixer.SetMinTolerance(profile->Model->ModelFactors->Precision); + wireFixer.SetPrecision(oneMilli); + wireFixer.SetMaxTolerance(oneMilli * 10); + Standard_Boolean closed = wireFixer.Perform(); + if (closed) + *pWire = wireFixer.Wire(); + else + *pWire = loop; + } } catch (Standard_Failure sf) { diff --git a/Xbim.Geometry.Packages/Xbim.Geometry.Packages.csproj b/Xbim.Geometry.Packages/Xbim.Geometry.Packages.csproj index c04935130..944479847 100644 --- a/Xbim.Geometry.Packages/Xbim.Geometry.Packages.csproj +++ b/Xbim.Geometry.Packages/Xbim.Geometry.Packages.csproj @@ -13,7 +13,7 @@ - + diff --git a/Xbim.Geometry.Regression/BatchProcessor.cs b/Xbim.Geometry.Regression/BatchProcessor.cs index 9db7d1119..2a3dd32ba 100644 --- a/Xbim.Geometry.Regression/BatchProcessor.cs +++ b/Xbim.Geometry.Regression/BatchProcessor.cs @@ -6,6 +6,7 @@ using System.IO; using System.Linq; using Xbim.Common; +using Xbim.Geometry.Engine.Interop; using Xbim.Ifc; using Xbim.Ifc4.Interfaces; using Xbim.IO.Memory; @@ -121,7 +122,6 @@ private ProcessResult ProcessFile(string ifcFile, StreamWriter writer, ILogger(); + + var exportBrepByType = new string[] + { + "IfcFacetedBrep", + // IIfcGeometricRepresentationItem + "IfcCsgSolid", + "IfcExtrudedAreaSolid", + "IfcExtrudedAreaSolidTapered", + "IfcFixedReferenceSweptAreaSolid", + "IfcRevolvedAreaSolid", + "IfcRevolvedAreaSolidTapered", + "IfcSurfaceCurveSweptAreaSolid", + "IfcSectionedSolidHorizontal", + "IfcSweptDiskSolid", + "IfcSweptDiskSolidPolygonal", + "IfcBooleanResult", + "IfcBooleanClippingResult", + // composing objects + "IfcConnectedFaceSet" + }; + + foreach (var type in exportBrepByType) + { + ents.AddRange(s.Instances.OfType(type, false)); + } + foreach (var ent in ents) + { + try + { + Xbim.Common.Geometry.IXbimGeometryObject created = null; + if (ent is IIfcGeometricRepresentationItem igri) + created = engine.Create(igri); + if (ent is IIfcConnectedFaceSet icfs) + created = engine.CreateShell(icfs); + // IIfcConnectedFaceSet + if (created != null) + { + var brep = engine.ToBrep(created); + var brepFileName = Path.Combine(path, $"{ent.EntityLabel}.{ent.GetType().Name}.brep"); + using (var tw = File.CreateText(brepFileName)) + { + tw.WriteLine("DBRep_DrawableShape"); + tw.WriteLine(brep); + } + } + } + catch (Exception ex) + { + Console.WriteLine($"Error writing brep {ent.EntityLabel}: {ex.Message}"); + } + } + } + } + if (_params.Caching) { IfcStore s = ((IfcStore)model); - s.SaveAs(xbimFilename, Xbim.IO.StorageType.Xbim); - s.Close(); + if (s != null) + { + s.SaveAs(xbimFilename, Xbim.IO.StorageType.Xbim); + s.Close(); + } } } } diff --git a/Xbim.Geometry.Regression/Params.cs b/Xbim.Geometry.Regression/Params.cs index 4c8bc3f5f..82fd04d22 100644 --- a/Xbim.Geometry.Regression/Params.cs +++ b/Xbim.Geometry.Regression/Params.cs @@ -11,15 +11,13 @@ namespace XbimRegression /// public class Params { - public int MaxThreads; private const int DefaultTimeout = 1000 * 60 * 20; // 20 mins public bool Caching; + public bool WriteBreps = false; public bool GeometryV1; - - public Params(string[] args) { if (args.Length < 1) @@ -38,7 +36,6 @@ public Params(string[] args) } Timeout = DefaultTimeout; - CompoundParameter paramType = CompoundParameter.None; foreach (string arg in args.Skip(1)) @@ -51,6 +48,9 @@ public Params(string[] args) case "/singlethread": MaxThreads = 1; break; + case "/writebreps": + WriteBreps = true; + break; case "/timeout": paramType = CompoundParameter.Timeout; break; @@ -68,7 +68,6 @@ public Params(string[] args) break; } break; - case CompoundParameter.Timeout: int timeout; if (int.TryParse(arg, out timeout)) @@ -86,16 +85,13 @@ public Params(string[] args) paramType = CompoundParameter.None; break; } - } - IsValid = true; - } private static void WriteSyntax() { - Console.WriteLine("Syntax: XbimRegression [/timeout ]"); + Console.WriteLine("Syntax: XbimRegression [/timeout ] [/maxthreads ] [/singlethread] /writebreps"); } /// @@ -122,6 +118,4 @@ private enum CompoundParameter CachingOn }; } - - } diff --git a/Xbim.Geometry.Regression/XbimRegression.csproj b/Xbim.Geometry.Regression/XbimRegression.csproj index 13056088a..02a6a06ae 100644 --- a/Xbim.Geometry.Regression/XbimRegression.csproj +++ b/Xbim.Geometry.Regression/XbimRegression.csproj @@ -15,7 +15,7 @@ - + diff --git a/Xbim.ModelGeometry.Scene/Xbim.ModelGeometry.Scene.csproj b/Xbim.ModelGeometry.Scene/Xbim.ModelGeometry.Scene.csproj index 9cdd98c0b..1dd5da660 100644 --- a/Xbim.ModelGeometry.Scene/Xbim.ModelGeometry.Scene.csproj +++ b/Xbim.ModelGeometry.Scene/Xbim.ModelGeometry.Scene.csproj @@ -34,7 +34,7 @@ - + diff --git a/Xbim.ModelGeometry.Scene/Xbim3DModelContext.cs b/Xbim.ModelGeometry.Scene/Xbim3DModelContext.cs index d24a79dc1..794ba827c 100644 --- a/Xbim.ModelGeometry.Scene/Xbim3DModelContext.cs +++ b/Xbim.ModelGeometry.Scene/Xbim3DModelContext.cs @@ -1469,70 +1469,6 @@ private void WriteShapeGeometries(XbimCreateContextHelper contextHelper, ReportP if (progDelegate != null) progDelegate(101, "WriteShapeGeometries, (" + localTally + " written)"); } - private IXbimGeometryObject CallWithTimeout(IIfcGeometricRepresentationItem shape, ILogger logger, int booleanTimeOutMilliSeconds) - { - Thread threadToKill = null; - Func wrappedAction = () => - { - threadToKill = Thread.CurrentThread; - try - { - return Engine.Create(shape, logger); - } - catch (ThreadAbortException) - { - _logger.LogWarning("Thread aborted due to timeout"); - Thread.ResetAbort();// cancel hard aborting, lets to finish it nicely. - return null; - } - - }; - - IAsyncResult result = wrappedAction.BeginInvoke(null, null); - if (result.AsyncWaitHandle.WaitOne(booleanTimeOutMilliSeconds)) - { - var res = wrappedAction.EndInvoke(result); - result.AsyncWaitHandle.Close(); - return res; - } - else - { - threadToKill?.Abort(); - throw new TimeoutException(); - } - } - private IXbimGeometryObjectSet CutWithTimeOut(IXbimGeometryObjectSet elementGeom, IXbimSolidSet cutGeometries, double precision, int booleanTimeOutMilliSeconds) - { - Thread threadToKill = null; - Func wrappedAction = () => - { - try - { - threadToKill = Thread.CurrentThread; - return elementGeom.Cut(cutGeometries, precision); - } - catch (ThreadAbortException) - { - _logger.LogWarning("Thread aborted due to timeout"); - Thread.ResetAbort();// cancel hard aborting, lets to finish it nicely. - return null; - } - }; - - IAsyncResult result = wrappedAction.BeginInvoke(null, null); - if (result.AsyncWaitHandle.WaitOne(booleanTimeOutMilliSeconds)) - { - var res = wrappedAction.EndInvoke(result); - result.AsyncWaitHandle.Close(); - return res; - } - else - { - threadToKill?.Abort(); - throw new TimeoutException(); - } - } - private void WriteRegionsToStore(IIfcRepresentationContext context, IEnumerable elementsToCluster, IGeometryStoreInitialiser txn, XbimMatrix3D WorldCoordinateSystem) { //set up a world to partition the model diff --git a/Xbim.ModelGeometry.Scene/XbimEnvironment.cs b/Xbim.ModelGeometry.Scene/XbimEnvironment.cs index b390c9891..27e76021d 100644 --- a/Xbim.ModelGeometry.Scene/XbimEnvironment.cs +++ b/Xbim.ModelGeometry.Scene/XbimEnvironment.cs @@ -8,23 +8,6 @@ namespace Xbim.ModelGeometry { public static class XbimEnvironment { - /// - /// Tests if the requierd VC++ redist platform is installed for the current execution environment. - /// - /// true if installed - public static bool RedistInstalled(bool? overrideUse64Bit = null) - { - var use64 = Is64BitProcess(); - if (overrideUse64Bit.HasValue) - use64 = overrideUse64Bit.Value; - - var substring = use64 - ? "x64" - : "x86"; - - return InstalledRuntimes().Any(x => x.Contains(substring)); - } - /// /// Suggests the relevant download URL for the required C++ redistributable setup. /// @@ -38,37 +21,6 @@ public static string RedistDownloadPath() ? @"https://download.microsoft.com/download/2/E/6/2E61CFA4-993B-4DD4-91DA-3737CD5CD6E3/vcredist_x64.exe" : @"https://download.microsoft.com/download/2/E/6/2E61CFA4-993B-4DD4-91DA-3737CD5CD6E3/vcredist_x86.exe"; } - - /// - /// Tests for vc2013 redist installation through the registry - /// - /// A list of matching installations - public static IEnumerable InstalledRuntimes() - { - var t2 = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Default); - var t3 = t2.OpenSubKey(@"SOFTWARE\Classes\Installer\Dependencies"); - if (t3 == null) - yield break; - - foreach (var subKeyName in t3.GetSubKeyNames()) - { - var t4 = t3.OpenSubKey(subKeyName); - // ReSharper disable once UseNullPropagation - if (t4 == null) - continue; - var t5 = t4.GetValue(@"DisplayName"); - // ReSharper disable once UseNullPropagation - if (t5 == null) - continue; - var s = t5 as string; - if (s == null) - continue; - if (s.Contains(@"Microsoft Visual C++ 2013 Redistributable")) - { - yield return s; - } - } - } /// /// The function used by the underlying interop library to determin what C++ assembly to load.