Salome HOME
3e5221ee3adc3d3a1efe0174a6b71fe16ecaa061
[modules/med.git] / src / INTERP_KERNEL / Geometric2D / InterpKernelGeo2DComposedEdge.hxx
1 // Copyright (C) 2007-2013  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.
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 __INTERPKERNELGEO2DCOMPOSEDNODE_HXX__
22 #define __INTERPKERNELGEO2DCOMPOSEDNODE_HXX__
23
24 #include "INTERPKERNELDefines.hxx"
25 #include "InterpKernelGeo2DEdge.hxx"
26
27 #include <set>
28 #include <list>
29 #include <vector>
30 #include <ostream>
31
32 namespace INTERP_KERNEL
33 {
34   class Node;
35   class Edge;
36   class Bounds;
37   class ElementaryEdge;
38   class IteratorOnComposedEdge;
39
40   class ComposedEdge
41   {
42     friend class IteratorOnComposedEdge;
43   public:
44     INTERPKERNEL_EXPORT ComposedEdge() { }
45     INTERPKERNEL_EXPORT ComposedEdge(const ComposedEdge& other);
46     INTERPKERNEL_EXPORT ComposedEdge(int sz):_sub_edges(sz) { }
47     INTERPKERNEL_EXPORT static void Delete(ComposedEdge *pt) { delete pt; }
48     INTERPKERNEL_EXPORT static void SoftDelete(ComposedEdge *pt) { pt->_sub_edges.clear(); delete pt; }
49     INTERPKERNEL_EXPORT void reverse();
50     INTERPKERNEL_EXPORT int recursiveSize() const { return (int)_sub_edges.size(); }
51     INTERPKERNEL_EXPORT bool presenceOfOn() const;
52     INTERPKERNEL_EXPORT bool presenceOfQuadraticEdge() const;
53     INTERPKERNEL_EXPORT void initLocations() const;
54     INTERPKERNEL_EXPORT void initLocationsWithOther(const ComposedEdge& other) const;
55     INTERPKERNEL_EXPORT ComposedEdge *clone() const;
56     INTERPKERNEL_EXPORT bool isNodeIn(Node *n) const;
57     INTERPKERNEL_EXPORT double getArea() const;
58     INTERPKERNEL_EXPORT double getPerimeter() const;
59     INTERPKERNEL_EXPORT double getHydraulicDiameter() const;
60     INTERPKERNEL_EXPORT void getBarycenter(double *bary) const;
61     INTERPKERNEL_EXPORT void getBarycenterGeneral(double *bary) const;
62     INTERPKERNEL_EXPORT double normalizeMe(double& xBary, double& yBary);
63     INTERPKERNEL_EXPORT double normalize(ComposedEdge *other, double& xBary, double& yBary);
64     INTERPKERNEL_EXPORT double normalizeExt(ComposedEdge *other, double& xBary, double& yBary);
65     INTERPKERNEL_EXPORT void unApplyGlobalSimilarityExt(ComposedEdge& other, double xBary, double yBary, double fact);
66     INTERPKERNEL_EXPORT void fillBounds(Bounds& output) const;
67     INTERPKERNEL_EXPORT void applySimilarity(double xBary, double yBary, double dimChar);
68     INTERPKERNEL_EXPORT void applyGlobalSimilarity(double xBary, double yBary, double dimChar);
69     INTERPKERNEL_EXPORT void applyGlobalSimilarity2(ComposedEdge *other, double xBary, double yBary, double dimChar);
70     INTERPKERNEL_EXPORT void dispatchPerimeter(double& partConsidered) const;
71     INTERPKERNEL_EXPORT void dispatchPerimeterExcl(double& partConsidered, double& commonPart) const;
72     INTERPKERNEL_EXPORT double dispatchPerimeterAdv(const ComposedEdge& father, std::vector<double>& result) const;
73     INTERPKERNEL_EXPORT void getAllNodes(std::set<Node *>& output) const;
74     INTERPKERNEL_EXPORT void getBarycenter(double *bary, double& weigh) const;
75     INTERPKERNEL_EXPORT bool completed() const { return getEndNode()==getStartNode(); }
76     INTERPKERNEL_EXPORT void setValueAt(int i, Edge *e, bool direction=true);
77     INTERPKERNEL_EXPORT double getCommonLengthWith(const ComposedEdge& other) const;
78     INTERPKERNEL_EXPORT void clear();
79     INTERPKERNEL_EXPORT bool empty() const { return _sub_edges.empty(); }
80     INTERPKERNEL_EXPORT ElementaryEdge *front() const { return _sub_edges.front(); }
81     INTERPKERNEL_EXPORT ElementaryEdge *back() const { return _sub_edges.back(); }
82     INTERPKERNEL_EXPORT void resize(int i) { _sub_edges.resize(i); }
83     INTERPKERNEL_EXPORT void pushBack(Edge *edge, bool direction=true);
84     INTERPKERNEL_EXPORT void pushBack(ElementaryEdge *elem);
85     INTERPKERNEL_EXPORT void pushBack(ComposedEdge *elem);
86     INTERPKERNEL_EXPORT int size() const { return (int)_sub_edges.size(); }
87     INTERPKERNEL_EXPORT ElementaryEdge *operator[](int i) const;
88     INTERPKERNEL_EXPORT Node *getEndNode() const;
89     INTERPKERNEL_EXPORT Node *getStartNode() const;
90     INTERPKERNEL_EXPORT bool changeEndNodeWith(Node *node) const;
91     INTERPKERNEL_EXPORT bool changeStartNodeWith(Node *node) const;
92     INTERPKERNEL_EXPORT void dumpInXfigFile(std::ostream& stream, int resolution, const Bounds& box) const;
93     INTERPKERNEL_EXPORT bool isInOrOut(Node *nodeToTest) const;
94     INTERPKERNEL_EXPORT bool isInOrOut2(Node *nodeToTest) const;
95     INTERPKERNEL_EXPORT bool getDirection() const;
96     INTERPKERNEL_EXPORT bool intresincEqCoarse(const Edge *other) const;
97   private:
98     std::list<ElementaryEdge *>* getListBehind() { return &_sub_edges; }
99     double isInOrOutAlg(Node *nodeToTest, std::set< IntersectElement >& inOutSwitch) const;
100   protected:
101     ~ComposedEdge();
102   private:
103     void clearAll(std::list<ElementaryEdge *>::iterator startToDel);
104   protected:
105     std::list<ElementaryEdge *> _sub_edges;
106   };
107 }
108
109 #endif