1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // File: NMTDS_Tools.cxx
21 // Created: Tue Feb 20 14:57:28 2007
22 // Author: Peter KURNEV
26 #include <NMTDS_Tools.ixx>
27 #include <TopoDS_Vertex.hxx>
29 #include <BRep_Tool.hxx>
30 #include <TopoDS_Shape.hxx>
31 #include <TopTools_IndexedDataMapOfShapeShape.hxx>
32 #include <TopAbs_ShapeEnum.hxx>
33 #include <TopoDS_Iterator.hxx>
34 #include <BRep_Builder.hxx>
36 void CopySource(const TopoDS_Shape& aS,
37 TopTools_IndexedDataMapOfShapeShape& aMapSS,
40 //=======================================================================
41 //function : CopyShape
43 //=======================================================================
44 void NMTDS_Tools::CopyShape(const TopoDS_Shape& aS,
47 TopTools_IndexedDataMapOfShapeShape aMapSS;
49 CopySource(aS, aMapSS, aSC);
51 //=======================================================================
52 //function : CopyShape
54 //=======================================================================
55 void NMTDS_Tools::CopyShape(const TopoDS_Shape& aS,
57 TopTools_IndexedDataMapOfShapeShape& aMapSS)
59 CopySource(aS, aMapSS, aSC);
61 //=======================================================================
62 //function : CopySource
64 //=======================================================================
65 void CopySource(const TopoDS_Shape& aS,
66 TopTools_IndexedDataMapOfShapeShape& aMapSS,
69 Standard_Boolean bFree;
76 if (aMapSS.Contains(aS)) {
77 aSC=aMapSS.ChangeFromKey(aS);
78 aSC.Orientation(aS.Orientation());
87 aSC.Free(Standard_True);
89 for (; aIt.More(); aIt.Next()) {
92 const TopoDS_Shape& aSx=aIt.Value();
94 CopySource (aSx, aMapSS, aSCx);
96 aSCx.Orientation(aSx.Orientation());
101 //=======================================================================
102 // function: ComputeVV
104 //=======================================================================
105 Standard_Integer NMTDS_Tools::ComputeVV(const TopoDS_Vertex& aV1,
106 const TopoDS_Vertex& aV2)
108 Standard_Real aTolV1, aTolV2, aTolSum, aTolSum2, aD2;
111 aTolV1=BRep_Tool::Tolerance(aV1);
112 aTolV2=BRep_Tool::Tolerance(aV2);
113 aTolSum=aTolV1+aTolV2;
114 aTolSum2=aTolSum*aTolSum;
116 aP1=BRep_Tool::Pnt(aV1);
117 aP2=BRep_Tool::Pnt(aV2);
119 aD2=aP1.SquareDistance(aP2);
125 //=======================================================================
128 //=======================================================================
129 Standard_Boolean NMTDS_Tools::HasBRep(const TopAbs_ShapeEnum aTi)
131 return (aTi==TopAbs_VERTEX || aTi==TopAbs_EDGE || aTi==TopAbs_FACE);
133 //=======================================================================
134 //function : TypeToInteger
136 //=======================================================================
137 Standard_Integer NMTDS_Tools::TypeToInteger(const TopAbs_ShapeEnum aType1,
138 const TopAbs_ShapeEnum aType2)
140 Standard_Integer iRet, iT1, iT2, iX;
143 iT1=(Standard_Integer)aType1;
144 iT2=(Standard_Integer)aType2;