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