Skip to content

Add support for free-form triangle shading objects.#157

Merged
bramton merged 1 commit intolibharu:develfrom
alliepiper:shadings
Jun 11, 2022
Merged

Add support for free-form triangle shading objects.#157
bramton merged 1 commit intolibharu:develfrom
alliepiper:shadings

Conversation

@alliepiper
Copy link
Copy Markdown

We needed the ability to draw polygons with smoothly interpolated vertex colors in VTK, and this patch is sufficient for our needs. Sharing as a MR if anyone else is interested.

Refs #102

@mathstuf
Copy link
Copy Markdown
Contributor

Cc: @opoplawski for Fedora VTK/ParaView packages, libharu will need this patch if VTK is to use the system version. I'll try and find the other distro maintainer github accounts…

@mathstuf
Copy link
Copy Markdown
Contributor

Cc: @lu-zero @domibel @samueljohn @badshah400 (Sorry if my maintainer list is out-of-date.)

@lu-zero
Copy link
Copy Markdown

lu-zero commented May 10, 2017

I'm not really the person keeping vtk up in Gentoo, the sci@gentoo.org alias collectively maintains it.

@badshah400
Copy link
Copy Markdown

@mathstuf Thanks for the ping. I will get this patch into openSUSE's packages.

Copy link
Copy Markdown
Contributor

@mathstuf mathstuf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

High-level overview only; I don't know enough about the spec to review the rest.

src/hpdf_pages.c Outdated
/* search shading-object from shading-resource */
key = HPDF_Dict_GetKeyByObj (attr->shadings, shading);
if (!key) {
/* if the shading is not resisterd in shadings resource, register
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"resisters" -> "registered"

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yeah. I copy/pasted that bit from somewhere else. I'll clean up the other instances too.

return HPDF_TRUE;
}

static void UINT32Swap (HPDF_UINT32 *value)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought there was a C standard header which provided these functions.

HPDF_DOUBLE norm = (x - xMin) / (xMax - xMin);
HPDF_DOUBLE max = (HPDF_DOUBLE)(0xFFFFFFFF);
HPDF_UINT32 enc = (HPDF_UINT32)(norm * max);
UINT32Swap(&enc);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or maybe this should be "make into big endian order" like the pton family. Does this swap need to happen on big endian architectures?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be htonl (host-to-network-long), conforming to POSIX.1-2001

@alliepiper
Copy link
Copy Markdown
Author

The byteswap thing follows the same pattern used other places in the libharu code, so I just went for consistency. If a libharu dev has an issue with this bit I can rework it, but until there's a problem I think this is good enough for us. I don't think we're targeting any BE archs anyway, so it's not worth the trouble (especially since this project appears to be abandoned -- I get the feeling that this patch will live as an MR forever ;) )

@mathstuf
Copy link
Copy Markdown
Contributor

OK, I'd suggest opening an issue. I know that at least Debian targets BE architectures, but I don't know how much libharu or VTK is used on those.


HPDF_Real r;

for (int i = 0; i < 4; ++i)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for (int ..) not allowed in C code.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, it's allowed in "newer" C code (C99), but I guess libharu uses an older standard of C?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most versions of MSVC barely support C99 (if they support it at all), so we're more or less stuck with pre-C99 standards until we stop caring about MSVC < 2015 ;-)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They support this much (because it's part of the C++ standard). The complainer in ParaView was actually an older GCC which doesn't default to C99 without a flag :) .

@zhouzhanke
Copy link
Copy Markdown

does this patch has API reference or examples? work for days, still didn't figure out how to use it

@alliepiper
Copy link
Copy Markdown
Author

The only example of its use that I'm aware of is here. The shadings follows a similar pattern to the other HPDF objects.

@zhouzhanke
Copy link
Copy Markdown

thank you for the example.

zhouzhanke added a commit to zhouzhanke/libharu that referenced this pull request May 3, 2018
add shading type 3, function 2,RGB.
modify shading type 4, from libharu#157 pull request.
@opoplawski
Copy link
Copy Markdown

Is this complete, or still in progress?

@alliepiper
Copy link
Copy Markdown
Author

Yes. It's working well enough for our purposes in VTK, and I don't intend to make any more changes to this patch.

chuckatkins pushed a commit to chuckatkins/spack that referenced this pull request Apr 25, 2019
VTK requires a patched libharu that is not maintained upstream
See libharu/libharu#157
ax3l pushed a commit to spack/spack that referenced this pull request Apr 30, 2019
VTK requires a patched libharu that is not maintained upstream
See libharu/libharu#157
MarcusCalhoun-Lopez added a commit to macports/macports-ports that referenced this pull request Jul 21, 2019
The pull request has languished for more than two year.
Some ports (e.g. VTK) rely on the new functionality.
See libharu/libharu#157
xylar added a commit to xylar/libharu-feedstock that referenced this pull request May 5, 2020
@ArchangeGabriel
Copy link
Copy Markdown

There is an issue with this PR when used in VTK, there is a missing symbol export:

/usr/lib/libvtkIOExportPDF.so.1: undefined symbol: HPDF_Shading_AddVertexRGB

This was initially reported against the ArchLinux vtk package, when trying to import the vtk python module: https://bugs.archlinux.org/task/72574

@alliepiper
Copy link
Copy Markdown
Author

@ArchangeGabriel I'm no longer actively working on VTK, but they may be interested in fixing this. Can you make sure this gets reported at https://gitlab.kitware.com/vtk/vtk?

@ArchangeGabriel
Copy link
Copy Markdown

A colleague investigated the issue, and this is because we were building with autotools instead of CMake (so VTK is not affected). We switched to CMake to solve the issue. I think this should be sufficient for anyone stumbling upon this.

@mathstuf
Copy link
Copy Markdown
Contributor

mathstuf commented Nov 6, 2021

Ah, that makes sense. @allisonvacanti if you give me access to your fork, I can update the PR directly if there are any changes that need to be made.

@alliepiper
Copy link
Copy Markdown
Author

@mathstuf I unfortunately deleted that fork a while ago.

If you'd like to make a new PR under a KW managed account I can close this and update the description to link to the maintained version.

@mathstuf
Copy link
Copy Markdown
Contributor

mathstuf commented Nov 6, 2021

Ah. I'll make a new PR if there's ever any movement on this. If adding autotools support is going to have just as many crickets…not sure it's the best use of my time.

@ArchangeGabriel
Copy link
Copy Markdown

@mathstuf I honestly don’t think it’s worth it, only people ever affected are the ones building ParaView/VTK themselves with external dependencies instead of vendored one, that took the time to patch their libharu to make it suitable for this, and used autotools instead of CMake. If they went as far, they do know about this ticket and should be able to find the information here.

I guess it’s just a coincidence that it went under radar all this time in Arch, but now it’s fixed for us, so I guess this PR can go back to the deadly silence I’ve awoken it from. ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants