1 // Copyright (C) 2007-2011 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
19 // File: NMTDS_Tools.cxx
20 // Created: Tue Feb 20 14:57:28 2007
21 // Author: Peter KURNEV
23 #include <NMTDS_Tools.ixx>
24 #include <TopoDS_Vertex.hxx>
26 #include <BRep_Tool.hxx>
27 #include <TopoDS_Shape.hxx>
28 #include <TopTools_IndexedDataMapOfShapeShape.hxx>
29 #include <TopAbs_ShapeEnum.hxx>
30 #include <TopoDS_Iterator.hxx>
31 #include <BRep_Builder.hxx>
33 void CopySource(const TopoDS_Shape& aS,
34 TopTools_IndexedDataMapOfShapeShape& aMapSS,
37 //=======================================================================
38 //function : CopyShape
40 //=======================================================================
41 void NMTDS_Tools::CopyShape(const TopoDS_Shape& aS,
44 TopTools_IndexedDataMapOfShapeShape aMapSS;
46 CopySource(aS, aMapSS, aSC);
48 //=======================================================================
49 //function : CopyShape
51 //=======================================================================
52 void NMTDS_Tools::CopyShape(const TopoDS_Shape& aS,
54 TopTools_IndexedDataMapOfShapeShape& aMapSS)
56 CopySource(aS, aMapSS, aSC);
58 //=======================================================================
59 //function : CopySource
61 //=======================================================================
62 void CopySource(const TopoDS_Shape& aS,
63 TopTools_IndexedDataMapOfShapeShape& aMapSS,
66 Standard_Boolean bFree;
74 if (aMapSS.Contains(aS)) {
75 aSC=aMapSS.ChangeFromKey(aS);
76 aSC.Orientation(aS.Orientation());
85 aSC.Free(Standard_True);
86 //modified by NIZNHY-PKV Fri Nov 25 10:10:03 2011f
89 TopAbs_Orientation aOr;
92 if(aOr==TopAbs_INTERNAL) {
93 aSF.Orientation(TopAbs_FORWARD);
98 //modified by NIZNHY-PKV Fri Nov 25 10:10:05 2011t
99 for (; aIt.More(); aIt.Next()) {
102 const TopoDS_Shape& aSx=aIt.Value();
104 CopySource (aSx, aMapSS, aSCx);
106 aSCx.Orientation(aSx.Orientation());
111 //=======================================================================
112 // function: ComputeVV
114 //=======================================================================
115 Standard_Integer NMTDS_Tools::ComputeVV(const TopoDS_Vertex& aV1,
116 const TopoDS_Vertex& aV2)
118 Standard_Real aTolV1, aTolV2, aTolSum, aTolSum2, aD2;
121 aTolV1=BRep_Tool::Tolerance(aV1);
122 aTolV2=BRep_Tool::Tolerance(aV2);
123 aTolSum=aTolV1+aTolV2;
124 aTolSum2=aTolSum*aTolSum;
126 aP1=BRep_Tool::Pnt(aV1);
127 aP2=BRep_Tool::Pnt(aV2);
129 aD2=aP1.SquareDistance(aP2);
135 //=======================================================================
138 //=======================================================================
139 Standard_Boolean NMTDS_Tools::HasBRep(const TopAbs_ShapeEnum aTi)
141 return (aTi==TopAbs_VERTEX || aTi==TopAbs_EDGE || aTi==TopAbs_FACE);
143 //=======================================================================
144 //function : TypeToInteger
146 //=======================================================================
147 Standard_Integer NMTDS_Tools::TypeToInteger(const TopAbs_ShapeEnum aType1,
148 const TopAbs_ShapeEnum aType2)
150 Standard_Integer iRet, iT1, iT2, iX;
153 iT1=(Standard_Integer)aType1;
154 iT2=(Standard_Integer)aType2;