void SplineTrack::get_endpoints(PointList& output) const
{
   output.push_back(origin);

   if (abs(delta.x) > 0 || abs(delta.y) > 0)
      output.push_back(
         make_point(origin.x + delta.x, origin.y + delta.y));
}
Beispiel #2
0
/**
 * Calculates the points where the meshes merge.
 * @param   MeshList    * meshList  The list of meshes whose points must be calculated.
 */
void
Polyhedron::getPoints(MeshList * meshList)
{
	MeshList::iterator	i1, i2, i3;
    PointList vert; /* Set a Vertices list. */
	PointList::iterator vit;
	Point	* temp;

    /* Going through the list of meshes and calculating the vertices of the polyhedron. */
	for (i1 = meshList->begin(); i1 != meshList->end(); i1++) {
        vert.clear();
		for (i2 = meshList->begin(); i2 != meshList->end(); i2++) {
			for (i3 = meshList->begin(); i3 != meshList->end(); i3++) {
                /* Getting the vertices of the face only if all the meshes are different. */
                if (i1 != i2 && i1 != i3 && i2 != i3) {
    				temp = Mesh::intersection(*(*i1), *(*i2), *(*i3));
	    			if (temp != NULL) {
		    			vert.push_back(temp);
                        vertices.push_back(temp);
                    }
                }
			}
		}
        faces.push_back(new Face(&vertices, &(*i1)->normal));
	}
    getOrigin();
}
void transform(const PointList& in,PointList& out,const osg::Matrix& matrix)
{
    for(PointList::const_iterator itr=in.begin();
        itr!=in.end();
        ++itr)
    {
        out.push_back(Point(itr->first,itr->second * matrix));
    }
}
Beispiel #4
0
void handleDual(Segment_2 s, std::vector<PointList>& polylines)
{
        Point_2 ss = s.source();
        Point_2 st = s.target();
        PointList points;
        points.push_back(ss);
        points.push_back(st);
        polylines.push_back(points);
}
Beispiel #5
0
/*!
  \brief Add linestring to a ring (private)

  \param[in,out] papoRing list of rings
  \param poLine pointer to linestring to be added to a ring 

  \return TRUE on success
  \return FALSE on failure
*/
bool IVFKDataBlock::AppendLineToRing(PointListArray *papoRing, const OGRLineString *poLine, bool bNewRing)
{
    OGRPoint *poFirst, *poLast;
    OGRPoint *poFirstNew, *poLastNew;

    OGRPoint  pt;
    PointList poList;

    /* OGRLineString -> PointList */
    for (int i = 0; i < poLine->getNumPoints(); i++) {
        poLine->getPoint(i, &pt);
        poList.push_back(pt);
    }

    /* create new ring */
    if (bNewRing) {
        papoRing->push_back(new PointList(poList));
        return TRUE;
    }
    
    poFirstNew = &(poList.front());
    poLastNew  = &(poList.back());
    for (PointListArray::const_iterator i = papoRing->begin(), e = papoRing->end();
         i != e; ++i) {
        PointList *ring = (*i);
        poFirst = &(ring->front());
        poLast  = &(ring->back());
        if (!poFirst || !poLast || poLine->getNumPoints() < 2)
            return FALSE;

        if (poFirstNew->Equals(poLast)) {
            /* forward, skip first point */
            ring->insert(ring->end(), poList.begin()+1, poList.end());
            return TRUE;
        }
        
        if (poFirstNew->Equals(poFirst)) {
            /* backward, skip last point */
            ring->insert(ring->begin(), poList.rbegin(), poList.rend()-1);
            return TRUE;
        }
        
        if (poLastNew->Equals(poLast)) {
            /* backward, skip first point */
            ring->insert(ring->end(), poList.rbegin()+1, poList.rend());
            return TRUE;
        }
        
        if (poLastNew->Equals(poFirst)) {
            /* forward, skip last point */
            ring->insert(ring->begin(), poList.begin(), poList.end()-1);
            return TRUE;
        }
    }

    return FALSE;
}
Beispiel #6
0
PointList Board::removeDuplicates(PointList lst) const {
	PointList res;
	for (auto pt : lst) {
		if (std::find(res.begin(), res.end(), pt) == res.end()) {
			res.push_back(pt);
		}
	}
	return res;
}
Beispiel #7
0
PointList Board::findAll(Element el) const {
	PointList rslt;
	for (auto i = 0; i < size*size; ++i) {
		Point pt = xyl.getXY(i);
		if (isAt(pt.getX(), pt.getY(), el)) {
			rslt.push_back(pt);
		}
	}
	return rslt;
}
Beispiel #8
0
PointList Board::getFutureBlasts() const {
	PointList bombs = getBombs();
	bombs.splice(bombs.end(), findAll(Element(LL("OTHER_BOMB_BOMBERMAN"))));
	bombs.splice(bombs.end(), findAll(Element(LL("BOMB_BOMBERMAN"))));

	PointList rslt;
	PointList walls = getWalls();
	for (auto bmb : bombs) {
		rslt.push_back(bmb);
		PointList bombSurrs = bmb.getSurrounds(size);
		for (auto surr : bombSurrs) {
			if (std::find(walls.begin(), walls.end(), surr) == walls.end()) {
				rslt.push_back(surr);
			}
		}
	}

	return removeDuplicates(rslt);
}
Beispiel #9
0
//-----------------------------------------------------------------------------
void CDrawContext::drawPolygon (const CPoint* pPoints, int32_t numberOfPoints, const CDrawStyle drawStyle)
{
	assert (numberOfPoints < 0);
	PointList list (static_cast<uint32_t> (numberOfPoints));
	for (int32_t i = 0; i < numberOfPoints; i++)
	{
		list.push_back (pPoints[i]);
	}
	drawPolygon (list, drawStyle);
}
PointList Planner::getNeighbors(GridPoint p, bool diagonal) const
{
	PointList neighbors;
	GridPoint n;
	
	n.x = p.x-1 ; n.y = p.y   ; neighbors.push_back(n);
	n.x = p.x   ; n.y = p.y-1 ; neighbors.push_back(n);
	n.x = p.x+1 ; n.y = p.y   ; neighbors.push_back(n);
	n.x = p.x   ; n.y = p.y+1 ; neighbors.push_back(n);
	
	if(diagonal)
	{
		n.x = p.x-1 ; n.y = p.y-1 ; neighbors.push_back(n);
		n.x = p.x-1 ; n.y = p.y+1 ; neighbors.push_back(n);
		n.x = p.x+1 ; n.y = p.y-1 ; neighbors.push_back(n);
		n.x = p.x+1 ; n.y = p.y+1 ; neighbors.push_back(n);
	}
	return neighbors;
}
Beispiel #11
0
void handleDual(Segment_2 s, std::vector<PointList>& polylines)
{
        Point_2 ss = s.source();
        Point_2 st = s.target();
        std::cerr << "segment " << ss << " " << st << std::endl; // str << s;
        PointList points;
        points.push_back(ss);
        points.push_back(st);
        polylines.push_back(points);
}
// copyVertexListToPointList a vector for Vec3 into a vector of Point's.
void copyVertexListToPointList(const VertexList& in,PointList& out)
{
    out.reserve(in.size());
    for(VertexList::const_iterator itr=in.begin();
        itr!=in.end();
        ++itr)
    {
        out.push_back(Point(0,*itr));
    }
}
Beispiel #13
0
void SplineTrack::get_height_locked(PointList& output) const
{
   for (int x = min(0, delta.x); x <= max(0, delta.x) + 1; x++) {
      for (int y = min(0, delta.y); y <= max(0, delta.y) + 1; y++) {

         PointI p = make_point(x, y);
         if (point_in_polygon(bounds, point_cast<float>(p)))
            output.push_back(p + origin);
      }
   }
}
// clip the convex hull 'in' to plane to generate a clipped convex hull 'out'
// return true if points remain after clipping.
unsigned int clip(const Plane& plane,const PointList& in, PointList& out,unsigned int planeMask)
{
    std::vector<float> distance;
    distance.reserve(in.size());
    for(PointList::const_iterator itr=in.begin();
        itr!=in.end();
        ++itr)
    {
        distance.push_back(plane.distance(itr->second));
    }

    out.clear();

    for(unsigned int i=0;i<in.size();++i)
    {
        unsigned int i_1 = (i+1)%in.size(); // do the mod to wrap the index round back to the start.
        
        if (distance[i]>=0.0f)
        {
            out.push_back(in[i]);
            
            
            if (distance[i_1]<0.0f)
            {
                unsigned int mask = (in[i].first & in[i_1].first) | planeMask;
                float r = distance[i_1]/(distance[i_1]-distance[i]);
                out.push_back(Point(mask,in[i].second*r+in[i_1].second*(1.0f-r)));
            }
        
        }
        else if (distance[i_1]>0.0f)
        {
            unsigned int mask = (in[i].first & in[i_1].first) | planeMask;
            float r = distance[i_1]/(distance[i_1]-distance[i]);
            out.push_back(Point(mask,in[i].second*r+in[i_1].second*(1.0f-r)));
        }
    }
    
    return out.size();
}
Beispiel #15
0
ScreenCalibrator::PointList ScreenCalibrator::readTotalstationSurveyFile(const char* fileName,const char* tag) const
	{
	/* Open the CSV input file: */
	IO::TokenSource tok(Vrui::openFile(fileName));
	tok.setPunctuation(",\n");
	tok.setQuotes("\"");
	tok.skipWs();
	
	/* Read point records until the end of file: */
	PointList result;
	unsigned int line=2;
	while(!tok.eof())
		{
		/* Read the point coordinates: */
		Point p;
		for(int i=0;i<3;++i)
			{
			if(i>0)
				{
				tok.readNextToken();
				if(!tok.isToken(","))
					Misc::throwStdErr("MeasureEnvironment::MeasureEnvironment: Format error in input file %s",fileName);
				}
			p[i]=Scalar(atof(tok.readNextToken()));
			}
			
		tok.readNextToken();
		if(!tok.isToken(","))
			Misc::throwStdErr("MeasureEnvironment::MeasureEnvironment: Format error in input file %s",fileName);
		
		/* Read the point tag: */
		tok.readNextToken();
		if(tok.isCaseToken(tag))
			{
			/* Store the point: */
			result.push_back(p);
			}
		
		tok.readNextToken();
		if(!tok.isToken("\n"))
			Misc::throwStdErr("MeasureEnvironment::MeasureEnvironment: Format error in input file %s",fileName);
		
		++line;
		}
	
	/* Cull duplicate points from the point list: */
	size_t numDupes=cullDuplicates(result,Scalar(0.05));
	if(numDupes>0)
		std::cout<<"ScreenCalibrator::readTotalstationSurveyFile: "<<numDupes<<" duplicate points culled from input file"<<std::endl;
	
	return result;
	}
