Salome HOME
197f5dd8fcd1ba4ab1cdf738c86d9264d0d9cdc3
[modules/geom.git] / src / GEOMAlgo / GEOMAlgo_FinderShapeOn1.cxx
1 // Copyright (C) 2007-2023  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 // File:        GEOMAlgo_FinderShapeOn1.cxx
24 // Created:     Fri Mar  4 10:31:06 2005
25 // Author:      Peter KURNEV
26
27 #include <GEOMAlgo_FinderShapeOn1.hxx>
28
29 #include <math.h>
30
31 #include <Precision.hxx>
32 #include <TColStd_Array1OfInteger.hxx>
33 #include <TColStd_MapOfInteger.hxx>
34
35 #include <gp_Trsf.hxx>
36 #include <gp_Cylinder.hxx>
37 #include <gp_Pnt.hxx>
38
39 #include <TColgp_Array1OfPnt.hxx>
40
41 #include <Poly_Array1OfTriangle.hxx>
42 #include <Poly_Triangle.hxx>
43 #include <Poly_PolygonOnTriangulation.hxx>
44 #include <Poly_Triangulation.hxx>
45 #include <Poly_Polygon3D.hxx>
46
47 #include <Geom_Curve.hxx>
48 #include <Geom_Surface.hxx>
49 #include <GeomAdaptor_Surface.hxx>
50 #include <GeomAbs_SurfaceType.hxx>
51 #include <GeomAdaptor_Curve.hxx>
52 #include <GeomAbs_CurveType.hxx>
53
54 #include <TopAbs_State.hxx>
55
56 #include <TopLoc_Location.hxx>
57 #include <TopoDS.hxx>
58 #include <TopoDS_Shape.hxx>
59 #include <TopoDS_Vertex.hxx>
60 #include <TopoDS_Face.hxx>
61 #include <TopoDS_Edge.hxx>
62
63 #include <TopExp.hxx>
64 #include <TopExp_Explorer.hxx>
65
66 #include <TopTools_IndexedMapOfShape.hxx>
67
68 #include <BRep_Tool.hxx>
69 #include <BRepLib_MakeEdge.hxx>
70
71 #include <GEOMAlgo_ListIteratorOfListOfPnt.hxx>
72 #include <GEOMAlgo_SurfaceTools.hxx>
73 #include <GEOMAlgo_StateCollector.hxx>
74 #include <GEOMAlgo_AlgoTools.hxx>
75 #include <GEOMAlgo_PassKey.hxx>
76 #include <GEOMAlgo_DataMapOfPassKeyInteger.hxx>
77 #include <GEOMAlgo_DataMapIteratorOfDataMapOfPassKeyInteger.hxx>
78
79
80 //=======================================================================
81 //function : GEOMAlgo_FinderShapeOn1
82 //purpose  :
83 //=======================================================================
84 GEOMAlgo_FinderShapeOn1::GEOMAlgo_FinderShapeOn1()
85 :
86   GEOMAlgo_ShapeAlgo()
87 {
88   myTolerance=0.0001;
89   myShapeType=TopAbs_VERTEX;
90   myState=GEOMAlgo_ST_UNKNOWN;
91   myNbPntsMin=3;
92   myNbPntsMax=0;
93 }
94 //=======================================================================
95 //function : ~
96 //purpose  :
97 //=======================================================================
98 GEOMAlgo_FinderShapeOn1::~GEOMAlgo_FinderShapeOn1()
99 {
100 }
101 //=======================================================================
102 //function : SetSurface
103 //purpose  :
104 //=======================================================================
105 void GEOMAlgo_FinderShapeOn1::SetSurface(const Handle(Geom_Surface)& aS)
106 {
107   mySurface=aS;
108 }
109 //=======================================================================
110 //function : Surface
111 //purpose  :
112 //=======================================================================
113 const Handle(Geom_Surface)& GEOMAlgo_FinderShapeOn1::Surface() const
114 {
115   return mySurface;
116 }
117 //=======================================================================
118 //function : SetShapeType
119 //purpose  :
120 //=======================================================================
121 void GEOMAlgo_FinderShapeOn1::SetShapeType(const TopAbs_ShapeEnum aType)
122 {
123   myShapeType=aType;
124 }
125 //=======================================================================
126 //function : ShapeType
127 //purpose  :
128 //=======================================================================
129 TopAbs_ShapeEnum GEOMAlgo_FinderShapeOn1::ShapeType()const
130 {
131   return myShapeType;
132 }
133 //=======================================================================
134 //function : SetState
135 //purpose  :
136 //=======================================================================
137 void GEOMAlgo_FinderShapeOn1::SetState(const GEOMAlgo_State aState)
138 {
139   myState=aState;
140 }
141 //=======================================================================
142 //function : State
143 //purpose  :
144 //=======================================================================
145 GEOMAlgo_State GEOMAlgo_FinderShapeOn1::State() const
146 {
147   return myState;
148 }
149 //=======================================================================
150 //function : SetNbPntsMin
151 //purpose  :
152 //=======================================================================
153 void GEOMAlgo_FinderShapeOn1::SetNbPntsMin(const Standard_Integer aNb)
154 {
155   myNbPntsMin=aNb;
156 }
157 //=======================================================================
158 //function : NbPntsMin
159 //purpose  :
160 //=======================================================================
161 Standard_Integer GEOMAlgo_FinderShapeOn1::NbPntsMin()const
162 {
163   return myNbPntsMin;
164 }
165 //=======================================================================
166 //function : SetNbPntsMax
167 //purpose  :
168 //=======================================================================
169 void GEOMAlgo_FinderShapeOn1::SetNbPntsMax(const Standard_Integer aNb)
170 {
171   myNbPntsMax=aNb;
172 }
173 //=======================================================================
174 //function : NbPntsMax
175 //purpose  :
176 //=======================================================================
177 Standard_Integer GEOMAlgo_FinderShapeOn1::NbPntsMax()const
178 {
179   return myNbPntsMax;
180 }
181 //=======================================================================
182 // function: MSS
183 // purpose:
184 //=======================================================================
185 const GEOMAlgo_IndexedDataMapOfShapeState& GEOMAlgo_FinderShapeOn1::MSS() const
186 {
187   return myMSS;
188 }
189 //=======================================================================
190 // function: Shapes
191 // purpose:
192 //=======================================================================
193 const TopTools_ListOfShape& GEOMAlgo_FinderShapeOn1::Shapes() const
194 {
195   Standard_Integer i, aNb;
196   TopTools_ListOfShape* pL;
197   //
198   pL=(TopTools_ListOfShape*) &myLS;
199   pL->Clear();
200   //
201   aNb=myMSS.Extent();
202   for (i=1; i<=aNb; ++i) {
203     const TopoDS_Shape& aS=myMSS.FindKey(i);
204     if (aS.ShapeType()==myShapeType) {
205       pL->Append(aS);
206     }
207   }
208   return myLS;
209 }
210 //=======================================================================
211 //function : Perform
212 //purpose  :
213 //=======================================================================
214 void GEOMAlgo_FinderShapeOn1::Perform()
215 {
216   myErrorStatus=0;
217   myWarningStatus=0;
218   myLS.Clear();
219   myMSS.Clear();
220   //
221   CheckData();
222   if(myErrorStatus) {
223     return;
224   }
225   //
226   // Initialize the context
227   GEOMAlgo_ShapeAlgo::Perform();
228   //
229   // 1
230   ProcessVertices();
231   if(myErrorStatus) {
232     return;
233   }
234   if (myShapeType==TopAbs_VERTEX) {
235     return;
236   }
237   //
238   // 2
239   ProcessEdges();
240   if(myErrorStatus) {
241     return;
242   }
243   if (myShapeType==TopAbs_EDGE) {
244     return;
245   }
246   //
247   // 3
248   ProcessFaces();
249   if(myErrorStatus) {
250     return;
251   }
252   if (myShapeType==TopAbs_FACE) {
253     return;
254   }
255   //
256   // 4
257   ProcessSolids();
258   //
259 }
260 //=======================================================================
261 //function : ProcessVertices
262 //purpose  :
263 //=======================================================================
264 void GEOMAlgo_FinderShapeOn1::ProcessVertices()
265 {
266   myErrorStatus=0;
267   //
268   Standard_Boolean bIsConformState;
269   Standard_Integer i, aNb;
270   gp_Pnt aP;
271   TopTools_IndexedMapOfShape aM;
272   TopAbs_State aSt;
273   //
274   TopExp::MapShapes(myShape, TopAbs_VERTEX, aM);
275   aNb=aM.Extent();
276   for (i=1; i<=aNb; ++i) {
277     const TopoDS_Vertex& aV=TopoDS::Vertex(aM(i));
278     aP=BRep_Tool::Pnt(aV);
279     //
280     aSt = GetPointState( aP );
281     bIsConformState=GEOMAlgo_SurfaceTools::IsConformState(aSt, myState);
282     //
283     if (myShapeType==TopAbs_VERTEX){
284       if (bIsConformState) {
285         myMSS.Add(aV, aSt);
286       }
287     }
288     else if (bIsConformState || aSt==TopAbs_ON) {
289       myMSS.Add(aV, aSt);
290     }
291   }
292 }
293 //=======================================================================
294 //function : ProcessEdges
295 //purpose  :
296 //=======================================================================
297 void GEOMAlgo_FinderShapeOn1::ProcessEdges()
298 {
299   myErrorStatus=0;
300   //
301   Standard_Boolean bIsConformState, bIsToBreak;
302   Standard_Integer i, aNb, iCnt;
303   TopAbs_State aSt;
304   TopTools_IndexedMapOfShape aM;
305   TopExp_Explorer aExp;
306   GEOMAlgo_ListIteratorOfListOfPnt aIt;
307   GeomAbs_SurfaceType aType1;
308   //
309   aType1=myGAS.GetType();
310   //
311   TopExp::MapShapes(myShape, TopAbs_EDGE, aM);
312   //
313   bIsConformState=Standard_False;
314   //
315   aNb=aM.Extent();
316   for (i=1; i<=aNb; ++i) {
317     GEOMAlgo_ListOfPnt aLP;
318     GEOMAlgo_StateCollector aSC;
319     //
320     const TopoDS_Edge& aE=TopoDS::Edge(aM(i));
321     //
322     aExp.Init(aE, TopAbs_VERTEX);
323     for (; aExp.More(); aExp.Next()) {
324       const TopoDS_Shape& aV=aExp.Current();
325       //
326       bIsConformState=myMSS.Contains(aV);
327       if (!bIsConformState) {
328         break;// vertex has non-conformed state
329       }
330       else {
331         aSt=myMSS.FindFromKey(aV);
332         aSC.AppendState(aSt);
333       }
334     }
335     //
336     if (!bIsConformState) {
337       continue; // vertex has non-conformed state,skip edge
338     }
339     //
340     if (BRep_Tool::Degenerated(aE)) {
341       myMSS.Add(aE, aSt);
342       continue;
343     }
344     //
345     if (myState==GEOMAlgo_ST_ON && aType1==GeomAbs_Sphere) {
346       Standard_Real aT1, aT2;
347       Handle(Geom_Curve) aC;
348       GeomAdaptor_Curve aGAC;
349       GeomAbs_CurveType aType2;
350       //
351       aC=BRep_Tool::Curve(aE, aT1, aT2);
352       aGAC.Load(aC);
353       //
354       aType2=aGAC.GetType();
355       if (aType2==GeomAbs_Line) {
356         continue;
357       }
358     }
359     //
360     InnerPoints(aE, aLP);
361     if (myErrorStatus) {
362       return;
363     }
364     //
365     bIsConformState=Standard_True;
366     aIt.Initialize(aLP);
367     for (iCnt=0; aIt.More(); aIt.Next(), ++iCnt) {
368       if (myNbPntsMax) {
369         if (iCnt > myNbPntsMax) {
370           break;
371         }
372       }
373       //
374       const gp_Pnt& aP=aIt.Value();
375       aSt = GetPointState( aP );
376       bIsToBreak=aSC.AppendState(aSt);
377       if (bIsToBreak) {
378         break;
379       }
380     }
381     //
382     aSt=aSC.State();
383     //
384     bIsConformState=GEOMAlgo_SurfaceTools::IsConformState(aSt, myState);
385     if (myShapeType==TopAbs_EDGE) {
386       if (bIsConformState) {
387         myMSS.Add(aE, aSt);
388       }
389     }
390     else if (bIsConformState || aSt==TopAbs_ON) {
391       myMSS.Add(aE, aSt);
392     }
393   } //  for (i=1; i<=aNb; ++i) next edge
394 }
395 //=======================================================================
396 //function : ProcessFaces
397 //purpose  :
398 //=======================================================================
399 void GEOMAlgo_FinderShapeOn1::ProcessFaces()
400 {
401   myErrorStatus=0;
402   //
403   Standard_Boolean bIsConformState, bIsToBreak;
404   Standard_Integer i, aNbF, iCnt;
405   TopAbs_State aSt;
406   TopTools_IndexedMapOfShape aM;
407   TopExp_Explorer aExp;
408   GEOMAlgo_ListIteratorOfListOfPnt aIt;
409   GeomAbs_SurfaceType aType1, aType2;
410   //
411   aType1=myGAS.GetType();
412   //
413   TopExp::MapShapes(myShape, TopAbs_FACE, aM);
414   aNbF=aM.Extent();
415   for (i=1; i<=aNbF; ++i) {
416     GEOMAlgo_StateCollector aSC;
417     GEOMAlgo_ListOfPnt aLP;
418     //
419     const TopoDS_Face& aF=TopoDS::Face(aM(i));
420     //
421     if (myState==GEOMAlgo_ST_ON) {
422       Handle(Geom_Surface) aS;
423       GeomAdaptor_Surface aGAS;
424       //
425       aS=BRep_Tool::Surface(aF);
426       aGAS.Load(aS);
427       aType2=aGAS.GetType();
428       if (aType2!=aType1) {
429         continue;
430       }
431     }
432     //
433     bIsConformState=Standard_False;
434     //
435     aExp.Init(aF, TopAbs_EDGE);
436     for (; aExp.More(); aExp.Next()) {
437       const TopoDS_Shape& aE=aExp.Current();
438       bIsConformState=myMSS.Contains(aE);
439       if (!bIsConformState) {
440         break;// edge has non-conformed state
441       }
442       else {
443         aSt=myMSS.FindFromKey(aE);
444         aSC.AppendState(aSt);
445       }
446     }
447     //
448     if (!bIsConformState) {
449       continue; // edge has non-conformed state,skip face
450     }
451     //
452     InnerPoints(aF, aLP);
453     if (myErrorStatus) {
454       return;
455     }
456     //
457     bIsConformState=Standard_True;
458     aIt.Initialize(aLP);
459     for (iCnt=0; aIt.More(); aIt.Next(), ++iCnt) {
460       if (myNbPntsMax) {
461         if (iCnt > myNbPntsMax) {
462           break;
463         }
464       }
465       //
466       const gp_Pnt& aP=aIt.Value();
467       aSt = GetPointState( aP );
468       bIsToBreak=aSC.AppendState(aSt);
469       if (bIsToBreak) {
470         break;
471       }
472     }
473     //
474     aSt=aSC.State();
475     //
476     bIsConformState=GEOMAlgo_SurfaceTools::IsConformState(aSt, myState);
477     if (myShapeType==TopAbs_FACE) {
478       if (bIsConformState) {
479         myMSS.Add(aF, aSt);
480       }
481     }
482     else if (bIsConformState || aSt==TopAbs_ON) {
483       myMSS.Add(aF, aSt);
484     }
485   }//  for (i=1; i<=aNb; ++i) next face
486 }
487 //=======================================================================
488 //function : ProcessSolids
489 //purpose  :
490 //=======================================================================
491 void GEOMAlgo_FinderShapeOn1::ProcessSolids()
492 {
493   myErrorStatus=0;
494   //
495   Standard_Boolean bIsConformState;
496   Standard_Integer i, aNbS, j, aNbF;
497   TopTools_IndexedMapOfShape aM, aMF;
498   TopAbs_State aSt;
499   //
500   TopExp::MapShapes(myShape, TopAbs_SOLID, aM);
501   aNbS=aM.Extent();
502   for (i=1; i<=aNbS; ++i) {
503     GEOMAlgo_StateCollector aSC;
504     //
505     const TopoDS_Shape& aSd=aM(i);
506     aMF.Clear();
507     TopExp::MapShapes(aSd, TopAbs_FACE, aMF);
508     //
509     bIsConformState=Standard_False;
510     //
511     aNbF=aMF.Extent();
512     for (j=1; j<=aNbF; ++j) {
513       const TopoDS_Shape& aF=aMF(j);
514       bIsConformState=myMSS.Contains(aF);
515       if (!bIsConformState) {
516         break;// face has non-conformed state
517       }
518       else {
519         aSt=myMSS.FindFromKey(aF);
520         aSC.AppendState(aSt);
521       }
522     }
523     //
524     if (!bIsConformState) {
525       continue; // face has non-conformed state,skip solid
526     }
527     //
528     aSt=aSC.State();
529     //
530     bIsConformState=GEOMAlgo_SurfaceTools::IsConformState(aSt, myState);
531     if (bIsConformState) {
532       myMSS.Add(aSd, aSt);
533     }
534   }
535 }
536 //
537 //=======================================================================
538 //function : InnerPoints
539 //purpose  :
540 //=======================================================================
541 void GEOMAlgo_FinderShapeOn1::InnerPoints(const TopoDS_Face& aF,
542                                           GEOMAlgo_ListOfPnt& aLP)
543 {
544   myErrorStatus=0;
545   //
546   Standard_Integer j, j1, j2, k, n[4], aNbLinks, aNx, aNb, iCnt;//, aNbMax, *pIds;
547   TopLoc_Location aLoc;
548   Handle(Poly_Triangulation) aTRF;
549   TColStd_MapOfInteger aMBN;
550   GEOMAlgo_DataMapOfPassKeyInteger aMPKI;
551   GEOMAlgo_DataMapIteratorOfDataMapOfPassKeyInteger aIt;
552   gp_Pnt aP, aP1, aP2;
553   //
554   aLP.Clear();
555   //
556   aTRF=BRep_Tool::Triangulation(aF, aLoc);
557   if (aTRF.IsNull()) {
558     if (!GEOMAlgo_AlgoTools::BuildTriangulation(aF)) {
559       myWarningStatus=20; // no triangulation found
560       return;
561     }
562     aTRF=BRep_Tool::Triangulation(aF, aLoc);
563   }
564   //
565   const gp_Trsf& aTrsf=aLoc.Transformation();
566   const Poly_Array1OfTriangle& aTrs=aTRF->Triangles();
567   const TColgp_Array1OfPnt& aNodes=aTRF->Nodes();
568   //
569   // map link/nbtriangles
570   j1=aTrs.Lower();
571   j2=aTrs.Upper();
572   for (j=j1; j<=j2; ++j) {
573     const Poly_Triangle& aTr=aTrs(j);
574     aTr.Get(n[0], n[1], n[2]);
575     n[3]=n[0];
576     for (k=0; k<3; ++k) {
577       GEOMAlgo_PassKey aPK;
578       //
579       aPK.SetIds(n[k], n[k+1]);
580       if (aMPKI.IsBound(aPK)) {
581         Standard_Integer& iCntX=aMPKI.ChangeFind(aPK);
582         ++iCntX;
583       }
584       else {
585         aMPKI.Bind(aPK, 1);
586       }
587     }
588   }
589   //
590   // boundary nodes aMBN
591   aNbLinks=aMPKI.Extent();
592   aIt.Initialize(aMPKI);
593   for (; aIt.More(); aIt.Next()) {
594     iCnt=aIt.Value();
595     if (iCnt==1) {
596       const GEOMAlgo_PassKey& aPK=aIt.Key();
597       //
598       aNx=(Standard_Integer)aPK.Id(1);
599       aMBN.Add(aNx);
600       aNx=(Standard_Integer)aPK.Id(2);
601       aMBN.Add(aNx);
602     }
603   }
604   //
605   // inner nodes=all_nodes - boundary_nodes
606   j1=aNodes.Lower();
607   j2=aNodes.Upper();
608   for (j=j1; j<=j2; ++j) {
609     if (!aMBN.Contains(j)) {
610       aP=aNodes(j).Transformed(aTrsf);
611       aLP.Append(aP);
612     }
613   }
614   //
615   aNb=aLP.Extent();
616   //
617   if (!aNb && myNbPntsMin) {
618     // try to fill it yourself
619     Standard_Boolean bIsDone;
620     Standard_Integer aN1, aN2;
621     Handle(Geom_Surface) aS;
622     GeomAdaptor_Surface aGAS;
623     GeomAbs_SurfaceType aType;
624     //
625     aS=BRep_Tool::Surface(aF);
626     aGAS.Load(aS);
627     aType=aGAS.GetType();
628     if (aType==GeomAbs_Plane || aType==GeomAbs_Cylinder) {
629       // inner links
630       aNbLinks=aMPKI.Extent();
631       aIt.Initialize(aMPKI);
632       for (; aIt.More(); aIt.Next()) {
633         iCnt=aIt.Value();
634         if (iCnt>1) {
635           // take the first having occurred inner link
636           // and discretize it
637           const GEOMAlgo_PassKey& aPK=aIt.Key();
638           //
639           aN1=(Standard_Integer)aPK.Id(1);
640           aN2=(Standard_Integer)aPK.Id(2);
641           //
642           aP1=aNodes(aN1).Transformed(aTrsf);
643           aP2=aNodes(aN2).Transformed(aTrsf);
644           //
645           if (aType==GeomAbs_Cylinder) {
646             gp_Cylinder aCyl;
647             //
648             aCyl=aGAS.Cylinder();
649             if (!GEOMAlgo_SurfaceTools::IsCoaxial(aP1, aP2, aCyl, myTolerance)) {
650               continue;
651             }
652           }
653           //
654           BRepLib_MakeEdge aBME(aP1, aP2);
655           bIsDone=aBME.IsDone();
656           if (!bIsDone) {
657             myErrorStatus=30; //can not obtain the line from the link
658             return;
659           }
660           //
661           const TopoDS_Shape& aSx=aBME.Shape();
662           const TopoDS_Edge& aE=TopoDS::Edge(aSx);
663           //
664           InnerPoints(aE, myNbPntsMin, aLP);
665           break;
666         }// if (iCnt>1)
667       }// for (; aIt.More(); aIt.Next())
668     }// if (aType==GeomAbs_Plane || aType==GeomAbs_Cylinder)
669   }// if (!aNb && myNbPntsMin) {
670 }
671 //=======================================================================
672 //function : InnerPoints
673 //purpose  :
674 //=======================================================================
675 void GEOMAlgo_FinderShapeOn1::InnerPoints(const TopoDS_Edge& aE,
676                                           GEOMAlgo_ListOfPnt& aLP)
677 {
678   Standard_Integer aNbPntsMin;
679   //
680   myErrorStatus=0;
681   aNbPntsMin=21;
682   //
683   aLP.Clear();
684   InnerPoints(aE, aNbPntsMin, aLP);
685 }
686 //=======================================================================
687 //function : InnerPoints
688 //purpose  :
689 //=======================================================================
690 void GEOMAlgo_FinderShapeOn1::InnerPoints(const TopoDS_Edge& aE,
691                                           const Standard_Integer aNbPntsMin,
692                                           GEOMAlgo_ListOfPnt& aLP)
693 {
694   Standard_Boolean bInf1, bInf2;
695   Standard_Integer j, aNbT;
696   Standard_Real dT, aT, aT1, aT2;
697   gp_Pnt aP;
698   Handle(Geom_Curve) aC3D;
699   //
700   aC3D=BRep_Tool::Curve(aE, aT1, aT2);
701   if (aC3D.IsNull()) {
702     return;
703   }
704   //
705   bInf1=Precision::IsNegativeInfinite(aT1);
706   bInf2=Precision::IsPositiveInfinite(aT2);
707   if (bInf1 || bInf2) {
708     return;
709   }
710   //
711   aNbT=aNbPntsMin+1;
712   dT=(aT2-aT1)/aNbT;
713   for (j=1; j<aNbT; ++j) {
714     aT=aT1+j*dT;
715     aC3D->D0(aT, aP);
716     aLP.Append(aP);
717   }
718 }
719
720 //=======================================================================
721 //function : CheckData
722 //purpose  :
723 //=======================================================================
724 void GEOMAlgo_FinderShapeOn1::CheckData()
725 {
726   myErrorStatus=0;
727   //
728   if(mySurface.IsNull()) {
729     myErrorStatus=10; // mySurface=NULL
730     return;
731   }
732   //
733   if (myShape.IsNull()) {
734     myErrorStatus=11; // myShape=NULL
735     return;
736   }
737   //
738   if (!(myShapeType==TopAbs_VERTEX ||
739         myShapeType==TopAbs_EDGE ||
740         myShapeType==TopAbs_FACE ||
741         myShapeType==TopAbs_SOLID)) {
742     myErrorStatus=12; // unallowed subshape type
743     return;
744   }
745   //
746   if (myState==GEOMAlgo_ST_UNKNOWN ||
747       myState==GEOMAlgo_ST_INOUT) {
748     myErrorStatus=13; // unallowed state type
749     return;
750   }
751   //
752   GeomAbs_SurfaceType aType;
753   //
754   myGAS.Load(mySurface);
755   aType=myGAS.GetType();
756   if (!(aType==GeomAbs_Plane ||
757         aType==GeomAbs_Cylinder ||
758         aType==GeomAbs_Sphere)) {
759     myErrorStatus=14; // unallowed surface type
760   }
761 }
762
763 //=======================================================================
764 //function : GetPointState
765 //purpose  :
766 //=======================================================================
767
768 TopAbs_State GEOMAlgo_FinderShapeOn1::GetPointState(const gp_Pnt& aP)
769 {
770   TopAbs_State aSt;
771   GEOMAlgo_SurfaceTools::GetState(aP, myGAS, myTolerance, aSt);
772   return aSt;
773 }
774
775
776 //
777 // myErrorStatus :
778 //
779 // 10 -mySurface=NULL
780 // 11 -myShape=NULL
781 // 12 -unallowed type of subshapes
782 // 13 -unallowed state
783 // 14 -unallowed surface type
784 // 15 -unallowed surface type
785 // 20- no triangulation found
786 // 30- can not obtain the line from the link
787