Version: 6.3.1

src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DQuadraticPolygon.hxx

Go to the documentation of this file.
00001 // Copyright (C) 2007-2011  CEA/DEN, EDF R&D
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 #ifndef __INTERPKERNELGEO2DQUADRATICPOLYGON_HXX__
00021 #define __INTERPKERNELGEO2DQUADRATICPOLYGON_HXX__
00022 
00023 #include "INTERPKERNELGEOMETRIC2DDefines.hxx"
00024 
00025 #include "InterpKernelGeo2DComposedEdge.hxx"
00026 #include "InterpKernelGeo2DAbstractEdge.hxx"
00027 #include "InterpKernelGeo2DElementaryEdge.hxx"
00028 
00029 #include <list>
00030 #include <vector>
00031 
00032 namespace INTERP_KERNEL
00033 {
00034   class Edge;
00035   class MergePoints;
00036 
00037   class INTERPKERNELGEOMETRIC2D_EXPORT QuadraticPolygon : public ComposedEdge
00038   {
00039   public:
00040     QuadraticPolygon() { }
00041     QuadraticPolygon(const QuadraticPolygon& other):ComposedEdge(other) { }
00042     QuadraticPolygon(const char *fileName);
00043     static QuadraticPolygon *buildLinearPolygon(std::vector<Node *>& nodes);
00044     static QuadraticPolygon *buildArcCirclePolygon(std::vector<Node *>& nodes);
00045     static void buildDbgFile(const std::vector<Node *>& nodes, const char *fileName);
00046     ~QuadraticPolygon();
00047     void closeMe() const;
00048     void circularPermute();
00049     bool isButterfly() const;
00050     void dumpInXfigFile(const char *fileName) const;
00051     void dumpInXfigFileWithOther(const ComposedEdge& other, const char *fileName) const;
00053     double intersectWithAbs(QuadraticPolygon& other);
00055     double intersectWithAbs(QuadraticPolygon& other, double* barycenter);
00056     double intersectWith(const QuadraticPolygon& other) const;
00057     double intersectWith(const QuadraticPolygon& other, double* barycenter) const;
00058     std::vector<QuadraticPolygon *> intersectMySelfWith(const QuadraticPolygon& other) const;
00059     void intersectForPerimeter(const QuadraticPolygon& other, double& perimeterThisPart, double& perimeterOtherPart, double& perimeterCommonPart) const;
00060     void intersectForPerimeterAdvanced(const QuadraticPolygon& other, std::vector< double >& polThis, std::vector< double >& polOther) const;
00061     void intersectForPoint(const QuadraticPolygon& other, std::vector< int >& numberOfCreatedPointsPerEdge) const;
00062   public://Only public for tests reasons
00063     void performLocatingOperation(QuadraticPolygon& pol2) const;
00064     static void splitPolygonsEachOther(QuadraticPolygon& pol1, QuadraticPolygon& pol2, int& nbOfSplits);
00065     std::vector<QuadraticPolygon *> buildIntersectionPolygons(const QuadraticPolygon& pol1, const QuadraticPolygon& pol2) const;
00066     bool amIAChanceToBeCompletedBy(const QuadraticPolygon& pol1Splitted, const QuadraticPolygon& pol2NotSplitted, bool& direction);
00067   protected:
00068     std::list<QuadraticPolygon *> zipConsecutiveInSegments() const;
00069     void dumpInXfigFile(std::ostream& stream, int resolution, const Bounds& box) const;
00070     void closePolygons(std::list<QuadraticPolygon *>& pol2Zip, const QuadraticPolygon& pol1, std::vector<QuadraticPolygon *>& results) const;
00071     template<class EDGES>
00072       static void updateNeighbours(const MergePoints& merger, IteratorOnComposedEdge it1, IteratorOnComposedEdge it2,
00073                                    const EDGES *e1, const EDGES *e2);
00074     std::list<QuadraticPolygon *>::iterator fillAsMuchAsPossibleWith(const QuadraticPolygon& pol1Splitted,
00075                                                                      std::list<QuadraticPolygon *>::iterator iStart,
00076                                                                      std::list<QuadraticPolygon *>::iterator iEnd,
00077                                                                      bool direction);
00078     static std::list<QuadraticPolygon *>::iterator checkInList(Node *n, std::list<QuadraticPolygon *>::iterator iStart,
00079                                                                std::list<QuadraticPolygon *>::iterator iEnd);
00080   };
00081 }
00082 
00083 namespace INTERP_KERNEL
00084 {
00085   template<class EDGES>
00086   void QuadraticPolygon::updateNeighbours(const MergePoints& merger, IteratorOnComposedEdge it1, IteratorOnComposedEdge it2,
00087                                           const EDGES *e1, const EDGES *e2)
00088   {
00089     it1.previousLoop(); it2.previousLoop();
00090     ElementaryEdge *curE1=it1.current(); ElementaryEdge *curE2=it2.current();
00091     curE1->changeEndNodeWith(e1->getStartNode()); curE2->changeEndNodeWith(e2->getStartNode());
00092     it1.nextLoop(); it1.nextLoop(); it2.nextLoop(); it2.nextLoop();
00093     curE1->changeStartNodeWith(e1->getEndNode()); curE2->changeStartNodeWith(e2->getEndNode());
00094   }
00095 }
00096 
00097 #endif
Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS