Esempio n. 1
0
    def calculateROI(self):
        if hasattr(self, 'rotationMatrix') and \
           hasattr(self, 'translationVector') and \
           hasattr(self, 'fx') and hasattr(self, 'fy') and \
           hasattr(self, 'cx') and hasattr(self, 'cy') and \
           hasattr(self, 'width') and hasattr(self, 'height'):

            if (profile.getMachineSetting('machine_shape') == 'Circular' and hasattr(self, 'roiRadius') and hasattr(self, 'roiHeight')) or \
            (profile.getMachineSetting('machine_shape') == 'Rectangular' and hasattr(self, 'roiWidth') and hasattr(self, 'roiHeight') and hasattr(self, 'roiDepth')):

                #-- Platform system
                if profile.getMachineSetting('machine_shape') == 'Circular':
                    bottom = np.matrix(self.roiRadius * self.circleArray)
                elif profile.getMachineSetting(
                        'machine_shape') == 'Rectangular':
                    bottom = np.matrix(self.roiWidth * self.rectangleArray)

                top = bottom + np.matrix([0, 0, self.roiHeight]).T
                data = np.concatenate((bottom, top), axis=1)

                #-- Camera system
                data = self.rotationMatrix * data + np.matrix(
                    self.translationVector).T

                #-- Video system
                u = self.fx * data[0] / data[2] + self.cx
                v = self.fy * data[1] / data[2] + self.cy

                umin = int(round(np.min(u)))
                umax = int(round(np.max(u)))
                vmin = int(round(np.min(v)))
                vmax = int(round(np.max(v)))

                #visualization :
                v_ = np.array(v.T)
                #lower cylinder base
                a = v_[:(len(v_) / 2)]
                #upper cylinder base
                b = v_[(len(v_) / 2):]

                self.lower_vmin = int(round(np.max(a)))
                self.lower_vmax = int(round(np.min(a)))
                self.upper_vmin = int(round(np.min(b)))
                self.upper_vmax = int(round(np.max(b)))

                self.no_trimmed_umin = umin
                self.no_trimmed_umax = int(round(np.max(u)))
                self.no_trimmed_vmin = int(round(np.min(v)))
                self.no_trimmed_vmax = int(round(np.max(v)))

                self.umin = max(umin, 0)
                self.umax = min(umax, self.width)
                self.vmin = max(vmin, 0)
                self.vmax = min(vmax, self.height)
Esempio n. 2
0
 def updateProfile(self):
     section = self.sections['point_cloud_generation']
     section.items['view_roi'][0].updateProfile()
     section.items['roi_diameter'].updateProfile()
     section.items['roi_width'].updateProfile()
     section.items['roi_height'].updateProfile()
     section.items['roi_depth'].updateProfile()
     if profile.getMachineSetting('machine_shape') == "Rectangular":
         section.hideItem('roi_diameter')
         section.showItem('roi_width')
         section.showItem('roi_depth')
     elif profile.getMachineSetting('machine_shape') == "Circular":
         section.hideItem('roi_width')
         section.hideItem('roi_depth')
         section.showItem('roi_diameter')
     self.GetParent().GetParent().Layout()
Esempio n. 3
0
    def calculateCenter(self):
        #-- Platform system
        if profile.getMachineSetting('machine_shape') == 'Circular':
            bottom = np.matrix(0 * self.circleArray)
        elif profile.getMachineSetting('machine_shape') == 'Rectangular':
            bottom = np.matrix(0 * self.rectangleArray)
        top = bottom + np.matrix([0, 0, 0]).T
        data = np.concatenate((bottom, top), axis=1)

        #-- Camera system
        data = self.rotationMatrix * data + np.matrix(self.translationVector).T

        #-- Video system
        u = self.fx * data[0] / data[2] + self.cx
        v = self.fy * data[1] / data[2] + self.cy

        umin = int(round(np.min(u)))
        umax = int(round(np.max(u)))
        vmin = int(round(np.min(v)))
        vmax = int(round(np.max(v)))

        self.center_u = umin + (umax - umin) / 2
        self.center_v = vmin + (vmax - vmin) / 2
