Exemplo n.º 1
0
 def traverse(self, iter):
     winner = None
     winnerOrientation = 0
     #print(self.current_edge.id.first, self.current_edge.id.second)
     it = AdjacencyIterator(iter)
     tvertex = self.next_vertex
     if type(tvertex) is TVertex:
         mateVE = tvertex.get_mate(self.current_edge)
         while not it.is_end:
             ve = it.object
             if ve.id == mateVE.id:
                 winner = ve
                 if not it.is_incoming:
                     winnerOrientation = 1
                 else:
                     winnerOrientation = 0
                 break
             it.increment()
     else:
         ## case of NonTVertex
         natures = [
             Nature.SILHOUETTE, Nature.BORDER, Nature.CREASE,
             Nature.SUGGESTIVE_CONTOUR, Nature.VALLEY, Nature.RIDGE
         ]
         for nat in natures:
             if (self.current_edge.nature & nat) != 0:
                 count = 0
                 while not it.is_end:
                     ve = it.object
                     if (ve.nature & nat) != 0:
                         count = count + 1
                         winner = ve
                         if not it.is_incoming:
                             winnerOrientation = 1
                         else:
                             winnerOrientation = 0
                     it.increment()
                 if count != 1:
                     winner = None
                 break
     if winner is not None:
         # check whether this edge was part of the selection
         if winner.time_stamp != CF.get_time_stamp():
             #print("---", winner.id.first, winner.id.second)
             # nw let's compute the length of this connex non selected part:
             connexl = 0
             _cit = pyChainSilhouetteGenericIterator(0, 0)
             _cit.begin = winner
             _cit.current_edge = winner
             _cit.orientation = winnerOrientation
             _cit.init()
             while _cit.is_end == 0 and _cit.object.time_stamp != CF.get_time_stamp(
             ):
                 ve = _cit.object
                 #print("-------- --------", ve.id.first, ve.id.second)
                 connexl = connexl + ve.length_2d
                 _cit.increment()
             if connexl > self._length:
                 winner = None
     return winner
Exemplo n.º 2
0
	def __call__(self, iter):
		p = iter.object.point_2d
		gx = CF.read_complete_view_map_pixel(self._l, int(p.x+self._step), int(p.y)) - \
		    CF.read_complete_view_map_pixel(self._l, int(p.x), int(p.y))
		gy = CF.read_complete_view_map_pixel(self._l, int(p.x), int(p.y+self._step)) - \
		    CF.read_complete_view_map_pixel(self._l, int(p.x), int(p.y))
		return mathutils.Vector([gx, gy])
Exemplo n.º 3
0
	def traverse(self, iter):
		winner = None
		winnerOrientation = 0
		#print(self.current_edge.id.first, self.current_edge.id.second)
		it = AdjacencyIterator(iter)
		tvertex = self.next_vertex
		if type(tvertex) is TVertex:
			mateVE = tvertex.get_mate(self.current_edge)
			while not it.is_end:
				ve = it.object
				if ve.id == mateVE.id:
					winner = ve
					if not it.is_incoming:
						winnerOrientation = 1
					else:
						winnerOrientation = 0
					break
				it.increment()
		else:
			## case of NonTVertex
			natures = [Nature.SILHOUETTE,Nature.BORDER,Nature.CREASE,Nature.SUGGESTIVE_CONTOUR,Nature.VALLEY,Nature.RIDGE]
			for nat in natures:
				if (self.current_edge.nature & nat) != 0:
					count=0
					while not it.is_end:
						ve = it.object
						if (ve.nature & nat) != 0:
							count = count+1
							winner = ve
							if not it.is_incoming:
								winnerOrientation = 1
							else:
								winnerOrientation = 0
						it.increment()
					if count != 1:
						winner = None
					break
		if winner is not None:
			# check whether this edge was part of the selection
			if winner.time_stamp != CF.get_time_stamp():
				#print("---", winner.id.first, winner.id.second)
				# nw let's compute the length of this connex non selected part:
				connexl = 0
				_cit = pyChainSilhouetteGenericIterator(0,0)
				_cit.begin = winner
				_cit.current_edge = winner
				_cit.orientation = winnerOrientation
				_cit.init()
				while _cit.is_end == 0 and _cit.object.time_stamp != CF.get_time_stamp():
					ve = _cit.object
					#print("-------- --------", ve.id.first, ve.id.second)
					connexl = connexl + ve.length_2d
					_cit.increment()
				if connexl > self._length:
					winner = None
		return winner
