1 // Copyright (C) 2007-2014 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 for (i=0; i<4; ++i) {
422 if (fabs (aDot) > myTolerance) {
423 aInfo.SetKindOfName(GEOMAlgo_KN_QUADRANGLE);
429 aInfo.SetKindOfName(GEOMAlgo_KN_RECTANGLE);
431 // shift location to the center and calc. sizes
432 aXYZc.SetCoord(0.,0.,0.);
433 TopExp::MapShapes(aF, TopAbs_VERTEX, aMV);
434 for (i=1; i<=aNbV; ++i) {
435 const TopoDS_Vertex& aV=TopoDS::Vertex(aMV(i));
436 aP=BRep_Tool::Pnt(aV);
437 const gp_XYZ& aXYZ=aP.XYZ();
441 // Location : aPc in center of rectangle
442 // Position : 0z is plane normal
443 // 0x is along length
448 gp_Lin aL0(aPx[0], aDx[0]);
449 gp_Lin aL1(aPx[1], aDx[1]);
451 aD0=aL0.Distance(aPc);
452 aD1=aL1.Distance(aPc);
466 aInfo.SetLocation(aPc);
467 aInfo.SetLength(aLength);
468 aInfo.SetWidth(aWidth);
470 const gp_Dir& aDZ=aPln.Axis().Direction();
471 gp_Ax2 aAx2(aPc, aDZ, aDX);
473 aInfo.SetPosition(aAx3);
478 //=======================================================================
479 //function : FillDetails
481 //=======================================================================
482 void GEOMAlgo_ShapeInfoFiller::FillDetails(const TopoDS_Face& aF,
485 Standard_Integer aNbV, aNbE, aNbSE, aNbDE;
487 TopExp_Explorer aExp;
488 TopTools_MapOfShape aM;
489 GEOMAlgo_KindOfShape aKS, aKSE;
491 GEOMAlgo_ShapeInfo& aInfo=myMapInfo.ChangeFromKey(aF);
492 aInfo.SetKindOfName(GEOMAlgo_KN_UNKNOWN);
494 aKS=aInfo.KindOfShape();
495 if (aKS!=GEOMAlgo_KS_SPHERE) {
499 aNbV=aInfo.NbSubShapes(TopAbs_VERTEX);
500 aNbE=aInfo.NbSubShapes(TopAbs_EDGE);
501 if (!(aNbV==2 && aNbE==3)) {
507 aExp.Init(aF, TopAbs_EDGE);
508 for (; aExp.More(); aExp.Next()) {
509 aE=TopoDS::Edge(aExp.Current());
511 const GEOMAlgo_ShapeInfo& aInfoE=myMapInfo.FindFromKey(aE);
512 aKSE=aInfoE.KindOfShape();
514 if (BRep_Tool::IsClosed(aE, aF)) {
517 else if (aKSE==GEOMAlgo_KS_DEGENERATED) {
523 if (!(aNbSE==1 && aNbDE==2)) {
526 aInfo.SetKindOfName(GEOMAlgo_KN_SPHERE);
528 //=======================================================================
529 //function : FillDetails
531 //=======================================================================
532 void GEOMAlgo_ShapeInfoFiller::FillDetails(const TopoDS_Face& aF,
533 const gp_Cone& )//aCone)
535 Standard_Integer aNbV, aNbE, aNbCE, aNbSE, aNbDE, i;
536 Standard_Real aR[3], aHeight;
537 gp_Pnt aPC[3], aPD, aPc, aPX[3];
541 TopExp_Explorer aExp;
542 TopTools_MapOfShape aM;
543 GEOMAlgo_KindOfShape aKS, aKSE;
544 GEOMAlgo_KindOfName aKN, aKNE;
545 GEOMAlgo_KindOfClosed aKCE;
547 GEOMAlgo_ShapeInfo& aInfo=myMapInfo.ChangeFromKey(aF);
548 aKN=GEOMAlgo_KN_UNKNOWN;
549 aInfo.SetKindOfName(aKN);
551 aKS=aInfo.KindOfShape();
552 if (aKS!=GEOMAlgo_KS_CONE) {
556 if (aInfo.KindOfBounds()==GEOMAlgo_KB_INFINITE) {
560 aNbV=aInfo.NbSubShapes(TopAbs_VERTEX);
561 aNbE=aInfo.NbSubShapes(TopAbs_EDGE);
562 if (!(aNbV==2 && aNbE==3)) {
570 aExp.Init(aF, TopAbs_EDGE);
571 for (; aExp.More(); aExp.Next()) {
572 aE=TopoDS::Edge(aExp.Current());
574 const GEOMAlgo_ShapeInfo& aInfoE=myMapInfo.FindFromKey(aE);
575 aKNE=aInfoE.KindOfName();
576 aKCE=aInfoE.KindOfClosed();
577 aKSE=aInfoE.KindOfShape();
578 if (aKNE==GEOMAlgo_KN_CIRCLE && aKCE==GEOMAlgo_KC_CLOSED) {
579 aPC[i]=aInfoE.Location();
580 aR[i]=aInfoE.Radius1();
583 for (; aIt.More(); aIt.Next()) {
584 aVD=TopoDS::Vertex(aIt.Value());
587 aPX[i]=BRep_Tool::Pnt(aVD);
592 else if (aKNE==GEOMAlgo_KN_SEGMENT) {
593 if (BRep_Tool::IsClosed(aE, aF)) {
597 else if (aKSE==GEOMAlgo_KS_DEGENERATED) {
599 for (; aIt.More(); aIt.Next()) {
600 aVD=TopoDS::Vertex(aIt.Value());
604 aPD=BRep_Tool::Pnt(aVD);
611 if (!((aNbCE==2 || (aNbCE==1 && aNbDE==1)) && aNbSE==1)) {
620 aHeight=aPC[0].Distance(aPC[1]);
622 Standard_Real aRmin, aRmax;
629 gp_Vec aVz(aPC[0], aPC[1]);
630 gp_Vec aVx(aPC[0], aPX[0]);
633 gp_Ax2 aAx2(aPc, aDz, aDx);
640 gp_Vec aVz(aPC[1], aPC[0]);
641 gp_Vec aVx(aPC[1], aPX[1]);
644 gp_Ax2 aAx2(aPc, aDz, aDx);
648 gp_Ax3 aAx3(aAx2new);
649 aInfo.SetLocation(aPc);
650 aInfo.SetPosition(aAx3);
651 aInfo.SetRadius1(aRmax);
652 aInfo.SetRadius2(aRmin);
653 aInfo.SetHeight(aHeight);
655 aInfo.SetKindOfName(GEOMAlgo_KN_CONE);
657 //=======================================================================
658 //function : FillDetails
660 //=======================================================================
661 void GEOMAlgo_ShapeInfoFiller::FillDetails(const TopoDS_Face& aF,
662 const gp_Cylinder& aCyl)
664 Standard_Integer i, aNbV, aNbE, aNbCE, aNbSE;
665 Standard_Real aT0, aT1, aHeight;
668 TopExp_Explorer aExp;
669 TopTools_MapOfShape aM;
670 GEOMAlgo_KindOfShape aKS;
671 GEOMAlgo_KindOfName aKN, aKNE;
672 GEOMAlgo_KindOfClosed aKCE;
674 GEOMAlgo_ShapeInfo& aInfo=myMapInfo.ChangeFromKey(aF);
675 aKN=GEOMAlgo_KN_UNKNOWN;
676 aInfo.SetKindOfName(aKN);
678 aKS=aInfo.KindOfShape();
679 if (aKS!=GEOMAlgo_KS_CYLINDER) {
683 if (aInfo.KindOfBounds()==GEOMAlgo_KB_INFINITE) {
687 aNbV=aInfo.NbSubShapes(TopAbs_VERTEX);
688 aNbE=aInfo.NbSubShapes(TopAbs_EDGE);
689 if (!(aNbV==2 && aNbE==3)) {
696 aExp.Init(aF, TopAbs_EDGE);
697 for (; aExp.More(); aExp.Next()) {
698 aE=TopoDS::Edge(aExp.Current());
700 const GEOMAlgo_ShapeInfo& aInfoE=myMapInfo.FindFromKey(aE);
701 aKNE=aInfoE.KindOfName();
702 aKCE=aInfoE.KindOfClosed();
703 if (aKNE==GEOMAlgo_KN_CIRCLE && aKCE==GEOMAlgo_KC_CLOSED) {
704 aPC[aNbCE]=aInfoE.Location();
707 else if (aKNE==GEOMAlgo_KN_SEGMENT) {
708 if (BRep_Tool::IsClosed(aE, aF)) {
715 if (!(aNbCE==2 && aNbSE==1)) {
719 const gp_Ax1& aAx1=aCyl.Axis();
720 const gp_Dir& aDir=aAx1.Direction();
721 const gp_Pnt& aPLoc=aAx1.Location();
722 gp_Lin aLin(aPLoc, aDir);
724 aT0=ElCLib::Parameter(aLin, aPC[0]);
725 aT1=ElCLib::Parameter(aLin, aPC[1]);
731 aHeight=aPC[0].Distance(aPC[1]);
733 gp_Ax3 aAx3=aCyl.Position();
734 aAx3.SetLocation(aPc);
736 aInfo.SetKindOfName(GEOMAlgo_KN_CYLINDER);
737 aInfo.SetPosition(aAx3);
738 aInfo.SetLocation(aPc);
739 aInfo.SetHeight(aHeight);
742 //=======================================================================
743 //function : FillDetails
745 //=======================================================================
746 void GEOMAlgo_ShapeInfoFiller::FillDetails(const TopoDS_Face& aF,
749 Standard_Integer aNbV, aNbE, aNbSE;
751 TopExp_Explorer aExp;
752 TopTools_MapOfShape aM;
753 GEOMAlgo_KindOfShape aKS;
755 GEOMAlgo_ShapeInfo& aInfo=myMapInfo.ChangeFromKey(aF);
756 aInfo.SetKindOfName(GEOMAlgo_KN_UNKNOWN);
758 aKS=aInfo.KindOfShape();
759 if (aKS!=GEOMAlgo_KS_TORUS) {
763 aNbV=aInfo.NbSubShapes(TopAbs_VERTEX);
764 aNbE=aInfo.NbSubShapes(TopAbs_EDGE);
765 if (!(aNbV==1 && aNbE==2)) {
770 aExp.Init(aF, TopAbs_EDGE);
771 for (; aExp.More(); aExp.Next()) {
772 aE=TopoDS::Edge(aExp.Current());
774 if (BRep_Tool::IsClosed(aE, aF)) {
783 aInfo.SetKindOfName(GEOMAlgo_KN_TORUS);
785 //modified by NIZNHY-PKV Tue Jul 03 13:29:41 2012f
786 //=======================================================================
787 //function : TreatStepSphere
789 //=======================================================================
791 GEOMAlgo_ShapeInfoFiller::TreatStepSphere(const TopoDS_Solid& aSd)
793 Standard_Boolean bRet, bIsAllowedType, bOnlyClosed, bIsEqual;
795 Standard_Real aTolAng, aTolLin;
796 Standard_Real aVolume, aVolumeS, dV, aArea, aAreaS, dA;
797 gp_Sphere aSphere[2];
798 GeomAbs_SurfaceType aST;
799 Handle(Geom_Surface) aS;
800 GeomAdaptor_Surface aGAS;
801 TopExp_Explorer aExp;
804 aTolLin=Precision::Confusion();
805 aTolAng=Precision::Angular();
807 aExp.Init(aSd, TopAbs_FACE);
808 for (j=0; aExp.More(); aExp.Next(), ++j) {
809 const TopoDS_Face& aF=*((TopoDS_Face*)&aExp.Current());
810 aS=BRep_Tool::Surface(aF);
813 bIsAllowedType=GEOMAlgo_ShapeInfoFiller::IsAllowedType(aST);
814 if (!bIsAllowedType) {
818 if (aST!=GeomAbs_Sphere) {
822 aSphere[j]=aGAS.Sphere();
825 bIsEqual=IsEqual(aSphere[0], aSphere[1], aTolLin);
830 //--------------------------------
831 GProp_GProps aGProps;
833 bOnlyClosed=Standard_False;
835 aVolume=aSphere[0].Volume();
837 BRepGProp::VolumeProperties(aSd, aGProps, bOnlyClosed);
838 aVolumeS=aGProps.Mass();
843 dV=fabs(aVolumeS-aVolume);
847 //--------------------------------
848 aArea=aSphere[0].Area();
850 BRepGProp::SurfaceProperties(aSd, aGProps);
851 aAreaS=aGProps.Mass();
853 dA=fabs(aAreaS-aArea);
858 //--------------------------------
863 aP0=aSphere[0].Location();
864 aAx3=aSphere[0].Position();
865 aR1=aSphere[0].Radius();
867 GEOMAlgo_ShapeInfo& aInfo=myMapInfo.ChangeFromKey(aSd);
869 aInfo.SetKindOfName(GEOMAlgo_KN_SPHERE);
870 aInfo.SetLocation(aP0);
871 aInfo.SetPosition(aAx3);
872 aInfo.SetRadius1(aR1);
876 //=======================================================================
879 //=======================================================================
880 Standard_Boolean IsEqual(const gp_Sphere& aSp1,
881 const gp_Sphere& aSp2,
882 const Standard_Real aTolLin)
884 Standard_Boolean bRet;
885 Standard_Real aR1, aR2, aD2;
890 if (fabs(aR1-aR2)>aTolLin) {
894 const gp_Pnt& aPC1=aSp1.Position().Location();
895 const gp_Pnt& aPC2=aSp2.Position().Location();
897 aD2=aPC1.SquareDistance(aPC2);
898 bRet=(aD2<aTolLin*aTolLin);
902 //modified by NIZNHY-PKV Tue Jul 03 13:29:43 2012t