Salome HOME
fad4ada113f2be84edd82386ab1296a2ceecc69b
[tools/medcoupling.git] / src / INTERP_KERNEL / Geometric2D / InterpKernelGeo2DEdgeLin.hxx
1 // Copyright (C) 2007-2015  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(const Bounds *whereToFind, 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
46   };
47
48   class INTERPKERNEL_EXPORT EdgeLin : public Edge
49   {
50     friend class SegSegIntersector;
51   public:
52     EdgeLin(std::istream& lineInXfig);
53     EdgeLin(Node *start, Node *end, bool direction=true);
54     EdgeLin(double sX, double sY, double eX, double eY);
55     ~EdgeLin();
56     TypeOfFunction getTypeOfFunc() const { return SEG; }
57     void dumpInXfigFile(std::ostream& stream, bool direction, int resolution, const Bounds& box) const;
58     void update(Node *m);
59     double getNormSq() const;
60     double getAreaOfZone() const;
61     double getCurveLength() const;
62     void getBarycenter(double *bary) const;
63     void getBarycenterOfZone(double *bary) const;
64     void getMiddleOfPoints(const double *p1, const double *p2, double *mid) const;
65     bool isIn(double characterVal) const;
66     Node *buildRepresentantOfMySelf() const;
67     double getCharactValue(const Node& node) const;
68     double getCharactValueBtw0And1(const Node& node) const;
69     double getDistanceToPoint(const double *pt) const;
70     bool isNodeLyingOn(const double *coordOfNode) const;
71     bool isLower(double val1, double val2) const { return val1<val2; }
72     double getCharactValueEng(const double *node) const;
73     bool doIHaveSameDirectionAs(const Edge& other) const;
74     void dynCastFunction(const EdgeLin * &seg,
75                          const EdgeArcCircle * &arcSeg) const { seg=this; }
76   protected:
77     EdgeLin() { }
78     void updateBounds();
79     Edge *buildEdgeLyingOnMe(Node *start, Node *end, bool direction) const;
80     void fillGlobalInfoAbs(bool direction, const std::map<INTERP_KERNEL::Node *,int>& mapThis, const std::map<INTERP_KERNEL::Node *,int>& mapOther, int offset1, int offset2, double fact, double baryX, double baryY,
81                            std::vector<int>& edgesThis, std::vector<double>& addCoo, std::map<INTERP_KERNEL::Node *,int> mapAddCoo) const;
82     void fillGlobalInfoAbs2(const std::map<INTERP_KERNEL::Node *,int>& mapThis, const std::map<INTERP_KERNEL::Node *,int>& mapOther, int offset1, int offset2, double fact, double baryX, double baryY,
83                             std::vector<int>& edgesOther, std::vector<double>& addCoo, std::map<INTERP_KERNEL::Node *,int>& mapAddCoo) const;
84   };
85 }
86
87 #endif