inline int ternarylook_fix_ternary_implications( const int nrval ) { int i, lit1, lit2, *tImp = TernaryImp[ -nrval ]; for( i = TernaryImpSize[ -nrval ]; i > 0; i-- ) { lit1 = *(tImp++); lit2 = *(tImp++); if( IS_FIXED(lit1) ) { if( FIXED_ON_COMPLEMENT(lit1) ) { if( IS_FIXED(lit2) ) { if( FIXED_ON_COMPLEMENT(lit2) ) return UNSAT; } else { FIX( lit2, currentTimeStamp ); *(look_fixstackp++) = lit2; *(look_resstackp++) = lit2; } } } else if( IS_FIXED(lit2) ) if( FIXED_ON_COMPLEMENT(lit2) ) { FIX( lit1, currentTimeStamp ); *(look_fixstackp++) = lit1; *(look_resstackp++) = lit1; } } return SAT; }
inline int look_fix_binary_implications( const int nrval ) { int i, lit, *bImp, *local_fixstackp = end_fixstackp; if( IS_FIXED(nrval) ) return( FIXED_ON_COMPLEMENT(nrval) == UNSAT ); FIX( nrval, currentTimeStamp ); *( end_fixstackp++ ) = nrval; while( local_fixstackp < end_fixstackp ) { bImp = BIMP_START( *(local_fixstackp++) ); for( i = BIMP_ELEMENTS; --i; ) { lit = *(bImp++); if( IS_FIXED(lit) ) { if( FIXED_ON_COMPLEMENT(lit) ) return UNSAT; } else { FIX( lit, currentTimeStamp ); *( end_fixstackp++ ) = lit; } } } return SAT; }
Vec3D<> CVXS_Voxel::CalcTotalMoment(void) { Vec3D<> TotalMoment(0,0,0); for (int i=0; i<GetNumLocalBonds(); i++) { //add moments from bond if (MySIndex == GetBond(i)->GetpV1()->MySIndex){ TotalMoment -= GetBond(i)->GetMoment1(); } //if this is voxel 1 else { TotalMoment -= GetBond(i)->GetMoment2(); } //if this is voxel 2 } //EXTERNAL moments //ground damping???? //Vec3D<> _NegSlowDampZxAngVel = -p_Sim->GetSlowDampZ() * S.AngVel; // TotalMoment += _NegSlowDampZxAngVel * (2*sqrt(Inertia*GetEMod()*S.Scale.x*S.Scale.x*S.Scale.x)); //TODO: cache!!! TotalMoment += -p_Sim->GetSlowDampZ() * S.AngVel *_2xSqIxExSxSxS; //(2*sqrt(Inertia*GetEMod()*S.Scale.x*S.Scale.x*S.Scale.x)); //TODO: cache!!! // Inertia = Mass * (AvgDim*AvgDim)/6; //simple 1D apprix //TotalForce += CalcGndDampEffect(); TotalMoment += ExtInputScale*ExternalTorque; //add in any external forces.... if (IS_FIXED(DOF_TX, DofFixed)) TotalMoment.x=0; if (IS_FIXED(DOF_TY, DofFixed)) TotalMoment.y=0; if (IS_FIXED(DOF_TZ, DofFixed)) TotalMoment.z=0; return TotalMoment; }
void lookahead_subsume( const int nrval ) { int i, lit1, lit2, last, *tImp = TernaryImp[ nrval ]; for( i = TernaryImpSize[ nrval ]-1; i >= 0; i-- ) { lit1 = tImp[ 2*i ]; lit2 = tImp[ 2*i+1 ]; if( IS_FIXED(lit1) || IS_FIXED(lit2) ) { if( IS_FORCED(lit1) || IS_FORCED(lit2) ) continue; PUSH( subsume, nrval ); last = --TernaryImpSize[ nrval ]; if( last != i ) { tImp[ 2*i ] = tImp[ 2*last ]; tImp[ 2*last ] = lit1; tImp[ 2*i+1 ] = tImp[ 2*last+1 ]; tImp[ 2*last+1 ] = lit2; } swap_ternary_implications( lit1, lit2, nrval ); swap_ternary_implications( lit2, nrval, lit1 ); } } }
inline int look_fix_ternary_implications( const int nrval ) { int i, lit1, lit2, *tImp = TernaryImp[ -nrval ]; for( i = TernaryImpSize[ -nrval ]; i > 0; i-- ) { lit1 = *(tImp++); lit2 = *(tImp++); if( IS_FIXED(lit1) ) { if( FIXED_ON_COMPLEMENT(lit1) ) { if( IS_FIXED(lit2) ) { if( FIXED_ON_COMPLEMENT(lit2) ) return UNSAT; } else if( add_constraint_resolvent( lit2 ) == UNSAT ) return UNSAT; } } else if( IS_FIXED(lit2) ) { if( FIXED_ON_COMPLEMENT(lit2) ) if( add_constraint_resolvent( lit1 ) == UNSAT ) return UNSAT; } else { new_binaries++; weighted_new_binaries += diff[ lit1 ] * diff[ lit2 ]; } } return SAT; }
int DPLL_add_binary_implications( int lit1, int lit2 ) { int i, *bImp; if( IS_FIXED(lit1) ) { if( !FIXED_ON_COMPLEMENT(lit1) ) return SAT; else if( IS_FIXED(lit2) ) return( !FIXED_ON_COMPLEMENT(lit2) ); else return look_fix_binary_implications(lit2); } else if( IS_FIXED(lit2) ) { if( !FIXED_ON_COMPLEMENT(lit2) ) return SAT; else return look_fix_binary_implications(lit1); } #ifdef BIEQ while( (VeqDepends[ NR(lit1) ] != INDEPENDENT) && (VeqDepends[ NR(lit1) ] != EQUIVALENT) ) lit1 = VeqDepends[ NR(lit1) ] * SGN(lit1); while( (VeqDepends[ NR(lit2) ] != INDEPENDENT) && (VeqDepends[ NR(lit2) ] != EQUIVALENT) ) lit2 = VeqDepends[ NR(lit2) ] * SGN(lit2); if( lit1 == -lit2 ) return SAT; if( lit1 == lit2 ) return look_fix_binary_implications(lit1); #endif STAMP_IMPLICATIONS( -lit1 ); if( bImp_stamps[ -lit2 ] == current_bImp_stamp ) return look_fix_binary_implications( lit1 ); if( bImp_stamps[lit2] != current_bImp_stamp ) { int _result; bImp_stamps[ BinaryImp[-lit1][ BinaryImp[-lit1][0] - 1] ] = current_bImp_stamp; _result = DPLL_add_compensation_resolvents( lit1, lit2 ); if( _result != UNKNOWN ) return _result; STAMP_IMPLICATIONS( -lit2 ); if( bImp_stamps[ -lit1 ] == current_bImp_stamp ) return look_fix_binary_implications( lit2 ); _result = DPLL_add_compensation_resolvents( lit2, lit1 ); if( _result != UNKNOWN ) return _result; ADD_BINARY_IMPLICATIONS( lit1, lit2 ); } return SAT; }
inline int DPLL_add_compensation_resolvents( const int lit1, const int lit2 ) { int i, lit, *bImp = BIMP_START(lit2); CHECK_NODE_STAMP( -lit1 ); CHECK_BIMP_UPPERBOUND( -lit1, BinaryImp[ lit2 ][ 0 ] ); for (i = BIMP_ELEMENTS; --i; ) { lit = *(bImp++); if( IS_FIXED(lit) ) continue; if( bImp_stamps[ -lit ] == current_bImp_stamp ) return look_fix_binary_implications( lit1 ); #ifdef COMPENSATION_RESOLVENTS if( bImp_stamps[ lit ] != current_bImp_stamp ) { CHECK_NODE_STAMP( -lit ); CHECK_BIMP_BOUND ( -lit ); ADD_BINARY_IMPLICATIONS( lit, lit1 ); } #endif } return UNKNOWN; }
Vec3D<> CVXS_Voxel::CalcTotalForce(bool WithRestraint) { // THE NEXT optimization target //INTERNAL forces Vec3D<> TotalForce = Vec3D<>(0,0,0); // Vec3D<> _NegSlowDampZxVel = -p_Sim->GetSlowDampZ() * S.Vel; TotalForce += -p_Sim->GetSlowDampZ() * S.Vel*_2xSqMxExS; //(2*sqrt(Mass*GetEMod()*S.Scale.x)); //TOOODOOO!!! GetEMod = slow, slow, slow!! //Forces from the bonds int NumLocBond = GetNumLocalBonds(); for (int i=0; i<NumLocBond; i++){ CVXS_Bond* pThisBond = GetBond(i); bool IAmVox1 = IsMe(pThisBond->GetpV1()); //otherwise vox 2 of the bond if (IAmVox1) TotalForce -= pThisBond->GetForce1(); //Force on Vox 1 from this bond else TotalForce -= pThisBond->GetForce2(); //Force on Vox 2 from this bond } //from interactive click/drag. TODO: This should just be another bond, and treated as such. ? if (p_Sim->Dragging && MyXIndex == p_Sim->CurXSel){ //if we're currently dragging this one! TotalForce += p_Sim->InputBond()->GetForce1(); TotalForce -= 2*Mass*sqrt(p_Sim->InputBond()->GetLinearStiffness()/Mass)*S.Vel; //critically damp force for this bond to ground } //From gravity if (p_Sim->pEnv->IsGravityEnabled()) TotalForce.z += Mass*p_Sim->pEnv->GetGravityAccel(); //EXTERNAL forces TotalForce += ExtInputScale*ExternalForce; //add in any external forces.... if(p_Sim->pEnv->IsFloorEnabled()) TotalForce += CalcFloorEffect(Vec3D<vfloat>(TotalForce)); else StaticFricFlag = false; if (StaticFricFlag) {TotalForce.x = 0; TotalForce.y = 0;} if (IS_FIXED(DOF_X, DofFixed) && WithRestraint) TotalForce.x=0; if (IS_FIXED(DOF_Y, DofFixed) && WithRestraint) TotalForce.y=0; if (IS_FIXED(DOF_Z, DofFixed) && WithRestraint) TotalForce.z=0; return TotalForce; }
inline int ternarylook_fix_direct_implications( const int parent, const int reference ) { int i, lit1, lit2, *tImp = TernaryImp[ parent ]; for( i = TernaryImpSize[ parent ]; i > 0; i-- ) { lit1 = *(tImp++); lit2 = *(tImp++); if( lit1 == reference ) { if( IS_FIXED(lit2) ) { if( FIXED_ON_COMPLEMENT(lit2) ) return UNSAT; } else{ FIX( lit2, currentTimeStamp ); *(look_fixstackp++) = lit2; } } else if( lit2 == reference ) { if( IS_FIXED(lit1) ) { if( FIXED_ON_COMPLEMENT(lit1) ) return UNSAT; } else{ FIX( lit1, currentTimeStamp ); *(look_fixstackp++) = lit1; } } } return SAT; }
void Dlg_BCs::UpdateUI(bool UpdatingTextField) { if (!CurRegion){ //if nothing selected: ui.FixAllButton->setEnabled(false); ui.FixNoneButton->setEnabled(false); ui.TranslationGroup->setEnabled(false); ui.RotationGroup->setEnabled(false); } else { //if something selected: ui.FixAllButton->setEnabled(true); ui.FixNoneButton->setEnabled(true); ui.TranslationGroup->setEnabled(true); ui.RotationGroup->setEnabled(true); char CurDofFixed = CurRegion->DofFixed; bool DofXFixed = IS_FIXED(DOF_X, CurDofFixed); bool DofYFixed = IS_FIXED(DOF_Y, CurDofFixed); bool DofZFixed = IS_FIXED(DOF_Z, CurDofFixed); bool DofTXFixed = IS_FIXED(DOF_TX, CurDofFixed); bool DofTYFixed = IS_FIXED(DOF_TY, CurDofFixed); bool DofTZFixed = IS_FIXED(DOF_TZ, CurDofFixed); ui.XFixed->setChecked(DofXFixed); ui.YFixed->setChecked(DofYFixed); ui.ZFixed->setChecked(DofZFixed); ui.XDispEdit->setEnabled(DofXFixed); ui.YDispEdit->setEnabled(DofYFixed); ui.ZDispEdit->setEnabled(DofZFixed); ui.XForceEdit->setEnabled(!DofXFixed); ui.YForceEdit->setEnabled(!DofYFixed); ui.ZForceEdit->setEnabled(!DofZFixed); ui.TXFixed->setChecked(DofTXFixed); ui.TYFixed->setChecked(DofTYFixed); ui.TZFixed->setChecked(DofTZFixed); ui.TXDispEdit->setEnabled(DofTXFixed); ui.TYDispEdit->setEnabled(DofTYFixed); ui.TZDispEdit->setEnabled(DofTZFixed); ui.TXTorqueEdit->setEnabled(!DofTXFixed); ui.TYTorqueEdit->setEnabled(!DofTYFixed); ui.TZTorqueEdit->setEnabled(!DofTZFixed); if (UpdatingTextField){ ui.XDispEdit->setText(QString::number(CurRegion->Displace.x*1000, 'g', 3)); ui.YDispEdit->setText(QString::number(CurRegion->Displace.y*1000, 'g', 3)); ui.ZDispEdit->setText(QString::number(CurRegion->Displace.z*1000, 'g', 3)); ui.XForceEdit->setText(QString::number(CurRegion->Force.x, 'g', 3)); ui.YForceEdit->setText(QString::number(CurRegion->Force.y, 'g', 3)); ui.ZForceEdit->setText(QString::number(CurRegion->Force.z, 'g', 3)); ui.TXDispEdit->setText(QString::number(CurRegion->AngDisplace.x*RtoD, 'g', 3)); ui.TYDispEdit->setText(QString::number(CurRegion->AngDisplace.y*RtoD, 'g', 3)); ui.TZDispEdit->setText(QString::number(CurRegion->AngDisplace.z*RtoD, 'g', 3)); ui.TXTorqueEdit->setText(QString::number(CurRegion->Torque.x*1000, 'g', 3)); ui.TYTorqueEdit->setText(QString::number(CurRegion->Torque.y*1000, 'g', 3)); ui.TZTorqueEdit->setText(QString::number(CurRegion->Torque.z*1000, 'g', 3)); } } }
int tree_lookahead() { int i, _forced_literals; struct treeNode _treeNode, *_treeArray; #ifdef LONG_LOOK forced_literals = 0; if( long_lookahead( forced_literal_array, &forced_literals ) == UNSAT ) return UNSAT; if( long_fix_forced_literals() == UNSAT ) return UNSAT; #endif init_lookahead_procedure(); #ifdef ITERATE_LOOKAHEAD do { _forced_literals = forced_literals; #endif _treeArray = treeArray; for( i = tree_elements-1; i >= 0; i-- ) { _treeNode = *(_treeArray++); if( _treeNode.literal == lastChanged ) return SAT; currentTimeStamp += _treeNode.gap; if( currentTimeStamp >= LOOK_MAX ) { currentTimeStamp -= _treeNode.gap; // is dit nodig? return SAT; } if( treelookvar(_treeNode.literal) == UNSAT ) return UNSAT; currentTimeStamp -= _treeNode.gap; if( forced_literals > _forced_literals ) { if( IS_FIXED( _treeNode.literal ) && ( Rank[NR(_treeNode.literal)] < Rank_trigger) ) { Rank_trigger = Rank[NR(_treeNode.literal)]; printf("c forced var with Rank %i\n", Rank_trigger ); } _forced_literals = forced_literals; lastChanged = _treeNode.literal; } } #ifdef ITERATE_LOOKAHEAD currentTimeStamp += 2 * tree_elements; } while( lastChanged != 0 ); #endif return SAT; }
inline int look_fix_ternary_implications( const int nrval ) { int i, lit1, lit2, *tImp = TernaryImp[ -nrval ]; for( i = TernaryImpSize[ -nrval ]; i > 0; i-- ) { lit1 = *(tImp++); lit2 = *(tImp++); if( IS_FIXED(lit1) ) { if( FIXED_ON_COMPLEMENT(lit1) ) { if( IS_FIXED(lit2) ) { if( FIXED_ON_COMPLEMENT(lit2) ) return UNSAT; } else if( add_hyper_binary( lit2, 0 ) == UNSAT ) return UNSAT; } } else if( IS_FIXED(lit2) ) { if( FIXED_ON_COMPLEMENT(lit2) ) if( add_hyper_binary( lit1, 0 ) == UNSAT ) return UNSAT; } else { #ifndef EVAL_VAR new_binaries++; #endif weighted_new_binaries += diff[ lit1 ] * diff[ lit2 ]; } } #ifdef EVAL_VAR new_binaries++; #endif return SAT; }
inline void look_backtrack( ) { int *tail_stackp = end_fixstackp; do { if( tail_stackp == rstackp ) break; if( IS_FIXED( *(tail_stackp - 1) ) ) break; tail_stackp--; } while( 1 ); restore_big_clauses( end_fixstackp, tail_stackp ); }
void CVXS_Voxel::FixDof(char DofFixedIn) //fixes any of the degrees of freedom indicated. Doesn't unfix any currently fixed ones { if (IS_FIXED(DOF_X, DofFixedIn)) SET_FIXED(DOF_X, DofFixed, true); if (IS_FIXED(DOF_Y, DofFixedIn)) SET_FIXED(DOF_Y, DofFixed, true); if (IS_FIXED(DOF_Z, DofFixedIn)) SET_FIXED(DOF_Z, DofFixed, true); if (IS_FIXED(DOF_TX, DofFixedIn)) SET_FIXED(DOF_TX, DofFixed, true); if (IS_FIXED(DOF_TY, DofFixedIn)) SET_FIXED(DOF_TY, DofFixed, true); if (IS_FIXED(DOF_TZ, DofFixedIn)) SET_FIXED(DOF_TZ, DofFixed, true); }
inline int look_fix_equivalences( const int nrval ) { int i, j, eq_clause, *eq_array; int lit, sign; eq_array = Veq[ NR(nrval) ] + 1; for( i = eq_array[ -1 ] - 1; i > 0; i-- ) { eq_clause = *(eq_array++); lit = 0; sign = 1; for( j = CeqSizes[ eq_clause ] - 1; j >= 0; j-- ) { if( IS_FIXED(Ceq[ eq_clause ][ j ]) ) sign *= EQSGN( Ceq[ eq_clause ][ j ] ); else if( !lit ) lit = Ceq[ eq_clause ][ j ]; else { new_binaries += 2; weighted_new_binaries += lengthWeight[ j + 2 ]; goto ceqend; } } sign = sign * CeqValues[ eq_clause ]; if( lit != 0 ) { if( add_constraint_resolvent(lit * sign) == UNSAT ) return UNSAT; } else if( sign == -1 ) return UNSAT; ceqend :; } return SAT; }
static void sudoku_draw_grid(UINT8 row, UINT8 col) { UINT8 pos; UINT8 WStyle; pos = row*BOARD_COLS+col; if(IS_FIXED(pos)) WStyle = WSTL_GAME_BG_FIX; else if((row%6<3&&col%6<3)||(row%6>=3&&col%6>=3)) WStyle = WSTL_GAMESUDOKU_NORMAL1_HD; else WStyle = WSTL_GAMESUDOKU_NORMAL2_HD; drawSquare(BK_X_OFFSET+col*GRID_WIDTH-2, BK_Y_OFFSET+row*GRID_WIDTH-2,\ GRID_WIDTH+4, GRID_WIDTH+4, WStyle); if(pboard[pos]!=' ') { OSD_MoveObject((POBJECT_HEAD)&txt_Grid,BK_X_OFFSET+col*GRID_WIDTH,BK_Y_OFFSET+row*GRID_WIDTH,FALSE); OSD_SetTextFieldContent(&txt_Grid,STRING_NUMBER, (UINT32)(pboard[pos]-'0')); OSD_DrawObject((POBJECT_HEAD)&txt_Grid,C_UPDATE_ALL); } }
void Dlg_BCs::UpdateBCLists(void) { int PrevCurRow = CurBcIndex; ui.BCList->clear(); for (int i=0; i<pEnv->GetNumBCs(); i++){ char ThisDofFixed = pEnv->GetBC(i)->DofFixed; QString MyName = "BC" + QString::number(i) + " : ("; if (IS_FIXED(DOF_X, ThisDofFixed)) MyName += "*"; else MyName += "_"; if (IS_FIXED(DOF_Y, ThisDofFixed)) MyName += "*"; else MyName += "_"; if (IS_FIXED(DOF_Z, ThisDofFixed)) MyName += "*"; else MyName += "_"; if (IS_FIXED(DOF_TX, ThisDofFixed)) MyName += "*"; else MyName += "_"; if (IS_FIXED(DOF_TY, ThisDofFixed)) MyName += "*"; else MyName += "_"; if (IS_FIXED(DOF_TZ, ThisDofFixed)) MyName += "*"; else MyName += "_"; MyName += ")"; new QListWidgetItem(MyName, ui.BCList); } ApplySelection(PrevCurRow); // ui.BCList->setCurrentRow(PrevCurRow); UpdateUI(); }
static PRESULT sudoku_key_proc(UINT32 vkey, UINT8 key_repeat_cnt, UINT8 key_status) { PRESULT ret = PROC_LOOP; UINT8 back_saved; UINT8 pos; UINT8 i; if (key_status == PAN_KEY_PRESSED) { switch (vkey) { case V_KEY_UP: case V_KEY_DOWN: case V_KEY_LEFT: case V_KEY_RIGHT: sudoku_draw_grid(cur_row, cur_col); if (vkey == V_KEY_UP) { cur_row = cur_row == 0 ? 8 : cur_row - 1; } else if (vkey == V_KEY_DOWN) { cur_row = cur_row == 8 ? 0 : cur_row + 1; } else if (vkey == V_KEY_LEFT) { cur_col = cur_col == 0 ? 8 : cur_col - 1; } else if (vkey == V_KEY_RIGHT) { cur_col = cur_col == 8 ? 0 : cur_col + 1; } sudoku_draw_cursor(cur_row, cur_col); break; case V_KEY_0: pos = cur_row*BOARD_COLS+cur_col; if(!IS_FIXED(pos)) { if(pboard[pos]!=' ') { pboard[pos]=' '; sudoku_draw_cursor(cur_row, cur_col); } } break; case V_KEY_1: case V_KEY_2: case V_KEY_3: case V_KEY_4: case V_KEY_5: case V_KEY_6: case V_KEY_7: case V_KEY_8: case V_KEY_9: pos = cur_row*BOARD_COLS+cur_col; if(!IS_FIXED(pos)) { pboard[pos]=(vkey-V_KEY_0)+0x30; sudoku_draw_cursor(cur_row, cur_col); } for (i=0;i<81 ;i++ ) if(pboard[i]==' ') break; if(i==81) { for (i=0;i<81 ;i++ ) if(pboard[i]!=(GET_DIGIT(solved_board[i])+0x30)) break; } if(i==81) { completed=1; win_compopup_init(WIN_POPUP_TYPE_OK); win_compopup_set_frame(GAME_MSG_LEFT, GAME_MSG_TOP, GAME_MSG_WIDTH,GAME_MSG_HEIGHT); win_compopup_set_msg(NULL, NULL, RS_GAME_YOU_WIN); if (win_compopup_open_ext(&back_saved) == WIN_POP_CHOICE_YES) { sudoku_draw_board(); //sudoku_draw_grid(cur_row, cur_col); OSD_SetAttr((POBJECT_HEAD)&txt_newgame, C_ATTR_ACTIVE); OSD_ChangeFocus((POBJECT_HEAD)&game_sudoku_con, 1, \ C_UPDATE_FOCUS | C_DRAW_SIGN_EVN_FLG); } } break; case V_KEY_MENU: case V_KEY_EXIT: win_compopup_init(WIN_POPUP_TYPE_OKNO); win_compopup_set_frame(GAME_MSG_LEFT, GAME_MSG_TOP, GAME_MSG_WIDTH,GAME_MSG_HEIGHT); win_compopup_set_msg(NULL, NULL, RS_GAME_MSG_DO_YOU_QUIT); if (win_compopup_open_ext(&back_saved) == WIN_POP_CHOICE_YES) { sudoku_draw_board(); //sudoku_draw_grid(cur_row, cur_col); OSD_SetAttr((POBJECT_HEAD)&txt_newgame, C_ATTR_ACTIVE); OSD_ChangeFocus((POBJECT_HEAD)&game_sudoku_con, 1, \ C_UPDATE_FOCUS | C_DRAW_SIGN_EVN_FLG); } else { sudoku_draw_board(); sudoku_draw_cursor(cur_row, cur_col); } break; default : ret = PROC_PASS; break; } } return ret; }
int symresolve(struct idl *idl, struct sym *sym) { struct sym *s; char *key; iter_t iter; int align; size_t size; s = symlook(idl, sym->idl_type); if (s) { /* merge stuff */ sym->flags |= s->flags & 0xFFFF; sym->ndr_type = s->ndr_type; if (sym->ptr && (!IS_PRIMATIVE(sym) || hashmap_get(&sym->attrs, "string"))) { sym->ndr_size = 4; } else { sym->ndr_size = s->ndr_size; } sym->align = sym->ptr ? 4 : sym->ndr_size; /* inherit attributes */ hashmap_iterate(&s->attrs, &iter); while ((key = hashmap_next(&s->attrs, &iter))) { /* Only add attributes that the symbol does not have already */ if (hashmap_get(&sym->attrs, key) == NULL) { char *data; data = hashmap_get(&s->attrs, key); hashmap_put(&sym->attrs, key, data); } } if (sym->out_type == NULL) { if (s->out_type) { sym->out_type = s->out_type; } else if (IS_TYPEDEFD(sym)) { sym->out_type = sym->idl_type = sym->name; } else if (strncmp(sym->idl_type, "struct ", 7) == 0 || strncmp(sym->idl_type, "union ", 6) == 0) { char buf[255]; if (*sym->idl_type == 's') { sprintf(buf, "struct_%s", sym->idl_type + 7); } else { sprintf(buf, "union_%s", sym->idl_type + 7); } sym->out_type = dupstr(buf, idl->al); } if ((strcmp(idl->type, "java") == 0 || strcmp(idl->type, "jcifs") == 0) && IS_IMPORTED(sym)) { char buf[255]; sprintf(buf, "%s.%s", sym->interface, sym->out_type); sym->out_type = dupstr(buf, idl->al); } } } align = 0; size = 0; linkedlist_iterate(&sym->mems, &iter); while ((s = linkedlist_next(&sym->mems, &iter))) { size_t msiz, mali, m; symresolve(idl, s); if (s->align > align) { align = s->align; } if (s->ptr) { msiz = mali = 4; } else { msiz = s->ndr_size; mali = s->align; } m = mali - 1; size = (size + m) & ~m; /* align the type */ s->offset = size; if (IS_ENUM(sym)) { size = msiz; /* size only size of member not sum of mems */ } else if (IS_UNION(sym)) { /* size is largest of mems (not really used for any logic so far) */ if (msiz > size) { size = msiz; } } else { size += msiz; /* and size of type */ } } if (align) { sym->align = align; } if (size) { sym->ndr_size = size; } /* check array conformance */ hashmap_iterate(&sym->attrs, &iter); while ((key = hashmap_next(&sym->attrs, &iter))) { if (!IS_FIXED(sym) && (strcmp(key, "size_is") == 0 || strcmp(key, "max_is") == 0)) { sym->flags |= FLAGS_CONFORMANT; break; } } if (IS_PRIMATIVE(sym)) { if (!IS_OPERATION(sym)) { sym->interface = NULL; } sym->flags &= ~FLAGS_IMPORTED; } return 0; }
void list_configure(unsigned long *body) { struct ConfigWinPacket *cfgpacket = (void *)body; char *grav; printf( "0x%08lx %-20s x %ld, y %ld, width %ld, height %ld\n", cfgpacket->w, "frame", cfgpacket->frame_x, cfgpacket->frame_y, cfgpacket->frame_width, cfgpacket->frame_height ); printf( "0x%08lx %-20s %ld\n" ,cfgpacket->w, "desktop", cfgpacket->desk); /* Oooh, you asked for it... */ if (Opt_flags == 2) { printf( "Packet flags\n" ); printf( "is_sticky_across_pages: %d\n", IS_STICKY_ACROSS_PAGES( cfgpacket ) ); printf( "is_sticky_across_desks: %d\n", IS_STICKY_ACROSS_DESKS( cfgpacket ) ); printf( "has_icon_font: %d\n", HAS_ICON_FONT( cfgpacket ) ); printf( "has_window_font: %d\n", HAS_WINDOW_FONT( cfgpacket ) ); printf( "do_circulate_skip: %d\n", DO_SKIP_CIRCULATE( cfgpacket ) ); printf( "do_circulate_skip_icon: %d\n", DO_SKIP_ICON_CIRCULATE( cfgpacket ) ); printf( "do_circulate_skip_shaded: %d\n", DO_SKIP_SHADED_CIRCULATE( cfgpacket ) ); printf( "do_grab_focus_when_created: %d\n", FP_DO_GRAB_FOCUS( FW_FOCUS_POLICY(cfgpacket) ) ); printf( "do_grab_focus_when_transient_created: %d\n", FP_DO_GRAB_FOCUS_TRANSIENT( FW_FOCUS_POLICY(cfgpacket) ) ); printf( "do_ignore_restack: %d\n", DO_IGNORE_RESTACK( cfgpacket ) ); printf( "do_lower_transient: %d\n", DO_LOWER_TRANSIENT( cfgpacket ) ); printf( "do_not_show_on_map: %d\n", DO_NOT_SHOW_ON_MAP( cfgpacket ) ); printf( "do_not_pass_click_focus_click: %d\n", FP_DO_PASS_FOCUS_CLICK( FW_FOCUS_POLICY(cfgpacket) ) ); printf( "do_raise_transient: %d\n", DO_RAISE_TRANSIENT( cfgpacket ) ); printf( "do_resize_opaque: %d\n", DO_RESIZE_OPAQUE( cfgpacket ) ); printf( "do_shrink_windowshade: %d\n", DO_SHRINK_WINDOWSHADE( cfgpacket ) ); printf( "do_stack_transient_parent: %d\n", DO_STACK_TRANSIENT_PARENT( cfgpacket ) ); printf( "do_window_list_skip: %d\n", DO_SKIP_WINDOW_LIST( cfgpacket ) ); printf( "has_depressable_border: %d\n", HAS_DEPRESSABLE_BORDER( cfgpacket ) ); printf( "has_mwm_border: %d\n", HAS_MWM_BORDER( cfgpacket ) ); printf( "has_mwm_buttons: %d\n", HAS_MWM_BUTTONS( cfgpacket ) ); printf( "has_mwm_override: %d\n", HAS_MWM_OVERRIDE_HINTS( cfgpacket ) ); printf( "has_no_icon_title: %d\n", HAS_NO_ICON_TITLE( cfgpacket ) ); printf( "has_override_size: %d\n", HAS_OVERRIDE_SIZE_HINTS( cfgpacket ) ); printf( "has_stippled_title: %d\n", HAS_STIPPLED_TITLE( cfgpacket ) ); printf( "is_fixed: %d\n", IS_FIXED( cfgpacket ) ); printf( "is_icon_sticky_across_pages: %d\n", IS_ICON_STICKY_ACROSS_PAGES( cfgpacket ) ); printf( "is_icon_sticky_across_desks: %d\n", IS_ICON_STICKY_ACROSS_DESKS( cfgpacket ) ); printf( "is_icon_suppressed: %d\n", IS_ICON_SUPPRESSED( cfgpacket ) ); printf( "is_lenient: %d\n", FP_IS_LENIENT( FW_FOCUS_POLICY(cfgpacket) ) ); printf( "does_wm_delete_window: %d\n", WM_DELETES_WINDOW( cfgpacket ) ); printf( "does_wm_take_focus: %d\n", WM_TAKES_FOCUS( cfgpacket ) ); printf( "do_iconify_after_map: %d\n", DO_ICONIFY_AFTER_MAP( cfgpacket ) ); printf( "do_reuse_destroyed: %d\n", DO_REUSE_DESTROYED( cfgpacket ) ); printf( "has_border: %d\n", !HAS_NO_BORDER( cfgpacket ) ); printf( "has_title: %d\n", HAS_TITLE( cfgpacket ) ); printf( "is_iconify_pending: %d\n", IS_ICONIFY_PENDING( cfgpacket ) ); printf( "is_fully_visible: %d\n", IS_FULLY_VISIBLE( cfgpacket ) ); printf( "is_iconified: %d\n", IS_ICONIFIED( cfgpacket ) ); printf( "is_iconfied_by_parent: %d\n", IS_ICONIFIED_BY_PARENT( cfgpacket ) ); printf( "is_icon_entered: %d\n", IS_ICON_ENTERED( cfgpacket ) ); printf( "is_icon_font_loaded: %d\n", IS_ICON_FONT_LOADED( cfgpacket ) ); printf( "is_icon_moved: %d\n", IS_ICON_MOVED( cfgpacket ) ); printf( "is_icon_ours: %d\n", IS_ICON_OURS( cfgpacket ) ); printf( "is_icon_shaped: %d\n", IS_ICON_SHAPED( cfgpacket ) ); printf( "is_icon_unmapped: %d\n", IS_ICON_UNMAPPED( cfgpacket ) ); printf( "is_mapped: %d\n", IS_MAPPED( cfgpacket ) ); printf( "is_map_pending: %d\n", IS_MAP_PENDING( cfgpacket ) ); printf( "is_maximized: %d\n", IS_MAXIMIZED( cfgpacket ) ); printf( "is_name_changed: %d\n", IS_NAME_CHANGED( cfgpacket ) ); printf( "is_partially_visible: %d\n", IS_PARTIALLY_VISIBLE( cfgpacket ) ); printf( "is_pixmap_ours: %d\n", IS_PIXMAP_OURS( cfgpacket ) ); printf( "is_size_inc_set: %d\n", IS_SIZE_INC_SET( cfgpacket ) ); printf( "is_transient: %d\n", IS_TRANSIENT( cfgpacket ) ); printf( "is_window_drawn_once: %d\n", cfgpacket->flags.is_window_drawn_once ); printf( "is_viewport_moved: %d\n", IS_VIEWPORT_MOVED( cfgpacket ) ); printf( "is_window_being_moved_opaque: %d\n", IS_WINDOW_BEING_MOVED_OPAQUE( cfgpacket ) ); printf( "is_window_font_loaded: %d\n", IS_WINDOW_FONT_LOADED( cfgpacket ) ); printf( "is_window_shaded %d\n", IS_SHADED( cfgpacket ) ); printf( "title_dir: %d\n", GET_TITLE_DIR( cfgpacket ) ); } printf( "0x%08lx %-20s %hd\n", cfgpacket->w, "title height", cfgpacket->title_height); printf( "0x%08lx %-20s %hd\n", cfgpacket->w, "border width", cfgpacket->border_width); printf( "0x%08lx %-20s width %ld, height %ld\n", cfgpacket->w, "base size", cfgpacket->hints_base_width, cfgpacket->hints_base_height); printf( "0x%08lx %-20s width %ld, height %ld\n", cfgpacket->w, "size increment", cfgpacket->hints_width_inc, cfgpacket->hints_height_inc); printf( "0x%08lx %-20s width %ld, height %ld\n", cfgpacket->w, "min size", cfgpacket->hints_min_width, cfgpacket->hints_min_height); printf( "0x%08lx %-20s width %ld, height %ld\n", cfgpacket->w, "max size", cfgpacket->hints_max_width, cfgpacket->hints_max_height); switch(cfgpacket->hints_win_gravity) { case ForgetGravity: grav = "Forget"; break; case NorthWestGravity: grav = "NorthWest"; break; case NorthGravity: grav = "North"; break; case NorthEastGravity: grav = "NorthEast"; break; case WestGravity: grav = "West"; break; case CenterGravity: grav = "Center"; break; case EastGravity: grav = "East"; break; case SouthWestGravity: grav = "SouthWest"; break; case SouthGravity: grav = "South"; break; case SouthEastGravity: grav = "SouthEast"; break; case StaticGravity: grav = "Static"; break; default: grav = "Unknown"; break; } printf( "0x%08lx %-20s %s\n", cfgpacket->w, "gravity", grav); printf( "0x%08lx %-20s text 0x%lx, back 0x%lx\n", cfgpacket->w, "pixel", cfgpacket->TextPixel, cfgpacket->BackPixel); }
/* ** seemed kind of silly to have check_allowed_function and ** check_allowed_function2 partially overlapping in their checks, so I ** combined them here and made them wrapper functions instead. */ Bool is_function_allowed( int function, char *action_string, const FvwmWindow *t, request_origin_t request_origin, Bool do_allow_override_mwm_hints) { unsigned int functions; char *functionlist[] = { MOVE_STRING, RESIZE_STRING1, RESIZE_STRING2, MINIMIZE_STRING, MINIMIZE_STRING2, MAXIMIZE_STRING, CLOSE_STRING1, CLOSE_STRING2, CLOSE_STRING3, CLOSE_STRING4, NULL }; if (t == NULL) { return True; /* this logic come from animated menu */ } if (do_allow_override_mwm_hints && HAS_MWM_OVERRIDE_HINTS(t)) { /* allow everything */ functions = ~0; } else { /* restrict by mwm hints */ functions = t->functions; } /* Hate to do it, but for lack of a better idea, check based on the * menu entry name */ /* Complex functions are a little tricky, ignore them if no menu item*/ if (function == F_FUNCTION && action_string != NULL) { int i; /* remap to regular actions */ i = GetTokenIndex(action_string, functionlist, -1, NULL); switch (i) { case 0: function = F_MOVE; break; case 1: function = F_RESIZE; break; case 2: function = F_RESIZE; break; case 3: function = F_ICONIFY; break; case 4: function = F_ICONIFY; break; case 5: function = F_MAXIMIZE; break; case 6: function = F_CLOSE; break; case 7: function = F_DELETE; break; case 8: function = F_DESTROY; break; case 9: function = F_QUIT; break; default: break; } } /* now do the real checks */ switch(function) { case F_DELETE: if (IS_UNCLOSABLE(t)) { return False; } if (IS_TEAR_OFF_MENU(t)) { /* always allow this on tear off menus */ break; } if (!WM_DELETES_WINDOW(t)) { return False; } /* fall through to close clause */ case F_CLOSE: if (IS_UNCLOSABLE(t)) { return False; } if (IS_TEAR_OFF_MENU(t)) { /* always allow this on tear off menus */ break; } if (!(functions & MWM_FUNC_CLOSE)) { return False; } break; case F_DESTROY: /* shouldn't destroy always be allowed??? */ if (IS_UNCLOSABLE(t)) { return False; } if (IS_TEAR_OFF_MENU(t)) { /* always allow this on tear off menus */ break; } if (!(functions & MWM_FUNC_CLOSE)) { return False; } break; case F_RESIZE: if(!__is_resize_allowed(t, functions, request_origin)) { return False; } break; case F_ICONIFY: if ((!IS_ICONIFIED(t) && !(functions & MWM_FUNC_MINIMIZE)) || IS_UNICONIFIABLE(t)) { return False; } break; case F_MAXIMIZE: if (IS_MAXIMIZE_FIXED_SIZE_DISALLOWED(t) && !__is_resize_allowed(t, functions, request_origin)) { return False; } if ((request_origin && !(functions & MWM_FUNC_MAXIMIZE)) || IS_UNMAXIMIZABLE(t)) { return False; } break; case F_MOVE: /* Move is a funny hint. Keeps it out of the menu, but you're * still allowed to move. */ if (request_origin && IS_FIXED(t)) { return False; } else if (!request_origin && IS_FIXED_PPOS(t)) { return False; } if (request_origin && !(functions & MWM_FUNC_MOVE)) { return False; } break; case F_FUNCTION: default: break; } /* end of switch */ /* if we fell through, just return True */ return True; }
int treelookvar( const int nrval ) { int i, parent; const int *loc; assert( currentTimeStamp < VARMAX ); parent = assignment_array[ nrval ].parent; assert(parent != nrval); if( (parent != 0) && IS_FIXED(parent) && IS_NOT_FORCED(parent) ) { NBCounter [ nrval ] = NBCounter [ parent ]; WNBCounter[ nrval ] = WNBCounter[ parent ]; } else { NBCounter [ nrval ] = 0; WNBCounter[ nrval ] = 0; } if( IS_FIXED(nrval) ) { if (IS_FORCED(nrval) ) return SAT; if( FIXED_ON_COMPLEMENT(nrval) ) { return look_fix_forced_literal(-nrval); } #ifdef AUTARKY look_add_autarky_binary_implications( parent, nrval ); #endif return SAT; } lookAheadCount++; if( look_IFIUP(nrval) == UNSAT ) return look_fix_forced_literal(-nrval); NBCounter [ nrval ] += new_binaries; WNBCounter[ nrval ] += weighted_new_binaries; #ifdef DOUBLELOOK if( check_doublelook( nrval ) == UNSAT ) return UNSAT; #endif #ifdef AUTARKY if( new_binaries == 0 ) { if( (parent == 0) || IS_FORCED(parent) ) { look_fix_forced_literal( nrval ); return SAT; } look_add_autarky_binary_implications( parent, nrval ); } #endif loc = BinaryImp[ -nrval ]; for( i = 2; i < loc[ 0 ]; i++ ) { const int lit = loc[ i ]; if( IS_FIXED(lit) && IS_NOT_FORCED(lit) ) { if( !FIXED_ON_COMPLEMENT(lit) ) { necessary_assignments++; if( look_fix_forced_literal(lit) == UNSAT ) return UNSAT; loc = BinaryImp[ -nrval ]; } else { #ifdef BIEQ int bieq = -parent; if( VeqDepends[ NR(nrval) ] != INDEPENDENT ) return 1; while( VeqDepends[ NR(bieq) ] != INDEPENDENT ) { if( VeqDepends[ NR(bieq) ] != EQUIVALENT ) bieq = VeqDepends[ NR(bieq) ] * SGN(bieq); else bieq = EQUIVALENT; if( bieq == nrval ) break; } if( (bieq != EQUIVALENT) && (bieq != nrval) ) { VeqDepends[ NR(bieq) ] = nrval * SGN(bieq); PUSH( bieq, NR(bieq) ); } #endif } } } return SAT; }
//http://klas-physics.googlecode.com/svn/trunk/src/general/Integrator.cpp (reference) void CVXS_Voxel::EulerStep(void) { double dt = p_Sim->dt; //bool EqMode = p_Sim->IsEquilibriumEnabled(); if (IS_ALL_FIXED(DofFixed)){ //if fixed, just update the position and forces acting on it (for correct simulation-wide summing S.LinMom = Vec3D<double>(0,0,0); S.Pos = OriginalPos + ExtInputScale*ExternalDisp; S.AngMom = Vec3D<double>(0,0,0); S.Angle.FromRotationVector(Vec3D<double>(ExtInputScale*ExternalTDisp)); dS.Force = CalcTotalForce(); } else { Vec3D<> ForceTot = CalcTotalForce(); //TotVoxForce; //DISPLACEMENT S.LinMom = S.LinMom + ForceTot*dt; Vec3D<double> Disp(S.LinMom*(dt*_massInv)); //vector of what the voxel moves if(p_Sim->IsMaxVelLimitEnabled()){ //check to make sure we're not going over the speed limit! vfloat DispMag = Disp.Length(); vfloat MaxDisp = p_Sim->GetMaxVoxVelLimit()*p_Sim->pEnv->pObj->GetLatticeDim(); if (DispMag>MaxDisp) Disp *= (MaxDisp/DispMag); } S.Pos += Disp; //update position (source of noise in float mode??? if (IS_FIXED(DOF_X, DofFixed)){S.Pos.x = OriginalPos.x + ExtInputScale*ExternalDisp.x; S.LinMom.x = 0;} if (IS_FIXED(DOF_Y, DofFixed)){S.Pos.y = OriginalPos.y + ExtInputScale*ExternalDisp.y; S.LinMom.y = 0;} if (IS_FIXED(DOF_Z, DofFixed)){S.Pos.z = OriginalPos.z + ExtInputScale*ExternalDisp.z; S.LinMom.z = 0;} //ANGLE Vec3D<> TotVoxMoment = CalcTotalMoment(); //debug S.AngMom = S.AngMom + TotVoxMoment*dt; //convert Angular velocity to quaternion form ("Spin") Vec3D<double> dSAngVel(S.AngMom * _inertiaInv); CQuat<double> Spin = 0.5 * CQuat<double>(0, dSAngVel.x, dSAngVel.y, dSAngVel.z) * S.Angle; //current "angular velocity" S.Angle += CQuat<double>(Spin*dt); //see above S.Angle.NormalizeFast(); //Through profiling, quicker to normalize every time than check to see if needed then do it... // TODO: Only constrain fixed angles if one is non-zero! (support symmetry boundary conditions while still only doing this calculation) (only works if all angles are constrained for now...) if (IS_FIXED(DOF_TX, DofFixed) && IS_FIXED(DOF_TY, DofFixed) && IS_FIXED(DOF_TZ, DofFixed)){ S.Angle.FromRotationVector(Vec3D<double>(ExtInputScale*ExternalTDisp)); S.AngMom = Vec3D<>(0,0,0); } } //SCALE // S.ScaleMom = S.ScaleMom + CalcTotalScaleForce()*p_Sim->dt; vfloat TempFact = 1.0; if(p_Sim->pEnv->IsTempEnabled()){ //TempFact = (1+(p_Sim->pEnv->CurTemp-p_Sim->pEnv->TempBase)*GetCTE()); //LocalVXC.GetBaseMat(VoxArray[i].MatIndex)->GetCTE()); double ThisTemp = p_Sim->pEnv->pObj->GetBaseMat(GetMaterial())->GetCurMatTemp(); double ThisCTE = GetCTE(); double TempBase = p_Sim->pEnv->GetTempBase(); TempFact = (1+(ThisTemp - TempBase)*ThisCTE); //To allow selective temperature actuation for each different material } if (TempFact < MIN_TEMP_FACTOR) TempFact = MIN_TEMP_FACTOR; S.Scale = TempFact*OriginalSize; //Recalculate secondary: S.AngVel = S.AngMom * _inertiaInv; S.Vel = S.LinMom * _massInv; //vfloat LastKinE = S.KineticEnergy; if(p_Sim->StatToCalc & CALCSTAT_KINE) S.KineticEnergy = 0.5*Mass*S.Vel.Length2() + 0.5*Inertia*S.AngVel.Length2(); //1/2 m v^2 ////Testing: //if (EqMode && S.KineticEnergy < LastKinE){ // S.LinMom *= 0.99; //Vec3D<double>(0,0,0); // S.AngMom *= 0.99; //= Vec3D<double>(0,0,0); // S.Vel *= 0.99; //= Vec3D<>(0,0,0); // S.AngVel*= 0.99; // = Vec3D<>(0,0,0); // //S.KineticEnergy = 0; // S.KineticEnergy = 0.5*Mass*S.Vel.Length2() + 0.5*Inertia*S.AngVel.Length2(); //1/2 m v^2 //} }
int tree_lookahead() { int i, _forced_literals, _hyper_bins; struct treeNode _treeNode, *_treeArray; forced_literals = 0; hyper_bins = 0; lastChanged = 0; init_lookahead_procedure(); if( treebased_lookahead() == UNSAT ) return UNSAT; #ifdef ITERATE_LOOKAHEAD do { _forced_literals = forced_literals; _hyper_bins = hyper_bins; if( depth == 0 ) { // for( i = 1; i <= nrofvars; i++ ) { hyperTRD[ i ] = 0; hyperTRD[ -i ] = 0; } // transitive_red( ); // transitive_reduction( ); // clean_bImp(); lastChanged = 0; } #endif _treeArray = treeArray; for( i = tree_elements-1; i >= 0; i-- ) { _treeNode = *(_treeArray++); if( _treeNode.literal == lastChanged ) { if( depth == 0 ) printf("c found %i NHBRs\n", hyper_bins ); return SAT; } currentTimeStamp += _treeNode.gap; if( currentTimeStamp >= LOOK_MAX ) { currentTimeStamp -= _treeNode.gap; // is dit nodig? return SAT; } if( treelookvar(_treeNode.literal) == UNSAT ) { if( depth == 0 ) printf("c found %i NHBRs\n", hyper_bins ); return UNSAT; } currentTimeStamp -= _treeNode.gap; if( forced_literals > _forced_literals ) { if( IS_FIXED( _treeNode.literal ) && ( Rank[NR(_treeNode.literal)] < Rank_trigger) ) { Rank_trigger = Rank[NR(_treeNode.literal)]; printf("c forced var with Rank %i\n", Rank_trigger ); } _forced_literals = forced_literals; lastChanged = _treeNode.literal; } if( (depth == 0) && (hyper_bins > _hyper_bins) ) { _hyper_bins = hyper_bins; lastChanged = _treeNode.literal; } } #ifdef ITERATE_LOOKAHEAD currentTimeStamp += 2 * tree_elements; if( (depth == 0) && (lastChanged != 0) ) { if( treebased_lookahead() == UNSAT ) return UNSAT; } } while( lastChanged != 0 ); #endif if( depth == 0 ) printf("c found %i NHBRs\n", hyper_bins ); return SAT; }