0024530: TKMesh - remove unused package IntPoly
[occt.git] / src / BRepFill / BRepFill_EdgeOnSurfLaw.cxx
CommitLineData
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//
973c2be1 8// This library is free software; you can redistribute it and / or modify it
9// under the terms of the GNU Lesser General Public 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.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
17#include <BRepFill_EdgeOnSurfLaw.ixx>
18
19#include <BRepTools_WireExplorer.hxx>
20#include <BRep_Tool.hxx>
21#include <TopoDS.hxx>
22#include <TopoDS_Edge.hxx>
23#include <TopExp_Explorer.hxx>
24#include <TopTools_HArray1OfShape.hxx>
25
26#include <GeomFill_LocationLaw.hxx>
27#include <GeomFill_HArray1OfLocationLaw.hxx>
28#include <GeomFill_Darboux.hxx>
29#include <GeomFill_CurveAndTrihedron.hxx>
30
31#include <Geom2d_Curve.hxx>
32#include <Geom2d_TrimmedCurve.hxx>
33#include <Adaptor3d_CurveOnSurface.hxx>
34#include <Adaptor3d_HCurveOnSurface.hxx>
35#include <Geom2dAdaptor_HCurve.hxx>
36#include <BRepAdaptor_HSurface.hxx>
37
38
39BRepFill_EdgeOnSurfLaw::BRepFill_EdgeOnSurfLaw(const TopoDS_Wire& Path,
40 const TopoDS_Shape& Surf)
41{
42 hasresult = Standard_True;
43 Init(Path);
44
45 Standard_Boolean Trouve;
46 Standard_Integer ipath;// ,NbEdge;
47 TopAbs_Orientation Or;
48 BRepTools_WireExplorer wexp;
49 TopExp_Explorer exp;
50// Class BRep_Tool without fields and without Constructor :
51// BRep_Tool B;
52 TopoDS_Edge E;
53 Handle(Geom2d_Curve) C;
54 Handle(Geom2dAdaptor_HCurve) AC2d;
55 Handle(Adaptor3d_HCurveOnSurface) AC;
56 Handle(BRepAdaptor_HSurface) AS;
1d47d8d0 57 Standard_Real First = 0., Last = 0.;
7fd59977 58 Handle(GeomFill_Darboux) TLaw = new (GeomFill_Darboux)() ;
59 Handle(GeomFill_CurveAndTrihedron) Law =
60 new (GeomFill_CurveAndTrihedron) (TLaw);
61
62 for (ipath=0, wexp.Init(myPath);
63 wexp.More(); wexp.Next()) {
64 E = wexp.Current();
65// if (!B.Degenerated(E)) {
66 if (!BRep_Tool::Degenerated(E)) {
67 ipath++;
68 myEdges->SetValue(ipath, E);
69 for (Trouve=Standard_False, exp.Init(Surf, TopAbs_FACE);
70 exp.More() && !Trouve; exp.Next()) {
71 const TopoDS_Face& F = TopoDS::Face(exp.Current());
72 C = BRep_Tool::CurveOnSurface(E, F, First, Last);
73 if (!C.IsNull()) {
74 Trouve=Standard_True;
75 AS = new (BRepAdaptor_HSurface) (F);
76 }
77 }
0d969553 78 if (!Trouve) { // Impossible to construct the law.
7fd59977 79 hasresult = Standard_False;
80 myLaws.Nullify();
81 return;
82 }
83
84 Or = E.Orientation();
85 if (Or == TopAbs_REVERSED) {
86 Handle(Geom2d_TrimmedCurve) CBis =
87 new (Geom2d_TrimmedCurve) (C, First, Last);
0d969553 88 CBis->Reverse(); // To avoid spoiling the topology
7fd59977 89 C = CBis;
90 First = C->FirstParameter();
91 Last = C->LastParameter();
92 }
93
94 AC2d = new (Geom2dAdaptor_HCurve) (C,First, Last);
95 AC = new (Adaptor3d_HCurveOnSurface)
96 (Adaptor3d_CurveOnSurface(AC2d, AS));
97 myLaws->SetValue(ipath, Law->Copy());
98 myLaws->ChangeValue(ipath)->SetCurve(AC);
99 }
100 }
101}
102
103 Standard_Boolean BRepFill_EdgeOnSurfLaw::HasResult() const
104{
105 return hasresult;
106}
107