Simbody
3.4 (development)
|
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-13 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 00071 class SimTK_SimTKCOMMON_EXPORT PolygonalMesh 00072 : public PIMPLHandle<PolygonalMesh, PolygonalMeshImpl, true> { 00073 public: 00075 PolygonalMesh() {} 00076 00088 static PolygonalMesh createSphereMesh(Real radius, 00089 int resolution = 1); 00090 00123 static PolygonalMesh createBrickMesh(const Vec3& halfDims, 00124 int resolution = 1); 00125 00154 static PolygonalMesh createCylinderMesh(const UnitVec3& axis, 00155 Real radius, 00156 Real halfLength, 00157 int resolution=1); 00158 00161 void clear(); 00162 00164 int getNumFaces() const; 00166 int getNumVertices() const; 00167 00172 const Vec3& getVertexPosition(int vertex) const; 00175 int getNumVerticesForFace(int face) const; 00182 int getFaceVertex(int face, int vertex) const; 00183 00188 int addVertex(const Vec3& position); 00189 00198 int addFace(const Array_<int>& vertices); 00199 00207 PolygonalMesh& scaleMesh(Real scale); 00208 00215 PolygonalMesh& transformMesh(const Transform& X_AM); 00216 00221 void loadObjFile(std::istream& file); 00222 00226 void loadVtpFile(const String& pathname); 00227 00228 private: 00229 explicit PolygonalMesh(PolygonalMeshImpl* impl) : HandleBase(impl) {} 00230 void initializeHandleIfEmpty(); 00231 }; 00232 00233 } // namespace SimTK 00234 00235 #endif // SimTK_SimTKCOMMON_POLYGONAL_MESH_H_