Salome HOME
Bug moteur + ajout cas test
[modules/hexablock.git] / src / HEXABLOCK / HexEdgeShape.cxx
index bd34bb705e092d5f3fd1279b2d631a61db40849a..0b90d6b68ba005f99d38d2b6064d7d47608afd0a 100755 (executable)
 #include <GCPnts_AbscissaPoint.hxx>
 
 #include <GeomAPI_ProjectPointOnCurve.hxx>
+#include <Geom_Circle.hxx>
+
+/****************
+#include <Standard_Stream.hxx>
+#include <GEOMImpl_IMeasureOperations.hxx>
+#include <GEOMImpl_Types.hxx>
+#include <GEOMImpl_MeasureDriver.hxx>
+#include <GEOMImpl_IMeasure.hxx>
+#include <GEOMImpl_IShapesOperations.hxx>
+#include <GEOMUtils.hxx>
+#include <GEOMAlgo_ShapeInfo.hxx>
+#include <GEOMAlgo_ShapeInfoFiller.hxx>
+*********************************/
 
 BEGIN_NAMESPACE_HEXA
 
@@ -50,6 +63,8 @@ EdgeShape::EdgeShape (NewShape* dad, int id)
    lin_end   [dir_x] = lin_end   [dir_y] = lin_end   [dir_z] = 0;
    par_mini   = 0;
    par_maxi   = 0;
+   lin_radius = 0;
+   lin_angle  = 0;
 }
 // ====================================================== getCurve
 BRepAdaptor_Curve* EdgeShape::getCurve ()
@@ -136,6 +151,19 @@ int EdgeShape::onExtremity (double* point)
    else
       return NOTHING;
 }
+// ========================================================= definedBy
+bool EdgeShape::definedBy (double p1[], double p2[])
+{
+   if (maj_curve)
+      updateCurve ();
+
+   bool rep = false;
+   if (samePoints  (p1, lin_start))
+      rep = samePoints  (p2, lin_end);
+   else if (samePoints  (p1, lin_end))
+      rep = samePoints  (p2, lin_start);
+   return rep;
+}
 // ========================================================= getParam
 double EdgeShape::getParam (double* coord)
 {
@@ -168,6 +196,13 @@ double EdgeShape::getParam (double* coord)
       return -1.0;
 
    GeomAdaptor_Curve  adapt_curve (handle);
+
+/******************
+   enum GeomAbs_CurveType { GeomAbs_Line, GeomAbs_Circle, GeomAbs_Ellipse,
+                            GeomAbs_Hyperbola, GeomAbs_Parabola, GeomAbs_BezierCurve,
+                            GeomAbs_BSplineCurve, GeomAbs_OtherCurve };
+ **********************/
+
    double abscis = GCPnts_AbscissaPoint::Length (adapt_curve, umin, gparam);
    double hparam = abscis/lin_length;
 
@@ -189,6 +224,9 @@ void EdgeShape::addAssociation (Edge* edge)
    is_associated = true;
 }
 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+ // ------- Cf GEOMImpl_IMeasureOperations.cxx
+
 // ====================================================== updateCurve
 void EdgeShape::updateCurve ()
 {
@@ -216,5 +254,40 @@ void EdgeShape::updateCurve ()
                                // Extremites
    getPoint (0, lin_start);
    getPoint (1, lin_end);
+
+   lin_radius = lin_angle = 0;
+   kind_of    = (EnumKindOfShape) adapt_curve.GetType();
+#ifndef NO_CASCADE
+   if (kind_of==KS_Circle)
+      {
+      Handle(Geom_Circle) hgc = Handle(Geom_Circle)::DownCast (handle);
+      lin_radius = hgc->Radius ();
+      lin_angle  = (par_maxi-par_mini)*180/M_PI;
+      }
+#endif
+}
+// ====================================================== getAngle
+double EdgeShape::getAngle ()
+{
+   if (maj_curve)
+      updateCurve ();
+
+   return lin_angle;
+}
+// ====================================================== getRadius
+double EdgeShape::getRadius ()
+{
+   if (maj_curve)
+      updateCurve ();
+
+   return lin_radius;
+}
+// ====================================================== getRadius
+EnumKindOfShape EdgeShape::kindOf ()
+{
+   if (maj_curve)
+      updateCurve ();
+
+   return kind_of;
 }
 END_NAMESPACE_HEXA