Example #1
0
        def _validate_(self):
	    mc.file(new=True,f=True)
            self.int_iterations = int(cgmValid.valueArg(self.d_kws['iterations'],noneValid=False))
            self.int_children = int(cgmValid.valueArg(self.d_kws['childrenCount'],noneValid=False))
	    
            self.l_valueBuffer = [i for i in range(self.int_iterations)]
            self.log_debug("Debug in _validate_")
            #For each of our test values, we're gonna create a transform and store it
            self.md_rootToChildren = {}
            self.l_times_1 = []
	    self.l_times_2 = []
	    self.l_roots_1  = []
	    self.l_roots_2 = []
 def test_numberNotInRangeHigh(self):
     self.assertFalse(
         validateArgs.valueArg(
             numberToCheck=42,
             inRange=[0,41]
         )
     )
 def test_numberNotInRangeLow(self):
     self.assertFalse(
         validateArgs.valueArg(
             numberToCheck=42,
             inRange=[44,99]
         )
     )
 def test_isEquivalentNotEqual(self):
     self.assertFalse(
         validateArgs.valueArg(
             numberToCheck=42,
             isEquivalent=4.2
         )
     )
 def test_isValueNotEqual(self):
     self.assertFalse(
         validateArgs.valueArg(
             numberToCheck=42,
             isValue=-42
         )
     )
Example #6
0
def frameRate_set(arg):
    _str_func = 'frameRate_set'
    log.debug(cgmGEN.logString_start(_str_func))

    if VALID.valueArg(arg):
        _arg = '{0}fps'.format(arg)

    else:
        d_validArgs = {
            'ntsc': ['n', 'ntsc'],
            'pal': ['p', 'pal'],
            'film': ['f', 'film'],
            'game': ['g', 'game'],
            'ntscf': ['ntscf']
        }

        _arg = VALID.kw_fromDict(arg,
                                 d_validArgs,
                                 calledFrom=_str_func,
                                 noneValid=True)

    if not _arg:
        _arg = arg

    log.debug(
        cgmGEN.logString_msg(_str_func,
                             "| arg: {0} | validated: {1}".format(arg, _arg)))

    mc.currentUnit(time=_arg)
Example #7
0
        def _validate(self):
            #>> validate ============================================================================
            self.mi_crv = cgmMeta.validateObjArg(self.d_kws['crvToLoft'],
                                                 cgmMeta.cgmObject,
                                                 noneValid=False,
                                                 mayaType=['nurbsCurve'])
            try:
                self.mi_target = cgmMeta.validateObjArg(
                    self.d_kws['aimPointObject'],
                    cgmMeta.cgmObject,
                    noneValid=False)
            except:
                VALID.valueArg
            #self._str_funcCombined = self._str_funcCombined + "(%s,%s)"%(self.mi_obj.p_nameShort,self.mi_targetSurface.p_nameShort)
            self.f_offset = VALID.valueArg(self.d_kws['f_offset'],
                                           calledFrom=self._str_funcCombined)
            self.d_info = {
                'l_eps': self.mi_crv.getComponents('ep'),
                'l_cvs': self.mi_crv.getComponents('cv'),
                'l_constraints': [],
                'ml_locators': [],
                'l_locPos': []
            }

            #Running Lists ============================================================================
            self.md_return = {}
 def test_maxValueNoAutoClamp(self):
     self.assertFalse(
         validateArgs.valueArg(
             numberToCheck=42,
             maxValue=27,
             autoClamp=False
         )
     )
    def test_simpleFloat(self):
        '''
        Confirm that the function will return the same value if 
        it is passed an int.
        '''
        arg = 1.999999

        self.assertEqual(
            validateArgs.valueArg(arg, noneValid=True), 
            arg,
            "validateArgs.valueArg did not return the arg "+\
            "it was passed when noneValid=True")

        self.assertEqual(
            validateArgs.valueArg(arg, noneValid=False), 
            arg,
            "validateArgs.valueArg did not return the arg "+\
            "it was passed when noneValid=False")
Example #10
0
    def test_simpleFloat(self):
        '''
        Confirm that the function will return the same value if 
        it is passed an int.
        '''
        arg = 1.999999

        self.assertEqual(
            validateArgs.valueArg(arg, noneValid=True),
            arg,
            "validateArgs.valueArg did not return the arg "+\
            "it was passed when noneValid=True")

        self.assertEqual(
            validateArgs.valueArg(arg, noneValid=False),
            arg,
            "validateArgs.valueArg did not return the arg "+\
            "it was passed when noneValid=False")
 def validateModifier(self):
     _modifier = self._d_fromUI.get('modifier', self._d_kws['modifier'])
     if _modifier is None:
         return False
     elif cgmValid.stringArg(_modifier):
         if _modifier.lower() in cgmHotkeyer._l_modifierOptions:
             return _modifier
         else:return False
     elif cgmValid.valueArg(_modifier, inRange = [0,len(cgmHotkeyer._l_modifierOptions)]):
         return cgmHotkeyer._l_modifierOptions[_modifier]
     return False
Example #12
0
 def validateModifier(self):
     _modifier = self._d_fromUI.get('modifier', self._d_kws['modifier'])
     if _modifier is None:
         return False
     elif cgmValid.stringArg(_modifier):
         if _modifier.lower() in cgmHotkeyer._l_modifierOptions:
             return _modifier
         else:return False
     elif cgmValid.valueArg(_modifier, inRange = [0,len(cgmHotkeyer._l_modifierOptions)]):
         return cgmHotkeyer._l_modifierOptions[_modifier]
     return False
Example #13
0
 def _validate_(self):
     self.int_value = int(cgmValid.valueArg(self.d_kws['value'],noneValid=False))
     self.l_valueBuffer = [i for i in range(self.int_value)]
     self.b_testException = cgmValid.boolArg(self.d_kws['testException'])
     self.log_debug("Debug in _validate_")
     #For each of our test values, we're gonna create a transform and store it
     self.md_idxToObj = {}
     self.md_shortNameToIdx = {}
     self.log_error("Test error")
     self.log_warning("Test warning")	    
     self.log_toDo("Note to self -- do this sometime")
Example #14
0
	def __func__(self):
	    """
	    """	    
	    self.f_factor = cgmValid.valueArg(self.d_kws['factor'],minValue=0,maxValue=1.0)
	    self.mi_crv = cgmMeta.validateObjArg(self.d_kws['curve'],mayaType='nurbsCurve',noneValid=False)
	    #self._str_funcCombined = self._str_funcCombined + "('{0}')".format(self.mi_crv.p_nameShort)	    
	    try:self.str_bufferU = mc.ls("{0}{1}".format(self.mi_crv.mNode,".u[*]"))[0]
	    except Exception,error:raise Exception,"ls fail | error: {0}".format(error)
	    self.f_maxU = float(self.str_bufferU.split(':')[-1].split(']')[0])	
	    
	    return mc.pointPosition("%s.u[%f]"%(self.mi_crv.mNode,self.f_maxU*self.f_factor), w=True)
