DGtal 1.3.0
Loading...
Searching...
No Matches
Functions
testArithDSS3d.cpp File Reference
#include <iostream>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <fstream>
#include <vector>
#include "DGtal/base/Common.h"
#include "DGtal/base/Exceptions.h"
#include "DGtal/kernel/SpaceND.h"
#include "DGtal/kernel/domains/HyperRectDomain.h"
#include "DGtal/geometry/curves/StandardDSS6Computer.h"
#include "DGtal/geometry/curves/GreedySegmentation.h"

Go to the source code of this file.

Functions

bool testDSSreco ()
 
bool testSegmentation ()
 
void testStandardDSS6ComputerConceptChecking ()
 
int main (int argc, char **argv)
 

Detailed Description

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Author
Tristan Roussillon (trist.nosp@m.an.r.nosp@m.oussi.nosp@m.llon.nosp@m.@liri.nosp@m.s.cn.nosp@m.rs.fr ) Laboratoire d'InfoRmatique en Image et Systèmes d'information - LIRIS (CNRS, UMR 5205), CNRS, France
Date
2011/06/01

This file is part of the DGtal library

Definition in file testArithDSS3d.cpp.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 175 of file testArithDSS3d.cpp.

176{
177 trace.beginBlock ( "Testing class ArithmeticalDSSComputer" );
178
180
181 trace.info() << "Args:";
182 for ( int i = 0; i < argc; ++i )
183 trace.info() << " " << argv[ i ];
184 trace.info() << endl;
185
186 bool res = testDSSreco()
188
189 ;
190 trace.emphase() << ( res ? "Passed." : "Error." ) << endl;
191 trace.endBlock();
192
193 return res ? 0 : 1;
194
195}
void beginBlock(const std::string &keyword="")
std::ostream & emphase()
std::ostream & info()
double endBlock()
Trace trace
Definition: Common.h:154
void testStandardDSS6ComputerConceptChecking()
bool testDSSreco()
bool testSegmentation()

References DGtal::Trace::beginBlock(), DGtal::Trace::emphase(), DGtal::Trace::endBlock(), DGtal::Trace::info(), testDSSreco(), testSegmentation(), testStandardDSS6ComputerConceptChecking(), and DGtal::trace.

◆ testDSSreco()

bool testDSSreco ( )

simple test

Definition at line 62 of file testArithDSS3d.cpp.

63{
64
66 typedef std::vector<Point>::iterator Iterator;
68
69 std::vector<Point> sequence;
70 sequence.push_back(Point(0,0,0));
71 sequence.push_back(Point(1,0,0));
72 sequence.push_back(Point(2,0,0));
73 sequence.push_back(Point(2,1,0));
74 sequence.push_back(Point(2,1,1));
75 sequence.push_back(Point(3,1,1));
76 sequence.push_back(Point(4,1,1));
77 sequence.push_back(Point(4,2,1));
78 sequence.push_back(Point(4,2,2));
79 sequence.push_back(Point(5,2,2));
80 sequence.push_back(Point(6,2,2));
81 sequence.push_back(Point(6,3,2));
82 sequence.push_back(Point(6,3,3));
83 sequence.push_back(Point(6,4,3));
84 sequence.push_back(Point(6,4,4));
85 sequence.push_back(Point(6,5,4));
86
87 // Adding step
88 trace.beginBlock("Add points while it is possible and display the result");
89
90 SegmentComputer algo;
91 Iterator i = sequence.begin();
92 algo.init(i);
93 trace.info() << "init with " << (*i) << std::endl;
94
95 while ( (algo.end() != sequence.end())
96 && algo.extendFront()) {
97 trace.info() << "extended with " << (*(--algo.end())) << std::endl;
98 }
99
100
101 trace.info() << algo << " " << algo.isValid() << std::endl;
102
103 trace.endBlock();
104
105 return ( algo.isValid() && (algo.end() == (sequence.begin()+13)) );
106}
ConstIterator end() const
ConstIterator begin() const
void init(const ConstIterator &it)
Aim: Implements basic operations that will be used in Point and Vector classes.
Definition: PointVector.h:593
Aim: Dynamic recognition of a 3d-digital straight segment (DSS)
ArithmeticalDSSComputer< std::vector< Z2i::Point >::const_iterator, int, 4 > SegmentComputer
MyPointD Point
Definition: testClone2.cpp:383

References DGtal::ArithmeticalDSSComputer< TIterator, TInteger, adjacency >::begin(), DGtal::Trace::beginBlock(), DGtal::ArithmeticalDSSComputer< TIterator, TInteger, adjacency >::end(), DGtal::Trace::endBlock(), DGtal::ArithmeticalDSSComputer< TIterator, TInteger, adjacency >::extendFront(), DGtal::Trace::info(), DGtal::ArithmeticalDSSComputer< TIterator, TInteger, adjacency >::init(), DGtal::ArithmeticalDSSComputer< TIterator, TInteger, adjacency >::isValid(), and DGtal::trace.

Referenced by main().

◆ testSegmentation()

bool testSegmentation ( )

segmentation test

Definition at line 114 of file testArithDSS3d.cpp.

115{
116
118 typedef std::vector<Point>::iterator Iterator;
120 typedef GreedySegmentation<SegmentComputer> Decomposition;
121
122 std::vector<Point> sequence;
123 sequence.push_back(Point(0,0,0));
124 sequence.push_back(Point(1,0,0));
125 sequence.push_back(Point(2,0,0));
126 sequence.push_back(Point(2,1,0));
127 sequence.push_back(Point(2,1,1));
128 sequence.push_back(Point(3,1,1));
129 sequence.push_back(Point(4,1,1));
130 sequence.push_back(Point(4,2,1));
131 sequence.push_back(Point(4,2,2));
132 sequence.push_back(Point(5,2,2));
133 sequence.push_back(Point(6,2,2));
134 sequence.push_back(Point(6,3,2));
135 sequence.push_back(Point(6,3,3));
136 sequence.push_back(Point(6,4,3));
137 sequence.push_back(Point(6,4,4));
138 sequence.push_back(Point(6,5,4));
139
140 //Segmentation
141 trace.beginBlock("Segmentation test");
142
143 SegmentComputer algo;
144 Decomposition theDecomposition(sequence.begin(), sequence.end(), algo);
145
146 unsigned int c = 0;
147 Decomposition::SegmentComputerIterator i = theDecomposition.begin();
148 for ( ; i != theDecomposition.end(); ++i) {
149 SegmentComputer currentSegmentComputer(*i);
150 trace.info() << currentSegmentComputer << std::endl; //standard output
151 c++;
152 }
153
154 trace.endBlock();
155 return (c==2);
156}
Aim: Computes the greedy segmentation of a range given by a pair of ConstIterators....

References DGtal::Trace::beginBlock(), DGtal::Trace::endBlock(), DGtal::Trace::info(), and DGtal::trace.

Referenced by main().

◆ testStandardDSS6ComputerConceptChecking()

void testStandardDSS6ComputerConceptChecking ( )

Definition at line 159 of file testArithDSS3d.cpp.

160{
162 typedef std::vector<Point>::const_iterator ConstIterator;
164
165 trace.beginBlock("Concept checking");
166
167 BOOST_CONCEPT_ASSERT(( concepts::CForwardSegmentComputer<ArithDSS3d> ));
168
169 trace.endBlock();
170
171}
MyDigitalSurface::ConstIterator ConstIterator
Aim: Defines the concept describing a forward segment computer. Like any model of CIncrementalSegment...

References DGtal::Trace::beginBlock(), DGtal::Trace::endBlock(), and DGtal::trace.

Referenced by main().