DGtal 1.4.0
Loading...
Searching...
No Matches
dgtalBoard3D-2-ks.cpp
Go to the documentation of this file.
1
39#include <iostream>
40#include "DGtal/io/boards/Board3D.h"
41#include "DGtal/base/Common.h"
42#include "DGtal/helpers/StdDefs.h"
43#include "DGtal/shapes/Shapes.h"
44#include "DGtal/io/DrawWithDisplay3DModifier.h"
45
46using namespace std;
47using namespace DGtal;
48using namespace Z3i;
49
50
51// Standard services - public :
52
53int main( )
54{
55
56 KSpace K;
57 Point plow(0,0,0);
58 Point pup(1,1,0);
59 Domain domain( plow, pup );
60 K.init( plow, pup, true );
61
63
64 // drawing cells of dimension 3
65
66 SCell v2 = K.sSpel( Point( 1, 0, 0 ), KSpace::POS ); // +v
67 SCell v3 = K.sSpel( Point( 0, 1, 0 ), KSpace::POS ); // +v
68 SCell v4 = K.sSpel( Point( 1, 1, 0 ), KSpace::NEG ); // +v
70 SCell v = K.sSpel( Point( 0, 0, 0 ), KSpace::POS ); // +v
71 board << SetMode3D( v.className(), "Illustration" );
73
74 board << v << v2 << v3;
75 board.saveOBJ("board3D-2-ks.obj");
76
78
79 // Surfel of Voxel (0,0)
81 SCell sx = K.sIncident( v, 0, true ); // surfel further along x
82 DGtal::TransformedPrism tsx (sx, v);
84
85 SCell sy = K.sIncident( v, 1, true ); // surfel further along y
86 SCell sz = K.sIncident( v, 2, true ); // surfel further along z
87 SCell sxn = K.sIncident( v, 0, false ); // surfel further along x
88 SCell syn = K.sIncident( v, 1, false ); // surfel further along y
89 SCell szn = K.sIncident( v, 2, false ); // surfel further along z
90
91 // Resizing and shifting the surfel towords its associated voxel (v).
92
93 DGtal::TransformedPrism tsy (sy, v);
94 DGtal::TransformedPrism tsz (sz, v);
95 DGtal::TransformedPrism tsxn (sxn, v);
96 DGtal::TransformedPrism tsyn (syn, v);
97 DGtal::TransformedPrism tszn (szn, v);
98
99 board2 << tsx << tsy << tsz << tsxn << tsyn << tszn;
100
101
102 // Surfel of Voxel (1,0)
103 SCell sx2 = K.sIncident( v2, 0, true ); // surfel further along x
104 SCell sy2 = K.sIncident( v2, 1, true ); // surfel further along y
105 SCell sz2 = K.sIncident( v2, 2, true ); // surfel further along z
106 SCell sxn2 = K.sIncident( v2, 0, false ); // surfel further along x
107 SCell syn2 = K.sIncident( v2, 1, false ); // surfel further along y
108 SCell szn2 = K.sIncident( v2, 2, false ); // surfel further along z
109
110 // Resizing and shifting the surfel towords its associated voxel (v2).
111 DGtal::TransformedPrism tsx2 (sx2, v2);
112 DGtal::TransformedPrism tsy2 (sy2, v2);
113 DGtal::TransformedPrism tsz2 (sz2, v2);
114 DGtal::TransformedPrism tsxn2 (sxn2, v2);
115 DGtal::TransformedPrism tsyn2 (syn2, v2);
116 DGtal::TransformedPrism tszn2 (szn2, v2);
117
118 board2 << tsx2 << tsy2 << tsz2 << tsxn2 << tsyn2 << tszn2;
119
120
121 // Surfel of Voxel (0,1)
122 SCell sx3 = K.sIncident( v3, 0, true ); // surfel further along x
123 SCell sy3 = K.sIncident( v3, 1, true ); // surfel further along y
124 SCell sz3 = K.sIncident( v3, 2, true ); // surfel further along z
125 SCell sxn3 = K.sIncident( v3, 0, false ); // surfel further along x
126 SCell syn3 = K.sIncident( v3, 1, false ); // surfel further along y
127 SCell szn3 = K.sIncident( v3, 2, false ); // surfel further along z
128
129 // Shifting the surfel to its associated voxel (v3).
130 DGtal::TransformedPrism tsx3 (sx3, v3);
131 DGtal::TransformedPrism tsy3 (sy3, v3);
132 DGtal::TransformedPrism tsz3 (sz3, v3);
133 DGtal::TransformedPrism tsxn3 (sxn3, v3);
134 DGtal::TransformedPrism tsyn3 (syn3, v3);
135 DGtal::TransformedPrism tszn3 (szn3, v3);
136
137
138 board2 << tsx3 << tsy3 << tsz3 << tsxn3 << tsyn3 << tszn3;
139
140 std::cout << "save obj" << std::endl;
141 board2.saveOBJ("board3D-2bis-ks.obj");
142
143
144}
The class Board3D is a type of Display3D which export the figures in the format OBJ/MTL when calling ...
Definition Board3D.h:82
void saveOBJ(const std::string &filename, const bool isNormalized=false)
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.
static const constexpr Sign NEG
SCell sSpel(Point p, Sign sign=POS) const
From the digital coordinates of a point in Zn, builds the corresponding spel (cell of maximal dimensi...
static const constexpr Sign POS
SCell sIncident(const SCell &c, Dimension k, bool up) const
Return the forward or backward signed cell incident to [c] along axis [k], depending on [up].
int main()
Space::Point Point
Definition StdDefs.h:168
DGtal is the top-level namespace which contains all DGtal functions and types.
STL namespace.
Modifier class in a Display3D stream. Useful to choose your own mode for a given class....
Represents a signed cell in a cellular grid space by its Khalimsky coordinates and a boolean value.
class to modify the position and scale to construct better illustration mode.
KSpace K
Domain domain