1 // Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #include <GEOMAlgo_ShapeInfoFiller.hxx>
21 #include <Precision.hxx>
22 #include <TColStd_MapOfInteger.hxx>
23 #include <TColStd_IndexedMapOfInteger.hxx>
35 #include <GeomAdaptor_Surface.hxx>
38 #include <TopoDS_Vertex.hxx>
39 #include <TopoDS_Edge.hxx>
40 #include <TopoDS_Wire.hxx>
41 #include <TopoDS_Face.hxx>
42 #include <TopoDS_Iterator.hxx>
44 #include <BRep_Tool.hxx>
47 #include <TopExp_Explorer.hxx>
49 #include <TopTools_MapOfShape.hxx>
50 #include <TopTools_IndexedMapOfShape.hxx>
52 #include <BRepTools_WireExplorer.hxx>
53 #include <BRepGProp.hxx>
54 #include <GProp_GProps.hxx>
56 #include <GEOMAlgo_ShapeInfo.hxx>
59 Standard_Boolean IsEqual(const gp_Sphere& aSp1,
60 const gp_Sphere& aSp2,
61 const Standard_Real aTolDst);
63 //=======================================================================
64 //function : FillDetails
66 //=======================================================================
67 void GEOMAlgo_ShapeInfoFiller::FillDetails(const TopoDS_Solid& aSd)
69 Standard_Boolean bIsStepSphere;
70 Standard_Integer i, aNbF, aNbCyl, aNbCon, aNbPgn, aNbRct, aNbCrc, aNbX;
71 TopoDS_Shape aFCyl, aFCon;
72 TopTools_IndexedMapOfShape aMF;
73 GEOMAlgo_KindOfName aKNF;
75 GEOMAlgo_ShapeInfo& aInfo=myMapInfo.ChangeFromKey(aSd);
76 aInfo.SetKindOfName(GEOMAlgo_KN_UNKNOWN);
78 TopExp::MapShapes(aSd, TopAbs_FACE, aMF);
86 const TopoDS_Shape& aF=aMF(1);
87 GEOMAlgo_ShapeInfo& aInfoF=myMapInfo.ChangeFromKey(aF);
88 aKNF=aInfoF.KindOfName(); // mb: sphere, torus
89 if (aKNF==GEOMAlgo_KN_SPHERE ||
90 aKNF==GEOMAlgo_KN_TORUS) {
91 aInfo.SetKindOfName(aKNF);
92 aInfo.SetLocation(aInfoF.Location());
93 aInfo.SetPosition(aInfoF.Position());
94 aInfo.SetRadius1(aInfoF.Radius1());
95 if(aKNF==GEOMAlgo_KN_TORUS) {
96 aInfo.SetRadius2(aInfoF.Radius2());
101 //modified by NIZNHY-PKV Tue Jul 03 13:23:55 2012f
103 // specific solid that should be treated as a sphere
104 bIsStepSphere=TreatStepSphere(aSd);
109 //modified by NIZNHY-PKV Tue Jul 03 13:23:57 2012t
116 for (i=1; i<=aNbF; ++i) {
117 const TopoDS_Shape& aF=aMF(i);
118 GEOMAlgo_ShapeInfo& aInfoF=myMapInfo.ChangeFromKey(aF);
119 aKNF=aInfoF.KindOfName();
120 if (aKNF==GEOMAlgo_KN_CYLINDER) {
124 else if (aKNF==GEOMAlgo_KN_CONE) {
128 else if (aKNF==GEOMAlgo_KN_DISKCIRCLE) {
131 else if (aKNF==GEOMAlgo_KN_POLYGON ||
132 aKNF==GEOMAlgo_KN_TRIANGLE ||
133 aKNF==GEOMAlgo_KN_QUADRANGLE) {
136 else if (aKNF==GEOMAlgo_KN_RECTANGLE) {
143 if (aNbCyl==1 && aNbCrc==2 && aNbX==aNbF) {
144 // cylinder (as they understand it)
145 GEOMAlgo_ShapeInfo& aInfoF=myMapInfo.ChangeFromKey(aFCyl);
146 aKNF=aInfoF.KindOfName();
147 aInfo.SetKindOfName(aKNF);
148 aInfo.SetLocation(aInfoF.Location());
149 aInfo.SetPosition(aInfoF.Position());
150 aInfo.SetRadius1(aInfoF.Radius1());
151 aInfo.SetHeight(aInfoF.Height());
156 if (aNbCon==1 && (aNbCrc==1 || aNbCrc==2) && aNbX==aNbF) {
158 GEOMAlgo_ShapeInfo& aInfoF=myMapInfo.ChangeFromKey(aFCon);
159 aKNF=aInfoF.KindOfName();
160 aInfo.SetKindOfName(aKNF);
161 aInfo.SetLocation(aInfoF.Location());
162 aInfo.SetPosition(aInfoF.Position());
163 aInfo.SetRadius1(aInfoF.Radius1());
164 aInfo.SetRadius2(aInfoF.Radius2());
165 aInfo.SetHeight(aInfoF.Height());
170 return;// -> GEOMAlgo_KN_UNKNOWN
173 aInfo.SetKindOfName(GEOMAlgo_KN_POLYHEDRON);
177 if (aNbPgn!=aNbRct) {
178 aInfo.SetKindOfName(GEOMAlgo_KN_POLYHEDRON);
181 //===================================================
184 Standard_Integer j, aNbFi, aNbV, iMax, iMin, iMid;
185 Standard_Real aDot, aLength, aWidth, aHeight, aDist[3];
186 Standard_Real aDistMin, aDistMax;
190 TColStd_IndexedMapOfInteger aMp;
191 TopTools_IndexedMapOfShape aMV, aMFi;
194 TopExp::MapShapes(aSd, TopAbs_VERTEX, aMV);
200 aXYZc.SetCoord(0.,0.,0.);
201 for (i=1; i<=aNbV; ++i) {
202 const TopoDS_Vertex& aVi=TopoDS::Vertex(aMV(i));
203 aPi=BRep_Tool::Pnt(aVi);
204 const gp_XYZ& aXYZ=aPi.XYZ();
212 for (i=1; i<=aNbF; ++i) {
213 if (aMp.Contains(i)) {
217 const TopoDS_Shape& aFi=aMF(i);
218 const GEOMAlgo_ShapeInfo& aIFi=myMapInfo.FindFromKey(aFi);
219 const gp_Dir& aDNi=aIFi.Position().Direction();
221 for (j=i+1; j<=aNbF; ++j) {
222 if (aMp.Contains(j)) {
226 const TopoDS_Shape& aFj=aMF(j);
227 const GEOMAlgo_ShapeInfo& aIFj=myMapInfo.FindFromKey(aFj);
228 const gp_Dir& aDNj=aIFj.Position().Direction();
231 //modified by NIZNHY-PKV Tue Jul 03 10:01:56 2012f
235 //modified by NIZNHY-PKV Tue Jul 03 10:01:52 2012t
236 if (fabs(1.-aDot)<0.0001) {
252 for (i=0; i<aNbFi; ++i) {
253 const TopoDS_Shape& aFi=aMFi(i+1);
254 const GEOMAlgo_ShapeInfo& aIFi=myMapInfo.FindFromKey(aFi);
256 aDist[i]=aPc.Distance(aPi);
257 if (aDist[i]>aDistMax) {
261 if (aDist[i]<aDistMin) {
265 gp_Vec aVi(aPc, aPi);
276 aLength=2.*aDist[iMax];
277 aWidth=2.*aDist[iMid];
278 aHeight=2.*aDist[iMin];
280 gp_Ax2 aAx2(aPc, aDir[iMin], aDir[iMax]);
283 aInfo.SetKindOfName(GEOMAlgo_KN_BOX);
284 aInfo.SetLocation(aPc);
285 aInfo.SetLength(aLength);
286 aInfo.SetWidth(aWidth);
287 aInfo.SetHeight(aHeight);
288 aInfo.SetPosition(aAx3);
290 //=======================================================================
291 //function : FillDetails
293 //=======================================================================
294 void GEOMAlgo_ShapeInfoFiller::FillDetails(const TopoDS_Face& aF,
297 Standard_Integer aNbV, aNbE, i, j;
298 Standard_Real aDot, aD0, aD1, aLength, aWidth;
300 gp_Pnt aPx[4], aP, aPc;
302 TopExp_Explorer aExp;
307 TopTools_IndexedMapOfShape aMV;
308 BRepTools_WireExplorer aWExp;
309 GEOMAlgo_KindOfName aKN, aKNE;
310 GEOMAlgo_KindOfShape aKS;
312 GEOMAlgo_ShapeInfo& aInfo=myMapInfo.ChangeFromKey(aF);
313 aKN=GEOMAlgo_KN_UNKNOWN;
314 aInfo.SetKindOfName(GEOMAlgo_KN_UNKNOWN);
316 aKS=aInfo.KindOfShape();
317 if (aKS!=GEOMAlgo_KS_PLANE) {
321 if (aInfo.KindOfBounds()==GEOMAlgo_KB_INFINITE) {
322 aInfo.SetKindOfName(GEOMAlgo_KN_PLANE);
326 aNbV=aInfo.NbSubShapes(TopAbs_VERTEX);
327 aNbE=aInfo.NbSubShapes(TopAbs_EDGE);
329 // 1. may be it is circle/ellipse
330 if (aNbV==1 && aNbE==1) {
331 aExp.Init(aF, TopAbs_EDGE);
332 for (; aExp.More(); aExp.Next()) {
337 const GEOMAlgo_ShapeInfo& aInfoE=myMapInfo.FindFromKey(aE);
338 aKNE=aInfoE.KindOfName();
339 if (aKNE==GEOMAlgo_KN_CIRCLE) {
340 aKN=GEOMAlgo_KN_DISKCIRCLE;
341 aInfo.SetKindOfName(aKN);
342 aInfo.SetRadius1(aInfoE.Radius1());
343 aInfo.SetLocation(aInfoE.Location());
344 aInfo.SetPosition(aInfoE.Position());
346 if (aKNE==GEOMAlgo_KN_ELLIPSE) {
347 aKN=GEOMAlgo_KN_DISKELLIPSE;
348 aInfo.SetKindOfName(aKN);
349 aInfo.SetRadius1(aInfoE.Radius1());
350 aInfo.SetRadius2(aInfoE.Radius2());
351 aInfo.SetLocation(aInfoE.Location());
352 aInfo.SetPosition(aInfoE.Position());
356 // 2. may be it is rectangle
358 aExp.Init(aF, TopAbs_EDGE);
359 for (; aExp.More(); aExp.Next()) {
361 const GEOMAlgo_ShapeInfo& aInfoE=myMapInfo.FindFromKey(aE);
362 aKNE=aInfoE.KindOfName();
363 if (aKNE!=GEOMAlgo_KN_SEGMENT) {
368 aInfo.SetKindOfName(GEOMAlgo_KN_POLYGON);
370 if (aNbV==3 && aNbE==3) {
371 aInfo.SetKindOfName(GEOMAlgo_KN_TRIANGLE);
373 aXYZc.SetCoord(0.,0.,0.);
374 TopExp::MapShapes(aF, TopAbs_VERTEX, aMV);
375 for (i=1; i<=aNbV; ++i) {
376 const TopoDS_Vertex& aV=TopoDS::Vertex(aMV(i));
377 aP=BRep_Tool::Pnt(aV);
378 const gp_XYZ& aXYZ=aP.XYZ();
385 gp_Vec aVX(aPc, aPx[0]);
387 aDX.SetXYZ(aVX.XYZ());
388 const gp_Dir& aDZ=aPln.Axis().Direction();
390 gp_Ax2 aAx2(aPc, aDZ, aDX);
393 aInfo.SetLocation(aPc);
394 aInfo.SetPosition(aAx3);
399 if (!(aNbV==4 && aNbE==4)) {
403 // aNbV==4 && aNbE==4 and all edges are segments
405 for (; aIt.More(); aIt.Next()){
406 aW=TopoDS::Wire(aIt.Value());
411 for (i=0; aWExp.More(); aWExp.Next(), ++i) {
413 const GEOMAlgo_ShapeInfo& aInfoEx=myMapInfo.FindFromKey(aEx);
414 aDx[i]=aInfoEx.Direction();
415 aPx[i]=aInfoEx.Location();
418 for (i=0; i<4; ++i) {
421 if (fabs (aDot) > myTolerance) {
422 aInfo.SetKindOfName(GEOMAlgo_KN_QUADRANGLE);
428 aInfo.SetKindOfName(GEOMAlgo_KN_RECTANGLE);
430 // shift location to the center and calc. sizes
431 aXYZc.SetCoord(0.,0.,0.);
432 TopExp::MapShapes(aF, TopAbs_VERTEX, aMV);
433 for (i=1; i<=aNbV; ++i) {
434 const TopoDS_Vertex& aV=TopoDS::Vertex(aMV(i));
435 aP=BRep_Tool::Pnt(aV);
436 const gp_XYZ& aXYZ=aP.XYZ();
440 // Location : aPc in center of rectangle
441 // Position : 0z is plane normal
442 // 0x is along length
447 gp_Lin aL0(aPx[0], aDx[0]);
448 gp_Lin aL1(aPx[1], aDx[1]);
450 aD0=aL0.Distance(aPc);
451 aD1=aL1.Distance(aPc);
465 aInfo.SetLocation(aPc);
466 aInfo.SetLength(aLength);
467 aInfo.SetWidth(aWidth);
469 const gp_Dir& aDZ=aPln.Axis().Direction();
470 gp_Ax2 aAx2(aPc, aDZ, aDX);
472 aInfo.SetPosition(aAx3);
477 //=======================================================================
478 //function : FillDetails
480 //=======================================================================
481 void GEOMAlgo_ShapeInfoFiller::FillDetails(const TopoDS_Face& aF,
484 Standard_Integer aNbV, aNbE, aNbSE, aNbDE;
486 TopExp_Explorer aExp;
487 TopTools_MapOfShape aM;
488 GEOMAlgo_KindOfShape aKS, aKSE;
490 GEOMAlgo_ShapeInfo& aInfo=myMapInfo.ChangeFromKey(aF);
491 aInfo.SetKindOfName(GEOMAlgo_KN_UNKNOWN);
493 aKS=aInfo.KindOfShape();
494 if (aKS!=GEOMAlgo_KS_SPHERE) {
498 aNbV=aInfo.NbSubShapes(TopAbs_VERTEX);
499 aNbE=aInfo.NbSubShapes(TopAbs_EDGE);
500 if (!(aNbV==2 && aNbE==3)) {
506 aExp.Init(aF, TopAbs_EDGE);
507 for (; aExp.More(); aExp.Next()) {
508 aE=TopoDS::Edge(aExp.Current());
510 const GEOMAlgo_ShapeInfo& aInfoE=myMapInfo.FindFromKey(aE);
511 aKSE=aInfoE.KindOfShape();
513 if (BRep_Tool::IsClosed(aE, aF)) {
516 else if (aKSE==GEOMAlgo_KS_DEGENERATED) {
522 if (!(aNbSE==1 && aNbDE==2)) {
525 aInfo.SetKindOfName(GEOMAlgo_KN_SPHERE);
527 //=======================================================================
528 //function : FillDetails
530 //=======================================================================
531 void GEOMAlgo_ShapeInfoFiller::FillDetails(const TopoDS_Face& aF,
532 const gp_Cone& )//aCone)
534 Standard_Integer aNbV, aNbE, aNbCE, aNbSE, aNbDE, i;
535 Standard_Real aR[3], aHeight;
536 gp_Pnt aPC[3], aPD, aPc, aPX[3];
540 TopExp_Explorer aExp;
541 TopTools_MapOfShape aM;
542 GEOMAlgo_KindOfShape aKS, aKSE;
543 GEOMAlgo_KindOfName aKN, aKNE;
544 GEOMAlgo_KindOfClosed aKCE;
546 GEOMAlgo_ShapeInfo& aInfo=myMapInfo.ChangeFromKey(aF);
547 aKN=GEOMAlgo_KN_UNKNOWN;
548 aInfo.SetKindOfName(aKN);
550 aKS=aInfo.KindOfShape();
551 if (aKS!=GEOMAlgo_KS_CONE) {
555 if (aInfo.KindOfBounds()==GEOMAlgo_KB_INFINITE) {
559 aNbV=aInfo.NbSubShapes(TopAbs_VERTEX);
560 aNbE=aInfo.NbSubShapes(TopAbs_EDGE);
561 if (!(aNbV==2 && aNbE==3)) {
569 aExp.Init(aF, TopAbs_EDGE);
570 for (; aExp.More(); aExp.Next()) {
571 aE=TopoDS::Edge(aExp.Current());
573 const GEOMAlgo_ShapeInfo& aInfoE=myMapInfo.FindFromKey(aE);
574 aKNE=aInfoE.KindOfName();
575 aKCE=aInfoE.KindOfClosed();
576 aKSE=aInfoE.KindOfShape();
577 if (aKNE==GEOMAlgo_KN_CIRCLE && aKCE==GEOMAlgo_KC_CLOSED) {
578 aPC[i]=aInfoE.Location();
579 aR[i]=aInfoE.Radius1();
582 for (; aIt.More(); aIt.Next()) {
583 aVD=TopoDS::Vertex(aIt.Value());
586 aPX[i]=BRep_Tool::Pnt(aVD);
591 else if (aKNE==GEOMAlgo_KN_SEGMENT) {
592 if (BRep_Tool::IsClosed(aE, aF)) {
596 else if (aKSE==GEOMAlgo_KS_DEGENERATED) {
598 for (; aIt.More(); aIt.Next()) {
599 aVD=TopoDS::Vertex(aIt.Value());
603 aPD=BRep_Tool::Pnt(aVD);
610 if (!((aNbCE==2 || (aNbCE==1 && aNbDE==1)) && aNbSE==1)) {
619 aHeight=aPC[0].Distance(aPC[1]);
621 Standard_Real aRmin, aRmax;
628 gp_Vec aVz(aPC[0], aPC[1]);
629 gp_Vec aVx(aPC[0], aPX[0]);
632 gp_Ax2 aAx2(aPc, aDz, aDx);
639 gp_Vec aVz(aPC[1], aPC[0]);
640 gp_Vec aVx(aPC[1], aPX[1]);
643 gp_Ax2 aAx2(aPc, aDz, aDx);
647 gp_Ax3 aAx3(aAx2new);
648 aInfo.SetLocation(aPc);
649 aInfo.SetPosition(aAx3);
650 aInfo.SetRadius1(aRmax);
651 aInfo.SetRadius2(aRmin);
652 aInfo.SetHeight(aHeight);
654 aInfo.SetKindOfName(GEOMAlgo_KN_CONE);
656 //=======================================================================
657 //function : FillDetails
659 //=======================================================================
660 void GEOMAlgo_ShapeInfoFiller::FillDetails(const TopoDS_Face& aF,
661 const gp_Cylinder& aCyl)
663 Standard_Integer i, aNbV, aNbE, aNbCE, aNbSE;
664 Standard_Real aT0, aT1, aHeight;
667 TopExp_Explorer aExp;
668 TopTools_MapOfShape aM;
669 GEOMAlgo_KindOfShape aKS;
670 GEOMAlgo_KindOfName aKN, aKNE;
671 GEOMAlgo_KindOfClosed aKCE;
673 GEOMAlgo_ShapeInfo& aInfo=myMapInfo.ChangeFromKey(aF);
674 aKN=GEOMAlgo_KN_UNKNOWN;
675 aInfo.SetKindOfName(aKN);
677 aKS=aInfo.KindOfShape();
678 if (aKS!=GEOMAlgo_KS_CYLINDER) {
682 if (aInfo.KindOfBounds()==GEOMAlgo_KB_INFINITE) {
686 aNbV=aInfo.NbSubShapes(TopAbs_VERTEX);
687 aNbE=aInfo.NbSubShapes(TopAbs_EDGE);
688 if (!(aNbV==2 && aNbE==3)) {
695 aExp.Init(aF, TopAbs_EDGE);
696 for (; aExp.More(); aExp.Next()) {
697 aE=TopoDS::Edge(aExp.Current());
699 const GEOMAlgo_ShapeInfo& aInfoE=myMapInfo.FindFromKey(aE);
700 aKNE=aInfoE.KindOfName();
701 aKCE=aInfoE.KindOfClosed();
702 if (aKNE==GEOMAlgo_KN_CIRCLE && aKCE==GEOMAlgo_KC_CLOSED) {
703 aPC[aNbCE]=aInfoE.Location();
706 else if (aKNE==GEOMAlgo_KN_SEGMENT) {
707 if (BRep_Tool::IsClosed(aE, aF)) {
714 if (!(aNbCE==2 && aNbSE==1)) {
718 const gp_Ax1& aAx1=aCyl.Axis();
719 const gp_Dir& aDir=aAx1.Direction();
720 const gp_Pnt& aPLoc=aAx1.Location();
721 gp_Lin aLin(aPLoc, aDir);
723 aT0=ElCLib::Parameter(aLin, aPC[0]);
724 aT1=ElCLib::Parameter(aLin, aPC[1]);
730 aHeight=aPC[0].Distance(aPC[1]);
732 gp_Ax3 aAx3=aCyl.Position();
733 aAx3.SetLocation(aPc);
735 aInfo.SetKindOfName(GEOMAlgo_KN_CYLINDER);
736 aInfo.SetPosition(aAx3);
737 aInfo.SetLocation(aPc);
738 aInfo.SetHeight(aHeight);
741 //=======================================================================
742 //function : FillDetails
744 //=======================================================================
745 void GEOMAlgo_ShapeInfoFiller::FillDetails(const TopoDS_Face& aF,
748 Standard_Integer aNbV, aNbE, aNbSE;
750 TopExp_Explorer aExp;
751 TopTools_MapOfShape aM;
752 GEOMAlgo_KindOfShape aKS;
754 GEOMAlgo_ShapeInfo& aInfo=myMapInfo.ChangeFromKey(aF);
755 aInfo.SetKindOfName(GEOMAlgo_KN_UNKNOWN);
757 aKS=aInfo.KindOfShape();
758 if (aKS!=GEOMAlgo_KS_TORUS) {
762 aNbV=aInfo.NbSubShapes(TopAbs_VERTEX);
763 aNbE=aInfo.NbSubShapes(TopAbs_EDGE);
764 if (!(aNbV==1 && aNbE==2)) {
769 aExp.Init(aF, TopAbs_EDGE);
770 for (; aExp.More(); aExp.Next()) {
771 aE=TopoDS::Edge(aExp.Current());
773 if (BRep_Tool::IsClosed(aE, aF)) {
782 aInfo.SetKindOfName(GEOMAlgo_KN_TORUS);
784 //modified by NIZNHY-PKV Tue Jul 03 13:29:41 2012f
785 //=======================================================================
786 //function : TreatStepSphere
788 //=======================================================================
790 GEOMAlgo_ShapeInfoFiller::TreatStepSphere(const TopoDS_Solid& aSd)
792 Standard_Boolean bRet, bIsAllowedType, bOnlyClosed, bIsEqual;
794 Standard_Real aTolAng, aTolLin;
795 Standard_Real aVolume, aVolumeS, dV, aArea, aAreaS, dA;
796 gp_Sphere aSphere[2];
797 GeomAbs_SurfaceType aST;
798 Handle(Geom_Surface) aS;
799 GeomAdaptor_Surface aGAS;
800 TopExp_Explorer aExp;
803 aTolLin=Precision::Confusion();
804 aTolAng=Precision::Angular();
806 aExp.Init(aSd, TopAbs_FACE);
807 for (j=0; aExp.More(); aExp.Next(), ++j) {
808 const TopoDS_Face& aF=*((TopoDS_Face*)&aExp.Current());
809 aS=BRep_Tool::Surface(aF);
812 bIsAllowedType=GEOMAlgo_ShapeInfoFiller::IsAllowedType(aST);
813 if (!bIsAllowedType) {
817 if (aST!=GeomAbs_Sphere) {
821 aSphere[j]=aGAS.Sphere();
824 bIsEqual=IsEqual(aSphere[0], aSphere[1], aTolLin);
829 //--------------------------------
830 GProp_GProps aGProps;
832 bOnlyClosed=Standard_False;
834 aVolume=aSphere[0].Volume();
836 BRepGProp::VolumeProperties(aSd, aGProps, bOnlyClosed);
837 aVolumeS=aGProps.Mass();
842 dV=fabs(aVolumeS-aVolume);
846 //--------------------------------
847 aArea=aSphere[0].Area();
849 BRepGProp::SurfaceProperties(aSd, aGProps);
850 aAreaS=aGProps.Mass();
852 dA=fabs(aAreaS-aArea);
857 //--------------------------------
862 aP0=aSphere[0].Location();
863 aAx3=aSphere[0].Position();
864 aR1=aSphere[0].Radius();
866 GEOMAlgo_ShapeInfo& aInfo=myMapInfo.ChangeFromKey(aSd);
868 aInfo.SetKindOfName(GEOMAlgo_KN_SPHERE);
869 aInfo.SetLocation(aP0);
870 aInfo.SetPosition(aAx3);
871 aInfo.SetRadius1(aR1);
875 //=======================================================================
878 //=======================================================================
879 Standard_Boolean IsEqual(const gp_Sphere& aSp1,
880 const gp_Sphere& aSp2,
881 const Standard_Real aTolLin)
883 Standard_Boolean bRet;
884 Standard_Real aR1, aR2, aD2;
889 if (fabs(aR1-aR2)>aTolLin) {
893 const gp_Pnt& aPC1=aSp1.Position().Location();
894 const gp_Pnt& aPC2=aSp2.Position().Location();
896 aD2=aPC1.SquareDistance(aPC2);
897 bRet=(aD2<aTolLin*aTolLin);
901 //modified by NIZNHY-PKV Tue Jul 03 13:29:43 2012t