/usr/include/sofa/component/topology/CubeTopology.h is in libsofa1-dev 1.0~beta4-9.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | /******************************************************************************
* SOFA, Simulation Open-Framework Architecture, version 1.0 beta 4 *
* (c) 2006-2009 MGH, INRIA, USTL, UJF, CNRS *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by *
* the Free Software Foundation; either version 2.1 of the License, or (at *
* your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
*******************************************************************************
* SOFA :: Modules *
* *
* Authors: The SOFA Team and external contributors (see Authors.txt) *
* *
* Contact information: contact@sofa-framework.org *
******************************************************************************/
#ifndef SOFA_COMPONENT_TOPOLOGY_CUBETOPOLOGY_H
#define SOFA_COMPONENT_TOPOLOGY_CUBETOPOLOGY_H
#include <sofa/component/topology/MeshTopology.h>
#include <sofa/defaulttype/Vec.h>
namespace sofa
{
namespace component
{
namespace topology
{
using namespace sofa::defaulttype;
class SOFA_COMPONENT_CONTAINER_API CubeTopology : public MeshTopology
{
public:
CubeTopology(int nx, int ny, int nz);
CubeTopology();
void setSize(int nx, int ny, int nz);
void parse(core::objectmodel::BaseObjectDescription* arg);
int getNx() const { return nx.getValue(); }
int getNy() const { return ny.getValue(); }
int getNz() const { return nz.getValue(); }
void setNx(int n) { nx.setValue(n); setSize(); }
void setNy(int n) { ny.setValue(n); setSize(); }
void setNz(int n) { nz.setValue(n); setSize(); }
virtual void init();
virtual void reinit();
//int getNbQuads();
//Quad getQuad(int i);
//Quad getQuad(int x, int y, int z);
enum Plane { PLANE_UNKNOWN=0,
PLANE_X0,
PLANE_X1,
PLANE_Y0,
PLANE_Y1,
PLANE_Z0,
PLANE_Z1 };
int point(int x, int y, int z, Plane p = PLANE_UNKNOWN) const; // { return x+nx.getValue()*(y+ny.getValue()*z); }
void setP0(const Vector3& val) { p0 = val; }
void setDx(const Vector3& val) { dx = val; inv_dx2 = 1/(dx*dx); }
void setDy(const Vector3& val) { dy = val; inv_dy2 = 1/(dy*dy); }
void setDz(const Vector3& val) { dz = val; inv_dz2 = 1/(dz*dz); }
void setPos(SReal xmin, SReal xmax, SReal ymin, SReal ymax, SReal zmin, SReal zmax);
const Vector3& getP0() const { return p0; }
const Vector3& getDx() const { return dx; }
const Vector3& getDy() const { return dy; }
const Vector3& getDz() const { return dz; }
Vector3 getMin() const { return min.getValue();}
Vector3 getMax() const { return max.getValue();}
Vector3 getPoint(int i) const;
Vector3 getPoint(int x, int y, int z) const;
bool hasPos() const{ return true; }
double getPX(int i) const { return getPoint(i)[0]; }
double getPY(int i) const { return getPoint(i)[1]; }
double getPZ(int i) const { return getPoint(i)[2]; }
void setSplitNormals(bool b){splitNormals.setValue(b);}
protected:
Data<int> nx;
Data<int> ny;
Data<int> nz;
Data<bool> internalPoints;
Data<bool> splitNormals;
Data< Vector3 > min, max;
/// Position of point 0
Vector3 p0;
/// Distance between points in the grid. Must be perpendicular to each other
Vector3 dx,dy,dz;
SReal inv_dx2, inv_dy2, inv_dz2;
virtual void setSize();
void updateEdges();
void updateQuads();
//void updateHexas();
};
} // namespace topology
} // namespace component
} // namespace sofa
#endif
|