b311480e |
1 | // Created by: Laurent BUCHARD |
2 | // Copyright (c) 1993-1999 Matra Datavision |
973c2be1 |
3 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
4 | // |
973c2be1 |
5 | // This file is part of Open CASCADE Technology software library. |
b311480e |
6 | // |
d5f74e42 |
7 | // This library is free software; you can redistribute it and/or modify it under |
8 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
9 | // by the Free Software Foundation, with special exception defined in the file |
10 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
11 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
12 | // |
973c2be1 |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
7fd59977 |
15 | |
42cf5bc1 |
16 | |
17 | #include <Adaptor3d_HCurve.hxx> |
18 | #include <Adaptor3d_HSurface.hxx> |
7fd59977 |
19 | #include <BRepAdaptor_Surface.hxx> |
42cf5bc1 |
20 | #include <Geom_BezierSurface.hxx> |
21 | #include <Geom_BSplineSurface.hxx> |
22 | #include <gp_Pnt.hxx> |
23 | #include <gp_Vec.hxx> |
24 | #include <HLRBRep_SurfaceTool.hxx> |
25 | #include <Standard_NoSuchObject.hxx> |
26 | #include <Standard_OutOfRange.hxx> |
7fd59977 |
27 | |
28 | Standard_Integer HLRBRep_SurfaceTool::NbSamplesU(const Standard_Address S) { |
29 | Standard_Integer nbs; |
30 | GeomAbs_SurfaceType typS = ((BRepAdaptor_Surface *)S)->GetType(); |
31 | switch(typS) { |
32 | case GeomAbs_Plane: |
33 | { |
34 | nbs = 2; |
35 | } |
36 | break; |
37 | case GeomAbs_BezierSurface: |
38 | { |
39 | nbs = 3 + ((BRepAdaptor_Surface *)S)->NbUPoles(); |
40 | } |
41 | break; |
42 | case GeomAbs_BSplineSurface: |
43 | { |
44 | nbs = ((BRepAdaptor_Surface *)S)->NbUKnots(); |
45 | nbs*= ((BRepAdaptor_Surface *)S)->UDegree(); |
46 | if(nbs < 2) nbs=2; |
47 | |
48 | } |
49 | break; |
50 | case GeomAbs_Torus: |
51 | { |
52 | nbs = 20; |
53 | } |
54 | break; |
55 | case GeomAbs_Cylinder: |
56 | case GeomAbs_Cone: |
57 | case GeomAbs_Sphere: |
58 | case GeomAbs_SurfaceOfRevolution: |
59 | case GeomAbs_SurfaceOfExtrusion: |
60 | { |
61 | nbs = 10; |
62 | } |
63 | break; |
64 | |
65 | default: |
66 | { |
67 | nbs = 10; |
68 | } |
69 | break; |
70 | } |
71 | return(nbs); |
72 | } |
73 | |
74 | Standard_Integer HLRBRep_SurfaceTool::NbSamplesV(const Standard_Address S) { |
75 | Standard_Integer nbs; |
76 | GeomAbs_SurfaceType typS = ((BRepAdaptor_Surface *)S)->GetType(); |
77 | switch(typS) { |
78 | case GeomAbs_Plane: |
79 | { |
80 | nbs = 2; |
81 | } |
82 | break; |
83 | case GeomAbs_BezierSurface: |
84 | { |
85 | nbs = 3 + ((BRepAdaptor_Surface *)S)->NbVPoles(); |
86 | } |
87 | break; |
88 | case GeomAbs_BSplineSurface: |
89 | { |
90 | nbs = ((BRepAdaptor_Surface *)S)->NbVKnots(); |
91 | nbs*= ((BRepAdaptor_Surface *)S)->VDegree(); |
92 | if(nbs < 2) nbs=2; |
93 | |
94 | } |
95 | break; |
96 | case GeomAbs_Cylinder: |
97 | case GeomAbs_Cone: |
98 | case GeomAbs_Sphere: |
99 | case GeomAbs_Torus: |
100 | case GeomAbs_SurfaceOfRevolution: |
101 | case GeomAbs_SurfaceOfExtrusion: |
102 | { |
103 | nbs = 15; |
104 | } |
105 | break; |
106 | |
107 | default: |
108 | { |
109 | nbs = 10; |
110 | } |
111 | break; |
112 | } |
113 | return(nbs); |
114 | } |
115 | |
116 | Standard_Integer HLRBRep_SurfaceTool::NbSamplesU(const Standard_Address S, |
117 | const Standard_Real u1, |
118 | const Standard_Real u2) { |
119 | Standard_Integer nbs = NbSamplesU(S); |
120 | Standard_Integer n = nbs; |
121 | if(nbs>10) { |
122 | Standard_Real uf = FirstUParameter(S); |
123 | Standard_Real ul = LastUParameter(S); |
124 | n*= (Standard_Integer)((u2-u1)/(uf-ul)); |
125 | if(n>nbs) n = nbs; |
126 | if(n<5) n = 5; |
127 | } |
128 | return(n); |
129 | } |
130 | |
131 | Standard_Integer HLRBRep_SurfaceTool::NbSamplesV(const Standard_Address S, |
132 | const Standard_Real v1, |
133 | const Standard_Real v2) { |
134 | Standard_Integer nbs = NbSamplesV(S); |
135 | Standard_Integer n = nbs; |
136 | if(nbs>10) { |
137 | Standard_Real vf = FirstVParameter(S); |
138 | Standard_Real vl = LastVParameter(S); |
139 | n*= (Standard_Integer)((v2-v1)/(vf-vl)); |
140 | if(n>nbs) n = nbs; |
141 | if(n<5) n = 5; |
142 | } |
143 | return(n); |
144 | } |