0027961: Visualization - remove unused and no more working OpenGl_AVIWriter
[occt.git] / src / TopOpeBRep / TopOpeBRep_GeomTool.cxx
CommitLineData
b311480e 1// Created on: 1993-06-24
2// Created by: Jean Yves LEBEY
3// Copyright (c) 1993-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.
7fd59977 16
7fd59977 17
18#include <BRep_Tool.hxx>
42cf5bc1 19#include <Geom2d_Curve.hxx>
20#include <Geom_Curve.hxx>
21#include <Standard_ProgramError.hxx>
7fd59977 22#include <TColgp_Array1OfPnt.hxx>
23#include <TColgp_Array1OfPnt2d.hxx>
42cf5bc1 24#include <TColStd_Array1OfInteger.hxx>
25#include <TColStd_Array1OfReal.hxx>
26#include <TopoDS.hxx>
27#include <TopoDS_Shape.hxx>
28#include <TopOpeBRep_GeomTool.hxx>
29#include <TopOpeBRep_LineInter.hxx>
30#include <TopOpeBRep_TypeLineCurve.hxx>
7fd59977 31#include <TopOpeBRep_WPointInter.hxx>
32#include <TopOpeBRep_WPointInterIterator.hxx>
42cf5bc1 33#include <TopOpeBRepDS_Curve.hxx>
7fd59977 34#include <TopOpeBRepTool_CurveTool.hxx>
35#include <TopOpeBRepTool_ShapeTool.hxx>
36
7fd59977 37//=======================================================================
38//function : MakeCurves
39//purpose :
40//=======================================================================
41void TopOpeBRep_GeomTool::MakeCurves
35e08fe8 42(const Standard_Real min,
43 const Standard_Real max,
7fd59977 44 const TopOpeBRep_LineInter& L,
35e08fe8 45 const TopoDS_Shape& /*S1*/,
46 const TopoDS_Shape& /*S2*/,
7fd59977 47 TopOpeBRepDS_Curve& C,
35e08fe8 48 Handle(Geom2d_Curve)& PC1,
49 Handle(Geom2d_Curve)& PC2)
7fd59977 50{
51 Standard_Boolean IsWalk = Standard_False;
52 Handle(Geom_Curve) C3D;
53 TopOpeBRep_TypeLineCurve typeline = L.TypeLineCurve();
54
55 switch (typeline) {
56
57 case TopOpeBRep_WALKING : {
58 // make BSplines of degree 1
59 C3D = MakeBSpline1fromWALKING3d(L);
60 PC1 = MakeBSpline1fromWALKING2d(L,1);
61 PC2 = MakeBSpline1fromWALKING2d(L,2);
62 if (!PC1.IsNull())
63 C.Curve1(PC1);
64 if (!PC2.IsNull())
65 C.Curve2(PC2);
66 IsWalk = Standard_True;
67 break;
68 }
69 case TopOpeBRep_LINE :
70 case TopOpeBRep_CIRCLE :
71 case TopOpeBRep_ELLIPSE : {
72 C3D = L.Curve();
73 break;
74 }
75 case TopOpeBRep_PARABOLA :
76 case TopOpeBRep_HYPERBOLA : {
77 C3D = L.Curve(min,max); // Trimmed
78 break;
79 }
80 case TopOpeBRep_ANALYTIC :
81 case TopOpeBRep_RESTRICTION :
82 case TopOpeBRep_OTHERTYPE :
83 default :
84 Standard_ProgramError::Raise("TopOpeBRep_GeomTool::MakePrivateCurves");
85 break;
86 }
87
88 Standard_Real tol = C.Tolerance();
89 C.DefineCurve(C3D,tol,IsWalk);
90 C.SetRange(min,max);
91}
92
93
94//=======================================================================
95//function : MakeCurve
96//purpose :
97//=======================================================================
98void TopOpeBRep_GeomTool::MakeCurve
99(const Standard_Real min,const Standard_Real max,
100 const TopOpeBRep_LineInter& L,
101 Handle(Geom_Curve)& C3D)
102{
103 TopOpeBRep_TypeLineCurve typeline = L.TypeLineCurve();
104
105 switch (typeline) {
106
107 case TopOpeBRep_WALKING :
108 C3D = MakeBSpline1fromWALKING3d(L);
109 break;
110
111 case TopOpeBRep_LINE :
112 C3D = L.Curve();
113 break;
114
115 case TopOpeBRep_CIRCLE :
116 case TopOpeBRep_ELLIPSE :
117 case TopOpeBRep_PARABOLA :
118 case TopOpeBRep_HYPERBOLA :
119
120 if (typeline == TopOpeBRep_CIRCLE)
121 C3D = L.Curve();
122 else if (typeline == TopOpeBRep_ELLIPSE)
123 C3D = L.Curve();
124 else if (typeline == TopOpeBRep_PARABOLA)
125 C3D = L.Curve(min,max); // Trimmed
126 else if (typeline == TopOpeBRep_HYPERBOLA)
127 C3D = L.Curve(min,max); //Trimmed
128
129 break;
130
131 case TopOpeBRep_ANALYTIC :
132 case TopOpeBRep_RESTRICTION :
133 case TopOpeBRep_OTHERTYPE :
134 default :
135 Standard_ProgramError::Raise("TopOpeBRep_GeomTool::MakePrivateCurves");
136 break;
137 }
138}
139
140//=======================================================================
141//function : MakeBSpline1fromWALKING3d
142//purpose :
143//=======================================================================
144Handle(Geom_Curve) TopOpeBRep_GeomTool::MakeBSpline1fromWALKING3d
145(const TopOpeBRep_LineInter& L)
146{
147 Standard_Integer ip;
148 TopOpeBRep_WPointInterIterator itW(L);
149 Standard_Integer nbpoints = L.NbWPoint();
150 // Define points3d with the walking 3d points of <L>
151 TColgp_Array1OfPnt points3d(1,nbpoints);
152 for (ip = 1, itW.Init(); itW.More(); ip++, itW.Next()) {
153 points3d.SetValue(ip,itW.CurrentWP().Value());
154 }
155 Handle(Geom_Curve) C=TopOpeBRepTool_CurveTool::MakeBSpline1fromPnt(points3d);
156 return C;
157}
158
159//=======================================================================
160//function : MakeBSpline1fromWALKING2d
161//purpose :
162//=======================================================================
163Handle(Geom2d_Curve) TopOpeBRep_GeomTool::MakeBSpline1fromWALKING2d
164(const TopOpeBRep_LineInter& L, const Standard_Integer SI)
165{
166 Standard_Integer ip;
167 TopOpeBRep_WPointInterIterator itW(L);
168 Standard_Integer nbpoints = L.NbWPoint();
169 // Define points2d with the walking 2d points of <L>
170 TColgp_Array1OfPnt2d points2d(1,nbpoints);
171 for (ip = 1, itW.Init(); itW.More(); ip++, itW.Next()) {
172 if (SI == 1) points2d.SetValue(ip,itW.CurrentWP().ValueOnS1());
173 else if (SI == 2) points2d.SetValue(ip,itW.CurrentWP().ValueOnS2());
174 }
175 Handle(Geom2d_Curve) C=TopOpeBRepTool_CurveTool::MakeBSpline1fromPnt2d(points2d);
176 return C;
177}