Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CGoGN
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
David Cazier
CGoGN
Commits
033af6c1
Commit
033af6c1
authored
Jul 26, 2013
by
Sylvain Thery
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of cgogn:CGoGN
parents
4ddbd122
53cd3199
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
251 additions
and
16 deletions
+251
-16
Apps/Examples/viewerOBJ.cpp
Apps/Examples/viewerOBJ.cpp
+3
-4
include/Algo/Import/importObjTex.h
include/Algo/Import/importObjTex.h
+9
-1
include/Algo/Import/importObjTex.hpp
include/Algo/Import/importObjTex.hpp
+15
-3
include/Algo/MC/image.h
include/Algo/MC/image.h
+10
-0
include/Algo/MC/image.hpp
include/Algo/MC/image.hpp
+171
-0
include/Container/containerBrowser.h
include/Container/containerBrowser.h
+1
-0
include/Container/containerBrowser.hpp
include/Container/containerBrowser.hpp
+24
-7
include/Topology/generic/genericmap.h
include/Topology/generic/genericmap.h
+10
-0
include/Topology/generic/genericmap.hpp
include/Topology/generic/genericmap.hpp
+8
-0
include/Utils/textures.hpp
include/Utils/textures.hpp
+0
-1
No files found.
Apps/Examples/viewerOBJ.cpp
View file @
033af6c1
...
...
@@ -104,18 +104,17 @@ void ObjView::cb_redraw()
{
m_shader2
->
setTexture
(
mats
[
i
]
->
textureDiffuse
);
m_shader2
->
setShininess
(
mats
[
i
]
->
shininess
);
m_shader2
->
setAmbient
(
0.
3
f
);
m_shader2
->
setAmbient
(
0.
8
f
);
m_shader2
->
activeTexture
();
m_shader2
->
enableVertexAttribs
();
glDrawArrays
(
GL_TRIANGLES
,
m_obj
.
beginIndex
(
i
),
m_obj
.
nbIndices
(
i
));
m_shader2
->
disableVertexAttribs
();
}
else
{
Geom
::
Vec4f
v
;
v
[
0
]
=
mats
[
i
]
->
ambiantColor
[
0
];
v
[
1
]
=
mats
[
i
]
->
ambiantColor
[
1
];
v
[
2
]
=
mats
[
i
]
->
ambiantColor
[
2
];
v
[
3
]
=
0.0
f
;
// v[0] = mats[i]->ambiantColor[0]; v[1] = mats[i]->ambiantColor[1]; v[2] = mats[i]->ambiantColor[2]; v[3] = 0.0f;
v
[
0
]
=
0.5
f
;
v
[
1
]
=
0.5
f
;
v
[
2
]
=
0.5
f
;
v
[
3
]
=
0.0
f
;
m_phongShader
->
setAmbiant
(
v
)
;
v
[
0
]
=
mats
[
i
]
->
diffuseColor
[
0
];
v
[
1
]
=
mats
[
i
]
->
diffuseColor
[
1
];
v
[
2
]
=
mats
[
i
]
->
diffuseColor
[
2
];
v
[
3
]
=
0.0
f
;
m_phongShader
->
setDiffuse
(
v
)
;
...
...
include/Algo/Import/importObjTex.h
View file @
033af6c1
...
...
@@ -93,6 +93,8 @@ protected:
std
::
vector
<
unsigned
int
>
m_beginIndices
;
std
::
vector
<
unsigned
int
>
m_nbIndices
;
unsigned
int
m_maxTextureSize
;
/// vector of group name
// std::vector<std::string> m_groupNames;
// std::vector<std::string> m_groupMaterialNames;
...
...
@@ -149,6 +151,12 @@ public:
~
OBJModel
();
/**
* @brief resize texture (at import) to max size
* @param mts max texture size in x & y
*/
void
setMaxTextureSize
(
unsigned
int
mts
);
/**
* @brief set position attribute
* @param position attribute
...
...
@@ -231,7 +239,7 @@ public:
* @brief read materials from files. Call after creating VBOs !!
* @param filename name of file
*/
void
readMaterials
(
unsigned
int
maxTextureSize
=
2048
,
const
std
::
string
&
filename
=
""
);
void
readMaterials
(
const
std
::
string
&
filename
=
""
);
/**
* @brief getMaterials
...
...
include/Algo/Import/importObjTex.hpp
View file @
033af6c1
...
...
@@ -41,7 +41,7 @@ namespace Import
template <typename PFP>
OBJModel<PFP>::OBJModel(typename PFP::MAP& map):
m_map(map),
m_map(map),
m_maxTextureSize(2048),
m_tagV(0),m_tagVT(0),m_tagVN(0),m_tagG(0),m_tagF(0),
m_specialVertices(map),m_dirtyEdges(map)
{
...
...
@@ -55,6 +55,16 @@ OBJModel<PFP>::~OBJModel()
delete *it;
}
template <typename PFP>
inline void OBJModel<PFP>::setMaxTextureSize(unsigned int mts)
{
m_maxTextureSize = mts;
}
template <typename PFP>
inline typename PFP::VEC3 OBJModel<PFP>::getPosition(Dart d)
{
...
...
@@ -62,6 +72,7 @@ inline typename PFP::VEC3 OBJModel<PFP>::getPosition(Dart d)
}
template <typename PFP>
inline typename PFP::VEC3 OBJModel<PFP>::getNormal(Dart d)
{
...
...
@@ -105,7 +116,7 @@ void OBJModel<PFP>::setTexCoordAttribute(VertexAttribute<Geom::Vec2f>texcoord)
template <typename PFP>
void OBJModel<PFP>::readMaterials(
unsigned int /*maxTextureSize*/,
const std::string& filename)
void OBJModel<PFP>::readMaterials(const std::string& filename)
{
m_materials.reserve(m_materialNames.size());
...
...
@@ -211,7 +222,7 @@ void OBJModel<PFP>::readMaterials(unsigned int /*maxTextureSize*/, const std::st
currentMat->textureDiffuse->load(m_matPath+tname);
CGoGNout << "Loading texture "<< m_matPath+tname << " -> "<<std::hex << currentMat->textureDiffuse <<std::dec<<CGoGNendl;
// currentMat->textureDiffuse->scaleNearest( currentMat->textureDiffuse->newMaxSize(
maxTextureSize));
currentMat->textureDiffuse->scaleNearest( currentMat->textureDiffuse->newMaxSize(m_
maxTextureSize));
currentMat->textureDiffuse->setFiltering(GL_LINEAR);
currentMat->textureDiffuse->setWrapping(GL_REPEAT);
currentMat->textureDiffuse->update();
...
...
@@ -231,6 +242,7 @@ void OBJModel<PFP>::readMaterials(unsigned int /*maxTextureSize*/, const std::st
tname = tname.substr(0,tname.length()-1);
currentMat->textureDiffuse->load(m_matPath+tname);
CGoGNout << "Loading texture "<< m_matPath+tname << " -> "<<std::hex << currentMat->textureDiffuse <<std::dec<<CGoGNendl;
currentMat->textureDiffuse->scaleNearest( currentMat->textureDiffuse->newMaxSize(m_maxTextureSize));
currentMat->textureDiffuse->setFiltering(GL_LINEAR);
currentMat->textureDiffuse->setWrapping(GL_REPEAT);
currentMat->textureDiffuse->update();
...
...
include/Algo/MC/image.h
View file @
033af6c1
...
...
@@ -133,6 +133,9 @@ protected:
PTRINRIMAGE
mImage
;
#endif
template
<
typename
T
>
void
readVTKBuffer
(
std
::
ifstream
&
in
);
public:
/**
...
...
@@ -168,6 +171,13 @@ public:
*/
bool
loadInrgz
(
const
char
*
filename
);
/**
* @brief load VTK binary mask image
* @param filename
* @return
*/
bool
loadVTKBinaryMask
(
const
char
*
filename
);
/**
* Constructor
* @param data pointer on voxel
...
...
include/Algo/MC/image.hpp
View file @
033af6c1
...
...
@@ -281,6 +281,177 @@ void Image<DataType>::saveInrMask(const char* filename)
#endif
template< typename DataType >
template< typename T>
void Image<DataType>::readVTKBuffer(std::ifstream& in)
{
int total = m_WXY * m_WZ;
if (m_Data != NULL)
delete[] m_Data;
m_Data = new DataType[total];
DataType* ptr = m_Data;
T* buffer = new T[total];
in.read(reinterpret_cast<char*>(buffer), total*sizeof(T));
T* buf = buffer;
for (int i=0; i<total; ++i)
if (*buf++ !=0)
*ptr++ = 255;
else
*ptr++ = 0;
delete[] buffer;
}
template< typename DataType >
bool Image<DataType>::loadVTKBinaryMask(const char* filename)
{
std::ifstream in(filename, std::ios::binary);
if (!in)
{
CGoGNerr << "Mesh_Base::loadVox: Unable to open file " << CGoGNendl;
return false;
}
m_SX = 1.0 ;
m_SY = 1.0 ;
m_SZ = 1.0 ;
// read encoding
std::string keyword ;
int dtType = 0;
do
{
char line[1024] ;
in.getline(line, 1024) ;
std::cout << "LINE = "<< line << std::endl;
std::istringstream line_input(line) ;
line_input >> keyword ;
std::cout << "keyword = "<< keyword << std::endl;
if(keyword == "VTK")
{
std::cout << "reading vtk file" << std::endl;
} else if(keyword == "DIMENSIONS")
{
line_input >> m_WX ;
line_input >> m_WY ;
line_input >> m_WZ ;
std::cout << "DIM= "<< m_WX << "/"<< m_WY << "/"<< m_WZ << std::endl;
} else if(keyword == "SPACING")
{
line_input >> m_SX ;
line_input >> m_SY ;
line_input >> m_SZ ;
std::cout << "SPACING= "<< m_SX << "/"<< m_SY << "/"<< m_SZ << std::endl;
}
else if(keyword == "SCALARS")
{
std::string str;
line_input >> str;
line_input >> str;
std::cout << "SCALAR= "<< str << std::endl;
if (str == "unsigned_char")
dtType = 1 ;
else if (str == "unsigned_short")
dtType = 2 ;
else if (str == "unsigned_int")
dtType = 3 ;
else if (str == "char")
dtType = 4 ;
else if (str == "short")
dtType = 5 ;
else if (str == "int")
dtType = 6 ;
}
/*else if(keyword == "POINT_DATA")
{
} */
}while (keyword != "LOOKUP_TABLE");
m_WXY = m_WX * m_WY;
// int total = m_WXY * m_WZ;
// m_Data = new DataType[total];
// DataType* ptr = m_Data;
switch(dtType)
{
case 1:
readVTKBuffer<unsigned char>(in);
// {
// unsigned char* buffer = new unsigned char[total];
// in.read(reinterpret_cast<char*>(buffer), total*sizeof(unsigned char));
// unsigned char* buf = buffer;
// for (int i=0; i<total; ++i)
// if (*buf++ !=0)
// *ptr++ = 255;
// else
// *ptr++ = 0;
// delete[] buffer;
// }
break;
case 2:
readVTKBuffer<unsigned short>(in);
// {
// unsigned short* buffer = new unsigned short[total];
// in.read(reinterpret_cast<char*>(buffer), total*sizeof(unsigned short));
// unsigned short* buf = buffer;
// for (int i=0; i<total; ++i)
// if (*buf++ !=0)
// *ptr++ = 255;
// else
// *ptr++ = 0;
// delete[] buffer;
// }
break;
case 3:
readVTKBuffer<unsigned int>(in);
// {
// unsigned int* buffer = new unsigned int[total];
// in.read(reinterpret_cast<char*>(buffer), total*sizeof(unsigned int));
// unsigned int* buf = buffer;
// for (int i=0; i<total; ++i)
// if (*buf++ !=0)
// *ptr++ = 255;
// else
// *ptr++ = 0;
// delete[] buffer;
// }
break;
case 4:
readVTKBuffer<char>(in);
break;
case 5:
readVTKBuffer<short>(in);
break;
case 6:
readVTKBuffer<int>(in);
break;
default:
CGoGNerr << "unknown format" << CGoGNendl;
break;
}
m_Alloc=true;
return true;
}
template< typename DataType >
...
...
include/Container/containerBrowser.h
View file @
033af6c1
...
...
@@ -42,6 +42,7 @@ class DartContainerBrowserSelector : public ContainerBrowser
protected:
AttributeContainer
*
m_cont
;
const
FunctorSelect
*
m_selector
;
AttribMap
&
m_map
;
public:
DartContainerBrowserSelector
(
AttribMap
&
m
,
const
FunctorSelect
&
fs
);
...
...
include/Container/containerBrowser.hpp
View file @
033af6c1
...
...
@@ -29,9 +29,17 @@ namespace CGoGN
{
inline
DartContainerBrowserSelector
::
DartContainerBrowserSelector
(
AttribMap
&
m
,
const
FunctorSelect
&
fs
)
inline
DartContainerBrowserSelector
::
DartContainerBrowserSelector
(
AttribMap
&
m
,
const
FunctorSelect
&
fs
)
:
m_map
(
m
)
{
m_cont
=
&
(
m
.
getAttributeContainer
<
DART
>
());
if
(
GenericMap
::
isMultiRes
())
{
m_cont
=
&
(
m
.
getMRAttributeContainer
());
}
else
{
m_cont
=
&
(
m
.
getAttributeContainer
<
DART
>
());
}
m_selector
=
fs
.
copy
();
}
...
...
@@ -42,11 +50,20 @@ inline DartContainerBrowserSelector::~DartContainerBrowserSelector()
inline
unsigned
int
DartContainerBrowserSelector
::
begin
()
const
{
unsigned
int
it
=
m_cont
->
realBegin
()
;
while
(
(
it
!=
m_cont
->
realEnd
())
&&
!
m_selector
->
operator
()(
Dart
(
it
))
)
m_cont
->
realNext
(
it
);
return
it
;
if
(
GenericMap
::
isMultiRes
())
{
unsigned
int
it
=
m_cont
->
realBegin
()
;
while
(
(
it
!=
m_cont
->
realEnd
())
&&
!
m_selector
->
operator
()(
m_map
.
indexDart
(
it
))
)
m_cont
->
realNext
(
it
);
return
it
;
}
else
{
unsigned
int
it
=
m_cont
->
realBegin
()
;
while
(
(
it
!=
m_cont
->
realEnd
())
&&
!
m_selector
->
operator
()(
Dart
(
it
))
)
m_cont
->
realNext
(
it
);
return
it
;
}
}
inline
unsigned
int
DartContainerBrowserSelector
::
end
()
const
...
...
include/Topology/generic/genericmap.h
View file @
033af6c1
...
...
@@ -320,6 +320,16 @@ public:
*/
unsigned
int
dartIndex
(
Dart
d
)
const
;
/**
* get the Dart of index in topological table
*/
Dart
indexDart
(
unsigned
int
index
)
const
;
/**
* @brief are we in MR ?
*/
static
bool
isMultiRes
()
{
return
m_isMultiRes
;
}
/**
* get the insertion level of a dart (use only in MRMaps)
*/
...
...
include/Topology/generic/genericmap.hpp
View file @
033af6c1
...
...
@@ -236,6 +236,14 @@ inline unsigned int GenericMap::dartIndex(Dart d) const
return d.index;
}
inline Dart GenericMap::indexDart(unsigned int index) const
{
if (m_isMultiRes)
return Dart( (*m_mrDarts[m_mrCurrentLevel])[index]) ;
return Dart(index);
}
inline unsigned int GenericMap::getDartLevel(Dart d) const
{
return (*m_mrLevels)[d.index] ;
...
...
include/Utils/textures.hpp
View file @
033af6c1
...
...
@@ -1095,7 +1095,6 @@ void Texture<DIM,TYPE>::update()
glTexImage1D(m_target, 0, internalFormat(), this->m_size[0], 0, format(), m_type, this->m_data_ptr);
break;
case 2:
std::cout << "updateSize: " << this->m_size[0] << " / " << this->m_size[1] << std::endl;
glTexImage2D(m_target, 0, internalFormat(), this->m_size[0], this->m_size[1], 0, format(), m_type, this->m_data_ptr);
break;
case 3:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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