Example #15
0
	def _validate(self):
	    """
	    Validate the args, get our data
	    """
	    self.mi_baseCurve = cgmMeta.validateObjArg(self.d_kws['baseCurve'],mayaType='nurbsCurve',noneValid=False)
	    self.mi_targetCurve = cgmMeta.validateObjArg(self.d_kws['targetCurve'],mayaType='nurbsCurve',noneValid=True)
	    self.f_threshold = cgmValid.valueArg(self.d_kws['mirrorThreshold'],calledFrom = self._str_funcCombined)
	    
	    self.str_mirrorAcross = cgmValid.stringArg(self.d_kws['mirrorAcross'],noneValid=True)
	    self.int_across = 0#This is the index to check -- ie pos[0] for x
	    if self.str_mirrorAcross.lower() != 'x':
		raise NotImplementedError, "Only implmeneted x mirror so far | kw: %s"%self.str_mirrorAcross
Example #16
0
	def _validate(self):
	    #>> validate ============================================================================
	    self.mi_crv = cgmMeta.validateObjArg(self.d_kws['crvToLoft'],cgmMeta.cgmObject,noneValid=False,mayaType = ['nurbsCurve'])
	    try:self.mi_target = cgmMeta.validateObjArg(self.d_kws['aimPointObject'],cgmMeta.cgmObject,noneValid=False)
	    except:
		cgmValid.valueArg
	    #self._str_funcCombined = self._str_funcCombined + "(%s,%s)"%(self.mi_obj.p_nameShort,self.mi_targetSurface.p_nameShort)	    
	    self.f_offset = cgmValid.valueArg(self.d_kws['f_offset'], calledFrom=self._str_funcCombined)
	    self.d_info = {'l_eps':self.mi_crv.getComponents('ep'),
	                   'l_cvs':self.mi_crv.getComponents('cv'),
	                   'l_constraints':[],
	                   'ml_locators':[],
	                   'l_locPos':[]}
	    
	    #Running Lists ============================================================================
	    self.md_return = {}
Example #17
0
        def _validate(self):
            #>> validate ============================================================================
            self.mi_obj = cgmMeta.validateObjArg(self.d_kws['objToAttach'],
                                                 cgmMeta.cgmObject,
                                                 noneValid=False)
            self.mi_targetSurface = cgmMeta.validateObjArg(
                self.d_kws['targetSurface'], noneValid=False)
            self.mi_orientation = VALID.simpleOrientation(
                self.d_kws['orientation'])
            self._str_funcCombined = self._str_funcCombined + "(%s,%s)" % (
                self.mi_obj.p_nameShort, self.mi_targetSurface.p_nameShort)

            self.l_shapes = mc.listRelatives(self.mi_targetSurface.mNode,
                                             shapes=True)
            if len(self.l_shapes) > 1:
                log.debug(
                    "More than one shape found. Using 0. targetSurface : %s | shapes: %s"
                    % (self.mi_targetSurface.p_nameShort, self.l_shapes))
            self.mi_shape = cgmMeta.validateObjArg(self.l_shapes[0],
                                                   cgmMeta.cgmNode,
                                                   noneValid=False)
            self.b_createControlLoc = VALID.boolArg(
                self.d_kws['createControlLoc'],
                calledFrom=self._str_funcCombined)
            self.b_createUpLoc = VALID.boolArg(
                self.d_kws['createUpLoc'], calledFrom=self._str_funcCombined)
            self.b_parentToFollowGroup = VALID.boolArg(
                self.d_kws['parentToFollowGroup'],
                calledFrom=self._str_funcCombined)
            self.b_attachControlLoc = VALID.boolArg(
                self.d_kws['attachControlLoc'],
                calledFrom=self._str_funcCombined)
            self.b_connectOffset = VALID.boolArg(
                self.d_kws['connectOffset'], calledFrom=self._str_funcCombined)
            self.b_pointAttach = VALID.boolArg(
                self.d_kws['pointAttach'], calledFrom=self._str_funcCombined)

            self.f_offset = VALID.valueArg(self.d_kws['f_offset'],
                                           calledFrom=self._str_funcCombined)
            #Get info ============================================================================
            self.d_closestInfo = distance.returnClosestPointOnSurfaceInfo(
                self.mi_obj.mNode, self.mi_targetSurface.mNode)
            self.d_closestInfo = DIST.get_closest_point_data_from_mesh(
                self.mi_obj.mNode, self.mi_targetSurface.mNode)
            #Running Lists ============================================================================
            self.md_return = {}
def frameRate_set(arg, fixFractionalSlider=True):
    _str_func = 'frameRate_set'
    log.debug(cgmGEN.logString_start(_str_func))

    if VALID.valueArg(arg):
        _arg = '{0}fps'.format(arg)

    else:
        d_validArgs = {
            'ntsc': ['n', 'ntsc'],
            'pal': ['p', 'pal'],
            'film': ['f', 'film'],
            'game': ['g', 'game'],
            'ntscf': ['ntscf']
        }

        _arg = VALID.kw_fromDict(arg,
                                 d_validArgs,
                                 calledFrom=_str_func,
                                 noneValid=True)

    if not _arg:
        _arg = arg

    log.debug(
        cgmGEN.logString_msg(_str_func,
                             "| arg: {0} | validated: {1}".format(arg, _arg)))

    mc.currentUnit(time=_arg)

    if fixFractionalSlider:
        log.debug(cgmGEN.logString_msg(_str_func, 'fixFractionalSlider...'))
        _current = mc.currentTime(q=True)
        mc.playbackOptions(
            animationStartTime=int(
                mc.playbackOptions(q=True, animationStartTime=True)),
            animationEndTime=int(
                mc.playbackOptions(q=True, animationEndTime=True)),
            max=int(mc.playbackOptions(q=True, max=True)),
            min=int(mc.playbackOptions(q=True, min=True)),
        )
        mc.currentTime(int(_current))
