Bug fixes and debug enhancements.

This commit is contained in:
Fernando Cacciola 2006-02-16 16:07:03 +00:00
parent 470069c53c
commit f99b9ccc26
11 changed files with 242 additions and 95 deletions

View File

@ -1,6 +1,5 @@
1 February 2006
16 February 2006
* Finish the handling of degenerate vertices (collinear consecutive edges)
* Create and add pictures to the docs
* Fix compilation and doc errors as shown in the testsuites

View File

@ -1,2 +1,4 @@
07 February 2005 Andreas Fabri
- Put the file under version control.
16 February 2006 Fernando Cacciola
- Bug fixes. ALL current sample cases pass for the first time (with both the SLS and the Offseting)

View File

@ -9,7 +9,7 @@
<ignoreparts/>
<projectdirectory>.</projectdirectory>
<absoluteprojectpath>false</absoluteprojectpath>
<description></description>
<description/>
<secondaryLanguages/>
<versioncontrol/>
</general>
@ -18,37 +18,37 @@
<mainprogram>straight_skeleton_2</mainprogram>
<directoryradio>build</directoryradio>
<customdirectory>/</customdirectory>
<programargs></programargs>
<programargs/>
<terminal>false</terminal>
<autocompile>true</autocompile>
<envvars/>
</run>
<build>
<buildtool>make</buildtool>
<builddir></builddir>
<builddir/>
</build>
<make>
<abortonerror>false</abortonerror>
<numberofjobs>1</numberofjobs>
<prio>0</prio>
<dontact>false</dontact>
<makebin></makebin>
<makebin/>
<makeoptions>CGAL_MAKEFILE=/home/fcacciola/Programming/CGAL/make/makefile_i686_Linux-2.6_g++-3.3.5</makeoptions>
<selectedenvironment>default</selectedenvironment>
<environments>
<default/>
</environments>
<defaulttarget></defaulttarget>
<defaulttarget/>
</make>
</kdevcustomproject>
<kdevdebugger>
<general>
<dbgshell></dbgshell>
<programargs></programargs>
<gdbpath></gdbpath>
<configGdbScript></configGdbScript>
<runShellScript></runShellScript>
<runGdbScript></runGdbScript>
<dbgshell/>
<programargs/>
<gdbpath/>
<configGdbScript/>
<runShellScript/>
<runGdbScript/>
<breakonloadinglibs>true</breakonloadinglibs>
<separatetty>false</separatetty>
<floatingtoolbar>false</floatingtoolbar>
@ -134,7 +134,7 @@
</codecompletion>
<references/>
<creategettersetter>
<prefixGet></prefixGet>
<prefixGet/>
<prefixSet>set</prefixSet>
<prefixVariable>m_,_</prefixVariable>
<parameterName>theValue</parameterName>
@ -161,8 +161,8 @@
</kdevfileview>
<kdevvisualadvance>
<emulator>VisualBoyAdvance</emulator>
<binary></binary>
<addOptions></addOptions>
<binary/>
<addOptions/>
<terminal>false</terminal>
<fullscreen>false</fullscreen>
<graphicFilter>-f0</graphicFilter>

View File

