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