19 #include <boost/foreach.hpp>
83 if (TYElement::operator!=(other))
123 for (
int i = 0; i < pOtherPoly->
getNbPts(); i++)
139 std::string str =
"TYPolygon";
140 for (
int i = 0; i <
getNbPts(); i++)
142 str +=
"\n\tPt" +
intToStr(i) +
"=" +
_pts[i].toString();
151 for (
int i = 0; i <
getNbPts(); i++)
153 _pts[i].toXML(domNewElem);
168 QDomNodeList childs = domElement.childNodes();
170 for (
unsigned int i = 0; i < childs.length(); i++)
172 elemCur = childs.item(i).toElement();
192 size_t nbPts = tabPt.size();
197 for (
int i = 0; i < nbPts; i++)
199 OPoint3D oVertex(tabPt[i]._x, tabPt[i]._y, 0);
204 QList<OPoint3D> vertexes = oDelaunayMaker.
getVertex();
205 QList<OTriangle> faces = oDelaunayMaker.
getFaces();
207 QListIterator<OTriangle> it(faces);
215 double Xa = vertexes[face.
_p1]._x;
216 double Xb = vertexes[face.
_p2]._x;
217 double Xc = vertexes[face.
_p3]._x;
218 double Ya = vertexes[face.
_p1]._y;
219 double Yb = vertexes[face.
_p2]._y;
220 double Yc = vertexes[face.
_p3]._y;
223 a = sqrt((Xa - Xb) * (Xa - Xb) + (Ya - Yb) * (Ya - Yb));
224 b = sqrt((Xb - Xc) * (Xb - Xc) + (Yb - Yc) * (Yb - Yc));
225 c = sqrt((Xc - Xa) * (Xc - Xa) + (Yc - Ya) * (Yc - Ya));
230 res += sqrt(P * (P - a) * (P - b) * (P -
c));
263 for (
unsigned int i = 0; i < tabPts.size(); i++)
265 pts.push_back(tabPts[i]);
308 int nbPts =
static_cast<int>(
getNbPts());
326 double max_normal = normale[0];
328 if (max_normal < normale[1])
331 max_normal = normale[1];
334 if (max_normal < normale[2])
365 for (
int i = 0; i < nbPts; i++)
401 size_t nbPts =
_pts.size();
407 for (
size_t i = 3; i < nbPts; ++i)
419 for (
int j = 0; j < this->
getNbPts(); j++)
421 this->
_pts[j] = matrix * this->
_pts[j];
429 printf(
"TYPolygon::isValid non implemente.\n");
478 ptMax = ptMin = matrix *
_pts[0];
480 for (i = 0; i < nbPts; i++)
483 pt = matrix *
_pts[i];
489 if (pt.
_x <= ptMin.
_x)
493 if (pt.
_y <= ptMin.
_y)
498 if (pt.
_x >= ptMax.
_x)
502 if (pt.
_y >= ptMax.
_y)
515 for (i = 0; i < 4; i++)
517 BoundingRect.
_pts[i] = matrix * BoundingRect.
_pts[i];
525 int nbpoints =
static_cast<int>(
getNbPts());
533 for (
int i = 0; i < nbpoints; i++)
552 int nbPts =
static_cast<int>(
getNbPts());
558 for (
int i = 0; i < nbPts; i++)
579 double xnew = NAN, ynew = NAN;
580 double xold = NAN, yold = NAN;
581 double x1 = NAN, y1 = NAN;
582 double x2 = NAN, y2 = NAN;
591 xold = poly[npoints - 1][0];
592 yold = poly[npoints - 1][1];
594 for (i = 0; i < npoints; i++)
614 if ((xnew < xt) == (xt <= xold) && (yt - y1) * (x2 - x1) < (y2 - y1) * (xt - x1))
629 double xnew = NAN, ynew = NAN;
630 double xold = NAN, yold = NAN;
631 double x1 = NAN, y1 = NAN;
632 double x2 = NAN, y2 = NAN;
641 xold = poly[npoints - 1][0];
642 yold = poly[npoints - 1][2];
644 for (i = 0; i < npoints; i++)
664 if ((xnew < xt) == (xt <= xold) && (yt - y1) * (x2 - x1) < (y2 - y1) * (xt - x1))
679 double xnew = NAN, ynew = NAN;
680 double xold = NAN, yold = NAN;
681 double x1 = NAN, y1 = NAN;
682 double x2 = NAN, y2 = NAN;
691 xold = poly[npoints - 1][1];
692 yold = poly[npoints - 1][2];
694 for (i = 0; i < npoints; i++)
714 if ((xnew < xt) == (xt <= xold) && (yt - y1) * (x2 - x1) < (y2 - y1) * (xt - x1))
731 std::vector<TYPoint>::reverse_iterator it;
732 for (it = tabPtsTemp.rbegin(); it != tabPtsTemp.rend(); it++)
734 _pts.push_back((*it));
748 BOOST_FOREACH (
auto& pt, gpoly.
_pts)
752 triangulator->exportMesh(points, triangles);
All base classes related to 3D manipulation.
#define INTERS_OUI
The intersection exists.
#define INTERS_NULLE
No intersection.
std::vector< TYPoint > TYTabPoint
Collection de TYPoint.
std::deque< OPoint3D > TYTabPoint3D
Collection de OPoint3D.
Representation graphique d'un polygone (fichier header)
TY_EXT_GRAPHIC_INST(TYPolygon)
TY_EXTENSION_INST(TYPolygon)
Bridges TY* types with CGAL functionalities exposed by.
virtual bool isInside(const OPoint3D &pt) const
Test whether the point is inside the box or not.
double _y
y coordinate of OCoord3D
double _x
x coordinate of OCoord3D
bool compute(void)
Compute the triangulation.
QList< OTriangle > getFaces(void)
Return faces list.
QList< OPoint3D > getVertex(void)
Return the vertexes list.
void addVertex(OPoint3D vertex)
Add a vertex.
static void boundingBox(OPoint3D *pts, int nbPts, OPoint3D &ptMin, OPoint3D &ptMax)
Computes the simple bounding box for a volume using min-max method.
static void computeNormal(OPoint3D *pts, int nbPts, OVector3D &normal)
Computes the normal of the list of points.
static bool pointInPolygonAngleSum(const OPoint3D &ptP, const OPoint3D *pts, int nbPts)
Tests if a point is inside a polygon using angle sum algorithm.
static bool pointInPolygonRayCasting(const OPoint3D &ptP, const OPoint3D *pts, int nbPts)
Tests if a point is inside a polygon using ray casting algorithm.
int invert()
Matrix inversion.
Plan defined by its equation : ax+by+cz+d=0.
int intersectsSegment(const OPoint3D &pt1, const OPoint3D &pt2, OPoint3D &ptIntersec) const
Calculate the intersection of this plane with a segment defined by two points.
double _a
The a parameter in the equation ax+by+cz+d=0.
double _c
The c parameter in the equation ax+by+cz+d=0.
bool isInPlan(const OPoint3D &pt)
Check if a point belongs to a plane.
double _b
The b parameter in the equation ax+by+cz+d=0.
void set(double a, double b, double c, double d)
Sets a, b, c and d parameters directly.
virtual const char * getClassName() const
3D frame with a point and 3 vectors.
OVector3D _vecK
Vector K for the Z axis.
OVector3D _vecJ
Vector J for the Y axis.
OVector3D _vecI
Vector I for the X axis.
OPoint3D _origin
The origin point.
OMatrix asMatrix() const
return the transformation matrix from unity to this pose such as this = transform * unity
Class to define a segment.
OPoint3D _ptA
Point A of the segment.
OPoint3D _ptB
Point B of the segment.
int _p1
Index of the first OPoint3D _A.
int _p3
Index of the third OPoint3D _C.
int _p2
Index of the second OPoint3D _B.
void normalize()
Normalizes this vector.
OVector3D cross(const OVector3D &vector) const
Cross product.
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
virtual DOM_Element toXML(DOM_Element &domElement)
QString _name
Nom courant de l'element.
TYElement & operator=(const TYElement &other)
bool callFromXMLIfEqual(DOM_Element &domElement, int *pRetVal=NULL)
virtual int fromXML(DOM_Element domElement)
virtual void setIsGeometryModified(bool isModified)
OMatrix localToGlobal() const
QString generateName(const char *classname)
Retourne le nom de la classe associe a un nombre.
static TYNameManager * get()
Retourne l'instance singleton.
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
const TYTabPoint & getPoints() const
TYRectangle getBoundingRect() const
void exportMesh(std::deque< OPoint3D > &points, std::deque< OTriangle > &triangles, const TYGeometryNode &geonode) const
Export the surface as a triangular mesh.
virtual void inverseNormale()
bool operator!=(const TYPolygon &other) const
Operateur !=.
virtual OVector3D normal() const
bool checkCoplanar() const
ORepere3D getORepere3D() const
int isInpolyYZ(const TYTabPoint &poly, int npoints, double xt, double yt) const
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
int isInpolyXY(const TYTabPoint &poly, int npoints, double xt, double yt) const
virtual int intersects(const TYSurfaceInterface *pSurf, OSegment3D &seg) const
void transform(const OMatrix &matrix)
virtual TYTabPoint3D getOContour(int n=-1) const
virtual TYTabPoint getContour(int n=-1) const
virtual std::string toString() const
virtual int fromXML(DOM_Element domElement)
virtual DOM_Element toXML(DOM_Element &domElement)
TYPolygon & operator=(const TYPolygon &other)
Operateur =.
void setPoints(const TYTabPoint &pts)
virtual OPlan plan() const
int isInpolyXZ(const TYTabPoint &poly, int npoints, double xt, double yt) const
virtual double surface() const
bool operator==(const TYPolygon &other) const
Operateur ==.
virtual double surface() const
virtual int intersects(const OPoint3D &pt) const =0
std::string intToStr(int val)
std::unique_ptr< ITYPolygonTriangulator > make_polygon_triangulator(const TYPolygon &poly)