| 
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -25,8 +25,9 @@ bool isLeft(Blob b) { return b.isLeft == 1; } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					class BlobTree | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					{ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					public: | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    std::vector<Blob>         structure; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    std::vector<unsigned int> primtiveNodeIdx; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    std::vector<Blob> structure; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    std::vector<unsigned int> primitiveNodeIdx; // 由primitive数组下标指向node中对应leaf的下标
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    BlobTree() {} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					}; | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -83,14 +84,17 @@ void propagate(BlobTree& tree, unsigned int nodeIdx, bool in) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    return; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					// 这里传入的是拷贝,因为要修改,但不同traversal的修改不相互影响
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					// 这里传入的BlobTree是拷贝,因为要修改且不同traversal的修改不相互影响
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					// TODO: 最好优化掉拷贝
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					// TODO: std::vector<bool> 可以改成bitset之类
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					bool traverse(BlobTree tree, std::vector<int> possiblePrimtivies, const std::vector<bool>& primitiveInout) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					// TODO: std::vector<bool> 可以改成bitset之TT
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					/**
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					 * relatedPrimitives 是当次traversal需要care的primitives的索引,例如OcTree子问题中管理的Primitive | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					 */ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					bool traverse(BlobTree tree, const std::vector<int>& relatedPrimitives, const std::vector<bool>& primitiveInout) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					{ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    assert(possiblePrimtivies.size() == tree.primtiveNodeIdx.size()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    for (int nodeIdx : tree.primtiveNodeIdx) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        propagate(tree, nodeIdx, primitiveInout[]); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    assert(relatedPrimitives.size() == primitiveInout.size()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    for (int primitiveIdx : relatedPrimitives) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        propagate(tree, tree.primitiveNodeIdx[primitiveIdx], primitiveInout[primitiveIdx]); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        if (tree.structure.back().inOut != 0) { return tree.structure.back().inOut == 1; } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    std::cerr << "should not be here" << std::endl; | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
				 | 
				
					
  |