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