Triangulator.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2008, AIST, the University of Tokyo and General Robotix Inc.
00003  * All rights reserved. This program is made available under the terms of the
00004  * Eclipse Public License v1.0 which accompanies this distribution, and is
00005  * available at http://www.eclipse.org/legal/epl-v10.html
00006  * Contributors:
00007  * National Institute of Advanced Industrial Science and Technology (AIST)
00008  */
00009 
00014 #ifndef HRPUTIL_TRIANGULATOR_H_INCLUDED
00015 #define HRPUTIL_TRIANGULATOR_H_INCLUDED
00016 
00017 #include <vector>
00018 #include <boost/dynamic_bitset.hpp>
00019 #include <hrpUtil/Eigen3d.h>
00020 #include "VrmlNodes.h"
00021 
00022 namespace hrp {
00023     
00024     class Triangulator
00025     {
00026     public:
00027 
00028         void setVertices(const MFVec3f& vertices) {
00029             this->vertices = &vertices;
00030         }
00031 
00035         int apply(const std::vector<int>& polygon);
00036 
00042         const std::vector<int>& triangles() {
00043             return triangles_;
00044         }
00045 
00046     private:
00047 
00048         enum Convexity { FLAT, CONVEX, CONCAVE };
00049         
00050         const MFVec3f* vertices;
00051         const std::vector<int>* orgPolygon;                                                                  
00052         std::vector<int> triangles_;
00053         std::vector<int> workPolygon;
00054         Vector3 ccs; // cyclic cross sum
00055         boost::dynamic_bitset<> earMask;
00056 
00057         Vector3Ref vertex(int localIndex){
00058             return getVector3Ref((*vertices)[(*orgPolygon)[localIndex]].data());
00059         }
00060 
00061         Vector3Ref workVertex(int workPolygonIndex){
00062             return getVector3Ref((*vertices)[(*orgPolygon)[workPolygon[workPolygonIndex]]].data());
00063         }
00064 
00065         Convexity calcConvexity(int ear);
00066         bool checkIfEarContainsOtherVertices(int ear);
00067     };
00068 
00069 }
00070 
00071 #endif


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Thu Apr 11 2019 03:30:19