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>
19 //=======================================================================
22 //=======================================================================
24 void Poly_CoherentNode::Clear (const Handle(NCollection_BaseAllocator)& theAlloc)
26 Poly_CoherentTriPtr::RemoveList (myTriangles, theAlloc);
27 myUV[0] = Precision::Infinite();
28 myUV[1] = Precision::Infinite();
35 //=======================================================================
36 //function : SetNormal
37 //purpose : Define the normal vector in the Node.
38 //=======================================================================
40 void Poly_CoherentNode::SetNormal (const gp_XYZ& theVector)
42 myNormal[0] = static_cast<Standard_ShortReal>(theVector.X());
43 myNormal[1] = static_cast<Standard_ShortReal>(theVector.Y());
44 myNormal[2] = static_cast<Standard_ShortReal>(theVector.Z());
47 //=======================================================================
48 //function : AddTriangle
50 //=======================================================================
52 void Poly_CoherentNode::AddTriangle
53 (const Poly_CoherentTriangle& theTri,
54 const Handle(NCollection_BaseAllocator)& theAlloc)
56 if (myTriangles == NULL)
57 myTriangles = new (theAlloc) Poly_CoherentTriPtr(theTri);
59 myTriangles->Prepend(&theTri, theAlloc);
62 //=======================================================================
63 //function : RemoveTriangle
65 //=======================================================================
67 Standard_Boolean Poly_CoherentNode::RemoveTriangle
68 (const Poly_CoherentTriangle& theTri,
69 const Handle(NCollection_BaseAllocator)& theAlloc)
71 Standard_Boolean aResult(Standard_False);
72 if (&myTriangles->GetTriangle() == &theTri) {
73 Poly_CoherentTriPtr * aLostPtr = myTriangles;
74 if (myTriangles == &myTriangles->Next())
77 myTriangles = &myTriangles->Next();
78 Poly_CoherentTriPtr::Remove(aLostPtr, theAlloc);
79 aResult = Standard_True;
81 Poly_CoherentTriPtr::Iterator anIter(* myTriangles);
82 for (anIter.Next(); anIter.More(); anIter.Next())
83 if (&anIter.Value() == &theTri) {
84 Poly_CoherentTriPtr::Remove
85 (const_cast<Poly_CoherentTriPtr *>(&anIter.PtrValue()), theAlloc);
86 aResult = Standard_True;
93 //=======================================================================
96 //=======================================================================
98 void Poly_CoherentNode::Dump(Standard_OStream& theStream) const
101 Sprintf (buf, " X =%9.4f; Y =%9.4f; Z =%9.4f", X(), Y(), Z());
102 theStream << buf << std::endl;
103 Poly_CoherentTriPtr::Iterator anIter(* myTriangles);
104 for (; anIter.More(); anIter.Next()) {
105 const Poly_CoherentTriangle& aTri = anIter.Value();
106 Sprintf (buf, " %5d %5d %5d", aTri.Node(0),aTri.Node(1),aTri.Node(2));
107 theStream << buf << std::endl;