Example #19
0
	def _validate(self):
	    #>> validate ============================================================================
	    self.mi_obj = cgmMeta.validateObjArg(self.d_kws['objToAttach'],cgmMeta.cgmObject,noneValid=False)
	    self.mi_targetSurface = cgmMeta.validateObjArg(self.d_kws['targetSurface'],mayaType='nurbsSurface',noneValid=False)
	    self.mi_orientation = cgmValid.simpleOrientation( self.d_kws['orientation'] )
	    self._str_funcCombined = self._str_funcCombined + "(%s,%s)"%(self.mi_obj.p_nameShort,self.mi_targetSurface.p_nameShort)
	    
	    self.l_shapes = mc.listRelatives(self.mi_targetSurface.mNode,shapes=True)
	    if len(self.l_shapes)>1:
		log.debug( "More than one shape found. Using 0. targetSurface : %s | shapes: %s"%(self.mi_targetSurface.p_nameShort,self.l_shapes) )
	    self.mi_shape = cgmMeta.validateObjArg(self.l_shapes[0],cgmMeta.cgmNode,noneValid=False)
	    self.b_createControlLoc = cgmValid.boolArg(self.d_kws['createControlLoc'],calledFrom=self._str_funcCombined)
	    self.b_createUpLoc = cgmValid.boolArg(self.d_kws['createUpLoc'],calledFrom=self._str_funcCombined)
	    self.b_parentToFollowGroup = cgmValid.boolArg(self.d_kws['parentToFollowGroup'],calledFrom=self._str_funcCombined)
	    self.b_attachControlLoc = cgmValid.boolArg(self.d_kws['attachControlLoc'],calledFrom=self._str_funcCombined)
	    self.b_connectOffset = cgmValid.boolArg(self.d_kws['connectOffset'],calledFrom=self._str_funcCombined)
	    self.b_pointAttach = cgmValid.boolArg(self.d_kws['pointAttach'],calledFrom=self._str_funcCombined)
	    
	    self.f_offset = cgmValid.valueArg(self.d_kws['f_offset'], calledFrom=self._str_funcCombined)
	    #Get info ============================================================================
	    self.d_closestInfo = distance.returnClosestPointOnSurfaceInfo(self.mi_obj.mNode,self.mi_targetSurface.mNode)
	    
	    #Running Lists ============================================================================
	    self.md_return = {}
Example #20
0
 def test_maxValueNoAutoClamp(self):
     self.assertFalse(
         validateArgs.valueArg(numberToCheck=42,
                               maxValue=27,
                               autoClamp=False))
