Salome HOME
Synchronize adm files
[modules/geom.git] / src / GEOMAlgo / GEOMAlgo_FinderShapeOn1.cxx
1 // Copyright (C) 2007-2014  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   aNb=aM.Extent();
313   for (i=1; i<=aNb; ++i) {
314     GEOMAlgo_ListOfPnt aLP;
315     GEOMAlgo_StateCollector aSC;
316     //
317     const TopoDS_Edge& aE=TopoDS::Edge(aM(i));
318     //
319     aExp.Init(aE, TopAbs_VERTEX);
320     for (; aExp.More(); aExp.Next()) {
321       const TopoDS_Shape& aV=aExp.Current();
322       //
323       bIsConformState=myMSS.Contains(aV);
324       if (!bIsConformState) {
325         break;// vertex has non-conformed state
326       }
327       else {
328         aSt=myMSS.FindFromKey(aV);
329         aSC.AppendState(aSt);
330       }
331     }
332     //
333     if (!bIsConformState) {
334       continue; // vertex has non-conformed state,skip edge
335     }
336     //
337     if (BRep_Tool::Degenerated(aE)) {
338       myMSS.Add(aE, aSt);
339       continue;
340     }
341     //
342     if (myState==GEOMAlgo_ST_ON && aType1==GeomAbs_Sphere) {
343       Standard_Real aT1, aT2;
344       Handle(Geom_Curve) aC;
345       GeomAdaptor_Curve aGAC;
346       GeomAbs_CurveType aType2;
347       //
348       aC=BRep_Tool::Curve(aE, aT1, aT2);
349       aGAC.Load(aC);
350       //
351       aType2=aGAC.GetType();
352       if (aType2==GeomAbs_Line) {
353         continue;
354       }
355     }
356     //
357     InnerPoints(aE, aLP);
358     if (myErrorStatus) {
359       return;
360     }
361     //
362     bIsConformState=Standard_True;
363     aIt.Initialize(aLP);
364     for (iCnt=0; aIt.More(); aIt.Next(), ++iCnt) {
365       if (myNbPntsMax) {
366         if (iCnt > myNbPntsMax) {
367           break;
368         }
369       }
370       //
371       const gp_Pnt& aP=aIt.Value();
372       aSt = GetPointState( aP );
373       bIsToBreak=aSC.AppendState(aSt);
374       if (bIsToBreak) {
375         break;
376       }
377     }
378     //
379     aSt=aSC.State();
380     //
381     bIsConformState=GEOMAlgo_SurfaceTools::IsConformState(aSt, myState);
382     if (myShapeType==TopAbs_EDGE) {
383       if (bIsConformState) {
384         myMSS.Add(aE, aSt);
385       }
386     }
387     else if (bIsConformState || aSt==TopAbs_ON) {
388       myMSS.Add(aE, aSt);
389     }
390   } //  for (i=1; i<=aNb; ++i) next edge
391 }
392 //=======================================================================
393 //function : ProcessFaces
394 //purpose  :
395 //=======================================================================
396 void GEOMAlgo_FinderShapeOn1::ProcessFaces()
397 {
398   myErrorStatus=0;
399   //
400   Standard_Boolean bIsConformState, bIsToBreak;
401   Standard_Integer i, aNbF, iCnt;
402   TopAbs_State aSt;
403   TopTools_IndexedMapOfShape aM;
404   TopExp_Explorer aExp;
405   GEOMAlgo_ListIteratorOfListOfPnt aIt;
406   GeomAbs_SurfaceType aType1, aType2;
407   //
408   aType1=myGAS.GetType();
409   //
410   TopExp::MapShapes(myShape, TopAbs_FACE, aM);
411   aNbF=aM.Extent();
412   for (i=1; i<=aNbF; ++i) {
413     GEOMAlgo_StateCollector aSC;
414     GEOMAlgo_ListOfPnt aLP;
415     //
416     const TopoDS_Face& aF=TopoDS::Face(aM(i));
417     //
418     if (myState==GEOMAlgo_ST_ON) {
419       Handle(Geom_Surface) aS;
420       GeomAdaptor_Surface aGAS;
421       //
422       aS=BRep_Tool::Surface(aF);
423       aGAS.Load(aS);
424       aType2=aGAS.GetType();
425       if (aType2!=aType1) {
426         continue;
427       }
428     }
429     //
430     aExp.Init(aF, TopAbs_EDGE);
431     for (; aExp.More(); aExp.Next()) {
432       const TopoDS_Shape& aE=aExp.Current();
433       bIsConformState=myMSS.Contains(aE);
434       if (!bIsConformState) {
435         break;// edge has non-conformed state
436       }
437       else {
438         aSt=myMSS.FindFromKey(aE);
439         aSC.AppendState(aSt);
440       }
441     }
442     //
443     if (!bIsConformState) {
444       continue; // edge has non-conformed state,skip face
445     }
446     //
447     InnerPoints(aF, aLP);
448     if (myErrorStatus) {
449       return;
450     }
451     //
452     bIsConformState=Standard_True;
453     aIt.Initialize(aLP);
454     for (iCnt=0; aIt.More(); aIt.Next(), ++iCnt) {
455       if (myNbPntsMax) {
456         if (iCnt > myNbPntsMax) {
457           break;
458         }
459       }
460       //
461       const gp_Pnt& aP=aIt.Value();
462       aSt = GetPointState( aP );
463       bIsToBreak=aSC.AppendState(aSt);
464       if (bIsToBreak) {
465         break;
466       }
467     }
468     //
469     aSt=aSC.State();
470     //
471     bIsConformState=GEOMAlgo_SurfaceTools::IsConformState(aSt, myState);
472     if (myShapeType==TopAbs_FACE) {
473       if (bIsConformState) {
474         myMSS.Add(aF, aSt);
475       }
476     }
477     else if (bIsConformState || aSt==TopAbs_ON) {
478       myMSS.Add(aF, aSt);
479     }
480   }//  for (i=1; i<=aNb; ++i) next face
481 }
482 //=======================================================================
483 //function : ProcessSolids
484 //purpose  :
485 //=======================================================================
486 void GEOMAlgo_FinderShapeOn1::ProcessSolids()
487 {
488   myErrorStatus=0;
489   //
490   Standard_Boolean bIsConformState;
491   Standard_Integer i, aNbS, j, aNbF;
492   TopTools_IndexedMapOfShape aM, aMF;
493   TopAbs_State aSt;
494   //
495   TopExp::MapShapes(myShape, TopAbs_SOLID, aM);
496   aNbS=aM.Extent();
497   for (i=1; i<=aNbS; ++i) {
498     GEOMAlgo_StateCollector aSC;
499     //
500     const TopoDS_Shape& aSd=aM(i);
501     aMF.Clear();
502     TopExp::MapShapes(aSd, TopAbs_FACE, aMF);
503     aNbF=aMF.Extent();
504     for (j=1; j<=aNbF; ++j) {
505       const TopoDS_Shape& aF=aMF(j);
506       bIsConformState=myMSS.Contains(aF);
507       if (!bIsConformState) {
508         break;// face has non-conformed state
509       }
510       else {
511         aSt=myMSS.FindFromKey(aF);
512         aSC.AppendState(aSt);
513       }
514     }
515     //
516     if (!bIsConformState) {
517       continue; // face has non-conformed state,skip solid
518     }
519     //
520     aSt=aSC.State();
521     //
522     bIsConformState=GEOMAlgo_SurfaceTools::IsConformState(aSt, myState);
523     if (bIsConformState) {
524       myMSS.Add(aSd, aSt);
525     }
526   }
527 }
528 //
529 //=======================================================================
530 //function : InnerPoints
531 //purpose  :
532 //=======================================================================
533 void GEOMAlgo_FinderShapeOn1::InnerPoints(const TopoDS_Face& aF,
534                                           GEOMAlgo_ListOfPnt& aLP)
535 {
536   myErrorStatus=0;
537   //
538   Standard_Integer j, j1, j2, k, n[4], aNbLinks, aNx, aNb, iCnt;//, aNbMax, *pIds;
539   TopLoc_Location aLoc;
540   Handle(Poly_Triangulation) aTRF;
541   TColStd_MapOfInteger aMBN;
542   GEOMAlgo_DataMapOfPassKeyInteger aMPKI;
543   GEOMAlgo_DataMapIteratorOfDataMapOfPassKeyInteger aIt;
544   gp_Pnt aP, aP1, aP2;
545   //
546   aLP.Clear();
547   //
548   aTRF=BRep_Tool::Triangulation(aF, aLoc);
549   if (aTRF.IsNull()) {
550     if (!GEOMAlgo_AlgoTools::BuildTriangulation(aF)) {
551       myWarningStatus=20; // no triangulation found
552       return;
553     }
554     aTRF=BRep_Tool::Triangulation(aF, aLoc);
555   }
556   //
557   const gp_Trsf& aTrsf=aLoc.Transformation();
558   const Poly_Array1OfTriangle& aTrs=aTRF->Triangles();
559   const TColgp_Array1OfPnt& aNodes=aTRF->Nodes();
560   //
561   // map link/nbtriangles
562   j1=aTrs.Lower();
563   j2=aTrs.Upper();
564   for (j=j1; j<=j2; ++j) {
565     const Poly_Triangle& aTr=aTrs(j);
566     aTr.Get(n[0], n[1], n[2]);
567     n[3]=n[0];
568     for (k=0; k<3; ++k) {
569       GEOMAlgo_PassKey aPK;
570       //
571       aPK.SetIds(n[k], n[k+1]);
572       if (aMPKI.IsBound(aPK)) {
573         Standard_Integer& iCntX=aMPKI.ChangeFind(aPK);
574         ++iCntX;
575       }
576       else {
577         aMPKI.Bind(aPK, 1);
578       }
579     }
580   }
581   //
582   // boundary nodes aMBN
583   aNbLinks=aMPKI.Extent();
584   aIt.Initialize(aMPKI);
585   for (; aIt.More(); aIt.Next()) {
586     iCnt=aIt.Value();
587     if (iCnt==1) {
588       const GEOMAlgo_PassKey& aPK=aIt.Key();
589       //
590       aNx=(Standard_Integer)aPK.Id(1);
591       aMBN.Add(aNx);
592       aNx=(Standard_Integer)aPK.Id(2);
593       aMBN.Add(aNx);
594     }
595   }
596   //
597   // inner nodes=all_nodes - boundary_nodes
598   j1=aNodes.Lower();
599   j2=aNodes.Upper();
600   for (j=j1; j<=j2; ++j) {
601     if (!aMBN.Contains(j)) {
602       aP=aNodes(j).Transformed(aTrsf);
603       aLP.Append(aP);
604     }
605   }
606   //
607   aNb=aLP.Extent();
608   //
609   if (!aNb && myNbPntsMin) {
610     // try to fill it yourself
611     Standard_Boolean bIsDone;
612     Standard_Integer aN1, aN2;
613     Handle(Geom_Surface) aS;
614     GeomAdaptor_Surface aGAS;
615     GeomAbs_SurfaceType aType;
616     //
617     aS=BRep_Tool::Surface(aF);
618     aGAS.Load(aS);
619     aType=aGAS.GetType();
620     if (aType==GeomAbs_Plane || aType==GeomAbs_Cylinder) {
621       // inner links
622       aNbLinks=aMPKI.Extent();
623       aIt.Initialize(aMPKI);
624       for (; aIt.More(); aIt.Next()) {
625         iCnt=aIt.Value();
626         if (iCnt>1) {
627           // take the first having occured inner link
628           // and discretize it
629           const GEOMAlgo_PassKey& aPK=aIt.Key();
630           //
631           aN1=(Standard_Integer)aPK.Id(1);
632           aN2=(Standard_Integer)aPK.Id(2);
633           //
634           aP1=aNodes(aN1).Transformed(aTrsf);
635           aP2=aNodes(aN2).Transformed(aTrsf);
636           //
637           if (aType==GeomAbs_Cylinder) {
638             gp_Cylinder aCyl;
639             //
640             aCyl=aGAS.Cylinder();
641             if (!GEOMAlgo_SurfaceTools::IsCoaxial(aP1, aP2, aCyl, myTolerance)) {
642               continue;
643             }
644           }
645           //
646           BRepLib_MakeEdge aBME(aP1, aP2);
647           bIsDone=aBME.IsDone();
648           if (!bIsDone) {
649             myErrorStatus=30; //can not obtain the line fron the link
650             return;
651           }
652           //
653           const TopoDS_Shape& aSx=aBME.Shape();
654           const TopoDS_Edge& aE=TopoDS::Edge(aSx);
655           //
656           InnerPoints(aE, myNbPntsMin, aLP);
657           break;
658         }// if (iCnt>1)
659       }// for (; aIt.More(); aIt.Next())
660     }// if (aType==GeomAbs_Plane || aType==GeomAbs_Cylinder)
661   }// if (!aNb && myNbPntsMin) {
662 }
663 //modified by NIZNHY-PKV Thu Jan 26 09:56:20 2012f
664 //=======================================================================
665 //function : InnerPoints
666 //purpose  :
667 //=======================================================================
668 void GEOMAlgo_FinderShapeOn1::InnerPoints(const TopoDS_Edge& aE,
669                                           GEOMAlgo_ListOfPnt& aLP)
670 {
671   Standard_Integer aNbPntsMin;
672   //
673   myErrorStatus=0;
674   aNbPntsMin=21;
675   //
676   aLP.Clear();
677   InnerPoints(aE, aNbPntsMin, aLP);
678 }
679 //modified by NIZNHY-PKV Thu Jan 26 09:56:32 2012t
680 //=======================================================================
681 //function : InnerPoints
682 //purpose  :
683 //=======================================================================
684 void GEOMAlgo_FinderShapeOn1::InnerPoints(const TopoDS_Edge& aE,
685                                           const Standard_Integer aNbPntsMin,
686                                           GEOMAlgo_ListOfPnt& aLP)
687 {
688   Standard_Boolean bInf1, bInf2;
689   Standard_Integer j, aNbT;
690   Standard_Real dT, aT, aT1, aT2;
691   gp_Pnt aP;
692   Handle(Geom_Curve) aC3D;
693   //
694   aC3D=BRep_Tool::Curve(aE, aT1, aT2);
695   if (aC3D.IsNull()) {
696     return;
697   }
698   //
699   bInf1=Precision::IsNegativeInfinite(aT1);
700   bInf2=Precision::IsPositiveInfinite(aT2);
701   if (bInf1 || bInf2) {
702     return;
703   }
704   //
705   //modified by NIZNHY-PKV Thu Jan 26 09:51:20 2012f
706   /*
707   aNbT=myNbPntsMin+1;
708   dT=(aT2-aT1)/aNbT;
709   for (j=1; j<=aNbPntsMin; ++j) {
710     aT=aT1+j*dT;
711     aC3D->D0(aT, aP);
712     aLP.Append(aP);
713   }
714   */
715   aNbT=aNbPntsMin+1;
716   dT=(aT2-aT1)/aNbT;
717   for (j=1; j<aNbT; ++j) {
718     aT=aT1+j*dT;
719     aC3D->D0(aT, aP);
720     aLP.Append(aP);
721   }
722   //modified by NIZNHY-PKV Thu Jan 26 09:51:24 2012t
723 }
724
725 //=======================================================================
726 //function : CheckData
727 //purpose  :
728 //=======================================================================
729 void GEOMAlgo_FinderShapeOn1::CheckData()
730 {
731   myErrorStatus=0;
732   //
733   if(mySurface.IsNull()) {
734     myErrorStatus=10; // mySurface=NULL
735     return;
736   }
737   //
738   if (myShape.IsNull()) {
739     myErrorStatus=11; // myShape=NULL
740     return;
741   }
742   //
743   if (!(myShapeType==TopAbs_VERTEX ||
744         myShapeType==TopAbs_EDGE ||
745         myShapeType==TopAbs_FACE ||
746         myShapeType==TopAbs_SOLID)) {
747     myErrorStatus=12; // unallowed subshape type
748     return;
749   }
750   //
751   if (myState==GEOMAlgo_ST_UNKNOWN ||
752       myState==GEOMAlgo_ST_INOUT) {
753     myErrorStatus=13; // unallowed state type
754     return;
755   }
756   //
757   GeomAbs_SurfaceType aType;
758   //
759   myGAS.Load(mySurface);
760   aType=myGAS.GetType();
761   if (!(aType==GeomAbs_Plane ||
762         aType==GeomAbs_Cylinder ||
763         aType==GeomAbs_Sphere)) {
764     myErrorStatus=14; // unallowed surface type
765   }
766 }
767
768 //=======================================================================
769 //function : GetPointState
770 //purpose  :
771 //=======================================================================
772
773 TopAbs_State GEOMAlgo_FinderShapeOn1::GetPointState(const gp_Pnt& aP)
774 {
775   TopAbs_State aSt;
776   GEOMAlgo_SurfaceTools::GetState(aP, myGAS, myTolerance, aSt);
777   return aSt;
778 }
779
780
781 //
782 // myErrorStatus :
783 //
784 // 10 -mySurface=NULL
785 // 11 -myShape=NULL
786 // 12 -unallowed type of subshapes
787 // 13 -unallowed state
788 // 14 -unallowed surface type
789 // 15 -unallowed surface type
790 // 20- no triangulation found
791 // 30- can not obtain the line from the link
792