Пример #1
0
from OCCT.BOPAlgo import BOPAlgo_Options
from OCCT.BRepAlgoAPI import BRepAlgoAPI_Fuse
from OCCT.TopTools import TopTools_ListOfShape

from OCCT.Exchange import ExchangeBasic
from OCCT.Visualization.WxViewer import ViewerWx

fn = './models/wing_assy.brep'
wing_assy = ExchangeBasic.read_brep(fn)

fn = './models/fuse_assy.brep'
fuse_assy = ExchangeBasic.read_brep(fn)

BOPAlgo_Options.SetParallelMode_(True)
bop = BRepAlgoAPI_Fuse()
args = TopTools_ListOfShape()
args.Append(wing_assy)
bop.SetArguments(args)
tools = TopTools_ListOfShape()
tools.Append(fuse_assy)
bop.SetTools(tools)
print('Starting fuse...')
start = time.time()
bop.Build()
print('Complete in ', time.time() - start, ' seconds.')

v = ViewerWx()
v.add(bop.Shape())
v.start()
Пример #2
0
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
from OCCT.STEPControl import STEPControl_Reader
from OCCT.TopAbs import TopAbs_FACE
from OCCT.TopExp import TopExp_Explorer

from OCCT.Visualization.WxViewer import ViewerWx

# Read the file and get the shape
reader = STEPControl_Reader()
tr = reader.WS().TransferReader()
reader.ReadFile('./models/shape_names.step')
reader.TransferRoots()
shape = reader.OneShape()

gui = ViewerWx()

# Explore the faces of the shape (these are known to be named)
exp = TopExp_Explorer(shape, TopAbs_FACE)
while exp.More():
    rgb = None
    s = exp.Current()
    exp.Next()
    item = tr.EntityFromShapeResult(s, 1)
    name = item.Name().ToCString()
    if name:
        print('Found entity: {}'.format(name))
        rgb = (1, 0, 0)
    gui.add(s, rgb)

gui.start()