Salome HOME
49204ee9032404f5fc90e19786ca27e61c2f2617
[modules/shaper.git] / src / GeomAlgoAPI / GeomAlgoAPI_Prism.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        GeomAlgoAPI_Prism.cpp
4 // Created:     5 May 2015
5 // Author:      Dmitry Bobylev
6
7 #include "GeomAlgoAPI_Prism.h"
8
9 #include <GeomAPI_Face.h>
10 #include <GeomAPI_Pln.h>
11 #include <GeomAPI_Pnt.h>
12 #include <GeomAPI_ShapeExplorer.h>
13 #include <GeomAPI_XYZ.h>
14 #include <GeomAlgoAPI_DFLoader.h>
15 #include <GeomAlgoAPI_FaceBuilder.h>
16 #include <GeomAlgoAPI_ShapeTools.h>
17
18 #include <Bnd_Box.hxx>
19 #include <BRep_Builder.hxx>
20 #include <BRepAlgoAPI_Cut.hxx>
21 #include <BRepBndLib.hxx>
22 #include <BRepBuilderAPI_FindPlane.hxx>
23 #include <BRepBuilderAPI_Transform.hxx>
24 #include <BRepTools.hxx>
25 #include <Geom_Curve.hxx>
26 #include <Geom2d_Curve.hxx>
27 #include <BRepLib_CheckCurveOnSurface.hxx>
28 #include <BRepPrimAPI_MakePrism.hxx>
29 #include <Geom_Plane.hxx>
30 #include <Geom_RectangularTrimmedSurface.hxx>
31 #include <gp_Pln.hxx>
32 #include <IntAna_IntConicQuad.hxx>
33 #include <IntAna_Quadric.hxx>
34 #include <IntTools_Context.hxx>
35 #include <TopExp_Explorer.hxx>
36 #include <TopoDS.hxx>
37 #include <TopoDS_Edge.hxx>
38 #include <TopoDS_Shell.hxx>
39 #include <TopoDS_Solid.hxx>
40 #include <TopTools_ListIteratorOfListOfShape.hxx>
41
42
43 static void storeGenerationHistory(GeomAlgoAPI_Prism* thePrismAlgo,
44                                    const TopoDS_Shape& theBase,
45                                    const TopAbs_ShapeEnum theType,
46                                    BRepPrimAPI_MakePrism* thePrismBuilder);
47
48 static void storeGenerationHistory(GeomAlgoAPI_Prism* thePrismAlgo,
49                                    const TopoDS_Shape& theResult,
50                                    const TopAbs_ShapeEnum theType,
51                                    const TopoDS_Face& theToFace,
52                                    const TopoDS_Face& theFromFace);
53
54
55 //==================================================================================================
56 GeomAlgoAPI_Prism::GeomAlgoAPI_Prism(const GeomShapePtr theBaseShape,
57                                      const double       theToSize,
58                                      const double       theFromSize)
59 {
60   build(theBaseShape, std::shared_ptr<GeomAPI_Dir>(), GeomShapePtr(), theToSize, GeomShapePtr(), theFromSize);
61 }
62
63 //==================================================================================================
64 GeomAlgoAPI_Prism::GeomAlgoAPI_Prism(const GeomShapePtr                 theBaseShape,
65                                      const std::shared_ptr<GeomAPI_Dir> theDirection,
66                                      const double                       theToSize,
67                                      const double                       theFromSize)
68 {
69   build(theBaseShape, theDirection, GeomShapePtr(), theToSize, GeomShapePtr(), theFromSize);
70 }
71
72 //==================================================================================================
73 GeomAlgoAPI_Prism::GeomAlgoAPI_Prism(const GeomShapePtr theBaseShape,
74                                      const GeomShapePtr theToShape,
75                                      const double       theToSize,
76                                      const GeomShapePtr theFromShape,
77                                      const double       theFromSize)
78 {
79   build(theBaseShape, std::shared_ptr<GeomAPI_Dir>(), theToShape, theToSize, theFromShape, theFromSize);
80 }
81
82 //==================================================================================================
83 GeomAlgoAPI_Prism::GeomAlgoAPI_Prism(const GeomShapePtr                 theBaseShape,
84                                      const std::shared_ptr<GeomAPI_Dir> theDirection,
85                                      const GeomShapePtr                 theToShape,
86                                      const double                       theToSize,
87                                      const GeomShapePtr                 theFromShape,
88                                      const double                       theFromSize)
89 {
90   build(theBaseShape, theDirection, theToShape, theToSize, theFromShape, theFromSize);
91 }
92
93 //==================================================================================================
94 void GeomAlgoAPI_Prism::build(const GeomShapePtr&                theBaseShape,
95                               const std::shared_ptr<GeomAPI_Dir> theDirection,
96                               const GeomShapePtr&                theToShape,
97                               const double                       theToSize,
98                               const GeomShapePtr&                theFromShape,
99                               const double                       theFromSize)
100 {
101   if(!theBaseShape.get() ||
102     (((!theFromShape.get() && !theToShape.get()) || (theFromShape.get() && theToShape.get() && theFromShape->isEqual(theToShape)))
103     && (theFromSize == -theToSize))) {
104     return;
105   }
106
107   // Getting base shape.
108   const TopoDS_Shape& aBaseShape = theBaseShape->impl<TopoDS_Shape>();
109   TopAbs_ShapeEnum aShapeTypeToExp;
110   switch(aBaseShape.ShapeType()) {
111     case TopAbs_VERTEX:
112       aShapeTypeToExp = TopAbs_VERTEX;
113       break;
114     case TopAbs_EDGE:
115     case TopAbs_WIRE:
116       aShapeTypeToExp = TopAbs_EDGE;
117       break;
118     case TopAbs_FACE:
119     case TopAbs_SHELL:
120       aShapeTypeToExp = TopAbs_FACE;
121       break;
122     case TopAbs_COMPOUND:
123       aShapeTypeToExp = TopAbs_COMPOUND;
124       break;
125     default:
126       return;
127   }
128
129   // Getting direction.
130   gp_Vec aDirVec;
131   std::shared_ptr<GeomAPI_Pnt> aBaseLoc;
132   std::shared_ptr<GeomAPI_Dir> aBaseDir;
133   GeomShapePtr aBasePlane;
134   const bool isBoundingShapesSet = theFromShape.get() || theToShape.get();
135   BRepBuilderAPI_FindPlane aFindPlane(aBaseShape);
136   if(theDirection.get()) {
137     aBaseDir = theDirection;
138     aDirVec = theDirection->impl<gp_Dir>();
139   } else {
140     if(aBaseShape.ShapeType() == TopAbs_VERTEX
141         || aBaseShape.ShapeType() == TopAbs_EDGE
142         || aFindPlane.Found() == Standard_False) {
143       return;
144     }
145
146     Handle(Geom_Plane) aPlane;
147     if(aBaseShape.ShapeType() == TopAbs_FACE || aBaseShape.ShapeType() == TopAbs_SHELL) {
148       TopExp_Explorer anExp(aBaseShape, TopAbs_FACE);
149       const TopoDS_Shape& aFace = anExp.Current();
150       Handle(Geom_Surface) aSurface = BRep_Tool::Surface(TopoDS::Face(aFace));
151       if(aSurface->DynamicType() == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) {
152         Handle(Geom_RectangularTrimmedSurface) aTrimSurface =
153           Handle(Geom_RectangularTrimmedSurface)::DownCast(aSurface);
154         aSurface = aTrimSurface->BasisSurface();
155       }
156       if(aSurface->DynamicType() != STANDARD_TYPE(Geom_Plane)) {
157         return;
158       }
159       aPlane = Handle(Geom_Plane)::DownCast(aSurface);
160     } else {
161       aPlane = aFindPlane.Plane();
162     }
163     gp_Pnt aLoc = aPlane->Axis().Location();
164     aDirVec = aPlane->Axis().Direction();
165     aBaseLoc.reset(new GeomAPI_Pnt(aLoc.X(), aLoc.Y(), aLoc.Z()));
166     aBaseDir.reset(new GeomAPI_Dir(aDirVec.X(), aDirVec.Y(), aDirVec.Z()));
167   }
168   if(!aBaseLoc.get()) {
169     gp_Pnt aLoc;
170     gp_XYZ aDirXYZ = aDirVec.XYZ();
171     Standard_Real aMinParam = Precision::Infinite();
172     for(TopExp_Explorer anExp(aBaseShape, TopAbs_VERTEX); anExp.More(); anExp.Next()) {
173       const TopoDS_Shape& aVertex = anExp.Current();
174       gp_Pnt aPnt = BRep_Tool::Pnt(TopoDS::Vertex(aVertex));
175       double aParam = aDirXYZ.Dot(aPnt.XYZ());
176       if(aParam < aMinParam) {
177         aMinParam = aParam;
178         aLoc = aPnt;
179       }
180     }
181     aBaseLoc.reset(new GeomAPI_Pnt(aLoc.X(), aLoc.Y(), aLoc.Z()));
182   }
183   aBasePlane = GeomAlgoAPI_FaceBuilder::planarFace(aBaseLoc, aBaseDir);
184
185   TopoDS_Shape aResult;
186   if(!isBoundingShapesSet) {
187     // Moving base shape.
188     gp_Trsf aTrsf;
189     aTrsf.SetTranslation(aDirVec * -theFromSize);
190     BRepBuilderAPI_Transform* aTransformBuilder = new BRepBuilderAPI_Transform(aBaseShape, aTrsf);
191     if(!aTransformBuilder) {
192       return;
193     }
194     this->appendAlgo(std::shared_ptr<GeomAlgoAPI_MakeShape>(new GeomAlgoAPI_MakeShape(aTransformBuilder)));
195     if(!aTransformBuilder->IsDone()) {
196       return;
197     }
198     TopoDS_Shape aMovedBase = aTransformBuilder->Shape();
199
200     // Making prism.
201     BRepPrimAPI_MakePrism* aPrismBuilder = new BRepPrimAPI_MakePrism(aMovedBase, aDirVec * (theFromSize + theToSize));
202     if(!aPrismBuilder) {
203       return;
204     }
205     this->appendAlgo(std::shared_ptr<GeomAlgoAPI_MakeShape>(new GeomAlgoAPI_MakeShape(aPrismBuilder)));
206     if(!aPrismBuilder->IsDone()) {
207       return;
208     }
209     aResult = aPrismBuilder->Shape();
210
211     // Setting naming.
212     if(aShapeTypeToExp == TopAbs_COMPOUND) {
213       storeGenerationHistory(this, aMovedBase, TopAbs_EDGE, aPrismBuilder);
214       storeGenerationHistory(this, aMovedBase, TopAbs_FACE, aPrismBuilder);
215     } else {
216       storeGenerationHistory(this, aMovedBase, aShapeTypeToExp, aPrismBuilder);
217     }
218   } else {
219     GeomShapePtr aBoundingFromShape = theFromShape ? theFromShape : aBasePlane;
220     GeomShapePtr aBoundingToShape   = theToShape   ? theToShape   : aBasePlane;
221
222     // Moving prism bounding faces according to "from" and "to" sizes.
223     std::shared_ptr<GeomAPI_Pln> aFromPln = GeomAPI_Face(aBoundingFromShape).getPlane();
224     std::shared_ptr<GeomAPI_Pnt> aFromLoc = aFromPln->location();
225     std::shared_ptr<GeomAPI_Dir> aFromDir = aFromPln->direction();
226
227     std::shared_ptr<GeomAPI_Pln> aToPln = GeomAPI_Face(aBoundingToShape).getPlane();
228     std::shared_ptr<GeomAPI_Pnt> aToLoc = aToPln->location();
229     std::shared_ptr<GeomAPI_Dir> aToDir = aToPln->direction();
230
231     bool aSign = aFromLoc->xyz()->dot(aBaseDir->xyz()) > aToLoc->xyz()->dot(aBaseDir->xyz());
232
233     std::shared_ptr<GeomAPI_Pnt> aFromPnt(new GeomAPI_Pnt(aFromLoc->xyz()->added(aBaseDir->xyz()->multiplied(
234                                                           aSign ? theFromSize : -theFromSize))));
235     aBoundingFromShape = GeomAlgoAPI_FaceBuilder::planarFace(aFromPnt, aFromDir);
236
237     std::shared_ptr<GeomAPI_Pnt> aToPnt(new GeomAPI_Pnt(aToLoc->xyz()->added(aBaseDir->xyz()->multiplied(
238                                                         aSign ? -theToSize : theToSize))));
239     aBoundingToShape = GeomAlgoAPI_FaceBuilder::planarFace(aToPnt, aToDir);
240
241     // Getting bounding box for base shape.
242     Bnd_Box aBndBox;
243     BRepBndLib::Add(aBaseShape, aBndBox);
244     Standard_Real aXArr[2] = {aBndBox.CornerMin().X(), aBndBox.CornerMax().X()};
245     Standard_Real aYArr[2] = {aBndBox.CornerMin().Y(), aBndBox.CornerMax().Y()};
246     Standard_Real aZArr[2] = {aBndBox.CornerMin().Z(), aBndBox.CornerMax().Z()};
247     gp_Pnt aPoints[8];
248     int aNum = 0;
249     for(int i = 0; i < 2; i++) {
250       for(int j = 0; j < 2; j++) {
251         for(int k = 0; k < 2; k++) {
252           aPoints[aNum] = gp_Pnt(aXArr[i], aYArr[j], aZArr[k]);
253           aNum++;
254         }
255       }
256     }
257
258     // Project points to bounding planes. Search max distance to them.
259     IntAna_Quadric aBndToQuadric(gp_Pln(aToPnt->impl<gp_Pnt>(), aToDir->impl<gp_Dir>()));
260     IntAna_Quadric aBndFromQuadric(gp_Pln(aFromPnt->impl<gp_Pnt>(), aFromDir->impl<gp_Dir>()));
261     Standard_Real aMaxToDist = 0, aMaxFromDist = 0;
262     for(int i = 0; i < 8; i++) {
263       gp_Lin aLine(aPoints[i], aDirVec);
264       IntAna_IntConicQuad aToIntAna(aLine, aBndToQuadric);
265       IntAna_IntConicQuad aFromIntAna(aLine, aBndFromQuadric);
266       if(aToIntAna.NbPoints() == 0 || aFromIntAna.NbPoints() == 0) {
267         return;
268       }
269       const gp_Pnt& aPntOnToFace = aToIntAna.Point(1);
270       const gp_Pnt& aPntOnFromFace = aFromIntAna.Point(1);
271       if(aPoints[i].Distance(aPntOnToFace) > aMaxToDist) {
272         aMaxToDist = aPoints[i].Distance(aPntOnToFace);
273       }
274       if(aPoints[i].Distance(aPntOnFromFace) > aMaxFromDist) {
275         aMaxFromDist = aPoints[i].Distance(aPntOnFromFace);
276       }
277     }
278
279     // We added 1 just to be sure that prism is long enough for boolean operation.
280     double aPrismLength = aMaxToDist + aMaxFromDist + 1;
281
282     // Moving base shape.
283     gp_Trsf aTrsf;
284     aTrsf.SetTranslation(aDirVec * -aPrismLength);
285     BRepBuilderAPI_Transform* aTransformBuilder = new BRepBuilderAPI_Transform(aBaseShape, aTrsf);
286     if(!aTransformBuilder) {
287       return;
288     }
289     this->appendAlgo(std::shared_ptr<GeomAlgoAPI_MakeShape>(new GeomAlgoAPI_MakeShape(aTransformBuilder)));
290     if(!aTransformBuilder->IsDone()) {
291       return;
292     }
293     TopoDS_Shape aMovedBase = aTransformBuilder->Shape();
294
295     // Making prism.
296     BRepPrimAPI_MakePrism* aPrismBuilder = new BRepPrimAPI_MakePrism(aMovedBase, aDirVec * 2 * aPrismLength);
297     if(!aPrismBuilder) {
298       return;
299     }
300     this->appendAlgo(std::shared_ptr<GeomAlgoAPI_MakeShape>(new GeomAlgoAPI_MakeShape(aPrismBuilder)));
301     if(!aPrismBuilder->IsDone()) {
302       return;
303     }
304     aResult = aPrismBuilder->Shape();
305
306     // Orienting bounding planes.
307     std::shared_ptr<GeomAPI_Pnt> aCentreOfMass = GeomAlgoAPI_ShapeTools::centreOfMass(theBaseShape);
308     const gp_Pnt& aCentrePnt = aCentreOfMass->impl<gp_Pnt>();
309     gp_Lin aLine(aCentrePnt, aDirVec);
310     IntAna_IntConicQuad aToIntAna(aLine, aBndToQuadric);
311     IntAna_IntConicQuad aFromIntAna(aLine, aBndFromQuadric);
312     Standard_Real aToParameter = aToIntAna.ParamOnConic(1);
313     Standard_Real aFromParameter = aFromIntAna.ParamOnConic(1);
314     if(aToParameter > aFromParameter) {
315       gp_Vec aVec = aToDir->impl<gp_Dir>();
316       if((aVec * aDirVec) > 0) {
317         aToDir->setImpl(new gp_Dir(aVec.Reversed()));
318         aBoundingToShape = GeomAlgoAPI_FaceBuilder::planarFace(aToPnt, aToDir);
319       }
320       aVec = aFromDir->impl<gp_Dir>();
321       if((aVec * aDirVec) < 0) {
322         aFromDir->setImpl(new gp_Dir(aVec.Reversed()));
323         aBoundingFromShape = GeomAlgoAPI_FaceBuilder::planarFace(aFromPnt, aFromDir);
324       }
325     } else {
326       gp_Vec aVec = aToDir->impl<gp_Dir>();
327       if((aVec * aDirVec) < 0) {
328         aToDir->setImpl(new gp_Dir(aVec.Reversed()));
329         aBoundingToShape = GeomAlgoAPI_FaceBuilder::planarFace(aToPnt, aToDir);
330       }
331       aVec = aFromDir->impl<gp_Dir>();
332       if((aVec * aDirVec) > 0) {
333         aFromDir->setImpl(new gp_Dir(aVec.Reversed()));
334         aBoundingFromShape = GeomAlgoAPI_FaceBuilder::planarFace(aFromPnt, aFromDir);
335       }
336     }
337
338     // Making solids from bounding planes.
339     TopoDS_Shell aToShell, aFromShell;
340     TopoDS_Solid aToSolid, aFromSolid;
341     const TopoDS_Shape& aToShape   = aBoundingToShape->impl<TopoDS_Shape>();
342     const TopoDS_Shape& aFromShape = aBoundingFromShape->impl<TopoDS_Shape>();
343     TopoDS_Face aToFace   = TopoDS::Face(aToShape);
344     TopoDS_Face aFromFace = TopoDS::Face(aFromShape);
345     BRep_Builder aBoundingBuilder;
346     aBoundingBuilder.MakeShell(aToShell);
347     aBoundingBuilder.Add(aToShell, aToShape);
348     aBoundingBuilder.MakeShell(aFromShell);
349     aBoundingBuilder.Add(aFromShell, aFromShape);
350     aBoundingBuilder.MakeSolid(aToSolid);
351     aBoundingBuilder.Add(aToSolid, aToShell);
352     aBoundingBuilder.MakeSolid(aFromSolid);
353     aBoundingBuilder.Add(aFromSolid, aFromShell);
354
355     // Cutting with to plane.
356     BRepAlgoAPI_Cut* aToCutBuilder = new BRepAlgoAPI_Cut(aResult, aToSolid);
357     aToCutBuilder->Build();
358     if(!aToCutBuilder->IsDone()) {
359       return;
360     }
361     this->appendAlgo(std::shared_ptr<GeomAlgoAPI_MakeShape>(new GeomAlgoAPI_MakeShape(aToCutBuilder)));
362     aResult = aToCutBuilder->Shape();
363     if(aResult.ShapeType() == TopAbs_COMPOUND) {
364       aResult = GeomAlgoAPI_DFLoader::refineResult(aResult);
365     }
366     if(aShapeTypeToExp == TopAbs_FACE || aShapeTypeToExp == TopAbs_COMPOUND) {
367       const TopTools_ListOfShape& aToShapes = aToCutBuilder->Modified(aToShape);
368       for(TopTools_ListIteratorOfListOfShape anIt(aToShapes); anIt.More(); anIt.Next()) {
369         GeomShapePtr aGeomSh(new GeomAPI_Shape());
370         aGeomSh->setImpl(new TopoDS_Shape(anIt.Value()));
371         this->addToShape(aGeomSh);
372       }
373     }
374
375     // Cutting with from plane.
376     BRepAlgoAPI_Cut* aFromCutBuilder = new BRepAlgoAPI_Cut(aResult, aFromSolid);
377     aFromCutBuilder->Build();
378     if(!aFromCutBuilder->IsDone()) {
379       return;
380     }
381     this->appendAlgo(std::shared_ptr<GeomAlgoAPI_MakeShape>(new GeomAlgoAPI_MakeShape(aFromCutBuilder)));
382     aResult = aFromCutBuilder->Shape();
383     TopoDS_Iterator aCheckIt(aResult);
384     if(!aCheckIt.More()) {
385       return;
386     }
387     if(aResult.ShapeType() == TopAbs_COMPOUND) {
388       aResult = GeomAlgoAPI_DFLoader::refineResult(aResult);
389     }
390     if(aShapeTypeToExp == TopAbs_FACE || aShapeTypeToExp == TopAbs_COMPOUND) {
391       const TopTools_ListOfShape& aFromShapes = aFromCutBuilder->Modified(aFromShape);
392       for(TopTools_ListIteratorOfListOfShape anIt(aFromShapes); anIt.More(); anIt.Next()) {
393         GeomShapePtr aGeomSh(new GeomAPI_Shape());
394         aGeomSh->setImpl(new TopoDS_Shape(anIt.Value()));
395         this->addFromShape(aGeomSh);
396       }
397     }
398
399     // Naming for extrusion from vertex, edge.
400     if(aShapeTypeToExp == TopAbs_COMPOUND) {
401       storeGenerationHistory(this, aResult, TopAbs_EDGE, aToFace, aFromFace);
402       storeGenerationHistory(this, aResult, TopAbs_FACE, aToFace, aFromFace);
403     } else {
404       storeGenerationHistory(this, aResult, aShapeTypeToExp, aToFace, aFromFace);
405     }
406
407     if(aResult.ShapeType() == TopAbs_COMPOUND) {
408       std::shared_ptr<GeomAPI_Shape> aGeomShape(new GeomAPI_Shape);
409       aGeomShape->setImpl(new TopoDS_Shape(aResult));
410       ListOfShape aCompSolids, aFreeSolids;
411       aGeomShape = GeomAlgoAPI_ShapeTools::combineShapes(aGeomShape,
412                                                          GeomAPI_Shape::COMPSOLID,
413                                                          aCompSolids,
414                                                          aFreeSolids);
415       aResult = aGeomShape->impl<TopoDS_Shape>();
416     }
417   }
418
419   // Setting result.
420   if(aResult.IsNull()) {
421     return;
422   }
423   aResult = GeomAlgoAPI_DFLoader::refineResult(aResult);
424   GeomShapePtr aGeomSh(new GeomAPI_Shape());
425   aGeomSh->setImpl(new TopoDS_Shape(aResult));
426   this->setShape(aGeomSh);
427   this->setDone(true);
428 }
429
430 // Auxilary functions:
431 //==================================================================================================
432 void storeGenerationHistory(GeomAlgoAPI_Prism* thePrismAlgo,
433                             const TopoDS_Shape& theBase,
434                             const TopAbs_ShapeEnum theType,
435                             BRepPrimAPI_MakePrism* thePrismBuilder)
436 {
437   for(TopExp_Explorer anExp(theBase, theType); anExp.More(); anExp.Next()) {
438     const TopoDS_Shape& aShape = anExp.Current();
439     GeomShapePtr aFromShape(new GeomAPI_Shape), aToShape(new GeomAPI_Shape);
440     aFromShape->setImpl(new TopoDS_Shape(thePrismBuilder->FirstShape(aShape)));
441     aToShape->setImpl(new TopoDS_Shape(thePrismBuilder->LastShape(aShape)));
442     thePrismAlgo->addFromShape(aFromShape);
443     thePrismAlgo->addToShape(aToShape);
444   }
445 }
446
447 //==================================================================================================
448 void storeGenerationHistory(GeomAlgoAPI_Prism* thePrismAlgo,
449                             const TopoDS_Shape& theResult,
450                             const TopAbs_ShapeEnum theType,
451                             const TopoDS_Face& theToFace,
452                             const TopoDS_Face& theFromFace)
453 {
454   for(TopExp_Explorer anExp(theResult, theType); anExp.More(); anExp.Next()) {
455     const TopoDS_Shape& aShape = anExp.Current();
456     GeomShapePtr aGeomSh(new GeomAPI_Shape());
457     if(theType == TopAbs_VERTEX) {
458       gp_Pnt aPnt = BRep_Tool::Pnt(TopoDS::Vertex(aShape));
459       IntTools_Context anIntTools;
460       if(anIntTools.IsValidPointForFace(aPnt, theToFace, Precision::Confusion()) == Standard_True) {
461         aGeomSh->setImpl(new TopoDS_Shape(aShape));
462         thePrismAlgo->addToShape(aGeomSh);
463       }
464       if(anIntTools.IsValidPointForFace(aPnt, theFromFace, Precision::Confusion()) == Standard_True) {
465         aGeomSh->setImpl(new TopoDS_Shape(aShape));
466         thePrismAlgo->addFromShape(aGeomSh);
467       }
468     } else if(theType == TopAbs_EDGE) {
469       TopoDS_Edge anEdge = TopoDS::Edge(aShape);
470       BRepLib_CheckCurveOnSurface anEdgeCheck(anEdge, theToFace);
471       anEdgeCheck.Perform();
472       if(anEdgeCheck.MaxDistance() < Precision::Confusion()) {
473         aGeomSh->setImpl(new TopoDS_Shape(aShape));
474         thePrismAlgo->addToShape(aGeomSh);
475       }
476       anEdgeCheck.Init(anEdge, theFromFace);
477       anEdgeCheck.Perform();
478       if(anEdgeCheck.MaxDistance() < Precision::Confusion()) {
479         aGeomSh->setImpl(new TopoDS_Shape(aShape));
480         thePrismAlgo->addFromShape(aGeomSh);
481       }
482     } else {
483       break;
484     }
485   }
486 }