Beispiel #16
0
void handleDual(Ray_2 r, Iso_rectangle_2 crect, std::vector<PointList>& polylines)
{
        Object_2 o = CGAL::intersection(crect, r);

        Segment_2 seg;
        Point_2 pnt;
        if (assign(seg, o)) {
          Point_2 ss = seg.source();
          Point_2 st = seg.target();
          PointList points;
          points.push_back(ss);
          points.push_back(st);
          polylines.push_back(points);
        } else if (assign(pnt, o)){
          // no use for points
        }
}
Beispiel #17
0
void SplineTrack::get_covers(PointList& output) const
{
   const Point<float> off = make_point(0.5f, 0.5f);

   for (int x = min(0, delta.x); x <= max(0, delta.x) + 1; x++) {
      for (int y = min(0, delta.y); y <= max(0, delta.y) + 1; y++) {
         PointI p = make_point(x, y);

         const bool is_origin = p == make_point(0, 0);
         const bool is_delta = p == make_point(delta.x, delta.y);

         if (point_in_polygon(bounds, point_cast<float>(p) + off)
             && !(is_origin || is_delta))
            output.push_back(p + origin);
      }
   }
}
PointList Planner::willBeExplored(Pose p)
{
    // TODO: Transform SensorFields to Pose p
    SensorField transformedSF = transformSensorField(p);
    
    // Rasterize transformed SensorField
    SensorField::iterator sensor;
    Polygon::iterator point;
    FloatPoint min, max, current;
    PointList result;
    for(sensor = transformedSF.begin(); sensor < transformedSF.end(); sensor++)
    {
        // Determine bounding box for efficiency
        min = max = *(sensor->begin());
        for(point = sensor->begin()+1; point < sensor->end(); point++)
        {
            if(point->x < min.x) min.x = point->x;
            if(point->x > max.x) max.x = point->x;
            if(point->y < min.y) min.y = point->y;
            if(point->y > max.y) max.y = point->y;
        }

        // Rasterize polygon
        for(int y = min.y; y <= max.y; y++)
        {
            for(int x = min.x; x <= max.x; x++)
            {
                current.x = x;
                current.y = y;
                GridPoint gp;
                gp.x = x;
                gp.y = y;
                char c = 0;
                if(     mCoverageMap->getData(gp, c) &&
                        c == UNKNOWN && 
                        pointInPolygon(current, *sensor) && 
                        isVisible(current, p))
                {
                        result.push_back(gp);
                }
            }
        }
    }
    return result;
}
PointList Planner::getUnexploredCells() const
{
	PointList result;
	GridPoint p;
    char c = 0;
	
	for(unsigned int y = 0; y < mCoverageMap->getHeight(); y++)
	{
		for(unsigned int x = 0; x < mCoverageMap->getWidth(); x++)
		{
			p.x = x;
			p.y = y;
			if(mCoverageMap->getData(p, c) && c == UNKNOWN) {
				result.push_back(p);
            }
		}
	}	
	return result;
}
Beispiel #20
0
void handleDual(Line_2 l, Iso_rectangle_2 crect, std::vector<PointList>& polylines)
{
        std::cerr << "line" << std::endl; //str << l;
        Object_2 o = CGAL::intersection(l, crect);

        Segment_2 seg;
        Point_2 pnt;
        if (assign(seg, o)) {
          std::cerr << "line -> segment" << std::endl;
          Point_2 ss = seg.source();
          Point_2 st = seg.target();
          PointList points;
          points.push_back(ss);
          points.push_back(st);
          polylines.push_back(points);
        } else if (assign(pnt, o)){
          std::cerr << "line -> point" << std::endl;
          // no use for points
        }
}
Beispiel #21
0
 void update_hand_trace(int trackingId, const astra::Vector2i& position)
 {
     auto it = pointMap_.find(trackingId);
     if (it == pointMap_.end())
     {
         PointList list;
         for (int i = 0; i < maxTraceLength_; i++)
         {
             list.push_back(position);
         }
         pointMap_.insert({trackingId, list});
     }
     else
     {
         PointList& list = it->second;
         while (list.size() < maxTraceLength_)
         {
             list.push_back(position);
         }
     }
 }
