1 // Copyright (C) 2007-2012 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
24 #include <NMTDS_Tools.hxx>
25 #include <TopoDS_Vertex.hxx>
27 #include <BRep_Tool.hxx>
28 #include <TopoDS_Shape.hxx>
29 #include <TopTools_IndexedDataMapOfShapeShape.hxx>
30 #include <TopAbs_ShapeEnum.hxx>
31 #include <TopoDS_Iterator.hxx>
32 #include <BRep_Builder.hxx>
34 void CopySource(const TopoDS_Shape& aS,
35 TopTools_IndexedDataMapOfShapeShape& aMapSS,
38 //=======================================================================
39 //function : CopyShape
41 //=======================================================================
42 void NMTDS_Tools::CopyShape(const TopoDS_Shape& aS,
45 TopTools_IndexedDataMapOfShapeShape aMapSS;
47 CopySource(aS, aMapSS, aSC);
49 //=======================================================================
50 //function : CopyShape
52 //=======================================================================
53 void NMTDS_Tools::CopyShape(const TopoDS_Shape& aS,
55 TopTools_IndexedDataMapOfShapeShape& aMapSS)
57 CopySource(aS, aMapSS, aSC);
59 //=======================================================================
60 //function : CopySource
62 //=======================================================================
63 void CopySource(const TopoDS_Shape& aS,
64 TopTools_IndexedDataMapOfShapeShape& aMapSS,
67 Standard_Boolean bFree;
75 if (aMapSS.Contains(aS)) {
76 aSC=aMapSS.ChangeFromKey(aS);
77 aSC.Orientation(aS.Orientation());
86 aSC.Free(Standard_True);
89 TopAbs_Orientation aOr;
92 if(aOr==TopAbs_INTERNAL) {
93 aSF.Orientation(TopAbs_FORWARD);
97 for (; aIt.More(); aIt.Next()) {
100 const TopoDS_Shape& aSx=aIt.Value();
102 CopySource (aSx, aMapSS, aSCx);
104 aSCx.Orientation(aSx.Orientation());
109 //=======================================================================
110 // function: ComputeVV
112 //=======================================================================
113 Standard_Integer NMTDS_Tools::ComputeVV(const TopoDS_Vertex& aV1,
114 const TopoDS_Vertex& aV2)
116 Standard_Real aTolV1, aTolV2, aTolSum, aTolSum2, aD2;
119 aTolV1=BRep_Tool::Tolerance(aV1);
120 aTolV2=BRep_Tool::Tolerance(aV2);
121 aTolSum=aTolV1+aTolV2;
122 aTolSum2=aTolSum*aTolSum;
124 aP1=BRep_Tool::Pnt(aV1);
125 aP2=BRep_Tool::Pnt(aV2);
127 aD2=aP1.SquareDistance(aP2);
133 //=======================================================================
136 //=======================================================================
137 Standard_Boolean NMTDS_Tools::HasBRep(const TopAbs_ShapeEnum aTi)
139 return (aTi==TopAbs_VERTEX || aTi==TopAbs_EDGE || aTi==TopAbs_FACE);
141 //=======================================================================
142 //function : TypeToInteger
144 //=======================================================================
145 Standard_Integer NMTDS_Tools::TypeToInteger(const TopAbs_ShapeEnum aType1,
146 const TopAbs_ShapeEnum aType2)
148 Standard_Integer iRet, iT1, iT2, iX;
151 iT1=(Standard_Integer)aType1;
152 iT2=(Standard_Integer)aType2;