1 // Created on: 1998-09-01
2 // Created by: Stephanie Humeau
3 // Copyright (c) 1998-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
23 #include <BRepFill_ACRLaw.ixx>
25 #include <BRepTools_WireExplorer.hxx>
26 #include <BRep_Tool.hxx>
28 #include <TopoDS_Edge.hxx>
30 #include <TopTools_HArray1OfShape.hxx>
31 #include <BRepFill.hxx>
32 #include <GeomFill_LocationLaw.hxx>
33 #include <GeomFill_LocationGuide.hxx>
35 #include <GeomFill_HArray1OfLocationLaw.hxx>
36 #include <Geom_Curve.hxx>
37 #include <Geom_TrimmedCurve.hxx>
38 #include <GeomAdaptor_HCurve.hxx>
39 #include <Approx_CurvlinFunc.hxx>
41 BRepFill_ACRLaw::BRepFill_ACRLaw(const TopoDS_Wire& Path,
42 const Handle(GeomFill_LocationGuide)& theLaw)
46 // calculate the nb of edge of the path
47 BRepTools_WireExplorer wexp;
48 Standard_Integer NbEdge = 0;
49 for (wexp.Init(myPath); wexp.More(); wexp.Next()) NbEdge++;
51 // tab to memorize ACR for each edge
52 OrigParam = new (TColStd_HArray1OfReal)(0,NbEdge);
53 TColStd_Array1OfReal Orig (0,NbEdge);
54 BRepFill::ComputeACR(Path, Orig);
56 Standard_Integer ipath;
57 TopAbs_Orientation Or;
58 // Class BRep_Tool without fields and without Constructor :
62 Handle(GeomAdaptor_HCurve) AC;
63 Standard_Real First, Last;
65 // return ACR of edges of the trajectory
66 OrigParam->SetValue(0,0);
67 for (ipath=1;ipath<=NbEdge;ipath++)
68 OrigParam->SetValue(ipath, Orig(ipath));
70 // process each edge of the trajectory
71 for (ipath=0, wexp.Init(myPath);
72 wexp.More(); wexp.Next()) {
74 // if (!B.Degenerated(E)) {
75 if (!BRep_Tool::Degenerated(E)) {
77 myEdges->SetValue(ipath, E);
78 C = BRep_Tool::Curve(E,First,Last);
80 if (Or == TopAbs_REVERSED) {
81 Handle(Geom_TrimmedCurve) CBis =
82 new (Geom_TrimmedCurve) (C, First, Last);
83 CBis->Reverse(); // To avoid damaging the topology
85 First = C->FirstParameter();
86 Last = C->LastParameter();
88 AC = new (GeomAdaptor_HCurve) (C, First, Last);
90 // Set the parameters for the case multi-edges
91 Standard_Real t1 = OrigParam->Value(ipath-1);
92 Standard_Real t2 = OrigParam->Value(ipath);
93 Handle(GeomFill_LocationGuide) Loc;
94 Loc = Handle(GeomFill_LocationGuide)::DownCast(theLaw);
95 Loc->SetOrigine(t1,t2);
97 myLaws->SetValue(ipath, Loc->Copy());
98 myLaws->ChangeValue(ipath)->SetCurve(AC);