@ -207,8 +207,11 @@ private:
//#define CGAL_STRAIGHT_SKELETON_ENABLE_TRACE
//#define CGAL_STRAIGHT_SKELETON_ENABLE_SHOW
//#define CGAL_STRAIGHT_SKELETON_ENABLE_SHOW_AUX
//#define CGAL_POLYGON_OFFSET_ENABLE_TRACE
//#define CGAL_POLYGON_OFFSET_ENABLE_SHOW
//#define CGAL_POLYGON_OFFSET_ENABLE_SHOW_AUX
#ifdef CGAL_STRAIGHT_SKELETON_ENABLE_TRACE
#if defined(CGAL_STRAIGHT_SKELETON_ENABLE_TRACE) || defined(CGAL_POLYGON_OFFSET_ENABLE_TRACE)
void Straight_skeleton_external_trace ( std::string s )
{
static std::ofstream lout("ss_builder_log");
@ -217,7 +220,7 @@ void Straight_skeleton_external_trace ( std::string s )
}
#endif
#ifdef CGAL_STRAIGHT_SKELETON_ENABLE_SHOW
#if defined(CGAL_STRAIGHT_SKELETON_ENABLE_SHOW) || defined(CGAL_POLYGON_OFFSET_ENABLE_SHOW)
ActiveCanvasClient sAC_Client ;
@ -524,31 +527,49 @@ private slots:
QString::null, "Polygonal PolygonalRegion Files (*.poly)", this ) );
if ( s.isEmpty() )
return;
std::ifstream in(s);
CGAL::set_ascii_mode(in);
input_region.clear();
int ccb_count ;
in >> ccb_count ;
for ( int i = 0 ; i < ccb_count ; ++ i )
bool auto_offset_table = true ;
std::ifstream offset_table(s + QString(".oft") );
if ( offset_table )
{
PolygonPtr poly( new Polygon() );
in >> *poly;
if ( i == 0 )
CGAL::set_ascii_mode(offset_table);
offset_table >> offset_val;
offset_table >> offset_steps ;
auto_offset_table = false ;
}
std::ifstream in(s);
if ( in )
{
CGAL::set_ascii_mode(in);
input_region.clear();
int ccb_count ;
in >> ccb_count ;
for ( int i = 0 ; i < ccb_count ; ++ i )
{
CGAL::Bbox_2 lBbox = poly->bbox();
double w = lBbox.xmax() - lBbox.xmin();
double h = lBbox.ymax() - lBbox.ymin();
double s = std::sqrt(w*w+h*h);
double m = s * 0.01 ;
widget->set_window(lBbox.xmin()-m, lBbox.xmax()+m, lBbox.ymin()-m, lBbox.ymax()+m);
offset_val = m ;
offset_steps = 30 ;
PolygonPtr poly( new Polygon() );
in >> *poly;
if ( i == 0 )
{
CGAL::Bbox_2 lBbox = poly->bbox();
double w = lBbox.xmax() - lBbox.xmin();
double h = lBbox.ymax() - lBbox.ymin();
double s = std::sqrt(w*w+h*h);
double m = s * 0.01 ;
widget->set_window(lBbox.xmin()-m, lBbox.xmax()+m, lBbox.ymin()-m, lBbox.ymax()+m);
if ( auto_offset_table )
{
offset_val = m ;
offset_steps = 30 ;
}
}
CGAL::Orientation expected = ( input_region.size() == 0 ? CGAL::COUNTERCLOCKWISE : CGAL::CLOCKWISE ) ;
if ( poly->orientation() != expected )
poly->reverse_orientation();
input_region.push_back(poly);
}
CGAL::Orientation expected = ( input_region.size() == 0 ? CGAL::COUNTERCLOCKWISE : CGAL::CLOCKWISE ) ;
if ( poly->orientation() != expected )
poly->reverse_orientation();
input_region.push_back(poly);
}
offset_region.clear();

View File

@ -1 +1 @@
Straight line skeleton computation
Straight line skeleton computation and SLS-Based Polygon Offseting.

View File