Example #21
0
	def __func__(self):
	    """
	    """
	    _str_funcName = self._str_funcCombined
	    points = self.d_kws['points']
	    int_points = cgmValid.valueArg(self.d_kws['points'],minValue=1,calledFrom = _str_funcName)
	    f_insetSplitFactor = cgmValid.valueArg(self.d_kws['insetSplitFactor'],calledFrom = _str_funcName)	
	    f_startSplitFactor = cgmValid.valueArg(self.d_kws['startSplitFactor'],calledFrom = _str_funcName)		
	    f_minU = cgmValid.valueArg(self.d_kws['minU'], noneValid=True, calledFrom = _str_funcName)
	    f_maxU = cgmValid.valueArg(self.d_kws['maxU'], noneValid=True, calledFrom = _str_funcName)    
	    f_points = float(int_points)
	    int_spans = int(cgmValid.valueArg(self.d_kws['points'],minValue=5,autoClamp=True,calledFrom = _str_funcName))
	    b_cullStartEnd = cgmValid.boolArg(self.d_kws['cullStartEnd'], calledFrom = _str_funcName)
	    
	    if f_insetSplitFactor is not False or f_startSplitFactor is not False:
		if not isFloatEquivalent(f_minU,0):
		    raise StandardError,"Min U must be 0 when f_insetSplitFactor or f_startSplitFactor are used"
	    
	    try:#>>> Divide stuff
		#==========================	
		l_spanUPositions = []    
		l_uValues = [f_minU]
	
		if f_startSplitFactor is not False:
		    if points < 5:
			raise StandardError,"Need at least 5 points for startSplitFactor. Points : %s"%(points)
		    log.debug("%s >> f_startSplitFactor : %s"%(_str_funcName,f_startSplitFactor))  
		    #Figure out our u's
		    f_base = f_startSplitFactor * f_maxU 
		    l_uValues.append( f_base )
		    f_len = f_maxU - (f_base *2)	
		    int_toMake = f_points-4
		    f_factor = f_len/(int_toMake+1)
		    log.debug("%s >> f_maxU : %s"%(_str_funcName,f_maxU)) 
		    log.debug("%s >> f_len : %s"%(_str_funcName,f_len)) 	
		    log.debug("%s >> int_toMake : %s"%(_str_funcName,int_toMake)) 						
		    log.debug("%s >> f_base : %s"%(_str_funcName,f_base)) 			
		    log.debug("%s >> f_factor : %s"%(_str_funcName,f_factor))               
		    for i in range(1,int_points-3):
			l_uValues.append(((i*f_factor + f_base)))
		    l_uValues.append(f_maxU - f_base)
		    l_uValues.append(f_maxU)
		    log.debug("%s >> l_uValues : %s"%(_str_funcName,l_uValues))  	
		    
		elif f_insetSplitFactor is not False:
		    log.debug("%s >> f_insetSplitFactor : %s"%(_str_funcName,f_insetSplitFactor))  
		    #Figure out our u's
		    
		    f_base = f_insetSplitFactor * f_maxU 
		    f_len = f_maxU - (f_base *2)	
		    f_factor = f_len/(f_points-1)
		    
		    #f_base = (f_maxU - f_minU) * f_insetSplitFactor
		    #f_len = (f_maxU - f_base) - (f_minU + f_base)
		    #f_factor = f_len/(f_points-1)
		    log.debug("%s >> f_maxU : %s"%(_str_funcName,f_maxU)) 
		    log.debug("%s >> f_base : %s"%(_str_funcName,f_base)) 					    
		    log.debug("%s >> f_len : %s"%(_str_funcName,f_len)) 			
		    log.debug("%s >> f_factor : %s"%(_str_funcName,f_factor))               
		    for i in range(1,int_points-1):
			l_uValues.append(((i*f_factor)+f_base))
		    l_uValues.append(f_maxU)
		    log.debug("%s >> l_uValues : %s"%(_str_funcName,l_uValues))

		else:
		    #Figure out our u's
		    log.debug("%s >> Regular mode. Points = %s "%(_str_funcName,int_points))
		    if int_points == 1:
			l_uValues = [((f_maxU - f_minU)/2)+f_minU]
		    elif int_points == 2:
			l_uValues = [f_minU,f_maxU]
		    elif int_points == 3:
			l_uValues.append(((f_maxU - f_minU)/2)+f_minU)
			l_uValues.append(f_maxU)
		    else:
			f_factor = (f_maxU-f_minU)/(f_points-1)
			log.debug("%s >> f_maxU : %s"%(_str_funcName,f_maxU)) 
			log.debug("%s >> f_factor : %s"%(_str_funcName,f_factor))               
			for i in range(1,int_points-1):
			    l_uValues.append((i*f_factor)+f_minU)
			l_uValues.append(f_maxU)
		    log.debug("%s >> l_uValues : %s"%(_str_funcName,l_uValues))  
		    
		if b_cullStartEnd and len(l_uValues)>3:
		    l_uValues = l_uValues[1:-1]
	    except Exception,error:raise StandardError,"Divide fail | %s"%error
    
	    return l_uValues	    
    def chain_create(self, objs = None,
                     fwd = None, up=None,
                     name = None,
                     upSetup = "guess",
                     extendStart = None,
                     extendEnd = True,
                     mNucleus=None,
                     upControl = None,
                     aimUpMode = None,
                     **kws):
        
        _str_func = 'chain_create'
        
        if not objs:
            _sel = mc.ls(sl=1)
            if _sel:objs = _sel
        
        ml = cgmMeta.asMeta( objs, noneValid = True )
        ml_baseTargets = copy.copy(ml)
        
        if not ml:
            return log.warning("No objects passed. Unable to chain_create")
            
        if not name:
            name = ml[-1].p_nameBase
                    
        _idx = self.get_nextIdx()
        

        #Make our sub group...
        mGrp = self.doCreateAt(setClass=1)
        mGrp.p_parent = self
        mGrp.rename("chain_{0}_grp".format(name))
        mGrp.dagLock()
        self.connectChildNode(mGrp.mNode,'chain_{0}'.format(_idx),'owner')
        
        
        #holders and dat...
        ml_targets = []
        ml_posLocs = []
        ml_aim_locs = []
        
        fwd = fwd or self.fwd
        up = up or self.up
        upSetup = upSetup or self.upSetup
        extendStart = extendStart or self.extendStart
        extendEnd = extendEnd or self.extendEnd
        upControl = upControl or self.upControl
        aimUpMode = aimUpMode or self.aimUpMode
        
        #fwdAxis = simpleAxis(fwd)
        #upAxis = simpleAxis(up)

        fwdAxis = TRANS.closestAxisTowardObj_get(ml[0], ml[1])
        upAxis = TRANS.crossAxis_get(fwdAxis)

        mGrp.doStore('fwd', fwdAxis.p_string)
        mGrp.doStore('up', upAxis.p_string)

        #Curve positions...
        l_pos = []
        
        if upSetup == 'manual':
            if len(ml) < 2:
                log.debug(cgmGEN.logString_msg(_str_func, 'Single count. Adding extra handle.'))
                mLoc = ml[0].doLoc()
                mLoc.rename("chain_{0}_end_loc".format(name))
                _size = DIST.get_bb_size(ml[0],True,'max')
                mLoc.p_position = ml[0].getPositionByAxisDistance(fwdAxis.p_string,_size)
                ml.append(mLoc)
                mLoc.p_parent = mGrp
            
            for obj in ml:
                l_pos.append(obj.p_position)
                
                
            _v_baseDist = DIST.get_distance_between_points(l_pos[-1],l_pos[-2])
            _v_baseDist = MATHUTILS.Clamp(_v_baseDist, .5,None)

            _p_baseExtend = DIST.get_pos_by_axis_dist(ml[-1],
                                                      fwdAxis.p_string,
                                                      _v_baseDist)
            
            
            if extendEnd:
                log.debug(cgmGEN.logString_msg(_str_func, 'extendEnd...'))
                
                extendEnd = VALID.valueArg(extendEnd)
                
                if issubclass(type(extendEnd),bool):#VALID.boolArg(extendEnd):
                    log.debug(cgmGEN.logString_msg(_str_func, 'extendEnd | guess'))
                    l_pos.append(_p_baseExtend)
                elif extendEnd:
                    log.debug(cgmGEN.logString_msg(_str_func, 'extendEnd | {0}'.format(extendEnd)))
                    
                    l_pos.append( DIST.get_pos_by_axis_dist(ml[-1],
                                                            fwdAxis.p_string,
                                                            extendEnd ))                            
            else:
                l_pos.append( _p_baseExtend)
        
            if extendStart:
                f_extendStart = VALID.valueArg(extendStart)
                if f_extendStart:
                    l_pos.insert(0, DIST.get_pos_by_axis_dist(ml[0],
                                                              fwdAxis.inverse.p_string,
                                                              f_extendStart ))
                    
        else:
            log.debug(cgmGEN.logString_msg(_str_func, 'Resolving aim'))
            if len(ml) < 2:
                return log.error(cgmGEN.logString_msg(_str_func, 'Single count. Must use manual upSetup and aim/up args'))
            
            for obj in ml:
                l_pos.append(obj.p_position)
            
            _vecEnd = MATHUTILS.get_vector_of_two_points(l_pos[-2],l_pos[-1])
            if extendEnd:
                log.debug(cgmGEN.logString_msg(_str_func, 'extendEnd...'))
                
                extendEnd = VALID.valueArg(extendEnd)
                
                if issubclass(type(extendEnd),bool):#VALID.boolArg(extendEnd):
                    log.debug(cgmGEN.logString_msg(_str_func, 'extendEnd | guess'))
                    
                    l_pos.append( DIST.get_pos_by_vec_dist(l_pos[-1], _vecEnd,
                                                           (DIST.get_distance_between_points(l_pos[-2],l_pos[-1])/2)))
                elif extendEnd:
                    log.debug(cgmGEN.logString_msg(_str_func, 'extendStart | {0}'.format(extendEnd)))
                    
                    l_pos.append( DIST.get_pos_by_vec_dist(l_pos[-1], _vecEnd,
                                                           extendEnd))
            
            if extendStart:
                f_extendStart = VALID.valueArg(extendStart)
                if f_extendStart:
                    log.debug(cgmGEN.logString_msg(_str_func, 'extendStart...'))
                    
                    _vecStart = MATHUTILS.get_vector_of_two_points(l_pos[1],l_pos[0])
                    
                    l_pos.insert(0, DIST.get_pos_by_vec_dist(l_pos[0],
                                                             _vecStart,
                                                             f_extendStart))

        #pprint.pprint(l_pos)
        
        #for i,p in enumerate(l_pos):
        #    LOC.create(position=p,name='p_{0}'.format(i))
            
        crv = CORERIG.create_at(create='curve',l_pos= l_pos, baseName = name)
        mInCrv = cgmMeta.asMeta(crv)
        mInCrv.rename("{0}_inCrv".format(name))
        mGrp.connectChildNode(mInCrv.mNode,'mInCrv')
        mc.select(cl=1)

        # make the dynamic setup
        log.debug(cgmGEN.logString_sub(_str_func,'dyn setup'))
        b_existing = False
        b_existing_nucleus = False
        
        mHairSys = self.getMessageAsMeta('mHairSysShape')
        if mHairSys:
            mHairSysDag = mHairSys.getTransform(asMeta=1)
            log.info(cgmGEN.logString_msg(_str_func,'Using existing system: {0}'.format(mHairSys.mNode)))
            mc.select(mHairSysDag.mNode, add=True)
            b_existing = True
            
        if self.useExistingNucleus or mNucleus:
            mNucleus = self.get_nucleus(mNucleus)
            if mNucleus:
                #mc.select(mNucleus.mNode,add=1)
                b_existing_nucleus = True
                log.info(cgmGEN.logString_msg(_str_func,'Using existing nucleus: {0}'.format(mNucleus.mNode)))
                self.connectChildNode(mNucleus.mNode,'mNucleus')
        
        mc.select(mInCrv.mNode,add=True)
        mel.eval('makeCurvesDynamic 2 { "0", "0", "1", "1", "0" }')

        # get relevant nodes
        follicle = mc.listRelatives(mInCrv.mNode,parent=True)[0]
        mFollicle = cgmMeta.asMeta(follicle)
        mFollicle.rename("{0}_foll".format(name))
        parent = mFollicle.getParent(asMeta=1)
        mFollicle.p_parent = mGrp
        mFollicleShape = mFollicle.getShapes(1)[0]
        mc.delete(parent.mNode)
        
        _follicle = mFollicle.mNode
        mGrp.connectChildNode(mFollicle.mNode,'mFollicle','group')
        
        follicleShape = mFollicleShape.mNode#mc.listRelatives(mFollicle.mNode, shapes=True)[0]
        _hairSystem = mc.listRelatives( mc.listConnections('%s.currentPosition' % follicleShape)[0],
                                        shapes=True)[0]
        if not b_existing:
            mHairSys = cgmMeta.asMeta(_hairSystem)
            mHairSysDag = mHairSys.getTransform(asMeta=1)
            
            mHairSysDag.rename("{0}_hairSys".format(self.baseName))
            self.connectChildNode(mHairSysDag.mNode,'mHairSysDag','owner')
            self.connectChildNode(mHairSys.mNode,'mHairSysShape','owner')
            
            mHairSysDag.p_parent = self
            _hairSystem = mHairSys.mNode
            
        outCurve = mc.listConnections('%s.outCurve' % _follicle)[0]
        mCrv = cgmMeta.asMeta(outCurve)
        parent = mCrv.getParent(asMeta=1)

        outCurveShape = mc.listRelatives(mCrv.mNode, shapes=True)[0]
        mCrv.p_parent = mGrp.mNode
        
        mc.delete(parent.mNode)
        _nucleus = mc.listConnections( '%s.currentState' % mHairSys.mNode )[0]
        
        if not b_existing_nucleus:
            mNucleus = cgmMeta.asMeta(_nucleus)
            mNucleus.rename("cgmDynFK_nucleus")            
            #self.connectChildNode(mNucleus.mNode,'mNucleus','owner')
            self.connectChildNode(mNucleus.mNode,'mNucleus')
            
            if self.startFrame is not None:
                mNucleus.startFrame = self.startFrame
        else:
            #Because maya is crappy we gotta manually wire the existing nucleus
            ##startFrame out to startFrame in
            ##outputObjects[x] - nextState
            ##shape.currentState>inputActive[x]
            ##shape.startState>inputActiveStart[x]
            if cgmMeta.asMeta(_nucleus).mNode != mNucleus.mNode:
                mc.delete(_nucleus)

            _useNucleus = mNucleus.mNode

            """
            _useIdx = ATTR.get_nextCompoundIndex(mNucleus.mNode,'outputObjects')
            log.info("useIdx: {0}".format(_useIdx))
            ATTR.connect('{0}.outputObjects[{1}]'.format(_useNucleus,_useIdx),'{0}.nextState'.format(_hairSystem))
            ATTR.connect('{0}.currentState'.format(_hairSystem),'{0}.inputActive[{1}]'.format(_useNucleus,_useIdx))
            ATTR.connect('{0}.startState'.format(_hairSystem),'{0}.inputActiveStart[{1}]'.format(_useNucleus,_useIdx))"""            
            
            
        mParent = ml[0].getParent(asMeta=1)
        if not mParent:
            mParent = ml[0].doGroup(1,1,
                                    asMeta=True,
                                    typeModifier = 'dynFKParent',
                                    setClass='cgmObject')
        #else:
            #mParent.getParent(asMeta=1)
        
        mGrp.connectChildNode(mCrv.mNode,'mOutCrv','group')

        #self.follicles.append(follicle)
        #self.outCurves.append(outCurve)
        
        # set default properties
        mFollicleShape.pointLock = 1
        #mc.setAttr( '%s.pointLock' % follicleShape, 1 )
        mc.parentConstraint(ml[0].getParent(), _follicle, mo=True)
        
        # create locators on objects
        locators = []
        prs = []
        
        ml_locs = []
        ml_aims = []
        ml_prts = []
        
        _upVector = None
        if upSetup == 'guess':
            log.debug(cgmGEN.logString_msg(_str_func, 'Resolving up/aim'))
            poci_base = CURVES.create_pointOnInfoNode(mInCrv.mNode,1)
            mPoci_base = cgmMeta.asMeta(poci_base)
            
            _upVector = mPoci_base.normalizedNormal
            log.debug(cgmGEN.logString_msg(_str_func, "upVector: {0}".format(_upVector)))        
        
        
        #Let's make an up object as the parent of the root isn't good enough
        mUp = ml[0].doCreateAt(setClass=1)
        mUp.rename("chain_{0}_up".format(name))
        mUp.p_parent = mGrp
        
        if _upVector:
            SNAP.aim_atPoint(mUp.mNode,
                             DIST.get_pos_by_vec_dist(mUp.p_position,
                                                      _upVector,
                                                      10),aimAxis='y+',upAxis='z+')
        
        if upControl:
            log.debug(cgmGEN.logString_msg(_str_func,'upControl'))
            if len(ml_baseTargets)>1:
                sizeControl = DIST.get_distance_between_targets([mObj.mNode for mObj in ml_baseTargets],True)
            else:
                sizeControl = DIST.get_bb_size(ml[0],True,'max')
                
            crv = CURVES.create_controlCurve(mUp.mNode,'arrowSingle', size= sizeControl, direction = 'y+')
            CORERIG.shapeParent_in_place(mUp.mNode, crv, False)
            mUpGroup = mUp.doGroup(True,True,
                                   asMeta=True,
                                   typeModifier = 'master',
                                   setClass='cgmObject')
            
            mc.parentConstraint(ml[0].getParent(), mUpGroup.mNode, mo=True)
            
            
        else:
            mc.parentConstraint(ml[0].getParent(), mUp.mNode, mo=True)
            
        
        # create control joint chain
        mc.select(cl=True)
        chain = []
        for obj in ml:
            if len(chain) > 0:
                mc.select(chain[-1])
            jnt = mc.joint(name='%s_%s_jnt' % (name, obj.p_nameBase))
            SNAP.matchTarget_set(jnt, obj.mNode)
            mObj = cgmMeta.asMeta(jnt)
            mObj.doSnapTo(mObj.getMessageAsMeta('cgmMatchTarget'))

            chain.append(jnt)

        mc.parent(chain[0], _follicle)
        mInCrv.p_parent = mGrp

        mc.bindSkin(mInCrv.mNode, chain[0], ts=True)


        log.debug(cgmGEN.logString_msg(_str_func,'aimUpMode: {0}'.format(aimUpMode)))
        
        
        for i, mObj in enumerate(ml):
            if not i:
                mUpUse = mUp
            else:
                mUpUse = ml_locs[-1]
                
            mLoc = cgmMeta.asMeta( LOC.create(mObj.getNameLong()) )
            loc = mLoc.mNode
            ml_locs.append(mLoc)
            #loc = LOC.create(mObj.getNameLong())
            
            mAim = mLoc.doGroup(False,False,
                                 asMeta=True,
                                 typeModifier = 'aim',
                                 setClass='cgmObject')
            ml_aims.append(mAim)
            #aimNull = mc.group(em=True)
            #aimNull = mc.rename('%s_aim' % mObj.getShortName())
            
            poc = CURVES.create_pointOnInfoNode(outCurveShape)
