2 // C++ : Implementation des associations d'edges
4 // Copyright (C) 2009-2021 CEA/DEN, EDF R&D
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #include "HexAssoEdge.hxx"
24 #include "HexXmlWriter.hxx"
26 #include <BRep_Builder.hxx>
27 #include <BRepAdaptor_Curve.hxx>
29 #include <GCPnts_AbscissaPoint.hxx>
35 // static bool db = on_debug ();
37 // ======================================================= Constructeur
38 AssoEdge::AssoEdge (EdgeShape* shape, double deb, double fin)
41 arc_para1 = std::min (deb, fin);
42 arc_para2 = std::max (deb, fin);
44 arc_line->getPoint (arc_para1, arc_start);
45 arc_line->getPoint (arc_para2, arc_end);
47 // arc_curve = arc_line->getCurve (); Provisoire en attendant modif plugin
48 arc_curve = arc_line->makeCurve ();
51 // ========================================================= onExtremity
52 int AssoEdge::onExtremity (double* point)
54 if (EdgeShape::samePoints (point, arc_start))
56 else if (EdgeShape::samePoints (point, arc_end))
61 // ========================================================= onExtremity
62 int AssoEdge::onExtremity (AssoEdge* other, int& ext_other)
68 int rep = onExtremity (other->arc_start);
75 rep = onExtremity (other->arc_end);
82 // ========================================================= length
83 double AssoEdge::length ()
85 double longueur = (arc_para2-arc_para1)*arc_line->getLength ();
88 // ========================================================= getUstart
89 double AssoEdge::getUstart ()
92 BRepAdaptor_Curve* curve = arc_line->getCurve () ;
93 double len = arc_line->getLength ();
95 GCPnts_AbscissaPoint discret_start (*curve, len*arc_para1,
96 curve->FirstParameter() );
97 ustart = discret_start.Parameter();
100 // ========================================================= saveXml
101 void AssoEdge::saveXml (XmlWriter* xml)
104 sprintf (interval, "%g %g", arc_para1, arc_para2);
106 arc_line->callXml (xml);
107 xml->addAttribute ("interval", interval);
110 // ========================================================= setStart
111 void AssoEdge::setStart (double param)
114 arc_line->getPoint (arc_para1, arc_start);
116 // ========================================================= setEnd
117 void AssoEdge::setEnd (double param)
120 arc_line->getPoint (arc_para2, arc_end);
122 // -----------------------------------------------------------------------
123 // ========================================================= dump
124 void AssoEdge::dump ()
126 std::cout << " AssoEddge = " << arc_line->getName()
127 << " (" << arc_para1 << ", " << arc_para2 << ")" << std::endl;
129 PutCoord (arc_start);