mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-28 11:18:18 +00:00
Don't load OCC upon startup, in preparation for deprecation when IfcConvert can handle #1153. See #1400 and #1358.
This commit is contained in:
@@ -6,7 +6,10 @@ import numpy
|
|||||||
import pickle
|
import pickle
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
|
|
||||||
try:
|
|
||||||
|
def load_occ():
|
||||||
|
# Don't import until we really need to, as a temporary step before we can purge OCC
|
||||||
|
try:
|
||||||
from OCC.Core import (
|
from OCC.Core import (
|
||||||
gp,
|
gp,
|
||||||
Geom,
|
Geom,
|
||||||
@@ -37,7 +40,7 @@ try:
|
|||||||
IntCurvesFace,
|
IntCurvesFace,
|
||||||
)
|
)
|
||||||
from OCC.Core.TopoDS import topods
|
from OCC.Core.TopoDS import topods
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from OCC import (
|
from OCC import (
|
||||||
gp,
|
gp,
|
||||||
Geom,
|
Geom,
|
||||||
@@ -79,6 +82,7 @@ this_file = os.path.join(cwd, "cut_ifc.py")
|
|||||||
|
|
||||||
|
|
||||||
def get_booleaned_edges(shape):
|
def get_booleaned_edges(shape):
|
||||||
|
load_occ()
|
||||||
edges = []
|
edges = []
|
||||||
exp = TopExp.TopExp_Explorer(shape, TopAbs.TopAbs_EDGE)
|
exp = TopExp.TopExp_Explorer(shape, TopAbs.TopAbs_EDGE)
|
||||||
while exp.More():
|
while exp.More():
|
||||||
@@ -88,6 +92,7 @@ def get_booleaned_edges(shape):
|
|||||||
|
|
||||||
|
|
||||||
def connect_edges_into_wires(unconnected_edges):
|
def connect_edges_into_wires(unconnected_edges):
|
||||||
|
load_occ()
|
||||||
edges = TopTools.TopTools_HSequenceOfShape()
|
edges = TopTools.TopTools_HSequenceOfShape()
|
||||||
edges_handle = TopTools.Handle_TopTools_HSequenceOfShape(edges)
|
edges_handle = TopTools.Handle_TopTools_HSequenceOfShape(edges)
|
||||||
wires = TopTools.TopTools_HSequenceOfShape()
|
wires = TopTools.TopTools_HSequenceOfShape()
|
||||||
@@ -101,6 +106,7 @@ def connect_edges_into_wires(unconnected_edges):
|
|||||||
|
|
||||||
|
|
||||||
def do_cut(process_data):
|
def do_cut(process_data):
|
||||||
|
load_occ()
|
||||||
global_id, shape, section, trsf_data = process_data
|
global_id, shape, section, trsf_data = process_data
|
||||||
|
|
||||||
axis = gp.gp_Ax2(
|
axis = gp.gp_Ax2(
|
||||||
@@ -320,6 +326,7 @@ class IfcCutter:
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def create_section_box(self):
|
def create_section_box(self):
|
||||||
|
load_occ()
|
||||||
top_left_corner = gp.gp_Pnt(
|
top_left_corner = gp.gp_Pnt(
|
||||||
self.section_box["top_left_corner"][0],
|
self.section_box["top_left_corner"][0],
|
||||||
self.section_box["top_left_corner"][1],
|
self.section_box["top_left_corner"][1],
|
||||||
@@ -350,6 +357,7 @@ class IfcCutter:
|
|||||||
self.transformation.SetDisplacement(source, destination)
|
self.transformation.SetDisplacement(source, destination)
|
||||||
|
|
||||||
def get_bbox(self, shape):
|
def get_bbox(self, shape):
|
||||||
|
load_occ()
|
||||||
bbox = Bnd.Bnd_Box()
|
bbox = Bnd.Bnd_Box()
|
||||||
BRepBndLib.brepbndlib_Add(shape, bbox)
|
BRepBndLib.brepbndlib_Add(shape, bbox)
|
||||||
return bbox
|
return bbox
|
||||||
@@ -361,6 +369,7 @@ class IfcCutter:
|
|||||||
return zpos, zmax
|
return zpos, zmax
|
||||||
|
|
||||||
def get_booleaned_edges(self, shape):
|
def get_booleaned_edges(self, shape):
|
||||||
|
load_occ()
|
||||||
edges = []
|
edges = []
|
||||||
exp = TopExp.TopExp_Explorer(shape, TopAbs.TopAbs_EDGE)
|
exp = TopExp.TopExp_Explorer(shape, TopAbs.TopAbs_EDGE)
|
||||||
while exp.More():
|
while exp.More():
|
||||||
@@ -377,6 +386,7 @@ class IfcCutter:
|
|||||||
|
|
||||||
def get_annotation(self):
|
def get_annotation(self):
|
||||||
import mathutils
|
import mathutils
|
||||||
|
load_occ()
|
||||||
|
|
||||||
self.annotation_objs = []
|
self.annotation_objs = []
|
||||||
settings_2d = ifcopenshell.geom.settings()
|
settings_2d = ifcopenshell.geom.settings()
|
||||||
|
|||||||
@@ -12,9 +12,12 @@ from mathutils import Vector
|
|||||||
from mathutils import geometry
|
from mathutils import geometry
|
||||||
from blenderbim.bim.ifc import IfcStore
|
from blenderbim.bim.ifc import IfcStore
|
||||||
|
|
||||||
try:
|
|
||||||
|
def load_occ():
|
||||||
|
# Don't import until we really need to, as a temporary step before we can purge OCC
|
||||||
|
try:
|
||||||
from OCC.Core import BRep, BRepTools, TopExp, TopAbs
|
from OCC.Core import BRep, BRepTools, TopExp, TopAbs
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from OCC import BRep, BRepTools, TopExp, TopAbs
|
from OCC import BRep, BRepTools, TopExp, TopAbs
|
||||||
|
|
||||||
|
|
||||||
@@ -599,6 +602,7 @@ class SvgWriter:
|
|||||||
self.draw_polygon(polygon, "cut")
|
self.draw_polygon(polygon, "cut")
|
||||||
|
|
||||||
def draw_polyline(self, element, position):
|
def draw_polyline(self, element, position):
|
||||||
|
load_occ()
|
||||||
classes = self.get_classes(element["raw"], position)
|
classes = self.get_classes(element["raw"], position)
|
||||||
exp = BRepTools.BRepTools_WireExplorer(element["geometry"])
|
exp = BRepTools.BRepTools_WireExplorer(element["geometry"])
|
||||||
points = []
|
points = []
|
||||||
@@ -609,6 +613,7 @@ class SvgWriter:
|
|||||||
self.svg.add(self.svg.polyline(points=points, class_=" ".join(classes)))
|
self.svg.add(self.svg.polyline(points=points, class_=" ".join(classes)))
|
||||||
|
|
||||||
def draw_line(self, element, position):
|
def draw_line(self, element, position):
|
||||||
|
load_occ()
|
||||||
classes = self.get_classes(element["raw"], position)
|
classes = self.get_classes(element["raw"], position)
|
||||||
exp = TopExp.TopExp_Explorer(element["geometry"], TopAbs.TopAbs_VERTEX)
|
exp = TopExp.TopExp_Explorer(element["geometry"], TopAbs.TopAbs_VERTEX)
|
||||||
points = []
|
points = []
|
||||||
|
|||||||
Reference in New Issue
Block a user