#mc.createNode('pointOnCurveInfo', name='%s_pos' % loc)
            mPoci_obj = cgmMeta.asMeta(poc)
            mPoci_obj.rename('%s_pos' % loc)
            pocAim = CURVES.create_pointOnInfoNode(outCurveShape)
            #mc.createNode('pointOnCurveInfo', name='%s_aim' % loc)
            
            pr = CURVES.getUParamOnCurve(loc, outCurve)
            mPoci_obj.parameter = pr
            
            #mc.connectAttr( '%s.worldSpace[0]' % outCurveShape, '%s.inputCurve' % poc, f=True )
            #mc.connectAttr( '%s.worldSpace[0]' % outCurveShape, '%s.inputCurve' % pocAim, f=True )

            #mc.setAttr( '%s.parameter' % poc, pr )
            
            if i < len(ml)-1:
                nextpr = CURVES.getUParamOnCurve(ml[i+1], outCurve)
                mc.setAttr('%s.parameter' % pocAim, (nextpr))# + pr))# * .5)
            else:
                if extendStart:
                    mc.setAttr( '%s.parameter' % pocAim, len(ml)+1 )                    
                else:
                    mc.setAttr( '%s.parameter' % pocAim, len(ml) )
                    
                    
            
            mLocParent = mLoc.doGroup(False,False,
                                      asMeta=True,
                                      typeModifier = 'pos',
                                      setClass='cgmObject')
            ml_prts.append(mLocParent)
            #locParent = mc.group(em=True)
            #locParent = mc.rename( '%s_pos' % mObj.getShortName() )

            mc.connectAttr( '%s.position' % mPoci_obj.mNode, '%s.translate' % mLocParent.mNode)
            mc.connectAttr( '%s.position' % pocAim, '%s.translate' % mAim.mNode)
            
            
            
            if aimUpMode == 'master':
                aimConstraint = mc.aimConstraint( mAim.mNode,
                                                  mLocParent.mNode,
                                                  aimVector=fwdAxis.p_vector,
                                                  upVector = upAxis.p_vector,
                                                  worldUpType = "objectrotation",
                                                  worldUpVector = upAxis.p_vector,
                                                  worldUpObject = mUp.mNode )
            elif aimUpMode == 'orientToMaster':
                mc.orientConstraint( mUp.mNode,
                                     mLocParent.mNode,
                                     maintainOffset = 1)
                
            elif aimUpMode == 'sequential':
                aimConstraint = mc.aimConstraint( mAim.mNode,
                                                  mLocParent.mNode,
                                                  aimVector=fwdAxis.p_vector,
                                                  upVector = upAxis.p_vector,
                                                  worldUpType = "objectrotation",
                                                  worldUpVector = upAxis.p_vector,
                                                  worldUpObject = mUpUse.mNode )                
            elif aimUpMode == 'joint':
                aimConstraint = mc.aimConstraint( mAim.mNode,
                                                  mLocParent.mNode,
                                                  aimVector=fwdAxis.p_vector,
                                                  upVector = upAxis.p_vector,
                                                  worldUpType = "objectrotation",
                                                  worldUpVector = upAxis.p_vector,
                                                  worldUpObject = chain[i] )  
            elif aimUpMode == 'curveNormal':
                mUpLoc = mLoc.doGroup(False,False,
                                      asMeta=True,
                                      typeModifier = 'up',
                                      setClass='cgmObject')
                mUpLoc.p_parent = mLocParent
                
                aimConstraint = mc.aimConstraint( mAim.mNode,
                                                  mLocParent.mNode,
                                                  aimVector=fwdAxis.p_vector,
                                                  upVector = upAxis.p_vector,
                                                  worldUpType = "object")
                
                mPlusMinusAverage = cgmMeta.cgmNode(name="{0}_pma".format(mObj.p_nameBase),
                                                    nodeType = 'plusMinusAverage')
                mPlusMinusAverage.operation = 3
                
                mPoci_obj.doConnectOut('position','{0}.input3D[0]'.format(mPlusMinusAverage.mNode))
                mPoci_obj.doConnectOut('normalizedNormal','{0}.input3D[1]'.format(mPlusMinusAverage.mNode))
                mUpLoc.doConnectIn('translate','{0}.output3D'.format(mPlusMinusAverage.mNode))

            
            
            mLoc.p_parent = mLocParent
            mAim.p_parent = mGrp
            mLocParent.p_parent = mGrp
            
            #mc.parent(loc, locParent)
        
        mCrv.rename("{0}_outCrv".format(name))
        mCrvParent = mCrv.getParent(asMeta=1)
        mCrvParent.p_parent = mGrp
        
        mGrp.msgList_connect('mLocs',ml_locs)
        mGrp.msgList_connect('mAims',ml_aims)
        mGrp.msgList_connect('mParents',ml_prts)
        mGrp.msgList_connect('mTargets',ml)
        mGrp.msgList_connect('mBaseTargets',ml_baseTargets)
        mGrp.msgList_connect('mObjJointChain',chain)
        mGrp.doStore('cgmName', name)

        mNucleus.doConnectOut('startFrame',"{0}.startFrame".format(mHairSys.mNode))