Esempio n. 4
0
	def __init__(self, parent):
		super(MachineSettingsDialog, self).__init__(None, title=_("Machine Settings"))

		self.main = parent

		#-- Graphic elements
		self.machineShapeLabel = wx.StaticText(self, label=_("Platform Shape"))
		self.machineShapes = profile.getMachineSettingType("machine_shape")
		self.machineShapeCombo = wx.ComboBox(self, choices=self.machineShapes, size=(170,-1), style=wx.CB_READONLY)

		self.dimensionsStaticText = wx.StaticText(self, label=_("Platform Dimensions"), style=wx.ALIGN_CENTRE)
		self.diameterLabel = wx.StaticText(self, label=_("Diameter"))
		self.diameterField = wx.lib.intctrl.IntCtrl(self, size=(170,-1), style=wx.TE_RIGHT)
		self.widthLabel = wx.StaticText(self, label=_("Width"))
		self.widthField = wx.lib.intctrl.IntCtrl(self, size=(170,-1), style=wx.TE_RIGHT)
		self.heightLabel = wx.StaticText(self, label=_("Height"))
		self.heightField = wx.lib.intctrl.IntCtrl(self, size=(170,-1), style=wx.TE_RIGHT)
		self.depthLabel = wx.StaticText(self, label=_("Depth"))
		self.depthField = wx.lib.intctrl.IntCtrl(self, size=(170,-1), style=wx.TE_RIGHT)

		self.machineModelLabel = wx.StaticText(self, label=_("Machine Model"))
		self.machineModelButton = wx.Button(self, label=_("Browse"))
		self.machineModelField = wx.StaticText(self, size=(200,-1))

		self.defaultButton = wx.Button(self, label=_("Default"))
		self.cancelButton = wx.Button(self, label=_("Cancel"))
		self.saveButton = wx.Button(self, label=_("Save"))

		#-- Events
		self.machineShapeCombo.Bind(wx.EVT_COMBOBOX, self.onmachineShapeComboChanged)
		self.machineModelButton.Bind(wx.EVT_BUTTON, self.onMachineModelButton)
		self.cancelButton.Bind(wx.EVT_BUTTON, self.onCancelButton)
		self.saveButton.Bind(wx.EVT_BUTTON, self.onSaveButton)
		self.defaultButton.Bind(wx.EVT_BUTTON, self.onDefaultButton)
		self.Bind(wx.EVT_CLOSE, self.onCancelButton)

		#-- Layout
		vbox = wx.BoxSizer(wx.VERTICAL)

		hbox = wx.BoxSizer(wx.HORIZONTAL)
		hbox.Add(self.machineShapeLabel, 0, wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, 10)
		hbox.AddStretchSpacer()
		hbox.Add(self.machineShapeCombo, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)
		vbox.Add(hbox, 0, wx.ALL|wx.EXPAND, 10)
		vbox.Add(wx.StaticLine(self), 0, wx.EXPAND|wx.ALL, 5)

		vbox.Add(self.dimensionsStaticText, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 10)
		# Diameter
		self.diam_hbox = wx.BoxSizer(wx.HORIZONTAL)
		self.diam_hbox.Add(self.diameterLabel, 0, wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, 10)
		self.diam_hbox.AddStretchSpacer()
		self.diam_hbox.Add(self.diameterField, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)
		vbox.Add(self.diam_hbox, 0, wx.ALL|wx.EXPAND, 10)
		# Width
		self.width_hbox = wx.BoxSizer(wx.HORIZONTAL)
		self.width_hbox.Add(self.widthLabel, 0, wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, 10)
		self.width_hbox.AddStretchSpacer()
		self.width_hbox.Add(self.widthField, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)
		vbox.Add(self.width_hbox, 0, wx.ALL|wx.EXPAND, 10)
		# Height
		hbox = wx.BoxSizer(wx.HORIZONTAL)
		hbox.Add(self.heightLabel, 0, wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, 10)
		hbox.AddStretchSpacer()
		hbox.Add(self.heightField, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)
		vbox.Add(hbox, 0, wx.BOTTOM|wx.LEFT|wx.RIGHT|wx.EXPAND, 10)
		# Depth
		self.depth_hbox = wx.BoxSizer(wx.HORIZONTAL)
		self.depth_hbox.Add(self.depthLabel, 0, wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, 10)
		self.depth_hbox.AddStretchSpacer()
		self.depth_hbox.Add(self.depthField, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)
		vbox.Add(self.depth_hbox, 0, wx.BOTTOM|wx.LEFT|wx.RIGHT|wx.EXPAND, 10)
		vbox.Add(wx.StaticLine(self), 0, wx.EXPAND|wx.ALL, 5)

		# Machine STL
		vbox.Add(self.machineModelLabel, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 10)
		hbox = wx.BoxSizer(wx.HORIZONTAL)
		hbox.Add(self.machineModelButton, 0, wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, 10)
		hbox.AddStretchSpacer()
		hbox.Add(self.machineModelField, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)
		vbox.Add(hbox, 0, wx.ALL|wx.EXPAND, 10)
		vbox.Add(wx.StaticLine(self), 0, wx.EXPAND|wx.ALL, 5)

		hbox = wx.BoxSizer(wx.HORIZONTAL)
		hbox.Add(self.defaultButton, 0, wx.ALL^wx.RIGHT, 10)
		hbox.Add(self.cancelButton, 0, wx.ALL^wx.RIGHT, 10)
		hbox.Add(self.saveButton, 0, wx.ALL, 10)
		vbox.Add(hbox, 0, wx.BOTTOM|wx.ALIGN_CENTER_HORIZONTAL, 5)

		#-- Fill data from settings
		self.machineShapeCombo.SetValue(profile.getMachineSetting('machine_shape'))
		self.diameterField.SetValue(profile.getMachineSettingInteger('machine_diameter'))
		self.widthField.SetValue(profile.getMachineSettingInteger('machine_width'))
		self.heightField.SetValue(profile.getMachineSettingInteger('machine_height'))
		self.depthField.SetValue(profile.getMachineSettingInteger('machine_depth'))
		self.machineModelPath = profile.getMachineSettingPath('machine_model_path')
		self.machineModelField.SetLabel(self._getFileName(self.machineModelPath))

		self.SetSizerAndFit(vbox)

		self.onmachineShapeComboChanged(None)

		self.Centre()
		self.Layout()
		self.Fit()
