24 static QSharedPointer<ccTorus>
c_torus(
nullptr);
33 context.transformInfo.setTranslationStart(start);
50 axis = Z.
cross(direction);
54 context.transformInfo.setRotation(angle_deg, axis.
x, axis.
y, axis.
z);
61 axis = Z.
cross(direction);
64 context.transformInfo.setRotation(angle_deg, axis.
x, axis.
y, axis.
z);
69 new ccCylinder(0.15f, 0.6f,
nullptr,
"ArrowShaft", 12));
72 new ccCone(0.3f, 0, 0.4f, 0, 0,
nullptr,
"ArrowHead", 24));
79 context.transformInfo.setTranslationEnd(0.3f * 0.5f * dir);
81 context.transformInfo.setTranslationEnd(0.3f * dir);
83 context.viewID = QString::number(ID, 10) +
"-arrowShaft";
91 context.transformInfo.setTranslationEnd((0.3f + 0.2f) * 0.5f * dir);
93 context.transformInfo.setTranslationEnd((0.3f + 0.2f) * dir);
96 context.viewID = QString::number(ID, 10) +
"-arrowHead";
115 context.transformInfo.setTranslationStart(center);
132 axis = Z.
cross(direction);
136 context.transformInfo.setRotation(angle_deg, axis.
x, axis.
y, axis.
z);
143 axis = Z.
cross(direction);
145 context.transformInfo.setRotation(angle_deg, axis.
x, axis.
y, axis.
z);
150 0.2f, 0.4f, 2.0 *
M_PI,
false, 0,
nullptr,
"Torus", 12));
156 context.transformInfo.setTranslationEnd(0.3f * dir);
157 context.viewID = QString::number(ID, 10) +
"-torus";
219 m_entityContainer(
"entities"),
221 m_activeComponent(NONE) {
243 get(extents, transformation);
249 for (
unsigned d = 0; d < 3; ++d) {
260 posPlane.
equation.
w = -
static_cast<double>(C.
dot(N)) + halfDim.
u[d];
277 negPlane.
equation.
w =
static_cast<double>(C.
dot(N)) + halfDim.
u[d];
321 QStringList removeViewIds;
328 QStringList removeViewIds;
336 removeViewIds.clear();
337 removeViewIds.push_back(QString::number(
X_MINUS_ARROW, 10) +
"-arrowShaft");
338 removeViewIds.push_back(QString::number(
X_MINUS_ARROW, 10) +
"-arrowHead");
339 removeViewIds.push_back(QString::number(
X_PLUS_ARROW, 10) +
"-arrowShaft");
340 removeViewIds.push_back(QString::number(
X_PLUS_ARROW, 10) +
"-arrowHead");
341 removeViewIds.push_back(QString::number(
Y_MINUS_ARROW, 10) +
"-arrowShaft");
342 removeViewIds.push_back(QString::number(
Y_MINUS_ARROW, 10) +
"-arrowHead");
343 removeViewIds.push_back(QString::number(
Y_PLUS_ARROW, 10) +
"-arrowShaft");
344 removeViewIds.push_back(QString::number(
Y_PLUS_ARROW, 10) +
"-arrowHead");
345 removeViewIds.push_back(QString::number(
Z_MINUS_ARROW, 10) +
"-arrowShaft");
346 removeViewIds.push_back(QString::number(
Z_MINUS_ARROW, 10) +
"-arrowHead");
347 removeViewIds.push_back(QString::number(
Z_PLUS_ARROW, 10) +
"-arrowShaft");
348 removeViewIds.push_back(QString::number(
Z_PLUS_ARROW, 10) +
"-arrowHead");
350 for (
int i =
CROSS * 10; i <
CROSS * 10 + 6; ++i) {
351 removeViewIds.push_back(QString::number(i, 10) +
"-arrowShaft");
352 removeViewIds.push_back(QString::number(i, 10) +
"-arrowHead");
355 removeViewIds.push_back(QString::number(
X_MINUS_TORUS, 10) +
"-torus");
356 removeViewIds.push_back(QString::number(
Y_MINUS_TORUS, 10) +
"-torus");
357 removeViewIds.push_back(QString::number(
Z_MINUS_TORUS, 10) +
"-torus");
358 removeViewIds.push_back(QString::number(
X_PLUS_TORUS, 10) +
"-torus");
359 removeViewIds.push_back(QString::number(
Y_PLUS_TORUS, 10) +
"-torus");
360 removeViewIds.push_back(QString::number(
Z_PLUS_TORUS, 10) +
"-torus");
437 CCVector3d v(
static_cast<double>(2 * std::max(std::min(
x, screenWidth - 1),
440 static_cast<double>(screenWidth),
441 static_cast<double>(screenHeight -
442 2 * std::max(std::min(
y, screenHeight - 1),
443 -screenHeight + 1)) /
444 static_cast<double>(screenHeight),
448 double d2 = v.
x * v.
x + v.
y * v.
y;
463 int x,
int y,
int dx,
int dy,
int screenWidth,
int screenHeight) {
477 transMat = rotMat * transMat;
592 for (
int i = 1; i < 3; ++i) {
594 if (fabs(dot) > fabs(maxDot)) {
601 if (maxDot < 0.0) angle_rad = -angle_rad;
609 transMat = rotMat * transMat;
647 bool shrink )
const {
648 if (!cloud || !visTable) {
653 if (cloud->
size() != visTable->size()) {
659 int count =
static_cast<int>(cloud->
size());
665 #pragma omp parallel for
667 for (
int i = 0; i <
count; ++i) {
677 #pragma omp parallel for
679 for (
int i = 0; i <
count; ++i) {
692 if (withGLFeatures) {
705 scale = std::max<PointCoordinateType>(scale,
706 getBox().getDiagNorm() / 25);
757 entityPickingMode =
true;
783 minC -
CCVector3(scale, scale, scale) / 2.0, scale,
constexpr unsigned char POINT_VISIBLE
constexpr unsigned char POINT_HIDDEN
Vector3Tpl< double > CCVector3d
Double 3D Vector.
Vector3Tpl< PointCoordinateType > CCVector3
Default 3D Vector.
float PointCoordinateType
Type of the coordinates of a (N-D) point.
Type dot(const Vector3Tpl &v) const
Dot product.
Type norm() const
Returns vector norm.
Vector3Tpl cross(const Vector3Tpl &v) const
Cross product.
static Vector3Tpl fromArray(const int a[3])
Constructor from an int array.
void draw(CC_DRAW_CONTEXT &context) override
Draws entity and its children.
void shift(const CCVector3 &v)
Shifts the current box.
void getInteractorIds(QStringList &removeViewIds)
void flagPointsInside(ccGenericPointCloud *cloud, ccGenericPointCloud::VisibilityTableType *visTable, bool shrink=false) const
const ccBBox & getBox() const
Returns the box extents.
bool addAssociatedEntity(ccHObject *associatedEntity)
Adds an associated entity.
void setClickedPoint(int x, int y, int screenWidth, int screenHeight, const ccGLMatrixd &viewMatrix)
Sets last clicked point (on screen)
void update()
Updates the associated entity clipping planes.
ccGLMatrixd m_viewMatrix
View matrix.
ccHObject m_entityContainer
Associated entities container.
ccClipBox(QString name=QString("Clipping box"))
Default constructor.
bool move2D(int x, int y, int dx, int dy, int screenWidth, int screenHeight) override
Called on mouse move (for 2D interactors)
PointCoordinateType computeArrowsScale()
Computes arrows display scale.
void set(const ccBBox &extents, const ccGLMatrix &transformation)
Manually sets the box parameters.
CCVector3d m_lastOrientation
Last "orientation" vector (corresponding to last clicked point)
void boxModified(const ccBBox *box)
Signal sent each time the box is modified.
void releaseAssociatedEntities()
Releases all associated entities.
ccBBox getOwnBB(bool withGLFeatures=false) override
Returns the entity's own bounding-box.
ccBBox m_box
Clipping box.
void setBox(const ccBBox &box)
Sets the box extents.
Components m_activeComponent
Active component.
~ccClipBox() override
Destructor.
void releaseAllInterators()
void get(ccBBox &extents, ccGLMatrix &transformation)
Returns the box parameters.
void drawMeOnly(CC_DRAW_CONTEXT &context) override
Draws the entity only (not its children)
bool move3D(const CCVector3d &u) override
Called on mouse move (for 3D interactors)
void setActiveComponent(int id)
Sets currently active component.
void hideShowAllInterators(bool visibility)
virtual void setGLTransformation(const ccGLMatrix &trans)
Associates entity with a GL transformation (rotation + translation)
virtual bool addClipPlanes(const ccClipPlane &plane)
Registers a new clipping plane.
virtual bool isGLTransEnabled() const
Returns whether a GL transformation is enabled or not.
bool m_glTransEnabled
Current GL transformation activation state.
ccGLMatrix m_glTrans
Current GL transformation.
bool m_selected
Specifies whether the object is selected or not.
virtual void removeAllClipPlanes()
Removes all clipping planes (if any)
virtual void enableGLTransformation(bool state)
Enables/disables associated GL transformation.
virtual void resetGLTransformation()
Resets associated GL transformation.
Vector3Tpl< T > getTranslationAsVec3D() const
Returns a copy of the translation as a CCVector3.
void applyRotation(Vector3Tpl< float > &vec) const
Applies rotation only to a 3D vector (in place) - float version.
static ccGLMatrixTpl< double > FromToRotation(const Vector3Tpl< double > &from, const Vector3Tpl< double > &to)
Creates a transformation matrix that rotates a vector to another.
T * data()
Returns a pointer to internal data.
ccGLMatrixTpl< T > inverse() const
Returns inverse transformation.
void apply(float vec[3]) const
Applies transformation to a 3D vector (in place) - float version.
void setTranslation(const Vector3Tpl< float > &Tr)
Sets translation (float version)
Vector3Tpl< T > getColumnAsVec3D(unsigned index) const
Returns a copy of a given column as a CCVector3.
void initFromParameters(T alpha_rad, const Vector3Tpl< T > &axis3D, const Vector3Tpl< T > &t3D)
Inits transformation from a rotation axis, an angle and a translation.
virtual void toIdentity()
Sets matrix to identity.
Float version of ccGLMatrixTpl.
Double version of ccGLMatrixTpl.
A 3D cloud interface with associated features (color, normals, octree, etc.)
std::vector< unsigned char > VisibilityTableType
Array of "visibility" information for each point.
Hierarchical CLOUDVIEWER Object.
virtual ccBBox getBB_recursive(bool withGLFeatures=false, bool onlyEnabledChildren=true)
Returns the bounding-box of this entity and it's children.
void removeAllChildren()
Removes all children.
QString getViewId() const
unsigned getChildrenNumber() const
Returns the number of children.
virtual void setSelectionBehavior(SelectionBehavior mode)
Sets selection behavior (when displayed)
virtual bool addChild(ccHObject *child, int dependencyFlags=DP_PARENT_OF_OTHER, int insertIndex=-1)
Adds a child.
ccHObject * getChild(unsigned childPos) const
Returns the ith child.
Vector3Tpl< T > getDiagVec() const
Returns diagonal vector.
Vector3Tpl< T > getCenter() const
Returns center.
bool contains(const Vector3Tpl< T > &P) const
Returns whether a points is inside the box or not.
const Vector3Tpl< T > & maxCorner() const
Returns max corner (const)
T getDiagNorm() const
Returns diagonal length.
void clear()
Resets the bounding box.
const Vector3Tpl< T > & minCorner() const
Returns min corner (const)
bool isValid() const
Returns whether bounding box is valid or not.
virtual unsigned size() const =0
Returns the number of points.
virtual const CCVector3 * getPoint(unsigned index) const =0
Returns the ith point.
void DrawUnitArrow(int ID, const CCVector3 &start, const CCVector3 &direction, PointCoordinateType scale, const ecvColor::Rgb &col, CC_DRAW_CONTEXT &context)
const ColorCompType c_lightComp
static QSharedPointer< ccTorus > c_torus(nullptr)
static void DrawUnitTorus(int ID, const CCVector3 ¢er, const CCVector3 &direction, PointCoordinateType scale, const ecvColor::Rgb &col, CC_DRAW_CONTEXT &context)
const ecvColor::Rgb c_lightRed(ecvColor::MAX, c_lightComp, c_lightComp)
static QSharedPointer< ccSphere > c_centralSphere(nullptr)
const ecvColor::Rgb c_lightBlue(c_lightComp, c_lightComp, ecvColor::MAX)
static CCVector3d PointToVector(int x, int y, int screenWidth, int screenHeight)
const ecvColor::Rgb c_lightGreen(c_lightComp, ecvColor::MAX, c_lightComp)
static QSharedPointer< ccCone > c_arrowHead(nullptr)
static QSharedPointer< ccCylinder > c_arrowShaft(nullptr)
static void DrawUnitCross(int ID, const CCVector3 ¢er, PointCoordinateType scale, const ecvColor::Rgb &col, CC_DRAW_CONTEXT &context)
unsigned char ColorCompType
Default color components type (R,G and B)
#define MACRO_Draw3D(context)
#define MACRO_EntityPicking(context)
for(size_t i=0;i< 36;++i)
float RadiansToDegrees(int radians)
Convert radians to degrees.
constexpr ColorCompType MAX
Max value of a single color component (default type)
constexpr Rgb red(MAX, 0, 0)
constexpr Rgb blue(0, 0, MAX)
constexpr Rgb green(0, MAX, 0)
constexpr Rgb yellow(MAX, MAX, 0)
Simple (clipping) plane equation.
Tuple4Tpl< double > equation
int drawingFlags
Drawing options (see below)
ENTITY_TYPE removeEntityType
MESH_RENDERING_MODE meshRenderingMode