DGtal  1.2.0
Functions
ctopo-1-3d.cpp File Reference
#include <iostream>
#include "DGtal/base/Common.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/io/DrawWithDisplay3DModifier.h"
#include "DGtal/io/viewers/Viewer3D.h"
Include dependency graph for ctopo-1-3d.cpp:

Go to the source code of this file.

Functions

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
Bertrand Kerautret (kerau.nosp@m.tre@.nosp@m.loria.nosp@m..fr ) LORIA (CNRS, UMR 7503), University of Nancy, France
Date
2011/05/13

An example file named ctopo-1-3d.cpp.

This file is part of the DGtal library.

Definition in file ctopo-1-3d.cpp.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 71 of file ctopo-1-3d.cpp.

72 {
73  // for 3D display with Viewer3D
74  QApplication application(argc,argv);
75 
76  KSpace K;
77  Point plow(0,0,0);
78  Point pup(3,3,2);
79  Domain domain( plow, pup );
80  K.init( plow, pup, true );
81  //
83  MyViewer viewer(K);
84  viewer.show();
85  viewer << SetMode3D( domain.className(), "Paving" );
86 
87  Cell ptlow = K.uPointel( plow ); // pointel (0*2,0*2, 0*2)
88  Cell ptup1 = K.uPointel( pup ); // pointel (3*2,3*2, 2*2)
89  Cell ptup2 = K.uTranslation( ptup1, Point::diagonal() ); // pointel (4*2, 4*2, 3*2)
90 
91  viewer << ptlow << ptup1 << ptup2;
92 
93  // drawing cells of dimension 0
94  Cell p1= K.uCell(Point(0,0,2)); // pointel (0*2,0*2,2*2)
95  Cell p2= K.uCell(Point(0,2,2)); // ...
96  Cell p3= K.uCell(Point(2,2,2));
97  Cell p4= K.uCell(Point(2,0,2));
98  Cell p5= K.uCell(Point(0,0,4));
99  Cell p6= K.uCell(Point(0,2,4));
100  Cell p7= K.uCell(Point(2,2,4));
101  Cell p8= K.uCell(Point(2,0,4));
102  viewer << p1 << p2 << p3 << p4 << p5 << p6 << p7 << p8;
103 
104  // drawing Cells of dimension 1
105  Cell linel0 = K.uCell( Point( 1, 0, 2 ) ); // linel (2*1+1, 0, 2*2)
106  Cell linel1 = K.uCell( Point( 1, 2, 2 ) ); // ...
107  Cell linel2 = K.uCell( Point( 0, 1, 2 ) );
108  Cell linel3 = K.uCell( Point( 2, 1, 2 ) );
109 
110  Cell linel4 = K.uCell( Point( 1, 0, 4 ) );
111  Cell linel5 = K.uCell( Point( 1, 2, 4 ) );
112  Cell linel6 = K.uCell( Point( 0, 1, 4 ) );
113  Cell linel7 = K.uCell( Point( 2, 1, 4 ) );
114 
115  Cell linel8 = K.uCell( Point( 0, 0, 3 ) );
116  Cell linel9 = K.uCell( Point( 0, 2, 3 ) );
117  Cell linel10 = K.uCell( Point( 2, 0, 3 ) );
118  Cell linel11 = K.uCell( Point( 2, 2, 3 ) );
119 
120 
121  Cell linel12 = K.uCell( Point( 3, 2, 2 ) );
122 
123  viewer << linel0<< linel1<< linel2 << linel3 ;
124  viewer << linel4<< linel5<< linel6 << linel7 ;
125  viewer << linel8<< linel9<< linel10 << linel11 << linel12;
126 
127  // drawing cells of dimension 2
128 
129  Cell surfelA = K.uCell( Point( 2, 1, 3 ) ); // surfel (2*2,2*1+1,2*3+1)
130  Cell surfelB = K.uCell( Point( 1, 0, 1 ) ); // surfel (2*1,2*0,2*1+1)
131  Cell surfelC = K.uCell( Point( 2, 1, 1 ) ); // surfel (2*2,2*1+1,2*1+1)
132  viewer << surfelA << surfelB << surfelC;
133 
134  // drawing cells of dimension 3
135  Cell vox1 = K.uCell( Point( 3, 3, 3 ) ); // voxel (2*3+1,2*3+1,2*3+1)
136  Cell vox2 = K.uCell( Point( 1, 1, 3 ) ); // voxel (2*1+1,2*1+1,2*3+1)
137  viewer << vox1 << vox2;
138 
139  viewer<< MyViewer::updateDisplay;
140  return application.exec();
141 
142 }
std::string className() const
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...
bool init(const Point &lower, const Point &upper, bool isClosed)
Specifies the upper and lower bounds for the maximal cells in this space.
Cell uTranslation(const Cell &p, const Vector &vec) const
Add the vector [vec] to [p].
Cell uPointel(Point p) const
From the digital coordinates of a point in Zn, builds the corresponding pointel (cell of dimension 0)...
Cell uCell(const PreCell &c) const
From an unsigned cell, returns an unsigned cell lying into this Khalismky space.
Modifier class in a Display3D stream. Useful to choose your own mode for a given class....
MyPointD Point
Definition: testClone2.cpp:383
KSpace K
Domain domain

References DGtal::HyperRectDomain< TSpace >::className(), domain, DGtal::KhalimskySpaceND< dim, TInteger >::init(), K, DGtal::Viewer3D< TSpace, TKSpace >::show(), DGtal::KhalimskySpaceND< dim, TInteger >::uCell(), DGtal::KhalimskySpaceND< dim, TInteger >::uPointel(), and DGtal::KhalimskySpaceND< dim, TInteger >::uTranslation().