2 // C++ : Implementation des associations d'edges
4 // Copyright (C) 2009-2013 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.
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/
21 // 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>
33 // static bool db = on_debug ();
35 // ======================================================= Constructeur
36 AssoEdge::AssoEdge (EdgeShape* shape, double deb, double fin)
39 arc_para1 = std::min (deb, fin);
40 arc_para2 = std::max (deb, fin);
42 arc_line->getPoint (arc_para1, arc_start);
43 arc_line->getPoint (arc_para2, arc_end);
45 // arc_curve = arc_line->getCurve (); Provisoire en attendant modif plugin
46 arc_curve = arc_line->makeCurve ();
49 // ========================================================= onExtremity
50 int AssoEdge::onExtremity (double* point)
52 if (EdgeShape::samePoints (point, arc_start))
54 else if (EdgeShape::samePoints (point, arc_end))
59 // ========================================================= onExtremity
60 int AssoEdge::onExtremity (AssoEdge* other, int& ext_other)
66 int rep = onExtremity (other->arc_start);
73 rep = onExtremity (other->arc_end);
80 // ========================================================= length
81 double AssoEdge::length ()
83 double longueur = (arc_para2-arc_para1)*arc_line->getLength ();
86 // ========================================================= getUstart
87 double AssoEdge::getUstart ()
90 BRepAdaptor_Curve* curve = arc_line->getCurve () ;
91 double len = arc_line->getLength ();
93 GCPnts_AbscissaPoint discret_start (*curve, len*arc_para1,
94 curve->FirstParameter() );
95 ustart = discret_start.Parameter();
98 // ========================================================= saveXml
99 void AssoEdge::saveXml (XmlWriter* xml)
102 sprintf (interval, "%g %g", arc_para1, arc_para2);
104 arc_line->callXml (xml);
105 xml->addAttribute ("interval", interval);
108 // ========================================================= setStart
109 void AssoEdge::setStart (double param)
112 arc_line->getPoint (arc_para1, arc_start);
114 // ========================================================= setEnd
115 void AssoEdge::setEnd (double param)
118 arc_line->getPoint (arc_para2, arc_end);
120 // -----------------------------------------------------------------------
121 // ========================================================= dump
122 void AssoEdge::dump ()
124 cout << " AssoEddge = " << arc_line->getName()
125 << " (" << arc_para1 << ", " << arc_para2 << ")" << endl;
127 PutCoord (arc_start);