def test_loft(self): w1 = cm.Wire([cm.circle(1.0)]) w2 = cm.Wire([cm.circle(2.0)]) w2.translate((0.0, 0.0, 5.0)) w3 = cm.Wire([cm.circle(1.5)]) w3.translate((0.0, 0.0, 10.0)) s1 = cm.loft([w1, w2, w3]) # empirical self.assert_(close(98.407, s1.volume(), 0.001))
def query(self): """Reports the properties of a selection Should do something other than print (popup?) *** """ if self.selected is not None: if self.selection_type == 'Vertex': s = _cm.Vertex(self.selected) retval = 'center: ' + str(s.center()) + \ '\ntolerance: ' + str(s.tolerance()) elif self.selection_type == 'Edge': s = _cm.Edge(self.selected) retval = 'center: ' + str(s.center()) + \ '\nlength: ' + str(s.length()) + \ '\ntolerance: ' + str(s.tolerance()) elif self.selection_type == 'Wire': s = _cm.Wire(self.selected) retval = 'center: ' + str(s.center()) + \ '\nlength: ' + str(s.length()) elif self.selection_type == 'Face': s = _cm.Face(self.selected) retval = 'center: ' + str(s.center()) + \ '\ntype: ' + str(s.type()) + \ '\narea: ' + str(s.area()) + \ '\ntolerance: ' + str(s.tolerance()) else: retval = 'No properties for type ' + self.selection_type print(retval)
def test_pipe(self): profile = cm.ngon(2.0, 6) e1 = cm.arc(8.0, 0.0, math.pi / 2) e2 = cm.segment((0.0, 8.0, 0.0), (-8.0, 8.0, 0.0)) spine = cm.Wire([e1, e2]) spine.translate((-8.0, 0.0, 0.0)) spine.rotatex(math.pi / 2) s1 = cm.pipe(profile, spine) # empirical self.assert_(close(213.732, s1.volume(), 0.001))
def triedre(U): O = (0., 0.0, 0.0) X = U[:, 0] Y = U[:, 1] Z = U[:, 2] x = cm.segment(O, X) y = cm.segment(O, Y) z = cm.segment(O, Z) t = cm.Wire([x, y, z]) return (t)
def test_filling(self): e1 = cm.spline([(0.0, 0.0, 0.0), (1.0, 0.2, 0.3), (1.5, 0.8, 1.0), (0.8, 1.2, 0.2), (0.0, 1.0, 0.0)]) e2 = cm.spline([(0.0, 0.0, 0.0), (-1.0, 0.2, 0.3), (-1.5, 0.8, 1.0), (-0.8, 1.2, 0.2), (0.0, 1.0, 0.0)]) w1 = cm.Wire([e1, e2]) f1 = cm.filling(w1) # empirical # Can vary considerably given the spline nature # self.assert_(close(5.479, f1.area(), 0.01)) self.assert_(close(5.44100168973, f1.area(), 0.01))
def _build_hashes(self, htype): if htype == 'Face': ex_type = _TopAbs.TopAbs_FACE elif htype == 'Wire': ex_type = _TopAbs.TopAbs_WIRE elif htype == 'Edge': ex_type = _TopAbs.TopAbs_EDGE elif htype == 'Vertex': ex_type = _TopAbs.TopAbs_VERTEX else: print('Error: Unknown hash type', htype) if (self.selected_shape.ShapeType == _TopAbs.TopAbs_WIRE and htype == 'Edge'): ex = _BRepTools_WireExplorer( self.selected_shape) # Ordered this way else: ex = _TopExp_Explorer(self.selected_shape, ex_type) self.hashes = [] self.positions = [] while ex.More(): s1 = ex.Current() # Calculate hash s1_hash = s1.__hash__() if s1_hash not in self.hashes: self.hashes.append(s1_hash) # Calculate position if htype == 'Face': f = _cm.Face(s1) c = (' type ' + f.type(), f.center()) elif htype == 'Wire': w = _cm.Wire(s1) c = ('', w.center()) elif htype == 'Edge': e = _cm.Edge(s1) c = ('', e.center()) elif htype == 'Vertex': c = ('', _cm.Vertex(s1).center()) self.positions.append(c) ex.Next()