Esempio n. 5
0
    def _drawMachine(self):
        glEnable(GL_BLEND)

        machine = profile.getMachineSetting('machine_type')
        if machine.startswith('ciclop'):

            glEnable(GL_CULL_FACE)
            #-- Draw Platform
            if machine not in self._platformMesh:
                mesh = meshLoader.loadMesh(
                    resources.getPathForMesh(machine + '_platform.stl'))
                if mesh is not None:
                    self._platformMesh[machine] = mesh
                else:
                    self._platformMesh[machine] = None
                self._platformMesh[machine]._drawOffset = numpy.array(
                    [0, 0, 8.05], numpy.float32)
            glColor4f(0.6, 0.6, 0.6, 0.5)
            self._objectShader.bind()
            self._renderObject(self._platformMesh[machine])
            self._objectShader.unbind()
            glDisable(GL_CULL_FACE)

        glDepthMask(False)

        size = numpy.array([
            profile.getProfileSettingFloat('roi_diameter'),
            profile.getProfileSettingFloat('roi_diameter'),
            profile.getProfileSettingFloat('roi_height')
        ], numpy.float32)

        if profile.getProfileSettingBool('view_roi'):
            polys = profile.getSizePolygons(size)
            height = profile.getProfileSettingFloat('roi_height')
            circular = profile.getMachineSetting('machine_shape') == 'Circular'
            # Draw the sides of the build volume.
            glBegin(GL_QUADS)
            for n in xrange(0, len(polys[0])):
                if not circular:
                    if n % 2 == 0:
                        glColor4ub(5, 171, 231, 96)
                    else:
                        glColor4ub(5, 171, 231, 64)
                else:
                    glColor4ub(5, 171, 231, 96)
                    #glColor4ub(200, 200, 200, 150)

                glVertex3f(polys[0][n][0], polys[0][n][1], height)
                glVertex3f(polys[0][n][0], polys[0][n][1], 0)
                glVertex3f(polys[0][n - 1][0], polys[0][n - 1][1], 0)
                glVertex3f(polys[0][n - 1][0], polys[0][n - 1][1], height)
            glEnd()

            #Draw bottom and top of build volume.
            glColor4ub(5, 171, 231, 150)  #128)
            #glColor4ub(200, 200, 200, 200)
            glBegin(GL_TRIANGLE_FAN)
            for p in polys[0][::-1]:
                glVertex3f(p[0], p[1], 0)
            glEnd()
            glBegin(GL_TRIANGLE_FAN)
            for p in polys[0][::-1]:
                glVertex3f(p[0], p[1], height)
            glEnd()

            #view center:
            center = self.getObjectCenterPos()
            quadric = gluNewQuadric()
            gluQuadricNormals(quadric, GLU_SMOOTH)
            gluQuadricTexture(quadric, GL_TRUE)
            glColor4ub(255, 0, 0, 255)
            #lower center:
            gluCylinder(quadric, 6, 6, 1, 32, 16)
            gluDisk(quadric, 0.0, 6, 32, 1)

            glTranslate(0, 0, height - 1)
            gluDisk(quadric, 0.0, 6, 32, 1)
            gluCylinder(quadric, 6, 6, 1, 32, 16)
            glTranslate(0, 0, -height + 1)

        polys = profile.getMachineSizePolygons()

        #-- Draw checkerboard
        if self._platformTexture is None:
            self._platformTexture = openglHelpers.loadGLTexture(
                'checkerboard.png')
            glBindTexture(GL_TEXTURE_2D, self._platformTexture)
            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
        glColor4f(1, 1, 1, 0.5)
        glBindTexture(GL_TEXTURE_2D, self._platformTexture)
        glEnable(GL_TEXTURE_2D)
        glBegin(GL_TRIANGLE_FAN)
        for p in polys[0]:
            glTexCoord2f(p[0] / 20, p[1] / 20)
            glVertex3f(p[0], p[1], 0)
        glEnd()

        glDepthMask(True)
        glDisable(GL_BLEND)
