Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Thomas Pitiot
CGoGN
Commits
7522659d
Commit
7522659d
authored
Feb 24, 2012
by
Sylvain Thery
Browse files
update MC
modif tuto_oper
parent
8bfd76d1
Changes
6
Hide whitespace changes
Inline
Side-by-side
Apps/Tuto/tuto_oper2.cpp
View file @
7522659d
...
...
@@ -149,6 +149,17 @@ void MyQT::operation(int x)
m_selected
=
NIL
;
}
break
;
case
9
:
CGoGNout
<<
"delete face"
<<
CGoGNendl
;
if
(
m_selected
!=
NIL
)
{
myMap
.
deleteFace
(
m_selected
);
updateMap
();
m_selected
=
NIL
;
m_selected2
=
NIL
;
}
break
;
default:
break
;
}
...
...
@@ -325,6 +336,11 @@ void MyQT::cb_keyPress(int keycode)
void
MyQT
::
svg
()
{
if
(
m_selected
!=
NIL
)
m_render_topo
->
setDartColor
(
m_selected
,
0.8
f
,
0.0
f
,
0.0
f
);
if
(
m_selected2
!=
NIL
)
m_render_topo
->
setDartColor
(
m_selected2
,
0.0
f
,
0.8
f
,
0.0
f
);
std
::
string
filename
=
selectFileSave
(
"snapshot file"
,
"."
,
"(*.svg)"
);
m_render_topo
->
svgout2D
(
filename
,
modelViewMatrix
(),
projectionMatrix
());
}
...
...
Apps/Tuto/tuto_oper2.ui
View file @
7522659d
...
...
@@ -94,6 +94,11 @@
<string>
mergeFace
</string>
</property>
</item>
<item>
<property
name=
"text"
>
<string>
deleteFace
</string>
</property>
</item>
</widget>
</item>
<item>
...
...
include/Algo/MC/image.h
View file @
7522659d
...
...
@@ -30,7 +30,9 @@
#include
"Utils/img3D_IO.h"
#ifdef WITH_ZINRI
#include
"Zinrimage.h"
#endif
namespace
CGoGN
{
...
...
@@ -121,11 +123,12 @@ protected:
*/
//bool correct(const gmtl::Vec3i& _V);
#ifdef WITH_ZINRI
/**
* internal inrimage prt
*/
PTRINRIMAGE
mImage
;
#endif
public:
...
...
include/Algo/MC/image.hpp
View file @
7522659d
...
...
@@ -29,9 +29,6 @@
#include
<math.h>
#include
<typeinfo>
#include
"Utils/img3D_IO.h"
#include
"Zinrimage.h"
namespace
CGoGN
{
...
...
@@ -177,6 +174,7 @@ void Image<DataType>::loadVox(char *filename)
m_Alloc
=
true
;
}
#ifdef WITH_QT
template
<
typename
DataType
>
bool
Image
<
DataType
>::
loadPNG3D
(
const
char
*
filename
)
{
...
...
@@ -199,8 +197,9 @@ bool Image<DataType>::loadPNG3D(const char* filename)
return
true
;
}
#endif
#ifdef WITH_ZINRI
template
<
typename
DataType
>
bool
Image
<
DataType
>::
loadInrgz
(
const
char
*
filename
)
{
...
...
@@ -230,7 +229,7 @@ bool Image<DataType>::loadInrgz(const char* filename)
return
true
;
}
#endif
...
...
@@ -472,9 +471,52 @@ Image<DataType>* Image<DataType>::Blur3()
return
newImg
;
}
//template<typename DataType>
//void Image<DataType>::createMaskOffsetSphere(std::vector<int>& table, int _i32radius)
//{
// // compute the width of the sphere for memory allocation
// int i32Width = 2*_i32radius + 1;
// // squared radius
// float fRad2 = (float)(_i32radius*_i32radius);
//
// // memory allocation
// // difficult to know how many voxels before computing,
// // so the reserve for the BB
// table.reserve(i32Width*i32Width*i32Width);
// table.clear();
//
// // scan all the BB of the sphere
// for (int z = -_i32radius; z<=_i32radius; z++)
// {
// for (int y = -_i32radius; y<=_i32radius; y++)
// {
// for (int x = -_i32radius; x<=_i32radius; x++)
// {
// Geom::Vec3f v((float)x,(float)y,(float)z);
// float fLength = v.norm2();
// // if inside the sphere
// if (fLength<=fRad2)
// {
// // the the index of the voxel
// int index = z * m_WXY + y * m_WX + x;
// table.push_back(index);
// }
// }
// }
// }
//}
template
<
typename
DataType
>
void
Image
<
DataType
>::
createMaskOffsetSphere
(
std
::
vector
<
int
>&
table
,
int
_i32radius
)
{
float
smin
=
std
::
min
(
m_SX
,
std
::
min
(
m_SY
,
m_SZ
));
float
xs
=
m_SX
/
smin
;
float
ys
=
m_SY
/
smin
;
float
zs
=
m_SZ
/
smin
;
// compute the width of the sphere for memory allocation
int
i32Width
=
2
*
_i32radius
+
1
;
// squared radius
...
...
@@ -493,7 +535,7 @@ void Image<DataType>::createMaskOffsetSphere(std::vector<int>& table, int _i32ra
{
for
(
int
x
=
-
_i32radius
;
x
<=
_i32radius
;
x
++
)
{
Geom
::
Vec3f
v
(
(
float
)
x
,(
float
)
y
,(
float
)
z
);
Geom
::
Vec3f
v
(
float
(
x
)
*
xs
,
float
(
y
)
*
ys
,
float
(
z
)
*
zs
);
float
fLength
=
v
.
norm2
();
// if inside the sphere
if
(
fLength
<=
fRad2
)
...
...
@@ -507,6 +549,7 @@ void Image<DataType>::createMaskOffsetSphere(std::vector<int>& table, int _i32ra
}
}
template
<
typename
DataType
>
float
Image
<
DataType
>::
computeCurvatureCount
(
const
DataType
*
ptrVox
,
const
std
::
vector
<
int
>&
sphere
,
DataType
val
)
{
...
...
include/Algo/MC/marchingcube.h
View file @
7522659d
...
...
@@ -261,7 +261,7 @@ public:
void
removeFacesOfBoundary
(
AttributeHandler
<
unsigned
char
>&
boundVertices
,
unsigned
int
frameWidth
);
void
recalPoints
();
void
recalPoints
(
const
Geom
::
Vec3f
&
origin
);
};
...
...
include/Algo/MC/marchingcube.hpp
View file @
7522659d
...
...
@@ -120,7 +120,7 @@ void MarchingCube<DataType, Windowing, PFP>::simpleMeshing()
// compute value to transform points directly to final system coordinate
//
m_fOrigin = typename PFP::VEC3((float)(m_Image->getOrigin()[0]),(float)(m_Image->getOrigin()[1]),(float)(m_Image->getOrigin()[2]));
m_fOrigin
=
typename
PFP
::
VEC3
((
float
)(
m_Image
->
getOrigin
()[
0
]),(
float
)(
m_Image
->
getOrigin
()[
1
]),(
float
)(
m_Image
->
getOrigin
()[
2
]));
m_fScal
[
0
]
=
m_Image
->
getVoxSizeX
();
m_fScal
[
1
]
=
m_Image
->
getVoxSizeY
();
...
...
@@ -483,7 +483,9 @@ void MarchingCube<DataType, Windowing, PFP>::createFaces_1(DataType *vox, const
unsigned
int
lVertTable
[
12
];
typename
PFP
::
VEC3
vPos
((
float
)
_lX
+
0.5
f
,
(
float
)
_lY
+
0.5
f
,
(
float
)
_lZ
+
0.5
f
);
// typename PFP::VEC3 vPos(float(_lX) , float(_lY) , float(_lZ) );
// typename PFP::VEC3 vPos(float(_lX) + 0.5f, float(_lY) + 0.5f, (float)_lZ + 0.5f);
typename
PFP
::
VEC3
vPos
(
_lX
,
_lY
,
_lZ
);
// create the new vertices
...
...
@@ -545,8 +547,7 @@ void MarchingCube<DataType, Windowing, PFP>::createFaces_2(DataType *vox, const
return
;
unsigned
int
lVertTable
[
12
];
// typename PFP::VEC3 vPos((float)_lX , (float)_lY, (float)_lZ);
typename
PFP
::
VEC3
vPos
((
float
)
_lX
+
0.5
f
,
(
float
)
_lY
+
0.5
f
,
(
float
)
_lZ
+
0.5
f
);
typename
PFP
::
VEC3
vPos
(
_lX
,
_lY
,
_lZ
);
// create the new vertices
int
lX
=
_lX
;
...
...
@@ -603,8 +604,7 @@ void MarchingCube<DataType, Windowing, PFP>::createFaces_3(DataType *vox, const
return
;
unsigned
int
lVertTable
[
12
];
// typename PFP::VEC3 vPos((float)_lX , (float)_lY, (float)_lZ);
typename
PFP
::
VEC3
vPos
((
float
)
_lX
+
0.5
f
,
(
float
)
_lY
+
0.5
f
,
(
float
)
_lZ
+
0.5
f
);
typename
PFP
::
VEC3
vPos
(
_lX
,
_lY
,
_lZ
);
// create the new vertices
int
lX
=
_lX
;
...
...
@@ -659,8 +659,7 @@ void MarchingCube<DataType, Windowing, PFP>::createFaces_4(DataType *vox, const
return
;
unsigned
int
lVertTable
[
12
];
// typename PFP::VEC3 vPos((float)_lX , (float)_lY, (float)_lZ);
typename
PFP
::
VEC3
vPos
((
float
)
_lX
+
0.5
f
,
(
float
)
_lY
+
0.5
f
,
(
float
)
_lZ
+
0.5
f
);
typename
PFP
::
VEC3
vPos
(
_lX
,
_lY
,
_lZ
);
// create the new vertices
int
lX
=
_lX
;
...
...
@@ -718,8 +717,7 @@ void MarchingCube<DataType, Windowing, PFP>::createFaces_5(DataType *vox, const
return
;
unsigned
int
lVertTable
[
12
];
// typename PFP::VEC3 vPos((float)_lX , (float)_lY, (float)_lZ);
typename
PFP
::
VEC3
vPos
((
float
)
_lX
+
0.5
f
,
(
float
)
_lY
+
0.5
f
,
(
float
)
_lZ
+
0.5
f
);
typename
PFP
::
VEC3
vPos
(
_lX
,
_lY
,
_lZ
);
// create the new vertices
int
lX
=
_lX
;
...
...
@@ -775,8 +773,7 @@ void MarchingCube<DataType, Windowing, PFP>::createFaces_6(DataType *vox, const
return
;
unsigned
int
lVertTable
[
12
];
// typename PFP::VEC3 vPos((float)_lX , (float)_lY, (float)_lZ);
typename
PFP
::
VEC3
vPos
((
float
)
_lX
+
0.5
f
,
(
float
)
_lY
+
0.5
f
,
(
float
)
_lZ
+
0.5
f
);
typename
PFP
::
VEC3
vPos
(
_lX
,
_lY
,
_lZ
);
// create the new vertices
int
lX
=
_lX
+
1
;
...
...
@@ -837,8 +834,7 @@ void MarchingCube<DataType, Windowing, PFP>::createFaces_7(DataType *vox, const
return
;
unsigned
int
lVertTable
[
12
];
// typename PFP::VEC3 vPos((float)_lX , (float)_lY, (float)_lZ);
typename
PFP
::
VEC3
vPos
((
float
)
_lX
+
0.5
f
,
(
float
)
_lY
+
0.5
f
,
(
float
)
_lZ
+
0.5
f
);
typename
PFP
::
VEC3
vPos
(
_lX
,
_lY
,
_lZ
);
// create the new vertices
int
lX
=
_lX
+
1
;
...
...
@@ -899,8 +895,7 @@ void MarchingCube<DataType, Windowing, PFP>::createFaces_8(DataType *vox, const
return
;
unsigned
int
lVertTable
[
12
];
// typename PFP::VEC3 vPos((float)_lX , (float)_lY, (float)_lZ);
typename
PFP
::
VEC3
vPos
((
float
)
_lX
+
0.5
f
,
(
float
)
_lY
+
0.5
f
,
(
float
)
_lZ
+
0.5
f
);
typename
PFP
::
VEC3
vPos
(
_lX
,
_lY
,
_lZ
);
// create the new vertices
int
lX
=
_lX
+
1
;
...
...
@@ -1241,7 +1236,7 @@ void MarchingCube<DataType, Windowing, PFP>::removeFacesOfBoundary(AttributeHand
}
template
<
typename
DataType
,
template
<
typename
D2
>
class
Windowing
,
typename
PFP
>
void
MarchingCube
<
DataType
,
Windowing
,
PFP
>::
recalPoints
()
void
MarchingCube
<
DataType
,
Windowing
,
PFP
>::
recalPoints
(
const
Geom
::
Vec3f
&
origin
)
{
for
(
unsigned
int
i
=
m_positions
.
begin
();
i
!=
m_positions
.
end
();
m_positions
.
next
(
i
))
...
...
@@ -1251,7 +1246,7 @@ void MarchingCube<DataType, Windowing, PFP>::recalPoints()
P
[
0
]
=
P
[
0
]
*
m_fScal
[
0
];
P
[
1
]
=
P
[
1
]
*
m_fScal
[
1
];
P
[
2
]
=
P
[
2
]
*
m_fScal
[
2
];
P
+=
origin
;
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment