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.
		
		
		
		
		
			
		
			
				
					
					
						
							68 lines
						
					
					
						
							2.6 KiB
						
					
					
				
			
		
		
		
			
			
			
				
					
				
				
					
				
			
		
		
	
	
							68 lines
						
					
					
						
							2.6 KiB
						
					
					
				
								#pragma once
							 | 
						|
								
							 | 
						|
								#include "io_primitive.h"
							 | 
						|
								
							 | 
						|
								EXTERN_C_BEGIN
							 | 
						|
								
							 | 
						|
								// forward declartions
							 | 
						|
								struct blobtree_t;
							 | 
						|
								struct baked_blobtree_t;
							 | 
						|
								
							 | 
						|
								enum node_operation { UNION_OP, INTERSECTION_OP, DIFFERENCE_OP };
							 | 
						|
								
							 | 
						|
								// just used for guards the data range of the iterator
							 | 
						|
								// DO NOT TRY TO MODIFY THIS STRUCTURE MANUALLY
							 | 
						|
								struct node_iterator_t {
							 | 
						|
								    void *_, *__, *___;
							 | 
						|
								};
							 | 
						|
								
							 | 
						|
								/**
							 | 
						|
								 * @brief Creates a new blobtree.
							 | 
						|
								 * @return A pointer to the newly created blobtree.
							 | 
						|
								 * @note The blobtree just holds some information pointing to each primitive given, but not has the own of the primitives.
							 | 
						|
								 */
							 | 
						|
								API blobtree_t* create_blobtree() noexcept;
							 | 
						|
								API void        destroy_blobtree(blobtree_t* blobtree) noexcept;
							 | 
						|
								
							 | 
						|
								/**
							 | 
						|
								 * @brief Bakes the blobtree into a more efficient structure for solvers.
							 | 
						|
								 * @param[in] blobtree The blobtree to bake, which should only hold one tree but a forest of trees.
							 | 
						|
								 * @return A pointer to the baked blobtree.
							 | 
						|
								 * @note This operation can be time consuming since it involves twice time of depth-first travelsal.
							 | 
						|
								 */
							 | 
						|
								API baked_blobtree_t* bake_blobtree(const blobtree_t* blobtree) noexcept;
							 | 
						|
								API void              destroy_baked_blobtree(baked_blobtree_t* baked_blobtree) noexcept;
							 | 
						|
								
							 | 
						|
								/**
							 | 
						|
								 * @brief Add a primitive node to the blobtree.
							 | 
						|
								 * @param[in] blobtree The blobtree to add the node to.
							 | 
						|
								 * @param[in] primitive The primitive to add to the blobtree.
							 | 
						|
								 * @return The iterator of the newly created node.
							 | 
						|
								 */
							 | 
						|
								API node_iterator_t blobtree_add_primitive_node(blobtree_t* blobtree, primitive* primitive) noexcept;
							 | 
						|
								
							 | 
						|
								/**
							 | 
						|
								 * @brief Add an operation node to the blobtree.
							 | 
						|
								 * @param[in] blobtree The blobtree to add the node to.
							 | 
						|
								 * @param[in] lhs The left-hand side node iterator.
							 | 
						|
								 * @param[in] rhs The right-hand side node iterator.
							 | 
						|
								 * @param[in] op The operation to perform on the two nodes.
							 | 
						|
								 * @return The iterator of the newly created node.
							 | 
						|
								 * @note This function does not check whether the input nodes are on that blobtree or not.
							 | 
						|
								 *       It is the user's responsibility to check that.
							 | 
						|
								 */
							 | 
						|
								API node_iterator_t blobtree_add_operation_node(blobtree_t*     blobtree,
							 | 
						|
								                                                node_iterator_t lhs,
							 | 
						|
								                                                node_iterator_t rhs,
							 | 
						|
								                                                node_operation  op) noexcept;
							 | 
						|
								
							 | 
						|
								/**
							 | 
						|
								 * @brief remove a node from the blobtree.
							 | 
						|
								 * @param[in] blobtree The blobtree to remove the node from.
							 | 
						|
								 * @param[in] node The iterator of the node to remove.
							 | 
						|
								 * @note This function does not check whether the node is on that blobtree or not.
							 | 
						|
								 *       It is the user's responsibility to check that.
							 | 
						|
								 */
							 | 
						|
								API void blobtree_remove_node(blobtree_t* blobtree, node_iterator_t node) noexcept;
							 | 
						|
								
							 | 
						|
								EXTERN_C_END
							 |