00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __INTERPKERNELGEO2DEDGEARCCIRCLE_HXX__
00021 #define __INTERPKERNELGEO2DEDGEARCCIRCLE_HXX__
00022
00023 #include "INTERPKERNELGEOMETRIC2DDefines.hxx"
00024 #include "InterpKernelGeo2DEdge.hxx"
00025
00026 namespace INTERP_KERNEL
00027 {
00028 class INTERPKERNELGEOMETRIC2D_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 INTERPKERNELGEOMETRIC2D_EXPORT ArcCSegIntersector : public CrossTypeEdgeIntersector
00048 {
00049 public:
00050 ArcCSegIntersector(const EdgeArcCircle& e1, const EdgeLin& e2, bool reverse=true);
00051
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 INTERPKERNELGEOMETRIC2D_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 getDistanceToPoint(const double *pt) const;
00086 bool isNodeLyingOn(const double *coordOfNode) const;
00087 TypeOfFunction getTypeOfFunc() const { return ARC_CIRCLE; }
00088 void dynCastFunction(const EdgeLin * &seg,
00089 const EdgeArcCircle * &arcSeg) const { arcSeg=this; }
00090 const double *getCenter() const { return _center; }
00091 void getCenter(double *center) const { center[0]=_center[0]; center[1]=_center[1]; }
00092 bool doIHaveSameDirectionAs(const Edge& other) const { return false; }
00093 void applySimilarity(double xBary, double yBary, double dimChar);
00094 double getAngle0() const { return _angle0; }
00095 double getRadius() const { return _radius; }
00096 double getAngle() const { return _angle; }
00097 static double getAbsoluteAngle(const double *vect, double& normVect);
00098 static double getAbsoluteAngleOfNormalizedVect(double ux, double uy);
00099 static void getArcOfCirclePassingThru(const double *start, const double *middle, const double *end,
00100 double *center, double& radius, double& angleInRad, double& angleInRad0);
00102 static double safeSqrt(double val) { double ret=std::max(val,0.); return sqrt(ret); }
00103 static double safeAcos(double cosAngle) { double ret=std::min(cosAngle,1.); ret=std::max(ret,-1.); return acos(ret); }
00104 static double safeAsin(double sinAngle) { double ret=std::min(sinAngle,1.); ret=std::max(ret,-1.); return asin(ret); }
00106 static bool isIn2Pi(double start, double delta, double angleIn);
00108 static bool isAngleNotIn(double start, double delta, double angleIn);
00110 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; }
00111 protected:
00112 void updateBounds();
00113 Edge *buildEdgeLyingOnMe(Node *start, Node *end, bool direction=true) const;
00114 protected:
00116 double _angle;
00118 double _angle0;
00119 double _radius;
00120 double _center[2];
00121 };
00122 }
00123
00124 #endif