b311480e |
1 | // Created on: 1999-02-12 |
2 | // Created by: Andrey BETENEV |
3 | // Copyright (c) 1999-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. |
b311480e |
16 | |
7fd59977 |
17 | //#4 szv S4163: optimization |
18 | //: abv 07.04.99 S4136: turn off fixing intersection of non-adjacent edges |
19 | |
20 | #include <StepToTopoDS_TranslateCurveBoundedSurface.ixx> |
21 | |
22 | #include <Precision.hxx> |
23 | |
24 | #include <Geom_BoundedSurface.hxx> |
25 | #include <StepToGeom_MakeSurface.hxx> |
26 | #include <StepGeom_HArray1OfSurfaceBoundary.hxx> |
c04c30b3 |
27 | #include <StepGeom_BoundaryCurve.hxx> |
7fd59977 |
28 | #include <StepToTopoDS_TranslateCompositeCurve.hxx> |
29 | |
30 | #include <TopoDS.hxx> |
31 | #include <TopoDS_Edge.hxx> |
32 | #include <TopoDS_Iterator.hxx> |
33 | #include <BRep_Builder.hxx> |
34 | |
35 | #include <BRepBuilderAPI_MakeFace.hxx> |
36 | #include <StepGeom_BSplineSurface.hxx> |
37 | #include <ShapeAlgo.hxx> |
38 | #include <ShapeAlgo_AlgoContainer.hxx> |
39 | |
40 | //======================================================================= |
41 | //function : StepToTopoDS_TranslateCurveBoundedSurface |
42 | //purpose : |
43 | //======================================================================= |
44 | |
45 | StepToTopoDS_TranslateCurveBoundedSurface::StepToTopoDS_TranslateCurveBoundedSurface () |
46 | { |
47 | } |
48 | |
49 | //======================================================================= |
50 | //function : StepToTopoDS_TranslateCurveBoundedSurface |
51 | //purpose : |
52 | //======================================================================= |
53 | |
54 | StepToTopoDS_TranslateCurveBoundedSurface::StepToTopoDS_TranslateCurveBoundedSurface ( |
55 | const Handle(StepGeom_CurveBoundedSurface) &CBS, |
56 | const Handle(Transfer_TransientProcess) &TP) |
57 | { |
58 | Init ( CBS, TP ); |
59 | } |
60 | |
61 | Standard_Boolean StepToTopoDS_TranslateCurveBoundedSurface::Init ( |
62 | const Handle(StepGeom_CurveBoundedSurface) &CBS, |
63 | const Handle(Transfer_TransientProcess) &TP) |
64 | { |
65 | myFace.Nullify(); |
66 | if ( CBS.IsNull() ) return Standard_False; |
67 | |
68 | // translate basis surface |
69 | Handle(StepGeom_Surface) S = CBS->BasisSurface(); |
70 | Handle(Geom_Surface) Surf; |
71 | if ( !StepToGeom_MakeSurface::Convert(S,Surf) ) { |
72 | TP->AddFail ( CBS, "Basis surface not translated" ); |
73 | return Standard_False; |
74 | } |
75 | |
76 | // abv 30.06.00: trj4_k1_geo-tu.stp #108: do as in TranslateFace |
77 | // pdn to force bsplsurf to be periodic |
78 | Handle(StepGeom_BSplineSurface) sgbss = Handle(StepGeom_BSplineSurface)::DownCast(S); |
79 | if (!sgbss.IsNull()) { |
80 | /* |
81 | StepGeom_BSplineSurfaceForm form = sgbss->SurfaceForm(); |
82 | if ((form == StepGeom_bssfCylindricalSurf)|| |
83 | (form == StepGeom_bssfConicalSurf)|| |
84 | (form == StepGeom_bssfSphericalSurf)|| |
85 | (form == StepGeom_bssfToroidalSurf)|| |
86 | (form == StepGeom_bssfSurfOfRevolution)|| |
87 | (form == StepGeom_bssfGeneralisedCone)|| |
88 | (form == StepGeom_bssfUnspecified)) |
89 | */ |
90 | { |
91 | Handle(Geom_Surface) periodicSurf = ShapeAlgo::AlgoContainer()->ConvertToPeriodic (Surf); |
92 | if(!periodicSurf.IsNull()) { |
93 | TP->AddWarning(S,"Surface forced to be periodic"); |
94 | Surf = periodicSurf; |
95 | } |
96 | } |
97 | } |
98 | |
99 | // create face |
100 | BRep_Builder B; |
101 | B.MakeFace ( myFace, Surf, Precision::Confusion() ); |
102 | |
103 | // add natural bound if implicit |
104 | if ( CBS->ImplicitOuter() ) { |
105 | if ( Surf->IsKind(STANDARD_TYPE(Geom_BoundedSurface)) ) { |
1c72dff6 |
106 | BRepBuilderAPI_MakeFace mf (Surf, Precision::Confusion()); |
7fd59977 |
107 | myFace = mf.Face(); |
108 | } |
109 | else TP->AddWarning ( CBS, "Cannot make natural bounds on infinite surface" ); |
110 | } |
111 | |
112 | // translate boundaries |
113 | Handle(StepGeom_HArray1OfSurfaceBoundary) bnd = CBS->Boundaries(); |
114 | Standard_Integer nb = bnd->Length(); |
115 | for ( Standard_Integer i=1; i <= nb; i++ ) { |
116 | Handle(StepGeom_CompositeCurve) cc = bnd->Value ( i ).BoundaryCurve(); |
117 | if ( cc.IsNull() ) continue; |
118 | StepToTopoDS_TranslateCompositeCurve TrCC ( cc, TP, S, Surf ); |
119 | if ( ! TrCC.IsDone() ) { |
120 | TP->AddWarning ( CBS, "Boundary not translated" ); |
121 | continue; |
122 | } |
123 | B.Add ( myFace, TrCC.Value() ); |
124 | } |
125 | |
126 | done = ! myFace.IsNull(); |
127 | return done; |
128 | } |
129 | |
130 | //======================================================================= |
131 | //function : Value |
132 | //purpose : |
133 | //======================================================================= |
134 | |
135 | const TopoDS_Face &StepToTopoDS_TranslateCurveBoundedSurface::Value () const |
136 | { |
137 | return myFace; |
138 | } |