Simbody
3.5
|
00001 #ifndef SimTK_SimTKCOMMON_POLYGONAL_MESH_H_ 00002 #define SimTK_SimTKCOMMON_POLYGONAL_MESH_H_ 00003 00004 /* -------------------------------------------------------------------------- * 00005 * Simbody(tm): SimTKcommon * 00006 * -------------------------------------------------------------------------- * 00007 * This is part of the SimTK biosimulation toolkit originating from * 00008 * Simbios, the NIH National Center for Physics-Based Simulation of * 00009 * Biological Structures at Stanford, funded under the NIH Roadmap for * 00010 * Medical Research, grant U54 GM072970. See https://simtk.org/home/simbody. * 00011 * * 00012 * Portions copyright (c) 2008-14 Stanford University and the Authors. * 00013 * Authors: Peter Eastman * 00014 * Contributors: Michael Sherman * 00015 * * 00016 * Licensed under the Apache License, Version 2.0 (the "License"); you may * 00017 * not use this file except in compliance with the License. You may obtain a * 00018 * copy of the License at http://www.apache.org/licenses/LICENSE-2.0. * 00019 * * 00020 * Unless required by applicable law or agreed to in writing, software * 00021 * distributed under the License is distributed on an "AS IS" BASIS, * 00022 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * 00023 * See the License for the specific language governing permissions and * 00024 * limitations under the License. * 00025 * -------------------------------------------------------------------------- */ 00026 00027 #include "SimTKcommon/Simmatrix.h" 00028 #include "SimTKcommon/internal/PrivateImplementation.h" 00029 00030 namespace SimTK { 00031 00032 class PolygonalMesh; 00033 class PolygonalMeshImpl; 00034 00035 // We only want the template instantiation to occur once. This symbol is defined 00036 // in the SimTKcommon compilation unit that defines the PolygonalMesh class but 00037 // should not be defined any other time. 00038 #ifndef SimTK_SIMTKCOMMON_DEFINING_POLYGONALMESH 00039 extern template class PIMPLHandle<PolygonalMesh, PolygonalMeshImpl, true>; 00040 #endif 00041 00070 class SimTK_SimTKCOMMON_EXPORT PolygonalMesh 00071 : public PIMPLHandle<PolygonalMesh, PolygonalMeshImpl, true> { 00072 public: 00074 PolygonalMesh() {} 00075 00087 static PolygonalMesh createSphereMesh(Real radius, 00088 int resolution = 1); 00089 00122 static PolygonalMesh createBrickMesh(const Vec3& halfDims, 00123 int resolution = 1); 00124 00153 static PolygonalMesh createCylinderMesh(const UnitVec3& axis, 00154 Real radius, 00155 Real halfLength, 00156 int resolution=1); 00157 00160 void clear(); 00161 00163 int getNumFaces() const; 00165 int getNumVertices() const; 00166 00171 const Vec3& getVertexPosition(int vertex) const; 00174 int getNumVerticesForFace(int face) const; 00181 int getFaceVertex(int face, int vertex) const; 00182 00187 int addVertex(const Vec3& position); 00188 00197 int addFace(const Array_<int>& vertices); 00198 00206 PolygonalMesh& scaleMesh(Real scale); 00207 00214 PolygonalMesh& transformMesh(const Transform& X_AM); 00215 00227 void loadFile(const String& pathname); 00228 00233 void loadObjFile(const String& pathname); 00234 00240 void loadObjFile(std::istream& file); 00241 00246 void loadVtpFile(const String& pathname); 00247 00256 void loadStlFile(const String& pathname); 00257 00258 private: 00259 explicit PolygonalMesh(PolygonalMeshImpl* impl) : HandleBase(impl) {} 00260 void initializeHandleIfEmpty(); 00261 }; 00262 00263 } // namespace SimTK 00264 00265 #endif // SimTK_SimTKCOMMON_POLYGONAL_MESH_H_