def addSegmentTableLoops( self, boundaryLayerIndex ): "Add the segment tables and loops to the boundary." boundaryLayer = self.boundaryLayers[ boundaryLayerIndex ] euclidean.subtractXIntersectionsTable( boundaryLayer.outerHorizontalTable, boundaryLayer.innerHorizontalTable ) euclidean.subtractXIntersectionsTable( boundaryLayer.outerVerticalTable, boundaryLayer.innerVerticalTable ) boundaryLayer.horizontalSegmentTable = self.getHorizontalSegmentTableForXIntersectionsTable( boundaryLayer.outerHorizontalTable ) boundaryLayer.verticalSegmentTable = self.getVerticalSegmentTableForXIntersectionsTable( boundaryLayer.outerVerticalTable ) innerHorizontalSegmentTable = self.getHorizontalSegmentTableForXIntersectionsTable( boundaryLayer.innerHorizontalTable ) innerVerticalSegmentTable = self.getVerticalSegmentTableForXIntersectionsTable( boundaryLayer.innerVerticalTable ) betweenPoints = getPointsFromSegmentTable( boundaryLayer.horizontalSegmentTable ) betweenPoints += getPointsFromSegmentTable( boundaryLayer.verticalSegmentTable ) innerPoints = getPointsFromSegmentTable( innerHorizontalSegmentTable ) innerPoints += getPointsFromSegmentTable( innerVerticalSegmentTable ) innerPointTable = {} for innerPoint in innerPoints: innerPointTable[ innerPoint ] = None boundaryLayer.innerLoops = [] boundaryLayer.outerLoops = [] millRadius = 0.75 * self.millWidth loops = triangle_mesh.getInclusiveLoops( betweenPoints, betweenPoints, millRadius ) loops = euclidean.getSimplifiedLoops( loops, millRadius ) for loop in loops: if isPointOfTableInLoop( loop, innerPointTable ): boundaryLayer.innerLoops.append( loop ) else: boundaryLayer.outerLoops.append( loop ) if self.repository.crossHatch.value and boundaryLayerIndex % 2 == 1: boundaryLayer.segmentTable = boundaryLayer.verticalSegmentTable else: boundaryLayer.segmentTable = boundaryLayer.horizontalSegmentTable
def getLoopsFromMesh( self, z ): "Get loops from a carve of a mesh." originalLoops = [] if self.isCorrectMesh: originalLoops = getLoopsFromCorrectMesh( self.edges, self.faces, self.vertices, z ) if len( originalLoops ) < 1: originalLoops = getLoopsFromUnprovenMesh( self.edges, self.faces, self.importRadius, self.vertices, z ) loops = getLoopsInOrderOfArea( compareAreaDescending, euclidean.getSimplifiedLoops( originalLoops, self.importRadius ) ) for loopIndex in xrange( len( loops ) ): loop = loops[ loopIndex ] leftPoint = euclidean.getLeftPoint( loop ) isInFilledRegion = euclidean.isInFilledRegion( loops[ : loopIndex ] + loops[ loopIndex + 1 : ], leftPoint ) if isInFilledRegion == euclidean.isWiddershins( loop ): loop.reverse() return loops
def getLoops( self, importRadius, z ): "Get loops sliced through shape." if len( self.subObjectInfos ) < 1: return [] operationString = self.object.attributeTable[ 'operation' ] subObjectInfoLoopsList = getSubObjectInfoLoopsList( importRadius, self.subObjectInfos, z ) loops = [] if operationString == '0': loops = self.getJoinedLoops( importRadius, subObjectInfoLoopsList ) elif operationString == '1': loops = self.getIntersectedLoops( importRadius, subObjectInfoLoopsList ) elif operationString == '2': loops = self.getSubtractedLoops( importRadius, subObjectInfoLoopsList ) elif operationString == '3': subObjectInfoLoopsList.reverse() loops = self.getSubtractedLoops( importRadius, subObjectInfoLoopsList ) return euclidean.getSimplifiedLoops( loops, importRadius )
def addSegmentTableLoops(self, boundaryLayerIndex): "Add the segment tables and loops to the boundary." boundaryLayer = self.boundaryLayers[boundaryLayerIndex] euclidean.subtractXIntersectionsTable( boundaryLayer.outerHorizontalTable, boundaryLayer.innerHorizontalTable) euclidean.subtractXIntersectionsTable(boundaryLayer.outerVerticalTable, boundaryLayer.innerVerticalTable) boundaryLayer.horizontalSegmentTable = self.getHorizontalSegmentTableForXIntersectionsTable( boundaryLayer.outerHorizontalTable) boundaryLayer.verticalSegmentTable = self.getVerticalSegmentTableForXIntersectionsTable( boundaryLayer.outerVerticalTable) innerHorizontalSegmentTable = self.getHorizontalSegmentTableForXIntersectionsTable( boundaryLayer.innerHorizontalTable) innerVerticalSegmentTable = self.getVerticalSegmentTableForXIntersectionsTable( boundaryLayer.innerVerticalTable) betweenPoints = getPointsFromSegmentTable( boundaryLayer.horizontalSegmentTable) betweenPoints += getPointsFromSegmentTable( boundaryLayer.verticalSegmentTable) innerPoints = getPointsFromSegmentTable(innerHorizontalSegmentTable) innerPoints += getPointsFromSegmentTable(innerVerticalSegmentTable) innerPointTable = {} for innerPoint in innerPoints: innerPointTable[innerPoint] = None boundaryLayer.innerLoops = [] boundaryLayer.outerLoops = [] millRadius = 0.75 * self.millWidth loops = triangle_mesh.getInclusiveLoops(betweenPoints, betweenPoints, millRadius) loops = euclidean.getSimplifiedLoops(loops, millRadius) for loop in loops: if isPointOfTableInLoop(loop, innerPointTable): boundaryLayer.innerLoops.append(loop) else: boundaryLayer.outerLoops.append(loop) if self.repository.crossHatch.value and boundaryLayerIndex % 2 == 1: boundaryLayer.segmentTable = boundaryLayer.verticalSegmentTable else: boundaryLayer.segmentTable = boundaryLayer.horizontalSegmentTable