summaryrefslogtreecommitdiff
path: root/src/StepToTopoDS/StepToTopoDS_TranslateCurveBoundedSurface.cxx
blob: 72cf16252140179a8c818172a65446df7ff68f9a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
// File:	StepToTopoDS_TranslateCurveBoundedSurface.cxx
// Created:	Fri Feb 12 13:30:17 1999
// Author:	Andrey BETENEV
//		<abv@doomox.nnov.matra-dtv.fr>
//#4  szv          S4163: optimization
//:   abv 07.04.99 S4136: turn off fixing intersection of non-adjacent edges

#include <StepToTopoDS_TranslateCurveBoundedSurface.ixx>

#include <Precision.hxx>

#include <Geom_BoundedSurface.hxx>
#include <StepToGeom_MakeSurface.hxx>
#include <StepGeom_HArray1OfSurfaceBoundary.hxx>
#include <StepToTopoDS_TranslateCompositeCurve.hxx>

#include <TopoDS.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Iterator.hxx>
#include <BRep_Builder.hxx>

#include <BRepBuilderAPI_MakeFace.hxx>
#include <StepGeom_BSplineSurface.hxx>
#include <ShapeAlgo.hxx>
#include <ShapeAlgo_AlgoContainer.hxx>

//=======================================================================
//function : StepToTopoDS_TranslateCurveBoundedSurface
//purpose  : 
//=======================================================================

StepToTopoDS_TranslateCurveBoundedSurface::StepToTopoDS_TranslateCurveBoundedSurface ()
{
}

//=======================================================================
//function : StepToTopoDS_TranslateCurveBoundedSurface
//purpose  : 
//=======================================================================

StepToTopoDS_TranslateCurveBoundedSurface::StepToTopoDS_TranslateCurveBoundedSurface (
					   const Handle(StepGeom_CurveBoundedSurface) &CBS, 
					   const Handle(Transfer_TransientProcess) &TP)
{
  Init ( CBS, TP );
}

Standard_Boolean StepToTopoDS_TranslateCurveBoundedSurface::Init (
		 const Handle(StepGeom_CurveBoundedSurface) &CBS, 
		 const Handle(Transfer_TransientProcess) &TP)
{
  myFace.Nullify();
  if ( CBS.IsNull() ) return Standard_False;
  
  // translate basis surface 
  Handle(StepGeom_Surface) S = CBS->BasisSurface();
  Handle(Geom_Surface) Surf;
  if ( !StepToGeom_MakeSurface::Convert(S,Surf) ) {
    TP->AddFail ( CBS, "Basis surface not translated" );
    return Standard_False;
  }

  // abv 30.06.00: trj4_k1_geo-tu.stp #108: do as in TranslateFace
  // pdn to force bsplsurf to be periodic
  Handle(StepGeom_BSplineSurface) sgbss = Handle(StepGeom_BSplineSurface)::DownCast(S);
  if (!sgbss.IsNull()) {
/*
    StepGeom_BSplineSurfaceForm form = sgbss->SurfaceForm();
    if ((form == StepGeom_bssfCylindricalSurf)||
	(form == StepGeom_bssfConicalSurf)||
	(form == StepGeom_bssfSphericalSurf)||
	(form == StepGeom_bssfToroidalSurf)||
	(form == StepGeom_bssfSurfOfRevolution)||
	(form == StepGeom_bssfGeneralisedCone)||
        (form == StepGeom_bssfUnspecified)) 
*/
    {
      Handle(Geom_Surface) periodicSurf = ShapeAlgo::AlgoContainer()->ConvertToPeriodic (Surf);
      if(!periodicSurf.IsNull()) {
	TP->AddWarning(S,"Surface forced to be periodic");
	Surf = periodicSurf;
      }
    }
  }
    
  // create face
  BRep_Builder B;
  B.MakeFace ( myFace, Surf, Precision::Confusion() );

  // add natural bound if implicit
  if ( CBS->ImplicitOuter() ) { 
    if ( Surf->IsKind(STANDARD_TYPE(Geom_BoundedSurface)) ) {
      BRepBuilderAPI_MakeFace mf (Surf, Precision::Confusion());
      myFace = mf.Face();
    }
    else TP->AddWarning ( CBS, "Cannot make natural bounds on infinite surface" );
  }

  // translate boundaries 
  Handle(StepGeom_HArray1OfSurfaceBoundary) bnd = CBS->Boundaries();
  Standard_Integer nb = bnd->Length();
  for ( Standard_Integer i=1; i <= nb; i++ ) {
    Handle(StepGeom_CompositeCurve) cc = bnd->Value ( i ).BoundaryCurve();
    if ( cc.IsNull() ) continue;
    StepToTopoDS_TranslateCompositeCurve TrCC ( cc, TP, S, Surf );
    if ( ! TrCC.IsDone() ) {
      TP->AddWarning ( CBS, "Boundary not translated" );
      continue;
    }
    B.Add ( myFace, TrCC.Value() );
  }

  done = ! myFace.IsNull();
  return done;
}
	
//=======================================================================
//function : Value
//purpose  : 
//=======================================================================

const TopoDS_Face &StepToTopoDS_TranslateCurveBoundedSurface::Value () const
{
  return myFace;
}