1 // Created on: 1998-07-27
2 // Created by: Philippe MANGIN
3 // Copyright (c) 1998-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
18 #include <Adaptor3d_CurveOnSurface.hxx>
19 #include <Adaptor3d_HCurveOnSurface.hxx>
20 #include <BRep_Tool.hxx>
21 #include <BRepAdaptor_HSurface.hxx>
22 #include <BRepFill_EdgeOnSurfLaw.hxx>
23 #include <BRepTools_WireExplorer.hxx>
24 #include <Geom2d_Curve.hxx>
25 #include <Geom2d_TrimmedCurve.hxx>
26 #include <Geom2dAdaptor_HCurve.hxx>
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>
34 #include <TopoDS_Edge.hxx>
35 #include <TopoDS_Shape.hxx>
36 #include <TopoDS_Wire.hxx>
37 #include <TopTools_HArray1OfShape.hxx>
39 IMPLEMENT_STANDARD_RTTIEXT(BRepFill_EdgeOnSurfLaw,BRepFill_LocationLaw)
41 BRepFill_EdgeOnSurfLaw::BRepFill_EdgeOnSurfLaw(const TopoDS_Wire& Path,
42 const TopoDS_Shape& Surf)
44 hasresult = Standard_True;
47 Standard_Boolean Trouve;
48 Standard_Integer ipath;// ,NbEdge;
49 TopAbs_Orientation Or;
50 BRepTools_WireExplorer wexp;
52 // Class BRep_Tool without fields and without Constructor :
55 Handle(Geom2d_Curve) C;
56 Handle(Geom2dAdaptor_HCurve) AC2d;
57 Handle(Adaptor3d_HCurveOnSurface) AC;
58 Handle(BRepAdaptor_HSurface) AS;
59 Standard_Real First = 0., Last = 0.;
60 Handle(GeomFill_Darboux) TLaw = new (GeomFill_Darboux)() ;
61 Handle(GeomFill_CurveAndTrihedron) Law =
62 new (GeomFill_CurveAndTrihedron) (TLaw);
64 for (ipath=0, wexp.Init(myPath);
65 wexp.More(); wexp.Next()) {
67 // if (!B.Degenerated(E)) {
68 if (!BRep_Tool::Degenerated(E)) {
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);
77 AS = new (BRepAdaptor_HSurface) (F);
80 if (!Trouve) { // Impossible to construct the law.
81 hasresult = Standard_False;
87 if (Or == TopAbs_REVERSED) {
88 Handle(Geom2d_TrimmedCurve) CBis =
89 new (Geom2d_TrimmedCurve) (C, First, Last);
90 CBis->Reverse(); // To avoid spoiling the topology
92 First = C->FirstParameter();
93 Last = C->LastParameter();
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);
105 Standard_Boolean BRepFill_EdgeOnSurfLaw::HasResult() const