0024002: Overall code and build procedure refactoring -- automatic
[occt.git] / src / BRepFill / BRepFill_ACRLaw.cxx
CommitLineData
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
36BRepFill_ACRLaw::BRepFill_ACRLaw(const TopoDS_Wire& Path,
37 const Handle(GeomFill_LocationGuide)& theLaw)
38{
39 Init(Path);
40
0d969553 41// calculate the nb of edge of the path
7fd59977 42 BRepTools_WireExplorer wexp;
43 Standard_Integer NbEdge = 0;
44 for (wexp.Init(myPath); wexp.More(); wexp.Next()) NbEdge++;
45
0d969553 46// tab to memorize ACR for each edge
7fd59977 47 OrigParam = new (TColStd_HArray1OfReal)(0,NbEdge);
48 TColStd_Array1OfReal Orig (0,NbEdge);
49 BRepFill::ComputeACR(Path, Orig);
50
51 Standard_Integer ipath;
52 TopAbs_Orientation Or;
53// Class BRep_Tool without fields and without Constructor :
54// BRep_Tool B;
55 TopoDS_Edge E;
56 Handle(Geom_Curve) C;
57 Handle(GeomAdaptor_HCurve) AC;
58 Standard_Real First, Last;
59
0d969553 60// return ACR of edges of the trajectory
7fd59977 61 OrigParam->SetValue(0,0);
62 for (ipath=1;ipath<=NbEdge;ipath++)
63 OrigParam->SetValue(ipath, Orig(ipath));
64
0d969553 65// process each edge of the trajectory
7fd59977 66 for (ipath=0, wexp.Init(myPath);
67 wexp.More(); wexp.Next()) {
68 E = wexp.Current();
69// if (!B.Degenerated(E)) {
70 if (!BRep_Tool::Degenerated(E)) {
71 ipath++;
72 myEdges->SetValue(ipath, E);
73 C = BRep_Tool::Curve(E,First,Last);
74 Or = E.Orientation();
75 if (Or == TopAbs_REVERSED) {
76 Handle(Geom_TrimmedCurve) CBis =
77 new (Geom_TrimmedCurve) (C, First, Last);
0d969553 78 CBis->Reverse(); // To avoid damaging the topology
7fd59977 79 C = CBis;
80 First = C->FirstParameter();
81 Last = C->LastParameter();
82 }
83 AC = new (GeomAdaptor_HCurve) (C, First, Last);
84
0d969553 85 // Set the parameters for the case multi-edges
7fd59977 86 Standard_Real t1 = OrigParam->Value(ipath-1);
87 Standard_Real t2 = OrigParam->Value(ipath);
88 Handle(GeomFill_LocationGuide) Loc;
89 Loc = Handle(GeomFill_LocationGuide)::DownCast(theLaw);
90 Loc->SetOrigine(t1,t2);
91
92 myLaws->SetValue(ipath, Loc->Copy());
93 myLaws->ChangeValue(ipath)->SetCurve(AC);
94 }
95 }
96}