add ScalarType to OccupancyGrid and MeshTree
This commit is contained in:
parent
2b507b5540
commit
30f0383fc6
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
namespace vcg {
|
namespace vcg {
|
||||||
|
|
||||||
template<class MeshType>
|
template<class MeshType, class ScalarType>
|
||||||
class MeshTree {
|
class MeshTree {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -24,11 +24,11 @@ namespace vcg {
|
||||||
|
|
||||||
MeshNode(MeshType *_m) : m{_m}, glued{false} {}
|
MeshNode(MeshType *_m) : m{_m}, glued{false} {}
|
||||||
|
|
||||||
vcg::Matrix44d &tr() {
|
vcg::Matrix44<ScalarType> &tr() {
|
||||||
return m->cm.Tr;
|
return m->cm.Tr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const vcg::Box3d &bbox() const {
|
const vcg::Box3<ScalarType> &bbox() const {
|
||||||
return m->cm.bbox;
|
return m->cm.bbox;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -47,7 +47,7 @@ namespace vcg {
|
||||||
std::map<int, MeshNode*> nodeMap;
|
std::map<int, MeshNode*> nodeMap;
|
||||||
std::vector<vcg::AlignPair::Result> resultList;
|
std::vector<vcg::AlignPair::Result> resultList;
|
||||||
|
|
||||||
vcg::OccupancyGrid<CMeshO> OG;
|
vcg::OccupancyGrid<CMeshO, ScalarType> OG;
|
||||||
vcg::CallBackPos * cb;
|
vcg::CallBackPos * cb;
|
||||||
|
|
||||||
MeshType *MM(unsigned int i) {
|
MeshType *MM(unsigned int i) {
|
||||||
|
|
@ -137,12 +137,12 @@ namespace vcg {
|
||||||
std::sprintf(buf, "Computing Overlaps %i glued meshes...\n", gluedNum());
|
std::sprintf(buf, "Computing Overlaps %i glued meshes...\n", gluedNum());
|
||||||
cb(0, buf);
|
cb(0, buf);
|
||||||
|
|
||||||
OG.Init(static_cast<int>(nodeMap.size()), vcg::Box3d::Construct(gluedBBox()), mtp.OGSize);
|
OG.Init(static_cast<int>(nodeMap.size()), vcg::Box3<ScalarType>::Construct(gluedBBox()), mtp.OGSize);
|
||||||
|
|
||||||
for(auto ni = std::begin(nodeMap); ni != std::end(nodeMap); ++ni) {
|
for(auto ni = std::begin(nodeMap); ni != std::end(nodeMap); ++ni) {
|
||||||
MeshTree::MeshNode *mn = ni->second;
|
MeshTree::MeshNode *mn = ni->second;
|
||||||
if (mn->glued) {
|
if (mn->glued) {
|
||||||
OG.AddMesh(mn->m->cm, vcg::Matrix44d::Construct(mn->tr()), mn->Id());
|
OG.AddMesh(mn->m->cm, vcg::Matrix44<ScalarType>::Construct(mn->tr()), mn->Id());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -357,22 +357,22 @@ namespace vcg {
|
||||||
result.MovName=movId;
|
result.MovName=movId;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline vcg::Box3d bbox() {
|
inline vcg::Box3<ScalarType> bbox() {
|
||||||
|
|
||||||
vcg::Box3d FullBBox;
|
vcg::Box3<ScalarType> FullBBox;
|
||||||
for (auto ni = std::begin(nodeMap); ni != std::end(nodeMap); ++ni) {
|
for (auto ni = std::begin(nodeMap); ni != std::end(nodeMap); ++ni) {
|
||||||
FullBBox.Add(vcg::Matrix44d::Construct(ni->second->tr()),ni->second->bbox());
|
FullBBox.Add(vcg::Matrix44d::Construct(ni->second->tr()),ni->second->bbox());
|
||||||
}
|
}
|
||||||
return FullBBox;
|
return FullBBox;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline vcg::Box3d gluedBBox() {
|
inline vcg::Box3<ScalarType> gluedBBox() {
|
||||||
|
|
||||||
vcg::Box3d FullBBox;
|
vcg::Box3<ScalarType> FullBBox;
|
||||||
|
|
||||||
for (auto ni = std::begin(nodeMap); ni != std::end(nodeMap); ++ni) {
|
for (auto ni = std::begin(nodeMap); ni != std::end(nodeMap); ++ni) {
|
||||||
if (ni->second->glued) {
|
if (ni->second->glued) {
|
||||||
FullBBox.Add(vcg::Matrix44d::Construct(ni->second->tr()), ni->second->bbox());
|
FullBBox.Add(vcg::Matrix44<ScalarType>::Construct(ni->second->tr()), ni->second->bbox());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return FullBBox;
|
return FullBBox;
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
#define OG_MESH_INFO_MAX_STAT 64
|
#define OG_MESH_INFO_MAX_STAT 64
|
||||||
|
|
||||||
namespace vcg {
|
namespace vcg {
|
||||||
template<class MeshType>
|
template<class MeshType, class ScalarType>
|
||||||
class OccupancyGrid {
|
class OccupancyGrid {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -165,7 +165,7 @@ namespace vcg {
|
||||||
*/
|
*/
|
||||||
std::map<int, OGMeshInfo> VM;
|
std::map<int, OGMeshInfo> VM;
|
||||||
|
|
||||||
bool Init(int _mn, Box3d bb, int size) {
|
bool Init(int _mn, Box3<ScalarType> bb, int size) {
|
||||||
|
|
||||||
// the number of meshes (including all the unused ones; eg it is the range of the possible id)
|
// the number of meshes (including all the unused ones; eg it is the range of the possible id)
|
||||||
mn = _mn;
|
mn = _mn;
|
||||||
|
|
@ -180,7 +180,7 @@ namespace vcg {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Add(const char *MeshName, Matrix44d &Tr, int id) {
|
void Add(const char *MeshName, Matrix44<ScalarType> &Tr, int id) {
|
||||||
|
|
||||||
AlignPair::A2Mesh M;
|
AlignPair::A2Mesh M;
|
||||||
|
|
||||||
|
|
@ -190,9 +190,9 @@ namespace vcg {
|
||||||
AddMesh(M,Tr,id);
|
AddMesh(M,Tr,id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddMeshes(std::vector<std::string> &names, std::vector<Matrix44d> &trv,int size) {
|
void AddMeshes(std::vector<std::string> &names, std::vector<Matrix44<ScalarType>> &trv,int size) {
|
||||||
|
|
||||||
Box3d bb, totalbb;
|
Box3<ScalarType> bb, totalbb;
|
||||||
|
|
||||||
bb.SetNull();
|
bb.SetNull();
|
||||||
totalbb.SetNull();
|
totalbb.SetNull();
|
||||||
|
|
@ -212,7 +212,7 @@ namespace vcg {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddMesh(MeshType &mesh, const Matrix44d &Tr, int ind) {
|
void AddMesh(MeshType &mesh, const Matrix44<ScalarType> &Tr, int ind) {
|
||||||
|
|
||||||
Matrix44f Trf;
|
Matrix44f Trf;
|
||||||
Trf.Import(Tr);
|
Trf.Import(Tr);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue