1 /*---------------------------------------------------------------------------*\
2 * OpenSG NURBS Library *
5 * Copyright (C) 2001-2006 by the University of Bonn, Computer Graphics Group*
7 * http://cg.cs.uni-bonn.de/ *
9 * contact: edhellon@cs.uni-bonn.de, guthe@cs.uni-bonn.de, rk@cs.uni-bonn.de *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
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. *
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. *
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. *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
37 \*---------------------------------------------------------------------------*/
41 inline ParSpaceTrimmerError::ParSpaceTrimmerError(void) :
46 inline ParSpaceTrimmerError::ParSpaceTrimmerError(int t)
51 inline ParSpaceTrimmerError::~ParSpaceTrimmerError(void)
56 inline bool SScanLineEventLess::operator() (
57 const SScanLineEvent *ptEvent1, const SScanLineEvent *ptEvent2) const
59 const SScanLineEdge *cui_e1 = ptEvent1->ptEdge;
60 const SScanLineEdge *cui_e2 = ptEvent2->ptEdge;
62 // std::cerr << cui_e1 << " " << cui_e2 << std::endl;
63 if( ( cui_e1 == cui_e2 ) && ( ptEvent1->bStart == ptEvent2->bStart ) )
66 // std::cerr << "same event!" << std::endl;
67 // std::cerr << ptEvent1->ptEdge << " <-> " << ptEvent2->ptEdge << std::endl;
68 // std::cerr << ptEvent1->bStart << " <-> " << ptEvent2->bStart << std::endl;
73 if( osgAbs( ptEvent1->clPos[1] - ptEvent2->clPos[1] ) > 1e-15 )
75 return ptEvent1->clPos[1] < ptEvent2->clPos[1];
79 if( osgAbs( ptEvent1->clPos[0] - ptEvent2->clPos[0] ) > 1e-15 )
81 return ptEvent1->clPos[0] < ptEvent2->clPos[0];
84 if(DCTPVecIsNotEqual(ptEvent1->clPos, ptEvent2->clPos) )
86 // return ( ptEvent1->clPos < ptEvent2->clPos );
87 return ( DCTPVecIsLesser(ptEvent1->clPos, ptEvent2->clPos) );
90 if( ( ptEvent1->bStart ) && !( ptEvent2->bStart ) )
92 if(!( ptEvent1->bStart ) && ( ptEvent2->bStart ) )
95 // std::cerr << "start = " << ptEvent1->bStart << " " << ptEvent2->bStart;
96 // std::cerr << " checking dirs..." << std::endl;
100 dir1 = ptEvent1->clOther - ptEvent1->clPos;
101 dir2 = ptEvent2->clOther - ptEvent2->clPos;
102 if(DCTPVecIsNotEqual(dir1, dir2) )
104 if(!ptEvent1->bStart)
110 if(osgAbs(dir1[1]) < DCTP_EPS)
112 if(osgAbs(dir2[1]) < DCTP_EPS)
114 if(dir1[0] < 0.0) // this can't be zero!
117 return true; // this can't be zero!
122 return false; // this can't be zero!
124 // return ( dir1[0] < dir2[0] );
128 // std::cerr << "( dir1[0] < 0.0 )" << dir1[0];
129 return ( dir1[0] < 0.0 ); // this can't be zero!
132 else if(osgAbs(dir2[1]) < DCTP_EPS)
134 // std::cerr << "( dir2[0] > 0.0 )" << dir2[0];
135 return ( dir2[0] > 0.0 ); // this can't be zero!
139 const double r1 = dir1[0] / dir1[1];
140 const double r2 = dir2[0] / dir2[1];
142 if(osgAbs(r1 - r2) >= DCTP_EPS)
149 // this can only be false for both ways, if it is the same edge!
150 return( cui_e1 < cui_e2 );
155 inline bool SPolySimVertexLess::operator() (
156 const SPolySimVertex *ptVertex1, const SPolySimVertex *ptVertex2) const
158 if(ptVertex2->dSimplifyError - ptVertex1->dSimplifyError > 1e-20)
160 if(ptVertex1->dSimplifyError - ptVertex2->dSimplifyError > 1e-20)
162 return ( ptVertex1->uiIndex < ptVertex2->uiIndex );
166 inline ParSpaceTrimmer::ParSpaceTrimmer(void) :
168 tcs(NULL), //trimming curves
169 tcs3d(NULL), // 3d trimming curves
170 terr(0), // trimming error (used for 3d loops only!)
172 start_face(NULL), //the face in which the curve starts (if it starts OVER_FACE)
173 ie(NULL), //last intersected edge
174 ip(0.0), //intersection parameter on bezier curve
178 #ifdef OSG_FORCE_NO_T_VERTICES
179 /* #ifndef OSG_CREATE_NORMAL_MAPS
180 std::vector< std::vector< Vec3d > > *m_pvvclNormals;
182 #ifdef OSG_KEEP_2D_POINTS
186 m_bDeleteVertexInfo(false),
189 #ifdef OSG_ADAPTIVE_QUAD_TREE
195 #ifdef OSG_USE_SIMPLIFIER
199 // std::cerr << "pst constr" << std::endl;
202 inline ParSpaceTrimmer::~ParSpaceTrimmer(void)
204 // std::cerr << "pst destr" << std::endl;
205 if(m_bDeleteVertexInfo)