Exemplo n.º 4
0
	def shade(self, stroke):
		fe = CF.get_selected_fedge()
		id1 = fe.first_svertex.id
		id2 = fe.second_svertex.id
		#print(id1.first, id1.second)
		#print(id2.first, id2.second)
		it = stroke.stroke_vertices_begin()
		found = True
		foundfirst = True
		foundsecond = False
		while not it.is_end:
			cp = it.object
			if cp.first_svertex.id == id1 or cp.second_svertex.id == id1:
				foundfirst = True
			if cp.first_svertex.id == id2 or cp.second_svertex.id == id2:
				foundsecond = True
			if foundfirst and foundsecond:
				found = True
				break
			it.increment()
		if found:
			print("The selected Stroke id is: ", stroke.id.first, stroke.id.second)
Exemplo n.º 5
0
    def traverse(self, iter):
        winner = None
        it = AdjacencyIterator(iter)
        while not it.is_end:
            ve = it.object
            if self._isExternalContour(ve):
                if ve.time_stamp == CF.get_time_stamp():
                    winner = ve
            it.increment()

        self._nEdges = self._nEdges + 1
        if winner is None:
            orient = 1
            it = AdjacencyIterator(iter)
            while not it.is_end:
                ve = it.object
                if it.is_incoming:
                    orient = 0
                good = self.checkViewEdge(ve, orient)
                if good != 0:
                    winner = ve
                it.increment()
        return winner
Exemplo n.º 6
0
 def shade(self, stroke):
     fe = CF.get_selected_fedge()
     id1 = fe.first_svertex.id
     id2 = fe.second_svertex.id
     #print(id1.first, id1.second)
     #print(id2.first, id2.second)
     it = stroke.stroke_vertices_begin()
     found = True
     foundfirst = True
     foundsecond = False
     while not it.is_end:
         cp = it.object
         if cp.first_svertex.id == id1 or cp.second_svertex.id == id1:
             foundfirst = True
         if cp.first_svertex.id == id2 or cp.second_svertex.id == id2:
             foundsecond = True
         if foundfirst and foundsecond:
             found = True
             break
         it.increment()
     if found:
         print("The selected Stroke id is: ", stroke.id.first,
               stroke.id.second)
Exemplo n.º 7
0
	def traverse(self, iter):
		winner = None
		it = AdjacencyIterator(iter)
		while not it.is_end:
			ve = it.object
			if self._isExternalContour(ve):
				if ve.time_stamp == CF.get_time_stamp():
					winner = ve
			it.increment()
		
		self._nEdges = self._nEdges+1
		if winner is None:
			orient = 1
			it = AdjacencyIterator(iter)
			while not it.is_end:
				ve = it.object
				if it.is_incoming:
					orient = 0
				good = self.checkViewEdge(ve,orient)
				if good != 0:
					winner = ve
				it.increment()
		return winner
Exemplo n.º 8
0
    def traverse(self, iter):
        winner = None
        winnerOrientation = 0
        print(self.current_edge.id.first, self.current_edge.id.second)
        it = AdjacencyIterator(iter)
        tvertex = self.next_vertex
        if type(tvertex) is TVertex:
            mateVE = tvertex.get_mate(self.current_edge)
            while not it.is_end:
                ve = it.object
                if ve.id == mateVE.id:
                    winner = ve
                    if not it.is_incoming:
                        winnerOrientation = 1
                    else:
                        winnerOrientation = 0
                    break
                it.increment()
        else:
            ## case of NonTVertex
            natures = [
                Nature.SILHOUETTE, Nature.BORDER, Nature.CREASE,
                Nature.SUGGESTIVE_CONTOUR, Nature.VALLEY, Nature.RIDGE
            ]
            for nat in natures:
                if (self.current_edge.nature & nat) != 0:
                    count = 0
                    while not it.is_end:
                        ve = it.object
                        if (ve.nature & nat) != 0:
                            count = count + 1
                            winner = ve
                            if not it.is_incoming:
                                winnerOrientation = 1
                            else:
                                winnerOrientation = 0
                        it.increment()
                    if count != 1:
                        winner = None
                    break
        if winner is not None:
            # check whether this edge was part of the selection
            if winner.time_stamp != CF.get_time_stamp():
                #print("---", winner.id.first, winner.id.second)
                # if not, let's check whether it's short enough with
                # respect to the chain made without staying in the selection
                #------------------------------------------------------------
                # Did we compute the prospective chain length already ?
                if self._length == 0:
                    #if not, let's do it
                    _it = pyChainSilhouetteGenericIterator(0, 0)
                    _it.begin = winner
                    _it.current_edge = winner
                    _it.orientation = winnerOrientation
                    _it.init()
                    while not _it.is_end:
                        ve = _it.object
                        #print("--------", ve.id.first, ve.id.second)
                        self._length = self._length + ve.length_2d
                        _it.increment()
                        if _it.is_begin:
                            break
                    _it.begin = winner
                    _it.current_edge = winner
                    _it.orientation = winnerOrientation
                    if not _it.is_begin:
                        _it.decrement()
                        while (not _it.is_end) and (not _it.is_begin):
                            ve = _it.object
                            #print("--------", ve.id.first, ve.id.second)
                            self._length = self._length + ve.length_2d
                            _it.decrement()

                # let's do the comparison:
                # nw let's compute the length of this connex non selected part:
                connexl = 0
                _cit = pyChainSilhouetteGenericIterator(0, 0)
                _cit.begin = winner
                _cit.current_edge = winner
                _cit.orientation = winnerOrientation
                _cit.init()
                while _cit.is_end == 0 and _cit.object.time_stamp != CF.get_time_stamp(
                ):
                    ve = _cit.object
                    #print("-------- --------", ve.id.first, ve.id.second)
                    connexl = connexl + ve.length_2d
                    _cit.increment()
                if (connexl > self._percent * self._length) or (
                        connexl > self._absLength):
                    winner = None
        return winner
