1 // Created on: 1999-02-12
2 // Created by: Andrey BETENEV
3 // Copyright (c) 1999-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.
17 //#4 szv S4163: optimization
18 //: abv 07.04.99 S4136: turn off fixing intersection of non-adjacent edges
20 #include <BRep_Builder.hxx>
21 #include <BRepBuilderAPI_MakeFace.hxx>
22 #include <Geom_BoundedSurface.hxx>
23 #include <Precision.hxx>
24 #include <ShapeAlgo.hxx>
25 #include <ShapeAlgo_AlgoContainer.hxx>
26 #include <StepGeom_BoundaryCurve.hxx>
27 #include <StepGeom_BSplineSurface.hxx>
28 #include <StepGeom_CurveBoundedSurface.hxx>
29 #include <StepGeom_HArray1OfSurfaceBoundary.hxx>
30 #include <StepToGeom.hxx>
31 #include <StepToTopoDS_TranslateCompositeCurve.hxx>
32 #include <StepToTopoDS_TranslateCurveBoundedSurface.hxx>
34 #include <TopoDS_Edge.hxx>
35 #include <TopoDS_Face.hxx>
36 #include <TopoDS_Iterator.hxx>
37 #include <Transfer_TransientProcess.hxx>
39 //=======================================================================
40 //function : StepToTopoDS_TranslateCurveBoundedSurface
42 //=======================================================================
43 StepToTopoDS_TranslateCurveBoundedSurface::StepToTopoDS_TranslateCurveBoundedSurface ()
47 //=======================================================================
48 //function : StepToTopoDS_TranslateCurveBoundedSurface
50 //=======================================================================
52 StepToTopoDS_TranslateCurveBoundedSurface::StepToTopoDS_TranslateCurveBoundedSurface (
53 const Handle(StepGeom_CurveBoundedSurface) &CBS,
54 const Handle(Transfer_TransientProcess) &TP)
59 Standard_Boolean StepToTopoDS_TranslateCurveBoundedSurface::Init (
60 const Handle(StepGeom_CurveBoundedSurface) &CBS,
61 const Handle(Transfer_TransientProcess) &TP)
64 if ( CBS.IsNull() ) return Standard_False;
66 // translate basis surface
67 Handle(StepGeom_Surface) S = CBS->BasisSurface();
68 Handle(Geom_Surface) Surf = StepToGeom::MakeSurface (S);
71 TP->AddFail ( CBS, "Basis surface not translated" );
72 return Standard_False;
75 // abv 30.06.00: trj4_k1_geo-tu.stp #108: do as in TranslateFace
76 // pdn to force bsplsurf to be periodic
77 Handle(StepGeom_BSplineSurface) sgbss = Handle(StepGeom_BSplineSurface)::DownCast(S);
78 if (!sgbss.IsNull()) {
80 StepGeom_BSplineSurfaceForm form = sgbss->SurfaceForm();
81 if ((form == StepGeom_bssfCylindricalSurf)||
82 (form == StepGeom_bssfConicalSurf)||
83 (form == StepGeom_bssfSphericalSurf)||
84 (form == StepGeom_bssfToroidalSurf)||
85 (form == StepGeom_bssfSurfOfRevolution)||
86 (form == StepGeom_bssfGeneralisedCone)||
87 (form == StepGeom_bssfUnspecified))
90 Handle(Geom_Surface) periodicSurf = ShapeAlgo::AlgoContainer()->ConvertToPeriodic (Surf);
91 if(!periodicSurf.IsNull()) {
92 TP->AddWarning(S,"Surface forced to be periodic");
100 B.MakeFace ( myFace, Surf, Precision::Confusion() );
102 // add natural bound if implicit
103 if ( CBS->ImplicitOuter() ) {
104 if ( Surf->IsKind(STANDARD_TYPE(Geom_BoundedSurface)) ) {
105 BRepBuilderAPI_MakeFace mf (Surf, Precision::Confusion());
108 else TP->AddWarning ( CBS, "Cannot make natural bounds on infinite surface" );
111 // translate boundaries
112 Handle(StepGeom_HArray1OfSurfaceBoundary) bnd = CBS->Boundaries();
113 Standard_Integer nb = bnd->Length();
114 for ( Standard_Integer i=1; i <= nb; i++ ) {
115 Handle(StepGeom_CompositeCurve) cc = bnd->Value ( i ).BoundaryCurve();
116 if ( cc.IsNull() ) continue;
117 StepToTopoDS_TranslateCompositeCurve TrCC ( cc, TP, S, Surf );
118 if ( ! TrCC.IsDone() ) {
119 TP->AddWarning ( CBS, "Boundary not translated" );
122 B.Add ( myFace, TrCC.Value() );
125 done = ! myFace.IsNull();
129 //=======================================================================
132 //=======================================================================
134 const TopoDS_Face &StepToTopoDS_TranslateCurveBoundedSurface::Value () const