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 import BasicViewer 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 = BasicViewer() v.add(bop.Shape()) v.start()
# fn = './models/wingbox.brep' # fn = './models/fuselage_structure.brep' fn = './models/wing_body.brep' shape = ExchangeBasic.read_brep(fn) gen = SMESH_Gen() mesh = gen.CreateMesh(0, True) assert isinstance(mesh, SMESH_Mesh) mesh.ShapeToMesh(shape) mg_hyp = BLSURFPlugin_Hypothesis(0, 0, gen, True) mg_alg = BLSURFPlugin_BLSURF(1, 0, gen, True) mg_hyp.SetPhySize(4) mg_hyp.SetQuadAllowed(True) mesh.AddHypothesis(mesh.GetShapeToMesh(), 0) mesh.AddHypothesis(mesh.GetShapeToMesh(), 1) print('Computing mesh...') start = time.time() done = gen.Compute(mesh, mesh.GetShapeToMesh()) print('done in ', time.time() - start, ' seconds.') v = BasicViewer() v.add(mesh) v.start()
# 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 import BasicViewer cheese = ExchangeBasic.read_step('./models/cheese.stp') planes = ExchangeBasic.read_step('./models/planes.stp') v = BasicViewer() 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) print('Complete in ', time.time() - start, ' seconds.')
# 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 import BasicViewer # 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 = BasicViewer() # 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()