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.
17 #include <BRepFill_EdgeOnSurfLaw.hxx>
19 #include <Adaptor3d_CurveOnSurface.hxx>
20 #include <BRep_Tool.hxx>
21 #include <BRepAdaptor_Surface.hxx>
22 #include <BRepTools_WireExplorer.hxx>
23 #include <Geom2d_Curve.hxx>
24 #include <Geom2d_TrimmedCurve.hxx>
25 #include <Geom2dAdaptor_Curve.hxx>
26 #include <GeomFill_CurveAndTrihedron.hxx>
27 #include <GeomFill_Darboux.hxx>
28 #include <GeomFill_HArray1OfLocationLaw.hxx>
29 #include <GeomFill_LocationLaw.hxx>
30 #include <Standard_Type.hxx>
31 #include <TopExp_Explorer.hxx>
33 #include <TopoDS_Edge.hxx>
34 #include <TopoDS_Shape.hxx>
35 #include <TopoDS_Wire.hxx>
36 #include <TopTools_HArray1OfShape.hxx>
38 IMPLEMENT_STANDARD_RTTIEXT(BRepFill_EdgeOnSurfLaw,BRepFill_LocationLaw)
40 BRepFill_EdgeOnSurfLaw::BRepFill_EdgeOnSurfLaw(const TopoDS_Wire& Path,
41 const TopoDS_Shape& Surf)
43 hasresult = Standard_True;
46 Standard_Boolean Trouve;
47 Standard_Integer ipath;// ,NbEdge;
48 TopAbs_Orientation Or;
49 BRepTools_WireExplorer wexp;
51 // Class BRep_Tool without fields and without Constructor :
54 Handle(Geom2d_Curve) C;
55 Handle(Geom2dAdaptor_Curve) AC2d;
56 Handle(Adaptor3d_CurveOnSurface) AC;
57 Handle(BRepAdaptor_Surface) AS;
58 Standard_Real First = 0., Last = 0.;
59 Handle(GeomFill_Darboux) TLaw = new (GeomFill_Darboux)() ;
60 Handle(GeomFill_CurveAndTrihedron) Law =
61 new (GeomFill_CurveAndTrihedron) (TLaw);
63 for (ipath=0, wexp.Init(myPath);
64 wexp.More(); wexp.Next()) {
66 // if (!B.Degenerated(E)) {
67 if (!BRep_Tool::Degenerated(E)) {
69 myEdges->SetValue(ipath, E);
70 for (Trouve=Standard_False, exp.Init(Surf, TopAbs_FACE);
71 exp.More() && !Trouve; exp.Next()) {
72 const TopoDS_Face& F = TopoDS::Face(exp.Current());
73 C = BRep_Tool::CurveOnSurface(E, F, First, Last);
76 AS = new (BRepAdaptor_Surface) (F);
79 if (!Trouve) { // Impossible to construct the law.
80 hasresult = Standard_False;
86 if (Or == TopAbs_REVERSED) {
87 Handle(Geom2d_TrimmedCurve) CBis =
88 new (Geom2d_TrimmedCurve) (C, First, Last);
89 CBis->Reverse(); // To avoid spoiling the topology
91 First = C->FirstParameter();
92 Last = C->LastParameter();
95 AC2d = new (Geom2dAdaptor_Curve) (C,First, Last);
96 AC = new (Adaptor3d_CurveOnSurface)
97 (Adaptor3d_CurveOnSurface(AC2d, AS));
98 myLaws->SetValue(ipath, Law->Copy());
99 myLaws->ChangeValue(ipath)->SetCurve(AC);
104 Standard_Boolean BRepFill_EdgeOnSurfLaw::HasResult() const