Esempio n. 6
0
	def _drawMachine(self):
		glEnable(GL_BLEND)

		machine = profile.getMachineSetting('machine_type')
		if machine.startswith('ciclop'):

			glEnable(GL_CULL_FACE)
			#-- Draw Platform
			if machine not in self._platformMesh:
				mesh = meshLoader.loadMesh(resources.getPathForMesh(machine + '_platform.stl'))
				if mesh is not None:
					self._platformMesh[machine] = mesh
				else:
					self._platformMesh[machine] = None
				self._platformMesh[machine]._drawOffset = numpy.array([0,0,8.05], numpy.float32)
			glColor4f(0.6,0.6,0.6,0.5)
			self._objectShader.bind()
			self._renderObject(self._platformMesh[machine])
			self._objectShader.unbind()
			glDisable(GL_CULL_FACE)

		glDepthMask(False)
		
		size = numpy.array([profile.getProfileSettingFloat('roi_diameter'),
							profile.getProfileSettingFloat('roi_diameter'),
							profile.getProfileSettingFloat('roi_height')], numpy.float32)

		if profile.getProfileSettingBool('view_roi'):
			polys = profile.getSizePolygons(size)
			height = profile.getProfileSettingFloat('roi_height')
			circular = profile.getMachineSetting('machine_shape') == 'Circular'
			# Draw the sides of the build volume.
			glBegin(GL_QUADS)
			for n in xrange(0, len(polys[0])):
				if not circular:
					if n % 2 == 0:
						glColor4ub(5, 171, 231, 96)
					else:
						glColor4ub(5, 171, 231, 64)
				else:
					glColor4ub(5, 171, 231, 96)
					#glColor4ub(200, 200, 200, 150)

				glVertex3f(polys[0][n][0], polys[0][n][1], height)
				glVertex3f(polys[0][n][0], polys[0][n][1], 0)
				glVertex3f(polys[0][n-1][0], polys[0][n-1][1], 0)
				glVertex3f(polys[0][n-1][0], polys[0][n-1][1], height)
			glEnd()

			#Draw bottom and top of build volume.
			glColor4ub(5, 171, 231, 150)#128)
			#glColor4ub(200, 200, 200, 200)
			glBegin(GL_TRIANGLE_FAN)
			for p in polys[0][::-1]:
				glVertex3f(p[0], p[1], 0)
			glEnd()
			glBegin(GL_TRIANGLE_FAN)
			for p in polys[0][::-1]:
				glVertex3f(p[0], p[1], height)
			glEnd()

			quadric=gluNewQuadric();
			gluQuadricNormals(quadric, GLU_SMOOTH);
			gluQuadricTexture(quadric, GL_TRUE);
			glColor4ub(0, 100, 200, 150)
			
			gluCylinder(quadric,6,6,1,32,16);
			gluDisk(quadric, 0.0, 6, 32, 1); 

			glTranslate(0,0,height-1)
			gluDisk(quadric, 0.0, 6, 32, 1); 
			gluCylinder(quadric,6,6,1,32,16);
			glTranslate(0,0,-height+1)

		polys = profile.getMachineSizePolygons()
		
		#-- Draw checkerboard
		if self._platformTexture is None:
			self._platformTexture = openglHelpers.loadGLTexture('checkerboard.png')
			glBindTexture(GL_TEXTURE_2D, self._platformTexture)
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
		glColor4f(1,1,1,0.5)
		glBindTexture(GL_TEXTURE_2D, self._platformTexture)
		glEnable(GL_TEXTURE_2D)
		glBegin(GL_TRIANGLE_FAN)
		for p in polys[0]:
			glTexCoord2f(p[0]/20, p[1]/20)
			glVertex3f(p[0], p[1], 0)
		glEnd()
		glDisable(GL_TEXTURE_2D)

		glDepthMask(True)
		glDisable(GL_BLEND)
