152 inline unsigned int numSeedPoints()
const {
return static_cast<unsigned int>(_seedPointList.size()); }
156 inline unsigned int numPathPointLists()
const {
return static_cast<unsigned int>(_pathPointsList.size()); }
213 inline unsigned int numGroups()
const {
return static_cast<unsigned int>(_csoGroupIds.size()); }
218 inline unsigned int getGroupIdAt(
unsigned int index)
const {
return _csoGroupIds[index]; }
237 inline void setType(
const std::string& type) { _type = type; }
239 inline const std::string&
getType()
const {
return _type; }
243 inline const std::string&
getSubType()
const {
return _subtype; }
255 inline void setUserData(
const std::string& name,
Variant value) { _attributes.setUserData(name, value); }
261 inline void removeUserData(
const std::string& name) { _attributes.removeUserData(name); }
294 inline double getArea()
const { _computeArea();
return _area; }
340 inline unsigned int getId()
const {
return _uniqueId; }
350 inline const std::string&
getLabel()
const {
return _attributes.label; }
354 inline const std::string&
getDescription()
const {
return _attributes.description; }
490 template <
class Method>
491 int getOverrideGroupIndexForAttribute(
Method method)
const;
495 void _fillPathPointCoordinatesFlattened(std::vector<T>&
pathPointCoords)
const;
500 unsigned int _uniqueId;
503 std::vector<CSOSeedPoint*> _seedPointList;
505 std::vector<CSOPathPoints*> _pathPointsList;
513 std::vector<unsigned int> _csoGroupIds;
516 std::vector<unsigned int> _selectedSeedPointsIndices;
519 std::string _type{
"TYPE_NOT_SET"};
521 std::string _subtype{
"SUB_TYPE_NOT_SET"};
526 CSOAttributes _attributes;
529 mutable bool _hasValidWorldBoundingBox{};
531 mutable CSOBoundingBox _worldBoundingBox;
534 mutable boost::unordered_map < MatrixHashPair, CSOBoundingBox, MatrixHashFunction > _voxelBoundingBoxCache;
536 mutable boost::unordered_map < MatrixHashPair, CSOBoundingBox, MatrixHashFunction > _voxelSeedPointBoundingBoxCache;
539 mutable bool _hasValidPlaneStatus{};
541 mutable bool _hasValidArea{};
544 mutable bool _hasValidSelfIntersectingStatus{};
552 mutable bool _isInPlane{};
557 bool _needsInterpolation{};
560 mutable double _area{};
563 mutable bool _isSelfIntersecting{};
569 void _computeIsInPlane()
const;
571 void _computeArea()
const;
573 void _resetSeedPathLinks();
const unsigned int INVALID_CSO_ID
Defines a CSO/CSOGroup id that is invalid.
#define MLCSO_EXPORT
Defines export symbols for classes, so they can be used in other DLLs.
This class comprises some attributes that are common for a CSO and a CSOGroup.
The CSOBoundingBox defines an axis parallel bounding box with double precision.
A CSOGroup comprises a number of CSOs, which themselves can be in a number of different CSOGroups.
A CSOList comprises a number of CSOs and CSOGroups and is the central object for contour segmentation...
The CSOManager allows for storing and iterating CSOs, and implements an undo/redo mechanism.
The CSOPathPoints is a list of world coordinates which are interpolated by a certain interpolation sc...
The CSOSeedPoint can be interactively set and modified and is the framework for contours.
The CSO represents a contour segmentation object.
void removeUserData(const std::string &name)
Removes a user data entry.
CSOList * getCSOList() const
Returns the internal pointer to the embracing CSOList.
bool getPrivateEditableState() const
Returns the private attribute 'editableState'.
void invalidateArea()
Invalidates the internal area flag, so it can be recomputed.
unsigned int numSeedPoints() const
Returns the number of seed points.
CSOBoundingBox getVoxelBoundingBoxSeedPoints(const Matrix4 &worldToVoxelMatrix, size_t hashKey) const
Returns the bounding box of the seed points of this CSO in voxel coordinates computed by the given (i...
CSOPathPoints * appendPathPoints()
Appends just a path point list the internal list and returns a pointer to it.
void swapPoints(CSO &other)
Swaps the seed and path points of two cso. No events are emitted.
float getPathPointAlpha() const
Returns the alpha value of the path points.
bool isClosed() const
Returns whether the CSO is closed.
void setDescription(std::string description)
Sets the description of this CSO.
const std::string & getDescription() const
Returns the description of this CSO.
bool getEditableState() const
Returns the 'editable' state of this CSO.
CSOAttributes & getWritableAttributes()
Get write access to all CSO attributes (NOTE: be careful, no events are emitted when changing the att...
void setSeedPointSize(float size)
Sets the size of the seed points.
float getPrivatePathPointWidth() const
Returns the private attribute 'path point width'.
unsigned int numPathPointLists() const
Returns the number of path point lists.
unsigned int numGroups() const
Returns the number of groups this CSO is in.
CSOPathPointsStyle getPathPointStyle() const
Returns the style of the path points.
Vector3 getSeedPointColor() const
Returns the color of the seed points.
float getPrivateSeedPointAlpha() const
Returns the private attribute 'seed point alpha'.
CSOSeedPoint * insertSeedPointAt(CSOPathPoints *toBeSplitPath, const Vector3 &toInsertPos)
Inserts a seed point into the given toBeSplitPath at the given position.
bool getIsFinished() const
Returns the finished status of this contour.
const Vector3 & getPlaneNormal() const
Returns the plane normal. Only valid, if isInPlane returns 'true'.
CSOSeedPoint * appendSeedAndPathPointNoEvent(const Vector3 &position)
Appends a seed point and a path point list to the end of the seed point list and returns a pointer to...
void applyTransformationMatrix(const Matrix4 &matrix)
const std::string & getLabel() const
Returns the label of this CSO.
void setPrivateIsFinished(bool isFinished)
Sets the 'isFinished' flag without any side effects.
CSOBoundingBox getVoxelBoundingBox(const Matrix4 &worldToVoxelMatrix, size_t hashKey) const
Returns the bounding box of this contour in voxel coordinates computed by the given (image) matrix.
void setNeedInterpolationAllSeedPoints(bool needsInterpolation)
Sets the need for interpolation to all member seed points.
void setSeedPointsAndPathPoints(const CSO *cso)
Sets the seed points and the path point of the given CSO.
float getPathPointWidth() const
Returns the width of the path points.
float getVoxelWriteValue() const
Returns the voxel write value of this CSO.
CSOPathPoints * insertPathPointsEndStartNoEvent()
Inserts a CSOPathPoint between the ending and the starting seed points and returns a pointer to it.
void setId(unsigned int newId)
Sets the unique ID of this CSO.
unsigned int getNumSelectedSeedPoints() const
Returns the number of selected seed points.
void setPrivatePlaneNormal(const Vector3 &normal)
Sets the plane normal of this CSO.
CSOPathPoints * insertPathPointsEndStart()
Inserts a CSOPathPoint between the ending and the starting seed points and returns a pointer to it.
float getSeedPointAlpha() const
Returns the alpha value of the seed points.
const std::string & getSubType() const
Returns the type of the CSO. This is set by the Processor, which generated this CSO.
void setVoxelWriteMode(int mode)
Sets the voxel write mode of this CSO.
bool isPoint() const
Returns whether the CSO is just a point.
void removeSeedPoint(CSOSeedPoint *sPoint)
Removes the given seed point from this CSO.
void setLabel(const std::string &label)
void _removeReferenceToGroup(const CSOGroup &group)
Removes the given group from the internal list.
float getPrivatePathPointAlpha() const
Returns the private attribute 'path point alpha'.
void clearSelectedSeedPoints()
Clears the list of selected seed points.
void setPrivateIsClosed(bool isClosedP)
Sets the 'isClosed' flag without any side effects.
void resortSeedPointsClockwise()
void getUserDataNames(std::vector< std::string > &names) const
Fills the given vector with the keys/name under which user data are stored for this CSO.
void setSeedPointColor(const Vector3 &color)
Sets the color of the seed points.
void setCreatorId(int id)
Sets the creator ID of the CSO. This is set by the Processor, which generates this CSO.
void moveSeedPointsAndPathPoints(const Vector3 &offset, int timepoint)
Moves all seed points and all path points by the given coordinates offset and sets it to the given ti...
bool getVoxelizeState() const
Returns the 'voxelize' state of this CSO.
Vector3 getPathPointColor() const
Returns the color of the path points.
bool isInSameGroupsAs(CSO *cso) const
void setUserData(const std::string &name, Variant value)
int getTimePointIndex() const
Returns the time point index of this CSO.
void moveSeedPointsAndPathPoints(double dx, double dy, double dz, int timepoint)
Moves all seed points and all path points by the given coordinates offset and sets it to the given ti...
float getPrivateSeedPointSize() const
Returns the private attribute 'seed point size'.
bool getSeedPointIndex(CSOSeedPoint *sPoint, unsigned int &index) const
Sets the sIndex to the index of the given seed point and returns whether such a seed point exists.
int getCreatorId() const
Returns the creator ID of the CSO. This is set by the Processor, which generated this CSO.
bool isInPlane(Vector3 &planeNormal) const
Returns the plane status and fills the argument vector with the plane normal (only valid if all seed ...
unsigned int getTotalNumUniquePathPoints() const
Returns the total number of unique path points in this CSO; this number equals the number of path poi...
void setPrivateBoundingBox(const CSOBoundingBox &bb)
Sets the bounding box of this CSO.
void setNeedInterpolation(CSOSeedPoint *seedPoint)
Sets the need of being interpolated to the given seed point and to the CSO's state.
int getPrivateSeedPointStyle() const
Returns the private attribute 'seed point style'.
CSOSeedPoint * getLastSeedPoint() const
Returns a pointer to the last seed point of this CSO.
CSOSeedPoint * appendSeedPoint()
Appends just a seed point to the internal list and returns a pointer to it.
bool isSelfIntersecting() const
Returns whether this CSO is self-intersecting.
CSO(const CSO &cso, CSOList *csoList=nullptr, unsigned int csoId=INVALID_CSO_ID)
Copy constructor; the unique id is taken from the given CSOList but if the CSOList is NULL,...
void setSeedAndPathPoints(unsigned int numSeedPoints, bool isClosed=true)
Generates the given number of seed points and path point lists between those.
void setPathPointAlpha(float alpha)
Sets the alpha value of the path points.
void setPathPointStyle(CSOPathPointsStyle style)
Sets the style of the path points.
CSOGroup * getGroupAt(unsigned int index) const
Returns the group at the specified index. If the index is out of bounds, NULL is returned.
void setCSOList(CSOList *csoList)
unsigned int getId() const
Returns the unique ID of this CSO.
void reverseSeedPointOrder()
Reverses the order of all seed points and clears all path points in between.
CSO()
Standard constructor. The unique id is initialized with 0.
void storeInUndoManager()
Stores the geometric information of the CSO in the UndoRedo manager.
void moveSingleSeedPoint(CSOSeedPoint *sPoint, double dx, double dy, double dz)
Moves a certain seed point by the given coordinate offset.
int getPrivateTimePointIndex() const
void removeFromGroup(CSOGroup &group, bool useUndoRedo=true)
Removes this CSO from the given group.
void setVoxelizeState(bool state)
Sets the 'voxelize' state of this CSO.
void moveSeedPointsAndPathPoints(const Vector3 &offset)
Moves all seed points and all path points by the given coordinates offset.
void setSeedPointStyle(int style)
Sets the style of the seed points.
bool getPrivateVoxelizeState() const
Returns the private attribute 'voxelizeState'.
void removeAllSeedAndPathPoints()
Removes all seed points and all path point lists from this CSO.
void fillPathPointCoordinatesFlattened(std::vector< Vector4 > &pathPointCoordsAndValues) const
Fills up the given std::vector<Vector4> with all the path point coordinates and values in order.
CSOSeedPoint * getSelectedSeedPointAt(unsigned int index) const
Returns a pointer to a selected seed point at the given index.
double getArea() const
Returns the area of this CSO (this value is only meaningful if all points lie in a plane)
void setAbsoluteMovementCommand(double fromX, double fromY, double fromZ, double toX, double toY, double toZ, int fromTimePointIndex, int toTimePointIndex)
Sets the absolute movement for undo/redo.
bool isSelected() const
Returns whether this CSO is selected in its CSOList. If there is no enclosing CSOList,...
void invalidatePlaneNormal()
Invalidates the plane normal.
Vector3 getPrivatePathPointColor() const
Returns the private attribute 'path point color'.
Vector3 getPrivateSeedPointColor() const
Returns the private attribute 'seed point color'.
void setPrivateIsInPlane(bool isInPlaneP)
Sets the 'isInPlane' flag without any side effects.
void setInsertRemoveSeedPointCommand()
Triggers the according undo/redo command to be put on the stack.
bool isSelectedSeedPoint(CSOSeedPoint *sPoint) const
Returns whether the given seed point is selected.
void _addReferenceToGroup(const CSOGroup &group)
void setIsFinished(bool isFinished)
Sets the finished status of this contour. Note that the finished status is set to 'true' if the conto...
void setNeedsInterpolation(bool needsInterpolation)
Sets if this CSO needs interpolation.
void setPathPointWidth(float width)
Sets the width of the path points.
CSOSeedPoint * appendSeedAndPathPoint()
Appends a seed point and a path point list to the end of the seed point list and returns a pointer to...
void setPlaneNormal(const Vector3 &planeNormal)
Sets the plane normal which becomes valid by this.
void setSubType(const std::string &subtype)
Sets the subtype of the CSO. This is set by the Processor, which generates this CSO.
bool getShowState() const
Returns the 'show' status of this CSO.
void setIsInPlane(bool status)
Sets the plane normal status for this CSO.
void computePlaneNormal()
Forces to recompute the plane normal (status).
void storeVisualAttributesInUndoManager()
void setVoxelWriteValue(float value)
Sets the voxel write value of this CSO.
void removeFromAllGroups()
Removes this CSO from all its groups.
void setSeedPointSelectedAt(unsigned int index)
Sets the seed point at the given index selected.
unsigned int getGroupIdAt(unsigned int index) const
Returns a group id at the specified index.
bool isInPlane() const
Returns the plane status (do all seed points lie in a plane?).
double getLength() const
Returns the length of this CSO (this is sum of the the euclidean distances between all successive pat...
void determineNeedsInterpolation()
Determines by investigating the CSO's seed points if this CSO needs interpolation and sets this state...
void setEditableState(bool state)
Sets the 'editable' state of this CSO.
const std::string & getType() const
Returns the type of the CSO. This is set by the Processor, which generated this CSO.
bool saveAttributes(std::ostream &outStream, bool useAscii=false)
Save attributes to stream and returns whether the saving was successful.
int getPrivateVoxelWriteMode() const
Returns the private attribute 'voxelWriteMode'.
CSOSeedPoint * getSeedPointAt(unsigned int index) const
int getVoxelWriteMode() const
Returns the voxel write mode of this CSO.
void fillPathPointCoordinatesFlattened(std::vector< Vector3 > &pathPointCoords) const
Fills up the given std::vector<Vector3> with all the path point coordinates in order.
CSOManager * getManager() const
void setType(const std::string &type)
void setSeedPointAlpha(float alpha)
Sets the alpha value of the seed points.
void setShowState(bool state)
Sets the 'show' status of this CSO.
void setPathPointStyle(int style)
Sets the style of the path points as an int.
CSO(CSOList *csoList)
Constructor takes a pointer to the CSOList this CSO is in; in this method, the unique id is set.
void setAllValuesTo(float value)
Sets all position values to the given value.
bool getNeedsInterpolation() const
Returns whether this CSO needs interpolation.
CSOSeedPoint * getFirstSeedPoint() const
Returns a pointer to the first seed point of this CSO.
void loadAttributes(std::istream &inStream, short version, bool swapBytes, bool useAscii=false)
Load attributes from stream.
unsigned int getTotalNumPathPoints() const
Returns the total number of path points in this CSO; this number may differ from the number of path p...
bool isInGroup(unsigned int groupId) const
Returns whether this CSO is in the group with the given ID.
void setAbsoluteSeedPointMovementCommand()
Sets the absolute movement of a single seed point for undo/redo.
float getSeedPointSize() const
Returns the size of the seed points.
void setIsClosed(bool isClosed)
Sets the closed state of this contour.
float getPrivateVoxelWriteValue() const
Returns the private attribute 'voxelWriteValue'.
CSOSeedPoint * appendSeedAndPathPointNoEvent()
bool getPrivateShowState() const
Returns the private attribute 'showState'.
void setSelectedSeedPoint(CSOSeedPoint *sPoint)
Sets the given seed point as being selected, and deselects all previously selected seed points.
bool isInGroup(const CSOGroup *group) const
Returns whether this CSO is in the given Group.
int getSeedPointStyle() const
Returns the style of the seed points.
CSOSeedPoint * appendSeedAndPathPoint(const Vector3 &position)
Appends a seed point and a path point list to the end of the seed point list and returns a pointer to...
void setAttributesFrom(const CSO *const cso)
Copies all attributes from the given CSO to this one.
int getPrivatePathPointStyle() const
Returns the private attribute 'path point style'.
CSOPathPoints * getPathPointsAt(unsigned int index) const
Returns the list of path points at a given position.
void setPathPointColor(const Vector3 &color)
Sets the color of the path points.
void addSelectedSeedPoint(CSOSeedPoint *sPoint)
bool isEmpty() const
Returns whether the CSO is empty; an empty CSO has neither seed points nor path points.
Variant getUserData(const std::string &name) const
Returns the user data under the given name or an invalid value if the entry does not exist.
bool addToGroup(CSOGroup &group, bool useUndoRedo=true)
const CSOBoundingBox & getWorldBoundingBox() const
void setInitialSeedAndPathPointsNoEvent(unsigned int numSeedPoints, bool isClosed=true)
See setSeedAndPathPoints, but faster because no events are emitted and no checks are done,...
void pathChanged()
Sets any pre-computed values depending on the exact path to invalid.
void moveSeedPointsAndPathPoints(double dx, double dy, double dz)
Moves all seed points and all path points by the given coordinates offset.
void setTimePointIndex(MLint index)
Sets the time point index of this CSO.
virtual ~CSO()
Standard destructor.
const CSOAttributes & getAttributes() const
Get const access to all CSO attributes.
The Variant class stores different data types.
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
MLint64 MLint
A signed ML integer type with at least 64 bits used for index calculations on very large images even ...
CSOPathPointsStyle
Enumeration of line styles (order as StylePalette::LineStyle).
Tvec3< MLdouble > Vector3
A vector with 3 components of type double.