b311480e |
1 | // Created on: 1998-09-01 |
2 | // Created by: Stephanie Humeau |
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 <Approx_CurvlinFunc.hxx> |
7fd59977 |
19 | #include <BRep_Tool.hxx> |
7fd59977 |
20 | #include <BRepFill.hxx> |
42cf5bc1 |
21 | #include <BRepFill_ACRLaw.hxx> |
22 | #include <BRepTools_WireExplorer.hxx> |
7fd59977 |
23 | #include <Geom_Curve.hxx> |
24 | #include <Geom_TrimmedCurve.hxx> |
25 | #include <GeomAdaptor_HCurve.hxx> |
42cf5bc1 |
26 | #include <GeomFill_HArray1OfLocationLaw.hxx> |
27 | #include <GeomFill_LocationGuide.hxx> |
28 | #include <GeomFill_LocationLaw.hxx> |
29 | #include <Standard_Type.hxx> |
30 | #include <TopExp.hxx> |
31 | #include <TopoDS.hxx> |
32 | #include <TopoDS_Edge.hxx> |
33 | #include <TopoDS_Wire.hxx> |
34 | #include <TopTools_HArray1OfShape.hxx> |
7fd59977 |
35 | |
92efcf78 |
36 | IMPLEMENT_STANDARD_RTTIEXT(BRepFill_ACRLaw,BRepFill_LocationLaw) |
37 | |
7fd59977 |
38 | BRepFill_ACRLaw::BRepFill_ACRLaw(const TopoDS_Wire& Path, |
39 | const Handle(GeomFill_LocationGuide)& theLaw) |
40 | { |
41 | Init(Path); |
42 | |
0d969553 |
43 | // calculate the nb of edge of the path |
7fd59977 |
44 | BRepTools_WireExplorer wexp; |
45 | Standard_Integer NbEdge = 0; |
46 | for (wexp.Init(myPath); wexp.More(); wexp.Next()) NbEdge++; |
47 | |
0d969553 |
48 | // tab to memorize ACR for each edge |
7fd59977 |
49 | OrigParam = new (TColStd_HArray1OfReal)(0,NbEdge); |
50 | TColStd_Array1OfReal Orig (0,NbEdge); |
51 | BRepFill::ComputeACR(Path, Orig); |
52 | |
53 | Standard_Integer ipath; |
54 | TopAbs_Orientation Or; |
55 | // Class BRep_Tool without fields and without Constructor : |
56 | // BRep_Tool B; |
57 | TopoDS_Edge E; |
58 | Handle(Geom_Curve) C; |
59 | Handle(GeomAdaptor_HCurve) AC; |
60 | Standard_Real First, Last; |
61 | |
0d969553 |
62 | // return ACR of edges of the trajectory |
7fd59977 |
63 | OrigParam->SetValue(0,0); |
64 | for (ipath=1;ipath<=NbEdge;ipath++) |
65 | OrigParam->SetValue(ipath, Orig(ipath)); |
66 | |
0d969553 |
67 | // process each edge of the trajectory |
7fd59977 |
68 | for (ipath=0, wexp.Init(myPath); |
69 | wexp.More(); wexp.Next()) { |
70 | E = wexp.Current(); |
71 | // if (!B.Degenerated(E)) { |
72 | if (!BRep_Tool::Degenerated(E)) { |
73 | ipath++; |
74 | myEdges->SetValue(ipath, E); |
75 | C = BRep_Tool::Curve(E,First,Last); |
76 | Or = E.Orientation(); |
77 | if (Or == TopAbs_REVERSED) { |
78 | Handle(Geom_TrimmedCurve) CBis = |
79 | new (Geom_TrimmedCurve) (C, First, Last); |
0d969553 |
80 | CBis->Reverse(); // To avoid damaging the topology |
7fd59977 |
81 | C = CBis; |
82 | First = C->FirstParameter(); |
83 | Last = C->LastParameter(); |
84 | } |
85 | AC = new (GeomAdaptor_HCurve) (C, First, Last); |
86 | |
0d969553 |
87 | // Set the parameters for the case multi-edges |
7fd59977 |
88 | Standard_Real t1 = OrigParam->Value(ipath-1); |
89 | Standard_Real t2 = OrigParam->Value(ipath); |
90 | Handle(GeomFill_LocationGuide) Loc; |
a9dde4a3 |
91 | Loc = theLaw; |
7fd59977 |
92 | Loc->SetOrigine(t1,t2); |
93 | |
94 | myLaws->SetValue(ipath, Loc->Copy()); |
95 | myLaws->ChangeValue(ipath)->SetCurve(AC); |
96 | } |
97 | } |
98 | } |