1 // Copyright (C) 2007-2010 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
20 // File: NMTDS_Tools.cxx
21 // Created: Tue Feb 20 14:57:28 2007
22 // Author: Peter KURNEV
25 #include <NMTDS_Tools.ixx>
26 #include <TopoDS_Vertex.hxx>
28 #include <BRep_Tool.hxx>
29 #include <TopoDS_Shape.hxx>
30 #include <TopTools_IndexedDataMapOfShapeShape.hxx>
31 #include <TopAbs_ShapeEnum.hxx>
32 #include <TopoDS_Iterator.hxx>
33 #include <BRep_Builder.hxx>
35 void CopySource(const TopoDS_Shape& aS,
36 TopTools_IndexedDataMapOfShapeShape& aMapSS,
39 //=======================================================================
40 //function : CopyShape
42 //=======================================================================
43 void NMTDS_Tools::CopyShape(const TopoDS_Shape& aS,
46 TopTools_IndexedDataMapOfShapeShape aMapSS;
48 CopySource(aS, aMapSS, aSC);
50 //=======================================================================
51 //function : CopyShape
53 //=======================================================================
54 void NMTDS_Tools::CopyShape(const TopoDS_Shape& aS,
56 TopTools_IndexedDataMapOfShapeShape& aMapSS)
58 CopySource(aS, aMapSS, aSC);
60 //=======================================================================
61 //function : CopySource
63 //=======================================================================
64 void CopySource(const TopoDS_Shape& aS,
65 TopTools_IndexedDataMapOfShapeShape& aMapSS,
68 Standard_Boolean bFree;
75 if (aMapSS.Contains(aS)) {
76 aSC=aMapSS.ChangeFromKey(aS);
77 aSC.Orientation(aS.Orientation());
86 aSC.Free(Standard_True);
88 for (; aIt.More(); aIt.Next()) {
91 const TopoDS_Shape& aSx=aIt.Value();
93 CopySource (aSx, aMapSS, aSCx);
95 aSCx.Orientation(aSx.Orientation());
100 //=======================================================================
101 // function: ComputeVV
103 //=======================================================================
104 Standard_Integer NMTDS_Tools::ComputeVV(const TopoDS_Vertex& aV1,
105 const TopoDS_Vertex& aV2)
107 Standard_Real aTolV1, aTolV2, aTolSum, aTolSum2, aD2;
110 aTolV1=BRep_Tool::Tolerance(aV1);
111 aTolV2=BRep_Tool::Tolerance(aV2);
112 aTolSum=aTolV1+aTolV2;
113 aTolSum2=aTolSum*aTolSum;
115 aP1=BRep_Tool::Pnt(aV1);
116 aP2=BRep_Tool::Pnt(aV2);
118 aD2=aP1.SquareDistance(aP2);
124 //=======================================================================
127 //=======================================================================
128 Standard_Boolean NMTDS_Tools::HasBRep(const TopAbs_ShapeEnum aTi)
130 return (aTi==TopAbs_VERTEX || aTi==TopAbs_EDGE || aTi==TopAbs_FACE);
132 //=======================================================================
133 //function : TypeToInteger
135 //=======================================================================
136 Standard_Integer NMTDS_Tools::TypeToInteger(const TopAbs_ShapeEnum aType1,
137 const TopAbs_ShapeEnum aType2)
139 Standard_Integer iRet, iT1, iT2, iX;
142 iT1=(Standard_Integer)aType1;
143 iT2=(Standard_Integer)aType2;