Example #1
0
def main():
    s1 = cm.sphere(1.0)
    s2 = cm.box(1.0, 2.0, 3.0)
    s2.translate((2.0, 0.0, 0.0))
    v1 = cd.view()
    v1.display(s1)
    v1.display(s2)
    cd.start()
def main():
    s1 = cm.sphere(1.0)
    s2 = cm.box(1.0, 2.0, 3.0)
    s2.translate((2.0, 0.0, 0.0))
    v1 = cd.view()
    v1.display(s1)
    v1.display(s2)
    cd.start()
Example #3
0
def display_display():
    s1 = cm.sphere(1.0) + cm.box(1.0, 2.0, 2.0)
    v.display(s1,
              color=(1.0, 0.0, 0.0),
              material='metallized',
              transparency=0.5)
    v.fit()
    v.save('display_display.png')
    v.clear()
Example #4
0
def display_display():
    s1 = cm.sphere(1.0) + cm.box(1.0, 2.0, 2.0)
    v.display(s1,
              color=(1.0, 0.0, 0.0),
              material='metallized',
              transparency=0.5)
    v.fit()
    v.save('display_display.png')
    v.clear()
Example #5
0
 def test_fillet_common(self):
     s1 = cm.sphere(1.0)
     s2 = cm.box(4.0, 4.0, 4.0)
     s2.translate((0.0, -2.0, -2.0))
     s3 = cm.fillet_common(s1, s2, 0.25)
     v3 = s3.volume()
     #print v3, 0.5*4.0/3.0*math.pi*1.0**3
     # empirical
     self.assert_(close(v3,
                        0.5 * 4.0 / 3.0 * math.pi * 1.0 ** 3 - 0.127, 0.1))
Example #6
0
 def test_fillet_common(self):
     s1 = cm.sphere(1.0)
     s2 = cm.box(4.0, 4.0, 4.0)
     s2.translate((0.0, -2.0, -2.0))
     s3 = cm.fillet_common(s1, s2, 0.25)
     v3 = s3.volume()
     # print v3, 0.5*4.0/3.0*math.pi*1.0**3
     # empirical
     self.assert_(close(v3, 0.5 * 4.0 / 3.0 * math.pi * 1.0**3 - 0.127,
                        0.1))
Example #7
0
 def test_chamfer_fuse(self):
     s1 = cm.sphere(1.0)
     s2 = cm.box(4.0, 4.0, 4.0)
     s2.translate((0.0, -2.0, -2.0))
     s3 = cm.chamfer_fuse(s1, s2, 0.25)
     v3 = s3.volume()
     # print v3, 4.0*4.0*4.0 + 0.5*4.0/3.0*math.pi*1.0**3
     # empirical
     self.assert_(close(v3,
                        0.2 + 4.0 * 4.0 * 4.0 +
                        0.5 * 4.0 / 3.0 * math.pi * 1.0 ** 3, 0.1))
Example #8
0
 def test_chamfer_fuse(self):
     s1 = cm.sphere(1.0)
     s2 = cm.box(4.0, 4.0, 4.0)
     s2.translate((0.0, -2.0, -2.0))
     s3 = cm.chamfer_fuse(s1, s2, 0.25)
     v3 = s3.volume()
     #print v3, 4.0*4.0*4.0 + 0.5*4.0/3.0*math.pi*1.0**3
     # empirical
     self.assert_(close(v3,
                        0.2 + 4.0 * 4.0 * 4.0 +
                        0.5 * 4.0 / 3.0 * math.pi * 1.0 ** 3, 0.1))
Example #9
0
 def test_cut(self):
     s1 = cm.sphere(1.0)
     s2 = cm.box(2.0, 2.0, 2.0)
     s2.translate((0.0, -1.0, -1.0))
     s3 = cm.cut(s1, s2)
     v3new = s3.volume()
     s3 = cm.old_cut(s1, s2)
     v3old = s3.volume()
     s3 = s1 - s2
     v3op = s3.volume()
     value = 0.5 * 4.0 / 3.0 * math.pi * 1.0**3
     self.assert_(
         close(v3new, value) and close(v3old, value) and close(v3op, value))
