Пример #1
0
	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 = trianglemesh.getDescendingAreaLoops(betweenPoints, betweenPoints, 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 subtractJoinedFill(self, supportLayerIndex):
     'Join the fill then subtract it from the support layer table.'
     supportLayer = self.supportLayers[supportLayerIndex]
     fillXIntersectionsTable = supportLayer.fillXIntersectionsTable
     belowFillXIntersectionsTable = self.supportLayers[ supportLayerIndex - 1 ].fillXIntersectionsTable
     euclidean.joinXIntersectionsTables(belowFillXIntersectionsTable, supportLayer.fillXIntersectionsTable)
     euclidean.subtractXIntersectionsTable(supportLayer.xIntersectionsTable, supportLayer.fillXIntersectionsTable)
Пример #3
0
	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)
		betweenPoints = getPointsFromSegmentTable(boundaryLayer.horizontalSegmentTable)
		betweenPoints += getPointsFromSegmentTable(boundaryLayer.verticalSegmentTable)
		innerPoints = euclidean.getPointsByHorizontalDictionary(self.millWidth, boundaryLayer.innerHorizontalTable)
		innerPoints += euclidean.getPointsByVerticalDictionary(self.millWidth, boundaryLayer.innerVerticalTable)
		innerPointTable = {}
		for innerPoint in innerPoints:
			innerPointTable[innerPoint] = None
		boundaryLayer.innerLoops = []
		boundaryLayer.outerLoops = []
		millRadius = 0.75 * self.millWidth
		loops = triangle_mesh.getDescendingAreaOrientedLoops(betweenPoints, betweenPoints, 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 addSupportSegmentTable(self, layerIndex):
        'Add support segments from the boundary layers.'
        aboveLoops = self.boundaryLayers[ layerIndex + 1 ]
        supportLayer = self.supportLayers[layerIndex]

        if len(aboveLoops) < 1:
            return

        boundaryLayer = self.boundaryLayers[layerIndex]
        rise = self.slicedModel.layers[layerIndex + 1 ].z - self.slicedModel.layers[layerIndex].z

        outsetSupportLoops = intercircle.getInsetSeparateLoopsFromLoops(-self.minimumSupportRatio * rise, boundaryLayer)
        numberOfSubSteps = 4
        subStepSize = self.interfaceStep / float(numberOfSubSteps)
        aboveIntersectionsTable = {}
        euclidean.addXIntersectionsFromLoopsForTable(aboveLoops, aboveIntersectionsTable, subStepSize)
        outsetIntersectionsTable = {}
        euclidean.addXIntersectionsFromLoopsForTable(outsetSupportLoops, outsetIntersectionsTable, subStepSize)
        euclidean.subtractXIntersectionsTable(aboveIntersectionsTable, outsetIntersectionsTable)
        for aboveIntersectionsTableKey in aboveIntersectionsTable.keys():
            supportIntersectionsTableKey = int(round(float(aboveIntersectionsTableKey) / numberOfSubSteps))
            xIntersectionIndexList = []
            if supportIntersectionsTableKey in supportLayer.xIntersectionsTable:
                euclidean.addXIntersectionIndexesFromXIntersections(0, xIntersectionIndexList, supportLayer.xIntersectionsTable[ supportIntersectionsTableKey ])
            euclidean.addXIntersectionIndexesFromXIntersections(1, xIntersectionIndexList, aboveIntersectionsTable[ aboveIntersectionsTableKey ])
            supportLayer.xIntersectionsTable[ supportIntersectionsTableKey ] = euclidean.getJoinOfXIntersectionIndexes(xIntersectionIndexList)
    def setBoundaryLayers(self):
        'Set the boundary layers.'

        if len(self.boundaryLayers) < 2:
            return

        if self.supportLocation == 'EmptyLayersOnly':
            supportLayer = SupportLayer([])
            self.supportLayers.append(supportLayer)
            for boundaryLayerIndex in xrange(1, len(self.boundaryLayers) - 1):
                self.addEmptyLayerSupport(boundaryLayerIndex)
            self.truncateSupportSegmentTables()
            self.addSegmentTablesToSupportLayers()
            return

        for boundaryLayer in self.boundaryLayers:
            # thresholdRadius of 0.8 is needed to avoid the ripple inset bug http://hydraraptor.blogspot.com/2010/12/crackers.html
            supportLoops = intercircle.getInsetSeparateLoopsFromLoops(-self.supportOutset, boundaryLayer, 0.8)
            supportLayer = SupportLayer(supportLoops)
            self.supportLayers.append(supportLayer)


        for supportLayerIndex in xrange(len(self.supportLayers) -1 ):
            self.addSupportSegmentTable(supportLayerIndex)

        self.truncateSupportSegmentTables()

        for supportLayerIndex in xrange(len(self.supportLayers) - 1):
            boundaryLoops = self.boundaryLayers[supportLayerIndex]
            self.extendXIntersections(boundaryLoops, self.supportOutset, self.supportLayers[supportLayerIndex].xIntersectionsTable)

        for supportLayer in self.supportLayers:
            self.addToFillXIntersectionIndexTables(supportLayer)

        if self.supportLocation == 'ExteriorOnly':
            for supportLayerIndex in xrange(1, len(self.supportLayers)):
                self.subtractJoinedFill(supportLayerIndex)

        for supportLayer in self.supportLayers:
            euclidean.subtractXIntersectionsTable(supportLayer.xIntersectionsTable, supportLayer.fillXIntersectionsTable)

        for supportLayerIndex in xrange(len(self.supportLayers) - 2, -1, -1):
            xIntersectionsTable = self.supportLayers[supportLayerIndex].xIntersectionsTable
            aboveXIntersectionsTable = self.supportLayers[supportLayerIndex + 1].xIntersectionsTable
            euclidean.joinXIntersectionsTables(aboveXIntersectionsTable, xIntersectionsTable)

        for supportLayerIndex in xrange(len(self.supportLayers)):
            supportLayer = self.supportLayers[supportLayerIndex]
            self.extendXIntersections(supportLayer.supportLoops, self.raftOutsetRadius, supportLayer.xIntersectionsTable)

        for supportLayer in self.supportLayers:
            euclidean.subtractXIntersectionsTable(supportLayer.xIntersectionsTable, supportLayer.fillXIntersectionsTable)

        self.addSegmentTablesToSupportLayers()
 def subtractJoinedFill(self, supportLayerIndex):
     'Join the fill then subtract it from the support layer table.'
     supportLayer = self.supportLayers[supportLayerIndex]
     fillXIntersectionsTable = supportLayer.fillXIntersectionsTable
     belowFillXIntersectionsTable = self.supportLayers[
         supportLayerIndex - 1].fillXIntersectionsTable
     euclidean.joinXIntersectionsTables(
         belowFillXIntersectionsTable, supportLayer.fillXIntersectionsTable)
     euclidean.subtractXIntersectionsTable(
         supportLayer.xIntersectionsTable,
         supportLayer.fillXIntersectionsTable)
    def addSupportSegmentTable(self, layerIndex):
        'Add support segments from the boundary layers.'
        aboveLoops = self.boundaryLayers[layerIndex + 1]
        supportLayer = self.supportLayers[layerIndex]

        if len(aboveLoops) < 1:
            return

        boundaryLayer = self.boundaryLayers[layerIndex]
        rise = self.slicedModel.layers[
            layerIndex + 1].z - self.slicedModel.layers[layerIndex].z

        outsetSupportLoops = intercircle.getInsetSeparateLoopsFromLoops(
            -self.minimumSupportRatio * rise, boundaryLayer)
        numberOfSubSteps = 4
        subStepSize = self.interfaceStep / float(numberOfSubSteps)
        aboveIntersectionsTable = {}
        euclidean.addXIntersectionsFromLoopsForTable(aboveLoops,
                                                     aboveIntersectionsTable,
                                                     subStepSize)
        outsetIntersectionsTable = {}
        euclidean.addXIntersectionsFromLoopsForTable(outsetSupportLoops,
                                                     outsetIntersectionsTable,
                                                     subStepSize)
        euclidean.subtractXIntersectionsTable(aboveIntersectionsTable,
                                              outsetIntersectionsTable)
        for aboveIntersectionsTableKey in aboveIntersectionsTable.keys():
            supportIntersectionsTableKey = int(
                round(float(aboveIntersectionsTableKey) / numberOfSubSteps))
            xIntersectionIndexList = []
            if supportIntersectionsTableKey in supportLayer.xIntersectionsTable:
                euclidean.addXIntersectionIndexesFromXIntersections(
                    0, xIntersectionIndexList, supportLayer.
                    xIntersectionsTable[supportIntersectionsTableKey])
            euclidean.addXIntersectionIndexesFromXIntersections(
                1, xIntersectionIndexList,
                aboveIntersectionsTable[aboveIntersectionsTableKey])
            supportLayer.xIntersectionsTable[
                supportIntersectionsTableKey] = euclidean.getJoinOfXIntersectionIndexes(
                    xIntersectionIndexList)
    def setBoundaryLayers(self):
        'Set the boundary layers.'

        if len(self.boundaryLayers) < 2:
            return

        if self.supportLocation == 'EmptyLayersOnly':
            supportLayer = SupportLayer([])
            self.supportLayers.append(supportLayer)
            for boundaryLayerIndex in xrange(1, len(self.boundaryLayers) - 1):
                self.addEmptyLayerSupport(boundaryLayerIndex)
            self.truncateSupportSegmentTables()
            self.addSegmentTablesToSupportLayers()
            return

        for boundaryLayer in self.boundaryLayers:
            # thresholdRadius of 0.8 is needed to avoid the ripple inset bug http://hydraraptor.blogspot.com/2010/12/crackers.html
            supportLoops = intercircle.getInsetSeparateLoopsFromLoops(
                -self.supportOutset, boundaryLayer, 0.8)
            supportLayer = SupportLayer(supportLoops)
            self.supportLayers.append(supportLayer)

        for supportLayerIndex in xrange(len(self.supportLayers) - 1):
            self.addSupportSegmentTable(supportLayerIndex)

        self.truncateSupportSegmentTables()

        for supportLayerIndex in xrange(len(self.supportLayers) - 1):
            boundaryLoops = self.boundaryLayers[supportLayerIndex]
            self.extendXIntersections(
                boundaryLoops, self.supportOutset,
                self.supportLayers[supportLayerIndex].xIntersectionsTable)

        for supportLayer in self.supportLayers:
            self.addToFillXIntersectionIndexTables(supportLayer)

        if self.supportLocation == 'ExteriorOnly':
            for supportLayerIndex in xrange(1, len(self.supportLayers)):
                self.subtractJoinedFill(supportLayerIndex)

        for supportLayer in self.supportLayers:
            euclidean.subtractXIntersectionsTable(
                supportLayer.xIntersectionsTable,
                supportLayer.fillXIntersectionsTable)

        for supportLayerIndex in xrange(len(self.supportLayers) - 2, -1, -1):
            xIntersectionsTable = self.supportLayers[
                supportLayerIndex].xIntersectionsTable
            aboveXIntersectionsTable = self.supportLayers[
                supportLayerIndex + 1].xIntersectionsTable
            euclidean.joinXIntersectionsTables(aboveXIntersectionsTable,
                                               xIntersectionsTable)

        for supportLayerIndex in xrange(len(self.supportLayers)):
            supportLayer = self.supportLayers[supportLayerIndex]
            self.extendXIntersections(supportLayer.supportLoops,
                                      self.raftOutsetRadius,
                                      supportLayer.xIntersectionsTable)

        for supportLayer in self.supportLayers:
            euclidean.subtractXIntersectionsTable(
                supportLayer.xIntersectionsTable,
                supportLayer.fillXIntersectionsTable)

        self.addSegmentTablesToSupportLayers()