Example #23
0
	def __func__(self):
	    """
	    """
	    _str_funcName = self._str_funcCombined
	    curve = self.d_kws['curve']
	    points = self.d_kws['points']
	    mi_crv = cgmMeta.validateObjArg(self.d_kws['curve'],cgmMeta.cgmObject,mayaType='nurbsCurve',noneValid=False)
	    int_points = cgmValid.valueArg(self.d_kws['points'],minValue=1,calledFrom = _str_funcName)
	    f_insetSplitFactor = cgmValid.valueArg(self.d_kws['insetSplitFactor'],calledFrom = _str_funcName)	
	    f_startSplitFactor = cgmValid.valueArg(self.d_kws['startSplitFactor'],calledFrom = _str_funcName)		
	    f_kwMinU = cgmValid.valueArg(self.d_kws['minU'], noneValid=True, calledFrom = _str_funcName)	
	    f_kwMaxU = cgmValid.valueArg(self.d_kws['maxU'], noneValid=True, calledFrom = _str_funcName)	    
	    f_points = float(int_points)
	    int_spans = int(cgmValid.valueArg(self.d_kws['points'],minValue=5,autoClamp=True,calledFrom = _str_funcName))
	    b_rebuild = cgmValid.boolArg(self.d_kws['rebuildForSplit'],calledFrom = _str_funcName)
	    b_markPoints = cgmValid.boolArg(self.d_kws['markPoints'],calledFrom = _str_funcName)
	    b_reverseCurve = cgmValid.boolArg(self.d_kws['reverseCurve'],calledFrom = _str_funcName)
	    
	    try:#>>> Rebuild curve
		if b_rebuild:
		    useCurve = mc.rebuildCurve (curve, ch=0, rpo=0, rt=0, end=1, kr=0, kcp=0, kep=1, kt=0, s=int_spans, d=3, tol=0.001)[0]
		else:
		    useCurve = mc.duplicate(curve)[0]
		    
		if b_reverseCurve:
		    useCurve = mc.reverseCurve(useCurve,rpo = True)[0]
	    except Exception,error:raise StandardError,"Rebuild fail | %s"%error
	    
	    try:#>>> Divide stuff
		#==========================	
		l_spanUPositions = []
		str_bufferU = mc.ls("%s.u[*]"%useCurve)[0]
		log.debug("%s >> u list : %s"%(_str_funcName,str_bufferU))       
		f_maxU = float(str_bufferU.split(':')[-1].split(']')[0])
		l_uValues = [0]
		
		if points == 1:
		    l_uValues = [f_maxU/2]
		elif f_startSplitFactor is not False:
		    if points < 5:
			raise StandardError,"Need at least 5 points for startSplitFactor. Points : %s"%(points)
		    log.debug("%s >> f_startSplitFactor : %s"%(_str_funcName,f_startSplitFactor))  
		    #Figure out our u's
		    f_base = f_startSplitFactor * f_maxU 
		    l_uValues.append( f_base )
		    f_len = f_maxU - (f_base *2)	
		    int_toMake = f_points-4
		    f_factor = f_len/(int_toMake+1)
		    log.debug("%s >> f_maxU : %s"%(_str_funcName,f_maxU)) 
		    log.debug("%s >> f_len : %s"%(_str_funcName,f_len)) 	
		    log.debug("%s >> int_toMake : %s"%(_str_funcName,int_toMake)) 						
		    log.debug("%s >> f_base : %s"%(_str_funcName,f_base)) 			
		    log.debug("%s >> f_factor : %s"%(_str_funcName,f_factor))               
		    for i in range(1,int_points-3):
			l_uValues.append(((i*f_factor + f_base)))
		    l_uValues.append(f_maxU - f_base)
		    l_uValues.append(f_maxU)
		    log.debug("%s >> l_uValues : %s"%(_str_funcName,l_uValues))  	
		    
		elif f_insetSplitFactor is not False:
		    log.debug("%s >> f_insetSplitFactor : %s"%(_str_funcName,f_insetSplitFactor))  
		    #Figure out our u's
		    f_base = f_insetSplitFactor * f_maxU 
		    f_len = f_maxU - (f_base *2)	
		    f_factor = f_len/(f_points-1)
		    log.debug("%s >> f_maxU : %s"%(_str_funcName,f_maxU)) 
		    log.debug("%s >> f_len : %s"%(_str_funcName,f_len)) 			
		    log.debug("%s >> f_base : %s"%(_str_funcName,f_base)) 			
		    log.debug("%s >> f_factor : %s"%(_str_funcName,f_factor))               
		    for i in range(1,int_points-1):
			l_uValues.append((i*f_factor))
		    l_uValues.append(f_maxU)
		    log.debug("%s >> l_uValues : %s"%(_str_funcName,l_uValues))  			
		elif f_kwMinU is not False or f_kwMaxU is not False:
		    log.debug("%s >> Sub mode. "%(_str_funcName))
		    if f_kwMinU is not False:
			if f_kwMinU > f_maxU:
			    raise StandardError, "kw minU value(%s) cannot be greater than maxU(%s)"%(f_kwMinU,f_maxU)
			f_useMinU = f_kwMinU
		    else:f_useMinU = 0.0
		    if f_kwMaxU is not False:
			if f_kwMaxU > f_maxU:
			    raise StandardError, "kw maxU value(%s) cannot be greater than maxU(%s)"%(f_kwMaxU,f_maxU)	
			f_useMaxU = f_kwMaxU
		    else:f_useMaxU = f_maxU
		    
		    if int_points == 1:
			l_uValues = [(f_useMaxU - f_useMinU)/2]
		    elif int_points == 2:
			l_uValues = [f_useMaxU,f_useMinU]		    
		    else:
			l_uValues = [f_useMinU]
			f_factor = (f_useMaxU - f_useMinU)/(f_points-1)
			log.debug("%s >> f_maxU : %s"%(_str_funcName,f_useMaxU)) 
			log.debug("%s >> f_factor : %s"%(_str_funcName,f_factor))               
			for i in range(1,int_points-1):
			    l_uValues.append((i*f_factor) + f_useMinU)
			l_uValues.append(f_useMaxU)
		else:
		    #Figure out our u's
		    log.debug("%s >> Regular mode. Points = %s "%(_str_funcName,int_points))
		    if int_points == 3:
			l_uValues.append(f_maxU/2)
			l_uValues.append(f_maxU)
		    else:
			f_factor = f_maxU/(f_points-1)
			log.debug("%s >> f_maxU : %s"%(_str_funcName,f_maxU)) 
			log.debug("%s >> f_factor : %s"%(_str_funcName,f_factor))               
			for i in range(1,int_points-1):
			    l_uValues.append(i*f_factor)
			l_uValues.append(f_maxU)
		    log.debug("%s >> l_uValues : %s"%(_str_funcName,l_uValues))  
	    except Exception,error:raise StandardError,"Divide fail | %s"%error
    
	    for u in l_uValues:
		try:l_spanUPositions.append(mc.pointPosition("%s.u[%f]"%(useCurve,u)))
		except StandardError,error:raise StandardError,"Failed on pointPositioning: %s"%u			
	    log.debug("%s >> l_spanUPositions | len: %s | list: %s"%(_str_funcName,len(l_spanUPositions),l_spanUPositions))  
    
	    try:
		if b_markPoints:
		    ml_built = []
		    for i,pos in enumerate(l_spanUPositions):
			buffer =  mc.spaceLocator(n = "%s_u_%f"%(useCurve,(l_uValues[i])))[0] 
			ml_built.append( cgmMeta.cgmObject(buffer))
			log.debug("%s >> created : %s | at: %s"%(_str_funcName,ml_built[-1].p_nameShort,pos))              											
			mc.xform(ml_built[-1].mNode, t = (pos[0],pos[1],pos[2]), ws=True)
		    
		    if len(ml_built)>1:
			try:f_distance = distance.returnAverageDistanceBetweenObjects([o.mNode for o in ml_built]) * .5
			except StandardError,error:raise StandardError,"Average distance fail. Objects: %s| error: %s"%([o.mNode for o in ml_built],error)
			try:
			    for o in ml_built:
				o.scale = [f_distance,f_distance,f_distance]
			except StandardError,error:raise StandardError,"Scale fail : %s"%error
	    except StandardError,error:log.error("Mark points fail. error : %s"%(error))
	    mc.delete(useCurve)#Delete our use curve
	    return l_spanUPositions
