1 // Copyright (C) 2007-2008 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.
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 #ifndef __QUADRATICPOLYGON_HXX__
20 #define __QUADRATICPOLYGON_HXX__
22 #include "INTERPKERNELGEOMETRIC2DDefines.hxx"
24 #include "ComposedEdge.hxx"
25 #include "AbstractEdge.hxx"
26 #include "ElementaryEdge.hxx"
31 namespace INTERP_KERNEL
36 class INTERPKERNELGEOMETRIC2D_EXPORT QuadraticPolygon : public ComposedEdge
39 QuadraticPolygon() { }
40 QuadraticPolygon(const QuadraticPolygon& other):ComposedEdge(other) { }
41 QuadraticPolygon(const char *fileName);
42 static QuadraticPolygon *buildLinearPolygon(std::vector<Node *>& nodes);
43 static QuadraticPolygon *buildArcCirclePolygon(std::vector<Node *>& nodes);
44 static void buildDbgFile(const std::vector<Node *>& nodes, const char *fileName);
47 void circularPermute();
48 void dumpInXfigFile(const char *fileName) const;
49 void dumpInXfigFileWithOther(const ComposedEdge& other, const char *fileName) const;
50 //! Before intersecting as intersectWith a normalization is done.
51 double intersectWithAbs(QuadraticPolygon& other);
52 double intersectWith(const QuadraticPolygon& other) const;
53 std::vector<QuadraticPolygon *> intersectMySelfWith(const QuadraticPolygon& other) const;
54 void intersectForPerimeter(const QuadraticPolygon& other, double& perimeterThisPart, double& perimeterOtherPart, double& perimeterCommonPart) const;
55 void intersectForPerimeterAdvanced(const QuadraticPolygon& other, std::vector< double >& polThis, std::vector< double >& polOther) const;
56 void intersectForPoint(const QuadraticPolygon& other, std::vector< int >& numberOfCreatedPointsPerEdge) const;
57 public://Only public for tests reasons
58 void performLocatingOperation(QuadraticPolygon& pol2) const;
59 static void splitPolygonsEachOther(QuadraticPolygon& pol1, QuadraticPolygon& pol2, int& nbOfSplits);
60 std::vector<QuadraticPolygon *> buildIntersectionPolygons(const QuadraticPolygon& pol1, const QuadraticPolygon& pol2) const;
61 bool amIAChanceToBeCompletedBy(const QuadraticPolygon& pol1Splitted, const QuadraticPolygon& pol2NotSplitted, bool& direction);
63 std::list<QuadraticPolygon *> zipConsecutiveInSegments() const;
64 void dumpInXfigFile(std::ostream& stream, int resolution, const Bounds& box) const;
65 void closePolygons(std::list<QuadraticPolygon *>& pol2Zip, const QuadraticPolygon& pol1, std::vector<QuadraticPolygon *>& results) const;
67 static void updateNeighbours(const MergePoints& merger, IteratorOnComposedEdge it1, IteratorOnComposedEdge it2,
68 const EDGES *e1, const EDGES *e2);
69 std::list<QuadraticPolygon *>::iterator fillAsMuchAsPossibleWith(const QuadraticPolygon& pol1Splitted,
70 std::list<QuadraticPolygon *>::iterator iStart,
71 std::list<QuadraticPolygon *>::iterator iEnd,
73 static std::list<QuadraticPolygon *>::iterator checkInList(Node *n, std::list<QuadraticPolygon *>::iterator iStart,
74 std::list<QuadraticPolygon *>::iterator iEnd);
78 namespace INTERP_KERNEL
81 void QuadraticPolygon::updateNeighbours(const MergePoints& merger, IteratorOnComposedEdge it1, IteratorOnComposedEdge it2,
82 const EDGES *e1, const EDGES *e2)
84 it1.previousLoop(); it2.previousLoop();
85 ElementaryEdge *curE1=it1.current(); ElementaryEdge *curE2=it2.current();
86 curE1->changeEndNodeWith(e1->getStartNode()); curE2->changeEndNodeWith(e2->getStartNode());
87 it1.nextLoop(); it1.nextLoop(); it2.nextLoop(); it2.nextLoop();
88 curE1->changeStartNodeWith(e1->getEndNode()); curE2->changeStartNodeWith(e2->getEndNode());