Ejemplo n.º 1
0
    def _generateSceneNode(self, file_name, offset, peak_height, slopeHeight,
                           closeTopButtonFace, reversePathToration, splitWord):
        Job.yieldThread()
        if not splitWord:
            scene_node = SceneNode()
            mesh = MeshBuilder()
        else:
            scene_node = []
        areaTop = 0
        areaBottom = 0
        pathDetectNotEqual = False
        for subPaths in self._paths:
            if splitWord:
                mesh = MeshBuilder()
            pros = self._vu._gen_offset_paths(subPaths)
            clocks = []
            for path in subPaths:
                reverse = file_name.endswith('.nc')
                if reverse == (not reversePathToration):
                    path.reverse()
                (clock, holePoint) = self._vu.clockWish(path)
                clocks.append(clock)

            lastPaths = self._vu._exec_offset(pros, clocks, 0)
            if offset != 0:
                currPaths = lastPaths
                self._vu.addSidFaces(lastPaths, currPaths, clocks, mesh, 0,
                                     peak_height - slopeHeight)
                currPaths = self._vu._exec_offset(pros, clocks, offset)
                pathDetectNotEqual = self._vu.addSidFaces(
                    lastPaths, currPaths, clocks, mesh,
                    peak_height - slopeHeight, peak_height)
            else:
                currPaths = lastPaths
                self._vu.addSidFaces(lastPaths, currPaths, clocks, mesh, 0,
                                     peak_height)
            if closeTopButtonFace:
                areaTop += self._vu.addTopButtonFace(True, currPaths, mesh,
                                                     peak_height)
                areaBottom += self._vu.addTopButtonFace(
                    False, lastPaths, mesh, 0)
            if splitWord:
                mesh.calculateNormals(fast=True)
                _sceneNode = SceneNode()
                _sceneNode.setMeshData(mesh.build())
                scene_node.append(_sceneNode)
        if not splitWord:
            mesh.calculateNormals(fast=True)
            scene_node.setMeshData(mesh.build())
        else:
            scene_node.reverse()
        if closeTopButtonFace:
            if pathDetectNotEqual:
                m = Message(i18n_catalog.i18nc(
                    '@info:status',
                    'Top/Buttom area :{} mm\xc2\xb2 ,{} mm\xc2\xb2\n There may be broken, please reduce the offset',
                    round(areaTop, 2), round(areaBottom, 2)),
                            lifetime=0)
            else:
                m = Message(i18n_catalog.i18nc(
                    '@info:status',
                    'Top/Buttom area :{} mm\xc2\xb2 ,{} mm\xc2\xb2',
                    round(areaTop, 2), round(areaBottom, 2)),
                            lifetime=0)
            m.addAction(
                'regenerate', i18n_catalog.i18nc('@action:button',
                                                 'regenerate'), 'regenerate',
                i18n_catalog.i18nc('@info:tooltip', 'Regenerating model'))
            m._filename = file_name
            m.actionTriggered.connect(self._onMessageActionTriggered)
            m.show()
        return scene_node