Back to index

salome-med  6.5.0
InterpKernelGeo2DEdgeArcCircle.hxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  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 __INTERPKERNELGEO2DEDGEARCCIRCLE_HXX__
00021 #define __INTERPKERNELGEO2DEDGEARCCIRCLE_HXX__
00022 
00023 #include "INTERPKERNELDefines.hxx"
00024 #include "InterpKernelGeo2DEdge.hxx"
00025 
00026 namespace INTERP_KERNEL
00027 {
00028   class INTERPKERNEL_EXPORT ArcCArcCIntersector : public SameTypeEdgeIntersector
00029   {
00030   public:
00031     ArcCArcCIntersector(const EdgeArcCircle& e1, const EdgeArcCircle& e2);
00032     bool haveTheySameDirection() const;
00033     void getPlacements(Node *start, Node *end, TypeOfLocInEdge& whereStart, TypeOfLocInEdge& whereEnd, MergePoints& commonNode) const;
00034     void areOverlappedOrOnlyColinears(const Bounds *whereToFind, bool& obviousNoIntersection, bool& areOverlapped);
00035     std::list< IntersectElement > getIntersectionsCharacteristicVal() const;
00036   private:
00038     double getAngle(Node *node) const;
00039     static bool areArcsOverlapped(const EdgeArcCircle& a1, const EdgeArcCircle& a2);
00040   private:
00041     const EdgeArcCircle& getE1() const { return (const EdgeArcCircle&)_e1; }
00042     const EdgeArcCircle& getE2() const { return (const EdgeArcCircle&)_e2; }
00043   private:
00044     double _dist;
00045   };
00046 
00047   class INTERPKERNEL_EXPORT ArcCSegIntersector : public CrossTypeEdgeIntersector
00048   {
00049   public:
00050     ArcCSegIntersector(const EdgeArcCircle& e1, const EdgeLin& e2, bool reverse=true);
00051     //virtual overloading
00052     void getPlacements(Node *start, Node *end, TypeOfLocInEdge& whereStart, TypeOfLocInEdge& whereEnd, MergePoints& commonNode) const;
00053     void areOverlappedOrOnlyColinears(const Bounds *whereToFind, bool& obviousNoIntersection, bool& areOverlapped);
00054     std::list< IntersectElement > getIntersectionsCharacteristicVal() const;
00055   private:
00056     const EdgeArcCircle& getE1() const { return (const EdgeArcCircle&)_e1; }
00057     const EdgeLin& getE2() const { return (const EdgeLin&)_e2; }
00058   private:
00059     double _dx;
00060     double _dy;
00061     double _drSq;
00062     double _cross;
00063     double _determinant;
00064   };
00065   
00066   class INTERPKERNEL_EXPORT EdgeArcCircle : public Edge
00067   {
00068   public:
00069     EdgeArcCircle(std::istream& lineInXfig);
00070     EdgeArcCircle(Node *start, Node *middle, Node *end, bool direction = true);
00071     EdgeArcCircle(double sX, double sY, double mX, double mY, double eX, double eY);
00072     EdgeArcCircle(Node *start, Node *end, const double *center, double radius, double angle0, double deltaAngle, bool direction=true);
00074     void changeMiddle(Node *newMiddle);
00075     void dumpInXfigFile(std::ostream& stream, bool direction, int resolution, const Bounds& box) const;
00076     void update(Node *m);
00077     double getAreaOfZone() const;
00078     double getCurveLength() const;
00079     void getBarycenter(double *bary) const;
00080     void getBarycenterOfZone(double *bary) const;
00081     bool isIn(double characterVal) const;
00082     Node *buildRepresentantOfMySelf() const;
00083     bool isLower(double val1, double val2) const;
00084     double getCharactValue(const Node& node) const;
00085     double getCharactValueBtw0And1(const Node& node) const;
00086     double getDistanceToPoint(const double *pt) const;
00087     bool isNodeLyingOn(const double *coordOfNode) const;
00088     TypeOfFunction getTypeOfFunc() const { return ARC_CIRCLE; }
00089     void dynCastFunction(const EdgeLin * &seg,
00090                          const EdgeArcCircle * &arcSeg) const { arcSeg=this; }
00091     const double *getCenter() const { return _center; }
00092     void getCenter(double *center) const { center[0]=_center[0]; center[1]=_center[1]; }
00093     bool doIHaveSameDirectionAs(const Edge& other) const { return false; }
00094     void applySimilarity(double xBary, double yBary, double dimChar);
00095     void unApplySimilarity(double xBary, double yBary, double dimChar);
00096     double getAngle0() const { return _angle0; }
00097     double getRadius() const { return _radius; }
00098     double getAngle() const { return _angle; }
00099     void tesselate(const int *conn, int offset, double eps, std::vector<int>& newConn, std::vector<double>& addCoo) const;
00100     static EdgeArcCircle *BuildFromNodes(Node *start, Node *middle, Node *end);
00101     static double GetAbsoluteAngle(const double *vect, double& normVect);
00102     static double GetAbsoluteAngleOfNormalizedVect(double ux, double uy);
00103     static void GetArcOfCirclePassingThru(const double *start, const double *middle, const double *end, 
00104                                           double *center, double& radius, double& angleInRad, double& angleInRad0);
00106     static double SafeSqrt(double val) { double ret=std::max(val,0.); return sqrt(ret); }
00107     static double SafeAcos(double cosAngle) { double ret=std::min(cosAngle,1.); ret=std::max(ret,-1.); return acos(ret); }
00108     static double SafeAsin(double sinAngle) { double ret=std::min(sinAngle,1.); ret=std::max(ret,-1.); return asin(ret); }
00110     static bool IsIn2Pi(double start, double delta, double angleIn);
00112     static bool IsAngleNotIn(double start, double delta, double angleIn);
00114     static double NormalizeAngle(double angle) { if(angle>M_PI) return angle-2.*M_PI; if(angle<-M_PI) return angle+2.*M_PI; return angle; }
00115   protected:
00116     void updateBounds();
00117     Edge *buildEdgeLyingOnMe(Node *start, Node *end, bool direction=true) const;
00118     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,
00119                            std::vector<int>& edgesThis, std::vector<double>& addCoo, std::map<INTERP_KERNEL::Node *,int> mapAddCoo) const;
00120     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,
00121                             std::vector<int>& edgesOther, std::vector<double>& addCoo, std::map<INTERP_KERNEL::Node *,int>& mapAddCoo) const;
00122   protected:
00124     double _angle;
00126     double _angle0;
00127     double _radius;
00128     double _center[2];
00129   };
00130 }
00131 
00132 #endif