1 // Copyright (C) 2007-2015 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, or (at your option) any later version.
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
20 #include <GEOMAlgo_ShapeInfoFiller.hxx>
22 #include <Precision.hxx>
23 #include <TColStd_MapOfInteger.hxx>
24 #include <TColStd_IndexedMapOfInteger.hxx>
36 #include <GeomAdaptor_Surface.hxx>
39 #include <TopoDS_Vertex.hxx>
40 #include <TopoDS_Edge.hxx>
41 #include <TopoDS_Wire.hxx>
42 #include <TopoDS_Face.hxx>
43 #include <TopoDS_Iterator.hxx>
45 #include <BRep_Tool.hxx>
48 #include <TopExp_Explorer.hxx>
50 #include <TopTools_MapOfShape.hxx>
51 #include <TopTools_IndexedMapOfShape.hxx>
53 #include <BRepTools_WireExplorer.hxx>
54 #include <BRepGProp.hxx>
55 #include <GProp_GProps.hxx>
57 #include <GEOMAlgo_ShapeInfo.hxx>
60 Standard_Boolean IsEqual(const gp_Sphere& aSp1,
61 const gp_Sphere& aSp2,
62 const Standard_Real aTolDst);
64 //=======================================================================
65 //function : FillDetails
67 //=======================================================================
68 void GEOMAlgo_ShapeInfoFiller::FillDetails(const TopoDS_Solid& aSd)
70 Standard_Boolean bIsStepSphere;
71 Standard_Integer i, aNbF, aNbCyl, aNbCon, aNbPgn, aNbRct, aNbCrc, aNbX;
72 TopoDS_Shape aFCyl, aFCon;
73 TopTools_IndexedMapOfShape aMF;
74 GEOMAlgo_KindOfName aKNF;
76 GEOMAlgo_ShapeInfo& aInfo=myMapInfo.ChangeFromKey(aSd);
77 aInfo.SetKindOfName(GEOMAlgo_KN_UNKNOWN);
79 TopExp::MapShapes(aSd, TopAbs_FACE, aMF);
87 const TopoDS_Shape& aF=aMF(1);
88 GEOMAlgo_ShapeInfo& aInfoF=myMapInfo.ChangeFromKey(aF);
89 aKNF=aInfoF.KindOfName(); // mb: sphere, torus
90 if (aKNF==GEOMAlgo_KN_SPHERE ||
91 aKNF==GEOMAlgo_KN_TORUS) {
92 aInfo.SetKindOfName(aKNF);
93 aInfo.SetLocation(aInfoF.Location());
94 aInfo.SetPosition(aInfoF.Position());
95 aInfo.SetRadius1(aInfoF.Radius1());
96 if(aKNF==GEOMAlgo_KN_TORUS) {
97 aInfo.SetRadius2(aInfoF.Radius2());
102 //modified by NIZNHY-PKV Tue Jul 03 13:23:55 2012f
104 // specific solid that should be treated as a sphere
105 bIsStepSphere=TreatStepSphere(aSd);
110 //modified by NIZNHY-PKV Tue Jul 03 13:23:57 2012t
117 for (i=1; i<=aNbF; ++i) {
118 const TopoDS_Shape& aF=aMF(i);
119 GEOMAlgo_ShapeInfo& aInfoF=myMapInfo.ChangeFromKey(aF);
120 aKNF=aInfoF.KindOfName();
121 if (aKNF==GEOMAlgo_KN_CYLINDER) {
125 else if (aKNF==GEOMAlgo_KN_CONE) {
129 else if (aKNF==GEOMAlgo_KN_DISKCIRCLE) {
132 else if (aKNF==GEOMAlgo_KN_POLYGON ||
133 aKNF==GEOMAlgo_KN_TRIANGLE ||
134 aKNF==GEOMAlgo_KN_QUADRANGLE) {
137 else if (aKNF==GEOMAlgo_KN_RECTANGLE) {
144 if (aNbCyl==1 && aNbCrc==2 && aNbX==aNbF) {
145 // cylinder (as they understand it)
146 GEOMAlgo_ShapeInfo& aInfoF=myMapInfo.ChangeFromKey(aFCyl);
147 aKNF=aInfoF.KindOfName();
148 aInfo.SetKindOfName(aKNF);
149 aInfo.SetLocation(aInfoF.Location());
150 aInfo.SetPosition(aInfoF.Position());
151 aInfo.SetRadius1(aInfoF.Radius1());
152 aInfo.SetHeight(aInfoF.Height());
157 if (aNbCon==1 && (aNbCrc==1 || aNbCrc==2) && aNbX==aNbF) {
159 GEOMAlgo_ShapeInfo& aInfoF=myMapInfo.ChangeFromKey(aFCon);
160 aKNF=aInfoF.KindOfName();
161 aInfo.SetKindOfName(aKNF);
162 aInfo.SetLocation(aInfoF.Location());
163 aInfo.SetPosition(aInfoF.Position());
164 aInfo.SetRadius1(aInfoF.Radius1());
165 aInfo.SetRadius2(aInfoF.Radius2());
166 aInfo.SetHeight(aInfoF.Height());
171 return;// -> GEOMAlgo_KN_UNKNOWN
174 aInfo.SetKindOfName(GEOMAlgo_KN_POLYHEDRON);
178 if (aNbPgn!=aNbRct) {
179 aInfo.SetKindOfName(GEOMAlgo_KN_POLYHEDRON);
182 //===================================================
185 Standard_Integer j, aNbFi, aNbV, iMax, iMin, iMid;
186 Standard_Real aDot, aLength, aWidth, aHeight, aDist[3];
187 Standard_Real aDistMin, aDistMax;
191 TColStd_IndexedMapOfInteger aMp;
192 TopTools_IndexedMapOfShape aMV, aMFi;
195 TopExp::MapShapes(aSd, TopAbs_VERTEX, aMV);
201 aXYZc.SetCoord(0.,0.,0.);
202 for (i=1; i<=aNbV; ++i) {
203 const TopoDS_Vertex& aVi=TopoDS::Vertex(aMV(i));
204 aPi=BRep_Tool::Pnt(aVi);
205 const gp_XYZ& aXYZ=aPi.XYZ();
213 for (i=1; i<=aNbF; ++i) {
214 if (aMp.Contains(i)) {
218 const TopoDS_Shape& aFi=aMF(i);
219 const GEOMAlgo_ShapeInfo& aIFi=myMapInfo.FindFromKey(aFi);
220 const gp_Dir& aDNi=aIFi.Position().Direction();
222 for (j=i+1; j<=aNbF; ++j) {
223 if (aMp.Contains(j)) {
227 const TopoDS_Shape& aFj=aMF(j);
228 const GEOMAlgo_ShapeInfo& aIFj=myMapInfo.FindFromKey(aFj);
229 const gp_Dir& aDNj=aIFj.Position().Direction();
232 //modified by NIZNHY-PKV Tue Jul 03 10:01:56 2012f
236 //modified by NIZNHY-PKV Tue Jul 03 10:01:52 2012t
237 if (fabs(1.-aDot)<0.0001) {
253 for (i=0; i<aNbFi; ++i) {
254 const TopoDS_Shape& aFi=aMFi(i+1);
255 const GEOMAlgo_ShapeInfo& aIFi=myMapInfo.FindFromKey(aFi);
257 aDist[i]=aPc.Distance(aPi);
258 if (aDist[i]>aDistMax) {
262 if (aDist[i]<aDistMin) {
266 gp_Vec aVi(aPc, aPi);
277 aLength=2.*aDist[iMax];
278 aWidth=2.*aDist[iMid];
279 aHeight=2.*aDist[iMin];
281 gp_Ax2 aAx2(aPc, aDir[iMin], aDir[iMax]);
284 aInfo.SetKindOfName(GEOMAlgo_KN_BOX);
285 aInfo.SetLocation(aPc);
286 aInfo.SetLength(aLength);
287 aInfo.SetWidth(aWidth);
288 aInfo.SetHeight(aHeight);
289 aInfo.SetPosition(aAx3);
291 //=======================================================================
292 //function : FillDetails
294 //=======================================================================
295 void GEOMAlgo_ShapeInfoFiller::FillDetails(const TopoDS_Face& aF,
298 Standard_Integer aNbV, aNbE, i, j;
299 Standard_Real aDot, aD0, aD1, aLength, aWidth;
301 gp_Pnt aPx[4], aP, aPc;
303 TopExp_Explorer aExp;
308 TopTools_IndexedMapOfShape aMV;
309 BRepTools_WireExplorer aWExp;
310 GEOMAlgo_KindOfName aKN, aKNE;
311 GEOMAlgo_KindOfShape aKS;
313 GEOMAlgo_ShapeInfo& aInfo=myMapInfo.ChangeFromKey(aF);
314 aKN=GEOMAlgo_KN_UNKNOWN;
315 aInfo.SetKindOfName(GEOMAlgo_KN_UNKNOWN);
317 aKS=aInfo.KindOfShape();
318 if (aKS!=GEOMAlgo_KS_PLANE) {
322 if (aInfo.KindOfBounds()==GEOMAlgo_KB_INFINITE) {
323 aInfo.SetKindOfName(GEOMAlgo_KN_PLANE);
327 aNbV=aInfo.NbSubShapes(TopAbs_VERTEX);
328 aNbE=aInfo.NbSubShapes(TopAbs_EDGE);
330 // 1. may be it is circle/ellipse
331 if (aNbV==1 && aNbE==1) {
332 aExp.Init(aF, TopAbs_EDGE);
333 for (; aExp.More(); aExp.Next()) {
338 const GEOMAlgo_ShapeInfo& aInfoE=myMapInfo.FindFromKey(aE);
339 aKNE=aInfoE.KindOfName();
340 if (aKNE==GEOMAlgo_KN_CIRCLE) {
341 aKN=GEOMAlgo_KN_DISKCIRCLE;
342 aInfo.SetKindOfName(aKN);
343 aInfo.SetRadius1(aInfoE.Radius1());
344 aInfo.SetLocation(aInfoE.Location());
345 aInfo.SetPosition(aInfoE.Position());
347 if (aKNE==GEOMAlgo_KN_ELLIPSE) {
348 aKN=GEOMAlgo_KN_DISKELLIPSE;
349 aInfo.SetKindOfName(aKN);
350 aInfo.SetRadius1(aInfoE.Radius1());
351 aInfo.SetRadius2(aInfoE.Radius2());
352 aInfo.SetLocation(aInfoE.Location());
353 aInfo.SetPosition(aInfoE.Position());
357 // 2. may be it is rectangle
359 aExp.Init(aF, TopAbs_EDGE);
360 for (; aExp.More(); aExp.Next()) {
362 const GEOMAlgo_ShapeInfo& aInfoE=myMapInfo.FindFromKey(aE);
363 aKNE=aInfoE.KindOfName();
364 if (aKNE!=GEOMAlgo_KN_SEGMENT) {
369 aInfo.SetKindOfName(GEOMAlgo_KN_POLYGON);
371 if (aNbV==3 && aNbE==3) {
372 aInfo.SetKindOfName(GEOMAlgo_KN_TRIANGLE);
374 aXYZc.SetCoord(0.,0.,0.);
375 TopExp::MapShapes(aF, TopAbs_VERTEX, aMV);
376 for (i=1; i<=aNbV; ++i) {
377 const TopoDS_Vertex& aV=TopoDS::Vertex(aMV(i));
378 aP=BRep_Tool::Pnt(aV);
379 const gp_XYZ& aXYZ=aP.XYZ();
386 gp_Vec aVX(aPc, aPx[0]);
388 aDX.SetXYZ(aVX.XYZ());
389 const gp_Dir& aDZ=aPln.Axis().Direction();
391 gp_Ax2 aAx2(aPc, aDZ, aDX);
394 aInfo.SetLocation(aPc);
395 aInfo.SetPosition(aAx3);
400 if (!(aNbV==4 && aNbE==4)) {
404 // aNbV==4 && aNbE==4 and all edges are segments
406 for (; aIt.More(); aIt.Next()){
407 aW=TopoDS::Wire(aIt.Value());
412 for (i=0; aWExp.More(); aWExp.Next(), ++i) {
414 const GEOMAlgo_ShapeInfo& aInfoEx=myMapInfo.FindFromKey(aEx);
415 aDx[i]=aInfoEx.Direction();
416 aPx[i]=aInfoEx.Location();
419 Standard_Boolean isRectangle = Standard_True;
420 for (i=0; i<4; ++i) {
423 if (fabs (aDot) > myTolerance) {
424 isRectangle = Standard_False;
430 // shift location to the center
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 the first edge (quadrangle) or
443 // along length (rectangle)
448 aInfo.SetLocation(aPc);
452 gp_Lin aL0(aPx[0], aDx[0]);
453 gp_Lin aL1(aPx[1], aDx[1]);
455 aD0=aL0.Distance(aPc);
456 aD1=aL1.Distance(aPc);
470 aInfo.SetLength(aLength);
471 aInfo.SetWidth(aWidth);
472 aInfo.SetKindOfName(GEOMAlgo_KN_RECTANGLE);
474 aInfo.SetKindOfName(GEOMAlgo_KN_QUADRANGLE);
477 const gp_Dir& aDZ=aPln.Axis().Direction();
478 gp_Ax2 aAx2(aPc, aDZ, aDX);
480 aInfo.SetPosition(aAx3);
485 //=======================================================================
486 //function : FillDetails
488 //=======================================================================
489 void GEOMAlgo_ShapeInfoFiller::FillDetails(const TopoDS_Face& aF,
492 Standard_Integer aNbV, aNbE, aNbSE, aNbDE;
494 TopExp_Explorer aExp;
495 TopTools_MapOfShape aM;
496 GEOMAlgo_KindOfShape aKS, aKSE;
498 GEOMAlgo_ShapeInfo& aInfo=myMapInfo.ChangeFromKey(aF);
499 aInfo.SetKindOfName(GEOMAlgo_KN_UNKNOWN);
501 aKS=aInfo.KindOfShape();
502 if (aKS!=GEOMAlgo_KS_SPHERE) {
506 aNbV=aInfo.NbSubShapes(TopAbs_VERTEX);
507 aNbE=aInfo.NbSubShapes(TopAbs_EDGE);
508 if (!(aNbV==2 && aNbE==3)) {
514 aExp.Init(aF, TopAbs_EDGE);
515 for (; aExp.More(); aExp.Next()) {
516 aE=TopoDS::Edge(aExp.Current());
518 const GEOMAlgo_ShapeInfo& aInfoE=myMapInfo.FindFromKey(aE);
519 aKSE=aInfoE.KindOfShape();
521 if (BRep_Tool::IsClosed(aE, aF)) {
524 else if (aKSE==GEOMAlgo_KS_DEGENERATED) {
530 if (!(aNbSE==1 && aNbDE==2)) {
533 aInfo.SetKindOfName(GEOMAlgo_KN_SPHERE);
535 //=======================================================================
536 //function : FillDetails
538 //=======================================================================
539 void GEOMAlgo_ShapeInfoFiller::FillDetails(const TopoDS_Face& aF,
540 const gp_Cone& )//aCone)
542 Standard_Integer aNbV, aNbE, aNbCE, aNbSE, aNbDE, i;
543 Standard_Real aR[3], aHeight;
544 gp_Pnt aPC[3], aPD, aPc, aPX[3];
548 TopExp_Explorer aExp;
549 TopTools_MapOfShape aM;
550 GEOMAlgo_KindOfShape aKS, aKSE;
551 GEOMAlgo_KindOfName aKN, aKNE;
552 GEOMAlgo_KindOfClosed aKCE;
554 GEOMAlgo_ShapeInfo& aInfo=myMapInfo.ChangeFromKey(aF);
555 aKN=GEOMAlgo_KN_UNKNOWN;
556 aInfo.SetKindOfName(aKN);
558 aKS=aInfo.KindOfShape();
559 if (aKS!=GEOMAlgo_KS_CONE) {
563 if (aInfo.KindOfBounds()==GEOMAlgo_KB_INFINITE) {
567 aNbV=aInfo.NbSubShapes(TopAbs_VERTEX);
568 aNbE=aInfo.NbSubShapes(TopAbs_EDGE);
569 if (!(aNbV==2 && aNbE==3)) {
577 aExp.Init(aF, TopAbs_EDGE);
578 for (; aExp.More(); aExp.Next()) {
579 aE=TopoDS::Edge(aExp.Current());
581 const GEOMAlgo_ShapeInfo& aInfoE=myMapInfo.FindFromKey(aE);
582 aKNE=aInfoE.KindOfName();
583 aKCE=aInfoE.KindOfClosed();
584 aKSE=aInfoE.KindOfShape();
585 if (aKNE==GEOMAlgo_KN_CIRCLE && aKCE==GEOMAlgo_KC_CLOSED) {
586 aPC[i]=aInfoE.Location();
587 aR[i]=aInfoE.Radius1();
590 for (; aIt.More(); aIt.Next()) {
591 aVD=TopoDS::Vertex(aIt.Value());
594 aPX[i]=BRep_Tool::Pnt(aVD);
599 else if (aKNE==GEOMAlgo_KN_SEGMENT) {
600 if (BRep_Tool::IsClosed(aE, aF)) {
604 else if (aKSE==GEOMAlgo_KS_DEGENERATED) {
606 for (; aIt.More(); aIt.Next()) {
607 aVD=TopoDS::Vertex(aIt.Value());
611 aPD=BRep_Tool::Pnt(aVD);
618 if (!((aNbCE==2 || (aNbCE==1 && aNbDE==1)) && aNbSE==1)) {
627 aHeight=aPC[0].Distance(aPC[1]);
629 Standard_Real aRmin, aRmax;
636 gp_Vec aVz(aPC[0], aPC[1]);
637 gp_Vec aVx(aPC[0], aPX[0]);
640 gp_Ax2 aAx2(aPc, aDz, aDx);
647 gp_Vec aVz(aPC[1], aPC[0]);
648 gp_Vec aVx(aPC[1], aPX[1]);
651 gp_Ax2 aAx2(aPc, aDz, aDx);
655 gp_Ax3 aAx3(aAx2new);
656 aInfo.SetLocation(aPc);
657 aInfo.SetPosition(aAx3);
658 aInfo.SetRadius1(aRmax);
659 aInfo.SetRadius2(aRmin);
660 aInfo.SetHeight(aHeight);
662 aInfo.SetKindOfName(GEOMAlgo_KN_CONE);
664 //=======================================================================
665 //function : FillDetails
667 //=======================================================================
668 void GEOMAlgo_ShapeInfoFiller::FillDetails(const TopoDS_Face& aF,
669 const gp_Cylinder& aCyl)
671 Standard_Integer i, aNbV, aNbE, aNbCE, aNbSE;
672 Standard_Real aT0, aT1, aHeight;
675 TopExp_Explorer aExp;
676 TopTools_MapOfShape aM;
677 GEOMAlgo_KindOfShape aKS;
678 GEOMAlgo_KindOfName aKN, aKNE;
679 GEOMAlgo_KindOfClosed aKCE;
681 GEOMAlgo_ShapeInfo& aInfo=myMapInfo.ChangeFromKey(aF);
682 aKN=GEOMAlgo_KN_UNKNOWN;
683 aInfo.SetKindOfName(aKN);
685 aKS=aInfo.KindOfShape();
686 if (aKS!=GEOMAlgo_KS_CYLINDER) {
690 if (aInfo.KindOfBounds()==GEOMAlgo_KB_INFINITE) {
694 aNbV=aInfo.NbSubShapes(TopAbs_VERTEX);
695 aNbE=aInfo.NbSubShapes(TopAbs_EDGE);
696 if (!(aNbV==2 && aNbE==3)) {
703 aExp.Init(aF, TopAbs_EDGE);
704 for (; aExp.More(); aExp.Next()) {
705 aE=TopoDS::Edge(aExp.Current());
707 const GEOMAlgo_ShapeInfo& aInfoE=myMapInfo.FindFromKey(aE);
708 aKNE=aInfoE.KindOfName();
709 aKCE=aInfoE.KindOfClosed();
710 if (aKNE==GEOMAlgo_KN_CIRCLE && aKCE==GEOMAlgo_KC_CLOSED) {
711 aPC[aNbCE]=aInfoE.Location();
714 else if (aKNE==GEOMAlgo_KN_SEGMENT) {
715 if (BRep_Tool::IsClosed(aE, aF)) {
722 if (!(aNbCE==2 && aNbSE==1)) {
726 const gp_Ax1& aAx1=aCyl.Axis();
727 const gp_Dir& aDir=aAx1.Direction();
728 const gp_Pnt& aPLoc=aAx1.Location();
729 gp_Lin aLin(aPLoc, aDir);
731 aT0=ElCLib::Parameter(aLin, aPC[0]);
732 aT1=ElCLib::Parameter(aLin, aPC[1]);
738 aHeight=aPC[0].Distance(aPC[1]);
740 gp_Ax3 aAx3=aCyl.Position();
741 aAx3.SetLocation(aPc);
743 aInfo.SetKindOfName(GEOMAlgo_KN_CYLINDER);
744 aInfo.SetPosition(aAx3);
745 aInfo.SetLocation(aPc);
746 aInfo.SetHeight(aHeight);
749 //=======================================================================
750 //function : FillDetails
752 //=======================================================================
753 void GEOMAlgo_ShapeInfoFiller::FillDetails(const TopoDS_Face& aF,
756 Standard_Integer aNbV, aNbE, aNbSE;
758 TopExp_Explorer aExp;
759 TopTools_MapOfShape aM;
760 GEOMAlgo_KindOfShape aKS;
762 GEOMAlgo_ShapeInfo& aInfo=myMapInfo.ChangeFromKey(aF);
763 aInfo.SetKindOfName(GEOMAlgo_KN_UNKNOWN);
765 aKS=aInfo.KindOfShape();
766 if (aKS!=GEOMAlgo_KS_TORUS) {
770 aNbV=aInfo.NbSubShapes(TopAbs_VERTEX);
771 aNbE=aInfo.NbSubShapes(TopAbs_EDGE);
772 if (!(aNbV==1 && aNbE==2)) {
777 aExp.Init(aF, TopAbs_EDGE);
778 for (; aExp.More(); aExp.Next()) {
779 aE=TopoDS::Edge(aExp.Current());
781 if (BRep_Tool::IsClosed(aE, aF)) {
790 aInfo.SetKindOfName(GEOMAlgo_KN_TORUS);
792 //modified by NIZNHY-PKV Tue Jul 03 13:29:41 2012f
793 //=======================================================================
794 //function : TreatStepSphere
796 //=======================================================================
798 GEOMAlgo_ShapeInfoFiller::TreatStepSphere(const TopoDS_Solid& aSd)
800 Standard_Boolean bRet, bIsAllowedType, bOnlyClosed, bIsEqual;
802 Standard_Real aTolAng, aTolLin;
803 Standard_Real aVolume, aVolumeS, dV, aArea, aAreaS, dA;
804 gp_Sphere aSphere[2];
805 GeomAbs_SurfaceType aST;
806 Handle(Geom_Surface) aS;
807 GeomAdaptor_Surface aGAS;
808 TopExp_Explorer aExp;
811 aTolLin=Precision::Confusion();
812 aTolAng=Precision::Angular();
814 aExp.Init(aSd, TopAbs_FACE);
815 for (j=0; aExp.More(); aExp.Next(), ++j) {
816 const TopoDS_Face& aF=*((TopoDS_Face*)&aExp.Current());
817 aS=BRep_Tool::Surface(aF);
820 bIsAllowedType=GEOMAlgo_ShapeInfoFiller::IsAllowedType(aST);
821 if (!bIsAllowedType) {
825 if (aST!=GeomAbs_Sphere) {
829 aSphere[j]=aGAS.Sphere();
832 bIsEqual=IsEqual(aSphere[0], aSphere[1], aTolLin);
837 //--------------------------------
838 GProp_GProps aGProps;
840 bOnlyClosed=Standard_False;
842 aVolume=aSphere[0].Volume();
844 BRepGProp::VolumeProperties(aSd, aGProps, bOnlyClosed);
845 aVolumeS=aGProps.Mass();
850 dV=fabs(aVolumeS-aVolume);
854 //--------------------------------
855 aArea=aSphere[0].Area();
857 BRepGProp::SurfaceProperties(aSd, aGProps);
858 aAreaS=aGProps.Mass();
860 dA=fabs(aAreaS-aArea);
865 //--------------------------------
870 aP0=aSphere[0].Location();
871 aAx3=aSphere[0].Position();
872 aR1=aSphere[0].Radius();
874 GEOMAlgo_ShapeInfo& aInfo=myMapInfo.ChangeFromKey(aSd);
876 aInfo.SetKindOfName(GEOMAlgo_KN_SPHERE);
877 aInfo.SetLocation(aP0);
878 aInfo.SetPosition(aAx3);
879 aInfo.SetRadius1(aR1);
883 //=======================================================================
886 //=======================================================================
887 Standard_Boolean IsEqual(const gp_Sphere& aSp1,
888 const gp_Sphere& aSp2,
889 const Standard_Real aTolLin)
891 Standard_Boolean bRet;
892 Standard_Real aR1, aR2, aD2;
897 if (fabs(aR1-aR2)>aTolLin) {
901 const gp_Pnt& aPC1=aSp1.Position().Location();
902 const gp_Pnt& aPC2=aSp2.Position().Location();
904 aD2=aPC1.SquareDistance(aPC2);
905 bRet=(aD2<aTolLin*aTolLin);
909 //modified by NIZNHY-PKV Tue Jul 03 13:29:43 2012t