1 // Created on: 1993-06-24
2 // Created by: Jean Yves LEBEY
3 // Copyright (c) 1993-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.
18 #include <BRep_Tool.hxx>
19 #include <Geom2d_Curve.hxx>
20 #include <Geom_Curve.hxx>
21 #include <Standard_ProgramError.hxx>
22 #include <TColgp_Array1OfPnt.hxx>
23 #include <TColgp_Array1OfPnt2d.hxx>
24 #include <TColStd_Array1OfInteger.hxx>
25 #include <TColStd_Array1OfReal.hxx>
27 #include <TopoDS_Shape.hxx>
28 #include <TopOpeBRep_GeomTool.hxx>
29 #include <TopOpeBRep_LineInter.hxx>
30 #include <TopOpeBRep_TypeLineCurve.hxx>
31 #include <TopOpeBRep_WPointInter.hxx>
32 #include <TopOpeBRep_WPointInterIterator.hxx>
33 #include <TopOpeBRepDS_Curve.hxx>
34 #include <TopOpeBRepTool_CurveTool.hxx>
35 #include <TopOpeBRepTool_ShapeTool.hxx>
37 //=======================================================================
38 //function : MakeCurves
40 //=======================================================================
41 void TopOpeBRep_GeomTool::MakeCurves
42 (const Standard_Real min,
43 const Standard_Real max,
44 const TopOpeBRep_LineInter& L,
45 const TopoDS_Shape& /*S1*/,
46 const TopoDS_Shape& /*S2*/,
47 TopOpeBRepDS_Curve& C,
48 Handle(Geom2d_Curve)& PC1,
49 Handle(Geom2d_Curve)& PC2)
51 Standard_Boolean IsWalk = Standard_False;
52 Handle(Geom_Curve) C3D;
53 TopOpeBRep_TypeLineCurve typeline = L.TypeLineCurve();
57 case TopOpeBRep_WALKING : {
58 // make BSplines of degree 1
59 C3D = MakeBSpline1fromWALKING3d(L);
60 PC1 = MakeBSpline1fromWALKING2d(L,1);
61 PC2 = MakeBSpline1fromWALKING2d(L,2);
66 IsWalk = Standard_True;
69 case TopOpeBRep_LINE :
70 case TopOpeBRep_CIRCLE :
71 case TopOpeBRep_ELLIPSE : {
75 case TopOpeBRep_PARABOLA :
76 case TopOpeBRep_HYPERBOLA : {
77 C3D = L.Curve(min,max); // Trimmed
80 case TopOpeBRep_ANALYTIC :
81 case TopOpeBRep_RESTRICTION :
82 case TopOpeBRep_OTHERTYPE :
84 throw Standard_ProgramError("TopOpeBRep_GeomTool::MakePrivateCurves");
88 Standard_Real tol = C.Tolerance();
89 C.DefineCurve(C3D,tol,IsWalk);
94 //=======================================================================
95 //function : MakeCurve
97 //=======================================================================
98 void TopOpeBRep_GeomTool::MakeCurve
99 (const Standard_Real min,const Standard_Real max,
100 const TopOpeBRep_LineInter& L,
101 Handle(Geom_Curve)& C3D)
103 TopOpeBRep_TypeLineCurve typeline = L.TypeLineCurve();
107 case TopOpeBRep_WALKING :
108 C3D = MakeBSpline1fromWALKING3d(L);
111 case TopOpeBRep_LINE :
115 case TopOpeBRep_CIRCLE :
116 case TopOpeBRep_ELLIPSE :
117 case TopOpeBRep_PARABOLA :
118 case TopOpeBRep_HYPERBOLA :
120 if (typeline == TopOpeBRep_CIRCLE)
122 else if (typeline == TopOpeBRep_ELLIPSE)
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
131 case TopOpeBRep_ANALYTIC :
132 case TopOpeBRep_RESTRICTION :
133 case TopOpeBRep_OTHERTYPE :
135 throw Standard_ProgramError("TopOpeBRep_GeomTool::MakePrivateCurves");
140 //=======================================================================
141 //function : MakeBSpline1fromWALKING3d
143 //=======================================================================
144 Handle(Geom_Curve) TopOpeBRep_GeomTool::MakeBSpline1fromWALKING3d
145 (const TopOpeBRep_LineInter& L)
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());
155 Handle(Geom_Curve) C=TopOpeBRepTool_CurveTool::MakeBSpline1fromPnt(points3d);
159 //=======================================================================
160 //function : MakeBSpline1fromWALKING2d
162 //=======================================================================
163 Handle(Geom2d_Curve) TopOpeBRep_GeomTool::MakeBSpline1fromWALKING2d
164 (const TopOpeBRep_LineInter& L, const Standard_Integer SI)
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());
175 Handle(Geom2d_Curve) C=TopOpeBRepTool_CurveTool::MakeBSpline1fromPnt2d(points2d);