1 // Created on: 2007-12-14
2 // Created by: Alexander GRIGORIEV
3 // Copyright (c) 2007-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #include <Poly_CoherentNode.hxx>
17 #include <Poly_CoherentTriangle.hxx>
20 #pragma warning(disable:4996)
23 //=======================================================================
26 //=======================================================================
28 void Poly_CoherentNode::Clear (const Handle(NCollection_BaseAllocator)& theAlloc)
30 Poly_CoherentTriPtr::RemoveList (myTriangles, theAlloc);
31 myUV[0] = Precision::Infinite();
32 myUV[1] = Precision::Infinite();
39 //=======================================================================
40 //function : SetNormal
41 //purpose : Define the normal vector in the Node.
42 //=======================================================================
44 void Poly_CoherentNode::SetNormal (const gp_XYZ& theVector)
46 myNormal[0] = static_cast<Standard_ShortReal>(theVector.X());
47 myNormal[1] = static_cast<Standard_ShortReal>(theVector.Y());
48 myNormal[2] = static_cast<Standard_ShortReal>(theVector.Z());
51 //=======================================================================
52 //function : AddTriangle
54 //=======================================================================
56 void Poly_CoherentNode::AddTriangle
57 (const Poly_CoherentTriangle& theTri,
58 const Handle(NCollection_BaseAllocator)& theAlloc)
60 if (myTriangles == NULL)
61 myTriangles = new (theAlloc) Poly_CoherentTriPtr(theTri);
63 myTriangles->Prepend(&theTri, theAlloc);
66 //=======================================================================
67 //function : RemoveTriangle
69 //=======================================================================
71 Standard_Boolean Poly_CoherentNode::RemoveTriangle
72 (const Poly_CoherentTriangle& theTri,
73 const Handle(NCollection_BaseAllocator)& theAlloc)
75 Standard_Boolean aResult(Standard_False);
76 if (&myTriangles->GetTriangle() == &theTri) {
77 Poly_CoherentTriPtr * aLostPtr = myTriangles;
78 if (myTriangles == &myTriangles->Next())
81 myTriangles = &myTriangles->Next();
82 Poly_CoherentTriPtr::Remove(aLostPtr, theAlloc);
83 aResult = Standard_True;
85 Poly_CoherentTriPtr::Iterator anIter(* myTriangles);
86 for (anIter.Next(); anIter.More(); anIter.Next())
87 if (&anIter.Value() == &theTri) {
88 Poly_CoherentTriPtr::Remove
89 (const_cast<Poly_CoherentTriPtr *>(&anIter.PtrValue()), theAlloc);
90 aResult = Standard_True;
97 //=======================================================================
100 //=======================================================================
102 void Poly_CoherentNode::Dump(Standard_OStream& theStream) const
105 Sprintf (buf, " X =%9.4f; Y =%9.4f; Z =%9.4f", X(), Y(), Z());
106 theStream << buf << endl;
107 Poly_CoherentTriPtr::Iterator anIter(* myTriangles);
108 for (; anIter.More(); anIter.Next()) {
109 const Poly_CoherentTriangle& aTri = anIter.Value();
110 Sprintf (buf, " %5d %5d %5d", aTri.Node(0),aTri.Node(1),aTri.Node(2));
111 theStream << buf << endl;