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/ 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 ();
34 // static const double TolAsso = 1e-2; // Tolerance pour les associations
36 // ========================================================= Constructeur
37 AssoEdge::AssoEdge (EdgeShape* shape, double deb, double fin)
40 arc_para1 = std::min (deb, fin);
41 arc_para2 = std::max (deb, fin);
43 arc_line->getPoint (arc_para1, arc_start);
44 arc_line->getPoint (arc_para2, arc_end);
46 // arc_curve = arc_line->getCurve (); Provisoire en attendant modif plugin
47 arc_curve = arc_line->makeCurve ();
50 // ========================================================= onExtremity
51 int AssoEdge::onExtremity (double* point)
53 if (EdgeShape::samePoints (point, arc_start))
55 else if (EdgeShape::samePoints (point, arc_end))
60 // ========================================================= onExtremity
61 int AssoEdge::onExtremity (AssoEdge* other, int& ext_other)
67 int rep = onExtremity (other->arc_start);
74 rep = onExtremity (other->arc_end);
81 // ========================================================= length
82 double AssoEdge::length ()
84 double longueur = (arc_para2-arc_para1)*arc_line->getLength ();
87 // ========================================================= getUstart
88 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 double 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);