Esempio n. 7
0
	def _drawMachine(self):
		glEnable(GL_BLEND)
		machine_model_path = profile.getMachineSettingPath('machine_model_path')
		glEnable(GL_CULL_FACE)
		#-- Draw Platform
		if machine_model_path in self._platformMesh:
			self._platformMesh[machine_model_path]._mesh.vbo.release()

		mesh = meshLoader.loadMesh(machine_model_path)
		if mesh is not None:
			self._platformMesh[machine_model_path] = mesh
		else:
			self._platformMesh[machine_model_path] = None
		self._platformMesh[machine_model_path]._drawOffset = numpy.array([0,0,8.05], numpy.float32)
		glColor4f(0.6,0.6,0.6,0.5)
		self._objectShader.bind()
		self._renderObject(self._platformMesh[machine_model_path])
		self._objectShader.unbind()
		glDisable(GL_CULL_FACE)

		glDepthMask(False)
		
		machine_shape = profile.getMachineSetting('machine_shape')

		if machine_shape == 'Circular':
			size = numpy.array([profile.getMachineSettingFloat('roi_diameter'),
								profile.getMachineSettingFloat('roi_diameter'),
								profile.getMachineSettingFloat('roi_height')], numpy.float32)
		elif machine_shape == 'Rectangular':
			size = numpy.array([profile.getMachineSettingFloat('roi_width'),
								profile.getMachineSettingFloat('roi_depth'),
								profile.getMachineSettingFloat('roi_height')], numpy.float32)

		if profile.getMachineSettingBool('view_roi'):
			polys = profile.getSizePolygons(size, machine_shape)
			height = profile.getMachineSettingFloat('roi_height')

			# Draw the sides of the build volume.
			glBegin(GL_QUADS)
			for n in xrange(0, len(polys[0])):
				if machine_shape == 'Rectangular':
					if n % 2 == 0:
						glColor4ub(5, 171, 231, 96)
					else:
						glColor4ub(5, 171, 231, 64)
				elif machine_shape == 'Circular':
					glColor4ub(5, 171, 231, 96)
					#glColor4ub(200, 200, 200, 150)

				glVertex3f(polys[0][n][0], polys[0][n][1], height)
				glVertex3f(polys[0][n][0], polys[0][n][1], 0)
				glVertex3f(polys[0][n-1][0], polys[0][n-1][1], 0)
				glVertex3f(polys[0][n-1][0], polys[0][n-1][1], height)
			glEnd()

			#Draw bottom and top of build volume.
			glColor4ub(5, 171, 231, 150)#128)
			#glColor4ub(200, 200, 200, 200)
			glBegin(GL_TRIANGLE_FAN)
			for p in polys[0][::-1]:
				glVertex3f(p[0], p[1], 0)
			glEnd()
			glBegin(GL_TRIANGLE_FAN)
			for p in polys[0][::-1]:
				glVertex3f(p[0], p[1], height)
			glEnd()

			quadric=gluNewQuadric();
			gluQuadricNormals(quadric, GLU_SMOOTH);
			gluQuadricTexture(quadric, GL_TRUE);
			glColor4ub(0, 100, 200, 150)
			
			gluCylinder(quadric,6,6,1,32,16);
			gluDisk(quadric, 0.0, 6, 32, 1); 

			glTranslate(0,0,height-1)
			gluDisk(quadric, 0.0, 6, 32, 1); 
			gluCylinder(quadric,6,6,1,32,16);
			glTranslate(0,0,-height+1)

		polys = profile.getMachineSizePolygons(profile.getMachineSetting("machine_shape"))
		
		#-- Draw checkerboard
		if self._platformTexture is None:
			self._platformTexture = openglHelpers.loadGLTexture('checkerboard.png')
			glBindTexture(GL_TEXTURE_2D, self._platformTexture)
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
		glColor4f(1,1,1,0.5)
		glBindTexture(GL_TEXTURE_2D, self._platformTexture)
		glEnable(GL_TEXTURE_2D)
		glBegin(GL_TRIANGLE_FAN)
		for p in polys[0]:
			glTexCoord2f(p[0]/20, p[1]/20)
			glVertex3f(p[0], p[1], 0)
		glEnd()
		glDisable(GL_TEXTURE_2D)

		glDepthMask(True)
		glDisable(GL_BLEND)