/**------------------------------------------------------------------------
 * @file
 *
 * Copyright 2001 by the University of Toronto (UT).
 *
 *                       All Rights Reserved
 * 
 * Permission to copy and modify this software and its documentation 
 * only for internal use in your organization is hereby granted, 
 * provided that this notice is retained thereon and on all copies.  
 * UT makes no representations as to the suitability and operability 
 * of this software for any purpose.  It is provided "as is" without 
 * express or implied warranty.
 *
 * UT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT
 * SHALL UT BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA
 * OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 * PERFORMANCE OF THIS SOFTWARE.
 *
 * No other rights, including for example, the right to redistribute 
 * this software and its documentation or the right to prepare 
 * derivative works, are granted unless specifically provided in a 
 * separate license agreement.
 *
 * Author: Diego Macrini
 * 
 * $Log: Matching.h,v $
 *
 *-----------------------------------------------------------------------*/

#ifndef _MATCHING_H_
#define _MATCHING_H_
 
#ifndef WIN32
int AsyncIndexDAG(const DAG* pQueryDag, DAGDatabase& dagDB, MATCHINFO& info, STATINFO& idxSt);
double AsyncMatchDAG(const DAG* pQueryDag, const DAG* pModelDag, DAGNodeMap& nodeMap);
#endif

time_t MatchDAG(const DAG* pTargetDag, DAGDatabase& dagDB, MATCHINFO& info, STATINFO& idxSt, STATINFO& matSt);
void MatchDAG(const DAG* pImgDag, DAGDatabase& dagDB, MATCHINFO& info, std::streamoff nModelDagOffset, STATINFO& matSt);
void ProcessFile(const char* szFileName, DAGDatabase& dagDB, std::fstream& logFile, SGRECINFO& info, bool bAsyncProcessing);
void SaveResults(const DAG* pTarget, DAGDatabase& dagDB, STATINFO& idxSt, STATINFO& matSt, std::ostream& os);
bool ShowResults(const DAG* pTarget, STATINFO& matSt, DAGDatabase& queryDB, DAGDatabase& modelDB, int nTgtID =-1);
double OccludeDAG(DAGPtr& ptrDag, double dMaxOcclusionRate);
//double SGNodeDistance(const SGNode& n1, const SGNode& n2);
bool AskBool(const char* szQuestion);
int AskInt(const char* szQuestion);
void OnAlarm(int param);
void MakeSquare(const char* szPPMFileName);
void ShowMatch(const DAG* pDag1, const DAG* pDag2);
void ShowMatch(DAGDatabase& dagDB1, int nDag1Id, DAGDatabase& dagDB2, int nDag2Id);
void ShowSkeletonMatch(const DAG* pDag1, const DAG* pDag2, DAGNodeMap& nodeMap);
void ShowSkeleton(const DAG* pDag);
void AddSubsamplingInfo(ViewSubsampler& vs, const DAG* pTarget, STATINFO& matSt, int kBest);
void SaveSubsamplingInfo(ViewSubsampler& vs, String strDBFileName);
SmartArray<int> GetFarthestViews(int i, int res, double deg);
SmartArray<int> Complement128(int tgt, const int* views, int n);

#endif // _MATCHING_H_
