54 int id = rhs[0].toInt();
55 string method(rhs[1].toString());
58 if (method ==
"new") {
59 nargchk((nrhs==2 || nrhs==3) && nlhs<=1);
61 makePtr<Subdiv2D>(rhs[2].toRect()) : makePtr<Subdiv2D>();
71 if (method ==
"delete") {
76 else if (method ==
"initDelaunay") {
80 else if (method ==
"insert") {
82 if (rhs[2].isNumeric() && rhs[2].numel() == 2) {
84 int curr_point = obj->
insert(rhs[2].toPoint2f());
89 obj->
insert(rhs[2].toVector<Point2f>());
92 else if (method ==
"locate") {
95 int edge = 0, vertex = 0;
96 int location = obj->
locate(pt, edge, vertex);
103 else if (method ==
"findNearest") {
105 Point2f pt(rhs[2].toPoint2f()), nearestPt;
106 int vertex = obj->
findNearest(pt, (nlhs>1) ? &nearestPt : NULL);
111 else if (method ==
"getEdgeList") {
117 else if (method ==
"getLeadingEdgeList") {
121 plhs[0] =
MxArray(leadingEdgeList);
123 else if (method ==
"getTriangleList") {
127 plhs[0] =
MxArray(triangleList);
129 else if (method ==
"getVoronoiFacetList") {
137 plhs[1] =
MxArray(facetCenters);
139 else if (method ==
"getVertex") {
141 int vertex = rhs[2].toInt();
148 else if (method ==
"getEdge") {
150 int edge = rhs[2].toInt();
152 int e = obj->
getEdge(edge, nextEdgeType);
155 else if (method ==
"nextEdge") {
157 int edge = rhs[2].toInt();
161 else if (method ==
"rotateEdge") {
163 int edge = rhs[2].toInt();
164 int rotate = rhs[3].toInt();
168 else if (method ==
"symEdge") {
170 int edge = rhs[2].toInt();
174 else if (method ==
"edgeOrg") {
176 int edge = rhs[2].toInt();
178 int e = obj->
edgeOrg(edge, (nlhs>1) ? &orgpt : NULL);
183 else if (method ==
"edgeDst") {
185 int edge = rhs[2].toInt();
187 int e = obj->
edgeDst(edge, (nlhs>1) ? &dstpt : NULL);
194 "Unrecognized operation %s", method.
c_str());
void getLeadingEdgeList(std::vector< int > &leadingEdgeList) const
const ConstMap< int, string > PointLocationInvMap
inverse point location types for option processing
LIBMWMEX_API_EXTERN_C void mexLock(void)
Lock a MEX-function so that it cannot be cleared from memory.
int rotateEdge(int edge, int rotate) const
int nextEdge(int edge) const
int symEdge(int edge) const
struct mxArray_tag mxArray
Forward declaration for mxArray.
int edgeDst(int edge, Point2f *dstpt=0) const
int last_id
Last object id to allocate.
const ConstMap< string, int > EdgeTypeMap
edge types for option processing
LIBMWMEX_API_EXTERN_C void mexErrMsgIdAndTxt(const char *identifier, const char *err_msg,...)
Issue formatted error message with corresponding error identifier and return to MATLAB prompt...
LIBMWMEX_API_EXTERN_C void mexUnlock(void)
Unlock a locked MEX-function so that it can be cleared from memory.
mxArray object wrapper for data conversion and manipulation.
void nargchk(bool cond)
Alias for input/output arguments number check.
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
int edgeOrg(int edge, Point2f *orgpt=0) const
Global constant definitions.
void getTriangleList(std::vector< Vec6f > &triangleList) const
int getEdge(int edge, int nextEdgeType) const
void getEdgeList(std::vector< Vec4f > &edgeList) const
int locate(Point2f pt, int &edge, int &vertex)
map< int, Ptr< Subdiv2D > > obj_
Object container.
int findNearest(Point2f pt, Point2f *nearestPt=0)
std::map wrapper with one-line initialization and lookup method.
void initDelaunay(Rect rect)
void getVoronoiFacetList(const std::vector< int > &idx, std::vector< std::vector< Point2f > > &facetList, std::vector< Point2f > &facetCenters)
Point2f getVertex(int vertex, int *firstEdge=0) const