//=====================================================================
// 
// To Dave:
//
// Instruction to some modifications need do in femmview project 
// before use fast point location routine.
//
// From Si hang.
//                                       
//=====================================================================

1. Add files "ptloc.h" and "ptloc.cpp" to femmview project.

2. In file "problem.h". Add a member variable to CElement class:
   
   class CElement
   {
     public:

        int p[3];
        int blk,lbl;
        CComplex B1,B2;
        CComplex b1[3],b2[3];
        CComplex ctr;
        double rsqr;
        double mu1,mu2;
        int n[3];  // Add 3 ints to store elem's neigh. 

     private:
   };
   
3. In file "femmviewDoc.cpp" do these modifications:
   
   (1) Add a line at the beginning:
       
       include "ptloc.h"
   
   (2) Add a line at the end of function CFemmviewDoc::OnOpenDocument():
       
       BOOL CFemmviewDoc::OnOpenDocument(LPCSTR lpszPathName)
       {
       	 ...
       	 
       	 BuildElemMap(&meshnode, &meshelem, NumList, ConList); // Add this line.
       	 
       	 return TRUE;
       }
       	
    (3) Replace function CFemmviewDoc::InTriangle() as fowllowing:

        // This is a new version of InTriangle() use my point location 
        //   routines.

        int CFemmviewDoc::InTriangle(double x, double y)
        {
          //Origin code. 
          //int i;
          //double z;
          //BOOL InFlag;
          //
          //for(i=0;i<meshelem.GetSize();i++)
          //{
          //  z=(meshelem[i].ctr.re-x)*(meshelem[i].ctr.re-x) +
          //    (meshelem[i].ctr.im-y)*(meshelem[i].ctr.im-y);
          //  if(z>meshelem[i].rsqr) InFlag=FALSE;
          //  else InFlag=InTriangleTest(x,y,i); 
          //
          //  if(InFlag==TRUE) return i;
          //}
          //
          //return (-1);
	
          CMeshNode searchpoint;
          TriEdge searchtri;
	
          searchpoint.x = x;
          searchpoint.y = y;
          searchtri.ele = 0; // Choose a Elem Arbitrarily.
	
          enum LocateResult lres = Locate(searchpoint, &searchtri);
          if(lres != eOutSide) {
  	        return searchtri.ele;
          } else {	
  	        return (-1);
          }
        }
        
4. These predefine code need add to files "complex.h" and "problem.h" to avoid 
   overlap define compile error.
   
   (1) In complex.h at its begin and end add this lines:
       
       #ifndef complexH
       #define complexH  1
       
       ... 
       (origin complex.h file contents)
       
       #endif  // ifndef complexH   
       
   (2) In problem.h at its begin and end add this lines:
       
       #ifndef problemH
       #define problemH  1
       
       ... 
       (origin problem.h file contents)
       
       #endif // ifndef problemH
       
5. Build femmview project.