return nodes;
}
+MEDCouplingFieldDouble *ShapeRecognMesh::buildAffinePointField() const
+{
+ const std::vector<mcIdType> &areaIdByNodes = areas->getAreaIdByNodes();
+ MEDCouplingFieldDouble *field = MEDCouplingFieldDouble::New(
+ ON_NODES);
+ field->setName("area_affine_point");
+ field->setMesh(mesh);
+ DataArrayDouble *values = DataArrayDouble::New();
+ values->setName("area_affine_point");
+ values->alloc(nodes->getNbNodes(), 3);
+ values->setInfoOnComponent(0, "X");
+ values->setInfoOnComponent(1, "Y");
+ values->setInfoOnComponent(2, "Z");
+ for (mcIdType nodeId = 0; nodeId < (mcIdType)areaIdByNodes.size(); ++nodeId)
+ {
+ std::array<double, 3> affinePoint = areas->getAffinePoint(areaIdByNodes[nodeId]);
+ values->setIJ(nodeId, 0, affinePoint[0]);
+ values->setIJ(nodeId, 1, affinePoint[1]);
+ values->setIJ(nodeId, 2, affinePoint[2]);
+ }
+ field->setArray(values);
+ values->decrRef();
+ return field;
+}
+
+MEDCouplingFieldDouble *ShapeRecognMesh::buildNormalField() const
+{
+ const std::vector<mcIdType> &areaIdByNodes = areas->getAreaIdByNodes();
+ MEDCouplingFieldDouble *field = MEDCouplingFieldDouble::New(
+ ON_NODES);
+ field->setName("area_normal");
+ field->setMesh(mesh);
+ DataArrayDouble *values = DataArrayDouble::New();
+ values->setName("area_normal");
+ values->alloc(nodes->getNbNodes(), 3);
+ values->setInfoOnComponent(0, "X");
+ values->setInfoOnComponent(1, "Y");
+ values->setInfoOnComponent(2, "Z");
+ for (mcIdType nodeId = 0; nodeId < (mcIdType)areaIdByNodes.size(); ++nodeId)
+ {
+ std::array<double, 3> normal = areas->getNormal(areaIdByNodes[nodeId]);
+ values->setIJ(nodeId, 0, normal[0]);
+ values->setIJ(nodeId, 1, normal[1]);
+ values->setIJ(nodeId, 2, normal[2]);
+ }
+ field->setArray(values);
+ values->decrRef();
+ return field;
+}
+
const Areas *ShapeRecognMesh::getAreas() const
{
return areas;
DataArrayDouble *areaIds = DataArrayDouble::New();
areaIds->setName("area_ids");
areaIds->alloc(nodes->getNbNodes(), 1);
- for (mcIdType nodeId = 0; nodeId < areaIdByNodes.size(); ++nodeId)
+ for (mcIdType nodeId = 0; nodeId < (mcIdType)areaIdByNodes.size(); ++nodeId)
areaIds->setIJ(nodeId, 0, (double)areaIdByNodes[nodeId]);
fieldAreaIds->setArray(areaIds);
areaIds->decrRef();
DataArrayDouble *areaPrimitiveTypes = DataArrayDouble::New();
areaPrimitiveTypes->setName("area_primitive_types");
areaPrimitiveTypes->alloc(nodes->getNbNodes(), 1);
- for (mcIdType nodeId = 0; nodeId < areaIdByNodes.size(); ++nodeId)
+ for (mcIdType nodeId = 0; nodeId < (mcIdType)areaIdByNodes.size(); ++nodeId)
areaPrimitiveTypes->setIJ(nodeId, 0, (double)areas->getPrimitiveTypeInt(areaIdByNodes[nodeId]));
fieldAreaPrimitiveTypes->setArray(areaPrimitiveTypes);
areaPrimitiveTypes->decrRef();
WriteField(outputFile, fieldAreaPrimitiveTypes, false);
fieldAreaPrimitiveTypes->decrRef();
+ // - normal
+ auto fieldNormal = buildNormalField();
+ WriteField(outputFile, fieldNormal, false);
+ fieldNormal->decrRef();
+ // - affine point
+ auto fieldAffinePoint = buildAffinePointField();
+ WriteField(outputFile, fieldAffinePoint, false);
+ fieldAffinePoint->decrRef();
}