std::size_t i, ip1;
double v[3]={0.,0.,0.};
std::size_t sz=std::distance(begin,end);
- if(isQuadratic)
- sz/=2;
- for(i=0;i<sz;i++)
- {
- v[0]+=coords[3*begin[i]+1]*coords[3*begin[(i+1)%sz]+2]-coords[3*begin[i]+2]*coords[3*begin[(i+1)%sz]+1];
- v[1]+=coords[3*begin[i]+2]*coords[3*begin[(i+1)%sz]]-coords[3*begin[i]]*coords[3*begin[(i+1)%sz]+2];
- v[2]+=coords[3*begin[i]]*coords[3*begin[(i+1)%sz]+1]-coords[3*begin[i]+1]*coords[3*begin[(i+1)%sz]];
- }
- double ret = vec[0]*v[0]+vec[1]*v[1]+vec[2]*v[2];
-
- // Try using quadratic points if standard points are degenerated (for example a QPOLYG with two
- // SEG3 forming a circle):
- if (fabs(ret) < INTERP_KERNEL::DEFAULT_ABS_TOL && isQuadratic)
+ if(!isQuadratic)
+ for(i=0;i<sz;i++)
+ {
+ v[0]+=coords[3*begin[i]+1]*coords[3*begin[(i+1)%sz]+2]-coords[3*begin[i]+2]*coords[3*begin[(i+1)%sz]+1];
+ v[1]+=coords[3*begin[i]+2]*coords[3*begin[(i+1)%sz]]-coords[3*begin[i]]*coords[3*begin[(i+1)%sz]+2];
+ v[2]+=coords[3*begin[i]]*coords[3*begin[(i+1)%sz]+1]-coords[3*begin[i]+1]*coords[3*begin[(i+1)%sz]];
+ }
+ else
{
- v[0] = 0.0; v[1] = 0.0; v[2] = 0.0;
+ // Use all points if quadratic (taking only linear points might lead to issues if the linearized version of the
+ // polygon is not convex or self-intersecting ... see testCellOrientation4)
+ sz /= 2;
for(std::size_t j=0;j<sz;j++)
{
if (j%2) // current point i is quadratic, next point i+1 is standard
v[1]+=coords[3*begin[i]+2]*coords[3*begin[ip1]]-coords[3*begin[i]]*coords[3*begin[ip1]+2];
v[2]+=coords[3*begin[i]]*coords[3*begin[ip1]+1]-coords[3*begin[i]+1]*coords[3*begin[ip1]];
}
- ret = vec[0]*v[0]+vec[1]*v[1]+vec[2]*v[2];
}
+ double ret = vec[0]*v[0]+vec[1]*v[1]+vec[2]*v[2];
return (ret>0.);
}