@ -12,7 +12,7 @@
//
// $URL$
// $Id$
//
//
// Author(s) : Fernando Cacciola <fernando_cacciola@ciudad.com.ar>
//
#ifndef CGAL_POLYGON_OFFSET_BUILDER_2_C
@ -24,42 +24,62 @@ template<class Sls, class Gt, class Cont>
Polygon_offset_builder_2<Sls,Gt,Cont>::Polygon_offset_builder_2( Sls const& aSls, Traits const& aTraits )
:
mTraits(aTraits)
,mVisitedBisectors(aSls.size_of_halfedges())
{
int lMaxID = -1 ;
for ( Halfedge_const_handle lHE = aSls.halfedges_begin() ; lHE != aSls.halfedges_end() ; ++ lHE )
if ( !lHE->is_bisector() )
{
if ( lHE->id() > lMaxID )
lMaxID = lHE->id() ;
if ( !lHE->is_bisector() && handle_assigned(lHE->face()) )
{
CGAL_POLYOFFSET_SHOW ( DrawBorder(lHE) ) ;
mBorders.push_back(lHE);
}
}
CGAL_POLYOFFSET_TRACE("Border count: " << mBorders.size() ) ;
CGAL_POLYOFFSET_TRACE("Highest Bisector ID: " << lMaxID ) ;
mVisitedBisectors.resize(lMaxID+1);
ResetVisitedBisectorsMap();
}
template<class Sls, class Gt, class Cont>
typename Polygon_offset_builder_2<Sls,Gt,Cont>::Halfedge_const_handle
Polygon_offset_builder_2<Sls,Gt,Cont>::LocateHook( FT aTime, Halfedge_const_handle aBisector, bool aAbove )
Polygon_offset_builder_2<Sls,Gt,Cont>::LocateHook( FT aTime, Halfedge_const_handle aBisector )
{
CGAL_POLYOFFSET_TRACE("Searching for hook at " << aTime ) ;
Halfedge_const_handle rHook ;
while ( aBisector->is_bisector() )
{
CGAL_POLYOFFSET_TRACE("Testing hook on B" << aBisector->id() ) ;
Halfedge_const_handle lPrev = aBisector->prev();
Halfedge_const_handle lNext = aBisector->next();
if ( !IsVisited(aBisector) )
{
if ( lNext->is_bisector() )
{
Comparison_result lC = Compare_offset_against_event_time(aTime,aBisector,lNext) ;
if ( (aAbove && lC != SMALLER ) || (!aAbove && lC != LARGER) )
{
rHook = aBisector ;
break ;
}
}
else
{
if ( !aAbove )
rHook = aBisector ;
}
Comparison_result lCNext = lNext->is_bisector() ? Compare_offset_against_event_time(aTime,aBisector,lNext)
: SMALLER ;
Comparison_result lCPrev = lPrev->is_bisector() ? Compare_offset_against_event_time(aTime,lPrev,aBisector)
: SMALLER ;
CGAL_POLYOFFSET_TRACE("CPrev: " << lCPrev << " CNext: " << lCNext ) ;
if ( lCNext != lCPrev )
{
CGAL_POLYOFFSET_TRACE( "Hook found on B" << aBisector->id() ) ;
rHook = aBisector ;
break ;
}
}
aBisector = lNext ;
}
@ -77,46 +97,68 @@ Polygon_offset_builder_2<Sls,Gt,Cont>::LocateSeed( FT aTime )
; f != mBorders.end() && !handle_assigned(rSeed)
; ++ f
)
rSeed = LocateHook(aTime,(*f)->next(),true);
{
CGAL_POLYOFFSET_TRACE("Locating hook for face E" << (*f)->id() ) ;
rSeed = LocateHook(aTime,(*f)->next());
}
CGAL_POLYOFFSET_TRACE("Seed found on B" << ( handle_assigned(rSeed) ? rSeed->id() : -1 ) ) ;
return rSeed;
}
template<class Sls, class Gt, class Cont>
void Polygon_offset_builder_2<Sls,Gt,Cont>::AddOffsetVertex( FT aTime, Halfedge_const_handle aHook, ContainerPtr aPoly )
{
Visit(aHook);
Point_2 lP = Construct_offset_point(aTime,aHook);
CGAL_POLYOFFSET_SHOW ( DrawBisector(aHook) ) ;
CGAL_POLYOFFSET_SHOW ( DrawOffset(aPoly,lP) ) ;
CGAL_POLYOFFSET_TRACE("Constructing offset point along B" << aHook->id() ) ;
aPoly->push_back(lP);
}
template<class Sls, class Gt, class Cont>
template<class OutputIterator>
OutputIterator Polygon_offset_builder_2<Sls,Gt,Cont>::TraceOffsetPolygon( FT aTime, Halfedge_const_handle aSeed, OutputIterator aOut )
{
CGAL_POLYOFFSET_TRACE("Tracing new offset polygon" ) ;
ContainerPtr lPoly( new Container() ) ;
Halfedge_const_handle lHookL = aSeed ;
Halfedge_const_handle lHook = aSeed ;
AddOffsetVertex(aTime,lHook,lPoly);
while ( true )
{
//ACGEO_OFFSET_SHOW ( AutoACObject _( DrawSegment(lHookL.mBorderHE->segment(),Magenta,"OffsetAux") ) ) ;
Visit(lHookL);
lHook = LocateHook(aTime,lHook->next()) ;
Halfedge_const_handle lHookR = LocateHook(aTime,lHookL->next(),false) ;
if ( handle_assigned(lHookR) )
if ( handle_assigned(lHook) )
{
Visit(lHookR);
AddOffsetVertex(aTime,lHook,lPoly);
lPoly->push_back(Construct_offset_point(aTime,lHookR));
Halfedge_const_handle lNextBisector = lHookR->opposite();
Halfedge_const_handle lNextBisector = lHook->opposite();
if ( lNextBisector != aSeed && !IsVisited(lNextBisector) )
{
lHookL = lNextBisector;
lHook = lNextBisector;
continue;
}
}
break ;
}
CGAL_SSBUILDER_TRACE("Offset polygon of " << lPoly->size() << " vertices traced." ) ;
CGAL_POLYOFFSET_SHOW ( DrawOffset(lPoly,(*lPoly)[0]) ) ;
if ( lPoly->size() >= 3 )
{
CGAL_POLYOFFSET_TRACE("Offset polygon of " << lPoly->size() << " vertices traced." ) ;
*aOut++ = lPoly ;
}
// ResetVisitedBisectorsMap();
return aOut ;
}
@ -131,9 +173,11 @@ template<class Sls, class Gt, class Cont>
template<class OutputIterator>
OutputIterator Polygon_offset_builder_2<Sls,Gt,Cont>::construct_offset_polygons( FT aTime, OutputIterator aOut )
{
CGAL_precondition( aTime > static_cast<FT>(0.0) ) ;
ResetVisitedBisectorsMap();
CGAL_SSBUILDER_TRACE("Constructing offset polygons for offset: " << aTime ) ;
CGAL_POLYOFFSET_TRACE("Constructing offset polygons for offset: " << aTime ) ;
for ( Halfedge_const_handle lSeed = LocateSeed(aTime); handle_assigned(lSeed); lSeed = LocateSeed(aTime) )
aOut = TraceOffsetPolygon(aTime,lSeed,aOut);

View File

@ -12,7 +12,7 @@
//
// $URL$
// $Id$
//
//
// Author(s) : Fernando Cacciola <fernando_cacciola@ciudad.com.ar>
//
#ifndef CGAL_POLYGON_OFFSET_BUILDER_2_H
@ -63,7 +63,9 @@ private:
return aH != cNull ;
}
Halfedge_const_handle LocateHook( FT aTime, Halfedge_const_handle aBisector, bool aAbove ) ;
Halfedge_const_handle LocateHook( FT aTime, Halfedge_const_handle aBisector ) ;
void AddOffsetVertex( FT aTime, Halfedge_const_handle aHook, ContainerPtr aPoly ) ;
template<class OutputIterator>
OutputIterator TraceOffsetPolygon( FT aTime, Halfedge_const_handle aHook, OutputIterator aOut ) ;
@ -119,6 +121,44 @@ private:
void ResetVisitedBisectorsMap();
#ifdef CGAL_POLYGON_OFFSET_ENABLE_SHOW
template<class Halfedge>
void DrawBorder ( Halfedge aHalfedge )
{
SS_IO_AUX::ScopedSegmentDrawing draw_( aHalfedge->opposite()->vertex()->point()
, aHalfedge->vertex()->point()
, CGAL::RED
, "Border"
) ;
draw_.Release();
}
template<class Halfedge>
void DrawBisector ( Halfedge aHalfedge )
{
SS_IO_AUX::ScopedSegmentDrawing draw_( aHalfedge->opposite()->vertex()->point()
, aHalfedge->vertex()->point()
, aHalfedge->is_inner_bisector() ? CGAL::BLUE : CGAL::GREEN
, aHalfedge->is_inner_bisector() ? "IBisector" : "CBisector"
) ;
draw_.Release();
}
void DrawOffset ( ContainerPtr const& aPoly, Point_2 const& aP )
{
if ( aPoly->size() > 0 )
{
SS_IO_AUX::ScopedSegmentDrawing draw_( (*aPoly)[aPoly->size()-1], aP, CGAL::BLACK, "Offset" ) ;
draw_.Release();
}
else
{
SS_IO_AUX::ScopedPointDrawing draw_( aP, CGAL::BLACK, "Seed" ) ;
draw_.Release();
}
}
#endif
Traits const& mTraits ;
std::vector<int> mVisitedBisectors;
Halfedge_vector mBorders ;

