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 | |
c22b52d6 |
17 | #include <BRepFill_EdgeOnSurfLaw.hxx> |
7fd59977 |
18 | |
42cf5bc1 |
19 | #include <Adaptor3d_CurveOnSurface.hxx> |
7fd59977 |
20 | #include <BRep_Tool.hxx> |
c22b52d6 |
21 | #include <BRepAdaptor_Surface.hxx> |
42cf5bc1 |
22 | #include <BRepTools_WireExplorer.hxx> |
7fd59977 |
23 | #include <Geom2d_Curve.hxx> |
24 | #include <Geom2d_TrimmedCurve.hxx> |
c22b52d6 |
25 | #include <Geom2dAdaptor_Curve.hxx> |
42cf5bc1 |
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> |
32 | #include <TopoDS.hxx> |
33 | #include <TopoDS_Edge.hxx> |
34 | #include <TopoDS_Shape.hxx> |
35 | #include <TopoDS_Wire.hxx> |
36 | #include <TopTools_HArray1OfShape.hxx> |
7fd59977 |
37 | |
92efcf78 |
38 | IMPLEMENT_STANDARD_RTTIEXT(BRepFill_EdgeOnSurfLaw,BRepFill_LocationLaw) |
39 | |
7fd59977 |
40 | BRepFill_EdgeOnSurfLaw::BRepFill_EdgeOnSurfLaw(const TopoDS_Wire& Path, |
41 | const TopoDS_Shape& Surf) |
42 | { |
43 | hasresult = Standard_True; |
44 | Init(Path); |
45 | |
46 | Standard_Boolean Trouve; |
47 | Standard_Integer ipath;// ,NbEdge; |
48 | TopAbs_Orientation Or; |
49 | BRepTools_WireExplorer wexp; |
50 | TopExp_Explorer exp; |
51 | // Class BRep_Tool without fields and without Constructor : |
52 | // BRep_Tool B; |
53 | TopoDS_Edge E; |
54 | Handle(Geom2d_Curve) C; |
c22b52d6 |
55 | Handle(Geom2dAdaptor_Curve) AC2d; |
56 | Handle(Adaptor3d_CurveOnSurface) AC; |
57 | Handle(BRepAdaptor_Surface) AS; |
1d47d8d0 |
58 | Standard_Real First = 0., Last = 0.; |
7fd59977 |
59 | Handle(GeomFill_Darboux) TLaw = new (GeomFill_Darboux)() ; |
60 | Handle(GeomFill_CurveAndTrihedron) Law = |
61 | new (GeomFill_CurveAndTrihedron) (TLaw); |
62 | |
63 | for (ipath=0, wexp.Init(myPath); |
64 | wexp.More(); wexp.Next()) { |
65 | E = wexp.Current(); |
66 | // if (!B.Degenerated(E)) { |
67 | if (!BRep_Tool::Degenerated(E)) { |
68 | ipath++; |
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); |
74 | if (!C.IsNull()) { |
75 | Trouve=Standard_True; |
c22b52d6 |
76 | AS = new (BRepAdaptor_Surface) (F); |
7fd59977 |
77 | } |
78 | } |
0d969553 |
79 | if (!Trouve) { // Impossible to construct the law. |
7fd59977 |
80 | hasresult = Standard_False; |
81 | myLaws.Nullify(); |
82 | return; |
83 | } |
84 | |
85 | Or = E.Orientation(); |
86 | if (Or == TopAbs_REVERSED) { |
87 | Handle(Geom2d_TrimmedCurve) CBis = |
88 | new (Geom2d_TrimmedCurve) (C, First, Last); |
0d969553 |
89 | CBis->Reverse(); // To avoid spoiling the topology |
7fd59977 |
90 | C = CBis; |
91 | First = C->FirstParameter(); |
92 | Last = C->LastParameter(); |
93 | } |
94 | |
c22b52d6 |
95 | AC2d = new (Geom2dAdaptor_Curve) (C,First, Last); |
96 | AC = new (Adaptor3d_CurveOnSurface) |
7fd59977 |
97 | (Adaptor3d_CurveOnSurface(AC2d, AS)); |
98 | myLaws->SetValue(ipath, Law->Copy()); |
99 | myLaws->ChangeValue(ipath)->SetCurve(AC); |
100 | } |
101 | } |
102 | } |
103 | |
104 | Standard_Boolean BRepFill_EdgeOnSurfLaw::HasResult() const |
105 | { |
106 | return hasresult; |
107 | } |
108 | |