Exemple #1
0
 def test_discretize_edge(self):
     tor = BRepPrimAPI_MakeTorus(50, 20).Shape()
     topo = TopologyExplorer(tor)
     for edge in topo.edges():
         pnts = discretize_edge(edge)
         self.assertTrue(pnts)
t2 = time.monotonic()
t_multi.Compute(parallel=True, mesh_quality=0.5)
t3 = time.monotonic()
delta_multi = t3 - t2

print("Test 1 Results:")
print("  * single thread runtime: %.2fs" % delta_single)
print("  * multi thread runtime: %.2fs" % delta_multi)
print("  * muti/single=%.2f%%" % (delta_multi / delta_single * 100))

# TEST 2 : other step, with a loop over each subshape
print("TEST 2 ===")
shp3 = read_step_file(step_file)
shp4 = read_step_file(step_file)

topo1 = TopologyExplorer(shp3)
t4 = time.monotonic()
for solid in topo1.solids():
    o = Tesselator(solid)
    o.Compute(parallel=False, mesh_quality=0.5)
t5 = time.monotonic()
delta_single = t5 - t4

topo2 = TopologyExplorer(shp4)
t6 = time.monotonic()
for solid in topo2.solids():
    o = Tesselator(solid)
    o.Compute(parallel=True, mesh_quality=0.5)
t7 = time.monotonic()
delta_multi = t7 - t6
Exemple #3
0
from OCC.Core.BRepPrimAPI import BRepPrimAPI_MakeTorus, BRepPrimAPI_MakeBox
from OCC.Extend.TopologyUtils import (TopologyExplorer, WireExplorer,
                                      discretize_edge, discretize_wire)
from OCC.Core.TopoDS import TopoDS_Face, TopoDS_Edge


def get_test_box_shape():
    return BRepPrimAPI_MakeBox(10, 20, 30).Shape()


def get_test_sphere_shape():
    return BRepPrimAPI_MakeSphere(10.).Shape()


topo = TopologyExplorer(get_test_box_shape())


class TestExtendTopology(unittest.TestCase):
    def test_discretize_edge(self):
        tor = BRepPrimAPI_MakeTorus(50, 20).Shape()
        topo = TopologyExplorer(tor)
        for edge in topo.edges():
            pnts = discretize_edge(edge)
            self.assertTrue(pnts)

    def test_discretize_wire(self):
        tor = BRepPrimAPI_MakeTorus(50, 20).Shape()
        topo = TopologyExplorer(tor)
        for wire in topo.wires():
            pnts = discretize_wire(wire)
# 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 pythonOCC.  If not, see <http://www.gnu.org/licenses/>.

from __future__ import print_function

from random import random

from OCCT.AIS import AIS_ColoredShape
from OCCT.BRepPrimAPI import BRepPrimAPI_MakeBox
from OCC.Display.OCCViewer import rgb_color
from OCC.Display.SimpleGui import init_display
from OCC.Extend.TopologyUtils import TopologyExplorer

display, start_display, add_menu, add_function_to_menu = init_display()

my_box = BRepPrimAPI_MakeBox(10., 20., 30.).Shape()

ais_shp = AIS_ColoredShape(my_box)

for fc in TopologyExplorer(my_box).faces():
    # set a custom color per-face
    ais_shp.SetCustomColor(fc, rgb_color(random(), random(), random()))

display.Context.Display(ais_shp, True)
display.FitAll()

start_display()