View File

@ -12,31 +12,41 @@
//
// $URL$
// $Id$
//
//
// Author(s) : Fernando Cacciola <fernando_cacciola@ciudad.com.ar>
//
#ifndef CGAL_STRAIGHT_SKELETON_AUX_H
#define CGAL_STRAIGHT_SKELETON_AUX_H 1
#ifdef CGAL_STRAIGHT_SKELETON_ENABLE_TRACE
#if defined(CGAL_STRAIGHT_SKELETON_ENABLE_TRACE) || defined(CGAL_POLYGON_OFFSET_ENABLE_TRACE)
#define CGAL_SLS_ENABLE_TRACE
#endif
#if defined(CGAL_STRAIGHT_SKELETON_ENABLE_SHOW) \
|| defined(CGAL_POLYGON_OFFSET_ENABLE_SHOW) \
|| defined(CGAL_STRAIGHT_SKELETON_ENABLE_SHOW_AUX) \
|| defined(CGAL_POLYGON_OFFSET_ENABLE_SHOW_AUX)
#define CGAL_SLS_ENABLE_SHOW
#endif
#ifdef CGAL_SLS_ENABLE_TRACE
# include<string>
# include<iostream>
# include<sstream>
# define CGAL_SSBUILDER_TRACE(m) \
# define CGAL_SLS_TRACE(m) \
{ \
std::ostringstream ss ; \
ss << m << std::ends ; \
std::string s = ss.str(); \
Straight_skeleton_external_trace(s); \
}
#else
# define CGAL_SSBUILDER_TRACE(m)
#endif
#ifdef CGAL_STRAIGHT_SKELETON_ENABLE_SHOW_AUX
# define CGAL_SSBUILDER_SHOW_AUX(code) code
#ifdef CGAL_STRAIGHT_SKELETON_ENABLE_TRACE
# define CGAL_SSBUILDER_TRACE(m) CGAL_SLS_TRACE(m)
#else
# define CGAL_SSBUILDER_SHOW_AUX(code)
# define CGAL_SSBUILDER_TRACE(m)
#endif
#ifdef CGAL_STRAIGHT_SKELETON_ENABLE_SHOW
@ -45,9 +55,34 @@
# define CGAL_SSBUILDER_SHOW(code)
#endif
#ifdef CGAL_STRAIGHT_SKELETON_ENABLE_SHOW_AUX
# define CGAL_SSBUILDER_SHOW_AUX(code) code
#else
# define CGAL_SSBUILDER_SHOW_AUX(code)
#endif
#ifdef CGAL_POLYGON_OFFSET_ENABLE_TRACE
# define CGAL_POLYOFFSET_TRACE(m) CGAL_SLS_TRACE(m)
#else
# define CGAL_POLYOFFSET_TRACE(m)
#endif
#ifdef CGAL_POLYGON_OFFSET_ENABLE_SHOW
# define CGAL_POLYOFFSET_SHOW(code) code
#else
# define CGAL_POLYOFFSET_SHOW(code)
#endif
#ifdef CGAL_POLYGON_OFFSET_ENABLE_SHOW_AUX
# define CGAL_POLYOFFSET_SHOW_AUX(code) code
#else
# define CGAL_POLYOFFSET_SHOW_AUX(code)
#endif
CGAL_BEGIN_NAMESPACE
#ifdef CGAL_STRAIGHT_SKELETON_ENABLE_SHOW
#ifdef CGAL_SLS_ENABLE_SHOW
namespace SS_IO_AUX
{
class ScopedDrawing
@ -110,6 +145,7 @@ namespace SS_IO_AUX
}
#endif
class Ref_counted_base
{
private:
@ -128,12 +164,16 @@ public:
}
};
CGAL_END_NAMESPACE
namespace boost
{
inline void intrusive_ptr_add_ref( CGAL::Ref_counted_base const* p ) { p->AddRef(); }
inline void intrusive_ptr_release( CGAL::Ref_counted_base const* p ) { p->Release(); }
} // namespace boost
#undef CGAL_SLS_ENABLE_TRACE
#undef CGAL_SLS_ENABLE_SHOW
#endif // CGAL_STRAIGHT_SKELETON_AUX_H //
// EOF //

