Wed, 11/06/2024 - 06:12
For example, I have 10 TopoDS_Faces and 100 Geom_Curve, and I need to calculate the intersection of each face and each line, 10*100=1000 times, which will take a lot of time. So I expect multiple threads to compute the intersection of each surface and curve in parallel. However, the actual calculation time was found to be slower. Why and how to solve it. Thank you very much.
This is the main part of my code:
std::vector
{
auto start = std::chrono::high_resolution_clock::now();
std::vector
std::vector
IntCurveFace_ShapeIntersector intersector;
intersector.load(face, Precision::Confusion());
for(size_t i = 0 ;i
{
Handle(GeomAdaptor_Curve) h_curve = new GeomAdaptor_Curve(curve[i]);
intersector.Perform(h_curve, h_curve->FirstParamter(), h_curve->LastParamter());
if(intersector.IsDone)
{
//push back points
}
}
auto end = std::chrono::high_resolution_clock::now();
std::chrono::duration
cout
return pnts;
};
auto start = std::chrono::high_resolution_clock::now();
std::vector
std::vector<:vector>> res{};
for(size_t i = 0 ;i
{
res.emplace_back(Inter(faces[i]));
}
auto end = std::chrono::high_resolution_clock::now();
std::chrono::duration
cout
Wed, 11/06/2024 - 07:45
So where is the actual multithreading logic in your code? What are the actual times?
Please also use Markdown or HTML syntax while posting the code on the forum, and consider fixing misprints ...
Wed, 11/06/2024 - 08:54
This is a function of the intersection of TopoDS_Face and each curve.
This is the code for a single-threaded for loop.
This is multi-threaded code.
In actual calculation, there are a total of 10 surfaces and 370 curves. The single-threaded loop takes between 1 and 3 seconds per face in debug mode, with an average of 2 seconds, for a total of 21 seconds. With multiple threads, each face ranges from two 2 to 15 seconds, for a total of 30 seconds.