0026936: Drawbacks of inlining in new type system in OCCT 7.0 -- automatic
[occt.git] / src / BRepFill / BRepFill_EdgeOnSurfLaw.cxx
CommitLineData
b311480e 1// Created on: 1998-07-27
2// Created by: Philippe MANGIN
3// Copyright (c) 1998-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 8// This library is free software; you can redistribute it and/or modify it under
9// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 10// by the Free Software Foundation, with special exception defined in the file
11// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12// distribution for complete text of the license and disclaimer of any warranty.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
7fd59977 17
42cf5bc1 18#include <Adaptor3d_CurveOnSurface.hxx>
19#include <Adaptor3d_HCurveOnSurface.hxx>
7fd59977 20#include <BRep_Tool.hxx>
42cf5bc1 21#include <BRepAdaptor_HSurface.hxx>
22#include <BRepFill_EdgeOnSurfLaw.hxx>
23#include <BRepTools_WireExplorer.hxx>
7fd59977 24#include <Geom2d_Curve.hxx>
25#include <Geom2d_TrimmedCurve.hxx>
7fd59977 26#include <Geom2dAdaptor_HCurve.hxx>
42cf5bc1 27#include <GeomFill_CurveAndTrihedron.hxx>
28#include <GeomFill_Darboux.hxx>
29#include <GeomFill_HArray1OfLocationLaw.hxx>
30#include <GeomFill_LocationLaw.hxx>
31#include <Standard_Type.hxx>
32#include <TopExp_Explorer.hxx>
33#include <TopoDS.hxx>
34#include <TopoDS_Edge.hxx>
35#include <TopoDS_Shape.hxx>
36#include <TopoDS_Wire.hxx>
37#include <TopTools_HArray1OfShape.hxx>
7fd59977 38
92efcf78 39IMPLEMENT_STANDARD_RTTIEXT(BRepFill_EdgeOnSurfLaw,BRepFill_LocationLaw)
40
7fd59977 41BRepFill_EdgeOnSurfLaw::BRepFill_EdgeOnSurfLaw(const TopoDS_Wire& Path,
42 const TopoDS_Shape& Surf)
43{
44 hasresult = Standard_True;
45 Init(Path);
46
47 Standard_Boolean Trouve;
48 Standard_Integer ipath;// ,NbEdge;
49 TopAbs_Orientation Or;
50 BRepTools_WireExplorer wexp;
51 TopExp_Explorer exp;
52// Class BRep_Tool without fields and without Constructor :
53// BRep_Tool B;
54 TopoDS_Edge E;
55 Handle(Geom2d_Curve) C;
56 Handle(Geom2dAdaptor_HCurve) AC2d;
57 Handle(Adaptor3d_HCurveOnSurface) AC;
58 Handle(BRepAdaptor_HSurface) AS;
1d47d8d0 59 Standard_Real First = 0., Last = 0.;
7fd59977 60 Handle(GeomFill_Darboux) TLaw = new (GeomFill_Darboux)() ;
61 Handle(GeomFill_CurveAndTrihedron) Law =
62 new (GeomFill_CurveAndTrihedron) (TLaw);
63
64 for (ipath=0, wexp.Init(myPath);
65 wexp.More(); wexp.Next()) {
66 E = wexp.Current();
67// if (!B.Degenerated(E)) {
68 if (!BRep_Tool::Degenerated(E)) {
69 ipath++;
70 myEdges->SetValue(ipath, E);
71 for (Trouve=Standard_False, exp.Init(Surf, TopAbs_FACE);
72 exp.More() && !Trouve; exp.Next()) {
73 const TopoDS_Face& F = TopoDS::Face(exp.Current());
74 C = BRep_Tool::CurveOnSurface(E, F, First, Last);
75 if (!C.IsNull()) {
76 Trouve=Standard_True;
77 AS = new (BRepAdaptor_HSurface) (F);
78 }
79 }
0d969553 80 if (!Trouve) { // Impossible to construct the law.
7fd59977 81 hasresult = Standard_False;
82 myLaws.Nullify();
83 return;
84 }
85
86 Or = E.Orientation();
87 if (Or == TopAbs_REVERSED) {
88 Handle(Geom2d_TrimmedCurve) CBis =
89 new (Geom2d_TrimmedCurve) (C, First, Last);
0d969553 90 CBis->Reverse(); // To avoid spoiling the topology
7fd59977 91 C = CBis;
92 First = C->FirstParameter();
93 Last = C->LastParameter();
94 }
95
96 AC2d = new (Geom2dAdaptor_HCurve) (C,First, Last);
97 AC = new (Adaptor3d_HCurveOnSurface)
98 (Adaptor3d_CurveOnSurface(AC2d, AS));
99 myLaws->SetValue(ipath, Law->Copy());
100 myLaws->ChangeValue(ipath)->SetCurve(AC);
101 }
102 }
103}
104
105 Standard_Boolean BRepFill_EdgeOnSurfLaw::HasResult() const
106{
107 return hasresult;
108}
109