29 #include "WButterflyFactory.h"
30 #include "WSubdivisionValidator.h"
31 #include "core/kernel/WKernel.h"
75 std::ostringstream headerText;
76 headerText <<
"Iteration " << iteration;
89 for (
size_t thread = 0; thread < threads; thread++ )
91 size_t firstVert = vertSize * thread / threads;
92 size_t lastVert = vertSize * ( thread + 1 ) / threads - 1;
96 for (
size_t thread = 0; thread < threads; thread++ )
101 for (
size_t triID = 0; triID <
m_triCount; triID++ )
103 size_t vertID0 =
m_inputMesh->getTriVertId0( triID );
104 size_t vertID1 =
m_inputMesh->getTriVertId1( triID );
105 size_t vertID2 =
m_inputMesh->getTriVertId2( triID );
114 if ( iteration == 1 )
126 std::shared_ptr< WTriangleMesh > tmpMesh(
new WTriangleMesh( 0, 0 ) );
131 for (
size_t triID = 0; triID <
m_triCount; triID++ )
146 m_outputMesh->addVertex( osg::Vec3( vec.x(), vec.y(), vec.z() ) );
154 for (
size_t iteration = 1; iteration <=
m_iterations &&
192 for (
size_t thread = 0; thread < threads; thread++ )
194 size_t firstVert = vertSize * thread / threads;
195 size_t lastVert = vertSize * ( thread + 1 ) / threads - 1;
197 this, firstVert, lastVert );
199 for (
size_t thread = 0; thread < threads; thread++ )
204 for (
size_t vertID1 = fromVertex; vertID1 <= toVertex; vertID1++ )
208 for (
size_t newVert = 0; newVert < newVertices.size(); newVert++ )
211 size_t vertID2 = newVertex->
getToID();
222 for (
size_t vertID1 = 0; vertID1 <
m_inputMesh->vertSize(); vertID1++ )
226 for (
size_t newVert = 0; newVert < newVertices.size(); newVert++ )
242 size_t vertID0 =
m_inputMesh->getTriVertId0( triID );
243 size_t vertID1 =
m_inputMesh->getTriVertId1( triID );
244 size_t vertID2 =
m_inputMesh->getTriVertId2( triID );
Class managing progress inside of modules.
Triangle mesh data structure allowing for convenient access of the elements.
Object that contains all necessary properties of a vertex necessary for a sufficient analysis.
std::vector< WNewVertex * > getNewVerticesToHigherNeighborID()
Returns the properties of new registered vertices of the current vertex.
Class that depicts the whole Butterfly subdivision algorithm but nothing more as such.
void assignInputMesh(std::shared_ptr< WTriangleMesh > inputMesh, WVertexFactory *vertexProperties)
Assigns the input mesh andd its analyzed data that are required for the butterfly subdivision.
void setButterflySettingW(float butterflySettingW)
Set the general Butterfly Subdivision setting w that affects the subdivision.
osg::Vec3 calcNewVertex(size_t vertID1, size_t vertID2)
Calculate the subdivided new vertex between two vertices using the Butterfly Subdivision.
virtual ~WButterflyFactory()
Destroys the Butterfly instance object and its substructures.
WSubdivisionValidator * getValidator()
Returns the Butterfly subdivision validator.
size_t m_cpuThreadCount
CPU threads count for multithreading support.
void addInterpolatedContent()
Adds interpolated vertices and triangles to the output triangle mesh.
std::shared_ptr< WProgressCombiner > m_associatedProgressCombiner
Progress combiner for changing the plugin status in the modules overview.
void setCpuThreadCount(size_t cpuThreadCount)
Sets the count of CPU threads to use.
void setProgressSettings(size_t iteration, size_t steps)
Sets progress which iteration step and kind of cumputing step is currently done.
vector< boost::thread * > m_cpuThreads
CPU threads object for multithreading support.
size_t m_iterations
Iteration steps to apply iteratedly.
WSubdivisionValidator * m_validator
Triangle mesh validation instance.
WVertexFactory * m_verts
Data set used for analyzation of the triangle mesh.
std::shared_ptr< WTriangleMesh > getSubdividedMesh(std::shared_ptr< WTriangleMesh > edgedMmesh)
Launch the Butterfly subdivision.
size_t m_maxTriangles
Maximal allowed triangle count applyable for subdivision.
void examineStencilAll()
Examines Butterfly stencils of all vertices and stores data.
std::shared_ptr< WTriangleMesh > m_inputMesh
Base triangle mesh used for calculations.
void attachUncalculatedNewVertices()
Attachs new vertices that are used for the subdivision.
size_t m_triCount
Total triangle count.
void applyMeshPreprocessing(size_t iteration)
Applies triangle mesh preprocessing if vertex flip or triangle flip setting is not default.
WButterflyCalculator * m_butterflyCalculator
Instance for interpolating new vertices.
std::shared_ptr< WProgress > m_progressStatus
Current progress status.
size_t m_vertCount
Current count of currently added vertices during interpolation.
void setButterflySettingW(float butterflySettingW)
Set the general Butterfly Subdivision setting w that affects the subdivision.
void assignProgressCombiner(std::shared_ptr< WProgressCombiner > associatedProgressCombiner)
Assigns a ProbressCombiner to the Butterfly factory.
std::shared_ptr< WTriangleMesh > m_outputMesh
Triangle mesh that is set up by interpolation.
WButterflyFactory()
Butterfly subdivision tool object creating instance.
void interpolateNewVerticesRange(size_t fromVertex, size_t toVertex)
Calculates coordinates of the new vertices.
void setIterationsSettings(float m_iterations, float m_maxTriangles10n)
Assign main butterfly subdivision iterations settings.
void interpolateNewVertices()
Calculates coordinates of the new vertices.
void examineVertexNeighborhood(size_t iteration)
Examine The triangle mesh before Butterfly subdivision.
Depicts a point that is subdivided on a line between two vertices.
void setNewVertexID(size_t newVertexID)
Sets the proposed ID for that new vertex.
size_t getToID()
Returns the second vertex ID where the new vertex lies between these two points.
void setValid(bool isValid)
Sets the new vertex property whether it's valid for butterfly subdivision or not.
osg::Vec3 getCoordinate()
Returns coordinates of the new vertex.
bool isValid()
Returns whether the new vertex is marked to be valid for the butterfly subdivison of a line between t...
void setCoordinate(osg::Vec3 coordinate)
Sets coordinates of the new vertex.
Class that validates the Butterfly subdivision.
bool isValidSubdivision(size_t vertID1, size_t vertID2, osg::Vec3 newVert)
This function checks a subdivided line between two vertices for correctness.
float getMinSubdividedLineLengthMultiplierPerIteration()
Gets the factor where the minimal subdivided line length is multiplied by in each Subdivision iterati...
void setMinSubdividedLineLength(float minSubdividedLineLength)
Sets the minimal subdividable line length.
osg::Vec3 getValidatedSubdivision(size_t vertID1, size_t vertID2, osg::Vec3 interpolatedVertex)
Corrects Coordinates if they are determined to be invalid using validation settings.
void subdivideTriangle(size_t vertID0, size_t vertID1, size_t vertID2)
Subdivides the triangle at three vertex IDs regarding the not subdividable new vertices at lines betw...
std::shared_ptr< WTriangleMesh > joinNarrowVertices(std::shared_ptr< WTriangleMesh > inputMesh)
Joins Vertices where a triangle side is smaller than the longest one multiplied by a factor.
std::shared_ptr< WTriangleMesh > flipTrianglesAtLowAngles(std::shared_ptr< WTriangleMesh > inputMesh)
Searchs for all triangles which has two angles below a preset value.
float getMinSubdividedLineLength()
Gets the minimal subdividable line length.
void generateStatisticalInformation()
Generating statistical information of the triangle mesh.
void setTriangleMesh(std::shared_ptr< WTriangleMesh > processedMesh, WVertexFactory *vertexFactory)
Assign analyzable triangle mesh.
Class that manages all vertex properties.
WVertexProperty * getProperty(size_t vertexID)
Get properties of a vertex.
bool isValidTriangle(size_t triangleID)
Examine triangle by its ID for validity.
size_t getVertexCount()
Returns the Property List's vertex count.
void setTriangleMesh(std::shared_ptr< WTriangleMesh > triangleMesh)
Sets the WTriangleMesh.
void examineStencilRange(size_t fromVertex, size_t toVertex, std::shared_ptr< WProgress > progress)
Examines Butterfly stencils of all vertices and applies settings data to the vertex.
void attachNewVertex(size_t fromID, size_t toID)
Registering a subdividable new vertex of an ID between two vertices.
void registerTriangle(size_t vertexID, size_t triangleID)
Registers triangle to all its vertex IDs.
virtual ~WVertexFactory()
Destroys the vertex factory object.