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.ixx>
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);
87 //modified by NIZNHY-PKV Fri Nov 25 10:10:03 2011f
90 TopAbs_Orientation aOr;
93 if(aOr==TopAbs_INTERNAL) {
94 aSF.Orientation(TopAbs_FORWARD);
99 //modified by NIZNHY-PKV Fri Nov 25 10:10:05 2011t
100 for (; aIt.More(); aIt.Next()) {
103 const TopoDS_Shape& aSx=aIt.Value();
105 CopySource (aSx, aMapSS, aSCx);
107 aSCx.Orientation(aSx.Orientation());
112 //=======================================================================
113 // function: ComputeVV
115 //=======================================================================
116 Standard_Integer NMTDS_Tools::ComputeVV(const TopoDS_Vertex& aV1,
117 const TopoDS_Vertex& aV2)
119 Standard_Real aTolV1, aTolV2, aTolSum, aTolSum2, aD2;
122 aTolV1=BRep_Tool::Tolerance(aV1);
123 aTolV2=BRep_Tool::Tolerance(aV2);
124 aTolSum=aTolV1+aTolV2;
125 aTolSum2=aTolSum*aTolSum;
127 aP1=BRep_Tool::Pnt(aV1);
128 aP2=BRep_Tool::Pnt(aV2);
130 aD2=aP1.SquareDistance(aP2);
136 //=======================================================================
139 //=======================================================================
140 Standard_Boolean NMTDS_Tools::HasBRep(const TopAbs_ShapeEnum aTi)
142 return (aTi==TopAbs_VERTEX || aTi==TopAbs_EDGE || aTi==TopAbs_FACE);
144 //=======================================================================
145 //function : TypeToInteger
147 //=======================================================================
148 Standard_Integer NMTDS_Tools::TypeToInteger(const TopAbs_ShapeEnum aType1,
149 const TopAbs_ShapeEnum aType2)
151 Standard_Integer iRet, iT1, iT2, iX;
154 iT1=(Standard_Integer)aType1;
155 iT2=(Standard_Integer)aType2;