Salome HOME
Merge from V6_main 01/04/2013
[modules/geom.git] / src / GEOMAlgo / GEOMAlgo_FinderShapeOn1.cxx
1 // Copyright (C) 2007-2013  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.
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
73 #include <GEOMAlgo_SurfaceTools.hxx>
74 #include <GEOMAlgo_StateCollector.hxx>
75 #include <GEOMAlgo_FinderShapeOn.hxx>
76
77 #include <GEOMAlgo_PassKey.hxx>
78 #include <GEOMAlgo_DataMapOfPassKeyInteger.hxx>
79 #include <GEOMAlgo_DataMapIteratorOfDataMapOfPassKeyInteger.hxx>
80
81 //=======================================================================
82 //function : GEOMAlgo_FinderShapeOn1
83 //purpose  :
84 //=======================================================================
85 GEOMAlgo_FinderShapeOn1::GEOMAlgo_FinderShapeOn1()
86 :
87   GEOMAlgo_ShapeAlgo()
88 {
89   myTolerance=0.0001;
90   myShapeType=TopAbs_VERTEX;
91   myState=GEOMAlgo_ST_UNKNOWN;
92   myNbPntsMin=3;
93   myNbPntsMax=0;
94 }
95 //=======================================================================
96 //function : ~
97 //purpose  :
98 //=======================================================================
99 GEOMAlgo_FinderShapeOn1::~GEOMAlgo_FinderShapeOn1()
100 {
101 }
102 //=======================================================================
103 //function : SetSurface
104 //purpose  :
105 //=======================================================================
106 void GEOMAlgo_FinderShapeOn1::SetSurface(const Handle(Geom_Surface)& aS)
107 {
108   mySurface=aS;
109 }
110 //=======================================================================
111 //function : Surface
112 //purpose  :
113 //=======================================================================
114 const Handle(Geom_Surface)& GEOMAlgo_FinderShapeOn1::Surface() const
115 {
116   return mySurface;
117 }
118 //=======================================================================
119 //function : SetShapeType
120 //purpose  :
121 //=======================================================================
122 void GEOMAlgo_FinderShapeOn1::SetShapeType(const TopAbs_ShapeEnum aType)
123 {
124   myShapeType=aType;
125 }
126 //=======================================================================
127 //function : ShapeType
128 //purpose  :
129 //=======================================================================
130 TopAbs_ShapeEnum GEOMAlgo_FinderShapeOn1::ShapeType()const
131 {
132   return myShapeType;
133 }
134 //=======================================================================
135 //function : SetState
136 //purpose  :
137 //=======================================================================
138 void GEOMAlgo_FinderShapeOn1::SetState(const GEOMAlgo_State aState)
139 {
140   myState=aState;
141 }
142 //=======================================================================
143 //function : State
144 //purpose  :
145 //=======================================================================
146 GEOMAlgo_State GEOMAlgo_FinderShapeOn1::State() const
147 {
148   return myState;
149 }
150 //=======================================================================
151 //function : SetNbPntsMin
152 //purpose  :
153 //=======================================================================
154 void GEOMAlgo_FinderShapeOn1::SetNbPntsMin(const Standard_Integer aNb)
155 {
156   myNbPntsMin=aNb;
157 }
158 //=======================================================================
159 //function : NbPntsMin
160 //purpose  :
161 //=======================================================================
162 Standard_Integer GEOMAlgo_FinderShapeOn1::NbPntsMin()const
163 {
164   return myNbPntsMin;
165 }
166 //=======================================================================
167 //function : SetNbPntsMax
168 //purpose  :
169 //=======================================================================
170 void GEOMAlgo_FinderShapeOn1::SetNbPntsMax(const Standard_Integer aNb)
171 {
172   myNbPntsMax=aNb;
173 }
174 //=======================================================================
175 //function : NbPntsMax
176 //purpose  :
177 //=======================================================================
178 Standard_Integer GEOMAlgo_FinderShapeOn1::NbPntsMax()const
179 {
180   return myNbPntsMax;
181 }
182 //=======================================================================
183 // function: MSS
184 // purpose:
185 //=======================================================================
186 const GEOMAlgo_IndexedDataMapOfShapeState& GEOMAlgo_FinderShapeOn1::MSS() const
187 {
188   return myMSS;
189 }
190 //=======================================================================
191 // function: Shapes
192 // purpose:
193 //=======================================================================
194 const TopTools_ListOfShape& GEOMAlgo_FinderShapeOn1::Shapes() const
195 {
196   Standard_Integer i, aNb;
197   TopTools_ListOfShape* pL;
198   //
199   pL=(TopTools_ListOfShape*) &myLS;
200   pL->Clear();
201   //
202   aNb=myMSS.Extent();
203   for (i=1; i<=aNb; ++i) {
204     const TopoDS_Shape& aS=myMSS.FindKey(i);
205     if (aS.ShapeType()==myShapeType) {
206       pL->Append(aS);
207     }
208   }
209   return myLS;
210 }
211 //=======================================================================
212 //function : Perform
213 //purpose  :
214 //=======================================================================
215 void GEOMAlgo_FinderShapeOn1::Perform()
216 {
217   myErrorStatus=0;
218   myWarningStatus=0;
219   myLS.Clear();
220   myMSS.Clear();
221   //
222   CheckData();
223   if(myErrorStatus) {
224     return;
225   }
226   //
227   // Initialize the context
228   GEOMAlgo_ShapeAlgo::Perform();
229   //
230   // 1
231   ProcessVertices();
232   if(myErrorStatus) {
233     return;
234   }
235   if (myShapeType==TopAbs_VERTEX) {
236     return;
237   }
238   //
239   // 2
240   ProcessEdges();
241   if(myErrorStatus) {
242     return;
243   }
244   if (myShapeType==TopAbs_EDGE) {
245     return;
246   }
247   //
248   // 3
249   ProcessFaces();
250   if(myErrorStatus) {
251     return;
252   }
253   if (myShapeType==TopAbs_FACE) {
254     return;
255   }
256   //
257   // 4
258   ProcessSolids();
259   //
260 }
261 //=======================================================================
262 //function : ProcessVertices
263 //purpose  :
264 //=======================================================================
265 void GEOMAlgo_FinderShapeOn1::ProcessVertices()
266 {
267   myErrorStatus=0;
268   //
269   Standard_Boolean bIsConformState;
270   Standard_Integer i, aNb;
271   gp_Pnt aP;
272   TopTools_IndexedMapOfShape aM;
273   TopAbs_State aSt;
274   //
275   TopExp::MapShapes(myShape, TopAbs_VERTEX, aM);
276   aNb=aM.Extent();
277   for (i=1; i<=aNb; ++i) {
278     const TopoDS_Vertex& aV=TopoDS::Vertex(aM(i));
279     aP=BRep_Tool::Pnt(aV);
280     //
281     aSt = GetPointState( aP );
282     bIsConformState=GEOMAlgo_SurfaceTools::IsConformState(aSt, myState);
283     //
284     if (myShapeType==TopAbs_VERTEX){
285       if (bIsConformState) {
286         myMSS.Add(aV, aSt);
287       }
288     }
289     else if (bIsConformState || aSt==TopAbs_ON) {
290       myMSS.Add(aV, aSt);
291     }
292   }
293 }
294 //=======================================================================
295 //function : ProcessEdges
296 //purpose  :
297 //=======================================================================
298 void GEOMAlgo_FinderShapeOn1::ProcessEdges()
299 {
300   myErrorStatus=0;
301   //
302   Standard_Boolean bIsConformState, bIsToBreak;
303   Standard_Integer i, aNb, iCnt;
304   TopAbs_State aSt;
305   TopTools_IndexedMapOfShape aM;
306   TopExp_Explorer aExp;
307   GEOMAlgo_ListIteratorOfListOfPnt aIt;
308   GeomAbs_SurfaceType aType1;
309   //
310   aType1=myGAS.GetType();
311   //
312   TopExp::MapShapes(myShape, TopAbs_EDGE, aM);
313   aNb=aM.Extent();
314   for (i=1; i<=aNb; ++i) {
315     GEOMAlgo_ListOfPnt aLP;
316     GEOMAlgo_StateCollector aSC;
317     //
318     const TopoDS_Edge& aE=TopoDS::Edge(aM(i));
319     //
320     aExp.Init(aE, TopAbs_VERTEX);
321     for (; aExp.More(); aExp.Next()) {
322       const TopoDS_Shape& aV=aExp.Current();
323       //
324       bIsConformState=myMSS.Contains(aV);
325       if (!bIsConformState) {
326         break;// vertex has non-conformed state
327       }
328       else {
329         aSt=myMSS.FindFromKey(aV);
330         aSC.AppendState(aSt);
331       }
332     }
333     //
334     if (!bIsConformState) {
335       continue; // vertex has non-conformed state,skip edge
336     }
337     //
338     if (BRep_Tool::Degenerated(aE)) {
339       myMSS.Add(aE, aSt);
340       continue;
341     }
342     //
343     if (myState==GEOMAlgo_ST_ON && aType1==GeomAbs_Sphere) {
344       Standard_Real aT1, aT2;
345       Handle(Geom_Curve) aC;
346       GeomAdaptor_Curve aGAC;
347       GeomAbs_CurveType aType2;
348       //
349       aC=BRep_Tool::Curve(aE, aT1, aT2);
350       aGAC.Load(aC);
351       //
352       aType2=aGAC.GetType();
353       if (aType2==GeomAbs_Line) {
354         continue;
355       }
356     }
357     //
358     InnerPoints(aE, aLP);
359     if (myErrorStatus) {
360       return;
361     }
362     //
363     bIsConformState=Standard_True;
364     aIt.Initialize(aLP);
365     for (iCnt=0; aIt.More(); aIt.Next(), ++iCnt) {
366       if (myNbPntsMax) {
367         if (iCnt > myNbPntsMax) {
368           break;
369         }
370       }
371       //
372       const gp_Pnt& aP=aIt.Value();
373       aSt = GetPointState( aP );
374       bIsToBreak=aSC.AppendState(aSt);
375       if (bIsToBreak) {
376         break;
377       }
378     }
379     //
380     aSt=aSC.State();
381     //
382     bIsConformState=GEOMAlgo_SurfaceTools::IsConformState(aSt, myState);
383     if (myShapeType==TopAbs_EDGE) {
384       if (bIsConformState) {
385         myMSS.Add(aE, aSt);
386       }
387     }
388     else if (bIsConformState || aSt==TopAbs_ON) {
389       myMSS.Add(aE, aSt);
390     }
391   } //  for (i=1; i<=aNb; ++i) next edge
392 }
393 //=======================================================================
394 //function : ProcessFaces
395 //purpose  :
396 //=======================================================================
397 void GEOMAlgo_FinderShapeOn1::ProcessFaces()
398 {
399   myErrorStatus=0;
400   //
401   Standard_Boolean bIsConformState, bIsToBreak;
402   Standard_Integer i, aNbF, iCnt;
403   TopAbs_State aSt;
404   TopTools_IndexedMapOfShape aM;
405   TopExp_Explorer aExp;
406   GEOMAlgo_ListIteratorOfListOfPnt aIt;
407   GeomAbs_SurfaceType aType1, aType2;
408   //
409   aType1=myGAS.GetType();
410   //
411   TopExp::MapShapes(myShape, TopAbs_FACE, aM);
412   aNbF=aM.Extent();
413   for (i=1; i<=aNbF; ++i) {
414     GEOMAlgo_StateCollector aSC;
415     GEOMAlgo_ListOfPnt aLP;
416     //
417     const TopoDS_Face& aF=TopoDS::Face(aM(i));
418     //
419     if (myState==GEOMAlgo_ST_ON) {
420       Handle(Geom_Surface) aS;
421       GeomAdaptor_Surface aGAS;
422       //
423       aS=BRep_Tool::Surface(aF);
424       aGAS.Load(aS);
425       aType2=aGAS.GetType();
426       if (aType2!=aType1) {
427         continue;
428       }
429     }
430     //
431     aExp.Init(aF, TopAbs_EDGE);
432     for (; aExp.More(); aExp.Next()) {
433       const TopoDS_Shape& aE=aExp.Current();
434       bIsConformState=myMSS.Contains(aE);
435       if (!bIsConformState) {
436         break;// edge has non-conformed state
437       }
438       else {
439         aSt=myMSS.FindFromKey(aE);
440         aSC.AppendState(aSt);
441       }
442     }
443     //
444     if (!bIsConformState) {
445       continue; // edge has non-conformed state,skip face
446     }
447     //
448     InnerPoints(aF, aLP);
449     if (myErrorStatus) {
450       return;
451     }
452     //
453     bIsConformState=Standard_True;
454     aIt.Initialize(aLP);
455     for (iCnt=0; aIt.More(); aIt.Next(), ++iCnt) {
456       if (myNbPntsMax) {
457         if (iCnt > myNbPntsMax) {
458           break;
459         }
460       }
461       //
462       const gp_Pnt& aP=aIt.Value();
463       aSt = GetPointState( aP );
464       bIsToBreak=aSC.AppendState(aSt);
465       if (bIsToBreak) {
466         break;
467       }
468     }
469     //
470     aSt=aSC.State();
471     //
472     bIsConformState=GEOMAlgo_SurfaceTools::IsConformState(aSt, myState);
473     if (myShapeType==TopAbs_FACE) {
474       if (bIsConformState) {
475         myMSS.Add(aF, aSt);
476       }
477     }
478     else if (bIsConformState || aSt==TopAbs_ON) {
479       myMSS.Add(aF, aSt);
480     }
481   }//  for (i=1; i<=aNb; ++i) next face
482 }
483 //=======================================================================
484 //function : ProcessSolids
485 //purpose  :
486 //=======================================================================
487 void GEOMAlgo_FinderShapeOn1::ProcessSolids()
488 {
489   myErrorStatus=0;
490   //
491   Standard_Boolean bIsConformState;
492   Standard_Integer i, aNbS, j, aNbF;
493   TopTools_IndexedMapOfShape aM, aMF;
494   TopAbs_State aSt;
495   //
496   TopExp::MapShapes(myShape, TopAbs_SOLID, aM);
497   aNbS=aM.Extent();
498   for (i=1; i<=aNbS; ++i) {
499     GEOMAlgo_StateCollector aSC;
500     //
501     const TopoDS_Shape& aSd=aM(i);
502     aMF.Clear();
503     TopExp::MapShapes(aSd, TopAbs_FACE, aMF);
504     aNbF=aMF.Extent();
505     for (j=1; j<=aNbF; ++j) {
506       const TopoDS_Shape& aF=aMF(j);
507       bIsConformState=myMSS.Contains(aF);
508       if (!bIsConformState) {
509         break;// face has non-conformed state
510       }
511       else {
512         aSt=myMSS.FindFromKey(aF);
513         aSC.AppendState(aSt);
514       }
515     }
516     //
517     if (!bIsConformState) {
518       continue; // face has non-conformed state,skip solid
519     }
520     //
521     aSt=aSC.State();
522     //
523     bIsConformState=GEOMAlgo_SurfaceTools::IsConformState(aSt, myState);
524     if (bIsConformState) {
525       myMSS.Add(aSd, aSt);
526     }
527   }
528 }
529 //
530 //=======================================================================
531 //function : InnerPoints
532 //purpose  :
533 //=======================================================================
534 void GEOMAlgo_FinderShapeOn1::InnerPoints(const TopoDS_Face& aF,
535                                           GEOMAlgo_ListOfPnt& aLP)
536 {
537   myErrorStatus=0;
538   //
539   Standard_Integer j, j1, j2, k, n[4], aNbLinks, aNx, aNb, iCnt;//, aNbMax, *pIds;
540   TopLoc_Location aLoc;
541   Handle(Poly_Triangulation) aTRF;
542   TColStd_MapOfInteger aMBN;
543   GEOMAlgo_DataMapOfPassKeyInteger aMPKI;
544   GEOMAlgo_DataMapIteratorOfDataMapOfPassKeyInteger aIt;
545   gp_Pnt aP, aP1, aP2;
546   //
547   aLP.Clear();
548   //
549   aTRF=BRep_Tool::Triangulation(aF, aLoc);
550   if (aTRF.IsNull()) {
551     if (!GEOMAlgo_FinderShapeOn::BuildTriangulation(aF)) {
552       myWarningStatus=20; // no triangulation found
553       return;
554     }
555     aTRF=BRep_Tool::Triangulation(aF, aLoc);
556   }
557   //
558   const gp_Trsf& aTrsf=aLoc.Transformation();
559   const Poly_Array1OfTriangle& aTrs=aTRF->Triangles();
560   const TColgp_Array1OfPnt& aNodes=aTRF->Nodes();
561   //
562   // map link/nbtriangles
563   j1=aTrs.Lower();
564   j2=aTrs.Upper();
565   for (j=j1; j<=j2; ++j) {
566     const Poly_Triangle& aTr=aTrs(j);
567     aTr.Get(n[0], n[1], n[2]);
568     n[3]=n[0];
569     for (k=0; k<3; ++k) {
570       GEOMAlgo_PassKey aPK;
571       //
572       aPK.SetIds(n[k], n[k+1]);
573       if (aMPKI.IsBound(aPK)) {
574         Standard_Integer& iCntX=aMPKI.ChangeFind(aPK);
575         ++iCntX;
576       }
577       else {
578         aMPKI.Bind(aPK, 1);
579       }
580     }
581   }
582   //
583   // boundary nodes aMBN
584   aNbLinks=aMPKI.Extent();
585   aIt.Initialize(aMPKI);
586   for (; aIt.More(); aIt.Next()) {
587     iCnt=aIt.Value();
588     if (iCnt==1) {
589       const GEOMAlgo_PassKey& aPK=aIt.Key();
590       //
591       aNx=(Standard_Integer)aPK.Id(1);
592       aMBN.Add(aNx);
593       aNx=(Standard_Integer)aPK.Id(2);
594       aMBN.Add(aNx);
595     }
596   }
597   //
598   // inner nodes=all_nodes - boundary_nodes
599   j1=aNodes.Lower();
600   j2=aNodes.Upper();
601   for (j=j1; j<=j2; ++j) {
602     if (!aMBN.Contains(j)) {
603       aP=aNodes(j).Transformed(aTrsf);
604       aLP.Append(aP);
605     }
606   }
607   //
608   aNb=aLP.Extent();
609   //
610   if (!aNb && myNbPntsMin) {
611     // try to fill it yourself
612     Standard_Boolean bIsDone;
613     Standard_Integer aN1, aN2;
614     Handle(Geom_Surface) aS;
615     GeomAdaptor_Surface aGAS;
616     GeomAbs_SurfaceType aType;
617     //
618     aS=BRep_Tool::Surface(aF);
619     aGAS.Load(aS);
620     aType=aGAS.GetType();
621     if (aType==GeomAbs_Plane || aType==GeomAbs_Cylinder) {
622       // inner links
623       aNbLinks=aMPKI.Extent();
624       aIt.Initialize(aMPKI);
625       for (; aIt.More(); aIt.Next()) {
626         iCnt=aIt.Value();
627         if (iCnt>1) {
628           // take the first having occured inner link
629           // and discretize it
630           const GEOMAlgo_PassKey& aPK=aIt.Key();
631           //
632           aN1=(Standard_Integer)aPK.Id(1);
633           aN2=(Standard_Integer)aPK.Id(2);
634           //
635           aP1=aNodes(aN1).Transformed(aTrsf);
636           aP2=aNodes(aN2).Transformed(aTrsf);
637           //
638           if (aType==GeomAbs_Cylinder) {
639             Standard_Real aTolSM;
640             gp_Cylinder aCyl;
641             //
642             aTolSM=1.523e-6;//~1.-cos(0.1 deg)
643             aCyl=aGAS.Cylinder();
644             if (!GEOMAlgo_SurfaceTools::IsCoaxial(aP1, aP2, aCyl, aTolSM)) {
645               continue;
646             }
647           }
648           //
649           BRepLib_MakeEdge aBME(aP1, aP2);
650           bIsDone=aBME.IsDone();
651           if (!bIsDone) {
652             myErrorStatus=30; //can not obtain the line fron the link
653             return;
654           }
655           //
656           const TopoDS_Shape& aSx=aBME.Shape();
657           const TopoDS_Edge& aE=TopoDS::Edge(aSx);
658           //
659           InnerPoints(aE, myNbPntsMin, aLP);
660           break;
661         }// if (iCnt>1)
662       }// for (; aIt.More(); aIt.Next())
663     }// if (aType==GeomAbs_Plane || aType==GeomAbs_Cylinder)
664   }// if (!aNb && myNbPntsMin) {
665 }
666 //modified by NIZNHY-PKV Thu Jan 26 09:56:20 2012f
667 //=======================================================================
668 //function : InnerPoints
669 //purpose  :
670 //=======================================================================
671 void GEOMAlgo_FinderShapeOn1::InnerPoints(const TopoDS_Edge& aE,
672                                           GEOMAlgo_ListOfPnt& aLP)
673 {
674   Standard_Integer aNbPntsMin;
675   //
676   myErrorStatus=0;
677   aNbPntsMin=21;
678   //
679   aLP.Clear();
680   InnerPoints(aE, aNbPntsMin, aLP);
681 }
682 //modified by NIZNHY-PKV Thu Jan 26 09:56:32 2012t
683 //=======================================================================
684 //function : InnerPoints
685 //purpose  :
686 //=======================================================================
687 void GEOMAlgo_FinderShapeOn1::InnerPoints(const TopoDS_Edge& aE,
688                                           const Standard_Integer aNbPntsMin,
689                                           GEOMAlgo_ListOfPnt& aLP)
690 {
691   Standard_Boolean bInf1, bInf2;
692   Standard_Integer j, aNbT;
693   Standard_Real dT, aT, aT1, aT2;
694   gp_Pnt aP;
695   Handle(Geom_Curve) aC3D;
696   //
697   aC3D=BRep_Tool::Curve(aE, aT1, aT2);
698   if (aC3D.IsNull()) {
699     return;
700   }
701   //
702   bInf1=Precision::IsNegativeInfinite(aT1);
703   bInf2=Precision::IsPositiveInfinite(aT2);
704   if (bInf1 || bInf2) {
705     return;
706   }
707   //
708   //modified by NIZNHY-PKV Thu Jan 26 09:51:20 2012f
709   /*
710   aNbT=myNbPntsMin+1;
711   dT=(aT2-aT1)/aNbT;
712   for (j=1; j<=aNbPntsMin; ++j) {
713     aT=aT1+j*dT;
714     aC3D->D0(aT, aP);
715     aLP.Append(aP);
716   }
717   */
718   aNbT=aNbPntsMin+1;
719   dT=(aT2-aT1)/aNbT;
720   for (j=1; j<aNbT; ++j) {
721     aT=aT1+j*dT;
722     aC3D->D0(aT, aP);
723     aLP.Append(aP);
724   }
725   //modified by NIZNHY-PKV Thu Jan 26 09:51:24 2012t
726 }
727
728 //=======================================================================
729 //function : CheckData
730 //purpose  :
731 //=======================================================================
732 void GEOMAlgo_FinderShapeOn1::CheckData()
733 {
734   myErrorStatus=0;
735   //
736   if(mySurface.IsNull()) {
737     myErrorStatus=10; // mySurface=NULL
738     return;
739   }
740   //
741   if (myShape.IsNull()) {
742     myErrorStatus=11; // myShape=NULL
743     return;
744   }
745   //
746   if (!(myShapeType==TopAbs_VERTEX ||
747         myShapeType==TopAbs_EDGE ||
748         myShapeType==TopAbs_FACE ||
749         myShapeType==TopAbs_SOLID)) {
750     myErrorStatus=12; // unallowed subshape type
751     return;
752   }
753   //
754   if (myState==GEOMAlgo_ST_UNKNOWN ||
755       myState==GEOMAlgo_ST_INOUT) {
756     myErrorStatus=13; // unallowed state type
757     return;
758   }
759   //
760   GeomAbs_SurfaceType aType;
761   //
762   myGAS.Load(mySurface);
763   aType=myGAS.GetType();
764   if (!(aType==GeomAbs_Plane ||
765         aType==GeomAbs_Cylinder ||
766         aType==GeomAbs_Sphere)) {
767     myErrorStatus=14; // unallowed surface type
768   }
769 }
770
771 //=======================================================================
772 //function : GetPointState
773 //purpose  :
774 //=======================================================================
775
776 TopAbs_State GEOMAlgo_FinderShapeOn1::GetPointState(const gp_Pnt& aP)
777 {
778   TopAbs_State aSt;
779   GEOMAlgo_SurfaceTools::GetState(aP, myGAS, myTolerance, aSt);
780   return aSt;
781 }
782
783
784 //
785 // myErrorStatus :
786 //
787 // 10 -mySurface=NULL
788 // 11 -myShape=NULL
789 // 12 -unallowed type of subshapes
790 // 13 -unallowed state
791 // 14 -unallowed surface type
792 // 15 -unallowed surface type
793 // 20- no triangulation found
794 // 30- can not obtain the line from the link
795
796 //modified by NIZNHY-PKV Thu Jan 26 10:01:14 2012f
797 /*
798 //=======================================================================
799 //function : InnerPoints
800 //purpose  :
801 //=======================================================================
802 void GEOMAlgo_FinderShapeOn1::InnerPoints(const TopoDS_Edge& aE,
803                                           GEOMAlgo_ListOfPnt& aLP)
804 {
805   myErrorStatus=0;
806   //
807   Standard_Integer j, aNbNodes, aIndex, aNb;
808   Handle(Poly_PolygonOnTriangulation) aPTE;
809   Handle(Poly_Triangulation) aTRE;
810   TopLoc_Location aLoc;
811   gp_Pnt aP;
812   //
813   aLP.Clear();
814   BRep_Tool::PolygonOnTriangulation(aE, aPTE, aTRE, aLoc);
815   if (aTRE.IsNull() || aPTE.IsNull()) {
816     Handle(Poly_Polygon3D) aPE = BRep_Tool::Polygon3D(aE, aLoc);
817     if (aPE.IsNull()) {
818       if (!GEOMAlgo_FinderShapeOn::BuildTriangulation(aE)) {
819         myErrorStatus=20; // no triangulation found
820         return;
821       }
822       aPE = BRep_Tool::Polygon3D(aE, aLoc);
823     }
824     const gp_Trsf& aTrsf=aLoc.Transformation();
825     const TColgp_Array1OfPnt& aNodes=aPE->Nodes();
826     //
827     aNbNodes=aPE->NbNodes();
828     Standard_Integer low = aNodes.Lower(), up = aNodes.Upper();
829     for (j=low+1; j<up; ++j) {
830       aP=aNodes(j).Transformed(aTrsf);
831       aLP.Append(aP);
832     }
833   }
834   else {
835     const gp_Trsf& aTrsf=aLoc.Transformation();
836     const TColgp_Array1OfPnt& aNodes=aTRE->Nodes();
837     //
838     aNbNodes=aPTE->NbNodes();
839     const TColStd_Array1OfInteger& aInds=aPTE->Nodes();
840     for (j=2; j<aNbNodes; ++j) {
841       aIndex=aInds(j);
842       aP=aNodes(aIndex).Transformed(aTrsf);
843       aLP.Append(aP);
844     }
845   }
846   //
847   aNb=aLP.Extent();
848   if (!aNb && myNbPntsMin) {
849     // try to fill it yourself
850     InnerPoints(aE, myNbPntsMin, aLP);
851     aNb=aLP.Extent();
852   }
853 }
854 */
855 //modified by NIZNHY-PKV Thu Jan 26 10:01:17 2012t