View File

@ -12,7 +12,7 @@
//
// $URL$
// $Id$
//
//
// Author(s) : Fernando Cacciola <fernando_cacciola@ciudad.com.ar>
//
#ifndef CGAL_STRAIGHT_SKELETON_BUILDER_2_C
@ -86,7 +86,7 @@ Straight_skeleton_builder_2<Gt,SS>::FindEdgeEvent( Vertex_handle aLNode, Vertex_
) == SMALLER
)
{
CGAL_SSBUILDER_TRACE("New event for Left seed N" << aLNode->id() << " is in the past. discarded." ) ;
CGAL_SSBUILDER_TRACE("New edge event for Left seed N" << aLNode->id() << " is in the past. discarded." ) ;
lAccepted = false ;
}
}
@ -98,7 +98,7 @@ Straight_skeleton_builder_2<Gt,SS>::FindEdgeEvent( Vertex_handle aLNode, Vertex_
) == SMALLER
)
{
CGAL_SSBUILDER_TRACE("New event for Right seed N" << aRNode->id() << " is in the past. discarded." ) ;
CGAL_SSBUILDER_TRACE("New edge event for Right seed N" << aRNode->id() << " is in the past. discarded." ) ;
lAccepted = false ;
}
}
@ -143,10 +143,10 @@ void Straight_skeleton_builder_2<Gt,SS>::CollectSplitEvent( Vertex_handle aNo
{
if ( CompareEvents( CreateTriedge(aReflexLBorder,aReflexRBorder,aOppositeBorder)
, CreateTriedge(GetSkeletonVertexDefiningBorders(aNode))
) != SMALLER
) == SMALLER
)
{
CGAL_SSBUILDER_TRACE("New event for Split seed N" << aNode->id() << " is in the past. discarded." ) ;
CGAL_SSBUILDER_TRACE("New split event for Seed N" << aNode->id() << " is in the past. discarded." ) ;
lAccepted = false ;
}
}

View File

@ -12,7 +12,7 @@
//
// $URL$
// $Id$
//
//
// Author(s) : Fernando Cacciola <fernando_cacciola@ciudad.com.ar>
//
#ifndef CGAL_STRAIGHT_SKELETON_BUILDER_2_H
@ -381,14 +381,15 @@ private :
else return false ;
}
boost::tuple<FT,Point_2> ConstructEventTimeAndPoint( iTriedge const& aTri )
{
return Construct_sls_event_time_and_point_2<Traits>(mTraits)()(aTri);
}
void SetEventTimeAndPoint( Event& aE )
{
FT lTime ; Point_2 lP ;
boost::tie(lTime,lP) = Construct_sls_event_time_and_point_2<Traits>(mTraits)()( CreateTriedge(aE.border_a()
,aE.border_b()
,aE.border_c()
)
);
boost::tie(lTime,lP) = ConstructEventTimeAndPoint( CreateTriedge(aE.border_a(),aE.border_b(),aE.border_c()) );
aE.SetTimeAndPoint(lTime,lP);
}

View File

@ -1 +1 @@
Fernando Cacciola <Fernando_Cacciola@ciudad.com.ar>
Fernando Cacciola <fernando_cacciola@ciudad.com.ar>