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