Documentation for Ktirio function
1. Class PointSet
1.1. Initialisation :
-
We can initiate a Pointset empty, it will create empty map for
point
andnormal
. -
We can initiate a Pointset With a Mesh from ktirio, it will put all point in the map
point
kepping the same ID. -
We can initiata a Pointset from another one , it will copy both map.
1.2. Method :
- auto beging() , auto end() // cycle on the map 'point' to use a PointSet object in a for boucle.
- size_t size() // return the size of the map 'point'
- size_t size_normal() // return the size of the map 'normal'
- void addPoint(int id,PointType point) // PointType is most likely MeshPoint form ktirio library, it add the Point at the id if the id is free,
//else it modify the value (to do )
- void addNormal(int id,PointType normal) // Same as addPoint but for normal
- void printPoints() // print all point
- void clear() // clear both map. (to do add clear normal map)
- void addMarker() // add marker to a point
- void getMarkerFromMesh(Mesh const &m) // get all marker from the m mesh on corresponding point in the Point map
- std::vector<marker_id_type>& getMarker(int id) // get all the marker from a point
- PointType getMeshPoint(int id) // Return the Point associated to the id
- PointType getNormal(int id) // Return the Normal associated to the id
- void getBoundingBox(double &x_min,double &x_max,double &y_min,double &y_max,double &z_min,double &z_max) // get the bounding box of the point set in store in all argument
- std::unordered_map<int,pointType>const& points() // Return the map 'point'
- std::unordered_map<int,pointType>const& normals() // Return the map 'normal'
- std::unordered_map<int, std::vector<marker_id_type>>const& marker() // return the marker map
1.3. Conversion function
Conversion function for ktirio PointSet to Cgal Point_set and conversly.
template <typename KernelType,typename PointType>
void
toPointSetCgal(PointSet const &ps_ktirio,CGAL::Point_set_3<PointType> &ps,bool hasnormal = false )
// Convert the PointSet ps_ktirio to Cgal Point_set ps. If has normal = True copy the `normal` map also else only the `point` map is copied
template <typename KernelType, typename PointType>
void toPointSetKtirio(PointSet& ps_ktirio, const CGAL::Point_set_3<PointType>& ps_Cgal,bool has_normal = false)
// Convert the Cgal Point_set ps to PointSet ps_ktirio . If has normal = True copy the `normal` map also else only the `point` map is copied
2. Mesh Function
2.1. Check validity function
At first we had one function for each property we wanted to check, now we want to simplify it by grouping everything in one function that take an enum
in
input :
enum class propertyToCheck
{
isClosed,
isOutwardOriented,
isTriangle,
isSelfIntersect,
isConnected
};
template< typename Meshtype, typename KernelType>
bool
checkProperties(Meshtype &ktirio_mesh,const std::vector<propertyToCheck>& properties)
// This function will check if every properties stocked in the vector `properties` are true or not for the mesh ktirio_mesh.We can add later properties
// to the enum and just add the check to the properties in the function to add more flexibility to the function.
2.2. Mesh manipulation function
template<typename MeshType, typename Kernel> bool orient(MeshType &ktirio_mesh)
// This function look at the mesh and search for a compatible orientation avaible and reverse the faces that are miss-oriented.
template<typename MeshType,typename KernelType>
void remesh(MeshType &ktirio_mesh,double target_edge_length = 0.04)
// This function use isotropic_remeshing from cgal to modify the structure of the mesh,It unify the lenght of the faces and vertices to target_edge_length
// the lower the target_edge_length is , the highest the number or faces and vertices generates is. It Modify the ktirio_mesh given in input.
template<typename Meshtype, typename KernelType>
bool refineSelfIntersect(Meshtype &ktirio_mesh)
//This function use autorefine_triangle_soup from Cgal to modify the mesh and get ride of duplicated point,duplicated edge or self intersect faces by remeshing the mesh
// stocking the triangle without issue first then triangle coming from a subdivision of the intersection.
template<typename MeshType,typename KernelType>
void putName(MeshType &ksr_input,MeshType &ksr_output)
//This function use the AABB_tree package from CGAL to compare two meshes and bring the marker of the input mesh to the output.
More info on isotropic_remeshing
More info on autorefine_triangle_soup
3. PointSet manipulation [[PointSet manipulation]]
template<typename KernelType>
int
gridsimplify(Mesh &ktiriomesh,PointSet &ktiriops,double cell_size = 0.04 )
//This function take a ktirio_mesh and Pointset as and input, It read the mesh compute the normal associated to each point and stock one point of the mesh by
//cell define by the cell_size into the ktirio_ps
template<typename Kernel,typename FT,typename Meshtype>
int
KSR(po::variables_map &vm,PointSet &ktirio_ps,std::vector<std::vector<std::size_t>>& polylist,Meshtype &ktirio_mesh)
// description of parameters :
// po::variables_map &vm : Set of parameters giving in input when we execute the programs,
// PointSet &ktirio_ps : PointSet of the mesh we want to apply KSR,
// std::vector<std::vector<std::size_t>>& polylist : Vector containing which vertex composed each faces.(not triangulated )
// Meshtype &ktirio_mesh : Mesh to stock the mesh of the output from KSR triangulated.
//
// This function will apply KSR algorithms on the pointset, modifying it during the process and stocking the faces info in the vector polylist
// I add ktirio_mesh in input as the CGAL KSR didnt triangulated the output.You can read more info about KSR algorithms in the Kinetic part of methodo
More info on Kinetic
More info on gridSimplify
4. IO Function
//all files are written in ASCII for now
void readPly(std::string const &filename,PointSet &ps, bool with_normal = false)
// Read a PLY files and stock all point in the ps pointset, if the normal are describe in the files put the parameters with_normal to true, the normal will
// be stock in the ps pointset also
void writePly(PointSet &ps ,std::string &filename,bool hasnormal = false)
// Write a PLY files containing all point from ps Pointset , if ps has normal map put the parameters hasnormal to true to write them also.
void writeOff(std::string const &filename, PointSet &ps, std::vector<std::vector<std::size_t>> &polylist )
// Write the output of KSR algorithms into a .OFF files
void writeObj(const std::string& filename, const Feel::Ktirio::Geom::PointSet& ps, const std::vector<std::vector<std::size_t>>& polylist)
// Write the output of KSR algorithms into a .OBJ files (sometimes the .OFF files didnt work well)