/*----------------------------------------------------------------------* | print node mwgee 06/05| *----------------------------------------------------------------------*/ bool MOERTEL::Node::Print() const { std::cout << "Node " << std::setw(6) << Id_ << "\tCoords "; for (int i=0; i<3; ++i) std::cout << std::setw(12) << x_[i] << " "; std::cout << "Normal " ; for (int i=0; i<3; ++i) std::cout << std::setw(12) << n_[i] << " "; std::cout << "#Dofs " << dof_.size() << " Dofs "; for (int i=0; i<(int)dof_.size(); ++i) std::cout << dof_[i] << " "; std::cout << "#LMDofs " << LMdof_.size(); if (LMdof_.size()) { std::cout << " LMDofs "; for (int i=0; i<(int)LMdof_.size(); ++i) std::cout << LMdof_[i] << " "; } if (IsCorner()) std::cout << " is shared among 1D interfaces"; if (IsOnBoundary()) { std::cout << " is boundary of 2D-interface"; std::cout << ", member of " << NSupportSet() << " support sets"; } std::cout << std::endl; return true; }
void GameLogic::PushVertex(int nV) { m_anPath[m_nVexNum] = nV; m_nVexNum++; if (IsCorner()) { m_nCorner++; } }
void GoBoard::reset() { komi = 0.5; State.koPoint = NO_KO_POINT; for(int i = 0; i<(Size()*Size()); i++) { State.stones[i] = NONE; State.numNeighbours[S_WHITE][i] = 0; State.numNeighbours[S_BLACK][i] = 0; if(IsBorder(i)) { State.numNeighboursEmpty[i] = 3; } if(IsCorner(i)) { State.numNeighboursEmpty[i]= 2; } else if(!IsCorner(i) && !IsBorder(i)) //Mid board { State.numNeighboursEmpty[i] = 4; } } State.bw_prisoners[S_BLACK] = 0; State.bw_prisoners[S_WHITE] = 0; for(int i = 0; i<=blockPointer; ++i) { blocks[i]->reset(); } for(int i = 0; i<=movePointer; ++i) { moves[i]->Color= -1; moves[i]->Point.x=-1; moves[i]->Point.y=-1; moves[i]->Point.color=-1; } blockPointer = 0; movePointer = 0; }
static bool IsVertAllowed( CDispUtilsHelper *pDisp, CVertIndex const &sideVert, int iLevel ) { if( IsCorner( sideVert, pDisp->GetPowerInfo()->GetSideLength() ) ) return true; int iSide = GetEdgeIndexFromPoint( sideVert, pDisp->GetPowerInfo()->GetPower() ); if( iSide == -1 ) return true; int iSub = GetSubNeighborIndex( pDisp, iSide, sideVert ); if ( iSub == -1 ) return true; CDispSubNeighbor *pSub = &pDisp->GetEdgeNeighbor( iSide )->m_SubNeighbors[iSub]; CDispUtilsHelper *pNeighbor = pDisp->GetDispUtilsByIndex( pSub->m_iNeighbor ); Assert( pNeighbor ); // Ok, there is a neighbor.. see if this vertex exists in the neighbor. CShiftInfo *pShiftInfo = &g_ShiftInfos[pSub->m_Span][pSub->m_NeighborSpan]; Assert( pShiftInfo->m_bValid ); if( (pNeighbor->GetPowerInfo()->GetPower() + pShiftInfo->m_PowerShiftAdd) < (iLevel+1) ) { return false; } // Ok, it exists. Make sure the neighbor hasn't disallowed it. CVertIndex nbIndex; TransformIntoSubNeighbor( pDisp, iSide, iSub, sideVert, nbIndex ); CBitVec<MAX_DISPVERTS> &allowedVerts = CCoreDispInfo::FromDispUtils( pNeighbor )->GetAllowedVerts(); return !!allowedVerts.Get( pNeighbor->VertIndexToInt( nbIndex ) ); }
void GameLogic::PopVertex() { if (IsCorner()) { m_nCorner--; } m_nVexNum--; }
bool ofxCalibImage::makeFromImage(CVD::Image<CVD::byte> &im, ofxDataPackege * _data){ data = _data; mvCorners.clear(); mvGridCorners.clear(); mim = im; mim.make_unique(); // Find potential corners.. // This works better on a blurred image, so make a blurred copy // and run the corner finding on that. { CVD::Image<CVD::byte> imBlurred = mim; imBlurred.make_unique(); CVD::convolveGaussian(imBlurred, data->BlurSigma); CVD::ImageRef irTopLeft(5,5); CVD::ImageRef irBotRight = mim.size() - irTopLeft; CVD::ImageRef ir = irTopLeft; ofSetColor(255, 0, 255); int nGate = data->MeanGate; ofPushStyle(); ofNoFill(); do if( IsCorner(imBlurred, ir, nGate)){ mvCorners.push_back(ir); ofCircle(ir.x,ir.y, 2); } while( ir.next(irTopLeft, irBotRight)); ofPopStyle(); } // If there's not enough corners, i.e. camera pointing somewhere random, abort. if((int) mvCorners.size() < 20) return false; // Pick a central corner point... CVD::ImageRef irCenterOfImage = mim.size() / 2; CVD::ImageRef irBestCenterPos; unsigned int nBestDistSquared = 99999999; for(unsigned int i=0; i<mvCorners.size(); i++){ unsigned int nDist = (mvCorners[i] - irCenterOfImage).mag_squared(); if(nDist < nBestDistSquared){ nBestDistSquared = nDist; irBestCenterPos = mvCorners[i]; } } // ... and try to fit a corner-patch to that. PTAMM::CalibCornerPatch Patch( data->CornerPatchSize); PTAMM::CalibCornerPatch::Params Params; Params.v2Pos = vec(irBestCenterPos); Params.v2Angles = GuessInitialAngles(mim, irBestCenterPos); Params.dGain = 80.0; Params.dMean = 120.0; if(!Patch.IterateOnImageWithDrawing(Params, mim)) return false; // The first found corner patch becomes the origin of the detected grid. ofxCalibGridCorner cFirst; cFirst.Params = Params; mvGridCorners.push_back(cFirst); cFirst.draw(); // Next, go in two compass directions from the origin patch, and see if // neighbors can be found. if(!(expandByAngle(0,0) || expandByAngle(0,2))) return false; if(!(expandByAngle(0,1) || expandByAngle(0,3))) return false; mvGridCorners[1].mInheritedSteps = mvGridCorners[2].mInheritedSteps = mvGridCorners[0].GetSteps(mvGridCorners); // The three initial grid elements are enough to find the rest of the grid. int nNext; int nSanityCounter = 0; // Stop it getting stuck in an infinite loop... const int nSanityCounterLimit = 500; while((nNext = nextToExpand()) >= 0 && nSanityCounter < nSanityCounterLimit ){ expandByStep(nNext); nSanityCounter++; } if(nSanityCounter == nSanityCounterLimit) return false; drawImageGrid(); return true; }