Example #24
0
 def _validate_(self):
     self.int_value = int(cgmValid.valueArg(self.d_kws['value'],noneValid=False))
     self.l_valueBuffer = [i for i in range(self.int_value)]
     self.log_debug("Debug in _validate_")
Example #25
0
 def test_isEquivalentNotEqual(self):
     self.assertFalse(
         validateArgs.valueArg(numberToCheck=42, isEquivalent=4.2))
Example #26
0
 def test_numberNotInRangeHigh(self):
     self.assertFalse(
         validateArgs.valueArg(numberToCheck=42, inRange=[0, 41]))
Example #27
0
 def test_numberNotInRangeLow(self):
     self.assertFalse(
         validateArgs.valueArg(numberToCheck=42, inRange=[44, 99]))
Example #28
0
        def __func__(self):
            """
	    """
            _str_funcName = self._str_funcCombined
            points = self.d_kws['points']
            int_points = cgmValid.valueArg(self.d_kws['points'],
                                           minValue=1,
                                           calledFrom=_str_funcName)
            f_insetSplitFactor = cgmValid.valueArg(
                self.d_kws['insetSplitFactor'], calledFrom=_str_funcName)
            f_startSplitFactor = cgmValid.valueArg(
                self.d_kws['startSplitFactor'], calledFrom=_str_funcName)
            f_minU = cgmValid.valueArg(self.d_kws['minU'],
                                       noneValid=True,
                                       calledFrom=_str_funcName)
            f_maxU = cgmValid.valueArg(self.d_kws['maxU'],
                                       noneValid=True,
                                       calledFrom=_str_funcName)
            f_points = float(int_points)
            int_spans = int(
                cgmValid.valueArg(self.d_kws['points'],
                                  minValue=5,
                                  autoClamp=True,
                                  calledFrom=_str_funcName))
            b_cullStartEnd = cgmValid.boolArg(self.d_kws['cullStartEnd'],
                                              calledFrom=_str_funcName)

            if f_insetSplitFactor is not False or f_startSplitFactor is not False:
                if not isFloatEquivalent(f_minU, 0):
                    raise StandardError, "Min U must be 0 when f_insetSplitFactor or f_startSplitFactor are used"

            try:  #>>> Divide stuff
                #==========================
                l_spanUPositions = []
                l_uValues = [f_minU]

                if f_startSplitFactor is not False:
                    if points < 5:
                        raise StandardError, "Need at least 5 points for startSplitFactor. Points : %s" % (
                            points)
                    log.debug("%s >> f_startSplitFactor : %s" %
                              (_str_funcName, f_startSplitFactor))
                    #Figure out our u's
                    f_base = f_startSplitFactor * f_maxU
                    l_uValues.append(f_base)
                    f_len = f_maxU - (f_base * 2)
                    int_toMake = f_points - 4
                    f_factor = f_len / (int_toMake + 1)
                    log.debug("%s >> f_maxU : %s" % (_str_funcName, f_maxU))
                    log.debug("%s >> f_len : %s" % (_str_funcName, f_len))
                    log.debug("%s >> int_toMake : %s" %
                              (_str_funcName, int_toMake))
                    log.debug("%s >> f_base : %s" % (_str_funcName, f_base))
                    log.debug("%s >> f_factor : %s" %
                              (_str_funcName, f_factor))
                    for i in range(1, int_points - 3):
                        l_uValues.append(((i * f_factor + f_base)))
                    l_uValues.append(f_maxU - f_base)
                    l_uValues.append(f_maxU)
                    log.debug("%s >> l_uValues : %s" %
                              (_str_funcName, l_uValues))

                elif f_insetSplitFactor is not False:
                    log.debug("%s >> f_insetSplitFactor : %s" %
                              (_str_funcName, f_insetSplitFactor))
                    #Figure out our u's

                    f_base = f_insetSplitFactor * f_maxU
                    f_len = f_maxU - (f_base * 2)
                    f_factor = f_len / (f_points - 1)

                    #f_base = (f_maxU - f_minU) * f_insetSplitFactor
                    #f_len = (f_maxU - f_base) - (f_minU + f_base)
                    #f_factor = f_len/(f_points-1)
                    log.debug("%s >> f_maxU : %s" % (_str_funcName, f_maxU))
                    log.debug("%s >> f_base : %s" % (_str_funcName, f_base))
                    log.debug("%s >> f_len : %s" % (_str_funcName, f_len))
                    log.debug("%s >> f_factor : %s" %
                              (_str_funcName, f_factor))
                    for i in range(1, int_points - 1):
                        l_uValues.append(((i * f_factor) + f_base))
                    l_uValues.append(f_maxU)
                    log.debug("%s >> l_uValues : %s" %
                              (_str_funcName, l_uValues))

                else:
                    #Figure out our u's
                    log.debug("%s >> Regular mode. Points = %s " %
                              (_str_funcName, int_points))
                    if int_points == 1:
                        l_uValues = [((f_maxU - f_minU) / 2) + f_minU]
                    elif int_points == 2:
                        l_uValues = [f_minU, f_maxU]
                    elif int_points == 3:
                        l_uValues.append(((f_maxU - f_minU) / 2) + f_minU)
                        l_uValues.append(f_maxU)
                    else:
                        f_factor = (f_maxU - f_minU) / (f_points - 1)
                        log.debug("%s >> f_maxU : %s" %
                                  (_str_funcName, f_maxU))
                        log.debug("%s >> f_factor : %s" %
                                  (_str_funcName, f_factor))
                        for i in range(1, int_points - 1):
                            l_uValues.append((i * f_factor) + f_minU)
                        l_uValues.append(f_maxU)
                    log.debug("%s >> l_uValues : %s" %
                              (_str_funcName, l_uValues))

                if b_cullStartEnd and len(l_uValues) > 3:
                    l_uValues = l_uValues[1:-1]
            except Exception, error:
                raise StandardError, "Divide fail | %s" % error
Example #29
0
 def test_isValueNotEqual(self):
     self.assertFalse(validateArgs.valueArg(numberToCheck=42, isValue=-42))