1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : Anthony Geay (CEA/DEN)
21 #ifndef __INTERPKERNELGEO2DCOMPOSEDNODE_HXX__
22 #define __INTERPKERNELGEO2DCOMPOSEDNODE_HXX__
24 #include "INTERPKERNELDefines.hxx"
25 #include "InterpKernelGeo2DEdge.hxx"
32 namespace INTERP_KERNEL
38 class IteratorOnComposedEdge;
41 * A set of quadratic or linear edges, described mainly by their connectivity
42 * The set is assumed to be connected, but not necessarily closed (i.e. not necessarily forming a closed polygon).
43 * Some methods however requires a closed form.
47 friend class IteratorOnComposedEdge;
49 INTERPKERNEL_EXPORT ComposedEdge() { }
50 INTERPKERNEL_EXPORT ComposedEdge(const ComposedEdge& other);
51 INTERPKERNEL_EXPORT ComposedEdge(int sz):_sub_edges(sz) { }
52 INTERPKERNEL_EXPORT static void Delete(ComposedEdge *pt) { delete pt; }
53 INTERPKERNEL_EXPORT static void SoftDelete(ComposedEdge *pt) { pt->_sub_edges.clear(); delete pt; }
54 INTERPKERNEL_EXPORT void reverse();
55 INTERPKERNEL_EXPORT int recursiveSize() const { return (int)_sub_edges.size(); }
56 INTERPKERNEL_EXPORT bool presenceOfOn() const;
57 INTERPKERNEL_EXPORT bool presenceOfQuadraticEdge() const;
58 INTERPKERNEL_EXPORT void initLocations() const;
59 INTERPKERNEL_EXPORT static void InitLocationsWithOther(const ComposedEdge& first, const ComposedEdge& other);
60 INTERPKERNEL_EXPORT ComposedEdge *clone() const;
61 INTERPKERNEL_EXPORT bool isNodeIn(Node *n) const;
62 INTERPKERNEL_EXPORT double getArea() const;
63 INTERPKERNEL_EXPORT double getPerimeter() const;
64 INTERPKERNEL_EXPORT double getHydraulicDiameter() const;
65 INTERPKERNEL_EXPORT void getBarycenter(double *bary) const;
66 INTERPKERNEL_EXPORT void getBarycenterGeneral(double *bary) const;
67 INTERPKERNEL_EXPORT double normalizeMe(double& xBary, double& yBary);
68 INTERPKERNEL_EXPORT double normalize(ComposedEdge *other, double& xBary, double& yBary);
69 INTERPKERNEL_EXPORT double normalizeExt(ComposedEdge *other, double& xBary, double& yBary);
70 INTERPKERNEL_EXPORT void unApplyGlobalSimilarityExt(ComposedEdge& other, double xBary, double yBary, double fact);
71 INTERPKERNEL_EXPORT void fillBounds(Bounds& output) const;
72 INTERPKERNEL_EXPORT void applySimilarity(double xBary, double yBary, double dimChar);
73 INTERPKERNEL_EXPORT void applyGlobalSimilarity(double xBary, double yBary, double dimChar);
74 INTERPKERNEL_EXPORT void applyGlobalSimilarity2(ComposedEdge *other, double xBary, double yBary, double dimChar);
75 INTERPKERNEL_EXPORT void dispatchPerimeter(double& partConsidered) const;
76 INTERPKERNEL_EXPORT void dispatchPerimeterExcl(double& partConsidered, double& commonPart) const;
77 INTERPKERNEL_EXPORT double dispatchPerimeterAdv(const ComposedEdge& father, std::vector<double>& result) const;
78 INTERPKERNEL_EXPORT void getAllNodes(std::set<Node *>& output) const;
79 INTERPKERNEL_EXPORT void initNodeHitStatus() const;
80 INTERPKERNEL_EXPORT void applySimilarityOnMyNodes(double xBary, double yBary, double dimChar) const;
81 INTERPKERNEL_EXPORT void unApplySimilarityOnMyNodes(double xBary, double yBary, double dimChar) const;
82 INTERPKERNEL_EXPORT void applySimilarityOnMyNodesIfNotAlreadyHit(double xBary, double yBary, double dimChar) const;
83 INTERPKERNEL_EXPORT void unApplySimilarityOnMyNodesIfNotAlreadyHit(double xBary, double yBary, double dimChar) const;
84 INTERPKERNEL_EXPORT void initEdgeHitStatus() const;
85 INTERPKERNEL_EXPORT void applySimilarityOnMyEdges(double xBary, double yBary, double dimChar) const;
86 INTERPKERNEL_EXPORT void unApplySimilarityOnMyEdges(double xBary, double yBary, double dimChar) const;
87 INTERPKERNEL_EXPORT void applySimilarityOnMyEdgesIfNotAlreadyHit(double xBary, double yBary, double dimChar) const;
88 INTERPKERNEL_EXPORT void unApplySimilarityOnMyEdgesIfNotAlreadyHit(double xBary, double yBary, double dimChar) const;
89 INTERPKERNEL_EXPORT void getBarycenter(double *bary, double& weigh) const;
90 INTERPKERNEL_EXPORT bool completed() const { return getEndNode()==getStartNode(); }
91 INTERPKERNEL_EXPORT void setValueAt(int i, Edge *e, bool direction=true);
92 INTERPKERNEL_EXPORT double getCommonLengthWith(const ComposedEdge& other) const;
93 INTERPKERNEL_EXPORT void clear();
94 INTERPKERNEL_EXPORT bool empty() const { return _sub_edges.empty(); }
95 INTERPKERNEL_EXPORT ElementaryEdge *front() const { return _sub_edges.front(); }
96 INTERPKERNEL_EXPORT ElementaryEdge *back() const { return _sub_edges.back(); }
97 INTERPKERNEL_EXPORT void resize(int i) { _sub_edges.resize(i); }
98 INTERPKERNEL_EXPORT void pushBack(Edge *edge, bool direction=true);
99 INTERPKERNEL_EXPORT void pushBack(ElementaryEdge *elem);
100 INTERPKERNEL_EXPORT void pushBack(ComposedEdge *elem);
101 INTERPKERNEL_EXPORT int size() const { return (int)_sub_edges.size(); }
102 INTERPKERNEL_EXPORT ElementaryEdge *operator[](int i) const;
103 INTERPKERNEL_EXPORT Node *getEndNode() const;
104 INTERPKERNEL_EXPORT Node *getStartNode() const;
105 INTERPKERNEL_EXPORT bool changeEndNodeWith(Node *node) const;
106 INTERPKERNEL_EXPORT bool changeStartNodeWith(Node *node) const;
107 INTERPKERNEL_EXPORT void dumpInXfigFile(std::ostream& stream, int resolution, const Bounds& box) const;
108 INTERPKERNEL_EXPORT bool isInOrOut(Node *nodeToTest) const;
109 INTERPKERNEL_EXPORT bool isInOrOut2(Node *nodeToTest) const;
110 INTERPKERNEL_EXPORT bool getDirection() const;
111 INTERPKERNEL_EXPORT bool intresincEqCoarse(const Edge *other) const;
113 std::list<ElementaryEdge *>* getListBehind() { return &_sub_edges; }
114 double isInOrOutAlg(Node *nodeToTest, const std::set<Node*>& nodes, std::set< IntersectElement >& inOutSwitch) const;
118 void clearAll(std::list<ElementaryEdge *>::iterator startToDel);
120 std::list<ElementaryEdge *> _sub_edges;