Example #10
0
 def test_cut(self):
     s1 = cm.sphere(1.0)
     s2 = cm.box(2.0, 2.0, 2.0)
     s2.translate((0.0, -1.0, -1.0))
     s3 = cm.cut(s1, s2)
     v3new = s3.volume()
     s3 = cm.old_cut(s1, s2)
     v3old = s3.volume()
     s3 = s1 - s2
     v3op = s3.volume()
     value = 0.5 * 4.0 / 3.0 * math.pi * 1.0 ** 3
     self.assert_(close(v3new, value) and
                  close(v3old, value) and
                  close(v3op, value))
Example #11
0
 def test_fillet_common(self):
     s1 = cm.sphere(1.0)
     s2 = cm.box(4.0, 4.0, 4.0)
     # Issue #9:
     # Translating causes the box and the sphere to have nothing in common :
     # s2.translate((0.0, -2.0, -2.0))
     s3 = cm.fillet_common(s1, s2, 0.25)
     v3 = s3.volume()
     # empirical
     # v_sphere_inside_box = (4. / 3. * math.pi * 1**3) / 8.
     self.assert_(close(v3,
                        # 0.5 * 4.0 / 3.0 * math.pi * 1.0 ** 3 - 0.127,
                        0.463309,
                        0.1))
Example #12
0
 def test_common(self):
     s1 = cm.sphere(1.0)
     # v1 = s1.volume()
     _ = s1.volume()  # TODO : is this useful?
     s2 = cm.box(2.0, 2.0, 2.0)
     s2.translate((0.0, -1.0, -1.0))
     s3 = cm.common(s1, s2)
     v3new = s3.volume()
     s3 = cm.old_common(s1, s2)
     v3old = s3.volume()
     s3 = s1 & s2
     v3op = s3.volume()
     value = 0.5 * 4.0 / 3.0 * math.pi * 1.0 ** 3
     self.assert_(close(v3new, value) and
                  close(v3old, value) and
                  close(v3op, value))
Example #13
0
 def test_translated(self):
     delta = (0.1, 0.2, 0.3)
     s1 = cm.sphere(1.0)
     s2 = cm.translated(s1, delta)
     self.assert_(close(s2.center(), delta))
Example #14
0
 def test_sphere(self):
     s1 = cm.sphere(5.0)
     self.assert_(close(4.0 / 3.0 * math.pi * 5**3, s1.volume()))
Example #15
0
#!/usr/bin/env python
# coding: utf-8

r"""Simplistic geometry creation script

The part variable is assigned a ccad Solid in the global module namespace. This
part variable must exist as it is used by Part object constructors

"""

import ccad.model as cm

part = cm.sphere(2.0)
Example #16
0
#!/usr/bin/env python
# coding: utf-8
r"""Basic example

Probably the simplest example of using ccad

"""

import ccad.model as cm
#import ccad.display as cd
import wx
from aocutils.display.wx_viewer import Wx3dViewerFrame

s1 = cm.sphere(2.0)
#v1 = cd.view()
#v1.display(s1)
App = wx.App()
frame = Wx3dViewerFrame()
frame.wx_3d_viewer.display_shape(s1.shape)
#cd.start()
App.SetTopWindow(frame)
App.MainLoop()
Example #17
0
def boolean_common():
    s1 = cm.sphere(1.0)
    s2 = cm.box(1.0, 2.0, 3.0)
    s3 = s1 & s2
    save_iso(s3, 'boolean_common.png')
Example #18
0
def sphere_example():
    s1 = cm.sphere(10.0)
    save_iso(s1, 'sphere_example.png')
Example #19
0
def boolean_cut():
    s1 = cm.sphere(1.0)
    s2 = cm.box(1.0, 2.0, 3.0)
    s3 = s1 - s2
    save_iso(s3, 'boolean_cut.png')
Example #20
0
def solid_sphere():
    s1 = cm.sphere(5.0)
    save_iso(s1, 'solid_sphere.png')
