23 m_bottomRadius(fabs(bottomRadius)),
24 m_topRadius(fabs(topRadius)),
60 assert(!singlePointBottom || !singlePointTop);
65 unsigned vertCount = 2;
66 if (!singlePointBottom) vertCount += steps;
67 if (!singlePointTop) vertCount += steps;
69 unsigned faceNormCounts = steps + 2;
71 unsigned facesCount = steps;
72 if (!singlePointBottom) facesCount += steps;
73 if (!singlePointTop) facesCount += steps;
74 if (!singlePointBottom && !singlePointTop) facesCount += steps;
77 if (!
init(vertCount,
false, facesCount, faceNormCounts)) {
107 if (!singlePointBottom) {
108 for (
unsigned i = 0; i < steps; ++i) {
118 if (!singlePointTop) {
119 for (
unsigned i = 0; i < steps; ++i) {
128 for (
unsigned i = 0; i < steps; ++i) {
130 CCVector3 u(-sin(angle_rad_step * i), cos(angle_rad_step * i),
134 bottomCenter.
y - topCenter.
y -
136 bottomCenter.
z - topCenter.
z);
150 unsigned bottomIndex = 2;
151 unsigned topIndex = 2 + (singlePointBottom ? 0 : steps);
154 if (!singlePointBottom) {
155 for (
unsigned i = 0; i < steps; ++i) {
156 addTriangle(0, bottomIndex + (i + 1) % steps, bottomIndex + i);
161 if (!singlePointTop) {
162 for (
unsigned i = 0; i < steps; ++i) {
163 addTriangle(1, topIndex + i, topIndex + (i + 1) % steps);
168 if (!singlePointBottom && !singlePointTop) {
169 for (
unsigned i = 0; i < steps; ++i) {
170 unsigned iNext = (i + 1) % steps;
171 addTriangle(bottomIndex + i, bottomIndex + iNext, topIndex + i);
177 }
else if (!singlePointTop) {
178 for (
unsigned i = 0; i < steps; ++i) {
179 unsigned iNext = (i + 1) % steps;
187 for (
unsigned i = 0; i < steps; ++i) {
188 unsigned iNext = (i + 1) % steps;
189 addTriangle(bottomIndex + i, bottomIndex + iNext, 1);
236 trans.
apply(bottomCenter);
242 trans.
apply(topCenter);
275 assert(out.isOpen() && (out.openMode() & QIODevice::WriteOnly));
276 if (dataVersion < 21) {
284 QDataStream outStream(&out);
295 return std::max(
static_cast<short>(21),
308 QDataStream inStream(&in);
Vector3Tpl< PointCoordinateType > CCVector3
Default 3D Vector.
float PointCoordinateType
Type of the coordinates of a (N-D) point.
static bool Error(const char *format,...)
Display an error dialog with formatted message.
void normalize()
Sets vector norm to unity.
Vector3Tpl cross(const Vector3Tpl &v) const
Cross product.
void addElement(const Type &value)
virtual PointCoordinateType getLargeRadius() const
Returns whichever cone radii is larger.
bool fromFile_MeOnly(QFile &in, short dataVersion, int flags, LoadedIDMap &oldToNewIDMap) override
Loads own object data.
virtual void setBottomRadius(PointCoordinateType radius)
Sets bottom radius.
bool toFile_MeOnly(QFile &out, short dataVersion) const override
Save own object data.
PointCoordinateType m_xOff
Displacement of axes along X-axis (Snout mode)
short minimumFileVersion_MeOnly() const override
PointCoordinateType m_height
Height.
virtual ccGenericPrimitive * clone() const override
Clones primitive.
virtual CCVector3 getTopCenter() const
Returns cone axis top end point after applying transformation.
virtual CCVector3 getBottomCenter() const
Returns cone axis bottom end point after applying transformation.
virtual bool buildUp() override
Builds primitive.
virtual CCVector3 getLargeCenter() const
Returns cone axis end point associated with whichever radii is larger.
PointCoordinateType m_topRadius
Top radius.
PointCoordinateType m_bottomRadius
Bottom radius.
void setHeight(PointCoordinateType height)
Sets height.
virtual CCVector3 getSmallCenter() const
Returns cone axis end point associated with whichever radii is smaller.
virtual PointCoordinateType getSmallRadius() const
Returns whichever cone radii is smaller.
PointCoordinateType m_yOff
Displacement of axes along Y-axis (Snout mode)
virtual void setTopRadius(PointCoordinateType radius)
Sets top radius.
ccCone(PointCoordinateType bottomRadius, PointCoordinateType topRadius, PointCoordinateType height, PointCoordinateType xOff=0, PointCoordinateType yOff=0, const ccGLMatrix *transMat=0, QString name=QString("Cone"), unsigned precision=DEFAULT_DRAWING_PRECISION)
Default constructor.
void apply(float vec[3]) const
Applies transformation to a 3D vector (in place) - float version.
Float version of ccGLMatrixTpl.
virtual void showTriNorms(bool state)
Sets whether to show or not per-triangle normals.
Generic primitive interface.
void applyTransformationToVertices()
Applies associated transformation to vertices.
bool init(unsigned vertCount, bool vertNormals, unsigned faceCount, unsigned faceNormCount)
Inits internal structures.
virtual bool setDrawingPrecision(unsigned steps)
Sets drawing precision.
ccGenericPrimitive * finishCloneJob(ccGenericPrimitive *primitive) const
Finished 'clone' job (vertices color, etc.)
ccPointCloud * vertices()
Returns vertices.
const ccGLMatrix & getGLTransformationHistory() const override
inherited methods (ccHObject)
unsigned m_drawPrecision
Drawing precision (for primitives that support this feature)
static const int MIN_DRAWING_PRECISION
Minimum drawing precision.
bool toFile_MeOnly(QFile &out, short dataVersion) const override
Save own object data.
bool fromFile_MeOnly(QFile &in, short dataVersion, int flags, LoadedIDMap &oldToNewIDMap) override
Loads own object data.
ccGLMatrix m_transformation
Associated transformation (applied to vertices)
short minimumFileVersion_MeOnly() const override
virtual void notifyGeometryUpdate()
NormsIndexesTableType * m_triNormals
Per-triangle normals.
void addTriangle(unsigned i1, unsigned i2, unsigned i3)
Adds a triangle to the mesh.
void addTriangleNormalIndexes(int i1, int i2, int i3)
Adds a triplet of normal indexes for next triangle.
triangleIndexesContainer * m_triVertIndexes
Triangles' vertices indexes (3 per triangle)
static CompressedNormType GetNormIndex(const PointCoordinateType N[])
Returns the compressed index corresponding to a normal vector.
virtual QString getName() const
Returns object name.
A 3D cloud and its associated features (color, normals, scalar fields, etc.)
QMultiMap< unsigned, unsigned > LoadedIDMap
Map of loaded unique IDs (old ID --> new ID)
static void CoordsFromDataStream(QDataStream &stream, int flags, PointCoordinateType *out, unsigned count=1)
void addPoint(const CCVector3 &P)
Adds a 3D point to the database.
unsigned int CompressedNormType
Compressed normals type.
bool LessThanEpsilon(float x)
Test a floating point number against our epsilon (a very small number).