0031642: Visualization - crash in Graphic3d_Structure::SetVisual() on redisplaying...
[occt.git] / src / BRepFill / BRepFill_Edge3DLaw.cxx
1 // Created on: 1998-07-27
2 // Created by: Philippe MANGIN
3 // Copyright (c) 1998-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17
18 #include <BRep_Tool.hxx>
19 #include <BRepFill_Edge3DLaw.hxx>
20 #include <BRepTools_WireExplorer.hxx>
21 #include <Geom_Curve.hxx>
22 #include <Geom_TrimmedCurve.hxx>
23 #include <GeomAdaptor_HCurve.hxx>
24 #include <GeomFill_HArray1OfLocationLaw.hxx>
25 #include <GeomFill_LocationLaw.hxx>
26 #include <Standard_Type.hxx>
27 #include <TopExp.hxx>
28 #include <TopoDS.hxx>
29 #include <TopoDS_Edge.hxx>
30 #include <TopoDS_Wire.hxx>
31 #include <TopTools_HArray1OfShape.hxx>
32
33 IMPLEMENT_STANDARD_RTTIEXT(BRepFill_Edge3DLaw,BRepFill_LocationLaw)
34
35 BRepFill_Edge3DLaw::BRepFill_Edge3DLaw(const TopoDS_Wire& Path,
36                                      const Handle(GeomFill_LocationLaw)& Law)
37 {
38   Init(Path);
39
40   Standard_Integer ipath;
41   TopAbs_Orientation Or;
42   BRepTools_WireExplorer wexp;
43 // Class BRep_Tool without fields and without Constructor :
44 //  BRep_Tool B;
45   TopoDS_Edge E;
46   Handle(Geom_Curve) C;
47   Handle(GeomAdaptor_HCurve) AC;
48   Standard_Real First, Last;
49
50   for (ipath=0, wexp.Init(myPath); 
51        wexp.More(); wexp.Next()) {
52     E = wexp.Current();
53 //    if (!B.Degenerated(E)) {
54     if (!BRep_Tool::Degenerated(E)) {
55       ipath++;
56       myEdges->SetValue(ipath, E);
57       C = BRep_Tool::Curve(E,First,Last);
58       Or = E.Orientation();
59       if (Or == TopAbs_REVERSED) {
60         Handle(Geom_TrimmedCurve) CBis = 
61           new (Geom_TrimmedCurve) (C, First, Last);
62         CBis->Reverse(); // Pour eviter de deteriorer la topologie
63         C = CBis;
64         First =  C->FirstParameter();
65         Last  =  C->LastParameter();
66       }
67
68       AC = new  (GeomAdaptor_HCurve) (C,First, Last);
69       myLaws->SetValue(ipath, Law->Copy());
70       myLaws->ChangeValue(ipath)->SetCurve(AC);
71     }  
72   }
73 }
74
75
76
77