Example #21
0
 def test_mirrored(self):
     s1 = cm.sphere(1.0)
     s2 = cm.mirrored(s1, (1.0, 0.0, 0.0), (1.0, 0.0, 0.0))
     self.assert_(close(s2.center(), (2.0, 0.0, 0.0)))
Example #22
0
 def test_rotated(self):
     s1 = cm.sphere(1.0)
     s2 = cm.rotated(s1, (1.0, 0.0, 0.0), (0.0, 0.0, 1.0), math.pi / 2)
     self.assert_(close(s2.center(), (1.0, -1.0, 0.0)))
Example #23
0
def sphere_example():
    s1 = cm.sphere(10.0)
    save_iso(s1, 'sphere_example.png')
Example #24
0
 def test_sphere(self):
     s1 = cm.sphere(5.0)
     self.assert_(close(
             4.0 / 3.0 * math.pi * 5 ** 3, s1.volume()))
Example #25
0
import ccad.model as cm
import OCC.Display.SimpleGui as SimpleGui

s1 = cm.sphere(1.0)
display, start_display, add_menu, add_function_to_menu = \
    SimpleGui.init_display()
display.DisplayShape(s1.shape, update=True)
start_display()
Example #26
0
 def test_translated(self):
     delta = (0.1, 0.2, 0.3)
     s1 = cm.sphere(1.0)
     s2 = cm.translated(s1, delta)
     self.assert_(close(s2.center(), delta))
Example #27
0
 def test_rotated(self):
     s1 = cm.sphere(1.0)
     s2 = cm.rotated(s1, (1.0, 0.0, 0.0), (0.0, 0.0, 1.0), math.pi / 2)
     self.assert_(close(s2.center(), (1.0, -1.0, 0.0)))
Example #28
0
 def test_rotatedz(self):
     s1 = cm.sphere(1.0)
     s1.translate((1.0, 0.0, 0.0))
     s2 = cm.rotatedz(s1, math.pi / 2)
     self.assert_(close(s2.center(), (0.0, 1.0, 0.0)))
Example #29
0
 def test_rotatedz(self):
     s1 = cm.sphere(1.0)
     s1.translate((1.0, 0.0, 0.0))
     s2 = cm.rotatedz(s1, math.pi / 2)
     self.assert_(close(s2.center(), (0.0, 1.0, 0.0)))
Example #30
0
 def test_mirroredx(self):
     s1 = cm.sphere(1.0)
     s1.translate((1.0, 0.0, 0.0))
     s2 = cm.mirroredx(s1)
     self.assert_(close(s2.center(), (-1.0, 0.0, 0.0)))
Example #31
0
def solid_sphere():
    s1 = cm.sphere(5.0)
    save_iso(s1, 'solid_sphere.png')
Example #32
0
def boolean_fuse():
    s1 = cm.sphere(1.0)
    s2 = cm.box(1.0, 2.0, 3.0)
    s3 = s1 + s2
    save_iso(s3, 'boolean_fuse.png')
Example #33
0
 def test_mirroredx(self):
     s1 = cm.sphere(1.0)
     s1.translate((1.0, 0.0, 0.0))
     s2 = cm.mirroredx(s1)
     self.assert_(close(s2.center(), (-1.0, 0.0, 0.0)))
Example #34
0
def boolean_common():
    s1 = cm.sphere(1.0)
    s2 = cm.box(1.0, 2.0, 3.0)
    s3 = s1 & s2
    save_iso(s3, 'boolean_common.png')
Example #35
0
def boolean_fuse():
    s1 = cm.sphere(1.0)
    s2 = cm.box(1.0, 2.0, 3.0)
    s3 = s1 + s2
    save_iso(s3, 'boolean_fuse.png')
Example #36
0
 def test_mirrored(self):
     s1 = cm.sphere(1.0)
     s2 = cm.mirrored(s1, (1.0, 0.0, 0.0), (1.0, 0.0, 0.0))
     self.assert_(close(s2.center(), (2.0, 0.0, 0.0)))
Example #37
0
def boolean_cut():
    s1 = cm.sphere(1.0)
    s2 = cm.box(1.0, 2.0, 3.0)
    s3 = s1 - s2
    save_iso(s3, 'boolean_cut.png')