Example #1
0
inline bool TriangleInRegion(const Triangle2DF tri, const CvSubdiv2D* subdiv)
{
   return
      PointInRegion(tri.V0, subdiv)
      && PointInRegion(tri.V1, subdiv)
      && PointInRegion(tri.V2, subdiv);
}
bool TriangleInRegion (Triangle2DF tri, CvSubdiv2D* subdiv)
{
   return
      PointInRegion(tri.V0, subdiv)
      && PointInRegion(tri.V1, subdiv)
      && PointInRegion(tri.V2, subdiv);
}
Example #3
0
void PlanarSubdivisionGetSubdiv2DPoints(CvSubdiv2D* subdiv, CvPoint2D32f* points, CvSubdiv2DEdge* edges, int* pointCount)
{
   UniquePointSet pointSet;

   CvSet* subdivEdges = subdiv->edges;

   CvPoint2D32f* currentPoint = points;
   CvSubdiv2DEdge* currentEdge = edges;

   CvSeqReader reader;
   cvStartReadSeq((CvSeq*) subdivEdges, &reader);
   
   schar* start = reader.ptr;
   
   while(CV_IS_SET_ELEM(reader.ptr))
   {
      CvQuadEdge2D* qEdge = (CvQuadEdge2D*)reader.ptr;

      if (qEdge && CV_IS_SET_ELEM(qEdge))
      {
         CvSubdiv2DEdge e = (CvSubdiv2DEdge) qEdge;

         if (e && CV_IS_SET_ELEM(e))
         {
            CvSubdiv2DPoint* p1 = cvSubdiv2DEdgeOrg(e);
            if (p1 &&
               pointSet.insert(p1->pt).second &&
               PointInRegion(p1->pt, subdiv))
            {
               *currentPoint++ = p1->pt;
               *currentEdge++ = cvSubdiv2DRotateEdge(e, 1);
            }

            CvSubdiv2DPoint* p2 = cvSubdiv2DEdgeDst(e);
            if(p2 &&
               pointSet.insert(p2->pt).second &&
               PointInRegion(p2->pt, subdiv))
            {
               *currentPoint++ = p2->pt;
               *currentEdge++ = cvSubdiv2DRotateEdge(e, 3);
            }
         }
      }
      CV_NEXT_SEQ_ELEM(subdivEdges->elem_size, reader);
      
      // prevent infinite loop
      if(reader.ptr == start)
         break;
   }
   *pointCount = currentPoint - points;
}
Example #4
0
bool CombatSetupWnd::ValidPlacement(Ship* ship, const Ogre::Vector3& point) const {
    bool retval = false;
    std::size_t i = GroupIndexOfShip(m_setup_groups, ship);
    if (i != m_setup_groups.size()) {
        const CombatSetupGroup& group = m_setup_groups[i];
        retval = !group.m_allow;
        for (std::size_t j = 0; j < group.m_regions.size(); ++j) {
            double point_d[2] = { point.x, point.y };
            if (PointInRegion(point_d, group.m_regions[j])) {
                retval = !retval;
                break;
            }
        }
    }
    if (retval) {
        // verify that this placement is not too near to other ships
        for (std::map<int, Ogre::SceneNode*>::const_iterator it = m_placed_nodes.begin();
                it != m_placed_nodes.end();
                ++it) {
            Ship* this_ship = *Ogre::any_cast<Ship*>(&it->second->getUserAny());
            if (this_ship == ship)
                continue;
            Ogre::SceneNode::ObjectIterator iterator = it->second->getAttachedObjectIterator();
            assert(iterator.hasMoreElements());
            const Ogre::Sphere& sphere =
                boost::polymorphic_downcast<Ogre::Entity*>(iterator.getNext())->getWorldBoundingSphere();
            if (sphere.intersects(point)) {
                retval = false;
                break;
            }
        }
    }
    return retval;
}
Example #5
0
bool Triangle::ContainsPoint(const glm::vec2 &point)
{
	return PointInRegion(a, b, c, point) &&
		PointInRegion(a, c, b, point) &&
		PointInRegion(b, c, a, point);
}