Tue, 05/23/2023 - 12:50
Forums:
I have written some code to write open cascade ```TopoDS_Shape``` to a quadrilateral and triangle mesh in the fbx file format however i am experiencing some difficulty, I wish to reduce the complexity of the CAD model as to remove overly complex details like ridges, I was wondering how I can do this? I have seen that the function ```RWGltf_CafWriter::ToMergeFaces()``` exists in [How to decrease mesh number while STEP to GLB file conversion?](https://dev.opencascade.org/content/how-decrease-mesh-number-while-step-...) however i was wondering if there is some analogous function for the general ```TopoDS_Shape```
Wed, 05/24/2023 - 00:20
Try the algorithm ShapeUpgrade_UnifySameDomain.
Wed, 05/24/2023 - 12:30
I'm attempting to use this Algoritm however it breaks my codebase, here is a minimal reproduceable example of how i have used it:
```
#include <iostream>
#include <fstream>
#include <ShapeUpgrade_UnifySameDomain.hxx>
#include <STEPControl_Reader.hxx>
#include <STEPControl_Writer.hxx>
#include <TopoDS.hxx>
int main()
{
const char* inputPath = "ball-valve.step";
const char* outputPath = "output.step";
// Initialize the STEP reader
STEPControl_Reader reader;
if (reader.ReadFile(inputPath) != IFSelect_RetDone)
{
std::cout << "Error: cannot read file." << std::endl;
return 1;
}
// Check the load status
reader.PrintCheckLoad(true, IFSelect_ItemsByEntity);
if (reader.TransferRoots() != reader.NbRootsForTransfer())
{
std::cout << "Error: roots transferred unsuccessfully." << std::endl;
return 1;
}
// Get the shape from the reader
TopoDS_Shape shape = reader.Shape();
// Perform "unify domains" algorithm
ShapeUpgrade_UnifySameDomain unifyDomains(shape);
unifyDomains.Build();
TopoDS_Shape unifiedShape = unifyDomains.Shape();
// Write the unified shape to STEP file
STEPControl_Writer writer;
writer.Transfer(unifiedShape, STEPControl_AsIs);
if (!writer.Write(outputPath))
{
std::cout << "Error: failed to write output file." << std::endl;
return 1;
}
return 0;
}
```
I am getting error at unifyDomains.Build()
```
Exception thrown at 0x00007FFAA0BFE468 (TKG2d.dll) in quad-remeshing-algorithm.exe: 0xC0000005: Access violation reading location 0x0000000000000000.
```
are there any examples to see how I should use the function
Wed, 05/24/2023 - 22:37
It seems right. May be there is some bug that is reproduced with your shape. You may report it in the bug tracker. But you should publish your shape to reproduce it.
Wed, 05/24/2023 - 22:38
By the way, always check IsDone status before calling unifyDomains.Shape().
Thu, 05/25/2023 - 08:20
Hi Mikhail,
In "ShapeUpgrade_UnifySameDomain", there is no " IsDone" function to check whether the operation is successfully completed.
There are no "HasErrors" or "HasWarnings" functions either.
I think we need to have exception handling for this class to capture the program crashes.
Regards,
Lahiru Dilshan.
Mon, 12/30/2024 - 06:18
Any update? I meet the same question.
I try to heal them with ShapeFix, but it failed.
So any suggestion will be helpful.
Thanks All.