1 // Copyright (c) 1995-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
15 // AppDef_MyLineTool.cxx
17 #include <AppDef_MultiLine.hxx>
18 #include <AppDef_MultiPointConstraint.hxx>
19 #include <AppDef_MyLineTool.hxx>
21 #include <gp_Pnt2d.hxx>
23 #include <gp_Vec2d.hxx>
25 Standard_Integer AppDef_MyLineTool::FirstPoint(const AppDef_MultiLine&)
30 Standard_Integer AppDef_MyLineTool::LastPoint(const AppDef_MultiLine& ML)
32 return ML.NbMultiPoints();
35 Standard_Integer AppDef_MyLineTool::NbP2d(const AppDef_MultiLine& ML)
37 return ML.Value(1).NbPoints2d();
40 Standard_Integer AppDef_MyLineTool::NbP3d(const AppDef_MultiLine& ML)
42 return ML.Value(1).NbPoints();
46 void AppDef_MyLineTool::Value(const AppDef_MultiLine& ML,
47 const Standard_Integer MPointIndex,
48 TColgp_Array1OfPnt& tabPt)
50 AppDef_MultiPointConstraint MPC = ML.Value(MPointIndex);
51 Standard_Integer nbp3d = MPC.NbPoints(), low = tabPt.Lower();
52 for (Standard_Integer i = 1; i <= nbp3d; i++) {
53 tabPt(i+low-1) = MPC.Point(i);
57 void AppDef_MyLineTool::Value(const AppDef_MultiLine& ML,
58 const Standard_Integer MPointIndex,
59 TColgp_Array1OfPnt2d& tabPt2d)
61 AppDef_MultiPointConstraint MPC = ML.Value(MPointIndex);
62 Standard_Integer nbp3d = MPC.NbPoints();
63 Standard_Integer nbp2d = MPC.NbPoints2d();
64 Standard_Integer low = tabPt2d.Lower();
65 for (Standard_Integer i = 1; i <= nbp2d; i++) {
66 tabPt2d(i+low-1) = MPC.Point2d(nbp3d+i);
70 void AppDef_MyLineTool::Value(const AppDef_MultiLine& ML,
71 const Standard_Integer MPointIndex,
72 TColgp_Array1OfPnt& tabPt,
73 TColgp_Array1OfPnt2d& tabPt2d)
75 AppDef_MultiPointConstraint MPC = ML.Value(MPointIndex);
76 Standard_Integer i, nbp2d = MPC.NbPoints2d(), low2d = tabPt2d.Lower();
77 Standard_Integer nbp3d = MPC.NbPoints(), low = tabPt.Lower();
78 for (i = 1; i <= nbp3d; i++) {
79 tabPt(i+low-1) = MPC.Point(i);
81 for (i = 1; i <= nbp2d; i++) {
82 tabPt2d(i+low2d-1) = MPC.Point2d(nbp3d+i);
87 Standard_Boolean AppDef_MyLineTool::Tangency(const AppDef_MultiLine& ML,
88 const Standard_Integer MPointIndex,
89 TColgp_Array1OfVec& tabV)
91 AppDef_MultiPointConstraint MPC = ML.Value(MPointIndex);
92 if (MPC.IsTangencyPoint()) {
93 Standard_Integer nbp3d = MPC.NbPoints(), low = tabV.Lower();
94 for (Standard_Integer i = 1; i <= nbp3d; i++) {
95 tabV(i+low-1) = MPC.Tang(i);
99 else return Standard_False;
102 Standard_Boolean AppDef_MyLineTool::Tangency(const AppDef_MultiLine& ML,
103 const Standard_Integer MPointIndex,
104 TColgp_Array1OfVec2d& tabV2d)
106 AppDef_MultiPointConstraint MPC = ML.Value(MPointIndex);
107 if (MPC.IsTangencyPoint())
109 Standard_Integer nbp3d = MPC.NbPoints();
110 Standard_Integer nbp2d = MPC.NbPoints2d(), low = tabV2d.Lower();
111 for (Standard_Integer i = 1; i <= nbp2d; i++) {
112 tabV2d(i+low-1) = MPC.Tang2d(nbp3d+i);
114 return Standard_True;
116 else return Standard_False;
119 Standard_Boolean AppDef_MyLineTool::Tangency(const AppDef_MultiLine& ML,
120 const Standard_Integer MPointIndex,
121 TColgp_Array1OfVec& tabV,
122 TColgp_Array1OfVec2d& tabV2d)
124 AppDef_MultiPointConstraint MPC = ML.Value(MPointIndex);
125 if (MPC.IsTangencyPoint()) {
126 Standard_Integer i, nbp3d = MPC.NbPoints(), low = tabV.Lower();
127 Standard_Integer nbp2d = MPC.NbPoints2d(), low2d = tabV2d.Lower();
128 for (i = 1; i <= nbp3d; i++) {
129 tabV(i+low-1) = MPC.Tang(i);
131 for (i = 1; i <= nbp2d; i++) {
132 tabV2d(i+low2d-1) = MPC.Tang2d(nbp3d+i);
134 return Standard_True;
136 else return Standard_False;
141 AppDef_MultiLine& AppDef_MyLineTool::MakeMLBetween(const AppDef_MultiLine&,
142 const Standard_Integer ,
143 const Standard_Integer ,
144 const Standard_Integer )
146 return *((AppDef_MultiLine*) 0);
149 Standard_Boolean AppDef_MyLineTool::MakeMLOneMorePoint(const AppDef_MultiLine& ,
150 const Standard_Integer,
151 const Standard_Integer,
152 const Standard_Integer,
155 return Standard_False;
158 Approx_Status AppDef_MyLineTool::WhatStatus(const AppDef_MultiLine&,
159 const Standard_Integer,
160 const Standard_Integer)
162 return Approx_NoPointsAdded;
166 Standard_Boolean AppDef_MyLineTool::Curvature(const AppDef_MultiLine& ML,
167 const Standard_Integer MPointIndex,
168 TColgp_Array1OfVec& tabV)
170 AppDef_MultiPointConstraint MPC = ML.Value(MPointIndex);
171 if (MPC.IsCurvaturePoint()) {
172 Standard_Integer nbp3d = MPC.NbPoints(), low = tabV.Lower();
173 for (Standard_Integer i = 1; i <= nbp3d; i++) {
174 tabV(i+low-1) = MPC.Curv(i);
176 return Standard_True;
178 else return Standard_False;
181 Standard_Boolean AppDef_MyLineTool::Curvature(const AppDef_MultiLine& ML,
182 const Standard_Integer MPointIndex,
183 TColgp_Array1OfVec2d& tabV2d)
185 AppDef_MultiPointConstraint MPC = ML.Value(MPointIndex);
186 if (MPC.IsCurvaturePoint())
188 Standard_Integer nbp3d = MPC.NbPoints();
189 Standard_Integer nbp2d = MPC.NbPoints2d(), low = tabV2d.Lower();
190 for (Standard_Integer i = 1; i <= nbp2d; i++) {
191 tabV2d(i+low-1) = MPC.Curv2d(nbp3d+i);
193 return Standard_True;
195 else return Standard_False;
199 Standard_Boolean AppDef_MyLineTool::Curvature(const AppDef_MultiLine& ML,
200 const Standard_Integer MPointIndex,
201 TColgp_Array1OfVec& tabV,
202 TColgp_Array1OfVec2d& tabV2d)
205 AppDef_MultiPointConstraint MPC = ML.Value(MPointIndex);
206 if (MPC.IsCurvaturePoint()) {
207 Standard_Integer i, nbp3d = MPC.NbPoints(), low = tabV.Lower();
208 Standard_Integer nbp2d = MPC.NbPoints2d(), low2d = tabV2d.Lower();
209 for (i = 1; i <= nbp3d; i++) {
210 tabV(i+low-1) = MPC.Curv(i);
212 for (i = 1; i <= nbp2d; i++) {
213 tabV2d(i+low2d-1) = MPC.Curv2d(nbp3d+i);
215 return Standard_True;
217 else return Standard_False;