0024057: Eliminate compiler warning C4100 in MSVC++ with warning level 4
[occt.git] / src / StdPrs / StdPrs_PoleCurve.cxx
CommitLineData
b311480e 1// Created on: 1995-07-24
2// Created by: Modelistation
3// Copyright (c) 1995-1999 Matra Datavision
4// Copyright (c) 1999-2012 OPEN CASCADE SAS
5//
6// The content of this file is subject to the Open CASCADE Technology Public
7// License Version 6.5 (the "License"). You may not use the content of this file
8// except in compliance with the License. Please obtain a copy of the License
9// at http://www.opencascade.org and read it completely before using this file.
10//
11// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13//
14// The Original Code and all software distributed under the License is
15// distributed on an "AS IS" basis, without warranty of any kind, and the
16// Initial Developer hereby disclaims all such warranties, including without
17// limitation, any warranties of merchantability, fitness for a particular
18// purpose or non-infringement. Please see the License for the specific terms
19// and conditions governing the rights and limitations under the License.
20
7fd59977 21#include <StdPrs_PoleCurve.ixx>
b8ddfc2f 22
23#include <Graphic3d_ArrayOfPolylines.hxx>
7fd59977 24#include <Graphic3d_Group.hxx>
25#include <Prs3d_LineAspect.hxx>
26#include <Prs3d_Arrow.hxx>
27#include <Prs3d_ArrowAspect.hxx>
28#include <gp_Pnt.hxx>
29#include <gp_Dir.hxx>
30#include <gp_Vec.hxx>
31#include <TColgp_Array1OfPnt.hxx>
32#include <Geom_BezierCurve.hxx>
33#include <Geom_BSplineCurve.hxx>
34
35
36//=======================================================================
37//function : Add
38//purpose :
39//=======================================================================
40
41void StdPrs_PoleCurve::Add (const Handle (Prs3d_Presentation)& aPresentation,
42 const Adaptor3d_Curve& aCurve,
43 const Handle (Prs3d_Drawer)& aDrawer)
44{
45 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(aDrawer->LineAspect()->Aspect());
46
47 GeomAbs_CurveType CType = aCurve.GetType();
48 if (CType == GeomAbs_BezierCurve || CType == GeomAbs_BSplineCurve) {
7fd59977 49 Standard_Integer i, Nb;
50 if (CType == GeomAbs_BezierCurve) {
51 Handle(Geom_BezierCurve) Bz = aCurve.Bezier();
52 Nb = Bz->NbPoles();
b8ddfc2f 53 Handle(Graphic3d_ArrayOfPolylines) aPrims = new Graphic3d_ArrayOfPolylines(Nb);
54 for (i = 1; i <= Nb; i++)
55 aPrims->AddVertex(Bz->Pole(i));
56 Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims);
7fd59977 57 }
58 else if (CType == GeomAbs_BSplineCurve) {
59 Handle(Geom_BSplineCurve) Bs = aCurve.BSpline();
60 Nb = Bs->NbPoles();
b8ddfc2f 61 Handle(Graphic3d_ArrayOfPolylines) aPrims = new Graphic3d_ArrayOfPolylines(Nb);
62 for (i = 1; i <= Nb; i++)
63 aPrims->AddVertex(Bs->Pole(i));
64 Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims);
7fd59977 65 }
66 }
67
68 if (aDrawer->LineArrowDraw()) {
69 gp_Pnt Location;
70 gp_Vec Direction;
71 aCurve.D1(aCurve.LastParameter(),Location,Direction);
72 Prs3d_Arrow::Draw (aPresentation,
73 Location,
74 gp_Dir(Direction),
75 aDrawer->ArrowAspect()->Angle(),
76 aDrawer->ArrowAspect()->Length());
77 }
78}
79
80
81//=======================================================================
82//function : Match
83//purpose :
84//=======================================================================
85
86Standard_Boolean StdPrs_PoleCurve::Match(const Quantity_Length X,
87 const Quantity_Length Y,
88 const Quantity_Length Z,
89 const Quantity_Length aDistance,
90 const Adaptor3d_Curve& aCurve,
35e08fe8 91 const Handle (Prs3d_Drawer)& /*aDrawer*/)
7fd59977 92{
93 GeomAbs_CurveType CType = aCurve.GetType();
94 Standard_Integer i, Nb = 0;
95 Standard_Real x,y,z;
96 if (CType == GeomAbs_BezierCurve) {
97 Handle(Geom_BezierCurve) Bz = aCurve.Bezier();
98 Nb = Bz->NbPoles();
99 for (i = 1; i <= Nb; i++) {
100 Bz->Pole(i).Coord(x,y,z);
101 if ( Abs(X-x) +Abs(Y-y)+Abs(Z-z) <= aDistance) return Standard_True;
102 }
103 return Standard_False;
104 }
105 else if (CType == GeomAbs_BSplineCurve) {
106 Handle(Geom_BSplineCurve) Bs = aCurve.BSpline();
107 Nb = Bs->NbPoles();
108 for (i = 1; i <= Nb; i++) {
109 Bs->Pole(i).Coord(x,y,z);
110 if ( Abs(X-x) +Abs(Y-y)+Abs(Z-z) <= aDistance) return Standard_True;
111 }
112 return Standard_False;
113 }
114 return Standard_False;
115}
116
117//=======================================================================
118//function : Pick
119//purpose :
120//=======================================================================
121
122Standard_Integer StdPrs_PoleCurve::Pick
123 (const Quantity_Length X,
124 const Quantity_Length Y,
125 const Quantity_Length Z,
126 const Quantity_Length aDistance,
127 const Adaptor3d_Curve& aCurve,
35e08fe8 128 const Handle(Prs3d_Drawer)& /*aDrawer*/)
7fd59977 129{
130 Standard_Real x, y, z, DistMin = RealLast();
131 Standard_Integer num = 0, i, Nb = 0;
132 Standard_Real dist;
133 GeomAbs_CurveType CType = aCurve.GetType();
134
135 if (CType == GeomAbs_BezierCurve) {
136 Handle(Geom_BezierCurve) Bz = aCurve.Bezier();
137 Nb = Bz->NbPoles();
138 for (i = 1; i <= Nb; i++) {
139 Bz->Pole(i).Coord(x,y,z);
140 dist = Abs(X-x) +Abs(Y-y)+Abs(Z-z);
141 if ( dist <= aDistance) {
142 if (dist < DistMin) {
143 DistMin = dist;
144 num = i;
145 }
146 }
147 }
148 }
149 else if (CType == GeomAbs_BSplineCurve) {
150 Handle(Geom_BSplineCurve) Bs = aCurve.BSpline();
151 Nb = Bs->NbPoles();
152 for (i = 1; i <= Nb; i++) {
153 Bs->Pole(i).Coord(x,y,z);
154 dist = Abs(X-x) +Abs(Y-y)+Abs(Z-z);
155 if (dist <= aDistance) {
156 if (dist < DistMin) {
157 DistMin = dist;
158 num = i;
159 }
160 }
161 }
162 }
163
164 return num;
165}
166
167
168
169
170
171
172