0022898: IGES import fails in german environment
[occt.git] / src / Poly / Poly_CoherentNode.cxx
CommitLineData
b311480e 1// Created on: 2007-12-14
2// Created by: Alexander GRIGORIEV
3// Copyright (c) 2007-2012 OPEN CASCADE SAS
4//
5// The content of this file is subject to the Open CASCADE Technology Public
6// License Version 6.5 (the "License"). You may not use the content of this file
7// except in compliance with the License. Please obtain a copy of the License
8// at http://www.opencascade.org and read it completely before using this file.
9//
10// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12//
13// The Original Code and all software distributed under the License is
14// distributed on an "AS IS" basis, without warranty of any kind, and the
15// Initial Developer hereby disclaims all such warranties, including without
16// limitation, any warranties of merchantability, fitness for a particular
17// purpose or non-infringement. Please see the License for the specific terms
18// and conditions governing the rights and limitations under the License.
19
7fd59977 20
21
22#include <Poly_CoherentNode.hxx>
23#include <Poly_CoherentTriangle.hxx>
24
25#ifdef WNT
1c35b92f 26#pragma warning(disable:4996)
7fd59977 27#endif
28
29//=======================================================================
30//function : Clear
31//purpose :
32//=======================================================================
33
34void Poly_CoherentNode::Clear (const Handle_NCollection_BaseAllocator& theAlloc)
35{
36 Poly_CoherentTriPtr::RemoveList (myTriangles, theAlloc);
37 myUV[0] = Precision::Infinite();
38 myUV[1] = Precision::Infinite();
39 myNormal[0] = 0.f;
40 myNormal[1] = 0.f;
41 myNormal[2] = 0.f;
42 SetCoord(0., 0., 0.);
43}
44
45//=======================================================================
46//function : SetNormal
47//purpose : Define the normal vector in the Node.
48//=======================================================================
49
50void Poly_CoherentNode::SetNormal (const gp_XYZ& theVector)
51{
52 myNormal[0] = static_cast<Standard_ShortReal>(theVector.X());
53 myNormal[1] = static_cast<Standard_ShortReal>(theVector.Y());
54 myNormal[2] = static_cast<Standard_ShortReal>(theVector.Z());
55}
56
57//=======================================================================
58//function : AddTriangle
59//purpose :
60//=======================================================================
61
62void Poly_CoherentNode::AddTriangle
63 (const Poly_CoherentTriangle& theTri,
64 const Handle_NCollection_BaseAllocator& theAlloc)
65{
66 if (myTriangles == NULL)
67 myTriangles = new (theAlloc) Poly_CoherentTriPtr(theTri);
68 else
69 myTriangles->Prepend(&theTri, theAlloc);
70}
71
72//=======================================================================
73//function : RemoveTriangle
74//purpose :
75//=======================================================================
76
77Standard_Boolean Poly_CoherentNode::RemoveTriangle
78 (const Poly_CoherentTriangle& theTri,
79 const Handle_NCollection_BaseAllocator& theAlloc)
80{
81 Standard_Boolean aResult(Standard_False);
82 if (&myTriangles->GetTriangle() == &theTri) {
83 Poly_CoherentTriPtr * aLostPtr = myTriangles;
84 if (myTriangles == &myTriangles->Next())
85 myTriangles = 0L;
86 else
87 myTriangles = &myTriangles->Next();
88 Poly_CoherentTriPtr::Remove(aLostPtr, theAlloc);
89 aResult = Standard_True;
90 } else {
91 Poly_CoherentTriPtr::Iterator anIter(* myTriangles);
92 for (anIter.Next(); anIter.More(); anIter.Next())
93 if (&anIter.Value() == &theTri) {
94 Poly_CoherentTriPtr::Remove
95 (const_cast<Poly_CoherentTriPtr *>(&anIter.PtrValue()), theAlloc);
96 aResult = Standard_True;
97 break;
98 }
99 }
100 return aResult;
101}
102
103//=======================================================================
104//function : Dump
105//purpose :
106//=======================================================================
107
108void Poly_CoherentNode::Dump(Standard_OStream& theStream) const
109{
110 char buf[256];
91322f44 111 Sprintf (buf, " X =%9.4f; Y =%9.4f; Z =%9.4f", X(), Y(), Z());
7fd59977 112 theStream << buf << endl;
113 Poly_CoherentTriPtr::Iterator anIter(* myTriangles);
114 for (; anIter.More(); anIter.Next()) {
115 const Poly_CoherentTriangle& aTri = anIter.Value();
91322f44 116 Sprintf (buf, " %5d %5d %5d", aTri.Node(0),aTri.Node(1),aTri.Node(2));
7fd59977 117 theStream << buf << endl;
118 }
119}