@@ -52,23 +52,28 @@ void constructDemoCurveNetwork(std::string curveName, std::vector<glm::vec3> nod
5252
5353 { // Add some node values
5454 std::vector<double > valX (nNodes);
55+ std::vector<double > valNodeCat (nNodes);
5556 std::vector<double > valXabs (nNodes);
5657 std::vector<std::array<double , 3 >> randColor (nNodes);
5758 std::vector<glm::vec3> randVec (nNodes);
5859 for (size_t iN = 0 ; iN < nNodes; iN++) {
5960 valX[iN] = nodes[iN].x ;
61+ valNodeCat[iN] = iN * 5 / nNodes;
6062 valXabs[iN] = std::fabs (nodes[iN].x );
6163 randColor[iN] = {{polyscope::randomUnit (), polyscope::randomUnit (), polyscope::randomUnit ()}};
6264 randVec[iN] = glm::vec3{polyscope::randomUnit () - .5 , polyscope::randomUnit () - .5 , polyscope::randomUnit () - .5 };
6365 }
6466 polyscope::getCurveNetwork (curveName)->addNodeScalarQuantity (" nX" , valX);
6567 polyscope::getCurveNetwork (curveName)->addNodeScalarQuantity (" nXabs" , valXabs);
68+ polyscope::getCurveNetwork (curveName)->addNodeScalarQuantity (" node categorical" , valNodeCat,
69+ polyscope::DataType::CATEGORICAL);
6670 polyscope::getCurveNetwork (curveName)->addNodeColorQuantity (" nColor" , randColor);
6771 polyscope::getCurveNetwork (curveName)->addNodeVectorQuantity (" randVecN" , randVec);
6872 }
6973
7074 { // Add some edge values
7175 std::vector<double > edgeLen (nEdges);
76+ std::vector<double > valEdgeCat (nEdges);
7277 std::vector<std::array<double , 3 >> randColor (nEdges);
7378 std::vector<glm::vec3> randVec (nEdges);
7479 for (size_t iE = 0 ; iE < nEdges; iE++) {
@@ -77,10 +82,13 @@ void constructDemoCurveNetwork(std::string curveName, std::vector<glm::vec3> nod
7782 size_t nB = std::get<1 >(edge);
7883
7984 edgeLen[iE] = glm::length (nodes[nA] - nodes[nB]);
85+ valEdgeCat[iE] = iE * 5 / nEdges;
8086 randColor[iE] = {{polyscope::randomUnit (), polyscope::randomUnit (), polyscope::randomUnit ()}};
8187 randVec[iE] = glm::vec3{polyscope::randomUnit () - .5 , polyscope::randomUnit () - .5 , polyscope::randomUnit () - .5 };
8288 }
8389 polyscope::getCurveNetwork (curveName)->addEdgeScalarQuantity (" edge len" , edgeLen, polyscope::DataType::MAGNITUDE);
90+ polyscope::getCurveNetwork (curveName)->addEdgeScalarQuantity (" edge categorical" , valEdgeCat,
91+ polyscope::DataType::CATEGORICAL);
8492 polyscope::getCurveNetwork (curveName)->addEdgeColorQuantity (" eColor" , randColor);
8593 polyscope::getCurveNetwork (curveName)->addEdgeVectorQuantity (" randVecE" , randVec);
8694 }
@@ -104,6 +112,7 @@ void processFileOBJ(std::string filename) {
104112 auto psMesh = polyscope::registerSurfaceMesh (niceName, vertexPositionsGLM, faceIndices);
105113
106114 auto psSimpleMesh = polyscope::registerSimpleTriangleMesh (niceName, vertexPositionsGLM, faceIndices);
115+ psSimpleMesh->setEnabled (false );
107116
108117 // Useful data
109118 size_t nVertices = psMesh->nVertices ();
@@ -114,12 +123,14 @@ void processFileOBJ(std::string filename) {
114123 std::vector<double > valY (nVertices);
115124 std::vector<double > valZ (nVertices);
116125 std::vector<double > valMag (nVertices);
126+ std::vector<double > valCat (nVertices);
117127 std::vector<std::array<double , 3 >> randColor (nVertices);
118128 for (size_t iV = 0 ; iV < nVertices; iV++) {
119129 valX[iV] = vertexPositionsGLM[iV].x / 10000 ;
120130 valY[iV] = vertexPositionsGLM[iV].y ;
121131 valZ[iV] = vertexPositionsGLM[iV].z ;
122132 valMag[iV] = glm::length (vertexPositionsGLM[iV]);
133+ valCat[iV] = (int32_t )(iV * 7 / nVertices) - 2 ;
123134
124135 randColor[iV] = {{polyscope::randomUnit (), polyscope::randomUnit (), polyscope::randomUnit ()}};
125136 }
@@ -129,6 +140,8 @@ void processFileOBJ(std::string filename) {
129140 polyscope::getSurfaceMesh (niceName)->addVertexColorQuantity (" vColor" , randColor);
130141 polyscope::getSurfaceMesh (niceName)->addVertexScalarQuantity (" cY_sym" , valY, polyscope::DataType::SYMMETRIC);
131142 polyscope::getSurfaceMesh (niceName)->addVertexScalarQuantity (" cNorm" , valMag, polyscope::DataType::MAGNITUDE);
143+ polyscope::getSurfaceMesh (niceName)->addVertexScalarQuantity (" categorical vert" , valCat,
144+ polyscope::DataType::CATEGORICAL);
132145
133146 polyscope::getSurfaceMesh (niceName)->addVertexDistanceQuantity (" cY_dist" , valY);
134147 polyscope::getSurfaceMesh (niceName)->addVertexSignedDistanceQuantity (" cY_signeddist" , valY);
@@ -137,6 +150,7 @@ void processFileOBJ(std::string filename) {
137150 // Add some face scalars
138151 std::vector<double > fArea (nFaces);
139152 std::vector<double > zero (nFaces);
153+ std::vector<double > fCat (nFaces);
140154 std::vector<std::array<double , 3 >> fColor (nFaces);
141155 for (size_t iF = 0 ; iF < nFaces; iF++) {
142156 std::vector<size_t >& face = faceIndices[iF];
@@ -153,10 +167,13 @@ void processFileOBJ(std::string filename) {
153167
154168 zero[iF] = 0 ;
155169 fColor [iF] = {{polyscope::randomUnit (), polyscope::randomUnit (), polyscope::randomUnit ()}};
170+ fCat [iF] = (int32_t )(iF * 25 / nFaces) - 12 ;
156171 }
157172 polyscope::getSurfaceMesh (niceName)->addFaceScalarQuantity (" face area" , fArea , polyscope::DataType::MAGNITUDE);
158173 polyscope::getSurfaceMesh (niceName)->addFaceScalarQuantity (" zero" , zero);
159174 polyscope::getSurfaceMesh (niceName)->addFaceColorQuantity (" fColor" , fColor );
175+ polyscope::getSurfaceMesh (niceName)->addFaceScalarQuantity (" categorical face" , fCat ,
176+ polyscope::DataType::CATEGORICAL);
160177
161178
162179 // size_t nEdges = psMesh->nEdges();
@@ -165,15 +182,19 @@ void processFileOBJ(std::string filename) {
165182 std::vector<double > eLen;
166183 std::vector<double > heLen;
167184 std::vector<double > cAngle;
185+ std::vector<double > cID;
186+ std::vector<double > eCat;
187+ std::vector<double > heCat;
188+ std::vector<double > cCat;
168189 std::unordered_set<std::pair<size_t , size_t >, polyscope::hash_combine::hash<std::pair<size_t , size_t >>> seenEdges;
169190 std::vector<uint32_t > edgeOrdering;
170191 for (size_t iF = 0 ; iF < nFaces; iF++) {
171192 std::vector<size_t >& face = faceIndices[iF];
172193
173- for (size_t iV = 0 ; iV < face.size (); iV ++) {
174- size_t i0 = face[iV ];
175- size_t i1 = face[(iV + 1 ) % face.size ()];
176- size_t im1 = face[(iV + face.size () - 1 ) % face.size ()];
194+ for (size_t iC = 0 ; iC < face.size (); iC ++) {
195+ size_t i0 = face[iC ];
196+ size_t i1 = face[(iC + 1 ) % face.size ()];
197+ size_t im1 = face[(iC + face.size () - 1 ) % face.size ()];
177198 glm::vec3 p0 = vertexPositionsGLM[i0];
178199 glm::vec3 p1 = vertexPositionsGLM[i1];
179200 glm::vec3 pm1 = vertexPositionsGLM[im1];
@@ -188,18 +209,29 @@ void processFileOBJ(std::string filename) {
188209 auto p = std::make_pair (iMin, iMax);
189210 if (seenEdges.find (p) == seenEdges.end ()) {
190211 eLen.push_back (len);
212+ eCat.push_back ((iF + iC) % 5 );
191213 edgeOrdering.push_back (edgeOrdering.size ()); // totally coincidentally, this is the trivial ordering
192214 seenEdges.insert (p);
193215 }
194216 heLen.push_back (len);
195217 cAngle.push_back (angle);
218+ heCat.push_back ((iF + iC) % 7 );
219+ cCat.push_back (i0 % 12 );
220+ cID.push_back (iC);
196221 }
197222 }
198223 size_t nEdges = edgeOrdering.size ();
199224 polyscope::getSurfaceMesh (niceName)->setEdgePermutation (edgeOrdering);
200225 polyscope::getSurfaceMesh (niceName)->addEdgeScalarQuantity (" edge length" , eLen);
201226 polyscope::getSurfaceMesh (niceName)->addHalfedgeScalarQuantity (" halfedge length" , heLen);
202227 polyscope::getSurfaceMesh (niceName)->addCornerScalarQuantity (" corner angle" , cAngle);
228+ polyscope::getSurfaceMesh (niceName)->addCornerScalarQuantity (" corner ID" , cID);
229+ polyscope::getSurfaceMesh (niceName)->addEdgeScalarQuantity (" categorical edge" , eCat,
230+ polyscope::DataType::CATEGORICAL);
231+ polyscope::getSurfaceMesh (niceName)->addHalfedgeScalarQuantity (" categorical halfedge" , heCat,
232+ polyscope::DataType::CATEGORICAL);
233+ polyscope::getSurfaceMesh (niceName)->addCornerScalarQuantity (" categorical corner" , cCat,
234+ polyscope::DataType::CATEGORICAL);
203235
204236
205237 // Test error
@@ -673,13 +705,16 @@ void addDataToPointCloud(std::string pointCloudName, const std::vector<glm::vec3
673705 // Add some scalar quantities
674706 std::vector<double > xC (points.size ());
675707 std::vector<std::array<double , 3 >> randColor (points.size ());
708+ std::vector<double > cat (points.size ());
676709 for (size_t i = 0 ; i < points.size (); i++) {
677710 xC[i] = points[i].x ;
678711 randColor[i] = {{polyscope::randomUnit (), polyscope::randomUnit (), polyscope::randomUnit ()}};
712+ cat[i] = i * 12 / points.size ();
679713 }
680714 polyscope::getPointCloud (pointCloudName)->addScalarQuantity (" xC" , xC);
681715 polyscope::getPointCloud (pointCloudName)->addColorQuantity (" random color" , randColor);
682716 polyscope::getPointCloud (pointCloudName)->addColorQuantity (" random color2" , randColor);
717+ polyscope::getPointCloud (pointCloudName)->addScalarQuantity (" categorical" , cat, polyscope::DataType::CATEGORICAL);
683718
684719
685720 // Add some vector quantities
0 commit comments