Salome HOME
15fc447790888051a7ff12385bfb8f02ae592f2d
[tools/medcoupling.git] / src / INTERP_KERNEL / Geometric2D / InterpKernelGeo2DEdgeLin.hxx
1 // Copyright (C) 2007-2016  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 // Author : Anthony Geay (CEA/DEN)
20
21 #ifndef __INTERPKERNELGEO2DEDGELIN_HXX__
22 #define __INTERPKERNELGEO2DEDGELIN_HXX__
23
24 #include "INTERPKERNELDefines.hxx"
25 #include "InterpKernelGeo2DEdge.hxx"
26
27 namespace INTERP_KERNEL
28 {
29   class INTERPKERNEL_EXPORT SegSegIntersector : SameTypeEdgeIntersector
30   {
31     friend class Edge;
32   public:
33     SegSegIntersector(const EdgeLin& e1, const EdgeLin& e2);
34     bool areColinears() const;
35     bool haveTheySameDirection() const;
36     void getPlacements(Node *start, Node *end, TypeOfLocInEdge& whereStart, TypeOfLocInEdge& whereEnd, MergePoints& commonNode) const;
37     void areOverlappedOrOnlyColinears(bool& obviousNoIntersection, bool& areOverlapped);
38     std::list< IntersectElement > getIntersectionsCharacteristicVal() const;
39   private:
40     void getCurveAbscisse(Node *node, TypeOfLocInEdge& where, MergePoints& commonNode) const;
41   private:
42     //! index on which all single index op will be performed. Filled in case colinearity is equal to true.
43     int _ind;
44     double _col[2];
45     double _matrix[4];               //SPACEDIM*SPACEDIM  = [e1_x, e1_y, e2_x, e2_y]
46     double _determinant;
47   };
48
49   class INTERPKERNEL_EXPORT EdgeLin : public Edge
50   {
51     friend class SegSegIntersector;
52   public:
53     EdgeLin(std::istream& lineInXfig);
54     EdgeLin(Node *start, Node *end, bool direction=true);
55     EdgeLin(double sX, double sY, double eX, double eY);
56     ~EdgeLin();
57     TypeOfFunction getTypeOfFunc() const { return SEG; }
58     void dumpInXfigFile(std::ostream& stream, bool direction, int resolution, const Bounds& box) const;
59     void update(Node *m);
60     double getNormSq() const;
61     double getAreaOfZone() const;
62     double getCurveLength() const;
63     void getBarycenter(double *bary) const;
64     void getBarycenterOfZone(double *bary) const;
65     void getMiddleOfPoints(const double *p1, const double *p2, double *mid) const;
66     bool isIn(double characterVal) const;
67     Node *buildRepresentantOfMySelf() const;
68     double getCharactValue(const Node& node) const;
69     double getCharactValueBtw0And1(const Node& node) const;
70     double getDistanceToPoint(const double *pt) const;
71     bool isNodeLyingOn(const double *coordOfNode) const;
72     bool isLower(double val1, double val2) const { return val1<val2; }
73     double getCharactValueEng(const double *node) const;
74     bool doIHaveSameDirectionAs(const Edge& other) const;
75     void dynCastFunction(const EdgeLin * &seg,
76                          const EdgeArcCircle * &arcSeg) const { seg=this; }
77   protected:
78     EdgeLin() { }
79     void updateBounds();
80     Edge *buildEdgeLyingOnMe(Node *start, Node *end, bool direction) const;
81   };
82 }
83
84 #endif