Scene_Objects::Scene_Objects() { ObjectId=0; ObjectPos=0; pnts.clear(); pen = QPen(); brush = QBrush(); QPointF pnt1(0,0); ObjectStrtBoundPnt=pnt1; ObjectEndBoundPnt=pnt1; rotation=0; }
bool MultilevelHexahedronSetTopologyContainer::Component::getConnection(const Component* other, Vec<3, int>& connection) const { if((this->_id - other->_id).norm2() > 3) return false; const int level = this->getLevel(); const int size = 1 << level; // check if the two components contain neighboring voxels for(std::set<Vec3i>::const_iterator voxelIter = this->_voxels.begin(); voxelIter != this->_voxels.end(); ++voxelIter) { const Vec3i& voxel1 = (*voxelIter); if((voxel1[0] % size > 0) && (voxel1[1] % size > 0) && (voxel1[2] % size > 0) && (voxel1[0] % size < size -1) && (voxel1[1] % size < size - 1) && (voxel1[2] % size < size - 1)) continue; for(std::set<Vec3i>::const_iterator voxelIter2 = other->_voxels.begin(); voxelIter2 != other->_voxels.end(); ++voxelIter2) { const Vec3i& voxel2 = (*voxelIter2); if((voxel2[0] % size > 0) && (voxel2[1] % size > 0) && (voxel2[2] % size > 0) && (voxel2[0] % size < size -1) && (voxel2[1] % size < size - 1) && (voxel2[2] % size < size - 1)) continue; const Vec3i diff(voxel1 - voxel2); const int diffNorm2 = diff.norm2(); if(diffNorm2 == 1) // face connection { connection = diff; return true; } else if(diffNorm2 == 2) // edge connection iff the connecting edge is also an edge of the top level comp. { if(level == 0) { connection = diff; } else { Vec3i d0, d1; d0[0] = (diff[0] == 1) ? 1 : 0; d0[1] = (diff[1] == 1) ? 1 : 0; d0[2] = (diff[2] == 1) ? 1 : 0; d1[0] = (diff[0] == 1) ? 1 : ((diff[0] == 0) ? 1 : 0); d1[1] = (diff[1] == 1) ? 1 : ((diff[1] == 0) ? 1 : 0); d1[2] = (diff[2] == 1) ? 1 : ((diff[2] == 0) ? 1 : 0); Vec3i pnt0((*voxelIter2) + d0); pnt0[0] = pnt0[0] % size; pnt0[1] = pnt0[1] % size; pnt0[2] = pnt0[2] % size; pnt0[0] = (pnt0[0] == 0) ? 1 : 0; pnt0[1] = (pnt0[1] == 0) ? 1 : 0; pnt0[2] = (pnt0[2] == 0) ? 1 : 0; Vec3i pnt1((*voxelIter2) + d1); pnt1[0] = pnt1[0] % size; pnt1[1] = pnt1[1] % size; pnt1[2] = pnt1[2] % size; pnt1[0] = (pnt1[0] == 0) ? 1 : 0; pnt1[1] = (pnt1[1] == 0) ? 1 : 0; pnt1[2] = (pnt1[2] == 0) ? 1 : 0; connection[0] = diff[0] * pnt0[0] * pnt1[0]; connection[1] = diff[1] * pnt0[1] * pnt1[1]; connection[2] = diff[2] * pnt0[2] * pnt1[2]; } return true; } else if(diffNorm2 == 3) // vertex connection iff the connecting vertex is also a vertex of the top level comp. { if(level == 0) { connection = diff; } else { Vec3i d; d[0] = (diff[0] == 1) ? 1 : 0; d[1] = (diff[1] == 1) ? 1 : 0; d[2] = (diff[2] == 1) ? 1 : 0; Vec3i pnt((*voxelIter2) + d); pnt[0] = pnt[0] % size; pnt[1] = pnt[1] % size; pnt[2] = pnt[2] % size; pnt[0] = (pnt[0] == 0) ? 1 : 0; pnt[1] = (pnt[1] == 0) ? 1 : 0; pnt[2] = (pnt[2] == 0) ? 1 : 0; connection[0] = diff[0] * pnt[0]; connection[1] = diff[1] * pnt[1]; connection[2] = diff[2] * pnt[2]; } return true; } } } return false; }