summaryrefslogtreecommitdiff
path: root/src/GeomToStep/GeomToStep_MakeRectangularTrimmedSurface.cxx
blob: fe70c89ccbdf9d37aba172ef5d3aea82794795ff (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
// File:	GeomToStep_MakeRectangularTrimmedSurface.cxx
// Created:	Thu Jan 25 11:16:17 1996
// Author:	Frederic MAUPAS
//		<fma@pronox>

#include <GeomToStep_MakeRectangularTrimmedSurface.ixx>
#include <StdFail_NotDone.hxx>

#include <GeomToStep_MakeSurface.hxx>
#include <StepGeom_Surface.hxx>
#include <TCollection_HAsciiString.hxx>

#include <Geom_CylindricalSurface.hxx>
#include <Geom_ConicalSurface.hxx>
#include <Geom_ToroidalSurface.hxx>
#include <Geom_SphericalSurface.hxx>
#include <Geom_SurfaceOfRevolution.hxx>
#include <UnitsMethods.hxx>
#include <Geom_Plane.hxx>

//=============================================================================
// Creation d' une rectangular_trimmed_surface de STEP
// a partir d' une RectangularTrimmedSurface de Geom
//=============================================================================

GeomToStep_MakeRectangularTrimmedSurface::
  GeomToStep_MakeRectangularTrimmedSurface( const
    Handle(Geom_RectangularTrimmedSurface)& RTSurf )
								      
{

  Handle(StepGeom_RectangularTrimmedSurface) StepRTS = new StepGeom_RectangularTrimmedSurface;

  Handle(TCollection_HAsciiString) aName = new TCollection_HAsciiString("");

  GeomToStep_MakeSurface mkSurf(RTSurf->BasisSurface());
  if (!mkSurf.IsDone()) {
    done = Standard_False;
    return;
  }
  Handle(StepGeom_Surface) StepSurf = mkSurf.Value();

  Standard_Real U1,U2,V1,V2;
  RTSurf->Bounds(U1, U2, V1, V2);
  
  // -----------------------------------------
  // Modification of the Trimming Parameters ?
  // -----------------------------------------

  Standard_Real AngleFact = 180./PI;
  Standard_Real uFact = 1.;
  Standard_Real vFact = 1.;
  Standard_Real LengthFact  = UnitsMethods::LengthFactor();
  Handle(Geom_Surface) theSurf = RTSurf->BasisSurface();
  if (theSurf->IsKind(STANDARD_TYPE(Geom_CylindricalSurface))) {
    uFact = AngleFact;
    vFact = 1. / LengthFact;
  }
  else if (theSurf->IsKind(STANDARD_TYPE(Geom_SurfaceOfRevolution))) {
    uFact = AngleFact;
  }
  else if (theSurf->IsKind(STANDARD_TYPE(Geom_ToroidalSurface)) ||
	   theSurf->IsKind(STANDARD_TYPE(Geom_SphericalSurface))) {
    uFact = AngleFact;
    vFact = AngleFact;
  }
  else if (theSurf->IsKind(STANDARD_TYPE(Geom_ConicalSurface))) {
    Handle(Geom_ConicalSurface) conicS = 
      Handle(Geom_ConicalSurface)::DownCast(theSurf);
    Standard_Real semAng = conicS->SemiAngle();
    uFact = AngleFact;
    vFact = Cos(semAng) / LengthFact;
  }
  else if (theSurf->IsKind(STANDARD_TYPE(Geom_Plane))) {
    uFact = vFact = 1. / LengthFact;
  }
  
  U1 = U1 * uFact;
  U2 = U2 * uFact;
  V1 = V1 * vFact;
  V2 = V2 * vFact;

  StepRTS->Init(aName, StepSurf, U1, U2, V1, V2, Standard_True, Standard_True);
  theRectangularTrimmedSurface = StepRTS;
  done = Standard_True;
}

//=============================================================================
// renvoi des valeurs
//=============================================================================

const Handle(StepGeom_RectangularTrimmedSurface) &
      GeomToStep_MakeRectangularTrimmedSurface::Value() const
{
  StdFail_NotDone_Raise_if(!done == Standard_True,"");
  return theRectangularTrimmedSurface;
}