1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File: NMTDS_Tools.cxx
23 // Created: Tue Feb 20 14:57:28 2007
24 // Author: Peter KURNEV
27 #include <NMTDS_Tools.ixx>
28 #include <TopoDS_Vertex.hxx>
30 #include <BRep_Tool.hxx>
31 #include <TopoDS_Shape.hxx>
32 #include <TopTools_IndexedDataMapOfShapeShape.hxx>
33 #include <TopAbs_ShapeEnum.hxx>
34 #include <TopoDS_Iterator.hxx>
35 #include <BRep_Builder.hxx>
37 void CopySource(const TopoDS_Shape& aS,
38 TopTools_IndexedDataMapOfShapeShape& aMapSS,
41 //=======================================================================
42 //function : CopyShape
44 //=======================================================================
45 void NMTDS_Tools::CopyShape(const TopoDS_Shape& aS,
48 TopTools_IndexedDataMapOfShapeShape aMapSS;
50 CopySource(aS, aMapSS, aSC);
52 //=======================================================================
53 //function : CopyShape
55 //=======================================================================
56 void NMTDS_Tools::CopyShape(const TopoDS_Shape& aS,
58 TopTools_IndexedDataMapOfShapeShape& aMapSS)
60 CopySource(aS, aMapSS, aSC);
62 //=======================================================================
63 //function : CopySource
65 //=======================================================================
66 void CopySource(const TopoDS_Shape& aS,
67 TopTools_IndexedDataMapOfShapeShape& aMapSS,
70 Standard_Boolean bFree;
77 if (aMapSS.Contains(aS)) {
78 aSC=aMapSS.ChangeFromKey(aS);
79 aSC.Orientation(aS.Orientation());
88 aSC.Free(Standard_True);
90 for (; aIt.More(); aIt.Next()) {
93 const TopoDS_Shape& aSx=aIt.Value();
95 CopySource (aSx, aMapSS, aSCx);
97 aSCx.Orientation(aSx.Orientation());
102 //=======================================================================
103 // function: ComputeVV
105 //=======================================================================
106 Standard_Integer NMTDS_Tools::ComputeVV(const TopoDS_Vertex& aV1,
107 const TopoDS_Vertex& aV2)
109 Standard_Real aTolV1, aTolV2, aTolSum, aTolSum2, aD2;
112 aTolV1=BRep_Tool::Tolerance(aV1);
113 aTolV2=BRep_Tool::Tolerance(aV2);
114 aTolSum=aTolV1+aTolV2;
115 aTolSum2=aTolSum*aTolSum;
117 aP1=BRep_Tool::Pnt(aV1);
118 aP2=BRep_Tool::Pnt(aV2);
120 aD2=aP1.SquareDistance(aP2);
126 //=======================================================================
129 //=======================================================================
130 Standard_Boolean NMTDS_Tools::HasBRep(const TopAbs_ShapeEnum aTi)
132 return (aTi==TopAbs_VERTEX || aTi==TopAbs_EDGE || aTi==TopAbs_FACE);
134 //=======================================================================
135 //function : TypeToInteger
137 //=======================================================================
138 Standard_Integer NMTDS_Tools::TypeToInteger(const TopAbs_ShapeEnum aType1,
139 const TopAbs_ShapeEnum aType2)
141 Standard_Integer iRet, iT1, iT2, iX;
144 iT1=(Standard_Integer)aType1;
145 iT2=(Standard_Integer)aType2;