Salome HOME
Copyright update 2020
[modules/hexablock.git] / src / HEXABLOCK / HexEdgeShape.cxx
old mode 100755 (executable)
new mode 100644 (file)
index 3a5b86d..2903000
@@ -1,12 +1,12 @@
 
 // C++ : Gestion des soous-shapes
 
-// Copyright (C) 2009-2013  CEA/DEN, EDF R&D
+// Copyright (C) 2009-2020  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 // License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -24,8 +24,6 @@
 
 #include "HexEdgeShape.hxx"
 
-#ifndef NO_CASCADE
-
 #include <TopoDS.hxx>
 #include <TopoDS_Edge.hxx>
 #include <gp_Pnt.hxx>
 #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
 
@@ -52,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 ()
@@ -138,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)
 {
@@ -170,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;
 
@@ -179,18 +212,21 @@ double EdgeShape::getParam (double* coord)
 // ====================================================== getAssociation
 Edge* EdgeShape::getAssociation (int nro)
 {
-   if (nro>0 && nro<tab_assoc.size())
+   if (nro>0 && nro<(int)tab_assoc.size())
       return tab_assoc[nro];
    else
       return NULL;
 }
-// ========================================================== addAssociation
+// ==================================================== addAssociation
 void EdgeShape::addAssociation (Edge* edge)
 {
    tab_assoc.push_back (edge);
    is_associated = true;
 }
-// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+ // ------- Cf GEOMImpl_IMeasureOperations.cxx
+
 // ====================================================== updateCurve
 void EdgeShape::updateCurve ()
 {
@@ -218,6 +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
-#endif