Пример #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
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
from OCCT.NETGENPlugin import (NETGENPlugin_SimpleHypothesis_3D,
                               NETGENPlugin_NETGEN_2D3D)
from OCCT.SMESH import SMESH_Gen

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

fn = './models/shape_names.step'
shape = ExchangeBasic.read_step(fn)

v = ViewerWx()
v.add(shape)
v.start()

gen = SMESH_Gen()
mesh = gen.CreateMesh(0, True)

hyp = NETGENPlugin_SimpleHypothesis_3D(0, 0, gen)
hyp.SetLocalLength(5)

alg = NETGENPlugin_NETGEN_2D3D(1, 0, gen)

mesh.ShapeToMesh(shape)
mesh.AddHypothesis(shape, 0)
mesh.AddHypothesis(shape, 1)
Пример #3
0
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
import time

from OCCT.BOPAlgo import BOPAlgo_Options
from OCCT.BRepAlgoAPI import BRepAlgoAPI_Common

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

cheese = ExchangeBasic.read_step('./models/cheese.stp')
planes = ExchangeBasic.read_step('./models/planes.stp')

v = ViewerWx()
v.add(cheese, planes)
v.start()
v.clear()

# Basic operation takes about 32 seconds
print('Starting Boolean operation...')
start = time.time()
BRepAlgoAPI_Common(cheese, planes)
print('Complete in ', time.time() - start, ' seconds.')

# Run in parallel. Should take 10 to 11 seconds on 4 cores
BOPAlgo_Options.SetParallelMode_(True)
print('Starting Boolean operation...')
start = time.time()
bop = BRepAlgoAPI_Common(cheese, planes)
Пример #4
0
# geometry kernel.
#
# Copyright (C) 2016-2018  Laughlin Research, LLC ([email protected])
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
from OCCT.Graphic3d import Graphic3d_NOM_ALUMINIUM
from OCCT.STEPControl import STEPControl_Reader

from OCCT.Visualization.WxViewer import ViewerWx

reader = STEPControl_Reader()
reader.ReadFile('./models/compressor.step')
reader.TransferRoots()
shape = reader.OneShape()

v = ViewerWx()
v.display_shape(shape, rgb=(0.5, 0.5, 0.5), material=Graphic3d_NOM_ALUMINIUM)
v.start()
Пример #5
0
# License along with this library; if not, write to the Free Software
# 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()