0031688: Visualization - Wrong ISO lines for a face created from BSpline
[occt.git] / src / StdPrs / StdPrs_ToolRFace.cxx
1 // Copyright (c) 1995-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 //
4 // This file is part of Open CASCADE Technology software library.
5 //
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
11 //
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
14
15 #include <StdPrs_ToolRFace.hxx>
16
17 #include <Adaptor2d_Curve2d.hxx>
18 #include <BRep_Tool.hxx>
19 #include <BRepAdaptor_HSurface.hxx>
20 #include <TopoDS.hxx>
21
22 //=======================================================================
23 //function : StdPrs_ToolRFace
24 //purpose  :
25 //=======================================================================
26 StdPrs_ToolRFace::StdPrs_ToolRFace()
27 : myHasNullCurves (Standard_False)
28 {
29 }
30
31 //=======================================================================
32 //function : StdPrs_ToolRFace
33 //purpose  :
34 //=======================================================================
35 StdPrs_ToolRFace::StdPrs_ToolRFace (const Handle(BRepAdaptor_HSurface)& theSurface)
36 : myFace (theSurface->ChangeSurface().Face()),
37   myHasNullCurves (Standard_False)
38 {
39   myFace.Orientation(TopAbs_FORWARD);
40 }
41
42 //=======================================================================
43 //function : Edge
44 //purpose  :
45 //=======================================================================
46 const TopoDS_Edge& StdPrs_ToolRFace::Edge() const
47 {
48   return TopoDS::Edge (myExplorer.Current());
49 }
50
51 //=======================================================================
52 //function : next
53 //purpose  :
54 //=======================================================================
55 void StdPrs_ToolRFace::next()
56 {
57   Standard_Real aParamU1, aParamU2;
58   for (; myExplorer.More(); myExplorer.Next())
59   {
60     // skip INTERNAL and EXTERNAL edges
61     if (myExplorer.Current().Orientation() != TopAbs_FORWARD
62      && myExplorer.Current().Orientation() != TopAbs_REVERSED)
63     {
64       continue;
65     }
66
67     if (Handle(Geom2d_Curve) aCurve = BRep_Tool::CurveOnSurface (TopoDS::Edge (myExplorer.Current()), myFace, aParamU1, aParamU2))
68     {
69       myCurve.Load (aCurve, aParamU1, aParamU2);
70       return;
71     }
72     else
73     {
74       myHasNullCurves = Standard_True;
75     }
76   }
77
78   myCurve.Reset();
79 }