Exemplo n.º 9
0
 def init(self):
     self._timeStamp = CF.get_time_stamp() + self._nRounds
Exemplo n.º 10
0
 def __init__(self, nRounds=3, stayInSelection=True):
     ChainingIterator.__init__(self, stayInSelection, False, None, True)
     self._timeStamp = CF.get_time_stamp() + nRounds
     self._nRounds = nRounds
Exemplo n.º 11
0
	def traverse(self, iter):
		winner = None
		winnerOrientation = 0
		#print(self.current_edge.id.first, self.current_edge.id.second)
		it = AdjacencyIterator(iter)
		tvertex = self.next_vertex
		if type(tvertex) is TVertex:
			mateVE = tvertex.get_mate(self.current_edge)
			while not it.is_end:
				ve = it.object
				if ve.id == mateVE.id:
					winner = ve
					if not it.is_incoming:
						winnerOrientation = 1
					else:
						winnerOrientation = 0
					break
				it.increment()
		else:
			## case of NonTVertex
			natures = [Nature.SILHOUETTE,Nature.BORDER,Nature.CREASE,Nature.SUGGESTIVE_CONTOUR,Nature.VALLEY,Nature.RIDGE]
			for nat in natures:
				if (self.current_edge.nature & nat) != 0:
					count=0
					while not it.is_end:
						ve = it.object
						if (ve.nature & nat) != 0:
							count = count+1
							winner = ve
							if not it.is_incoming:
								winnerOrientation = 1
							else:
								winnerOrientation = 0
						it.increment()
					if count != 1:
						winner = None
					break
		if winner is not None:
			# check whether this edge was part of the selection
			if winner.time_stamp != CF.get_time_stamp():
				#print("---", winner.id.first, winner.id.second)
				# if not, let's check whether it's short enough with
				# respect to the chain made without staying in the selection
				#------------------------------------------------------------
				# Did we compute the prospective chain length already ?
				if self._length == 0:
					#if not, let's do it
					_it = pyChainSilhouetteGenericIterator(0,0)
					_it.begin = winner
					_it.current_edge = winner
					_it.orientation = winnerOrientation
					_it.init()
					while not _it.is_end:
						ve = _it.object
						#print("--------", ve.id.first, ve.id.second)
						self._length = self._length + ve.length_2d
						_it.increment()
						if _it.is_begin:
							break;
					_it.begin = winner
					_it.current_edge = winner
					_it.orientation = winnerOrientation
					if not _it.is_begin:
						_it.decrement()
						while (not _it.is_end) and (not _it.is_begin):
							ve = _it.object
							#print("--------", ve.id.first, ve.id.second)
							self._length = self._length + ve.length_2d
							_it.decrement()

				# let's do the comparison:
				# nw let's compute the length of this connex non selected part:
				connexl = 0
				_cit = pyChainSilhouetteGenericIterator(0,0)
				_cit.begin = winner
				_cit.current_edge = winner
				_cit.orientation = winnerOrientation
				_cit.init()
				while _cit.is_end == 0 and _cit.object.time_stamp != CF.get_time_stamp():
					ve = _cit.object
					#print("-------- --------", ve.id.first, ve.id.second)
					connexl = connexl + ve.length_2d
					_cit.increment()
				if (connexl > self._percent * self._length) or (connexl > self._absLength):
					winner = None
		return winner
Exemplo n.º 12
0
	def init(self):
		self._timeStamp = CF.get_time_stamp()+self._nRounds
Exemplo n.º 13
0
	def __init__(self, nRounds=3, stayInSelection=True):
		ChainingIterator.__init__(self, stayInSelection, False, None, True)
		self._timeStamp = CF.get_time_stamp()+nRounds
		self._nRounds = nRounds