Integration of gauss map, osculating toroidal patches, loop detection and C2 judgement to figure out the singular or loop intersection.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

101 lines
3.6 KiB

//
// Created by 14727 on 2022/12/24.
//
#ifndef GAUSSMAP_GAUSS_MAP_H
#define GAUSSMAP_GAUSS_MAP_H
#include "aabb.h"
#include "glm/glm.hpp"
#include "map"
#include "real.h"
#include "set"
#include "tinynurbs/tinynurbs.h"
#include "vector"
// 一个节点就表示一个球上矩形面片
struct GaussMapNode {
// 四个顶点的法向量值确定一个平面的法向量值
AABB bound;
int level, firstChild;
int idx_u, idx_v;
};
class GaussMap {
public:
int maxLevel;
const std::vector<std::vector<glm::vec3>> &normals;
std::vector<GaussMapNode> tree;
void recursiveBuild(int level, int idx, int idx_u, int idx_v);
explicit GaussMap(const std::vector<std::vector<glm::vec3>> &normals_);
void build();
void printQuadTree();
};
// std::vector<std::pair<int, int>> getOverlapLeafNodes(const GaussMap &gm1,
// const GaussMap &gm2);
std::map<std::pair<int, int>, std::set<std::pair<int, int>>>
getOverlapLeafNodes(const GaussMap &gm1, const GaussMap &gm2);
void recursiveGetOverlapLeafNodes(const GaussMap &gm1, const GaussMap &gm2,
int idx1, int idx2,
std::vector<std::pair<int, int>> &pairs);
/**
* 判断两个曲面的Gauss Map在指定的、各自的参数范围内有没有交
* @param idxRange_u1 第一个gauss
* map的参数u范围对应的u方向上的采样网格的格子下标范围
* @param idxRange_v1 第一个gauss
* map的参数v范围对应的u方向上的采样网格的格子下标范围
* @param idxRange_u2 第而个gauss
* map的参数u范围对应的u方向上的采样网格的格子下标范围
* @param idxRange_v2 第二个gauss
* map的参数v范围对应的u方向上的采样网格的格子下标范围
* @return true:gauss map的包围盒有交集,说明gauss map<可能>有重合;false: gauss
* map一定没有重合
*/
bool isGaussMapsOverlapped(const GaussMap &gm1, const GaussMap &gm2,
std::pair<int, int> idxRange_u1,
std::pair<int, int> idxRange_v1,
std::pair<int, int> idxRange_u2,
std::pair<int, int> idxRange_v2);
bool isLeafNodesOverlapped(const GaussMap &gm1, const GaussMap &gm2,
std::pair<int, int> idx1, std::pair<int, int> idx2);
/**
* 判断两个曲面的Gauss Map在指定的、各自的参数范围内有没有交
* @param range_u1 第一个gauss map的参数u范围
* @param range_v1 第一个gauss map的参数v范围
* @param range_u2 第二个gauss map的参数u范围
* @param range_v2 第二个gauss map的参数v范围
* @param paramRange_u1 第一个gauss map的参数u定义域
* @param paramRange_v1 第一个gauss map的参数v定义域
* @param paramRange_u2 第二个gauss map的参数u定义域
* @param paramRange_v2 第二个gauss map的参数v定义域
* @return true:gauss map的包围盒有交集,说明gauss map<可能>有重合;false: gauss
* map一定没有重合
*/
bool isGaussMapsOverlapped(
const GaussMap &gm1, const GaussMap &gm2, std::pair<real, real> range_u1,
std::pair<real, real> range_v1, std::pair<real, real> range_u2,
std::pair<real, real> range_v2, std::pair<real, real> paramRange_u1,
std::pair<real, real> paramRange_v1, std::pair<real, real> paramRange_u2,
std::pair<real, real> paramRange_v2);
/**
* 当前层的第一个节点的坐标
* @param layer 层号。根节点为第一层
*/
int getStartIdxOfLayerN(int layer);
/**
* 根据u、v参数域中的小矩形的位置,判断它在BVH叶节点层(也就是最后一层)中的位置
*/
int getChildNodeIdx(int ix, int iy);
#endif // GAUSSMAP_GAUSS_MAP_H