summaryrefslogtreecommitdiff
path: root/src/AppDef/AppDef_MyLineTool.cxx
blob: b35286e4f61f00715e5a1b323b5639cc2fd54324 (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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
// AppDef_MyLineTool.cxx
// 24-06-96 : JPI : implementation des methodes AppDef_MyLineTool::Curvature
//                  pour le lissage variationnel 

#include <AppDef_MyLineTool.ixx>
#include <AppDef_MultiPointConstraint.hxx>
#include <gp_Pnt.hxx>
#include <gp_Pnt2d.hxx>
#include <gp_Vec.hxx>
#include <gp_Vec2d.hxx>

Standard_Integer AppDef_MyLineTool::FirstPoint(const AppDef_MultiLine&)
{
  return 1;
}

Standard_Integer AppDef_MyLineTool::LastPoint(const AppDef_MultiLine& ML)
{
  return ML.NbMultiPoints();
}

Standard_Integer AppDef_MyLineTool::NbP2d(const AppDef_MultiLine& ML)
{
  return ML.Value(1).NbPoints2d();
}

Standard_Integer AppDef_MyLineTool::NbP3d(const AppDef_MultiLine& ML)
{
  return ML.Value(1).NbPoints();
}


void AppDef_MyLineTool::Value(const AppDef_MultiLine& ML, 
			      const Standard_Integer MPointIndex,
			      TColgp_Array1OfPnt& tabPt)
{
  AppDef_MultiPointConstraint MPC = ML.Value(MPointIndex);
  Standard_Integer nbp3d = MPC.NbPoints(), low = tabPt.Lower();
  for (Standard_Integer i = 1; i <= nbp3d; i++) {
    tabPt(i+low-1) = MPC.Point(i);
  }
}

void AppDef_MyLineTool::Value(const AppDef_MultiLine& ML, 
			      const Standard_Integer MPointIndex,
			      TColgp_Array1OfPnt2d& tabPt2d)
{
  AppDef_MultiPointConstraint MPC = ML.Value(MPointIndex);
  Standard_Integer nbp2d = MPC.NbPoints2d(), low = tabPt2d.Lower();
  for (Standard_Integer i = 1; i <= nbp2d; i++) {
    tabPt2d(i+low-1) = MPC.Point2d(i);
  }
}

void AppDef_MyLineTool::Value(const AppDef_MultiLine& ML, 
			      const Standard_Integer MPointIndex,
			      TColgp_Array1OfPnt& tabPt,
			      TColgp_Array1OfPnt2d& tabPt2d)
{
  AppDef_MultiPointConstraint MPC = ML.Value(MPointIndex);
  Standard_Integer i, nbp2d = MPC.NbPoints2d(), low2d = tabPt2d.Lower();
  Standard_Integer nbp3d = MPC.NbPoints(), low = tabPt.Lower();
  for (i = 1; i <= nbp3d; i++) {
    tabPt(i+low-1) = MPC.Point(i);
  }
  for (i = 1; i <= nbp2d; i++) {
    tabPt2d(i+low2d-1) = MPC.Point2d(nbp3d+i);
  }
}


Standard_Boolean  AppDef_MyLineTool::Tangency(const AppDef_MultiLine& ML, 
				 const Standard_Integer MPointIndex,
				 TColgp_Array1OfVec& tabV)
{
  AppDef_MultiPointConstraint MPC = ML.Value(MPointIndex);
  if (MPC.IsTangencyPoint()) {
    Standard_Integer nbp3d = MPC.NbPoints(), low = tabV.Lower();
    for (Standard_Integer i = 1; i <= nbp3d; i++) {
      tabV(i+low-1) = MPC.Tang(i);
    }
    return Standard_True;
  }
  else return Standard_False;
}

Standard_Boolean AppDef_MyLineTool::Tangency(const AppDef_MultiLine& ML, 
				 const Standard_Integer MPointIndex,
				 TColgp_Array1OfVec2d& tabV2d)
{
  AppDef_MultiPointConstraint MPC = ML.Value(MPointIndex);
  if (MPC.IsTangencyPoint()) {
    Standard_Integer nbp2d = MPC.NbPoints2d(), low = tabV2d.Lower();
    for (Standard_Integer i = 1; i <= nbp2d; i++) {
      tabV2d(i+low-1) = MPC.Tang2d(i);
    }
    return Standard_True;
  }
  else return Standard_False;
}

Standard_Boolean AppDef_MyLineTool::Tangency(const AppDef_MultiLine& ML, 
				 const Standard_Integer MPointIndex,
				 TColgp_Array1OfVec& tabV,
				 TColgp_Array1OfVec2d& tabV2d)
{
  AppDef_MultiPointConstraint MPC = ML.Value(MPointIndex);
  if (MPC.IsTangencyPoint()) {
    Standard_Integer i, nbp3d = MPC.NbPoints(), low = tabV.Lower();
    Standard_Integer nbp2d = MPC.NbPoints2d(), low2d = tabV2d.Lower();
    for (i = 1; i <= nbp3d; i++) {
      tabV(i+low-1) = MPC.Tang(i);
    }
    for (i = 1; i <= nbp2d; i++) {
      tabV2d(i+low2d-1) = MPC.Tang2d(nbp3d+i);
    }
    return Standard_True;
  }
  else return Standard_False;
  
}


AppDef_MultiLine& AppDef_MyLineTool::MakeMLBetween(const AppDef_MultiLine&,
						   const Standard_Integer ,
						   const Standard_Integer ,
						   const Standard_Integer )
{
  return *((AppDef_MultiLine*) 0);
}

Approx_Status AppDef_MyLineTool::WhatStatus(const AppDef_MultiLine&,
					    const Standard_Integer,
					    const Standard_Integer)
{
  return Approx_NoPointsAdded;
}


Standard_Boolean  AppDef_MyLineTool::Curvature(const AppDef_MultiLine& ML, 
				 const Standard_Integer MPointIndex,
				 TColgp_Array1OfVec& tabV)
{
  AppDef_MultiPointConstraint MPC = ML.Value(MPointIndex);
  if (MPC.IsCurvaturePoint()) {
    Standard_Integer nbp3d = MPC.NbPoints(), low = tabV.Lower();
    for (Standard_Integer i = 1; i <= nbp3d; i++) {
      tabV(i+low-1) = MPC.Curv(i);
    }
    return Standard_True;
  }
  else return Standard_False;
}

Standard_Boolean AppDef_MyLineTool::Curvature(const AppDef_MultiLine& ML, 
				 const Standard_Integer MPointIndex,
				 TColgp_Array1OfVec2d& tabV2d)
{
  AppDef_MultiPointConstraint MPC = ML.Value(MPointIndex);
  if (MPC.IsCurvaturePoint()) {
    Standard_Integer nbp2d = MPC.NbPoints2d(), low = tabV2d.Lower();
    for (Standard_Integer i = 1; i <= nbp2d; i++) {
      tabV2d(i+low-1) = MPC.Curv2d(i);
    }
    return Standard_True;
  }
  else return Standard_False;
}


Standard_Boolean AppDef_MyLineTool::Curvature(const AppDef_MultiLine& ML, 
				 const Standard_Integer MPointIndex,
				 TColgp_Array1OfVec& tabV,
				 TColgp_Array1OfVec2d& tabV2d)

{
  AppDef_MultiPointConstraint MPC = ML.Value(MPointIndex);
  if (MPC.IsCurvaturePoint()) {
    Standard_Integer i, nbp3d = MPC.NbPoints(), low = tabV.Lower();
    Standard_Integer nbp2d = MPC.NbPoints2d(), low2d = tabV2d.Lower();
    for (i = 1; i <= nbp3d; i++) {
      tabV(i+low-1) = MPC.Curv(i);
    }
    for (i = 1; i <= nbp2d; i++) {
      tabV2d(i+low2d-1) = MPC.Curv2d(nbp3d+i);
    }
    return Standard_True;
  }
  else return Standard_False;
  
}