本文整理汇总了C++中Array1::size方法的典型用法代码示例。如果您正苦于以下问题:C++ Array1::size方法的具体用法?C++ Array1::size怎么用?C++ Array1::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Array1
的用法示例。
在下文中一共展示了Array1::size方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sampleBound
void SphSystemData2::computeMass() {
Array1<Vector2D> points;
TrianglePointGenerator pointsGenerator;
BoundingBox2D sampleBound(
Vector2D(-1.5*_kernelRadius, -1.5*_kernelRadius),
Vector2D(1.5*_kernelRadius, 1.5*_kernelRadius));
pointsGenerator.generate(sampleBound, _targetSpacing, &points);
double maxNumberDensity = 0.0;
SphStdKernel2 kernel(_kernelRadius);
for (size_t i = 0; i < points.size(); ++i) {
const Vector2D& point = points[i];
double sum = 0.0;
for (size_t j = 0; j < points.size(); ++j) {
const Vector2D& neighborPoint = points[j];
sum += kernel(neighborPoint.distanceTo(point));
}
maxNumberDensity = std::max(maxNumberDensity, sum);
}
JET_ASSERT(maxNumberDensity > 0);
double newMass = _targetDensity / maxNumberDensity;
ParticleSystemData2::setMass(newMass);
}
示例2: particlesToObj
void particlesToObj(const Array1<Vector3D>& positions, const Size3& resolution,
const Vector3D& gridSpacing, const Vector3D& origin,
double kernelRadius, const std::string& method,
const std::string& objFilename) {
PointsToImplicit3Ptr converter;
if (method == kSpherical) {
converter =
std::make_shared<SphericalPointsToImplicit3>(kernelRadius, false);
} else if (method == kSph) {
converter = std::make_shared<SphPointsToImplicit3>(
kernelRadius, sSphCutOffDensity, false);
} else if (method == kZhuBridson) {
converter = std::make_shared<ZhuBridsonPointsToImplicit3>(
kernelRadius, sZhuBridsonCutOffThreshold, false);
} else {
converter = std::make_shared<AnisotropicPointsToImplicit3>(
kernelRadius, sAnisoCutOffDensity, sAnisoPositionSmoothingFactor,
sAnisoMinNumNeighbors, false);
}
VertexCenteredScalarGrid3 sdf(resolution, gridSpacing, origin);
printInfo(resolution, sdf.boundingBox(), gridSpacing, positions.size(),
method);
converter->convert(positions, &sdf);
triangulateAndSave(sdf, objFilename);
}
示例3: particlesToXml
void particlesToXml(const Array1<Vector3D>& positions,
const std::string& xmlFilename) {
printInfo(positions.size());
std::ofstream file(xmlFilename.c_str());
if (file) {
printf("Writing %s...\n", xmlFilename.c_str());
file << "<scene version=\"0.5.0\">";
for (const auto& pos : positions) {
file << "<shape type=\"instance\">";
file << "<ref id=\"spheres\"/>";
file << "<transform name=\"toWorld\">";
char buffer[64];
snprintf(buffer, sizeof(buffer),
"<translate x=\"%f\" y=\"%f\" z=\"%f\"/>", pos.x, pos.y,
pos.z);
file << buffer;
file << "</transform>";
file << "</shape>";
}
file << "</scene>";
file.close();
} else {
printf("Cannot write file %s.\n", xmlFilename.c_str());
exit(EXIT_FAILURE);
}
}
示例4: compareFloatingArrays
bool Teuchos::compareFloatingArrays(
const Array1 &a1, const std::string &a1_name,
const Array2 &a2, const std::string &a2_name,
const ScalarMag &tol,
Teuchos::FancyOStream &out
)
{
using Teuchos::as;
bool success = true;
out << "Comparing " << a1_name << " == " << a2_name << " ... ";
const int n = a1.size();
// Compare sizes
if (as<int>(a2.size()) != n) {
out << "\nError, "<<a1_name<<".size() = "<<a1.size()<<" == "
<< a2_name<<".size() = "<<a2.size()<<" : failed!\n";
return false;
}
// Compare elements
for( int i = 0; i < n; ++i ) {
const ScalarMag err = relErr( a1[i], a2[i] );
if ( err > tol ) {
out
<<"\nError, relErr("<<a1_name<<"["<<i<<"],"
<<a2_name<<"["<<i<<"]) = relErr("<<a1[i]<<","<<a2[i]<<") = "
<<err<<" <= tol = "<<tol<<": failed!\n";
success = false;
}
}
if (success) {
out << "passed\n";
}
return success;
}