Hi,
I have a simple polysoup mesh of a Triangular Dipyramid <http://polyhedra.org/poly/show/56/triangular_dipyramid [polyhedra.org]>
When I iterate the faces, I get vertex count of 4 instead of the expected 3. Ideas ?
Number of vertices is the expected == 5
npolys = prim->getPolygonCount(); // npolys == 6
// std::cerr << “ArnoldGUDetailVisitor::processPrimPolySoup() npolys = ” << npolys << std::endl;
for (GA_Size polygonIndex = 0; polygonIndex < npolys; polygonIndex++)
{
GA_Size start, count;
prim->getPolygonVertexRange(polygonIndex, start, count);
// Expecting count == 3
for (GA_Size verticesIndex = 0; verticesIndex < count; verticesIndex++)
{
GA_Offset offset = prim->getPolygonVertexOffset(polygonIndex,verticesIndex);
// Expecting offset == 3
vertices.push_back(offset);
}
nvertices.push_back(count);
nloops.push_back(1);
}
Cheers
[HDK] Polysoup : triangular mesh ?
4554 4 1- nicholas_yue
- Member
- 301 posts
- Joined: July 2005
- Offline
- nicholas_yue
- Member
- 301 posts
- Joined: July 2005
- Offline
Here is the code and output showing the iterator showing duplicate vertices
GU_PrimPolySoup * polysoup = dynamic_cast<GU_PrimPolySoup*>(gprim);
if (polysoup)
{
GEO_Detail *detail = polysoup->getParent();
if (detail)
{
for (GEO_PrimPolySoup:olygonIterator it(*polysoup); !it.atEnd(); ++it)
{
printf(“Face: [”);
for (GEO_PrimPolySoup::VertexIterator vit(it); !vit.atEnd(); ++vit)
{
GA_Offset ptoff = detail->vertexPoint(vit.offset());
UT_Vector3 P = detail->getPos3(ptoff);
printf(“{%g,%g,%g},”, P.x(), P.y(), P.z());
}
printf(“]\n”);
}
}
}
Here is the print out of the duplicates
Face:
Face:
Face:
Face:
Face:
Face:
Cheers
GU_PrimPolySoup * polysoup = dynamic_cast<GU_PrimPolySoup*>(gprim);
if (polysoup)
{
GEO_Detail *detail = polysoup->getParent();
if (detail)
{
for (GEO_PrimPolySoup:olygonIterator it(*polysoup); !it.atEnd(); ++it)
{
printf(“Face: [”);
for (GEO_PrimPolySoup::VertexIterator vit(it); !vit.atEnd(); ++vit)
{
GA_Offset ptoff = detail->vertexPoint(vit.offset());
UT_Vector3 P = detail->getPos3(ptoff);
printf(“{%g,%g,%g},”, P.x(), P.y(), P.z());
}
printf(“]\n”);
}
}
}
Here is the print out of the duplicates
Face:
Face:
Face:
Face:
Face:
Face:
Cheers
Nicholas Yue
- nicholas_yue
- Member
- 301 posts
- Joined: July 2005
- Offline
Here is a printout with the ptoff value
There is a repetition of the index offset.
Should I be filtering out the duplicates or is that inherent in the polysoup design?
Face: [
(ptoff = 0) => {2.18557e-08,1,-3.78552e-08}
(ptoff = 0) => {2.18557e-08,1,-3.78552e-08}
(ptoff = 3) => {-0.5,0,-0.866025}
(ptoff = 2) => {1,0,0}
]
Face: [
(ptoff = 0) => {2.18557e-08,1,-3.78552e-08}
(ptoff = 0) => {2.18557e-08,1,-3.78552e-08}
(ptoff = 4) => {-0.5,0,0.866025}
(ptoff = 3) => {-0.5,0,-0.866025}
]
Face: [
(ptoff = 0) => {2.18557e-08,1,-3.78552e-08}
(ptoff = 0) => {2.18557e-08,1,-3.78552e-08}
(ptoff = 2) => {1,0,0}
(ptoff = 4) => {-0.5,0,0.866025}
]
Face: [
(ptoff = 2) => {1,0,0}
(ptoff = 3) => {-0.5,0,-0.866025}
(ptoff = 1) => {2.18557e-08,-1,-3.78552e-08}
(ptoff = 1) => {2.18557e-08,-1,-3.78552e-08}
]
Face: [
(ptoff = 3) => {-0.5,0,-0.866025}
(ptoff = 4) => {-0.5,0,0.866025}
(ptoff = 1) => {2.18557e-08,-1,-3.78552e-08}
(ptoff = 1) => {2.18557e-08,-1,-3.78552e-08}
]
Face: [
(ptoff = 4) => {-0.5,0,0.866025}
(ptoff = 2) => {1,0,0}
(ptoff = 1) => {2.18557e-08,-1,-3.78552e-08}
(ptoff = 1) => {2.18557e-08,-1,-3.78552e-08}
]
There is a repetition of the index offset.
Should I be filtering out the duplicates or is that inherent in the polysoup design?
Face: [
(ptoff = 0) => {2.18557e-08,1,-3.78552e-08}
(ptoff = 0) => {2.18557e-08,1,-3.78552e-08}
(ptoff = 3) => {-0.5,0,-0.866025}
(ptoff = 2) => {1,0,0}
]
Face: [
(ptoff = 0) => {2.18557e-08,1,-3.78552e-08}
(ptoff = 0) => {2.18557e-08,1,-3.78552e-08}
(ptoff = 4) => {-0.5,0,0.866025}
(ptoff = 3) => {-0.5,0,-0.866025}
]
Face: [
(ptoff = 0) => {2.18557e-08,1,-3.78552e-08}
(ptoff = 0) => {2.18557e-08,1,-3.78552e-08}
(ptoff = 2) => {1,0,0}
(ptoff = 4) => {-0.5,0,0.866025}
]
Face: [
(ptoff = 2) => {1,0,0}
(ptoff = 3) => {-0.5,0,-0.866025}
(ptoff = 1) => {2.18557e-08,-1,-3.78552e-08}
(ptoff = 1) => {2.18557e-08,-1,-3.78552e-08}
]
Face: [
(ptoff = 3) => {-0.5,0,-0.866025}
(ptoff = 4) => {-0.5,0,0.866025}
(ptoff = 1) => {2.18557e-08,-1,-3.78552e-08}
(ptoff = 1) => {2.18557e-08,-1,-3.78552e-08}
]
Face: [
(ptoff = 4) => {-0.5,0,0.866025}
(ptoff = 2) => {1,0,0}
(ptoff = 1) => {2.18557e-08,-1,-3.78552e-08}
(ptoff = 1) => {2.18557e-08,-1,-3.78552e-08}
]
Nicholas Yue
- nicholas_yue
- Member
- 301 posts
- Joined: July 2005
- Offline
- neil_math_comp
- Member
- 1743 posts
- Joined: March 2012
- Offline
nicholas_yue
I have found that enabling the “convex” parameter in the polysoup SOP eliminated the duplicate vertices but am unsure if that is the correct approach or proper solution.
Check the vertex count from before converting to PolySoup. If it's 24, you have quads that just happen to have the same point twice. PolySoups are supposed to be an exact representation of the original polygons. The polygons might not be in the same order, but the content should be identical.
Convexing probably isn't what you want to do to fix this, because you'll end up with 12 triangles (6 of them degenerate) instead of the 6 you want.
Writing code for fun and profit since... 2005? Wow, I'm getting old.
https://www.youtube.com/channel/UC_HFmdvpe9U2G3OMNViKMEQ [www.youtube.com]
https://www.youtube.com/channel/UC_HFmdvpe9U2G3OMNViKMEQ [www.youtube.com]
-
- Quick Links