Beispiel #22
0
void EntryManageDialog::OnBnClickedButtonOK()
{
	PointList* newPoints = new PointList();

	CString temp;
	for( int i = 0; i < m_LineDetailList.GetItemCount(); i++ )
	{
		PointEntry* point = new PointEntry();

		//得到当前编号(及其在列表中的序列号)
		point->m_PointNO = (UINT)i;

		temp = m_LineDetailList.GetItemText(i,1);
		acdbDisToF(temp.GetBuffer(), -1, &((point->m_Point)[X]));

		temp = m_LineDetailList.GetItemText(i,2);
		acdbDisToF(temp.GetBuffer(), -1, &((point->m_Point)[Y]));

		temp = m_LineDetailList.GetItemText(i,3);
		acdbDisToF(temp.GetBuffer(), -1, &((point->m_Point)[Z]));

		//加入到队列中
		newPoints->push_back(point);
	}

	//得到当前编辑的直线
	LineEntry* selectLine = GetSelectLine();

	//设置新的数据
	if( selectLine )
	{
		selectLine->SetPoints(newPoints);
	}

	//默认进入XY视图
	acedCommand(RTSTR, _T("._-VIEW"), RTSTR, L"TOP", 0);

	//保存到临时文件
	m_EntryFile->Persistent();
}
PointList Planner::getFrontier(GridMap* map, GridMap* plan, GridPoint start)
{
     // Mark the cell as "already added to a frontier" by setting 
     // the value in the plan to 2.
	PointList frontier;
	mFrontierCount++;
	
	// Initialize the queue with the first frontier cell
	Queue queue;
	queue.insert(Entry(0, start));
	plan->setData(start, OBSTACLE);
	
	// Do full search with weightless Dijkstra-Algorithm
	while(!queue.empty())
	{		
		// Get the nearest cell from the queue
		Queue::iterator next = queue.begin();
		int distance = next->first;
		GridPoint point = next->second;
		queue.erase(next);
		
		// Add it to the frontier
		frontier.push_back(point);
		mFrontierCellCount++;
		
		// Add all adjacent frontier cells to the queue
		PointList neighbors = getNeighbors(point, true);
        char c = 0;
		for(PointList::const_iterator cell = neighbors.begin(); cell < neighbors.end(); cell++)
		{
			if(plan->getData(*cell, c) && c != OBSTACLE && isFrontierCell(map, *cell))
			{
				plan->setData(*cell, OBSTACLE);
				queue.insert(Entry(distance+1, *cell));
			}
		}
	}
	
	return frontier;
}
Beispiel #24
0
void Points::get_covers(PointList& output) const
{
   const int reflect = reflected ? -1 : 1;

   if (my_axis == axis::X) {
      output.push_back(make_point(myX + 1, myY + 1*reflect));
      output.push_back(make_point(myX + 1, myY));
   }
   else if (my_axis == -axis::X) {
      output.push_back(make_point(myX - 1, myY - 1*reflect));
      output.push_back(make_point(myX - 1, myY));
   }
   else if (my_axis == axis::Y) {
      output.push_back(make_point(myX - 1*reflect, myY + 1));
      output.push_back(make_point(myX, myY + 1));
   }
   else if (my_axis == -axis::Y) {
      output.push_back(make_point(myX + 1*reflect, myY - 1));
      output.push_back(make_point(myX, myY - 1));
   }
   else
      assert(false);
}
Beispiel #25
0
// ============================================================================
// Draw points and curves
// ============================================================================
void CBezierWnd::Draw()
{
    // Draw control point handles and labels
  for ( PointSetIt i = m_Points.begin(); i != m_Points.end(); ++i )
  {
    DrawHandle( *i );
    DrawLabel( *i );
  }

  if ( m_Points.size() < 3)
    return;

    // Draw curve
  PointList lPoints;
  for ( PointSetIt i = m_Points.begin(); i != m_Points.end(); ++i )
    lPoints.push_back( *i );

  CPoint2D p2DStart =  *m_Points.begin();
  float fStep = 1.f / ( 10.f * ( float ) lPoints.size() );
  for ( float i = 0.f; i <= 1.f; i+= fStep )
  {

    CPoint2D p2D = GetBezierPoint( lPoints, i );
    DrawLine( p2DStart, p2D );
    p2DStart = p2D;
  }
  DrawLine( p2DStart, lPoints.back() );

    // Draw control polygon
  if ( m_bDrawPoly )
  {
    PointSetIt i = m_Points.begin(), iPrev = i++;
    do {
      DrawLine( *iPrev, *i );
      iPrev = i++;
    } while ( i != m_Points.end() );
  }
}
Beispiel #26
0
void handleDual(Ray_2 r, Iso_rectangle_2 crect, std::vector<PointList>& polylines)
{
        std::cerr << "ray" << std::endl;  // str << r;
        Object_2 o = CGAL::intersection(crect, r);

        Segment_2 seg;
        Point_2 pnt;
        if (assign(seg, o)) {
          std::cerr << "ray -> segment" << std::endl;
          Point_2 ss = seg.source();
          Point_2 st = seg.target();
          PointList points;
          points.push_back(ss);
          points.push_back(st);
          polylines.push_back(points);
        } else if (assign(pnt, o)){
          std::cerr << "ray -> point" << std::endl;
          // no use for points
        } else {
          std::cerr << "ray -> ?" << std::endl;
          std::cerr << r.source() << " " << r.point(1) << std::endl;
        }
}
Beispiel #27
0
void Points::get_endpoints(PointList& a_list) const
{
   a_list.push_back(make_point(myX, myY));
   a_list.push_back(straight_endpoint());
   a_list.push_back(displaced_endpoint());
}
// adapted from http://www.cgal.org/Manual/beta/examples/Surface_reconstruction_points_3/poisson_reconstruction_example.cpp
Mesh poissonSurface(const Mat ipoints, const Mat normals)
{
    // Poisson options
    FT sm_angle = 20.0; // Min triangle angle in degrees.
    FT sm_radius = 300; // Max triangle size w.r.t. point set average spacing.
    FT sm_distance = 0.375; // Surface Approximation error w.r.t. point set average spacing.

    PointList points;
    points.reserve(ipoints.rows);
    float min = 0, max = 0;
    for (int i=0; i<ipoints.rows; i++) {
        float const *p = ipoints.ptr<float const>(i), *n = normals.ptr<float const>(i);
        points.push_back(Point_with_normal(Point(p[0]/p[3], p[1]/p[3], p[2]/p[3]), Vector(n[0], n[1], n[2])));
        if (p[0]/p[3] > max) max = p[0]/p[3];
        if (p[0]/p[3] < min) min = p[0]/p[3];
    }

    // Creates implicit function from the read points using the default solver.

    // Note: this method requires an iterator over points
    // + property maps to access each point's position and normal.
    // The position property map can be omitted here as we use iterators over Point_3 elements.
    Poisson_reconstruction_function function(points.begin(), points.end(), CGAL::make_normal_of_point_with_normal_pmap(points.begin()) );

    // Computes the Poisson indicator function f() at each vertex of the triangulation.
    bool success = function.compute_implicit_function();
    assert(success);
#ifdef TEST_BUILD
    printf("implicit function ready. Meshing...\n");
#endif
    // Computes average spacing
    FT average_spacing = CGAL::compute_average_spacing(points.begin(), points.end(), 6 /* knn = 1 ring */);

    // Gets one point inside the implicit surface
    // and computes implicit function bounding sphere radius.
    Point inner_point = function.get_inner_point();
    Sphere bsphere = function.bounding_sphere();
    FT radius = std::sqrt(bsphere.squared_radius());

    // Defines the implicit surface: requires defining a
    // conservative bounding sphere centered at inner point.
    FT sm_sphere_radius = 5.0 * radius;
    FT sm_dichotomy_error = sm_distance*average_spacing/1000.0; // Dichotomy error must be << sm_distance
    Surface_3 surface(function, Sphere(inner_point,sm_sphere_radius*sm_sphere_radius), sm_dichotomy_error/sm_sphere_radius);

    // Defines surface mesh generation criteria
    // parameters: min triangle angle (degrees), max triangle size, approximation error
    CGAL::Surface_mesh_default_criteria_3<STr> criteria(sm_angle, sm_radius*average_spacing, sm_distance*average_spacing);

    // Generates surface mesh with manifold option
    STr tr; // 3D Delaunay triangulation for surface mesh generation
    C2t3 c2t3(tr); // 2D complex in 3D Delaunay triangulation
    // parameters: reconstructed mesh, implicit surface, meshing criteria, 'do not require manifold mesh'
    CGAL::make_surface_mesh(c2t3, surface, criteria, CGAL::Non_manifold_tag());

    assert(tr.number_of_vertices() > 0);

    // Search structure: index of the vertex at an exactly given position
    std::map<Point, int> vertexIndices;

    // Extract all vertices of the resulting mesh
    Mat vertices(tr.number_of_vertices(), 4, CV_32FC1), faces(c2t3.number_of_facets(), 3, CV_32SC1);
#ifdef TEST_BUILD
    printf("%i vertices, %i facets. Converting...\n", vertices.rows, faces.rows);
#endif
    {   int i=0;
        for (C2t3::Vertex_iterator it=c2t3.vertices_begin(); it!=c2t3.vertices_end(); it++, i++) {
            float *vertex = vertices.ptr<float>(i);
            Point p = it->point();
            vertex[0] = p.x();
            vertex[1] = p.y();
            vertex[2] = p.z();
            vertex[3] = 1;
            vertexIndices[p] = i;
        }
        vertices.resize(i);
    }

    // Extract all faces of the resulting mesh and calculate the index of each of their vertices
    {   int i=0;
        for (C2t3::Facet_iterator it=c2t3.facets_begin(); it!=c2t3.facets_end(); it++, i++) {
            Cell cell = *it->first;
            int vertex_excluded = it->second;
            int32_t* outfacet = faces.ptr<int32_t>(i);
            // a little magic so that face normals are oriented outside
            char sign = (function(cell.vertex(vertex_excluded)->point()) > 0) ? 1 : 2; // 2 = -1 (mod 3)
            for (char j = vertex_excluded + 1; j < vertex_excluded + 4; j++) {
                outfacet[(sign*j)%3] = vertexIndices[cell.vertex(j%4)->point()];
            }
        }
    }

    return Mesh(vertices, faces);
}
int main(int argc, char * argv[])
{
  std::cerr << "Test the Poisson Delaunay Reconstruction method" << std::endl;

  //***************************************
  // decode parameters
  //***************************************

  // usage
  if (argc-1 == 0)
  {
      std::cerr << "For each input point set or mesh's set of vertices, reconstruct a surface.\n";
      std::cerr << "\n";
      std::cerr << "Usage: " << argv[0] << " mesh1.off point_set2.xyz..." << std::endl;
      std::cerr << "Input file formats are .off (mesh) and .xyz or .pwn (point set).\n";
      std::cerr << "No output" << std::endl;
      return EXIT_FAILURE;
  }

  // Poisson options
  FT sm_angle = 20.0; // Min triangle angle (degrees).
  FT sm_radius = 100; // Max triangle size w.r.t. point set average spacing.
  FT sm_distance = 0.5; // Approximation error w.r.t. point set average spacing.

  // Accumulated errors
  int accumulated_fatal_err = EXIT_SUCCESS;

  // Process each input file
  for (int i = 1; i <= argc-1; i++)
  {
    CGAL::Timer task_timer; task_timer.start();

    std::cerr << std::endl;

    //***************************************
    // Loads mesh/point set
    //***************************************

    // File name is:
    std::string input_filename  = argv[i];

    PointList points;

    // If OFF file format
    std::cerr << "Open " << input_filename << " for reading..." << std::endl;
    std::string extension = input_filename.substr(input_filename.find_last_of('.'));
    if (extension == ".off" || extension == ".OFF")
    {
      // Reads the mesh file in a polyhedron
      std::ifstream stream(input_filename.c_str());
      Polyhedron input_mesh;
      CGAL::scan_OFF(stream, input_mesh, true /* verbose */);
      if(!stream || !input_mesh.is_valid() || input_mesh.empty())
      {
        std::cerr << "Error: cannot read file " << input_filename << std::endl;
        accumulated_fatal_err = EXIT_FAILURE;
        continue;
      }

      // Converts Polyhedron vertices to point set.
      // Computes vertices normal from connectivity.
      BOOST_FOREACH(boost::graph_traits<Polyhedron>::vertex_descriptor v, 
                    vertices(input_mesh)){
        const Point& p = v->point();
        Vector n = CGAL::Polygon_mesh_processing::compute_vertex_normal(v,input_mesh);
        points.push_back(Point_with_normal(p,n));
      }
    }
    // If XYZ file format
    else if (extension == ".xyz" || extension == ".XYZ" ||
/*!
	Draws the output of the component. This function is called from
	a "drawing" thread, which is different from the "processing" thread
	that calls Run(). In order to protect the shared resources between the
	threads, a mutex is used.
*/
void RegionAnalyzer::Draw(const DisplayInfoIn& dii) const
{
	PointList pts;
	for (unsigned i = 20; i < 40; ++i)
	{
		for (unsigned j = 20; j < 40; ++j)
		{
			pts.push_back(Point(i, j));
		}
	}
	DrawFilledPolygon(pts);
#if 0
	if (m_regionPyr.empty())
		return;

	RGBColor selCol(255, 0, 0), regCol;

	unsigned segmentIdx = (unsigned) dii.params[0];

	ASSERT(segmentIdx < m_regionPyr.height());

	const RegionArray& ra = m_regionPyr.level(segmentIdx);

	// Draw all the SELECTED regions
	for (auto it0 = ra.begin(); it0 < ra.end(); ++it0)
	{
		if (!it0->IsSelected())
			continue;

		PointList pts;

		const DiscreteXYArray& xya = it0->boundaryPts;
			
		for (unsigned i = 0; i < xya.xa.size(); i++)
			pts.push_back(Point(xya.xa[i], xya.ya[i]));

		// Find out the color of the first region in the group
		regCol = ra[it0->GetGroupId() - 1].fakeColor;

		SetDrawingColor(regCol);
		DrawFilledPolygon(pts);

		// Drar a well-defined red boundary
		SetDrawingColor(selCol);
		DrawPolygon(pts);
	}

	SetDefaultDrawingColor();

	/*if (!m_shapes.empty())
	{
		unsigned param0 = (unsigned) dii.params[0];
		unsigned param1 = (unsigned) dii.params[1];

		const ShapeParsingModel& spm = element_at(m_shapes, param0);

		switch (dii.outputIdx)
		{
			case 0:
				spm.GetShapeInfo().Draw(); break;
			case 1:
				spm.GetSCG().Draw(param1); 
				break;
			case 2:
				spm.Draw(param1); 
				break;
			default:
				unsigned param2 = (unsigned) dii.params[2];

				if (param1 < spm.NumberOfParses() && param2 <=
					(unsigned)spm.GetShapeParse(param1).number_of_nodes())
				{
					spm.GetShapeParse(param1).Draw(NodeMatchMap(), param2); 
				}
				break;
		}
	}*/
#endif
}