Ejemplo n.º 1
0
	def __init__(self, p0, p1, id = None, pocketClass=Pocket):
		"""Initialize a Joint object"""
		
		self.posts = [p0, p1]
		
		self.id = id
		
		self.intersection = common.findClosestPoints(p0.axis, p1.axis)
		
		if rs.Distance(*self.intersection) <= sc.doc.PageAbsoluteTolerance:
			#lines actually intersect. axis is normal to both input lines
			self.intersecting = True
			self.axis = rs.VectorCrossProduct(p0.axis.UnitTangent, p1.axis.UnitTangent)
		else:
			self.intersecting = False
			self.axis = rs.VectorUnitize(Rhino.Geometry.Vector3d(self.intersection[1] 
				- self.intersection[0]))
				
		#store distance between post axes
		self.separation = rs.Distance(*self.intersection)
		
		#orientation is plane at origin, normal along self.axis, x axis along p0
		#start (arbitrarily) at p0's closest point
		self.orientation = rs.PlaneFromNormal(self.intersection[0], self.axis,
			self.posts[0].axis.UnitTangent)
		#origin is midpoint between furthest protrusions of posts, along joint axis
		self.origin = self.getOrigin()
		#move orientation to midpoint of post profiles' bounding box
		self.orientation.Origin = self.origin
		#know how to get back home
		self.selfToGlobal = Rhino.Geometry.Transform.ChangeBasis(self.orientation,
			Rhino.Geometry.Plane.WorldXY)
		
		#initialize pockets
		self.pockets = [pocketClass(p0, 0, self), pocketClass(p1, 1, self)]
		#create sheared surface - starting point for creating pocket toolpaths
		self.face = self.commonFace()

		#create pockets
		for p in self.pockets:
			p.create()
Ejemplo n.º 2
0
	def findPairs(self):
		"""Find all pairs of Posts in Structure which might intersect
		
		Returns: list of lists, each with two posts
		"""
		
		pairs = []
		keys = self.axes.keys()
		
		#loop through indeces of each Post
		for a in range(0, self.dim):
			#loop through all remaining Posts (higher indices)
			for b in range(a+1, self.dim):
				#only accept pairs within specified distance
				if rs.Distance(*common.findClosestPoints(self.posts[keys[a]].axis, 
					self.posts[keys[b]].axis)) < 2:
					pairs.append((keys[a], keys[b]))
					self.connections[keys[a]][keys[b]] = [[keys[b]]]
					self.connections[keys[b]][keys[a]] = [[keys[a]]]
		
		return pairs