fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / NodeCores / Drawables / Nurbs / Internal / OSGDCTPEdge.inl
blobf70ccd0f3d4e2fc3d0691f654e8d6c4c5a1c837d
1 /*---------------------------------------------------------------------------*\
2  *                           OpenSG NURBS Library                            *
3  *                                                                           *
4  *                                                                           *
5  * Copyright (C) 2001-2006 by the University of Bonn, Computer Graphics Group*
6  *                                                                           *
7  *                         http://cg.cs.uni-bonn.de/                         *
8  *                                                                           *
9  * contact: edhellon@cs.uni-bonn.de, guthe@cs.uni-bonn.de, rk@cs.uni-bonn.de *
10  *                                                                           *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
13  *                                License                                    *
14  *                                                                           *
15  * This library is free software; you can redistribute it and/or modify it   *
16  * under the terms of the GNU Library General Public License as published    *
17  * by the Free Software Foundation, version 2.                               *
18  *                                                                           *
19  * This library is distributed in the hope that it will be useful, but       *
20  * WITHOUT ANY WARRANTY; without even the implied warranty of                *
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU         *
22  * Library General Public License for more details.                          *
23  *                                                                           *
24  * You should have received a copy of the GNU Library General Public         *
25  * License along with this library; if not, write to the Free Software       *
26  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                 *
27  *                                                                           *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
30  *                                Changes                                    *
31  *                                                                           *
32  *                                                                           *
33  *                                                                           *
34  *                                                                           *
35  *                                                                           *
36  *                                                                           *
37 \*---------------------------------------------------------------------------*/
39 OSG_BEGIN_NAMESPACE
41 inline DCTPEdge::DCTPEdge(DCTPVertex * vx1, DCTPVertex * vx2, int orient) :
42     v1         (NULL  ),
43     v2         (NULL  ),
44     faces      (      ),
45     orientation(orient),
46     id         (0     ),
47     edgeinfo   (NULL  )
49 #ifndef OSG_NO_EDGE_SET
50     faces.clear();
51     if(vx1 < vx2)
52     {
53         v1          = vx1;
54         v2          = vx2;
55         orientation = orient;
56     }
57     else
58     {
59         v1          = vx2;
60         v2          = vx1;
61         orientation = -orient;
62     }
63 #else
64     v1          = vx1;
65     v2          = vx2;
66     orientation = orient;
67 #endif /* OSG_NO_EDGE_SET */
69     edgeinfo = NULL;
72 inline DCTPEdge::~DCTPEdge(void)
74     // nothing to do
77 inline void DCTPEdge::getVertices(DCTPVertex* & vx1, DCTPVertex* & vx2)
79     vx1 = v1;
80     vx2 = v2;
83 inline void DCTPEdge::setVertices(DCTPVertex* vx1, DCTPVertex*  vx2)
85 #ifndef OSG_NO_EDGE_SET
86     if(vx1 < vx2)
87     {
88         v1 = vx1;
89         v2 = vx2;
90     }
91     else
92     {
93         v1 = vx2;
94         v2 = vx1;
95     }
96 #else
97     v1 = vx1;
98     v2 = vx2;
99 #endif /* OSG_NO_EDGE_SET */
102 inline void DCTPEdge::AddFace(DCTPFace *f)
104     //    std::cerr << v1->coords << " " << v2->coords << f << std::endl;
105     //FIXME: shouldn't warn always...
106     //FIXME: check for adding existing face?
107     if((faces.size() != 0) && (faces[0] == f))
108         return;
110     if(faces.size() >= 2)
111     {
112         if(faces[1] == f)
113             return;
115         std::cerr << "DCTPEdge::AddFace: third (nonmanifold) face supplied... " << faces.size() + 1 << std::endl;
116         // FIXME: operator<< deprecated
117         //      std::cerr << "I am: " << v1->coords << ' ' << v2->coords << std::endl;
118         std::cerr << "The already existing triangles:\n";
120         for(unsigned int i = 0; i < faces.size(); ++i)
121         {
122             std::cerr << "Ptr: " << static_cast<void*>(faces[i]) << ' ';
123             faces[i]->dump_triangle();
124         }
126         std::cerr << "And the new one:\n";
127         std::cerr << "Ptr: " << static_cast<void*>(f) << ' '; f->dump_triangle();
128     }
130     faces.push_back(f);
133 inline void DCTPEdge::RemoveFace(DCTPFace *f)
135     dctpfacevector::iterator fe      = faces.end();
136     bool                     removed = false;
138     for(dctpfacevector::iterator i = faces.begin(); i != fe; ++i)
139     {
140         if(*i == f)
141         {
142             removed = true;
143             faces.erase(i);
144             break;
145         }
146     }
148     if(!removed)
149     {
150         std::cerr << "DCTPEdge::RemoveFace: trying to remove nonexistant face..." << std::endl;
151     }
154 #ifndef OSG_NO_EDGE_SET
155 inline bool DCTPEdge::DCTPEdgeless::operator ()(
156     DCTPEdge *e1, DCTPEdge *e2) const
158     DCTPVertex *e1v1;
159     DCTPVertex *e1v2;
160     DCTPVertex *e2v1;
161     DCTPVertex *e2v2;
162     e1->        getVertices(e1v1, e1v2);
163     e2->        getVertices(e2v1, e2v2);
165     if((e1v1 < e2v1) || (e1v1 == e2v1 && e1v2 < e2v2))
166         return true;
167     else
168         return false;
170 #endif
172 OSG_END_NAMESPACE